GemaCoreLib
The GeMA Core library
gmTriSurfaceDiscontinuity.h
Go to the documentation of this file.
1 /************************************************************************
2 **
3 ** Copyright (C) 2023 by Carlos Augusto Teixeira Mendes
4 ** All rights reserved.
5 **
6 ** This file is part of the "GeMA" software. It's use should respect
7 ** the terms in the license agreement that can be found together
8 ** with this source code.
9 ** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10 ** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11 ** A PARTICULAR PURPOSE.
12 **
13 ************************************************************************/
14 
24 #ifndef _GEMA_TRISURFACE_DISCONTINUITY_H_
25 #define _GEMA_TRISURFACE_DISCONTINUITY_H_
26 
27 #include "gmDiscontinuity.h"
28 #include "gmBVHAcceleration.h"
29 #include "gmCellMesh.h"
30 
33 {
34 public:
36 
37  // See comments on the base class
38  virtual int numSegments() const { return _numTriangles; };
39 
40  // See comments on the base class
41  virtual int numIntersections() const { return intPoint.size(); }
42 
44  int numPoints() const { return _numPoints; }
45 
47  const double* pointCoordinates() const { return _pointCoord; }
48 
50  int numTriangles() const { return _numTriangles; }
51 
53  const int* triangleIncidences() const { return _triList; }
54 
55  //TODO
56  //const auto intersectionList() const { return cellIntersections; }
57 
58  virtual void clearGeometry();
59 
60  virtual void printGeometry(const GmLogCategory& logger, GmLogLevel level) const;
61 
62  // See comments on the base class
63  virtual size_t usedGeometryMemory() const { return _numPoints * 3 * sizeof(double) + _numTriangles * 3 * sizeof(int); }
64 
65  virtual size_t usedIntersectionMemory() const {
66 
67  return intPoint.size() * sizeof(RayIntersection) +
68  std::accumulate(cellIntersection.begin(),
69  cellIntersection.end(),
70  (size_t)cellIntersection.size() * sizeof(CellIntersection),
71  [](size_t v, CellIntersection c) {
72  return v + c.size() * sizeof(EdgeId);
73  }
74  );
75  }
76 
77  virtual bool findIntersections(const GmLogCategory& logger);
78  virtual void printIntersections(const GmLogCategory& logger, GmLogLevel level) const;
79 
80 private:
82  GmTriSurfaceDiscontinuity(const GmDiscontinuitySet* ds, int index, QString id, int groupIndex, const QVector<int>& psIndex)
83  : GmDiscontinuity(ds, index, id, groupIndex, psIndex), _numPoints(0), _numTriangles(0), _pointCoord(NULL), _triList(NULL) {}
84 
88  virtual void setGeometry(double* dvec, int nd, int* ivec, int ni)
89  {
90  assert(dvec && ivec);
91  _numPoints = nd;
92  _numTriangles = ni;
93  _pointCoord = dvec;
94  _triList = ivec;
95  }
96 
97  friend class GmDiscontinuitySet;
98 
99  int _numPoints;
101  double* _pointCoord;
102  int* _triList;
103 
104 
105  //Map storing <cellId, vector<edgeGlobalId, edgeLocalId>>
106  using EdgeId = QPair<size_t, int>;
108  QHash<size_t, CellIntersection> cellIntersection;
109  QHash<size_t, bool> validCellIntersection;
110 
111  //Map storing <edgeGlobalId, RayIntersection>
113  QHash<size_t, bool> validIntPoint;
114 
115  int markAmbiguousEdges();
121 
122  QVector<EdgeId> popEdgesOnFace(QVector<EdgeId>& edges, QVector<bool>& FELine);
123 
124 
126  //Edge-Edge index
128  //Edge-Face index
130  //Given an faceEdge map, build a matrix[edge1][edge2] = true
131  // if the edge1 and edge2 have a face in common
132  BoolMat buildEEMatrix(QVector<QVector<int>> faceEdge, int nedges);
133  //Given an edgeFace map, build a matrix[edge][face] = true
134  // if the face contais edge
135  BoolMat buildFEMatrix(QVector<QVector<int>> edgeFace, int nface);
136 
137  const BoolMat getOrBuildEEMatrix(const GmCellGeometryInfo* info);
138  const BoolMat getOrBuildFEMatrix(const GmCellGeometryInfo* info);
139 
140  bool checkConsistency();
141 
142  //To be removed after validation
143  void DebugCell(size_t cellId, GmMatrix& points, CellIntersection& ci);
144 };
145 
146 
147 #endif // _GEMA_TRISURFACE_DISCONTINUITY_H_
int _numPoints
The number of points in the surface.
Definition: gmTriSurfaceDiscontinuity.h:99
double * _pointCoord
The coordinate vector. Size == _numPoints * 3.
Definition: gmTriSurfaceDiscontinuity.h:101
int index() const
Returns this discontinuity index in the father set.
Definition: gmDiscontinuity.h:42
virtual ~GmTriSurfaceDiscontinuity()
Destructor.
Definition: gmTriSurfaceDiscontinuity.cpp:42
virtual int numIntersections() const
A generic interface to return the number of intersections between the mesh and the user given geometr...
Definition: gmTriSurfaceDiscontinuity.h:41
Definition: gmBVHAcceleration.h:31
int size() const const
virtual void printGeometry(const GmLogCategory &logger, GmLogLevel level) const
Prints the discontinuity geometry information.
Definition: gmTriSurfaceDiscontinuity.cpp:62
virtual int numSegments() const
A generic interface to return the number of discontinuity "segments", where a segment depends on the ...
Definition: gmTriSurfaceDiscontinuity.h:38
const double * pointCoordinates() const
Returns the surface coordinates vector, organized as x1, y1, z1, x2, y2, z2, .... Size equal to numPo...
Definition: gmTriSurfaceDiscontinuity.h:47
virtual void setGeometry(double *dvec, int nd, int *ivec, int ni)
Sets the geometry. dvec should be a vector with coordinates (size nd * 3), nd the number of coordinat...
Definition: gmTriSurfaceDiscontinuity.h:88
int numPoints() const
Returns the number of surface points.
Definition: gmTriSurfaceDiscontinuity.h:44
bool reorderIntersections(CellIntersection &ci, const GmCellGeometryInfo *info)
For each cellIntersection[i] reorder its edges indexes to form a polygon with the intersection points...
Definition: gmTriSurfaceDiscontinuity.cpp:271
virtual size_t usedGeometryMemory() const
Returns an estimative of the memory used by the discontinuity geometry in bytes.
Definition: gmTriSurfaceDiscontinuity.h:63
virtual void printIntersections(const GmLogCategory &logger, GmLogLevel level) const
Prints the discontinuity-mesh intersection information.
Definition: gmTriSurfaceDiscontinuity.cpp:372
The geometric representation for a single discontinuity from the Discontinuity set....
Definition: gmDiscontinuity.h:35
Surface 3D representation for a discontinuity.
Definition: gmTriSurfaceDiscontinuity.h:32
Declaration of the gmBVHAcceleration class using https://github.com/madmann91/bvh/ header-only implem...
GmTriSurfaceDiscontinuity(const GmDiscontinuitySet *ds, int index, QString id, int groupIndex, const QVector< int > &psIndex)
Constructor.
Definition: gmTriSurfaceDiscontinuity.h:82
virtual size_t usedIntersectionMemory() const
Returns an estimative of the memory used by the intersection data in bytes.
Definition: gmTriSurfaceDiscontinuity.h:65
Declaration of the GmCellMesh interface class.
int * _triList
The list with triangle incidences. Size == _numTriangles * 3.
Definition: gmTriSurfaceDiscontinuity.h:102
GmLogLevel
Available log levels list.
Definition: gmLog.h:36
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
Base interface for providing discontinuity geometry information for spatial indices.
Definition: gmDiscontinuitySet.h:48
Definition: gmCellGeometryInfo.h:153
virtual void clearGeometry()
Clears the original discontinuity geometry information, releasing memory.
Definition: gmTriSurfaceDiscontinuity.cpp:51
int numTriangles() const
Returns the number of surface triangles.
Definition: gmTriSurfaceDiscontinuity.h:50
int size() const const
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition: gmMatrix.h:38
virtual bool findIntersections(const GmLogCategory &logger)
Builds the element intersection list for this discontinuity.
Definition: gmTriSurfaceDiscontinuity.cpp:82
QString id() const
Returns the discontinuity id (name)
Definition: gmDiscontinuity.h:45
const int * triangleIncidences() const
Returns the incidence vector, organized as p11, p12, p13, p21, p22, p23, .... Size equal to numTriang...
Definition: gmTriSurfaceDiscontinuity.h:53
Declaration of the GmDiscontinuity class.
int _numTriangles
The number of triangles in the surface.
Definition: gmTriSurfaceDiscontinuity.h:100