diff --git a/src/ifcgeom/mapping/IfcIndexedPolyCurve.cpp b/src/ifcgeom/mapping/IfcIndexedPolyCurve.cpp index 535ec89aaa..f63725a997 100644 --- a/src/ifcgeom/mapping/IfcIndexedPolyCurve.cpp +++ b/src/ifcgeom/mapping/IfcIndexedPolyCurve.cpp @@ -50,8 +50,8 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) { auto segments = *inst->Segments(); for (auto it = segments->begin(); it != segments->end(); ++it) { auto segment = *it; - if (segment->declaration().is(IfcSchema::IfcLineIndex::Class())) { - IfcSchema::IfcLineIndex* line = (IfcSchema::IfcLineIndex*) segment; + if (segment->as()) { + IfcSchema::IfcLineIndex* line = segment->as(); std::vector indices = *line; taxonomy::point3::ptr previous; for (std::vector::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) { @@ -64,8 +64,8 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) { } previous = current; } - } else if (segment->declaration().is(IfcSchema::IfcArcIndex::Class())) { - IfcSchema::IfcArcIndex* arc = (IfcSchema::IfcArcIndex*) segment; + } else if (segment->as()) { + IfcSchema::IfcArcIndex* arc = segment->as(); std::vector indices = *arc; if (indices.size() != 3) { throw IfcParse::IfcException("Invalid IfcArcIndex encountered"); @@ -89,7 +89,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIndexedPolyCurve* inst) { Logger::Warning("Ignoring segment on", inst); } } else { - throw IfcParse::IfcException("Unexpected IfcIndexedPolyCurve segment of type " + segment->declaration().name()); + throw IfcParse::IfcException("Unexpected IfcIndexedPolyCurve segment of type " + segment->as()->declaration().name()); } } } else if (points.begin() < points.end()) { diff --git a/src/ifcgeom/mapping/IfcTrimmedCurve.cpp b/src/ifcgeom/mapping/IfcTrimmedCurve.cpp index aa1d286ca4..cc5d49596e 100644 --- a/src/ifcgeom/mapping/IfcTrimmedCurve.cpp +++ b/src/ifcgeom/mapping/IfcTrimmedCurve.cpp @@ -48,11 +48,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrimmedCurve* inst) { for (auto it = trims1->begin(); it != trims1->end(); it ++) { auto i = *it; - if ( i->declaration().is(IfcSchema::IfcCartesianPoint::Class()) ) { + if (i->as()) { pnts[sense_agreement] = taxonomy::cast(map(i)); has_pnts[sense_agreement] = true; - } else if ( i->declaration().is(IfcSchema::IfcParameterValue::Class()) ) { - const double value = *((IfcSchema::IfcParameterValue*)i); + } else if (i->as()) { + const double value = *i->as(); flts[sense_agreement] = value * parameterFactor; has_flts[sense_agreement] = true; } @@ -60,11 +60,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcTrimmedCurve* inst) { for (auto it = trims2->begin(); it != trims2->end(); it ++) { auto i = *it; - if ( i->declaration().is(IfcSchema::IfcCartesianPoint::Class()) ) { + if (i->as()) { pnts[1 - sense_agreement] = taxonomy::cast(map(i)); has_pnts[1-sense_agreement] = true; - } else if ( i->declaration().is(IfcSchema::IfcParameterValue::Class()) ) { - const double value = *((IfcSchema::IfcParameterValue*)i); + } else if (i->as()) { + const double value = *i->as(); flts[1-sense_agreement] = value * parameterFactor; has_flts[1-sense_agreement] = true; } diff --git a/src/ifcparse/aggregate_of_instance.h b/src/ifcparse/aggregate_of_instance.h index b1645a6bb9..3ee8507426 100644 --- a/src/ifcparse/aggregate_of_instance.h +++ b/src/ifcparse/aggregate_of_instance.h @@ -90,10 +90,9 @@ class aggregate_of { template typename U::list::ptr as() { typename U::list::ptr result(new typename U::list); - const bool all = !U::Class().as_entity(); for (it i = begin(); i != end(); ++i) { - if (all || (*i)->declaration().is(U::Class())) { - result->push((U*)*i); + if ((*i)->as()) { + result->push(r->push((*i)->as()); } } return result; @@ -150,13 +149,12 @@ class IFC_PARSE_API aggregate_of_aggregate_of_instance { template typename aggregate_of_aggregate_of::ptr as() { typename aggregate_of_aggregate_of::ptr result(new aggregate_of_aggregate_of); - const bool all = !U::Class().as_entity(); for (outer_it outer = begin(); outer != end(); ++outer) { const std::vector& from = *outer; typename std::vector to; for (inner_it inner = from.begin(); inner != from.end(); ++inner) { - if (all || (*inner)->declaration().is(U::Class())) { - to.push_back((U*)*inner); + if ((*inner)->as()) { + to.push_back((*i)->as()); } } result->push(to);