51 #ifndef OBJIMPORTER_HH 52 #define OBJIMPORTER_HH 54 #define TEXTUREINDEX "OriginalTexIndexMapping" 64 #include <OpenMesh/Core/Geometry/VectorT.hh> 70 #ifdef ENABLE_BSPLINECURVE_SUPPORT 74 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 78 #include "Material.hh" 82 typedef int VertexHandle;
83 typedef int FaceHandle;
84 typedef std::vector<VertexHandle> VHandles;
85 typedef std::vector<OpenMesh::VertexHandle> OMVHandles;
108 FORCE_NOCOLOR = 1 << 8,
109 FORCE_NONORMALS = 1 << 9,
110 FORCE_NOTEXTURES = 1 << 10
113 typedef unsigned int ObjectOptions;
118 addGroup(
"DefaultGroup");
156 #ifdef ENABLE_BSPLINECURVE_SUPPORT 159 unsigned int numCurves() {
return curvesMap_.size(); }
161 void setCurveGroupId(
const unsigned int _count,
const int _id);
163 int getCurveGroupId(
const unsigned int _count);
165 void setCurveParentId(
const int _curveGroup,
const int _parentGroup);
167 int getCurveParentId(
const int _curveGroup);
170 #ifdef ENABLE_BSPLINECURVE_SUPPORT 173 unsigned int numSurfaces() {
return surfacesMap_.size(); }
175 void setSurfaceGroupId(
const unsigned int _count,
const int _id);
177 int getSurfaceGroupId(
const unsigned int _count);
179 void setSurfaceParentId(
const int _surfaceGroup,
const int _parentGroup);
181 int getSurfaceParentId(
const int _surfaceGroup);
191 void setNormal(
int _index,
int _normalID);
194 void addFace(
const VHandles& _indices);
197 void addFace(
const VHandles& _indices,
const std::vector<int>& _face_texcoords);
200 bool addFace(
const VHandles& _indices,
OpenMesh::FaceHandle &_outFH, std::vector< TriMesh::VertexHandle > &_outTriVertices, std::vector< PolyMesh::VertexHandle > &_outPolyVertices);
208 bool hasTexture(
int _objectID);
209 bool hasTextureCoords(
int _objectID);
210 bool isTriangleMesh(
int _objectID);
211 bool isPolyMesh(
int _objectID);
212 bool isCurve(
int _objectID);
213 bool isSurface(
int _objectID);
217 unsigned int n_normals();
218 unsigned int n_texCoords();
220 unsigned int objectCount();
232 const std::vector<std::string>
usedMaterials(
unsigned int _objectID);
233 void useMaterial( std::string _materialName );
240 void setPath(QString _path);
250 bool hasOption(
unsigned int _id, ObjectOptions _option );
256 int addGroup(
const QString& _groupName);
257 int groupId(
const QString& _groupName)
const;
258 unsigned int numGroups()
const {
return groupNames_.size(); }
259 const QString groupName(
const int _grpId)
const;
260 void setGroupName(
const int _grp,
const QString& _name);
262 void setCurrentGroup(
const int _current);
263 int currentGroup()
const;
272 bool vertexListIsManifold(
const std::vector<PolyMesh::VertexHandle>& _vertices)
const;
275 std::vector< Vec3f > vertices_;
276 std::vector< Vec3f > normals_;
277 std::vector< Vec2f > texCoords_;
280 std::map<TriMesh::VertexHandle,TriMesh::Normal> storedTriHENormals_;
281 std::map<TriMesh::VertexHandle,PolyMesh::Normal> storedPolyHENormals_;
286 MaterialList materials_;
290 std::vector<QString> groupNames_;
294 std::vector<std::map< int, PolyMesh::VertexHandle > > vertexMapPoly_;
296 PolyMesh::FaceHandle addedFacePoly_;
299 std::vector<std::map< int, TriMesh::VertexHandle > > vertexMapTri_;
301 std::vector<std::vector< TriMesh::FaceHandle > > addedFacesTri_;
306 std::vector<TriMeshObject*> triMeshes_;
307 std::vector<PolyMeshObject*> polyMeshes_;
308 #ifdef ENABLE_BSPLINECURVE_SUPPORT 309 std::vector<BSplineCurveObject*> bSplineCurves_;
311 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 312 std::vector<BSplineSurfaceObject*> bSplineSurfaces_;
315 std::vector< ObjectOptions > objectOptions_;
318 std::vector< std::vector< std::string > > usedMaterials_;
322 std::vector< std::map< int, VertexHandle > > usedVertices_;
326 std::vector< std::vector< OMVHandles > > invalidFaces_;
328 #ifdef ENABLE_BSPLINECURVE_SUPPORT 329 std::map<unsigned int, int> curvesMap_;
332 std::map<int, int> curveParentGroupMap_;
335 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 336 std::map<unsigned int, int> surfacesMap_;
339 std::map<int, int> surfaceParentGroupMap_;
345 #endif // OBJIMPORTER_HH OBJImporter()
Constructor.
void setDegreeV(int _degree)
set degree V direction
void useVertex(int _vertex_index)
used vertices
void setNormal(int _index, int _normalID)
set vertex normal
int currentObject()
get id of the active object
void setObjectName(int _objectID, QString _name)
change the name of an object
VertexHandle addVertex(const Vec3f &_point)
add a vertex with coordinate _point
void forceMeshType(ObjectOptions _meshType)
force all meshes to be opened with specific type
void addUsedVertices(int _groupId)
add all vertices that are used to the mesh (in correct order)
unsigned int n_vertices()
Global Properties.
void setObjectOptions(ObjectOptions _options)
QString path()
Path of the OBJ file.
void setDegreeU(int _degree)
set degree
int addTexCoord(const Vec2f &_coord)
add texture coordinates
int degreeV()
get current degree
void setVertexTexCoord(VertexHandle _vh, int _texCoordID)
set vertex texture coordinate
~OBJImporter()
base class needs virtual destructor
Vec3f vertex(unsigned int _index)
get vertex with given index
bool hasNormals(int _objectID)
Query Object Options.
BaseObject * object(int _objectID)
return object with given index
int degreeU()
get current degree
PolyMesh * currentPolyMesh()
get a pointer to the active polyMesh
Handle for a face entity.
void addFace(const VHandles &_indices)
add a face with indices _indices refering to vertices
const std::vector< std::string > usedMaterials(unsigned int _objectID)
used materials
TriMesh * currentTriMesh()
get a pointer to the active triMesh
std::vector< ObjectOptions > & objectOptions()
Object Options for all objects.
void setObject(BaseObject *_object, int _groupId)
add an object
void addMaterial(std::string _materialName)
Add a material.
bool hasOption(unsigned int _id, ObjectOptions _option)
check if object with given id has given option
int addNormal(const Vec3f &_normal)
add a normal
MaterialList & materials()
return all loaded materials