52 #define OPENMESH_SUBDIVIDER_ADAPTIVE_COMPOSITET_CC
57 #include <OpenMesh/Core/System/config.hh>
61 #include <OpenMesh/Tools/Subdivider/Adaptive/Composite/RuleInterfaceT.hh>
67 namespace Subdivider {
82 const typename Mesh::Point zero_point(0.0, 0.0, 0.0);
85 for (v_it = mesh_.vertices_begin(); v_it != mesh_.vertices_end(); ++v_it)
87 mesh_.data(*v_it).set_state(0);
88 mesh_.data(*v_it).set_final();
89 mesh_.data(*v_it).set_position(0, mesh_.point(*v_it));
93 for (f_it = mesh_.faces_begin(); f_it != mesh_.faces_end(); ++f_it)
95 mesh_.data(*f_it).set_state(0);
96 mesh_.data(*f_it).set_final();
97 mesh_.data(*f_it).set_position(0, zero_point);
101 for (e_it = mesh_.edges_begin(); e_it != mesh_.edges_end(); ++e_it)
103 mesh_.data(*e_it).set_state(0);
104 mesh_.data(*e_it).set_final();
105 mesh_.data(*e_it).set_position(0, zero_point);
111 int n_subdiv_rules_ = 0;
115 for (
size_t i=0; i < n_rules(); ++i) {
117 if (rule_sequence_[i]->type()[0] ==
'T' ||
118 rule_sequence_[i]->type()[0] ==
't')
121 subdiv_rule_ = rule_sequence_[i];
122 subdiv_type_ = rule_sequence_[i]->subdiv_type();
128 assert(n_subdiv_rules_ == 1);
130 if (n_subdiv_rules_ != 1)
132 ::omerr() <<
"Error! More than one subdivision rules not allowed!\n";
137 assert(subdiv_type_ == 3 || subdiv_type_ == 4);
139 if (subdiv_type_ != 3 && subdiv_type_ != 4)
141 ::omerr() <<
"Error! Unknown subdivision type in sequence!" << std::endl;
150 for (
size_t i = 0; i < n_rules(); ++i)
152 rule_sequence_[i]->set_subdiv_type(subdiv_type_);
153 rule_sequence_[i]->set_n_rules(n_rules());
154 rule_sequence_[i]->set_number(i);
155 rule_sequence_[i]->set_prev_rule(rule_sequence_[(i+n_rules()-1)%n_rules()]);
156 rule_sequence_[i]->set_subdiv_rule(subdiv_rule_);
164 #define MOBJ mesh_.deref
165 #define TVH to_vertex_handle
166 #define HEH halfedge_handle
167 #define NHEH next_halfedge_handle
168 #define PHEH prev_halfedge_handle
169 #define OHEH opposite_halfedge_handle
176 std::vector<typename Mesh::HalfedgeHandle> hh_vector;
180 t_rule()->number() + 1 +
181 ((int)floor((
float)(mesh_.data(_fh).state() - t_rule()->number() - 1)/n_rules()) + 1) * n_rules();
183 int new_vertex_level =
184 new_face_level + l_rule()->number() - t_rule()->number();
190 vh[0] = mesh_.TVH(mesh_.HEH(_fh));
191 vh[1] = mesh_.TVH(mesh_.NHEH(mesh_.HEH(_fh)));
192 vh[2] = mesh_.TVH(mesh_.PHEH(mesh_.HEH(_fh)));
196 if (subdiv_type_ == 4)
201 if (mesh_.data(_fh).final())
205 for (; fh_it.is_valid(); ++fh_it)
207 hh_vector.push_back(mesh_.PHEH(mesh_.OHEH(*fh_it)));
217 hh_vector.push_back(mesh_.PHEH(mesh_.OHEH(mesh_.NHEH(red_hh))));
218 hh_vector.push_back(mesh_.PHEH(mesh_.OHEH(mesh_.PHEH(mesh_.OHEH(red_hh)))));
224 if (t_rule()->number() > 0)
225 t_rule()->prev_rule()->raise(_fh, new_face_level-1);
228 t_rule()->raise(_fh, new_face_level);
231 assert(MOBJ(_fh).state() >=
232 subdiv_rule_->number()+1+(
int) (MOBJ(_fh).state()/n_rules())*n_rules());
234 assert( mesh_.data(_fh).state() >= ( t_rule()->number()+1+generation(_fh) ) );
238 if (subdiv_type_ == 3)
243 l_rule()->raise(new_vh, new_vertex_level);
246 if (subdiv_type_ == 4)
251 while (!hh_vector.empty()) {
253 hh = hh_vector.back();
254 hh_vector.pop_back();
257 new_vh = mesh_.TVH(mesh_.NHEH(hh));
260 l_rule()->raise(new_vh, new_vertex_level);
265 l_rule()->raise(vh[0], new_vertex_level);
266 l_rule()->raise(vh[1], new_vertex_level);
267 l_rule()->raise(vh[2], new_vertex_level);
278 int new_vertex_state = generation(_vh) + l_rule()->number() + 1;
281 l_rule()->raise(_vh, new_vertex_state);
292 typename RuleSequence::const_iterator it = rule_sequence_.begin();
294 if ( it != rule_sequence_.end() )
297 for (++it; it != rule_sequence_.end(); ++it )
300 seq += (*it)->type();
This file provides the streams omlog, omout, and omerr.
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Definition: PolyMeshT.hh:136
Kernel::FaceIter FaceIter
Scalar type.
Definition: PolyMeshT.hh:146
Kernel::HalfedgeHandle HalfedgeHandle
Scalar type.
Definition: PolyMeshT.hh:137
Kernel::EdgeIter EdgeIter
Scalar type.
Definition: PolyMeshT.hh:145
Kernel::FaceHalfedgeIter FaceHalfedgeIter
Circulator.
Definition: PolyMeshT.hh:168
Kernel::Point Point
Coordinate type.
Definition: PolyMeshT.hh:112
Kernel::VertexIter VertexIter
Scalar type.
Definition: PolyMeshT.hh:143
Adaptive Composite Subdivision framework.
Definition: CompositeT.hh:134
std::string rules_as_string(const std::string &_sep=" * ") const
Return the sequence as string.
Definition: CompositeT_impl.hh:289
void refine(typename M::FaceHandle &_fh)
Refine one face.
Definition: CompositeT_impl.hh:174