OpenMesh
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CatmullClarkT.hh
Go to the documentation of this file.
1 /*===========================================================================*\
2  * *
3  * OpenMesh *
4  * Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
5  * www.openmesh.org *
6  * *
7  *---------------------------------------------------------------------------*
8  * This file is part of OpenMesh. *
9  * *
10  * OpenMesh is free software: you can redistribute it and/or modify *
11  * it under the terms of the GNU Lesser General Public License as *
12  * published by the Free Software Foundation, either version 3 of *
13  * the License, or (at your option) any later version with the *
14  * following exceptions: *
15  * *
16  * If other files instantiate templates or use macros *
17  * or inline functions from this file, or you compile this file and *
18  * link it with other files to produce an executable, this file does *
19  * not by itself cause the resulting executable to be covered by the *
20  * GNU Lesser General Public License. This exception does not however *
21  * invalidate any other reasons why the executable file might be *
22  * covered by the GNU Lesser General Public License. *
23  * *
24  * OpenMesh is distributed in the hope that it will be useful, *
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27  * GNU Lesser General Public License for more details. *
28  * *
29  * You should have received a copy of the GNU LesserGeneral Public *
30  * License along with OpenMesh. If not, *
31  * see <http://www.gnu.org/licenses/>. *
32  * *
33 \*===========================================================================*/
34 
35 /*===========================================================================*\
36  * *
37  * $Revision: 520 $ *
38  * $Date: 2012-01-20 15:29:31 +0100 (Fr, 20 Jan 2012) $ *
39  * *
40 \*===========================================================================*/
41 
45 //=============================================================================
46 //
47 // CLASS CatmullClarkT
48 //
49 //=============================================================================
50 
51 
52 #ifndef OPENMESH_SUBDIVIDER_UNIFORM_CATMULLCLARKT_HH
53 #define OPENMESH_SUBDIVIDER_UNIFORM_CATMULLCLARKT_HH
54 
55 
56 //== INCLUDES =================================================================
57 
59 
60 // -------------------- STL
61 #if defined(OM_CC_MIPS)
62 # include <math.h>
63 #else
64 # include <cmath>
65 #endif
66 
67 //== FORWARDDECLARATIONS ======================================================
68 
69 //== NAMESPACES ===============================================================
70 
71 namespace OpenMesh { // BEGIN_NS_OPENMESH
72 namespace Subdivider { // BEGIN_NS_SUBVIDER
73 namespace Uniform { // BEGIN_NS_UNIFORM
74 
75 //== CLASS DEFINITION =========================================================
76 
77 
84 template <typename MeshType, typename RealType = float>
85 class CatmullClarkT : public SubdividerT< MeshType, RealType >
86 {
87 public:
88 
89  typedef typename MeshType::FaceHandle FaceHandle;
90  typedef typename MeshType::VertexHandle VertexHandle;
91  typedef typename MeshType::EdgeHandle EdgeHandle;
92  typedef typename MeshType::HalfedgeHandle HalfedgeHandle;
93 
94  typedef typename MeshType::Point Point;
95  typedef typename MeshType::Normal Normal;
96  typedef typename MeshType::FaceIter FaceIter;
97  typedef typename MeshType::EdgeIter EdgeIter;
98  typedef typename MeshType::VertexIter VertexIter;
99 
100  typedef typename MeshType::VertexEdgeIter VertexEdgeIter;
101  typedef typename MeshType::VertexFaceIter VertexFaceIter;
102 
103  typedef typename MeshType::VOHIter VOHIter;
104 
106 
109 
111  CatmullClarkT(MeshType &_m) : parent_t(_m) { }
112 
113  virtual ~CatmullClarkT() {}
114 
115 public:
116 
117  const char *name() const { return "Uniform CatmullClark"; }
118 
119 protected:
120 
122  virtual bool prepare( MeshType& _m );
123 
125  virtual bool cleanup( MeshType& _m );
126 
134  virtual bool subdivide( MeshType& _m, size_t _n , const bool _update_points = true);
135 
136 private:
137 
138  //===========================================================================
141  //===========================================================================
142 
143  void split_edge( MeshType& _m, const EdgeHandle& _eh);
144 
145  void split_face( MeshType& _m, const FaceHandle& _fh);
146 
147  void compute_midpoint( MeshType& _m, const EdgeHandle& _eh);
148 
149  void update_vertex(MeshType& _m, const VertexHandle& _vh);
150 
154 private:
155  OpenMesh::VPropHandleT< Point > vp_pos_; // next vertex pos
156  OpenMesh::EPropHandleT< Point > ep_pos_; // new edge pts
157  OpenMesh::FPropHandleT< Point > fp_pos_; // new face pts
158  OpenMesh::EPropHandleT<double> creaseWeights_;// crease weights
159 
160 };
161 
162 
163 //=============================================================================
164 } // END_NS_UNIFORM
165 } // END_NS_SUBDIVIDER
166 } // END_NS_OPENMESH
167 //=============================================================================
168 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SUBDIVIDER_UNIFORM_CATMULLCLARK_CC)
169 # define OPENMESH_SUBDIVIDER_TEMPLATES
170 # include "CatmullClarkT.cc"
171 #endif
172 //=============================================================================
173 #endif // OPENMESH_SUBDIVIDER_UNIFORM_CATMULLCLARKT_HH defined
174 //=============================================================================
175 

acg pic Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .