| OpenMesh

CompositeTraits.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
48 //=============================================================================
49 //
50 // CLASS Traits
51 //
52 //=============================================================================
53
54 #ifndef OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITETRAITS_HH
55 #define OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITETRAITS_HH
56
57
58 //== INCLUDES =================================================================
59
60 //#include "Config.hh"
61 // --------------------
62 #include <OpenMesh/Core/Mesh/Traits.hh>
63 #include <OpenMesh/Core/Mesh/Attributes.hh>
64
65
66 //== NAMESPACE ================================================================
67
68 namespace OpenMesh { // BEGIN_NS_OPENMESH
69 namespace Subdivider { // BEGIN_NS_DECIMATER
70 namespace Uniform { // BEGIN_NS_UNIFORM
71
72
73 //== CLASS DEFINITION =========================================================
74
75
79 struct CompositeTraits : public OpenMesh::DefaultTraits
80 {
81 FaceAttributes( OpenMesh::Attributes::Normal );
82
83 VertexAttributes( OpenMesh::Attributes::Normal );
84
85 //HalfedgeAttributes( OpenMesh::Attributes::PrevHalfedge );
86
87 FaceTraits
88 {
89 private:
90 typedef typename Refs::HalfedgeHandle HalfedgeHandle;
91 typedef typename Refs::Scalar Scalar;
92 typedef typename Refs::Point Point;
93 HalfedgeHandle red_halfedge_handle_;
94 unsigned int generation_;
95 bool red_;
96 Scalar quality_;
97 Point midpoint_;
98 Point position_;
99
100 public:
101 const unsigned int& generation() { return generation_; }
102 void set_generation(const unsigned int& _g) { generation_ = _g; }
103 void inc_generation() { ++generation_; }
104 void set_red() { red_ = 1; }
105 void set_green() {red_ = 0; }
106 bool is_red() { return red_; }
107 bool is_green() { return !red_; }
108 void set_red_halfedge_handle(HalfedgeHandle& _heh)
109 { red_halfedge_handle_ = _heh; }
110 HalfedgeHandle& red_halfedge_handle() { return red_halfedge_handle_; }
111 void set_quality(Scalar& _q) { quality_ = _q; }
112 Scalar& quality() { return quality_; }
113 const Point& midpoint() const { return midpoint_; }
114 void set_midpoint(const Point& _p) { midpoint_ = _p; }
115 const Point& position() const { return position_; }
116 void set_position(const Point& _p) { position_ = _p; }
117 };
118
119 EdgeTraits
120 {
121 private:
122 typedef typename Refs::Point Point;
123 typedef typename Refs::Scalar Scalar;
124 Point midpoint_;
125 Scalar length_;
126 Point position_;
127 public:
128 const Point& midpoint() const { return midpoint_; }
129 void set_midpoint(const Point& _vh) { midpoint_ = _vh; }
130 const Scalar& length() const { return length_; }
131 void set_length(const Scalar& _s) { length_ = _s; }
132 const Point& position() const { return position_; }
133 void set_position(const Point& _p) { position_ = _p; }
134 };
135
136 VertexTraits
137 {
138 private:
139 typedef typename Refs::Point Point;
140 Point new_pos_;
141 Point orig_pos_;
142 Point position_;
143 unsigned int generation_;
144 public:
145 const Point& new_pos() const { return new_pos_; }
146 void set_new_pos(const Point& _p) { new_pos_ = _p; }
147 const unsigned int& generation() const { return generation_; }
148 void set_generation(const unsigned int& _i) { generation_ = _i; }
149 const Point& orig_pos() const { return orig_pos_; }
150 void set_orig_pos(const Point& _p) { orig_pos_ = _p; }
151 const Point& position() const { return position_; }
152 void set_position(const Point& _p) { position_ = _p; }
153 };
154 };
155
156 //=============================================================================
157 } // END_NS_UNIFORM
158 } // END_NS_SUBDIVIDER
159 } // END_NS_OPENMESH
160 //=============================================================================
161 #endif // OPENMESH_SUBDIVIDER_UNIFORM_COMPOSITETRAITS_HH defined
162 //=============================================================================
163
OpenMesh::DefaultTraits
Base class for all traits.
Definition: Traits.hh:121
OpenMesh::Subdivider::Uniform::CompositeTraits
Uniform Composite Subdivision framework.
Definition: CompositeTraits.hh:79
VertexTraits
#define VertexTraits
Macro for defining the vertex traits. See Specifying your MyMesh.
Definition: Traits.hh:91
Traits.hh
This file defines the default traits and some convenience macros.
OpenMesh::Attributes::Normal
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:82
EdgeTraits
#define EdgeTraits
Macro for defining the edge traits. See Specifying your MyMesh.
Definition: Traits.hh:99
Attributes.hh
This file provides some macros containing attribute usage.
OpenMesh
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
OpenMesh::DefaultTraits::Point
Vec3f Point
The default coordinate type is OpenMesh::Vec3f.
Definition: Traits.hh:124
FaceTraits
#define FaceTraits
Macro for defining the face traits. See Specifying your MyMesh.
Definition: Traits.hh:103