KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
List of all members
Kratos::IntersectionUtilities Class Reference

Utilities to compute intersections between different geometries. More...

#include <intersection_utilities.h>

Collaboration diagram for Kratos::IntersectionUtilities:

Public Member Functions

Type Definitions
 KRATOS_CLASS_POINTER_DEFINITION (IntersectionUtilities)
 Pointer definition of IntersectionUtilities. More...
 
Operators
 IntersectionUtilities ()
 Default constructor. More...
 
virtual ~IntersectionUtilities ()
 Destructor. More...
 

Static Public Member Functions

Operations
template<class TGeometryType >
static int ComputeTriangleLineIntersection (const TGeometryType &rTriangleGeometry, const array_1d< double, 3 > &rLinePoint1, const array_1d< double, 3 > &rLinePoint2, array_1d< double, 3 > &rIntersectionPoint, const double epsilon=1e-12)
 
template<class TGeometryType >
static bool TriangleLineIntersection2D (const TGeometryType &rTriangle, const array_1d< double, 3 > &rPoint0, const array_1d< double, 3 > &rPoint1)
 
static bool TriangleLineIntersection2D (const array_1d< double, 3 > &rVert0, const array_1d< double, 3 > &rVert1, const array_1d< double, 3 > &rVert2, const array_1d< double, 3 > &rPoint0, const array_1d< double, 3 > &rPoint1)
 
static bool PointInTriangle (const array_1d< double, 3 > &rVert0, const array_1d< double, 3 > &rVert1, const array_1d< double, 3 > &rVert2, const array_1d< double, 3 > &rPoint, const double Tolerance=std::numeric_limits< double >::epsilon())
 This uses the Cramer's rule for solving a linear system and obtain the barycentric coordinates. More...
 
template<class TGeometryType , class TCoordinatesType >
static int ComputeTriangleLineIntersectionInTheSamePlane (const TGeometryType &rTriangleGeometry, const TCoordinatesType &rLinePoint1, const TCoordinatesType &rLinePoint2, TCoordinatesType &rIntersectionPoint1, TCoordinatesType &rIntersectionPoint2, int &rSolution, const double Epsilon=1e-12)
 Find the 3D intersection of a line (bounded) with a triangle (bounded) in the same plane. More...
 
template<class TGeometryType , class TCoordinatesType , bool TConsiderInsidePoints = true>
static int ComputeTetrahedraLineIntersection (const TGeometryType &rTetrahedraGeometry, const TCoordinatesType &rLinePoint1, const TCoordinatesType &rLinePoint2, TCoordinatesType &rIntersectionPoint1, TCoordinatesType &rIntersectionPoint2, const double Epsilon=1e-12)
 Find the 3D intersection of a line (bounded) with a tetrahedra (bounded) More...
 
template<class TGeometryType >
static PointerVector< PointComputeShortestLineBetweenTwoLines (const TGeometryType &rSegment1, const TGeometryType &rSegment2)
 Calculates the line to line intersection (shortest line). If line is length 0, it is considered a point and therefore there is intersection (3D version) More...
 
template<class TGeometryType >
static int ComputeLineLineIntersection (const TGeometryType &rLineGeometry, const array_1d< double, 3 > &rLinePoint0, const array_1d< double, 3 > &rLinePoint1, array_1d< double, 3 > &rIntersectionPoint, const double epsilon=1e-12)
 
static int ComputeLineLineIntersection (const array_1d< double, 3 > &rLine1Point0, const array_1d< double, 3 > &rLine1Point1, const array_1d< double, 3 > &rLine2Point0, const array_1d< double, 3 > &rLine2Point1, array_1d< double, 3 > &rIntersectionPoint, const double epsilon=1e-12)
 
static int ComputePlaneLineIntersection (const array_1d< double, 3 > &rPlaneBasePoint, const array_1d< double, 3 > &rPlaneNormal, const array_1d< double, 3 > &rLinePoint1, const array_1d< double, 3 > &rLinePoint2, array_1d< double, 3 > &rIntersectionPoint, const double epsilon=1e-12)
 Find the 3D intersection of a plane (infinite) with a segment (bounded) More...
 
