diff --git a/src/ifcgeom/IfcGeom.cpp b/src/ifcgeom/IfcGeom.cpp index f235d9b07a..d0f17a46c8 100644 --- a/src/ifcgeom/IfcGeom.cpp +++ b/src/ifcgeom/IfcGeom.cpp @@ -991,7 +991,7 @@ std::pair IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn } else { for (auto it = units->begin(); it != units->end(); ++it) { IfcSchema::IfcUnit* base = *it; - if (base->declaration().is(IfcSchema::IfcNamedUnit::Class())) { + if (base->as()) { IfcSchema::IfcNamedUnit* named_unit = base->as(); if (named_unit->UnitType() == IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT || named_unit->UnitType() == IfcSchema::IfcUnitEnum::IfcUnit_PLANEANGLEUNIT) @@ -999,10 +999,10 @@ std::pair IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn std::string current_unit_name; const double current_unit_magnitude = IfcParse::get_SI_equivalent(named_unit); if (current_unit_magnitude != 0.) { - if (named_unit->declaration().is(IfcSchema::IfcConversionBasedUnit::Class())) { - IfcSchema::IfcConversionBasedUnit* u = (IfcSchema::IfcConversionBasedUnit*)base; + if (named_unit->as()) { + IfcSchema::IfcConversionBasedUnit* u = named_unit->as(); current_unit_name = u->Name(); - } else if (named_unit->declaration().is(IfcSchema::IfcSIUnit::Class())) { + } else if (named_unit->as()) { IfcSchema::IfcSIUnit* si_unit = named_unit->as(); if (si_unit->Prefix()) { current_unit_name = IfcSchema::IfcSIPrefix::ToString(*si_unit->Prefix()) + unit_name; diff --git a/src/ifcgeom/IfcGeom.h b/src/ifcgeom/IfcGeom.h index 41cbce4802..42575acb3e 100644 --- a/src/ifcgeom/IfcGeom.h +++ b/src/ifcgeom/IfcGeom.h @@ -347,8 +347,8 @@ public: if (surface_style->Side() != IfcSchema::IfcSurfaceSide::IfcSurfaceSide_NEGATIVE) { auto styles_elements = surface_style->Styles(); for (auto mt = styles_elements->begin(); mt != styles_elements->end(); ++mt) { - if ((*mt)->declaration().is(T::Class())) { - return std::make_pair(surface_style, (T*) *mt); + if ((*mt)->as())) { + return std::make_pair(surface_style, (*mt)->as()); } } } diff --git a/src/ifcgeom/IfcGeometricSet.cpp b/src/ifcgeom/IfcGeometricSet.cpp index 7b4556d439..ce74dbe3dc 100644 --- a/src/ifcgeom/IfcGeometricSet.cpp +++ b/src/ifcgeom/IfcGeometricSet.cpp @@ -58,14 +58,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresenta part_succes = true; decltype(parent_style) style = 0; - if (element->declaration().is(IfcSchema::IfcPoint::Class())) { - style = get_style((IfcSchema::IfcPoint*) element); + if (element->as()) { + style = get_style(element->as()); } - else if (element->declaration().is(IfcSchema::IfcCurve::Class())) { - style = get_style((IfcSchema::IfcCurve*) element); + else if (element->as()) { + style = get_style(element->as()); } - else if (element->declaration().is(IfcSchema::IfcSurface::Class())) { - style = get_style((IfcSchema::IfcSurface*) element); + else if (element->as()) { + style = get_style(element->as()); } shapes.push_back(IfcRepresentationShapeItem(l->data().id(), s, style ? style : parent_style)); } diff --git a/src/ifcgeom/IfcIndexedPolyCurve.cpp b/src/ifcgeom/IfcIndexedPolyCurve.cpp index 29ac4372ad..81ae655b2f 100644 --- a/src/ifcgeom/IfcIndexedPolyCurve.cpp +++ b/src/ifcgeom/IfcIndexedPolyCurve.cpp @@ -61,8 +61,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIndexedPolyCurve* l, TopoDS_Wi auto segments = *l->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; gp_Pnt previous; for (std::vector::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) { @@ -80,8 +80,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIndexedPolyCurve* l, TopoDS_Wi } 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"); @@ -103,7 +103,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIndexedPolyCurve* l, TopoDS_Wi Logger::Warning("Ignoring segment on", l); } } 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/IfcShellBasedSurfaceModel.cpp b/src/ifcgeom/IfcShellBasedSurfaceModel.cpp index ed2bb79007..0d78ceec64 100644 --- a/src/ifcgeom/IfcShellBasedSurfaceModel.cpp +++ b/src/ifcgeom/IfcShellBasedSurfaceModel.cpp @@ -28,8 +28,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcShellBasedSurfaceModel* l, Ifc for(auto it = shells->begin(); it != shells->end(); ++ it) { TopoDS_Shape s; decltype(collective_style) shell_style; - if ((*it)->declaration().is(IfcSchema::IfcRepresentationItem::Class())) { - shell_style = get_style((IfcSchema::IfcRepresentationItem*)*it); + if ((*it)->as()) { + shell_style = get_style((*it)->as()); } if (convert_shape(*it,s)) { shapes.push_back(IfcRepresentationShapeItem(l->data().id(), s, shell_style ? shell_style : collective_style)); diff --git a/src/ifcgeom/IfcTrimmedCurve.cpp b/src/ifcgeom/IfcTrimmedCurve.cpp index 5b2081ad3c..77140a1e2a 100644 --- a/src/ifcgeom/IfcTrimmedCurve.cpp +++ b/src/ifcgeom/IfcTrimmedCurve.cpp @@ -85,11 +85,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire& for (auto it = trims1->begin(); it != trims1->end(); it ++ ) { auto i = *it; - if ( i->declaration().is(IfcSchema::IfcCartesianPoint::Class()) ) { - IfcGeom::Kernel::convert((IfcSchema::IfcCartesianPoint*)i, pnts[sense_agreement] ); + if (i->as()) { + IfcGeom::Kernel::convert(i->as(), pnts[sense_agreement] ); 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; } @@ -97,11 +97,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire& for (auto it = trims2->begin(); it != trims2->end(); it ++ ) { auto i = *it; - if ( i->declaration().is(IfcSchema::IfcCartesianPoint::Class()) ) { - IfcGeom::Kernel::convert((IfcSchema::IfcCartesianPoint*)i, pnts[1-sense_agreement] ); + if (i->as()) { + IfcGeom::Kernel::convert(i->as(), pnts[1-sense_agreement] ); 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 59f335f79d..c6bf8f5921 100644 --- a/src/ifcparse/aggregate_of_instance.h +++ b/src/ifcparse/aggregate_of_instance.h @@ -45,8 +45,11 @@ public: template typename U::list::ptr as() { typename U::list::ptr r(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())) r->push((U*)*i); + for (it i = begin(); i != end(); ++i) { + if ((*i)->as()) { + r->push((*i)->as()); + } + } return r; } void remove(IfcUtil::IfcBaseClass*);