From eb3f1a97fc04f63a6b016345d22eb8e7e3fe941b Mon Sep 17 00:00:00 2001 From: ganovelli Date: Thu, 24 Jun 2010 12:35:37 +0000 Subject: [PATCH] added HasPerVertexVFAdjacency and HasPerFaceVFAdjacency. Removed generic HasVFAdjacency which made the logical AND of the two and updated the relative calls. --- vcg/complex/trimesh/allocate.h | 12 +-- vcg/complex/trimesh/append.h | 14 ++-- vcg/complex/trimesh/base.h | 32 +++++--- vcg/complex/trimesh/closest.h | 2 +- vcg/complex/trimesh/smooth.h | 2 +- .../trimesh/update/curvature_fitting.h | 2 +- vcg/complex/trimesh/update/normal.h | 76 ------------------- vcg/math/base.h | 1 + vcg/simplex/face/component_ocf.h | 2 +- vcg/simplex/vertex/base.h | 2 +- vcg/simplex/vertex/component_ocf.h | 7 ++ 11 files changed, 47 insertions(+), 105 deletions(-) diff --git a/vcg/complex/trimesh/allocate.h b/vcg/complex/trimesh/allocate.h index 505adc46..18d75ad1 100644 --- a/vcg/complex/trimesh/allocate.h +++ b/vcg/complex/trimesh/allocate.h @@ -477,7 +477,7 @@ namespace vcg { for(int i = 0; i < (*fi).VN(); ++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) if ((*fi).cVFp(i)!=0) pu.Update((*fi).VFp(i)); ++ii; @@ -488,7 +488,7 @@ namespace vcg { for (vi=m.vert.begin(); vi!=m.vert.end(); ++vi) if(!(*vi).IsD()) { - if(HasVFAdjacency(m)) + if(HasPerVertexVFAdjacency(m) && HasPerFaceVFAdjacency(m)) if ((*vi).cVFp()!=0) pu.Update((FaceType * &)(*vi).VFp()); // Note the above cast is probably not useful if you have correctly defined @@ -586,7 +586,7 @@ namespace vcg { { assert(!m.vert[i].IsD()); m.vert[ newVertIndex[i] ].ImportData(m.vert[i]); - if(HasVFAdjacency(m)) + if(HasPerVertexVFAdjacency(m) &&HasPerFaceVFAdjacency(m) ) if (m.vert[i].cVFp()!=0) { 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(1) = m.face[i].V(1); 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) if (m.face[i].cVFp(j)!=0) { 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) if(!(*vi).IsD()) { - if(HasVFAdjacency(m)) + if(HasPerVertexVFAdjacency(m) &&HasPerFaceVFAdjacency(m) ) if ((*vi).cVFp()!=0) { size_t oldIndex = (*vi).cVFp() - fbase; @@ -725,7 +725,7 @@ namespace vcg { for(fi=m.face.begin();fi!=m.face.end();++fi) if(!(*fi).IsD()) { - if(HasVFAdjacency(m)) + if(HasPerVertexVFAdjacency(m) &&HasPerFaceVFAdjacency(m) ) for(i=0;i<3;++i) if ((*fi).cVFp(i)!=0) { diff --git a/vcg/complex/trimesh/append.h b/vcg/complex/trimesh/append.h index 0eaa0594..a4120426 100644 --- a/vcg/complex/trimesh/append.h +++ b/vcg/complex/trimesh/append.h @@ -73,7 +73,9 @@ public: } // 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()); vl.VFp() = (i>ml.face.size())? 0 :&ml.face[remap.face[i]]; vl.VFi() = vr.VFi(); @@ -120,14 +122,14 @@ public: // Face to Vertex Adj if(vcg::tri::HasFVAdjacency(ml) && vcg::tri::HasFVAdjacency(mr)){ 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))]]; } // Face to Edge Adj if(vcg::tri::HasFEAdjacency(ml) && vcg::tri::HasFEAdjacency(mr)){ 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)); fl.FEp(i) = (i>ml.edge.size())? 0 : &ml.edge[remap.edge[i]]; } @@ -136,10 +138,10 @@ public: // Face to Face Adj if(vcg::tri::HasFFAdjacency(ml) && vcg::tri::HasFFAdjacency(mr)){ 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)); - fl.FFp(i) = (i>ml.face.size()) ? 0 :&ml.face[remap.face[i]]; - fl.FFi(i) = fr.cFFi(i); + fl.FFp(vi) = (i>ml.face.size()) ? 0 :&ml.face[remap.face[i]]; + fl.FFi(vi) = fr.cFFi(vi); } } diff --git a/vcg/complex/trimesh/base.h b/vcg/complex/trimesh/base.h index ac90c133..9d3c30df 100644 --- a/vcg/complex/trimesh/base.h +++ b/vcg/complex/trimesh/base.h @@ -493,6 +493,9 @@ template 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> 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> 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> 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> 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> -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 - // for the macro assert - bool a1 = TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::FaceContainer::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 - (void)a1; - (void)a2; - assert(a1==a2); - return TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::FaceContainer::value_type::HasVFAdjacency(); -} +//template < class ContainerType0, class ContainerType1 , class ContainerType2, class ContainerType3> +//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 +// // for the macro assert +// bool a1 = TriMesh < ContainerType0 , ContainerType1, ContainerType2, ContainerType3>::FaceContainer::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 +// (void)a1; +// (void)a2; +// assert(a1==a2); +// +// return vcg::tri::HasPerVertexVFAdjacency< ContainerType0, ContainerType1 , ContainerType2, ContainerType3>(m) && +// vcg::tri::HasPerFaceVFAdjacency< ContainerType0, ContainerType1 , ContainerType2, ContainerType3>(m) ; +//} template bool HasPerVertexAttribute(const MESH_TYPE &m, std::string name){ diff --git a/vcg/complex/trimesh/closest.h b/vcg/complex/trimesh/closest.h index 0471fe0b..78d34ae8 100644 --- a/vcg/complex/trimesh/closest.h +++ b/vcg/complex/trimesh/closest.h @@ -211,7 +211,7 @@ namespace vcg { // f=bestf; typename MESH::ScalarType alfa, beta, gamma; //calcolo normale con interpolazione trilineare - InterpolationParameters(*bestf,bestf->N(),_closestPt, alfa, beta, gamma); + InterpolationParameters(*bestf,bestf->N(),_closestPt, alfa, beta, gamma); _normf = (bestf->V(0)->cN())*alfa+ (bestf->V(1)->cN())*beta+ (bestf->V(2)->cN())*gamma ; diff --git a/vcg/complex/trimesh/smooth.h b/vcg/complex/trimesh/smooth.h index e8a99ad9..5b624320 100644 --- a/vcg/complex/trimesh/smooth.h +++ b/vcg/complex/trimesh/smooth.h @@ -968,7 +968,7 @@ static void FaceNormalLaplacianVF(MeshType &m) PDFaceInfo lpzf; lpzf.m=CoordType(0,0,0); - assert(tri::HasVFAdjacency(m)); + assert(tri::HasPerVertexVFAdjacency(m) && tri::HasPerFaceVFAdjacency(m) ); TDF.Start(lpzf); int i; diff --git a/vcg/complex/trimesh/update/curvature_fitting.h b/vcg/complex/trimesh/update/curvature_fitting.h index e5ed5ab8..1fdf08e1 100644 --- a/vcg/complex/trimesh/update/curvature_fitting.h +++ b/vcg/complex/trimesh/update/curvature_fitting.h @@ -229,7 +229,7 @@ class Quadric static void computeCurvature(MeshType & m) { - assert(vcg::tri::HasVFAdjacency(m)); + assert(tri::HasPerVertexVFAdjacency(m) && tri::HasPerFaceVFAdjacency(m) ); vcg::tri::UpdateTopology::VertexFace(m); diff --git a/vcg/complex/trimesh/update/normal.h b/vcg/complex/trimesh/update/normal.h index 9c36d117..d2fcce4d 100644 --- a/vcg/complex/trimesh/update/normal.h +++ b/vcg/complex/trimesh/update/normal.h @@ -20,83 +20,7 @@ * 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 #define __VCG_TRI_UPDATE_NORMALS diff --git a/vcg/math/base.h b/vcg/math/base.h index 8327d976..96329195 100644 --- a/vcg/math/base.h +++ b/vcg/math/base.h @@ -89,6 +89,7 @@ Edited Comments and GPL license #include #include #include +#include /// 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, diff --git a/vcg/simplex/face/component_ocf.h b/vcg/simplex/face/component_ocf.h index ab838e16..ff728a9e 100644 --- a/vcg/simplex/face/component_ocf.h +++ b/vcg/simplex/face/component_ocf.h @@ -674,7 +674,7 @@ public: 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(); else return FaceType::FaceType::HasVFAdjacency(); diff --git a/vcg/simplex/vertex/base.h b/vcg/simplex/vertex/base.h index 51c68a67..c8486db3 100644 --- a/vcg/simplex/vertex/base.h +++ b/vcg/simplex/vertex/base.h @@ -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 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 Revision 1.1 2004/03/29 08:36:26 cignoni diff --git a/vcg/simplex/vertex/component_ocf.h b/vcg/simplex/vertex/component_ocf.h index c8eed342..bc7eefb6 100644 --- a/vcg/simplex/vertex/component_ocf.h +++ b/vcg/simplex/vertex/component_ocf.h @@ -684,6 +684,13 @@ namespace tri 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 > bool HasPerVertexRadius (const TriMesh < vertex::vector_ocf< VertexType > , ContainerType0, ContainerType1, ContainerType2 > & m) {