Improved management of fauxbit for quad and polygonal meshes in OBJ (did not set the high level polygonal bit) and OFF (wrong faux bits for polygonal faces with more than 4 sides)
This commit is contained in:
parent
371ff46282
commit
e77e13a8fe
|
|
@ -416,6 +416,8 @@ namespace vcg {
|
||||||
GoodObjIndex(indexTVect[pi],oi.numTexCoords);
|
GoodObjIndex(indexTVect[pi],oi.numTexCoords);
|
||||||
polygonVect[0][pi].Import(m.vert[indexVVect[pi]].cP());
|
polygonVect[0][pi].Import(m.vert[indexVVect[pi]].cP());
|
||||||
}
|
}
|
||||||
|
if(vertexesPerFace>3)
|
||||||
|
oi.mask |= Mask::IOM_BITPOLYGONAL;
|
||||||
|
|
||||||
if(vertexesPerFace<5)
|
if(vertexesPerFace<5)
|
||||||
InternalFanTessellator(polygonVect, indexTriangulatedVect);
|
InternalFanTessellator(polygonVect, indexTriangulatedVect);
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ namespace vcg
|
||||||
// OFF codes
|
// OFF codes
|
||||||
enum OFFCodes {NoError=0, CantOpen, InvalidFile,
|
enum OFFCodes {NoError=0, CantOpen, InvalidFile,
|
||||||
InvalidFile_MissingOFF,
|
InvalidFile_MissingOFF,
|
||||||
UnsupportedFormat, ErrorNotTriangularFace,ErrorHighDimension,ErrorDegenerateFace};
|
UnsupportedFormat, ErrorNotTriangularFace,ErrorHighDimension,ErrorDegenerateFace};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Standard call for knowing the meaning of an error code
|
* Standard call for knowing the meaning of an error code
|
||||||
|
|
@ -71,9 +71,9 @@ namespace vcg
|
||||||
{
|
{
|
||||||
"No errors", "Can't open file", "Invalid file",
|
"No errors", "Can't open file", "Invalid file",
|
||||||
"Invalid file: OFF file should have in the first line the OFF keyword as a first token",
|
"Invalid file: OFF file should have in the first line the OFF keyword as a first token",
|
||||||
"Unsupported format", "Face with more than 3 vertices","File with high dimensional vertexes are not supported", "Error Degenerate Face with less than 3 vertices" };
|
"Unsupported format", "Face with more than 3 vertices","File with high dimensional vertexes are not supported", "Error Degenerate Face with less than 3 vertices" };
|
||||||
|
|
||||||
if(message_code>6 || message_code<0)
|
if(message_code>6 || message_code<0)
|
||||||
return "Unknown error";
|
return "Unknown error";
|
||||||
else
|
else
|
||||||
return error_msg[message_code];
|
return error_msg[message_code];
|
||||||
|
|
@ -90,9 +90,9 @@ namespace vcg
|
||||||
{
|
{
|
||||||
// To obtain the loading mask all the file must be parsed
|
// To obtain the loading mask all the file must be parsed
|
||||||
// to distinguish between per-vertex and per-face color attribute.
|
// to distinguish between per-vertex and per-face color attribute.
|
||||||
loadmask=0;
|
loadmask=0;
|
||||||
MESH_TYPE dummyMesh;
|
MESH_TYPE dummyMesh;
|
||||||
return (Open(dummyMesh, filename, loadmask)==NoError);
|
return (Open(dummyMesh, filename, loadmask)==NoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Open(MESH_TYPE &mesh, const char *filename,CallBackPos *cb=0)
|
static int Open(MESH_TYPE &mesh, const char *filename,CallBackPos *cb=0)
|
||||||
|
|
@ -109,7 +109,7 @@ namespace vcg
|
||||||
* \return the operation result
|
* \return the operation result
|
||||||
*/
|
*/
|
||||||
static int Open(MESH_TYPE &mesh, const char *filename, int &loadmask,
|
static int Open(MESH_TYPE &mesh, const char *filename, int &loadmask,
|
||||||
CallBackPos *cb=0)
|
CallBackPos *cb=0)
|
||||||
{
|
{
|
||||||
std::ifstream stream(filename);
|
std::ifstream stream(filename);
|
||||||
if (stream.fail())
|
if (stream.fail())
|
||||||
|
|
@ -163,7 +163,7 @@ namespace vcg
|
||||||
}
|
}
|
||||||
else return InvalidFile_MissingOFF;
|
else return InvalidFile_MissingOFF;
|
||||||
|
|
||||||
// If the file is slightly malformed and it has nvert and nface AFTER the OFF string instead of in the next line
|
// If the file is slightly malformed and it has nvert and nface AFTER the OFF string instead of in the next line
|
||||||
// we manage it here...
|
// we manage it here...
|
||||||
if(tokens.size()==1) TokenizeNextLine(stream, tokens);
|
if(tokens.size()==1) TokenizeNextLine(stream, tokens);
|
||||||
else tokens.erase(tokens.begin(),tokens.begin()+1);
|
else tokens.erase(tokens.begin(),tokens.begin()+1);
|
||||||
|
|
@ -178,7 +178,7 @@ namespace vcg
|
||||||
if (isColorDefined) { loadmask |= Mask::IOM_VERTCOLOR;loadmask |= Mask::IOM_FACECOLOR;}
|
if (isColorDefined) { loadmask |= Mask::IOM_VERTCOLOR;loadmask |= Mask::IOM_FACECOLOR;}
|
||||||
|
|
||||||
|
|
||||||
//if(onlyMaskFlag) return NoError;
|
//if(onlyMaskFlag) return NoError;
|
||||||
|
|
||||||
|
|
||||||
mesh.Clear();
|
mesh.Clear();
|
||||||
|
|
@ -410,7 +410,7 @@ namespace vcg
|
||||||
nFaces += trigs;
|
nFaces += trigs;
|
||||||
Allocator<MESH_TYPE>::AddFaces(mesh, trigs);
|
Allocator<MESH_TYPE>::AddFaces(mesh, trigs);
|
||||||
std::vector<int> vertIndices(vert_per_face);
|
std::vector<int> vertIndices(vert_per_face);
|
||||||
std::vector<vcg::Point3f > polygonVect(vert_per_face); // vec of polygon loops used for the triangulation of polygonal face
|
std::vector<vcg::Point3f > polygonVect(vert_per_face); // vec of polygon loops used for the triangulation of polygonal face
|
||||||
for (int j=0; j < vert_per_face; j++)
|
for (int j=0; j < vert_per_face; j++)
|
||||||
{
|
{
|
||||||
if (k == tokens.size()) // if EOL // Go to next line when needed
|
if (k == tokens.size()) // if EOL // Go to next line when needed
|
||||||
|
|
@ -420,7 +420,7 @@ namespace vcg
|
||||||
k = 0;
|
k = 0;
|
||||||
}
|
}
|
||||||
vertIndices[j] = atoi(tokens[k].c_str());
|
vertIndices[j] = atoi(tokens[k].c_str());
|
||||||
polygonVect[j].Import<ScalarType> (mesh.vert[ vertIndices[j] ].P());
|
polygonVect[j].Import<ScalarType> (mesh.vert[ vertIndices[j] ].P());
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
if(vert_per_face==4)
|
if(vert_per_face==4)
|
||||||
|
|
@ -449,7 +449,7 @@ namespace vcg
|
||||||
{
|
{
|
||||||
std::vector<int> indexTriangulatedVect;
|
std::vector<int> indexTriangulatedVect;
|
||||||
// TessellatePlanarPolygon3(polygonVect,indexTriangulatedVect);
|
// TessellatePlanarPolygon3(polygonVect,indexTriangulatedVect);
|
||||||
std::vector< std::vector<Point3f> > loopVect;
|
std::vector< std::vector<Point3f> > loopVect;
|
||||||
loopVect.push_back(polygonVect);
|
loopVect.push_back(polygonVect);
|
||||||
#ifdef __gl_h_
|
#ifdef __gl_h_
|
||||||
//qDebug("OK: using opengl tessellation for a polygon of %i vertices",vertexesPerFace);
|
//qDebug("OK: using opengl tessellation for a polygon of %i vertices",vertexesPerFace);
|
||||||
|
|
@ -463,6 +463,14 @@ namespace vcg
|
||||||
mesh.face[f+j/3].V(0) = &(mesh.vert[ vertIndices[ indexTriangulatedVect[j+0] ] ]);
|
mesh.face[f+j/3].V(0) = &(mesh.vert[ vertIndices[ indexTriangulatedVect[j+0] ] ]);
|
||||||
mesh.face[f+j/3].V(1) = &(mesh.vert[ vertIndices[ indexTriangulatedVect[j+1] ] ]);
|
mesh.face[f+j/3].V(1) = &(mesh.vert[ vertIndices[ indexTriangulatedVect[j+1] ] ]);
|
||||||
mesh.face[f+j/3].V(2) = &(mesh.vert[ vertIndices[ indexTriangulatedVect[j+2] ] ]);
|
mesh.face[f+j/3].V(2) = &(mesh.vert[ vertIndices[ indexTriangulatedVect[j+2] ] ]);
|
||||||
|
// To correctly set Faux edges we have to clear the faux bit for all the edges that do not correspond to consecutive vertices
|
||||||
|
// Consecutivity is in the space of the index of the polygon.
|
||||||
|
for(int qq=0;qq<3;++qq)
|
||||||
|
{
|
||||||
|
if( (indexTriangulatedVect[j+qq]+1)%indexTriangulatedVect.size() == indexTriangulatedVect[j+(qq+1)%3])
|
||||||
|
mesh.face[f+j/3].ClearF(qq);
|
||||||
|
else mesh.face[f+j/3].SetF(qq);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f+=trigs;
|
f+=trigs;
|
||||||
|
|
@ -471,11 +479,11 @@ namespace vcg
|
||||||
// NOTE: It is assumed that colored face takes exactly one text line
|
// NOTE: It is assumed that colored face takes exactly one text line
|
||||||
// (otherwise it is impossible to parse color information since
|
// (otherwise it is impossible to parse color information since
|
||||||
// color components can vary)
|
// color components can vary)
|
||||||
size_t color_elements = tokens.size() - vert_per_face-1;
|
size_t color_elements = tokens.size() - vert_per_face-1;
|
||||||
isColorDefined |= (color_elements>0);
|
isColorDefined |= (color_elements>0);
|
||||||
if(isColorDefined) loadmask |= Mask::IOM_FACECOLOR;
|
if(isColorDefined) loadmask |= Mask::IOM_FACECOLOR;
|
||||||
|
|
||||||
if( (color_elements>0) && tri::HasPerFaceColor(mesh) )
|
if( (color_elements>0) && tri::HasPerFaceColor(mesh) )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -551,14 +559,14 @@ namespace vcg
|
||||||
|
|
||||||
} // end Open
|
} // end Open
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Read the next valid line and parses it into "tokens", allowing the tokens to be read one at a time.
|
* Read the next valid line and parses it into "tokens", allowing the tokens to be read one at a time.
|
||||||
* \param stream The object providing the input stream
|
* \param stream The object providing the input stream
|
||||||
* \param tokens The "tokens" in the next line
|
* \param tokens The "tokens" in the next line
|
||||||
*/
|
*/
|
||||||
inline static void TokenizeNextLine(std::ifstream &stream, std::vector< std::string > &tokens)
|
inline static void TokenizeNextLine(std::ifstream &stream, std::vector< std::string > &tokens)
|
||||||
{
|
{
|
||||||
std::string line;
|
std::string line;
|
||||||
do
|
do
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue