Files
IfcOpenShell/src/ifcgeom/kernels/cgal/CgalKernel.h
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

114 lines
5.4 KiB
C++
Raw Normal View History

2017-01-16 11:53:11 +01:00
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
#ifndef CGAL_KERNEL_H
#define CGAL_KERNEL_H
/*
#ifdef NO_CACHE
#define IN_CACHE(T,E,t,e)
#define CACHE(T,E,e)
#else
#define IN_CACHE(T,E,t,e) std::map<int,t>::const_iterator it = cache.T.find(E->entity->id());\
if ( it != cache.T.end() ) { e = it->second; return true; }
#define CACHE(T,E,e) cache.T[E->entity->id()] = e;
#endif
*/
2019-01-23 17:27:13 +01:00
#include <cmath>
2019-01-18 16:43:38 +01:00
#include "../../../ifcparse/macros.h"
2019-01-20 13:16:42 +01:00
2023-03-21 20:15:01 +01:00
#include "../../../ifcgeom/AbstractKernel.h"
2019-01-20 13:16:42 +01:00
2023-03-21 20:15:01 +01:00
#include "../../../ifcgeom/IfcGeomElement.h"
2019-09-01 16:29:00 +02:00
#include "../../../ifcgeom/kernels/cgal/CgalConversionResult.h"
2019-01-18 16:43:38 +01:00
2019-01-23 17:27:13 +01:00
struct PolyhedronBuilder : public CGAL::Modifier_base<CGAL::Polyhedron_3<Kernel_>::HalfedgeDS> {
private:
2023-03-21 20:15:01 +01:00
std::list<cgal_face_t> *face_list;
public:
2023-03-21 20:15:01 +01:00
boost::optional<cgal_shape_t> from_soup;
PolyhedronBuilder(std::list<cgal_face_t> *face_list);
void operator()(CGAL::Polyhedron_3<Kernel_>::HalfedgeDS &hds);
};
2019-09-01 16:29:00 +02:00
namespace ifcopenshell {
2023-03-21 20:15:01 +01:00
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_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);
}
2019-01-18 16:43:38 +01:00
2023-03-21 20:15:01 +01:00
namespace kernels {
2017-01-16 11:53:11 +01:00
2023-03-21 20:15:01 +01:00
class IFC_GEOM_API CgalKernel : public AbstractKernel {
private:
size_t circle_segments_;
// CGAL::Nef_polyhedron_3<Kernel_> precision_cube_;
2019-10-06 19:03:31 +02:00
2023-03-21 20:15:01 +01:00
bool preprocess_boolean_operand(const IfcUtil::IfcBaseClass* log_reference, const cgal_shape_t& shape_const, CGAL::Nef_polyhedron_3<Kernel_>& result, bool dilate);
bool thin_solid(const CGAL::Nef_polyhedron_3<Kernel_>& a, CGAL::Nef_polyhedron_3<Kernel_>& result);
2017-01-16 11:53:11 +01:00
2023-03-21 20:15:01 +01:00
CGAL::Nef_polyhedron_3<Kernel_> create_precision_cube_() const {
auto cc = utils::create_cube(conv_settings_.getValue(ConversionSettings::GV_PRECISION));
return CGAL::Nef_polyhedron_3<Kernel_>(cc);
}
public:
CgalKernel(const ConversionSettings& settings)
: AbstractKernel("cgal", settings)
, circle_segments_(32)
{}
void remove_duplicate_points_from_loop(cgal_wire_t& polygon);
bool convert(const taxonomy::extrusion*, cgal_shape_t&);
bool convert(const taxonomy::face*, cgal_face_t&);
bool convert(const taxonomy::loop*, cgal_wire_t&);
// bool convert(const taxonomy::matrix4*, cgal_placement_t&);
bool convert(const taxonomy::shell*, cgal_shape_t&);
bool process_extrusion(const cgal_face_t& bottom_face, const taxonomy::direction3& direction, double height, cgal_shape_t& shape);
bool process_as_2d_polygon(const taxonomy::boolean_result* br, std::list<CGAL::Polygon_2<Kernel_>>& loops, double& z0, double& z1);
bool process_as_2d_polygon(const std::list<std::list<std::pair<const IfcUtil::IfcBaseClass*, cgal_shape_t>>>& operands, std::list<CGAL::Polygon_2<Kernel_>>& loops, double& z0, double& z1);
virtual bool convert_impl(const taxonomy::shell*, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::extrusion*, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::boolean_result*, IfcGeom::ConversionResults&);
virtual bool convert_impl(const taxonomy::solid*, IfcGeom::ConversionResults&);
virtual bool convert_openings(const IfcUtil::IfcBaseEntity* entity, const std::vector<std::pair<taxonomy::item*, ifcopenshell::geometry::taxonomy::matrix4>>& openings,
const IfcGeom::ConversionResults& entity_shapes, const ifcopenshell::geometry::taxonomy::matrix4& entity_trsf, IfcGeom::ConversionResults& cut_shapes);
CGAL::Nef_polyhedron_3<Kernel_> precision_cube() const { return create_precision_cube_(); }
};
}
}
2019-09-01 16:29:00 +02:00
}
2017-01-16 11:53:11 +01:00
#endif