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

Method find_openings

src/ifcgeom/mapping/mapping.cpp:164–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164aggregate_of_instance::ptr mapping::find_openings(const IfcUtil::IfcBaseEntity* inst) {
165 aggregate_of_instance::ptr openings(new aggregate_of_instance);
166
167 if (auto rep = inst->as<IfcSchema::IfcRepresentation>()) {
168 // @todo this is essentially only for hybrid kernel trying to guess
169 // when not to use a simple kernel.
170 IfcSchema::IfcRepresentationMap* rmap;
171 auto prods = products_represented_by(rep, rmap, true);
172 for (auto& p : *prods) {
173 openings->push(find_openings(p));
174 }
175 return openings;
176 }
177
178 if (inst->as<IfcSchema::IfcElement>() && !inst->as<IfcSchema::IfcFeatureElementSubtraction>()) {
179 const IfcSchema::IfcElement* element = inst->as<IfcSchema::IfcElement>();
180 auto rels = element->HasOpenings();
181 for (auto& rel : *rels) {
182 openings->push(rel->RelatedOpeningElement());
183 }
184 }
185
186 // Is the IfcElement a decomposition of an IfcElement with any IfcOpeningElements?
187 const IfcSchema::IfcObjectDefinition* obdef = inst->as<IfcSchema::IfcObjectDefinition>();
188 if (obdef != nullptr) {
189 for (;;) {
190 auto decomposes = obdef->Decomposes()->generalize();
191 if (decomposes->size() != 1) {
192 // If we have multiple decompositions, not allowed by schema,
193 // openings associated to relating decompositions are not
194 // considered;
195 break;
196 }
197 if ((*decomposes->begin())->as<IfcSchema::IfcRelAggregates>() == nullptr) {
198 // Only aggregation, not nesting is considered.
199 break;
200 }
201 IfcSchema::IfcObjectDefinition* rel_obdef = (*decomposes->begin())->as<IfcSchema::IfcRelAggregates>()->RelatingObject();
202 if (rel_obdef->as<IfcSchema::IfcElement>() && !rel_obdef->as<IfcSchema::IfcFeatureElementSubtraction>()) {
203 IfcSchema::IfcElement* element = rel_obdef->as<IfcSchema::IfcElement>();
204 auto rels = element->HasOpenings();
205 for (auto& rel : *rels) {
206 openings->push(rel->RelatedOpeningElement());
207 }
208 }
209
210 obdef = rel_obdef;
211 }
212 }
213
214 return openings;
215}
216
217
218void mapping::get_representations(std::vector<geometry_conversion_task>& tasks, std::vector<filter_t>& filters) {

Callers 2

convertMethod · 0.80

Calls 4

pushMethod · 0.45
generalizeMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected