1 #ifndef PARAM_MESH 2 #define PARAM_MESH 3 4 // stuff to define the mesh 5 #include <vcg/simplex/face/component_ep.h> 6 #include <vcg/complex/complex.h> 7 #include "iso_parametrization.h" 8 9 class BaseVertex; 10 class BaseEdge; 11 class BaseFace; 12 13 class BaseUsedTypes: public vcg::UsedTypes < vcg::Use<BaseVertex>::AsVertexType, 14 vcg::Use<BaseEdge >::AsEdgeType, 15 vcg::Use<BaseFace >::AsFaceType >{}; 16 17 18 ///AUXILIARY STRUCTURES USED FOR PARAMETRIZATION COMPUTATION 19 class BaseVertex : public vcg::Vertex< BaseUsedTypes, 20 vcg::vertex::VFAdj, 21 vcg::vertex::Coord3f, 22 vcg::vertex::Normal3f, 23 vcg::vertex::Mark, 24 vcg::vertex::BitFlags, 25 vcg::vertex::Color4b, 26 vcg::vertex::TexCoord2f> 27 { 28 public: 29 30 ScalarType area; 31 CoordType RPos; 32 BaseVertex *brother; 33 BaseFace *father; 34 CoordType Bary; 35 //ScalarType Damp; 36 BaseVertex()37 BaseVertex() 38 { 39 brother=NULL; 40 //Damp=1; 41 //num_collapse=1; 42 } 43 Has_Auxiliary()44 static bool Has_Auxiliary(){return true;} 45 46 vcg::Point2<ScalarType> RestUV; 47 48 vcg::Color4b OriginalCol; 49 //int num_collapse; 50 ImportData(const BaseVertex & left)51 void ImportData(const BaseVertex & left ) 52 { 53 vcg::Vertex< BaseUsedTypes, 54 vcg::vertex::VFAdj, 55 vcg::vertex::Coord3f, 56 vcg::vertex::Normal3f, 57 vcg::vertex::Mark, 58 vcg::vertex::BitFlags, 59 vcg::vertex::Color4b, 60 vcg::vertex::TexCoord2f>::ImportData(left); 61 62 this->area=left.area; 63 this->RPos=left.RPos; 64 this->brother=left.brother; 65 this->father=left.father; 66 this->Bary=left.Bary; 67 } 68 69 template < class LeftV> ImportData(const LeftV & left)70 void ImportData(const LeftV & left ) 71 { 72 vcg::Vertex< BaseUsedTypes, 73 vcg::vertex::VFAdj, 74 vcg::vertex::Coord3f, 75 vcg::vertex::Normal3f, 76 vcg::vertex::Mark, 77 vcg::vertex::BitFlags, 78 vcg::vertex::Color4b, 79 vcg::vertex::TexCoord2f>::ImportData(left); 80 } 81 82 83 }; 84 85 ///class maintaining additional auxiliary data used during the parameterization 86 class AuxiliaryVertData{ 87 public: 88 BaseVertex::ScalarType area; 89 BaseVertex::CoordType RPos; 90 BaseVertex *brother; 91 BaseFace *father; 92 BaseVertex::CoordType Bary; 93 94 vcg::Point2<BaseVertex::ScalarType> RestUV; 95 96 vcg::Color4b OriginalCol; 97 AuxiliaryVertData()98 AuxiliaryVertData() 99 {brother=NULL;} 100 }; 101 102 class AuxiliaryFaceData 103 { 104 public: 105 std::vector<std::pair<BaseVertex*,vcg::Point3f> > vertices_bary; 106 typedef std::vector<std::pair<BaseVertex*,vcg::Point3f> >::iterator IteVBary; 107 vcg::Color4b group; 108 BaseVertex::ScalarType areadelta; 109 vcg::Color4b colorDivision; 110 }; 111 112 class BaseFace; 113 114 class BaseEdge : public vcg::Edge<BaseUsedTypes,vcg::edge::EVAdj> { 115 public: BaseEdge()116 inline BaseEdge() {}; BaseEdge(BaseVertex * v0,BaseVertex * v1)117 inline BaseEdge( BaseVertex * v0, BaseVertex * v1) 118 { 119 V(0)=v0; 120 V(1)=v1; 121 } 122 //EdgeBase<BaseVertex,BaseEdge,BaseFace>(v0,v1){}; OrderedEdge(BaseVertex * v0,BaseVertex * v1)123 static inline BaseEdge OrderedEdge(BaseVertex* v0,BaseVertex* v1){ 124 if(v0<v1) return BaseEdge(v0,v1); 125 else return BaseEdge(v1,v0); 126 } 127 }; 128 129 130 class BaseFace : public vcg::Face < BaseUsedTypes, 131 vcg::face::VFAdj, 132 vcg::face::FFAdj, 133 vcg::face::VertexRef, 134 vcg::face::BitFlags, 135 vcg::face::EdgePlane, 136 vcg::face::Mark, 137 vcg::face::Normal3f, 138 vcg::face::Color4b, 139 vcg::face::Quality3f> 140 { 141 public: 142 std::vector<std::pair<BaseVertex*,vcg::Point3f> > vertices_bary; 143 typedef std::vector<std::pair<BaseVertex*,vcg::Point3f> >::iterator IteVBary; 144 vcg::Color4b group; 145 ScalarType areadelta; 146 vcg::Color4b colorDivision; 147 148 template < class LeftV> ImportData(const LeftV & left)149 void ImportData(const LeftV & left ) 150 { 151 vcg::Face < BaseUsedTypes, 152 vcg::face::VFAdj, 153 vcg::face::FFAdj, 154 vcg::face::VertexRef, 155 vcg::face::BitFlags, 156 vcg::face::EdgePlane, 157 vcg::face::Mark, 158 vcg::face::Normal3f, 159 vcg::face::Color4b, 160 vcg::face::Quality3f>::ImportData(left); 161 } 162 ImportData(const BaseFace & left)163 void ImportData(const BaseFace & left ) 164 { 165 vcg::Face < BaseUsedTypes, 166 vcg::face::VFAdj, 167 vcg::face::FFAdj, 168 vcg::face::VertexRef, 169 vcg::face::BitFlags, 170 vcg::face::EdgePlane, 171 vcg::face::Mark, 172 vcg::face::Normal3f, 173 vcg::face::Color4b, 174 vcg::face::Quality3f>::ImportData(left); 175 this->vertices_bary = std::vector<std::pair<BaseVertex*,vcg::Point3f> > (left.vertices_bary); 176 this->group=left.group; 177 this->areadelta=left.areadelta; 178 this->colorDivision=left.colorDivision; 179 } 180 181 182 }; 183 184 /// the main mesh class 185 class BaseMesh: public vcg::tri::TriMesh<std::vector<BaseVertex>, std::vector<BaseFace> > {}; 186 187 #endif 188