static int ComputeLineBoxIntersection (const array_1d< double, 3 > &rBoxPoint0, const array_1d< double, 3 > &rBoxPoint1, const array_1d< double, 3 > &rLinePoint0, const array_1d< double, 3 > &rLinePoint1)
 Compute a segment box intersection Provided the minimum and maximum points of a box cell, this method checks if the segment intersects it. If it does intersect, it returns the rIntersectionPointpoint as well. Note that the cell box is assumed to be aligned to the cartesian axes. Adapted from: https://www.3dkingdoms.com/weekly/weekly.php?a=3. More...
 

Detailed Description

Utilities to compute intersections between different geometries.

This class provides static methods to check if there is intersections between different entities, and if there is, give back the intersection points.

Author
Ruben Zorrilla
Vicente Mataix Ferrandiz

Constructor & Destructor Documentation

◆ IntersectionUtilities()

Kratos::IntersectionUtilities::IntersectionUtilities ( )
inline

Default constructor.

◆ ~IntersectionUtilities()

virtual Kratos::IntersectionUtilities::~IntersectionUtilities ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ ComputeLineBoxIntersection()

static int Kratos::IntersectionUtilities::ComputeLineBoxIntersection ( const array_1d< double, 3 > &  rBoxPoint0,
const array_1d< double, 3 > &  rBoxPoint1,
const array_1d< double, 3 > &  rLinePoint0,
const array_1d< double, 3 > &  rLinePoint1 
)
inlinestatic

Compute a segment box intersection Provided the minimum and maximum points of a box cell, this method checks if the segment intersects it. If it does intersect, it returns the rIntersectionPointpoint as well. Note that the cell box is assumed to be aligned to the cartesian axes. Adapted from: https://www.3dkingdoms.com/weekly/weekly.php?a=3.

Parameters
rBoxPoint0Minimum point of the box cell
rBoxPoint1Maximum point of the box cell
rLinePoint0Segment origin point
rLinePoint1Segment end point
Returns
int Returns 0 if there is no intersection and 1 otherwise

◆ ComputeLineLineIntersection() [1/2]

static int Kratos::IntersectionUtilities::ComputeLineLineIntersection ( const array_1d< double, 3 > &  rLine1Point0,
const array_1d< double, 3 > &  rLine1Point1,
const array_1d< double, 3 > &  rLine2Point0,
const array_1d< double, 3 > &  rLine2Point1,
array_1d< double, 3 > &  rIntersectionPoint,
const double  epsilon = 1e-12 
)
inlinestatic

Find the 2D intersection of two lines (both bounded)

Parameters
rLine1Point0Coordinates of the first point of the first line
rLine1Point1Coordinates of the second point of the first line
rLine2Point0Coordinates of the first point of the second line
rLine2Point1Coordinates of the second point of the second line
Returns
rIntersectionPoint The intersection point coordinates
The intersection type index: 0 (disjoint - no intersection) 1 (intersect in a unique point) 2 (overlap) 3 (intersect in one endpoint)

◆ ComputeLineLineIntersection() [2/2]

template<class TGeometryType >
static int Kratos::IntersectionUtilities::ComputeLineLineIntersection ( const TGeometryType &  rLineGeometry,
const array_1d< double, 3 > &  rLinePoint0,
const array_1d< double, 3 > &  rLinePoint1,
array_1d< double, 3 > &  rIntersectionPoint,
const double  epsilon = 1e-12 
)
inlinestatic

Find the 2D intersection of two lines (both bounded)

Parameters
rLineGeometryIs the line to intersect
rLinePoint1Coordinates of the first point of the intersecting line
rLinePoint2Coordinates of the second point of the intersecting line
Returns
rIntersectionPoint The intersection point coordinates
The intersection type index: 0 (disjoint - no intersection) 1 (intersect in a unique point) 2 (overlap) 3 (intersect in one endpoint)

◆ ComputePlaneLineIntersection()

static int Kratos::IntersectionUtilities::ComputePlaneLineIntersection ( const array_1d< double, 3 > &  rPlaneBasePoint,
const array_1d< double, 3 > &  rPlaneNormal,
const array_1d< double, 3 > &  rLinePoint1,
const array_1d< double, 3 > &  rLinePoint2,
array_1d< double, 3 > &  rIntersectionPoint,
const double  epsilon = 1e-12 
)
inlinestatic

Find the 3D intersection of a plane (infinite) with a segment (bounded)

