PolygonalMesh Debugging: Added direct loading of quad mesh into polygonal meshes (without need of having a trimesh to support)

This commit is contained in:
Paolo Cignoni 2014-02-18 10:58:57 +00:00
parent 1a4c5ef80d
commit d2f164d90c
1 changed files with 663 additions and 636 deletions

View File

@ -25,15 +25,13 @@
#include <fstream> #include <fstream>
#include<vcg/complex/algorithms/bitquad_support.h> #include<vcg/complex/algorithms/bitquad_support.h>
#include <wrap/callback.h>
#include <wrap/io_trimesh/io_mask.h> #include <wrap/io_trimesh/io_mask.h>
#include <wrap/io_trimesh/io_fan_tessellator.h> #include <wrap/io_trimesh/io_fan_tessellator.h>
namespace vcg
{ namespace vcg {
namespace tri namespace tri {
{ namespace io {
namespace io
{
// /** \addtogroup */ // /** \addtogroup */
// /* @{ */ // /* @{ */
/** /**
@ -364,7 +362,36 @@ namespace vcg
// READ FACES // READ FACES
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
if(FaceType::HasPolyInfo())
{
for (unsigned int f=0; f < nFaces; f++)
{
if(cb && (f%1000)==0) cb(50+f*50/nFaces,"Face Loading");
TokenizeNextLine(stream, tokens);
int vert_per_face = atoi(tokens[0].c_str());
std::vector<int> vInd(vert_per_face);
k = 1;
for (int j=0; j < vert_per_face; j++)
{
if (k == tokens.size()) // if EOL // Go to next line when needed
{
TokenizeNextLine(stream, tokens);
if (tokens.size() == 0) return InvalidFile; // if EOF
k = 0;
}
vInd[j] = atoi(tokens[k].c_str());
k++;
}
if(vert_per_face==3)
Allocator<MESH_TYPE>::AddFace(mesh, &mesh.vert[ vInd[0] ], &mesh.vert[ vInd[1] ], &mesh.vert[ vInd[2] ]);
if(vert_per_face==4)
Allocator<MESH_TYPE>::AddQuadFace(mesh, &mesh.vert[ vInd[0] ], &mesh.vert[ vInd[1] ], &mesh.vert[ vInd[2] ],&mesh.vert[ vInd[3] ]);
}
}
else // Standard Triangular Mesh Loading
{
Allocator<MESH_TYPE>::AddFaces(mesh, nFaces); Allocator<MESH_TYPE>::AddFaces(mesh, nFaces);
unsigned int f0=0; unsigned int f0=0;
@ -553,7 +580,7 @@ namespace vcg
} //end switch } //end switch
} // end if (isColorDefined) } // end if (isColorDefined)
} // end of for f=... } // end of for f=...
}
return NoError; return NoError;
} // end Open } // end Open