RobWorkProject
23.9.11-
|
Boundary representation (or B-Rep) of a geometric shape, using a collection of connected surfaces, edges and vertices. More...
#include <BREP.hpp>
Inherits GeometryData.
Inherited by ImplicitBREP, and QuadraticBREP.
Classes | |
class | CommonCurveSet |
Convenience type for a set of curves in a BREP. More... | |
struct | Face |
Face concept in the half-edge structure. More... | |
struct | HalfEdge |
Half-edge structure. More... | |
struct | Vertex |
Vertex for the half-edge structure. More... | |
Public Types | |
typedef rw::core::Ptr< BREP > | Ptr |
Smart pointer type to BREP. | |
typedef rw::core::Ptr< const BREP > | CPtr |
Smart pointer type to const BREP. | |
Public Types inherited from GeometryData | |
enum | GeometryType { PointCloud , LineMesh , PlainTriMesh , IdxTriMesh , SpherePrim , BoxPrim , OBBPrim , AABBPrim , LinePrim , PointPrim , PyramidPrim , ConePrim , TrianglePrim , CylinderPrim , TubePrim , PlanePrim , RayPrim , Implicit , Quadratic , UserType } |
geometry data types | |
typedef rw::core::Ptr< GeometryData > | Ptr |
smart pointer type to this class | |
typedef rw::core::Ptr< const GeometryData > | CPtr |
const smart pointer type to this class | |
Public Member Functions | |
virtual | ~BREP () |
Destructor. | |
virtual GeometryType | getType () const =0 |
the type of this primitive More... | |
virtual rw::core::Ptr< TriMesh > | getTriMesh (bool forceCopy=true) |
Create a TriMesh representation from this boundary representation. More... | |
virtual bool | isConvex () |
test if this geometry data is convex More... | |
virtual bool | isConvex () const |
test if this geometry data is convex More... | |
virtual const rw::geometry::Surface & | getSurface (std::size_t surfaceIndex) const =0 |
Get surface. More... | |
virtual const rw::geometry::Curve & | getCurve (std::size_t curveIndex) const =0 |
Get curve. More... | |
virtual void | scale (double factor)=0 |
Scale the object. More... | |
BREP::Ptr | clone () const |
Make a deep copy of the BREP. More... | |
rw::core::Ptr< const rw::geometry::Shell > | shellProxy () const |
Get a Shell representation as a proxy to the BREP. More... | |
std::vector< rw::core::Ptr< rw::geometry::Curve > > | getCurves (std::size_t loopIdx) const |
Get the curves in a given loop. More... | |
CommonCurveSet::CPtr | getCommonCurves (const std::set< std::size_t > &faces) const |
Get a set of common curves between a set of faces. More... | |
std::size_t | faceCount () const |
The number of faces. More... | |
std::size_t | loopCount () const |
The number of loops. More... | |
std::size_t | edgeCount () const |
The number of edges. More... | |
std::size_t | verticeCount () const |
The number of vertices. More... | |
const rw::math::Vector3D< double > & | getVertex (std::size_t vertexIndex) const |
Get vertex. More... | |
std::vector< rw::math::Vector3D< double > > | getVertices (std::size_t loopIdx) const |
Get the vertices in a given loop. More... | |
bool | hasSurfaceSet (std::size_t loop) |
Check if a certain loop has a surface set. More... | |
std::size_t | getSurfaceIndex (std::size_t loop) |
Get the surface index of a loop. More... | |
rw::geometry::OBB | obb (const rw::math::Rotation3D<> &R) |
Create Oriented Bounding Box with certain principal directions. More... | |
rw::geometry::OBB | obb () |
Create Oriented Bounding Box where the directions are estimated. More... | |
void | addVertex (const rw::math::Vector3D< double > &point) |
Add a vertex to the BREP. More... | |
void | makeLoop (int singleEdgeId) |
Create a loop containing a single edge (typically for circles and ellipses and similar). More... | |
template<typename T > | |
int | makeLoop (T first, T second) |
Create a loop containing two edges. More... | |
template<typename T , typename... Args> | |
int | makeLoop (T first, Args... args) |
Create a loop with a variable number of edges. More... | |
void | stitchEdges (std::size_t first, std::size_t second) |
Connect two half-edges. More... | |
void | stitchAuto (double eps) |
Try to stitch edges automatically. More... | |
rw::geometry::OBB | faceOBB (std::size_t faceIndex) |
Create Oriented Bounding Box for a face. More... | |
rw::geometry::OBB | edgeOBR (std::size_t edge) const |
Create Oriented Bounding Rectangle for an edge. More... | |
std::pair< double, double > | faceExtremums (std::size_t faceIndex, const rw::math::Vector3D< double > &dir) const |
Find the extent of the surface along a specific direction. More... | |
rw::core::Ptr< rw::geometry::TriMesh > | faceTriMesh (std::size_t faceIndex) |
Construct a Triangle Mesh for a face. More... | |
void | setMeshResolution (double resolution=10) |
Set the resolution used for discretization in the getTriMesh and faceTriMesh functions. More... | |
virtual void | print () |
Print the structure of the BREP for debugging purposes. | |
Public Member Functions inherited from GeometryData | |
virtual | ~GeometryData () |
Destructor. | |
Protected Member Functions | |
BREP () | |
Constructor. | |
void | copyTopologyTo (BREP::Ptr brep) const |
Copy the topology of this BREP to another brep. More... | |
void | addBREPEdge (std::size_t curveIndex, std::size_t vertex1, std::size_t vertex2) |
Add a edge (will insert a pair of half-edges). More... | |
void | setBREPFace (std::size_t surfaceIndex, std::size_t loop) |
Attach a surface to a loop. More... | |
Protected Attributes | |
std::vector< Vertex * > | _vertices |
The vertices in the BREP. | |
std::vector< std::pair< HalfEdge *, HalfEdge * > > | _edges |
The half-edges in the BREP. | |
std::vector< Face * > | _faces |
The faces in the BREP. A face is added for each loop constructed. | |
double | _resolution |
Resolution used for discretization functions. | |
Additional Inherited Members | |
Static Public Member Functions inherited from GeometryData | |
static std::string | toString (GeometryType type) |
format GeometryType to string More... | |
Boundary representation (or B-Rep) of a geometric shape, using a collection of connected surfaces, edges and vertices.
In the Shell representation, the geometric shape is formed as a collection of disconnected faces. The BREP representation adds more information about the topology, as surface and curve elements are connected. For a certain surface, curve or vertex, it is possible to find information about the directly connected neighbouring surfaces, edges and vertices. From a BREP it is also possible to retrieve a Shell representation, but in the Shell representation information about connectedness is lost.
The half-edge data structure is used internally to store the topological information about the faces, edges and vertices, and how they are connected. Subtypes of BREP implements the concrete Surface and Curve geometries that can be attached to the faces and edges.
In general, the procedure for forming a BREP is the following:
|
protected |
Add a edge (will insert a pair of half-edges).
Notice that a curve has direction, so it should start in vertex1 and end in vertex2.
curveIndex | [in] index of the curve data for the edge. |
vertex1 | [in] the first vertex. |
vertex2 | [in] the end vertex. |
void addVertex | ( | const rw::math::Vector3D< double > & | point | ) |
Add a vertex to the BREP.
point | [in] the vertex to add. |
|
protected |
Copy the topology of this BREP to another brep.
brep | [in/out] the other brep to copy data to. |
|
inline |
The number of edges.
rw::geometry::OBB edgeOBR | ( | std::size_t | edge | ) | const |
Create Oriented Bounding Rectangle for an edge.
edge | [in] the edge index, which should be less than edgeCount(). |
std::size_t faceCount | ( | ) | const |
The number of faces.
The number of faces is the number of loops, where a surface has been attached.
std::pair<double, double> faceExtremums | ( | std::size_t | faceIndex, |
const rw::math::Vector3D< double > & | dir | ||
) | const |
Find the extent of the surface along a specific direction.
If the surface has no lower bound, the value -std::numeric_limits<double>::max() can be returned to indicate that the surface has unbounded minimum value in the given direction.
If the surface has no upper bound, the value std::numeric_limits<double>::max() can be returned to indicate that the surface has unbounded maximum value in the given direction.
faceIndex | [in] the face index, which should be less than loopCount(). |
dir | [in] a normalized direction vector. |
rw::geometry::OBB faceOBB | ( | std::size_t | faceIndex | ) |
Create Oriented Bounding Box for a face.
faceIndex | [in] the face index, which should be less than loopCount(). |
rw::core::Ptr<rw::geometry::TriMesh> faceTriMesh | ( | std::size_t | faceIndex | ) |
Construct a Triangle Mesh for a face.
faceIndex | [in] the face index, which should be less than loopCount(). |
CommonCurveSet::CPtr getCommonCurves | ( | const std::set< std::size_t > & | faces | ) | const |
Get a set of common curves between a set of faces.
faces | [in] loop indexes for the faces to consider. |
|
pure virtual |
Get curve.
curveIndex | [in] index of the curve. Should be less than the number returned by edgeCount(). |
Implemented in QuadraticBREP, and ImplicitBREP.
std::vector<rw::core::Ptr<rw::geometry::Curve> > getCurves | ( | std::size_t | loopIdx | ) | const |
Get the curves in a given loop.
The curves will be traversed in an ordered way, and curves will have a direction that leads to the next curve.
loopIdx | [in] the loop index. |
|
pure virtual |
Get surface.
surfaceIndex | [in] the index of the surface. Should be less than the number returned by size(). |
Implemented in QuadraticBREP, and ImplicitBREP.
std::size_t getSurfaceIndex | ( | std::size_t | loop | ) |
Get the surface index of a loop.
loop | [in] the loop index. |
|
virtual |
Create a TriMesh representation from this boundary representation.
This function relies on the resolution set with setMeshResolution. The resolution is passed on to Curve::discretizeAdaptive and Surface::setDiscretizationResolution.
forceCopy | [in] generate a new copy, or use a cached TriMesh. |
Implements GeometryData.
|
pure virtual |
|
inline |
Get vertex.
vertexIndex | [in] index of the vertex. Should be less than the number returned by vertices(). |
std::vector<rw::math::Vector3D<double> > getVertices | ( | std::size_t | loopIdx | ) | const |
Get the vertices in a given loop.
The curves will be traversed in an ordered way around the loop.
loopIdx | [in] the loop index. |
|
inline |
Check if a certain loop has a surface set.
loop | [in] index of the loop, which should be less than loopCount(). |
|
virtual |
|
virtual |
test if this geometry data is convex
|
inline |
The number of loops.
void makeLoop | ( | int | singleEdgeId | ) |
Create a loop containing a single edge (typically for circles and ellipses and similar).
The half-edge structure requires that an edge must start and end in a vertex. Sometimes it is possible to have an edge without any vertices. This is, for example, the case for a circular or elliptic cylinder, where there will be two circular or elliptic edges. It is necessary to place one vertex on the circle or ellipse that can act as both the start and end vertex for the curve.
singleEdgeId | [in] id of the edge to create loop for. 1-indexing is expected, with a sign that indicates the edge direction. |
|
inline |
Create a loop with a variable number of edges.
first | [in] id of the first edge. 1-indexing is expected, with a sign that indicates the edge direction. |
args | [in] id of the following edges. Any number of arguments can be given. |
|
inline |
Create a loop containing two edges.
first | [in] id of the first edge. 1-indexing is expected, with a sign that indicates the edge direction. |
second | [in] id of the following edge. 1-indexing is expected, with a sign that indicates the edge direction. |
rw::geometry::OBB obb | ( | ) |
rw::geometry::OBB obb | ( | const rw::math::Rotation3D<> & | R | ) |
|
pure virtual |
Scale the object.
factor | [in] the factor to scale with. |
Implemented in QuadraticBREP, and ImplicitBREP.
|
protected |
Attach a surface to a loop.
surfaceIndex | [in] index of the surface data for the loop. |
loop | [in] the loop index. |
|
inline |
Set the resolution used for discretization in the getTriMesh and faceTriMesh functions.
The meaning of this parameter depends on the type of surface.
resolution | [in] the resolution parameter. |
|
inline |
void stitchAuto | ( | double | eps | ) |
Try to stitch edges automatically.
eps | [in] distance threshold for vertices and curves. |
void stitchEdges | ( | std::size_t | first, |
std::size_t | second | ||
) |
Connect two half-edges.
first | [in] id of the first edge. 0-indexing is expected, with a sign that indicates the edge direction. |
second | [in] id of the second edge. 0-indexing is expected, with a sign that indicates the edge direction. |
rw::core::Exception | if one of the given half-edges is already connected to another half-edge. |
|
inline |
The number of vertices.