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

A (much more) compact version of GmSegmentCellIntersection for 2d intersections only. Must be created on the heap by a call to instance(). More...

#include <gmSegmentCellIntersection.h>

Collaboration diagram for GmCompact2DSegmentCellIntersection:
Collaboration graph
[legend]

Public Types

typedef QPair< int, int > SegmentId
 Discontinuity index, segment index in the intersection list.
 

Public Member Functions

int cellId () const
 Returns the cell id.
 
SegmentId segmentId () const
 Returns the segment id (discontinuity index in the set + segment index in the intersection list) More...
 
void setSegmentIdIndex (int index)
 Updates the segment index part of the segment Id.
 
GmSegmentCellIntersectionPointKind kind (int i) const
 Returns the intersection kind for the given intersection point (0 = first, 1 = second).
 
int border (int i) const
 If kind(i) is not INTERNAL, returns the local node / edge index for the given intersection point (0 = first, 1 = second). If it is, returns -1.
 
int edge () const
 If the segment lies over an edge, returns the intersected edge number. -1 otherwise.
 
GmVector cartCoord (int i) const
 Returns the cartesian coordinate for the given intersection point (0 = first, 1 = second), IN the MESH UNIT coordinates. More...
 
const double * rawCartCoord (int i) const
 Same as cartCoord(i) but returning a pointer to the internal buffer. No cdata copy to construct a GmVector.
 
GmVector natCoord (int i) const
 Returns the natural coordinate for the given intersection point (0 = first, 1 = second).
 
bool continuous () const
 Returns true if this intersection segment start point is the same as the last point for the previous intersection.
 
void setContinuous (bool mode)
 Updates the continuous flag.
 
bool segmentIntersection () const
 Returns true if this intersection segment takes part in an inter segments intersection.
 
void setSegmentIntersection ()
 Mark this intersection as taking part in an inter segments intersection.
 
bool hasIntersectionElementId () const
 Returns true if this object was created with the option to store an intersection element id.
 
int intersectionElementId () const
 
void setIntersectionElementId (int id)
 Updates the stored intersection element id. Can only be called if hasIntersectionElementId() returns true.
 
void updateOutputData (const GmCompact2DSegmentCellIntersection *out, int edge)
 Updates the "out" data with the values from the given object. Updates edge with the given value.
 
void updateOutputData (const GmVector &cartCoord, const GmVector &natCoord, GmSegmentCellIntersectionPointKind kind, int border)
 Updates the "out" data with the given values.
 
void print (const GmLogCategory &logger, GmLogLevel level) const
 Prints the contents of the intersection to the given logger.
 
void operator delete (void *ptr)
 Matching operator delete.
 
void operator delete (void *ptr, int, bool)
 Matching operator delete for the placement new. Needed in case of exceptions in the constructor.
 

Static Public Member Functions

static GmCompact2DSegmentCellIntersectioninstance (const GmSegmentCellIntersection &data, int segmentIndex, bool hasIntElementId)
 Instance a new compact intersection object based on the intersection data received. The hasIntElementId defines if the object will add space to store an associated intersection element id or not. The segmentIndex parameter is used to initialize the segment index in the segment id (which is different from the sourde data).
 

Private Member Functions

 Q_DISABLE_COPY (GmCompact2DSegmentCellIntersection)
 
 GmCompact2DSegmentCellIntersection (const GmSegmentCellIntersection &data, int segmentIndex, bool hasIntElementId)
 GmCompact2DSegmentCellIntersection objects MUST ALWAYS be created on the HEAP through a call to instance() More...
 
void * operator new (std::size_t count, int nnatural, bool hasIntElementId)
 Operator new. Allocates the class size + the needed extra space for the natural coordinates vector and optional intersection element id.
 
int numNatCoordinates () const
 Returns the number of entries in a natural coordinate for the element cell type.
 

Private Attributes

int _cellId
 The cell id.
 
SegmentId _segmentId
 The segment id (discontinuity id + segment index)
 
quint8 _kindAndFlags
 The kind enum value for both intersection points compacted at bits 1-3 (first) / 4-6 (second). Bits 7 and 8 are used for the continuous and intersection flags.
 
qint8 _border [2]
 The local node / edge index, for the first ([0]) and second ([1]) intersection points, if _kind is not INTERNAL. -1 if it is.
 
quint8 _edgeAndNatSize
 6 most significant bits store the edge number, if the segment lies over an edge, or -1 otherwise. 2 least significant bits store flags. Bit 1 is 1 if natural coordinates have 3 components and bit 2 is 1 if there is extra space for the intersection element id in the _natCoord vector.
 
double _cartCoord [4]
 The set of cartesian coordinates (x1, y1, x2, y2) for the first and second intersection points in the polyline direction.
 
double _natCoord [1]
 Start of the vector used for storing natural coordinates for both in and out intersection points. Its real size is either 4 or 6 doubles and the extra needed entries are allocated with the object by the instance function. Unfortunatelly, C99 flexible arrays are not part of the C++ standard so we can not declare it as _natCoordinates[] If hasIntersectionElementId() returns true, the first entry of the vector is used to store the intersection element id (as a double) and in this scenario the vector size is effectively 5 or 7 doubles.
 

Detailed Description

A (much more) compact version of GmSegmentCellIntersection for 2d intersections only. Must be created on the heap by a call to instance().

When using two natural coordinates, this structure uses 80 bytes. For 3 natural coordinates, 96 bytes (add 8 bytes if the intersection element id is stored). A GmSegmentCellIntersection structure takes 752 bytes (without the intersection element id), mostly due to the GmVector internal allocation of space for 16 vector entries + control data, but also due to poor alignment packing of the other fields.

Constructor & Destructor Documentation

◆ GmCompact2DSegmentCellIntersection()

GmCompact2DSegmentCellIntersection::GmCompact2DSegmentCellIntersection ( const GmSegmentCellIntersection data,
int  segmentIndex,
bool  hasIntElementId 
)
private

GmCompact2DSegmentCellIntersection objects MUST ALWAYS be created on the HEAP through a call to instance()

Constructor from a filled GmSegmentCellIntersection data. Object MUST have been allocated by use of the defined placement new operator that allocates the extra space for natural coordinates at the end of the structure.

To guarantee that, this constructor is made private and the instance() function makes the correct new call. The hasIntElementId defines if the object will add space to store an associated intersection element id or not. The segmentIndex parameter is used to initialize the segment index in the segment id (which is different from the sourde data).

Member Function Documentation

◆ cartCoord()

GmVector GmCompact2DSegmentCellIntersection::cartCoord ( int  i) const
inline

Returns the cartesian coordinate for the given intersection point (0 = first, 1 = second), IN the MESH UNIT coordinates.

   IMPORTANT: When querying coordinates from a PHYSICS implementation, or any other situation that allows for the mesh 
   coordinates to be expressed in a different unit, PLEASE make use of a GmSegmentCell2DIntersectionCoordAccessor retrieved
   from the discontinuity set using the current physics coordinate unit. That is also automated by the common Fem physics
   object.

◆ segmentId()

SegmentId GmCompact2DSegmentCellIntersection::segmentId ( ) const
inline

Returns the segment id (discontinuity index in the set + segment index in the intersection list)

   If multiple segments intersected this element and they where combined into a single 
   one due to internal intersection node removal, the returned segment index will 
   correspond to the first intersection segment

   Kepp in mind that the segment index value (and semantics) is DIFFERENT from the value in the 
   source GmSegmentCellIntersection data.

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