16#ifdef ENABLE_OPENCASCADE
18#ifdef __INTEL_COMPILER
19#pragma warning disable 191
27#undef _USE_MATH_DEFINES
36#include <BRepBuilderAPI_Transform.hxx>
37#include <BRepMesh_IncrementalMesh.hxx>
38#include <BRep_Tool.hxx>
39#include <Poly_Triangulation.hxx>
40#include <Standard_Version.hxx>
41#include <StdFail_NotDone.hxx>
42#include <TopExp_Explorer.hxx>
44#include <TopoDS_Face.hxx>
45#include <TopoDS_Shape.hxx>
52#ifdef __INTEL_COMPILER
53#pragma warning enable 191
57auto getNode(
const Handle(Poly_Triangulation) facing, Standard_Integer i) {
58#if OCC_VERSION_MAJOR >= 7 && OCC_VERSION_MINOR >= 6
59 return facing->Node(i);
62 TColgp_Array1OfPnt tab(1, (facing->NbNodes()));
63 tab = facing->Nodes();
68auto getTriangle(
const Handle(Poly_Triangulation) facing, Standard_Integer i) {
69#if OCC_VERSION_MAJOR >= 7 && OCC_VERSION_MINOR >= 6
70 return facing->Triangle(i);
73 Poly_Array1OfTriangle tri(1, facing->NbTriangles());
74 tri = facing->Triangles();
84Kernel::Logger
g_log(
"GeometryTriangulator");
88 : m_isTriangulated(false), m_nFaces(0), m_nPoints(0), m_csgObj(
obj)
89#ifdef ENABLE_OPENCASCADE
97 : m_isTriangulated(false), m_meshObj(
std::move(
obj)) {}
102#ifdef ENABLE_OPENCASCADE
103 if (m_objSurface ==
nullptr)
119#ifdef ENABLE_OPENCASCADE
120bool GeometryTriangulator::hasOCSurface()
const {
return m_objSurface !=
nullptr; }
122const TopoDS_Shape &GeometryTriangulator::getOCSurface() {
124 return *m_objSurface;
158#ifdef ENABLE_OPENCASCADE
159void GeometryTriangulator::OCAnalyzeObject() {
164 if (
top ==
nullptr) {
165 m_objSurface.reset(
new TopoDS_Shape());
169 TopoDS_Shape Result =
const_cast<Rule *
>(
top)->analyze();
171 m_objSurface.reset(
new TopoDS_Shape(Result));
172 BRepMesh_IncrementalMesh(Result, 0.001);
173 }
catch (StdFail_NotDone &) {
174 g_log.
error(
"Cannot build the geometry. Check the geometry definition");
183size_t GeometryTriangulator::numPoints()
const {
184 size_t countVert = 0;
185 if (m_objSurface !=
nullptr) {
187 for (Ex.Init(*m_objSurface, TopAbs_FACE); Ex.More(); Ex.Next()) {
188 TopoDS_Face F = TopoDS::Face(Ex.Current());
190 Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L);
191 countVert +=
static_cast<size_t>(facing->NbNodes());
197size_t GeometryTriangulator::numFaces()
const {
198 size_t countFace = 0;
199 if (m_objSurface !=
nullptr) {
201 for (Ex.Init(*m_objSurface, TopAbs_FACE); Ex.More(); Ex.Next()) {
202 TopoDS_Face F = TopoDS::Face(Ex.Current());
204 Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L);
205 countFace +=
static_cast<size_t>(facing->NbTriangles());
211void GeometryTriangulator::setupPoints() {
217 for (Ex.Init(*m_objSurface, TopAbs_FACE); Ex.More(); Ex.Next()) {
218 TopoDS_Face F = TopoDS::Face(Ex.Current());
220 Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L);
221 for (Standard_Integer i = 1; i <= (facing->NbNodes()); i++) {
222 const auto pnt = getNode(facing, i);
232void GeometryTriangulator::setupFaces() {
239 for (Ex.Init(*m_objSurface, TopAbs_FACE); Ex.More(); Ex.Next()) {
240 TopoDS_Face F = TopoDS::Face(Ex.Current());
242 Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L);
243 for (Standard_Integer i = 1; i <= (facing->NbTriangles()); i++) {
244 Poly_Triangle trian = getTriangle(facing, i);
245 Standard_Integer index1, index2, index3;
246 trian.Get(index1, index2, index3);
247 m_faces[
index * 3 + 0] =
static_cast<uint32_t
>(maxindex + index1 - 1);
248 m_faces[
index * 3 + 1] =
static_cast<uint32_t
>(maxindex + index2 - 1);
249 m_faces[
index * 3 + 2] =
static_cast<uint32_t
>(maxindex + index3 - 1);
252 maxindex += facing->NbNodes();
259 std::vector<uint32_t> &&faces) {
std::map< DeltaEMode::Type, std::string > index
double obj
the value of the quadratic function
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
Constructive Solid Geometry object.
const Rule * topRule() const
Return the top rule.
Object generation rule tree.
size_t numTriangleVertices()
Return the number of triangle vertices.
GeometryTriangulator(const CSGObject *obj=nullptr)
void setGeometryCache(size_t nPoints, size_t nFaces, std::vector< double > &&points, std::vector< uint32_t > &&faces)
size_t numTriangleFaces()
Return the number of triangle faces.
std::unique_ptr< RenderingMesh > m_meshObj
std::vector< double > m_points
double array or points
const std::vector< double > & getTriangleVertices()
get a pointer to the 3x(NumberOfPoints) coordinates (x1,y1,z1,x2..) of mesh
std::vector< uint32_t > m_faces
Integer array of faces.
const CSGObject * m_csgObj
Input Object.
const std::vector< uint32_t > & getTriangleFaces()
get a pointer to the 3x(NumberOFaces) integers describing points forming faces (p1,...
void error(const std::string &msg)
Logs at error level.
ShapeInfo : Stores shape types and information relevant to drawing the shape.
Mantid::Kernel::Logger g_log("Goniometer")