OpenMesh
CatmullClarkT.hh
Go to the documentation of this file.
1 /* ========================================================================= *
2  * *
3  * OpenMesh *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openmesh.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenMesh. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39  * *
40  * ========================================================================= */
41 
42 /*===========================================================================*\
43  * *
44  * $Revision: 520 $ *
45  * $Date: 2012-01-20 15:29:31 +0100 (Fr, 20 Jan 2012) $ *
46  * *
47 \*===========================================================================*/
48 
52 //=============================================================================
53 //
54 // CLASS CatmullClarkT
55 //
56 //=============================================================================
57 
58 
59 #ifndef OPENMESH_SUBDIVIDER_UNIFORM_CATMULLCLARKT_HH
60 #define OPENMESH_SUBDIVIDER_UNIFORM_CATMULLCLARKT_HH
61 
62 
63 //== INCLUDES =================================================================
64 
66 
67 // -------------------- STL
68 #if defined(OM_CC_MIPS)
69 # include <math.h>
70 #else
71 # include <cmath>
72 #endif
73 
74 //== FORWARDDECLARATIONS ======================================================
75 
76 //== NAMESPACES ===============================================================
77 
78 namespace OpenMesh { // BEGIN_NS_OPENMESH
79 namespace Subdivider { // BEGIN_NS_SUBVIDER
80 namespace Uniform { // BEGIN_NS_UNIFORM
81 
82 //== CLASS DEFINITION =========================================================
83 
84 
91 template <typename MeshType, typename RealType = double>
92 class CatmullClarkT : public SubdividerT< MeshType, RealType >
93 {
94 public:
95 
96  typedef typename MeshType::FaceHandle FaceHandle;
97  typedef typename MeshType::VertexHandle VertexHandle;
98  typedef typename MeshType::EdgeHandle EdgeHandle;
99  typedef typename MeshType::HalfedgeHandle HalfedgeHandle;
100 
101  typedef typename MeshType::Point Point;
102  typedef typename MeshType::Normal Normal;
103  typedef typename MeshType::FaceIter FaceIter;
104  typedef typename MeshType::EdgeIter EdgeIter;
105  typedef typename MeshType::VertexIter VertexIter;
106 
107  typedef typename MeshType::VertexEdgeIter VertexEdgeIter;
108  typedef typename MeshType::VertexFaceIter VertexFaceIter;
109 
110  typedef typename MeshType::VOHIter VOHIter;
111 
113 
115  CatmullClarkT( ) : parent_t() { }
116 
118  explicit CatmullClarkT(MeshType &_m) : parent_t(_m) { }
119 
120  virtual ~CatmullClarkT() {}
121 
122 public:
123 
124  const char *name() const { return "Uniform CatmullClark"; }
125 
126 protected:
127 
129  virtual bool prepare( MeshType& _m );
130 
132  virtual bool cleanup( MeshType& _m );
133 
141  virtual bool subdivide( MeshType& _m, size_t _n , const bool _update_points = true);
142 
143 private:
144 
145  //===========================================================================
148  //===========================================================================
149 
150  void split_edge( MeshType& _m, const EdgeHandle& _eh);
151 
152  void split_face( MeshType& _m, const FaceHandle& _fh);
153 
154  void compute_midpoint( MeshType& _m, const EdgeHandle& _eh, const bool _update_points);
155 
156  void update_vertex(MeshType& _m, const VertexHandle& _vh);
157 
161 private:
162  OpenMesh::VPropHandleT< Point > vp_pos_; // next vertex pos
163  OpenMesh::EPropHandleT< Point > ep_pos_; // new edge pts
164  OpenMesh::FPropHandleT< Point > fp_pos_; // new face pts
165  OpenMesh::EPropHandleT<double> creaseWeights_;// crease weights
166 
167 };
168 
169 
170 //=============================================================================
171 } // END_NS_UNIFORM
172 } // END_NS_SUBDIVIDER
173 } // END_NS_OPENMESH
174 //=============================================================================
175 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SUBDIVIDER_UNIFORM_CATMULLCLARK_CC)
176 # define OPENMESH_SUBDIVIDER_TEMPLATES
177 # include "CatmullClarkT.cc"
178 #endif
179 //=============================================================================
180 #endif // OPENMESH_SUBDIVIDER_UNIFORM_CATMULLCLARKT_HH defined
181 //=============================================================================
182 
CatmullClarkT(MeshType &_m)
Constructor.
Definition: CatmullClarkT.hh:118
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:64
CatmullClarkT()
Constructor.
Definition: CatmullClarkT.hh:115
const char * name() const
Return name of subdivision algorithm.
Definition: CatmullClarkT.hh:124
virtual bool cleanup(MeshType &_m)
Remove properties and weights.
Definition: CatmullClarkT.cc:90
Abstract base class for uniform subdivision algorithms.
Definition: SubdividerT.hh:93
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:87
virtual bool prepare(MeshType &_m)
Initialize properties and weights.
Definition: CatmullClarkT.cc:72
virtual bool subdivide(MeshType &_m, size_t _n, const bool _update_points=true)
Execute n subdivision steps.
Definition: CatmullClarkT.cc:103
Based on code from Leon Kos, CAD lab, Mech.Eng., University of Ljubljana, Slovenia (http://www...
Definition: CatmullClarkT.hh:92

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