MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / Parse

Method Parse

src/qtviewer/ParseIfcFile.cpp:25–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23ParseIfcFile::~ParseIfcFile() {}
24
25bool ParseIfcFile::Parse(
26 const std::string& filePath,
27 std::vector<osg::ref_ptr<osg::MatrixTransform>>& matrixTransforms
28) {
29 IfcParse::IfcFile file(filePath);
30 ifcopenshell::geometry::Settings settings;
31 settings.set("use-world-coords", false);
32 settings.set("weld-vertices", false);
33 settings.set("apply-default-materials", true);
34
35 IfcGeom::Iterator* it = new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(&file, "opencascade", settings), settings, &file);
36 if (!it->initialize()) {
37 MessageLogger::log("Error: Iterator failed to initialize! Aborting.");
38 delete it;
39 return false;
40 }
41
42 std::string lastId;
43 std::vector<osg::ref_ptr<osg::Geometry>> lastGeometrySet;
44
45 do {
46 //const IfcGeom::BRepElement* bRepElem = it->get_native();
47 const IfcGeom::TriangulationElement* triElem = static_cast<const IfcGeom::TriangulationElement*>(it->get());
48
49 // Print element info
50 std::string elemInfo = triElem->type();
51 elemInfo += triElem->name() == "" ? "" : ": " + triElem->name();
52 MessageLogger::log(elemInfo);
53
54 const std::string id = triElem->geometry().id();
55
56 //MessageLogger::log("id: " + id);
57
58 // Transformation Matrix
59 std::vector<double> matrixData;
60 auto transform4x4 = triElem->transformation().data()->components();
61 for (int col = 0; col<4; col++)
62 {
63 for (int row =0; row<3; row++)
64 {
65 matrixData.push_back(transform4x4(row,col));
66 }
67
68 }
69
70 // Debugging:
71 std::string matrixStr = "";
72 int col = 0;
73 int row = 0;
74 for (auto d : matrixData) {
75 matrixStr += std::to_string(d) + " ";
76 if (++col == 3) {
77 std::string lastCol = (row == 3) ? "1" : "0";
78 matrixStr += lastCol + "\n";
79 col = 0;
80 row++;
81 }
82 }

Callers 1

loadFileMethod · 0.80

Calls 15

constructFunction · 0.85
to_stringFunction · 0.85
dataMethod · 0.80
push_backMethod · 0.80
setMethod · 0.45
initializeMethod · 0.45
getMethod · 0.45
typeMethod · 0.45
nameMethod · 0.45
idMethod · 0.45
materialsMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected