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;
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();
Base class for all handle types.
bool is_valid() const
The handle is valid iff the index is not negative.
void set_subdiv_type(int _n)
Set coefficient - ignored by non-parameterized rules.
void update(typename M::EdgeHandle &_eh, state_t _target_state)
Raise item to target state _target_state.
virtual void raise(typename M::FaceHandle &_fh, state_t _target_state)
Raise item to target state _target_state.
Mesh & mesh_
Set coefficient - ignored by non-parameterized rules.
int n_rules_
Set coefficient - ignored by non-parameterized rules.
scalar_t coeff() const
Get coefficient - ignored by non-parameterized rules.
RuleInterfaceT(const RuleInterfaceT &)
Set coefficient - ignored by non-parameterized rules.
virtual void raise(typename M::EdgeHandle &_eh, state_t _target_state)
Raise item to target state _target_state.
int number_
Set coefficient - ignored by non-parameterized rules.
void update(typename M::VertexHandle &_vh, state_t _target_state)
Raise item to target state _target_state.
scalar_t coeff_
Set coefficient - ignored by non-parameterized rules.
void set_prev_rule(Self *&_p)
Set coefficient - ignored by non-parameterized rules.
int number() const
Position in rule sequence.
Self * subdiv_rule() const
Set coefficient - ignored by non-parameterized rules.
virtual ~RuleInterfaceT()
Destructor.
Self * prev_rule()
Set coefficient - ignored by non-parameterized rules.
virtual void raise(typename M::VertexHandle &_vh, state_t _target_state)
Raise item to target state _target_state.
RuleInterfaceT(Mesh &_mesh)
Default constructor.
int subdiv_type() const
Type of split operation, if it is a topological operator.
void set_subdiv_rule(Self *&_n)
Set coefficient - ignored by non-parameterized rules.
Self * prev_rule_
Set coefficient - ignored by non-parameterized rules.
RuleInterfaceT & operator=(const RuleInterfaceT &)
Set coefficient - ignored by non-parameterized rules.
void set_number(int _n)
Set coefficient - ignored by non-parameterized rules.
void update(typename M::FaceHandle &_fh, state_t _target_state)
Raise item to target state _target_state.
virtual const char * type() const =0
void set_n_rules(int _n)
Set coefficient - ignored by non-parameterized rules.
virtual void set_coeff(scalar_t _coeff)
Set coefficient - ignored by non-parameterized rules.
int subdiv_type_
Set coefficient - ignored by non-parameterized rules.
int n_rules() const
Set coefficient - ignored by non-parameterized rules.
Self * subdiv_rule_
Set coefficient - ignored by non-parameterized rules.
CompositeTraits::state_t state_t