From b4b7f45041f867451f74769e17afd67b21fa4b40 Mon Sep 17 00:00:00 2001 From: cignoni Date: Fri, 18 Mar 2005 00:13:45 +0000 Subject: [PATCH] Removed NormalizedNormalV (out of standard and wrong) and added the member functions Normal and NormalizedNormal() (just like for faces) --- vcg/simplex/vertex/base.h | 65 +++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/vcg/simplex/vertex/base.h b/vcg/simplex/vertex/base.h index 08f11ec7..efded352 100644 --- a/vcg/simplex/vertex/base.h +++ b/vcg/simplex/vertex/base.h @@ -23,6 +23,9 @@ /**************************************************************************** History $Log: not supported by cvs2svn $ +Revision 1.21 2004/10/28 00:50:49 cignoni +Better Doxygen documentation + Revision 1.20 2004/10/11 17:45:05 ganovelli added template on corrdinate type (default Point3) @@ -54,6 +57,9 @@ Revision 1.12 2004/05/10 13:31:13 ganovelli function for edge adjacency added $Log: not supported by cvs2svn $ +Revision 1.21 2004/10/28 00:50:49 cignoni +Better Doxygen documentation + Revision 1.20 2004/10/11 17:45:05 ganovelli added template on corrdinate type (default Point3) @@ -717,6 +723,42 @@ public: return *(CoordType *)this; #endif } + +template +const CoordType GenericNormal() +{ + if (!v->HasVFAdjacency()) + { + assert(0); + return (VERTEX_TYPE::CoordType (0,0,0)); + } + else + { + vcg::face::VFIterator VFi=vcg::face::VFIterator(); + VFi.f=v->VFp(); + VFi.z=v->VFi(); + typename VERTEX_TYPE::CoordType N= typename VERTEX_TYPE::CoordType(0,0,0); + while (!VFi.End()) + { + N+=VFi.f->Normal(); + VFi++; + } + if(NormalizeFlag) N.Normalize(); + return N; + } +} + +/// Return the un-normalized value of the vertex normal as it correspond to the current geometry. +/// It is always computed and never use any stored value. +/// REQUIRES vertex-face topology +const CoordType Normal() { return GenericNormal(); } + +/// Return the normalized value of the vertex normal as it correspond to the current geometry. +/// It is always computed and never use any stored value. +/// REQUIRES vertex-face topology +const CoordType NormalizedNormal() { return GenericNormal(); } + + //@} /***********************************************/ @@ -857,29 +899,6 @@ inline void Convert( VERT_TYPE &v ) }; -template typename VERTEX_TYPE::CoordType NormalizedNormalV(VERTEX_TYPE *v) -{ - if (!v->HasVFAdjacency()) - { - assert(0); - return (VERTEX_TYPE::CoordType (0,0,0)); - } - else - { - vcg::face::VFIterator VFi=vcg::face::VFIterator(); - VFi.f=v->VFp(); - VFi.z=v->VFi(); - typename VERTEX_TYPE::CoordType N= typename VERTEX_TYPE::CoordType(0,0,0); - int i=0; - while (!VFi.End()) - { - N+=VFi.f->NormalizedNormal(); - i++; - VFi++; - } - return ((typename VERTEX_TYPE::CoordType) N/(typename VERTEX_TYPE::CoordType::ScalarType)i); - } -} //@} } // end namespace #endif