51#ifndef OPENMESH_SUBDIVIDER_ADAPTIVE_RULEINTERFACET_HH
52#define OPENMESH_SUBDIVIDER_ADAPTIVE_RULEINTERFACET_HH
69template <
typename M>
class CompositeT;
70template <
typename M>
class RuleInterfaceT;
82template <
typename R >
88 operator bool()
const {
return is_valid(); }
95#define COMPOSITE_RULE( classname, mesh_type ) \
97 friend class CompositeT<mesh_type>; \
99 const char *type() const override { return #classname; } \
100 typedef classname<mesh_type> Self; \
101 typedef RuleHandleT< Self > Handle
116 typedef typename M::Scalar scalar_t;
121 RuleInterfaceT(Mesh& _mesh) :
mesh_(_mesh),prev_rule_(nullptr),subdiv_rule_(nullptr),subdiv_type_(0),number_(0),n_rules_(0) {};
131 virtual const char *
type()
const = 0;
140 if (
mesh_.data(_fh).state() < _target_state) {
141 update(_fh, _target_state);
142 mesh_.data(_fh).inc_state();
148 if (
mesh_.data(_eh).state() < _target_state) {
149 update(_eh, _target_state);
150 mesh_.data(_eh).inc_state();
154 virtual void raise(
typename M::VertexHandle& _vh,
state_t _target_state)
156 if (
mesh_.data(_vh).state() < _target_state) {
157 update(_vh, _target_state);
158 mesh_.data(_vh).inc_state();
165 typename M::FaceHandle opp_fh;
167 while (
mesh_.data(_fh).state() < _target_state - 1) {
174 if (
mesh_.face_handle(
mesh_.opposite_halfedge_handle(
mesh_.halfedge_handle(_fh))).is_valid()) {
176 while (!
mesh_.data(_fh).final()) {
178 opp_fh =
mesh_.face_handle(
mesh_.opposite_halfedge_handle(
mesh_.halfedge_handle(_fh)));
180 assert (
mesh_.data(_fh).state() >=
181 mesh_.data(opp_fh).state());
184 if (
mesh_.data(_fh).state() >
mesh_.data(opp_fh).state()){
229 mesh_.data(_fh).final() ||
232 typename M::FaceEdgeIter fe_it;
233 typename M::FaceVertexIter fv_it;
234 typename M::EdgeHandle eh;
235 typename M::VertexHandle vh;
237 std::vector<typename M::FaceHandle> face_vector;
240 if (_target_state > 1) {
242 for (fe_it =
mesh_.fe_iter(_fh); fe_it.is_valid(); ++fe_it) {
248 for (fv_it =
mesh_.fv_iter(_fh); fv_it.is_valid(); ++fv_it) {
262 if (state + 1 < _target_state && _target_state > 0) {
267 typename M::VertexHandle vh;
268 typename M::FaceHandle fh;
270 if (_target_state > 1)
272 vh =
mesh_.to_vertex_handle(
mesh_.halfedge_handle(_eh, 0));
275 vh =
mesh_.to_vertex_handle(
mesh_.halfedge_handle(_eh, 1));
278 fh =
mesh_.face_handle(
mesh_.halfedge_handle(_eh, 0));
282 fh =
mesh_.face_handle(
mesh_.halfedge_handle(_eh, 1));
294 if (state + 1 < _target_state)
299 std::vector<typename M::HalfedgeHandle> halfedge_vector;
300 halfedge_vector.clear();
302 typename M::VertexOHalfedgeIter voh_it;
303 typename M::EdgeHandle eh;
304 typename M::FaceHandle fh;
306 if (_target_state > 1)
309 for (voh_it =
mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it) {
310 halfedge_vector.push_back(*voh_it);
313 while ( !halfedge_vector.empty() ) {
314 eh =
mesh_.edge_handle(halfedge_vector.back());
315 halfedge_vector.pop_back();
320 for (voh_it =
mesh_.voh_iter(_vh); voh_it.is_valid(); ++voh_it) {
321 halfedge_vector.push_back(*voh_it);
324 while ( !halfedge_vector.empty() ) {
325 fh =
mesh_.face_handle(halfedge_vector.back());
326 halfedge_vector.pop_back();
348 virtual void set_coeff( scalar_t _coeff ) { coeff_ = _coeff; }
351 scalar_t
coeff()
const {
return coeff_; }
369 { assert(_n == 3 || _n == 4); subdiv_type_ = _n; }
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
CompositeTraits::state_t state_t
Adaptive Composite Subdivision framework.
Definition: CompositeTraits.hh:250
Base class for all handle types.
Definition: Handles.hh:63
bool is_valid() const
The handle is valid iff the index is not negative.
Definition: Handles.hh:72
Handle template for adaptive composite subdividion rules.
Definition: RuleInterfaceT.hh:84
Base class for adaptive composite subdivision rules.
Definition: RuleInterfaceT.hh:109
void set_subdiv_type(int _n)
Set coefficient - ignored by non-parameterized rules.
Definition: RuleInterfaceT.hh:368
void update(typename M::EdgeHandle &_eh, state_t _target_state)
Raise item to target state _target_state.
Definition: RuleInterfaceT.hh:257
virtual void raise(typename M::FaceHandle &_fh, state_t _target_state)
Raise item to target state _target_state.
Definition: RuleInterfaceT.hh:138
Mesh & mesh_
Set coefficient - ignored by non-parameterized rules.
Definition: RuleInterfaceT.hh:375
scalar_t coeff() const
Get coefficient - ignored by non-parameterized rules.
Definition: RuleInterfaceT.hh:351
virtual void raise(typename M::EdgeHandle &_eh, state_t _target_state)
Raise item to target state _target_state.
Definition: RuleInterfaceT.hh:146
void update(typename M::VertexHandle &_vh, state_t _target_state)
Raise item to target state _target_state.
Definition: RuleInterfaceT.hh:289
void set_prev_rule(Self *&_p)
Set coefficient - ignored by non-parameterized rules.
Definition: RuleInterfaceT.hh:357
int number() const
Position in rule sequence.
Definition: RuleInterfaceT.hh:342
Self * subdiv_rule() const
Set coefficient - ignored by non-parameterized rules.
Definition: RuleInterfaceT.hh:361
virtual ~RuleInterfaceT()
Destructor.
Definition: RuleInterfaceT.hh:126
Self * prev_rule()
Set coefficient - ignored by non-parameterized rules.
Definition: RuleInterfaceT.hh:358
virtual void raise(typename M::VertexHandle &_vh, state_t _target_state)
Raise item to target state _target_state.
Definition: RuleInterfaceT.hh:154
RuleInterfaceT(Mesh &_mesh)
Default constructor.
Definition: RuleInterfaceT.hh:121
int subdiv_type() const
Type of split operation, if it is a topological operator.
Definition: RuleInterfaceT.hh:338
void set_subdiv_rule(Self *&_n)
Set coefficient - ignored by non-parameterized rules.
Definition: RuleInterfaceT.hh:360
void set_number(int _n)
Set coefficient - ignored by non-parameterized rules.
Definition: RuleInterfaceT.hh:363
void update(typename M::FaceHandle &_fh, state_t _target_state)
Raise item to target state _target_state.
Definition: RuleInterfaceT.hh:163
virtual const char * type() const =0
Returns the name of the rule.
void set_n_rules(int _n)
Set coefficient - ignored by non-parameterized rules.
Definition: RuleInterfaceT.hh:365
virtual void set_coeff(scalar_t _coeff)
Set coefficient - ignored by non-parameterized rules.
Definition: RuleInterfaceT.hh:348
int n_rules() const
Set coefficient - ignored by non-parameterized rules.
Definition: RuleInterfaceT.hh:366
Adaptive Composite Subdivision framework.
Definition: CompositeT.hh:134
Mesh traits for adaptive composite subdivider.