VICUS Library
Documentation of Vicus library
|
#include <VICUS_PlaneGeometry.h>
Classes | |
struct | Hole |
Public Member Functions | |
PlaneGeometry () | |
PlaneGeometry (IBKMK::Polygon2D::type_t t, const IBKMK::Vector3D &a, const IBKMK::Vector3D &b, const IBKMK::Vector3D &c) | |
PlaneGeometry (const IBKMK::Polygon3D &poly3D) | |
bool | isValid () const |
double | inclination (int digits=1) const |
double | orientation (int digits=1) const |
const VICUS::Polygon3D & | polygon3D () const |
const IBKMK::Vector3D & | offset () const |
const IBKMK::Vector3D & | normal () const |
const IBKMK::Vector3D & | localX () const |
const IBKMK::Vector3D & | localY () const |
double | area (int digits=1) const |
IBKMK::Vector3D | centerPoint () const |
const IBKMK::Polygon2D & | polygon2D () const |
const std::vector< Hole > & | holes () const |
void | setPolygon (const Polygon3D &polygon3D) |
void | setHoles (const std::vector< Hole > &holes) |
void | setGeometry (const Polygon3D &polygon3D, const std::vector< Hole > &holes) |
void | flip () |
void | changeOrigin (unsigned int idx) |
const PlaneTriangulationData & | triangulationData () const |
const PlaneTriangulationData & | triangulationDataWithoutHoles () const |
const std::vector< PlaneTriangulationData > & | holeTriangulationData () const |
bool | intersectsLine (const IBKMK::Vector3D &p1, const IBKMK::Vector3D &d, IBKMK::Vector3D &intersectionPoint, double &dist, int &holeIndex, bool hitBackfacingPlanes=false, bool endlessPlane=false) const |
Class PlaneGeometry encapsulates the vertex data and plane type of a single plane in the geometrical model. Its main purpose is the triangulation of the outer polygon (optionally with holes) and the triangulation of the subsurfaces and to provide said data for visualization. Also, it implements intersection tests (for picking).
Since triangulation operations may be costly, the class implements lazy evaluation. Anything setting function that affects the computed triangulation just marks the PlaneGeometry as dirty. The triangulation is then computed on demand the triangulation data is accessed.
Note: PlaneGeometry is a runtime-only class and not used in the VICUS::Project data model. Instead, all data stored in PlaneGeometry is actually held in VICUS::Surface and its member variables.
|
inline |
Default constructor.
VICUS::PlaneGeometry::PlaneGeometry | ( | IBKMK::Polygon2D::type_t | t, |
const IBKMK::Vector3D & | a, | ||
const IBKMK::Vector3D & | b, | ||
const IBKMK::Vector3D & | c | ||
) |
Initializing constructor. Vertexes a, b and c must be given in counter-clockwise order, so that (b-a) x (c-a) yields the normal vector of the plane.
VICUS::PlaneGeometry::PlaneGeometry | ( | const IBKMK::Polygon3D & | poly3D | ) |
Convenience constructor, initializes plane geometry with Polygon3D.
double VICUS::PlaneGeometry::area | ( | int | digits = 1 | ) | const |
Calculates surface area in m2. Requires valid polygon, otherwise an exception is thrown.
|
inline |
Calculates the center point of the surface/polygon . Requires valid polygon, otherwise an exception is thrown.
void VICUS::PlaneGeometry::changeOrigin | ( | unsigned int | idx | ) |
void VICUS::PlaneGeometry::flip | ( | ) |
Flips the normal vector of the geometry. Does not require update of triangulation. Requires valid polygon, otherwise an exception is thrown.
|
inline |
Returns the vector of holes (2D polygons in the plane of the polygon).
const std::vector< PlaneTriangulationData > & VICUS::PlaneGeometry::holeTriangulationData | ( | ) | const |
Returns the triangulation data for each of the holes.
double VICUS::PlaneGeometry::inclination | ( | int | digits = 1 | ) | const |
Return the inclination in Deg. 0° -> Roof; 90° -> Wall; 180° -> Floor.
bool VICUS::PlaneGeometry::intersectsLine | ( | const IBKMK::Vector3D & | p1, |
const IBKMK::Vector3D & | d, | ||
IBKMK::Vector3D & | intersectionPoint, | ||
double & | dist, | ||
int & | holeIndex, | ||
bool | hitBackfacingPlanes = false , |
||
bool | endlessPlane = false |
||
) | const |
Tests if a line (with equation p = p1 + t * d) hits this plane. Returns true if intersection is found, and returns the normalized distance (t) between intersection point 'intersectionPoint' and point p1.
The optional argument hitBackfacingPlanes disables the front-facing check (if true). The optional argument endlessPlane disables the check if the intersection point lies within the plane (useful for getting intersections with, for example, the xy-plane).
If plane contains holes, 'holeIndex' contains the index of the respective hole. If the plane does not have any holes or the opaque surface was clicked, holeIndex will be -1.
bool VICUS::PlaneGeometry::isValid | ( | ) | const |
A polygon is considered "fully valid" for painting, if it has enough vertexes, a valid polygon and can be correctly triangulated (triangles not empty).
|
inline |
|
inline |
|
inline |
|
inline |
Returns the offset point (origin of the plane's local coordinate system)
double VICUS::PlaneGeometry::orientation | ( | int | digits = 1 | ) | const |
Return the orientation in Deg. 0° -> North; 90° -> East; 180° -> South; etc.
|
inline |
Returns the 2D polygon (only if it exists) in the plane of the polygon.
|
inline |
void VICUS::PlaneGeometry::setGeometry | ( | const Polygon3D & | polygon3D, |
const std::vector< Hole > & | holes | ||
) |
Set outer polygon and holes together (needs only one call to triangulate()).
void VICUS::PlaneGeometry::setHoles | ( | const std::vector< Hole > & | holes | ) |
Sets the vector of holes (2D polygons in the plane of the polygon).
void VICUS::PlaneGeometry::setPolygon | ( | const Polygon3D & | polygon3D | ) |
Sets the outer polygon alone.
const PlaneTriangulationData & VICUS::PlaneGeometry::triangulationData | ( | ) | const |
Returns the triangulation data for the opaque surface (excluding holes).
const PlaneTriangulationData & VICUS::PlaneGeometry::triangulationDataWithoutHoles | ( | ) | const |
Returns the triangulation data for the opaque surface (including holes, as if there were no holes).