MCPcopy Create free account
hub / github.com/assimp/assimp / RateRepresentationPredicate

Class RateRepresentationPredicate

code/AssetLib/IFC/IFCLoader.cpp:462–520  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

460
461// ------------------------------------------------------------------------------------------------
462struct RateRepresentationPredicate {
463 int Rate(const Schema_2x3::IfcRepresentation *r) const {
464 // the smaller, the better
465
466 if (!r->RepresentationIdentifier) {
467 // neutral choice if no extra information is specified
468 return 0;
469 }
470
471 const std::string &name = r->RepresentationIdentifier.Get();
472 if (name == "MappedRepresentation") {
473 if (!r->Items.empty()) {
474 // take the first item and base our choice on it
475 const Schema_2x3::IfcMappedItem *const m = r->Items.front()->ToPtr<Schema_2x3::IfcMappedItem>();
476 if (m) {
477 return Rate(m->MappingSource->MappedRepresentation);
478 }
479 }
480 return 100;
481 }
482
483 return Rate(name);
484 }
485
486 int Rate(const std::string &r) const {
487 if (r == "SolidModel") {
488 return -3;
489 }
490
491 // give strong preference to extruded geometry.
492 if (r == "SweptSolid") {
493 return -10;
494 }
495
496 if (r == "Clipping") {
497 return -5;
498 }
499
500 // 'Brep' is difficult to get right due to possible voids in the
501 // polygon boundaries, so take it only if we are forced to (i.e.
502 // if the only alternative is (non-clipping) boolean operations,
503 // which are not supported at all).
504 if (r == "Brep") {
505 return -2;
506 }
507
508 // Curves, bounding boxes - those will most likely not be loaded
509 // as we can't make any use out of this data. So consider them
510 // last.
511 if (r == "BoundingBox" || r == "Curve2D") {
512 return 100;
513 }
514 return 0;
515 }
516
517 bool operator()(const Schema_2x3::IfcRepresentation *a, const Schema_2x3::IfcRepresentation *b) const {
518 return Rate(a) < Rate(b);
519 }

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected