Maya 1.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
MayaGeometry Class Reference

A simple triangle mesh representation. More...

#include <maya.h>

Inheritance diagram for MayaGeometry:
MayaGeometrySet MayaGeometryStack MayaSceneStack

Public Member Functions

 MayaGeometry ()
 Creates an empty mesh structure.
 
 MayaGeometry (const QString &, const MayaMaterial &=MayaMaterial::None)
 Creates an empty mesh structure. More...
 
 MayaGeometry (const QString &, const QVector< Vector > &, const QVector< Vector > &, const QVector< MayaIndexVertexData > &, const MayaMaterial &=MayaMaterial::None)
 Creates a mesh given an array of vertices and normals, and an array of integers defining the (possibly smooth) triangles of the mesh. More...
 
 MayaGeometry (const QString &, const QVector< Vector > &, const QVector< Vector > &, const QVector< Vector > &, const QVector< MayaIndexVertexData > &, const MayaMaterial &=MayaMaterial::None)
 Creates a mesh. More...
 
 MayaGeometry (const QString &, const QVector< Vector > &, const QVector< Vector > &, const QVector< Vector2 > &, const QVector< MayaIndexVertexData > &, const MayaMaterial &=MayaMaterial::None)
 Creates a mesh given an array of vertices, normals and colors, and an array of integers defining the (possibly smooth) triangles of the mesh. More...
 
 MayaGeometry (const QString &, const Mesh &, const MayaMaterial &=MayaMaterial::None)
 Creates an geometry from a mesh. More...
 
 MayaGeometry (const QString &, const MeshColor &, const MayaMaterial &=MayaMaterial::None)
 Creates an geometry from a mesh. More...
 
 MayaGeometry (const QString &, const Mesh2 &, const MayaMaterial &=MayaMaterial::None)
 Creates an geometry from a mesh. More...
 
 MayaGeometry (const QString &, const QVector< Triangle > &, const MayaMaterial &=MayaMaterial::None)
 Creates a geometry from a set of triangles. More...
 
 ~MayaGeometry ()
 Empty.
 
 MayaGeometry (const QString &, const Vector *, int, const Vector *, int, const int *, int, const MayaMaterial &=MayaMaterial::None)
 Create a mesh. More...
 
void AddTriangle (const Vector &, const Vector &, const Vector &)
 Adds a triangle to the mesh. More...
 
void AddSmoothTriangle (const Vector &, const Vector &, const Vector &, const Vector &, const Vector &, const Vector &)
 Adds a smooth triangle to the mesh. More...
 
void SetName (const QString &)
 Set the name. More...
 
void SetMaterial (const MayaMaterial &)
 Set the MayaMaterial. More...
 
void Merge (const MayaGeometry &)
 Merges an argument mesh with the existing mesh. More...
 
Triangle GetTriangle (int) const
 Get the i-th triangle from the mesh as a flat triangle. More...
 
QVector< TriangleGetTriangles () const
 Returns the geometry as a set of triangles.
 
QString GetName () const
 Get the name of the geometry.
 
MayaMaterial GetMaterial () const
 Get the material of the geometry.
 
Box GetBox () const
 Compute the bounding box of the object.
 
MayaGeometryTransform (const FrameScaled &)
 Transforms the geometry given a transformation operator. More...
 
MayaGeometryInverseTransform (const FrameScaled &)
 Inverse transforms the geometry given a transformation operator. More...
 
bool Load_OBJ (const QString &)
 Loads the geometry from a OBJ file into a single MayaGeometry. More...
 
bool find_MTL_Address (const QString &url, const QString &name, QString &nameR, QString &nameA)
 Loads the geometrys from an .obj file into a MayaGeometryAll. More...
 
bool Save_OBJ (const QString &) const
 Save the geometry as a Maya .obj file. More...
 
bool Save_OBJ_forVUE (const QString &url) const
 Save the geometry as a Maya .obj file. !!!! Y up for VUE. More...
 
bool Save_OBJ (QTextStream &, int=1, int=1, int=1) const
 Save the geometry as a Maya .obj file (QTextStream). More...
 
bool Save_PLY (const QString &) const
 Save the geometry as a Maya .obj file. More...
 
bool Save_PBRT (QTextStream &) const
 Save the geometry as a pbrt file (QTextStream). More...
 
MayaStatistics GetStatistics () const
 Compute the statistics of the object. More...
 
QString GetText (int=0, bool=false) const
 Get the text information. More...
 
const VectorGetVertex (int, int) const
 Get the k-th vertex of the i-th triangle. More...
 
const VectorGetVertex (int) const
 Get the i-th vertec in the array. More...
 
const VectorGetNormal (int, int) const
 Get the normal of the k-th vertexof the i-th triangle. More...
 
const VectorGetNormal (int) const
 Get the i-th normal in the array. More...
 
const VectorGetColor (int, int) const
 Get the color of the k-th vertex of the i-th triangle. More...
 
const VectorGetColor (int) const
 Get the i-th color in the array. More...
 
const Vector2GetUV (int, int) const
 Get the i-th UV in the array. More...
 
const Vector2GetUV (int) const
 Get the i-th UV in the array. More...
 
void Clear ()
 Clear every data and set a neutral grey material.
 
void generatePlannarZ_Mapping (Box2)
 Apply a planar mapping onto the object. More...
 
void generatePlannarMapping (const Vector &dir, const double &step)
 Apply a planar mapping onto the object using a given normal direction. More...
 

Static Public Member Functions

static MayaGeometryAll CreateVectorField (const VectorField &, const double &=1.0)
 Create a set of arrows representing a vector field. More...
 
static MayaGeometry extrusion8new (const QString &, QVector< Vector >, double, double, double)
  Warning Extrusion en pointillés
 
static MayaGeometry extrusion5new (const QString &, Vector, Vector, QVector< QVector< Vector > >, QVector< QVector< Vector > >)
  Warning Extrusion d'un ensemble de contours autour d'une position et en fonction d'une direction ou chaque contour a une normale.
 
static MayaGeometry extrusion4new (const QString &, Vector, Vector, QVector< QVector< Vector > >)
  Warning Extrusion d'un ensemble de contours autour d'une position et en fonction d'une direction.
 
static MayaGeometry extrusion3new (const QString &, QVector< Vector >, QVector< QVector< Vector > >, QVector< int >, QVector< double >)
  Warning Extrusion le long d'une courbe en utilisant différents profils. Le choix des profils est paramétré par des indices et des distances.
 
static MayaGeometry extrusion9new (const QString &, Vector, QVector< Vector >, double, double, double)
 extrusion circulaire
 

Public Attributes

QString name
 Signature of the object.
 
QVector< Vectorvertex
 Array of vertices.
 
QVector< Vectornormal
 Array of normals.
 
QVector< Vectorcolor
 Array of colors.
 
QVector< Vector2UVmap
 Array of UVs.
 
QVector< MayaIndexVertexData > indexes
 Array of integers referencing vertices, normals, colors and UV.
 
MayaMaterial mat
 Material of the object.
 

Protected Member Functions

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 AddQuadrangle (int, int, int, int, int)
 Add a quadrangle to the geometry. More...
 

Detailed Description

A simple triangle mesh representation.

This class has been designed for the manipulation of geometric instances.

Example of a MayaGeometry that stores a tetrahedron:

