Last minute refactoring

This commit is contained in:
Thomas Krijnen
2026-08-08 07:42:45 +02:00
parent 8870ffb018
commit af58eaf79f
300 changed files with 5230 additions and 5150 deletions
+30 -30
View File
@@ -72,7 +72,7 @@
#include <IntTools_FaceFace.hxx>
#include "clash_utils.h"
namespace IfcGeom {
namespace ifcopenshell::geom {
namespace {
// Approximates the distance `other` protrudes into `volume` by finding the
@@ -1349,9 +1349,9 @@ namespace IfcGeom {
return ts_filtered;
}
std::vector<T> select(const IfcGeom::BRepElement* elem, bool completely_within = false, double extend = -1.e-5) const {
auto shp = (ifcopenshell::geometry::OpenCascadeShape*)elem->geometry().as_compound();
TopoDS_Shape compound(std::move(((ifcopenshell::geometry::OpenCascadeShape*)shp)->shape()));
std::vector<T> select(const ifcopenshell::geom::brep_element* elem, bool completely_within = false, double extend = -1.e-5) const {
auto shp = (ifcopenshell::geom::open_cascade_shape*)elem->geometry().as_compound();
TopoDS_Shape compound(std::move(((ifcopenshell::geom::open_cascade_shape*)shp)->shape()));
delete shp;
const auto& m = elem->transformation().data()->ccomponents();
@@ -1380,7 +1380,7 @@ namespace IfcGeom {
TopoDS_Vertex v;
if (extend > 0.) {
BRep_Builder B;
B.MakeVertex(v, p, Precision::Confusion());
B.MakeVertex(v, p, ::Precision::Confusion());
}
typename std::vector<T>::const_iterator it = ts.begin();
@@ -1425,13 +1425,13 @@ namespace IfcGeom {
std::unordered_map<T, std::vector<gp_Vec>> normals_;
// Temporary structures for H5
std::vector<IfcGeom::TriangulationElement*> triangulation_elements_;
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::vector<ifcopenshell::geom::triangulation_element*> triangulation_elements_;
std::map<express::base, std::string> global_ids_;
std::map<express::base, std::string> names_;
std::map<express::base, ifcopenshell::geom::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_;
std::map<std::string, std::vector<ifcopenshell::geom::taxonomy::style::ptr>> local_materials_;
std::map<std::string, std::vector<int>> local_material_ids_;
bool enable_face_styles_ = false;
@@ -1465,44 +1465,44 @@ namespace IfcGeom {
};
}
class opencascade_tree : public impl::tree<express::Entity> {
class opencascade_tree : public impl::tree<express::entity> {
public:
opencascade_tree() {};
opencascade_tree(ifcopenshell::file& f) {
add_file(f, ifcopenshell::geometry::Settings{});
add_file(f, ifcopenshell::geom::settings{});
}
opencascade_tree(ifcopenshell::file& f, ifcopenshell::geometry::Settings settings) {
opencascade_tree(ifcopenshell::file& f, ifcopenshell::geom::settings settings) {
add_file(f, settings);
}
opencascade_tree(IfcGeom::Iterator& it) {
opencascade_tree(ifcopenshell::geom::iterator& it) {
add_file(it);
}
void add_file(ifcopenshell::file& f, ifcopenshell::geometry::Settings settings) {
ifcopenshell::geometry::Settings settings_ = settings;
settings_.get<ifcopenshell::geometry::settings::IteratorOutput>().value = ifcopenshell::geometry::settings::NATIVE;
settings_.get<ifcopenshell::geometry::settings::UseWorldCoords>().value = true;
settings_.get<ifcopenshell::geometry::settings::ReorientShells>().value = true;
void add_file(ifcopenshell::file& f, ifcopenshell::geom::settings settings) {
ifcopenshell::geom::settings settings_ = settings;
settings_.get<ifcopenshell::geom::settings::IteratorOutput>().value = ifcopenshell::geom::settings::NATIVE;
settings_.get<ifcopenshell::geom::settings::UseWorldCoords>().value = true;
settings_.get<ifcopenshell::geom::settings::ReorientShells>().value = true;
IfcGeom::Iterator it(std::unique_ptr<ifcopenshell::geometry::kernels::AbstractKernel>(new OpenCascadeKernel(settings_)), settings_, &f, {}, 1);
ifcopenshell::geom::iterator it(std::unique_ptr<ifcopenshell::geom::kernels::abstract_kernel>(new open_cascade_kernel(settings_)), settings_, &f, {}, 1);
add_file(it);
}
void add_file(IfcGeom::Iterator& it) {
void add_file(ifcopenshell::geom::iterator& it) {
if (it.initialize()) {
do {
add_element(dynamic_cast<IfcGeom::BRepElement*>(it.get()));
add_element(dynamic_cast<ifcopenshell::geom::brep_element*>(it.get()));
} while (it.next());
}
}
template <typename T>
void apply_matrix_to_flat_verts(const std::vector<T>& flat_list, const ifcopenshell::geometry::taxonomy::matrix4::ptr& matrix, std::vector<T>& result) {
void apply_matrix_to_flat_verts(const std::vector<T>& flat_list, const ifcopenshell::geom::taxonomy::matrix4::ptr& matrix, std::vector<T>& result) {
Eigen::Vector3d vin;
result.clear();
result.reserve(flat_list.size());
@@ -1547,7 +1547,7 @@ namespace IfcGeom {
return dict.empty();
}
void add_element(IfcGeom::TriangulationElement* elem) {
void add_element(ifcopenshell::geom::triangulation_element* elem) {
Bnd_Box aabb;
Bnd_OBB obb;
@@ -1705,7 +1705,7 @@ namespace IfcGeom {
gp_Vec dir1(v1_pnt, v2_pnt);
gp_Vec dir2(v1_pnt, v3_pnt);
gp_Vec cross_product = dir1.Crossed(dir2);
if (cross_product.Magnitude() > Precision::Confusion()) {
if (cross_product.Magnitude() > ::Precision::Confusion()) {
#if OCC_VERSION_HEX >= 0x80000
triangulation.Elements.Append(BVH_Vec4i(
#else
@@ -1744,12 +1744,12 @@ namespace IfcGeom {
max_protrusions_[t] = std::min(std::min(obb.XHSize(), obb.YHSize()), obb.ZHSize()) * 2;
}
void add_element(IfcGeom::BRepElement* elem) {
void add_element(ifcopenshell::geom::brep_element* elem) {
if (!elem) {
return;
}
auto compound_generic = (ifcopenshell::geometry::OpenCascadeShape*)elem->geometry().as_compound();
auto compound_generic = (ifcopenshell::geom::open_cascade_shape*)elem->geometry().as_compound();
TopoDS_Shape compound(std::move(compound_generic->shape()));
delete compound_generic;
@@ -1795,7 +1795,7 @@ namespace IfcGeom {
return protrusion_distances_;
}
std::vector<IfcGeom::ray_intersection_result> select_ray(const gp_Pnt& p0, const gp_Dir& d, double length = 1000.) const {
std::vector<ifcopenshell::geom::ray_intersection_result> select_ray(const gp_Pnt& p0, const gp_Dir& d, double length = 1000.) const {
gp_Pnt p1 = p0.XYZ() + d.XYZ() * length;
auto E = BRepBuilderAPI_MakeEdge(p0, p1).Edge();
Bnd_Box bb;
@@ -1852,7 +1852,7 @@ namespace IfcGeom {
enable_face_styles_ = b;
}
const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>& styles() const {
const std::vector<ifcopenshell::geom::taxonomy::style::ptr>& styles() const {
return styles_;
}
@@ -1860,7 +1860,7 @@ namespace IfcGeom {
typedef NCollection_DataMap<TopoDS_Shape, int, TopTools_ShapeMapHasher> face_style_map_t;
face_style_map_t face_styles_;
std::vector<ifcopenshell::geometry::taxonomy::style::ptr> styles_;
std::vector<ifcopenshell::geom::taxonomy::style::ptr> styles_;
};
}
@@ -29,9 +29,9 @@
#include <TopTools_FormatVersion.hxx>
#endif
using IfcGeom::OpaqueNumber;
using IfcGeom::OpaqueCoordinate;
using IfcGeom::ConversionResultShape;
using ifcopenshell::geom::opaque_number;
using ifcopenshell::geom::opaque_coordinate;
using ifcopenshell::geom::conversion_result_shape;
namespace {
// We bypass the conversion to gp_GTrsf, because it does not work
@@ -46,31 +46,31 @@ namespace {
}
}
ifcopenshell::geometry::OpenCascadeShape::OpenCascadeShape(const TopoDS_Shape& shape)
ifcopenshell::geom::open_cascade_shape::open_cascade_shape(const TopoDS_Shape& shape)
: shape_(shape) {}
ifcopenshell::geometry::OpenCascadeShape::OpenCascadeShape(TopoDS_Shape&& shape)
ifcopenshell::geom::open_cascade_shape::open_cascade_shape(TopoDS_Shape&& shape)
: shape_(std::move(shape)) {}
const TopoDS_Shape& ifcopenshell::geometry::OpenCascadeShape::shape() const {
const TopoDS_Shape& ifcopenshell::geom::open_cascade_shape::shape() const {
return shape_;
}
ifcopenshell::geometry::OpenCascadeShape::operator const TopoDS_Shape& () {
ifcopenshell::geom::open_cascade_shape::operator const TopoDS_Shape& () {
return shape_;
}
std::string_view ifcopenshell::geometry::OpenCascadeShape::backend_id() const {
std::string_view ifcopenshell::geom::open_cascade_shape::backend_id() const {
return "opencascade";
}
IfcGeom::ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::clone() const {
return new OpenCascadeShape(shape_);
ifcopenshell::geom::conversion_result_shape* ifcopenshell::geom::open_cascade_shape::clone() const {
return new open_cascade_shape(shape_);
}
void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger) const {
void ifcopenshell::geom::open_cascade_shape::Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger) const {
// @todo remove duplication with OpenCascadeKernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf);
// @todo remove duplication with open_cascade_kernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf);
// above can be static?
// A 3x3 matrix to rotate the vertex normals
@@ -243,7 +243,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr
}
if (polyhedral_output_without_holes || polyhedral_output_with_holes) {
auto loops = IfcGeom::util::find_boundary_loops(t->verts(), triangle_indices);
auto loops = ifcopenshell::geom::util::find_boundary_loops(t->verts(), triangle_indices);
if (polyhedral_output_without_holes) {
if (!loops.empty() && !loops[0].empty()) {
t->addFace(item_id, surface_style_id, loops[0]);
@@ -257,7 +257,7 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr
}
if (!t->normals().empty() && settings.get<settings::GenerateUvs>().get()) {
t->uvs_ref() = IfcGeom::Representation::Triangulation::box_project_uvs(t->verts(), t->normals());
t->uvs_ref() = ifcopenshell::geom::Representation::triangulation::box_project_uvs(t->verts(), t->normals());
}
if (num_faces == 0) {
@@ -372,8 +372,8 @@ void ifcopenshell::geometry::OpenCascadeShape::Triangulate(ifcopenshell::geometr
}
}
void ifcopenshell::geometry::OpenCascadeShape::Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string& r) const {
auto s = IfcGeom::util::apply_transformation(shape_, place);
void ifcopenshell::geom::open_cascade_shape::Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string& r) const {
auto s = ifcopenshell::geom::util::apply_transformation(shape_, place);
std::stringstream sstream;
#if OCC_VERSION_HEX >= 0x70600
BRepTools::Write(s, sstream, false, false, TopTools_FormatVersion_VERSION_2);
@@ -383,90 +383,90 @@ void ifcopenshell::geometry::OpenCascadeShape::Serialize(const ifcopenshell::geo
r = sstream.str();
}
int ifcopenshell::geometry::OpenCascadeShape::surface_genus() const {
return IfcGeom::util::surface_genus(shape_);
int ifcopenshell::geom::open_cascade_shape::surface_genus() const {
return ifcopenshell::geom::util::surface_genus(shape_);
}
bool ifcopenshell::geometry::OpenCascadeShape::is_manifold() const {
return IfcGeom::util::is_manifold(shape_);
bool ifcopenshell::geom::open_cascade_shape::is_manifold() const {
return ifcopenshell::geom::util::is_manifold(shape_);
}
int ifcopenshell::geometry::OpenCascadeShape::num_vertices() const
int ifcopenshell::geom::open_cascade_shape::num_vertices() const
{
return IfcGeom::util::count(shape_, TopAbs_VERTEX);
return ifcopenshell::geom::util::count(shape_, TopAbs_VERTEX);
}
int ifcopenshell::geometry::OpenCascadeShape::num_edges() const
int ifcopenshell::geom::open_cascade_shape::num_edges() const
{
return IfcGeom::util::count(shape_, TopAbs_EDGE);
return ifcopenshell::geom::util::count(shape_, TopAbs_EDGE);
}
int ifcopenshell::geometry::OpenCascadeShape::num_faces() const
int ifcopenshell::geom::open_cascade_shape::num_faces() const
{
return IfcGeom::util::count(shape_, TopAbs_FACE);
return ifcopenshell::geom::util::count(shape_, TopAbs_FACE);
}
OpaqueNumber ifcopenshell::geometry::OpenCascadeShape::OpenCascadeShape::length()
opaque_number ifcopenshell::geom::open_cascade_shape::open_cascade_shape::length()
{
GProp_GProps prop;
BRepGProp::LinearProperties(shape_, prop);
double l = prop.Mass();
return OpaqueNumber(l);
return opaque_number(l);
}
OpaqueNumber ifcopenshell::geometry::OpenCascadeShape::area()
opaque_number ifcopenshell::geom::open_cascade_shape::area()
{
GProp_GProps prop;
BRepGProp::SurfaceProperties(shape_, prop);
double l = prop.Mass();
return OpaqueNumber(l);
return opaque_number(l);
}
OpaqueNumber ifcopenshell::geometry::OpenCascadeShape::volume()
opaque_number ifcopenshell::geom::open_cascade_shape::volume()
{
GProp_GProps prop;
BRepGProp::VolumeProperties(shape_, prop);
double l = prop.Mass();
return OpaqueNumber(l);
return opaque_number(l);
}
#include <Geom_Plane.hxx>
OpaqueCoordinate<3> ifcopenshell::geometry::OpenCascadeShape::position()
opaque_coordinate<3> ifcopenshell::geom::open_cascade_shape::position()
{
if (shape_.ShapeType() == TopAbs_FACE) {
auto surf = BRep_Tool::Surface(TopoDS::Face(shape_));
auto plane = Handle(Geom_Plane)::DownCast(surf);
if (plane) {
auto loc = plane->Location();
return OpaqueCoordinate<3>(
OpaqueNumber(loc.X()),
OpaqueNumber(loc.Y()),
OpaqueNumber(loc.Z())
return opaque_coordinate<3>(
opaque_number(loc.X()),
opaque_number(loc.Y()),
opaque_number(loc.Z())
);
}
}
throw std::runtime_error("Invalid shape type");
}
OpaqueCoordinate<3> ifcopenshell::geometry::OpenCascadeShape::axis()
opaque_coordinate<3> ifcopenshell::geom::open_cascade_shape::axis()
{
if (shape_.ShapeType() == TopAbs_FACE) {
auto surf = BRep_Tool::Surface(TopoDS::Face(shape_));
auto plane = Handle(Geom_Plane)::DownCast(surf);
if (plane) {
auto dir = plane->Axis().Direction();
return OpaqueCoordinate<3>(
OpaqueNumber(dir.X()),
OpaqueNumber(dir.Y()),
OpaqueNumber(dir.Z())
return opaque_coordinate<3>(
opaque_number(dir.X()),
opaque_number(dir.Y()),
opaque_number(dir.Z())
);
}
}
throw std::runtime_error("Invalid shape type");
}
OpaqueCoordinate<4> ifcopenshell::geometry::OpenCascadeShape::plane_equation()
opaque_coordinate<4> ifcopenshell::geom::open_cascade_shape::plane_equation()
{
if (shape_.ShapeType() == TopAbs_FACE) {
auto surf = BRep_Tool::Surface(TopoDS::Face(shape_));
@@ -474,121 +474,121 @@ OpaqueCoordinate<4> ifcopenshell::geometry::OpenCascadeShape::plane_equation()
if (plane) {
double a, b, c, d;
plane->Pln().Coefficients(a, b, c, d);
return OpaqueCoordinate<4>(
OpaqueNumber(a),
OpaqueNumber(b),
OpaqueNumber(c),
OpaqueNumber(d)
return opaque_coordinate<4>(
opaque_number(a),
opaque_number(b),
opaque_number(c),
opaque_number(d)
);
}
}
throw std::runtime_error("Invalid shape type");
}
std::vector<ConversionResultShape*> ifcopenshell::geometry::OpenCascadeShape::convex_decomposition()
std::vector<conversion_result_shape*> ifcopenshell::geom::open_cascade_shape::convex_decomposition()
{
throw std::runtime_error("Not implemented");
}
ConversionResultShape * ifcopenshell::geometry::OpenCascadeShape::halfspaces()
conversion_result_shape * ifcopenshell::geom::open_cascade_shape::halfspaces()
{
throw std::runtime_error("Not implemented");
}
ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::solid()
conversion_result_shape* ifcopenshell::geom::open_cascade_shape::solid()
{
throw std::runtime_error("Not implemented");
}
ConversionResultShape * ifcopenshell::geometry::OpenCascadeShape::box()
conversion_result_shape * ifcopenshell::geom::open_cascade_shape::box()
{
throw std::runtime_error("Not implemented");
}
ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::wrap_in_compound()
conversion_result_shape* ifcopenshell::geom::open_cascade_shape::wrap_in_compound()
{
TopoDS_Compound compound;
BRep_Builder builder;
builder.MakeCompound(compound);
builder.Add(compound, shape_);
return new OpenCascadeShape(std::move(compound));
return new open_cascade_shape(std::move(compound));
}
std::vector<ConversionResultShape*> ifcopenshell::geometry::OpenCascadeShape::vertices()
std::vector<conversion_result_shape*> ifcopenshell::geom::open_cascade_shape::vertices()
{
NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> map;
TopExp::MapShapes(shape_, TopAbs_VERTEX, map);
std::vector<ConversionResultShape*> vec;
std::vector<conversion_result_shape*> vec;
for (int i = 1; i <= map.Extent(); ++i) {
vec.push_back(new OpenCascadeShape(map.FindKey(i)));
vec.push_back(new open_cascade_shape(map.FindKey(i)));
}
return vec;
}
std::vector<ConversionResultShape*> ifcopenshell::geometry::OpenCascadeShape::edges()
std::vector<conversion_result_shape*> ifcopenshell::geom::open_cascade_shape::edges()
{
NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> map;
TopExp::MapShapes(shape_, TopAbs_EDGE, map);
std::vector<ConversionResultShape*> vec;
std::vector<conversion_result_shape*> vec;
for (int i = 1; i <= map.Extent(); ++i) {
vec.push_back(new OpenCascadeShape(map.FindKey(i)));
vec.push_back(new open_cascade_shape(map.FindKey(i)));
}
return vec;
}
std::vector<ConversionResultShape*> ifcopenshell::geometry::OpenCascadeShape::facets()
std::vector<conversion_result_shape*> ifcopenshell::geom::open_cascade_shape::facets()
{
NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> map;
TopExp::MapShapes(shape_, TopAbs_FACE, map);
std::vector<ConversionResultShape*> vec;
std::vector<conversion_result_shape*> vec;
for (int i = 1; i <= map.Extent(); ++i) {
vec.push_back(new OpenCascadeShape(map.FindKey(i)));
vec.push_back(new open_cascade_shape(map.FindKey(i)));
}
return vec;
}
namespace {
ConversionResultShape* boolean_op(BOPAlgo_Operation op, const TopoDS_Shape& shape_, const TopoDS_Shape& other_shape) {
IfcGeom::util::boolean_settings st;
conversion_result_shape* boolean_op(BOPAlgo_Operation op, const TopoDS_Shape& shape_, const TopoDS_Shape& other_shape) {
ifcopenshell::geom::util::boolean_settings st;
st.attempt_2d = true;
st.debug = false;
st.precision = 1.e-5;
TopoDS_Shape result;
if (IfcGeom::util::boolean_operation(st, shape_, other_shape, op, result)) {
return new ifcopenshell::geometry::OpenCascadeShape(result);
if (ifcopenshell::geom::util::boolean_operation(st, shape_, other_shape, op, result)) {
return new ifcopenshell::geom::open_cascade_shape(result);
} else {
throw std::runtime_error("Failed to process boolean operation");
}
}
}
ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::add(ConversionResultShape* other)
conversion_result_shape* ifcopenshell::geom::open_cascade_shape::add(conversion_result_shape* other)
{
return boolean_op(BOPAlgo_FUSE, shape_, ((ifcopenshell::geometry::OpenCascadeShape*)other)->shape_);
return boolean_op(BOPAlgo_FUSE, shape_, ((ifcopenshell::geom::open_cascade_shape*)other)->shape_);
}
ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::subtract(ConversionResultShape* other)
conversion_result_shape* ifcopenshell::geom::open_cascade_shape::subtract(conversion_result_shape* other)
{
return boolean_op(BOPAlgo_CUT, shape_, ((ifcopenshell::geometry::OpenCascadeShape*)other)->shape_);
return boolean_op(BOPAlgo_CUT, shape_, ((ifcopenshell::geom::open_cascade_shape*)other)->shape_);
}
ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::intersect(ConversionResultShape* other)
conversion_result_shape* ifcopenshell::geom::open_cascade_shape::intersect(conversion_result_shape* other)
{
return boolean_op(BOPAlgo_COMMON, shape_, ((ifcopenshell::geometry::OpenCascadeShape*)other)->shape_);
return boolean_op(BOPAlgo_COMMON, shape_, ((ifcopenshell::geom::open_cascade_shape*)other)->shape_);
}
ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::concat(ConversionResultShape* other)
conversion_result_shape* ifcopenshell::geom::open_cascade_shape::concat(conversion_result_shape* other)
{
TopoDS_Compound compound;
BRep_Builder builder;
auto& left = shape_;
auto& right = ((ifcopenshell::geometry::OpenCascadeShape*)other)->shape_;
auto& right = ((ifcopenshell::geom::open_cascade_shape*)other)->shape_;
// This reads a bit strange, but we want to specifically avoid compounds of faces that are
// the result of shell instances that are not sewn into a shell (yet).
if (left.ShapeType() == TopAbs_COMPOUND && !IfcGeom::util::is_compound_of_faces(left)) {
if (left.ShapeType() == TopAbs_COMPOUND && !ifcopenshell::geom::util::is_compound_of_faces(left)) {
compound = TopoDS::Compound(left);
} else {
builder.MakeCompound(compound);
@@ -597,17 +597,17 @@ ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::concat(Conversi
builder.Add(compound, right);
return new OpenCascadeShape(std::move(compound));
return new open_cascade_shape(std::move(compound));
}
std::pair<OpaqueCoordinate<3>, OpaqueCoordinate<3>> ifcopenshell::geometry::OpenCascadeShape::bounding_box() const
std::pair<opaque_coordinate<3>, opaque_coordinate<3>> ifcopenshell::geom::open_cascade_shape::bounding_box() const
{
throw std::runtime_error("Not implemented");
}
ConversionResultShape* ifcopenshell::geometry::OpenCascadeShape::moved(ifcopenshell::geometry::taxonomy::matrix4::ptr t) const
conversion_result_shape* ifcopenshell::geom::open_cascade_shape::moved(ifcopenshell::geom::taxonomy::matrix4::ptr t) const
{
return new OpenCascadeShape(IfcGeom::util::apply_transformation(shape_, *t));
return new open_cascade_shape(ifcopenshell::geom::util::apply_transformation(shape_, *t));
}
namespace {
@@ -694,7 +694,7 @@ namespace {
}
bool ifcopenshell::geometry::OpenCascadeShape::surface_area_along_direction(double tol, const ifcopenshell::geometry::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const
bool ifcopenshell::geom::open_cascade_shape::surface_area_along_direction(double tol, const ifcopenshell::geom::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const
{
gp_GTrsf trsf;
@@ -717,10 +717,10 @@ bool ifcopenshell::geometry::OpenCascadeShape::surface_area_along_direction(doub
return true;
}
std::size_t ifcopenshell::geometry::OpenCascadeShape::map(OpaqueCoordinate<4>&, OpaqueCoordinate<4>&) {
std::size_t ifcopenshell::geom::open_cascade_shape::map(opaque_coordinate<4>&, opaque_coordinate<4>&) {
throw std::runtime_error("Not implemented");
}
std::size_t ifcopenshell::geometry::OpenCascadeShape::map(const std::vector<OpaqueCoordinate<4>>&, const std::vector<OpaqueCoordinate<4>>&) {
std::size_t ifcopenshell::geom::open_cascade_shape::map(const std::vector<opaque_coordinate<4>>&, const std::vector<opaque_coordinate<4>>&) {
throw std::runtime_error("Not implemented");
}
@@ -35,24 +35,24 @@
#include "../../../ifcgeom/kernels/ifc_geomlibrary_api.h"
namespace ifcopenshell {
namespace geometry {
namespace geom {
using IfcGeom::OpaqueCoordinate;
using IfcGeom::OpaqueNumber;
using ifcopenshell::geom::opaque_coordinate;
using ifcopenshell::geom::opaque_number;
class IFC_GEOMLIBRARY_API OpenCascadeShape : public IfcGeom::ConversionResultShape {
class IFC_GEOMLIBRARY_API open_cascade_shape : public ifcopenshell::geom::conversion_result_shape {
public:
OpenCascadeShape(const TopoDS_Shape& shape);
OpenCascadeShape(TopoDS_Shape&& shape);
open_cascade_shape(const TopoDS_Shape& shape);
open_cascade_shape(TopoDS_Shape&& shape);
const TopoDS_Shape& shape() const;
operator const TopoDS_Shape& ();
virtual std::string_view backend_id() const;
virtual void Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const;
virtual void Serialize(const ifcopenshell::geometry::taxonomy::matrix4& place, std::string&) const;
virtual void Triangulate(ifcopenshell::geom::settings settings, const ifcopenshell::geom::taxonomy::matrix4& place, ifcopenshell::geom::Representation::triangulation* t, int item_id, int surface_style_id, ::logger& logger = ::logger::root()) const;
virtual void Serialize(const ifcopenshell::geom::taxonomy::matrix4& place, std::string&) const;
virtual IfcGeom::ConversionResultShape* clone() const;
virtual ifcopenshell::geom::conversion_result_shape* clone() const;
virtual double bounding_box(void*&) const {
throw std::runtime_error("Not implemented");
@@ -70,36 +70,36 @@ namespace ifcopenshell {
virtual int num_faces() const;
// @todo this must be something with a virtual dtor so that we can delete it.
virtual std::pair<OpaqueCoordinate<3>, OpaqueCoordinate<3>> bounding_box() const;
virtual std::pair<opaque_coordinate<3>, opaque_coordinate<3>> bounding_box() const;
virtual OpaqueNumber length();
virtual OpaqueNumber area();
virtual OpaqueNumber volume();
virtual opaque_number length();
virtual opaque_number area();
virtual opaque_number volume();
virtual OpaqueCoordinate<3> position();
virtual OpaqueCoordinate<3> axis();
virtual OpaqueCoordinate<4> plane_equation();
virtual opaque_coordinate<3> position();
virtual opaque_coordinate<3> axis();
virtual opaque_coordinate<4> plane_equation();
virtual std::vector<ConversionResultShape*> convex_decomposition();
virtual ConversionResultShape* halfspaces();
virtual ConversionResultShape* solid();
virtual ConversionResultShape* box();
virtual ConversionResultShape* wrap_in_compound();
virtual std::vector<conversion_result_shape*> convex_decomposition();
virtual conversion_result_shape* halfspaces();
virtual conversion_result_shape* solid();
virtual conversion_result_shape* box();
virtual conversion_result_shape* wrap_in_compound();
virtual std::vector<ConversionResultShape*> vertices();
virtual std::vector<ConversionResultShape*> edges();
virtual std::vector<ConversionResultShape*> facets();
virtual std::vector<conversion_result_shape*> vertices();
virtual std::vector<conversion_result_shape*> edges();
virtual std::vector<conversion_result_shape*> facets();
virtual ConversionResultShape* add(ConversionResultShape*);
virtual ConversionResultShape* subtract(ConversionResultShape*);
virtual ConversionResultShape* intersect(ConversionResultShape*);
virtual ConversionResultShape* concat(ConversionResultShape*);
virtual conversion_result_shape* add(conversion_result_shape*);
virtual conversion_result_shape* subtract(conversion_result_shape*);
virtual conversion_result_shape* intersect(conversion_result_shape*);
virtual conversion_result_shape* concat(conversion_result_shape*);
virtual std::size_t map(OpaqueCoordinate<4>& from, OpaqueCoordinate<4>& to);
virtual std::size_t map(const std::vector<OpaqueCoordinate<4>>& from, const std::vector<OpaqueCoordinate<4>>& to);
virtual ConversionResultShape* moved(ifcopenshell::geometry::taxonomy::matrix4::ptr) const;
virtual std::size_t map(opaque_coordinate<4>& from, opaque_coordinate<4>& to);
virtual std::size_t map(const std::vector<opaque_coordinate<4>>& from, const std::vector<opaque_coordinate<4>>& to);
virtual conversion_result_shape* moved(ifcopenshell::geom::taxonomy::matrix4::ptr) const;
virtual bool surface_area_along_direction(double tol, const ifcopenshell::geometry::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const;
virtual bool surface_area_along_direction(double tol, const ifcopenshell::geom::taxonomy::matrix4::ptr&, double& along_x, double& along_y, double& along_z) const;
private:
TopoDS_Shape shape_;
};
@@ -41,10 +41,10 @@ namespace {
};
}
using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geom;
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) {
bool ifcopenshell::geom::open_cascade_kernel::convert_openings(const express::base& entity, const std::vector<std::pair<taxonomy::ptr, ifcopenshell::geom::taxonomy::matrix4>>& openings,
const ifcopenshell::geom::conversion_results& entity_shapes, const ifcopenshell::geom::taxonomy::matrix4& entity_trsf, ifcopenshell::geom::conversion_results& cut_shapes) {
util::boolean_settings bst;
bst.attempt_2d = settings_.get<settings::BooleanAttempt2d>().get();
@@ -83,13 +83,13 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c
Eigen::Matrix4d relative = entity_trsf.ccomponents().inverse() * opening_trsf.ccomponents();
// opening_trsf = relative;
IfcGeom::ConversionResults opening_shapes;
ifcopenshell::geom::conversion_results opening_shapes;
// @todo
AbstractKernel::convert(op.first, opening_shapes);
abstract_kernel::convert(op.first, opening_shapes);
for (unsigned int i = 0; i < opening_shapes.size(); ++i) {
auto opening_shape_i = std::static_pointer_cast<OpenCascadeShape>(opening_shapes[i].Shape())->shape();
auto opening_shape_i = std::static_pointer_cast<open_cascade_shape>(opening_shapes[i].Shape())->shape();
const TopoDS_Shape& opening_shape_unlocated = util::ensure_fit_for_subtraction(opening_shape_i, settings_.get<settings::Precision>().get());
auto gtrsf = opening_shapes[i].Placement();
@@ -110,7 +110,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c
std::sort(opening_vector.begin(), opening_vector.end(), opening_sorter());
// Iterate over the shapes of the IfcProduct
for (IfcGeom::ConversionResults::const_iterator it3 = entity_shapes.begin(); it3 != entity_shapes.end(); ++it3) {
for (ifcopenshell::geom::conversion_results::const_iterator it3 = entity_shapes.begin(); it3 != entity_shapes.end(); ++it3) {
TopoDS_Compound C;
BRep_Builder B;
@@ -119,7 +119,7 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c
std::list<TopoDS_Shape> parts;
auto it3_shape = std::static_pointer_cast<OpenCascadeShape>(it3->Shape())->shape();
auto it3_shape = std::static_pointer_cast<open_cascade_shape>(it3->Shape())->shape();
if (it3_shape.IsNull()) {
logger_.error("GEO", 187, "Null operand");
continue;
@@ -142,8 +142,8 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c
if (!is_manifold) {
// force sewing, edge identity might have been mudied by FixAdvFace.FixOrientation.MSG5 to fix interior loop winding order
NCollection_List<TopoDS_Shape> list;
IfcGeom::util::shape_to_face_list(entity_part, list);
IfcGeom::util::create_solid_from_faces(list, entity_part, settings_.get<settings::Precision>().get(), true);
ifcopenshell::geom::util::shape_to_face_list(entity_part, list);
ifcopenshell::geom::util::create_solid_from_faces(list, entity_part, settings_.get<settings::Precision>().get(), true);
is_manifold = util::is_manifold(entity_part);
if (is_manifold) {
logger_.warning("GEO", 188, "Successfully sewed non-manifold first operand");
@@ -160,8 +160,8 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c
try {
mv.Perform();
auto entity_part_2 = mv.Shape();
if (IfcGeom::util::count(entity_part_2, TopAbs_FACE) == 0) {
failure = "Empty result (no faces) for BOPAlgo_MakerVolume; original was " + std::to_string(IfcGeom::util::count(entity_part, TopAbs_FACE));
if (ifcopenshell::geom::util::count(entity_part_2, TopAbs_FACE) == 0) {
failure = "Empty result (no faces) for BOPAlgo_MakerVolume; original was " + std::to_string(ifcopenshell::geom::util::count(entity_part, TopAbs_FACE));
} else {
is_manifold = util::is_manifold(entity_part_2);
logger_.warning("GEO", 189, std::string("Sucessfully detected exterior volume to non-manifold first operand; shape is now ") + (is_manifold ? std::string("manifold") : std::string("non-manifold")));
@@ -262,24 +262,24 @@ bool IfcGeom::OpenCascadeKernel::convert_openings(const express::Base& entity, c
combined_result = C;
}
cut_shapes.push_back(IfcGeom::ConversionResult(it3->ItemId(), new OpenCascadeShape(combined_result), it3->StylePtr()));
cut_shapes.push_back(ifcopenshell::geom::conversion_result(it3->ItemId(), new open_cascade_shape(combined_result), it3->StylePtr()));
}
return true;
}
bool IfcGeom::OpenCascadeKernel::unify_shapes(const IfcGeom::ConversionResults& input, IfcGeom::ConversionResults& output) {
bool ifcopenshell::geom::open_cascade_kernel::unify_shapes(const ifcopenshell::geom::conversion_results& input, ifcopenshell::geom::conversion_results& output) {
std::transform(input.begin(), input.end(), std::back_inserter(output), [this](auto v) {
auto& s = std::static_pointer_cast<OpenCascadeShape>(v.Shape())->shape();
return IfcGeom::ConversionResult(
auto& s = std::static_pointer_cast<open_cascade_shape>(v.Shape())->shape();
return ifcopenshell::geom::conversion_result(
v.ItemId(),
v.Placement(),
new OpenCascadeShape(util::unify(s, settings_.get<ifcopenshell::geometry::settings::Precision>().get())),
new open_cascade_shape(util::unify(s, settings_.get<ifcopenshell::geom::settings::Precision>().get())),
v.StylePtr());
});
return true;
}
bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, IfcGeom::ConversionResults& results) {
bool ifcopenshell::geom::open_cascade_kernel::convert_impl(const taxonomy::revolve::ptr r, ifcopenshell::geom::conversion_results& results) {
gp_Ax1 ax(
@@ -298,16 +298,16 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
shape = BRepPrimAPI_MakeRevol(face, ax);
}
results.emplace_back(ConversionResult(
results.emplace_back(conversion_result(
r->instance.id(),
r->matrix,
new OpenCascadeShape(shape),
new open_cascade_shape(shape),
r->surface_style
));
return true;
}
// IfcSchema::IfcRelVoidsElement::list::ptr IfcGeom::Kernel::find_openings(IfcSchema::IfcProduct* product) {
// IfcSchema::IfcRelVoidsElement::list::ptr ifcopenshell::geom::Kernel::find_openings(IfcSchema::IfcProduct* product) {
// std::vector<IfcSchema::IfcRelVoidsElement*> rs;
//
// if (product->declaration().is(IfcSchema::IfcElement::Class()) && !product->declaration().is(IfcSchema::IfcOpeningElement::Class())) {
@@ -345,7 +345,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// return openings;
// }
//
// const IfcSchema::IfcMaterial* IfcGeom::Kernel::get_single_material_association(const IfcSchema::IfcProduct* product) {
// const IfcSchema::IfcMaterial* ifcopenshell::geom::Kernel::get_single_material_association(const IfcSchema::IfcProduct* product) {
// IfcSchema::IfcMaterial* single_material = 0;
// IfcSchema::IfcRelAssociatesMaterial::list::ptr associated_materials = product->HasAssociations()->as<IfcSchema::IfcRelAssociatesMaterial>();
// if (associated_materials->size() == 1) {
@@ -367,15 +367,15 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// return single_material;
// }
//
// IfcGeom::BRepElement* IfcGeom::Kernel::create_brep_for_representation_and_product(
// ifcopenshell::geom::brep_element* ifcopenshell::geom::Kernel::create_brep_for_representation_and_product(
// const IteratorSettings& settings, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product)
// {
// std::stringstream representation_id_builder;
//
// representation_id_builder << representation->data().id();
//
// IfcGeom::Representation::BRep* shape;
// IfcGeom::ConversionResults shapes, shapes2;
// ifcopenshell::geom::Representation::brep* shape;
// ifcopenshell::geom::conversion_results shapes, shapes2;
//
// if (!convert_shapes(representation, shapes)) {
// return 0;
@@ -430,7 +430,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// const IfcSchema::IfcMaterial* single_material = get_single_material_association(product);
// if (single_material) {
// auto s = get_style(single_material);
// for (IfcGeom::ConversionResults::iterator it = shapes.begin(); it != shapes.end(); ++it) {
// for (ifcopenshell::geom::conversion_results::iterator it = shapes.begin(); it != shapes.end(); ++it) {
// if (!it->hasStyle() && s) {
// it->setStyle(s);
// material_style_applied = true;
@@ -438,7 +438,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// }
// } else {
// bool some_items_without_style = false;
// for (IfcGeom::ConversionResults::iterator it = shapes.begin(); it != shapes.end(); ++it) {
// for (ifcopenshell::geom::conversion_results::iterator it = shapes.begin(); it != shapes.end(); ++it) {
// if (!it->hasStyle() && util::count(it->Shape(), TopAbs_FACE)) {
// some_items_without_style = true;
// break;
@@ -458,7 +458,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// if (s.hasStyle()) {
// for (auto& p : style_cache) {
// if (p.second == s.StylePtr()) {
// std::const_pointer_cast<IfcGeom::SurfaceStyle>(p.second)->Transparency() = settings.force_space_transparency();
// std::const_pointer_cast<ifcopenshell::geom::SurfaceStyle>(p.second)->Transparency() = settings.force_space_transparency();
// }
// }
// }
@@ -467,7 +467,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
//
// int parent_id = -1;
// try {
// express::Entity* 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();
// }
@@ -496,13 +496,13 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// const std::string product_type = product->declaration().name();
// ElementSettings element_settings(settings, getValue(GV_LENGTH_UNIT), product_type);
//
// if (!settings.get(IfcGeom::IteratorSettings::DISABLE_OPENING_SUBTRACTIONS) && openings && openings->size()) {
// if (!settings.get(ifcopenshell::geom::IteratorSettings::DISABLE_OPENING_SUBTRACTIONS) && openings && openings->size()) {
// representation_id_builder << "-openings";
// for (IfcSchema::IfcRelVoidsElement::list::it it = openings->begin(); it != openings->end(); ++it) {
// representation_id_builder << "-" << (*it)->data().id();
// }
//
// IfcGeom::ConversionResults opened_shapes;
// ifcopenshell::geom::conversion_results opened_shapes;
// bool caught_error = false;
// try {
// convert_openings(product, openings, shapes, trsf, opened_shapes);
@@ -518,22 +518,22 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// }
//
// if (settings.get(IteratorSettings::USE_WORLD_COORDS)) {
// for (IfcGeom::ConversionResults::iterator it = opened_shapes.begin(); it != opened_shapes.end(); ++it) {
// for (ifcopenshell::geom::conversion_results::iterator it = opened_shapes.begin(); it != opened_shapes.end(); ++it) {
// it->prepend(trsf);
// }
// trsf = gp_Trsf();
// representation_id_builder << "-world-coords";
// }
// shape = new IfcGeom::Representation::BRep(element_settings, representation_id_builder.str(), opened_shapes);
// shape = new ifcopenshell::geom::Representation::brep(element_settings, representation_id_builder.str(), opened_shapes);
// } else if (settings.get(IteratorSettings::USE_WORLD_COORDS)) {
// for (IfcGeom::ConversionResults::iterator it = shapes.begin(); it != shapes.end(); ++it) {
// for (ifcopenshell::geom::conversion_results::iterator it = shapes.begin(); it != shapes.end(); ++it) {
// it->prepend(trsf);
// }
// trsf = gp_Trsf();
// representation_id_builder << "-world-coords";
// shape = new IfcGeom::Representation::BRep(element_settings, representation_id_builder.str(), shapes);
// shape = new ifcopenshell::geom::Representation::brep(element_settings, representation_id_builder.str(), shapes);
// } else {
// shape = new IfcGeom::Representation::BRep(element_settings, representation_id_builder.str(), shapes);
// shape = new ifcopenshell::geom::Representation::brep(element_settings, representation_id_builder.str(), shapes);
// }
//
// std::string context_string = "";
@@ -543,7 +543,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// context_string = *representation->ContextOfItems()->ContextType();
// }
//
// auto elem = new BRepElement(
// auto elem = new brep_element(
// product->data().id(),
// parent_id,
// name,
@@ -551,7 +551,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// guid,
// context_string,
// trsf,
// boost::shared_ptr<IfcGeom::Representation::BRep>(shape),
// boost::shared_ptr<ifcopenshell::geom::Representation::brep>(shape),
// product
// );
//
@@ -627,7 +627,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// return elem;
// }
//
// IfcSchema::IfcRepresentation* IfcGeom::Kernel::representation_mapped_to(const IfcSchema::IfcRepresentation* representation) {
// IfcSchema::IfcRepresentation* ifcopenshell::geom::Kernel::representation_mapped_to(const IfcSchema::IfcRepresentation* representation) {
// IfcSchema::IfcRepresentation* representation_mapped_to = 0;
// try {
// IfcSchema::IfcRepresentationItem::list::ptr items = representation->Items();
@@ -652,7 +652,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// return representation_mapped_to;
// }
//
// IfcSchema::IfcProduct::list::ptr IfcGeom::Kernel::products_represented_by(const IfcSchema::IfcRepresentation* representation) {
// IfcSchema::IfcProduct::list::ptr ifcopenshell::geom::Kernel::products_represented_by(const IfcSchema::IfcRepresentation* representation) {
// IfcSchema::IfcProduct::list::ptr products(new IfcSchema::IfcProduct::list);
//
// IfcSchema::IfcProductRepresentation::list::ptr prodreps = representation->OfProductRepresentation();
@@ -710,13 +710,13 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// return products;
// }
//
// IfcGeom::BRepElement* IfcGeom::Kernel::create_brep_for_processed_representation(
// ifcopenshell::geom::brep_element* ifcopenshell::geom::Kernel::create_brep_for_processed_representation(
// const IteratorSettings& /*settings*/, IfcSchema::IfcRepresentation* representation, IfcSchema::IfcProduct* product,
// IfcGeom::BRepElement* brep)
// ifcopenshell::geom::brep_element* brep)
// {
// int parent_id = -1;
// try {
// express::Entity* 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();
// }
@@ -747,7 +747,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
//
// const std::string product_type = product->declaration().name();
//
// return new BRepElement(
// return new brep_element(
// product->data().id(),
// parent_id,
// name,
@@ -760,17 +760,17 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// );
// }
//
// bool IfcGeom::Kernel::convert_layerset(const IfcSchema::IfcProduct* product, std::vector<Handle_Geom_Surface>& surfaces, std::vector<std::shared_ptr<const SurfaceStyle>>& styles, std::vector<double>& thicknesses) {
// bool ifcopenshell::geom::Kernel::convert_layerset(const IfcSchema::IfcProduct* product, std::vector<Handle_Geom_Surface>& surfaces, std::vector<std::shared_ptr<const SurfaceStyle>>& styles, std::vector<double>& thicknesses) {
//
// }
//
// bool IfcGeom::Kernel::find_wall_end_points(const IfcSchema::IfcWall* wall, gp_Pnt& start, gp_Pnt& end) {
// bool ifcopenshell::geom::Kernel::find_wall_end_points(const IfcSchema::IfcWall* wall, gp_Pnt& start, gp_Pnt& end) {
// IfcSchema::IfcRepresentation* axis_representation = find_representation(wall, "Axis");
// if (!axis_representation) {
// return false;
// }
//
// ConversionResults items;
// conversion_results items;
// {
// Kernel temp = *this;
// temp.setValue(GV_DIMENSIONALITY, -1.);
@@ -778,7 +778,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// }
//
// TopoDS_Vertex a, b;
// for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
// for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) {
// TopExp_Explorer exp(it->Shape(), TopAbs_VERTEX);
// for (; exp.More(); exp.Next()) {
// b = TopoDS::Vertex(exp.Current());
@@ -798,7 +798,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// return true;
// }
//
// bool IfcGeom::Kernel::fold_layers(const IfcSchema::IfcWall* wall, const ConversionResults& items, const std::vector<Handle_Geom_Surface>& surfaces, const std::vector<double>& thicknesses, std::vector< std::vector<Handle_Geom_Surface> >& result) {
// bool ifcopenshell::geom::Kernel::fold_layers(const IfcSchema::IfcWall* wall, const conversion_results& items, const std::vector<Handle_Geom_Surface>& surfaces, const std::vector<double>& thicknesses, std::vector< std::vector<Handle_Geom_Surface> >& result) {
// /*
// * @todo isn't it easier to do this based on the non-folded surfaces of
// * the connected walls and fold both pairs of layersets simultaneously?
@@ -969,7 +969,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// continue;
// }
//
// ConversionResults axis_items;
// conversion_results axis_items;
// {
// Kernel temp = *this;
// temp.setValue(GV_DIMENSIONALITY, -1.);
@@ -1172,7 +1172,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// return folds_made;
// }
//
// IfcSchema::IfcRepresentation* IfcGeom::Kernel::find_representation(const IfcSchema::IfcProduct* product, const std::string& identifier) {
// IfcSchema::IfcRepresentation* ifcopenshell::geom::Kernel::find_representation(const IfcSchema::IfcProduct* product, const std::string& identifier) {
// if (!product->Representation()) return 0;
// IfcSchema::IfcProductRepresentation* prod_rep = product->Representation();
// IfcSchema::IfcRepresentation::list::ptr reps = prod_rep->Representations();
@@ -1184,7 +1184,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// return 0;
// }
//
// const IfcSchema::IfcRepresentationptr IfcGeom::Kernel::find_item_carrying_style(const IfcSchema::IfcRepresentationptr item) {
// const IfcSchema::IfcRepresentationptr ifcopenshell::geom::Kernel::find_item_carrying_style(const IfcSchema::IfcRepresentationptr item) {
// if (item->StyledByItem()->size()) {
// return item;
// }
@@ -1206,7 +1206,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// return item;
// }
//
// bool IfcGeom::Kernel::is_identity_transform(ifcopenshell::IfcBaseInterface* l) {
// bool ifcopenshell::geom::Kernel::is_identity_transform(ifcopenshell::IfcBaseInterface* l) {
// IfcSchema::IfcAxis2Placement2D* ax2d;
// IfcSchema::IfcAxis2Placement3D* ax3d;
//
@@ -1244,11 +1244,11 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// }
// }
//
// void IfcGeom::Kernel::set_conversion_placement_rel_to_type(const ifcopenshell::declaration* type) {
// void ifcopenshell::geom::Kernel::set_conversion_placement_rel_to_type(const ifcopenshell::declaration* type) {
// placement_rel_to_type_ = type;
// }
//
// void IfcGeom::Kernel::set_conversion_placement_rel_to_instance(const express::Entity* instance) {
// void ifcopenshell::geom::Kernel::set_conversion_placement_rel_to_instance(const express::entity* instance) {
// placement_rel_to_instance_ = instance;
// }
//
@@ -1288,7 +1288,7 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
//
// #define Kernel POSTFIX_SCHEMA(Kernel)
//
// std::shared_ptr<const IfcGeom::SurfaceStyle> IfcGeom::Kernel::internalize_surface_style(const std::pair<express::Base, express::Base>& shading_styles) {
// std::shared_ptr<const ifcopenshell::geom::SurfaceStyle> ifcopenshell::geom::Kernel::internalize_surface_style(const std::pair<express::base, express::base>& shading_styles) {
// if (shading_styles.second == 0) {
// return 0;
// }
@@ -1354,11 +1354,11 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// return style_cache[surface_style_id] = surface_style_ptr_const;
// }
//
// std::shared_ptr<const IfcGeom::SurfaceStyle> IfcGeom::Kernel::get_style(const IfcSchema::IfcRepresentationptr item) {
// std::shared_ptr<const ifcopenshell::geom::SurfaceStyle> ifcopenshell::geom::Kernel::get_style(const IfcSchema::IfcRepresentationptr item) {
// return internalize_surface_style(get_surface_style<IfcSchema::IfcSurfaceStyleShading>(item));
// }
//
// std::shared_ptr<const IfcGeom::SurfaceStyle> IfcGeom::Kernel::get_style(const IfcSchema::IfcMaterial* material) {
// std::shared_ptr<const ifcopenshell::geom::SurfaceStyle> ifcopenshell::geom::Kernel::get_style(const IfcSchema::IfcMaterial* material) {
// IfcSchema::IfcMaterialDefinitionRepresentation::list::ptr defs = material->HasRepresentation();
// for (IfcSchema::IfcMaterialDefinitionRepresentation::list::it jt = defs->begin(); jt != defs->end(); ++jt) {
// IfcSchema::IfcRepresentation::list::ptr reps = (*jt)->Representations();
@@ -1373,11 +1373,11 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// }
// }
// }
// auto material_style = std::make_shared<IfcGeom::SurfaceStyle>(material->data().id(), material->Name());
// auto material_style = std::make_shared<ifcopenshell::geom::SurfaceStyle>(material->data().id(), material->Name());
// return style_cache[material->data().id()] = material_style;
// }
//
// void IfcGeom::Kernel::apply_layerset(IfcGeom::ConversionResults& r, const ifcopenshell::geometry::layerset_information& info) {
// void ifcopenshell::geom::Kernel::apply_layerset(ifcopenshell::geom::conversion_results& r, const ifcopenshell::geom::layerset_information& info) {
// convert(info.layers);
//
// if (info.layers.empty()) {
@@ -1398,8 +1398,8 @@ bool IfcGeom::OpenCascadeKernel::convert_impl(const taxonomy::revolve::ptr r, If
// return false;
// }
//
// IfcGeom::ConversionResults r2;
// if (IfcGeom::util::apply_layerset(r, const std::vector<ifcopenshell::geometry::taxonomy::style>&, ConversionResults& r2, double tol)) {
// ifcopenshell::geom::conversion_results r2;
// if (ifcopenshell::geom::util::apply_layerset(r, const std::vector<ifcopenshell::geom::taxonomy::style>&, conversion_results& r2, double tol)) {
// std::swap(r, r2)
// }
// }
@@ -69,9 +69,9 @@ bool handle_occt_exception(Fn&& fn) {
}
}
namespace IfcGeom {
namespace ifcopenshell::geom {
class IFC_GEOMLIBRARY_API OpenCascadeKernel : public ifcopenshell::geometry::kernels::AbstractKernel {
class IFC_GEOMLIBRARY_API open_cascade_kernel : public ifcopenshell::geom::kernels::abstract_kernel {
private:
/*
@@ -84,16 +84,16 @@ private:
class faceset_helper {
private:
OpenCascadeKernel* kernel_;
open_cascade_kernel* kernel_;
std::set<int> duplicates_;
std::map<int, int> vertex_mapping_;
std::map<std::pair<int, int>, TopoDS_Edge> edges_;
double eps_;
bool non_manifold_;
void loop_(const ifcopenshell::geometry::taxonomy::loop::ptr ps, const std::function<void(int, int, bool)>& callback);
void loop_(const ifcopenshell::geom::taxonomy::loop::ptr ps, const std::function<void(int, int, bool)>& callback);
public:
faceset_helper(OpenCascadeKernel* kernel, const ifcopenshell::geometry::taxonomy::shell::ptr l);
faceset_helper(open_cascade_kernel* kernel, const ifcopenshell::geom::taxonomy::shell::ptr l);
~faceset_helper();
bool non_manifold() const { return non_manifold_; }
@@ -102,54 +102,54 @@ private:
bool edge(int A, int B, TopoDS_Edge& e);
bool wire(const ifcopenshell::geometry::taxonomy::loop::ptr loop, TopoDS_Wire& wire);
bool wires(const ifcopenshell::geometry::taxonomy::loop::ptr loop, NCollection_List<TopoDS_Shape>& wires);
bool wire(const ifcopenshell::geom::taxonomy::loop::ptr loop, TopoDS_Wire& wire);
bool wires(const ifcopenshell::geom::taxonomy::loop::ptr loop, NCollection_List<TopoDS_Shape>& wires);
};
faceset_helper* faceset_helper_;
double precision_;
public:
OpenCascadeKernel(const ifcopenshell::geometry::Settings& settings, ::logger& logger = ::logger::root())
: AbstractKernel("opencascade", settings, logger)
open_cascade_kernel(const ifcopenshell::geom::settings& settings, ::logger& logger = ::logger::root())
: abstract_kernel("opencascade", settings, logger)
, faceset_helper_(nullptr)
, precision_(settings.get<ifcopenshell::geometry::settings::Precision>().get())
, precision_(settings.get<ifcopenshell::geom::settings::Precision>().get())
{}
virtual AbstractKernel* clone(::logger& logger) const {
return new OpenCascadeKernel(settings(), logger);
virtual abstract_kernel* clone(::logger& logger) const {
return new open_cascade_kernel(settings(), logger);
}
virtual bool supports_boolean_operations() const { return true; }
bool convert(const ifcopenshell::geometry::taxonomy::extrusion::ptr, TopoDS_Shape&);
bool convert(const ifcopenshell::geometry::taxonomy::face::ptr, TopoDS_Shape&, bool reversed_surface = false);
bool convert(const ifcopenshell::geometry::taxonomy::loop::ptr, TopoDS_Wire&);
bool convert(const ifcopenshell::geometry::taxonomy::matrix4::ptr, gp_GTrsf&);
bool convert(const ifcopenshell::geometry::taxonomy::shell::ptr, TopoDS_Shape&);
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&);
bool convert(const ifcopenshell::geom::taxonomy::extrusion::ptr, TopoDS_Shape&);
bool convert(const ifcopenshell::geom::taxonomy::face::ptr, TopoDS_Shape&, bool reversed_surface = false);
bool convert(const ifcopenshell::geom::taxonomy::loop::ptr, TopoDS_Wire&);
bool convert(const ifcopenshell::geom::taxonomy::matrix4::ptr, gp_GTrsf&);
bool convert(const ifcopenshell::geom::taxonomy::shell::ptr, TopoDS_Shape&);
bool convert(const ifcopenshell::geom::taxonomy::solid::ptr, TopoDS_Shape&);
bool convert(const ifcopenshell::geom::taxonomy::loft::ptr, TopoDS_Shape&);
bool convert(const ifcopenshell::geom::taxonomy::bspline_surface::ptr bs, Handle(Geom_Surface) surf);
bool convert(const ifcopenshell::geom::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&);
virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::face::ptr, IfcGeom::ConversionResults&);
virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::solid::ptr, IfcGeom::ConversionResults&);
virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::shell::ptr, IfcGeom::ConversionResults&);
virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::extrusion::ptr, IfcGeom::ConversionResults&);
virtual bool convert_impl(const ifcopenshell::geometry::taxonomy::revolve::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_impl(const ifcopenshell::geom::taxonomy::edge::ptr, ifcopenshell::geom::conversion_results&);
virtual bool convert_impl(const ifcopenshell::geom::taxonomy::loop::ptr, ifcopenshell::geom::conversion_results&);
virtual bool convert_impl(const ifcopenshell::geom::taxonomy::face::ptr, ifcopenshell::geom::conversion_results&);
virtual bool convert_impl(const ifcopenshell::geom::taxonomy::solid::ptr, ifcopenshell::geom::conversion_results&);
virtual bool convert_impl(const ifcopenshell::geom::taxonomy::shell::ptr, ifcopenshell::geom::conversion_results&);
virtual bool convert_impl(const ifcopenshell::geom::taxonomy::extrusion::ptr, ifcopenshell::geom::conversion_results&);
virtual bool convert_impl(const ifcopenshell::geom::taxonomy::revolve::ptr, ifcopenshell::geom::conversion_results&);
virtual bool convert_impl(const ifcopenshell::geom::taxonomy::boolean_result::ptr, ifcopenshell::geom::conversion_results&);
virtual bool convert_impl(const ifcopenshell::geom::taxonomy::loft::ptr, ifcopenshell::geom::conversion_results&);
virtual bool convert_impl(const ifcopenshell::geom::taxonomy::sweep_along_curve::ptr, ifcopenshell::geom::conversion_results&);
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);
virtual bool convert_openings(const express::base& entity, const std::vector<std::pair<ifcopenshell::geom::taxonomy::ptr, ifcopenshell::geom::taxonomy::matrix4>>& openings,
const ifcopenshell::geom::conversion_results& entity_shapes, const ifcopenshell::geom::taxonomy::matrix4& entity_trsf, ifcopenshell::geom::conversion_results& cut_shapes);
virtual bool unify_shapes(const ifcopenshell::geom::conversion_results& input, ifcopenshell::geom::conversion_results& output);
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);
curve_creation_visitor_result_type convert_curve(const ifcopenshell::geom::taxonomy::ptr);
Handle(Geom_Surface) convert_surface(const ifcopenshell::geom::taxonomy::ptr);
template <typename T, typename U>
static T convert_xyz(const U& u) {
@@ -164,8 +164,8 @@ public:
}
};
express::Base POSTFIX_SCHEMA(tesselate_)(const TopoDS_Shape& shape, double deflection);
express::Base 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
+40 -40
View File
@@ -56,7 +56,7 @@
// For axis placements detect equality early in order for the
// relatively computionaly expensive gp_Trsf calculation to be skipped
bool IfcGeom::util::axis_equal(const gp_Ax3 & a, const gp_Ax3 & b, double tolerance) {
bool ifcopenshell::geom::util::axis_equal(const gp_Ax3 & a, const gp_Ax3 & b, double tolerance) {
if (!a.Location().IsEqual(b.Location(), tolerance)) return false;
// Note that the tolerance below is angular, above is linear. Since architectural
// objects are about 1m'ish in scale, it should be somewhat equivalent. Besides,
@@ -67,13 +67,13 @@ bool IfcGeom::util::axis_equal(const gp_Ax3 & a, const gp_Ax3 & b, double tolera
return true;
}
bool IfcGeom::util::axis_equal(const gp_Ax2d & a, const gp_Ax2d & b, double tolerance) {
bool ifcopenshell::geom::util::axis_equal(const gp_Ax2d & a, const gp_Ax2d & b, double tolerance) {
if (!a.Location().IsEqual(b.Location(), tolerance)) return false;
if (!a.Direction().IsEqual(b.Direction(), tolerance)) return false;
return true;
}
int IfcGeom::util::count(const TopoDS_Shape& s, TopAbs_ShapeEnum t, bool unique) {
int ifcopenshell::geom::util::count(const TopoDS_Shape& s, TopAbs_ShapeEnum t, bool unique) {
if (unique) {
NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> map;
TopExp::MapShapes(s, t, map);
@@ -89,7 +89,7 @@ int IfcGeom::util::count(const TopoDS_Shape& s, TopAbs_ShapeEnum t, bool unique)
}
int IfcGeom::util::surface_genus(const TopoDS_Shape& s) {
int ifcopenshell::geom::util::surface_genus(const TopoDS_Shape& s) {
int nv = count(s, TopAbs_VERTEX, true);
int ne = count(s, TopAbs_EDGE, true);
int nf = count(s, TopAbs_FACE, true);
@@ -100,7 +100,7 @@ int IfcGeom::util::surface_genus(const TopoDS_Shape& s) {
return genus;
}
bool IfcGeom::util::is_manifold(const TopoDS_Shape& a) {
bool ifcopenshell::geom::util::is_manifold(const TopoDS_Shape& a) {
if (a.ShapeType() == TopAbs_COMPOUND || a.ShapeType() == TopAbs_SOLID) {
TopoDS_Iterator it(a);
for (; it.More(); it.Next()) {
@@ -134,7 +134,7 @@ bool IfcGeom::util::is_manifold(const TopoDS_Shape& a) {
}
bool IfcGeom::util::is_nested_compound_of_solid(const TopoDS_Shape& s, int depth) {
bool ifcopenshell::geom::util::is_nested_compound_of_solid(const TopoDS_Shape& s, int depth) {
if (s.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator it(s);
for (; it.More(); it.Next()) {
@@ -174,23 +174,23 @@ namespace {
}
}
bool IfcGeom::util::is_identity(const gp_Trsf2d& t, double tolerance) {
bool ifcopenshell::geom::util::is_identity(const gp_Trsf2d& t, double tolerance) {
return is_identity_helper(t, tolerance);
}
bool IfcGeom::util::is_identity(const gp_GTrsf2d& t, double tolerance) {
bool ifcopenshell::geom::util::is_identity(const gp_GTrsf2d& t, double tolerance) {
return is_identity_helper(t, tolerance);
}
bool IfcGeom::util::is_identity(const gp_Trsf& t, double tolerance) {
bool ifcopenshell::geom::util::is_identity(const gp_Trsf& t, double tolerance) {
return is_identity_helper(t, tolerance);
}
bool IfcGeom::util::is_identity(const gp_GTrsf& t, double tolerance) {
bool ifcopenshell::geom::util::is_identity(const gp_GTrsf& t, double tolerance) {
return is_identity_helper(t, tolerance);
}
gp_Trsf IfcGeom::util::combine_offset_and_rotation(const gp_Vec & offset, const gp_Quaternion & rotation) {
gp_Trsf ifcopenshell::geom::util::combine_offset_and_rotation(const gp_Vec & offset, const gp_Quaternion & rotation) {
auto offset_transform = gp_Trsf{};
offset_transform.SetTranslation(offset);
@@ -201,7 +201,7 @@ gp_Trsf IfcGeom::util::combine_offset_and_rotation(const gp_Vec & offset, const
}
bool IfcGeom::util::project(const opencascade::handle<Geom_Surface>& srf, const TopoDS_Shape& shp, double& u1, double& v1, double& u2, double& v2, double widen) {
bool ifcopenshell::geom::util::project(const opencascade::handle<Geom_Surface>& srf, const TopoDS_Shape& shp, double& u1, double& v1, double& u2, double& v2, double widen) {
// @todo std::unique_ptr for C++11
ShapeAnalysis_Surface* sas = 0;
opencascade::handle<Geom_Plane> pln;
@@ -281,7 +281,7 @@ bool IfcGeom::util::project(const opencascade::handle<Geom_Surface>& srf, const
}
TopoDS_Shape IfcGeom::util::apply_transformation(const TopoDS_Shape& s, const gp_Trsf& t) {
TopoDS_Shape ifcopenshell::geom::util::apply_transformation(const TopoDS_Shape& s, const gp_Trsf& t) {
if (t.Form() == gp_Identity) {
return s;
} else {
@@ -295,7 +295,7 @@ TopoDS_Shape IfcGeom::util::apply_transformation(const TopoDS_Shape& s, const gp
}
TopoDS_Shape IfcGeom::util::apply_transformation(const TopoDS_Shape& s, const gp_GTrsf& t) {
TopoDS_Shape ifcopenshell::geom::util::apply_transformation(const TopoDS_Shape& s, const gp_GTrsf& t) {
if (t.Form() == gp_Other) {
return BRepBuilderAPI_GTransform(s, t, true);
} else {
@@ -318,7 +318,7 @@ namespace {
}
}
TopoDS_Shape IfcGeom::util::apply_transformation(const TopoDS_Shape& s, const ifcopenshell::geometry::taxonomy::matrix4& t) {
TopoDS_Shape ifcopenshell::geom::util::apply_transformation(const TopoDS_Shape& s, const ifcopenshell::geom::taxonomy::matrix4& t) {
gp_GTrsf trsf;
if (t.components_) {
@@ -353,7 +353,7 @@ TopoDS_Shape IfcGeom::util::apply_transformation(const TopoDS_Shape& s, const if
return apply_transformation(s, trsf);
}
bool IfcGeom::util::fit_halfspace(const TopoDS_Shape& a, const TopoDS_Shape& b, TopoDS_Shape& box, double& height, double tol) {
bool ifcopenshell::geom::util::fit_halfspace(const TopoDS_Shape& a, const TopoDS_Shape& b, TopoDS_Shape& box, double& height, double tol) {
TopExp_Explorer exp(b, TopAbs_FACE);
if (!exp.More()) {
return false;
@@ -451,7 +451,7 @@ bool IfcGeom::util::fit_halfspace(const TopoDS_Shape& a, const TopoDS_Shape& b,
}
const opencascade::handle<Geom_Curve> IfcGeom::util::intersect(const opencascade::handle<Geom_Surface>& a, const opencascade::handle<Geom_Surface>& b) {
const opencascade::handle<Geom_Curve> ifcopenshell::geom::util::intersect(const opencascade::handle<Geom_Surface>& a, const opencascade::handle<Geom_Surface>& b) {
GeomAPI_IntSS x(a, b, 1.e-7);
if (x.IsDone() && x.NbLines() == 1) {
return x.Line(1);
@@ -461,15 +461,15 @@ const opencascade::handle<Geom_Curve> IfcGeom::util::intersect(const opencascade
}
}
const opencascade::handle<Geom_Curve> IfcGeom::util::intersect(const opencascade::handle<Geom_Surface>& a, const TopoDS_Face& b) {
const opencascade::handle<Geom_Curve> ifcopenshell::geom::util::intersect(const opencascade::handle<Geom_Surface>& a, const TopoDS_Face& b) {
return intersect(a, BRep_Tool::Surface(b));
}
const opencascade::handle<Geom_Curve> IfcGeom::util::intersect(const TopoDS_Face& a, const opencascade::handle<Geom_Surface>& b) {
const opencascade::handle<Geom_Curve> ifcopenshell::geom::util::intersect(const TopoDS_Face& a, const opencascade::handle<Geom_Surface>& b) {
return intersect(BRep_Tool::Surface(a), b);
}
bool IfcGeom::util::intersect(const opencascade::handle<Geom_Curve>& a, const opencascade::handle<Geom_Surface>& b, gp_Pnt& p) {
bool ifcopenshell::geom::util::intersect(const opencascade::handle<Geom_Curve>& a, const opencascade::handle<Geom_Surface>& b, gp_Pnt& p) {
GeomAPI_IntCS x(a, b);
if (x.IsDone() && x.NbPoints() == 1) {
p = x.Point(1);
@@ -479,11 +479,11 @@ bool IfcGeom::util::intersect(const opencascade::handle<Geom_Curve>& a, const op
}
}
bool IfcGeom::util::intersect(const opencascade::handle<Geom_Curve>& a, const TopoDS_Face& b, gp_Pnt &c) {
bool ifcopenshell::geom::util::intersect(const opencascade::handle<Geom_Curve>& a, const TopoDS_Face& b, gp_Pnt &c) {
return intersect(a, BRep_Tool::Surface(b), c);
}
bool IfcGeom::util::intersect(const opencascade::handle<Geom_Curve>& a, const TopoDS_Shape& b, std::vector<gp_Pnt>& out) {
bool ifcopenshell::geom::util::intersect(const opencascade::handle<Geom_Curve>& a, const TopoDS_Shape& b, std::vector<gp_Pnt>& out) {
TopExp_Explorer exp(b, TopAbs_FACE);
gp_Pnt p;
for (; exp.More(); exp.Next()) {
@@ -494,7 +494,7 @@ bool IfcGeom::util::intersect(const opencascade::handle<Geom_Curve>& a, const To
return !out.empty();
}
bool IfcGeom::util::intersect(const opencascade::handle<Geom_Surface>& a, const TopoDS_Shape& b, std::vector< std::pair<opencascade::handle<Geom_Surface>, opencascade::handle<Geom_Curve> > >& out) {
bool ifcopenshell::geom::util::intersect(const opencascade::handle<Geom_Surface>& a, const TopoDS_Shape& b, std::vector< std::pair<opencascade::handle<Geom_Surface>, opencascade::handle<Geom_Curve> > >& out) {
TopExp_Explorer exp(b, TopAbs_FACE);
for (; exp.More(); exp.Next()) {
const TopoDS_Face& f = TopoDS::Face(exp.Current());
@@ -507,7 +507,7 @@ bool IfcGeom::util::intersect(const opencascade::handle<Geom_Surface>& a, const
return !out.empty();
}
bool IfcGeom::util::closest(const gp_Pnt& a, const std::vector<gp_Pnt>& b, gp_Pnt& c) {
bool ifcopenshell::geom::util::closest(const gp_Pnt& a, const std::vector<gp_Pnt>& b, gp_Pnt& c) {
double minimal_distance = std::numeric_limits<double>::infinity();
for (std::vector<gp_Pnt>::const_iterator it = b.begin(); it != b.end(); ++it) {
const double d = a.Distance(*it);
@@ -519,26 +519,26 @@ bool IfcGeom::util::closest(const gp_Pnt& a, const std::vector<gp_Pnt>& b, gp_Pn
return minimal_distance != std::numeric_limits<double>::infinity();
}
bool IfcGeom::util::project(const opencascade::handle<Geom_Curve>& crv, const gp_Pnt& pt, gp_Pnt& p, double& u, double& d) {
bool ifcopenshell::geom::util::project(const opencascade::handle<Geom_Curve>& crv, const gp_Pnt& pt, gp_Pnt& p, double& u, double& d) {
ShapeAnalysis_Curve sac;
sac.Project(crv, pt, 1e-3, p, u, false);
d = pt.Distance(p);
return true;
}
double IfcGeom::util::shape_volume(const TopoDS_Shape& s) {
double ifcopenshell::geom::util::shape_volume(const TopoDS_Shape& s) {
GProp_GProps prop;
BRepGProp::VolumeProperties(s, prop);
return prop.Mass();
}
double IfcGeom::util::face_area(const TopoDS_Face& f) {
double ifcopenshell::geom::util::face_area(const TopoDS_Face& f) {
GProp_GProps prop;
BRepGProp::SurfaceProperties(f, prop);
return prop.Mass();
}
bool IfcGeom::util::is_convex(const TopoDS_Wire& wire, double tol) {
bool ifcopenshell::geom::util::is_convex(const TopoDS_Wire& wire, double tol) {
for (TopExp_Explorer exp1(wire, TopAbs_VERTEX); exp1.More(); exp1.Next()) {
TopoDS_Vertex V1 = TopoDS::Vertex(exp1.Current());
gp_Pnt P1 = BRep_Tool::Pnt(V1);
@@ -585,12 +585,12 @@ bool IfcGeom::util::is_convex(const TopoDS_Wire& wire, double tol) {
return true;
}
TopoDS_Shape IfcGeom::util::halfspace_from_plane(const gp_Pln& pln, const gp_Pnt& cent) {
TopoDS_Shape ifcopenshell::geom::util::halfspace_from_plane(const gp_Pln& pln, const gp_Pnt& cent) {
TopoDS_Face face = BRepBuilderAPI_MakeFace(pln).Face();
return BRepPrimAPI_MakeHalfSpace(face, cent).Solid();
}
gp_Pln IfcGeom::util::plane_from_face(const TopoDS_Face& face) {
gp_Pln ifcopenshell::geom::util::plane_from_face(const TopoDS_Face& face) {
BRepGProp_Face prop(face);
double u1, u2, v1, v2;
prop.Bounds(u1, u2, v1, v2);
@@ -602,7 +602,7 @@ gp_Pln IfcGeom::util::plane_from_face(const TopoDS_Face& face) {
return gp_Pln(p, n);
}
gp_Pnt IfcGeom::util::point_above_plane(const gp_Pln& pln, bool agree) {
gp_Pnt ifcopenshell::geom::util::point_above_plane(const gp_Pln& pln, bool agree) {
if (agree) {
return pln.Location().Translated(pln.Axis().Direction());
} else {
@@ -610,7 +610,7 @@ gp_Pnt IfcGeom::util::point_above_plane(const gp_Pln& pln, bool agree) {
}
}
bool IfcGeom::util::is_compound_of_faces(const TopoDS_Shape& shape) {
bool ifcopenshell::geom::util::is_compound_of_faces(const TopoDS_Shape& shape) {
bool has_solids = TopExp_Explorer(shape, TopAbs_SOLID).More() != 0;
bool has_shells = TopExp_Explorer(shape, TopAbs_SHELL).More() != 0;
bool has_compounds = TopExp_Explorer(shape, TopAbs_COMPOUND).More() != 0;
@@ -618,7 +618,7 @@ bool IfcGeom::util::is_compound_of_faces(const TopoDS_Shape& shape) {
return has_compounds && has_faces && !has_solids && !has_shells;
}
bool IfcGeom::util::shape_to_face_list(const TopoDS_Shape& s, NCollection_List<TopoDS_Shape>& li) {
bool ifcopenshell::geom::util::shape_to_face_list(const TopoDS_Shape& s, NCollection_List<TopoDS_Shape>& li) {
TopExp_Explorer exp(s, TopAbs_FACE);
for (; exp.More(); exp.Next()) {
TopoDS_Face face = TopoDS::Face(exp.Current());
@@ -627,7 +627,7 @@ bool IfcGeom::util::shape_to_face_list(const TopoDS_Shape& s, NCollection_List<T
return true;
}
bool IfcGeom::util::create_solid_from_compound(const TopoDS_Shape& compound, TopoDS_Shape& shape, double tol) {
bool ifcopenshell::geom::util::create_solid_from_compound(const TopoDS_Shape& compound, TopoDS_Shape& shape, double tol) {
NCollection_List<TopoDS_Shape> face_list;
shape_to_face_list(compound, face_list);
if (face_list.Extent() == 0) {
@@ -636,7 +636,7 @@ bool IfcGeom::util::create_solid_from_compound(const TopoDS_Shape& compound, Top
return create_solid_from_faces(face_list, shape, tol);
}
bool IfcGeom::util::create_solid_from_faces(const NCollection_List<TopoDS_Shape>& face_list, TopoDS_Shape& shape, double tol, bool force_sewing) {
bool ifcopenshell::geom::util::create_solid_from_faces(const NCollection_List<TopoDS_Shape>& face_list, TopoDS_Shape& shape, double tol, bool force_sewing) {
bool valid_shell = false;
if (face_list.Extent() == 1) {
@@ -803,16 +803,16 @@ bool IfcGeom::util::create_solid_from_faces(const NCollection_List<TopoDS_Shape>
return valid_shell;
}
bool IfcGeom::util::flatten_shape_list(const IfcGeom::ConversionResults& shapes, TopoDS_Shape& result, bool fuse, bool create_shell, double tol) {
bool ifcopenshell::geom::util::flatten_shape_list(const ifcopenshell::geom::conversion_results& shapes, TopoDS_Shape& result, bool fuse, bool create_shell, double tol) {
TopoDS_Compound compound;
BRep_Builder builder;
builder.MakeCompound(compound);
result = TopoDS_Shape();
for (IfcGeom::ConversionResults::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
for (ifcopenshell::geom::conversion_results::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
TopoDS_Shape merged;
const TopoDS_Shape& s = std::static_pointer_cast<ifcopenshell::geometry::OpenCascadeShape>(it->Shape())->shape();
const TopoDS_Shape& s = std::static_pointer_cast<ifcopenshell::geom::open_cascade_shape>(it->Shape())->shape();
if (fuse || create_shell) {
merged = util::ensure_fit_for_subtraction(s, tol);
} else {
@@ -866,7 +866,7 @@ bool IfcGeom::util::flatten_shape_list(const IfcGeom::ConversionResults& shapes,
return success;
}
bool IfcGeom::util::validate_shape(const TopoDS_Shape& s) {
bool ifcopenshell::geom::util::validate_shape(const TopoDS_Shape& s) {
BRepCheck_Analyzer ana(s);
if (ana.IsValid()) {
return true;
@@ -906,7 +906,7 @@ bool IfcGeom::util::validate_shape(const TopoDS_Shape& s) {
return false;
}
TopoDS_Shape IfcGeom::util::unify(const TopoDS_Shape& s, double tolerance) {
TopoDS_Shape ifcopenshell::geom::util::unify(const TopoDS_Shape& s, double tolerance) {
tolerance = (std::min)(min_edge_length(s) / 2., tolerance);
ShapeUpgrade_UnifySameDomain usd(s);
#if OCC_VERSION_HEX >= 0x70200
+3 -3
View File
@@ -25,7 +25,7 @@
#include <vector>
namespace IfcGeom {
namespace ifcopenshell::geom {
namespace util {
IFC_GEOMLIBRARY_API int count(const TopoDS_Shape&, TopAbs_ShapeEnum, bool unique = false);
@@ -74,11 +74,11 @@ namespace IfcGeom {
IFC_GEOMLIBRARY_API double shape_volume(const TopoDS_Shape& s);
IFC_GEOMLIBRARY_API double face_area(const TopoDS_Face& f);
IFC_GEOMLIBRARY_API TopoDS_Shape apply_transformation(const TopoDS_Shape&, const ifcopenshell::geometry::taxonomy::matrix4& t);
IFC_GEOMLIBRARY_API TopoDS_Shape apply_transformation(const TopoDS_Shape&, const ifcopenshell::geom::taxonomy::matrix4& t);
IFC_GEOMLIBRARY_API TopoDS_Shape apply_transformation(const TopoDS_Shape&, const gp_Trsf&);
IFC_GEOMLIBRARY_API TopoDS_Shape apply_transformation(const TopoDS_Shape&, const gp_GTrsf&);
IFC_GEOMLIBRARY_API bool flatten_shape_list(const IfcGeom::ConversionResults& shapes, TopoDS_Shape& result, bool fuse, bool create_shell, double tol);
IFC_GEOMLIBRARY_API bool flatten_shape_list(const ifcopenshell::geom::conversion_results& shapes, TopoDS_Shape& result, bool fuse, bool create_shell, double tol);
IFC_GEOMLIBRARY_API bool validate_shape(const TopoDS_Shape&);
IFC_GEOMLIBRARY_API TopoDS_Shape unify(const TopoDS_Shape& s, double tolerance);
@@ -3,9 +3,8 @@
#include "boolean_utils.h"
#include "base_utils.h"
using namespace IfcGeom;
using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geometry::kernels;
using namespace ifcopenshell::geom;
using namespace ifcopenshell::geom::kernels;
// @todo should we reapply the technique to apply openings in batches?
namespace {
@@ -15,7 +14,7 @@ namespace {
}
};
bool apply_in_batches(IfcGeom::util::boolean_settings bst, const TopoDS_Shape& first_operand, std::vector< std::pair<double, TopoDS_Shape> >& opening_vector, BOPAlgo_Operation occ_op, TopoDS_Shape& result) {
bool apply_in_batches(ifcopenshell::geom::util::boolean_settings bst, const TopoDS_Shape& first_operand, std::vector< std::pair<double, TopoDS_Shape> >& opening_vector, BOPAlgo_Operation occ_op, TopoDS_Shape& result) {
auto it = opening_vector.begin();
auto jt = it;
@@ -29,7 +28,7 @@ namespace {
}
TopoDS_Shape intermediate_result;
if (IfcGeom::util::boolean_operation(bst, result, opening_list, occ_op, intermediate_result)) {
if (ifcopenshell::geom::util::boolean_operation(bst, result, opening_list, occ_op, intermediate_result)) {
result = intermediate_result;
} else {
return false;
@@ -83,7 +82,7 @@ namespace {
}
}
bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, ConversionResults& results) {
bool open_cascade_kernel::convert_impl(const taxonomy::boolean_result::ptr br, conversion_results& results) {
return handle_occt_exception([&]() -> bool {
bool valid_result = false;
bool first = true;
@@ -95,11 +94,11 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con
taxonomy::style::ptr first_item_style;
for (auto& c : br->children) {
IfcGeom::ConversionResults cr;
AbstractKernel::convert(c, cr);
ifcopenshell::geom::conversion_results cr;
abstract_kernel::convert(c, cr);
if (first && br->operation == taxonomy::boolean_result::SUBTRACTION) {
// @todo A will be null on union/intersection, intended?
IfcGeom::util::flatten_shape_list(cr, a, false, true, settings_.get<settings::Precision>().get());
ifcopenshell::geom::util::flatten_shape_list(cr, a, false, true, settings_.get<settings::Precision>().get());
first_item_style = c->surface_style;
if (!first_item_style && c->kind() == taxonomy::COLLECTION) {
// @todo recursively right?
@@ -107,10 +106,10 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con
}
if (settings_.get<settings::DisableBooleanResult>().get()) {
results.emplace_back(IfcGeom::ConversionResult(
results.emplace_back(ifcopenshell::geom::conversion_result(
br->instance.id(),
br->matrix,
new OpenCascadeShape(a),
new open_cascade_shape(a),
br->surface_style ? br->surface_style : first_item_style
));
return true;
@@ -123,7 +122,7 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con
} else {
for (auto& r : cr) {
auto S = std::static_pointer_cast<OpenCascadeShape>(r.Shape())->shape();
auto S = std::static_pointer_cast<open_cascade_shape>(r.Shape())->shape();
if (S.IsNull()) {
logger_.error("GEO", 120, "Null operand");
continue;
@@ -190,10 +189,10 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::boolean_result::ptr br, Con
std::swap(r, a);
}
results.emplace_back(IfcGeom::ConversionResult(
results.emplace_back(ifcopenshell::geom::conversion_result(
br->instance.id(),
br->matrix,
new OpenCascadeShape(a),
new open_cascade_shape(a),
br->surface_style ? br->surface_style : first_item_style
));
@@ -30,7 +30,7 @@
#include <vector>
#include <thread>
void IfcGeom::util::copy_operand(const NCollection_List<TopoDS_Shape>& l, NCollection_List<TopoDS_Shape>& r) {
void ifcopenshell::geom::util::copy_operand(const NCollection_List<TopoDS_Shape>& l, NCollection_List<TopoDS_Shape>& r) {
#if OCC_VERSION_HEX < 0x70000
r.Clear();
TopTools_ListIteratorOfListOfShape it(l);
@@ -45,7 +45,7 @@ void IfcGeom::util::copy_operand(const NCollection_List<TopoDS_Shape>& l, NColle
#endif
}
TopoDS_Shape IfcGeom::util::copy_operand(const TopoDS_Shape & s) {
TopoDS_Shape ifcopenshell::geom::util::copy_operand(const TopoDS_Shape & s) {
#if OCC_VERSION_HEX < 0x70000
return BRepBuilderAPI_Copy(s);
#else
@@ -53,7 +53,7 @@ TopoDS_Shape IfcGeom::util::copy_operand(const TopoDS_Shape & s) {
#endif
}
double IfcGeom::util::min_edge_length(const TopoDS_Shape & a) {
double ifcopenshell::geom::util::min_edge_length(const TopoDS_Shape & a) {
double min_edge_len = std::numeric_limits<double>::infinity();
TopExp_Explorer exp(a, TopAbs_EDGE);
for (; exp.More(); exp.Next()) {
@@ -77,7 +77,7 @@ double IfcGeom::util::min_edge_length(const TopoDS_Shape & a) {
return min_edge_len;
}
double IfcGeom::util::min_vertex_edge_distance(const TopoDS_Shape & a, double min_search, double max_search) {
double ifcopenshell::geom::util::min_vertex_edge_distance(const TopoDS_Shape & a, double min_search, double max_search) {
double M = std::numeric_limits<double>::infinity();
NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> vertices, edges;
@@ -85,7 +85,7 @@ double IfcGeom::util::min_vertex_edge_distance(const TopoDS_Shape & a, double mi
TopExp::MapShapes(a, TopAbs_VERTEX, vertices);
TopExp::MapShapes(a, TopAbs_EDGE, edges);
IfcGeom::impl::tree<int> tree;
ifcopenshell::geom::impl::tree<int> tree;
// Add edges to tree
for (int i = 1; i <= edges.Extent(); ++i) {
@@ -129,7 +129,7 @@ double IfcGeom::util::min_vertex_edge_distance(const TopoDS_Shape & a, double mi
return M;
}
bool IfcGeom::util::faces_overlap(const TopoDS_Face & f, const TopoDS_Face & g) {
bool ifcopenshell::geom::util::faces_overlap(const TopoDS_Face & f, const TopoDS_Face & g) {
points_on_planar_face_generator pgen(f);
BRep_Builder B;
@@ -141,7 +141,7 @@ bool IfcGeom::util::faces_overlap(const TopoDS_Face & f, const TopoDS_Face & g)
while (pgen(test)) {
TopoDS_Vertex V;
B.MakeVertex(V, test, Precision::Confusion());
B.MakeVertex(V, test, ::Precision::Confusion());
x.LoadS2(V);
x.Perform();
if (x.IsDone() && x.NbSolution() == 1) {
@@ -154,7 +154,7 @@ bool IfcGeom::util::faces_overlap(const TopoDS_Face & f, const TopoDS_Face & g)
return true;
}
double IfcGeom::util::min_face_face_distance(const TopoDS_Shape & a, double max_search) {
double ifcopenshell::geom::util::min_face_face_distance(const TopoDS_Shape & a, double max_search) {
/*
NB: This is currently only implemented for planar surfaces.
*/
@@ -164,7 +164,7 @@ double IfcGeom::util::min_face_face_distance(const TopoDS_Shape & a, double max_
TopExp::MapShapes(a, TopAbs_FACE, faces);
IfcGeom::impl::tree<int> tree;
ifcopenshell::geom::impl::tree<int> tree;
// Add faces to tree
for (int i = 1; i <= faces.Extent(); ++i) {
@@ -229,7 +229,7 @@ double IfcGeom::util::min_face_face_distance(const TopoDS_Shape & a, double max_
return M;
}
int IfcGeom::util::bounding_box_overlap(double p, const TopoDS_Shape & a, const NCollection_List<TopoDS_Shape> & b, NCollection_List<TopoDS_Shape> & c) {
int ifcopenshell::geom::util::bounding_box_overlap(double p, const TopoDS_Shape & a, const NCollection_List<TopoDS_Shape> & b, NCollection_List<TopoDS_Shape> & c) {
int N = 0;
Bnd_Box A;
@@ -258,7 +258,7 @@ int IfcGeom::util::bounding_box_overlap(double p, const TopoDS_Shape & a, const
return N;
}
bool IfcGeom::util::get_edge_axis(const TopoDS_Edge & e, gp_Ax1 & ax) {
bool ifcopenshell::geom::util::get_edge_axis(const TopoDS_Edge & e, gp_Ax1 & ax) {
double _, __;
auto crv = BRep_Tool::Curve(e, _, __);
@@ -279,7 +279,7 @@ bool IfcGeom::util::get_edge_axis(const TopoDS_Edge & e, gp_Ax1 & ax) {
return false;
}
bool IfcGeom::util::is_subset(const NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& lhs, const NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& rhs) {
bool ifcopenshell::geom::util::is_subset(const NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& lhs, const NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& rhs) {
if (rhs.Extent() < lhs.Extent()) {
return false;
}
@@ -292,7 +292,7 @@ bool IfcGeom::util::is_subset(const NCollection_IndexedMap<TopoDS_Shape, TopTool
return true;
}
bool IfcGeom::util::is_extrusion(const gp_Vec & v, const TopoDS_Shape & s, TopoDS_Face & base, std::pair<double, double>& interval) {
bool ifcopenshell::geom::util::is_extrusion(const gp_Vec & v, const TopoDS_Shape & s, TopoDS_Face & base, std::pair<double, double>& interval) {
// This assumes UnifySameDomain has been processed on s, so that
// the extrusion top and bottom are a single face.
@@ -405,7 +405,7 @@ bool IfcGeom::util::is_extrusion(const gp_Vec & v, const TopoDS_Shape & s, TopoD
return true;
}
int IfcGeom::util::eliminate_narrow_operands(double prec, const NCollection_List<TopoDS_Shape>& bs, NCollection_List<TopoDS_Shape> & c, ::logger& logger) {
int ifcopenshell::geom::util::eliminate_narrow_operands(double prec, const NCollection_List<TopoDS_Shape>& bs, NCollection_List<TopoDS_Shape> & c, ::logger& logger) {
int N = 0;
NCollection_List<TopoDS_Shape>::Iterator it(bs);
for (; it.More(); it.Next()) {
@@ -429,7 +429,7 @@ int IfcGeom::util::eliminate_narrow_operands(double prec, const NCollection_List
return N;
}
int IfcGeom::util::eliminate_touching_operands(double prec, const TopoDS_Shape & a, const NCollection_List<TopoDS_Shape> & bs, NCollection_List<TopoDS_Shape> & c) {
int ifcopenshell::geom::util::eliminate_touching_operands(double prec, const TopoDS_Shape & a, const NCollection_List<TopoDS_Shape> & bs, NCollection_List<TopoDS_Shape> & c) {
NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> a_faces;
TopExp::MapShapes(a, TopAbs_FACE, a_faces);
@@ -445,7 +445,7 @@ int IfcGeom::util::eliminate_touching_operands(double prec, const TopoDS_Shape &
NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> a_vertices;
TopExp::MapShapes(a, TopAbs_VERTEX, a_vertices);
IfcGeom::impl::tree<int> tree;
ifcopenshell::geom::impl::tree<int> tree;
// Add faces to tree
for (int i = 1; i <= a_faces.Extent(); ++i) {
@@ -573,8 +573,8 @@ int IfcGeom::util::eliminate_touching_operands(double prec, const TopoDS_Shape &
return N;
}
bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_input, const NCollection_List<TopoDS_Shape> & b_input, TopoDS_Shape & result, double eps, ::logger& logger) {
IfcGeom::impl::tree<int> edge_tree;
bool ifcopenshell::geom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_input, const NCollection_List<TopoDS_Shape> & b_input, TopoDS_Shape & result, double eps, ::logger& logger) {
ifcopenshell::geom::impl::tree<int> edge_tree;
NCollection_List<TopoDS_Shape> ab_input = b_input;
ab_input.Prepend(a_input);
@@ -756,7 +756,7 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_
// Now build a tree to find inner wires contained in other inner wires
// NB first wire is *not* in this tree
IfcGeom::impl::tree<int> wire_tree;
ifcopenshell::geom::impl::tree<int> wire_tree;
for (size_t wire_index = 1; wire_index < wires.size(); ++wire_index) {
wire_tree.add(wire_index, wires[wire_index]);
}
@@ -806,11 +806,11 @@ bool IfcGeom::util::boolean_subtraction_2d_using_builder(const TopoDS_Shape & a_
return true;
}
void IfcGeom::util::points_on_planar_face_generator::reset() {
void ifcopenshell::geom::util::points_on_planar_face_generator::reset() {
i = j = (int)inset_;
}
bool IfcGeom::util::points_on_planar_face_generator::operator()(gp_Pnt& p) {
bool ifcopenshell::geom::util::points_on_planar_face_generator::operator()(gp_Pnt& p) {
while (j < N) {
double u = u0 + (u1 - u0) * i / N;
double v = v0 + (v1 - v0) * j / N;
@@ -832,7 +832,7 @@ bool IfcGeom::util::points_on_planar_face_generator::operator()(gp_Pnt& p) {
}
bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const TopoDS_Shape& a_input, const NCollection_List<TopoDS_Shape>& b_input, BOPAlgo_Operation op, TopoDS_Shape& result, double fuzziness) {
bool ifcopenshell::geom::util::boolean_operation(const boolean_settings& settings, const TopoDS_Shape& a_input, const NCollection_List<TopoDS_Shape>& b_input, BOPAlgo_Operation op, TopoDS_Shape& result, double fuzziness) {
using namespace std::string_literals;
const bool do_unify = true;
@@ -1239,7 +1239,7 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
TopExp::MapShapes(bb, TopAbs_EDGE, edges);
TopExp::MapShapesAndAncestors(bb, TopAbs_EDGE, TopAbs_FACE, map);
}
IfcGeom::impl::tree<int> tree;
ifcopenshell::geom::impl::tree<int> tree;
for (int i = 1; i <= edges.Extent(); ++i) {
tree.add(i, edges.FindKey(i));
}
@@ -1425,13 +1425,13 @@ bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const To
return success && !result.IsNull();
}
bool IfcGeom::util::boolean_operation(const boolean_settings& settings, const TopoDS_Shape& a, const TopoDS_Shape& b, BOPAlgo_Operation op, TopoDS_Shape& result, double fuzziness) {
bool ifcopenshell::geom::util::boolean_operation(const boolean_settings& settings, const TopoDS_Shape& a, const TopoDS_Shape& b, BOPAlgo_Operation op, TopoDS_Shape& result, double fuzziness) {
NCollection_List<TopoDS_Shape> bs;
bs.Append(b);
return boolean_operation(settings, a, bs, op, result, fuzziness);
}
TopoDS_Shape IfcGeom::util::ensure_fit_for_subtraction(const TopoDS_Shape& shape, double tol) {
TopoDS_Shape ifcopenshell::geom::util::ensure_fit_for_subtraction(const TopoDS_Shape& shape, double tol) {
const bool is_comp = is_compound_of_faces(shape);
if (!is_comp) {
return shape;
@@ -38,7 +38,7 @@
#include "../../../ifcparse/logger.h"
#include "../ifc_geomlibrary_api.h"
namespace IfcGeom {
namespace ifcopenshell::geom {
namespace util {
IFC_GEOMLIBRARY_API void copy_operand(const NCollection_List<TopoDS_Shape>& l, NCollection_List<TopoDS_Shape>& r);
@@ -97,7 +97,7 @@ namespace IfcGeom {
bool debug, attempt_2d;
double precision;
// Set by callers that carry a per-conversion logger (e.g. kernels deriving
// from AbstractKernel). Falls back to the global ::logger::root() singleton.
// from abstract_kernel). Falls back to the global ::logger::root() singleton.
::logger* logger = nullptr;
::logger& log() const { return logger ? *logger : ::logger::root(); }
};
@@ -2,11 +2,10 @@
#include <Geom_BSplineSurface.hxx>
using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
using namespace ifcopenshell::geom;
using namespace ifcopenshell::geom::kernels;
bool OpenCascadeKernel::convert(const taxonomy::bspline_surface::ptr bs, Handle(Geom_Surface) surf) {
bool open_cascade_kernel::convert(const taxonomy::bspline_surface::ptr bs, Handle(Geom_Surface) surf) {
const bool is_rational = !!bs->weights;
NCollection_Array2<gp_Pnt> Poles(0, (int)bs->control_points.size() - 1, 0, (int)(*bs->control_points.begin()).size() - 1);
+19 -19
View File
@@ -6,7 +6,7 @@
#define GU_CULLING_EPSILON_RAY_TRIANGLE FLT_EPSILON*FLT_EPSILON
#define PX_MAX_F32 3.4028234663852885981170418348452e+38F
typedef uint32_t PxU32;
typedef uint32_t px_u32;
// Why can't I use std::clamp?
template<typename TC>
@@ -357,23 +357,23 @@ double distanceTriangleTriangleSquared(gp_Vec& cp, gp_Vec& cq, const std::array<
//Based on the paper A Fast Triangle-Triangle Intersection Test by T. Moeller
//http://web.stanford.edu/class/cs277/resources/papers/Moller1997b.pdf
namespace {
struct Interval
struct interval
{
double min;
double max;
gp_Vec minPoint;
gp_Vec maxPoint;
Interval() : min(FLT_MAX), max(-FLT_MAX), minPoint(gp_Vec(NAN, NAN, NAN)), maxPoint(gp_Vec(NAN, NAN, NAN)) { }
interval() : min(FLT_MAX), max(-FLT_MAX), minPoint(gp_Vec(NAN, NAN, NAN)), maxPoint(gp_Vec(NAN, NAN, NAN)) { }
static bool overlapOrTouch(const Interval& a, const Interval& b)
static bool overlapOrTouch(const interval& a, const interval& b)
{
return !(a.min > b.max || b.min > a.max);
}
static Interval intersection(const Interval& a, const Interval& b)
static interval intersection(const interval& a, const interval& b)
{
Interval result;
interval result;
if (!overlapOrTouch(a, b))
return result;
@@ -407,9 +407,9 @@ namespace {
// https://github.com/NVIDIA-Omniverse/PhysX/blob/main/LICENSE.md
// https://github.com/NVIDIA-Omniverse/PhysX/blob/main/physx/source/geomutils/src/intersection/GuIntersectionTriangleTriangle.cpp
// With minor modifications to use gp_Vec type.
static Interval computeInterval(double distanceA, double distanceB, double distanceC, const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, const gp_Vec& dir)
static interval computeInterval(double distanceA, double distanceB, double distanceC, const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, const gp_Vec& dir)
{
Interval i;
interval i;
const bool bA = distanceA > 0;
const bool bB = distanceB > 0;
@@ -441,7 +441,7 @@ static Interval computeInterval(double distanceA, double distanceB, double dista
// https://github.com/NVIDIA-Omniverse/PhysX/blob/main/LICENSE.md
// https://github.com/NVIDIA-Omniverse/PhysX/blob/main/physx/source/geomutils/src/intersection/GuIntersectionTriangleTriangle.cpp
// With minor modifications to use gp_Vec type.
double orient2d(const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, PxU32 x, PxU32 y)
double orient2d(const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, px_u32 x, px_u32 y)
{
return (a.Coord(y) - c.Coord(y)) * (b.Coord(x) - c.Coord(x)) - (a.Coord(x) - c.Coord(x)) * (b.Coord(y) - c.Coord(y));
}
@@ -450,7 +450,7 @@ double orient2d(const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, PxU32 x, PxU3
// https://github.com/NVIDIA-Omniverse/PhysX/blob/main/LICENSE.md
// https://github.com/NVIDIA-Omniverse/PhysX/blob/main/physx/source/geomutils/src/intersection/GuIntersectionTriangleTriangle.cpp
// With minor modifications to use gp_Vec type.
double pointInTriangle(const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, const gp_Vec& point, PxU32 x, PxU32 y)
double pointInTriangle(const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, const gp_Vec& point, px_u32 x, px_u32 y)
{
const double ab = orient2d(a, b, point, x, y);
const double bc = orient2d(b, c, point, x, y);
@@ -466,7 +466,7 @@ double pointInTriangle(const gp_Vec& a, const gp_Vec& b, const gp_Vec& c, const
// https://github.com/NVIDIA-Omniverse/PhysX/blob/main/LICENSE.md
// https://github.com/NVIDIA-Omniverse/PhysX/blob/main/physx/source/geomutils/src/intersection/GuIntersectionTriangleTriangle.cpp
// With minor modifications to use gp_Vec type.
double linesIntersect(const gp_Vec& startA, const gp_Vec& endA, const gp_Vec& startB, const gp_Vec& endB, PxU32 x, PxU32 y)
double linesIntersect(const gp_Vec& startA, const gp_Vec& endA, const gp_Vec& startB, const gp_Vec& endB, px_u32 x, px_u32 y)
{
const double aaS = orient2d(startA, endA, startB, x, y);
const double aaE = orient2d(startA, endA, endB, x, y);
@@ -487,7 +487,7 @@ double linesIntersect(const gp_Vec& startA, const gp_Vec& endA, const gp_Vec& st
// https://github.com/NVIDIA-Omniverse/PhysX/blob/main/LICENSE.md
// https://github.com/NVIDIA-Omniverse/PhysX/blob/main/physx/source/geomutils/src/intersection/GuIntersectionTriangleTriangle.cpp
// With minor modifications to use gp_Vec type.
void getProjectionIndices(gp_Vec normal, PxU32& x, PxU32& y)
void getProjectionIndices(gp_Vec normal, px_u32& x, px_u32& y)
{
normal.SetCoord(std::abs(normal.X()), std::abs(normal.Y()), std::abs(normal.Z()));
@@ -517,8 +517,8 @@ void getProjectionIndices(gp_Vec normal, PxU32& x, PxU32& y)
// With minor modifications to use gp_Vec type.
bool trianglesIntersectCoplanar(const gp_Vec& p1_n, const gp_Vec& a1, const gp_Vec& b1, const gp_Vec& c1, const gp_Vec& a2, const gp_Vec& b2, const gp_Vec& c2)
{
PxU32 x = 0;
PxU32 y = 0;
px_u32 x = 0;
px_u32 y = 0;
getProjectionIndices(p1_n, x, y);
const double third = (1.0 / 3.0);
@@ -570,18 +570,18 @@ bool trianglesIntersect(const gp_Vec& a1, const gp_Vec& b1, const gp_Vec& c1, co
const double l2 = intersectionDirection.SquareMagnitude();
intersectionDirection *= 1.0f / std::sqrt(l2);
const Interval i1 = computeInterval(p2ToA, p2ToB, p2ToC, a1, b1, c1, intersectionDirection);
const Interval i2 = computeInterval(p1ToA, p1ToB, p1ToC, a2, b2, c2, intersectionDirection);
const interval i1 = computeInterval(p2ToA, p2ToB, p2ToC, a1, b1, c1, intersectionDirection);
const interval i2 = computeInterval(p1ToA, p1ToB, p1ToC, a2, b2, c2, intersectionDirection);
if (Interval::overlapOrTouch(i1, i2))
if (interval::overlapOrTouch(i1, i2))
{
/*if (intersection)
{
const Interval i = Interval::intersection(i1, i2);
const interval i = interval::intersection(i1, i2);
intersection->p0 = i.minPoint;
intersection->p1 = i.maxPoint;
}*/
const Interval i = Interval::intersection(i1, i2);
const interval i = interval::intersection(i1, i2);
int1 = i.minPoint;
int2 = i.maxPoint;
return true;
@@ -2,11 +2,10 @@
#include <BRepPrimAPI_MakePrism.hxx>
using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
using namespace ifcopenshell::geom;
using namespace ifcopenshell::geom::kernels;
bool OpenCascadeKernel::convert(const taxonomy::extrusion::ptr extrusion, TopoDS_Shape& shape) {
bool open_cascade_kernel::convert(const taxonomy::extrusion::ptr extrusion, TopoDS_Shape& shape) {
const double& height = extrusion->depth;
if (height < settings_.get<settings::Precision>().get()) {
@@ -71,7 +70,7 @@ bool OpenCascadeKernel::convert(const taxonomy::extrusion::ptr extrusion, TopoDS
return !shape.IsNull();
}
bool OpenCascadeKernel::convert_impl(const taxonomy::extrusion::ptr extrusion, IfcGeom::ConversionResults& results) {
bool open_cascade_kernel::convert_impl(const taxonomy::extrusion::ptr extrusion, ifcopenshell::geom::conversion_results& results) {
return handle_occt_exception([&]() -> bool {
TopoDS_Shape shape;
@@ -79,10 +78,10 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::extrusion::ptr extrusion, I
return false;
}
results.emplace_back(ConversionResult(
results.emplace_back(conversion_result(
extrusion->instance.id(),
extrusion->matrix,
new OpenCascadeShape(shape),
new open_cascade_shape(shape),
extrusion->surface_style
));
return true;
+23 -24
View File
@@ -63,15 +63,14 @@
#include "wire_utils.h"
#include "base_utils.h"
using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
using namespace IfcGeom::util;
using namespace ifcopenshell::geom;
using namespace ifcopenshell::geom::kernels;
using namespace ifcopenshell::geom::util;
namespace {
struct surface_creation_visitor {
OpenCascadeKernel* kernel;
open_cascade_kernel* kernel;
Handle(Geom_Surface) result;
Handle(Geom_Surface) operator()(const taxonomy::bspline_surface::ptr& bs) {
@@ -122,34 +121,34 @@ namespace {
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))));
open_cascade_kernel::convert_xyz2<gp_Pnt>(m.col(3)),
open_cascade_kernel::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))
open_cascade_kernel::convert_xyz2<gp_Pnt>(m.col(3)),
open_cascade_kernel::convert_xyz2<gp_Dir>(m.col(2)),
open_cascade_kernel::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))
open_cascade_kernel::convert_xyz2<gp_Pnt>(m.col(3)),
open_cascade_kernel::convert_xyz2<gp_Dir>(m.col(2)),
open_cascade_kernel::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))
open_cascade_kernel::convert_xyz2<gp_Pnt>(m.col(3)),
open_cascade_kernel::convert_xyz2<gp_Dir>(m.col(2)),
open_cascade_kernel::convert_xyz2<gp_Dir>(m.col(0))
), t->radius1, t->radius2));
}
@@ -204,7 +203,7 @@ namespace {
result = Handle(Geom_Surface)(new Geom_SurfaceOfLinearExtrusion(
crv,
OpenCascadeKernel::convert_xyz<gp_Dir>(*e->direction)
open_cascade_kernel::convert_xyz<gp_Dir>(*e->direction)
));
result->Transform(tr);
@@ -214,8 +213,8 @@ namespace {
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));
open_cascade_kernel::convert_xyz<gp_Pnt>(*e->axis_origin),
open_cascade_kernel::convert_xyz<gp_Dir>(*e->direction));
gp_Trsf tr;
if (e->matrix && !e->matrix->is_identity()) {
@@ -257,7 +256,7 @@ namespace {
};
}
Handle(Geom_Surface) OpenCascadeKernel::convert_surface(const taxonomy::ptr surface) {
Handle(Geom_Surface) open_cascade_kernel::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;
@@ -266,7 +265,7 @@ Handle(Geom_Surface) OpenCascadeKernel::convert_surface(const taxonomy::ptr surf
}
}
bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& result, bool reversed_surface) {
bool open_cascade_kernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& result, bool reversed_surface) {
#ifdef IFOPSH_DEBUG
std::ostringstream oss;
face->print(oss);
@@ -625,16 +624,16 @@ bool OpenCascadeKernel::convert(const taxonomy::face::ptr face, TopoDS_Shape& re
return true;
}
bool OpenCascadeKernel::convert_impl(const taxonomy::face::ptr face, IfcGeom::ConversionResults& results) {
bool open_cascade_kernel::convert_impl(const taxonomy::face::ptr face, ifcopenshell::geom::conversion_results& results) {
return handle_occt_exception([&]() -> bool {
TopoDS_Shape shape;
if (!convert(face, shape)) {
return false;
}
results.emplace_back(ConversionResult(
results.emplace_back(conversion_result(
face->instance.id(),
new OpenCascadeShape(shape),
new open_cascade_shape(shape),
face->surface_style
));
return true;
@@ -6,7 +6,7 @@
#include <TopoDS_Iterator.hxx>
/* Returns whether wire conforms to a polyhedron, i.e. only edges with linear curves*/
bool IfcGeom::util::is_polyhedron(const TopoDS_Wire & wire) {
bool ifcopenshell::geom::util::is_polyhedron(const TopoDS_Wire & wire) {
double a, b;
TopLoc_Location l;
@@ -26,7 +26,7 @@
#include <map>
#include <vector>
namespace IfcGeom {
namespace ifcopenshell::geom {
namespace util {
/* Returns whether wire conforms to a polyhedron, i.e. only edges with linear curves*/
@@ -4,7 +4,7 @@
#include "wire_utils.h"
namespace {
void find_neighbours(IfcGeom::impl::tree<int>& tree, std::vector<std::unique_ptr<gp_Pnt>>& pnts, std::set<int>& visited, int p, double eps) {
void find_neighbours(ifcopenshell::geom::impl::tree<int>& tree, std::vector<std::unique_ptr<gp_Pnt>>& pnts, std::set<int>& visited, int p, double eps) {
visited.insert(p);
Bnd_Box b;
@@ -25,16 +25,16 @@ namespace {
}
}
IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
OpenCascadeKernel* kernel,
const ifcopenshell::geometry::taxonomy::shell::ptr shell
ifcopenshell::geom::open_cascade_kernel::faceset_helper::faceset_helper(
open_cascade_kernel* kernel,
const ifcopenshell::geom::taxonomy::shell::ptr shell
)
: kernel_(kernel)
, non_manifold_(false)
{
// @todo use pointers?
std::vector<ifcopenshell::geometry::taxonomy::point3::ptr> points;
std::vector<ifcopenshell::geometry::taxonomy::loop::ptr> loops;
std::vector<ifcopenshell::geom::taxonomy::point3::ptr> points;
std::vector<ifcopenshell::geom::taxonomy::loop::ptr> loops;
std::set<uint32_t> point_identities_visited;
for (auto& f : shell->children) {
@@ -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 = std::get<ifcopenshell::geometry::taxonomy::point3::ptr>(i == 0 ? e->start : e->end);
auto& p = std::get<ifcopenshell::geom::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);
@@ -56,7 +56,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
std::vector<std::unique_ptr<gp_Pnt>> pnts(points.size());
std::vector<TopoDS_Vertex> vertices(pnts.size());
IfcGeom::impl::tree<int> tree;
ifcopenshell::geom::impl::tree<int> tree;
BRep_Builder B;
@@ -64,7 +64,7 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
for (size_t i = 0; i < points.size(); ++i) {
gp_Pnt* p = new gp_Pnt(convert_xyz<gp_Pnt>(*points[i]));
pnts[i].reset(p);
B.MakeVertex(vertices[i], *p, Precision::Confusion());
B.MakeVertex(vertices[i], *p, ::Precision::Confusion());
tree.add(i, vertices[i]);
box.Add(*p);
}
@@ -86,12 +86,12 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
double bdiff = std::numeric_limits<double>::infinity();
for (size_t i = 0; i < 3; ++i) {
const double d = bmax[i] - bmin[i];
if (d > kernel->settings().get<ifcopenshell::geometry::settings::Precision>().get() * 10. && d < bdiff) {
if (d > kernel->settings().get<ifcopenshell::geom::settings::Precision>().get() * 10. && d < bdiff) {
bdiff = d;
}
}
eps_ = kernel->settings().get<ifcopenshell::geometry::settings::Precision>().get() * 10. * (std::min)(1.0, bdiff);
eps_ = kernel->settings().get<ifcopenshell::geom::settings::Precision>().get() * 10. * (std::min)(1.0, bdiff);
size_t loops_removed, non_manifold, duplicate_faces;
@@ -111,10 +111,10 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
edge_use.clear();
if (eps_ < Precision::Confusion()) {
if (eps_ < ::Precision::Confusion()) {
// occt uses some hard coded precision values, don't go smaller than that.
// @todo, can be reset though with BRepLib::Precision(double)
eps_ = Precision::Confusion();
eps_ = ::Precision::Confusion();
}
std::vector<bool> retained(pnts.size());
@@ -210,14 +210,14 @@ IfcGeom::OpenCascadeKernel::faceset_helper::faceset_helper(
}
}
void IfcGeom::OpenCascadeKernel::faceset_helper::loop_(const ifcopenshell::geometry::taxonomy::loop::ptr ps, const std::function<void(int, int, bool)>& callback) {
void ifcopenshell::geom::open_cascade_kernel::faceset_helper::loop_(const ifcopenshell::geom::taxonomy::loop::ptr ps, const std::function<void(int, int, bool)>& callback) {
if (ps->children.size() < 3) {
return;
}
for (auto& edge : ps->children) {
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 A = std::get<ifcopenshell::geom::taxonomy::point3::ptr>(edge->start)->identity();
auto B = std::get<ifcopenshell::geom::taxonomy::point3::ptr>(edge->end)->identity();
auto C = vertex_mapping_[A], D = vertex_mapping_[B];
bool fwd = C < D;
if (!fwd) {
@@ -232,7 +232,7 @@ void IfcGeom::OpenCascadeKernel::faceset_helper::loop_(const ifcopenshell::geome
}
}
bool IfcGeom::OpenCascadeKernel::faceset_helper::edge(int A, int B, TopoDS_Edge& e) {
bool ifcopenshell::geom::open_cascade_kernel::faceset_helper::edge(int A, int B, TopoDS_Edge& e) {
auto it = edges_.find({ A, B });
if (it == edges_.end()) {
return false;
@@ -241,7 +241,7 @@ bool IfcGeom::OpenCascadeKernel::faceset_helper::edge(int A, int B, TopoDS_Edge&
return true;
}
bool IfcGeom::OpenCascadeKernel::faceset_helper::wire(const ifcopenshell::geometry::taxonomy::loop::ptr loop, TopoDS_Wire& w) {
bool ifcopenshell::geom::open_cascade_kernel::faceset_helper::wire(const ifcopenshell::geom::taxonomy::loop::ptr loop, TopoDS_Wire& w) {
NCollection_List<TopoDS_Shape> ws;
if (!wires(loop, ws)) {
return false;
@@ -250,7 +250,7 @@ bool IfcGeom::OpenCascadeKernel::faceset_helper::wire(const ifcopenshell::geomet
return true;
}
bool IfcGeom::OpenCascadeKernel::faceset_helper::wires(const ifcopenshell::geometry::taxonomy::loop::ptr loop, NCollection_List<TopoDS_Shape>& wires) {
bool ifcopenshell::geom::open_cascade_kernel::faceset_helper::wires(const ifcopenshell::geom::taxonomy::loop::ptr loop, NCollection_List<TopoDS_Shape>& wires) {
if (duplicates_.find(loop->identity()) != duplicates_.end()) {
return false;
}
@@ -272,10 +272,10 @@ bool IfcGeom::OpenCascadeKernel::faceset_helper::wires(const ifcopenshell::geome
wire.Closed(true);
NCollection_List<TopoDS_Shape> results;
if (!kernel_->settings().get<ifcopenshell::geometry::settings::NoWireIntersectionCheck>().get() && util::wire_intersections(wire, results, {
!kernel_->settings().get<ifcopenshell::geometry::settings::NoWireIntersectionCheck>().get(),
!kernel_->settings().get<ifcopenshell::geometry::settings::NoWireIntersectionTolerance>().get(), 0.,
kernel_->settings().get<ifcopenshell::geometry::settings::Precision>().get()}))
if (!kernel_->settings().get<ifcopenshell::geom::settings::NoWireIntersectionCheck>().get() && util::wire_intersections(wire, results, {
!kernel_->settings().get<ifcopenshell::geom::settings::NoWireIntersectionCheck>().get(),
!kernel_->settings().get<ifcopenshell::geom::settings::NoWireIntersectionTolerance>().get(), 0.,
kernel_->settings().get<ifcopenshell::geom::settings::Precision>().get()}))
{
::logger::root().warning("GEO", 170, "Self-intersections with " + boost::lexical_cast<std::string>(results.Extent()) + " cycles detected");
non_manifold_ = true;
@@ -290,7 +290,7 @@ bool IfcGeom::OpenCascadeKernel::faceset_helper::wires(const ifcopenshell::geome
}
}
IfcGeom::OpenCascadeKernel::faceset_helper::~faceset_helper() {
ifcopenshell::geom::open_cascade_kernel::faceset_helper::~faceset_helper() {
// @todo this is super ugly, but how else can we be notified that the unique_ptr goes out of scope?
// Perhaps just supply a custom std::deleter?
kernel_->faceset_helper_ = nullptr;
+23 -23
View File
@@ -34,7 +34,7 @@
#include <ShapeFix_Shape.hxx>
#include <NCollection_IncAllocator.hxx>
using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geom;
namespace {
@@ -152,8 +152,8 @@ namespace {
surf = BRep_Tool::Surface(TopoDS::Face(s));
}
if ((s.ShapeType() == TopAbs_FACE && IfcGeom::util::split_solid_by_surface(i, surf, a, b)) ||
(s.ShapeType() == TopAbs_SHELL && IfcGeom::util::split_solid_by_shell(i, s, a, b))) {
if ((s.ShapeType() == TopAbs_FACE && ifcopenshell::geom::util::split_solid_by_surface(i, surf, a, b)) ||
(s.ShapeType() == TopAbs_SHELL && ifcopenshell::geom::util::split_solid_by_shell(i, s, a, b))) {
slices.push_back(b);
i = a;
} else {
@@ -167,7 +167,7 @@ namespace {
}
bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const std::vector< std::vector<opencascade::handle<Geom_Surface>>>& surfaces, const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>& styles, ConversionResults& result, double tol) {
bool ifcopenshell::geom::util::apply_folded_layerset(const conversion_results& items, const std::vector< std::vector<opencascade::handle<Geom_Surface>>>& surfaces, const std::vector<ifcopenshell::geom::taxonomy::style::ptr>& styles, conversion_results& result, double tol) {
Bnd_Box bb;
TopoDS_Shape input;
flatten_shape_list(items, input, false, false, tol);
@@ -249,11 +249,11 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const
} else if (shells.Extent() == 1) {
for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) {
TopoDS_Shape a, b;
if (split_solid_by_shell(std::static_pointer_cast<OpenCascadeShape>(it->Shape())->shape(), shells.First(), a, b, tol)) {
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(b), (!!styles[0] ? styles[0] : it->StylePtr())));
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(a), (!!styles[1] ? styles[1] : it->StylePtr())));
if (split_solid_by_shell(std::static_pointer_cast<open_cascade_shape>(it->Shape())->shape(), shells.First(), a, b, tol)) {
result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(b), (!!styles[0] ? styles[0] : it->StylePtr())));
result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(a), (!!styles[1] ? styles[1] : it->StylePtr())));
} else {
continue;
}
@@ -263,15 +263,15 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const
} else {
for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) {
const TopoDS_Shape& s = std::static_pointer_cast<OpenCascadeShape>(it->Shape())->shape();
const TopoDS_Shape& s = std::static_pointer_cast<open_cascade_shape>(it->Shape())->shape();
TopoDS_Shape sld = ensure_fit_for_subtraction(s, tol);
std::vector<TopoDS_Shape> slices;
if (split(s, shells, tol, slices) && slices.size() == styles.size()) {
for (size_t i = 0; i < slices.size(); ++i) {
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr())));
result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr())));
}
} else {
return false;
@@ -284,18 +284,18 @@ bool IfcGeom::util::apply_folded_layerset(const ConversionResults& items, const
}
bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::vector<opencascade::handle<Geom_Surface>>& surfaces, const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>& styles, ConversionResults& result, double tol) {
bool ifcopenshell::geom::util::apply_layerset(const conversion_results& items, const std::vector<opencascade::handle<Geom_Surface>>& surfaces, const std::vector<ifcopenshell::geom::taxonomy::style::ptr>& styles, conversion_results& result, double tol) {
if (surfaces.size() < 3) {
return false;
} else if (surfaces.size() == 3) {
for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) {
TopoDS_Shape a, b;
if (split_solid_by_surface(std::static_pointer_cast<OpenCascadeShape>(it->Shape())->shape(), surfaces[1], a, b, tol)) {
result.push_back(ConversionResult(it->ItemId(), it->Placement(),new OpenCascadeShape(b), (!!styles[0] ? styles[0] : it->StylePtr())));
result.push_back(ConversionResult(it->ItemId(), it->Placement(),new OpenCascadeShape(a), (!!styles[1] ? styles[1] : it->StylePtr())));
if (split_solid_by_surface(std::static_pointer_cast<open_cascade_shape>(it->Shape())->shape(), surfaces[1], a, b, tol)) {
result.push_back(conversion_result(it->ItemId(), it->Placement(),new open_cascade_shape(b), (!!styles[0] ? styles[0] : it->StylePtr())));
result.push_back(conversion_result(it->ItemId(), it->Placement(),new open_cascade_shape(a), (!!styles[1] ? styles[1] : it->StylePtr())));
} else {
continue;
}
@@ -309,7 +309,7 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve
// Determine whether sequence of surfaces is consistent with surface normal, so that
// layer operations are applied in the correct order. This seems to be always the case.
Bnd_Box bb;
for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) {
BRepBndLib::Add(it->Shape(), bb);
}
@@ -334,9 +334,9 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve
mass.ChangeCoord() += n1.XYZ();
*/
for (ConversionResults::const_iterator it = items.begin(); it != items.end(); ++it) {
for (conversion_results::const_iterator it = items.begin(); it != items.end(); ++it) {
const TopoDS_Shape& s = std::static_pointer_cast<OpenCascadeShape>(it->Shape())->shape();
const TopoDS_Shape& s = std::static_pointer_cast<open_cascade_shape>(it->Shape())->shape();
TopoDS_Shape sld = ensure_fit_for_subtraction(s, tol);
NCollection_List<TopoDS_Shape> operands;
@@ -354,14 +354,14 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve
/*
// enable this is you want to see how IfcOpenShell has placed the layer surfaces
for (auto& x : operands) {
result.push_back(ConversionResult(it->ItemId(), it->Placement(), x, nullptr));
result.push_back(conversion_result(it->ItemId(), it->Placement(), x, nullptr));
}
*/
std::vector<TopoDS_Shape> slices;
if (split(s, operands, tol, slices) && slices.size() == styles.size()) {
for (size_t i = 0; i < slices.size(); ++i) {
result.push_back(ConversionResult(it->ItemId(), it->Placement(), new OpenCascadeShape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr())));
result.push_back(conversion_result(it->ItemId(), it->Placement(), new open_cascade_shape(slices[i]), (!!styles[i] ? styles[i] : it->StylePtr())));
}
} else {
return false;
@@ -373,7 +373,7 @@ bool IfcGeom::util::apply_layerset(const ConversionResults& items, const std::ve
}
bool IfcGeom::util::split_solid_by_surface(const TopoDS_Shape& input, const opencascade::handle<Geom_Surface>& surface, TopoDS_Shape& front, TopoDS_Shape& back, double tol) {
bool ifcopenshell::geom::util::split_solid_by_surface(const TopoDS_Shape& input, const opencascade::handle<Geom_Surface>& surface, TopoDS_Shape& front, TopoDS_Shape& back, double tol) {
// Use an unbounded surface, that isolate part of the input shape,
// to split this shape into two parts. Make sure that the addition
// of the two result volumes matches that of the input.
@@ -394,7 +394,7 @@ bool IfcGeom::util::split_solid_by_surface(const TopoDS_Shape& input, const open
return b;
}
bool IfcGeom::util::split_solid_by_shell(const TopoDS_Shape& input, const TopoDS_Shape& shell, TopoDS_Shape& front, TopoDS_Shape& back, double tol) {
bool ifcopenshell::geom::util::split_solid_by_shell(const TopoDS_Shape& input, const TopoDS_Shape& shell, TopoDS_Shape& front, TopoDS_Shape& back, double tol) {
// Use a shell, typically one or more connected faces, that isolate part
// of the input shape, to split this shape into two parts. Make sure that
// the addition of the two result volumes matches that of the input.
+4 -4
View File
@@ -9,11 +9,11 @@
#include <list>
#include <vector>
namespace IfcGeom {
namespace ifcopenshell::geom {
namespace util {
bool apply_layerset(const ConversionResults&, const std::vector<opencascade::handle<Geom_Surface>>&, const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>&, ConversionResults&, double tol);
bool apply_layerset(const conversion_results&, const std::vector<opencascade::handle<Geom_Surface>>&, const std::vector<ifcopenshell::geom::taxonomy::style::ptr>&, conversion_results&, double tol);
bool apply_folded_layerset(const ConversionResults&, const std::vector<std::vector<opencascade::handle<Geom_Surface>>>&, const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>&, ConversionResults&, double tol);
bool apply_folded_layerset(const conversion_results&, const std::vector<std::vector<opencascade::handle<Geom_Surface>>>&, const std::vector<ifcopenshell::geom::taxonomy::style::ptr>&, conversion_results&, double tol);
bool split_solid_by_surface(const TopoDS_Shape&, const opencascade::handle<Geom_Surface>&, TopoDS_Shape&, TopoDS_Shape&, double tol);
@@ -21,4 +21,4 @@ namespace IfcGeom {
}
}
#endif
#endif
+7 -8
View File
@@ -29,10 +29,9 @@
#include <BRepBuilderAPI_MakeSolid.hxx>
#include <BRepBuilderAPI_Transform.hxx>
using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
using namespace IfcGeom::util;
using namespace ifcopenshell::geom;
using namespace ifcopenshell::geom::kernels;
using namespace ifcopenshell::geom::util;
// @todo duplicated
namespace {
@@ -55,7 +54,7 @@ bool has_intersection(const std::set<T, Cmp>& A,
}
}
bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& result) {
bool open_cascade_kernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& result) {
if (loft->children.size() < 2) {
return false;
}
@@ -453,15 +452,15 @@ bool OpenCascadeKernel::convert(const taxonomy::loft::ptr loft, TopoDS_Shape& re
return true;
}
bool OpenCascadeKernel::convert_impl(const taxonomy::loft::ptr loft, IfcGeom::ConversionResults& results) {
bool open_cascade_kernel::convert_impl(const taxonomy::loft::ptr loft, ifcopenshell::geom::conversion_results& results) {
TopoDS_Shape shape;
if (!convert(loft, shape)) {
return false;
}
results.emplace_back(ConversionResult(
results.emplace_back(conversion_result(
loft->instance.id(),
loft->matrix,
new OpenCascadeShape(shape),
new open_cascade_shape(shape),
loft->surface_style
));
return true;
+32 -33
View File
@@ -26,17 +26,16 @@
#include <BRepAdaptor_HCompCurve.hxx>
#endif
using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
using namespace IfcGeom::util;
using namespace ifcopenshell::geom;
using namespace ifcopenshell::geom::kernels;
using namespace ifcopenshell::geom::util;
namespace {
struct curve_creation_visitor {
OpenCascadeKernel* kernel;
OpenCascadeKernel::curve_creation_visitor_result_type result;
open_cascade_kernel* kernel;
open_cascade_kernel::curve_creation_visitor_result_type result;
OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::bspline_curve::ptr& bc) {
open_cascade_kernel::curve_creation_visitor_result_type operator()(const taxonomy::bspline_curve::ptr& bc) {
const bool is_rational = !!bc->weights;
@@ -60,7 +59,7 @@ namespace {
i = 0;
for (auto it = bc->control_points.begin(); it != bc->control_points.end(); ++it, ++i) {
Poles(i) = OpenCascadeKernel::convert_xyz<gp_Pnt>(**it);
Poles(i) = open_cascade_kernel::convert_xyz<gp_Pnt>(**it);
}
i = 0;
@@ -80,22 +79,22 @@ namespace {
}
}
OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::line::ptr& l) {
open_cascade_kernel::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))));
return result = Handle(Geom_Curve)(new Geom_Line(open_cascade_kernel::convert_xyz2<gp_Pnt>(m.col(3)), open_cascade_kernel::convert_xyz2<gp_Dir>(m.col(2))));
}
OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::circle::ptr& c) {
open_cascade_kernel::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));
return result = Handle(Geom_Curve)(new Geom_Circle(gp_Ax2(open_cascade_kernel::convert_xyz2<gp_Pnt>(m.col(3)), open_cascade_kernel::convert_xyz2<gp_Dir>(m.col(2)), open_cascade_kernel::convert_xyz2<gp_Dir>(m.col(0))), c->radius));
}
OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::ellipse::ptr& e) {
open_cascade_kernel::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));
return result = Handle(Geom_Curve)(new Geom_Ellipse(gp_Ax2(open_cascade_kernel::convert_xyz2<gp_Pnt>(m.col(3)), open_cascade_kernel::convert_xyz2<gp_Dir>(m.col(2)), open_cascade_kernel::convert_xyz2<gp_Dir>(m.col(0))), e->radius, e->radius2));
}
OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::loop::ptr& l) {
open_cascade_kernel::curve_creation_visitor_result_type operator()(const taxonomy::loop::ptr& l) {
TopoDS_Wire wire;
if (!kernel->convert(l, wire)) {
throw std::runtime_error("Failed to convert loop to wire");
@@ -103,7 +102,7 @@ namespace {
return result = wire;
}
OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::edge::ptr& e) {
open_cascade_kernel::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.index() != e->end.index()) {
@@ -156,8 +155,8 @@ namespace {
if (e_start.index() == 0) {
E = BRepBuilderAPI_MakeEdge(curve).Edge();
} 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));
auto p1 = open_cascade_kernel::convert_xyz<gp_Pnt>(*std::get<taxonomy::point3::ptr>(e_start));
auto p2 = open_cascade_kernel::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();
@@ -186,8 +185,8 @@ namespace {
if (e->start.index() != 1) {
throw std::runtime_error("Non-cartesian trim on edge without curve");
}
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));
auto p1 = open_cascade_kernel::convert_xyz<gp_Pnt>(*std::get<taxonomy::point3::ptr>(e->start));
auto p2 = open_cascade_kernel::convert_xyz<gp_Pnt>(*std::get<taxonomy::point3::ptr>(e->end));
E = BRepBuilderAPI_MakeEdge(p1, p2).Edge();
}
@@ -214,7 +213,7 @@ namespace {
return result = W;
}
OpenCascadeKernel::curve_creation_visitor_result_type operator()(const taxonomy::offset_curve::ptr&) {
open_cascade_kernel::curve_creation_visitor_result_type operator()(const taxonomy::offset_curve::ptr&) {
// @todo
throw std::runtime_error("Offset curves not supported as part of loop");
}
@@ -222,7 +221,7 @@ namespace {
}
OpenCascadeKernel::curve_creation_visitor_result_type OpenCascadeKernel::convert_curve(const taxonomy::ptr curve) {
open_cascade_kernel::curve_creation_visitor_result_type open_cascade_kernel::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;
@@ -233,7 +232,7 @@ OpenCascadeKernel::curve_creation_visitor_result_type OpenCascadeKernel::convert
#include "../../../ifcparse/file.h"
bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wire) {
bool open_cascade_kernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wire) {
NCollection_List<TopoDS_Shape> converted_segments;
/*
@@ -294,14 +293,14 @@ bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wir
NCollection_List<TopoDS_Shape>::Iterator it(converted_segments);
bool force_close = false;
if (loop->instance && loop->instance.as<express::Entity>()) {
auto inst = loop->instance.as<express::Entity>();
auto file = loop->instance.as<express::Entity>().file();
if (loop->instance && loop->instance.as<express::entity>()) {
auto inst = loop->instance.as<express::entity>();
auto file = loop->instance.as<express::entity>().file();
auto profile = file->get_inverse(inst.id(), file->schema()->declaration_by_name("IfcProfileDef"), -1);
force_close = profile.size() > 0;
}
wire_builder bld(precision_, loop->instance ? loop->instance.as<express::Entity>() : express::Base{});
wire_builder bld(precision_, loop->instance ? loop->instance.as<express::entity>() : express::base{});
shape_pair_enumerate(it, bld, force_close);
wire = bld.wire();
@@ -395,26 +394,26 @@ bool OpenCascadeKernel::convert(const taxonomy::loop::ptr loop, TopoDS_Wire& wir
return true;
}
bool OpenCascadeKernel::convert_impl(const taxonomy::loop::ptr loop, IfcGeom::ConversionResults& results) {
bool open_cascade_kernel::convert_impl(const taxonomy::loop::ptr loop, ifcopenshell::geom::conversion_results& results) {
TopoDS_Wire shape;
if (!convert(loop, shape)) {
return false;
}
results.emplace_back(ConversionResult(
results.emplace_back(conversion_result(
loop->instance.id(),
new OpenCascadeShape(shape),
new open_cascade_shape(shape),
loop->surface_style
));
return true;
}
bool OpenCascadeKernel::convert_impl(const taxonomy::edge::ptr edge, IfcGeom::ConversionResults& results) {
bool open_cascade_kernel::convert_impl(const taxonomy::edge::ptr edge, ifcopenshell::geom::conversion_results& results) {
TopoDS_Wire shape = std::get<TopoDS_Wire>(convert_curve(edge));
results.emplace_back(ConversionResult(
results.emplace_back(conversion_result(
edge->instance.id(),
new OpenCascadeShape(shape),
new open_cascade_shape(shape),
edge->surface_style
));
return true;
+5 -6
View File
@@ -1,11 +1,10 @@
#include "OpenCascadeKernel.h"
using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
using namespace IfcGeom::util;
using namespace ifcopenshell::geom;
using namespace ifcopenshell::geom::kernels;
using namespace ifcopenshell::geom::util;
bool OpenCascadeKernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf) {
bool open_cascade_kernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& trsf) {
// @todo check
const auto& m = matrix->ccomponents();
gp_Mat mat(
@@ -43,4 +42,4 @@ bool OpenCascadeKernel::convert(const taxonomy::matrix4::ptr matrix, gp_GTrsf& t
}
return true;
}
}
+6 -6
View File
@@ -23,7 +23,7 @@
#include <boost/dll/alias.hpp>
namespace ifcopenshell {
namespace geometry {
namespace geom {
namespace kernels {
namespace opencascade_plugin {
@@ -35,8 +35,8 @@ namespace ifcopenshell {
return kernel_plugin_metadata("opencascade");
}
AbstractKernel* create_kernel(ifcopenshell::file*, Settings& settings) {
return new IfcGeom::OpenCascadeKernel(settings);
abstract_kernel* create_kernel(ifcopenshell::file*, ifcopenshell::geom::settings& settings) {
return new ifcopenshell::geom::open_cascade_kernel(settings);
}
void register_plugin(kernel_registry& registry, const plugin::module& module) {
@@ -51,6 +51,6 @@ namespace ifcopenshell {
}
}
BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::opencascade_plugin::plugin_abi, ifcopenshell_plugin_abi_v1)
BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::opencascade_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1)
BOOST_DLL_ALIAS(ifcopenshell::geometry::kernels::opencascade_plugin::register_plugin, ifcopenshell_register_kernel_plugin_v1)
BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::opencascade_plugin::plugin_abi, ifcopenshell_plugin_abi_v1)
BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::opencascade_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1)
BOOST_DLL_ALIAS(ifcopenshell::geom::kernels::opencascade_plugin::register_plugin, ifcopenshell_register_kernel_plugin_v1)
+7 -8
View File
@@ -2,10 +2,9 @@
#include "base_utils.h"
using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
using namespace IfcGeom::util;
using namespace ifcopenshell::geom;
using namespace ifcopenshell::geom::kernels;
using namespace ifcopenshell::geom::util;
namespace {
// @todo move into taxonomy;
@@ -24,7 +23,7 @@ namespace {
}
}
bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shape) {
bool open_cascade_kernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shape) {
std::unique_ptr<faceset_helper> helper_scope;
if (shell_polyhedral(l)) {
helper_scope.reset(new faceset_helper(this, l));
@@ -106,17 +105,17 @@ bool OpenCascadeKernel::convert(const taxonomy::shell::ptr l, TopoDS_Shape& shap
return true;
}
bool OpenCascadeKernel::convert_impl(const taxonomy::shell::ptr shell, IfcGeom::ConversionResults& results) {
bool open_cascade_kernel::convert_impl(const taxonomy::shell::ptr shell, ifcopenshell::geom::conversion_results& results) {
return handle_occt_exception([&]() -> bool {
TopoDS_Shape shape;
if (!convert(shell, shape)) {
return false;
}
results.emplace_back(ConversionResult(
results.emplace_back(conversion_result(
shell->instance.id(),
shell->matrix,
new OpenCascadeShape(shape),
new open_cascade_shape(shape),
shell->surface_style
));
return true;
+7 -8
View File
@@ -26,12 +26,11 @@
#include <ShapeFix_Solid.hxx>
#include <BRepPrimAPI_MakeSphere.hxx>
using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
using namespace IfcGeom::util;
using namespace ifcopenshell::geom;
using namespace ifcopenshell::geom::kernels;
using namespace ifcopenshell::geom::util;
bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape& result) {
bool open_cascade_kernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape& result) {
TopoDS_Shape S;
if (solid->instance.declaration().is("IfcHalfSpaceSolid")) {
@@ -101,17 +100,17 @@ bool OpenCascadeKernel::convert(const taxonomy::solid::ptr solid, TopoDS_Shape&
return !result.IsNull();
}
bool OpenCascadeKernel::convert_impl(const taxonomy::solid::ptr solid, IfcGeom::ConversionResults& results) {
bool open_cascade_kernel::convert_impl(const taxonomy::solid::ptr solid, ifcopenshell::geom::conversion_results& results) {
return handle_occt_exception([&]() -> bool {
TopoDS_Shape shape;
if (!convert(solid, shape)) {
return false;
}
results.emplace_back(ConversionResult(
results.emplace_back(conversion_result(
solid->instance.id(),
solid->matrix,
new OpenCascadeShape(shape),
new open_cascade_shape(shape),
solid->surface_style
));
return true;
@@ -31,10 +31,9 @@
#include <Geom_Circle.hxx>
#include <BRepBuilderAPI_MakeSolid.hxx>
using namespace ifcopenshell::geometry;
using namespace ifcopenshell::geometry::kernels;
using namespace IfcGeom;
using namespace IfcGeom::util;
using namespace ifcopenshell::geom;
using namespace ifcopenshell::geom::kernels;
using namespace ifcopenshell::geom::util;
namespace {
bool wire_is_c1_continuous(const TopoDS_Wire& w, double tol) {
@@ -83,8 +82,8 @@ namespace {
}
}
bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, TopoDS_Shape& result) {
using namespace ifcopenshell::geometry;
bool open_cascade_kernel::convert(const taxonomy::sweep_along_curve::ptr scs, TopoDS_Shape& result) {
using namespace ifcopenshell::geom;
bool applied_temporary_offset = false;
Eigen::Vector3d mean;
@@ -150,7 +149,7 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo
0.,
settings_.get<settings::Precision>().get()
};
if (!IfcGeom::util::convert_wire_to_face(TopoDS::Wire(face_), face, settings)) {
if (!ifcopenshell::geom::util::convert_wire_to_face(TopoDS::Wire(face_), face, settings)) {
return false;
}
} else {
@@ -316,7 +315,7 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo
return true;
}
bool OpenCascadeKernel::convert_impl(const taxonomy::sweep_along_curve::ptr scs, IfcGeom::ConversionResults& results) {
bool open_cascade_kernel::convert_impl(const taxonomy::sweep_along_curve::ptr scs, ifcopenshell::geom::conversion_results& results) {
return handle_occt_exception([&]() -> bool {
TopoDS_Shape shape;
@@ -356,10 +355,10 @@ bool OpenCascadeKernel::convert_impl(const taxonomy::sweep_along_curve::ptr scs,
} else {
m = scs->matrix;
}
results.emplace_back(ConversionResult(
results.emplace_back(conversion_result(
scs->instance.id(),
m,
new OpenCascadeShape(shape),
new open_cascade_shape(shape),
scs->surface_style
));
return true;
+11 -11
View File
@@ -24,7 +24,7 @@
#include "../../../ifcparse/logger.h"
#include "base_utils.h"
bool IfcGeom::util::wire_is_c1_continuous(const TopoDS_Wire & w, double tol) {
bool ifcopenshell::geom::util::wire_is_c1_continuous(const TopoDS_Wire & w, double tol) {
// NB Note that c0 continuity is NOT checked!
NCollection_IndexedDataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher> map;
@@ -57,7 +57,7 @@ bool IfcGeom::util::wire_is_c1_continuous(const TopoDS_Wire & w, double tol) {
return true;
}
bool IfcGeom::util::wire_to_ax(const TopoDS_Wire & wire, gp_Ax2 & directrix) {
bool ifcopenshell::geom::util::wire_to_ax(const TopoDS_Wire & wire, gp_Ax2 & directrix) {
gp_Pnt directrix_origin;
gp_Vec directrix_tangent;
@@ -106,7 +106,7 @@ bool IfcGeom::util::wire_to_ax(const TopoDS_Wire & wire, gp_Ax2 & directrix) {
return true;
}
bool IfcGeom::util::is_single_linear_edge(const TopoDS_Wire & wire) {
bool ifcopenshell::geom::util::is_single_linear_edge(const TopoDS_Wire & wire) {
TopExp_Explorer exp(wire, TopAbs_EDGE);
if (!exp.More()) {
return false;
@@ -121,7 +121,7 @@ bool IfcGeom::util::is_single_linear_edge(const TopoDS_Wire & wire) {
return crv->DynamicType() == STANDARD_TYPE(Geom_Line);
}
bool IfcGeom::util::is_single_circular_edge(const TopoDS_Wire & wire) {
bool ifcopenshell::geom::util::is_single_circular_edge(const TopoDS_Wire & wire) {
TopExp_Explorer exp(wire, TopAbs_EDGE);
if (!exp.More()) {
return false;
@@ -136,7 +136,7 @@ bool IfcGeom::util::is_single_circular_edge(const TopoDS_Wire & wire) {
return crv->DynamicType() == STANDARD_TYPE(Geom_Circle);
}
void IfcGeom::util::process_sweep_as_extrusion(const TopoDS_Wire & wire, const TopoDS_Wire & section, TopoDS_Shape & result) {
void ifcopenshell::geom::util::process_sweep_as_extrusion(const TopoDS_Wire & wire, const TopoDS_Wire & section, TopoDS_Shape & result) {
TopExp_Explorer exp(wire, TopAbs_EDGE);
TopoDS_Edge e = TopoDS::Edge(exp.Current());
double u, v;
@@ -149,7 +149,7 @@ void IfcGeom::util::process_sweep_as_extrusion(const TopoDS_Wire & wire, const T
result = BRepPrimAPI_MakePrism(face, depth*dir).Shape();
}
void IfcGeom::util::process_sweep_as_revolution(const TopoDS_Wire & wire, const TopoDS_Wire & section, TopoDS_Shape & result) {
void ifcopenshell::geom::util::process_sweep_as_revolution(const TopoDS_Wire & wire, const TopoDS_Wire & section, TopoDS_Shape & result) {
TopExp_Explorer exp(wire, TopAbs_EDGE);
TopoDS_Edge e = TopoDS::Edge(exp.Current());
double u, v;
@@ -161,7 +161,7 @@ void IfcGeom::util::process_sweep_as_revolution(const TopoDS_Wire & wire, const
result = BRepPrimAPI_MakeRevol(face, circ->Axis(), depth).Shape();
}
void IfcGeom::util::process_sweep_as_pipe(const TopoDS_Wire & wire, const TopoDS_Wire & section, TopoDS_Shape & result, bool force_transformed) {
void ifcopenshell::geom::util::process_sweep_as_pipe(const TopoDS_Wire & wire, const TopoDS_Wire & section, TopoDS_Shape & result, bool force_transformed) {
// This tolerance is fairly high due to the linear edge substitution for small (or large radii) conical curves.
const bool is_continuous = wire_is_c1_continuous(wire, 1.e-2);
BRepOffsetAPI_MakePipeShell builder(wire);
@@ -181,7 +181,7 @@ void IfcGeom::util::process_sweep_as_pipe(const TopoDS_Wire & wire, const TopoDS
result = builder.Shape();
}
void IfcGeom::util::sort_edges(const TopoDS_Wire & wire, std::vector<TopoDS_Edge>& sorted_edges) {
void ifcopenshell::geom::util::sort_edges(const TopoDS_Wire & wire, std::vector<TopoDS_Edge>& sorted_edges) {
NCollection_IndexedDataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher> map;
TopExp::MapShapesAndAncestors(wire, TopAbs_VERTEX, TopAbs_EDGE, map);
@@ -232,7 +232,7 @@ void IfcGeom::util::sort_edges(const TopoDS_Wire & wire, std::vector<TopoDS_Edge
// #939: a closed loop causes failed triangulation in 7.3 and artefacts
// in 7.4 so we break up a closed wire into two equal parts.
void IfcGeom::util::break_closed(const TopoDS_Wire & wire, std::vector<TopoDS_Wire>& wires) {
void ifcopenshell::geom::util::break_closed(const TopoDS_Wire & wire, std::vector<TopoDS_Wire>& wires) {
std::vector<TopoDS_Edge> sorted_edges;
sort_edges(wire, sorted_edges);
@@ -257,7 +257,7 @@ void IfcGeom::util::break_closed(const TopoDS_Wire & wire, std::vector<TopoDS_Wi
}
}
void IfcGeom::util::segment_adjacent_non_linear(const TopoDS_Wire & wire, std::vector<TopoDS_Wire>& wires) {
void ifcopenshell::geom::util::segment_adjacent_non_linear(const TopoDS_Wire & wire, std::vector<TopoDS_Wire>& wires) {
std::vector<TopoDS_Edge> sorted_edges;
sort_edges(wire, sorted_edges);
@@ -290,7 +290,7 @@ void IfcGeom::util::segment_adjacent_non_linear(const TopoDS_Wire & wire, std::v
}
// @todo make this generic for other sweeps not just swept disk
void IfcGeom::util::process_sweep(const TopoDS_Wire & wire, double radius, TopoDS_Shape & result) {
void ifcopenshell::geom::util::process_sweep(const TopoDS_Wire & wire, double radius, TopoDS_Shape & result) {
std::vector<TopoDS_Wire> wires, wires_tmp;
segment_adjacent_non_linear(wire, wires_tmp);
for (auto& w : wires_tmp) {
@@ -25,7 +25,7 @@
#include <vector>
namespace IfcGeom {
namespace ifcopenshell::geom {
namespace util {
bool wire_is_c1_continuous(const TopoDS_Wire& w, double tol);
+32 -32
View File
@@ -26,15 +26,15 @@
#include "IfcGeomTree.h"
namespace ifcopenshell {
namespace geometry {
namespace geom {
namespace trees {
namespace opencascade_tree_backends {
inline gp_Pnt make_point(const IfcGeom::tree_point& point) {
inline gp_Pnt make_point(const ifcopenshell::geom::tree_point& point) {
return gp_Pnt(point[0], point[1], point[2]);
}
inline Bnd_Box make_box(const IfcGeom::tree_box& bounds) {
inline Bnd_Box make_box(const ifcopenshell::geom::tree_box& bounds) {
Bnd_Box box;
box.Add(make_point(bounds[0]));
box.Add(make_point(bounds[1]));
@@ -47,13 +47,13 @@ namespace ifcopenshell {
return "opencascade.brep";
}
void add_file(ifcopenshell::file& file, const ifcopenshell::geometry::Settings& settings) override {
void add_file(ifcopenshell::file& file, const ifcopenshell::geom::settings& settings) override {
auto settings_ = settings;
settings_.get<ifcopenshell::geometry::settings::IteratorOutput>().value = ifcopenshell::geometry::settings::NATIVE;
settings_.get<ifcopenshell::geometry::settings::UseWorldCoords>().value = true;
settings_.get<ifcopenshell::geometry::settings::ReorientShells>().value = true;
settings_.get<ifcopenshell::geom::settings::IteratorOutput>().value = ifcopenshell::geom::settings::NATIVE;
settings_.get<ifcopenshell::geom::settings::UseWorldCoords>().value = true;
settings_.get<ifcopenshell::geom::settings::ReorientShells>().value = true;
IfcGeom::Iterator iterator(ifcopenshell::geometry::kernels::construct(&file, "opencascade", settings_), settings_, &file, {}, 1);
ifcopenshell::geom::iterator iterator(ifcopenshell::geom::kernels::construct(&file, "opencascade", settings_), settings_, &file, {}, 1);
if (iterator.initialize()) {
do {
add_element(iterator.get());
@@ -61,43 +61,43 @@ namespace ifcopenshell {
}
}
void add_element(IfcGeom::Element* element) override {
auto* brep = dynamic_cast<IfcGeom::BRepElement*>(element);
void add_element(ifcopenshell::geom::element* element) override {
auto* brep = dynamic_cast<ifcopenshell::geom::brep_element*>(element);
if (!brep) {
throw ifcopenshell::exception("Tree backend 'opencascade.brep' requires native BRep elements");
throw ifcopenshell::exception("Tree backend 'opencascade.brep' requires native brep elements");
}
tree_.add_element(brep);
}
std::vector<express::Entity> select_box(const express::Entity& entity, bool completely_within, double extend) const override {
std::vector<express::entity> select_box(const express::entity& entity, bool completely_within, double extend) const override {
return tree_.select_box(entity, completely_within, extend);
}
std::vector<express::Entity> select_box(const IfcGeom::tree_point& point) const override {
std::vector<express::entity> select_box(const ifcopenshell::geom::tree_point& point) const override {
return tree_.select_box(make_point(point));
}
std::vector<express::Entity> select_box(const IfcGeom::tree_box& bounds, bool completely_within) const override {
std::vector<express::entity> select_box(const ifcopenshell::geom::tree_box& bounds, bool completely_within) const override {
return tree_.select_box(make_box(bounds), completely_within);
}
std::vector<express::Entity> select(const express::Entity& entity, bool completely_within, double extend) const override {
std::vector<express::entity> select(const express::entity& entity, bool completely_within, double extend) const override {
return tree_.select(entity, completely_within, extend);
}
std::vector<express::Entity> select(const IfcGeom::Element* element, bool completely_within, double extend) const override {
auto* brep = dynamic_cast<const IfcGeom::BRepElement*>(element);
std::vector<express::entity> select(const ifcopenshell::geom::element* element, bool completely_within, double extend) const override {
auto* brep = dynamic_cast<const ifcopenshell::geom::brep_element*>(element);
if (!brep) {
throw ifcopenshell::exception("Tree backend 'opencascade.brep' requires BRep elements for select()");
throw ifcopenshell::exception("Tree backend 'opencascade.brep' requires brep elements for select()");
}
return tree_.select(brep, completely_within, extend);
}
std::vector<express::Entity> select(const IfcGeom::tree_point& point, double extend) const override {
std::vector<express::entity> select(const ifcopenshell::geom::tree_point& point, double extend) const override {
return tree_.select(make_point(point), extend);
}
std::vector<IfcGeom::ray_intersection_result> select_ray(const IfcGeom::tree_point& origin, const IfcGeom::tree_point& direction, double length) const override {
std::vector<ifcopenshell::geom::ray_intersection_result> select_ray(const ifcopenshell::geom::tree_point& origin, const ifcopenshell::geom::tree_point& direction, double length) const override {
return tree_.select_ray(make_point(origin), gp_Dir(direction[0], direction[1], direction[2]), length);
}
@@ -117,12 +117,12 @@ namespace ifcopenshell {
tree_.enable_face_styles(enable);
}
const std::vector<ifcopenshell::geometry::taxonomy::style::ptr>& styles() const override {
const std::vector<ifcopenshell::geom::taxonomy::style::ptr>& styles() const override {
return tree_.styles();
}
private:
IfcGeom::opencascade_tree tree_;
ifcopenshell::geom::opencascade_tree tree_;
};
class trianglebvh_tree : public abstract_tree {
@@ -131,12 +131,12 @@ namespace ifcopenshell {
return "opencascade.trianglebvh";
}
void add_file(ifcopenshell::file& file, const ifcopenshell::geometry::Settings& settings) override {
void add_file(ifcopenshell::file& file, const ifcopenshell::geom::settings& settings) override {
auto settings_ = settings;
settings_.get<ifcopenshell::geometry::settings::IteratorOutput>().value = ifcopenshell::geometry::settings::TRIANGULATED;
settings_.get<ifcopenshell::geometry::settings::UseWorldCoords>().value = true;
settings_.get<ifcopenshell::geom::settings::IteratorOutput>().value = ifcopenshell::geom::settings::TRIANGULATED;
settings_.get<ifcopenshell::geom::settings::UseWorldCoords>().value = true;
IfcGeom::Iterator iterator(ifcopenshell::geometry::kernels::construct(&file, "opencascade", settings_), settings_, &file, {}, 1);
ifcopenshell::geom::iterator iterator(ifcopenshell::geom::kernels::construct(&file, "opencascade", settings_), settings_, &file, {}, 1);
if (iterator.initialize()) {
do {
add_element(iterator.get());
@@ -144,28 +144,28 @@ namespace ifcopenshell {
}
}
void add_element(IfcGeom::Element* element) override {
auto* triangulation = dynamic_cast<IfcGeom::TriangulationElement*>(element);
void add_element(ifcopenshell::geom::element* element) override {
auto* triangulation = dynamic_cast<ifcopenshell::geom::triangulation_element*>(element);
if (!triangulation) {
throw ifcopenshell::exception("Tree backend 'opencascade.trianglebvh' requires triangulation elements");
}
tree_.add_element(triangulation);
}
std::vector<IfcGeom::clash> clash_intersection_many(const std::vector<express::Entity>& set_a, const std::vector<express::Entity>& set_b, double tolerance, bool check_all) const override {
std::vector<ifcopenshell::geom::clash> clash_intersection_many(const std::vector<express::entity>& set_a, const std::vector<express::entity>& set_b, double tolerance, bool check_all) const override {
return tree_.clash_intersection_many(set_a, set_b, tolerance, check_all);
}
std::vector<IfcGeom::clash> clash_collision_many(const std::vector<express::Entity>& set_a, const std::vector<express::Entity>& set_b, bool allow_touching) const override {
std::vector<ifcopenshell::geom::clash> clash_collision_many(const std::vector<express::entity>& set_a, const std::vector<express::entity>& set_b, bool allow_touching) const override {
return tree_.clash_collision_many(set_a, set_b, allow_touching);
}
std::vector<IfcGeom::clash> clash_clearance_many(const std::vector<express::Entity>& set_a, const std::vector<express::Entity>& set_b, double clearance, bool check_all) const override {
std::vector<ifcopenshell::geom::clash> clash_clearance_many(const std::vector<express::entity>& set_a, const std::vector<express::entity>& set_b, double clearance, bool check_all) const override {
return tree_.clash_clearance_many(set_a, set_b, clearance, check_all);
}
private:
IfcGeom::opencascade_tree tree_;
ifcopenshell::geom::opencascade_tree tree_;
};
}
@@ -23,7 +23,7 @@
#include <boost/dll/alias.hpp>
namespace ifcopenshell {
namespace geometry {
namespace geom {
namespace trees {
namespace opencascade_brep_tree_plugin {
@@ -50,6 +50,6 @@ namespace ifcopenshell {
}
}
BOOST_DLL_ALIAS(ifcopenshell::geometry::trees::opencascade_brep_tree_plugin::plugin_abi, ifcopenshell_plugin_abi_v1)
BOOST_DLL_ALIAS(ifcopenshell::geometry::trees::opencascade_brep_tree_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1)
BOOST_DLL_ALIAS(ifcopenshell::geometry::trees::opencascade_brep_tree_plugin::register_plugin, ifcopenshell_register_tree_plugin_v1)
BOOST_DLL_ALIAS(ifcopenshell::geom::trees::opencascade_brep_tree_plugin::plugin_abi, ifcopenshell_plugin_abi_v1)
BOOST_DLL_ALIAS(ifcopenshell::geom::trees::opencascade_brep_tree_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1)
BOOST_DLL_ALIAS(ifcopenshell::geom::trees::opencascade_brep_tree_plugin::register_plugin, ifcopenshell_register_tree_plugin_v1)
@@ -23,7 +23,7 @@
#include <boost/dll/alias.hpp>
namespace ifcopenshell {
namespace geometry {
namespace geom {
namespace trees {
namespace opencascade_trianglebvh_tree_plugin {
@@ -50,6 +50,6 @@ namespace ifcopenshell {
}
}
BOOST_DLL_ALIAS(ifcopenshell::geometry::trees::opencascade_trianglebvh_tree_plugin::plugin_abi, ifcopenshell_plugin_abi_v1)
BOOST_DLL_ALIAS(ifcopenshell::geometry::trees::opencascade_trianglebvh_tree_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1)
BOOST_DLL_ALIAS(ifcopenshell::geometry::trees::opencascade_trianglebvh_tree_plugin::register_plugin, ifcopenshell_register_tree_plugin_v1)
BOOST_DLL_ALIAS(ifcopenshell::geom::trees::opencascade_trianglebvh_tree_plugin::plugin_abi, ifcopenshell_plugin_abi_v1)
BOOST_DLL_ALIAS(ifcopenshell::geom::trees::opencascade_trianglebvh_tree_plugin::plugin_metadata, ifcopenshell_plugin_metadata_v1)
BOOST_DLL_ALIAS(ifcopenshell::geom::trees::opencascade_trianglebvh_tree_plugin::register_plugin, ifcopenshell_register_tree_plugin_v1)
@@ -15,7 +15,7 @@
#include <GeomAdaptor_Curve.hxx>
// Returns the first edge of a wire
TopoDS_Edge IfcGeom::util::first_edge(const TopoDS_Wire & w) {
TopoDS_Edge ifcopenshell::geom::util::first_edge(const TopoDS_Wire & w) {
TopoDS_Vertex v1, v2;
TopExp::Vertices(w, v1, v2);
NCollection_IndexedDataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher> wm;
@@ -24,7 +24,7 @@ TopoDS_Edge IfcGeom::util::first_edge(const TopoDS_Wire & w) {
}
// Returns new wire with the edge replaced by a linear edge with the vertex v moved to p
TopoDS_Wire IfcGeom::util::adjust(const TopoDS_Wire & w, const TopoDS_Vertex & v, const gp_Pnt & p) {
TopoDS_Wire ifcopenshell::geom::util::adjust(const TopoDS_Wire & w, const TopoDS_Vertex & v, const gp_Pnt & p) {
NCollection_IndexedDataMap<TopoDS_Shape, NCollection_List<TopoDS_Shape>, TopTools_ShapeMapHasher> map;
TopExp::MapShapesAndAncestors(w, TopAbs_VERTEX, TopAbs_EDGE, map);
@@ -66,7 +66,7 @@ TopoDS_Wire IfcGeom::util::adjust(const TopoDS_Wire & w, const TopoDS_Vertex & v
GC_MakeCircle mc(p1, p2, p3);
if (!mc.IsDone()) {
throw IfcGeom::geometry_exception("Failed to adjust circle");
throw ifcopenshell::geom::geometry_exception("Failed to adjust circle");
}
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(mc.Value(), p1, p3).Edge();
@@ -74,15 +74,15 @@ TopoDS_Wire IfcGeom::util::adjust(const TopoDS_Wire & w, const TopoDS_Vertex & v
builder.Add(edge);
return builder.Wire();
} else {
throw IfcGeom::geometry_exception("Unexpected wire to adjust");
throw ifcopenshell::geom::geometry_exception("Unexpected wire to adjust");
}
}
double IfcGeom::util::deflection_for_approximating_circle(double radius, double param) {
double ifcopenshell::geom::util::deflection_for_approximating_circle(double radius, double param) {
return -radius * std::cos(1. / 2. * param) * std::cos(param) - radius * std::sin(1. / 2. * param) * std::sin(param) + radius;
}
bool IfcGeom::util::create_edge_over_curve_with_log_messages(const opencascade::handle<Geom_Curve>& crv, const double eps, const gp_Pnt& p1, const gp_Pnt& p2, TopoDS_Edge& result) {
bool ifcopenshell::geom::util::create_edge_over_curve_with_log_messages(const opencascade::handle<Geom_Curve>& crv, const double eps, const gp_Pnt& p1, const gp_Pnt& p2, TopoDS_Edge& result) {
if (crv->IsClosed() && p1.Distance(p2) <= eps) {
BRepBuilderAPI_MakeEdge me(crv);
if (me.IsDone()) {
@@ -132,7 +132,7 @@ bool IfcGeom::util::create_edge_over_curve_with_log_messages(const opencascade::
return true;
}
void IfcGeom::util::wire_builder::operator()(const TopoDS_Shape& a) {
void ifcopenshell::geom::util::wire_builder::operator()(const TopoDS_Shape& a) {
const TopoDS_Wire& w = TopoDS::Wire(a);
if (override_next_) {
override_next_ = false;
@@ -143,7 +143,7 @@ void IfcGeom::util::wire_builder::operator()(const TopoDS_Shape& a) {
}
}
void IfcGeom::util::wire_builder::operator()(const TopoDS_Shape& a, const TopoDS_Shape& b, bool last) {
void ifcopenshell::geom::util::wire_builder::operator()(const TopoDS_Shape& a, const TopoDS_Shape& b, bool last) {
TopoDS_Wire w1 = TopoDS::Wire(a);
const TopoDS_Wire& w2 = TopoDS::Wire(b);
@@ -31,7 +31,7 @@
#include <Extrema_ExtPC.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
namespace IfcGeom {
namespace ifcopenshell::geom {
namespace util {
// Returns the first edge of a wire
TopoDS_Edge first_edge(const TopoDS_Wire& w);
@@ -46,10 +46,10 @@ namespace IfcGeom {
double p_;
bool override_next_;
gp_Pnt next_override_;
express::Base inst_;
express::base inst_;
public:
wire_builder(double p, const express::Base& inst = express::Base()) : 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);
+20 -20
View File
@@ -36,7 +36,7 @@
#include <map>
bool IfcGeom::util::approximate_plane_through_wire(const TopoDS_Wire& wire, gp_Pln& plane, double eps_) {
bool ifcopenshell::geom::util::approximate_plane_through_wire(const TopoDS_Wire& wire, gp_Pln& plane, double eps_) {
// Newell's Method is used for the normal calculation
// as a simple edge cross product can give opposite results
// for a concave face boundary.
@@ -108,7 +108,7 @@ bool IfcGeom::util::approximate_plane_through_wire(const TopoDS_Wire& wire, gp_P
return true;
}
bool IfcGeom::util::flatten_wire(TopoDS_Wire& wire, double eps) {
bool ifcopenshell::geom::util::flatten_wire(TopoDS_Wire& wire, double eps) {
gp_Pln pln;
if (!approximate_plane_through_wire(wire, pln, eps)) {
return false;
@@ -129,7 +129,7 @@ bool IfcGeom::util::flatten_wire(TopoDS_Wire& wire, double eps) {
return true;
}
IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std::vector<TopoDS_Wire>& wires, NCollection_List<TopoDS_Shape>& faces) {
ifcopenshell::geom::util::triangulate_wire_result ifcopenshell::geom::util::triangulate_wire(const std::vector<TopoDS_Wire>& wires, NCollection_List<TopoDS_Shape>& faces) {
// This is a bit of a precarious approach, but seems to work for the
// versions of OCCT tested for. OCCT has a Delaunay triangulation function
// BRepMesh_Delaun, but it is notoriously hard to interpret the results
@@ -210,7 +210,7 @@ IfcGeom::util::triangulate_wire_result IfcGeom::util::triangulate_wire(const std
const TopoDS_Face& face = mf->Face();
// Create a triangular mesh from the face
BRepMesh_IncrementalMesh(face, Precision::Confusion());
BRepMesh_IncrementalMesh(face, ::Precision::Confusion());
int n123[3];
TopLoc_Location loc;
@@ -364,13 +364,13 @@ namespace {
}
namespace {
double get_wire_intersection_tolerance(const IfcGeom::util::wire_tolerance_settings& settings, const TopoDS_Wire& wire) {
double get_wire_intersection_tolerance(const ifcopenshell::geom::util::wire_tolerance_settings& settings, const TopoDS_Wire& wire) {
if (settings.use_wire_intersection_tolerance) {
// This corresponds to faceset_helper::epsilon
if (settings.vertex_clustering_epsilon > 0.) {
return settings.vertex_clustering_epsilon / 3.;
} else {
return (std::min)(IfcGeom::util::min_edge_length(wire) / 2., settings.precision * 10.);
return (std::min)(ifcopenshell::geom::util::min_edge_length(wire) / 2., settings.precision * 10.);
}
} else {
return 0.;
@@ -378,7 +378,7 @@ namespace {
}
}
bool IfcGeom::util::wire_intersections(const TopoDS_Wire& wire, NCollection_List<TopoDS_Shape>& wires, const wire_tolerance_settings& settings) {
bool ifcopenshell::geom::util::wire_intersections(const TopoDS_Wire& wire, NCollection_List<TopoDS_Shape>& wires, const wire_tolerance_settings& settings) {
double eps = get_wire_intersection_tolerance(settings, wire);
double eps_real = settings.precision;
@@ -398,7 +398,7 @@ bool IfcGeom::util::wire_intersections(const TopoDS_Wire& wire, NCollection_List
// ... to be sure to get consecutive edges
BRepTools_WireExplorer exp(wire);
IfcGeom::impl::tree<int> tree;
ifcopenshell::geom::impl::tree<int> tree;
int edge_idx = 0;
for (; exp.More(); exp.Next()) {
@@ -561,7 +561,7 @@ bool IfcGeom::util::wire_intersections(const TopoDS_Wire& wire, NCollection_List
return intersected;
}
void IfcGeom::util::select_largest(const NCollection_List<TopoDS_Shape>& shapes, TopoDS_Shape& largest) {
void ifcopenshell::geom::util::select_largest(const NCollection_List<TopoDS_Shape>& shapes, TopoDS_Shape& largest) {
double mass = 0.;
NCollection_List<TopoDS_Shape>::Iterator it(shapes);
for (; it.More(); it.Next()) {
@@ -584,10 +584,10 @@ void IfcGeom::util::select_largest(const NCollection_List<TopoDS_Shape>& shapes,
double m = 1.;
for (int i = 0; i < 3; ++i) {
if (Precision::IsNegativeInfinite(xyz_min[i])) {
if (::Precision::IsNegativeInfinite(xyz_min[i])) {
xyz_min[i] = 0.;
}
if (Precision::IsInfinite(xyz_max[i])) {
if (::Precision::IsInfinite(xyz_max[i])) {
xyz_max[i] = 0.;
}
m *= (xyz_max[i] + eps) - (xyz_min[i] - eps);
@@ -601,7 +601,7 @@ void IfcGeom::util::select_largest(const NCollection_List<TopoDS_Shape>& shapes,
}
bool IfcGeom::util::wire_to_sequence_of_point(const TopoDS_Wire& w, NCollection_Sequence<gp_Pnt>& p) {
bool ifcopenshell::geom::util::wire_to_sequence_of_point(const TopoDS_Wire& w, NCollection_Sequence<gp_Pnt>& p) {
TopExp_Explorer exp(w, TopAbs_EDGE);
for (; exp.More(); exp.Next()) {
double a, b;
@@ -628,7 +628,7 @@ bool IfcGeom::util::wire_to_sequence_of_point(const TopoDS_Wire& w, NCollection_
return true;
}
void IfcGeom::util::sequence_of_point_to_wire(const NCollection_Sequence<gp_Pnt>& p, TopoDS_Wire& w, bool close) {
void ifcopenshell::geom::util::sequence_of_point_to_wire(const NCollection_Sequence<gp_Pnt>& p, TopoDS_Wire& w, bool close) {
BRepBuilderAPI_MakePolygon builder;
for (int i = 1; i <= p.Length(); ++i) {
builder.Add(p.Value(i));
@@ -639,7 +639,7 @@ void IfcGeom::util::sequence_of_point_to_wire(const NCollection_Sequence<gp_Pnt>
w = builder.Wire();
}
void IfcGeom::util::remove_collinear_points_from_loop(NCollection_Sequence<gp_Pnt>& polygon, bool closed, double tol) {
void ifcopenshell::geom::util::remove_collinear_points_from_loop(NCollection_Sequence<gp_Pnt>& polygon, bool closed, double tol) {
const int start = closed ? 1 : 2;
const int end = polygon.Length() - (closed ? 0 : 1);
std::vector<bool> to_remove(polygon.Length(), false);
@@ -663,7 +663,7 @@ void IfcGeom::util::remove_collinear_points_from_loop(NCollection_Sequence<gp_Pn
}
}
void IfcGeom::util::remove_duplicate_points_from_loop(NCollection_Sequence<gp_Pnt>& polygon, bool closed, double tol) {
void ifcopenshell::geom::util::remove_duplicate_points_from_loop(NCollection_Sequence<gp_Pnt>& polygon, bool closed, double tol) {
tol *= tol;
for (;;) {
@@ -716,7 +716,7 @@ namespace {
}
bool IfcGeom::util::fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape, double tol) {
bool ifcopenshell::geom::util::fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape, double tol) {
BRepOffsetAPI_Sewing sew;
sew.Add(shape);
@@ -806,7 +806,7 @@ bool IfcGeom::util::fill_nonmanifold_wires_with_planar_faces(TopoDS_Shape& shape
}
bool IfcGeom::util::convert_curve_to_wire(const opencascade::handle<Geom_Curve>& curve, TopoDS_Wire& wire) {
bool ifcopenshell::geom::util::convert_curve_to_wire(const opencascade::handle<Geom_Curve>& curve, TopoDS_Wire& wire) {
try {
wire = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(curve));
return true;
@@ -823,7 +823,7 @@ bool IfcGeom::util::convert_curve_to_wire(const opencascade::handle<Geom_Curve>&
}
void IfcGeom::util::assert_closed_wire(TopoDS_Wire& wire, double tol) {
void ifcopenshell::geom::util::assert_closed_wire(TopoDS_Wire& wire, double tol) {
if (wire.Closed() == 0) {
TopoDS_Vertex v0, v1;
TopExp::Vertices(wire, v0, v1);
@@ -842,7 +842,7 @@ void IfcGeom::util::assert_closed_wire(TopoDS_Wire& wire, double tol) {
}
}
bool IfcGeom::util::convert_wire_to_face(const TopoDS_Wire& w, TopoDS_Face& face, const IfcGeom::util::wire_tolerance_settings& settings) {
bool ifcopenshell::geom::util::convert_wire_to_face(const TopoDS_Wire& w, TopoDS_Face& face, const ifcopenshell::geom::util::wire_tolerance_settings& settings) {
TopoDS_Wire wire = w;
NCollection_List<TopoDS_Shape> results;
@@ -887,7 +887,7 @@ bool IfcGeom::util::convert_wire_to_face(const TopoDS_Wire& w, TopoDS_Face& face
return true;
}
bool IfcGeom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoDS_Compound& faces, const IfcGeom::util::wire_tolerance_settings& settings) {
bool ifcopenshell::geom::util::convert_wire_to_faces(const TopoDS_Wire& w, TopoDS_Compound& faces, const ifcopenshell::geom::util::wire_tolerance_settings& settings) {
bool is_2d = true;
TopExp_Explorer exp(w, TopAbs_EDGE);
for (; exp.More(); exp.Next()) {
+3 -3
View File
@@ -18,7 +18,7 @@
#include <vector>
namespace IfcGeom {
namespace ifcopenshell::geom {
namespace util {
IFC_GEOMLIBRARY_API bool approximate_plane_through_wire(const TopoDS_Wire& wire, gp_Pln& plane, double eps);
@@ -44,9 +44,9 @@ namespace IfcGeom {
IFC_GEOMLIBRARY_API void select_largest(const NCollection_List<TopoDS_Shape>& shapes, TopoDS_Shape& largest);
IFC_GEOMLIBRARY_API bool convert_wire_to_face(const TopoDS_Wire& wire, TopoDS_Face& face, const IfcGeom::util::wire_tolerance_settings& settings);
IFC_GEOMLIBRARY_API bool convert_wire_to_face(const TopoDS_Wire& wire, TopoDS_Face& face, const ifcopenshell::geom::util::wire_tolerance_settings& settings);
IFC_GEOMLIBRARY_API bool convert_wire_to_faces(const TopoDS_Wire& wire, TopoDS_Compound& face, const IfcGeom::util::wire_tolerance_settings& settings);
IFC_GEOMLIBRARY_API bool convert_wire_to_faces(const TopoDS_Wire& wire, TopoDS_Compound& face, const ifcopenshell::geom::util::wire_tolerance_settings& settings);
IFC_GEOMLIBRARY_API void assert_closed_wire(TopoDS_Wire& wire, double tol);