#include <PolyhedronShape_fwd.hpp>
A polyhedron represented by a closed triangular mesh.
This class uses CGAL (https://www.cgal.org/) and its Surface_mesh
class to do the heavy lifting.
vec_t | This shape class is used only for 3D domains. |
Usage example:
Definition at line 46 of file PolyhedronShape_fwd.hpp.
Public Member Functions | |
PolyhedronShape (const Mesh &surface) | |
Construct a shape from a CGAL surface mesh. More... | |
PolyhedronShape (const PolyhedronShape &other) | |
Copy constructor (necessary to rebuild the tree). More... | |
PolyhedronShape & | operator= (const PolyhedronShape &other) |
Copy assignment (necessary to rebuild the tree). More... | |
bool | contains (const vec_t &point) const override |
Return true if point is not more than margin() outside the domain. More... | |
std::pair< vec_t, vec_t > | bbox () const override |
Return the bounding box of the domain. More... | |
DomainDiscretization< vec_t > | discretizeBoundaryWithDensity (const std::function< scalar_t(vec_t)> &dr, int type) const override |
Discretizes boundary with given density and fill engine. More... | |
std::ostream & | print (std::ostream &os) const override |
Output information about this shape to given output stream os . More... | |
PolyhedronShape * | clone () const override |
Polymorphic clone pattern. More... | |
virtual DomainDiscretization< vec_t > | discretizeBoundaryWithDensity (const std::function< scalar_t(vec_t)> &dr, int type) const=0 |
Discretizes boundary with given density and fill engine. More... | |
DomainDiscretization< vec_t > | discretizeBoundaryWithDensity (const std::function< scalar_t(vec_t)> &dr) const |
Overload with default type. More... | |
virtual DomainDiscretization< vec_t > | discretizeBoundaryWithStep (scalar_t step, int type) const |
Returns a discretization of the boundary of this shape with approximately uniform distance step between nodes. More... | |
DomainDiscretization< vec_t > | discretizeBoundaryWithStep (scalar_t step) const |
Returns a discretization of the boundary of this shape with approximately uniform distance step between nodes. More... | |
scalar_t | margin () const |
Returns current margin. More... | |
virtual void | setMargin (scalar_t margin) |
Sets domain margin to margin . More... | |
void | toggleMargin () |
Toggles the margin from positive to negative. More... | |
ShapeUnion< vec_t > | add (const DomainShape &other) const |
Returns a shape representing a union of *this and other . More... | |
ShapeUnion< vec_t > | operator+ (const DomainShape &other) const |
Operator form of DomainShape::add. More... | |
ShapeDifference< vec_t > | subtract (const DomainShape &other) const |
Returns a shape representing a difference of *this and other . More... | |
ShapeDifference< vec_t > | operator- (const DomainShape &other) const |
Operator form of DomainShape::subtract. More... | |
virtual std::pair< bool, vec_t > | projectPointToBoundary (const vec_t &point, const vec_t &unit_normal) const |
Project point to boundary using bisection along the line define by unit_normal . More... | |
virtual bool | hasContains () const |
Return true if shape has contains() method implemented. More... | |
virtual DomainDiscretization< vec_t > | discretizeBoundaryWithStep (scalar_t step, int type) const |
Returns a discretization of the boundary of this shape with approximately uniform distance step between nodes. More... | |
DomainDiscretization< vec_t > | discretizeBoundaryWithStep (scalar_t step) const |
Returns a discretization of the boundary of this shape with approximately uniform distance step between nodes. More... | |
virtual DomainDiscretization< vec_t > | discretizeWithStep (scalar_t step, int internal_type, int boundary_type) const |
Returns a discretization of this shape with approximately uniform distance step between nodes. More... | |
DomainDiscretization< vec_t > | discretizeWithStep (scalar_t step) const |
discretizeWithStep but with default types as assigned by the shape. More... | |
virtual DomainDiscretization< vec_t > | discretizeWithDensity (const std::function< scalar_t(vec_t)> &dr, int internal_type, int boundary_type) const |
Returns a discretization of the domain with spatially variable step. More... | |
template<typename func_t , typename fill_t > | |
DomainDiscretization< vec_t > | discretizeWithDensity (const func_t &dr, const fill_t &fill, int internal_type, int boundary_type) const |
Overload for fill engine. More... | |
DomainDiscretization< vec_t > | discretizeWithDensity (const std::function< scalar_t(vec_t)> &dr) const |
Overload with default types. More... | |
template<typename func_t , typename fill_t > | |
DomainDiscretization< vec_t > | discretizeWithDensity (const func_t &dr, const fill_t &fill) const |
Overload for fill engine with default types. More... | |
DomainDiscretization< vec_t > | discretizeBoundaryWithDensity (const std::function< scalar_t(vec_t)> &dr) const |
Overload with default type. More... | |
TranslatedShape< vec_t > | translate (const vec_t &a) |
Translate the shape by given vector a . More... | |
RotatedShape< vec_t > | rotate (const Eigen::Matrix< scalar_t, dim, dim > &Q) |
Transform the shape by given orthogonal matrix Q . More... | |
RotatedShape< vec_t > | rotate (scalar_t angle) |
2D version of rotate accepting an angle. More... | |
Static Public Member Functions | |
static PolyhedronShape | fromOFF (const std::string &filename) |
Read a triangular closed surface mesh describing a polyhedron from a .off file. More... | |
static int | rgb2type (uint8_t r, uint8_t g, uint8_t b) |
Convert a RBG color to an integer value that can be used as a boundary type. More... | |
Public Types | |
typedef vec_t::Scalar | scalar_t |
Scalar data type used in computation. More... | |
typedef vec_t | vector_t |
Vector data type used in computations. More... | |
enum | { dim = vec_t::dim } |
Store dimension of the domain. More... | |
Protected Attributes | |
scalar_t | margin_ |
Tolerance for the geometric operation of the domain. More... | |
Private Types | |
using | base_t = DomainShape< vec_t > |
Base class type. More... | |
typedef CGAL::Simple_cartesian< double > | K |
CGAL geometry kernel. More... | |
typedef K::Point_3 | Point |
CGAL point type. More... | |
typedef K::Vector_3 | Vector |
CGAL vector type. More... | |
typedef CGAL::Surface_mesh< Point > | Mesh |
CGAL surface mesh type. More... | |
typedef Mesh::Vertex_index | VI |
CGAL index type for a point on a surface mesh. More... | |
typedef Mesh::Face_index | FI |
CGAL index type for a face on a surface mesh. More... | |
typedef CGAL::AABB_face_graph_triangle_primitive< Mesh > | Primitive |
CGAL type for storing triangular faces of surface meshes in AABB tree. More... | |
typedef CGAL::AABB_tree< CGAL::AABB_traits< K, Primitive > > | Tree |
CGAL type for axis-aligned bounding-box trees, used for testing point inclusions. More... | |
typedef CGAL::Side_of_triangle_mesh< Mesh, K > | PointInside |
CGAL type of the function for testing point inclusion. More... | |
Private Member Functions | |
void | init () |
Initialize the tree and compute surface normals. More... | |
vec_t | getPoint (VI idx) const |
Convert a CGAL vertex index to a Medusa vector. More... | |
Private Attributes | |
Mesh | surface |
Surface of the polyhedron represented as a triangular mesh. More... | |
Tree | tree |
AABB tree of the faces. More... | |
PointInside | inside_tester |
Function used for testing point inclusions. More... | |
|
inherited |
Store dimension of the domain.
Enumerator | |
---|---|
dim | Dimensionality of the domain. |
Definition at line 57 of file DomainShape_fwd.hpp.
|
inlineexplicit |
Construct a shape from a CGAL surface mesh.
Definition at line 87 of file PolyhedronShape_fwd.hpp.
|
inline |
Copy constructor (necessary to rebuild the tree).
Definition at line 91 of file PolyhedronShape_fwd.hpp.
|
inherited |
Returns a shape representing a union of *this
and other
.
Definition at line 66 of file DomainShape.hpp.
|
inlineoverridevirtual |
Return the bounding box of the domain.
Bounding box is returned in format bbox() == {{mx, my, ...}, {MX, MY, ...}}
, such that mx <= Mx
and my <= My
etc.\ and that the whole domain is contained in the cuboid [mx, my, ...] x [Mx, My, ...]
.
Implements mm::DomainShape< vec_t >.
Definition at line 128 of file PolyhedronShape_fwd.hpp.
|
inlineoverridevirtual |
Polymorphic clone pattern.
Implements mm::DomainShape< vec_t >.
Definition at line 141 of file PolyhedronShape_fwd.hpp.
|
inlineoverridevirtual |
Return true if point
is not more than margin()
outside the domain.
Implements mm::DomainShape< vec_t >.
Definition at line 124 of file PolyhedronShape_fwd.hpp.
|
inline |
Overload with default type.
Definition at line 189 of file DomainShape_fwd.hpp.
|
inlineinherited |
Overload with default type.
Definition at line 189 of file DomainShape_fwd.hpp.
|
overridevirtual |
Discretizes boundary with given density and fill engine.
If type is 0, the underlying shape provides the default.
Implements mm::DomainShape< vec_t >.
Definition at line 11 of file PolyhedronShape.hpp.
virtual DomainDiscretization<vec_t> mm::DomainShape< vec_t >::discretizeBoundaryWithDensity |
Discretizes boundary with given density and fill engine.
If type is 0, the underlying shape provides the default.
|
inline |
Returns a discretization of the boundary of this shape with approximately uniform distance step
between nodes.
Node type are decided by the underlying shape.
Definition at line 126 of file DomainShape_fwd.hpp.
|
inlineinherited |
Returns a discretization of the boundary of this shape with approximately uniform distance step
between nodes.
Node type are decided by the underlying shape.
Definition at line 126 of file DomainShape_fwd.hpp.
|
inline |
Returns a discretization of the boundary of this shape with approximately uniform distance step
between nodes.
step
must be positive. Added nodes are of type type
, which must be non-positive. Value 0 indicates that types are dependant on the implementation of concrete shape.
Definition at line 118 of file DomainShape_fwd.hpp.
|
inlinevirtualinherited |
Returns a discretization of the boundary of this shape with approximately uniform distance step
between nodes.
step
must be positive. Added nodes are of type type
, which must be non-positive. Value 0 indicates that types are dependant on the implementation of concrete shape.
Reimplemented in mm::PolygonShape< vec_t >, mm::TranslatedShape< vec_t >, mm::ShapeUnion< vec_t >, mm::BoxShape< vec_t >, mm::ShapeDifference< vec_t >, and mm::BallShape< vec_t >.
Definition at line 118 of file DomainShape_fwd.hpp.
|
inlineinherited |
Overload for fill engine with default types.
Definition at line 177 of file DomainShape_fwd.hpp.
|
inlineinherited |
Overload for fill engine.
Definition at line 162 of file DomainShape_fwd.hpp.
|
inlineinherited |
Overload with default types.
Definition at line 170 of file DomainShape_fwd.hpp.
|
virtualinherited |
Returns a discretization of the domain with spatially variable step.
dr | Function giving desired internodal distance at each point. |
internal_type | User supplied type of internal nodes. Must be non-negative. |
boundary_type | User supplied type of boundary nodes. Must be non-positive. If any of the types is 0, the underlying shape provides the default. |
dr
. Reimplemented in mm::TranslatedShape< vec_t >, mm::ShapeUnion< vec_t >, and mm::ShapeDifference< vec_t >.
Definition at line 77 of file DomainShape.hpp.
|
inlineinherited |
discretizeWithStep but with default types as assigned by the shape.
Definition at line 144 of file DomainShape_fwd.hpp.
|
inlinevirtualinherited |
Returns a discretization of this shape with approximately uniform distance step
between nodes.
step
must be positive.
step | Desired internodal distance. |
internal_type | User supplied type of internal nodes. Must be non-negative. |
boundary_type | User supplied type of boundary nodes. Must be non-positive. If any of the types is 0, the underlying shape provides the default. |
Reimplemented in mm::TranslatedShape< vec_t >, mm::ShapeUnion< vec_t >, mm::BoxShape< vec_t >, mm::ShapeDifference< vec_t >, and mm::BallShape< vec_t >.
Definition at line 137 of file DomainShape_fwd.hpp.
|
inlinestatic |
Read a triangular closed surface mesh describing a polyhedron from a .off
file.
The face colors are read and stored as well and used to determine surface point types. See the method rgb2type for how RBG colors are converted to boundary types.
filename | Path to the .off file. |
Assertion | fails if file cannot be read, the surface is empty, not triangular or not closed. |
Definition at line 110 of file PolyhedronShape_fwd.hpp.
|
inlineprivate |
Convert a CGAL vertex index to a Medusa vector.
Definition at line 150 of file PolyhedronShape_fwd.hpp.
|
inlinevirtualinherited |
Return true if shape has contains()
method implemented.
Reimplemented in mm::NURBSShape< vec_t, param_vec_t >, mm::RotatedShape< vec_t >, mm::ShapeDifference< vec_t >, mm::ShapeUnion< vec_t >, mm::STLShape< vec_t >, mm::TranslatedShape< vec_t >, and mm::UnknownShape< vec_t >.
Definition at line 96 of file DomainShape_fwd.hpp.
|
inlineprivate |
Initialize the tree and compute surface normals.
Definition at line 69 of file PolyhedronShape_fwd.hpp.
|
inlineinherited |
Returns current margin.
Definition at line 72 of file DomainShape_fwd.hpp.
|
inlineinherited |
|
inlineinherited |
Operator form of DomainShape::subtract.
Definition at line 86 of file DomainShape_fwd.hpp.
|
inline |
Copy assignment (necessary to rebuild the tree).
Definition at line 95 of file PolyhedronShape_fwd.hpp.
|
inlineoverridevirtual |
Output information about this shape to given output stream os
.
Implements mm::DomainShape< vec_t >.
Definition at line 136 of file PolyhedronShape_fwd.hpp.
|
virtualinherited |
Project point to boundary using bisection along the line define by unit_normal
.
Definition at line 21 of file DomainShape.hpp.
|
inlinestatic |
Convert a RBG color to an integer value that can be used as a boundary type.
Definition at line 144 of file PolyhedronShape_fwd.hpp.
|
inherited |
Transform the shape by given orthogonal matrix Q
.
Definition at line 98 of file DomainShape.hpp.
|
inherited |
2D version of rotate accepting an angle.
Definition at line 89 of file DomainShape.hpp.
|
inlinevirtualinherited |
Sets domain margin to margin
.
Reimplemented in mm::PolygonShape< vec_t >.
Definition at line 75 of file DomainShape_fwd.hpp.
|
inherited |
Returns a shape representing a difference of *this
and other
.
Definition at line 71 of file DomainShape.hpp.
|
inlineinherited |
Toggles the margin from positive to negative.
Definition at line 77 of file DomainShape_fwd.hpp.
|
inherited |
Translate the shape by given vector a
.
Definition at line 84 of file DomainShape.hpp.
|
private |
Function used for testing point inclusions.
Definition at line 66 of file PolyhedronShape_fwd.hpp.
|
protectedinherited |
Tolerance for the geometric operation of the domain.
The domain should behave as if it was margin_
thicker. Default margin is 1e-10
.
Definition at line 64 of file DomainShape_fwd.hpp.
|
private |
Surface of the polyhedron represented as a triangular mesh.
Definition at line 64 of file PolyhedronShape_fwd.hpp.
|
private |
AABB tree of the faces.
Definition at line 65 of file PolyhedronShape_fwd.hpp.