sm_decorator.h

来自「CGAL is a collaborative effort of severa」· C头文件 代码 · 共 1,028 行 · 第 1/3 页

H
1,028
字号
}void close_tip_at_source(SHalfedge_handle e, SVertex_handle v) /*{\Mop sets |v| as source of |e| and closes the tip by setting the   corresponding pointers such that |prev(e) == twin(e)| and  |next(twin(e)) == e|.}*/{ link_as_source_of(e,v);   link_as_prev_next_pair(twin(e),e); }void close_tip_at_target(SHalfedge_handle e, SVertex_handle v) /*{\Mop sets |v| as target of |e| and closes the tip by setting the   corresponding pointers such that |prev(twin(e)) == e| and   |next(e) == twin(e)|.}*/{ link_as_target_of(e,v);  link_as_prev_next_pair(e,twin(e)); }void remove_from_adj_list_at_source(SHalfedge_handle e)/*{\Mop removes a halfedge pair |(e,twin(e)| from the adjacency listof |source(e)|. Afterwards |next(prev(e))==next(twin(e))| and|first_out_edge(source(e))| is valid if |degree(source(v))>1| beforethe operation.}*/{  SVertex_handle v = source(e);  if ( is_closed_at_source(e) ) { // last outgoing    v->out_sedge() = SHalfedge_handle();  } else {    if (e == first_out_edge(v)) v->out_sedge() = cap(e);    set_adjacency_at_source_between(cap(e),cas(e));  }}void set_face(SHalfedge_handle e, SFace_handle f) const{ e->incident_sface() = f; }void set_face(SHalfloop_handle l, SFace_handle f) const{ l->incident_sface() = f; }void set_face(SVertex_handle v, SFace_handle f) const{ v->incident_sface() = f; }void set_first_out_edge(SVertex_handle v, SHalfedge_handle e) const{ v->out_sedge() = e; }void set_prev(SHalfedge_handle e, SHalfedge_handle ep) const{ e->sprev() = ep; }void set_next(SHalfedge_handle e, SHalfedge_handle en) const{ e->snext() = en; }void set_source(SHalfedge_handle e, SVertex_handle v) const{ e->source() = v; }/*{\Mtext \headerline{Associated Information}\restoreopdims}*/Sphere_point& point(SVertex_handle v) const/*{\Mop returns the embedding of |v|.}*/{ return v->point(); }Sphere_circle& circle(SHalfedge_handle e) const/*{\Mop returns the plane supporting |e|.}*/{ return e->circle(); }Sphere_circle& circle(SHalfloop_handle l) const/*{\Mop returns the plane supporting |e|.}*/{ return l->circle(); }Mark& mark(SVertex_handle v) const/*{\Mop returns the mark of |v|.}*/{ return v->mark(); }Mark& mark(SHalfedge_handle e) const/*{\Mop returns the mark of |e|.}*/{ return e->mark(); }Mark& mark(SHalfloop_handle l) const/*{\Mop returns the mark of |l|.}*/{ return l->mark(); }Mark& mark(SFace_handle f) const/*{\Mop returns the mark of |f|.}*/{ return f->mark(); }const Sphere_point& point(SVertex_const_handle v) const{ return v->point(); }const Sphere_circle& circle(SHalfedge_const_handle e) const{ return e->circle(); }const Sphere_circle& circle(SHalfloop_const_handle l) const{ return l->circle(); }const Mark& mark(SVertex_const_handle v) const{ return v->mark(); }const Mark& mark(SHalfedge_const_handle e) const{ return e->mark(); }const Mark& mark(SHalfloop_const_handle l) const{ return l->mark(); }const Mark& mark(SFace_const_handle f) const{ return f->mark(); }void set_marks_in_face_cycle(SHalfedge_handle e, Mark m) const{ SHalfedge_around_sface_circulator hfc(e), hend(hfc);  CGAL_For_all(hfc,hend) mark(hfc) = mark(target(hfc)) = m;}GenPtr& info(SVertex_handle v) const{ return v->info(); }GenPtr& info(SHalfedge_handle e) const{ return e->info(); }GenPtr& info(SHalfloop_handle l) const{ return l->info(); }GenPtr& info(SFace_handle f) const{ return f->info(); }const GenPtr& info(SVertex_const_handle v) const{ return v->info(); }const GenPtr& info(SHalfedge_const_handle e) const{ return e->info(); }const GenPtr& info(SHalfloop_const_handle l) const{ return l->info(); }const GenPtr& info(SFace_const_handle f) const{ return f->info(); } /*{\Mtext \headerline{Iteration}}*//*{\Mtext The list of all objects can be accessed via iterator ranges.For comfortable iteration we also provide iterations macros. The iterator range access operations are of the following kind:\\|SVertex_iterator svertices_begin()/svertices_end()|\\|SHalfedge_iterator shalfedges_begin()/shalfedges_end()|\\|SHalfedge_iterator sedges_begin()/sedges_end()|\\|SFace_iterator sfaces_begin()/sfaces_end()|The macros are then |CGAL_forall_svertices_of(v,V)|,|CGAL_forall_shalfedges_of(e,V)|, |CGAL_forall_sedges_of(e,V)|, |CGAL_forall_sfaces_of(f,V)|, |CGAL_forall_sface_cycles_of(fc,F)|.}*/void transform( const Aff_transformation_3& linear) {  //  CGAL_NEF_TRACEN("transform sphere map of vertex" << center_vertex()->point());    // The affine transformation is linear, i.e., no translation part.    CGAL_precondition( linear.hm(0,3) == 0 &&                        linear.hm(1,3) == 0 &&                        linear.hm(2,3) == 0);    //    CGAL_NEF_TRACEN(linear);    for (SVertex_iterator i = svertices_begin(); i != svertices_end(); ++i)      point(i) = normalized(Sphere_point( point(i).transform( linear)));    for (SHalfedge_iterator i = shalfedges_begin(); i !=shalfedges_end(); ++i)      circle(i) = Sphere_circle( circle(i).transform( linear));    if ( has_shalfloop()) {      circle(shalfloop()) = Sphere_circle(circle(shalfloop())					  .transform( linear));      circle(twin(shalfloop()))	= Sphere_circle(circle(twin(shalfloop())).transform( linear));    }}void extract_complement() {  SVertex_handle sv;  CGAL_forall_svertices(sv,*this) mark(sv) = !mark(sv);  SHalfedge_handle she;  CGAL_forall_shalfedges(she,*this) mark(she) = !mark(she);  SHalfloop_handle shl;  if(has_shalfloop()) {    shl = shalfloop();     mark(shl) = mark(twin(shl)) = !mark(shl);  }  SFace_handle sf;  CGAL_forall_sfaces(sf,*this)     mark(sf) = !mark(sf);}void extract_interior() {  SVertex_handle sv;  CGAL_forall_svertices(sv,*this) mark(sv) = false;  SHalfedge_handle she;  CGAL_forall_shalfedges(she,*this) mark(she) = false;  SHalfloop_handle shl;  if(has_shalfloop()) {     shl = shalfloop();     mark(shl) = mark(twin(shl)) = false;  }}void extract_boundary() {  SVertex_handle sv;  CGAL_forall_svertices(sv,*this) mark(sv) = true;  SHalfedge_handle she;  CGAL_forall_shalfedges(she,*this) mark(she) = true;  SHalfloop_handle shl;  if(has_shalfloop()) {     shl = shalfloop();     mark(shl) = mark(twin(shl)) = true;  }  SFace_handle sf;  CGAL_forall_sfaces(sf,*this) mark(sf) = false;}bool is_valid( Unique_hash_map<SVertex_handle,bool>& sv_hash,	       Unique_hash_map<SHalfedge_handle,bool>& se_hash,	       Unique_hash_map<SFace_handle,bool>& sf_hash,	       bool verb = false, int level = 0) {      Verbose_ostream verr(verb);  verr << "begin CGAL::SNC_SM_decorator<...>::is_valid( verb=true, "    "level = " << level << "):" << std::endl;      bool valid = true;  int count = 0;  int max = 2 * number_of_svertices()     + 2 * number_of_shalfedges()    + number_of_sfaces()    + 2;    SVertex_handle sv;  int isolated_vertices_found = 0;  CGAL_forall_svertices(sv,*this) {    valid = valid && (!sv_hash[sv]);    sv_hash[sv] = true;    if(is_isolated(sv))       isolated_vertices_found++;    valid = valid && (++count <= max);  }  SHalfedge_iterator she;  CGAL_forall_shalfedges(she,*this) {    valid = valid && she->is_valid(verb, level);    valid = valid && (twin(she) != she);    valid = valid && (twin(twin(she)) == she);    valid = valid && (previous(next(she)) == she);    valid = valid && ((previous(she) != she && next(she) != she) || 		      (previous(she) == she && next(she) == she));    valid = valid && (face(she) == face(next(she)));    valid = valid && (face(she) == face(previous(she)));    valid = valid && (!se_hash[she]);    //    Plane_3 pl(point(source(she)),point(target(she)),Point_3(0,0,0));    //    Sphere_point vct(pl.orthogonal_vector());    //    valid = valid && (normalized(Sphere_point(circle(she).orthogonal_vector())) == normalized(vct) ||     //	      normalized(Sphere_point(circle(she).opposite().orthogonal_vector())) == normalized(vct));    se_hash[she] = true;    valid = valid && (++count <= max);  }  if(has_shalfloop()) {    SHalfloop_handle shl = shalfloop();    valid = valid && shl->is_valid();    valid = valid && twin(shl)->is_valid();    valid = valid && (twin(shl) != shl);    valid = valid && (twin(twin(shl)) == shl);   }  SFace_iterator sf;  SFace_cycle_iterator sfc;    int loop_entries_found = 0;  int edge_entries_found = 0;  int vertex_entries_found = 0;  CGAL_forall_sfaces(sf,*this) {    valid = valid && sf->is_valid(verb, level);    valid = valid && (!sf_hash[sf]);    sf_hash[sf] = true;        CGAL_forall_sface_cycles_of(sfc,sf) {      if (sfc.is_shalfloop()) 	loop_entries_found++;      else if(sfc.is_shalfedge())	edge_entries_found++;      else if(sfc.is_svertex())	vertex_entries_found++;      valid = valid && (++count <= max);    }        valid = valid && (++count <= max);  }  if(has_shalfloop())    valid = valid && (loop_entries_found == 2);  else    valid = valid && (loop_entries_found == 0);  if(number_of_shalfedges() > 0)    valid = valid && (edge_entries_found > 0);  else    valid = valid && (edge_entries_found == 0);  valid = valid && (vertex_entries_found == isolated_vertices_found);  verr << "end of CGAL::SNC_SM_decorator<...>::is_valid(): structure is "       << ( valid ? "valid." : "NOT VALID.") << std::endl;  return valid;}  template <typename Selection>  void change_marks(const Mark& m, const Selection& SP) {       psm_->mark() = SP(m, psm_->mark());    SVertex_iterator v;    CGAL_forall_svertices(v,*this)      mark(v) = SP(m, mark(v));    SHalfedge_iterator e;    CGAL_forall_shalfedges(e,*this)      mark(e) = SP(m, mark(e));    SFace_iterator f;    CGAL_forall_sfaces(f,*this)       mark(f) = SP(m, mark(f));  }  template <typename Selection>  void change_marks(const Selection& SP, const Mark& m) {       psm_->mark() = SP(psm_->mark(), m);    SVertex_iterator v;    CGAL_forall_svertices(v,*this)      mark(v) = SP(mark(v),m);    SHalfedge_iterator e;    CGAL_forall_shalfedges(e,*this)      mark(e) = SP(mark(e),m);    SFace_iterator f;    CGAL_forall_sfaces(f,*this)       mark(f) = SP(mark(f),m);  }void check_integrity_and_topological_planarity(bool faces=true) const {  SM_const_decorator C(psm_);  C.check_integrity_and_topological_planarity(faces);}}; // SM_decoratorCGAL_END_NAMESPACE#endif // CGAL_SM_DECORATOR_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?