mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
Work towards v1.0 data model with encapsulated weak_ptr as basis for instances
This commit is contained in:
@@ -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