Many small changes to remove useless annoying warnings.
This commit is contained in:
parent
15bec03c89
commit
6efdd91ecc
|
@ -230,7 +230,8 @@ static ScalarType EdgeLenghtVariationIfVertexRotated(const FaceType &f, int w0)
|
||||||
pi = pf->cFFi( pi );
|
pi = pf->cFFi( pi );
|
||||||
pi = (pi+1)%3; // FaceType::Next( pf->FFi( pi ) );
|
pi = (pi+1)%3; // FaceType::Next( pf->FFi( pi ) );
|
||||||
pf = t;
|
pf = t;
|
||||||
assert(guard++<100);
|
guard++;
|
||||||
|
assert(guard<100);
|
||||||
} while (pf != &f);
|
} while (pf != &f);
|
||||||
assert (na == n);
|
assert (na == n);
|
||||||
return (after-before);
|
return (after-before);
|
||||||
|
@ -251,8 +252,6 @@ static ScalarType QuadQualityVariationIfVertexRotated(const FaceType &f, int w0)
|
||||||
// rotate arond vertex
|
// rotate arond vertex
|
||||||
const FaceType* pf = &f;
|
const FaceType* pf = &f;
|
||||||
int pi = w0;
|
int pi = w0;
|
||||||
int nb = 0; // vertex valency
|
|
||||||
int na = 0;
|
|
||||||
std::vector<const VertexType *> s; // 1 star around v
|
std::vector<const VertexType *> s; // 1 star around v
|
||||||
do {
|
do {
|
||||||
// ScalarType triEdge = (pf->P0(pi) - pf->P1(pi) ).Norm();
|
// ScalarType triEdge = (pf->P0(pi) - pf->P1(pi) ).Norm();
|
||||||
|
@ -272,7 +271,8 @@ static ScalarType QuadQualityVariationIfVertexRotated(const FaceType &f, int w0)
|
||||||
pi = pf->cFFi( pi );
|
pi = pf->cFFi( pi );
|
||||||
pi = (pi+1)%3; // FaceType::Next( pf->FFi( pi ) );
|
pi = (pi+1)%3; // FaceType::Next( pf->FFi( pi ) );
|
||||||
pf = t;
|
pf = t;
|
||||||
assert(guard++<100);
|
guard++;
|
||||||
|
assert(guard<100);
|
||||||
} while (pf != &f);
|
} while (pf != &f);
|
||||||
|
|
||||||
assert(s.size()%2==0);
|
assert(s.size()%2==0);
|
||||||
|
@ -285,7 +285,6 @@ static ScalarType QuadQualityVariationIfVertexRotated(const FaceType &f, int w0)
|
||||||
after+=quadQuality( s[h]->P(),s[i]->P(),s[j]->P(),f.P(w0) );
|
after+=quadQuality( s[h]->P(),s[i]->P(),s[j]->P(),f.P(w0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (na == nb);
|
|
||||||
return (after-before);
|
return (after-before);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,7 +594,8 @@ static bool IsDoubletFF(const FaceType& f, int wedge){
|
||||||
pi = pf->cFFi( pi );
|
pi = pf->cFFi( pi );
|
||||||
pi = (pi+1)%3; // FaceType::Next( pf->FFi( pi ) );
|
pi = (pi+1)%3; // FaceType::Next( pf->FFi( pi ) );
|
||||||
pf = t;
|
pf = t;
|
||||||
assert(guard++<100);
|
guard++;
|
||||||
|
assert(guard<100);
|
||||||
} while (pf != &f);
|
} while (pf != &f);
|
||||||
return (res == 2);
|
return (res == 2);
|
||||||
}
|
}
|
||||||
|
@ -631,7 +631,8 @@ static bool IsSingletFF(const FaceType& f, int wedge){
|
||||||
pi = pf->cFFi( pi );
|
pi = pf->cFFi( pi );
|
||||||
pi = (pi+1)%3; // FaceType::Next( pf->FFi( pi ) );
|
pi = (pi+1)%3; // FaceType::Next( pf->FFi( pi ) );
|
||||||
pf = t;
|
pf = t;
|
||||||
assert(guard++<100);
|
guard++;
|
||||||
|
assert(guard<100);
|
||||||
} while (pf != &f);
|
} while (pf != &f);
|
||||||
return (res == 1);
|
return (res == 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,38 +113,38 @@ public:
|
||||||
|
|
||||||
static void FillEdgeVector(MeshType &m, std::vector<PEdge> &e, bool includeFauxEdge=true)
|
static void FillEdgeVector(MeshType &m, std::vector<PEdge> &e, bool includeFauxEdge=true)
|
||||||
{
|
{
|
||||||
FaceIterator pf;
|
FaceIterator pf;
|
||||||
typename std::vector<PEdge>::iterator p;
|
typename std::vector<PEdge>::iterator p;
|
||||||
|
|
||||||
// Alloco il vettore ausiliario
|
// Alloco il vettore ausiliario
|
||||||
//e.resize(m.fn*3);
|
//e.resize(m.fn*3);
|
||||||
FaceIterator fi;
|
FaceIterator fi;
|
||||||
int n_edges = 0;
|
int n_edges = 0;
|
||||||
for(fi = m.face.begin(); fi != m.face.end(); ++fi) if(! (*fi).IsD()) n_edges+=(*fi).VN();
|
for(fi = m.face.begin(); fi != m.face.end(); ++fi) if(! (*fi).IsD()) n_edges+=(*fi).VN();
|
||||||
e.resize(n_edges);
|
e.resize(n_edges);
|
||||||
|
|
||||||
p = e.begin();
|
p = e.begin();
|
||||||
for(pf=m.face.begin();pf!=m.face.end();++pf)
|
for(pf=m.face.begin();pf!=m.face.end();++pf)
|
||||||
if( ! (*pf).IsD() )
|
if( ! (*pf).IsD() )
|
||||||
for(int j=0;j<(*pf).VN();++j)
|
for(int j=0;j<(*pf).VN();++j)
|
||||||
if(includeFauxEdge || !(*pf).IsF(j))
|
if(includeFauxEdge || !(*pf).IsF(j))
|
||||||
{
|
{
|
||||||
(*p).Set(&(*pf),j);
|
(*p).Set(&(*pf),j);
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(includeFauxEdge) assert(p==e.end());
|
if(includeFauxEdge) assert(p==e.end());
|
||||||
else e.resize(p-e.begin());
|
else e.resize(p-e.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FillUniqueEdgeVector(MeshType &m, std::vector<PEdge> &Edges, bool includeFauxEdge=true)
|
static void FillUniqueEdgeVector(MeshType &m, std::vector<PEdge> &Edges, bool includeFauxEdge=true)
|
||||||
{
|
{
|
||||||
FillEdgeVector(m,Edges,includeFauxEdge);
|
FillEdgeVector(m,Edges,includeFauxEdge);
|
||||||
sort(Edges.begin(), Edges.end()); // Lo ordino per vertici
|
sort(Edges.begin(), Edges.end()); // Lo ordino per vertici
|
||||||
|
|
||||||
typename std::vector< PEdge>::iterator newEnd = std::unique(Edges.begin(), Edges.end());
|
typename std::vector< PEdge>::iterator newEnd = std::unique(Edges.begin(), Edges.end());
|
||||||
|
|
||||||
Edges.resize(newEnd-Edges.begin());
|
Edges.resize(newEnd-Edges.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief Initialize the edge vector all the edges that can be inferred from current face vector, setting up all the current adjacency relations
|
/*! \brief Initialize the edge vector all the edges that can be inferred from current face vector, setting up all the current adjacency relations
|
||||||
|
@ -365,57 +365,57 @@ static void FaceFaceFromTexCoord(MeshType &m)
|
||||||
if( m.fn == 0 ) return;
|
if( m.fn == 0 ) return;
|
||||||
|
|
||||||
// e.resize(m.fn*3); // Alloco il vettore ausiliario
|
// e.resize(m.fn*3); // Alloco il vettore ausiliario
|
||||||
FaceIterator fi;
|
FaceIterator fi;
|
||||||
int n_edges = 0;
|
int n_edges = 0;
|
||||||
for(fi = m.face.begin(); fi != m.face.end(); ++fi) if(! (*fi).IsD()) n_edges+=(*fi).VN();
|
for(fi = m.face.begin(); fi != m.face.end(); ++fi) if(! (*fi).IsD()) n_edges+=(*fi).VN();
|
||||||
e.resize(n_edges);
|
e.resize(n_edges);
|
||||||
|
|
||||||
p = e.begin();
|
p = e.begin();
|
||||||
for(pf=m.face.begin();pf!=m.face.end();++pf) // Lo riempio con i dati delle facce
|
for(pf=m.face.begin();pf!=m.face.end();++pf) // Lo riempio con i dati delle facce
|
||||||
if( ! (*pf).IsD() )
|
if( ! (*pf).IsD() )
|
||||||
for(int j=0;j<(*pf).VN();++j)
|
for(int j=0;j<(*pf).VN();++j)
|
||||||
{
|
{
|
||||||
if( (*pf).WT(j) != (*pf).WT((*pf).Next(j)))
|
if( (*pf).WT(j) != (*pf).WT((*pf).Next(j)))
|
||||||
{
|
{
|
||||||
(*p).Set(&(*pf),j);
|
(*p).Set(&(*pf),j);
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e.resize(p-e.begin()); // remove from the end of the edge vector the unitiailized ones
|
e.resize(p-e.begin()); // remove from the end of the edge vector the unitiailized ones
|
||||||
//assert(p==e.end()); // this formulation of the assert argument is not really correct, will crash on visual studio
|
//assert(p==e.end()); // this formulation of the assert argument is not really correct, will crash on visual studio
|
||||||
sort(e.begin(), e.end());
|
sort(e.begin(), e.end());
|
||||||
|
|
||||||
int ne = 0; // number of real edges
|
int ne = 0; // number of real edges
|
||||||
typename std::vector<PEdgeTex>::iterator pe,ps;
|
typename std::vector<PEdgeTex>::iterator pe,ps;
|
||||||
ps = e.begin();pe=e.begin();
|
ps = e.begin();pe=e.begin();
|
||||||
//for(ps = e.begin(),pe=e.begin();pe<=e.end();++pe) // Scansione vettore ausiliario
|
//for(ps = e.begin(),pe=e.begin();pe<=e.end();++pe) // Scansione vettore ausiliario
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if( pe==e.end() || (*pe) != (*ps) ) // Trovo blocco di edge uguali
|
if( pe==e.end() || (*pe) != (*ps) ) // Trovo blocco di edge uguali
|
||||||
{
|
{
|
||||||
typename std::vector<PEdgeTex>::iterator q,q_next;
|
typename std::vector<PEdgeTex>::iterator q,q_next;
|
||||||
for (q=ps;q<pe-1;++q) // Scansione facce associate
|
for (q=ps;q<pe-1;++q) // Scansione facce associate
|
||||||
{
|
{
|
||||||
assert((*q).z>=0);
|
assert((*q).z>=0);
|
||||||
assert((*q).z< 3);
|
assert((*q).z< 3);
|
||||||
q_next = q;
|
q_next = q;
|
||||||
++q_next;
|
++q_next;
|
||||||
assert((*q_next).z>=0);
|
assert((*q_next).z>=0);
|
||||||
assert((*q_next).z< (*q_next).f->VN());
|
assert((*q_next).z< (*q_next).f->VN());
|
||||||
(*q).f->FFp(q->z) = (*q_next).f; // Collegamento in lista delle facce
|
(*q).f->FFp(q->z) = (*q_next).f; // Collegamento in lista delle facce
|
||||||
(*q).f->FFi(q->z) = (*q_next).z;
|
(*q).f->FFi(q->z) = (*q_next).z;
|
||||||
}
|
}
|
||||||
assert((*q).z>=0);
|
assert((*q).z>=0);
|
||||||
assert((*q).z< (*q).f->VN());
|
assert((*q).z< (*q).f->VN());
|
||||||
(*q).f->FFp((*q).z) = ps->f;
|
(*q).f->FFp((*q).z) = ps->f;
|
||||||
(*q).f->FFi((*q).z) = ps->z;
|
(*q).f->FFi((*q).z) = ps->z;
|
||||||
ps = pe;
|
ps = pe;
|
||||||
++ne; // Aggiorno il numero di edge
|
++ne; // Aggiorno il numero di edge
|
||||||
}
|
}
|
||||||
if(pe==e.end()) break;
|
if(pe==e.end()) break;
|
||||||
++pe;
|
++pe;
|
||||||
} while(true);
|
} while(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -429,42 +429,40 @@ static void TestVertexFace(MeshType &m)
|
||||||
|
|
||||||
assert(tri::HasPerVertexVFAdjacency(m));
|
assert(tri::HasPerVertexVFAdjacency(m));
|
||||||
|
|
||||||
FaceIterator fi;
|
FaceIterator fi;
|
||||||
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
for(fi=m.face.begin();fi!=m.face.end();++fi)
|
||||||
{
|
{
|
||||||
if (!(*fi).IsD())
|
if (!(*fi).IsD())
|
||||||
{
|
{
|
||||||
numVertex[(*fi).V0(0)]++;
|
numVertex[(*fi).V0(0)]++;
|
||||||
numVertex[(*fi).V1(0)]++;
|
numVertex[(*fi).V1(0)]++;
|
||||||
numVertex[(*fi).V2(0)]++;
|
numVertex[(*fi).V2(0)]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexIterator vi;
|
VertexIterator vi;
|
||||||
vcg::face::VFIterator<FaceType> VFi;
|
vcg::face::VFIterator<FaceType> VFi;
|
||||||
|
|
||||||
for(vi=m.vert.begin();vi!=m.vert.end();++vi)
|
for(vi=m.vert.begin();vi!=m.vert.end();++vi)
|
||||||
{
|
{
|
||||||
if (!vi->IsD())
|
if (!vi->IsD())
|
||||||
if(vi->VFp()!=0) // unreferenced vertices MUST have VF == 0;
|
if(vi->VFp()!=0) // unreferenced vertices MUST have VF == 0;
|
||||||
{
|
{
|
||||||
int num=0;
|
int num=0;
|
||||||
assert(vi->VFp() >= &*m.face.begin());
|
assert(vi->VFp() >= &*m.face.begin());
|
||||||
assert(vi->VFp() <= &m.face.back());
|
assert(vi->VFp() <= &m.face.back());
|
||||||
VFi.f=vi->VFp();
|
VFi.f=vi->VFp();
|
||||||
VFi.z=vi->VFi();
|
VFi.z=vi->VFi();
|
||||||
while (!VFi.End())
|
while (!VFi.End())
|
||||||
{
|
{
|
||||||
num++;
|
num++;
|
||||||
assert(!VFi.F()->IsD());
|
assert(!VFi.F()->IsD());
|
||||||
assert((VFi.F()->V(VFi.I()))==&(*vi));
|
assert((VFi.F()->V(VFi.I()))==&(*vi));
|
||||||
++VFi;
|
++VFi;
|
||||||
}
|
}
|
||||||
int num1=numVertex[&(*vi)];
|
assert(num==numVertex[&(*vi)]);
|
||||||
assert(num==num1);
|
}
|
||||||
/*assert(num>1);*/
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Test correctness of FFtopology (only for 2Manifold Meshes!)
|
/// \brief Test correctness of FFtopology (only for 2Manifold Meshes!)
|
||||||
|
@ -496,8 +494,8 @@ static void TestFaceFace(MeshType &m)
|
||||||
assert( (ffv1i==v0i) || (ffv1i==v1i) );
|
assert( (ffv1i==v0i) || (ffv1i==v1i) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Auxiliairy data structure for computing edge edge adjacency information.
|
/// Auxiliairy data structure for computing edge edge adjacency information.
|
||||||
|
|
|
@ -239,8 +239,9 @@ void FFDetach(FaceType & f, const int e)
|
||||||
{
|
{
|
||||||
assert(FFCorrectness<FaceType>(f,e));
|
assert(FFCorrectness<FaceType>(f,e));
|
||||||
assert(!IsBorder<FaceType>(f,e)); // Never try to detach a border edge!
|
assert(!IsBorder<FaceType>(f,e)); // Never try to detach a border edge!
|
||||||
int complexity;
|
int complexity=ComplexSize(f,e);
|
||||||
assert(complexity=ComplexSize(f,e));
|
(void) complexity;
|
||||||
|
assert(complexity>0);
|
||||||
|
|
||||||
Pos< FaceType > FirstFace(&f,e); // Build the half edge
|
Pos< FaceType > FirstFace(&f,e); // Build the half edge
|
||||||
Pos< FaceType > LastFace(&f,e); // Build the half edge
|
Pos< FaceType > LastFace(&f,e); // Build the half edge
|
||||||
|
@ -343,13 +344,14 @@ void FFSetBorder(FaceType * &f1, int z1)
|
||||||
template <class FaceType>
|
template <class FaceType>
|
||||||
void AssertAdj(FaceType & f)
|
void AssertAdj(FaceType & f)
|
||||||
{
|
{
|
||||||
assert(f.FFp(0)->FFp(f.FFi(0))==&f);
|
(void)f;
|
||||||
assert(f.FFp(1)->FFp(f.FFi(1))==&f);
|
assert(f.FFp(0)->FFp(f.FFi(0))==&f);
|
||||||
assert(f.FFp(2)->FFp(f.FFi(2))==&f);
|
assert(f.FFp(1)->FFp(f.FFi(1))==&f);
|
||||||
|
assert(f.FFp(2)->FFp(f.FFi(2))==&f);
|
||||||
|
|
||||||
assert(f.FFp(0)->FFi(f.FFi(0))==0);
|
assert(f.FFp(0)->FFi(f.FFi(0))==0);
|
||||||
assert(f.FFp(1)->FFi(f.FFi(1))==1);
|
assert(f.FFp(1)->FFi(f.FFi(1))==1);
|
||||||
assert(f.FFp(2)->FFi(f.FFi(2))==2);
|
assert(f.FFp(2)->FFi(f.FFi(2))==2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -435,11 +437,10 @@ void SwapEdge(FaceType &f, const int z)
|
||||||
* Basic link conditions
|
* Basic link conditions
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
template <class MeshType>
|
template <class FaceType>
|
||||||
bool FFLinkCondition(typename MeshType::FaceType &f, const int z)
|
bool FFLinkCondition(FaceType &f, const int z)
|
||||||
{
|
{
|
||||||
typedef typename MeshType::FaceType FaceType;
|
typedef typename FaceType::VertexType VertexType;
|
||||||
typedef typename MeshType::VertexType VertexType;
|
|
||||||
typedef typename vcg::face::Pos< FaceType > PosType;
|
typedef typename vcg::face::Pos< FaceType > PosType;
|
||||||
|
|
||||||
VertexType *v0=f.V0(z);
|
VertexType *v0=f.V0(z);
|
||||||
|
|
|
@ -113,11 +113,11 @@ template <class P3ScalarType> class Point3
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
/// The only data member. Hidden to user.
|
/// The only data member. Hidden to user.
|
||||||
P3ScalarType _v[3];
|
P3ScalarType _v[3];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef P3ScalarType ScalarType;
|
typedef P3ScalarType ScalarType;
|
||||||
enum {Dimension = 3};
|
enum {Dimension = 3};
|
||||||
|
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
|
@ -127,65 +127,65 @@ public:
|
||||||
**/
|
**/
|
||||||
|
|
||||||
inline Point3 () { }
|
inline Point3 () { }
|
||||||
inline Point3 ( const P3ScalarType nx, const P3ScalarType ny, const P3ScalarType nz )
|
inline Point3 ( const P3ScalarType nx, const P3ScalarType ny, const P3ScalarType nz )
|
||||||
{
|
{
|
||||||
_v[0] = nx;
|
_v[0] = nx;
|
||||||
_v[1] = ny;
|
_v[1] = ny;
|
||||||
_v[2] = nz;
|
_v[2] = nz;
|
||||||
}
|
}
|
||||||
inline Point3 ( Point3 const & p )
|
inline Point3 ( Point3 const & p )
|
||||||
{
|
{
|
||||||
_v[0]= p._v[0];
|
_v[0]= p._v[0];
|
||||||
_v[1]= p._v[1];
|
_v[1]= p._v[1];
|
||||||
_v[2]= p._v[2];
|
_v[2]= p._v[2];
|
||||||
}
|
}
|
||||||
inline Point3 ( const P3ScalarType nv[3] )
|
inline Point3 ( const P3ScalarType nv[3] )
|
||||||
{
|
{
|
||||||
_v[0] = nv[0];
|
_v[0] = nv[0];
|
||||||
_v[1] = nv[1];
|
_v[1] = nv[1];
|
||||||
_v[2] = nv[2];
|
_v[2] = nv[2];
|
||||||
}
|
}
|
||||||
inline Point3 & operator =( Point3 const & p )
|
inline Point3 & operator =( Point3 const & p )
|
||||||
{
|
{
|
||||||
_v[0]= p._v[0]; _v[1]= p._v[1]; _v[2]= p._v[2];
|
_v[0]= p._v[0]; _v[1]= p._v[1]; _v[2]= p._v[2];
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline void SetZero()
|
inline void SetZero()
|
||||||
{
|
{
|
||||||
_v[0] = 0;
|
_v[0] = 0;
|
||||||
_v[1] = 0;
|
_v[1] = 0;
|
||||||
_v[2] = 0;
|
_v[2] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Padding function: give a default 0 value to all the elements that are not in the [0..2] range.
|
/// Padding function: give a default 0 value to all the elements that are not in the [0..2] range.
|
||||||
/// Useful for managing in a consistent way object that could have point2 / point3 / point4
|
/// Useful for managing in a consistent way object that could have point2 / point3 / point4
|
||||||
inline P3ScalarType Ext( const int i ) const
|
inline P3ScalarType Ext( const int i ) const
|
||||||
{
|
{
|
||||||
if(i>=0 && i<=2) return _v[i];
|
if(i>=0 && i<=2) return _v[i];
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Q>
|
template <class Q>
|
||||||
inline void Import( const Point3<Q> & b )
|
inline void Import( const Point3<Q> & b )
|
||||||
{
|
{
|
||||||
_v[0] = P3ScalarType(b[0]);
|
_v[0] = P3ScalarType(b[0]);
|
||||||
_v[1] = P3ScalarType(b[1]);
|
_v[1] = P3ScalarType(b[1]);
|
||||||
_v[2] = P3ScalarType(b[2]);
|
_v[2] = P3ScalarType(b[2]);
|
||||||
}
|
}
|
||||||
template <class EigenVector>
|
template <class EigenVector>
|
||||||
inline void FromEigenVector( const EigenVector & b )
|
inline void FromEigenVector( const EigenVector & b )
|
||||||
{
|
{
|
||||||
_v[0] = P3ScalarType(b[0]);
|
_v[0] = P3ScalarType(b[0]);
|
||||||
_v[1] = P3ScalarType(b[1]);
|
_v[1] = P3ScalarType(b[1]);
|
||||||
_v[2] = P3ScalarType(b[2]);
|
_v[2] = P3ScalarType(b[2]);
|
||||||
}
|
}
|
||||||
template <class EigenVector>
|
template <class EigenVector>
|
||||||
inline void ToEigenVector( EigenVector & b ) const
|
inline void ToEigenVector( EigenVector & b ) const
|
||||||
{
|
{
|
||||||
b[0]=_v[0] ;
|
b[0]=_v[0] ;
|
||||||
b[1]=_v[1] ;
|
b[1]=_v[1] ;
|
||||||
b[2]=_v[2] ;
|
b[2]=_v[2] ;
|
||||||
}
|
}
|
||||||
template <class Q>
|
template <class Q>
|
||||||
static inline Point3 Construct( const Point3<Q> & b )
|
static inline Point3 Construct( const Point3<Q> & b )
|
||||||
{
|
{
|
||||||
|
@ -210,40 +210,40 @@ public:
|
||||||
/** @name Data Access.
|
/** @name Data Access.
|
||||||
access to data is done by overloading of [] or explicit naming of coords (x,y,z)**/
|
access to data is done by overloading of [] or explicit naming of coords (x,y,z)**/
|
||||||
|
|
||||||
inline P3ScalarType & operator [] ( const int i )
|
inline P3ScalarType & operator [] ( const int i )
|
||||||
{
|
{
|
||||||
assert(i>=0 && i<3);
|
assert(i>=0 && i<3);
|
||||||
return _v[i];
|
return _v[i];
|
||||||
}
|
}
|
||||||
inline const P3ScalarType & operator [] ( const int i ) const
|
inline const P3ScalarType & operator [] ( const int i ) const
|
||||||
{
|
{
|
||||||
assert(i>=0 && i<3);
|
assert(i>=0 && i<3);
|
||||||
return _v[i];
|
return _v[i];
|
||||||
}
|
}
|
||||||
inline const P3ScalarType &X() const { return _v[0]; }
|
inline const P3ScalarType &X() const { return _v[0]; }
|
||||||
inline const P3ScalarType &Y() const { return _v[1]; }
|
inline const P3ScalarType &Y() const { return _v[1]; }
|
||||||
inline const P3ScalarType &Z() const { return _v[2]; }
|
inline const P3ScalarType &Z() const { return _v[2]; }
|
||||||
inline P3ScalarType &X() { return _v[0]; }
|
inline P3ScalarType &X() { return _v[0]; }
|
||||||
inline P3ScalarType &Y() { return _v[1]; }
|
inline P3ScalarType &Y() { return _v[1]; }
|
||||||
inline P3ScalarType &Z() { return _v[2]; }
|
inline P3ScalarType &Z() { return _v[2]; }
|
||||||
inline const P3ScalarType * V() const
|
inline const P3ScalarType * V() const
|
||||||
{
|
{
|
||||||
return _v;
|
return _v;
|
||||||
}
|
}
|
||||||
inline P3ScalarType * V()
|
inline P3ScalarType * V()
|
||||||
{
|
{
|
||||||
return _v;
|
return _v;
|
||||||
}
|
}
|
||||||
inline P3ScalarType & V( const int i )
|
inline P3ScalarType & V( const int i )
|
||||||
{
|
{
|
||||||
assert(i>=0 && i<3);
|
assert(i>=0 && i<3);
|
||||||
return _v[i];
|
return _v[i];
|
||||||
}
|
}
|
||||||
inline const P3ScalarType & V( const int i ) const
|
inline const P3ScalarType & V( const int i ) const
|
||||||
{
|
{
|
||||||
assert(i>=0 && i<3);
|
assert(i>=0 && i<3);
|
||||||
return _v[i];
|
return _v[i];
|
||||||
}
|
}
|
||||||
//@}
|
//@}
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
|
@ -251,136 +251,136 @@ public:
|
||||||
Note
|
Note
|
||||||
**/
|
**/
|
||||||
|
|
||||||
inline Point3 operator + ( Point3 const & p) const
|
inline Point3 operator + ( Point3 const & p) const
|
||||||
{
|
{
|
||||||
return Point3<P3ScalarType>( _v[0]+p._v[0], _v[1]+p._v[1], _v[2]+p._v[2] );
|
return Point3<P3ScalarType>( _v[0]+p._v[0], _v[1]+p._v[1], _v[2]+p._v[2] );
|
||||||
}
|
}
|
||||||
inline Point3 operator - ( Point3 const & p) const
|
inline Point3 operator - ( Point3 const & p) const
|
||||||
{
|
{
|
||||||
return Point3<P3ScalarType>( _v[0]-p._v[0], _v[1]-p._v[1], _v[2]-p._v[2] );
|
return Point3<P3ScalarType>( _v[0]-p._v[0], _v[1]-p._v[1], _v[2]-p._v[2] );
|
||||||
}
|
}
|
||||||
inline Point3 operator * ( const P3ScalarType s ) const
|
inline Point3 operator * ( const P3ScalarType s ) const
|
||||||
{
|
{
|
||||||
return Point3<P3ScalarType>( _v[0]*s, _v[1]*s, _v[2]*s );
|
return Point3<P3ScalarType>( _v[0]*s, _v[1]*s, _v[2]*s );
|
||||||
}
|
}
|
||||||
inline Point3 operator / ( const P3ScalarType s ) const
|
inline Point3 operator / ( const P3ScalarType s ) const
|
||||||
{
|
{
|
||||||
return Point3<P3ScalarType>( _v[0]/s, _v[1]/s, _v[2]/s );
|
return Point3<P3ScalarType>( _v[0]/s, _v[1]/s, _v[2]/s );
|
||||||
}
|
}
|
||||||
/// Dot product
|
/// Dot product
|
||||||
inline P3ScalarType operator * ( Point3 const & p ) const
|
inline P3ScalarType operator * ( Point3 const & p ) const
|
||||||
{
|
{
|
||||||
return ( _v[0]*p._v[0] + _v[1]*p._v[1] + _v[2]*p._v[2] );
|
return ( _v[0]*p._v[0] + _v[1]*p._v[1] + _v[2]*p._v[2] );
|
||||||
}
|
}
|
||||||
inline P3ScalarType dot( const Point3 & p ) const { return (*this) * p; }
|
inline P3ScalarType dot( const Point3 & p ) const { return (*this) * p; }
|
||||||
/// Cross product
|
/// Cross product
|
||||||
inline Point3 operator ^ ( Point3 const & p ) const
|
inline Point3 operator ^ ( Point3 const & p ) const
|
||||||
{
|
{
|
||||||
return Point3 <P3ScalarType>
|
return Point3 <P3ScalarType>
|
||||||
(
|
(
|
||||||
_v[1]*p._v[2] - _v[2]*p._v[1],
|
_v[1]*p._v[2] - _v[2]*p._v[1],
|
||||||
_v[2]*p._v[0] - _v[0]*p._v[2],
|
_v[2]*p._v[0] - _v[0]*p._v[2],
|
||||||
_v[0]*p._v[1] - _v[1]*p._v[0]
|
_v[0]*p._v[1] - _v[1]*p._v[0]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Point3 & operator += ( Point3 const & p)
|
inline Point3 & operator += ( Point3 const & p)
|
||||||
{
|
{
|
||||||
_v[0] += p._v[0];
|
_v[0] += p._v[0];
|
||||||
_v[1] += p._v[1];
|
_v[1] += p._v[1];
|
||||||
_v[2] += p._v[2];
|
_v[2] += p._v[2];
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline Point3 & operator -= ( Point3 const & p)
|
inline Point3 & operator -= ( Point3 const & p)
|
||||||
{
|
{
|
||||||
_v[0] -= p._v[0];
|
_v[0] -= p._v[0];
|
||||||
_v[1] -= p._v[1];
|
_v[1] -= p._v[1];
|
||||||
_v[2] -= p._v[2];
|
_v[2] -= p._v[2];
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline Point3 & operator *= ( const P3ScalarType s )
|
inline Point3 & operator *= ( const P3ScalarType s )
|
||||||
{
|
{
|
||||||
_v[0] *= s;
|
_v[0] *= s;
|
||||||
_v[1] *= s;
|
_v[1] *= s;
|
||||||
_v[2] *= s;
|
_v[2] *= s;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline Point3 & operator /= ( const P3ScalarType s )
|
inline Point3 & operator /= ( const P3ScalarType s )
|
||||||
{
|
{
|
||||||
_v[0] /= s;
|
_v[0] /= s;
|
||||||
_v[1] /= s;
|
_v[1] /= s;
|
||||||
_v[2] /= s;
|
_v[2] /= s;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
// Norme
|
// Norme
|
||||||
inline P3ScalarType Norm() const
|
inline P3ScalarType Norm() const
|
||||||
{
|
{
|
||||||
return math::Sqrt( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] );
|
return math::Sqrt( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] );
|
||||||
}
|
}
|
||||||
inline P3ScalarType SquaredNorm() const
|
inline P3ScalarType SquaredNorm() const
|
||||||
{
|
{
|
||||||
return ( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] );
|
return ( _v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2] );
|
||||||
}
|
}
|
||||||
// Scalatura differenziata
|
// Scalatura differenziata
|
||||||
inline Point3 & Scale( const P3ScalarType sx, const P3ScalarType sy, const P3ScalarType sz )
|
inline Point3 & Scale( const P3ScalarType sx, const P3ScalarType sy, const P3ScalarType sz )
|
||||||
{
|
{
|
||||||
_v[0] *= sx;
|
_v[0] *= sx;
|
||||||
_v[1] *= sy;
|
_v[1] *= sy;
|
||||||
_v[2] *= sz;
|
_v[2] *= sz;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline Point3 & Scale( const Point3 & p )
|
inline Point3 & Scale( const Point3 & p )
|
||||||
{
|
{
|
||||||
_v[0] *= p._v[0];
|
_v[0] *= p._v[0];
|
||||||
_v[1] *= p._v[1];
|
_v[1] *= p._v[1];
|
||||||
_v[2] *= p._v[2];
|
_v[2] *= p._v[2];
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalizzazione
|
// Normalizzazione
|
||||||
inline Point3 & Normalize()
|
inline Point3 & Normalize()
|
||||||
{
|
{
|
||||||
P3ScalarType n = P3ScalarType(math::Sqrt(_v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2]));
|
P3ScalarType n = P3ScalarType(math::Sqrt(_v[0]*_v[0] + _v[1]*_v[1] + _v[2]*_v[2]));
|
||||||
if (n > P3ScalarType(0)) { _v[0] /= n; _v[1] /= n; _v[2] /= n; }
|
if (n > P3ScalarType(0)) { _v[0] /= n; _v[1] /= n; _v[2] /= n; }
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// for compatibility with eigen port
|
// for compatibility with eigen port
|
||||||
inline Point3 & normalized() { return Normalize(); }
|
inline Point3 & normalized() { return Normalize(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert to polar coordinates from cartesian coordinates.
|
* Convert to polar coordinates from cartesian coordinates.
|
||||||
*
|
*
|
||||||
* Theta is the azimuth angle and ranges between [0, 2PI) degrees.
|
* Theta is the azimuth angle and ranges between [0, 2PI) degrees.
|
||||||
* Phi is the elevation angle (not the polar angle) and ranges between [-PI/2, PI/2] degrees.
|
* Phi is the elevation angle (not the polar angle) and ranges between [-PI/2, PI/2] degrees.
|
||||||
*
|
*
|
||||||
* /note Note that instead of the classical polar angle, which ranges between
|
* /note Note that instead of the classical polar angle, which ranges between
|
||||||
* 0 and PI degrees we opt for the elevation angle to obtain a more
|
* 0 and PI degrees we opt for the elevation angle to obtain a more
|
||||||
* intuitive spherical coordinate system.
|
* intuitive spherical coordinate system.
|
||||||
*/
|
*/
|
||||||
void ToPolarRad(P3ScalarType &ro, P3ScalarType &theta, P3ScalarType &phi) const
|
void ToPolarRad(P3ScalarType &ro, P3ScalarType &theta, P3ScalarType &phi) const
|
||||||
{
|
{
|
||||||
ro = Norm();
|
ro = Norm();
|
||||||
theta = (P3ScalarType)atan2(_v[2], _v[0]);
|
theta = (P3ScalarType)atan2(_v[2], _v[0]);
|
||||||
phi = (P3ScalarType)asin(_v[1]/ro);
|
phi = (P3ScalarType)asin(_v[1]/ro);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert from polar coordinates to cartesian coordinates.
|
* Convert from polar coordinates to cartesian coordinates.
|
||||||
*
|
*
|
||||||
* Theta is the azimuth angle and ranges between [0, 2PI) radians.
|
* Theta is the azimuth angle and ranges between [0, 2PI) radians.
|
||||||
* Phi is the elevation angle (not the polar angle) and ranges between [-PI/2, PI/2] radians.
|
* Phi is the elevation angle (not the polar angle) and ranges between [-PI/2, PI/2] radians.
|
||||||
*
|
*
|
||||||
* \note Note that instead of the classical polar angle, which ranges between
|
* \note Note that instead of the classical polar angle, which ranges between
|
||||||
* 0 and PI degrees, we opt for the elevation angle to obtain a more
|
* 0 and PI degrees, we opt for the elevation angle to obtain a more
|
||||||
* intuitive spherical coordinate system.
|
* intuitive spherical coordinate system.
|
||||||
*/
|
*/
|
||||||
void FromPolarRad(const P3ScalarType &ro, const P3ScalarType &theta, const P3ScalarType &phi)
|
void FromPolarRad(const P3ScalarType &ro, const P3ScalarType &theta, const P3ScalarType &phi)
|
||||||
{
|
{
|
||||||
_v[0]= ro*cos(theta)*cos(phi);
|
_v[0]= ro*cos(theta)*cos(phi);
|
||||||
_v[1]= ro*sin(phi);
|
_v[1]= ro*sin(phi);
|
||||||
_v[2]= ro*sin(theta)*cos(phi);
|
_v[2]= ro*sin(theta)*cos(phi);
|
||||||
}
|
}
|
||||||
|
|
||||||
Box3<P3ScalarType> GetBBox(Box3<P3ScalarType> &bb) const;
|
Box3<P3ScalarType> GetBBox(Box3<P3ScalarType> &bb) const;
|
||||||
//@}
|
//@}
|
||||||
|
@ -391,43 +391,43 @@ public:
|
||||||
**/
|
**/
|
||||||
|
|
||||||
inline bool operator == ( Point3 const & p ) const
|
inline bool operator == ( Point3 const & p ) const
|
||||||
{
|
{
|
||||||
return _v[0]==p._v[0] && _v[1]==p._v[1] && _v[2]==p._v[2];
|
return _v[0]==p._v[0] && _v[1]==p._v[1] && _v[2]==p._v[2];
|
||||||
}
|
}
|
||||||
inline bool operator != ( Point3 const & p ) const
|
inline bool operator != ( Point3 const & p ) const
|
||||||
{
|
{
|
||||||
return _v[0]!=p._v[0] || _v[1]!=p._v[1] || _v[2]!=p._v[2];
|
return _v[0]!=p._v[0] || _v[1]!=p._v[1] || _v[2]!=p._v[2];
|
||||||
}
|
}
|
||||||
inline bool operator < ( Point3 const & p ) const
|
inline bool operator < ( Point3 const & p ) const
|
||||||
{
|
{
|
||||||
return (_v[2]!=p._v[2])?(_v[2]<p._v[2]):
|
return (_v[2]!=p._v[2])?(_v[2]<p._v[2]):
|
||||||
(_v[1]!=p._v[1])?(_v[1]<p._v[1]):
|
(_v[1]!=p._v[1])?(_v[1]<p._v[1]):
|
||||||
(_v[0]<p._v[0]);
|
(_v[0]<p._v[0]);
|
||||||
}
|
}
|
||||||
inline bool operator > ( Point3 const & p ) const
|
inline bool operator > ( Point3 const & p ) const
|
||||||
{
|
{
|
||||||
return (_v[2]!=p._v[2])?(_v[2]>p._v[2]):
|
return (_v[2]!=p._v[2])?(_v[2]>p._v[2]):
|
||||||
(_v[1]!=p._v[1])?(_v[1]>p._v[1]):
|
(_v[1]!=p._v[1])?(_v[1]>p._v[1]):
|
||||||
(_v[0]>p._v[0]);
|
(_v[0]>p._v[0]);
|
||||||
}
|
}
|
||||||
inline bool operator <= ( Point3 const & p ) const
|
inline bool operator <= ( Point3 const & p ) const
|
||||||
{
|
{
|
||||||
return (_v[2]!=p._v[2])?(_v[2]< p._v[2]):
|
return (_v[2]!=p._v[2])?(_v[2]< p._v[2]):
|
||||||
(_v[1]!=p._v[1])?(_v[1]< p._v[1]):
|
(_v[1]!=p._v[1])?(_v[1]< p._v[1]):
|
||||||
(_v[0]<=p._v[0]);
|
(_v[0]<=p._v[0]);
|
||||||
}
|
}
|
||||||
inline bool operator >= ( Point3 const & p ) const
|
inline bool operator >= ( Point3 const & p ) const
|
||||||
{
|
{
|
||||||
return (_v[2]!=p._v[2])?(_v[2]> p._v[2]):
|
return (_v[2]!=p._v[2])?(_v[2]> p._v[2]):
|
||||||
(_v[1]!=p._v[1])?(_v[1]> p._v[1]):
|
(_v[1]!=p._v[1])?(_v[1]> p._v[1]):
|
||||||
(_v[0]>=p._v[0]);
|
(_v[0]>=p._v[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Point3 operator - () const
|
inline Point3 operator - () const
|
||||||
{
|
{
|
||||||
return Point3<P3ScalarType> ( -_v[0], -_v[1], -_v[2] );
|
return Point3<P3ScalarType> ( -_v[0], -_v[1], -_v[2] );
|
||||||
}
|
}
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
}; // end class definition
|
}; // end class definition
|
||||||
|
@ -436,11 +436,11 @@ inline bool operator == ( Point3 const & p ) const
|
||||||
template <class P3ScalarType>
|
template <class P3ScalarType>
|
||||||
inline P3ScalarType Angle( Point3<P3ScalarType> const & p1, Point3<P3ScalarType> const & p2 )
|
inline P3ScalarType Angle( Point3<P3ScalarType> const & p1, Point3<P3ScalarType> const & p2 )
|
||||||
{
|
{
|
||||||
P3ScalarType w = p1.Norm()*p2.Norm();
|
P3ScalarType w = p1.Norm()*p2.Norm();
|
||||||
if(w==0) return -1;
|
if(w==0) return -1;
|
||||||
P3ScalarType t = (p1*p2)/w;
|
P3ScalarType t = (p1*p2)/w;
|
||||||
if(t>1) t = 1;
|
if(t>1) t = 1;
|
||||||
else if(t<-1) t = -1;
|
else if(t<-1) t = -1;
|
||||||
return (P3ScalarType) acos(t);
|
return (P3ScalarType) acos(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,11 +448,11 @@ inline P3ScalarType Angle( Point3<P3ScalarType> const & p1, Point3<P3ScalarType>
|
||||||
template <class P3ScalarType>
|
template <class P3ScalarType>
|
||||||
inline P3ScalarType AngleN( Point3<P3ScalarType> const & p1, Point3<P3ScalarType> const & p2 )
|
inline P3ScalarType AngleN( Point3<P3ScalarType> const & p1, Point3<P3ScalarType> const & p2 )
|
||||||
{
|
{
|
||||||
P3ScalarType w = p1*p2;
|
P3ScalarType w = p1*p2;
|
||||||
if(w>1)
|
if(w>1)
|
||||||
w = 1;
|
w = 1;
|
||||||
else if(w<-1)
|
else if(w<-1)
|
||||||
w=-1;
|
w=-1;
|
||||||
return (P3ScalarType) acos(w);
|
return (P3ScalarType) acos(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ inline P3ScalarType AngleN( Point3<P3ScalarType> const & p1, Point3<P3ScalarType
|
||||||
template <class P3ScalarType>
|
template <class P3ScalarType>
|
||||||
inline P3ScalarType Norm( Point3<P3ScalarType> const & p )
|
inline P3ScalarType Norm( Point3<P3ScalarType> const & p )
|
||||||
{
|
{
|
||||||
return p.Norm();
|
return p.Norm();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P3ScalarType>
|
template <class P3ScalarType>
|
||||||
|
@ -503,36 +503,36 @@ P3ScalarType ApproximateGeodesicDistance(const Point3<P3ScalarType>& p0, const P
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Dot product preciso numericamente (solo double!!)
|
// Dot product preciso numericamente (solo double!!)
|
||||||
// Implementazione: si sommano i prodotti per ordine di esponente
|
// Implementazione: si sommano i prodotti per ordine di esponente
|
||||||
// (prima le piu' grandi)
|
// (prima le piu' grandi)
|
||||||
template<class P3ScalarType>
|
template<class P3ScalarType>
|
||||||
double stable_dot ( Point3<P3ScalarType> const & p0, Point3<P3ScalarType> const & p1 )
|
double stable_dot ( Point3<P3ScalarType> const & p0, Point3<P3ScalarType> const & p1 )
|
||||||
{
|
{
|
||||||
P3ScalarType k0 = p0._v[0]*p1._v[0];
|
P3ScalarType k0 = p0._v[0]*p1._v[0];
|
||||||
P3ScalarType k1 = p0._v[1]*p1._v[1];
|
P3ScalarType k1 = p0._v[1]*p1._v[1];
|
||||||
P3ScalarType k2 = p0._v[2]*p1._v[2];
|
P3ScalarType k2 = p0._v[2]*p1._v[2];
|
||||||
|
|
||||||
int exp0,exp1,exp2;
|
int exp0,exp1,exp2;
|
||||||
|
|
||||||
frexp( double(k0), &exp0 );
|
frexp( double(k0), &exp0 );
|
||||||
frexp( double(k1), &exp1 );
|
frexp( double(k1), &exp1 );
|
||||||
frexp( double(k2), &exp2 );
|
frexp( double(k2), &exp2 );
|
||||||
|
|
||||||
if( exp0<exp1 )
|
if( exp0<exp1 )
|
||||||
{
|
{
|
||||||
if(exp0<exp2)
|
if(exp0<exp2)
|
||||||
return (k1+k2)+k0;
|
return (k1+k2)+k0;
|
||||||
else
|
else
|
||||||
return (k0+k1)+k2;
|
return (k0+k1)+k2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(exp1<exp2)
|
if(exp1<exp2)
|
||||||
return(k0+k2)+k1;
|
return(k0+k2)+k1;
|
||||||
else
|
else
|
||||||
return (k0+k1)+k2;
|
return (k0+k1)+k2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -540,15 +540,15 @@ double stable_dot ( Point3<P3ScalarType> const & p0, Point3<P3ScalarType> const
|
||||||
/// Point(p) Edge(v1-v2) dist, q is the point in v1-v2 with min dist
|
/// Point(p) Edge(v1-v2) dist, q is the point in v1-v2 with min dist
|
||||||
template<class P3ScalarType>
|
template<class P3ScalarType>
|
||||||
P3ScalarType PSDist( const Point3<P3ScalarType> & p,
|
P3ScalarType PSDist( const Point3<P3ScalarType> & p,
|
||||||
const Point3<P3ScalarType> & v1,
|
const Point3<P3ScalarType> & v1,
|
||||||
const Point3<P3ScalarType> & v2,
|
const Point3<P3ScalarType> & v2,
|
||||||
Point3<P3ScalarType> & q )
|
Point3<P3ScalarType> & q )
|
||||||
{
|
{
|
||||||
Point3<P3ScalarType> e = v2-v1;
|
Point3<P3ScalarType> e = v2-v1;
|
||||||
P3ScalarType t = ((p-v1)*e)/e.SquaredNorm();
|
P3ScalarType t = ((p-v1)*e)/e.SquaredNorm();
|
||||||
if(t<0) t = 0;
|
if(t<0) t = 0;
|
||||||
else if(t>1) t = 1;
|
else if(t>1) t = 1;
|
||||||
q = v1+e*t;
|
q = v1+e*t;
|
||||||
return Distance(p,q);
|
return Distance(p,q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,31 +556,30 @@ P3ScalarType PSDist( const Point3<P3ScalarType> & p,
|
||||||
template <class P3ScalarType>
|
template <class P3ScalarType>
|
||||||
void GetUV( Point3<P3ScalarType> &n,Point3<P3ScalarType> &u, Point3<P3ScalarType> &v, Point3<P3ScalarType> up=(Point3<P3ScalarType>(0,1,0)) )
|
void GetUV( Point3<P3ScalarType> &n,Point3<P3ScalarType> &u, Point3<P3ScalarType> &v, Point3<P3ScalarType> up=(Point3<P3ScalarType>(0,1,0)) )
|
||||||
{
|
{
|
||||||
n.Normalize();
|
n.Normalize();
|
||||||
const double LocEps=double(1e-7);
|
const double LocEps=double(1e-7);
|
||||||
u=n^up;
|
u=n^up;
|
||||||
double len = u.Norm();
|
double len = u.Norm();
|
||||||
if(len < LocEps)
|
if(len < LocEps)
|
||||||
{
|
{
|
||||||
if(fabs(n[0])<fabs(n[1])){
|
if(fabs(n[0])<fabs(n[1])){
|
||||||
if(fabs(n[0])<fabs(n[2])) up=Point3<P3ScalarType>(1,0,0); // x is the min
|
if(fabs(n[0])<fabs(n[2])) up=Point3<P3ScalarType>(1,0,0); // x is the min
|
||||||
else up=Point3<P3ScalarType>(0,0,1); // z is the min
|
else up=Point3<P3ScalarType>(0,0,1); // z is the min
|
||||||
}else {
|
}else {
|
||||||
if(fabs(n[1])<fabs(n[2])) up=Point3<P3ScalarType>(0,1,0); // y is the min
|
if(fabs(n[1])<fabs(n[2])) up=Point3<P3ScalarType>(0,1,0); // y is the min
|
||||||
else up=Point3<P3ScalarType>(0,0,1); // z is the min
|
else up=Point3<P3ScalarType>(0,0,1); // z is the min
|
||||||
}
|
}
|
||||||
u=n^up;
|
u=n^up;
|
||||||
}
|
}
|
||||||
u.Normalize();
|
u.Normalize();
|
||||||
v=n^u;
|
v=n^u;
|
||||||
v.Normalize();
|
v.Normalize();
|
||||||
Point3<P3ScalarType> uv=u^v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class SCALARTYPE>
|
template <class SCALARTYPE>
|
||||||
inline Point3<SCALARTYPE> Abs(const Point3<SCALARTYPE> & p) {
|
inline Point3<SCALARTYPE> Abs(const Point3<SCALARTYPE> & p) {
|
||||||
return (Point3<SCALARTYPE>(math::Abs(p[0]), math::Abs(p[1]), math::Abs(p[2])));
|
return (Point3<SCALARTYPE>(math::Abs(p[0]), math::Abs(p[1]), math::Abs(p[2])));
|
||||||
}
|
}
|
||||||
// probably a more uniform naming should be defined...
|
// probably a more uniform naming should be defined...
|
||||||
template <class SCALARTYPE>
|
template <class SCALARTYPE>
|
||||||
|
|
|
@ -19,17 +19,6 @@
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
* for more details. *
|
* for more details. *
|
||||||
* *
|
* *
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
History
|
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
|
||||||
Revision 1.1 2007/02/14 01:20:37 ganovelli
|
|
||||||
working draft of VCG Mesh Image importer and exporter. Does not consider optional attributes. The mesh atributes are only vn and fn (no bbox, texture coordiantes)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __VCGLIB_EXPORT_VMI
|
#ifndef __VCGLIB_EXPORT_VMI
|
||||||
|
@ -37,35 +26,29 @@
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
VMI VCG Mesh Image.
|
VMI VCG Mesh Image.
|
||||||
The vmi image file consists of a header containing the description of the vertex and face type,
|
The vmi image file consists of a header containing the description of the vertex and face type,
|
||||||
the length of vectors containing vertices of faces and the memory image of the object mesh as it is when
|
the length of vectors containing vertices of faces and the memory image of the object mesh as it is when
|
||||||
passed to the function Save(SaveMeshType m).
|
passed to the function Save(SaveMeshType m).
|
||||||
NOTE: THIS IS NOT A FILE FORMAT. IT IS ONLY USEFUL FOR DUMPING MESH IMAGES FOR DEBUG PURPOSE.
|
NOTE: THIS IS NOT A FILE FORMAT. IT IS ONLY USEFUL FOR DUMPING MESH IMAGES FOR DEBUG PURPOSE.
|
||||||
Example of use: say you are running a time consuming mesh processing and you want to save intermediate
|
Example of use: say you are running a time consuming mesh processing and you want to save intermediate
|
||||||
state, but no file format support all the attributes you need in your vertex/face type.
|
state, but no file format support all the attributes you need in your vertex/face type.
|
||||||
NOTE2: At the present if you add members to your TriMesh these will NOT be saved. More precisely, this file and
|
NOTE2: At the present if you add members to your TriMesh these will NOT be saved. More precisely, this file and
|
||||||
import_vmi must be updated to reflect changes in vcg/complex/trimesh/base.h
|
import_vmi must be updated to reflect changes in vcg/complex/trimesh/base.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <vcg/complex/complex.h>
|
#include <vcg/complex/complex.h>
|
||||||
//#include <vcg/simplex/face/component.h>
|
|
||||||
//#include <vcg/simplex/face/component_ocf.h>
|
|
||||||
//#include <vcg/simplex/vertex/component.h>
|
|
||||||
//#include <vcg/simplex/vertex/component_ocf.h>
|
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
namespace tri {
|
namespace tri {
|
||||||
namespace io {
|
namespace io {
|
||||||
|
|
||||||
template <int N> struct PlaceHolderType{ char A[N];};
|
template <int N> struct PlaceHolderType{ char A[N];};
|
||||||
|
|
||||||
|
|
||||||
|
template <class SaveMeshType>
|
||||||
|
class ExporterVMI
|
||||||
template <class SaveMeshType>
|
{
|
||||||
class ExporterVMI
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
static char * & Out_mem(){static char * out_mem; return out_mem;}
|
static char * & Out_mem(){static char * out_mem; return out_mem;}
|
||||||
|
@ -83,178 +66,180 @@ namespace io {
|
||||||
case 1: return fwrite_mem(src, size,count); break;
|
case 1: return fwrite_mem(src, size,count); break;
|
||||||
case 2: return fwrite(src, size,count, F() ); break;
|
case 2: return fwrite(src, size,count, F() ); break;
|
||||||
}
|
}
|
||||||
|
assert(0);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void WriteString( const char * in) { unsigned int l = strlen(in); WriteOut(&l,4,1 ); WriteOut(in,1,l );}
|
static void WriteString( const char * in) { unsigned int l = strlen(in); WriteOut(&l,4,1 ); WriteOut(in,1,l );}
|
||||||
static void WriteInt (const unsigned int i) { WriteOut(&i,1,4 );}
|
static void WriteInt (const unsigned int i) { WriteOut(&i,1,4 );}
|
||||||
|
|
||||||
static void WriteFloat( const float v) { WriteOut(&v,1,sizeof(float) );}
|
static void WriteFloat( const float v) { WriteOut(&v,1,sizeof(float) );}
|
||||||
|
|
||||||
/* save Ocf Vertex Components */
|
/* save Ocf Vertex Components */
|
||||||
template <typename OpenMeshType,typename CONT>
|
template <typename OpenMeshType,typename CONT>
|
||||||
struct SaveVertexOcf{
|
struct SaveVertexOcf{
|
||||||
SaveVertexOcf( const CONT & /*vert*/, bool only_header){
|
SaveVertexOcf( const CONT & /*vert*/, bool only_header){
|
||||||
// do nothing, it is a std::vector
|
// do nothing, it is a std::vector
|
||||||
if(only_header){
|
if(only_header){
|
||||||
WriteString( "NOT_HAS_VERTEX_QUALITY_OCF");
|
WriteString( "NOT_HAS_VERTEX_QUALITY_OCF");
|
||||||
WriteString( "NOT_HAS_VERTEX_COLOR_OCF");
|
WriteString( "NOT_HAS_VERTEX_COLOR_OCF");
|
||||||
WriteString( "NOT_HAS_VERTEX_NORMAL_OCF");
|
WriteString( "NOT_HAS_VERTEX_NORMAL_OCF");
|
||||||
WriteString( "NOT_HAS_VERTEX_MARK_OCF");
|
WriteString( "NOT_HAS_VERTEX_MARK_OCF");
|
||||||
WriteString( "NOT_HAS_VERTEX_TEXCOORD_OCF");
|
WriteString( "NOT_HAS_VERTEX_TEXCOORD_OCF");
|
||||||
WriteString( "NOT_HAS_VERTEX_VFADJACENCY_OCF");
|
WriteString( "NOT_HAS_VERTEX_VFADJACENCY_OCF");
|
||||||
WriteString( "NOT_HAS_VERTEX_CURVATURE_OCF");
|
WriteString( "NOT_HAS_VERTEX_CURVATURE_OCF");
|
||||||
WriteString( "NOT_HAS_VERTEX_CURVATUREDIR_OCF");
|
WriteString( "NOT_HAS_VERTEX_CURVATUREDIR_OCF");
|
||||||
WriteString( "NOT_HAS_VERTEX_RADIUS_OCF");
|
WriteString( "NOT_HAS_VERTEX_RADIUS_OCF");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* partial specialization for vector_ocf */
|
/* partial specialization for vector_ocf */
|
||||||
template <typename MeshType>
|
template <typename MeshType>
|
||||||
struct SaveVertexOcf<MeshType, vertex::vector_ocf<typename MeshType::VertexType> >{
|
struct SaveVertexOcf<MeshType, vertex::vector_ocf<typename MeshType::VertexType> >{
|
||||||
typedef typename MeshType::VertexType VertexType;
|
typedef typename MeshType::VertexType VertexType;
|
||||||
SaveVertexOcf( const vertex::vector_ocf<VertexType> & vert, bool only_header){
|
SaveVertexOcf( const vertex::vector_ocf<VertexType> & vert, bool only_header){
|
||||||
|
|
||||||
if( VertexType::HasQualityOcf() && vert.IsQualityEnabled()){
|
if( VertexType::HasQualityOcf() && vert.IsQualityEnabled()){
|
||||||
WriteString( "HAS_VERTEX_QUALITY_OCF");
|
WriteString( "HAS_VERTEX_QUALITY_OCF");
|
||||||
if(!only_header) WriteOut(&vert.QV[0],sizeof(typename VertexType::QualityType),vert.size() );
|
if(!only_header) WriteOut(&vert.QV[0],sizeof(typename VertexType::QualityType),vert.size() );
|
||||||
}else WriteString( "NOT_HAS_VERTEX_QUALITY_OCF");
|
}else WriteString( "NOT_HAS_VERTEX_QUALITY_OCF");
|
||||||
|
|
||||||
if( VertexType::HasColorOcf() && vert.IsColorEnabled()){
|
if( VertexType::HasColorOcf() && vert.IsColorEnabled()){
|
||||||
WriteString( "HAS_VERTEX_COLOR_OCF");
|
WriteString( "HAS_VERTEX_COLOR_OCF");
|
||||||
if(!only_header) WriteOut(&vert.CV[0],sizeof(typename VertexType::ColorType),vert.size() );
|
if(!only_header) WriteOut(&vert.CV[0],sizeof(typename VertexType::ColorType),vert.size() );
|
||||||
}else WriteString( "NOT_HAS_VERTEX_COLOR_OCF");
|
}else WriteString( "NOT_HAS_VERTEX_COLOR_OCF");
|
||||||
|
|
||||||
if( VertexType::HasNormalOcf() && vert.IsNormalEnabled()){
|
if( VertexType::HasNormalOcf() && vert.IsNormalEnabled()){
|
||||||
WriteString( "HAS_VERTEX_NORMAL_OCF");
|
WriteString( "HAS_VERTEX_NORMAL_OCF");
|
||||||
if(!only_header) WriteOut(&vert.NV[0],sizeof(typename VertexType::NormalType),vert.size() );
|
if(!only_header) WriteOut(&vert.NV[0],sizeof(typename VertexType::NormalType),vert.size() );
|
||||||
}else WriteString( "NOT_HAS_VERTEX_NORMAL_OCF");
|
}else WriteString( "NOT_HAS_VERTEX_NORMAL_OCF");
|
||||||
|
|
||||||
if( VertexType::HasMarkOcf() && vert.IsMarkEnabled()){
|
if( VertexType::HasMarkOcf() && vert.IsMarkEnabled()){
|
||||||
WriteString( "HAS_VERTEX_MARK_OCF");
|
WriteString( "HAS_VERTEX_MARK_OCF");
|
||||||
if(!only_header) WriteOut(&vert.MV[0],sizeof(typename VertexType::MarkType),vert.size() );
|
if(!only_header) WriteOut(&vert.MV[0],sizeof(typename VertexType::MarkType),vert.size() );
|
||||||
}else WriteString( "NOT_HAS_VERTEX_MARK_OCF");
|
}else WriteString( "NOT_HAS_VERTEX_MARK_OCF");
|
||||||
|
|
||||||
if( VertexType::HasTexCoordOcf() && vert.IsTexCoordEnabled()){
|
if( VertexType::HasTexCoordOcf() && vert.IsTexCoordEnabled()){
|
||||||
WriteString( "HAS_VERTEX_TEXCOORD_OCF");
|
WriteString( "HAS_VERTEX_TEXCOORD_OCF");
|
||||||
if(!only_header) WriteOut(&vert.TV[0],sizeof(typename VertexType::TexCoordType),vert.size() );
|
if(!only_header) WriteOut(&vert.TV[0],sizeof(typename VertexType::TexCoordType),vert.size() );
|
||||||
}else WriteString( "NOT_HAS_VERTEX_TEXCOORD_OCF");
|
}else WriteString( "NOT_HAS_VERTEX_TEXCOORD_OCF");
|
||||||
|
|
||||||
if( VertexType::HasVFAdjacencyOcf() && vert.IsVFAdjacencyEnabled()){
|
if( VertexType::HasVFAdjacencyOcf() && vert.IsVFAdjacencyEnabled()){
|
||||||
WriteString( "HAS_VERTEX_VFADJACENCY_OCF");
|
WriteString( "HAS_VERTEX_VFADJACENCY_OCF");
|
||||||
if(!only_header) WriteOut(&vert.AV[0],sizeof(typename vertex::vector_ocf<VertexType>::VFAdjType),vert.size() );
|
if(!only_header) WriteOut(&vert.AV[0],sizeof(typename vertex::vector_ocf<VertexType>::VFAdjType),vert.size() );
|
||||||
}else WriteString( "NOT_HAS_VERTEX_VFADJACENCY_OCF");
|
}else WriteString( "NOT_HAS_VERTEX_VFADJACENCY_OCF");
|
||||||
|
|
||||||
if( VertexType::HasCurvatureOcf() && vert.IsCurvatureEnabled()){
|
if( VertexType::HasCurvatureOcf() && vert.IsCurvatureEnabled()){
|
||||||
WriteString( "HAS_VERTEX_CURVATURE_OCF");
|
WriteString( "HAS_VERTEX_CURVATURE_OCF");
|
||||||
if(!only_header) WriteOut(&vert.CuV[0],sizeof(typename VertexType::CurvatureType),vert.size() );
|
if(!only_header) WriteOut(&vert.CuV[0],sizeof(typename VertexType::CurvatureType),vert.size() );
|
||||||
}else WriteString( "NOT_HAS_VERTEX_CURVATURE_OCF");
|
}else WriteString( "NOT_HAS_VERTEX_CURVATURE_OCF");
|
||||||
|
|
||||||
if( VertexType::HasCurvatureDirOcf() && vert.IsCurvatureDirEnabled()){
|
if( VertexType::HasCurvatureDirOcf() && vert.IsCurvatureDirEnabled()){
|
||||||
WriteString( "HAS_VERTEX_CURVATUREDIR_OCF");
|
WriteString( "HAS_VERTEX_CURVATUREDIR_OCF");
|
||||||
if(!only_header) WriteOut(&vert.CuDV[0],sizeof(typename VertexType::CurvatureDirType),vert.size() );
|
if(!only_header) WriteOut(&vert.CuDV[0],sizeof(typename VertexType::CurvatureDirType),vert.size() );
|
||||||
}else WriteString( "NOT_HAS_VERTEX_CURVATUREDIR_OCF");
|
}else WriteString( "NOT_HAS_VERTEX_CURVATUREDIR_OCF");
|
||||||
|
|
||||||
if( VertexType::HasRadiusOcf() && vert.IsRadiusEnabled()){
|
if( VertexType::HasRadiusOcf() && vert.IsRadiusEnabled()){
|
||||||
WriteString( "HAS_VERTEX_RADIUS_OCF");
|
WriteString( "HAS_VERTEX_RADIUS_OCF");
|
||||||
if(!only_header) WriteOut(&vert.RadiusV[0],sizeof(typename VertexType::RadiusType),vert.size() );
|
if(!only_header) WriteOut(&vert.RadiusV[0],sizeof(typename VertexType::RadiusType),vert.size() );
|
||||||
}else WriteString( "NOT_HAS_VERTEX_RADIUS_OCF");
|
}else WriteString( "NOT_HAS_VERTEX_RADIUS_OCF");
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* save Ocf Face Components */
|
/* save Ocf Face Components */
|
||||||
template <typename MeshType,typename CONT>
|
template <typename MeshType,typename CONT>
|
||||||
struct SaveFaceOcf{
|
struct SaveFaceOcf{
|
||||||
SaveFaceOcf( const CONT & /*face*/, bool only_header){
|
SaveFaceOcf( const CONT & /*face*/, bool only_header){
|
||||||
// it is a std::vector
|
// it is a std::vector
|
||||||
if(only_header){
|
if(only_header){
|
||||||
WriteString( "NOT_HAS_FACE_QUALITY_OCF");
|
WriteString( "NOT_HAS_FACE_QUALITY_OCF");
|
||||||
WriteString( "NOT_HAS_FACE_COLOR_OCF");
|
WriteString( "NOT_HAS_FACE_COLOR_OCF");
|
||||||
WriteString( "NOT_HAS_FACE_NORMAL_OCF");
|
WriteString( "NOT_HAS_FACE_NORMAL_OCF");
|
||||||
WriteString( "NOT_HAS_FACE_MARK_OCF");
|
WriteString( "NOT_HAS_FACE_MARK_OCF");
|
||||||
WriteString( "NOT_HAS_FACE_WEDGETEXCOORD_OCF");
|
WriteString( "NOT_HAS_FACE_WEDGETEXCOORD_OCF");
|
||||||
WriteString( "NOT_HAS_FACE_FFADJACENCY_OCF");
|
WriteString( "NOT_HAS_FACE_FFADJACENCY_OCF");
|
||||||
WriteString( "NOT_HAS_FACE_VFADJACENCY_OCF");
|
WriteString( "NOT_HAS_FACE_VFADJACENCY_OCF");
|
||||||
WriteString( "NOT_HAS_FACE_WEDGECOLOR_OCF");
|
WriteString( "NOT_HAS_FACE_WEDGECOLOR_OCF");
|
||||||
WriteString( "NOT_HAS_FACE_WEDGENORMAL_OCF");
|
WriteString( "NOT_HAS_FACE_WEDGENORMAL_OCF");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* partial specialization for vector_ocf */
|
/* partial specialization for vector_ocf */
|
||||||
template <typename MeshType>
|
template <typename MeshType>
|
||||||
struct SaveFaceOcf< MeshType, face::vector_ocf<typename MeshType::FaceType> >{
|
struct SaveFaceOcf< MeshType, face::vector_ocf<typename MeshType::FaceType> >{
|
||||||
typedef typename MeshType::FaceType FaceType;
|
typedef typename MeshType::FaceType FaceType;
|
||||||
SaveFaceOcf( const face::vector_ocf<FaceType> & face, bool only_header){
|
SaveFaceOcf( const face::vector_ocf<FaceType> & face, bool only_header){
|
||||||
|
|
||||||
if( FaceType::HasQualityOcf() && face.IsQualityEnabled()){
|
if( FaceType::HasQualityOcf() && face.IsQualityEnabled()){
|
||||||
WriteString( "HAS_FACE_QUALITY_OCF");
|
WriteString( "HAS_FACE_QUALITY_OCF");
|
||||||
if(!only_header) WriteOut(&face.QV[0],sizeof(typename FaceType::QualityType),face.size() );
|
if(!only_header) WriteOut(&face.QV[0],sizeof(typename FaceType::QualityType),face.size() );
|
||||||
}else WriteString( "NOT_HAS_FACE_QUALITY_OCF");
|
}else WriteString( "NOT_HAS_FACE_QUALITY_OCF");
|
||||||
|
|
||||||
if( FaceType::HasColorOcf() && face.IsColorEnabled()){
|
if( FaceType::HasColorOcf() && face.IsColorEnabled()){
|
||||||
WriteString( "HAS_FACE_COLOR_OCF");
|
WriteString( "HAS_FACE_COLOR_OCF");
|
||||||
if(!only_header) WriteOut(&face.CV[0],sizeof(typename FaceType::ColorType),face.size() );
|
if(!only_header) WriteOut(&face.CV[0],sizeof(typename FaceType::ColorType),face.size() );
|
||||||
}else WriteString( "NOT_HAS_FACE_COLOR_OCF");
|
}else WriteString( "NOT_HAS_FACE_COLOR_OCF");
|
||||||
|
|
||||||
if( FaceType::HasNormalOcf() && face.IsNormalEnabled()){
|
if( FaceType::HasNormalOcf() && face.IsNormalEnabled()){
|
||||||
WriteString( "HAS_FACE_NORMAL_OCF");
|
WriteString( "HAS_FACE_NORMAL_OCF");
|
||||||
if(!only_header) WriteOut(&face.NV[0],sizeof(typename FaceType::NormalType),face.size() );
|
if(!only_header) WriteOut(&face.NV[0],sizeof(typename FaceType::NormalType),face.size() );
|
||||||
}else WriteString( "NOT_HAS_FACE_NORMAL_OCF");
|
}else WriteString( "NOT_HAS_FACE_NORMAL_OCF");
|
||||||
|
|
||||||
if( FaceType::HasMarkOcf() && face.IsMarkEnabled()){
|
if( FaceType::HasMarkOcf() && face.IsMarkEnabled()){
|
||||||
WriteString( "HAS_FACE_MARK_OCF");
|
WriteString( "HAS_FACE_MARK_OCF");
|
||||||
if(!only_header) WriteOut(&face.MV[0],sizeof(typename FaceType::MarkType),face.size() );
|
if(!only_header) WriteOut(&face.MV[0],sizeof(typename FaceType::MarkType),face.size() );
|
||||||
}else WriteString( "NOT_HAS_FACE_MARK_OCF");
|
}else WriteString( "NOT_HAS_FACE_MARK_OCF");
|
||||||
|
|
||||||
if( FaceType::HasWedgeTexCoordOcf() && face.IsWedgeTexCoordEnabled()){
|
if( FaceType::HasWedgeTexCoordOcf() && face.IsWedgeTexCoordEnabled()){
|
||||||
WriteString( "HAS_FACE_WEDGETEXCOORD_OCF");
|
WriteString( "HAS_FACE_WEDGETEXCOORD_OCF");
|
||||||
if(!only_header) WriteOut(&face.WTV[0],sizeof(typename FaceType::WedgeTexCoordType),face.size() );
|
if(!only_header) WriteOut(&face.WTV[0],sizeof(typename FaceType::WedgeTexCoordType),face.size() );
|
||||||
}else WriteString( "NOT_HAS_FACE_WEDGETEXCOORD_OCF");
|
}else WriteString( "NOT_HAS_FACE_WEDGETEXCOORD_OCF");
|
||||||
|
|
||||||
if( FaceType::HasFFAdjacencyOcf() && face.IsFFAdjacencyEnabled()){
|
if( FaceType::HasFFAdjacencyOcf() && face.IsFFAdjacencyEnabled()){
|
||||||
WriteString( "HAS_FACE_FFADJACENCY_OCF");
|
WriteString( "HAS_FACE_FFADJACENCY_OCF");
|
||||||
if(!only_header) WriteOut(&face.AF[0],sizeof(typename face::vector_ocf<FaceType>::AdjTypePack),face.size() );
|
if(!only_header) WriteOut(&face.AF[0],sizeof(typename face::vector_ocf<FaceType>::AdjTypePack),face.size() );
|
||||||
}else WriteString( "NOT_HAS_FACE_FFADJACENCY_OCF");
|
}else WriteString( "NOT_HAS_FACE_FFADJACENCY_OCF");
|
||||||
|
|
||||||
if( FaceType::HasVFAdjacencyOcf() && face.IsVFAdjacencyEnabled()){
|
if( FaceType::HasVFAdjacencyOcf() && face.IsVFAdjacencyEnabled()){
|
||||||
WriteString( "HAS_FACE_VFADJACENCY_OCF");
|
WriteString( "HAS_FACE_VFADJACENCY_OCF");
|
||||||
if(!only_header) WriteOut(&face.AV[0],sizeof(typename face::vector_ocf<FaceType>::AdjTypePack),face.size() );
|
if(!only_header) WriteOut(&face.AV[0],sizeof(typename face::vector_ocf<FaceType>::AdjTypePack),face.size() );
|
||||||
}else WriteString( "NOT_HAS_FACE_VFADJACENCY_OCF");
|
}else WriteString( "NOT_HAS_FACE_VFADJACENCY_OCF");
|
||||||
|
|
||||||
if( FaceType::HasWedgeColorOcf() && face.IsWedgeColorEnabled()){
|
if( FaceType::HasWedgeColorOcf() && face.IsWedgeColorEnabled()){
|
||||||
WriteString( "HAS_FACE_WEDGECOLOR_OCF");
|
WriteString( "HAS_FACE_WEDGECOLOR_OCF");
|
||||||
if(!only_header) WriteOut(&face.WCV[0],sizeof(typename face::vector_ocf<FaceType>::WedgeColorTypePack),face.size() );
|
if(!only_header) WriteOut(&face.WCV[0],sizeof(typename face::vector_ocf<FaceType>::WedgeColorTypePack),face.size() );
|
||||||
}else WriteString( "NOT_HAS_FACE_WEDGECOLOR_OCF");
|
}else WriteString( "NOT_HAS_FACE_WEDGECOLOR_OCF");
|
||||||
|
|
||||||
if( FaceType::HasWedgeNormalOcf() && face.IsWedgeNormalEnabled()){
|
if( FaceType::HasWedgeNormalOcf() && face.IsWedgeNormalEnabled()){
|
||||||
WriteString( "HAS_FACE_WEDGENORMAL_OCF");
|
WriteString( "HAS_FACE_WEDGENORMAL_OCF");
|
||||||
if(!only_header) WriteOut(&face.WNV[0],sizeof(typename face::vector_ocf<FaceType>::WedgeNormalTypePack),face.size() );
|
if(!only_header) WriteOut(&face.WNV[0],sizeof(typename face::vector_ocf<FaceType>::WedgeNormalTypePack),face.size() );
|
||||||
}else WriteString( "NOT_HAS_FACE_WEDGENORMAL_OCF");
|
}else WriteString( "NOT_HAS_FACE_WEDGENORMAL_OCF");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static FILE *& F(){static FILE * f; return f;}
|
static FILE *& F(){static FILE * f; return f;}
|
||||||
|
|
||||||
typedef typename SaveMeshType::FaceContainer FaceContainer;
|
typedef typename SaveMeshType::FaceContainer FaceContainer;
|
||||||
typedef typename SaveMeshType::FaceIterator FaceIterator;
|
typedef typename SaveMeshType::FaceIterator FaceIterator;
|
||||||
typedef typename SaveMeshType::VertContainer VertContainer;
|
typedef typename SaveMeshType::VertContainer VertContainer;
|
||||||
typedef typename SaveMeshType::VertexIterator VertexIterator;
|
typedef typename SaveMeshType::VertexIterator VertexIterator;
|
||||||
typedef typename SaveMeshType::VertexType VertexType;
|
typedef typename SaveMeshType::VertexType VertexType;
|
||||||
typedef typename SaveMeshType::FaceType FaceType;
|
typedef typename SaveMeshType::FaceType FaceType;
|
||||||
typedef SimpleTempDataBase STDBv;
|
typedef SimpleTempDataBase STDBv;
|
||||||
typedef SimpleTempDataBase STDBf;
|
typedef SimpleTempDataBase STDBf;
|
||||||
// typedef typename SaveMeshType::Attribute <SaveMeshType::FaceContainer> STDBm;
|
// typedef typename SaveMeshType::Attribute <SaveMeshType::FaceContainer> STDBm;
|
||||||
|
|
||||||
/* save Ocf Components */
|
/* save Ocf Components */
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static int Save(const SaveMeshType &m,const char * filename){
|
static int Save(const SaveMeshType &m,const char * filename){
|
||||||
Out_mode() = 2;
|
Out_mode() = 2;
|
||||||
|
@ -279,53 +264,53 @@ namespace io {
|
||||||
|
|
||||||
|
|
||||||
static int Serialize(const SaveMeshType &m){
|
static int Serialize(const SaveMeshType &m){
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int vertSize,faceSize;
|
unsigned int vertSize,faceSize;
|
||||||
std::vector<std::string> nameF,nameV;
|
std::vector<std::string> nameF,nameV;
|
||||||
SaveMeshType::FaceType::Name(nameF);
|
SaveMeshType::FaceType::Name(nameF);
|
||||||
SaveMeshType::VertexType::Name(nameV);
|
SaveMeshType::VertexType::Name(nameV);
|
||||||
vertSize = m.vert.size();
|
vertSize = m.vert.size();
|
||||||
faceSize = m.face.size();
|
faceSize = m.face.size();
|
||||||
|
|
||||||
/* write header */
|
/* write header */
|
||||||
WriteString( "FACE_TYPE");
|
WriteString( "FACE_TYPE");
|
||||||
WriteInt( nameF.size());
|
WriteInt( nameF.size());
|
||||||
|
|
||||||
for(i=0; i < nameF.size(); ++i) WriteString( nameF[i].c_str());
|
for(i=0; i < nameF.size(); ++i) WriteString( nameF[i].c_str());
|
||||||
SaveFaceOcf<SaveMeshType,FaceContainer>( m.face,true);
|
SaveFaceOcf<SaveMeshType,FaceContainer>( m.face,true);
|
||||||
WriteString( "SIZE_VECTOR_FACES");
|
WriteString( "SIZE_VECTOR_FACES");
|
||||||
WriteInt( faceSize );
|
WriteInt( faceSize );
|
||||||
|
|
||||||
WriteString( "VERTEX_TYPE");
|
WriteString( "VERTEX_TYPE");
|
||||||
WriteInt( nameV.size());
|
WriteInt( nameV.size());
|
||||||
|
|
||||||
for(i=0; i < nameV.size(); ++i) WriteString( nameV[i].c_str());
|
for(i=0; i < nameV.size(); ++i) WriteString( nameV[i].c_str());
|
||||||
SaveVertexOcf<SaveMeshType,VertContainer>( m.vert,true);
|
SaveVertexOcf<SaveMeshType,VertContainer>( m.vert,true);
|
||||||
|
|
||||||
WriteString( "SIZE_VECTOR_VERTS");
|
WriteString( "SIZE_VECTOR_VERTS");
|
||||||
WriteInt( vertSize);
|
WriteInt( vertSize);
|
||||||
|
|
||||||
WriteString( "BOUNDING_BOX");
|
WriteString( "BOUNDING_BOX");
|
||||||
float float_value;
|
float float_value;
|
||||||
for(unsigned int i =0; i < 2; ++i){float_value = m.bbox.min[i]; WriteFloat( float_value);}
|
for(unsigned int i =0; i < 2; ++i){float_value = m.bbox.min[i]; WriteFloat( float_value);}
|
||||||
for(unsigned int i =0; i < 2; ++i){float_value = m.bbox.max[i]; WriteFloat( float_value);}
|
for(unsigned int i =0; i < 2; ++i){float_value = m.bbox.max[i]; WriteFloat( float_value);}
|
||||||
|
|
||||||
WriteString( "end_header");
|
WriteString( "end_header");
|
||||||
/* end header */
|
/* end header */
|
||||||
|
|
||||||
if(vertSize!=0){
|
if(vertSize!=0){
|
||||||
void * offsetV = (void*) &m.vert[0];
|
void * offsetV = (void*) &m.vert[0];
|
||||||
/* write the address of the first vertex */
|
/* write the address of the first vertex */
|
||||||
WriteOut(&offsetV,sizeof(void *),1 );
|
WriteOut(&offsetV,sizeof(void *),1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if(faceSize!=0){
|
if(faceSize!=0){
|
||||||
void * offsetF= (void*)&m.face[0];
|
void * offsetF= (void*)&m.face[0];
|
||||||
/* write the address of the first face */
|
/* write the address of the first face */
|
||||||
WriteOut(&offsetF,sizeof( void *),1 );
|
WriteOut(&offsetF,sizeof( void *),1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save the object mesh */
|
/* save the object mesh */
|
||||||
WriteOut(&m.shot,sizeof(Shot<typename SaveMeshType::ScalarType>),1 );
|
WriteOut(&m.shot,sizeof(Shot<typename SaveMeshType::ScalarType>),1 );
|
||||||
WriteOut(&m.vn,sizeof(int),1 );
|
WriteOut(&m.vn,sizeof(int),1 );
|
||||||
WriteOut(&m.fn,sizeof(int),1 );
|
WriteOut(&m.fn,sizeof(int),1 );
|
||||||
|
@ -333,99 +318,99 @@ namespace io {
|
||||||
WriteOut(&m.bbox,sizeof(Box3<typename SaveMeshType::ScalarType>),1 );
|
WriteOut(&m.bbox,sizeof(Box3<typename SaveMeshType::ScalarType>),1 );
|
||||||
WriteOut(&m.C(),sizeof(Color4b),1 );
|
WriteOut(&m.C(),sizeof(Color4b),1 );
|
||||||
|
|
||||||
unsigned int written;
|
unsigned int written;
|
||||||
|
|
||||||
|
|
||||||
if(vertSize!=0){
|
if(vertSize!=0){
|
||||||
/* save the vertices */
|
/* save the vertices */
|
||||||
written = WriteOut((void*)&m.vert[0],sizeof(typename SaveMeshType::VertexType),m.vert.size() );
|
written = WriteOut((void*)&m.vert[0],sizeof(typename SaveMeshType::VertexType),m.vert.size() );
|
||||||
SaveVertexOcf<SaveMeshType,VertContainer>( m.vert,false);
|
SaveVertexOcf<SaveMeshType,VertContainer>( m.vert,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(faceSize!=0){
|
if(faceSize!=0){
|
||||||
/* save the faces */
|
/* save the faces */
|
||||||
written = WriteOut((void*)&m.face[0],sizeof(typename SaveMeshType::FaceType),faceSize );
|
written = WriteOut((void*)&m.face[0],sizeof(typename SaveMeshType::FaceType),faceSize );
|
||||||
SaveFaceOcf<SaveMeshType,FaceContainer>( m.face,false);
|
SaveFaceOcf<SaveMeshType,FaceContainer>( m.face,false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* save the attributes */
|
/* save the attributes */
|
||||||
typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai;
|
typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai;
|
||||||
|
|
||||||
|
|
||||||
/* save the per vertex attributes */
|
/* save the per vertex attributes */
|
||||||
{
|
{
|
||||||
typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai;
|
typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai;
|
||||||
unsigned int n_named_attr = 0;
|
unsigned int n_named_attr = 0;
|
||||||
for(ai = m.vert_attr.begin(); ai != m.vert_attr.end(); ++ai) n_named_attr+=!(*ai)._name.empty();
|
for(ai = m.vert_attr.begin(); ai != m.vert_attr.end(); ++ai) n_named_attr+=!(*ai)._name.empty();
|
||||||
|
|
||||||
WriteString( "N_PER_VERTEX_ATTRIBUTES"); WriteInt ( n_named_attr);
|
WriteString( "N_PER_VERTEX_ATTRIBUTES"); WriteInt ( n_named_attr);
|
||||||
for(ai = m.vert_attr.begin(); ai != m.vert_attr.end(); ++ai)
|
for(ai = m.vert_attr.begin(); ai != m.vert_attr.end(); ++ai)
|
||||||
if(!(*ai)._name.empty())
|
if(!(*ai)._name.empty())
|
||||||
{
|
{
|
||||||
STDBv * stdb = (STDBv *) (*ai)._handle;
|
STDBv * stdb = (STDBv *) (*ai)._handle;
|
||||||
|
|
||||||
WriteString( "PER_VERTEX_ATTR_NAME");
|
WriteString( "PER_VERTEX_ATTR_NAME");
|
||||||
WriteString( (*ai)._name.c_str() );
|
WriteString( (*ai)._name.c_str() );
|
||||||
|
|
||||||
WriteString( "PER_VERTEX_ATTR_SIZE");
|
WriteString( "PER_VERTEX_ATTR_SIZE");
|
||||||
WriteInt( stdb->SizeOf());
|
WriteInt( stdb->SizeOf());
|
||||||
|
|
||||||
WriteOut(stdb->DataBegin(),m.vert.size(),stdb->SizeOf() );
|
WriteOut(stdb->DataBegin(),m.vert.size(),stdb->SizeOf() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save the per face attributes */
|
/* save the per face attributes */
|
||||||
{
|
{
|
||||||
typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai;
|
typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai;
|
||||||
unsigned int n_named_attr = 0;
|
unsigned int n_named_attr = 0;
|
||||||
for(ai = m.face_attr.begin(); ai != m.face_attr.end(); ++ai) n_named_attr+=!(*ai)._name.empty();
|
for(ai = m.face_attr.begin(); ai != m.face_attr.end(); ++ai) n_named_attr+=!(*ai)._name.empty();
|
||||||
|
|
||||||
WriteString( "N_PER_FACE_ATTRIBUTES");
|
WriteString( "N_PER_FACE_ATTRIBUTES");
|
||||||
WriteInt ( n_named_attr);
|
WriteInt ( n_named_attr);
|
||||||
|
|
||||||
for(ai = m.face_attr.begin(); ai != m.face_attr.end(); ++ai)
|
for(ai = m.face_attr.begin(); ai != m.face_attr.end(); ++ai)
|
||||||
if(!(*ai)._name.empty())
|
if(!(*ai)._name.empty())
|
||||||
{
|
{
|
||||||
STDBf * stdb = (STDBf *) (*ai)._handle;
|
STDBf * stdb = (STDBf *) (*ai)._handle;
|
||||||
|
|
||||||
WriteString( "PER_FACE_ATTR_NAME");
|
WriteString( "PER_FACE_ATTR_NAME");
|
||||||
WriteString( (*ai)._name.c_str());
|
WriteString( (*ai)._name.c_str());
|
||||||
|
|
||||||
WriteString( "PER_FACE_ATTR_SIZE");
|
WriteString( "PER_FACE_ATTR_SIZE");
|
||||||
WriteInt( stdb->SizeOf());
|
WriteInt( stdb->SizeOf());
|
||||||
|
|
||||||
WriteOut(stdb->DataBegin(),m.face.size(),stdb->SizeOf() );
|
WriteOut(stdb->DataBegin(),m.face.size(),stdb->SizeOf() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///* save the per mesh attributes */
|
///* save the per mesh attributes */
|
||||||
{
|
{
|
||||||
typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai;
|
typename std::set< typename SaveMeshType::PointerToAttribute>::const_iterator ai;
|
||||||
unsigned int n_named_attr = 0;
|
unsigned int n_named_attr = 0;
|
||||||
for(ai = m.mesh_attr.begin(); ai != m.mesh_attr.end(); ++ai) n_named_attr+=!(*ai)._name.empty();
|
for(ai = m.mesh_attr.begin(); ai != m.mesh_attr.end(); ++ai) n_named_attr+=!(*ai)._name.empty();
|
||||||
WriteString( "N_PER_MESH_ATTRIBUTES"); WriteInt( n_named_attr);
|
WriteString( "N_PER_MESH_ATTRIBUTES"); WriteInt( n_named_attr);
|
||||||
for(ai = m.mesh_attr.begin(); ai != m.mesh_attr.end(); ++ai)
|
for(ai = m.mesh_attr.begin(); ai != m.mesh_attr.end(); ++ai)
|
||||||
if(!(*ai)._name.empty())
|
if(!(*ai)._name.empty())
|
||||||
{
|
{
|
||||||
SimpleTempDataBase * handle = (SimpleTempDataBase *) (*ai)._handle ;
|
SimpleTempDataBase * handle = (SimpleTempDataBase *) (*ai)._handle ;
|
||||||
|
|
||||||
WriteString( "PER_MESH_ATTR_NAME");
|
WriteString( "PER_MESH_ATTR_NAME");
|
||||||
WriteString( (*ai)._name.c_str());
|
WriteString( (*ai)._name.c_str());
|
||||||
|
|
||||||
WriteString( "PER_MESH_ATTR_SIZE");
|
WriteString( "PER_MESH_ATTR_SIZE");
|
||||||
WriteInt( handle->SizeOf());
|
WriteInt( handle->SizeOf());
|
||||||
|
|
||||||
WriteOut(handle->DataBegin(),1,handle->SizeOf() );
|
WriteOut(handle->DataBegin(),1,handle->SizeOf() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fflush(F());
|
// fflush(F());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static const char *ErrorMsg(int error)
|
static const char *ErrorMsg(int error)
|
||||||
{
|
{
|
||||||
static std::vector<std::string> off_error_msg;
|
static std::vector<std::string> off_error_msg;
|
||||||
|
@ -439,7 +424,7 @@ namespace io {
|
||||||
if(error>1 || error<0) return "Unknown error";
|
if(error>1 || error<0) return "Unknown error";
|
||||||
else return off_error_msg[error].c_str();
|
else return off_error_msg[error].c_str();
|
||||||
}
|
}
|
||||||
}; // end class
|
}; // end class
|
||||||
|
|
||||||
} // end Namespace tri
|
} // end Namespace tri
|
||||||
} // end Namespace io
|
} // end Namespace io
|
||||||
|
|
|
@ -128,6 +128,7 @@ namespace io {
|
||||||
m.vert_attr.erase(res);
|
m.vert_attr.erase(res);
|
||||||
pa._padding = padd;
|
pa._padding = padd;
|
||||||
std::pair<HWIte,bool > new_pa = m.vert_attr.insert(pa);
|
std::pair<HWIte,bool > new_pa = m.vert_attr.insert(pa);
|
||||||
|
(void)new_pa;
|
||||||
assert(new_pa.second);
|
assert(new_pa.second);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -155,6 +156,7 @@ namespace io {
|
||||||
m.face_attr.erase(res);
|
m.face_attr.erase(res);
|
||||||
pa._padding = padd;
|
pa._padding = padd;
|
||||||
std::pair<HWIte,bool > new_pa = m.face_attr.insert(pa);
|
std::pair<HWIte,bool > new_pa = m.face_attr.insert(pa);
|
||||||
|
(void)new_pa;
|
||||||
assert(new_pa.second);
|
assert(new_pa.second);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -180,6 +182,7 @@ namespace io {
|
||||||
m.mesh_attr.erase(res);
|
m.mesh_attr.erase(res);
|
||||||
pa._padding = padd;
|
pa._padding = padd;
|
||||||
std::pair<HWIte,bool > new_pa = m.mesh_attr.insert(pa);
|
std::pair<HWIte,bool > new_pa = m.mesh_attr.insert(pa);
|
||||||
|
(void)new_pa;
|
||||||
assert(new_pa.second);
|
assert(new_pa.second);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue