Skip to content

Commit 1058dc7

Browse files
committed
Fix some casting logic
1 parent 99a27fb commit 1058dc7

File tree

14 files changed

+2806
-2807
lines changed

14 files changed

+2806
-2807
lines changed

src/ifcgeom/IfcGeomCurves.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircle* l, Handle(Geom_Curve)&
9393
}
9494
gp_Trsf trsf;
9595
IfcSchema::IfcAxis2Placement* placement = l->Position();
96-
if (placement->declaration().is(IfcSchema::IfcAxis2Placement3D::Class())) {
97-
IfcGeom::Kernel::convert((IfcSchema::IfcAxis2Placement3D*)placement,trsf);
96+
if (placement->as<IfcSchema::IfcAxis2Placement3D>()) {
97+
IfcGeom::Kernel::convert(placement->as<IfcSchema::IfcAxis2Placement3D>(),trsf);
9898
} else {
9999
gp_Trsf2d trsf2d;
100-
IfcGeom::Kernel::convert((IfcSchema::IfcAxis2Placement2D*)placement,trsf2d);
100+
IfcGeom::Kernel::convert(placement->as<IfcSchema::IfcAxis2Placement2D>(),trsf2d);
101101
trsf = trsf2d;
102102
}
103103
gp_Ax2 ax = gp_Ax2().Transformed(trsf);
@@ -117,14 +117,16 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcEllipse* l, Handle(Geom_Curve)
117117
// when creating a trimmed curve off of an ellipse like this.
118118
const bool rotated = y > x;
119119
gp_Trsf trsf;
120+
120121
IfcSchema::IfcAxis2Placement* placement = l->Position();
121-
if (placement->declaration().is(IfcSchema::IfcAxis2Placement3D::Class())) {
122-
convert((IfcSchema::IfcAxis2Placement3D*)placement,trsf);
122+
if (placement->as<IfcSchema::IfcAxis2Placement3D>()) {
123+
IfcGeom::Kernel::convert(placement->as<IfcSchema::IfcAxis2Placement3D>(), trsf);
123124
} else {
124125
gp_Trsf2d trsf2d;
125-
convert((IfcSchema::IfcAxis2Placement2D*)placement,trsf2d);
126+
IfcGeom::Kernel::convert(placement->as<IfcSchema::IfcAxis2Placement2D>(), trsf2d);
126127
trsf = trsf2d;
127128
}
129+
128130
gp_Ax2 ax = gp_Ax2();
129131
if (rotated) {
130132
ax.Rotate(ax.Axis(), M_PI / 2.);

src/ifcgeom/IfcGeomFunctions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3445,8 +3445,8 @@ const IfcSchema::IfcRepresentationItem* IfcGeom::Kernel::find_item_carrying_styl
34453445
while (item->declaration().is(IfcSchema::IfcBooleanResult::Class())) {
34463446
// All instantiations of IfcBooleanOperand (type of FirstOperand) are subtypes of
34473447
// IfcGeometricRepresentationItem
3448-
item = (IfcSchema::IfcGeometricRepresentationItem*) ((IfcSchema::IfcBooleanResult*) item)->FirstOperand();
3449-
if (item->StyledByItem()->size()) {
3448+
item = item->as<IfcSchema::IfcBooleanResult>()->FirstOperand()->as<IfcSchema::IfcRepresentationItem>();
3449+
if (item && item->StyledByItem()->size()) {
34503450
return item;
34513451
}
34523452
}

src/ifcgeom/IfcGeomHelpers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& t
429429
for (;;) {
430430
gp_Trsf trsf2;
431431
IfcSchema::IfcAxis2Placement* relplacement = current->RelativePlacement();
432-
if ( relplacement->declaration().is(IfcSchema::IfcAxis2Placement3D::Class()) ) {
433-
IfcGeom::Kernel::convert((IfcSchema::IfcAxis2Placement3D*)relplacement,trsf2);
432+
if (relplacement->as<IfcSchema::IfcAxis2Placement3D>()) {
433+
IfcGeom::Kernel::convert(relplacement->as<IfcSchema::IfcAxis2Placement3D>(),trsf2);
434434
trsf.PreMultiply(trsf2);
435435
}
436436
if ( current->PlacementRelTo() ) {
@@ -444,7 +444,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& t
444444

445445
if ( parentPlacesType ) break;
446446
else if ( parent->declaration().is(IfcSchema::IfcLocalPlacement::Class()) )
447-
current = (IfcSchema::IfcLocalPlacement*)current->PlacementRelTo();
447+
current = current->PlacementRelTo()->as<IfcSchema::IfcLocalPlacement>();
448448
else break;
449449
} else break;
450450
}

src/ifcopenshell-python/ifcopenshell/express/implementation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def find_template(arg):
115115
"index": arg["index"] - 1,
116116
"type": arg["full_type"].replace("::Value", ""),
117117
"non_optional_type": arg["non_optional_type"].replace("::Value", ""),
118+
"non_optional_type_no_pointer": arg["non_optional_type"].replace("::Value", "").replace("*", ""),
118119
"list_instance_type": arg["list_instance_type"],
119120
"null_check": null_check
120121
},

src/ifcopenshell-python/ifcopenshell/express/templates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class IFC_PARSE_API %(name)s : %(superclass)s {
243243

244244
get_attr_stmt = "%(null_check)s %(non_optional_type)s v = *data_->getArgument(%(index)d); return v;"
245245
get_attr_stmt_enum = "%(null_check)s return %(non_optional_type)s::FromString(*data_->getArgument(%(index)d));"
246-
get_attr_stmt_entity = "%(null_check)s return (%(non_optional_type)s)((IfcUtil::IfcBaseClass*)(*data_->getArgument(%(index)d)));"
246+
get_attr_stmt_entity = "%(null_check)s return ((IfcUtil::IfcBaseClass*)(*data_->getArgument(%(index)d)))->as<%(non_optional_type_no_pointer)s>();"
247247
get_attr_stmt_array = (
248248
"%(null_check)s aggregate_of_instance::ptr es = *data_->getArgument(%(index)d); return es->as< %(list_instance_type)s >();"
249249
)

src/ifcparse/Ifc2x3.cpp

Lines changed: 353 additions & 353 deletions
Large diffs are not rendered by default.

src/ifcparse/Ifc4.cpp

Lines changed: 327 additions & 327 deletions
Large diffs are not rendered by default.

src/ifcparse/Ifc4x1.cpp

Lines changed: 338 additions & 338 deletions
Large diffs are not rendered by default.

src/ifcparse/Ifc4x2.cpp

Lines changed: 339 additions & 339 deletions
Large diffs are not rendered by default.

src/ifcparse/Ifc4x3_rc1.cpp

Lines changed: 352 additions & 352 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)