Program Listing for File boolean_utils.h¶
↰ Return to documentation for file (src/ifcgeom/kernels/opencascade/boolean_utils.h)
/********************************************************************************
* *
* 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 BOOLEAN_UTILS_H
#define BOOLEAN_UTILS_H
#include <TopoDS_Shape.hxx>
#include <Standard_Macro.hxx>
#include <NCollection_List.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <NCollection_IndexedMap.hxx>
#include <Geom_Surface.hxx>
#include <TopoDS_Face.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <BOPAlgo_Operation.hxx>
#include "../../../ifcparse/logger.h"
#include "../ifc_geomlibrary_api.h"
namespace ifcopenshell::geom {
namespace util {
IFC_GEOMLIBRARY_API void copy_operand(const NCollection_List<TopoDS_Shape>& l, NCollection_List<TopoDS_Shape>& r);
IFC_GEOMLIBRARY_API TopoDS_Shape copy_operand(const TopoDS_Shape& s);
IFC_GEOMLIBRARY_API double min_edge_length(const TopoDS_Shape& a);
IFC_GEOMLIBRARY_API double min_vertex_edge_distance(const TopoDS_Shape& a, double min_search, double max_search);
class points_on_planar_face_generator {
private:
const TopoDS_Face& f_;
Handle(Geom_Surface) plane_;
BRepTopAdaptor_FClass2d cls_;
double u0, u1, v0, v1;
int i, j;
bool inset_;
static const int N = 10;
public:
points_on_planar_face_generator(const TopoDS_Face& f, bool inset = false)
: f_(f)
, plane_(BRep_Tool::Surface(f_))
, cls_(f_, BRep_Tool::Tolerance(f_))
, i((int)inset), j((int)inset)
, inset_(inset)
{
BRepTools::UVBounds(f_, u0, u1, v0, v1);
}
void reset();
bool operator()(gp_Pnt& p);
};
IFC_GEOMLIBRARY_API bool faces_overlap(const TopoDS_Face& f, const TopoDS_Face& g);
IFC_GEOMLIBRARY_API double min_face_face_distance(const TopoDS_Shape& a, double max_search);
IFC_GEOMLIBRARY_API int bounding_box_overlap(double p, const TopoDS_Shape& a, const NCollection_List<TopoDS_Shape>& b, NCollection_List<TopoDS_Shape>& c);
IFC_GEOMLIBRARY_API bool get_edge_axis(const TopoDS_Edge& e, gp_Ax1& ax);
IFC_GEOMLIBRARY_API bool is_subset(const NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& lhs, const NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher>& rhs);
IFC_GEOMLIBRARY_API bool is_extrusion(const gp_Vec& v, const TopoDS_Shape& s, TopoDS_Face& base, std::pair<double, double>& interval);
IFC_GEOMLIBRARY_API int eliminate_touching_operands(double prec, const TopoDS_Shape& a, const NCollection_List<TopoDS_Shape>& bs, NCollection_List<TopoDS_Shape>& c);
IFC_GEOMLIBRARY_API int eliminate_narrow_operands(double prec, const NCollection_List<TopoDS_Shape>& bs, NCollection_List<TopoDS_Shape> & c, ifcopenshell::logger& logger = ifcopenshell::logger::root());
IFC_GEOMLIBRARY_API bool boolean_subtraction_2d_using_builder(const TopoDS_Shape& a_input, const NCollection_List<TopoDS_Shape>& b_input, TopoDS_Shape& result, double eps, ifcopenshell::logger& logger = ifcopenshell::logger::root());
struct boolean_settings {
bool debug, attempt_2d;
double precision;
// Set by callers that carry a per-conversion logger (e.g. kernels deriving
// from abstract_kernel). Falls back to the global ifcopenshell::logger::root() singleton.
ifcopenshell::logger* logger = nullptr;
ifcopenshell::logger& log() const { return logger ? *logger : ifcopenshell::logger::root(); }
};
IFC_GEOMLIBRARY_API bool boolean_operation(const boolean_settings& settings, const TopoDS_Shape&, const NCollection_List<TopoDS_Shape>&, BOPAlgo_Operation, TopoDS_Shape&, double fuzziness = -1.);
IFC_GEOMLIBRARY_API bool boolean_operation(const boolean_settings& settings, const TopoDS_Shape&, const TopoDS_Shape&, BOPAlgo_Operation, TopoDS_Shape&, double fuzziness = -1.);
IFC_GEOMLIBRARY_API TopoDS_Shape ensure_fit_for_subtraction(const TopoDS_Shape& shape, double tol);
}
}
#endif