mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
#2805 IfcGeom dynamic casting updates
This commit is contained in:
@@ -991,7 +991,7 @@ std::pair<std::string, double> IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn
|
|||||||
} else {
|
} else {
|
||||||
for (auto it = units->begin(); it != units->end(); ++it) {
|
for (auto it = units->begin(); it != units->end(); ++it) {
|
||||||
IfcSchema::IfcUnit* base = *it;
|
IfcSchema::IfcUnit* base = *it;
|
||||||
if (base->declaration().is(IfcSchema::IfcNamedUnit::Class())) {
|
if (base->as<IfcSchema::IfcNamedUnit>()) {
|
||||||
IfcSchema::IfcNamedUnit* named_unit = base->as<IfcSchema::IfcNamedUnit>();
|
IfcSchema::IfcNamedUnit* named_unit = base->as<IfcSchema::IfcNamedUnit>();
|
||||||
if (named_unit->UnitType() == IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT ||
|
if (named_unit->UnitType() == IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT ||
|
||||||
named_unit->UnitType() == IfcSchema::IfcUnitEnum::IfcUnit_PLANEANGLEUNIT)
|
named_unit->UnitType() == IfcSchema::IfcUnitEnum::IfcUnit_PLANEANGLEUNIT)
|
||||||
@@ -999,10 +999,10 @@ std::pair<std::string, double> IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn
|
|||||||
std::string current_unit_name;
|
std::string current_unit_name;
|
||||||
const double current_unit_magnitude = IfcParse::get_SI_equivalent<IfcSchema>(named_unit);
|
const double current_unit_magnitude = IfcParse::get_SI_equivalent<IfcSchema>(named_unit);
|
||||||
if (current_unit_magnitude != 0.) {
|
if (current_unit_magnitude != 0.) {
|
||||||
if (named_unit->declaration().is(IfcSchema::IfcConversionBasedUnit::Class())) {
|
if (named_unit->as<IfcSchema::IfcConversionBasedUnit>()) {
|
||||||
IfcSchema::IfcConversionBasedUnit* u = (IfcSchema::IfcConversionBasedUnit*)base;
|
IfcSchema::IfcConversionBasedUnit* u = named_unit->as<IfcSchema::IfcConversionBasedUnit>();
|
||||||
current_unit_name = u->Name();
|
current_unit_name = u->Name();
|
||||||
} else if (named_unit->declaration().is(IfcSchema::IfcSIUnit::Class())) {
|
} else if (named_unit->as<IfcSchema::IfcSIUnit>()) {
|
||||||
IfcSchema::IfcSIUnit* si_unit = named_unit->as<IfcSchema::IfcSIUnit>();
|
IfcSchema::IfcSIUnit* si_unit = named_unit->as<IfcSchema::IfcSIUnit>();
|
||||||
if (si_unit->Prefix()) {
|
if (si_unit->Prefix()) {
|
||||||
current_unit_name = IfcSchema::IfcSIPrefix::ToString(*si_unit->Prefix()) + unit_name;
|
current_unit_name = IfcSchema::IfcSIPrefix::ToString(*si_unit->Prefix()) + unit_name;
|
||||||
|
|||||||
@@ -347,8 +347,8 @@ public:
|
|||||||
if (surface_style->Side() != IfcSchema::IfcSurfaceSide::IfcSurfaceSide_NEGATIVE) {
|
if (surface_style->Side() != IfcSchema::IfcSurfaceSide::IfcSurfaceSide_NEGATIVE) {
|
||||||
auto styles_elements = surface_style->Styles();
|
auto styles_elements = surface_style->Styles();
|
||||||
for (auto mt = styles_elements->begin(); mt != styles_elements->end(); ++mt) {
|
for (auto mt = styles_elements->begin(); mt != styles_elements->end(); ++mt) {
|
||||||
if ((*mt)->declaration().is(T::Class())) {
|
if ((*mt)->as<T>())) {
|
||||||
return std::make_pair(surface_style, (T*) *mt);
|
return std::make_pair(surface_style, (*mt)->as<T>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,14 +58,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresenta
|
|||||||
|
|
||||||
part_succes = true;
|
part_succes = true;
|
||||||
decltype(parent_style) style = 0;
|
decltype(parent_style) style = 0;
|
||||||
if (element->declaration().is(IfcSchema::IfcPoint::Class())) {
|
if (element->as<IfcSchema::IfcPoint>()) {
|
||||||
style = get_style((IfcSchema::IfcPoint*) element);
|
style = get_style(element->as<IfcSchema::IfcPoint>());
|
||||||
}
|
}
|
||||||
else if (element->declaration().is(IfcSchema::IfcCurve::Class())) {
|
else if (element->as<IfcSchema::IfcPoint>()) {
|
||||||
style = get_style((IfcSchema::IfcCurve*) element);
|
style = get_style(element->as<IfcSchema::IfcPoint>());
|
||||||
}
|
}
|
||||||
else if (element->declaration().is(IfcSchema::IfcSurface::Class())) {
|
else if (element->as<IfcSchema::IfcPoint>()) {
|
||||||
style = get_style((IfcSchema::IfcSurface*) element);
|
style = get_style(element->as<IfcSchema::IfcPoint>());
|
||||||
}
|
}
|
||||||
shapes.push_back(IfcRepresentationShapeItem(l->data().id(), s, style ? style : parent_style));
|
shapes.push_back(IfcRepresentationShapeItem(l->data().id(), s, style ? style : parent_style));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIndexedPolyCurve* l, TopoDS_Wi
|
|||||||
auto segments = *l->Segments();
|
auto segments = *l->Segments();
|
||||||
for (auto it = segments->begin(); it != segments->end(); ++it) {
|
for (auto it = segments->begin(); it != segments->end(); ++it) {
|
||||||
auto segment = *it;
|
auto segment = *it;
|
||||||
if (segment->declaration().is(IfcSchema::IfcLineIndex::Class())) {
|
if (segment->as<IfcSchema::IfcLineIndex>()) {
|
||||||
IfcSchema::IfcLineIndex* line = (IfcSchema::IfcLineIndex*) segment;
|
IfcSchema::IfcLineIndex* line = segment->as<IfcSchema::IfcLineIndex>();
|
||||||
std::vector<int> indices = *line;
|
std::vector<int> indices = *line;
|
||||||
gp_Pnt previous;
|
gp_Pnt previous;
|
||||||
for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
|
for (std::vector<int>::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;
|
previous = current;
|
||||||
}
|
}
|
||||||
} else if (segment->declaration().is(IfcSchema::IfcArcIndex::Class())) {
|
} else if (segment->as<IfcSchema::IfcArcIndex>()) {
|
||||||
IfcSchema::IfcArcIndex* arc = (IfcSchema::IfcArcIndex*) segment;
|
IfcSchema::IfcArcIndex* arc = segment->as<IfcSchema::IfcArcIndex>();
|
||||||
std::vector<int> indices = *arc;
|
std::vector<int> indices = *arc;
|
||||||
if (indices.size() != 3) {
|
if (indices.size() != 3) {
|
||||||
throw IfcParse::IfcException("Invalid IfcArcIndex encountered");
|
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);
|
Logger::Warning("Ignoring segment on", l);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw IfcParse::IfcException("Unexpected IfcIndexedPolyCurve segment of type " + segment->declaration().name());
|
throw IfcParse::IfcException("Unexpected IfcIndexedPolyCurve segment of type " + segment->as<IfcUtil::IfcBaseClass>()->declaration().name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (points.begin() < points.end()) {
|
} else if (points.begin() < points.end()) {
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcShellBasedSurfaceModel* l, Ifc
|
|||||||
for(auto it = shells->begin(); it != shells->end(); ++ it) {
|
for(auto it = shells->begin(); it != shells->end(); ++ it) {
|
||||||
TopoDS_Shape s;
|
TopoDS_Shape s;
|
||||||
decltype(collective_style) shell_style;
|
decltype(collective_style) shell_style;
|
||||||
if ((*it)->declaration().is(IfcSchema::IfcRepresentationItem::Class())) {
|
if ((*it)->as<IfcSchema::IfcRepresentationItem>()) {
|
||||||
shell_style = get_style((IfcSchema::IfcRepresentationItem*)*it);
|
shell_style = get_style((*it)->as<IfcSchema::IfcRepresentationItem>());
|
||||||
}
|
}
|
||||||
if (convert_shape(*it,s)) {
|
if (convert_shape(*it,s)) {
|
||||||
shapes.push_back(IfcRepresentationShapeItem(l->data().id(), s, shell_style ? shell_style : collective_style));
|
shapes.push_back(IfcRepresentationShapeItem(l->data().id(), s, shell_style ? shell_style : collective_style));
|
||||||
|
|||||||
@@ -85,11 +85,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire&
|
|||||||
|
|
||||||
for (auto it = trims1->begin(); it != trims1->end(); it ++ ) {
|
for (auto it = trims1->begin(); it != trims1->end(); it ++ ) {
|
||||||
auto i = *it;
|
auto i = *it;
|
||||||
if ( i->declaration().is(IfcSchema::IfcCartesianPoint::Class()) ) {
|
if (i->as<IfcSchema::IfcCartesianPoint>()) {
|
||||||
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianPoint*)i, pnts[sense_agreement] );
|
IfcGeom::Kernel::convert(i->as<IfcSchema::IfcCartesianPoint>(), pnts[sense_agreement] );
|
||||||
has_pnts[sense_agreement] = true;
|
has_pnts[sense_agreement] = true;
|
||||||
} else if ( i->declaration().is(IfcSchema::IfcParameterValue::Class()) ) {
|
} else if (i->as<IfcSchema::IfcParameterValue>()) {
|
||||||
const double value = *((IfcSchema::IfcParameterValue*)i);
|
const double value = *i->as<IfcSchema::IfcParameterValue>();
|
||||||
flts[sense_agreement] = value * parameterFactor;
|
flts[sense_agreement] = value * parameterFactor;
|
||||||
has_flts[sense_agreement] = true;
|
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 ++ ) {
|
for (auto it = trims2->begin(); it != trims2->end(); it ++ ) {
|
||||||
auto i = *it;
|
auto i = *it;
|
||||||
if ( i->declaration().is(IfcSchema::IfcCartesianPoint::Class()) ) {
|
if (i->as<IfcSchema::IfcCartesianPoint>()) {
|
||||||
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianPoint*)i, pnts[1-sense_agreement] );
|
IfcGeom::Kernel::convert(i->as<IfcSchema::IfcCartesianPoint>(), pnts[1-sense_agreement] );
|
||||||
has_pnts[1-sense_agreement] = true;
|
has_pnts[1-sense_agreement] = true;
|
||||||
} else if ( i->declaration().is(IfcSchema::IfcParameterValue::Class()) ) {
|
} else if (i->as<IfcSchema::IfcParameterValue>()) {
|
||||||
const double value = *((IfcSchema::IfcParameterValue*)i);
|
const double value = *i->as<IfcSchema::IfcParameterValue>();
|
||||||
flts[1-sense_agreement] = value * parameterFactor;
|
flts[1-sense_agreement] = value * parameterFactor;
|
||||||
has_flts[1-sense_agreement] = true;
|
has_flts[1-sense_agreement] = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,11 @@ public:
|
|||||||
template <class U>
|
template <class U>
|
||||||
typename U::list::ptr as() {
|
typename U::list::ptr as() {
|
||||||
typename U::list::ptr r(new typename U::list);
|
typename U::list::ptr r(new typename U::list);
|
||||||
const bool all = !U::Class().as_entity();
|
for (it i = begin(); i != end(); ++i) {
|
||||||
for (it i = begin(); i != end(); ++i) if (all || (*i)->declaration().is(U::Class())) r->push((U*)*i);
|
if ((*i)->as<U>()) {
|
||||||
|
r->push((*i)->as<U>());
|
||||||
|
}
|
||||||
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
void remove(IfcUtil::IfcBaseClass*);
|
void remove(IfcUtil::IfcBaseClass*);
|
||||||
|
|||||||
Reference in New Issue
Block a user