Developer Documentation
OBJImporter Class Reference

Public Types

enum  ObjectOptionsE {
  NONE = 0, TRIMESH = 1, POLYMESH = 1 << 1, CURVE = 1 << 2,
  SURFACE = 1 << 3, NORMALS = 1 << 4, TEXCOORDS = 1 << 5, FACECOLOR = 1 << 6,
  TEXTURE = 1 << 7, FORCE_NOCOLOR = 1 << 8, FORCE_NONORMALS = 1 << 9, FORCE_NOTEXTURES = 1 << 10
}
 
typedef unsigned int ObjectOptions
 

Public Member Functions

 OBJImporter ()
 Constructor.
 
 ~OBJImporter ()
 base class needs virtual destructor
 
VertexHandle addVertex (const Vec3f &_point)
 add a vertex with coordinate _point
 
Vec3f vertex (unsigned int _index)
 get vertex with given index
 
int addTexCoord (const Vec2f &_coord)
 add texture coordinates
 
int addNormal (const Vec3f &_normal)
 add a normal
 
void setDegreeU (int _degree)
 set degree More...
 
void setDegreeV (int _degree)
 set degree V direction
 
int degreeU ()
 get current degree
 
int degreeV ()
 get current degree
 
void setObject (BaseObject *_object, int _groupId)
 add an object More...
 
int currentGroup ()
 Get the id of the current group. More...
 
PolyMeshcurrentPolyMesh ()
 get a pointer to the active polyMesh More...
 
TriMeshcurrentTriMesh ()
 get a pointer to the active triMesh More...
 
void addUsedVertices (int _groupId)
 add all vertices that are used to the mesh (in correct order)
 
void setVertexTexCoord (VertexHandle _vh, int _texCoordID)
 set vertex texture coordinate
 
void setNormal (int _index, int _normalID)
 set vertex normal
 
void addFace (const VHandles &_indices)
 add a face with indices _indices refering to vertices
 
void addFace (const VHandles &_indices, const std::vector< int > &_face_texcoords)
 add face and texture coordinates
 
void forceMeshType (ObjectOptions _meshType)
 force all meshes to be opened with specific type
 
bool hasNormals (int _objectID)
 Query Object Options.
 
bool hasTexture (int _objectID)
 
bool hasTextureCoords (int _objectID)
 
bool isTriangleMesh (int _objectID)
 
bool isPolyMesh (int _objectID)
 
bool isCurve (int _objectID)
 
bool isSurface (int _objectID)
 
bool isNone (int _objectID)
 
void setOption (ObjectOptionsE _option)
 Set Object Option.
 
void setOption (ObjectOptionsE _option, int _groupId)
 Set Object Option.
 
unsigned int n_vertices ()
 Global Properties.
 
unsigned int n_normals ()
 
unsigned int n_texCoords ()
 
unsigned int groupCount ()
 Number of groups currently stored in the importer. More...
 
BaseObjectobject (int _groupId)
 return object for the given group
 
MaterialList & materials ()
 return all loaded materials
 
void addMaterial (std::string _materialName)
 Add a material.
 
const std::vector< std::string > usedMaterials (unsigned int _objectID)
 used materials
 
void useMaterial (std::string _materialName)
 
void useVertex (int _vertex_index)
 used vertices
 
QString path ()
 Path of the OBJ file.
 
void setPath (QString _path)
 
void setObjectOptions (ObjectOptions _options)
 
bool noOptions ()
 Return true if the importer has no options stored.
 
bool hasOption (unsigned int _id, ObjectOptions _option)
 check if object with given id has given option
 
void setObjectName (int _objectID, QString _name)
 change the name of an object
 
int addGroup (const QString &_groupName)
 
int groupId (const QString &_groupName) const
 
unsigned int numGroups () const
 
const QString groupName (const int _grpId) const
 
void setGroupName (const int _grp, const QString &_name)
 
void setCurrentGroup (const int _current)
 
int currentGroup () const
 
void finish ()
 

Private Member Functions

bool addFace (const VHandles &_indices, OpenMesh::FaceHandle &_outFH, std::vector< TriMesh::VertexHandle > &_outTriVertices, std::vector< PolyMesh::VertexHandle > &_outPolyVertices)
 
bool vertexListIsManifold (const std::vector< PolyMesh::VertexHandle > &_vertices) const
 

Private Attributes

std::vector< Vec3fvertices_
 
std::vector< Vec3fnormals_
 
std::vector< Vec2ftexCoords_
 
std::map< TriMesh::VertexHandle, TriMesh::Normal > storedTriHENormals_
 
std::map< TriMesh::VertexHandle, PolyMesh::NormalstoredPolyHENormals_
 
int degreeU_
 
int degreeV_
 
MaterialList materials_
 
QString path_
 
std::vector< QString > groupNames_
 
int currentGroup_
 
std::vector< std::map< int, PolyMesh::VertexHandle > > vertexMapPoly_
 
PolyMesh::FaceHandle addedFacePoly_
 
std::vector< std::map< int, TriMesh::VertexHandle > > vertexMapTri_
 
std::vector< std::vector< TriMesh::FaceHandle > > addedFacesTri_
 
std::vector< TriMeshObject * > triMeshes_
 
std::vector< PolyMeshObject * > polyMeshes_
 
std::vector< ObjectOptions > objectOptions_
 
std::vector< std::vector< std::string > > usedMaterials_
 
std::vector< std::map< int, VertexHandle > > usedVertices_
 
std::vector< std::vector< OMVHandles > > invalidFaces_
 

Detailed Description

Definition at line 83 of file OBJImporter.hh.

Member Function Documentation

◆ currentGroup()

int OBJImporter::currentGroup ( )

Get the id of the current group.

get id of the active object

OBJ files can contain groups which are handled inside OpenFlipper as separate Objects. When loading a file, the importer has to keep track of the current group and store a state for each group with its properties (materials) )

Returns
Id of the current group

Definition at line 159 of file OBJImporter.cc.

◆ currentPolyMesh()

PolyMesh * OBJImporter::currentPolyMesh ( )

get a pointer to the active polyMesh

get the active polyMesh

Definition at line 167 of file OBJImporter.cc.

◆ currentTriMesh()

TriMesh * OBJImporter::currentTriMesh ( )

get a pointer to the active triMesh

get the active triMesh

Definition at line 175 of file OBJImporter.cc.

◆ finish()

void OBJImporter::finish ( )

Finish up importing: Duplicate vertices of non-manifold faces and add new face as isolated one

Definition at line 1013 of file OBJImporter.cc.

◆ groupCount()

unsigned int OBJImporter::groupCount ( )

Number of groups currently stored in the importer.

As OBJ files can contain several groups, we need to store information per group.

Returns
Number of groups currently found by the importer

Definition at line 863 of file OBJImporter.cc.

◆ setDegreeU()

void OBJImporter::setDegreeU ( int  _degree)

set degree

set degree U direction

Definition at line 93 of file OBJImporter.cc.

◆ setObject()

void OBJImporter::setObject ( BaseObject _object,
int  _groupId 
)

add an object

add a mesh

Definition at line 122 of file OBJImporter.cc.

◆ setObjectOptions()

void OBJImporter::setObjectOptions ( ObjectOptions  _options)

store an initial options object for an object containing info about the meshType

Definition at line 906 of file OBJImporter.cc.


The documentation for this class was generated from the following files: