mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 22:31:55 +00:00
Work towards v1.0 data model with encapsulated weak_ptr as basis for instances
This commit is contained in:
@@ -223,7 +223,7 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<double> smooth_treshold;
|
||||
std::optional<double> smooth_treshold;
|
||||
{
|
||||
auto setting_value = settings.get<ifcopenshell::geometry::settings::CgalSmoothAngleDegrees>().get();
|
||||
if (setting_value > 0.) {
|
||||
|
||||
@@ -180,9 +180,9 @@ namespace ifcopenshell { namespace geometry {
|
||||
class IFC_GEOMLIBRARY_API CgalShape : public IfcGeom::ConversionResultShape {
|
||||
private:
|
||||
bool convex_tag_ = false;
|
||||
mutable boost::optional<cgal_shape_t> shape_;
|
||||
mutable std::optional<cgal_shape_t> shape_;
|
||||
#ifndef IFOPSH_SIMPLE_KERNEL
|
||||
mutable boost::optional<CGAL::Nef_polyhedron_3<Kernel_>> nef_;
|
||||
mutable std::optional<CGAL::Nef_polyhedron_3<Kernel_>> nef_;
|
||||
#endif
|
||||
public:
|
||||
CgalShape(const cgal_shape_t& shape, bool convex = false);
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace {
|
||||
private:
|
||||
std::list<cgal_face_t> *face_list;
|
||||
public:
|
||||
boost::optional<cgal_shape_t> from_soup;
|
||||
std::optional<cgal_shape_t> from_soup;
|
||||
PolyhedronBuilder(std::list<cgal_face_t> *face_list);
|
||||
void operator()(CGAL::Polyhedron_3<Kernel_>::HalfedgeDS &hds);
|
||||
};
|
||||
@@ -232,7 +232,7 @@ bool CgalKernel::convert(const taxonomy::face::ptr face, std::list<cgal_face_t>&
|
||||
int num_outer_bounds = 0;
|
||||
|
||||
for (auto& bound : face->children) {
|
||||
if (bound->external.get_value_or(false)) num_outer_bounds++;
|
||||
if (bound->external.value_or(false)) num_outer_bounds++;
|
||||
}
|
||||
|
||||
if (face->children.size() > 1 && num_outer_bounds > 1 && face->children.size() != num_outer_bounds) {
|
||||
@@ -244,7 +244,7 @@ bool CgalKernel::convert(const taxonomy::face::ptr face, std::list<cgal_face_t>&
|
||||
|
||||
for (auto& bound : face->children) {
|
||||
|
||||
const bool is_interior = !(bound->external.get_value_or(false) || face->children.size() == 1);
|
||||
const bool is_interior = !(bound->external.value_or(false) || face->children.size() == 1);
|
||||
// single face bound is always external... even if not marked as such
|
||||
|
||||
cgal_wire_t wire;
|
||||
@@ -284,11 +284,11 @@ namespace {
|
||||
if (auto e = taxonomy::dcast<taxonomy::edge>(curve)) {
|
||||
if (true || e->basis == nullptr) {
|
||||
if (builder.empty()) {
|
||||
const auto& p = boost::get<taxonomy::point3::ptr>(e->start);
|
||||
const auto& p = std::get<taxonomy::point3::ptr>(e->start);
|
||||
cgal_point_t pnt(p->ccomponents()(0), p->ccomponents()(1), p->ccomponents()(2));
|
||||
builder.push_back(pnt);
|
||||
}
|
||||
const auto& p = boost::get<taxonomy::point3::ptr>(e->end);
|
||||
const auto& p = std::get<taxonomy::point3::ptr>(e->end);
|
||||
cgal_point_t pnt(p->ccomponents()(0), p->ccomponents()(1), p->ccomponents()(2));
|
||||
builder.push_back(pnt);
|
||||
} else if (e->basis->kind() == taxonomy::CIRCLE) {
|
||||
@@ -450,17 +450,17 @@ namespace {
|
||||
void operator()(const taxonomy::trimmed_curve::ptr& e) {
|
||||
auto e_basis = e->basis;
|
||||
|
||||
while (e_basis->kind() == taxonomy::EDGE && e_basis->instance && e_basis->instance->declaration().name() == "IfcTrimmedCurve") {
|
||||
while (e_basis->kind() == taxonomy::EDGE && e_basis->instance && e_basis->instance.declaration().name() == "IfcTrimmedCurve") {
|
||||
// @todo we still might have something to wrt orientation on periodic curves
|
||||
// to make sure we select the correct arc later on.
|
||||
e_basis = taxonomy::cast<taxonomy::edge>(e_basis)->basis;
|
||||
}
|
||||
|
||||
point_projection_visitor v1{ e->basis }, v2{ e->basis };
|
||||
boost::apply_visitor(v1, e->start);
|
||||
boost::apply_visitor(v2, e->end);
|
||||
std::visit(v1, e->start);
|
||||
std::visit(v2, e->end);
|
||||
|
||||
if (!e->curve_sense.get_value_or(true)) {
|
||||
if (!e->curve_sense.value_or(true)) {
|
||||
std::swap(v1.u, v2.u);
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ namespace {
|
||||
dispatch_curve_creation<cgal_curve_creation_visitor>::dispatch(e->basis, v);
|
||||
this->points = v.points;
|
||||
|
||||
if (!e->curve_sense.get_value_or(true)) {
|
||||
if (!e->curve_sense.value_or(true)) {
|
||||
std::reverse(this->points.begin(), this->points.end());
|
||||
}
|
||||
}
|
||||
@@ -581,7 +581,7 @@ namespace {
|
||||
CGAL::Polygon_2<Kernel_> loop_to_polygon_2(taxonomy::loop::ptr loop) {
|
||||
CGAL::Polygon_2<Kernel_> polygon;
|
||||
for (auto& e : loop->children) {
|
||||
auto& p = *boost::get<taxonomy::point3::ptr>(e->start);
|
||||
auto& p = *std::get<taxonomy::point3::ptr>(e->start);
|
||||
CGAL::Point_2<Kernel_> pnt(p.ccomponents()(0), p.ccomponents()(1));
|
||||
polygon.push_back(pnt);
|
||||
}
|
||||
@@ -685,12 +685,12 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
|
||||
convert_curve(settings_, e, edge);
|
||||
} else {
|
||||
edge = {
|
||||
*boost::get<taxonomy::point3::ptr>(e->start),
|
||||
*boost::get<taxonomy::point3::ptr>(e->end)
|
||||
*std::get<taxonomy::point3::ptr>(e->start),
|
||||
*std::get<taxonomy::point3::ptr>(e->end)
|
||||
};
|
||||
}
|
||||
|
||||
if (!e->orientation.get_value_or(true)) {
|
||||
if (!e->orientation.value_or(true)) {
|
||||
std::reverse(edge.begin(), edge.end());
|
||||
}
|
||||
|
||||
@@ -809,7 +809,7 @@ bool CgalKernel::convert_impl(const taxonomy::shell::ptr shell, ConversionResult
|
||||
return false;
|
||||
}
|
||||
results.emplace_back(ConversionResult(
|
||||
shell->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
shell->instance.id(),
|
||||
shell->matrix,
|
||||
new CgalShape(shape),
|
||||
shell->surface_style
|
||||
@@ -834,7 +834,7 @@ bool CgalKernel::convert_impl(const taxonomy::solid::ptr solid, ConversionResult
|
||||
return false;
|
||||
}
|
||||
results.emplace_back(ConversionResult(
|
||||
solid->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
solid->instance.id(),
|
||||
solid->matrix,
|
||||
new CgalShape(shape),
|
||||
solid->surface_style
|
||||
@@ -857,7 +857,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const IfcUtil::IfcBaseEntity * entity, const std::vector<std::pair<taxonomy::ptr, ifcopenshell::geometry::taxonomy::matrix4>>& openings, const IfcGeom::ConversionResults & entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4 & entity_trsf, IfcGeom::ConversionResults & cut_shapes)
|
||||
bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const express::Base& entity, const std::vector<std::pair<taxonomy::ptr, ifcopenshell::geometry::taxonomy::matrix4>>& openings, const IfcGeom::ConversionResults & entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4 & entity_trsf, IfcGeom::ConversionResults & cut_shapes)
|
||||
{
|
||||
#ifdef IFOPSH_SIMPLE_KERNEL
|
||||
return false;
|
||||
@@ -865,9 +865,9 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const IfcUtil
|
||||
CGAL::Nef_nary_union_3<CGAL::Nef_polyhedron_3<Kernel_>> second_operand_collector;
|
||||
size_t second_operand_collector_size = 0;
|
||||
|
||||
std::list<std::pair<const IfcUtil::IfcBaseClass*, std::list<cgal_shape_t>>> operands;
|
||||
std::list<std::pair<express::Base, std::list<cgal_shape_t>>> operands;
|
||||
|
||||
std::list<const IfcUtil::IfcBaseClass*> second_operand_instances;
|
||||
std::list<express::Base> second_operand_instances;
|
||||
std::list<cgal_shape_t> first_operands, second_operands;
|
||||
std::list<CGAL::Nef_polyhedron_3<Kernel_>> first_operands_nef, second_operands_nef;
|
||||
|
||||
@@ -916,13 +916,13 @@ bool ifcopenshell::geometry::kernels::CgalKernel::convert_openings(const IfcUtil
|
||||
}
|
||||
}
|
||||
CGAL::Nef_polyhedron_3<Kernel_> nef;
|
||||
if (!preprocess_boolean_operand(op.first->instance->as<IfcUtil::IfcBaseClass>(), {}, {}, {}, entity_shape, nef, PP_NONE)) {
|
||||
if (!preprocess_boolean_operand(op.first->instance, {}, {}, {}, entity_shape, nef, PP_NONE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// auto tree = build_halfspace_tree_decomposed(nef, all_operand_planes);
|
||||
|
||||
second_operand_instances.push_back(op.first->instance->as<IfcUtil::IfcBaseClass>());
|
||||
second_operand_instances.push_back(op.first->instance);
|
||||
second_operands.push_back(entity_shape);
|
||||
second_operands_nef.push_back(nef);
|
||||
}
|
||||
@@ -984,7 +984,7 @@ bool CgalKernel::convert_impl(const taxonomy::extrusion::ptr extrusion, Conversi
|
||||
return false;
|
||||
}
|
||||
results.emplace_back(ConversionResult(
|
||||
extrusion->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
extrusion->instance.id(),
|
||||
extrusion->matrix,
|
||||
new CgalShape(shape),
|
||||
extrusion->surface_style
|
||||
@@ -1321,7 +1321,7 @@ bool CgalKernel::thin_solid(const CGAL::Nef_polyhedron_3<Kernel_>& a, CGAL::Nef_
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CgalKernel::preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_reference, const std::list<cgal_shape_t>& first_operands, const std::list<CGAL::Nef_polyhedron_3<Kernel_>>& first_operands_nef, const std::list<Kernel_::Plane_3>& all_operand_planes, const cgal_shape_t& shape_const, CGAL::Nef_polyhedron_3<Kernel_>& result, boolean_operand_preprocess proc) {
|
||||
bool CgalKernel::preprocess_boolean_operand(const express::Base& log_reference, const std::list<cgal_shape_t>& first_operands, const std::list<CGAL::Nef_polyhedron_3<Kernel_>>& first_operands_nef, const std::list<Kernel_::Plane_3>& all_operand_planes, const cgal_shape_t& shape_const, CGAL::Nef_polyhedron_3<Kernel_>& result, boolean_operand_preprocess proc) {
|
||||
cgal_shape_t shape = shape_const;
|
||||
|
||||
if (!shape.is_valid()) {
|
||||
@@ -1727,7 +1727,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
bool CgalKernel::process_as_2d_polygon(const std::list<std::list<std::pair<const IfcUtil::IfcBaseClass*, cgal_shape_t>>>& operands, std::list<CGAL::Polygon_2<Kernel_>>& loops, double& z0, double& z1) {
|
||||
bool CgalKernel::process_as_2d_polygon(const std::list<std::list<std::pair<express::Base, cgal_shape_t>>>& operands, std::list<CGAL::Polygon_2<Kernel_>>& loops, double& z0, double& z1) {
|
||||
if (operands.front().size() != 1) {
|
||||
return false;
|
||||
}
|
||||
@@ -1887,7 +1887,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
|
||||
}
|
||||
|
||||
return ConversionResult(
|
||||
br->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
br->instance.id(),
|
||||
br->matrix,
|
||||
new CgalShape(shp),
|
||||
br->surface_style ? br->surface_style : first_item_style
|
||||
@@ -1912,7 +1912,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
|
||||
|
||||
taxonomy::style::ptr first_item_style = nullptr;
|
||||
|
||||
std::list<std::pair<const IfcUtil::IfcBaseClass*, std::list<cgal_shape_t>>> operands;
|
||||
std::list<std::pair<express::Base, std::list<cgal_shape_t>>> operands;
|
||||
|
||||
for (auto& c : br->children) {
|
||||
// AbstractKernel::convert(c, results);
|
||||
@@ -1921,9 +1921,9 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
|
||||
ConversionResults cr;
|
||||
|
||||
operands.emplace_back();
|
||||
operands.back().first = c->instance->as<IfcUtil::IfcBaseClass>();
|
||||
operands.back().first = c->instance;
|
||||
|
||||
if (c->kind() == taxonomy::SOLID && c->instance->declaration().is("IfcHalfSpaceSolid") && !first) {
|
||||
if (c->kind() == taxonomy::SOLID && c->instance.declaration().is("IfcHalfSpaceSolid") && !first) {
|
||||
auto face = taxonomy::cast<taxonomy::solid>(c)->children[0]->children[0];
|
||||
|
||||
if (face->basis == nullptr || face->basis->kind() != taxonomy::PLANE) {
|
||||
@@ -1951,7 +1951,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
|
||||
});
|
||||
|
||||
double wmin, wmax;
|
||||
if (face->orientation.get_value_or(false)) {
|
||||
if (face->orientation.value_or(false)) {
|
||||
wmin = 0.;
|
||||
wmax = uvw_max[2] + eps;
|
||||
} else {
|
||||
@@ -2043,7 +2043,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
|
||||
for (auto& li : operands) {
|
||||
for (auto& s : li.second) {
|
||||
results.emplace_back(ConversionResult(
|
||||
br->instance->data().id(),
|
||||
br->instance.data().id(),
|
||||
br->matrix,
|
||||
new CgalShape(s),
|
||||
br->surface_style ? br->surface_style : first_item_style
|
||||
@@ -2065,7 +2065,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
|
||||
for (auto& p : operands) {
|
||||
for (auto& s : p.second) {
|
||||
results.emplace_back(ConversionResult(
|
||||
br->instance->data().id(),
|
||||
br->instance.data().id(),
|
||||
br->matrix,
|
||||
new CgalShape(s),
|
||||
br->surface_style ? br->surface_style : first_item_style
|
||||
@@ -2131,7 +2131,7 @@ bool CgalKernel::convert_impl(const taxonomy::boolean_result::ptr br, Conversion
|
||||
}
|
||||
|
||||
results.emplace_back(ConversionResult(
|
||||
br->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
br->instance.id(),
|
||||
br->matrix,
|
||||
new CgalShape(a_poly),
|
||||
br->surface_style ? br->surface_style : first_item_style
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace ifcopenshell {
|
||||
PP_NONE
|
||||
};
|
||||
|
||||
bool preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_reference, const std::list<cgal_shape_t>& first_operands, const std::list<CGAL::Nef_polyhedron_3<Kernel_>>& first_operands_nef, const std::list<Kernel_::Plane_3>& all_operand_planes, const cgal_shape_t& shape_const, CGAL::Nef_polyhedron_3<Kernel_>& result, boolean_operand_preprocess proc);
|
||||
bool preprocess_boolean_operand(const express::Base& log_reference, const std::list<cgal_shape_t>& first_operands, const std::list<CGAL::Nef_polyhedron_3<Kernel_>>& first_operands_nef, const std::list<Kernel_::Plane_3>& all_operand_planes, const cgal_shape_t& shape_const, CGAL::Nef_polyhedron_3<Kernel_>& result, boolean_operand_preprocess proc);
|
||||
|
||||
bool thin_solid(const CGAL::Nef_polyhedron_3<Kernel_>& a, CGAL::Nef_polyhedron_3<Kernel_>& result);
|
||||
|
||||
@@ -115,14 +115,14 @@ namespace ifcopenshell {
|
||||
|
||||
bool process_extrusion(const cgal_face_t& bottom_face, taxonomy::direction3::ptr direction, double height, cgal_shape_t& shape);
|
||||
bool process_as_2d_polygon(const taxonomy::boolean_result::ptr br, std::list<CGAL::Polygon_2<Kernel_>>& loops, double& z0, double& z1);
|
||||
bool process_as_2d_polygon(const std::list<std::list<std::pair<const IfcUtil::IfcBaseClass*, cgal_shape_t>>>& operands, std::list<CGAL::Polygon_2<Kernel_>>& loops, double& z0, double& z1);
|
||||
bool process_as_2d_polygon(const std::list<std::list<std::pair<express::Base, cgal_shape_t>>>& operands, std::list<CGAL::Polygon_2<Kernel_>>& loops, double& z0, double& z1);
|
||||
|
||||
virtual bool convert_impl(const taxonomy::shell::ptr, IfcGeom::ConversionResults&);
|
||||
virtual bool convert_impl(const taxonomy::extrusion::ptr, IfcGeom::ConversionResults&);
|
||||
virtual bool convert_impl(const taxonomy::boolean_result::ptr, IfcGeom::ConversionResults&);
|
||||
virtual bool convert_impl(const taxonomy::solid::ptr, IfcGeom::ConversionResults&);
|
||||
|
||||
virtual bool convert_openings(const IfcUtil::IfcBaseEntity* entity, const std::vector<std::pair<taxonomy::ptr, ifcopenshell::geometry::taxonomy::matrix4>>& openings,
|
||||
virtual bool convert_openings(const express::Base& entity, const std::vector<std::pair<taxonomy::ptr, ifcopenshell::geometry::taxonomy::matrix4>>& openings,
|
||||
const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes);
|
||||
|
||||
#ifndef IFOPSH_SIMPLE_KERNEL
|
||||
|
||||
@@ -621,7 +621,7 @@ struct Intersection_visitor {
|
||||
template <typename Kernel>
|
||||
struct Segment_collector {
|
||||
typedef void result_type;
|
||||
boost::optional<CGAL::Segment_3<Kernel>> segment;
|
||||
std::optional<CGAL::Segment_3<Kernel>> segment;
|
||||
|
||||
void operator()(const CGAL::Point_3<Kernel>&)
|
||||
{
|
||||
@@ -648,7 +648,7 @@ public:
|
||||
|
||||
template <typename Edge, typename Graph>
|
||||
bool tree_edge(Edge e, const Graph& g) {
|
||||
if (boost::get(boost::edge_weight, g, e) == edgetype_) {
|
||||
if (std::get(boost::edge_weight, g, e) == edgetype_) {
|
||||
auto srcid = boost::source(e, g);
|
||||
auto tgtid = boost::target(e, g);
|
||||
|
||||
@@ -667,7 +667,7 @@ public:
|
||||
|
||||
typename boost::graph_traits<Graph>::out_edge_iterator ei, ei_end;
|
||||
for (boost::tie(ei, ei_end) = boost::out_edges(tgtid, g); ei != ei_end; ++ei) {
|
||||
if (boost::get(boost::edge_weight, g, *ei) != edgetype_) {
|
||||
if (std::get(boost::edge_weight, g, *ei) != edgetype_) {
|
||||
tgt_has_any_reflex_edge = true;
|
||||
// std::cout << " reflex: " << boost::source(*ei, g) << " -- " << boost::target(*ei, g) << std::endl;
|
||||
break;
|
||||
@@ -712,9 +712,9 @@ public:
|
||||
if (x) {
|
||||
// std::cout << " triangle: " << t << std::endl;
|
||||
// Intersection_visitor v;
|
||||
// boost::apply_visitor([](auto x) {std::cout << " intersects: " << x << std::endl; })(*x);
|
||||
// std::visit([](auto x) {std::cout << " intersects: " << x << std::endl; })(*x);
|
||||
Segment_collector<Kernel> sc;
|
||||
boost::apply_visitor(sc)(*x);
|
||||
std::visit(sc)(*x);
|
||||
if (sc.segment) {
|
||||
if (!std::any_of(edges_i.begin(), edges_i.end(), [&sc](CGAL::Segment_3<Kernel>& s) {
|
||||
// When intersecting with the boundary of a facet we likely multiple co-planar facets. Exclude intersection.
|
||||
@@ -723,7 +723,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
Segment_collector<Kernel> scy;
|
||||
boost::apply_visitor(scy)(*xy);
|
||||
std::visit(scy)(*xy);
|
||||
return (bool)scy.segment;
|
||||
})) {
|
||||
return true;
|
||||
@@ -807,7 +807,7 @@ std::unique_ptr<halfspace_tree<TreeKernel>> build_halfspace_tree(Graph<Kernel>&
|
||||
bool all_convex = true;
|
||||
typename boost::graph_traits<Graph<Kernel>>::edge_iterator ei, ei_end;
|
||||
for (boost::tie(ei, ei_end) = boost::edges(G); ei != ei_end; ++ei) {
|
||||
if (boost::get(boost::edge_weight, G, *ei) != edge_trait) {
|
||||
if (std::get(boost::edge_weight, G, *ei) != edge_trait) {
|
||||
// all_convex = false;
|
||||
break;
|
||||
}
|
||||
@@ -1030,7 +1030,7 @@ public:
|
||||
auto verts_backup = verts;
|
||||
auto facets_backup = facets;
|
||||
|
||||
boost::optional<CGAL::Polygon_with_holes_2<Kernel>> pwh;
|
||||
std::optional<CGAL::Polygon_with_holes_2<Kernel>> pwh;
|
||||
auto nf = std::distance(h->facet_cycles_begin(), h->facet_cycles_end());
|
||||
for (auto fc = h->facet_cycles_begin(); fc != h->facet_cycles_end(); ++fc) {
|
||||
// std::cout << "h_plane.point() " << h_plane.point() << std::endl;
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace IfcGeom {
|
||||
struct ray_intersection_result {
|
||||
double distance;
|
||||
int style_index;
|
||||
const IfcUtil::IfcBaseEntity* instance;
|
||||
express::Entity instance;
|
||||
std::array<double, 3> position;
|
||||
std::array<double, 3> normal;
|
||||
double ray_distance;
|
||||
@@ -82,8 +82,8 @@ namespace IfcGeom {
|
||||
|
||||
struct clash {
|
||||
int clash_type; // 0 = protrusion, 1 = pierce, 2 = collision, 3 = clearance
|
||||
const IfcUtil::IfcBaseClass* a;
|
||||
const IfcUtil::IfcBaseClass* b;
|
||||
express::Base a;
|
||||
express::Base b;
|
||||
double distance;
|
||||
std::array<double, 3> p1;
|
||||
std::array<double, 3> p2;
|
||||
@@ -1442,9 +1442,9 @@ namespace IfcGeom {
|
||||
|
||||
// Temporary structures for H5
|
||||
std::vector<IfcGeom::TriangulationElement*> triangulation_elements_;
|
||||
std::map<const IfcUtil::IfcBaseClass*, std::string> global_ids_;
|
||||
std::map<const IfcUtil::IfcBaseClass*, std::string> names_;
|
||||
std::map<const IfcUtil::IfcBaseClass*, ifcopenshell::geometry::taxonomy::matrix4::ptr> placements_;
|
||||
std::map<express::Base, std::string> global_ids_;
|
||||
std::map<express::Base, std::string> names_;
|
||||
std::map<express::Base, ifcopenshell::geometry::taxonomy::matrix4::ptr> placements_;
|
||||
std::map<std::string, std::vector<double>> local_verts_;
|
||||
std::map<std::string, std::vector<int>> local_faces_;
|
||||
std::map<std::string, std::vector<ifcopenshell::geometry::taxonomy::style::ptr>> local_materials_;
|
||||
@@ -1481,7 +1481,7 @@ namespace IfcGeom {
|
||||
};
|
||||
}
|
||||
|
||||
class tree : public impl::tree<const IfcUtil::IfcBaseEntity*> {
|
||||
class tree : public impl::tree<express::Entity> {
|
||||
public:
|
||||
|
||||
tree() {};
|
||||
|
||||
@@ -53,7 +53,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr
|
||||
// above can be static?
|
||||
|
||||
// A 3x3 matrix to rotate the vertex normals
|
||||
boost::optional<gp_Mat> rotation_matrix;
|
||||
std::optional<gp_Mat> rotation_matrix;
|
||||
|
||||
if (place.components_) {
|
||||
const auto& m = *place.components_;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace {
|
||||
|
||||
using namespace ifcopenshell::geometry;
|
||||
|
||||
bool IfcGeom::OpenCascadeKernel::convert_openings(const IfcUtil::IfcBaseEntity* entity, const std::vector<std::pair<taxonomy::ptr, ifcopenshell::geometry::taxonomy::matrix4>>& openings,
|
||||
bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, const std::vector<std::pair<taxonomy::ptr, ifcopenshell::geometry::taxonomy::matrix4>>& openings,
|
||||
const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes) {
|
||||
|
||||
util::boolean_settings bst;
|
||||
@@ -260,7 +260,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
|
||||
}
|
||||
|
||||
results.emplace_back(ConversionResult(
|
||||
r->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
r->instance.id(),
|
||||
r->matrix,
|
||||
new OpenCascadeShape(shape),
|
||||
r->surface_style
|
||||
@@ -297,7 +297,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
|
||||
// std::for_each(rs.begin(), rs.end(), [&openings](IfcSchema::IfcRelVoidsElement* rel) {
|
||||
// if (rel->RelatedOpeningElement()->ObjectPlacement() && rel->RelatedOpeningElement()->Representation()) {
|
||||
// auto reps = rel->RelatedOpeningElement()->Representation()->Representations();
|
||||
// if (!(reps->size() == 1 && (*reps->begin())->RepresentationIdentifier().get_value_or("") == "Reference")) {
|
||||
// if (!(reps->size() == 1 && (*reps->begin())->RepresentationIdentifier().value_or("") == "Reference")) {
|
||||
// openings->push(rel);
|
||||
// }
|
||||
// }
|
||||
@@ -428,7 +428,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
|
||||
//
|
||||
// int parent_id = -1;
|
||||
// try {
|
||||
// IfcUtil::IfcBaseEntity* parent_object = get_decomposing_entity(product);
|
||||
// express::Entity* parent_object = get_decomposing_entity(product);
|
||||
// if (parent_object && parent_object->as<IfcSchema::IfcObjectDefinition>()) {
|
||||
// parent_id = parent_object->data().id();
|
||||
// }
|
||||
@@ -436,7 +436,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
|
||||
// Logger::Error(e);
|
||||
// }
|
||||
//
|
||||
// const std::string name = product->Name().get_value_or("");
|
||||
// const std::string name = product->Name().value_or("");
|
||||
// const std::string guid = product->GlobalId();
|
||||
//
|
||||
// gp_Trsf trsf;
|
||||
@@ -677,7 +677,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
|
||||
// {
|
||||
// int parent_id = -1;
|
||||
// try {
|
||||
// IfcUtil::IfcBaseEntity* parent_object = get_decomposing_entity(product);
|
||||
// express::Entity* parent_object = get_decomposing_entity(product);
|
||||
// if (parent_object && parent_object->as<IfcSchema::IfcObjectDefinition>()) {
|
||||
// parent_id = parent_object->data().id();
|
||||
// }
|
||||
@@ -685,7 +685,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
|
||||
// Logger::Error(e);
|
||||
// }
|
||||
//
|
||||
// const std::string name = product->Name().get_value_or("");
|
||||
// const std::string name = product->Name().value_or("");
|
||||
// const std::string guid = product->GlobalId();
|
||||
//
|
||||
// gp_Trsf trsf;
|
||||
@@ -998,7 +998,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
|
||||
// layer_offset += *thickness++;
|
||||
//
|
||||
// bool found_intersection = false, parallel = false;
|
||||
// boost::optional<gp_Pnt> point_outside_param_range;
|
||||
// std::optional<gp_Pnt> point_outside_param_range;
|
||||
//
|
||||
// const Handle_Geom_Surface& surface = *jt;
|
||||
//
|
||||
@@ -1209,7 +1209,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
|
||||
// placement_rel_to_type_ = type;
|
||||
// }
|
||||
//
|
||||
// void IfcGeom::Kernel::set_conversion_placement_rel_to_instance(const IfcUtil::IfcBaseEntity* instance) {
|
||||
// void IfcGeom::Kernel::set_conversion_placement_rel_to_instance(const express::Entity* instance) {
|
||||
// placement_rel_to_instance_ = instance;
|
||||
// }
|
||||
//
|
||||
@@ -1281,7 +1281,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
|
||||
// if (shading_styles.second->declaration().is(IfcSchema::IfcSurfaceStyleRendering::Class())) {
|
||||
// IfcSchema::IfcSurfaceStyleRendering* rendering_style = static_cast<IfcSchema::IfcSurfaceStyleRendering*>(shading_styles.second);
|
||||
// if (rendering_style->DiffuseColour() && process_colour(rendering_style->DiffuseColour(), rgb)) {
|
||||
// SurfaceStyle::ColorComponent diffuse = surface_style.Diffuse().get_value_or(SurfaceStyle::ColorComponent(1, 1, 1));
|
||||
// SurfaceStyle::ColorComponent diffuse = surface_style.Diffuse().value_or(SurfaceStyle::ColorComponent(1, 1, 1));
|
||||
// surface_style.Diffuse().reset(SurfaceStyle::ColorComponent(diffuse.R() * rgb[0], diffuse.G() * rgb[1], diffuse.B() * rgb[2]));
|
||||
// }
|
||||
// if (rendering_style->DiffuseTransmissionColour()) {
|
||||
|
||||
@@ -130,11 +130,11 @@ public:
|
||||
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,
|
||||
virtual bool convert_openings(const express::Base& 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);
|
||||
virtual bool unify_shapes(const IfcGeom::ConversionResults& input, IfcGeom::ConversionResults& output);
|
||||
|
||||
typedef boost::variant<boost::blank, Handle(Geom_Curve), TopoDS_Wire> curve_creation_visitor_result_type;
|
||||
typedef std::variant<boost::blank, 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);
|
||||
|
||||
@@ -151,8 +151,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
IfcUtil::IfcBaseClass* POSTFIX_SCHEMA(tesselate_)(const TopoDS_Shape& shape, double deflection);
|
||||
IfcUtil::IfcBaseClass* POSTFIX_SCHEMA(serialise_)(const TopoDS_Shape& shape, bool advanced);
|
||||
express::Base POSTFIX_SCHEMA(tesselate_)(const TopoDS_Shape& shape, double deflection);
|
||||
express::Base POSTFIX_SCHEMA(serialise_)(const TopoDS_Shape& shape, bool advanced);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -107,7 +107,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con
|
||||
|
||||
if (settings_.get<settings::DisableBooleanResult>().get()) {
|
||||
results.emplace_back(IfcGeom::ConversionResult(
|
||||
br->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
br->instance.id(),
|
||||
br->matrix,
|
||||
new OpenCascadeShape(a),
|
||||
br->surface_style ? br->surface_style : first_item_style
|
||||
@@ -189,7 +189,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con
|
||||
}
|
||||
|
||||
results.emplace_back(IfcGeom::ConversionResult(
|
||||
br->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
br->instance.id(),
|
||||
br->matrix,
|
||||
new OpenCascadeShape(a),
|
||||
br->surface_style ? br->surface_style : first_item_style
|
||||
|
||||
@@ -78,7 +78,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::extrusion::ptr extrusion, I
|
||||
}
|
||||
|
||||
results.emplace_back(ConversionResult(
|
||||
extrusion->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
extrusion->instance.id(),
|
||||
extrusion->matrix,
|
||||
new OpenCascadeShape(shape),
|
||||
extrusion->surface_style
|
||||
|
||||
@@ -151,8 +151,8 @@ namespace {
|
||||
// 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() == 2) {
|
||||
const auto& w = boost::get<TopoDS_Wire>(crv_or_wire);
|
||||
if (crv_or_wire.index() == 2) {
|
||||
const auto& w = std::get<TopoDS_Wire>(crv_or_wire);
|
||||
return w;
|
||||
} else {
|
||||
throw std::runtime_error("Unexpected curve evaluation");
|
||||
@@ -162,15 +162,15 @@ namespace {
|
||||
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) {
|
||||
if (crv_or_wire.index() == 0) {
|
||||
throw std::runtime_error("Failed to obtain curve");
|
||||
} else if (crv_or_wire.which() == 1) {
|
||||
return boost::get<Handle(Geom_Curve)>(crv_or_wire);
|
||||
} else if (crv_or_wire.which() == 2) {
|
||||
} else if (crv_or_wire.index() == 1) {
|
||||
return std::get<Handle(Geom_Curve)>(crv_or_wire);
|
||||
} else if (crv_or_wire.index() == 2) {
|
||||
// @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);
|
||||
const auto& w = std::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));
|
||||
@@ -279,7 +279,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
|
||||
int num_outer_bounds = 0;
|
||||
|
||||
for (auto& bound : face->children) {
|
||||
if (bound->external.get_value_or(false)) {
|
||||
if (bound->external.value_or(false)) {
|
||||
num_outer_bounds++;
|
||||
}
|
||||
}
|
||||
@@ -305,7 +305,7 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
|
||||
bool same_sense = true; /* todo bound->Orientation(); */
|
||||
|
||||
const bool is_interior =
|
||||
!bound->external.get_value_or(false) &&
|
||||
!bound->external.value_or(false) &&
|
||||
(num_bounds > 1) &&
|
||||
(num_outer_bounds < num_bounds);
|
||||
|
||||
@@ -604,7 +604,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::face::ptr face, IfcGeom::Co
|
||||
return false;
|
||||
}
|
||||
results.emplace_back(ConversionResult(
|
||||
face->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
face->instance.id(),
|
||||
new OpenCascadeShape(shape),
|
||||
face->surface_style
|
||||
));
|
||||
|
||||
@@ -43,7 +43,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
|
||||
for (auto& e : l->children) {
|
||||
for (size_t i = 0; i < 2; ++i) {
|
||||
// @todo make sure only cartesian points are provided here
|
||||
auto& p = boost::get<ifcopenshell::geometry::taxonomy::point3::ptr>(i == 0 ? e->start : e->end);
|
||||
auto& p = std::get<ifcopenshell::geometry::taxonomy::point3::ptr>(i == 0 ? e->start : e->end);
|
||||
if (point_identities_visited.find(p->identity()) == point_identities_visited.end()) {
|
||||
point_identities_visited.insert(p->identity());
|
||||
points.push_back(p);
|
||||
@@ -198,7 +198,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
|
||||
}
|
||||
}
|
||||
|
||||
if (duplicates_.size() || loops_removed || (non_manifold && shell->closed.get_value_or(false))) {
|
||||
if (duplicates_.size() || loops_removed || (non_manifold && shell->closed.value_or(false))) {
|
||||
Logger::Warning(boost::lexical_cast<std::string>(duplicate_faces) + " duplicate faces removed, " + boost::lexical_cast<std::string>(loops_removed) + " degenerate loops eliminated and " + boost::lexical_cast<std::string>(non_manifold) + " non-manifold edges");
|
||||
}
|
||||
}
|
||||
@@ -209,14 +209,14 @@ void IfcGeom::OpenCascadeKernel::faceset_helper::loop_(const ifcopenshell::geome
|
||||
}
|
||||
|
||||
for (auto& edge : ps->children) {
|
||||
auto A = boost::get<ifcopenshell::geometry::taxonomy::point3::ptr>(edge->start)->identity();
|
||||
auto B = boost::get<ifcopenshell::geometry::taxonomy::point3::ptr>(edge->end)->identity();
|
||||
auto A = std::get<ifcopenshell::geometry::taxonomy::point3::ptr>(edge->start)->identity();
|
||||
auto B = std::get<ifcopenshell::geometry::taxonomy::point3::ptr>(edge->end)->identity();
|
||||
auto C = vertex_mapping_[A], D = vertex_mapping_[B];
|
||||
bool fwd = C < D;
|
||||
if (!fwd) {
|
||||
std::swap(C, D);
|
||||
}
|
||||
if (!edge->orientation.get_value_or(true)) {
|
||||
if (!edge->orientation.value_or(true)) {
|
||||
fwd = !fwd;
|
||||
}
|
||||
if (C != D) {
|
||||
|
||||
@@ -156,21 +156,21 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re
|
||||
// I think make_loft() where should just return a shell instead, because
|
||||
// this faceted lofting does not depend on any functionality in the geometry library
|
||||
// and the branching with tags needs to be solved twice otherwise
|
||||
auto loop_to_points = [](const taxonomy::loop::ptr& loop, const boost::optional<std::vector<std::string>>& input_tags) -> std::pair<std::vector<taxonomy::point3::ptr>, std::vector<std::set<std::string>>> {
|
||||
auto loop_to_points = [](const taxonomy::loop::ptr& loop, const std::optional<std::vector<std::string>>& input_tags) -> std::pair<std::vector<taxonomy::point3::ptr>, std::vector<std::set<std::string>>> {
|
||||
std::vector<taxonomy::point3::ptr> points;
|
||||
std::vector<std::set<std::string>> tags;
|
||||
std::vector<std::string>::const_iterator tag_it;
|
||||
|
||||
if (!loop->closed.get_value_or(false)) {
|
||||
points = {boost::get<taxonomy::point3::ptr>(loop->children[0]->start)};
|
||||
if (!loop->closed.value_or(false)) {
|
||||
points = {std::get<taxonomy::point3::ptr>(loop->children[0]->start)};
|
||||
if (input_tags) {
|
||||
tags = {{input_tags->front()}};
|
||||
tag_it = ++input_tags->begin();
|
||||
}
|
||||
}
|
||||
for (auto& e : loop->children) {
|
||||
const auto& p1 = boost::get<taxonomy::point3::ptr>(e->start);
|
||||
const auto& p2 = boost::get<taxonomy::point3::ptr>(e->end);
|
||||
const auto& p1 = std::get<taxonomy::point3::ptr>(e->start);
|
||||
const auto& p2 = std::get<taxonomy::point3::ptr>(e->end);
|
||||
if (input_tags && p1->ccomponents() == p2->ccomponents()) {
|
||||
tags.back().insert(*tag_it);
|
||||
++tag_it;
|
||||
@@ -184,7 +184,7 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re
|
||||
}
|
||||
}
|
||||
if (!input_tags) {
|
||||
if (loop->closed.get_value_or(false)) {
|
||||
if (loop->closed.value_or(false)) {
|
||||
// close polygon by referencing first point
|
||||
points.push_back(points.front());
|
||||
}
|
||||
@@ -409,7 +409,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::loft::ptr loft, IfcGeom::Co
|
||||
return false;
|
||||
}
|
||||
results.emplace_back(ConversionResult(
|
||||
loft->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
loft->instance.id(),
|
||||
loft->matrix,
|
||||
new OpenCascadeShape(shape),
|
||||
loft->surface_style
|
||||
|
||||
@@ -105,32 +105,32 @@ namespace {
|
||||
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()) {
|
||||
if (e->start.index() != e->end.index()) {
|
||||
throw std::runtime_error("Different trim types not supported");
|
||||
}
|
||||
|
||||
const bool reversed = !e->orientation.get_value_or(true);
|
||||
const bool reversed = !e->orientation.value_or(true);
|
||||
|
||||
TopoDS_Edge E;
|
||||
auto e_basis = e->basis;
|
||||
if (e_basis) {
|
||||
while (e_basis->kind() == taxonomy::EDGE && e_basis->instance && e_basis->instance->declaration().name() == "IfcTrimmedCurve") {
|
||||
while (e_basis->kind() == taxonomy::EDGE && e_basis->instance && e_basis->instance.declaration().name() == "IfcTrimmedCurve") {
|
||||
// @todo we still might have something to wrt orientation on periodic curves
|
||||
// to make sure we select the correct arc later on.
|
||||
e_basis = taxonomy::cast<taxonomy::edge>(e_basis)->basis;
|
||||
}
|
||||
auto crv_or_wire = kernel->convert_curve(e_basis);
|
||||
Handle(Geom_Curve) curve;
|
||||
if (crv_or_wire.which() == 0) {
|
||||
if (crv_or_wire.index() == 0) {
|
||||
// raise exception
|
||||
return result;
|
||||
} else if (crv_or_wire.which() == 1) {
|
||||
curve = boost::get<Handle(Geom_Curve)>(crv_or_wire);
|
||||
} else if (crv_or_wire.index() == 1) {
|
||||
curve = std::get<Handle(Geom_Curve)>(crv_or_wire);
|
||||
} else {
|
||||
// @todo
|
||||
const double precision_ = 1.e-5;
|
||||
Logger::Warning("Approximating BasisCurve due to possible discontinuities", e->instance);
|
||||
const auto& w = boost::get<TopoDS_Wire>(crv_or_wire);
|
||||
const auto& w = std::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));
|
||||
@@ -147,25 +147,25 @@ namespace {
|
||||
auto e_start = e->start;
|
||||
auto e_end = e->end;
|
||||
|
||||
if (!e->curve_sense.get_value_or(true)) {
|
||||
if (!e->curve_sense.value_or(true)) {
|
||||
std::swap(e_start, e_end);
|
||||
}
|
||||
|
||||
// @todo, copy over logic from previous IfcTrimmedCurve handling
|
||||
if (e_start.which() == 0) {
|
||||
if (e_start.index() == 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));
|
||||
} else if (e_start.index() == 1) {
|
||||
auto p1 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*std::get<taxonomy::point3::ptr>(e_start));
|
||||
auto p2 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*std::get<taxonomy::point3::ptr>(e_end));
|
||||
|
||||
if (curve->IsClosed() && p1.Distance(p2) <= kernel->settings().get<settings::Precision>().get()) {
|
||||
E = BRepBuilderAPI_MakeEdge(curve).Edge();
|
||||
} else {
|
||||
E = BRepBuilderAPI_MakeEdge(curve, p1, p2).Edge();
|
||||
}
|
||||
} else if (e_start.which() == 2) {
|
||||
auto v1 = boost::get<double>(e_start);
|
||||
auto v2 = boost::get<double>(e_end);
|
||||
} else if (e_start.index() == 2) {
|
||||
auto v1 = std::get<double>(e_start);
|
||||
auto v2 = std::get<double>(e_end);
|
||||
|
||||
if (is_conic && ALMOST_THE_SAME(fmod(v2 - v1, M_PI * 2.), 0.)) {
|
||||
E = BRepBuilderAPI_MakeEdge(curve).Edge();
|
||||
@@ -178,15 +178,15 @@ namespace {
|
||||
// comply with the direction of conical curves. The ordering of the
|
||||
// vertices then still needs to be reversed in order to have begin and
|
||||
// end vertex consistent with IFC.
|
||||
if (!e->curve_sense.get_value_or(true)) {
|
||||
if (!e->curve_sense.value_or(true)) {
|
||||
E.Reverse();
|
||||
}
|
||||
} else {
|
||||
if (e->start.which() != 1) {
|
||||
if (e->start.index() != 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));
|
||||
auto p2 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*boost::get<taxonomy::point3::ptr>(e->end));
|
||||
auto p1 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*std::get<taxonomy::point3::ptr>(e->start));
|
||||
auto p2 = OpenCascadeKernel::convert_xyz<gp_Pnt>(*std::get<taxonomy::point3::ptr>(e->end));
|
||||
|
||||
E = BRepBuilderAPI_MakeEdge(p1, p2).Edge();
|
||||
}
|
||||
@@ -235,10 +235,27 @@ OpenCascadeKernel::curve_creation_visitor_result_type OpenCascadeKernel::convert
|
||||
bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wire) {
|
||||
TopTools_ListOfShape converted_segments;
|
||||
|
||||
/*
|
||||
if (loop->tags) {
|
||||
std::wcout << "Tags:";
|
||||
for (const auto& t : *loop->tags) {
|
||||
std::wcout << " \"" << t.c_str() << "\"";
|
||||
}
|
||||
std::wcout << std::endl;
|
||||
}*/
|
||||
|
||||
for (auto& segment : loop->children) {
|
||||
|
||||
/*{
|
||||
std::ostringstream oss;
|
||||
segment->print(oss);
|
||||
auto s = oss.str();
|
||||
std::wcout << s.c_str() << std::endl;
|
||||
}*/
|
||||
|
||||
TopoDS_Wire segment_wire;
|
||||
try {
|
||||
segment_wire = boost::get<TopoDS_Wire>(convert_curve(segment));
|
||||
segment_wire = std::get<TopoDS_Wire>(convert_curve(segment));
|
||||
} catch (...) {
|
||||
// @todo we should do some better logging here and catch specific exceptions
|
||||
// but most notably we just want to continue processing when there are
|
||||
@@ -276,14 +293,14 @@ bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wir
|
||||
TopTools_ListIteratorOfListOfShape it(converted_segments);
|
||||
|
||||
bool force_close = false;
|
||||
if (loop->instance && loop->instance->as<IfcUtil::IfcBaseEntity>() && loop->instance->as<IfcUtil::IfcBaseEntity>()->file_) {
|
||||
auto* inst = loop->instance->as<IfcUtil::IfcBaseEntity>();
|
||||
auto* file = loop->instance->as<IfcUtil::IfcBaseEntity>()->file_;
|
||||
auto profile = file->getInverse(inst->id(), file->schema()->declaration_by_name("IfcProfileDef"), -1);
|
||||
force_close = profile && profile->size() > 0;
|
||||
if (loop->instance && loop->instance.as<express::Entity>()) {
|
||||
auto inst = loop->instance.as<express::Entity>();
|
||||
auto file = loop->instance.as<express::Entity>().data()->file();
|
||||
auto profile = file->getInverse(inst.id(), file->schema()->declaration_by_name("IfcProfileDef"), -1);
|
||||
force_close = profile.size() > 0;
|
||||
}
|
||||
|
||||
wire_builder bld(precision_, loop->instance ? loop->instance->as<IfcUtil::IfcBaseEntity>() : nullptr);
|
||||
wire_builder bld(precision_, loop->instance ? loop->instance.as<express::Entity>() : express::Base{});
|
||||
shape_pair_enumerate(it, bld, force_close);
|
||||
wire = bld.wire();
|
||||
|
||||
@@ -384,7 +401,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::loop::ptr loop, IfcGeom::Co
|
||||
}
|
||||
|
||||
results.emplace_back(ConversionResult(
|
||||
loop->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
loop->instance.id(),
|
||||
new OpenCascadeShape(shape),
|
||||
loop->surface_style
|
||||
));
|
||||
@@ -392,10 +409,10 @@ 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(edge));
|
||||
TopoDS_Wire shape = std::get<TopoDS_Wire>(convert_curve(edge));
|
||||
|
||||
results.emplace_back(ConversionResult(
|
||||
edge->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
edge->instance.id(),
|
||||
new OpenCascadeShape(shape),
|
||||
edge->surface_style
|
||||
));
|
||||
|
||||
@@ -14,7 +14,7 @@ bool OpenCascadeKernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& t
|
||||
m(2, 0), m(2, 1), m(2, 2)
|
||||
);
|
||||
|
||||
if (matrix->instance && matrix->instance->declaration().name() == "IfcCartesianTransformationOperator3DnonUniform") {
|
||||
if (matrix->instance && matrix->instance.declaration().name() == "IfcCartesianTransformationOperator3DnonUniform") {
|
||||
// std::wcout << "non uniform" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::shell::ptr shell, IfcGeom::
|
||||
return false;
|
||||
}
|
||||
results.emplace_back(ConversionResult(
|
||||
shell->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
shell->instance.id(),
|
||||
shell->matrix,
|
||||
new OpenCascadeShape(shape),
|
||||
shell->surface_style
|
||||
|
||||
@@ -34,7 +34,7 @@ using namespace IfcGeom::util;
|
||||
bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape& result) {
|
||||
TopoDS_Shape S;
|
||||
|
||||
if (solid->instance->declaration().is("IfcHalfSpaceSolid")) {
|
||||
if (solid->instance.declaration().is("IfcHalfSpaceSolid")) {
|
||||
// halfspace
|
||||
if (solid->children.size() != 1) {
|
||||
throw std::runtime_error("Unexpected number of children on solid");
|
||||
@@ -44,7 +44,7 @@ bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape&
|
||||
|
||||
const auto& m = taxonomy::cast<taxonomy::plane>(face->basis)->matrix->ccomponents();
|
||||
gp_Pln pln(convert_xyz2<gp_Pnt>(m.col(3)), convert_xyz2<gp_Dir>(m.col(2)));
|
||||
const gp_Pnt pnt = pln.Location().Translated(face->orientation.get_value_or(false) ? pln.Axis().Direction() : -pln.Axis().Direction());
|
||||
const gp_Pnt pnt = pln.Location().Translated(face->orientation.value_or(false) ? pln.Axis().Direction() : -pln.Axis().Direction());
|
||||
TopoDS_Shape halfspace = BRepPrimAPI_MakeHalfSpace(BRepBuilderAPI_MakeFace(pln), pnt).Solid();
|
||||
|
||||
if (!face->children.empty()) {
|
||||
@@ -107,7 +107,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::solid::ptr solid, IfcGeom::
|
||||
return false;
|
||||
}
|
||||
results.emplace_back(ConversionResult(
|
||||
solid->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
solid->instance.id(),
|
||||
solid->matrix,
|
||||
new OpenCascadeShape(shape),
|
||||
solid->surface_style
|
||||
|
||||
@@ -113,8 +113,8 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo
|
||||
applied_temporary_offset = true;
|
||||
std::set<taxonomy::point3::ptr> unique_points;
|
||||
for (auto& e : std::dynamic_pointer_cast<taxonomy::loop>(curve)->children) {
|
||||
auto* a = boost::get<taxonomy::point3::ptr>(&e->start);
|
||||
auto* b = boost::get<taxonomy::point3::ptr>(&e->end);
|
||||
auto* a = std::get_if<taxonomy::point3::ptr>(&e->start);
|
||||
auto* b = std::get_if<taxonomy::point3::ptr>(&e->end);
|
||||
if (a) {
|
||||
unique_points.insert(*a);
|
||||
}
|
||||
@@ -129,7 +129,7 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo
|
||||
}
|
||||
|
||||
auto w = convert_curve(scs->curve);
|
||||
if (w.which() != 2) {
|
||||
if (w.index() != 2) {
|
||||
Logger::Error("Unsupported directrix");
|
||||
return false;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo
|
||||
}
|
||||
|
||||
gp_Trsf directrix;
|
||||
TopoDS_Wire wire = boost::get<TopoDS_Wire>(w);
|
||||
TopoDS_Wire wire = std::get<TopoDS_Wire>(w);
|
||||
|
||||
const bool is_plane = surface && surface->DynamicType() == STANDARD_TYPE(Geom_Plane);
|
||||
|
||||
@@ -346,7 +346,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::sweep_along_curve::ptr scs,
|
||||
m = scs->matrix;
|
||||
}
|
||||
results.emplace_back(ConversionResult(
|
||||
scs->instance->as<IfcUtil::IfcBaseEntity>()->id(),
|
||||
scs->instance.id(),
|
||||
m,
|
||||
new OpenCascadeShape(shape),
|
||||
scs->surface_style
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef WIRE_BUILDER_H
|
||||
#define WIRE_BUILDER_H
|
||||
|
||||
#include "../../../ifcparse/IfcBaseClass.h"
|
||||
#include "../../../ifcparse/express.h"
|
||||
|
||||
#include <Geom_Curve.hxx>
|
||||
|
||||
@@ -46,10 +46,10 @@ namespace IfcGeom {
|
||||
double p_;
|
||||
bool override_next_;
|
||||
gp_Pnt next_override_;
|
||||
const IfcUtil::IfcBaseClass* inst_;
|
||||
express::Base inst_;
|
||||
|
||||
public:
|
||||
wire_builder(double p, const IfcUtil::IfcBaseClass* inst = 0) : p_(p), override_next_(false), inst_(inst) {}
|
||||
wire_builder(double p, const express::Base& inst = express::Base()) : p_(p), override_next_(false), inst_(inst) {}
|
||||
|
||||
void operator()(const TopoDS_Shape& a);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user