Commit 9f4f6f11 authored by Isaak Lim's avatar Isaak Lim
Browse files

the original per face/vertex texture coordinates are now back-upped when loading a PLY file

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14179 383ad7c9-94d9-4d36-a494-682f7c89f535
parent bae0deeb
......@@ -541,6 +541,9 @@ int FilePLYPlugin::loadTriMeshObject(QString _filename, const PLYHeader& _header
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::POINTS);
object->update();
backupTextureCoordinates(*mesh);
return object->id();
} else {
......@@ -600,6 +603,9 @@ int FilePLYPlugin::loadPolyMeshObject(QString _filename, const PLYHeader& _heade
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::POINTS);
object->update();
backupTextureCoordinates(*mesh);
return object->id();
} else {
......
......@@ -179,6 +179,9 @@ class FilePLYPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
template <class MeshT>
void writeHeader(std::ofstream& _os, MeshT* _mesh, bool _binary);
template <class MeshT>
void backupTextureCoordinates(MeshT& _mesh);
/// \brief Helper functions for writing/reading of binary data
template <class T>
......
......@@ -1096,3 +1096,34 @@ bool FilePLYPlugin::writeMeshFileBinary(QString _filename, MeshT* _mesh) {
ofs.close();
return true;
}
//===============================================================================================
/// creates a backup of the original per vertex/face texture coordinates
template <class MeshT>
void FilePLYPlugin::backupTextureCoordinates(MeshT& _mesh) {
// Create a backup of the original per Vertex texture Coordinates
if (_mesh.has_vertex_texcoords2D()) {
OpenMesh::VPropHandleT< typename MeshT::TexCoord2D > oldVertexCoords;
if (!_mesh.get_property_handle(oldVertexCoords, "Original Per Vertex Texture Coords"))
_mesh.add_property(oldVertexCoords, "Original Per Vertex Texture Coords");
for (typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it)
_mesh.property(oldVertexCoords, v_it) = _mesh.texcoord2D(v_it);
}
// Create a backup of the original per Face texture Coordinates
if (_mesh.has_halfedge_texcoords2D()) {
OpenMesh::HPropHandleT< typename MeshT::TexCoord2D > oldHalfedgeCoords;
if (!_mesh.get_property_handle(oldHalfedgeCoords,"Original Per Face Texture Coords"))
_mesh.add_property(oldHalfedgeCoords,"Original Per Face Texture Coords");
for (typename MeshT::HalfedgeIter he_it = _mesh.halfedges_begin(); he_it != _mesh.halfedges_end(); ++he_it)
_mesh.property(oldHalfedgeCoords, he_it) = _mesh.texcoord2D(he_it);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment