GemaCoreLib
The GeMA Core library
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
GmPolylineDiscontinuity Class Reference

Polyline 2D representation for a discontinuity. More...

#include <gmPolylineDiscontinuity.h>

Inheritance diagram for GmPolylineDiscontinuity:
Inheritance graph
[legend]
Collaboration diagram for GmPolylineDiscontinuity:
Collaboration graph
[legend]

Public Member Functions

virtual ~GmPolylineDiscontinuity ()
 Destructor.
 
virtual int numSegments () const
 A generic interface to return the number of discontinuity "segments", where a segment depends on the geometric representation type. For 2d meshes it will be either the number of polyline segments or the number of edges. For 3d meshes, the number of triangles or the number of faces.
 
virtual int numIntersections () const
 A generic interface to return the number of intersections between the mesh and the user given geometry. Is the number of line segments or faces (triangles an/or quads) in the intersection set.
 
int numPoints () const
 Returns the number of polyline points.
 
const double * pointCoordinates () const
 Returns the polyline coordinates vector, organized as x1, y1, x2, y2, .... Size equal to numPoints() * 2.
 
const QVector< GmCompact2DSegmentCellIntersection * > & intersectionList () const
 Returns the intersection list (filled by a call to findIntersections())
 
virtual void clearGeometry ()
 Clears the original discontinuity geometry information, releasing memory.
 
virtual void printGeometry (const GmLogCategory &logger, GmLogLevel level) const
 Prints the discontinuity geometry information.
 
virtual size_t usedGeometryMemory () const
 Returns an estimative of the memory used by the discontinuity geometry in bytes. More...
 
virtual bool findIntersections (const GmLogCategory &logger)
 Finds the intersections between this discontinuity and the associated mesh, using parameters stored in the discontinuity set.
 
virtual void printIntersections (const GmLogCategory &logger, GmLogLevel level) const
 Prints the discontinuity-mesh intersection information.
 
virtual size_t usedIntersectionMemory () const
 Returns an estimative of the memory used by the intersection data in bytes.
 
- Public Member Functions inherited from GmDiscontinuity
virtual ~GmDiscontinuity ()
 Virtuald destructor.
 
int index () const
 Returns this discontinuity index in the father set.
 
QString id () const
 Returns the discontinuity id (name)
 
int cellGroupIndex () const
 Returns the cell group index associated with this discontinuity, if any. This is the index of the group in the list returned by GmCellMesh::cellGroupIds() Returns -1 for an unspecified cell group.
 
virtual int propertyIndex (int propertySet) const
 Given a property set number, returns the line of the property set that contains property values for this discontinuity. The returned value can be used to get a property from a property accessor retrieved from the discontinuity set. More...
 

Private Member Functions

 GmPolylineDiscontinuity (const GmDiscontinuitySet *ds, int index, QString id, int groupIndex, const QVector< int > &psIndex)
 Constructor.
 
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 coordinates. ivec should be NULL.
 
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, if any. More...
 
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.
 
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 another.
 
bool checkMeshPreconditions (const GmCellMesh *mesh, const GmLogCategory &logger) const
 Check mesh preconditions, using looger to emmit warnings / error messages.
 
const GmCellfindAdjacentCell (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 the index of the found edge. More...
 
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 mesh.
 
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 an element. Should be called when a segment needs to be broken at the specified point. More...
 
void intersectionSegmentBreakingEnded ()
 Helper function for the process of finding intersections among different intersection segments inside an element. Called after all segments where broken to effectivelly finish the creation of the _brokenList and replace _intList with it.
 

Static Private Member Functions

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 an element. Given two segments, finds the intersection between them filling firstPos and secondPos with the "natural" coordinate of the intersection (between 0 and 1) and cartPos with its cartesian coordinate. If there is no intersection, returns false and leaves the output parameters unchanged. If the segments overlap, returns true but makes cartPos an empty.
 

Private Attributes

int _numPoints
 The number of points in the polyline. Number of segments is (_numPoints - 1)
 
double * _pointCoord
 The coordinate vector. Size == _numPoints * 2.
 
QVector< GmCompact2DSegmentCellIntersection * > _intList
 The intersection list, filled by a call to findIntersections(). We store pointers to the data to: 1) Enable the storing of pointers in the elementIntersectionMap in the discontinuity set (without the risk of them being invalidated if the vector grows). 2) Don't waste too much memory with allocated but unused entries (although we could call shrink) . More...
 
QVector< QPair< int, QVector< GmCompact2DSegmentCellIntersection * > > > _brokenList
 A temporary list built incrementally by calls to breakIntersectionSegment() with the new broken segments that need to be added to _intList in intersectionSegmentBreakingEnded(). Each entry is a pair with the index in _intList after which the elements in the vector should be added. The second entry in the pair is a vector and not a single pointer since an original segment from _intList can be broken in more than two pieces.
 

Friends

class GmDiscontinuitySet
 

Additional Inherited Members

- Protected Member Functions inherited from GmDiscontinuity
 GmDiscontinuity (const GmDiscontinuitySet *ds, int index, QString id, int groupIndex, const QVector< int > &psIndex)
 Private constructor. Discontinuities are only created by the DiscontinuitySet.
 
- Protected Attributes inherited from GmDiscontinuity
const GmDiscontinuitySet_ds
 Our "father" discontinuity set.
 
int _index
 The discontinuity index in its "father" discontinuity set.
 
QString _id
 The discontinuity id.
 
int _groupIndex
 The index in the mesh for the associated cell group or -1 if there is none.
 
QVector< int > _psIndex
 The property set line index for this discontinuity. One entry per associated property set.
 

Detailed Description

Polyline 2D representation for a discontinuity.

Member Function Documentation

◆ breakIntersectionSegment()

bool GmPolylineDiscontinuity::breakIntersectionSegment ( GmCompact2DSegmentCellIntersection segment,
double  natPos,
const GmVector cartPos,
GmValueAccessor coordAc,
GmCompact2DSegmentCellIntersection **  newSegment,
const GmLogCategory logger 
)
private

Helper function for the process of finding intersections among different intersection segments inside an element. Should be called when a segment needs to be broken at the specified point.

If natPos is either 0.0 or 1.0, the segment won't be broken. It will only be marked as part of an inside element intersection and newSegment will be filled with NULL. Otherwise, a new segment cell intersection object will be created, stored in newSegment, and both segments adjusted accordingly. The returned segment is the one with the segment part after natPos.

If there is any error while calculating the internal natural coordinate for the intersection point, the function returns false (and gives a message with the supplied logger).

Internally, to avoid multiple calls to insert on _intList, the newly created segments are stored at the temporarty _brokenList and will be inserted in _intList when intersectionSegmentBreakingEnded() is called.

◆ findAdjacentCell()

const GmCell * GmPolylineDiscontinuity::findAdjacentCell ( const GmCellMesh mesh,
const GmCell cell,
int  edgeIndex,
int *  adjCellEdge 
) const
private

Brute force method for finding cell adjacency when lacking a topological mesh. Updates edgeIndex to the index of the found edge.

Brute force method for finding cell adjacency when lacking a topological mesh. Updates adjCellEdge to the index of the found edge.

◆ segmentConvexLinearElementIntersection()

GmSegmentCellIntersection GmPolylineDiscontinuity::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
private

Given a discontinuity segment and a CONVEX, LINEAR, non interface cell, calculates their intersection, if any.

Intersections can be classified according to the location of the segment endpoints with respect to the cell in 'out-out' (both segment endpoints are outside the cell), 'in-in' (the segment is entirelly contained inside the cell) or 'in-out' / 'out-in'. This is returned by the in & out kind field result. Segment nodes located exactly ontop of the cell edge are considered inside the cell.

If the segment just touches the cell in one of its nodes or in a single edge, this is NOT considered an intersection.

If an edge intersection is within a distance given by snapTol to a vertex, that intersection is attracted to the vertex. The tolerance is measured in a percentage of the edge length (a value of 0.05 means a 5% distance). If an internal intersection distance to an edge / vertex is also within the given tolerance, it will also be attracted to the edge / vertex. A snapTol of 0.0 means no attraction!

Intersection results are represented by a Gm2DSegmentMeshIntersection structure. See the class comments for details.

Parameters
segmentThe discontinuity line segment as a GTE segment object.
segmentIdThe segment index
cellThe convex, linear, non interface cell. Keep in mind that those attributes are NOT checked by the function. In particular, cell CAN be a quadratic element whose geometry is linear.
coordAcThe accessor used to retrieve node coordinates
incomingBorderIf you know that the segment is "entering" the cell through a border, you can give the border id to speedup the calculations. This happends when a discontinuity segment passes "through" an element extending to its neighbor. If you don't have that information, or the segment is entering the element through a vertex, pass -1.
snapTolThe tolerance value in percentage of the edge length.
intersectsA boolean flag that is set to true or false depending on the segment really intersecting the element. Remember that a segment touching the cell in a single point is not considered to intersect the cell.
inoutAn output vector with two doubles filled with the relative position of the segment intersections, where 0.0 is the start of the segment and 1.0 its end.
snapAn output vector with two booleans filled with true if a segment border was snapped to a node or to a border (for an inside segment node close to an edge).
outgoingBorderAn output parameter set to a border id if the segment leaves the cell through one of its borders. Set to -1 if the segment ends inside the cell or leaves the cell through a vertex.
loggerThe logger used to emit messages if we find erros when translating cartesian to natural coordinates
Returns
Returns the filled intersection object if intersects is true or an invalid object if not.

◆ usedGeometryMemory()

virtual size_t GmPolylineDiscontinuity::usedGeometryMemory ( ) const
inlinevirtual

Returns an estimative of the memory used by the discontinuity geometry in bytes.

It returns in general the variable memory that depends on the number of lines in a polyline, edges or faces for boundary lists or points & triangles for surfaces, ignoring "constant" sizes.

Implements GmDiscontinuity.

Member Data Documentation

◆ _intList

QVector<GmCompact2DSegmentCellIntersection*> GmPolylineDiscontinuity::_intList
private

The intersection list, filled by a call to findIntersections(). We store pointers to the data to: 1) Enable the storing of pointers in the elementIntersectionMap in the discontinuity set (without the risk of them being invalidated if the vector grows). 2) Don't waste too much memory with allocated but unused entries (although we could call shrink) .

The list is ordered according to the order of the polyline segments, and so, unless the polyline has segments outside the mesh, each entry of the list is connected to the previous one.


The documentation for this class was generated from the following files: