59 #ifndef OPENMESH_SUBDIVIDER_ADAPTIVE_COMPOSITET_HH 60 #define OPENMESH_SUBDIVIDER_ADAPTIVE_COMPOSITET_HH 65 #include <OpenMesh/Core/System/config.hh> 76 namespace Subdivider {
144 typedef std::vector<Rule*> RuleSequence;
146 typedef typename M::VertexHandle VH;
147 typedef typename M::FaceHandle FH;
148 typedef typename M::EdgeHandle EH;
149 typedef typename M::HalfedgeHandle HH;
156 subdiv_rule_(NULL), mesh_(_mesh)
171 std::for_each(rule_sequence_.begin(),
172 rule_sequence_.end(), DeleteRule() );
173 rule_sequence_.clear();
182 void refine(
typename M::FaceHandle& _fh);
186 void refine(
typename M::VertexHandle& _vh);
194 const Rule& subdiv_rule()
const {
return *subdiv_rule_; }
205 template <
typename R >
208 size_t idx = rule_sequence_.size();
209 rule_sequence_.push_back(
new R( mesh_ ) );
210 return RuleHandleT<R>( (idx < rule_sequence_.size()) ? idx : -1 );
217 template <
typename R >
220 return _rh = add< R >();
228 template <
typename R >
231 typedef typename RuleHandleT<R>::Rule rule_t;
233 return *
dynamic_cast<rule_t*
>(rule_sequence_[ _rh.
idx() ]);
245 return *rule_sequence_[ _idx ];
249 size_t n_rules()
const {
return rule_sequence_.size(); }
259 const RuleSequence&
rules()
const {
return rule_sequence_; }
265 state_t generation( VH _vh ) {
return generation(mesh_.data(_vh).state()); }
266 state_t generation( EH _eh ) {
return generation(mesh_.data(_eh).state()); }
267 state_t generation( FH _fh ) {
return generation(mesh_.data(_fh).state()); }
272 Rule* t_rule() {
return subdiv_rule_; }
273 Rule* f_rule() {
return rule_sequence_.front(); }
274 Rule* l_rule() {
return rule_sequence_.back(); }
279 RuleSequence rule_sequence_;
293 #ifndef DOXY_IGNORE_THIS 294 struct DeleteRule {
void operator()( Rule* _r ) {
delete _r; } };
310 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SUBDIVIDER_ADAPTIVE_COMPOSITET_CC) 311 # define OPENMESH_SUBDIVIDER_TEMPLATES 312 # include "CompositeT.cc" 315 #endif // OPENMESH_SUBDIVIDER_ADAPTIVE_COMPOSITET_HH defined bool initialize(void)
Initialize faces, edges, vertices, and rules.
const RuleSequence & rules() const
The rule sequence.
RuleInterfaceT< M > & rule(size_t _idx)
RuleHandleT< R > & add(RuleHandleT< R > &_rh)
bool is_valid() const
The handle is valid iff the index is not equal to -1.
int idx() const
Get the underlying index of this handle.
int subdiv_type()
Return subdivision split type (3 for 1-to-3 split, 4 for 1-to-4 split).
size_t n_rules() const
Number of rules in the rule sequence.
std::string rules_as_string(const std::string &_sep=" * ") const
Return the sequence as string.
void refine(typename M::FaceHandle &_fh)
Refine one face.
CompositeT(Mesh &_mesh)
Constructor.
CompositeTraits::state_t state_t
RuleHandleT< R >::Rule & rule(const RuleHandleT< R > &_rh)