diff --git a/src/meshlab/meshmodel.h b/src/meshlab/meshmodel.h index 0f0cd1523..1251212cb 100644 --- a/src/meshlab/meshmodel.h +++ b/src/meshlab/meshmodel.h @@ -23,6 +23,10 @@ /**************************************************************************** History $Log$ +Revision 1.45 2008/04/04 10:03:13 cignoni +BIG CHANGE: now also the vertex vector has optional components (mark, and curvature components) +Removed the dangerous 'using namespace' (never put them in .h files!) + Revision 1.44 2008/01/28 13:00:53 cignoni added delMesh method @@ -96,12 +100,13 @@ abstract pointer to fileformat's dependent additional info added #include #include +#include #include #include +#include #include #include -#include #include #include @@ -110,31 +115,32 @@ abstract pointer to fileformat's dependent additional info added #include #include #include -using namespace vcg; -using namespace std; class CEdge; class CFaceO; class CVertexO; -//Vert Mem Occupancy --- 44b --- +//Vert Mem Occupancy --- 40b --- -class CVertexO : public VertexSimp2< CVertexO, CEdge, CFaceO, - vert::Coord3f, /* 12b */ - vert::BitFlags, /* 4b */ - vert::Normal3f, /* 12b */ - vert::Qualityf, /* 4b */ - vert::VFAdj, /* 4b */ - vert::Mark, /* 4b */ - vert::Color4b /* 4b */ +class CVertexO : public vcg::VertexSimp2< CVertexO, CEdge, CFaceO, + vcg::vert::InfoOcf, /* 4b */ + vcg::vert::Coord3f, /* 12b */ + vcg::vert::BitFlags, /* 4b */ + vcg::vert::Normal3f, /* 12b */ + vcg::vert::Qualityf, /* 4b */ + vcg::vert::Color4b, /* 4b */ + vcg::vert::VFAdjOcf, /* 0b */ + vcg::vert::MarkOcf, /* 0b */ + vcg::vert::CurvaturefOcf, /* 0b */ + vcg::vert::CurvatureDirfOcf /* 0b */ >{ }; -class CEdge : public Edge { +class CEdge : public vcg::Edge { public: inline CEdge() {}; - inline CEdge( CVertexO * v0, CVertexO * v1):Edge(v0,v1){}; + inline CEdge( CVertexO * v0, CVertexO * v1):vcg::Edge(v0,v1){}; static inline CEdge OrderedEdge(VertexType* v0,VertexType* v1){ if(v0 {}; -class CMeshO : public vcg::tri::TriMesh< vector, face::vector_ocf > { +class CMeshO : public vcg::tri::TriMesh< vcg::vert::vector_ocf, vcg::face::vector_ocf > { public : int sfn; //The number of selected faces. - Matrix44f Tr; // Usually it is the identity. It is applied in rendering and filters can or cannot use it. (most of the filter will ignore this) - const Box3f &trBB() { - static Box3f bb; + vcg::Matrix44f Tr; // Usually it is the identity. It is applied in rendering and filters can or cannot use it. (most of the filter will ignore this) + const vcg::Box3f &trBB() { + static vcg::Box3f bb; bb.SetNull(); bb.Add(Tr,bbox); return bb; @@ -175,7 +181,7 @@ The base class for representing a single mesh. It contains a single vcg mesh object with some additional information for keeping track of its origin and of what info it has. */ -class MeshModel : public tri::io::Mask +class MeshModel : public vcg::tri::io::Mask { public: @@ -185,15 +191,18 @@ public: MM_WEDGTEXCOORD = 0x0004, MM_FACECOLOR = 0x0008, MM_FACEMARK = 0x0010, - MM_VERTFACETOPO = 0x0020, + MM_VERTMARK = 0x0020, + MM_VERTFACETOPO = 0x0040, + MM_CURV = 0x0080, + MM_CURVDIR = 0x0100, MM_ALL = 0xffff} ; CMeshO cm; public: - GlTrimesh glw; - vector originalVertexColor; + vcg::GlTrimesh glw; + std::vector originalVertexColor; std::string fileName; // Bitmask denoting what fields are currently kept updated in mesh @@ -220,13 +229,13 @@ public: cm.Tr.SetIdentity(); cm.sfn=0; } - bool Render(GLW::DrawMode dm, GLW::ColorMode cm, GLW::TextureMode tm); + bool Render(vcg::GLW::DrawMode dm, vcg::GLW::ColorMode cm, vcg::GLW::TextureMode tm); bool RenderSelectedFaces(); inline void storeVertexColor() { originalVertexColor.resize(cm.vert.size()); - vector::iterator ci; + std::vector::iterator ci; CMeshO::VertexIterator vi; for(vi=cm.vert.begin(),ci=originalVertexColor.begin();vi!=cm.vert.end();++vi,++ci) (*ci)=(*vi).C(); @@ -235,7 +244,7 @@ public: { if(originalVertexColor.empty()) return; if(originalVertexColor.size() != cm.vert.size()) return; - vector::iterator ci; + std::vector::iterator ci; CMeshO::VertexIterator vi; for(vi=cm.vert.begin(),ci=originalVertexColor.begin();vi!=cm.vert.end();++vi,++ci) (*vi).C()=(*ci); @@ -266,19 +275,20 @@ public: { cm.face.EnableFFAdjacency(); currentDataMask |= MM_FACETOPO; - tri::UpdateTopology::FaceFace(cm); + vcg::tri::UpdateTopology::FaceFace(cm); } if( ( (neededDataMask & MM_VERTFACETOPO)!=0) && (currentDataMask& MM_VERTFACETOPO)==0) { + cm.vert.EnableVFAdjacency(); cm.face.EnableVFAdjacency(); currentDataMask |= MM_VERTFACETOPO; - tri::UpdateTopology::VertexFace(cm); + vcg::tri::UpdateTopology::VertexFace(cm); } if( ( (neededDataMask & MM_BORDERFLAG)!=0) && (currentDataMask& MM_BORDERFLAG)==0) { - if(currentDataMask& MM_FACETOPO) tri::UpdateFlags::FaceBorderFromFF(cm); - else tri::UpdateFlags::FaceBorderFromNone(cm); - tri::UpdateFlags::VertexBorderFromFace(cm); + if(currentDataMask& MM_FACETOPO) vcg::tri::UpdateFlags::FaceBorderFromFF(cm); + else vcg::tri::UpdateFlags::FaceBorderFromNone(cm); + vcg::tri::UpdateFlags::VertexBorderFromFace(cm); currentDataMask |= MM_BORDERFLAG; } @@ -297,6 +307,21 @@ public: cm.face.EnableMark(); currentDataMask |= MM_FACEMARK; } + if( ( (neededDataMask & MM_VERTMARK)!=0) && (currentDataMask& MM_VERTMARK)==0) + { + cm.vert.EnableMark(); + currentDataMask |= MM_VERTMARK; + } + if( ( (neededDataMask & MM_CURV)!=0) && (currentDataMask& MM_CURV)==0) + { + cm.vert.EnableCurvature(); + currentDataMask |= MM_CURV; + } + if( ( (neededDataMask & MM_CURVDIR)!=0) && (currentDataMask& MM_CURVDIR)==0) + { + cm.vert.EnableCurvatureDir(); + currentDataMask |= MM_CURVDIR; + } } void clearDataMask(int neededDataMask) @@ -324,9 +349,9 @@ public: RenderMode() { - drawMode = GLW::DMFlat; - colorMode = GLW::CMNone; - textureMode = GLW::TMNone; + drawMode = vcg::GLW::DMFlat; + colorMode = vcg::GLW::CMNone; + textureMode = vcg::GLW::TMNone; lighting = true; backFaceCull = false; @@ -403,9 +428,9 @@ MeshDocument() return tot; } - Box3f bbox() + vcg::Box3f bbox() { - Box3f FullBBox; + vcg::Box3f FullBBox; foreach(MeshModel * mp, meshList) FullBBox.Add(mp->cm.Tr,mp->cm.bbox); return FullBBox;