Parameters
rPlaneBasePointBase point of the plane to intersect with
rPlaneNormalNormal vector of the plane to intersect with
rLinePoint1Coordinates of the first point of the segment
rLinePoint2Coordinates of the second point of the segment
rIntersectionPointThe intersection point coordinates
Returns
The intersection type index: 0 (parallel or out of bounds - no intersection) 1 (unique intersection point) 2 (edge and plane coincide - no intersection)

◆ ComputeShortestLineBetweenTwoLines()

template<class TGeometryType >
static PointerVector<Point> Kratos::IntersectionUtilities::ComputeShortestLineBetweenTwoLines ( const TGeometryType &  rSegment1,
const TGeometryType &  rSegment2 
)
inlinestatic

Calculates the line to line intersection (shortest line). If line is length 0, it is considered a point and therefore there is intersection (3D version)

Calculate the line segment PaPb that is the shortest route between two lines P1P2 and P3P4. Calculate also the values of mua and mub where Pa = P1 + mua (P2 - P1) Pb = P3 + mub (P4 - P3) http://paulbourke.net/geometry/pointlineplane/

Parameters
rSegment1The first segment
rSegment2The second segment
Template Parameters
TGeometryTypeThe geometry type
Returns
Return empty points array if no solution exists. Otherwise returns the line intersection points array

◆ ComputeTetrahedraLineIntersection()

template<class TGeometryType , class TCoordinatesType , bool TConsiderInsidePoints = true>
static int Kratos::IntersectionUtilities::ComputeTetrahedraLineIntersection ( const TGeometryType &  rTetrahedraGeometry,
const TCoordinatesType &  rLinePoint1,
const TCoordinatesType &  rLinePoint2,
TCoordinatesType &  rIntersectionPoint1,
TCoordinatesType &  rIntersectionPoint2,
const double  Epsilon = 1e-12 
)
inlinestatic

Find the 3D intersection of a line (bounded) with a tetrahedra (bounded)