QVector<Vector> vertex;
QVector<Vector> normal;
QVector<int> index;
vertex.append(Vector(0,0,0));
vertex.append(Vector(1,0,0));
vertex.append(Vector(0,1,0));
vertex.append(Vector(0,0,1));
normal.append(Vector(-1,0,0));
normal.append(Vector(0,-1,0));
normal.append(Vector(0,0,-1));
normal.append(Normalized(Vector(1,1,1)));
// Set the indexes defining the oblique triangle
index.append(1); // Index of first vertex
index.append(3); // Oblique normal
index.append(2); // Second
index.append(3); // Same oblique normal
index.append(3); // Third
index.append(3); // Again the same normal
// and so on for the other triangles
MayaGeometry object("tetrahedron",vertex,normal,index);
A simple triangle mesh representation.
Definition: mayageometry.h:261
QVector< Vector > vertex
Array of vertices.
Definition: mayageometry.h:264
QVector< Vector > normal
Array of normals.
Definition: mayageometry.h:265

Note that in this case, the vertices and normals are uniquely defined and correctly shared. Another possibility is to create the tetrahedron by adding triangles directly to the MayaGeometry structure. In that case however, the object is a triangle soup: points (and normals) are replicated.

MayaGeometry object("tetrahedron");
object.AddTriangle(Vector(1,0,0),Vector(0,1,0),Vector(0,0,1)); // ... and so on for the other triangles

Constructor & Destructor Documentation

◆ MayaGeometry() [1/9]

MayaGeometry::MayaGeometry ( const QString &  name,
const MayaMaterial mo = MayaMaterial::None 
)

Creates an empty mesh structure.

Parameters
nameName of the object.
moMaterial.

◆ MayaGeometry() [2/9]

MayaGeometry::MayaGeometry ( const QString &  name,
const QVector< Vector > &  vertex,
const QVector< Vector > &  normal,
const QVector< MayaIndexVertexData > &  index,
const MayaMaterial mo = MayaMaterial::None 
)

Creates a mesh given an array of vertices and normals, and an array of integers defining the (possibly smooth) triangles of the mesh.

The array of integers stores the index of the vertices interlaced with the indexes of the normals.

Parameters
nameName of the object.
vertexArray of vertices.
normalArray of normals.
indexIndexes.
moMaterial.

References indexes, normal, and vertex.

◆ MayaGeometry() [3/9]

MayaGeometry::MayaGeometry ( const QString &  name,
const QVector< Vector > &  vertex,
const QVector< Vector > &  normal,
const QVector< Vector > &  color,
const QVector< MayaIndexVertexData > &  index,
const MayaMaterial mo = MayaMaterial::None 
)

Creates a mesh.

Parameters
nameName of the object.
vertexArray of vertices.
normalArray of normals.
colorArray of colors.
indexArray of integers defining the (possibly smooth) triangles of the mesh.
moMaterial.

References color, indexes, mat, normal, UVmap, and vertex.

◆ MayaGeometry() [4/9]

MayaGeometry::MayaGeometry ( const QString &  name,
const QVector< Vector > &  vertex,
const QVector< Vector > &  normal,
const QVector< Vector2 > &  UVmap,
const QVector< MayaIndexVertexData > &  index,
const MayaMaterial mo = MayaMaterial::None 
)

Creates a mesh given an array of vertices, normals and colors, and an array of integers defining the (possibly smooth) triangles of the mesh.

Parameters
nameName of the object.
vertexArray of vertices.
normalArray of normals.
UVmapArray of UVmaps.
indexIndexes.
moMaterial.

References indexes, mat, normal, UVmap, and vertex.

◆ MayaGeometry() [5/9]

MayaGeometry::MayaGeometry ( const QString &  name,
const Mesh mesh,
const MayaMaterial mo = MayaMaterial::None 
)

Creates an geometry from a mesh.

Parameters
nameName of the object.
meshThe mesh.
moMaterial.

References Mesh::GetNormals(), Mesh::GetVertices(), indexes, normal, Mesh::NormalIndex(), Mesh::Triangles(), vertex, and Mesh::VertexIndex().

◆ MayaGeometry() [6/9]

MayaGeometry::MayaGeometry ( const QString &  name,
const MeshColor mesh,
const MayaMaterial mo = MayaMaterial::None 
)

Creates an geometry from a mesh.

Parameters
nameName of the object.
meshThe mesh.
moMaterial.

References color, MeshColor::ColorIndex(), MeshColor::GetColor(), MeshColor::GetColors(), Mesh::GetNormals(), Mesh::GetVertices(), indexes, normal, Mesh::NormalIndex(), Mesh::Triangles(), vertex, and Mesh::VertexIndex().

◆ MayaGeometry() [7/9]

MayaGeometry::MayaGeometry ( const QString &  name,
const Mesh2 mesh,
const MayaMaterial mo = MayaMaterial::None 
)

Creates an geometry from a mesh.

Parameters
nameName of the object.
meshThe mesh.
moMaterial.

References Mesh2::index(), indexes, normal, Vector2::ToVector(), Mesh2::TriangleSize(), Mesh2::Vertex(), vertex, Mesh2::VertexSize(), and Vector::Z.

◆ MayaGeometry() [8/9]

MayaGeometry::MayaGeometry ( const QString &  name,
const QVector< Triangle > &  tris,
const MayaMaterial mo = MayaMaterial::None 
)

Creates a geometry from a set of triangles.

Parameters
nameName of the object.
tristhe triangles.
moMaterial.

References AddTriangle().

◆ MayaGeometry() [9/9]

MayaGeometry::MayaGeometry ( const QString &  name,
const Vector vertex,
int  nv,
const Vector normal,
int  nn,
const int *  index,
int  ni,
const MayaMaterial mo = MayaMaterial::None 
)

Create a mesh.

This function is the same as the constructor with QVector parameters, but uses C++ arrays instead.

Parameters
nameName of the object.
vertexArray of vertices.
nvNumber of vertices.
normalArray of normals.
nnNumber of normals.
indexIndexes defining the (possibly smooth) triangles of the mesh.
niNumber of indexes.
moMaterial.

References indexes, normal, and vertex.

Member Function Documentation

◆ AddQuadrangle()

void MayaGeometry::AddQuadrangle ( int  a,
int  b,
int  c,
int  d,
int  n 
)
protected

Add a quadrangle to the geometry.

It creates two triangles abc and acd.

Parameters
a,b,c,dIndex of the vertices.
nIndex of the normal shared by all vertices.

References AddTriangle().

◆ AddSmoothTriangle() [1/2]

void MayaGeometry::AddSmoothTriangle ( const Vector a,
const Vector b,
const Vector c,
const Vector na,
const Vector nb,
const Vector nc 
)

Adds a smooth triangle to the mesh.

Parameters
a,b,cVertices
na,nb,ncNormals

References AddSmoothTriangle(), normal, and vertex.

Referenced by AddSmoothTriangle().

◆ AddSmoothTriangle() [2/2]

void MayaGeometry::AddSmoothTriangle ( int  a,
int  na,
int  b,
int  nb,
int  c,
int  nc 
)
protected

Add a smooth triangle to the geometry.

Parameters
a,b,cIndex of the vertices.
na,nb,ncIndex of the normals.

References indexes.

◆ AddTriangle() [1/2]

void MayaGeometry::AddTriangle ( const Vector a,
const Vector b,
const Vector c 
)

Adds a triangle to the mesh.

Parameters
a,b,cVertices.

References AddTriangle(), normal, and vertex.

Referenced by AddQuadrangle(), MayaGeometryStack::AddTriangle(), AddTriangle(), MayaGeometryStack::AddTriangleOffset(), and MayaGeometry().

◆ AddTriangle() [2/2]

void MayaGeometry::AddTriangle ( int  a,
int  b,
int  c,
int  n 
)
protected

Add a triangle to the geometry.

Parameters
a,b,cIndex of the vertices.
nIndex of the normal shared by all vertices.

References indexes.

◆ CreateVectorField()

MayaGeometryAll MayaGeometry::CreateVectorField ( const VectorField field,
const double &  scale = 1.0 
)
static

Create a set of arrows representing a vector field.

Parameters
fieldVector field.
scaleScaling factor.

