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. More...
 
 ~OBJImporter ()
 base class needs virtual destructor More...
 
VertexHandle addVertex (const Vec3d &_point)
 add a vertex with coordinate _point More...
 
Vec3d vertex (unsigned int _index)
 get vertex with given index More...
 
int addTexCoord (const Vec2f &_coord)
 add texture coordinates More...
 
int addNormal (const Vec3d &_normal)
 add a normal More...
 
void setDegreeU (int _degree)
 set degree More...
 
void setDegreeV (int _degree)
 set degree V direction More...
 
int degreeU ()
 get current degree More...
 
int degreeV ()
 get current degree More...
 
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) More...
 
void setVertexTexCoord (VertexHandle _vh, int _texCoordID)
 set vertex texture coordinate More...
 
void setNormal (int _index, int _normalID)
 set vertex normal More...
 
void addFace (const VHandles &_indices)
 add a face with indices _indices refering to vertices More...
 
void addFace (const VHandles &_indices, const std::vector< int > &_face_texcoords)
 add face and texture coordinates More...
 
void forceMeshType (ObjectOptions _meshType)
 force all meshes to be opened with specific type More...
 
bool hasNormals (int _objectID)
 Query Object Options. More...
 
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. More...
 
void setOption (ObjectOptionsE _option, int _groupId)
 Set Object Option. More...
 
unsigned int n_vertices ()
 Global Properties. More...
 
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 More...
 
MaterialList & materials ()
 return all loaded materials More...
 
void addMaterial (std::string _materialName)
 Add a material. More...
 
const std::vector< std::string > usedMaterials (unsigned int _objectID)
 used materials More...
 
void useMaterial (std::string _materialName)
 
void useVertex (int _vertex_index)
 used vertices More...
 
QString path ()
 Path of the OBJ file. More...
 
void setPath (QString _path)
 
void setObjectOptions (ObjectOptions _options)
 
bool noOptions ()
 Return true if the importer has no options stored. More...
 
bool hasOption (unsigned int _id, ObjectOptions _option)
 check if object with given id has given option More...
 
void setObjectName (int _objectID, QString _name)
 change the name of an object More...
 
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< Vec3dvertices_
 
std::vector< Vec3dnormals_
 
std::vector< Vec2ftexCoords_
 
std::map< TriMesh::VertexHandle, TriMesh::NormalstoredTriHENormals_
 
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 85 of file OBJImporter.hh.

Member Typedef Documentation

◆ ObjectOptions

typedef unsigned int OBJImporter::ObjectOptions

Definition at line 105 of file OBJImporter.hh.

Member Enumeration Documentation

◆ ObjectOptionsE

enum OBJImporter::ObjectOptionsE

Definition at line 89 of file OBJImporter.hh.

Constructor & Destructor Documentation

◆ OBJImporter()

OBJImporter::OBJImporter ( )
inline

Constructor.

Definition at line 108 of file OBJImporter.hh.

◆ ~OBJImporter()

OBJImporter::~OBJImporter ( )

base class needs virtual destructor

Definition at line 50 of file OBJImporter.cc.

Member Function Documentation

◆ addFace() [1/3]

void OBJImporter::addFace ( const VHandles &  _indices)

add a face with indices _indices refering to vertices

Definition at line 464 of file OBJImporter.cc.

◆ addFace() [2/3]

void OBJImporter::addFace ( const VHandles &  _indices,
const std::vector< int > &  _face_texcoords 
)

add face and texture coordinates

Definition at line 487 of file OBJImporter.cc.

◆ addFace() [3/3]

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

Definition at line 354 of file OBJImporter.cc.

◆ addGroup()

int OBJImporter::addGroup ( const QString &  _groupName)

Definition at line 939 of file OBJImporter.cc.

◆ addMaterial()

void OBJImporter::addMaterial ( std::string  _materialName)

Add a material.

Definition at line 561 of file OBJImporter.cc.

◆ addNormal()

int OBJImporter::addNormal ( const Vec3d _normal)

add a normal

Definition at line 84 of file OBJImporter.cc.

◆ addTexCoord()

int OBJImporter::addTexCoord ( const Vec2f _coord)

add texture coordinates

Definition at line 75 of file OBJImporter.cc.

◆ addUsedVertices()

void OBJImporter::addUsedVertices ( int  _groupId)

add all vertices that are used to the mesh (in correct order)

Definition at line 205 of file OBJImporter.cc.

◆ addVertex()

VertexHandle OBJImporter::addVertex ( const Vec3d _point)

add a vertex with coordinate _point

Definition at line 57 of file OBJImporter.cc.

◆ currentGroup() [1/2]

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.

◆ currentGroup() [2/2]

int OBJImporter::currentGroup ( ) const

Definition at line 1001 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.

◆ degreeU()

int OBJImporter::degreeU ( )

get current degree

Definition at line 108 of file OBJImporter.cc.

◆ degreeV()

int OBJImporter::degreeV ( )

get current degree

Definition at line 115 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 1008 of file OBJImporter.cc.

◆ forceMeshType()

void OBJImporter::forceMeshType ( ObjectOptions  _meshType)

force all meshes to be opened with specific type

Definition at line 759 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 858 of file OBJImporter.cc.

◆ groupId()

int OBJImporter::groupId ( const QString &  _groupName) const

Definition at line 965 of file OBJImporter.cc.

◆ groupName()

const QString OBJImporter::groupName ( const int  _grpId) const

Definition at line 975 of file OBJImporter.cc.

◆ hasNormals()

bool OBJImporter::hasNormals ( int  _objectID)

Query Object Options.

Definition at line 809 of file OBJImporter.cc.

◆ hasOption()

bool OBJImporter::hasOption ( unsigned int  _id,
ObjectOptions  _option 
)

check if object with given id has given option

Definition at line 919 of file OBJImporter.cc.

◆ hasTexture()

bool OBJImporter::hasTexture ( int  _objectID)

Definition at line 816 of file OBJImporter.cc.

◆ hasTextureCoords()

bool OBJImporter::hasTextureCoords ( int  _objectID)

Definition at line 823 of file OBJImporter.cc.

◆ isCurve()

bool OBJImporter::isCurve ( int  _objectID)

Definition at line 793 of file OBJImporter.cc.

◆ isNone()

bool OBJImporter::isNone ( int  _objectID)

Definition at line 803 of file OBJImporter.cc.

◆ isPolyMesh()

bool OBJImporter::isPolyMesh ( int  _objectID)

Definition at line 787 of file OBJImporter.cc.

◆ isSurface()

bool OBJImporter::isSurface ( int  _objectID)

Definition at line 799 of file OBJImporter.cc.

◆ isTriangleMesh()

bool OBJImporter::isTriangleMesh ( int  _objectID)

Definition at line 781 of file OBJImporter.cc.

◆ materials()

MaterialList & OBJImporter::materials ( )

return all loaded materials

Definition at line 883 of file OBJImporter.cc.

◆ n_normals()

unsigned int OBJImporter::n_normals ( )

Definition at line 846 of file OBJImporter.cc.

◆ n_texCoords()

unsigned int OBJImporter::n_texCoords ( )

Definition at line 852 of file OBJImporter.cc.

◆ n_vertices()

unsigned int OBJImporter::n_vertices ( )

Global Properties.

Definition at line 840 of file OBJImporter.cc.

◆ noOptions()

bool OBJImporter::noOptions ( )

Return true if the importer has no options stored.

Definition at line 912 of file OBJImporter.cc.

◆ numGroups()

unsigned int OBJImporter::numGroups ( ) const
inline

Definition at line 270 of file OBJImporter.hh.

◆ object()

BaseObject * OBJImporter::object ( int  _groupId)

return object for the given group

Definition at line 864 of file OBJImporter.cc.

◆ path()

QString OBJImporter::path ( )

Path of the OBJ file.

Definition at line 889 of file OBJImporter.cc.

◆ setCurrentGroup()

void OBJImporter::setCurrentGroup ( const int  _current)

Definition at line 994 of file OBJImporter.cc.

◆ setDegreeU()

void OBJImporter::setDegreeU ( int  _degree)

set degree

set degree U direction

Definition at line 93 of file OBJImporter.cc.

◆ setDegreeV()

void OBJImporter::setDegreeV ( int  _degree)

set degree V direction

Definition at line 100 of file OBJImporter.cc.

◆ setGroupName()

void OBJImporter::setGroupName ( const int  _grp,
const QString &  _name 
)

Definition at line 985 of file OBJImporter.cc.

◆ setNormal()

void OBJImporter::setNormal ( int  _index,
int  _normalID 
)

set vertex normal

Definition at line 303 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.

◆ setObjectName()

void OBJImporter::setObjectName ( int  _objectID,
QString  _name 
)

change the name of an object

Definition at line 929 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 901 of file OBJImporter.cc.

◆ setOption() [1/2]

void OBJImporter::setOption ( ObjectOptionsE  _option)

Set Object Option.

Definition at line 829 of file OBJImporter.cc.

◆ setOption() [2/2]

