Fix some casting logic

This commit is contained in:
Thomas Krijnen
2021-09-13 13:19:56 +02:00
parent 99a27fbfef
commit 1058dc7099
14 changed files with 2806 additions and 2807 deletions
+8 -6
View File
@@ -93,11 +93,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircle* l, Handle(Geom_Curve)&
}
gp_Trsf trsf;
IfcSchema::IfcAxis2Placement* placement = l->Position();
if (placement->declaration().is(IfcSchema::IfcAxis2Placement3D::Class())) {
IfcGeom::Kernel::convert((IfcSchema::IfcAxis2Placement3D*)placement,trsf);
if (placement->as<IfcSchema::IfcAxis2Placement3D>()) {
IfcGeom::Kernel::convert(placement->as<IfcSchema::IfcAxis2Placement3D>(),trsf);
} else {
gp_Trsf2d trsf2d;
IfcGeom::Kernel::convert((IfcSchema::IfcAxis2Placement2D*)placement,trsf2d);
IfcGeom::Kernel::convert(placement->as<IfcSchema::IfcAxis2Placement2D>(),trsf2d);
trsf = trsf2d;
}
gp_Ax2 ax = gp_Ax2().Transformed(trsf);
@@ -117,14 +117,16 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcEllipse* l, Handle(Geom_Curve)
// when creating a trimmed curve off of an ellipse like this.
const bool rotated = y > x;
gp_Trsf trsf;
IfcSchema::IfcAxis2Placement* placement = l->Position();
if (placement->declaration().is(IfcSchema::IfcAxis2Placement3D::Class())) {
convert((IfcSchema::IfcAxis2Placement3D*)placement,trsf);
if (placement->as<IfcSchema::IfcAxis2Placement3D>()) {
IfcGeom::Kernel::convert(placement->as<IfcSchema::IfcAxis2Placement3D>(), trsf);
} else {
gp_Trsf2d trsf2d;
convert((IfcSchema::IfcAxis2Placement2D*)placement,trsf2d);
IfcGeom::Kernel::convert(placement->as<IfcSchema::IfcAxis2Placement2D>(), trsf2d);
trsf = trsf2d;
}
gp_Ax2 ax = gp_Ax2();
if (rotated) {
ax.Rotate(ax.Axis(), M_PI / 2.);
+2 -2
View File
@@ -3445,8 +3445,8 @@ const IfcSchema::IfcRepresentationItem* IfcGeom::Kernel::find_item_carrying_styl
while (item->declaration().is(IfcSchema::IfcBooleanResult::Class())) {
// All instantiations of IfcBooleanOperand (type of FirstOperand) are subtypes of
// IfcGeometricRepresentationItem
item = (IfcSchema::IfcGeometricRepresentationItem*) ((IfcSchema::IfcBooleanResult*) item)->FirstOperand();
if (item->StyledByItem()->size()) {
item = item->as<IfcSchema::IfcBooleanResult>()->FirstOperand()->as<IfcSchema::IfcRepresentationItem>();
if (item && item->StyledByItem()->size()) {
return item;
}
}
+3 -3
View File
@@ -429,8 +429,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& t
for (;;) {
gp_Trsf trsf2;
IfcSchema::IfcAxis2Placement* relplacement = current->RelativePlacement();
if ( relplacement->declaration().is(IfcSchema::IfcAxis2Placement3D::Class()) ) {
IfcGeom::Kernel::convert((IfcSchema::IfcAxis2Placement3D*)relplacement,trsf2);
if (relplacement->as<IfcSchema::IfcAxis2Placement3D>()) {
IfcGeom::Kernel::convert(relplacement->as<IfcSchema::IfcAxis2Placement3D>(),trsf2);
trsf.PreMultiply(trsf2);
}
if ( current->PlacementRelTo() ) {
@@ -444,7 +444,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& t
if ( parentPlacesType ) break;
else if ( parent->declaration().is(IfcSchema::IfcLocalPlacement::Class()) )
current = (IfcSchema::IfcLocalPlacement*)current->PlacementRelTo();
current = current->PlacementRelTo()->as<IfcSchema::IfcLocalPlacement>();
else break;
} else break;
}
@@ -115,6 +115,7 @@ class Implementation(codegen.Base):
"index": arg["index"] - 1,
"type": arg["full_type"].replace("::Value", ""),
"non_optional_type": arg["non_optional_type"].replace("::Value", ""),
"non_optional_type_no_pointer": arg["non_optional_type"].replace("::Value", "").replace("*", ""),
"list_instance_type": arg["list_instance_type"],
"null_check": null_check
},
@@ -243,7 +243,7 @@ optional_attr_stmt = "return !data_->getArgument(%(index)d)->isNull();"
get_attr_stmt = "%(null_check)s %(non_optional_type)s v = *data_->getArgument(%(index)d); return v;"
get_attr_stmt_enum = "%(null_check)s return %(non_optional_type)s::FromString(*data_->getArgument(%(index)d));"
get_attr_stmt_entity = "%(null_check)s return (%(non_optional_type)s)((IfcUtil::IfcBaseClass*)(*data_->getArgument(%(index)d)));"
get_attr_stmt_entity = "%(null_check)s return ((IfcUtil::IfcBaseClass*)(*data_->getArgument(%(index)d)))->as<%(non_optional_type_no_pointer)s>();"
get_attr_stmt_array = (
"%(null_check)s aggregate_of_instance::ptr es = *data_->getArgument(%(index)d); return es->as< %(list_instance_type)s >();"
)
+353 -353
View File
File diff suppressed because it is too large Load Diff
+327 -327
View File
File diff suppressed because one or more lines are too long
+338 -338
View File
File diff suppressed because one or more lines are too long
+339 -339
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -6
View File
@@ -52,9 +52,7 @@ namespace IfcUtil {
if (is_null(this)) {
return static_cast<T*>(0);
}
return declaration().is(T::Class())
? dynamic_cast<T*>(this)
: static_cast<T*>(0);
return dynamic_cast<T*>(this);
}
template <class T>
@@ -62,9 +60,7 @@ namespace IfcUtil {
if (is_null(this)) {
return static_cast<const T*>(0);
}
return declaration().is(T::Class())
? dynamic_cast<const T*>(this)
: static_cast<const T*>(0);
return dynamic_cast<const T*>(this);
}
};