References MayaGeometrySet::Append(), Mesh::Arrow(), Array::GetSizeX(), Array::GetSizeY(), Array::GetSizeZ(), MayaGeometry(), Vector::Null, Matrix::RotationCanonical(), VectorField::Value(), Array::Vertex(), and Vector::Z.

◆ find_MTL_Address()

bool MayaGeometry::find_MTL_Address ( const QString &  url,
const QString &  name,
QString &  nameR,
QString &  nameA 
)

Loads the geometrys from an .obj file into a MayaGeometryAll.

Parameters
urlFile name (which should contain the extension .obj).
nameName of the current material.
nameRTexture name of the diffuse map.
Returns
A boolean checking if loading has been successful.

References name.

Referenced by Load_OBJ().

◆ generatePlannarMapping()

void MayaGeometry::generatePlannarMapping ( const Vector dir,
const double &  step 
)

Apply a planar mapping onto the object using a given normal direction.

Delete old UVmaps.

Parameters
dirNormal direction.
stepSize in spatial coordinates of the tiling texture

References GetBox(), indexes, Vector::Orthonormal(), UVmap, and vertex.

◆ generatePlannarZ_Mapping()

void MayaGeometry::generatePlannarZ_Mapping ( Box2  box)

Apply a planar mapping onto the object.

Delete ancient UVmaps.

Parameters
boxDomain.

References indexes, Box2::Size(), UVmap, and vertex.

◆ GetColor() [1/2]

const Vector & MayaGeometry::GetColor ( int  i) const
inline

Get the i-th color in the array.

Parameters
iIndex.

References color.

◆ GetColor() [2/2]

const Vector & MayaGeometry::GetColor ( int  i,
int  k 
) const
inline

Get the color of the k-th vertex of the i-th triangle.

Parameters
iTriangle number.
kVertex.

References color, and indexes.

Referenced by MayaGpu::CreateGpu().

◆ GetNormal() [1/2]

const Vector & MayaGeometry::GetNormal ( int  i) const
inline

Get the i-th normal in the array.

Parameters
iIndex.

References normal.

◆ GetNormal() [2/2]

const Vector & MayaGeometry::GetNormal ( int  i,
int  k 
) const
inline

Get the normal of the k-th vertexof the i-th triangle.

Parameters
iTriangle number.
kVertex.

References indexes, and normal.

Referenced by MayaGpu::CreateGpu().

◆ GetStatistics()

MayaStatistics MayaGeometry::GetStatistics ( ) const

Compute the statistics of the object.

This member computes the number of vertices and triangles of the object. Since vertices may not be shared, those numbers may be larger than the real number of vertices of the geometric object.

Returns
The statistics.

References indexes, and vertex.

Referenced by MayaGpu::MayaGpu().

◆ GetText()

QString MayaGeometry::GetText ( int  spaces = 0,
bool  html = false 
) const

Get the text information.

Parameters
spacesSpacing for indenting the text.
htmlFlag to specify syntax highlighting.

References GetName().

Referenced by MayaSceneStack::GetText().

◆ GetTriangle()

Triangle MayaGeometry::GetTriangle ( int  i) const

Get the i-th triangle from the mesh as a flat triangle.

Note that the normals at the vertices of the triangle in the mesh structure is not taken into account.

Parameters
iIndex.

References indexes, and vertex.

◆ GetUV() [1/2]

const Vector2 & MayaGeometry::GetUV ( int  i) const
inline

Get the i-th UV in the array.

Parameters
iIndex.

References UVmap.

◆ GetUV() [2/2]

const Vector2 & MayaGeometry::GetUV ( int  i,
int  k 
) const
inline

Get the i-th UV in the array.

Parameters
i,kIndexes.

References indexes, and UVmap.

Referenced by MayaGpu::CreateGpu().

◆ GetVertex() [1/2]

const Vector & MayaGeometry::GetVertex ( int  i) const
inline

Get the i-th vertec in the array.

Parameters
iIndex.

