Skeleton for IfcObjectPlacement and IfcAxis2Placement3D

This commit is contained in:
Ken Arroyo Ohori
2017-02-07 19:51:16 -06:00
parent bae84b6753
commit 96e9c8ecc1
3 changed files with 48 additions and 2 deletions
@@ -49,3 +49,46 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcDirection* l, cgal_directi
return true;
}
bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcAxis2Placement3D* l, cgal_placement_t& trsf) {
// IN_CACHE(IfcAxis2Placement3D,l,gp_Trsf,trsf)
// cgal_point_t o;cgal_direction_t axis = new Kernel::Vector_3(0,0,1);cgal_direction_t refDirection;
// IfcGeom::OpenCascadeKernel::convert(l->Location(),o);
// bool hasRef = l->hasRefDirection();
// if ( l->hasAxis() ) IfcGeom::OpenCascadeKernel::convert(l->Axis(),axis);
// if ( hasRef ) IfcGeom::OpenCascadeKernel::convert(l->RefDirection(),refDirection);
// gp_Ax3 ax3;
// if ( hasRef ) ax3 = gp_Ax3(o,axis,refDirection);
// else ax3 = gp_Ax3(o,axis);
//
// if (!axis_equal(ax3, (gp_Ax3) gp::XOY(), getValue(GV_PRECISION))) {
// trsf.SetTransformation(ax3, gp::XOY());
// }
//
// CACHE(IfcAxis2Placement3D,l,trsf)
return true;
}
bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcObjectPlacement* l, cgal_placement_t& trsf) {
// IN_CACHE(IfcObjectPlacement,l,cgal_placement_t,trsf)
if ( ! l->is(IfcSchema::Type::IfcLocalPlacement) ) {
Logger::Message(Logger::LOG_ERROR, "Unsupported IfcObjectPlacement:", l->entity);
return false;
}
IfcSchema::IfcLocalPlacement* current = (IfcSchema::IfcLocalPlacement*)l;
for (;;) {
cgal_placement_t trsf2;
IfcSchema::IfcAxis2Placement* relplacement = current->RelativePlacement();
if ( relplacement->is(IfcSchema::Type::IfcAxis2Placement3D) ) {
IfcGeom::CgalKernel::convert((IfcSchema::IfcAxis2Placement3D*)relplacement,trsf2);
*trsf = *trsf * *trsf2; // TODO: Or should it be the other way around?
}
if ( current->hasPlacementRelTo() ) {
IfcSchema::IfcObjectPlacement* relto = current->PlacementRelTo();
if ( relto->is(IfcSchema::Type::IfcLocalPlacement) )
current = (IfcSchema::IfcLocalPlacement*)current->PlacementRelTo();
else break;
} else break;
}
// CACHE(IfcObjectPlacement,l,trsf)
return true;
}
@@ -44,3 +44,6 @@ WIRE(IfcPolyLoop);
CLASS(IfcCartesianPoint,cgal_point_t);
CLASS(IfcDirection,cgal_direction_t);
//CLASS(IfcAxis2Placement2D,cgal_placement_t);
CLASS(IfcAxis2Placement3D,cgal_placement_t);
CLASS(IfcObjectPlacement,cgal_placement_t);
+2 -2
View File
@@ -94,7 +94,7 @@ IfcGeom::NativeElement<double>* IfcGeom::CgalKernel::create_brep_for_representat
cgal_placement_t trsf;
try {
// convert(product->ObjectPlacement(), trsf);
convert(product->ObjectPlacement(), trsf);
} catch (...) {}
// Does the IfcElement have any IfcOpenings?
@@ -146,7 +146,7 @@ IfcGeom::NativeElement<double>* IfcGeom::CgalKernel::create_brep_for_processed_r
cgal_placement_t trsf;
try {
// convert(product->ObjectPlacement(), trsf);
convert(product->ObjectPlacement(), trsf);
} catch (...) {}
std::string context_string = "";