EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_DCEL_Face.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2022 Robert Marskar <robert.marskar@sintef.no>
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
12#ifndef EBGEOMETRY_DCEL_FACE_HPP
13#define EBGEOMETRY_DCEL_FACE_HPP
14
15// Std includes
16#include <cstddef>
17#include <memory>
18#include <type_traits>
19#include <vector>
20
21// Our includes
22#include "EBGeometry_DCEL.hpp"
26#include "EBGeometry_Vec.hpp"
27
28namespace EBGeometry {
29
30namespace DCEL {
31
52template <class T, class Meta>
53class FaceT
54{
55 static_assert(std::is_floating_point_v<T>, "FaceT requires a floating-point T");
56
57public:
61 using Vec3 = Vec3T<T>;
62
67
72
77
81 using VertexPtr = std::shared_ptr<Vertex>;
82
86 using EdgePtr = std::shared_ptr<Edge>;
87
91 using FacePtr = std::shared_ptr<Face>;
92
97
102 FaceT() = default;
103
110
124
135 FaceT(Face&& a_otherFace) = default;
136
140 ~FaceT() = default;
141
148 Face&
149 operator=(const Face& a_otherFace) noexcept;
150
158 Face&
160
166 inline void
167 define(const Vec3& a_normal, const EdgePtr& a_edge) noexcept;
168
175 inline void
177
187 inline void
189
193 inline void
195
200 inline void
202
207 inline void
209
217 inline void
219
229
236
241 [[nodiscard]] inline Vec3T<T>&
243
250
256 [[nodiscard]] inline T&
258
264 [[nodiscard]] inline const T&
266
271 [[nodiscard]] inline Vec3T<T>&
273
280
285 [[nodiscard]] inline T&
287
292 [[nodiscard]] inline const T&
294
301
308
318 [[nodiscard]] inline T
320
330 [[nodiscard]] inline T
332
338 [[nodiscard]] inline std::vector<Vec3T<T>>
340
346 [[nodiscard]] inline std::vector<VertexPtr>
348
354 [[nodiscard]] inline std::vector<EdgePtr>
356
361 [[nodiscard]] inline Vec3T<T>
363
368 [[nodiscard]] inline Vec3T<T>
370
379 std::weak_ptr<Edge> m_halfEdge;
380
384 Vec3 m_normal = Vec3::zeros();
385
389 Vec3 m_centroid = Vec3::zeros();
390
398
402 T m_area{T(0)};
403
408 std::shared_ptr<Polygon2D<T>> m_poly2 = nullptr;
409
414
418 inline void
420
424 inline void
426
430 inline void
432
436 inline void
438
444 [[nodiscard]] inline Vec3T<T>
446
453 [[nodiscard]] inline bool
455};
456} // namespace DCEL
457
458} // namespace EBGeometry
459
460#include "EBGeometry_DCEL_FaceImplem.hpp"
461
462#endif
Namespace documentation.
Declaration of a half-edge class for use in DCEL descriptions of polygon tessellations.
Declaration of a vertex class for use in DCEL descriptions of polygon tessellations.
Declaration of a two-dimensional polygon class for embedding 3D polygon faces.
Declaration of 2D and 3D point/vector classes with templated precision. Used with DCEL tools.
Face class for navigating a DCEL mesh.
Definition EBGeometry_DCEL_Face.hpp:54
Vec3 m_centroid
Polygon face centroid position.
Definition EBGeometry_DCEL_Face.hpp:389
void computeCentroid()
Compute the centroid position of this polygon.
std::shared_ptr< Polygon2D< T > > m_poly2
2D embedding of this polygon. This is the 2D view of the current object projected along its normal ve...
Definition EBGeometry_DCEL_Face.hpp:408
T signedDistance(const Vec3 &a_x0) const noexcept
Compute the signed distance to a point.
Vec3T< T > getSmallestCoordinate() const
Get the lower-left-most coordinate of this polygon face.
FaceT(Face &&a_otherFace)=default
Move constructor.
Vec3T< T > getHighestCoordinate() const
Get the upper-right-most coordinate of this polygon face.
std::shared_ptr< Face > FacePtr
Alias for face pointer type.
Definition EBGeometry_DCEL_Face.hpp:91
void flipNormal() noexcept
Flip the normal vector.
void setHalfEdge(const EdgePtr &a_halfEdge) noexcept
Set the half edge.
std::vector< Vec3T< T > > getAllVertexCoordinates() const
Return the coordinates of all the vertices on this polygon.
Meta m_metaData
Meta-data attached to this face.
Definition EBGeometry_DCEL_Face.hpp:397
void computePolygon2D()
Compute the 2D embedding of this polygon from the current normal vector and topology,...
std::shared_ptr< Edge > EdgePtr
Alias for edge pointer type.
Definition EBGeometry_DCEL_Face.hpp:86
Face & operator=(Face &&a_otherFace)=default
Move assignment operator.
void setInsideOutsideAlgorithm(typename Polygon2D< T >::InsideOutsideAlgorithm &a_algorithm) noexcept
Set the inside/outside algorithm when determining if a point projects to the inside or outside of the...
void normalizeNormalVector() noexcept
Normalize the normal vector, ensuring it has a length of 1.
Polygon2D< T >::InsideOutsideAlgorithm m_poly2Algorithm
Algorithm for inside/outside tests.
Definition EBGeometry_DCEL_Face.hpp:413
void reconcile()
Reconcile face. This will compute the normal vector, area, centroid, and the 2D embedding of the poly...
std::weak_ptr< Edge > m_halfEdge
This polygon's half-edge. A valid face will always have this set.
Definition EBGeometry_DCEL_Face.hpp:379
bool isPointInsideFace(const Vec3 &a_p) const noexcept
Check if a point projects to inside or outside the polygon face.
void computeNormal()
Compute the normal position of this polygon.
Face & operator=(const Face &a_otherFace) noexcept
Copy assignment operator.
Vec3T< T > & getCentroid() noexcept
Get modifiable centroid.
T m_area
Cached polygon face area (stored by reconcile()).
Definition EBGeometry_DCEL_Face.hpp:402
FaceT(const EdgePtr &a_edge)
Partial constructor. Calls default constructor but associates a half-edge.
std::shared_ptr< Vertex > VertexPtr
Alias for vertex pointer type.
Definition EBGeometry_DCEL_Face.hpp:81
void setMetaData(const Meta &a_metaData) noexcept
Set the meta-data.
T unsignedDistance2(const Vec3 &a_x0) const noexcept
Compute the unsigned squared distance to a point.
std::vector< EdgePtr > gatherEdges() const
Return all the half-edges on this polygon.
void define(const Vec3 &a_normal, const EdgePtr &a_edge) noexcept
Define function which sets the normal vector and half-edge.
FaceT(const Face &a_otherFace)
Copy constructor.
EdgePtr getHalfEdge() noexcept
Get the starting half-edge.
Meta & getMetaData() noexcept
Get meta-data.
Vec3 m_normal
Polygon face normal vector.
Definition EBGeometry_DCEL_Face.hpp:384
~FaceT()=default
Destructor (does nothing)
T & getArea() noexcept
Get modifiable polygon area (computed during reconcile()).
Vec3T< T > & getNormal() noexcept
Get modifiable normal vector.
void computeArea()
Compute the area of this polygon and cache it in m_area.
Vec3T< T > projectPointIntoFacePlane(const Vec3 &a_p) const noexcept
Compute the projection of a point onto the polygon face plane.
std::vector< VertexPtr > gatherVertices() const
Return all the vertices on this polygon.
FaceT()=default
Default constructor. Sets the half-edge to zero and the inside/outside algorithm to crossing number a...
Class for embedding a polygon face into 2D.
Definition EBGeometry_Polygon2D.hpp:46
InsideOutsideAlgorithm
Supported algorithms for performing inside/outside tests when checking if a point projects to the ins...
Definition EBGeometry_Polygon2D.hpp:55
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:225
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:31