dxf, gts and partial obj const correctness
This commit is contained in:
parent
8f953efd04
commit
8b36975248
|
@ -41,7 +41,7 @@ class ExporterDXF
|
|||
typedef typename SaveMeshType::CoordType CoordType;
|
||||
public:
|
||||
///Standard call for saving a mesh
|
||||
static int Save(SaveMeshType &m, const char * filename)
|
||||
static int Save(const SaveMeshType &m, const char * filename)
|
||||
{
|
||||
if(m.fn==0 && m.en != 0) return SaveEdge(m,filename);
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
fprintf(o,"2\n");
|
||||
fprintf(o,"ENTITIES\n");
|
||||
|
||||
typename SaveMeshType::FaceIterator fi;
|
||||
typename SaveMeshType::ConstFaceIterator fi;
|
||||
for(fi=m.face.begin(); fi!=m.face.end(); ++fi)
|
||||
{
|
||||
if (!fi->IsD())
|
||||
|
@ -109,7 +109,7 @@ public:
|
|||
}
|
||||
|
||||
|
||||
static bool SaveEdge(SaveMeshType &m, const char * filename)
|
||||
static bool SaveEdge(const SaveMeshType &m, const char * filename)
|
||||
{
|
||||
FILE * o = fopen(filename,"w");
|
||||
if(o==NULL) return 1;
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
fprintf(o,"2\n");
|
||||
fprintf(o,"ENTITIES\n");
|
||||
|
||||
typename SaveMeshType::EdgeIterator ei;
|
||||
typename SaveMeshType::ConstEdgeIterator ei;
|
||||
for(ei=m.edge.begin(); ei!=m.edge.end();++ei)
|
||||
{
|
||||
CoordType p1 = (*ei).V(0)->P();
|
||||
|
@ -155,7 +155,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool writeHeader(FILE* o, SaveMeshType &mp)
|
||||
static bool writeHeader(FILE* o, const SaveMeshType &mp)
|
||||
{
|
||||
// standard DXF header
|
||||
// most of data is meaningless, but required by a lot of importers
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <wrap/io_trimesh/io_mask.h>
|
||||
|
||||
|
||||
|
@ -45,15 +46,15 @@ namespace vcg {
|
|||
{
|
||||
|
||||
public:
|
||||
typedef typename SaveMeshType::VertexPointer VertexPointer;
|
||||
typedef typename SaveMeshType::ConstVertexPointer VertexPointer;
|
||||
typedef typename SaveMeshType::ScalarType ScalarType;
|
||||
typedef typename SaveMeshType::VertexType VertexType;
|
||||
typedef typename SaveMeshType::FaceType FaceType;
|
||||
typedef typename SaveMeshType::FacePointer FacePointer;
|
||||
typedef typename SaveMeshType::VertexIterator VertexIterator;
|
||||
typedef typename SaveMeshType::FaceIterator FaceIterator;
|
||||
typedef typename SaveMeshType::ConstFacePointer FacePointer;
|
||||
typedef typename SaveMeshType::ConstVertexIterator VertexIterator;
|
||||
typedef typename SaveMeshType::ConstFaceIterator FaceIterator;
|
||||
|
||||
static int Save(SaveMeshType &m, const char * filename, int /*mask*/ )
|
||||
static int Save(const SaveMeshType &m, const char * filename, int /*mask*/ )
|
||||
{
|
||||
QFile device(filename);
|
||||
if (!device.open(QFile::WriteOnly))
|
||||
|
@ -62,17 +63,19 @@ namespace vcg {
|
|||
QTextStream stream(&device);
|
||||
|
||||
// update vertex indices
|
||||
std::vector<int> FlagV;
|
||||
//std::vector<int> FlagV;
|
||||
std::unordered_map<VertexPointer, int> vertFlags;
|
||||
VertexPointer vp;
|
||||
VertexIterator vi;
|
||||
int j;
|
||||
for(j=0,vi=m.vert.begin(); vi!=m.vert.end(); ++vi)
|
||||
{
|
||||
vp = &(*vi);
|
||||
FlagV.push_back(vp->Flags());
|
||||
//FlagV.push_back(vp->Flags());
|
||||
if (!vp->IsD())
|
||||
{
|
||||
vp->Flags() = j;
|
||||
vertFlags[vp] = j;
|
||||
//vp->Flags() = j;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
@ -94,8 +97,8 @@ namespace vcg {
|
|||
{
|
||||
for (int k=0; k<3; ++k)
|
||||
{
|
||||
int a = fp->cV(k)->Flags();
|
||||
int b = fp->cV((k+1)%3)->Flags();
|
||||
int a = vertFlags[fp->cV(k)];//fp->cV(k)->Flags();
|
||||
int b = vertFlags[fp->cV((k+1)%3)];//fp->cV((k+1)%3)->Flags();
|
||||
if (a>b)
|
||||
std::swap(a,b);
|
||||
Edge e(a,b);
|
||||
|
@ -132,8 +135,8 @@ namespace vcg {
|
|||
{
|
||||
for (int k=0; k<3; ++k)
|
||||
{
|
||||
int a = fp->cV(k)->Flags();
|
||||
int b = fp->cV((k+1)%3)->Flags();
|
||||
int a = vertFlags[fp->cV(k)];//fp->cV(k)->Flags();
|
||||
int b = vertFlags[fp->cV((k+1)%3)];//fp->cV((k+1)%3)->Flags();
|
||||
if (a>b)
|
||||
std::swap(a,b);
|
||||
Edge e(a,b);
|
||||
|
@ -154,8 +157,8 @@ namespace vcg {
|
|||
{
|
||||
for (int k=0; k<3; ++k)
|
||||
{
|
||||
int a = fp->cV(k)->Flags();
|
||||
int b = fp->cV((k+1)%3)->Flags();
|
||||
int a = vertFlags[fp->cV(k)];//fp->cV(k)->Flags();
|
||||
int b = vertFlags[fp->cV((k+1)%3)];//fp->cV((k+1)%3)->Flags();
|
||||
if (a>b)
|
||||
std::swap(a,b);
|
||||
Edge e(a,b);
|
||||
|
@ -170,8 +173,8 @@ namespace vcg {
|
|||
}
|
||||
|
||||
// Recupera i flag originali
|
||||
for(j=0,vi=m.vert.begin();vi!=m.vert.end();++vi)
|
||||
(*vi).Flags()=FlagV[j++];
|
||||
//for(j=0,vi=m.vert.begin();vi!=m.vert.end();++vi)
|
||||
// (*vi).Flags()=FlagV[j++];
|
||||
|
||||
|
||||
int result = 0;
|
||||
|
|
|
@ -42,7 +42,9 @@ class ExporterOBJ
|
|||
{
|
||||
public:
|
||||
typedef typename SaveMeshType::FaceIterator FaceIterator;
|
||||
typedef typename SaveMeshType::ConstFaceIterator ConstFaceIterator;
|
||||
typedef typename SaveMeshType::EdgeIterator EdgeIterator;
|
||||
typedef typename SaveMeshType::ConstEdgeIterator ConstEdgeIterator;
|
||||
typedef typename SaveMeshType::VertexIterator VertexIterator;
|
||||
typedef typename SaveMeshType::VertexType VertexType;
|
||||
typedef typename SaveMeshType::ScalarType ScalarType;
|
||||
|
@ -212,7 +214,7 @@ public:
|
|||
int curMatIndex = -1;
|
||||
std::vector<Material> materialVec; //used if we do not have material attributes
|
||||
|
||||
for(FaceIterator fi=m.face.begin(); fi!=m.face.end(); ++fi) if( !(*fi).IsD() )
|
||||
for(ConstFaceIterator fi=m.face.begin(); fi!=m.face.end(); ++fi) if( !(*fi).IsD() )
|
||||
{
|
||||
if((mask & Mask::IOM_FACECOLOR) || (mask & Mask::IOM_WEDGTEXCOORD) || (mask & Mask::IOM_VERTTEXCOORD))
|
||||
{
|
||||
|
@ -269,7 +271,7 @@ public:
|
|||
|
||||
} // end for faces
|
||||
|
||||
for(EdgeIterator ei=m.edge.begin(); ei!=m.edge.end(); ++ei) if( !(*ei).IsD() )
|
||||
for(ConstEdgeIterator ei=m.edge.begin(); ei!=m.edge.end(); ++ei) if( !(*ei).IsD() )
|
||||
{
|
||||
fprintf(fp,"l %i %i\n",
|
||||
VertexId[tri::Index(m, (*ei).V(0))] + 1,
|
||||
|
@ -312,7 +314,7 @@ public:
|
|||
/*
|
||||
returns index of the vertex normal
|
||||
*/
|
||||
inline static int GetIndexVertexNormal(SaveMeshType &/*m*/, std::map<CoordType,int> &mapNormToInt, const CoordType &norm )
|
||||
inline static int GetIndexVertexNormal(const SaveMeshType &/*m*/, std::map<CoordType,int> &mapNormToInt, const CoordType &norm )
|
||||
{
|
||||
typename std::map<CoordType,int>::iterator iter= mapNormToInt.find(norm);
|
||||
if(iter != mapNormToInt.end()) return (*iter).second;
|
||||
|
@ -358,7 +360,7 @@ public:
|
|||
adds a new index to the normal per vertex if it is the first time
|
||||
which is otherwise met does not execute anything
|
||||
*/
|
||||
inline static bool AddNewNormalVertex(typename std::map<CoordType,int> &m, CoordType &n ,int value)
|
||||
inline static bool AddNewNormalVertex(typename std::map<CoordType,int> &m, const CoordType &n ,int value)
|
||||
{
|
||||
int index = m[n];
|
||||
if(index==0){m[n]=value;return true;}
|
||||
|
|
Loading…
Reference in New Issue