1 #ifndef MODBUTTERFLY_H_ 2 #define MODBUTTERFLY_H_ 3 4 /**************************************************************************** 5 * Rgb Triangulations Plugin * 6 * * 7 * Author: Daniele Panozzo (daniele.panozzo@gmail.com) * 8 * Copyright(C) 2007 * 9 * DISI - Department of Computer Science * 10 * University of Genova * 11 * * 12 * All rights reserved. * 13 * * 14 * This program is free software; you can redistribute it and/or modify * 15 * it under the terms of the GNU General Public License as published by * 16 * the Free Software Foundation; either version 2 of the License, or * 17 * (at your option) any later version. * 18 * * 19 * This program is distributed in the hope that it will be useful, * 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 22 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 23 * for more details. * 24 ****************************************************************************/ 25 26 27 #include <vcg/space/point3.h> 28 #include "rgbInfo.h" 29 #include <common/meshmodel.h> 30 #include "rgbPrimitives.h" 31 #include "topologicalOp.h" 32 33 namespace rgbt 34 { 35 //! Contain all the function needed to compute the coordinate of the vertexes. 36 /** Is based on a modified butterfly subdivision adapted for the use on an rgb triangulation */ 37 class ModButterfly 38 { 39 /// The tetrahedral mesh type 40 typedef CMeshO TriMeshType; 41 /// The face type 42 typedef TriMeshType::FaceType FaceType; 43 /// The vertex type 44 typedef FaceType::VertexType VertexType; 45 /// The vertex type pointer 46 typedef FaceType::VertexType* VertexPointer; 47 /// The vertex iterator type 48 typedef TriMeshType::VertexIterator VertexIterator; 49 /// The tetra iterator type 50 typedef TriMeshType::FaceIterator FaceIterator; 51 /// The coordinate type 52 typedef FaceType::VertexType::CoordType CoordType; 53 /// The scalar type 54 typedef TriMeshType::VertexType::ScalarType ScalarType; 55 ///the container of tetrahedron type 56 typedef TriMeshType::FaceContainer FaceContainer; 57 ///the container of vertex type 58 typedef TriMeshType::VertContainer VertContainer; 59 ///half edge type 60 typedef TriMeshType::FaceType::EdgeType EdgeType; 61 /// vector of pos 62 typedef std::vector<EdgeType> EdgeVec; 63 /// Face Pointer 64 typedef TriMeshType::FacePointer FacePointer; 65 /// Edge defined by Face and Index 66 typedef EdgeFI<FacePointer> EdgeFIType; 67 /// Topological Operation Class 68 typedef TopologicalOp<CMeshO,RgbInfo::VERTEXC,RgbInfo::FACEC > TopologicalOpC; 69 /// A Point 70 typedef vcg::Point3f Point; 71 /// RGB Triangle 72 typedef RgbTriangle<CMeshO> RgbTriangleC; 73 /// RGB Vertex 74 typedef RgbVertex<CMeshO> RgbVertexC; 75 /// Pos 76 typedef vcg::face::Pos<FaceType> Pos; 77 78 public: 79 80 /// Compute the initial vertex arity 81 static void init(TriMeshType& m, RgbInfo& info); 82 83 /// find the 4 vertexes of the stencil 84 static void findInitialStencil(RgbTriangleC& t, int EdgeIndex,int level, TopologicalOpC& to, vector<RgbVertexC>* indexes = 0,vector<RgbVertexC>* firstVertexes = 0); 85 86 //! Perform an edge split and set the final position of the new vertex 87 /* Return true if on the current edge was performed only a topological split 88 * return false if a complete split (with update on rgb Info) was performed. the complete split is performed 89 * during the calculation og the stencil 90 */ 91 static bool doSplit(RgbTriangleC& fp, int EdgeIndex, int level, TopologicalOpC& to , vector<FacePointer> *vfp = 0); 92 93 //! Perform an edge collapse 94 static void doCollapse(RgbTriangleC& fp, int EdgeIndex, TopologicalOpC& to, Point3<ScalarType> *p = 0, vector<FacePointer> *vfp = 0); 95 96 //! Rotate the pos of the specified angle 97 static void rotate(RgbVertexC& v, Pos& pos,int angle); 98 99 //! Move to the next point of the same level on the edge where the pos point 100 static RgbVertexC move(RgbVertexC& v, Pos& pos, int level); 101 102 //! Rotate the pos around v until a border edge is reached 103 static void rotateUntilBorder(RgbVertexC& v, Pos& pos); 104 105 //! Compute the position of the new vertex using the pattern for extraordinary vertexes. 106 /* Pos points to the S0 vertex and it contains the common face incident in S0 and S1 107 */ 108 static Point computeExtraordinary(RgbVertexC& v, Pos& pos); 109 110 //! Compute a vector of the coefficient needed by computeExtraordinary 111 static void computeExtraordinaryPattern(vector<double>& pattern, int k); 112 113 //! Return the base arity (if lvl is 0 the value is stored in the vertex elsewhere return 6) 114 static int baseArity(RgbVertexC& v); 115 116 private: 117 /// Auxiliary function for doSplit. It search the vertex in a half of the stencil 118 static void findHalfStencil(RgbVertexC& v, Pos& pos, vector<RgbVertexC>& stencil); 119 }; 120 121 } 122 123 #endif /*MODBUTTERFLY_H_*/ 124