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)
118#ifdef ENABLE_OPENCASCADE
119bool GeometryTriangulator::hasOCSurface()
const {
return m_objSurface !=
nullptr; }
121const TopoDS_Shape &GeometryTriangulator::getOCSurface() {
123 return *m_objSurface;
157#ifdef ENABLE_OPENCASCADE
158void GeometryTriangulator::OCAnalyzeObject() {
163 if (
top ==
nullptr) {
164 m_objSurface.reset(
new TopoDS_Shape());
170 m_objSurface.reset(
new TopoDS_Shape(
Result));
171 BRepMesh_IncrementalMesh(
Result, 0.001);
172 }
catch (StdFail_NotDone &) {
173 g_log.
error(
"Cannot build the geometry. Check the geometry definition");
182size_t GeometryTriangulator::numPoints()
const {
183 size_t countVert = 0;
184 if (m_objSurface !=
nullptr) {
186 for (Ex.Init(*m_objSurface, TopAbs_FACE); Ex.More(); Ex.Next()) {
187 TopoDS_Face F = TopoDS::Face(Ex.Current());
189 Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L);
190 countVert +=
static_cast<size_t>(facing->NbNodes());
196size_t GeometryTriangulator::numFaces()
const {
197 size_t countFace = 0;
198 if (m_objSurface !=
nullptr) {
200 for (Ex.Init(*m_objSurface, TopAbs_FACE); Ex.More(); Ex.Next()) {
201 TopoDS_Face F = TopoDS::Face(Ex.Current());
203 Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L);
204 countFace +=
static_cast<size_t>(facing->NbTriangles());
210void GeometryTriangulator::setupPoints() {
216 for (Ex.Init(*m_objSurface, TopAbs_FACE); Ex.More(); Ex.Next()) {
217 TopoDS_Face F = TopoDS::Face(Ex.Current());
219 Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L);
220 for (Standard_Integer i = 1; i <= (facing->NbNodes()); i++) {
221 const auto pnt = getNode(facing, i);
231void GeometryTriangulator::setupFaces() {
238 for (Ex.Init(*m_objSurface, TopAbs_FACE); Ex.More(); Ex.Next()) {
239 TopoDS_Face F = TopoDS::Face(Ex.Current());
241 Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L);
242 for (Standard_Integer i = 1; i <= (facing->NbTriangles()); i++) {
243 Poly_Triangle trian = getTriangle(facing, i);
244 Standard_Integer index1, index2, index3;
245 trian.Get(index1, index2, index3);
246 m_faces[
index * 3 + 0] =
static_cast<uint32_t
>(maxindex + index1 - 1);
247 m_faces[
index * 3 + 1] =
static_cast<uint32_t
>(maxindex + index2 - 1);
248 m_faces[
index * 3 + 2] =
static_cast<uint32_t
>(maxindex + index3 - 1);
251 maxindex += facing->NbNodes();
258 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")