| 48 | #define mapping POSTFIX_SCHEMA(mapping) |
| 49 | |
| 50 | IfcSchema::IfcProduct::list::ptr mapping::products_represented_by(const IfcSchema::IfcRepresentation* representation, IfcSchema::IfcRepresentationMap*& rmap, bool only_direct) { |
| 51 | IfcSchema::IfcProduct::list::ptr products(new IfcSchema::IfcProduct::list); |
| 52 | |
| 53 | IfcSchema::IfcProductRepresentation::list::ptr prodreps = representation->OfProductRepresentation(); |
| 54 | |
| 55 | for (IfcSchema::IfcProductRepresentation::list::it it = prodreps->begin(); it != prodreps->end(); ++it) { |
| 56 | // http://buildingsmart-tech.org/ifc/IFC2x3/TC1/html/ifcrepresentationresource/lexical/ifcproductrepresentation.htm |
| 57 | // IFC2x Edition 3 NOTE Users should not instantiate the entity IfcProductRepresentation from IFC2x Edition 3 onwards. |
| 58 | // It will be changed into an ABSTRACT supertype in future releases of IFC. |
| 59 | |
| 60 | // IfcProductRepresentation also lacks the INVERSE relation to IfcProduct |
| 61 | // Let's find the IfcProducts that reference the IfcProductRepresentation anyway |
| 62 | products->push((*it)->file_->getInverse((*it)->id(), &IfcSchema::IfcProduct::Class(), -1)->as<IfcSchema::IfcProduct>()); |
| 63 | } |
| 64 | |
| 65 | if (only_direct) { |
| 66 | return products; |
| 67 | } |
| 68 | |
| 69 | IfcSchema::IfcRepresentationMap::list::ptr maps = representation->RepresentationMap(); |
| 70 | if (maps->size() == 1) { |
| 71 | rmap = *maps->begin(); |
| 72 | if (not_reusable_maps_.find(rmap) != not_reusable_maps_.end()) { |
| 73 | return products; |
| 74 | } |
| 75 | taxonomy::matrix4::ptr origin = taxonomy::cast<taxonomy::matrix4>(map(rmap->MappingOrigin())); |
| 76 | if (origin->is_identity()) { |
| 77 | IfcSchema::IfcMappedItem::list::ptr items = rmap->MapUsage(); |
| 78 | for (IfcSchema::IfcMappedItem::list::it it = items->begin(); it != items->end(); ++it) { |
| 79 | IfcSchema::IfcMappedItem* item = *it; |
| 80 | if (item->StyledByItem()->size() != 0) continue; |
| 81 | |
| 82 | taxonomy::matrix4::ptr target; |
| 83 | try { |
| 84 | target = taxonomy::cast<taxonomy::matrix4>(map(item->MappingTarget())); |
| 85 | } catch (const std::exception& e) { |
| 86 | Logger::Error(e); |
| 87 | continue; |
| 88 | } |
| 89 | if (!target->is_identity()) { |
| 90 | continue; |
| 91 | } |
| 92 | |
| 93 | IfcSchema::IfcRepresentation::list::ptr reps = item->file_->getInverse(item->id(), (&IfcSchema::IfcRepresentation::Class()), -1)->as<IfcSchema::IfcRepresentation>(); |
| 94 | for (IfcSchema::IfcRepresentation::list::it jt = reps->begin(); jt != reps->end(); ++jt) { |
| 95 | IfcSchema::IfcRepresentation* rep = *jt; |
| 96 | if (rep->Items()->size() != 1) continue; |
| 97 | IfcSchema::IfcProductRepresentation::list::ptr prodreps_mapped = rep->OfProductRepresentation(); |
| 98 | for (IfcSchema::IfcProductRepresentation::list::it kt = prodreps_mapped->begin(); kt != prodreps_mapped->end(); ++kt) { |
| 99 | IfcSchema::IfcProduct::list::ptr ps = (*kt)->file_->getInverse((*kt)->id(), (&IfcSchema::IfcProduct::Class()), -1)->as<IfcSchema::IfcProduct>(); |
| 100 | products->push(ps); |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | return products; |
nothing calls this directly
no test coverage detected