@@ -86,6 +86,9 @@ namespace IfcGeom {
8686 template <typename P>
8787 class Iterator {
8888 private:
89+ Iterator (const Iterator&); // N/I
90+ Iterator& operator =(const Iterator&); // N/I
91+
8992 Kernel kernel;
9093 IteratorSettings settings;
9194
@@ -121,6 +124,7 @@ namespace IfcGeom {
121124 }
122125 }
123126
127+ std::set<boost::regex> names_to_include_or_exclude; // regex containing a name or a wildcard expression
124128 std::set<IfcSchema::Type::Enum> entities_to_include_or_exclude;
125129 bool include_entities_in_processing;
126130
@@ -148,7 +152,7 @@ namespace IfcGeom {
148152 } catch (...) {}
149153
150154 std::set<std::string> context_types;
151- if (!settings.exclude_solids_and_surfaces ( )) {
155+ if (!settings.get (IteratorSettings::EXCLUDE_SOLIDS_AND_SURFACES )) {
152156 // Really this should only be 'Model', as per
153157 // the standard 'Design' is deprecated. So,
154158 // just for backwards compatibility:
@@ -157,7 +161,7 @@ namespace IfcGeom {
157161 // DDS likes to output 'model view'
158162 context_types.insert (" model view" );
159163 }
160- if (settings.include_curves ( )) {
164+ if (settings.get (IteratorSettings::INCLUDE_CURVES )) {
161165 context_types.insert (" plan" );
162166 }
163167
@@ -250,36 +254,46 @@ namespace IfcGeom {
250254 return true ;
251255 }
252256
253- int progress () {
254- return 100 * done / total;
255- }
257+ int progress () const { return 100 * done / total; }
256258
257- const std::string& getUnitName () {
258- return unit_name;
259- }
259+ const std::string& getUnitName () const { return unit_name; }
260260
261- const P getUnitMagnitude () {
262- return unit_magnitude;
263- }
261+ P getUnitMagnitude () const { return unit_magnitude; }
264262
265- const std::string getLog () {
266- return Logger::GetLog ();
267- }
263+ std::string getLog () const { return Logger::GetLog (); }
268264
269- IfcParse::IfcFile* getFile () {
270- return ifc_file;
271- }
265+ IfcParse::IfcFile* getFile () const { return ifc_file; }
272266
267+ // / @note Entity names are handled case-insensitively.
273268 void includeEntities (const std::set<std::string>& entities) {
274269 populate_set (entities);
275270 include_entities_in_processing = true ;
276271 }
277272
273+ // / @note Entity names are handled case-insensitively.
278274 void excludeEntities (const std::set<std::string>& entities) {
279275 populate_set (entities);
280276 include_entities_in_processing = false ;
281277 }
282278
279+ // Arbitrary names or wildcard expressions are handled case-sensitively.
280+ void include_entity_names (const std::vector<std::string>& names)
281+ {
282+ names_to_include_or_exclude.clear ();
283+ foreach (const std::string &name, names)
284+ names_to_include_or_exclude.insert (IfcUtil::wildcard_string_to_regex (name));
285+ include_entities_in_processing = true ;
286+ }
287+
288+ // Arbitrary names or wildcard expressions are handled case-sensitively.
289+ void exclude_entity_names (const std::vector<std::string>& names)
290+ {
291+ names_to_include_or_exclude.clear ();
292+ foreach (const std::string &name, names)
293+ names_to_include_or_exclude.insert (IfcUtil::wildcard_string_to_regex (name));
294+ include_entities_in_processing = false ;
295+ }
296+
283297 private:
284298 // Move to the next IfcRepresentation
285299 void _nextShape () {
@@ -330,6 +344,14 @@ namespace IfcGeom {
330344 break ;
331345 }
332346 }
347+
348+ foreach (const boost::regex& r, names_to_include_or_exclude) {
349+ if (boost::regex_match ((*it)->Name (), r)) {
350+ found = true ;
351+ break ;
352+ }
353+ }
354+
333355 if (found == include_entities_in_processing) {
334356 ifcproducts->push (*jt);
335357 }
@@ -382,13 +404,17 @@ namespace IfcGeom {
382404 return create ();
383405 }
384406
385- Element<P>* get () {
386- // TODO: Test settings and throw
387- if (current_triangulation) return current_triangulation;
388- else if (current_serialization) return current_serialization;
389- else if (current_shape_model) return current_shape_model;
390- else return 0 ;
391- }
407+ // / Gets or takes the representation of the current geometrical entity.
408+ // / @param take_ownership Pass in 'true' as if wishing to maintain the element lifetime yourself.
409+ Element<P>* get (bool take_ownership = false )
410+ {
411+ // TODO: Test settings and throw
412+ Element<P>* ret = 0 ;
413+ if (current_triangulation) { ret = current_triangulation; if (take_ownership) current_triangulation = 0 ; }
414+ else if (current_serialization) { ret = current_serialization; if (take_ownership) current_serialization = 0 ; }
415+ else if (current_shape_model) { ret = current_shape_model; if (take_ownership) current_shape_model = 0 ; }
416+ return ret;
417+ }
392418
393419 const Element<P>* getObject (int id) {
394420
@@ -430,12 +456,12 @@ namespace IfcGeom {
430456 current_shape_model = create_shape_model_for_next_entity ();
431457 } catch (...) {}
432458 if (!current_shape_model) return false ;
433- if (settings.use_brep_data ( )) {
459+ if (settings.get (IteratorSettings::USE_BREP_DATA )) {
434460 try {
435461 current_serialization = new SerializedElement<P>(*current_shape_model);
436462 } catch (...) {}
437463 return !!current_serialization;
438- } else if (!settings.disable_triangulation ( )) {
464+ } else if (!settings.get (IteratorSettings::DISABLE_TRIANGULATION )) {
439465 try {
440466 current_triangulation = new TriangulationElement<P>(*current_shape_model);
441467 } catch (...) {}
@@ -457,8 +483,8 @@ namespace IfcGeom {
457483 unit_name = " METER" ;
458484 unit_magnitude = 1 .f ;
459485
460- kernel.setValue (IfcGeom::Kernel::GV_MAX_FACES_TO_SEW, settings.sew_shells ( ) ? 1000 : -1 );
461- kernel.setValue (IfcGeom::Kernel::GV_DIMENSIONALITY, (settings.include_curves ( ) ? (settings.exclude_solids_and_surfaces ( ) ? -1 . : 0 .) : +1 .));
486+ kernel.setValue (IfcGeom::Kernel::GV_MAX_FACES_TO_SEW, settings.get (IteratorSettings::SEW_SHELLS ) ? 1000 : -1 );
487+ kernel.setValue (IfcGeom::Kernel::GV_DIMENSIONALITY, (settings.get (IteratorSettings::INCLUDE_CURVES ) ? (settings.get (IteratorSettings::EXCLUDE_SOLIDS_AND_SURFACES ) ? -1 . : 0 .) : +1 .));
462488 }
463489
464490 bool owns_ifc_file;
0 commit comments