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

Method addParent

src/serializers/ColladaSerializer.cpp:231–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229}
230
231void ColladaSerializer::ColladaExporter::ColladaScene::addParent(const IfcGeom::Element& parent){
232 //we open the visual scene tag if it's not.
233 if (!scene_opened) {
234 openVisualScene(scene_id);
235 scene_opened = true;
236 }
237
238 const IfcGeom::Transformation& parent_trsf = parent.transformation();
239
240 auto transformation_towrite = parent_trsf.data()->ccomponents();
241
242 // If this is not the first parent, get the relative placement
243 if (parentNodes.size() > 0) {
244 // @todo check order
245 transformation_towrite = matrixStack.top().ccomponents() * transformation_towrite;
246 }
247
248 const auto& posmatrix = transformation_towrite;
249
250 double matrix_array[4][4] = {
251 { (double)posmatrix(0,0), (double)posmatrix(0,1), (double)posmatrix(0,2), (double)posmatrix(0,3) },
252 { (double)posmatrix(1,0), (double)posmatrix(1,1), (double)posmatrix(1,2), (double)posmatrix(1,3) },
253 { (double)posmatrix(2,0), (double)posmatrix(2,1), (double)posmatrix(2,2), (double)posmatrix(2,3) },
254 { (double)posmatrix(3,0), (double)posmatrix(3,1), (double)posmatrix(3,2), (double)posmatrix(3,3) }
255 };
256
257 std::string name = serializer->object_id(&parent);
258 collada_id(name);
259
260 COLLADASW::Node *current_node;
261 current_node = new COLLADASW::Node(mSW);
262 current_node->setNodeId(name);
263 /// @todo redundant information using ID as both ID and Name, maybe omit Name or allow specifying what would be used as the name
264 current_node->setNodeName(name);
265 current_node->setType(COLLADASW::Node::NODE);
266 current_node->start();
267 current_node->addMatrix(matrix_array);
268
269 // Add the node to the parent stack
270 matrixStack.push(ifcopenshell::geometry::taxonomy::matrix4(parent_trsf.data()->ccomponents().inverse()));
271 parentNodes.push(current_node);
272 serializer->parentStackId.push(parent.id());
273}
274
275void ColladaSerializer::ColladaExporter::ColladaScene::closeParent()
276{

Callers 1

endDocumentMethod · 0.80

Calls 8

matrix4Function · 0.85
dataMethod · 0.80
inverseMethod · 0.80
sizeMethod · 0.45
object_idMethod · 0.45
startMethod · 0.45
pushMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected