⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sm_io_parser.h

📁 很多二维 三维几何计算算法 C++ 类库
💻 H
📖 第 1 页 / 共 2 页
字号:
  set_prev(e,Edge_of[epr]);  set_next(e,Edge_of[ene]);  set_source(e,SVertex_of[v]);  set_face(e,SFace_of[f]);  mark(e) = m;  circle(e) = k;  return true;}template <typename Decorator_>void SM_io_parser<Decorator_>::print_loop(SHalfloop_const_handle l) const{ // syntax: index { twin, face, mark, circle }  out << index(l) << " { "      << index(l->twin()) << ", "       << index(l->incident_sface()) << ", "      << l->mark() << ", " << l->circle() << " }\n";}template <typename Decorator_>bool SM_io_parser<Decorator_>::read_loop(SHalfloop_handle l){ // syntax: index { twin, face, mark, circle }  int n, lo, f; bool m; Sphere_circle k;  if ( !(in >> n) ||       !check_sep("{") ||       !(in >> lo) || !check_sep(",") ||       !(in >> f) || !check_sep(",") ||       !(in >> m) || !check_sep(",") ||       !(in >> k) || !check_sep("}") )    return false;  CGAL_assertion_msg(    (lo >= 0 && lo < 2 && f >= 0 && f < fn),"wrong index in read_edge");    set_face(l,SFace_of[f]);  mark(l) = m;  circle(l) = k;  return true;}template <typename Decorator_>void SM_io_parser<Decorator_>::print_face(SFace_handle f) const{ // syntax: index { fclist, ivlist, loop, mark }  out << index(f) << " { ";   SFace_cycle_iterator it;  CGAL_forall_sface_cycles_of(it,f)    if ( it.is_shalfedge() ) out << index(SHalfedge_handle(it)) << ' ';  out << ", ";  CGAL_forall_sface_cycles_of(it,f)    if ( it.is_svertex() ) out << index(SVertex_handle(it)) << ' ';  out << ", ";  CGAL_forall_sface_cycles_of(it,f)    if ( it.is_shalfloop() ) out << index(SHalfloop_handle(it));  out << ", " << f->mark() << " }\n";}template <typename Decorator_>bool SM_io_parser<Decorator_>::read_face(SFace_handle f){ // syntax: index { fclist, ivlist, loop, mark }  int n, ei, vi, li; Mark m;  if ( !(in >> n) || !check_sep("{") ) return false;  while (in >> ei) {     CGAL_assertion_msg(ei >= 0 && ei < en,                            "wrong index in face cycle list.");    store_boundary_object(Edge_of[ei],f);  } in.clear();  if (!check_sep(",")) { return false; }  while (in >> vi) {     CGAL_assertion_msg(vi >= 0 && vi < vn,                            "wrong index in iso vertex list.");    store_boundary_object(SVertex_of[vi],f);  } in.clear();  if (!check_sep(",")) { return false; }  while (in >> li) {     CGAL_assertion_msg(li >= 0 && li < 2,                            "wrong index in iso vertex list.");    store_boundary_object(Loop_of[li],f);  } in.clear();  if (!check_sep(",") || !(in >> m) || !check_sep("}") )     return false;  mark(f) = m;  return true;}template <typename Decorator_>void SM_io_parser<Decorator_>::print() const{  out << "Sphere_map_2" << std::endl;  out << "vertices "  << vn << std::endl;  out << "edges "     << en << std::endl;  out << "loops "     << ln << std::endl;  out << "faces "     << fn << std::endl;  if (verbose)     out << "/* index { isolated ? face : edge, mark, point } */" << std::endl;  SVertex_iterator vit;  CGAL_forall_svertices(vit,*this) print_vertex(vit);  if (verbose)     out << "/* index { twin, prev, next, source, face, mark, circle } */" 	<< std::endl;  SHalfedge_iterator eit;  CGAL_forall_shalfedges(eit,*this) print_edge(eit);  if (verbose)     out << "/* index { twin, face, mark, circle } */" << std::endl;  if ( this->has_shalfloop() )     { print_loop(this->shalfloop()); print_loop(this->shalfloop()->twin()); }  if (verbose)     out << "/* index { fclist, ivlist, loop, mark } */" << std::endl;  SFace_iterator fit;  CGAL_forall_sfaces(fit,*this) print_face(fit);  out.flush();  if (verbose) debug();}template <typename Decorator_>void SM_io_parser<Decorator_>::read() {  if ( !check_sep("Plane_map_2") )      CGAL_assertion_msg(0,"SM_io_parser::read: no embedded_PM header.");  if ( !(check_sep("vertices") && (in >> vn)) )     CGAL_assertion_msg(0,"SM_io_parser::read: wrong vertex line.");  if ( !(check_sep("edges") && (in >> en) && (en%2==0)) )    CGAL_assertion_msg(0,"SM_io_parser::read: wrong edge line.");  if ( !(check_sep("loops") && (in >> ln)) )    CGAL_assertion_msg(0,"SM_io_parser::read: wrong loop line.");  if ( !(check_sep("faces") && (in >> fn)) )    CGAL_assertion_msg(0,"SM_io_parser::read: wrong face line.");  SVertex_of.resize(vn);  Edge_of.resize(en);  SFace_of.resize(fn);  for(i=0; i<vn; i++)  SVertex_of[i] =   this->new_vertex();  for(i=0; i<en; i++)     if (i%2==0) Edge_of[i] = this->new_edge_pair_without_vertices();    else Edge_of[i] = Edge_of[i-1]->twin();  for(i=0; i<fn; i++)  SFace_of[i] =     this->new_face();  if ( ln == 2 )     { Loop_of[0] = this->new_loop(); Loop_of[1] = this->loop()->twin(); }  for(i=0; i<vn; i++) {    if (!read_vertex(SVertex_of[i]))      CGAL_assertion_msg(0,"SM_io_parser::read: error in node line");  }  for(i=0; i<en; i++) {    if (!read_edge(Edge_of[i]))      CGAL_assertion_msg(0,"SM_io_parser::read: error in edge line");  }  if ( ln == 2 ) {    read_loop(Loop_of[0]); read_loop(Loop_of[1]);  }  for(i=0; i<fn; i++) {    if (!read_face(SFace_of[i]))      CGAL_assertion_msg(0,"SM_io_parser::read: error in face line");  }}//-----------------------------------------------------------------------------// VERBOSE OUTPUT:// note that we output the index of the objects which is stored in them// this is NOT the member index as produced by the forall loops//-----------------------------------------------------------------------------template <typename Decorator_>void SM_io_parser<Decorator_>::debug_vertex(SVertex_handle v) const{   out << index(v) << "[" << v->mark() << "," << v->point() << "]" << std::endl; }template <typename Decorator_>void SM_io_parser<Decorator_>::debug_edge(SHalfedge_handle e) const{   out << index(e)      << "(" << index(e->source()) << "," << index(e->target()) << ") "      << index(e->twin()) << " " << index(e->incident_sface())      << " ["<< e->mark() << "," << e->circle() << "] " << std::endl;}template <typename Decorator_>void SM_io_parser<Decorator_>::debug_loop(SHalfloop_const_handle l) const{   out << index(l) << " "      << index(l->twin()) << " " << index(l->incident_sface())      << " ["<< l->mark() << "] " << l->circle() << std::endl;}template <typename Decorator_>void SM_io_parser<Decorator_>::debug() const{   out << "\nDEBUG Plane_map\n";  out << "Vertices:  " << this->number_of_svertices() << "\n";  out << "SHalfedges: " << this->number_of_shalfedges() << "\n";  out << "Loop:      " << this->number_of_shalfloops() << "\n";  SVertex_iterator vit;   CGAL_forall_svertices(vit,*this) {    if ( is_isolated(vit) ) continue;    SHalfedge_around_svertex_circulator hcirc(out_edges(vit)), hend(hcirc);    debug_vertex(vit);    CGAL_For_all(hcirc,hend) { out << "  "; debug_edge(hcirc); }  }  if ( this->has_shalfloop() )     { debug_loop(this->shalfloop()); debug_loop(this->shalfloop()->twin()); }  out << std::endl;}template <typename Decorator_>void SM_io_parser<Decorator_>::print_faces() const{   out << "\nFACES\n";  out << "Vertices:  " << this->number_of_svertices() << "\n";  out << "SHalfedges: " << this->number_of_shalfedges() << "\n";  out << "Loop:      " << this->number_of_shalfloops() << "\n";  SHalfedge_iterator e;  Unique_hash_map<SHalfedge_iterator,bool> Done(false);  CGAL_forall_shalfedges(e,*this) {    if ( Done[e] ) continue;    typename Base::SHalfedge_around_sface_circulator c(e), ce = c;    out << "face cycle\n";    CGAL_For_all(c,ce)     { Done[c]=true; out << "  "; debug_vertex(c->source()); }  }  if ( this->has_shalfloop() )     { debug_loop(this->shalfloop()); debug_loop(this->shalfloop()->twin()); }  out << std::endl;}template <typename Decorator_>void SM_io_parser<Decorator_>::dump(const Decorator_& D, std::ostream& os){ SM_io_parser<Decorator_> Out(os,D);  Out.print();  Out.print_faces();}CGAL_END_NAMESPACE#if defined(BOOST_MSVC)#  pragma warning(pop)#endif#endif //CGAL_SM_IO_PARSER_H

⌨️ 快捷键说明

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