mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-15 18:14:08 +00:00
@@ -354,6 +354,10 @@ namespace {
|
||||
double u;
|
||||
typedef void result_type;
|
||||
|
||||
void operator()(const boost::blank&) {
|
||||
throw std::runtime_error("Unbounded curve not supported here");
|
||||
}
|
||||
|
||||
void operator()(const taxonomy::point3::ptr& p) {
|
||||
point_projection_visitor_ v{ *p };
|
||||
dispatch_curve_creation<point_projection_visitor_>::dispatch(curve, v);
|
||||
@@ -1121,7 +1125,7 @@ bool CgalKernel::convert(const taxonomy::extrusion::ptr extrusion, cgal_shape_t
|
||||
}
|
||||
|
||||
std::list<cgal_face_t> bottom_face;
|
||||
if (!convert(extrusion->basis, bottom_face) || bottom_face.size() != 1) {
|
||||
if (!convert(taxonomy::cast<taxonomy::face>(taxonomy::cast<taxonomy::face>(extrusion->basis)), bottom_face) || bottom_face.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1542,8 +1546,9 @@ bool CgalKernel::process_as_2d_polygon(const taxonomy::boolean_result::ptr br, s
|
||||
try {
|
||||
std::transform(extrusions.begin(), extrusions.end(), std::back_inserter(wires), [this](extrusion_pair& p) {
|
||||
auto ex = p.second;
|
||||
if (ex->basis->children.size() == 1 && ex->basis->children[0]->kind() == taxonomy::LOOP) {
|
||||
auto l = (taxonomy::loop::ptr) ex->basis->children[0];
|
||||
auto ex_basis = taxonomy::cast<taxonomy::face>(ex->basis);
|
||||
if (ex_basis->children.size() == 1 && ex_basis->children[0]->kind() == taxonomy::LOOP) {
|
||||
auto l = (taxonomy::loop::ptr) ex_basis->children[0];
|
||||
cgal_wire_t w;
|
||||
cgal_placement_t trsf;
|
||||
convert_placement(ex->matrix, trsf);
|
||||
|
||||
@@ -135,6 +135,7 @@ public:
|
||||
bool convert(const ifcopenshell::geometry::taxonomy::solid::ptr, TopoDS_Shape&);
|
||||
bool convert(const ifcopenshell::geometry::taxonomy::loft::ptr, TopoDS_Shape&);
|
||||
bool convert(const ifcopenshell::geometry::taxonomy::bspline_surface::ptr bs, Handle(Geom_Surface) surf);
|
||||
bool convert(const ifcopenshell::geometry::taxonomy::sweep_along_curve::ptr, TopoDS_Shape&);
|
||||
|
||||
virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::edge::ptr, IfcGeom::ConversionResults&);
|
||||
virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::loop::ptr, IfcGeom::ConversionResults&);
|
||||
@@ -144,10 +145,15 @@ public:
|
||||
virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::extrusion::ptr, IfcGeom::ConversionResults&);
|
||||
virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::boolean_result::ptr, IfcGeom::ConversionResults&);
|
||||
virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::loft::ptr, IfcGeom::ConversionResults&);
|
||||
virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::sweep_along_curve::ptr, IfcGeom::ConversionResults&);
|
||||
|
||||
virtual bool convert_openings(const IfcUtil::IfcBaseEntity* entity, const std::vector<std::pair<ifcopenshell::geometry::taxonomy::ptr, ifcopenshell::geometry::taxonomy::matrix4>>& openings,
|
||||
const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes);
|
||||
|
||||
typedef boost::variant<Handle(Geom_Curve), TopoDS_Wire> curve_creation_visitor_result_type;
|
||||
curve_creation_visitor_result_type convert_curve(const ifcopenshell::geometry::taxonomy::ptr);
|
||||
Handle(Geom_Surface) convert_surface(const ifcopenshell::geometry::taxonomy::ptr);
|
||||
|
||||
template <typename T, typename U>
|
||||
static T convert_xyz(const U& u) {
|
||||
const auto& vs = u.ccomponents();
|
||||
|
||||
@@ -15,7 +15,7 @@ bool OpenCascadeKernel::convert(const taxonomy::extrusion::ptr extrusion, TopoDS
|
||||
}
|
||||
|
||||
TopoDS_Shape face;
|
||||
if (!convert(extrusion->basis, face)) {
|
||||
if (!convert(taxonomy::cast<taxonomy::face>(extrusion->basis), face)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,17 @@
|
||||
#include <Message_Msg.hxx>
|
||||
#include <ShapeFix_Edge.hxx>
|
||||
#include <BRepPrimAPI_MakeHalfSpace.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#include <Geom_CylindricalSurface.hxx>
|
||||
#include <Geom_SphericalSurface.hxx>
|
||||
#include <Geom_ToroidalSurface.hxx>
|
||||
#include <BRepAdaptor_CompCurve.hxx>
|
||||
#include <Approx_Curve3d.hxx>
|
||||
#include <BRepAdaptor_HCompCurve.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include <Geom_SurfaceOfLinearExtrusion.hxx>
|
||||
#include <Geom_SurfaceOfRevolution.hxx>
|
||||
#include <BRepPrimAPI_MakeRevol.hxx>
|
||||
|
||||
#include "OpenCascadeKernel.h"
|
||||
#include "face_definition.h"
|
||||
@@ -48,6 +59,173 @@ using namespace ifcopenshell::geometry::kernels;
|
||||
using namespace IfcGeom;
|
||||
using namespace IfcGeom::util;
|
||||
|
||||
|
||||
namespace {
|
||||
struct surface_creation_visitor {
|
||||
OpenCascadeKernel* kernel;
|
||||
Handle(Geom_Surface) result;
|
||||
|
||||
Handle(Geom_Surface) operator()(const taxonomy::bspline_surface::ptr& bs) {
|
||||
auto& cps = bs->control_points;
|
||||
if (!cps.size() || !cps[0].size()) {
|
||||
throw std::runtime_error("Empty control point array");
|
||||
}
|
||||
|
||||
auto& uknots = bs->knots[0];
|
||||
auto& vknots = bs->knots[1];
|
||||
auto& umults = bs->multiplicities[0];
|
||||
auto& vmults = bs->multiplicities[1];
|
||||
|
||||
TColgp_Array2OfPnt Poles(0, (int)cps.size() - 1, 0, (int)cps[0].size() - 1);
|
||||
TColStd_Array1OfReal UKnots(0, (int)uknots.size() - 1);
|
||||
TColStd_Array1OfReal VKnots(0, (int)vknots.size() - 1);
|
||||
TColStd_Array1OfInteger UMults(0, (int)umults.size() - 1);
|
||||
TColStd_Array1OfInteger VMults(0, (int)vmults.size() - 1);
|
||||
Standard_Integer UDegree = bs->degree[0];
|
||||
Standard_Integer VDegree = bs->degree[1];
|
||||
|
||||
int i = 0, j;
|
||||
for (auto it = cps.begin(); it != cps.end(); ++it, ++i) {
|
||||
j = 0;
|
||||
for (auto jt = (*it).begin(); jt != (*it).end(); ++jt, ++j) {
|
||||
Poles(i, j) = kernel->convert_xyz<gp_Pnt>(**jt);
|
||||
}
|
||||
}
|
||||
i = 0;
|
||||
for (std::vector<double>::const_iterator it = uknots.begin(); it != uknots.end(); ++it, ++i) {
|
||||
UKnots(i) = *it;
|
||||
}
|
||||
i = 0;
|
||||
for (std::vector<double>::const_iterator it = vknots.begin(); it != vknots.end(); ++it, ++i) {
|
||||
VKnots(i) = *it;
|
||||
}
|
||||
i = 0;
|
||||
for (std::vector<int>::const_iterator it = umults.begin(); it != umults.end(); ++it, ++i) {
|
||||
UMults(i) = *it;
|
||||
}
|
||||
i = 0;
|
||||
for (std::vector<int>::const_iterator it = vmults.begin(); it != vmults.end(); ++it, ++i) {
|
||||
VMults(i) = *it;
|
||||
}
|
||||
return result = Handle(Geom_Surface)(new Geom_BSplineSurface(Poles, UKnots, VKnots, UMults, VMults, UDegree, VDegree));
|
||||
}
|
||||
|
||||
Handle(Geom_Surface) operator()(const taxonomy::plane::ptr& p) {
|
||||
const auto& m = p->matrix->ccomponents();
|
||||
return result = Handle(Geom_Surface)(new Geom_Plane(
|
||||
OpenCascadeKernel::convert_xyz2<gp_Pnt>(m.col(3)),
|
||||
OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(2))));
|
||||
}
|
||||
|
||||
Handle(Geom_Surface) operator()(const taxonomy::cylinder::ptr& c) {
|
||||
const auto& m = c->matrix->ccomponents();
|
||||
return result = Handle(Geom_Surface)(new Geom_CylindricalSurface(gp_Ax3(
|
||||
OpenCascadeKernel::convert_xyz2<gp_Pnt>(m.col(3)),
|
||||
OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(2)),
|
||||
OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(0))
|
||||
), c->radius));
|
||||
}
|
||||
|
||||
Handle(Geom_Surface) operator()(const taxonomy::sphere::ptr& s) {
|
||||
const auto& m = s->matrix->ccomponents();
|
||||
return result = Handle(Geom_Surface)(new Geom_SphericalSurface(gp_Ax3(
|
||||
OpenCascadeKernel::convert_xyz2<gp_Pnt>(m.col(3)),
|
||||
OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(2)),
|
||||
OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(0))
|
||||
), s->radius));
|
||||
}
|
||||
|
||||
Handle(Geom_Surface) operator()(const taxonomy::torus::ptr& t) {
|
||||
const auto& m = t->matrix->ccomponents();
|
||||
return result = Handle(Geom_Surface)(new Geom_ToroidalSurface(gp_Ax3(
|
||||
OpenCascadeKernel::convert_xyz2<gp_Pnt>(m.col(3)),
|
||||
OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(2)),
|
||||
OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(0))
|
||||
), t->radius1, t->radius2));
|
||||
}
|
||||
|
||||
TopoDS_Wire get_edges_as_wire(const taxonomy::item::ptr& i) {
|
||||
// It's a bit more convenient to use high level BRepPrimAPI calls that operate on
|
||||
// topology. On a single edge that will create a Geom_TrimmedCurve for us.
|
||||
auto crv_or_wire = kernel->convert_curve(i);
|
||||
if (crv_or_wire.which() == 1) {
|
||||
const auto& w = boost::get<TopoDS_Wire>(crv_or_wire);
|
||||
return w;
|
||||
} else {
|
||||
throw std::runtime_error("Unexpected curve evaluation");
|
||||
}
|
||||
}
|
||||
|
||||
Handle(Geom_Curve) get_curve(const taxonomy::item::ptr& i) {
|
||||
// @todo unify with trimmed curve handling
|
||||
auto crv_or_wire = kernel->convert_curve(i);
|
||||
if (crv_or_wire.which() == 0) {
|
||||
return boost::get<Handle(Geom_Curve)>(crv_or_wire);
|
||||
} else {
|
||||
// @todo
|
||||
const double precision_ = 1.e-5;
|
||||
Logger::Warning("Approximating BasisCurve due to possible discontinuities", i->instance);
|
||||
const auto& w = boost::get<TopoDS_Wire>(crv_or_wire);
|
||||
#if OCC_VERSION_HEX < 0x70600
|
||||
BRepAdaptor_CompCurve cc(w, true);
|
||||
Handle(Adaptor3d_HCurve) hcc = Handle(Adaptor3d_HCurve)(new BRepAdaptor_HCompCurve(cc));
|
||||
#else
|
||||
auto hcc = new BRepAdaptor_CompCurve(w, true);
|
||||
#endif
|
||||
// @todo, arbitrary numbers here, note they cannot be too high as contiguous memory is allocated based on them.
|
||||
Approx_Curve3d approx(hcc, precision_, GeomAbs_C0, 10, 10);
|
||||
return approx.Curve();
|
||||
}
|
||||
}
|
||||
|
||||
Handle(Geom_Surface) operator()(const taxonomy::extrusion::ptr& e) {
|
||||
auto crv = get_curve(e->basis);
|
||||
return result = Handle(Geom_Surface)(new Geom_SurfaceOfLinearExtrusion(
|
||||
crv,
|
||||
OpenCascadeKernel::convert_xyz<gp_Dir>(*e->direction)
|
||||
));
|
||||
}
|
||||
|
||||
Handle(Geom_Surface) operator()(const taxonomy::revolve::ptr& e) {
|
||||
gp_Ax1 ax(
|
||||
OpenCascadeKernel::convert_xyz<gp_Pnt>(*e->axis_origin),
|
||||
OpenCascadeKernel::convert_xyz<gp_Dir>(*e->direction));
|
||||
|
||||
if (e->basis && (e->basis->kind() == taxonomy::EDGE || (e->basis->kind() == taxonomy::LOOP && taxonomy::cast<taxonomy::loop>(e->basis)->children.size() == 1))) {
|
||||
auto e_basis = e->basis;
|
||||
if ((e->basis->kind() == taxonomy::LOOP)) {
|
||||
e_basis = taxonomy::cast<taxonomy::loop>(e->basis)->children[0];
|
||||
}
|
||||
auto w = get_edges_as_wire(e_basis);
|
||||
TopoDS_Shape shp = BRepPrimAPI_MakeRevol(w, ax);
|
||||
TopExp_Explorer exp(shp, TopAbs_FACE);
|
||||
if (exp.More()) {
|
||||
Handle(Geom_Surface) surf = BRep_Tool::Surface(TopoDS::Face(exp.Current()));
|
||||
exp.Next();
|
||||
if (!exp.More()) {
|
||||
return result = surf;
|
||||
}
|
||||
}
|
||||
// fall back to approach below
|
||||
}
|
||||
|
||||
auto crv = get_curve(e->basis);
|
||||
return result = Handle(Geom_Surface)(new Geom_SurfaceOfRevolution(
|
||||
crv, ax
|
||||
));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Handle(Geom_Surface) OpenCascadeKernel::convert_surface(const taxonomy::ptr surface) {
|
||||
surface_creation_visitor v{ this };
|
||||
if (dispatch_surface_creation<surface_creation_visitor, 0>::dispatch(surface, v)) {
|
||||
return v.result;
|
||||
} else {
|
||||
throw std::runtime_error("No surface created");
|
||||
}
|
||||
}
|
||||
|
||||
bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& result) {
|
||||
#ifdef IFOPSH_DEBUG
|
||||
std::ostringstream oss;
|
||||
@@ -58,24 +236,9 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
|
||||
|
||||
face_definition fd;
|
||||
|
||||
const bool is_face_surface = false; /* todo */
|
||||
|
||||
/*
|
||||
if (is_face_surface) {
|
||||
IfcSchema::IfcFaceSurface* fs = (IfcSchema::IfcFaceSurface*) l;
|
||||
fs->FaceSurface();
|
||||
// FIXME: Surfaces are interpreted as a TopoDS_Shape
|
||||
TopoDS_Shape surface_shape;
|
||||
if (!convert_shape(fs->FaceSurface(), surface_shape)) return false;
|
||||
|
||||
// FIXME: Assert this obtains the only face
|
||||
TopExp_Explorer exp(surface_shape, TopAbs_FACE);
|
||||
if (!exp.More()) return false;
|
||||
|
||||
TopoDS_Face surface = TopoDS::Face(exp.Current());
|
||||
fd.surface() = BRep_Tool::Surface(surface);
|
||||
if (face->basis) {
|
||||
fd.surface() = convert_surface(face->basis);
|
||||
}
|
||||
*/
|
||||
|
||||
const int num_bounds = face->children.size();
|
||||
int num_outer_bounds = 0;
|
||||
@@ -198,11 +361,22 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
|
||||
if (fd.all_outer()) {
|
||||
for (const auto& w : fd.wires()) {
|
||||
TopTools_ListOfShape fl;
|
||||
triangulate_wire({ w }, fl);
|
||||
auto r = triangulate_wire({ w }, fl);
|
||||
if (r == util::TRIANGULATE_WIRE_FAIL) {
|
||||
continue;
|
||||
}
|
||||
face_list.Append(fl);
|
||||
if (faceset_helper_ && r == util::TRIANGULATE_WIRE_NON_MANIFOLD) {
|
||||
faceset_helper_->non_manifold() = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
triangulate_wire(fd.wires(), face_list);
|
||||
auto r = triangulate_wire(fd.wires(), face_list);
|
||||
if (r != util::TRIANGULATE_WIRE_FAIL) {
|
||||
if (faceset_helper_ && r == util::TRIANGULATE_WIRE_NON_MANIFOLD) {
|
||||
faceset_helper_->non_manifold() = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!fd.all_outer()) {
|
||||
BRepBuilderAPI_MakeFace mf(fd.surface(), fd.outer_wire());
|
||||
@@ -210,13 +384,20 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
|
||||
if (mf.IsDone()) {
|
||||
// Is this necessary
|
||||
TopoDS_Face f = mf.Face();
|
||||
mf.Init(f);
|
||||
if (std::distance(fd.inner_wires().first, fd.inner_wires().second)) {
|
||||
mf.Init(f);
|
||||
|
||||
for (auto it = fd.inner_wires().first; it != fd.inner_wires().second; ++it) {
|
||||
mf.Add(*it);
|
||||
for (auto it = fd.inner_wires().first; it != fd.inner_wires().second; ++it) {
|
||||
mf.Add(*it);
|
||||
}
|
||||
|
||||
face_list.Append(mf.Face());
|
||||
} else {
|
||||
face_list.Append(f);
|
||||
}
|
||||
|
||||
face_list.Append(mf.Face());
|
||||
} else {
|
||||
Logger::Error("Internal error in face creation");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
for (const auto& w : fd.wires()) {
|
||||
@@ -237,12 +418,24 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
|
||||
// For planar faces, Open Cascade generates p-curves on the fly.
|
||||
|
||||
for (TopTools_ListIteratorOfListOfShape it(face_list); it.More(); it.Next()) {
|
||||
// Small chance there are multiple faces
|
||||
const TopoDS_Face& occ_face = TopoDS::Face(it.Value());
|
||||
for (TopExp_Explorer exp2(occ_face, TopAbs_EDGE); exp2.More(); exp2.Next()) {
|
||||
const TopoDS_Edge& edge = TopoDS::Edge(exp2.Current());
|
||||
ShapeFix_Edge fix_edge;
|
||||
fix_edge.FixAddPCurve(edge, occ_face, false, precision_);
|
||||
ShapeFix_Shape sfs(it.Value());
|
||||
|
||||
Handle(ShapeExtend_MsgRegistrator) msg;
|
||||
msg = new ShapeExtend_MsgRegistrator;
|
||||
sfs.SetMsgRegistrator(msg);
|
||||
|
||||
sfs.Perform();
|
||||
it.Value() = sfs.Shape();
|
||||
|
||||
ShapeExtend_DataMapIteratorOfDataMapOfShapeListOfMsg jt(msg->MapShape());
|
||||
for (; jt.More(); jt.Next()) {
|
||||
Message_ListIteratorOfListOfMsg kt(jt.Value());
|
||||
for (; kt.More(); kt.Next()) {
|
||||
char* c = new char[kt.Value().Value().LengthOfCString() + 1];
|
||||
kt.Value().Value().ToUTF8CString(c);
|
||||
Logger::Notice(c, face->instance);
|
||||
delete[] c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,14 +30,11 @@ using namespace IfcGeom;
|
||||
using namespace IfcGeom::util;
|
||||
|
||||
namespace {
|
||||
typedef boost::variant<Handle(Geom_Curve), TopoDS_Wire> curve_creation_visitor_result_type;
|
||||
curve_creation_visitor_result_type convert_curve(OpenCascadeKernel* kernel, const taxonomy::ptr curve);
|
||||
|
||||
struct curve_creation_visitor {
|
||||
OpenCascadeKernel* kernel;
|
||||
curve_creation_visitor_result_type result;
|
||||
OpenCascadeKernel::curve_creation_visitor_result_type result;
|
||||
|
||||
curve_creation_visitor_result_type operator()(const taxonomy::bspline_curve::ptr& bc) {
|
||||
OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::bspline_curve::ptr& bc) {
|
||||
|
||||
const bool is_rational = !!bc->weights;
|
||||
|
||||
@@ -81,28 +78,28 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
curve_creation_visitor_result_type operator()(const taxonomy::line::ptr& l) {
|
||||
OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::line::ptr& l) {
|
||||
const auto& m = l->matrix->ccomponents();
|
||||
return result = Handle(Geom_Curve)(new Geom_Line(OpenCascadeKernel::convert_xyz2<gp_Pnt>(m.col(3)), OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(2))));
|
||||
}
|
||||
|
||||
curve_creation_visitor_result_type operator()(const taxonomy::circle::ptr& c) {
|
||||
OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::circle::ptr& c) {
|
||||
const auto& m = c->matrix->ccomponents();
|
||||
return result = Handle(Geom_Curve)(new Geom_Circle(gp_Ax2(OpenCascadeKernel::convert_xyz2<gp_Pnt>(m.col(3)), OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(2)), OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(0))), c->radius));
|
||||
}
|
||||
|
||||
curve_creation_visitor_result_type operator()(const taxonomy::ellipse::ptr& e) {
|
||||
OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::ellipse::ptr& e) {
|
||||
const auto& m = e->matrix->ccomponents();
|
||||
return result = Handle(Geom_Curve)(new Geom_Ellipse(gp_Ax2(OpenCascadeKernel::convert_xyz2<gp_Pnt>(m.col(3)), OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(2)), OpenCascadeKernel::convert_xyz2<gp_Dir>(m.col(0))), e->radius, e->radius2));
|
||||
}
|
||||
|
||||
curve_creation_visitor_result_type operator()(const taxonomy::loop::ptr& l) {
|
||||
OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::loop::ptr& l) {
|
||||
TopoDS_Wire wire;
|
||||
kernel->convert(l, wire);
|
||||
return result = wire;
|
||||
}
|
||||
|
||||
curve_creation_visitor_result_type operator()(const taxonomy::edge::ptr& e) {
|
||||
OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::edge::ptr& e) {
|
||||
// @todo for polyloops/-lines we should probably construct edges based on correct oriented TopoDS_Vertex instead.
|
||||
|
||||
if (e->start.which() != e->end.which()) {
|
||||
@@ -117,7 +114,7 @@ namespace {
|
||||
// to make sure we select the correct arc later on.
|
||||
e_basis = taxonomy::cast<taxonomy::edge>(e_basis)->basis;
|
||||
}
|
||||
auto crv_or_wire = convert_curve(kernel, e_basis);
|
||||
auto crv_or_wire = kernel->convert_curve(e_basis);
|
||||
Handle(Geom_Curve) curve;
|
||||
if (crv_or_wire.which() == 0) {
|
||||
curve = boost::get<Handle(Geom_Curve)>(crv_or_wire);
|
||||
@@ -149,15 +146,17 @@ namespace {
|
||||
|
||||
// @todo, copy over logic from previous IfcTrimmedCurve handling
|
||||
if (e_start.which() == 0) {
|
||||
E = BRepBuilderAPI_MakeEdge(curve).Edge();
|
||||
} else if (e_start.which() == 1) {
|
||||
auto p1 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*boost::get<taxonomy::point3::ptr>(e_start));
|
||||
auto p2 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*boost::get<taxonomy::point3::ptr>(e_end));
|
||||
|
||||
E = BRepBuilderAPI_MakeEdge(curve, p1, p2).Edge();
|
||||
} else {
|
||||
} else if (e_start.which() == 2) {
|
||||
auto v1 = boost::get<double>(e_start);
|
||||
auto v2 = boost::get<double>(e_end);
|
||||
|
||||
if (is_conic && ALMOST_THE_SAME(fmod(v2 - v1, M_PI*2.), 0.)) {
|
||||
if (is_conic && ALMOST_THE_SAME(fmod(v2 - v1, M_PI * 2.), 0.)) {
|
||||
E = BRepBuilderAPI_MakeEdge(curve).Edge();
|
||||
} else {
|
||||
E = BRepBuilderAPI_MakeEdge(curve, v1, v2).Edge();
|
||||
@@ -176,7 +175,7 @@ namespace {
|
||||
E.Reverse();
|
||||
}
|
||||
} else {
|
||||
if (e->start.which() != 0) {
|
||||
if (e->start.which() != 1) {
|
||||
throw std::runtime_error("Non-cartesian trim on edge without curve");
|
||||
}
|
||||
auto p1 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*boost::get<taxonomy::point3::ptr>(e->start));
|
||||
@@ -203,19 +202,20 @@ namespace {
|
||||
return result = W;
|
||||
}
|
||||
|
||||
curve_creation_visitor_result_type operator()(const taxonomy::offset_curve::ptr&) {
|
||||
OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::offset_curve::ptr&) {
|
||||
// @todo
|
||||
throw std::runtime_error("Offset curves not supported as part of loop");
|
||||
}
|
||||
};
|
||||
|
||||
curve_creation_visitor_result_type convert_curve(OpenCascadeKernel* kernel, const taxonomy::ptr curve) {
|
||||
curve_creation_visitor v{ kernel };
|
||||
if (dispatch_curve_creation<curve_creation_visitor, 0>::dispatch(curve, v)) {
|
||||
return v.result;
|
||||
} else {
|
||||
throw std::runtime_error("No curve created");
|
||||
}
|
||||
}
|
||||
|
||||
OpenCascadeKernel::curve_creation_visitor_result_type OpenCascadeKernel::convert_curve(const taxonomy::ptr curve) {
|
||||
curve_creation_visitor v{ this };
|
||||
if (dispatch_curve_creation<curve_creation_visitor, 0>::dispatch(curve, v)) {
|
||||
return v.result;
|
||||
} else {
|
||||
throw std::runtime_error("No curve created");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,7 +367,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::loop::ptr loop, IfcGeom::Co
|
||||
}
|
||||
|
||||
bool OpenCascadeKernel::convert_impl(const taxonomy::edge::ptr edge, IfcGeom::ConversionResults& results) {
|
||||
TopoDS_Wire shape = boost::get<TopoDS_Wire>(convert_curve(this, edge));
|
||||
TopoDS_Wire shape = boost::get<TopoDS_Wire>(convert_curve(edge));
|
||||
|
||||
results.emplace_back(ConversionResult(
|
||||
edge->instance->data().id(),
|
||||
|
||||
@@ -15,7 +15,7 @@ bool OpenCascadeKernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& t
|
||||
);
|
||||
|
||||
if (matrix->instance && matrix->instance->declaration().name() == "IfcCartesianTransformationOperator3DnonUniform") {
|
||||
std::wcout << "non uniform" << std::endl;
|
||||
// std::wcout << "non uniform" << std::endl;
|
||||
}
|
||||
|
||||
// @nb SetVectorialPart() sets gp_GTrsf.scale to 0.0, causing an non-invertable
|
||||
|
||||
@@ -7,9 +7,28 @@ using namespace ifcopenshell::geometry::kernels;
|
||||
using namespace IfcGeom;
|
||||
using namespace IfcGeom::util;
|
||||
|
||||
namespace {
|
||||
// @todo move into taxonomy;
|
||||
bool shell_polyhedral(const taxonomy::shell::ptr& sh) {
|
||||
for (auto& f : sh->children) {
|
||||
for (auto& w : f->children) {
|
||||
if (!w->is_polyhedron()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (f->basis && f->basis->kind() != taxonomy::PLANE) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shape) {
|
||||
std::unique_ptr<faceset_helper> helper_scope;
|
||||
helper_scope.reset(new faceset_helper(this, l));
|
||||
if (shell_polyhedral(l)) {
|
||||
helper_scope.reset(new faceset_helper(this, l));
|
||||
}
|
||||
|
||||
faceset_helper_ = helper_scope.get();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user