Core 1.0
Public Member Functions | Protected Attributes | List of all members
MeshColor Class Reference

Core triangle mesh class with color support. More...

#include <meshcolor.h>

Inheritance diagram for MeshColor:
Mesh

Public Member Functions

 MeshColor ()
 Create an empty mesh.
 
 MeshColor (const Mesh &)
 Constructor from a Mesh. More...
 
 MeshColor (const Mesh &, const QVector< Color > &, const QVector< int > &)
 Constructor from a Mesh with color array and indices. More...
 
 ~MeshColor ()
 Empty.
 
Color GetColor (int) const
 Get a color. More...
 
void SetColor (int, const Color &)
 Set the color of a vertex. More...
 
void Merge (const MeshColor &)
 Merge two meshes into a single one. More...
 
int ColorIndex (int, int) const
 Get the color index of a given triangle. More...
 
QVector< ColorGetColors () const
 Get the array of colors.
 
QVector< int > ColorIndexes () const
 Return the set of color indices.
 
- Public Member Functions inherited from Mesh
 Mesh ()
 Initialize the mesh to empty.
 
 Mesh (const Mesh2 &)
 Initialize the structure from a two dimensional mesh. More...
 
 Mesh (const QVector< Vector > &)
 Create a mesh from a set of vertices. More...
 
 Mesh (const QVector< Vector > &, const QVector< int > &, bool=true)
 Create a mesh from a set of vertices and a set of triangle indexes. More...
 
 Mesh (const QVector< Vector > &, const QVector< Vector > &, const QVector< int > &, const QVector< int > &)
 Create the mesh. More...
 
 ~Mesh ()
 Empty.
 
void Reserve (int, int, int, int)
 Reserve memory for arrays. More...
 
Triangle GetTriangle (int) const
 Get a triangle. More...
 
const Vector Vertex (int) const
 Get a vertex. More...
 
VectorVertex (int)
 Acces to a vertex. More...
 
Vector Vertex (int, int) const
 Get a vertex from a specific triangle. More...
 
Vector Normal (int) const
 Get a normal. More...
 
int Triangles () const
 Get the number of triangles.
 
int Vertexes () const
 Get the number of vertices in the geometry. More...
 
bool Manifold () const
 Check if a mesh is manifold.
 
void Append (const Mesh &)
 Merge two meshes into a single one. More...
 
QVector< VectorGetVertices () const
 Get the array of vertices.
 
QVector< VectorGetNormals () const
 Get the array of normals.
 
QVector< int > VertexIndexes () const
 Return the set of vertex indexes.
 
QVector< int > NormalIndexes () const
 Return the set of normal indexes.
 
QVector< TriangleGetTriangles () const
 Returns the geometry as a set of triangles.
 
int VertexIndex (int, int) const
 Get the vertex index of a given triangle. More...
 
int NormalIndex (int, int) const
 Get the normal index of a given triangle. More...
 
Vector operator[] (int) const
 Get a vertex. More...
 
double R (const Vector &) const
 Compute the squared distance to the mesh. More...
 
double Signed (const Vector &) const
 Compute the signed distance to the mesh. More...
 
bool Intersect (const Ray &, double &, int &) const
 Compute the intersection between a ray and the mesh. More...
 
int Intersections (const Ray &) const
 Compute the number of intersections between a ray and the mesh. More...
 
bool Inside (const Vector &) const
 Check if a point is inside or outside of the object. More...
 
Box GetBox () const
 Compute the bounding box of the object.
 
Sphere GetSphere () const
 Compute the bounding sphere of the object.
 
double AverageEdgeLength () const
 Compute the average edge length.
 
void EdgeLengthRange (double &, double &) const
 Compute the range of edge lengths. More...
 
QVector< int > AspectRatios (int=4) const
 Compute the histogram of the aspect ratio of the triangles of the mesh. More...
 
void EdgeCollapse (const double &)
 Run a simple edge collapse algorithm over a triangle mesh. More...
 
void Transform (const FrameScaled &)
 Transforms the mesh given a transformation. More...
 
Mesh Transformed (const FrameScaled &) const
 Transforms the mesh given a transformation. More...
 
void InverseTransform (const FrameScaled &)
 Inverse transform. More...
 
void Symmetry (const Plane &)
 Apply a planar symmetry to the object. More...
 
void Rotate (const Matrix &)
 Rotate the mesh. More...
 
void Translate (const Vector &)
 Translate the mesh. More...
 
void Scale (const Vector &)
 Scale the mesh. More...
 
void Scale (const double &)
 Scale the mesh. More...
 
void SmoothNormals ()
 Smooth the normals of the mesh. More...
 
int IsSmooth (int) const
 Check if the ith triangle in the mesh is a flat or smooth triangle. More...
 
 Mesh (const Capsule &, int, int=2)
 Creates a capsule. More...
 
 Mesh (const Quadrangle &, int, int)
 Generate a grid geometry over an input quadrangle. More...
 
 Mesh (const Quadrangle &)
 Generate a quadrangle. More...
 
 Mesh (const Octahedron &)
 Creates the mesh of an octaedron. More...
 
 Mesh (const Box &)
 Creates an axis aligned box. More...
 
 Mesh (const Triangle &)
 Creates a triangle. More...
 
 Mesh (const Sphere &, int)
 Creates a sphere, using polar coordinates. More...
 
 Mesh (const SphereSet &, int)
 Creates a set of spheres. More...
 
 Mesh (const Cylinder &, int, bool=true, bool=true)
 Creates a cylinder. More...
 
 Mesh (const Disc &, int)
 Creates a disc. More...
 
 Mesh (const Dodecahedron &)
 This function creates the mesh of a dodecahedron. More...
 
 Mesh (const Icosahedron &)
 Create the mesh of an icosahedron. More...
 
 Mesh (const QVector< Vector > &, const QVector< Vector > &, const Vector &, const Vector &)
 Create a generalized cylinder with star-shaped contours. More...
 
 Mesh (const Torus &, int, int, int=-1, int=-1)
 Create the mesh of an torus. More...
 
 Mesh (const Cuboctahedron &)
 Create the mesh of a cuboctahedron. More...
 
 Mesh (const Icosidodecahedron &)
 Create the mesh of an icosidodecahedron. More...
 
 Mesh (const Hexagonal &)
 Create the mesh of a hexagonal prism. More...
 
 Mesh (const Cone &, int)
 Creates the mesh of a cone. More...
 
 Mesh (const Rectangles &, int, int)
 Generate a grid geometry over an input rectangle. More...
 
 Mesh (const Cuboid &)
 Creates the mesh of a cuboid. More...
 
 Mesh (const QuadricSurface &, const Box2 &, int, int)
 Generate a grid geometry and polygonize the quadric surface. More...
 
 Mesh (const QuadricCurve &, const double &, int, int)
 Create a swept-sphere along a quadric curve. More...
 
 Mesh (const CubicCurveSet &, const double &, int, int)
 Create a swept-sphere along a cubic curve. More...
 
 Mesh (const QuadricCurveSet &, const double &, int, int=2)
 Create a swept-sphere along a set of quadric curves. More...
 
Mesh ShrinkedTriangles (const double &) const
 Scales (shrinks) all the triangles of the model. More...
 
void Load (const QString &)
 Import a mesh from an .obj file. More...
 
void SaveObj (const QString &, const QString &=QString("mesh")) const
 Save the mesh in .obj format, with vertices and normals. More...
 

Protected Attributes

QVector< Colorcolors
 Array of colors.
 
QVector< int > carray
 Indexes.
 
- Protected Attributes inherited from Mesh
QVector< Vectorvertices
 Vertices.
 
QVector< Vectornormals
 Normals.
 
QVector< int > varray
 Vertex indexes.
 
QVector< int > narray
 Normal indexes.
 

Additional Inherited Members

- Static Public Member Functions inherited from Mesh
static Mesh Hull (const QVector< Vector > &)
 Compute the convex hull. More...
 
static Mesh Extrusion (const PointCurve &, const PointCurve2 &)
 Extrude a contour along a point curve. More...
 
static Mesh Extrusion (const PointCurve &, const QVector< PointCurve2 > &)
 Extrude a set of contour along a point curve. More...
 
static Mesh Arrow (const Vector &, const Vector &, const double &, const double &, const double &, int)
 Creates an arrow. The object has 3n+2 vertices, 2n+2 normals and 6n triangles. More...
 
- Protected Member Functions inherited from Mesh
void AddTriangle (int, int, int, int)
 Add a triangle to the geometry. More...
 
void AddSmoothTriangle (int, int, int, int, int, int)
 Add a smooth triangle to the geometry. More...
 
void AddSmoothQuadrangle (int, int, int, int, int, int, int, int)
 Add a smmoth quadrangle to the geometry. More...
 
void AddQuadrangle (int, int, int, int)
 Add a quadrangle to the geometry. More...
 
void AddQuadrangle (int, int, int, int, int)
 Add a quadrangle to the geometry. More...
 
void AddPentagon (int, int, int, int, int, int)
 Add a pentagon to the geometry. More...
 
int NextIndex (int) const
 Compute the next index of an edge in a triangle. More...
 
int PrevIndex (int) const
 Compute the previous index of an edge in a triangle. More...
 
int BaseIndex (int) const
 Compute the base index of a triangle given an edge index. More...
 

Detailed Description

Core triangle mesh class with color support.

Constructor & Destructor Documentation

◆ MeshColor() [1/2]

MeshColor::MeshColor ( const Mesh m)
explicit

Constructor from a Mesh.

Parameters
mthe base mesh

◆ MeshColor() [2/2]

MeshColor::MeshColor ( const Mesh m,
const QVector< Color > &  cols,
const QVector< int > &  carr 
)
explicit

Constructor from a Mesh with color array and indices.

Parameters
mBase mesh.
colsColor array.
carrColor indexes, should be the same size as Mesh::varray and Mesh::narray.

Member Function Documentation

◆ ColorIndex()

int MeshColor::ColorIndex ( int  t,
int  i 
) const
inline

Get the color index of a given triangle.

Parameters
tTriangle index.
iNormal index.

◆ GetColor()

Color MeshColor::GetColor ( int  i) const
inline

Get a color.

Parameters
iThe index of the desired color.
Returns
The color.

◆ Merge()

void MeshColor::Merge ( const MeshColor mesh)

Merge two meshes into a single one.

Parameters
meshArgument mesh.

◆ SetColor()

void MeshColor::SetColor ( int  i,
const Color c 
)
inline

Set the color of a vertex.

Parameters
iThe index of the desired color.
cThe color.