📄 snc_constructor.h
字号:
} sum=-h.a()+h.b()-h.c(); if(h.d()!=0 || sum!= 0) { CGAL_NEF_TRACEN(sum); create_extended_box_corner(-1, 1,-1, (sum<0 || (sum == 0 && h.d()<0))); } sum= h.a()-h.b()-h.c(); if(h.d()!=0 || sum!= 0) { CGAL_NEF_TRACEN(sum); create_extended_box_corner( 1,-1,-1, (sum<0 || (sum == 0 && h.d()<0))); } sum=-h.a()-h.b()-h.c(); if(h.d()!=0 || sum!= 0) { CGAL_NEF_TRACEN(sum); create_extended_box_corner(-1,-1,-1, (sum<0 || (sum == 0 && h.d()<0))); } } Vertex_handle create_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, Plane_3 h, const Mark& boundary, const Mark& inside, const Mark& outside) const { if(h.d() == 0) { CGAL_assertion(CGAL_NTS abs(p.hy()) != CGAL_NTS abs(p.hx()) || CGAL_NTS abs(p.hz()) != CGAL_NTS abs(p.hx())); } int max = 0; if(CGAL_NTS abs(p.hx()) > CGAL_NTS abs(p.hy())) max = 1; if(CGAL_NTS abs(p.hx()) > CGAL_NTS abs(p.hz())) max = 2; CGAL_NEF_TRACEN("create frame point "); CGAL_NEF_TRACEN("create spoints"); Sphere_point SP[4]; switch(max) { case 0: SP[2] = Sphere_point(1,0,0); break; case 1: SP[2] = Sphere_point(0,1,0); break; case 2: SP[2] = Sphere_point(0,0,1); break; default: CGAL_assertion_msg(0,"wrong value"); } SP[1]=sp1; SP[0]=sp2; if (spherical_orientation(SP[0],SP[1],SP[2]) < 0) { SP[3] = SP[2]; SP[2] = CGAL::ORIGIN-SP[3]; } else SP[3] = CGAL::ORIGIN-SP[2]; RT delta = h.a()*SP[2].hx()+h.b()*SP[2].hy()+h.c()*SP[2].hz(); CGAL_assertion(delta !=0); Mark swtch = (delta < 0); Mark fmark0 = (swtch && inside) || (!swtch && !inside); Mark fmark1 = (swtch && outside) || (!swtch && !outside); return create_SM_on_infibox(p, SP, 4, boundary, fmark0, fmark1); } Vertex_handle create_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, int max, Plane_3 h, const Mark& boundary, const Mark& inside, const Mark& outside) const { CGAL_assertion(h.d() == 0); Vector_3 vec = h.orthogonal_vector(); CGAL_assertion(CGAL_NTS abs(vec.hx()) != CGAL_NTS abs(vec.hy()) && CGAL_NTS abs(vec.hy()) != CGAL_NTS abs(vec.hz()) && CGAL_NTS abs(vec.hx()) != CGAL_NTS abs(vec.hz())); CGAL_assertion(vec.hx() + vec.hy() == vec.hz() || vec.hx() + vec.hz() == vec.hy() || vec.hy() + vec.hz() == vec.hx()); CGAL_NEF_TRACEN("create corner frame point "); RT vp[3]; vp[0] = -p.hx()[1]; vp[1] = -p.hy()[1]; vp[2] = -p.hz()[1]; CGAL_NEF_TRACEN("create spoints"); Sphere_point SP[5]; switch(max) { case 0: SP[3] = Sphere_point(0,vp[1],0); SP[2]= Sphere_point(0,0,vp[2]); SP[4] = Sphere_point(vp[0],0,0); break; case 1: SP[3] = Sphere_point(vp[0],0,0); SP[2]= Sphere_point(0,0,vp[2]); SP[4] = Sphere_point(0,vp[1],0); break; case 2: SP[3] = Sphere_point(vp[0],0,0); SP[2]= Sphere_point(0,vp[1],0); SP[4] = Sphere_point(0,0,vp[2]); break; default: CGAL_assertion_msg(0,"wrong value"); } if (spherical_orientation(SP[3],Sphere_point(sp1),Sphere_point(sp2)) > 0) { SP[0] = sp1; SP[1] = sp2; } else { SP[0] = sp2; SP[1] = sp1; } if (spherical_orientation(SP[2],SP[3],SP[0]) < 0) { Sphere_point sx = SP[2]; SP[2] = SP[3]; SP[3] = sx; } RT delta = h.a()*SP[4].hx()+h.b()*SP[4].hy()+h.c()*SP[4].hz(); CGAL_assertion(delta !=0); Mark swtch = (delta > 0); Mark fmark0 = (swtch && inside) || (!swtch && !inside); Mark fmark1 = (swtch && outside) || (!swtch && !outside); return create_SM_on_infibox(p, SP, 5, boundary, fmark0, fmark1); } Vertex_handle create_degenerate_corner_frame_point(Point_3 p, Point_3 sp1,Point_3 sp2, int min,int max, Plane_3 h, const Mark& boundary, const Mark& inside, const Mark& outside)const { CGAL_assertion(h.d() == 0); Vector_3 vec = h.orthogonal_vector(); CGAL_assertion( (CGAL_NTS abs(vec.hx()) == CGAL_NTS abs(vec.hy()) && vec.hz() == 0) || (CGAL_NTS abs(vec.hy()) == CGAL_NTS abs(vec.hz()) && vec.hx() == 0) || (CGAL_NTS abs(vec.hx()) == CGAL_NTS abs(vec.hz()) && vec.hy() == 0)); RT vp[3]; vp[0] = -p.hx()[1]; vp[1] = -p.hy()[1]; vp[2] = -p.hz()[1]; CGAL_NEF_TRACEN("create degenerate corner frame point "); CGAL_NEF_TRACEN("create spoints"); Sphere_point SP[4]; switch(max) { case 0: SP[2] = Sphere_point(vp[0],0,0); break; // plane(x,x,0), plane(x,0,x) case 1: SP[2] = Sphere_point(0,vp[1],0); break; // plane(0,x,x) default: CGAL_assertion_msg(0,"wrong value \"max\""); } switch(min+max) { case 1: SP[3] = Sphere_point(0,0,vp[2]); break; // plane(0,x,x), plane(x,0,x) case 2: SP[3] = Sphere_point(0,vp[1],0); break; // plane(x,x,0) default: CGAL_assertion_msg(0,"wrong value \"min+max\""); } if (spherical_orientation(SP[2],Sphere_point(sp1),Sphere_point(sp2)) > 0) { SP[0] = sp1; SP[1] = sp2; } else { SP[0] = sp2; SP[1] = sp1; } RT delta = h.a()*SP[2].hx()+h.b()*SP[2].hy()+h.c()*SP[2].hz(); CGAL_assertion(delta !=0); Mark swtch = (delta < 0); Mark fmark0 = (swtch && inside) || (!swtch && !inside); Mark fmark1 = (swtch && outside) || (!swtch && !outside); return create_SM_on_infibox(p, SP, 4, boundary, fmark0, fmark1); } Vertex_handle create_SM_on_infibox(const Point_3& center, Sphere_point* SP, int size, const Mark& boundary, const Mark& fmark0, const Mark& fmark1) const { Vertex_handle v=this->sncp()->new_vertex(normalized(center), boundary); SM_decorator SD(&*v); CGAL_NEF_TRACEN("create_SM_on_infibox: center = " << center); CGAL_NEF_TRACEN("create svertices"); std::vector<SVertex_handle> sv(size); CGAL_NEF_TRACEN("create_SM_on_infibox: size = " << size); for(int i=0; i<size; ++i) { CGAL_NEF_TRACEN(" SP["<< i << "]=" << SP[i]); sv[i] = SD.new_svertex(SP[i]); sv[i]->mark() = (i < 2 ? boundary : 1); } CGAL_NEF_TRACEN("create sedges"); std::vector<SHalfedge_handle> she(size+1); for(int si=0; si<size-1;++si) { she[si]=SD.new_shalfedge_pair(sv[si], sv[(si+1)%(size-1)]); she[si]->circle()= Sphere_circle(Plane_3(SP[si],SP[(si+1)%(size-1)],Point_3(0,0,0))); she[si]->twin()->circle() = she[si]->circle().opposite(); she[si]->mark() = she[si]->twin()->mark() = (si == 0 ? boundary : 1); } she[size-1] = SD.new_shalfedge_pair(she[0], sv[size-1], -1); CGAL_assertion(she[size-1]->snext() == she[size-1]->twin()); CGAL_assertion(she[size-1]->twin()->sprev() == she[size-1]); CGAL_assertion(she[size-1]->twin()->sprev()->twin() == she[size-1]->twin()); she[size] = SD.new_shalfedge_pair(she[size-1]->twin(), she[0]->twin(), 1, 1); CGAL_assertion(she[0]->snext() == she[1]); CGAL_assertion(she[1]->snext() == she[2]); if(size == 4) CGAL_assertion(she[2]->snext() == she[0]); else { CGAL_assertion(she[2]->snext() == she[3]); CGAL_assertion(she[3]->snext() == she[0]); } CGAL_assertion(she[0]->twin()->snext() == she[size-1]); CGAL_assertion(she[size-1]->snext() == she[size]); CGAL_assertion(she[size]->snext() == she[0]->twin()); CGAL_assertion(she[4]->twin()->snext() == she[3]->twin()); CGAL_assertion(she[3]->twin()->snext() == she[2]->twin()); CGAL_assertion(she[2]->twin()->snext() == she[1]->twin()); if(size == 4) CGAL_assertion(she[1]->twin()->snext() == she[4]->twin()); else { CGAL_assertion(she[5]->twin()->snext() == she[4]->twin()); CGAL_assertion(she[1]->twin()->snext() == she[5]->twin()); } she[size-1]->circle()= Sphere_circle(Plane_3(SP[0],SP[size-1],Point_3(0,0,0))); she[size-1]->twin()->circle() = she[size-1]->circle().opposite(); she[size-1]->mark() = she[size-1]->twin()->mark() = 1; she[size]->circle()= Sphere_circle(Plane_3(SP[size-1],SP[1],Point_3(0,0,0))); she[size]->twin()->circle() = she[size]->circle().opposite(); she[size]->mark() = she[size]->twin()->mark() = 1; CGAL_NEF_TRACEN("create sfaces"); SFace_handle sf[3]; for(int i=0; i<3; ++i) sf[i] = SD.new_sface(); sf[0]->mark()= fmark0; sf[1]->mark()= fmark1; sf[2]->mark()=0; SD.link_as_face_cycle(she[0],sf[0]); SD.link_as_face_cycle(she[0]->twin(),sf[1]); SD.link_as_face_cycle(she[1]->twin(),sf[2]); return v; } void correct_infibox_sface_marks() { Vertex_iterator v; CGAL_forall_vertices(v,*this->sncp()) { if(is_standard(v) || Infi_box::is_infibox_corner(v->point())) continue; SM_decorator SD(&*v); SFace_iterator sf; CGAL_forall_sfaces(sf, SD) sf->volume()->mark() = sf->mark(); } CGAL_forall_vertices(v,*this->sncp()) { if(is_standard(v) || !Infi_box::is_infibox_corner(v->point())) continue; SM_decorator SD(&*v); SFace_iterator sf; CGAL_forall_sfaces(sf, SD) sf->mark() = sf->volume()->mark(); } } void correct_infibox_sedge_marks() { SHalfedge_iterator se; Vertex_iterator v; CGAL_forall_vertices(v,*this->sncp()) { if(is_standard(v)) continue; SM_decorator SD(&*v); CGAL_forall_shalfedges(se,SD) if(Infi_box::is_sedge_on_infibox(se)) { se->mark() = true; se->source()->mark() = true; } } } void assign_indices() {}}; // SNC_constructor_base<SNC>template <typename Items, typename SNC_structure_>class SNC_constructor : public SNC_constructor_base<Items, SNC_structure_>{public: SNC_constructor( SNC_structure_& W) : SNC_constructor_base<Items, SNC_structure_>(W) {}}; template<typename SNC_structure_>class SNC_constructor<SNC_indexed_items, SNC_structure_> : public SNC_constructor_base<int, SNC_structure_> { typedef SNC_structure_ SNC_structure; typedef SNC_constructor_base<int, SNC_structure> Base; typedef typename SNC_structure::Sphere_map Sphere_map; typedef CGAL::SM_const_decorator<Sphere_map> SM_const_decorator; typedef CGAL::SM_decorator<Sphere_map> SM_decorator; public: typedef typename SNC_structure::SVertex_iterator SVertex_iterator; typedef typename SNC_structure::Halfedge_iterator Halfedge_iterator; typedef typename SNC_structure::Halffacet_iterator Halffacet_iterator; typedef typename SNC_structure::Vertex_handle Vertex_handle; typedef typename SNC_structure::Halfedge_handle Halfedge_handle; typedef typename SNC_structure::Halffacet_handle Halffacet_handle; typedef typename SNC_structure::Vertex_const_handle Vertex_const_handle; typedef typename SNC_structure::Halfedge_const_handle Halfedge_const_handle; typedef typename SNC_structure::Halffacet_const_handle Halffacet_const_handle; typedef typename SNC_structure::SVertex_const_handle SVertex_const_handle; typedef typename SNC_structure::SHalfedge_const_handle SHalfedge_const_handle; typedef typename SNC_structure::SHalfloop_const_handle SHalfloop_const_handle; typedef typename SNC_structure::SFace_const_handle SFace_const_handle; typedef typename SNC_structure::SVertex_handle SVertex_handle; typedef typename SNC_structure::SHalfedge_handle SHalfedge_handle; typedef typename SNC_structure::SFace_handle SFace_handle; typedef typename SNC_structure::SHalfloop_handle SHalfloop_handle; typedef typename SNC_structure::SHalfedge_around_facet_circulator SHalfedge_around_facet_circulator; typedef typename SNC_structure::SHalfedge_around_facet_const_circulator SHalfedge_around_facet_const_circulator; typedef typename SNC_structure::SHalfedge_around_svertex_circulator SHalfedge_around_svertex_circulator; typedef typename SNC_structure::SHalfedge_around_svertex_const_circulator SHalfedge_around_svertex_const_circulator; typedef typename SNC_structure::SFace_cycle_const_iterator SFace_cycle_const_iterator; typedef typename SNC_structure::Halffacet_cycle_iterator Halffacet_cycle_iterator; typedef typename SNC_structure::Halffacet_cycle_const_iterator Halffacet_cycle_const_iterator; typedef typename SNC_structure::Point_3 Point_3; typedef typename SNC_structure::Vector_3 Vector_3; typedef typename SNC_structure::Sphere_point Sphere_point; typedef typename SNC_structure::Sphere_segment Sphere_segment; typedef typename SNC_structure::Sphere_circle Sphere_circle; typedef typename SNC_structure::Mark Mark; public: SNC_constructor( SNC_structure& W) : Base(W) {} Vertex_handle create_from_facet(Halffacet_const_handle f, const Point_3& p) { Vertex_handle v = create_from_plane(f->plane(), p, f->mark(), f->twin()->incident_volume()->mark(), f->incident_volume()->mark()); v->shalfloop()->set_index_facet(f->twin()); v->shalfloop()->twin()->set_index_facet(f); SHalfedge_const_handle se = f->twin()->facet_cycles_begin(); CGAL_assertion(v->shalfloop()->circle() =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -