Developer Documentation
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 
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 = double>
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 
108  CatmullClarkT( ) : parent_t() { }
109 
111  explicit CatmullClarkT(MeshType &_m) : parent_t(_m) { }
112 
113  virtual ~CatmullClarkT() {}
114 
115 public:
116 
117  const char *name() const override { return "Uniform CatmullClark"; }
118 
119 protected:
120 
122  virtual bool prepare( MeshType& _m ) override;
123 
125  virtual bool cleanup( MeshType& _m ) override;
126 
134  virtual bool subdivide( MeshType& _m, size_t _n , const bool _update_points = true) override;
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, const bool _update_points);
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_impl.hh"
171 #endif
172 //=============================================================================
173 #endif // OPENMESH_SUBDIVIDER_UNIFORM_CATMULLCLARKT_HH defined
174 //=============================================================================
175 
const char * name() const override
Return name of subdivision algorithm.
virtual bool prepare(MeshType &_m) override
Initialize properties and weights.
virtual bool subdivide(MeshType &_m, size_t _n, const bool _update_points=true) override
Execute n subdivision steps.
virtual bool cleanup(MeshType &_m) override
Remove properties and weights.