54 #ifndef OPENMESH_SUBDIVIDER_ADAPTIVE_COMPOSITET_HH 55 #define OPENMESH_SUBDIVIDER_ADAPTIVE_COMPOSITET_HH 60 #include <OpenMesh/Core/System/config.hh> 71 namespace Subdivider {
139 typedef std::vector<Rule*> RuleSequence;
141 typedef typename M::VertexHandle VH;
142 typedef typename M::FaceHandle FH;
143 typedef typename M::EdgeHandle EH;
144 typedef typename M::HalfedgeHandle HH;
151 subdiv_rule_(nullptr), mesh_(_mesh)
164 subdiv_rule_ =
nullptr;
166 std::for_each(rule_sequence_.begin(),
167 rule_sequence_.end(), DeleteRule() );
168 rule_sequence_.clear();
177 void refine(
typename M::FaceHandle& _fh);
181 void refine(
typename M::VertexHandle& _vh);
189 const Rule& subdiv_rule()
const {
return *subdiv_rule_; }
200 template <
typename R >
203 size_t idx = rule_sequence_.size();
204 rule_sequence_.push_back(
new R( mesh_ ) );
205 return RuleHandleT<R>( (idx < rule_sequence_.size()) ? idx : -1 );
212 template <
typename R >
215 return _rh = add< R >();
223 template <
typename R >
226 typedef typename RuleHandleT<R>::Rule rule_t;
228 return *
dynamic_cast<rule_t*
>(rule_sequence_[ _rh.
idx() ]);
240 return *rule_sequence_[ _idx ];
244 size_t n_rules()
const {
return rule_sequence_.size(); }
254 const RuleSequence&
rules()
const {
return rule_sequence_; }
260 state_t generation( VH _vh )
const {
return generation(mesh_.data(_vh).state()); }
261 state_t generation( EH _eh )
const {
return generation(mesh_.data(_eh).state()); }
262 state_t generation( FH _fh )
const {
return generation(mesh_.data(_fh).state()); }
267 Rule* t_rule()
const {
return subdiv_rule_; }
268 Rule* f_rule() {
return rule_sequence_.front(); }
269 Rule* l_rule() {
return rule_sequence_.back(); }
274 RuleSequence rule_sequence_;
288 #ifndef DOXY_IGNORE_THIS 289 struct DeleteRule {
void operator()( Rule* _r ) {
delete _r; } };
305 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SUBDIVIDER_ADAPTIVE_COMPOSITET_CC) 306 # define OPENMESH_SUBDIVIDER_TEMPLATES 307 # include "CompositeT_impl.hh" 310 #endif // OPENMESH_SUBDIVIDER_ADAPTIVE_COMPOSITET_HH defined CompositeT(Mesh &_mesh)
Constructor.
void refine(typename M::FaceHandle &_fh)
Refine one face.
bool initialize(void)
Initialize faces, edges, vertices, and rules.
RuleHandleT< R > & add(RuleHandleT< R > &_rh)
int idx() const
Get the underlying index of this handle.
const RuleSequence & rules() const
The rule sequence.
bool is_valid() const
The handle is valid iff the index is not negative.
RuleInterfaceT< M > & rule(size_t _idx)
std::string rules_as_string(const std::string &_sep=" * ") const
Return the sequence as string.
RuleHandleT< R >::Rule & rule(const RuleHandleT< R > &_rh)
int subdiv_type()
Return subdivision split type (3 for 1-to-3 split, 4 for 1-to-4 split).
CompositeTraits::state_t state_t
size_t n_rules() const
Number of rules in the rule sequence.