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

Method get_representations

src/ifcgeom/mapping/mapping.cpp:218–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216
217
218void mapping::get_representations(std::vector<geometry_conversion_task>& tasks, std::vector<filter_t>& filters) {
219 IfcSchema::IfcRepresentation::list::ptr representations(new IfcSchema::IfcRepresentation::list);
220
221 if (!settings_.get<settings::ContextIds>().has()) {
222 addRepresentationsFromDefaultContexts(representations);
223 } else {
224 addRepresentationsFromContextIds(representations);
225 }
226
227 IfcSchema::IfcRepresentation::list::ptr ok_mapped_representations(new IfcSchema::IfcRepresentation::list);
228
229 int task_index = 0;
230
231 for (auto representation : *representations) {
232 IfcSchema::IfcRepresentationMap* rmap = nullptr;
233 IfcSchema::IfcProduct::list::ptr ifcproducts = filter_products(products_represented_by(representation, rmap, false), filters);
234
235 if (ifcproducts->size() == 0) {
236 continue;
237 }
238
239 auto geometry_reuse_ok_for_current_representation_ = reuse_ok_(ifcproducts);
240 if (!geometry_reuse_ok_for_current_representation_ && rmap != nullptr) {
241 not_reusable_maps_.insert(rmap);
242 }
243
244 IfcSchema::IfcRepresentationMap::list::ptr maps = representation->RepresentationMap();
245
246 if (!geometry_reuse_ok_for_current_representation_ && maps->size() == 1) {
247 // unfiltered_products contains products represented by this representation by means of mapped items.
248 // For example because of openings applied to products, reuse might not be acceptable and then the
249 // products will be processed by means of their immediate representation and not the mapped representation.
250
251 // IfcRepresentationMaps are also used for IfcTypeProducts, so an additional check is performed whether the map
252 // is indeed used by IfcMappedItems.
253 IfcSchema::IfcRepresentationMap* map = *maps->begin();
254 if (map->MapUsage()->size() > 0) {
255 continue;
256 }
257 }
258
259 // Check if this representation has (or will be) processed as part its mapped representation
260 bool representation_processed_as_mapped_item = false;
261 IfcSchema::IfcRepresentation* representation_mapped_to_result = representation_mapped_to(representation);
262 if (representation_mapped_to_result) {
263 representation_processed_as_mapped_item = geometry_reuse_ok_for_current_representation_ && (
264 ok_mapped_representations->contains(representation_mapped_to_result) || reuse_ok_(products_represented_by(representation_mapped_to_result, rmap)));
265 }
266
267 if (representation_processed_as_mapped_item) {
268 ok_mapped_representations->push(representation_mapped_to_result);
269 continue;
270 }
271
272 if (!geometry_reuse_ok_for_current_representation_ && ifcproducts->size() > 1) {
273 // reuse_ok is taken into account in products_represented_by(), but not when
274 // the same IfcRepresentation is directly assigned to multiple products.
275 for (auto& p : *ifcproducts) {

Callers 2

initializeMethod · 0.45
compute_boundsMethod · 0.45

Calls 8

filter_productsFunction · 0.85
hasMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
containsMethod · 0.45
pushMethod · 0.45
generalizeMethod · 0.45

Tested by

no test coverage detected