Template Parameters
TGeometryTypeThe geometry type
TCoordinatesTypeThe type of coordinates
TConsiderInsidePointsIf considering inside points or just the intersections in the faces
Parameters
[in]rTetrahedraGeometryIs the tetrahedra to intersect
[in]rLinePoint1Coordinates of the first point of the intersecting line
[in]rLinePoint2Coordinates of the second point of the intersecting line
[out]rIntersectionPoint1The first intersection point coordinates
[out]rIntersectionPoint2The second intersection point coordinates
Returns
The intersection type index: NO_INTERSECTION (disjoint - no intersection) TWO_POINTS_INTERSECTION (intersect in two points) ONE_POINT_INTERSECTION (intersect in one point) TWO_POINTS_INTERSECTION_BOTH_INSIDE (intersect in two points inside the tetrahedra) TWO_POINTS_INTERSECTION_ONE_INSIDE (intersect in two points, one inside the tetrahedra) FIRST_CORNER (intersect in the first corner of the tetrahedra) SECOND_CORNER (intersect in the second corner of the tetrahedra) THIRD_CORNER (intersect in the thid corner of the tetrahedra) FOURTH_CORNER (intersect in the fourth corner of the tetrahedra) Equivalent enum: enum class IntersectionUtilitiesTetrahedraLineIntersectionStatus { NO_INTERSECTION = 0, // (disjoint - no intersection) TWO_POINTS_INTERSECTION = 1, // (intersect in two points) ONE_POINT_INTERSECTION = 2, // (intersect in one point) TWO_POINTS_INTERSECTION_BOTH_INSIDE = 3, // (intersect in two points inside the tetrahedra) TWO_POINTS_INTERSECTION_ONE_INSIDE = 4, // (intersect in two points, one inside the tetrahedra) FIRST_CORNER = 5, // (intersect in the first corner of the tetrahedra) SECOND_CORNER = 6, // (intersect in the second corner of the tetrahedra) THIRD_CORNER = 7, // (intersect in the thid corner of the tetrahedra) FOURTH_CORNER = 8 // (intersect in the fourth corner of the tetrahedra) };
Parameters
EpsilonThe tolerance

◆ ComputeTriangleLineIntersection()

template<class TGeometryType >
static int Kratos::IntersectionUtilities::ComputeTriangleLineIntersection ( const TGeometryType &  rTriangleGeometry,
const array_1d< double, 3 > &  rLinePoint1,
const array_1d< double, 3 > &  rLinePoint2,
array_1d< double, 3 > &  rIntersectionPoint,
const double  epsilon = 1e-12 
)
inlinestatic

Find the 3D intersection of a line (bounded) with a triangle (bounded)

Parameters
rTriangleGeometryIs the triangle to intersect
rLinePoint1Coordinates of the first point of the intersecting line
rLinePoint2Coordinates of the second point of the intersecting line
Returns
rIntersectionPoint The intersection point coordinates
The intersection type index: -1 (the triangle is degenerate) 0 (disjoint - no intersection) 1 (intersect in a unique point) 2 (are in the same plane)

◆ ComputeTriangleLineIntersectionInTheSamePlane()

template<class TGeometryType , class TCoordinatesType >
static int Kratos::IntersectionUtilities::ComputeTriangleLineIntersectionInTheSamePlane ( const TGeometryType &  rTriangleGeometry,
const TCoordinatesType &  rLinePoint1,
const TCoordinatesType &  rLinePoint2,
TCoordinatesType &  rIntersectionPoint1,
TCoordinatesType &  rIntersectionPoint2,
int rSolution,
const double  Epsilon = 1e-12 
)
inlinestatic

Find the 3D intersection of a line (bounded) with a triangle (bounded) in the same plane.

Template Parameters
TGeometryTypeThe geometry type
TCoordinatesTypeThe type of coordinates
TConsiderInsidePointsIf considering inside points or just the intersections in the faces
Parameters
[in]rTriangleGeometryIs the tetrahedra to intersect
[in]rLinePoint1Coordinates of the first point of the intersecting line
[in]rLinePoint2Coordinates of the second point of the intersecting line
[out]rIntersectionPoint1The first intersection point coordinates
[out]rIntersectionPoint2The second intersection point coordinates
[out]rSolutionThe intersection type index: NO_INTERSECTION (disjoint - no intersection) TWO_POINTS_INTERSECTION (intersect in two points) ONE_POINT_INTERSECTION (intersect in one point)
EpsilonThe tolerance

◆ KRATOS_CLASS_POINTER_DEFINITION()

Kratos::IntersectionUtilities::KRATOS_CLASS_POINTER_DEFINITION ( IntersectionUtilities  )

Pointer definition of IntersectionUtilities.

◆ PointInTriangle()

static bool Kratos::IntersectionUtilities::PointInTriangle ( const array_1d< double, 3 > &  rVert0,
const array_1d< double, 3 > &  rVert1,
const array_1d< double, 3 > &  rVert2,
const array_1d< double, 3 > &  rPoint,
const double  Tolerance = std::numeric_limits<double>::epsilon() 
)
inlinestatic

This uses the Cramer's rule for solving a linear system and obtain the barycentric coordinates.

Check if a point is inside a 2D triangle

Parameters
rVert0The first vertex of the triangle to intersect
rVert1The second vertex of the triangle to intersect
rVert2The third vertex of the triangle to intersect
rPointCoordinates of the point
Returns
The intersection type index: -1 (the triangle is degenerate) 0 (disjoint - no intersection) 1 (intersect)

◆ TriangleLineIntersection2D() [1/2]

static bool Kratos::IntersectionUtilities::TriangleLineIntersection2D ( const array_1d< double, 3 > &  rVert0,
const array_1d< double, 3 > &  rVert1,
const array_1d< double, 3 > &  rVert2,
const array_1d< double, 3 > &  rPoint0,
const array_1d< double, 3 > &  rPoint1 
)
inlinestatic

Find the 2D intersection of a line (bounded) with a triangle (bounded)

Parameters
rVert1The first vertex of the triangle to intersect
rVert2The second vertex of the triangle to intersect
rVert3The third vertex of the triangle to intersect
rPoint1Coordinates of the first point of the intersecting line
rPoint2Coordinates of the second point of the intersecting line
Returns
If there is intersection

◆ TriangleLineIntersection2D() [2/2]

template<class TGeometryType >
static bool Kratos::IntersectionUtilities::TriangleLineIntersection2D ( const TGeometryType &  rTriangle,
const array_1d< double, 3 > &  rPoint0,
const array_1d< double, 3 > &  rPoint1 
)
inlinestatic

Find the 2D intersection of a line (bounded) with a triangle (bounded)

Parameters
rTriangleIs the triangle to intersect
rPoint0Coordinates of the first point of the intersecting line
rPoint1Coordinates of the second point of the intersecting line
Returns
If there is intersection

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