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

📄 snc_io_parser.h

📁 很多二维 三维几何计算算法 C++ 类库
💻 H
📖 第 1 页 / 共 5 页
字号:
    in >> cc;  while(isdigit(cc)) {    in.putback(cc);    in >> index;    ch->shell_entry_objects().push_back(SFace_of[index]);    in >> cc;  }  in >> ch->mark();  return OK;}template <typename EW>void SNC_io_parser<EW>::print_sedge(SHalfedge_handle e) const { //index { twin, sprev, snext, source, sface, prev, next, facet | circle } mark  out << index(e) << " { "      << index(e->twin()) << ", "       << index(e->sprev()) << ", " << index(e->snext()) << ", "      << index(e->source()) << ", " << index(e->incident_sface()) << ", "      << index(e->prev()) << ", " << index(e->next()) << ", "      << index(e->facet())       << " | ";  if(reduce) {    Standard_plane p(Infi_box::standard_plane(e->circle()));    out << p.a() << " " << p.b() << " " << p.c() << " " << p.d();  }  else    Geometry_io<typename Kernel::Kernel_tag, Kernel>::      print_plane(out, (Plane_3) e->circle());  out << " } " << e->mark() << "\n";}template <typename EW>template <typename K>bool SNC_io_parser<EW>::read_sedge(SHalfedge_handle seh) {  bool OK = true;  int index;  typename K::RT a,b,c,d;    in >> index;  OK = OK && test_string("{");    in >> index;  seh->twin() = SEdge_of[index];  OK = OK && test_string(",");  in >> index;  seh->sprev() = SEdge_of[index];  OK = OK && test_string(",");  in >> index;  seh->snext() = SEdge_of[index];  OK = OK && test_string(",");  in >> index;  seh->source() = Edge_of[index];  OK = OK && test_string(",");  in >> index;  seh->incident_sface() = SFace_of[index];  OK = OK && test_string(",");  in >> index;  seh->prev() = SEdge_of[index];  OK = OK && test_string(",");  in >> index;  seh->next() = SEdge_of[index];  OK = OK && test_string(",");  in >> index;  seh->facet() = Halffacet_of[index];  OK = OK && test_string("|");  //  in >> a >> b >> c >> d;  //  seh->circle() = Sphere_circle(Plane_3(a,b,c,d));  seh->circle() =         Geometry_io<typename K::Kernel_tag, Kernel>::    template read_plane<Kernel, K>(in);  OK = OK && test_string("}");  in >> seh->mark();  return OK;}template <typename EW>void SNC_io_parser<EW>::print_sloop(SHalfloop_handle l) const{ // syntax: index { twin, sface, facet | circle } mark  out << index(l) << " { "      << index(l->twin()) << ", " << index(l->incident_sface()) << ", "      << index(l->facet())       << " | ";    if(reduce) {    Standard_plane p(Infi_box::standard_plane(l->circle()));    out << p.a() << " " << p.b() << " " << p.c() << " " << p.d();  }  else    Geometry_io<typename Kernel::Kernel_tag, Kernel>::      print_plane(out, (Plane_3) l->circle());  out << " } " << l->mark() << "\n";}template <typename EW>template <typename K>bool SNC_io_parser<EW>::read_sloop(SHalfloop_handle slh) {  bool OK = true;  int index;  typename K::RT a,b,c,d;  in >> index;  OK = OK && test_string("{");    in >> index;  slh->twin() = SLoop_of[index];  OK = OK && test_string(",");  in >> index;  slh->incident_sface() = SFace_of[index];  OK = OK && test_string(",");  in >> index;  slh->facet() = Halffacet_of[index];  OK = OK && test_string("|");	  //  in >> a >> b >> c >> d;  //  slh->circle() = Sphere_circle(Plane_3(a,b,c,d));  slh->circle() =    Geometry_io<typename K::Kernel_tag, Kernel>::    template read_plane<Kernel, K>(in);	  OK = OK && test_string("}");	  in >> slh->mark();    return OK;}template <typename EW>void SNC_io_parser<EW>::print_sface(SFace_handle f) const{ // syntax: index { vertex, fclist, ivlist, sloop, volume }  SM_decorator D(&*f->center_vertex());  out << index(f) << " { " << index(f->center_vertex()) << ", ";   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 << ", " << index(f->volume()) << " } " << f->mark() <<"\n";}template <typename EW>bool SNC_io_parser<EW>::read_sface(SFace_handle sfh) {  bool OK = true;  int index;  char cc;  in >> index;  OK = OK && test_string("{");    in >> index;  sfh->center_vertex() = Vertex_of[index];  OK = OK && test_string(",");    in >> cc;  while(isdigit(cc)) {    in.putback(cc);    in >> index;    //    sfh->boundary_entry_objects().push_back(SEdge_of[index]);    SM_decorator SD(&*sfh->center_vertex());    SD.link_as_face_cycle(SEdge_of[index],sfh);    in >> cc;  }    in >> cc;  while(isdigit(cc)) {    in.putback(cc);    in >> index;    sfh->boundary_entry_objects().push_back(Edge_of[index]);    this->sncp()->store_sm_boundary_item(Edge_of[index], --(sfh->sface_cycles_end()));    in >> cc;  }  in >> cc;  while(isdigit(cc)) {    in.putback(cc);    in >> index;    sfh->boundary_entry_objects().push_back(SLoop_of[index]);    this->sncp()->store_sm_boundary_item(SLoop_of[index], --(sfh->sface_cycles_end()));    in >> cc;  }    in >> index;  sfh->volume() = Volume_of[index+addInfiBox];  OK = OK && test_string("}");	  in >> sfh->mark();    return OK;}template <typename EW>void SNC_io_parser<EW>::print_local_graph(Vertex_handle v) const{ SM_decorator D(&*v);  out << "Local Graph "       << D.number_of_vertices() << " " << D.number_of_edges() << " "      << D.number_of_loops() << " " << D.number_of_faces() << " "      << std::endl;  if (verbose)     out << "/* index { twin, source, isolated incident_object, mark } */\n";  SVertex_iterator vit;  CGAL_forall_svertices_of(vit,v) print_edge(vit);  if (verbose)     out << "/* index { twin, sprev, snext, source, sface,"        << " prev, next, facet } */\n";  SHalfedge_iterator eit;  CGAL_forall_shalfedges_of(eit,v) print_sedge(eit);  if (verbose)     out << "/* index { twin, sface, facet } */" << std::endl;  if ( D.has_sloop() )   { print_sloop(D.loop()); print_sloop(twin(D.loop())); }  if (verbose)     out << "/* index { fclist, ivlist, sloop, volume } */" << std::endl;  SFace_iterator fit;  CGAL_forall_sfaces_of(fit,v) print_sface(fit);  out.flush();}template <typename EW>void SNC_io_parser<EW>::add_infi_box() {  for(i=0; i<8; ++i)  Vertex_of.push_back(this->sncp()->new_vertex_only());  for(i=0; i<24; ++i)  Edge_of.push_back(this->sncp()->new_halfedge_only());  for(i=0; i<12; ++i)  Halffacet_of.push_back(this->sncp()->new_halffacet_only());  for(i=0; i<48; ++i) SEdge_of.push_back(this->sncp()->new_shalfedge_only());  for(i=0; i<16; ++i) SFace_of.push_back(this->sncp()->new_sface_only());  typename Standard_kernel::RT hx,hy,hz,hw;  for(int i=0; i<8; ++i) {    Vertex_handle vh = Vertex_of[vn+i];    vh->svertices_begin() = Edge_of[en+3*i];    vh->svertices_last()  = Edge_of[en+3*i+2];    vh->shalfedges_begin() = SEdge_of[sen+6*i];    vh->shalfedges_last()  = SEdge_of[sen+6*i+5];    vh->sfaces_begin() = SFace_of[sfn+2*i];    vh->sfaces_last()  = SFace_of[sfn+2*i+1];    vh->shalfloop() = this->shalfloops_end();    hx = i % 2 ? -1 : 1;    hy = i % 4 > 1 ? -1 : 1;    hz = i > 3 ? -1 : 1;    vh->point() = Infi_box::create_extended_point(hx, hy, hz);    vh->mark() = 1;		    vh->sncp() = this->sncp();  }    int seOff[3] = {0, 1, 3};  int twinIdx[24] = { 3, 7,14,		      0,10,17,		      9, 1,20,		      6, 4,23,		      15,19, 2,		      12,22, 5,		      21,13, 8,		      18,16,11};    for(int i = 0; i < 24; ++i) {    Halfedge_handle eh = Edge_of[en+i];    eh->twin() = Edge_of[en+twinIdx[i]];    eh->center_vertex() = Vertex_of[vn+(i/3)];    eh->out_sedge() = SEdge_of[sen+(i/3*6)+seOff[i%3]];    switch(i%3) {    case 0 :       hx = i % 6 ? 1 : -1;      hy = hz = 0;      break;    case 1:      hy = i % 12 >= 6 ? 1 : -1;      hx = hz = 0;      break;    case 2:      hz = i >= 12 ? 1 : -1;      hx = hy = 0;      break;    }    eh->point() = Sphere_point(hx,hy,hz);    eh->mark() = 1;  }    int bnd[12] = {19, 18, 43, 42, 35, 34,		 47, 46, 39, 38, 45, 44};  for(int i = 0; i < 12; ++i) {    Halffacet_handle fh = Halffacet_of[fn+i];    fh->twin() = Halffacet_of[fn+(i/2*2)+((i+1)%2)];    fh->boundary_entry_objects().push_back(SEdge_of[sen+bnd[i]]);    fh->incident_volume() = Volume_of[((i%4) == 1 || (i%4 == 2)) ? 1 : 0];    if(i<4) {      hz = i % 2 ? -1 : 1;      hx = hy = 0;    }    else if(i<8) {      hy = i % 2 ? -1 : 1;      hx = hz = 0;    }    else {      hx = i % 2 ? -1 : 1;      hz = hy = 0;    }    hw = ((i%4) == 1 || (i%4) == 2) ? 1 : -1;    fh->plane() = Infi_box::create_extended_plane(hx,hy,hz,hw);    fh->mark() = 1;  }    Volume_of[0]->shell_entry_objects().push_back(SFace_of[sfn]);  Volume_of[0]->mark() = 0;  Volume_of[1]->shell_entry_objects().push_front(SFace_of[sfn+1]);    int sprevOff[6] = {4,3,0,5,2,1};  int snextOff[6] = {2,5,4,1,0,3};  int prevIdx[48] = {7,12,15,26,29,10,		     1,18,21,32,35,4,		     19,0,3,38,41,22,		     13,6,9,44,47,16,		     31,36,39,2,5,34,		     25,42,45,8,11,28,		     43,24,27,14,17,46,		     37,30,33,20,23,40};  int nextIdx[48] = {13,6,27,14,11,28,		     19,0,33,20,5,34,		     1,18,39,2,23,40,		     7,12,45,8,17,46,		     37,30,3,38,35,4,		     43,24,9,44,29,10,		     25,42,15,26,47,16,		     31,36,21,32,41,22};  int factIdx[48] = {1,0,9,8,5,4,		     0,1,11,10,4,5,		     0,1,8,9,7,6,		     1,0,10,11,6,7,		     3,2,8,9,4,5,		     2,3,10,11,5,4,		     2,3,9,8,6,7,		     3,2,11,10,7,6};  int sgn[24] = {1,1,1,-1,1,-1,		 -1,-1,1,1,-1,-1,		 1,-1,-1,-1,-1,1,		 -1,1,-1,1,1,1};    for(int i = 0; i < 48; ++i) {    SHalfedge_handle seh = SEdge_of[sen+i];        seh->twin() = SEdge_of[sen+(i/2*2)+((i+1)%2)];    seh->sprev() = SEdge_of[sen+sprevOff[i%6]+(i/6*6)];    seh->snext() = SEdge_of[sen+snextOff[i%6]+(i/6*6)];    seh->source() = Edge_of[en+((i+1)%6)/2+(i/6)*3];    seh->incident_sface() = SFace_of[sfn+(i%2)+(i/6)*2];    seh->prev() = SEdge_of[sen+prevIdx[i]];    seh->next() = SEdge_of[sen+nextIdx[i]];    seh->facet() = Halffacet_of[fn+factIdx[i]];    if(i%6 < 2) {      hz = (i%2) ? sgn[i/2] * (-1) : sgn[i/2];      hx = hy = 0;    }    else if(i%6 < 4) {      hx = (i%2) ? sgn[i/2] * (-1) : sgn[i/2];      hz = hy = 0;    }    else {      hy = (i%2) ? sgn[i/2] * (-1) : sgn[i/2];      hx = hz = 0;    }    seh->circle() = Sphere_circle(Plane_3(RT(hx),RT(hy),RT(hz),RT(0)));    seh->mark() = 1;  }    int volIdx[8] = {0,1,1,0,1,0,0,1};    for(int i = 0; i < 16; ++i) {    SFace_handle sfh = SFace_of[sfn+i];    sfh->center_vertex() = Vertex_of[vn+(i/2)];    sfh->boundary_entry_objects().push_back(SEdge_of[sen+(i/2*6)+(i%2)]);    this->sncp()->store_sm_boundary_item(SEdge_of[sen+(i/2*6)+(i%2)], 					  --(sfh->sface_cycles_end()));    int cIdx = i%2 ? 1-volIdx[i/2] : volIdx[i/2];    sfh->volume() = Volume_of[cIdx];    sfh->mark() = cIdx ? Volume_of[1]->mark() : 0;  }}CGAL_END_NAMESPACE#endif //CGAL_SNC_IO_PARSER_H

⌨️ 快捷键说明

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