Implement shape serialization for cgal, possibility to supply geometry library to iterator in py

This commit is contained in:
Thomas Krijnen
2023-08-25 21:46:32 +02:00
parent 3f4d183680
commit 5336b2f987
7 changed files with 53 additions and 20 deletions
+18 -11
View File
@@ -145,11 +145,6 @@ IfcGeom::Representation::Serialization::Serialization(const BRep& brep)
: Representation(brep.settings())
, id_(brep.id())
{
#ifdef IFOPSH_WITH_OPENCASCADE
ConversionResultShape* shape = brep.as_compound();
TopoDS_Compound compound = TopoDS::Compound(((ifcopenshell::geometry::OpenCascadeShape*)shape)->shape());
delete shape;
for (auto it = brep.begin(); it != brep.end(); ++it) {
int sid = -1;
@@ -175,12 +170,24 @@ IfcGeom::Representation::Serialization::Serialization(const BRep& brep)
surface_style_ids_.push_back(sid);
}
std::stringstream sstream;
BRepTools::Write(compound,sstream);
brep_data_ = sstream.str();
#else
throw std::runtime_error("Not available without Open Cascade");
#endif
if (brep.begin() != brep.end()) {
if (dynamic_cast<ifcopenshell::geometry::OpenCascadeShape*>(brep.begin()->Shape())) {
ConversionResultShape* shape = brep.as_compound();
shape->Serialize(brep_data_);
delete shape;
} else {
for (auto it = brep.begin(); it != brep.end(); ++it) {
std::string part;
it->Shape()->Serialize(part);
if (brep_data_.size()) {
brep_data_ = brep_data_ + "\n---\n" + part;
} else {
brep_data_ = part;
}
}
}
}
}
IfcGeom::ConversionResultShape* IfcGeom::Representation::BRep::as_compound(bool force_meters) const {