------------------------------------------------------------------------------------------------
| 401 | |
| 402 | // ------------------------------------------------------------------------------------------------ |
| 403 | bool ProcessMappedItem(const Schema_2x3::IfcMappedItem &mapped, aiNode *nd_src, std::vector<aiNode *> &subnodes_src, unsigned int matid, ConversionData &conv) { |
| 404 | // insert a custom node here, the carthesian transform operator is simply a conventional transformation matrix |
| 405 | std::unique_ptr<aiNode> nd(new aiNode()); |
| 406 | nd->mName.Set("IfcMappedItem"); |
| 407 | |
| 408 | // handle the Cartesian operator |
| 409 | IfcMatrix4 m; |
| 410 | ConvertTransformOperator(m, *mapped.MappingTarget); |
| 411 | |
| 412 | IfcMatrix4 msrc; |
| 413 | ConvertAxisPlacement(msrc, *mapped.MappingSource->MappingOrigin, conv); |
| 414 | |
| 415 | msrc = m * msrc; |
| 416 | |
| 417 | std::set<unsigned int> meshes; |
| 418 | const size_t old_openings = conv.collect_openings ? conv.collect_openings->size() : 0; |
| 419 | if (conv.apply_openings) { |
| 420 | IfcMatrix4 minv = msrc; |
| 421 | minv.Inverse(); |
| 422 | for (TempOpening &open : *conv.apply_openings) { |
| 423 | open.Transform(minv); |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | unsigned int localmatid = ProcessMaterials(mapped.GetID(), matid, conv, false); |
| 428 | const Schema_2x3::IfcRepresentation &repr = mapped.MappingSource->MappedRepresentation; |
| 429 | |
| 430 | bool got = false; |
| 431 | for (const Schema_2x3::IfcRepresentationItem &item : repr.Items) { |
| 432 | if (!ProcessRepresentationItem(item, localmatid, meshes, conv)) { |
| 433 | IFCImporter::LogWarn("skipping mapped entity of type ", item.GetClassName(), ", no representations could be generated"); |
| 434 | } else |
| 435 | got = true; |
| 436 | } |
| 437 | |
| 438 | if (!got) { |
| 439 | return false; |
| 440 | } |
| 441 | |
| 442 | AssignAddedMeshes(meshes, nd.get(), conv); |
| 443 | if (conv.collect_openings) { |
| 444 | |
| 445 | // if this pass serves us only to collect opening geometry, |
| 446 | // make sure we transform the TempMesh's which we need to |
| 447 | // preserve as well. |
| 448 | if (const size_t diff = conv.collect_openings->size() - old_openings) { |
| 449 | for (size_t i = 0; i < diff; ++i) { |
| 450 | (*conv.collect_openings)[old_openings + i].Transform(msrc); |
| 451 | } |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | nd->mTransformation = nd_src->mTransformation * static_cast<aiMatrix4x4>(msrc); |
| 456 | subnodes_src.push_back(nd.release()); |
| 457 | |
| 458 | return true; |
| 459 | } |
| 460 |
no test coverage detected