mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-01 20:49:44 +00:00
dllimport/export #6926
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/repair.h>
|
||||
#include <CGAL/Polygon_mesh_processing/self_intersections.h>
|
||||
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>
|
||||
#include <CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h>
|
||||
|
||||
#include "../../../ifcparse/IfcLogger.h"
|
||||
#include "../../../ifcgeom/IfcGeomRepresentation.h"
|
||||
@@ -19,6 +21,10 @@ using ifcopenshell::geometry::NumberEpeck;
|
||||
#define NumberType NumberEpeck
|
||||
#endif
|
||||
|
||||
#ifdef IFOPSH_SIMPLE_KERNEL
|
||||
#define CgalShape SimpleCgalShape
|
||||
#endif
|
||||
|
||||
typedef CGAL::Polyhedron_3<Kernel_> Polyhedron;
|
||||
typedef Polyhedron::Facet_const_handle Facet_const_handle;
|
||||
typedef Polyhedron::Halfedge_around_facet_const_circulator Halfedge_around_facet_circulator;
|
||||
@@ -701,6 +707,43 @@ ConversionResultShape* ifcopenshell::geometry::CgalShape::intersect(ConversionRe
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace {
|
||||
template <typename Polyhedron>
|
||||
void concatenate_polyhedra(Polyhedron& p1, const Polyhedron& p2) {
|
||||
std::vector<cgal_point_t> points1, points2;
|
||||
std::vector<std::vector<std::size_t>> faces1, faces2;
|
||||
|
||||
// Extract soups
|
||||
CGAL::Polygon_mesh_processing::polygon_mesh_to_polygon_soup(p1, points1, faces1);
|
||||
CGAL::Polygon_mesh_processing::polygon_mesh_to_polygon_soup(p2, points2, faces2);
|
||||
|
||||
// Offset indices in faces2 by current number of points in points1
|
||||
std::size_t offset = points1.size();
|
||||
for (auto& f : faces2) {
|
||||
for (auto& idx : f) {
|
||||
idx += offset;
|
||||
}
|
||||
}
|
||||
|
||||
// Merge soups
|
||||
points1.insert(points1.end(), points2.begin(), points2.end());
|
||||
faces1.insert(faces1.end(), faces2.begin(), faces2.end());
|
||||
|
||||
// Build merged polyhedron
|
||||
Polyhedron merged;
|
||||
CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(points1, faces1, merged);
|
||||
|
||||
p1 = std::move(merged);
|
||||
}
|
||||
}
|
||||
|
||||
ConversionResultShape* ifcopenshell::geometry::CgalShape::concat(ConversionResultShape* other)
|
||||
{
|
||||
auto shp = poly();
|
||||
concatenate_polyhedra(shp, ((CgalShape*)other)->poly());
|
||||
return new CgalShape(shp);
|
||||
}
|
||||
|
||||
std::pair<OpaqueCoordinate<3>, OpaqueCoordinate<3>> ifcopenshell::geometry::CgalShape::bounding_box() const
|
||||
{
|
||||
throw std::runtime_error("Not implemented");
|
||||
@@ -736,6 +779,11 @@ void ifcopenshell::geometry::CgalShape::map(const std::vector<OpaqueCoordinate<4
|
||||
throw std::runtime_error("Not implemented");
|
||||
}
|
||||
|
||||
bool ifcopenshell::geometry::CgalShape::surface_area_along_direction(double tol, const ifcopenshell::geometry::taxonomy::matrix4::ptr& place, double& along_x, double& along_y, double& along_z) const {
|
||||
// @todo
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifndef IFOPSH_SIMPLE_KERNEL
|
||||
|
||||
void ifcopenshell::geometry::CgalShapeHalfSpaceDecomposition::Triangulate(ifcopenshell::geometry::Settings settings, const ifcopenshell::geometry::taxonomy::matrix4& place, IfcGeom::Representation::Triangulation* t, int item_id, int surface_style_id) const {
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#ifndef CGALCONVERSIONRESULT_H
|
||||
#define CGALCONVERSIONRESULT_H
|
||||
|
||||
#include "../../../ifcgeom/kernels/ifc_geomlibrary_api.h"
|
||||
|
||||
#include "../../../ifcgeom/IfcGeomElement.h"
|
||||
|
||||
#undef Handle
|
||||
@@ -100,7 +102,7 @@ namespace ifcopenshell { namespace geometry {
|
||||
using IfcGeom::negate_;
|
||||
|
||||
#ifndef IFOPSH_SIMPLE_KERNEL
|
||||
class IFC_GEOM_API NumberEpeck : public OpaqueNumber {
|
||||
class IFC_GEOMLIBRARY_API NumberEpeck : public OpaqueNumber {
|
||||
private:
|
||||
CGAL::Epeck::FT value_;
|
||||
|
||||
@@ -175,7 +177,7 @@ namespace ifcopenshell { namespace geometry {
|
||||
};
|
||||
#endif
|
||||
|
||||
class CgalShape : public IfcGeom::ConversionResultShape {
|
||||
class IFC_GEOMLIBRARY_API CgalShape : public IfcGeom::ConversionResultShape {
|
||||
private:
|
||||
bool convex_tag_ = false;
|
||||
mutable boost::optional<cgal_shape_t> shape_;
|
||||
@@ -250,17 +252,20 @@ namespace ifcopenshell { namespace geometry {
|
||||
virtual ConversionResultShape* add(ConversionResultShape*);
|
||||
virtual ConversionResultShape* subtract(ConversionResultShape*);
|
||||
virtual ConversionResultShape* intersect(ConversionResultShape*);
|
||||
virtual ConversionResultShape* concat(ConversionResultShape*);
|
||||
|
||||
virtual void map(OpaqueCoordinate<4>& from, OpaqueCoordinate<4>& to);
|
||||
virtual void map(const std::vector<OpaqueCoordinate<4>>& from, const std::vector<OpaqueCoordinate<4>>& to);
|
||||
virtual ConversionResultShape* moved(ifcopenshell::geometry::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;
|
||||
|
||||
bool convex_tag() const { return convex_tag_; }
|
||||
bool& convex_tag() { return convex_tag_; }
|
||||
};
|
||||
|
||||
#ifndef IFOPSH_SIMPLE_KERNEL
|
||||
class CgalShapeHalfSpaceDecomposition : public IfcGeom::ConversionResultShape {
|
||||
class IFC_GEOMLIBRARY_API CgalShapeHalfSpaceDecomposition : public IfcGeom::ConversionResultShape {
|
||||
private:
|
||||
std::unique_ptr<halfspace_tree<Kernel_>> shape_;
|
||||
std::list<CGAL::Plane_3<Kernel_>> planes_;
|
||||
@@ -315,12 +320,23 @@ namespace ifcopenshell { namespace geometry {
|
||||
virtual ConversionResultShape* add(ConversionResultShape*);
|
||||
virtual ConversionResultShape* subtract(ConversionResultShape*);
|
||||
virtual ConversionResultShape* intersect(ConversionResultShape*);
|
||||
virtual ConversionResultShape* concat(ConversionResultShape*) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void map(OpaqueCoordinate<4>& from, OpaqueCoordinate<4>& to);
|
||||
virtual void map(const std::vector<OpaqueCoordinate<4>>& from, const std::vector<OpaqueCoordinate<4>>& to);
|
||||
virtual ConversionResultShape* moved(ifcopenshell::geometry::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 {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
}}
|
||||
|
||||
#ifdef IFOPSH_SIMPLE_KERNEL
|
||||
#undef CgalShape
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
#include "../../../ifcparse/IfcLogger.h"
|
||||
#include "../../../ifcgeom/kernels/cgal/CgalConversionResult.h"
|
||||
|
||||
#ifdef IFOPSH_SIMPLE_KERNEL
|
||||
#define CgalShape SimpleCgalShape
|
||||
#endif
|
||||
|
||||
#include <CGAL/minkowski_sum_3.h>
|
||||
#include <CGAL/exceptions.h>
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ if ( it != cache.T.end() ) { e = it->second; return true; }
|
||||
|
||||
#include "../../../ifcgeom/IfcGeomElement.h"
|
||||
#include "../../../ifcgeom/kernels/cgal/CgalConversionResult.h"
|
||||
#include "../../../ifcgeom/kernels/ifc_geomlibrary_api.h"
|
||||
|
||||
#include <CGAL/Polygon_2.h>
|
||||
|
||||
@@ -55,20 +56,20 @@ if ( it != cache.T.end() ) { e = it->second; return true; }
|
||||
namespace ifcopenshell {
|
||||
namespace geometry {
|
||||
namespace utils {
|
||||
IFC_GEOM_API CGAL::Polyhedron_3<Kernel_> create_cube(double d);
|
||||
IFC_GEOM_API CGAL::Polyhedron_3<Kernel_> create_cube(const Kernel_::Point_3& lower, const Kernel_::Point_3& upper);
|
||||
IFC_GEOM_API CGAL::Polyhedron_3<Kernel_> create_polyhedron(std::list<cgal_face_t> &face_list, bool stitch_borders = false);
|
||||
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_cube(double d);
|
||||
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_cube(const Kernel_::Point_3& lower, const Kernel_::Point_3& upper);
|
||||
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_polyhedron(std::list<cgal_face_t> &face_list, bool stitch_borders = false);
|
||||
|
||||
#ifndef IFOPSH_SIMPLE_KERNEL
|
||||
IFC_GEOM_API CGAL::Polyhedron_3<Kernel_> create_polyhedron(const CGAL::Nef_polyhedron_3<Kernel_> &nef_polyhedron);
|
||||
IFC_GEOM_API CGAL::Nef_polyhedron_3<Kernel_> create_nef_polyhedron(std::list<cgal_face_t> &face_list);
|
||||
IFC_GEOM_API CGAL::Nef_polyhedron_3<Kernel_> create_nef_polyhedron(CGAL::Polyhedron_3<Kernel_> &polyhedron);
|
||||
IFC_GEOMLIBRARY_API CGAL::Polyhedron_3<Kernel_> create_polyhedron(const CGAL::Nef_polyhedron_3<Kernel_> &nef_polyhedron);
|
||||
IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3<Kernel_> create_nef_polyhedron(std::list<cgal_face_t> &face_list);
|
||||
IFC_GEOMLIBRARY_API CGAL::Nef_polyhedron_3<Kernel_> create_nef_polyhedron(CGAL::Polyhedron_3<Kernel_> &polyhedron);
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace kernels {
|
||||
|
||||
class IFC_GEOM_API CgalKernel : public AbstractKernel {
|
||||
class IFC_GEOMLIBRARY_API CgalKernel : public AbstractKernel {
|
||||
private:
|
||||
#ifndef IFOPSH_SIMPLE_KERNEL
|
||||
enum boolean_operand_preprocess {
|
||||
@@ -94,6 +95,18 @@ namespace ifcopenshell {
|
||||
: AbstractKernel("cgal", settings)
|
||||
{}
|
||||
|
||||
virtual AbstractKernel* clone() const {
|
||||
return new CgalKernel(settings());
|
||||
}
|
||||
|
||||
virtual bool supports_boolean_operations() const {
|
||||
#ifndef IFOPSH_SIMPLE_KERNEL
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool convert(const taxonomy::extrusion::ptr, cgal_shape_t&);
|
||||
bool convert(const taxonomy::face::ptr, std::list<cgal_face_t>&);
|
||||
bool convert(const taxonomy::loop::ptr, cgal_wire_t&);
|
||||
|
||||
Reference in New Issue
Block a user