OpenMesh: OpenMesh/Tools/Subdivider/Uniform/Composite/CompositeTraits.hh Source File

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