References vertex.

◆ GetVertex() [2/2]

const Vector & MayaGeometry::GetVertex ( int  i,
int  k 
) const
inline

Get the k-th vertex of the i-th triangle.

Parameters
iTriangle number.
kVertex.

References indexes, and vertex.

Referenced by MayaGpu::CreateGpu().

◆ InverseTransform()

MayaGeometry & MayaGeometry::InverseTransform ( const FrameScaled frame)

Inverse transforms the geometry given a transformation operator.

Parameters
frameTransformation.

References FrameScaled::InverseTransform(), FrameScaled::InverseTransformDirection(), normal, and vertex.

◆ Load_OBJ()

bool MayaGeometry::Load_OBJ ( const QString &  url)

Loads the geometry from a OBJ file into a single MayaGeometry.

Parameters
urlFilename, which should contain the extension .obj.

References color, find_MTL_Address(), indexes, name, normal, SetName(), UVmap, and vertex.

◆ Merge()

void MayaGeometry::Merge ( const MayaGeometry mesh)

Merges an argument mesh with the existing mesh.

Note that this function may be slow as it may require a time consuming copy of several arrays.

Parameters
meshGeometry that will be merged.

References color, indexes, normal, UVmap, and vertex.

Referenced by MayaGeometryStack::AddQuadrangle(), MayaGeometrySet::Collapse(), MayaGeometryAll::Collapse(), and MayaGeometryAll::GetGeometryByName().

◆ Save_OBJ() [1/2]

bool MayaGeometry::Save_OBJ ( const QString &  url) const

Save the geometry as a Maya .obj file.

Parameters
urlFilename.
Returns
A boolean indicating whether the file has been successfully created or not.

References indexes, mat, name, normal, UVmap, and vertex.

Referenced by MayaGeometryAll::Save_OBJ(), and MayaGeometryAll::Save_OBJ_Collapse().

◆ Save_OBJ() [2/2]

bool MayaGeometry::Save_OBJ ( QTextStream &  out,
int  decV = 1,
int  decN = 1,
int  decUV = 1 
) const

Save the geometry as a Maya .obj file (QTextStream).

Parameters
outQTextStream.
decV,decN,decUVOffsets for referencing indexes.
Returns
A boolean indicating whether the file has been successfully created or not.

References indexes, name, normal, UVmap, and vertex.

◆ Save_OBJ_forVUE()

bool MayaGeometry::Save_OBJ_forVUE ( const QString &  url) const

Save the geometry as a Maya .obj file. !!!! Y up for VUE.

Parameters
urlFilename.
Returns
A boolean indicating whether the file has been successfully created or not.

References indexes, name, normal, UVmap, and vertex.

◆ Save_PBRT()

bool MayaGeometry::Save_PBRT ( QTextStream &  out) const

Save the geometry as a pbrt file (QTextStream).

Parameters
outQTextStream.
Returns
A boolean indicating whether the file has been successfully created or not.

References indexes, and vertex.

Referenced by MayaGeometryAll::Save_PBRT().

◆ Save_PLY()

bool MayaGeometry::Save_PLY ( const QString &  name) const

Save the geometry as a Maya .obj file.

Parameters
nameFilename.
Returns
A boolean indicating whether the file has been successfully created or not.

References indexes, name, normal, and vertex.

◆ SetMaterial()

void MayaGeometry::SetMaterial ( const MayaMaterial mo)
inline

Set the MayaMaterial.

Parameters
moMayaMaterial.

References mat.

Referenced by MayaGeometrySet::Collapse().

◆ SetName()

void MayaGeometry::SetName ( const QString &  n)
inline

◆ Transform()

MayaGeometry & MayaGeometry::Transform ( const FrameScaled frame)

Transforms the geometry given a transformation operator.

Parameters
frameTransformation.

References normal, FrameScaled::Transform(), FrameScaled::TransformDirection(), and vertex.

Referenced by MayaGeometrySet::Collapse().