Simox
2.3.74.0
|
Data Structures | |
struct | triangle |
Public Member Functions | |
TriMeshModel () | |
Constructor. More... | |
TriMeshModel (TriMeshModel &&)=default | |
TriMeshModel (const TriMeshModel &)=default | |
TriMeshModel & | operator= (TriMeshModel &&)=default |
TriMeshModel & | operator= (const TriMeshModel &)=default |
TriMeshModel (const std::vector< triangle > &triangles) | |
Construct from vector of triangles. More... | |
TriMeshModel (const MathTools::ConvexHull3D &ch) | |
virtual | ~TriMeshModel ()=default |
Virtual destructor. More... | |
template<typename T > | |
Eigen::Vector3f | nonUniformSampleSurface (T &gen) const |
void | addTriangleWithFace (const Eigen::Vector3f &vertex1, const Eigen::Vector3f &vertex2, const Eigen::Vector3f &vertex3) |
void | addTriangleWithFace (const Eigen::Vector3f &vertex1, const Eigen::Vector3f &vertex2, const Eigen::Vector3f &vertex3, Eigen::Vector3f normal, const VisualizationFactory::Color &color1=VisualizationFactory::Color::Gray(), const VisualizationFactory::Color &color2=VisualizationFactory::Color::Gray(), const VisualizationFactory::Color &color3=VisualizationFactory::Color::Gray()) |
void | addTriangleWithFace (const Eigen::Vector3f &vertex1, const Eigen::Vector3f &vertex2, const Eigen::Vector3f &vertex3, const Eigen::Vector4f &vertexColor1, const Eigen::Vector4f &vertexColor2, const Eigen::Vector4f &vertexColor3) |
void | addMesh (const TriMeshModel &mesh) |
void | addFace (const MathTools::TriangleFace &face) |
int | addVertex (const Eigen::Vector3f &vertex) |
int | addVertex (float x, float y, float z) |
unsigned int | addNormal (const Eigen::Vector3f &normal) |
unsigned int | addNormal (float x, float y, float z) |
unsigned int | addColor (const VisualizationFactory::Color &color) |
unsigned int | addColor (const Eigen::Vector4f &color) |
unsigned int | addColor (float r, float g, float b, float a) |
unsigned int | addMaterial (const VisualizationFactory::PhongMaterial &material) |
void | addFace (unsigned int id0, unsigned int id1, unsigned int id2) |
void | clear () |
unsigned int | addMissingNormals () |
Checks all faces for existence of normals. Creates the normals in case they are missing. More... | |
unsigned int | addMissingColors (const VisualizationFactory::Color &color=VisualizationFactory::Color::Gray()) |
Checks all faces for existence of colors. First, mergeVertices() is called. Then, if no color is found, a face with the same vertex is searched and that color is used (if available). Otherwise sets color to the given color. More... | |
void | smoothNormalSurface () |
Smoothes the normal surface by calculating the average of all face-normals of one vertex. Calls first mergeVertices(). More... | |
void | flipVertexOrientations () |
void | mergeVertices (float mergeThreshold=0.0001f, bool removeVertices=true) |
Merges vertices that are close together (mergeThreshold). Usually, vertices that are close together should be one vertex. Otherwise the mesh could consist of many individual triangles. All vertex ids stored in faces are updated. This function is quite efficient due to a kd-tree and an inverted face-vertex mapping. More... | |
void | fattenShrink (float offset, bool updateNormals=false) |
fatten or shrink this trimesh. Done by moving a vertex along a normal calculated from the normals of all the faces the vertex is used in. More... | |
size_t | removeUnusedVertices () |
removeUnusedVertices Checks if vertices are used by faces. May rearrange vertices vector! More... | |
std::vector< float > | getFaceAreas () const |
Get the areas of all faces. More... | |
float | getVolume () const |
Computes the volume of the mesh. Works only for closed meshes. More... | |
void | rotate (const Eigen::Matrix3f &mx) |
void | setColor (VisualizationFactory::Color color) |
void | print () |
void | printNormals () |
void | printVertices () |
void | printFaces () |
Eigen::Vector3f | getCOM () |
bool | getSize (Eigen::Vector3f &storeMinSize, Eigen::Vector3f &storeMaxSize) |
bool | checkFacesHaveSameEdge (const MathTools::TriangleFace &face1, const MathTools::TriangleFace &face2, std::vector< std::pair< int, int > > &commonVertexIds) const |
unsigned int | checkAndCorrectNormals (bool inverted) |
Eigen::Vector3f | getNormalOfFace (std::size_t faceId) const |
virtual void | scale (const Eigen::Vector3f &scaleFactor) |
virtual void | scale (float scaleFactor) |
TriMeshModelPtr | clone () const |
TriMeshModelPtr | clone (const Eigen::Vector3f &scaleFactor) const |
TriMeshModelPtr | clone (float x, float y, float z) const |
Static Public Member Functions | |
static EIGEN_MAKE_ALIGNED_OPERATOR_NEW TriMeshModelPtr | FromFile (const std::string &str) |
static TriMeshModel | MakeBox (float a, float b, float c) |
static TriMeshModel | MakePoint (float x, float y, float z) |
static TriMeshModelPtr | MakePointPtr (float x, float y, float z) |
static TriMeshModelPtr | MakePointPtr (const Eigen::Vector3f &p) |
static Eigen::Vector3f | CreateNormal (const Eigen::Vector3f &vertex1, const Eigen::Vector3f &vertex2, const Eigen::Vector3f &vertex3) |
Data Fields | |
std::vector< Eigen::Vector3f > | normals |
std::vector< Eigen::Vector3f > | vertices |
std::vector< VisualizationFactory::Color > | colors |
std::vector< MathTools::TriangleFace > | faces |
std::vector< VisualizationFactory::PhongMaterial > | materials |
BoundingBox | boundingBox |
|
default |
Constructor.
|
default |
|
default |
VirtualRobot::TriMeshModel::TriMeshModel | ( | const std::vector< triangle > & | triangles | ) |
Construct from vector of triangles.
VirtualRobot::TriMeshModel::TriMeshModel | ( | const MathTools::ConvexHull3D & | ch | ) |
|
virtualdefault |
Virtual destructor.
unsigned int VirtualRobot::TriMeshModel::addColor | ( | const VisualizationFactory::Color & | color | ) |
This method adds a color to the internal data structure TriMeshModel::colors
unsigned int VirtualRobot::TriMeshModel::addColor | ( | const Eigen::Vector4f & | color | ) |
This method converts and adds a color to the internal data structure TriMeshModel::colors
|
inline |
void VirtualRobot::TriMeshModel::addFace | ( | const MathTools::TriangleFace & | face | ) |
This method adds a face to the internal data structure TriMeshModel::faces.
void VirtualRobot::TriMeshModel::addFace | ( | unsigned int | id0, |
unsigned int | id1, | ||
unsigned int | id2 | ||
) |
unsigned int VirtualRobot::TriMeshModel::addMaterial | ( | const VisualizationFactory::PhongMaterial & | material | ) |
This method converts and adds a color to the internal data structure TriMeshModel::materials
void VirtualRobot::TriMeshModel::addMesh | ( | const TriMeshModel & | mesh | ) |
unsigned int VirtualRobot::TriMeshModel::addMissingColors | ( | const VisualizationFactory::Color & | color = VisualizationFactory::Color::Gray() | ) |
Checks all faces for existence of colors. First, mergeVertices() is called. Then, if no color is found, a face with the same vertex is searched and that color is used (if available). Otherwise sets color to the given color.
color | Default Color |
unsigned int VirtualRobot::TriMeshModel::addMissingNormals | ( | ) |
Checks all faces for existence of normals. Creates the normals in case they are missing.
unsigned int VirtualRobot::TriMeshModel::addNormal | ( | const Eigen::Vector3f & | normal | ) |
This method adds a normal to the internal data structure TriMeshModel::normals.
|
inline |
void VirtualRobot::TriMeshModel::addTriangleWithFace | ( | const Eigen::Vector3f & | vertex1, |
const Eigen::Vector3f & | vertex2, | ||
const Eigen::Vector3f & | vertex3 | ||
) |
This method adds the vertices vertex1
, vertex2
and vertex3
to TriMeshModel::vertices and creates a new TriangleFace instance which is added to TriMeshModel::faces.
vertex1 | first vertex to use in the calculation |
vertex2 | second vertex to use in the calculation |
vertex3 | third vertex to use in the calculation |
void VirtualRobot::TriMeshModel::addTriangleWithFace | ( | const Eigen::Vector3f & | vertex1, |
const Eigen::Vector3f & | vertex2, | ||
const Eigen::Vector3f & | vertex3, | ||
Eigen::Vector3f | normal, | ||
const VisualizationFactory::Color & | color1 = VisualizationFactory::Color::Gray() , |
||
const VisualizationFactory::Color & | color2 = VisualizationFactory::Color::Gray() , |
||
const VisualizationFactory::Color & | color3 = VisualizationFactory::Color::Gray() |
||
) |
void VirtualRobot::TriMeshModel::addTriangleWithFace | ( | const Eigen::Vector3f & | vertex1, |
const Eigen::Vector3f & | vertex2, | ||
const Eigen::Vector3f & | vertex3, | ||
const Eigen::Vector4f & | vertexColor1, | ||
const Eigen::Vector4f & | vertexColor2, | ||
const Eigen::Vector4f & | vertexColor3 | ||
) |
int VirtualRobot::TriMeshModel::addVertex | ( | const Eigen::Vector3f & | vertex | ) |
This method adds a vertex to the internal data structure TriMeshModel::vertices.
|
inline |
unsigned int VirtualRobot::TriMeshModel::checkAndCorrectNormals | ( | bool | inverted | ) |
This method checks if all normals of the model point inwards or outwards and flippes the faces which have a wrong orientation.
inverted | inverts the check if set to true |
bool VirtualRobot::TriMeshModel::checkFacesHaveSameEdge | ( | const MathTools::TriangleFace & | face1, |
const MathTools::TriangleFace & | face2, | ||
std::vector< std::pair< int, int > > & | commonVertexIds | ||
) | const |
This method checks if the faces face1
and face2
share one common edge.
face1 | first TriangleFace to use in comparison |
face2 | second TriangleFace to use in comparison |
commonVertexIds | contains a list of |
void VirtualRobot::TriMeshModel::clear | ( | ) |
This method clears the internal data structures TriMeshModel::faces and TriMeshModel::vertices.
TriMeshModelPtr VirtualRobot::TriMeshModel::clone | ( | ) | const |
TriMeshModelPtr VirtualRobot::TriMeshModel::clone | ( | const Eigen::Vector3f & | scaleFactor | ) | const |
TriMeshModelPtr VirtualRobot::TriMeshModel::clone | ( | float | x, |
float | y, | ||
float | z | ||
) | const |
|
static |
This method creates the normal belonging to the vertices vertex1
, vertex2
and vertex3
.
vertex1 | first vertex to use in the calculation |
vertex2 | second vertex to use in the calculation |
vertex3 | third vertex to use in the calculation |
void VirtualRobot::TriMeshModel::fattenShrink | ( | float | offset, |
bool | updateNormals = false |
||
) |
fatten or shrink this trimesh. Done by moving a vertex along a normal calculated from the normals of all the faces the vertex is used in.
offset | All vertexes are moved about this offset in mm. |
updateNormals | If true, all normals will be updated with the average normal of all normals beloning to one vertex (from multiple faces) |
void VirtualRobot::TriMeshModel::flipVertexOrientations | ( | ) |
This method calls TriangleFace::flipOrientation() on each entry in TriMeshModel::faces.
|
static |
Eigen::Vector3f VirtualRobot::TriMeshModel::getCOM | ( | ) |
This method calculates the center of mass by accumulating all vertices and dividing the sum by the number of vertices.
std::vector< float > VirtualRobot::TriMeshModel::getFaceAreas | ( | ) | const |
Get the areas of all faces.
Eigen::Vector3f VirtualRobot::TriMeshModel::getNormalOfFace | ( | std::size_t | faceId | ) | const |
bool VirtualRobot::TriMeshModel::getSize | ( | Eigen::Vector3f & | storeMinSize, |
Eigen::Vector3f & | storeMaxSize | ||
) |
float VirtualRobot::TriMeshModel::getVolume | ( | ) | const |
Computes the volume of the mesh. Works only for closed meshes.
|
static |
|
static |
|
static |
|
static |
void VirtualRobot::TriMeshModel::mergeVertices | ( | float | mergeThreshold = 0.0001f , |
bool | removeVertices = true |
||
) |
Merges vertices that are close together (mergeThreshold). Usually, vertices that are close together should be one vertex. Otherwise the mesh could consist of many individual triangles. All vertex ids stored in faces are updated. This function is quite efficient due to a kd-tree and an inverted face-vertex mapping.
mergeThreshold | If squared Euclidan distance of two points is belong this threshold, two vertices are merged. |
removeVertices | If set, the vertex vextor is chekced for unused vertices. May result in a reassembled vertex vector. |
|
inline |
|
default |
|
default |
void VirtualRobot::TriMeshModel::print | ( | ) |
void VirtualRobot::TriMeshModel::printFaces | ( | ) |
void VirtualRobot::TriMeshModel::printNormals | ( | ) |
void VirtualRobot::TriMeshModel::printVertices | ( | ) |
size_t VirtualRobot::TriMeshModel::removeUnusedVertices | ( | ) |
removeUnusedVertices Checks if vertices are used by faces. May rearrange vertices vector!
void VirtualRobot::TriMeshModel::rotate | ( | const Eigen::Matrix3f & | mx | ) |
|
virtual |
|
virtual |
void VirtualRobot::TriMeshModel::setColor | ( | VisualizationFactory::Color | color | ) |
void VirtualRobot::TriMeshModel::smoothNormalSurface | ( | ) |
Smoothes the normal surface by calculating the average of all face-normals of one vertex. Calls first mergeVertices().
BoundingBox VirtualRobot::TriMeshModel::boundingBox |
std::vector<VisualizationFactory::Color> VirtualRobot::TriMeshModel::colors |
std::vector<MathTools::TriangleFace> VirtualRobot::TriMeshModel::faces |
std::vector<VisualizationFactory::PhongMaterial> VirtualRobot::TriMeshModel::materials |
std::vector<Eigen::Vector3f> VirtualRobot::TriMeshModel::normals |
std::vector<Eigen::Vector3f> VirtualRobot::TriMeshModel::vertices |