52 #ifndef OPENMESH_SUBDIVIDER_ADAPTIVE_COMPOSITET_HH
53 #define OPENMESH_SUBDIVIDER_ADAPTIVE_COMPOSITET_HH
58 #include <OpenMesh/Core/System/config.hh>
69 namespace Subdivider {
137 typedef std::vector<Rule*> RuleSequence;
139 typedef typename M::VertexHandle VH;
140 typedef typename M::FaceHandle FH;
141 typedef typename M::EdgeHandle EH;
142 typedef typename M::HalfedgeHandle HH;
149 subdiv_rule_(NULL), mesh_(_mesh)
164 std::for_each(rule_sequence_.begin(),
165 rule_sequence_.end(), DeleteRule() );
166 rule_sequence_.clear();
175 void refine(
typename M::FaceHandle& _fh);
179 void refine(
typename M::VertexHandle& _vh);
187 const Rule& subdiv_rule()
const {
return *subdiv_rule_; }
198 template <
typename R >
201 size_t idx = rule_sequence_.size();
202 rule_sequence_.push_back(
new R( mesh_ ) );
203 return RuleHandleT<R>( (idx < rule_sequence_.size()) ? idx : -1 );
210 template <
typename R >
213 return _rh = add< R >();
221 template <
typename R >
224 typedef typename RuleHandleT<R>::Rule rule_t;
226 return *
dynamic_cast<rule_t*
>(rule_sequence_[ _rh.
idx() ]);
238 return *rule_sequence_[ _idx ];
242 size_t n_rules()
const {
return rule_sequence_.size(); }
252 const RuleSequence&
rules()
const {
return rule_sequence_; }
258 state_t generation( VH _vh ) {
return generation(mesh_.data(_vh).state()); }
259 state_t generation( EH _eh ) {
return generation(mesh_.data(_eh).state()); }
260 state_t generation( FH _fh ) {
return generation(mesh_.data(_fh).state()); }
265 Rule* t_rule() {
return subdiv_rule_; }
266 Rule* f_rule() {
return rule_sequence_.front(); }
267 Rule* l_rule() {
return rule_sequence_.back(); }
272 RuleSequence rule_sequence_;
286 #ifndef DOXY_IGNORE_THIS
287 struct DeleteRule {
void operator()( Rule* _r ) {
delete _r; } };
303 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SUBDIVIDER_ADAPTIVE_COMPOSITET_CC)
304 # define OPENMESH_SUBDIVIDER_TEMPLATES
305 # include "CompositeT.cc"
308 #endif // OPENMESH_SUBDIVIDER_ADAPTIVE_COMPOSITET_HH defined
CompositeT(Mesh &_mesh)
Constructor.
Definition: CompositeT.hh:147
std::string rules_as_string(const std::string &_sep=" * ") const
Return the sequence as string.
Definition: CompositeT.cc:288
bool initialize(void)
Initialize faces, edges, vertices, and rules.
Definition: CompositeT.cc:76
size_t n_rules() const
Number of rules in the rule sequence.
Definition: CompositeT.hh:242
Base class for adaptive composite subdivision rules.
Definition: CompositeT.hh:77
int idx() const
Get the underlying index of this handle.
Definition: Handles.hh:67
RuleInterfaceT< M > & rule(size_t _idx)
Get rule (interface) by index.
Definition: CompositeT.hh:235
RuleHandleT< R >::Rule & rule(const RuleHandleT< R > &_rh)
Get rule in the rule sequence by a handle.
Definition: CompositeT.hh:222
CompositeTraits::state_t state_t
Adaptive Composite Subdivision framework.
Definition: CompositeTraits.hh:248
Adaptive Composite Subdivision framework.
Definition: CompositeT.hh:131
void refine(typename M::FaceHandle &_fh)
Refine one face.
Definition: CompositeT.cc:173
RuleHandleT< R > add()
Add new rule to rule sequence by passing the type of the wanted rule as template argument to the meth...
Definition: CompositeT.hh:199
const RuleSequence & rules() const
The rule sequence.
Definition: CompositeT.hh:252
int subdiv_type()
Return subdivision split type (3 for 1-to-3 split, 4 for 1-to-4 split).
Definition: CompositeT.hh:183
Handle template for adaptive composite subdividion rules.
Definition: CompositeT.hh:76
RuleHandleT< R > & add(RuleHandleT< R > &_rh)
Add new rule to rule sequence by passing an appropriate handle to the method.
Definition: CompositeT.hh:211
void cleanup(void)
Reset self to state after the default constructor except of the mesh.
Definition: CompositeT.hh:159
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:56
bool is_valid() const
The handle is valid iff the index is not equal to -1.
Definition: Handles.hh:70
Mesh traits for adaptive composite subdivider.