GemaCoreLib
The GeMA Core library
gmPolylineDiscontinuity.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_POLYLINE_DISCONTINUITY_H_
25 #define _GEMA_POLYLINE_DISCONTINUITY_H_
26 
27 #include "gmDiscontinuity.h"
29 
30 class GmCell;
31 class GmCellMesh;
32 class GmValueAccessor;
33 
34 
39 class GmPolylineSegment;
40 
43 {
44 public:
45  virtual ~GmPolylineDiscontinuity();
46 
47  // See comments on the base class
48  virtual int numSegments() const { return _numPoints ? _numPoints-1 : 0; };
49 
50  // See comments on the base class
51  virtual int numIntersections() const { return _intList.size(); }
52 
54  int numPoints() const { return _numPoints; }
55 
57  const double* pointCoordinates() const { return _pointCoord; }
58 
61 
62  virtual void clearGeometry();
63 
64  virtual void printGeometry(const GmLogCategory& logger, GmLogLevel level) const;
65 
66  // See comments on the base class
67  virtual size_t usedGeometryMemory() const { return _numPoints * 2 * sizeof(double); }
68 
69  virtual bool findIntersections (const GmLogCategory& logger);
70  virtual void printIntersections(const GmLogCategory& logger, GmLogLevel level) const;
71 
72  // See comments on the base class
73  virtual size_t usedIntersectionMemory() const { return _intList.capacity() * sizeof(GmCompact2DSegmentCellIntersection*) +
75 
76 private:
77  friend class GmDiscontinuitySet;
78 
80  GmPolylineDiscontinuity(const GmDiscontinuitySet* ds, int index, QString id, int groupIndex, const QVector<int>& psIndex)
81  : GmDiscontinuity(ds, index, id, groupIndex, psIndex), _numPoints(0), _pointCoord(NULL) {}
82 
84  virtual void setGeometry(double* dvec, int nd, int* ivec, int ni)
85  {
86  Q_UNUSED(ni); Q_UNUSED(ivec);
87  assert(dvec && !ivec);
88  _numPoints = nd;
89  _pointCoord = dvec;
90  }
91 
93  const GmValueAccessor* coordAc, int incomingBorder, double snapTol,
94  bool* intersects, double inout[2], bool snap[2], int* outgoingBorder,
95  const GmLogCategory& logger) const;
96 
97  GmSegmentCellIntersection findSegmentEntryPoint(const GmPolylineSegment& segment, int segmentId, const GmValueAccessor* coordAc,
98  double snapTol, bool* intersects, double inout[2], bool snap[2], int* outgoingBorder,
99  GmCell const** cell, const GmLogCategory& logger) const;
100 
101  void removeInternalNodes(const GmValueAccessor* coordAc, double snapTol, const GmLogCategory& logger);
102 
103  bool checkMeshPreconditions(const GmCellMesh* mesh, const GmLogCategory& logger) const;
104 
105  const GmCell* findAdjacentCell (const GmCellMesh* mesh, const GmCell* cell, int edgeIndex, int* adjCellEdge) const;
106  QVector<GmCell*> findNodeCellsBall(const GmCellMesh* mesh, int nodeIndex) const;
107 
108  static bool segmentIntersection(const GmCompact2DSegmentCellIntersection* firstSegment, const GmCompact2DSegmentCellIntersection* secondSegment,
109  double* firstPos, double* secondPos, GmVector& cartPos);
110 
111  bool breakIntersectionSegment(GmCompact2DSegmentCellIntersection* segment, double natPos, const GmVector& cartPos, GmValueAccessor* coordAc,
112  GmCompact2DSegmentCellIntersection** newSegment, const GmLogCategory& logger);
114 
116  double* _pointCoord;
117 
128 
136 };
137 
138 
139 #endif // _GEMA_POLYLINE_DISCONTINUITY_H_
const GmCell * findAdjacentCell(const GmCellMesh *mesh, const GmCell *cell, int edgeIndex, int *adjCellEdge) const
Brute force method for finding cell adjacency when lacking a topological mesh. Updates edgeIndex to t...
Definition: _repell_gmPolylineDiscontinuity.cpp:1028
virtual void printGeometry(const GmLogCategory &logger, GmLogLevel level) const
Prints the discontinuity geometry information.
Definition: _repell_gmPolylineDiscontinuity.cpp:85
GmSegmentCellIntersection findSegmentEntryPoint(const GmPolylineSegment &segment, int segmentId, const GmValueAccessor *coordAc, double snapTol, bool *intersects, double inout[2], bool snap[2], int *outgoingBorder, GmCell const **cell, const GmLogCategory &logger) const
Traverses the mesh seeking for the segment-element intersection closest to the segment start.
Definition: _repell_gmPolylineDiscontinuity.cpp:750
int _numPoints
The number of points in the polyline. Number of segments is (_numPoints - 1)
Definition: gmPolylineDiscontinuity.h:115
Representation for the intersection between a polyline segment and a mesh cell. Can be used both in 2...
Definition: gmSegmentCellIntersection.h:58
int index() const
Returns this discontinuity index in the father set.
Definition: gmDiscontinuity.h:42
void removeInternalNodes(const GmValueAccessor *coordAc, double snapTol, const GmLogCategory &logger)
Remove internal node so that every intersection segment traverses the element from one edge to anothe...
Definition: _repell_gmPolylineDiscontinuity.cpp:810
GmPolylineDiscontinuity(const GmDiscontinuitySet *ds, int index, QString id, int groupIndex, const QVector< int > &psIndex)
Constructor.
Definition: gmPolylineDiscontinuity.h:80
virtual void setGeometry(double *dvec, int nd, int *ivec, int ni)
Sets the geometry. dvec should be a vector with coordinates (size nd * 2), nd the number of coordinat...
Definition: gmPolylineDiscontinuity.h:84
virtual int numSegments() const
A generic interface to return the number of discontinuity "segments", where a segment depends on the ...
Definition: gmPolylineDiscontinuity.h:48
Polyline 2D representation for a discontinuity.
Definition: gmPolylineDiscontinuity.h:42
Base interface for mesh cells.
Definition: gmCell.h:81
void intersectionSegmentBreakingEnded()
Helper function for the process of finding intersections among different intersection segments inside...
Definition: _repell_gmPolylineDiscontinuity.cpp:1214
int numPoints() const
Returns the number of polyline points.
Definition: gmPolylineDiscontinuity.h:54
virtual void printIntersections(const GmLogCategory &logger, GmLogLevel level) const
Prints the discontinuity-mesh intersection information.
Definition: _repell_gmPolylineDiscontinuity.cpp:99
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
Declaration of the GmSegmentCellIntersection class & friends.
virtual ~GmPolylineDiscontinuity()
Destructor.
Definition: _repell_gmPolylineDiscontinuity.cpp:68
Definition: _repell_gmPolylineDiscontinuity.cpp:49
QVector< QPair< int, QVector< GmCompact2DSegmentCellIntersection * > > > _brokenList
A temporary list built incrementally by calls to breakIntersectionSegment() with the new broken segme...
Definition: gmPolylineDiscontinuity.h:135
The geometric representation for a single discontinuity from the Discontinuity set....
Definition: gmDiscontinuity.h:35
Base interface class for CellMesh type plugins.
Definition: gmCellMesh.h:39
GmSegmentCellIntersection segmentConvexLinearElementIntersection(const GmPolylineSegment &segment, int segmentId, const GmCell *cell, const GmValueAccessor *coordAc, int incomingBorder, double snapTol, bool *intersects, double inout[2], bool snap[2], int *outgoingBorder, const GmLogCategory &logger) const
Given a discontinuity segment and a CONVEX, LINEAR, non interface cell, calculates their intersection...
Definition: _repell_gmPolylineDiscontinuity.cpp:406
bool breakIntersectionSegment(GmCompact2DSegmentCellIntersection *segment, double natPos, const GmVector &cartPos, GmValueAccessor *coordAc, GmCompact2DSegmentCellIntersection **newSegment, const GmLogCategory &logger)
Helper function for the process of finding intersections among different intersection segments inside...
Definition: _repell_gmPolylineDiscontinuity.cpp:1126
int capacity() const const
static bool segmentIntersection(const GmCompact2DSegmentCellIntersection *firstSegment, const GmCompact2DSegmentCellIntersection *secondSegment, double *firstPos, double *secondPos, GmVector &cartPos)
Helper function for the process of finding intersections among different intersection segments inside...
Definition: _repell_gmPolylineDiscontinuity.cpp:1082
A (much more) compact version of GmSegmentCellIntersection for 2d intersections only....
Definition: gmSegmentCellIntersection.h:105
bool checkMeshPreconditions(const GmCellMesh *mesh, const GmLogCategory &logger) const
Check mesh preconditions, using looger to emmit warnings / error messages.
Definition: _repell_gmPolylineDiscontinuity.cpp:970
GmLogLevel
Available log levels list.
Definition: gmLog.h:36
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
virtual size_t usedGeometryMemory() const
Returns an estimative of the memory used by the discontinuity geometry in bytes.
Definition: gmPolylineDiscontinuity.h:67
Base interface for providing discontinuity geometry information for spatial indices.
Definition: gmDiscontinuitySet.h:48
virtual size_t usedIntersectionMemory() const
Returns an estimative of the memory used by the intersection data in bytes.
Definition: gmPolylineDiscontinuity.h:73
QVector< GmCompact2DSegmentCellIntersection * > _intList
The intersection list, filled by a call to findIntersections(). We store pointers to the data to: 1) ...
Definition: gmPolylineDiscontinuity.h:127
double * _pointCoord
The coordinate vector. Size == _numPoints * 2.
Definition: gmPolylineDiscontinuity.h:116
const QVector< GmCompact2DSegmentCellIntersection * > & intersectionList() const
Returns the intersection list (filled by a call to findIntersections())
Definition: gmPolylineDiscontinuity.h:60
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition: gmVector.h:34
GmCellMesh * mesh() const
Returns the mesh that this discontinuity set is tied to.
Definition: gmDiscontinuitySet.h:81
int size() const const
const double * pointCoordinates() const
Returns the polyline coordinates vector, organized as x1, y1, x2, y2, .... Size equal to numPoints() ...
Definition: gmPolylineDiscontinuity.h:57
QString id() const
Returns the discontinuity id (name)
Definition: gmDiscontinuity.h:45
virtual void clearGeometry()
Clears the original discontinuity geometry information, releasing memory.
Definition: _repell_gmPolylineDiscontinuity.cpp:77
virtual bool findIntersections(const GmLogCategory &logger)
Finds the intersections between this discontinuity and the associated mesh, using parameters stored i...
Definition: _repell_gmPolylineDiscontinuity.cpp:113
Declaration of the GmDiscontinuity class.
QVector< GmCell * > findNodeCellsBall(const GmCellMesh *mesh, int nodeIndex) const
Brute force method for finding the cells containing a node as a vertex when lacking a topological mes...
Definition: _repell_gmPolylineDiscontinuity.cpp:1058
virtual int numIntersections() const
A generic interface to return the number of intersections between the mesh and the user given geometr...
Definition: gmPolylineDiscontinuity.h:51