mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
Fix other unit conversion issues #5864
This commit is contained in:
@@ -51,6 +51,8 @@ namespace ifcopenshell { namespace geometry {
|
|||||||
|
|
||||||
IfcGeom::BRepElement* create_brep_for_representation_and_product(ifcopenshell::geometry::taxonomy::ptr, const IfcUtil::IfcBaseEntity* product, const ifcopenshell::geometry::taxonomy::matrix4::ptr& place);
|
IfcGeom::BRepElement* create_brep_for_representation_and_product(ifcopenshell::geometry::taxonomy::ptr, const IfcUtil::IfcBaseEntity* product, const ifcopenshell::geometry::taxonomy::matrix4::ptr& place);
|
||||||
IfcGeom::BRepElement* create_brep_for_processed_representation(const IfcUtil::IfcBaseEntity* product, const ifcopenshell::geometry::taxonomy::matrix4::ptr& place, IfcGeom::BRepElement*);
|
IfcGeom::BRepElement* create_brep_for_processed_representation(const IfcUtil::IfcBaseEntity* product, const ifcopenshell::geometry::taxonomy::matrix4::ptr& place, IfcGeom::BRepElement*);
|
||||||
|
|
||||||
|
const ifcopenshell::geometry::Settings& settings() { return settings_; }
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|||||||
@@ -848,10 +848,10 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Schema>
|
template <typename Schema>
|
||||||
static boost::variant<IfcGeom::Element*, IfcGeom::Representation::Representation*, IfcGeom::Transformation*> helper_fn_create_shape(const std::string& geometry_library, ifcopenshell::geometry::Settings& settings, IfcUtil::IfcBaseClass* instance, IfcUtil::IfcBaseClass* representation = 0) {
|
static boost::variant<IfcGeom::Element*, IfcGeom::Representation::Representation*, IfcGeom::Transformation*> helper_fn_create_shape(const std::string& geometry_library, ifcopenshell::geometry::Settings& st, IfcUtil::IfcBaseClass* instance, IfcUtil::IfcBaseClass* representation = 0) {
|
||||||
IfcParse::IfcFile* file = instance->file_;
|
IfcParse::IfcFile* file = instance->file_;
|
||||||
|
|
||||||
ifcopenshell::geometry::Converter kernel(geometry_library, file, settings);
|
ifcopenshell::geometry::Converter kernel(geometry_library, file, st);
|
||||||
|
|
||||||
if (typename Schema::IfcProduct* product = instance->as<typename Schema::IfcProduct>()) {
|
if (typename Schema::IfcProduct* product = instance->as<typename Schema::IfcProduct>()) {
|
||||||
if (representation) {
|
if (representation) {
|
||||||
@@ -875,7 +875,7 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
|||||||
if (!rep->RepresentationIdentifier()) {
|
if (!rep->RepresentationIdentifier()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (settings.get<ifcopenshell::geometry::settings::OutputDimensionality>().get() != ifcopenshell::geometry::settings::CURVES) {
|
if (st.get<ifcopenshell::geometry::settings::OutputDimensionality>().get() != ifcopenshell::geometry::settings::CURVES) {
|
||||||
if (*rep->RepresentationIdentifier() == "Body" || *rep->RepresentationIdentifier() == "Facetation") {
|
if (*rep->RepresentationIdentifier() == "Body" || *rep->RepresentationIdentifier() == "Facetation") {
|
||||||
ifc_representation = rep;
|
ifc_representation = rep;
|
||||||
break;
|
break;
|
||||||
@@ -898,7 +898,7 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
|||||||
// TODO: Remove redundancy with IfcGeomIterator.h
|
// TODO: Remove redundancy with IfcGeomIterator.h
|
||||||
if (context->ContextType()) {
|
if (context->ContextType()) {
|
||||||
std::set<std::string> context_types;
|
std::set<std::string> context_types;
|
||||||
if (settings.get<ifcopenshell::geometry::settings::OutputDimensionality>().get() != ifcopenshell::geometry::settings::CURVES) {
|
if (st.get<ifcopenshell::geometry::settings::OutputDimensionality>().get() != ifcopenshell::geometry::settings::CURVES) {
|
||||||
context_types.insert("model");
|
context_types.insert("model");
|
||||||
context_types.insert("design");
|
context_types.insert("design");
|
||||||
context_types.insert("model view");
|
context_types.insert("model view");
|
||||||
@@ -934,11 +934,11 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
|||||||
product->toString(oss_product);
|
product->toString(oss_product);
|
||||||
throw IfcParse::IfcException("Failed to process shape. Product: " + oss_product.str() + ", representation: " + oss_repr.str());
|
throw IfcParse::IfcException("Failed to process shape. Product: " + oss_product.str() + ", representation: " + oss_repr.str());
|
||||||
}
|
}
|
||||||
if (settings.get<ifcopenshell::geometry::settings::IteratorOutput>().get() == ifcopenshell::geometry::settings::SERIALIZED) {
|
if (st.get<ifcopenshell::geometry::settings::IteratorOutput>().get() == ifcopenshell::geometry::settings::SERIALIZED) {
|
||||||
IfcGeom::SerializedElement* serialization = new IfcGeom::SerializedElement(*brep);
|
IfcGeom::SerializedElement* serialization = new IfcGeom::SerializedElement(*brep);
|
||||||
delete brep;
|
delete brep;
|
||||||
return serialization;
|
return serialization;
|
||||||
} else if (settings.get<ifcopenshell::geometry::settings::IteratorOutput>().get() == ifcopenshell::geometry::settings::TRIANGULATED) {
|
} else if (st.get<ifcopenshell::geometry::settings::IteratorOutput>().get() == ifcopenshell::geometry::settings::TRIANGULATED) {
|
||||||
IfcGeom::TriangulationElement* triangulation = new IfcGeom::TriangulationElement(*brep);
|
IfcGeom::TriangulationElement* triangulation = new IfcGeom::TriangulationElement(*brep);
|
||||||
delete brep;
|
delete brep;
|
||||||
return triangulation;
|
return triangulation;
|
||||||
@@ -950,7 +950,13 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
|||||||
if (item == nullptr) {
|
if (item == nullptr) {
|
||||||
throw IfcParse::IfcException("Failed to convert placement");
|
throw IfcParse::IfcException("Failed to convert placement");
|
||||||
}
|
}
|
||||||
return new IfcGeom::Transformation(settings, item);
|
if (st.get<ifcopenshell::geometry::settings::ConvertBackUnits>().get()) {
|
||||||
|
// we pass the settings to the Transformation object, but access the data just offloads to the
|
||||||
|
// generic cartesian_base<Matrix4> so there's no time to apply the settings to the translation part.
|
||||||
|
item = ifcopenshell::geometry::taxonomy::matrix4::ptr(item->clone_());
|
||||||
|
item->components().col(3).head<3>() /= kernel.settings().get<ifcopenshell::geometry::settings::LengthUnit>().get();
|
||||||
|
}
|
||||||
|
return new IfcGeom::Transformation(kernel.settings(), item);
|
||||||
} else {
|
} else {
|
||||||
if (!representation) {
|
if (!representation) {
|
||||||
if (instance->declaration().is(Schema::IfcRepresentationItem::Class()) ||
|
if (instance->declaration().is(Schema::IfcRepresentationItem::Class()) ||
|
||||||
@@ -967,11 +973,11 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
|||||||
throw IfcParse::IfcException("Failed to process shape. Instance: " + oss.str());
|
throw IfcParse::IfcException("Failed to process shape. Instance: " + oss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcGeom::Representation::BRep brep(settings, instance->declaration().name(), to_locale_invariant_string(instance->as<IfcUtil::IfcBaseEntity>()->id()), shapes);
|
IfcGeom::Representation::BRep brep(kernel.settings(), instance->declaration().name(), to_locale_invariant_string(instance->as<IfcUtil::IfcBaseEntity>()->id()), shapes);
|
||||||
try {
|
try {
|
||||||
if (settings.get<ifcopenshell::geometry::settings::IteratorOutput>().get() == ifcopenshell::geometry::settings::SERIALIZED) {
|
if (st.get<ifcopenshell::geometry::settings::IteratorOutput>().get() == ifcopenshell::geometry::settings::SERIALIZED) {
|
||||||
return new IfcGeom::Representation::Serialization(brep);
|
return new IfcGeom::Representation::Serialization(brep);
|
||||||
} else if (settings.get<ifcopenshell::geometry::settings::IteratorOutput>().get() == ifcopenshell::geometry::settings::TRIANGULATED) {
|
} else if (st.get<ifcopenshell::geometry::settings::IteratorOutput>().get() == ifcopenshell::geometry::settings::TRIANGULATED) {
|
||||||
return new IfcGeom::Representation::Triangulation(brep);
|
return new IfcGeom::Representation::Triangulation(brep);
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|||||||
Reference in New Issue
Block a user