From f4fc8914b892459a9e90e98283dbbc5e8bb3bf7d Mon Sep 17 00:00:00 2001 From: johltn Date: Fri, 19 Feb 2021 11:52:32 +0100 Subject: [PATCH] Get BrepElement to triangulate + serialize from it --- src/ifcconvert/IfcConvert.cpp | 8 +------- src/serializers/HdfSerializer.cpp | 16 ++++++++++++++-- src/serializers/HdfSerializer.h | 6 +++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index c7a03323da..25c6b37daf 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -806,6 +806,7 @@ int main(int argc, char** argv) { } else if (output_extension == HDF) { const path_t mtl_filename = change_extension(output_filename, MTL); + settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true); serializer = boost::make_shared(IfcUtil::path::to_utf8(output_temp_filename), IfcUtil::path::to_utf8(output_filename), settings); } @@ -1034,13 +1035,6 @@ int main(int argc, char** argv) { IfcGeom::Element *geom_object = context_iterator.get(); - IfcGeom::Element *open_object = context_iterator.get_native(); - IfcGeom::BRepElement*elem = static_cast*>(open_object); - const IfcGeom::Representation::BRep& brepmesh = elem->geometry(); - const IfcGeom::Representation::Serialization *serialization = new IfcGeom::Representation::Serialization(brepmesh); - std::string dat = serialization->brep_data(); - - if (is_tesselated) { serializer->write(static_cast*>(geom_object)); diff --git a/src/serializers/HdfSerializer.cpp b/src/serializers/HdfSerializer.cpp index 3e1a6748a8..6c28d6d69b 100644 --- a/src/serializers/HdfSerializer.cpp +++ b/src/serializers/HdfSerializer.cpp @@ -93,7 +93,7 @@ void HdfSerializer::writeHeader() { } -void HdfSerializer::write(const IfcGeom::TriangulationElement* o) { +void HdfSerializer::write(const IfcGeom::BRepElement* o) { std::string guid = o->guid(); //Logger::Status(guid); @@ -101,13 +101,25 @@ void HdfSerializer::write(const IfcGeom::TriangulationElement* o) { //Logger::Status("\n"); H5::Group elementGroup; + H5::Group meshGroup; H5::DataSet positionsDataset; H5::DataSet normalsDataset; H5::DataSet indicesDataset; + H5::Group OCCTGroup; - const IfcGeom::Representation::Triangulation& mesh = o->geometry(); + //const IfcGeom::BRepElement*elem = static_cast*>(o); + + + const IfcGeom::Representation::BRep& brepmesh = o->geometry(); + const IfcGeom::Representation::Serialization *serialization = new IfcGeom::Representation::Serialization(brepmesh); + std::string brep_data = serialization->brep_data(); + + /*Logger::Status(brep_data);*/ + + const IfcGeom::TriangulationElement*triangular_element = new IfcGeom::TriangulationElement(*o); + const IfcGeom::Representation::Triangulation& mesh = triangular_element->geometry(); const int vcount = (int)mesh.verts().size() / 3; const int fcount = (int)mesh.faces().size() / 3; const bool isyup = settings().get(SerializerSettings::USE_Y_UP); diff --git a/src/serializers/HdfSerializer.h b/src/serializers/HdfSerializer.h index 0333a2ef0d..27bc11b14e 100644 --- a/src/serializers/HdfSerializer.h +++ b/src/serializers/HdfSerializer.h @@ -54,10 +54,10 @@ public: bool ready(); void writeHeader(); void writeMaterial(const IfcGeom::Material& style); - void write(const IfcGeom::TriangulationElement* o); - void write(const IfcGeom::BRepElement* /*o*/) {} + void write(const IfcGeom::BRepElement* o); + void write(const IfcGeom::TriangulationElement* /*o*/) {} void finalize() {} - bool isTesselated() const { return true; } + bool isTesselated() const { return false; } void setUnitNameAndMagnitude(const std::string& /*name*/, float /*magnitude*/) {} void setFile(IfcParse::IfcFile*) {} };