diff --git a/vcg/complex/trimesh/create/platonic.h b/vcg/complex/trimesh/create/platonic.h index 3faa108b..8967da78 100644 --- a/vcg/complex/trimesh/create/platonic.h +++ b/vcg/complex/trimesh/create/platonic.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.4 2005/07/01 11:17:06 cignoni +Added option of passing a base mesh to Sphere for spherifying it + Revision 1.3 2005/06/17 00:49:29 cignoni Added missing Sphere function @@ -81,22 +84,23 @@ template <class TetraMeshType> void Tetrahedron(TetraMeshType &in) { typedef TetraMeshType MeshType; - typedef typename MeshType::CoordType CoordType; - typedef typename MeshType::VertexPointer VertexPointer; - typedef typename MeshType::VertexIterator VertexIterator; - typedef typename MeshType::FaceIterator FaceIterator; + typedef typename TetraMeshType::CoordType CoordType; + typedef typename TetraMeshType::VertexPointer VertexPointer; + typedef typename TetraMeshType::VertexIterator VertexIterator; + typedef typename TetraMeshType::FaceIterator FaceIterator; in.Clear(); Allocator<TetraMeshType>::AddVertices(in,4); Allocator<TetraMeshType>::AddFaces(in,4); VertexPointer ivp[4]; - + CoordType test; +test=CoordType ( 1.0, 1.0, 1.0); VertexIterator vi=in.vert.begin(); - ivp[0]=&*vi;(*vi).P()=TetraMeshType::CoordType ( 1, 1, 1); ++vi; - ivp[1]=&*vi;(*vi).P()=TetraMeshType::CoordType (-1, 1,-1); ++vi; - ivp[2]=&*vi;(*vi).P()=TetraMeshType::CoordType (-1,-1, 1); ++vi; - ivp[3]=&*vi;(*vi).P()=TetraMeshType::CoordType ( 1,-1,-1); + ivp[0]=&*vi;(*vi).P()=CoordType ( 1.0, 1.0, 1.0); ++vi; + ivp[1]=&*vi;(*vi).P()=CoordType (-1.0, 1.0,-1.0); ++vi; + ivp[2]=&*vi;(*vi).P()=CoordType (-1.0,-1.0, 1.0); ++vi; + ivp[3]=&*vi;(*vi).P()=CoordType ( 1.0,-1.0,-1.0); FaceIterator fi=in.face.begin(); (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2]; ++fi; @@ -117,8 +121,8 @@ void Dodecahedron(DodMeshType & in) typedef typename MeshType::VertexIterator VertexIterator; typedef typename MeshType::FaceIterator FaceIterator; typedef typename MeshType::ScalarType ScalarType; - const N_penta=12; - const N_points=62; + const int N_penta=12; + const int N_points=62; int penta[N_penta*3*3]= {20,11, 18, 18, 11, 8, 8, 11, 4, @@ -194,7 +198,7 @@ void Dodecahedron(DodMeshType & in) added[ i ] = m++; } - vector<VertexPointer> index(in.vn); + std::vector<VertexPointer> index(in.vn); for(j=0,vi=in.vert.begin();j<in.vn;++j,++vi) index[j] = &(*vi); @@ -370,21 +374,26 @@ void Square(MeshType &in) // this function build a sphere starting from a eventually not empty mesh. // If the mesh is not empty it is 'spherified' and used as base for the subdivision process. // otherwise an icosahedron is used. -template <class MESH_TYPE> -void Sphere(MESH_TYPE &in, const int subdiv = 3 ) +template <class MeshType> +void Sphere(MeshType &in, const int subdiv = 3 ) { + typedef typename MeshType::ScalarType ScalarType; + typedef typename MeshType::CoordType CoordType; + typedef typename MeshType::VertexPointer VertexPointer; + typedef typename MeshType::VertexIterator VertexIterator; + typedef typename MeshType::FaceIterator FaceIterator; if(in.vn==0 && in.fn==0) Icosahedron(in); - MESH_TYPE::VertexIterator vi; + VertexIterator vi; for(vi = in.vert.begin(); vi!=in.vert.end();++vi) vi->P().Normalize(); - tri::UpdateFlags<AMesh>::FaceBorderFromNone(in); + tri::UpdateFlags<MeshType>::FaceBorderFromNone(in); int lastsize = 0; for(int i=0;i<subdiv;++i) { - Refine<MESH_TYPE, MidPoint<MESH_TYPE> >(in,MidPoint<MESH_TYPE>(),0); + Refine<MeshType, MidPoint<MeshType> >(in,MidPoint<MeshType>(),0); for(vi = in.vert.begin()+lastsize;vi!=in.vert.end();++vi) vi->P().Normalize(); @@ -547,39 +556,45 @@ void Box(MeshType &in, const typename MeshType::BoxType & bb ) /// Questa funzione costruisce una mesh a partire da un insieme di coordiante /// ed un insieme di terne di indici di vertici -template <class M,class V, class F > -void Build( M & in, const V & v, const F & f) +template <class MeshType,class V, class F > +void Build( MeshType & in, const V & v, const F & f) { - in.vn = v.size(); + typedef typename MeshType::ScalarType ScalarType; + typedef typename MeshType::CoordType CoordType; + typedef typename MeshType::VertexPointer VertexPointer; + typedef typename MeshType::VertexIterator VertexIterator; + typedef typename MeshType::FaceIterator FaceIterator; + + in.vn = v.size(); in.fn = f.size(); in.vert.clear(); in.face.clear(); - V::const_iterator vi; + typename V::const_iterator vi; - M::VertexType tv; + typename MeshType::VertexType tv; tv.Supervisor_Flags()=0; for(vi=v.begin();vi!=v.end();++vi) { - tv.P() = M::CoordType( - (M::ScalarType)(*vi).Ext(0), - (M::ScalarType)(*vi).Ext(1), - (M::ScalarType)(*vi).Ext(2) + tv.P() = CoordType( + (ScalarType)(*vi).Ext(0), + (ScalarType)(*vi).Ext(1), + (ScalarType)(*vi).Ext(2) ); in.vert.push_back(tv); } - vector<M::vertex_pointer> index(in.vn); - M::vertex_iterator j; + std::vector<VertexPointer> index(in.vn); + VertexIterator j; int k; for(k=0,j=in.vert.begin();j!=in.vert.end();++j,++k) index[k] = &*j; - F::const_iterator fi; + typename F::const_iterator fi; - M::face_type ft; + typename MeshType::FaceType ft; ft.Supervisor_Flags()=0; for(fi=f.begin();fi!=f.end();++fi) diff --git a/vcg/complex/trimesh/refine.h b/vcg/complex/trimesh/refine.h index d94870bc..aad013c5 100644 --- a/vcg/complex/trimesh/refine.h +++ b/vcg/complex/trimesh/refine.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.5 2005/06/29 15:25:41 callieri +deleted a wrong declaration "typename typename" + Revision 1.4 2005/06/17 00:48:27 cignoni Corrected the type name of wedge tex coords WedgeInterp in RefineE @@ -50,6 +53,7 @@ first working version #include <vcg/space/tcoord2.h> #include <vcg/space/color4.h> #include <vcg/simplex/face/pos.h> +#include<vcg/complex/trimesh/allocate.h> #include<vcg/complex/trimesh/update/topology.h> namespace vcg{ @@ -297,10 +301,10 @@ template<class MESH_TYPE,class MIDPOINT, class EDGEPRED> bool RefineE(MESH_TYPE &m, MIDPOINT mid, EDGEPRED ep,bool RefineSelected=false) { int j,NewVertNum=0,NewFaceNum=0; - typedef std::pair<typename MESH_TYPE::VertexIterator,typename MESH_TYPE::VertexIterator> vvpair; - std::map<vvpair,typename MESH_TYPE::VertexIterator> Edge2Vert; + typedef std::pair<typename MESH_TYPE::VertexPointer,typename MESH_TYPE::VertexPointer> vvpair; + std::map<vvpair,typename MESH_TYPE::VertexPointer> Edge2Vert; // Primo ciclo si conta quanti sono i vertici e facce da aggiungere - MESH_TYPE::FaceIterator fi; + typename MESH_TYPE::FaceIterator fi; for(fi=m.face.begin();fi!=m.face.end();++fi) if(!(*fi).IsD()) for(j=0;j<3;j++){ if(ep((*fi).V(j)->P(),(*fi).V1(j)->P()) && @@ -325,7 +329,7 @@ bool RefineE(MESH_TYPE &m, MIDPOINT mid, EDGEPRED ep,bool RefineSelected=false) (*lastv).UberFlags()=0; mid( (*lastv), face::Pos<typename MESH_TYPE::FaceType> (&*fi,j)); //(*lastv).P()=((*fi).V(j)->P()+(*fi).V1(j)->P())/2; - Edge2Vert[ vvpair((*fi).V(j),(*fi).V1(j)) ] = lastv; + Edge2Vert[ vvpair((*fi).V(j),(*fi).V1(j)) ] = &*lastv; ++lastv; } assert(lastv==m.vert.end()); @@ -350,10 +354,10 @@ bool RefineE(MESH_TYPE &m, MIDPOINT mid, EDGEPRED ep,bool RefineSelected=false) */ - typename MESH_TYPE::VertexIterator vv[6]; // i sei vertici in gioco + typename MESH_TYPE::VertexPointer vv[6]; // i sei vertici in gioco // 0..2 vertici originali del triangolo // 3..5 mp01, mp12, mp20 midpoints of the three edges - MESH_TYPE::FaceIterator nf[4]; // le quattro facce in gioco. + typename MESH_TYPE::FacePointer nf[4]; // le quattro facce in gioco. typename MESH_TYPE::FaceType::TexCoordType wtt[6]; // per ogni faccia sono al piu' tre i nuovi valori // di texture per wedge (uno per ogni edge) @@ -382,10 +386,10 @@ bool RefineE(MESH_TYPE &m, MIDPOINT mid, EDGEPRED ep,bool RefineSelected=false) else vv[5]=0; int ind=((&*vv[3])?1:0)+((&*vv[4])?2:0)+((&*vv[5])?4:0); - nf[0]=fi; - static int iii=0; - for(int i=1;i<SplitTab[ind].TriNum;++i){ - nf[i]=lastf; ++lastf; fca++; + nf[0]=&*fi; + int i; + for(i=1;i<SplitTab[ind].TriNum;++i){ + nf[i]=&*lastf; ++lastf; fca++; if(RefineSelected) (*nf[i]).SetS(); } @@ -537,7 +541,7 @@ struct MidPointButterfly : public std::unary_function<face::Pos<typename MESH_TY if(vl==vdr) rule+=4; if(vr==vdl) rule+=8; switch(rule){ -/* +/* */ /* */ case 0 : return ((*vl)+(*vr))/2.0+((*vu)+(*vd))/8.0 - ((*vul)+(*vur)+(*vdl)+(*vdr))/16.0; /* ul */ case 1 : return (*vl*6 + *vr*10 + *vu + *vd*3 - *vur - *vdl -*vdr*2 )/16.0; /* ur */ case 2 : return (*vr*6 + *vl*10 + *vu + *vd*3 - *vul - *vdr -*vdl*2 )/16.0; @@ -590,7 +594,7 @@ double Rules[11][10] = { .175 , .1213525492 , .01545084973 , -.04635254918, -.04045084973, -.025 , -.04045084973, -.04635254918, .01545084973, .1213525492 } // valenza 10 }; - Pos<typename MESH_TYPE::FaceType> he(ep.f,ep.z,ep.f->V(ep.z)); +face::Pos<typename MESH_TYPE::FaceType> he(ep.f,ep.z,ep.f->V(ep.z)); typename MESH_TYPE::CoordType *vl,*vr; vl=&he.v->P(); vr=&he.VFlip()->P(); @@ -609,7 +613,7 @@ double Rules[11][10] = int kl=0,kr=0; // valence of left and right vertices bool bl=false,br=false; // if left and right vertices are of border - Pos<typename MESH_TYPE::FaceType> heStart=he;assert(he.v->P()==*vl); + face::Pos<typename MESH_TYPE::FaceType> heStart=he;assert(he.v->P()==*vl); do { // compute valence of left vertex he.FlipE();he.FlipF(); if(he.IsBorder()) bl=true; @@ -763,4 +767,4 @@ class EdgeSplSphere -#endif \ No newline at end of file +#endif diff --git a/vcg/complex/trimesh/smooth.h b/vcg/complex/trimesh/smooth.h index 12d0dd66..0ff0bce2 100644 --- a/vcg/complex/trimesh/smooth.h +++ b/vcg/complex/trimesh/smooth.h @@ -23,11 +23,27 @@ /**************************************************************************** History $Log: not supported by cvs2svn $ +Revision 1.2 2005/03/16 16:14:12 spinelli +aggiunta funzione PasoDobleSmooth e relative: + +- FitMesh +- FaceErrorGrad +- CrossProdGradient +- TriAreaGradient +- NormalSmooth + +e le classi: + +- PDVertInfo +- PDFaceInfo + +necessarie per utilizzare SimpleTempData + Revision 1.1 2004/12/11 14:53:19 ganovelli first partial porting: compiled gcc,intel and msvc -/****************************************************************************/ +****************************************************************************/ #ifndef __VCGLIB__SMOOTH @@ -36,6 +52,7 @@ first partial porting: compiled gcc,intel and msvc #include <vcg/space/point3.h> #include <vcg/space/line3.h> #include <vcg/container/simple_temporary_data.h> +#include <vcg/complex/trimesh/update/normal.h> namespace vcg { @@ -534,7 +551,7 @@ void NormalSmooth(MESH_TYPE &m, vcg::face::VFIterator<typename MESH_TYPE::FaceType> ep; - MESH_TYPE::FaceIterator fi; + typename MESH_TYPE::FaceIterator fi; for(fi=m.face.begin();fi!=m.face.end();++fi) { @@ -645,13 +662,13 @@ Point3<FLT> FaceErrorGrad(Point3<FLT> &p,Point3<FLT> &p0,Point3<FLT> &p1, Point3 template<class MESH_TYPE> void FitMesh(MESH_TYPE &m, - SimpleTempData<typename MESH_TYPE::VertContainer, PDVertInfo<typename typename MESH_TYPE::ScalarType> > &TDV, - SimpleTempData<typename MESH_TYPE::FaceContainer, PDFaceInfo<typename typename MESH_TYPE::ScalarType> > &TDF, + SimpleTempData<typename MESH_TYPE::VertContainer, PDVertInfo<typename MESH_TYPE::ScalarType> > &TDV, + SimpleTempData<typename MESH_TYPE::FaceContainer, PDFaceInfo<typename MESH_TYPE::ScalarType> > &TDF, float lambda) { //vcg::face::Pos<typename MESH_TYPE::FaceType> ep; vcg::face::VFIterator<typename MESH_TYPE::FaceType> ep; - MESH_TYPE::VertexIterator vi; + typename MESH_TYPE::VertexIterator vi; for(vi=m.vert.begin();vi!=m.vert.end();++vi) { Point3f ErrGrad=Point3f(0,0,0); @@ -680,17 +697,19 @@ void FitMesh(MESH_TYPE &m, -template<class MESH_TYPE> -void PasoDobleSmooth(MESH_TYPE &m, int step, typename MESH_TYPE::ScalarType Sigma=0, int FitStep=10, typename MESH_TYPE::ScalarType FitLambda=0.05) +template<class MeshType> +void PasoDobleSmooth(MeshType &m, int step, typename MeshType::ScalarType Sigma=0, int FitStep=10, typename MeshType::ScalarType FitLambda=0.05) { + typedef typename MeshType::ScalarType ScalarType; + typedef typename MeshType::CoordType CoordType; - SimpleTempData< typedef MESH_TYPE::VertContainer, PDVertInfo<MESH_TYPE::ScalarType> > TDV(m.vert); - SimpleTempData< typedef MESH_TYPE::FaceContainer, PDFaceInfo<MESH_TYPE::ScalarType> > TDF(m.face); - PDVertInfo<MESH_TYPE::ScalarType> lpzv; - lpzv.np=typename MESH_TYPE::CoordType(0,0,0); - PDFaceInfo<MESH_TYPE::ScalarType> lpzf; - lpzf.m=typename MESH_TYPE::CoordType(0,0,0); + SimpleTempData< typename MeshType::VertContainer, PDVertInfo<ScalarType> > TDV(m.vert); + SimpleTempData< typename MeshType::FaceContainer, PDFaceInfo<ScalarType> > TDF(m.face); + PDVertInfo<ScalarType> lpzv; + lpzv.np=CoordType(0,0,0); + PDFaceInfo<ScalarType> lpzf; + lpzf.m=CoordType(0,0,0); assert(m.HasVFTopology()); m.HasVFTopology(); @@ -699,10 +718,10 @@ void PasoDobleSmooth(MESH_TYPE &m, int step, typename MESH_TYPE::ScalarType Sigm for(int j=0;j<step;++j) { - vcg::tri::UpdateNormals<MyMesh>::PerFace(m); - NormalSmooth<MESH_TYPE>(m,TDF,Sigma); + vcg::tri::UpdateNormals<MeshType>::PerFace(m); + NormalSmooth<MeshType>(m,TDF,Sigma); for(int k=0;k<FitStep;k++) - FitMesh<MESH_TYPE>(m,TDV,TDF,FitLambda); + FitMesh<MeshType>(m,TDV,TDF,FitLambda); } TDF.Stop(); @@ -714,4 +733,4 @@ void PasoDobleSmooth(MESH_TYPE &m, int step, typename MESH_TYPE::ScalarType Sigm } // End namespace vcg -#endif // VCG_SMOOTH \ No newline at end of file +#endif // VCG_SMOOTH diff --git a/vcg/container/simple_temporary_data.h b/vcg/container/simple_temporary_data.h index ede41197..5b629aff 100644 --- a/vcg/container/simple_temporary_data.h +++ b/vcg/container/simple_temporary_data.h @@ -24,11 +24,14 @@ History $Log: not supported by cvs2svn $ +Revision 1.3 2004/12/11 15:37:47 ganovelli +added one more [], now it is polymorphic, added typenames + Revision 1.2 2004/03/31 22:36:44 ganovelli First Working Release (with this comment) -/****************************************************************************/ +****************************************************************************/ #ifndef __VCGLIB_SIMPLE__ #define __VCGLIB_SIMPLE__ @@ -40,7 +43,6 @@ namespace vcg { template <class STL_CONT, class ATTR_TYPE> class SimpleTempData{ public: -typedef typename ATTR_TYPE attr_type; STL_CONT& c; std::vector<ATTR_TYPE> data; @@ -57,7 +59,7 @@ void Start(){data.reserve(c.capacity());data.resize(c.size());} // start and initialize temporary attribute void Start(ATTR_TYPE val){data.reserve(c.capacity());data.resize(c.size()); - std::vector<ATTR_TYPE>::iterator i; + typename std::vector<ATTR_TYPE>::iterator i; for(i = data.begin(); i!= data.end(); ++i) *i = val; } @@ -78,4 +80,4 @@ bool UpdateSize(){ }; // end namespace vcg -#endif \ No newline at end of file +#endif diff --git a/vcg/math/camera.h b/vcg/math/camera.h index 9a56cf50..b60f0fff 100644 --- a/vcg/math/camera.h +++ b/vcg/math/camera.h @@ -23,6 +23,9 @@ /**************************************************************************** History $Log: not supported by cvs2svn $ +Revision 1.21 2005/07/01 10:55:42 cignoni +Removed default values from the implementation of SetCavalieri and SetIsometric + Revision 1.20 2005/06/29 14:59:03 spinelli aggiunto: - l' enum dei tipi PERSPECTIVE, ORTHO, ISOMETRIC, CAVALIERI @@ -123,7 +126,7 @@ public: f(0.f),s(vcg::Point2<S>(0.0,0.0)), c(vcg::Point2<S>(0.0,0.0)), viewport(vcg::Point2<int>(0,0)), - _flags(0),viewportM(1), cameraType(0) + viewportM(1),_flags(0), cameraType(0) {} S f; // Focal Distance (cioe' la distanza del piano immagine dal centro di proiezione diff --git a/vcg/math/shot.h b/vcg/math/shot.h index 88a311c6..96ff51ae 100644 --- a/vcg/math/shot.h +++ b/vcg/math/shot.h @@ -23,6 +23,9 @@ /**************************************************************************** History $Log: not supported by cvs2svn $ +Revision 1.11 2005/01/22 11:20:20 ponchio +<...Point3.h> -> <...point3.h> + Revision 1.10 2005/01/05 13:26:15 ganovelli corretto cambiamento di sistema di rif. @@ -47,7 +50,7 @@ Revision 1.2 2004/09/06 21:41:30 ganovelli Revision 1.1 2004/09/03 13:01:51 ganovelli creation -/****************************************************************************/ +****************************************************************************/ #ifndef __VCGLIB_SHOT