added HasPerVertexVFAdjacency and HasPerFaceVFAdjacency. Removed

generic HasVFAdjacency which made the logical AND of the two and updated the 
relative calls.
This commit is contained in:
ganovelli 2010-06-24 12:35:37 +00:00
parent a42f07b445
commit eb3f1a97fc
11 changed files with 47 additions and 105 deletions

View File

@ -477,7 +477,7 @@ namespace vcg {
for(int i = 0; i < (*fi).VN(); ++i) for(int i = 0; i < (*fi).VN(); ++i)
if ((*fi).cFFp(i)!=0) pu.Update((*fi).FFp(i)); if ((*fi).cFFp(i)!=0) pu.Update((*fi).FFp(i));
if(HasVFAdjacency(m)) if(HasPerVertexVFAdjacency(m) && HasPerFaceVFAdjacency(m))
for(int i = 0; i < (*fi).VN(); ++i) for(int i = 0; i < (*fi).VN(); ++i)
if ((*fi).cVFp(i)!=0) pu.Update((*fi).VFp(i)); if ((*fi).cVFp(i)!=0) pu.Update((*fi).VFp(i));
++ii; ++ii;
@ -488,7 +488,7 @@ namespace vcg {
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(HasVFAdjacency(m)) if(HasPerVertexVFAdjacency(m) && HasPerFaceVFAdjacency(m))
if ((*vi).cVFp()!=0) if ((*vi).cVFp()!=0)
pu.Update((FaceType * &)(*vi).VFp()); pu.Update((FaceType * &)(*vi).VFp());
// Note the above cast is probably not useful if you have correctly defined // Note the above cast is probably not useful if you have correctly defined
@ -586,7 +586,7 @@ namespace vcg {
{ {
assert(!m.vert[i].IsD()); assert(!m.vert[i].IsD());
m.vert[ newVertIndex[i] ].ImportData(m.vert[i]); m.vert[ newVertIndex[i] ].ImportData(m.vert[i]);
if(HasVFAdjacency(m)) if(HasPerVertexVFAdjacency(m) &&HasPerFaceVFAdjacency(m) )
if (m.vert[i].cVFp()!=0) if (m.vert[i].cVFp()!=0)
{ {
m.vert[ newVertIndex[i] ].VFp() = m.vert[i].cVFp(); m.vert[ newVertIndex[i] ].VFp() = m.vert[i].cVFp();
@ -675,7 +675,7 @@ namespace vcg {
m.face[pos].V(0) = m.face[i].V(0); m.face[pos].V(0) = m.face[i].V(0);
m.face[pos].V(1) = m.face[i].V(1); m.face[pos].V(1) = m.face[i].V(1);
m.face[pos].V(2) = m.face[i].V(2); m.face[pos].V(2) = m.face[i].V(2);
if(HasVFAdjacency(m)) if(HasPerVertexVFAdjacency(m) && HasPerFaceVFAdjacency(m))
for(int j=0;j<3;++j) for(int j=0;j<3;++j)
if (m.face[i].cVFp(j)!=0) { if (m.face[i].cVFp(j)!=0) {
m.face[pos].VFp(j) = m.face[i].cVFp(j); m.face[pos].VFp(j) = m.face[i].cVFp(j);
@ -707,7 +707,7 @@ namespace vcg {
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(HasVFAdjacency(m)) if(HasPerVertexVFAdjacency(m) &&HasPerFaceVFAdjacency(m) )
if ((*vi).cVFp()!=0) if ((*vi).cVFp()!=0)
{ {
size_t oldIndex = (*vi).cVFp() - fbase; size_t oldIndex = (*vi).cVFp() - fbase;
@ -725,7 +725,7 @@ namespace vcg {
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())
{ {
if(HasVFAdjacency(m)) if(HasPerVertexVFAdjacency(m) &&HasPerFaceVFAdjacency(m) )
for(i=0;i<3;++i) for(i=0;i<3;++i)
if ((*fi).cVFp(i)!=0) if ((*fi).cVFp(i)!=0)
{ {

View File

@ -73,7 +73,9 @@ public:
} }
// Vertex to Face Adj // Vertex to Face Adj
if(vcg::tri::HasVFAdjacency(ml) && vcg::tri::HasVFAdjacency(mr)){ if(vcg::tri::HasPerVertexVFAdjacency(ml) && vcg::tri::HasPerVertexVFAdjacency(mr) &&
vcg::tri::HasPerFaceVFAdjacency(ml) && vcg::tri::HasPerFaceVFAdjacency(mr)
){
size_t i = Index(mr,vr.cVFp()); size_t i = Index(mr,vr.cVFp());
vl.VFp() = (i>ml.face.size())? 0 :&ml.face[remap.face[i]]; vl.VFp() = (i>ml.face.size())? 0 :&ml.face[remap.face[i]];
vl.VFi() = vr.VFi(); vl.VFi() = vr.VFi();
@ -120,14 +122,14 @@ public:
// Face to Vertex Adj // Face to Vertex Adj
if(vcg::tri::HasFVAdjacency(ml) && vcg::tri::HasFVAdjacency(mr)){ if(vcg::tri::HasFVAdjacency(ml) && vcg::tri::HasFVAdjacency(mr)){
assert(fl.VN() == fr.VN()); assert(fl.VN() == fr.VN());
for(unsigned int i = 0; i < fl.VN(); ++i ) for( int i = 0; i < fl.VN(); ++i )
fl.V(i) = &ml.vert[remap.vert[Index(mr,fr.V(i))]]; fl.V(i) = &ml.vert[remap.vert[Index(mr,fr.V(i))]];
} }
// Face to Edge Adj // Face to Edge Adj
if(vcg::tri::HasFEAdjacency(ml) && vcg::tri::HasFEAdjacency(mr)){ if(vcg::tri::HasFEAdjacency(ml) && vcg::tri::HasFEAdjacency(mr)){
assert(fl.VN() == fr.VN()); assert(fl.VN() == fr.VN());
for(unsigned int vi = 0; vi < fl.VN(); ++vi ){ for( int vi = 0; vi < fl.VN(); ++vi ){
size_t i = Index(mr,fr.cFEp(vi)); size_t i = Index(mr,fr.cFEp(vi));
fl.FEp(i) = (i>ml.edge.size())? 0 : &ml.edge[remap.edge[i]]; fl.FEp(i) = (i>ml.edge.size())? 0 : &ml.edge[remap.edge[i]];
} }
@ -136,10 +138,10 @@ public:
// Face to Face Adj // Face to Face Adj
if(vcg::tri::HasFFAdjacency(ml) && vcg::tri::HasFFAdjacency(mr)){ if(vcg::tri::HasFFAdjacency(ml) && vcg::tri::HasFFAdjacency(mr)){
assert(fl.VN() == fr.VN()); assert(fl.VN() == fr.VN());
for(unsigned int vi = 0; vi < fl.VN(); ++vi ){ for( int vi = 0; vi < fl.VN(); ++vi ){
size_t i = Index(mr,fr.cFFp(vi)); size_t i = Index(mr,fr.cFFp(vi));
fl.FFp(i) = (i>ml.face.size()) ? 0 :&ml.face[remap.face[i]]; fl.FFp(vi) = (i>ml.face.size()) ? 0 :&ml.face[remap.face[i]];
fl.FFi(i) = fr.cFFi(i); fl.FFi(vi) = fr.cFFi(vi);
} }
} }

View File

@ -493,6 +493,9 @@ template <class MeshType> inline void UnMarkAll(MeshType & m) { ++m.imark; }
template < class ContainerType0, class ContainerType1 , class ContainerType2, class ContainerType3>
bool HasPerVertexVFAdjacency (const TriMesh < ContainerType0, ContainerType1, ContainerType2, ContainerType3> & /*m*/) {return TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::VertContainer::value_type::HasVFAdjacency();}
template < class ContainerType0, class ContainerType1 , class ContainerType2, class ContainerType3> template < class ContainerType0, class ContainerType1 , class ContainerType2, class ContainerType3>
bool HasPerVertexQuality (const TriMesh < ContainerType0, ContainerType1, ContainerType2, ContainerType3> & /*m*/) {return TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::VertContainer::value_type::HasQuality();} bool HasPerVertexQuality (const TriMesh < ContainerType0, ContainerType1, ContainerType2, ContainerType3> & /*m*/) {return TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::VertContainer::value_type::HasQuality();}
@ -529,6 +532,9 @@ bool HasPerWedgeNormal (const TriMesh < ContainerType0, ContainerType1, Containe
template < class ContainerType0, class ContainerType1, class ContainerType2 , class ContainerType3> template < class ContainerType0, class ContainerType1, class ContainerType2 , class ContainerType3>
bool HasPerWedgeColor (const TriMesh < ContainerType0, ContainerType1, ContainerType2, ContainerType3> & /*m*/) {return TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::FaceContainer::value_type::HasWedgeColor();} bool HasPerWedgeColor (const TriMesh < ContainerType0, ContainerType1, ContainerType2, ContainerType3> & /*m*/) {return TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::FaceContainer::value_type::HasWedgeColor();}
template < class ContainerType0, class ContainerType1, class ContainerType2 , class ContainerType3>
bool HasPerFaceVFAdjacency (const TriMesh < ContainerType0, ContainerType1, ContainerType2, ContainerType3> & /*m*/) {return TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::FaceContainer::value_type::HasVFAdjacency();}
template < class ContainerType0, class ContainerType1, class ContainerType2 , class ContainerType3> template < class ContainerType0, class ContainerType1, class ContainerType2 , class ContainerType3>
bool HasPerFaceFlags (const TriMesh < ContainerType0, ContainerType1, ContainerType2, ContainerType3> & /*m*/) {return TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::FaceContainer::value_type::HasFlags();} bool HasPerFaceFlags (const TriMesh < ContainerType0, ContainerType1, ContainerType2, ContainerType3> & /*m*/) {return TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::FaceContainer::value_type::HasFlags();}
@ -592,18 +598,20 @@ bool HasHPrevAdjacency (const TriMesh < ContainerType0, ContainerType1, Containe
template < class ContainerType0, class ContainerType1, class ContainerType2 , class ContainerType3> template < class ContainerType0, class ContainerType1, class ContainerType2 , class ContainerType3>
bool HasHOppAdjacency (const TriMesh < ContainerType0, ContainerType1, ContainerType2, ContainerType3> & /*m*/) {return TriMesh< ContainerType0, ContainerType1, ContainerType2 , ContainerType3>::HEdgeType::HasHOppAdjacency();} bool HasHOppAdjacency (const TriMesh < ContainerType0, ContainerType1, ContainerType2, ContainerType3> & /*m*/) {return TriMesh< ContainerType0, ContainerType1, ContainerType2 , ContainerType3>::HEdgeType::HasHOppAdjacency();}
template < class ContainerType0, class ContainerType1 , class ContainerType2, class ContainerType3> //template < class ContainerType0, class ContainerType1 , class ContainerType2, class ContainerType3>
bool HasVFAdjacency (const TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3> & /*m*/) { //bool HasVFAdjacency (const TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3> & m ) {
// gcc 4.4: if the expressions assigned to a1 and a2 are replaced in the assert we get a compilation error // // gcc 4.4: if the expressions assigned to a1 and a2 are replaced in the assert we get a compilation error
// for the macro assert // // for the macro assert
bool a1 = TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::FaceContainer::value_type::HasVFAdjacency(); // bool a1 = TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::FaceContainer::value_type::HasVFAdjacency();
bool a2 = TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::VertContainer::value_type::HasVFAdjacency(); // bool a2 = TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::VertContainer::value_type::HasVFAdjacency();
// a1 and a2 are still evaluated but not referenced, this causes a warning // // a1 and a2 are still evaluated but not referenced, this causes a warning
(void)a1; // (void)a1;
(void)a2; // (void)a2;
assert(a1==a2); // assert(a1==a2);
return TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::FaceContainer::value_type::HasVFAdjacency(); //
} // return vcg::tri::HasPerVertexVFAdjacency< ContainerType0, ContainerType1 , ContainerType2, ContainerType3>(m) &&
// vcg::tri::HasPerFaceVFAdjacency< ContainerType0, ContainerType1 , ContainerType2, ContainerType3>(m) ;
//}
template <class MESH_TYPE> template <class MESH_TYPE>
bool HasPerVertexAttribute(const MESH_TYPE &m, std::string name){ bool HasPerVertexAttribute(const MESH_TYPE &m, std::string name){

View File

@ -211,7 +211,7 @@ namespace vcg {
// f=bestf; // f=bestf;
typename MESH::ScalarType alfa, beta, gamma; typename MESH::ScalarType alfa, beta, gamma;
//calcolo normale con interpolazione trilineare //calcolo normale con interpolazione trilineare
InterpolationParameters(*bestf,bestf->N(),_closestPt, alfa, beta, gamma); InterpolationParameters<typename MESH::FaceType,typename MESH::ScalarType>(*bestf,bestf->N(),_closestPt, alfa, beta, gamma);
_normf = (bestf->V(0)->cN())*alfa+ _normf = (bestf->V(0)->cN())*alfa+
(bestf->V(1)->cN())*beta+ (bestf->V(1)->cN())*beta+
(bestf->V(2)->cN())*gamma ; (bestf->V(2)->cN())*gamma ;

View File

@ -968,7 +968,7 @@ static void FaceNormalLaplacianVF(MeshType &m)
PDFaceInfo lpzf; PDFaceInfo lpzf;
lpzf.m=CoordType(0,0,0); lpzf.m=CoordType(0,0,0);
assert(tri::HasVFAdjacency(m)); assert(tri::HasPerVertexVFAdjacency(m) && tri::HasPerFaceVFAdjacency(m) );
TDF.Start(lpzf); TDF.Start(lpzf);
int i; int i;

View File

@ -229,7 +229,7 @@ class Quadric
static void computeCurvature(MeshType & m) static void computeCurvature(MeshType & m)
{ {
assert(vcg::tri::HasVFAdjacency(m)); assert(tri::HasPerVertexVFAdjacency(m) && tri::HasPerFaceVFAdjacency(m) );
vcg::tri::UpdateTopology<MeshType>::VertexFace(m); vcg::tri::UpdateTopology<MeshType>::VertexFace(m);

View File

@ -20,83 +20,7 @@
* for more details. * * for more details. *
* * * *
****************************************************************************/ ****************************************************************************/
/****************************************************************************
History
$Log: not supported by cvs2svn $
Revision 1.20 2008/04/18 17:52:08 cignoni
added PerVertexFromCurrentFaceNormal
AreaNormalizeFace NormalizeFace
and shortened PerVertexNormalizedPerFaceNormalized
Revision 1.19 2008/02/15 08:08:59 cignoni
added missing include matrix33
Revision 1.18 2007/12/13 17:57:27 cignoni
removed harmless gcc warnings
Revision 1.17 2007/11/23 17:02:47 cignoni
disambiguated pow call (again)
Revision 1.16 2007/11/23 15:42:11 cignoni
disambiguated pow call
Revision 1.15 2007/11/14 11:56:23 ganovelli
added updating of vertex and face normals
Revision 1.14 2007/07/12 23:11:35 cignoni
added the missing PerVertexNormalizedPerFaceNormalized
Revision 1.13 2007/01/10 17:25:14 matteodelle
*** empty log message ***
Revision 1.12 2006/11/07 15:13:56 zifnab1974
Necessary changes for compilation with gcc 3.4.6. Especially the hash function is a problem
Revision 1.11 2005/12/06 18:22:31 pietroni
changed FaceType::ComputeNormal and FaceType::ComputeNormalizedNormal
with face::ComputeNormal and face::ComputeNormalizedNormal
Revision 1.10 2005/12/06 15:30:45 ponchio
added #include triangle3.h for Normal(...)
added a few FaceType:: instead of face::
Revision 1.9 2005/11/22 15:47:34 cignoni
Moved ComputeNormal and ComputeNormalizedNormal out of the face class (no more a member function!)
Revision 1.8 2005/11/21 21:44:43 cignoni
Moved ComputeNormal and ComputeNormalizedNormal out of the face class (no more a member function!)
Revision 1.7 2005/10/13 08:38:00 cignoni
removed the access to the face member function normal and substituted with vcg::normal(*f);
Revision 1.6 2005/06/17 00:46:09 cignoni
Added a PerVertexNormalizedPerFace (vertex are face/area weighted AND normalized)
Revision 1.5 2005/04/01 13:04:55 fiorin
Minor changes
Revision 1.4 2004/09/09 14:35:14 ponchio
Typename changes for linux
Revision 1.3 2004/08/31 15:18:54 pietroni
minor changes to comply gcc compiler (typename's )
Revision 1.2 2004/03/12 15:22:19 cignoni
Written some documentation and added to the trimes doxygen module
Revision 1.1 2004/03/05 10:59:24 cignoni
Changed name from plural to singular (normals->normal)
Revision 1.1 2004/03/04 00:05:50 cignoni
First working version!
Revision 1.1 2004/02/19 13:11:06 cignoni
Initial commit
****************************************************************************/
#ifndef __VCG_TRI_UPDATE_NORMALS #ifndef __VCG_TRI_UPDATE_NORMALS
#define __VCG_TRI_UPDATE_NORMALS #define __VCG_TRI_UPDATE_NORMALS

View File

@ -89,6 +89,7 @@ Edited Comments and GPL license
#include <math.h> #include <math.h>
#include <assert.h> #include <assert.h>
#include <limits> #include <limits>
#include <math.h>
/// static_assert: implemented as a macro for "assert", but it is separated for clarity. /// static_assert: implemented as a macro for "assert", but it is separated for clarity.
/// Should be used for checking integrity constraints that can be tested at complile time, /// Should be used for checking integrity constraints that can be tested at complile time,

View File

@ -674,7 +674,7 @@ public:
template < class VertContainerType, class FaceType, class Container1, class Container2 > template < class VertContainerType, class FaceType, class Container1, class Container2 >
bool HasVFAdjacency (const TriMesh < VertContainerType , face::vector_ocf< FaceType >, Container1, Container2 > & m) bool HasPerFaceVFAdjacency (const TriMesh < VertContainerType , face::vector_ocf< FaceType >, Container1, Container2 > & m)
{ {
if(FaceType::HasVFAdjacencyOcf()) return m.face.IsVFAdjacencyEnabled(); if(FaceType::HasVFAdjacencyOcf()) return m.face.IsVFAdjacencyEnabled();
else return FaceType::FaceType::HasVFAdjacency(); else return FaceType::FaceType::HasVFAdjacency();

View File

@ -57,7 +57,7 @@ Standardized name of flags. It is plural becouse each simplex has many flag.
Revision 1.3 2005/11/12 18:36:51 cignoni Revision 1.3 2005/11/12 18:36:51 cignoni
Added 'Visited' flag functions Added 'Visited' flag functions
Revision 1.2 2004/04/03 13:33:55 cignoni Revision 1.2 lags2004/04/03 13:33:55 cignoni
Missing include Missing include
Revision 1.1 2004/03/29 08:36:26 cignoni Revision 1.1 2004/03/29 08:36:26 cignoni

View File

@ -684,6 +684,13 @@ namespace tri
template < class, class,class, class> class TriMesh; template < class, class,class, class> class TriMesh;
template < class VertexType, class ContainerType0, class Container1, class Container2 >
bool HasPerVertexVFAdjacency (const TriMesh < vertex::vector_ocf< VertexType > , ContainerType0, Container1, Container2 > & m)
{
if(VertexType::HasVFAdjacencyOcf()) return m.vert.IsVFAdjacencyEnabled();
else return VertexType::HasVFAdjacency();
}
template < class VertexType, class ContainerType0, class ContainerType1 ,class ContainerType2 > template < class VertexType, class ContainerType0, class ContainerType1 ,class ContainerType2 >
bool HasPerVertexRadius (const TriMesh < vertex::vector_ocf< VertexType > , ContainerType0, ContainerType1, ContainerType2 > & m) bool HasPerVertexRadius (const TriMesh < vertex::vector_ocf< VertexType > , ContainerType0, ContainerType1, ContainerType2 > & m)
{ {