@@ -114,44 +114,42 @@ std::string format_string(const AttributeValue& argument) {
114114}
115115
116116template <typename Schema, typename T>
117- void process_pset (element_properties& props, const T* inst) {
117+ void process_pset (element_properties& props, const T& inst) {
118118 // Process an individual Property or Quantity set.
119- if (auto pset = inst-> template as <typename Schema::IfcPropertySet>()) {
119+ if (auto pset = inst. template as <typename Schema::IfcPropertySet>()) {
120120 if (!pset->Name ()) {
121121 return ;
122122 }
123123 auto ps = pset->HasProperties ();
124- for (auto it = ps->begin (); it != ps->end (); ++it) {
125- auto & p = *it;
126- if (auto singleval = p->template as <typename Schema::IfcPropertySingleValue>()) {
124+ for (auto & p : ps) {
125+ if (auto singleval = p.template as <typename Schema::IfcPropertySingleValue>()) {
127126 std::string propname, propvalue;
128127 if constexpr (is_ifc4_or_higher<Schema>::value) {
129- if (!singleval-> Name ()) {
128+ if (!singleval. Name ()) {
130129 continue ;
131130 }
132- propname = *singleval-> Name ();
131+ propname = *singleval. Name ();
133132 }
134133 if constexpr (!is_ifc4_or_higher<Schema>::value) {
135- propname = singleval-> Name ();
134+ propname = singleval. Name ();
136135 }
137- if (!singleval-> NominalValue ()) {
136+ if (!singleval. NominalValue ()) {
138137 propvalue = " -" ;
139138 } else {
140- props[*pset-> Name ()][propname] = format_string (singleval-> NominalValue ()-> template as <IfcUtil::IfcBaseClass>()-> get_attribute_value (0 ));
139+ props[*pset. Name ()][propname] = format_string (singleval. NominalValue (). concrete (). get_attribute_value (0 ));
141140 }
142141 }
143142 }
144143 }
145- if (auto qset = inst-> template as <typename Schema::IfcElementQuantity>()) {
146- if (!qset-> Name ()) {
144+ if (auto qset = inst. template as <typename Schema::IfcElementQuantity>()) {
145+ if (!qset. Name ()) {
147146 return ;
148147 }
149- auto qs = qset->Quantities ();
150- for (auto it = qs->begin (); it != qs->end (); ++it) {
151- auto & q = *it;
152- if (q->template as <typename Schema::IfcPhysicalSimpleQuantity>() && q->get_attribute_value (3 ).type () == IfcUtil::Argument_DOUBLE) {
153- double v = q->get_attribute_value (3 );
154- props[*qset->Name ()][q->Name ()] = std::to_string (v);
148+ auto qs = qset.Quantities ();
149+ for (auto & q : qs) {
150+ if (q.template as <typename Schema::IfcPhysicalSimpleQuantity>() && q.get_attribute_value (3 ).type () == IfcUtil::Argument_DOUBLE) {
151+ double v = q.get_attribute_value (3 );
152+ props[*qset.Name ()][q.Name ()] = std::to_string (v);
155153 }
156154 }
157155 }
@@ -163,48 +161,43 @@ void process_pset(element_properties& props, const T* inst) {
163161}
164162
165163template <typename Schema>
166- void get_psets_s (element_properties& props, const typename Schema::IfcObjectDefinition* inst) {
164+ void get_psets_s (element_properties& props, const typename Schema::IfcObjectDefinition& inst) {
167165 // Extracts the property definitions for an IFC instance.
168- if (auto tyob = inst->template as <typename Schema::IfcTypeObject>()) {
169- if (tyob->HasPropertySets ()) {
170- auto defs = *tyob->HasPropertySets ();
171- for (auto it = defs->begin (); it != defs->end (); ++it) {
172- auto & def = *it;
166+ if (auto tyob = inst.template as <typename Schema::IfcTypeObject>()) {
167+ if (tyob.HasPropertySets ()) {
168+ auto defs = *tyob.HasPropertySets ();
169+ for (auto & def : defs) {
173170 process_pset<Schema>(props, def);
174171 }
175172 }
176173 }
177174 if constexpr (is_ifc4_or_higher<Schema>::value) {
178- if (auto mdef = inst->template as <typename Schema::IfcMaterialDefinition>()) {
179- auto defs = mdef->HasProperties ();
180- for (auto it = defs->begin (); it != defs->end (); ++it) {
181- auto & def = *it;
175+ if (auto mdef = inst.template as <typename Schema::IfcMaterialDefinition>()) {
176+ auto defs = mdef.HasProperties ();
177+ for (auto & def : defs) {
182178 process_pset<Schema>(props, def);
183179 }
184180 }
185- if (auto pdef = inst-> template as <typename Schema::IfcProfileDef>()) {
181+ if (auto pdef = inst. template as <typename Schema::IfcProfileDef>()) {
186182 auto defs = pdef->HasProperties ();
187- for (auto it = defs->begin (); it != defs->end (); ++it) {
188- auto & def = *it;
183+ for (auto & def : defs) {
189184 process_pset<Schema>(props, def);
190185 }
191186 }
192187 }
193- if (auto ob = inst-> template as <typename Schema::IfcObject>()) {
188+ if (auto ob = inst. template as <typename Schema::IfcObject>()) {
194189 if constexpr (is_ifc4_or_higher<Schema>::value) {
195- auto rels = ob->IsTypedBy ();
196- for (auto it = rels->begin (); it != rels->end (); ++it) {
197- auto & rel = *it;
190+ auto rels = ob.IsTypedBy ();
191+ for (auto & rel : rels) {
198192 get_psets_s<Schema>(props, rel->RelatingType ());
199193 }
200194 }
201195 {
202- auto rels = ob->IsDefinedBy ();
203- for (auto it = rels->begin (); it != rels->end (); ++it) {
204- auto & rel = *it;
205- if (auto bytype = rel->template as <typename Schema::IfcRelDefinesByType>()) {
196+ auto rels = ob.IsDefinedBy ();
197+ for (auto & rel : rels) {
198+ if (auto bytype = rel.template as <typename Schema::IfcRelDefinesByType>()) {
206199 get_psets_s<Schema>(props, bytype->RelatingType ());
207- } else if (auto byprops = rel-> template as <typename Schema::IfcRelDefinesByProperties>()) {
200+ } else if (auto byprops = rel. template as <typename Schema::IfcRelDefinesByProperties>()) {
208201 process_pset<Schema>(props, byprops->RelatingPropertyDefinition ());
209202 }
210203 }
@@ -220,10 +213,10 @@ void get_psets_s(element_properties& props, const typename Schema::IfcObjectDefi
220213#define GENERATE_LITERAL_STRING (elem ) " Ifc" # elem
221214
222215#define TEST_AND_DISPATCH (r, data, elem ) \
223- if (strcasecmp(schema_name, GENERATE_LITERAL_STRING(elem)) == 0 ) { get_psets_s<EXPAND_AND_CONCATENATE (elem)>(props, inst-> as <EXPAND_AND_CONCATENATE (elem)::IfcObjectDefinition>()); }
216+ if (strcasecmp(schema_name, GENERATE_LITERAL_STRING(elem)) == 0 ) { get_psets_s<EXPAND_AND_CONCATENATE (elem)>(props, inst. as <EXPAND_AND_CONCATENATE (elem)::IfcObjectDefinition>()); }
224217
225- void get_psets (element_properties& props, const IfcUtil::IfcBaseClass* inst) {
226- auto schema_name = inst-> declaration ().schema ()->name ().c_str ();
218+ void get_psets (element_properties& props, const express::Base& inst) {
219+ auto schema_name = inst. declaration ().schema ()->name ().c_str ();
227220 BOOST_PP_SEQ_FOR_EACH (TEST_AND_DISPATCH, , SCHEMA_SEQ)
228221}
229222
@@ -259,19 +252,17 @@ int main(int argc, char** argv) {
259252 // we need to cast them to IfcWindows. Since these properties
260253 // are optional we need to make sure the properties are
261254 // defined for the window in question before accessing them.
262- IfcSchema::IfcBuildingElement::list::ptr elements = file.instances_by_type <IfcSchema::IfcBuildingElement>();
255+ auto elements = file.instances_by_type <IfcSchema::IfcBuildingElement>();
263256
264- std::cout << " Found " << elements-> size () << " elements in " << argv[1 ] << " :" << std::endl;
257+ std::cout << " Found " << elements. size () << " elements in " << argv[1 ] << " :" << std::endl;
265258
266- for (auto it = elements->begin (); it != elements->end (); ++it) {
267- const auto * element = *it;
268- element->toString (std::cout);
259+ for (auto & element : elements) {
260+ element.toString (std::cout);
269261 std::cout << std::endl;
270262
271- const IfcSchema::IfcWindow* window;
272- if ((window = element->as <IfcSchema::IfcWindow>()) != 0 ) {
273- if (window->OverallWidth () && window->OverallHeight ()) {
274- const double area = *window->OverallWidth () * *window->OverallHeight ();
263+ if (auto window = element.as <IfcSchema::IfcWindow>()) {
264+ if (window.OverallWidth () && window.OverallHeight ()) {
265+ const double area = *window.OverallWidth () * *window.OverallHeight ();
275266 std::cout << " The area of this window is " << area << std::endl;
276267 }
277268 }
0 commit comments