Advanced brep, sweeps and various fixes #4848 #4895

This commit is contained in:
Thomas Krijnen
2024-07-03 14:36:35 +02:00
parent 9485190604
commit d4efcd40f9
19 changed files with 537 additions and 219 deletions
+7 -1
View File
@@ -40,7 +40,13 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcEdge* inst) {
e->end = taxonomy::cast<taxonomy::point3>(map(pnt2));
if (inst->as<IfcSchema::IfcEdgeCurve>()) {
e->basis = map(inst->as<IfcSchema::IfcEdgeCurve>()->EdgeGeometry());
auto basis = map(inst->as<IfcSchema::IfcEdgeCurve>()->EdgeGeometry());
auto loop = taxonomy::dcast<taxonomy::loop>(basis);
if (loop && loop->children.size() == 1) {
loop->calculate_linear_edge_curves();
basis = loop->children[0]->basis;
}
e->basis = basis;
e->curve_sense = inst->as<IfcSchema::IfcEdgeCurve>()->SameSense();
}
+7
View File
@@ -41,6 +41,13 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcFace* inst) {
face->children.push_back(r);
}
}
auto face_surface = inst->as<IfcSchema::IfcFaceSurface>();
if (face_surface) {
face->basis = map(face_surface->FaceSurface());
}
if (face->children.empty()) {
#ifdef TAXONOMY_USE_NAKED_PTR
delete face;
@@ -33,7 +33,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceCurveSweptAreaSolid*
matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
auto scs = taxonomy::make<taxonomy::surface_curve_sweep>(matrix, f, map(inst->ReferenceSurface()), map(inst->Directrix()));
auto scs = taxonomy::make<taxonomy::sweep_along_curve>(matrix, f, map(inst->ReferenceSurface()), map(inst->Directrix()));
scs->matrix = matrix;
return scs;
@@ -23,37 +23,19 @@ using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceOfLinearExtrusion* inst) {
return nullptr;
/*
TopoDS_Wire wire;
if ( !convert_wire(inst->SweptCurve(), wire) ) {
TopoDS_Face face;
if ( !convert_face(inst->SweptCurve(),face) ) return false;
TopExp_Explorer exp(face, TopAbs_WIRE);
wire = TopoDS::Wire(exp.Current());
}
const double height = inst->Depth() * length_unit_;
gp_Trsf trsf;
taxonomy::matrix4::ptr matrix;
bool has_position = true;
#ifdef SCHEMA_IfcSweptSurface_Position_IS_OPTIONAL
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = inst->Position() != nullptr;
#endif
if (has_position) {
IfcGeom::Kernel::convert(inst->Position(), trsf);
matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
gp_Dir dir;
convert(inst->ExtrudedDirection(),dir);
shape = BRepPrimAPI_MakePrism(wire, height*dir);
if (has_position) {
// IfcSweptSurface.Position (trsf) is an IfcAxis2Placement3D
// and therefore has a unit scale factor
shape.Move(trsf);
}
return !shape.IsNull();
*/
return taxonomy::make<taxonomy::extrusion>(
matrix,
taxonomy::cast<taxonomy::loop>(map(inst->SweptCurve())),
taxonomy::cast<taxonomy::direction3>(map(inst->ExtrudedDirection())),
std::numeric_limits<double>::infinity()
);
}
+10 -27
View File
@@ -22,37 +22,20 @@
using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceOfRevolution* inst) {
return nullptr;
/*
TopoDS_Wire wire;
if ( !convert_wire(inst->SweptCurve(), wire) ) {
TopoDS_Face face;
if ( !convert_face(inst->SweptCurve(),face) ) return false;
TopExp_Explorer exp(face, TopAbs_WIRE);
wire = TopoDS::Wire(exp.Current());
}
gp_Ax1 ax1;
IfcGeom::Kernel::convert(inst->AxisPosition(), ax1);
gp_Trsf trsf;
taxonomy::matrix4::ptr matrix;
bool has_position = true;
#ifdef SCHEMA_IfcSweptSurface_Position_IS_OPTIONAL
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = inst->Position() != nullptr;
#endif
if (has_position) {
IfcGeom::Kernel::convert(inst->Position(), trsf);
}
shape = BRepPrimAPI_MakeRevol(wire, ax1);
if (has_position) {
// IfcSweptSurface.Position (trsf) is an IfcAxis2Placement3D
// and therefore has a unit scale factor
shape.Move(trsf);
matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
}
return !shape.IsNull();
*/
return taxonomy::make<taxonomy::revolve>(
matrix,
taxonomy::cast<taxonomy::loop>(map(inst->SweptCurve())),
taxonomy::cast<taxonomy::point3>(map(inst->AxisPosition()->Location())),
taxonomy::cast<taxonomy::direction3>(map(inst->AxisPosition()->Axis())),
boost::none
);
}
+3 -1
View File
@@ -94,6 +94,8 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSweptDiskSolid* inst) {
e->basis = c;
e->start = 0.;
e->end = 2 * boost::math::constants::pi<double>();
// @todo allow identity by leaving unspecified?
c->matrix = taxonomy::make<taxonomy::matrix4>();
auto l = taxonomy::make<taxonomy::loop>();
l->children = { e };
@@ -103,7 +105,7 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSweptDiskSolid* inst) {
}
}
return taxonomy::make<taxonomy::surface_curve_sweep>(taxonomy::make<taxonomy::matrix4>(), f, nullptr, loop);
return taxonomy::make<taxonomy::sweep_along_curve>(taxonomy::make<taxonomy::matrix4>(), f, nullptr, loop);