void OBJImporter::setOption ( ObjectOptionsE  _option,
int  _groupId 
)

Set Object Option.

Definition at line 834 of file OBJImporter.cc.

◆ setPath()

void OBJImporter::setPath ( QString  _path)

Definition at line 895 of file OBJImporter.cc.

◆ setVertexTexCoord()

void OBJImporter::setVertexTexCoord ( VertexHandle  _vh,
int  _texCoordID 
)

set vertex texture coordinate

Definition at line 258 of file OBJImporter.cc.

◆ usedMaterials()

const std::vector< std::string > OBJImporter::usedMaterials ( unsigned int  _objectID)

used materials

Definition at line 1164 of file OBJImporter.cc.

◆ useMaterial()

void OBJImporter::useMaterial ( std::string  _materialName)

Definition at line 1174 of file OBJImporter.cc.

◆ useVertex()

void OBJImporter::useVertex ( int  _vertex_index)

used vertices

Definition at line 1191 of file OBJImporter.cc.

◆ vertex()

Vec3d OBJImporter::vertex ( unsigned int  _index)

get vertex with given index

Definition at line 64 of file OBJImporter.cc.

◆ vertexListIsManifold()

bool OBJImporter::vertexListIsManifold ( const std::vector< PolyMesh::VertexHandle > &  _vertices) const
private

Definition at line 474 of file OBJImporter.cc.

Member Data Documentation

◆ addedFacePoly_

PolyMesh::FaceHandle OBJImporter::addedFacePoly_
private

Definition at line 308 of file OBJImporter.hh.

◆ addedFacesTri_

std::vector<std::vector< TriMesh::FaceHandle > > OBJImporter::addedFacesTri_
private

Definition at line 313 of file OBJImporter.hh.

◆ currentGroup_

int OBJImporter::currentGroup_
private

Definition at line 303 of file OBJImporter.hh.

◆ degreeU_

int OBJImporter::degreeU_
private

Definition at line 295 of file OBJImporter.hh.

◆ degreeV_

int OBJImporter::degreeV_
private

Definition at line 296 of file OBJImporter.hh.

◆ groupNames_

std::vector<QString> OBJImporter::groupNames_
private

Definition at line 302 of file OBJImporter.hh.

◆ invalidFaces_

std::vector< std::vector< OMVHandles > > OBJImporter::invalidFaces_
private

Definition at line 338 of file OBJImporter.hh.

◆ materials_

MaterialList OBJImporter::materials_
private

Definition at line 298 of file OBJImporter.hh.

◆ normals_

std::vector< Vec3d > OBJImporter::normals_
private

Definition at line 288 of file OBJImporter.hh.

◆ objectOptions_

std::vector< ObjectOptions > OBJImporter::objectOptions_
private

Definition at line 327 of file OBJImporter.hh.

◆ path_

QString OBJImporter::path_
private

Definition at line 300 of file OBJImporter.hh.

◆ polyMeshes_

std::vector<PolyMeshObject*> OBJImporter::polyMeshes_
private

Definition at line 319 of file OBJImporter.hh.

◆ storedPolyHENormals_

std::map<TriMesh::VertexHandle,PolyMesh::Normal> OBJImporter::storedPolyHENormals_
private

Definition at line 293 of file OBJImporter.hh.

◆ storedTriHENormals_

std::map<TriMesh::VertexHandle,TriMesh::Normal> OBJImporter::storedTriHENormals_
private

Definition at line 292 of file OBJImporter.hh.

◆ texCoords_

std::vector< Vec2f > OBJImporter::texCoords_
private

Definition at line 289 of file OBJImporter.hh.

◆ triMeshes_

std::vector<TriMeshObject*> OBJImporter::triMeshes_
private

Definition at line 318 of file OBJImporter.hh.

◆ usedMaterials_

std::vector< std::vector< std::string > > OBJImporter::usedMaterials_
private

Definition at line 330 of file OBJImporter.hh.

◆ usedVertices_

std::vector< std::map< int, VertexHandle > > OBJImporter::usedVertices_
private

Definition at line 334 of file OBJImporter.hh.

◆ vertexMapPoly_

std::vector<std::map< int, PolyMesh::VertexHandle > > OBJImporter::vertexMapPoly_
private

Definition at line 306 of file OBJImporter.hh.

◆ vertexMapTri_

std::vector<std::map< int, TriMesh::VertexHandle > > OBJImporter::vertexMapTri_
private

Definition at line 311 of file OBJImporter.hh.

◆ vertices_

std::vector< Vec3d > OBJImporter::vertices_
private

Definition at line 287 of file OBJImporter.hh.


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