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

📄 snc_constructor.h

📁 很多二维 三维几何计算算法 C++ 类库
💻 H
📖 第 1 页 / 共 5 页
字号:
      sfi->mark()=false;    }    se=*se_list.begin();    SD.link_as_face_cycle(se,sfi);    SD.link_as_face_cycle(se->twin(),sfa);  }  Vertex_handle create_for_infibox_overlay(Vertex_const_handle vin) const {    Unique_hash_map<SHalfedge_handle, Mark> mark_of_right_sface;        Vertex_handle v = this->sncp()->new_vertex(vin->point(), vin->mark());    SM_decorator D(&*v);    SM_const_decorator E(&*vin);        SVertex_const_handle e;    CGAL_forall_svertices(e, E)      if(!Infi_box::is_edge_on_infibox(e))	break;        Sphere_point ps = e->point();    ps = normalized(ps);    SVertex_handle v1 = D.new_svertex(ps);    SVertex_handle v2 = D.new_svertex(ps.antipode());    CGAL_NEF_TRACEN("new svertex 1 " << ps);    CGAL_NEF_TRACEN("new svertex 2 " << ps.antipode());    v1->mark() = v2->mark() = e->mark();    CGAL_NEF_TRACEN("svertex 1 " << ps << " has mark " << v1->mark());    CGAL_NEF_TRACEN("svertex 2 " << ps.antipode() << " has mark " << v2->mark());        if(E.is_isolated(e)) {      CGAL_NEF_TRACEN("edge is isolated");      SFace_handle f = D.new_sface();      f->mark() = e->incident_sface()->mark();          D.link_as_isolated_vertex(v1, f);      D.link_as_isolated_vertex(v2, f);    }    else {      CGAL_NEF_TRACEN("edge is not isolated");      SHalfedge_handle se;      SFace_handle sf;            SHalfedge_around_svertex_const_circulator ec(E.out_edges(e)), ee(ec);      CGAL_For_all(ec,ee) {	Sphere_segment seg(ec->source()->point(), 			   ec->source()->point().antipode(), 			   ec->circle());	se = D.new_shalfedge_pair(v1, v2);	se->mark() = se->twin()->mark() = ec->mark();	mark_of_right_sface[se] = ec->incident_sface()->mark();	se->circle() = ec->circle();	se->twin()->circle() = se->circle().opposite();      }            SHalfedge_around_svertex_circulator ec2(D.out_edges(v1)), ee2(ec2);      CGAL_For_all(ec2,ee2) {	sf = D.new_sface();	sf->mark() = mark_of_right_sface[ec2];	D.link_as_face_cycle(SHalfedge_handle(ec2),sf);      }       }        return v;  }  Vertex_handle create_from_plane(const Plane_3& pl, const Point_3& p, 				  const Mark& bnd, 				  const Mark& in, const Mark& out) const {    typedef typename CGAL::SNC_const_decorator<SNC_structure> SNC_const_decorator;    Vertex_handle v = this->sncp()->new_vertex( p, bnd);    v->point() = p;    Sphere_circle c(pl); // circle through origin parallel to h    SM_decorator D(&*v);    SHalfloop_handle l = D.new_shalfloop_pair();    SFace_handle f1 = D.new_sface(), f2 = D.new_sface();    D.link_as_loop(l,f1);    D.link_as_loop(l->twin(),f2);        l->circle() = c;     l->twin()->circle() = c.opposite();    f1->mark() = out;    f2->mark() = in;    l->mark() = l->twin()->mark() = bnd;    return v;  }  Vertex_handle create_from_point_on_infibox_facet(const Point_3& p) const {        CGAL_assertion(!Infi_box::is_standard(p));    if(Infi_box::x_on_box(p)) {      if(p.hx() > 0) 	return create_from_plane(Plane_3(1,0,0,1), p, 1, 1, 0);      else	return create_from_plane(Plane_3(-1,0,0,1), p, 1, 1, 0);    }    if(Infi_box::y_on_box(p)) {      if(p.hy() > 0) 	return create_from_plane(Plane_3(0,1,0,1), p, 1, 1, 0);      else	return create_from_plane(Plane_3(0,-1,0,1), p, 1, 1, 0);    }    if(Infi_box::z_on_box(p)) {      if(p.hz() > 0) 	return create_from_plane(Plane_3(0,0,1,1), p, 1, 1, 0);      else	return create_from_plane(Plane_3(0,0,-1,1), p, 1, 1, 0);    }    CGAL_assertion_msg(0, "something is wrong");    return Vertex_handle();  }   Vertex_handle create_from_point_on_infibox_edge(const Point_3& p) const {    Sphere_point sp;    Sphere_circle c1,c2;        if(!Infi_box::x_on_box(p)) {      sp = Sphere_point(1,0,0);      c1 = (p.hy() < RT(0)) ? Sphere_circle(0,-1,0) : Sphere_circle(0,1,0);      c2 = (p.hz() < RT(0)) ? Sphere_circle(0,0,-1) : Sphere_circle(0,0,1);    } else if(!Infi_box::y_on_box(p)) {      sp = Sphere_point(0,1,0);      c1 = (p.hx() < RT(0)) ? Sphere_circle(-1,0,0) : Sphere_circle(1,0,0);      c2 = (p.hz() < RT(0)) ? Sphere_circle(0,0,-1) : Sphere_circle(0,0,1);    } else if(!Infi_box::z_on_box(p)) {      sp = Sphere_point(0,0,1);      c1 = (p.hx() < RT(0)) ? Sphere_circle(-1,0,0) : Sphere_circle(1,0,0);      c2 = (p.hy() < RT(0)) ? Sphere_circle(0,-1,0) : Sphere_circle(0,1,0);    } else      CGAL_assertion_msg(false, "line of code shall not be reached");        Vertex_handle v = this->sncp()->new_vertex( p, true);    SM_decorator D(&*v);    SVertex_handle v1 = D.new_svertex(sp);    SVertex_handle v2 = D.new_svertex(sp.antipode());    SHalfedge_handle e1 = D.new_shalfedge_pair(v1,v2);    SHalfedge_handle e2 = D.new_shalfedge_pair(v1,v2);    SFace_handle f1 = D.new_sface();    SFace_handle f2 = D.new_sface();    v1->mark() = v2->mark() =       e1->mark() = e1->twin()->mark() =      e2->mark() = e2->twin()->mark() = true;    f1->mark() = false;    f2->mark() = true;    D.link_as_face_cycle(e1,f1);      D.link_as_face_cycle(e2,f2);    e1->circle() = c1;    e1->twin()->circle() = c1.opposite();    e1->snext()->circle() = c2;    e1->snext()->twin()->circle() = c2.opposite();        return v;  }   Vertex_handle create_from_point_on_infibox_vertex(const Point_3& p) const {    typedef typename Infi_box::Standard_point Standard_point;    Standard_point ps(Infi_box::standard_point(p,1));    return create_extended_box_corner(ps.hx(),				      ps.hy(),				      ps.hz(),true,true);  }  Vertex_handle create_from_facet(Halffacet_const_handle f,				  const Point_3& p) {    return create_from_plane(f->plane(), p, 			     f->mark(), 			     f->twin()->incident_volume()->mark(), 			     f->incident_volume()->mark());  }  /*{\Mop produces the sphere map at point $p$ representing the local     view of $f$. \precond $p$ is part of $f$.}*/  Vertex_handle create_from_edge(Halfedge_const_handle e,				 const Point_3& p) {    //    typedef typename CGAL::SNC_const_decorator<SNC_structure> SNC_const_decorator;        //    CGAL_assertion(SNC_const_decorator::segment(e).has_on(p));    Vertex_handle v = this->sncp()->new_vertex( p, e->mark());    SM_decorator D(&*v);    SM_const_decorator E(&*e->source());    Sphere_point ps = e->point();    SVertex_handle v1 = D.new_svertex(ps);    SVertex_handle v2 = D.new_svertex(ps.antipode());    v1->mark() = v2->mark() = e->mark();    bool first = true;        // CGAL_NEF_SETDTHREAD(19*43*131);        SHalfedge_const_handle ceee;    CGAL_NEF_TRACEN("---------------------" << e->center_vertex()->point());    CGAL_forall_shalfedges(ceee,E)      CGAL_NEF_TRACEN("|" << ceee->circle() <<	     "|" << ceee->mark() << 	     " " << ceee->incident_sface()->mark());    CGAL_NEF_TRACEN(" ");        if(E.is_isolated(e)) {      SFace_handle f = D.new_sface();      D.link_as_isolated_vertex(v1,f);      D.link_as_isolated_vertex(v2,f);      f->mark() = e->incident_sface()->mark();    }        SHalfedge_around_svertex_const_circulator       ec1(e->out_sedge()), ee(ec1);    SHalfedge_handle e1,e2;    CGAL_For_all(ec1,ee) {      if (first) e1 = D.new_shalfedge_pair(v1,v2);      else       e1 = D.new_shalfedge_pair(e1, e2, SM_decorator::AFTER, 					   SM_decorator::BEFORE);      e2 = e1->twin();       first = false;    }        SHalfedge_handle eee;    CGAL_forall_shalfedges(eee,D)      CGAL_NEF_TRACEN("|" << eee->circle());    CGAL_NEF_TRACEN(" ");           ec1 = e->out_sedge();    SHalfedge_around_svertex_circulator ec2(v1->out_sedge());    CGAL_For_all(ec1,ee) {      CGAL_NEF_TRACEN("|" << ec1->circle() <<	     "|" << ec1->mark() << 	     " " << ec1->incident_sface()->mark());      ec2->mark() = ec2->twin()->mark() = ec1->mark();      ec2->circle() = ec1->circle();      ec2->twin()->circle() = ec1->twin()->circle();      SFace_handle f = D.new_sface();      D.link_as_face_cycle(ec2,f);      f->mark() = ec1->incident_sface()->mark();      ++ec2;    }        CGAL_NEF_TRACEN(" ");    CGAL_NEF_TRACEN("new vertex ");        CGAL_forall_svertices(v1, D) {      CGAL_NEF_TRACE("|" << v1->point() << "|" << v1->mark());      CGAL_NEF_TRACEN(" ");    }    CGAL_NEF_TRACEN(" ");    CGAL_forall_shalfedges(eee,D)      CGAL_NEF_TRACEN("|" << eee->circle() <<	     "|" << eee->mark() << 	     " " << eee->incident_sface()->mark());    CGAL_NEF_TRACEN("---------------------");        return v;  }  /*{\Mop produces the sphere map at point $p$ representing the local     view of $e$. \precond $p$ is part of $e$.}*/  Vertex_handle clone_SM( Vertex_const_handle vin) {    #ifdef CGAL_NEF3_TIMER_SPHERE_SWEEPS    ++number_of_clones;#endif    CGAL::Unique_hash_map<SVertex_const_handle, SVertex_handle>         VM;    CGAL::Unique_hash_map<SHalfedge_const_handle, SHalfedge_handle>     EM;    CGAL::Unique_hash_map<SHalfloop_const_handle, SHalfloop_handle>     LM;    CGAL::Unique_hash_map<SFace_const_handle, SFace_handle>             FM;        SM_const_decorator E(&*vin);    Vertex_handle vout = this->sncp()->new_vertex(vin->point(), vin->mark());    SM_decorator D(&*vout);        SVertex_const_handle sv;    CGAL_forall_svertices(sv, E) {      VM[sv] = D.new_svertex(sv->point());    }        SHalfedge_const_handle se;    CGAL_forall_sedges(se, E) {      EM[se] = D.new_shalfedge_pair();      EM[se->twin()] = EM[se]->twin();    }        SFace_const_handle sf;    CGAL_forall_sfaces(sf, E)      FM[sf] = D.new_sface();        SHalfloop_handle sl;    if(E.has_shalfloop()) {      sl = LM[E.shalfloop()] = D.new_shalfloop_pair();      LM[E.shalfloop()->twin()] = sl->twin();      D.set_face(sl, FM[E.shalfloop()->incident_sface()]);      D.set_face(sl->twin(), FM[E.shalfloop()->twin()->incident_sface()]);      sl->circle() = E.shalfloop()->circle();      sl->twin()->circle() = E.shalfloop()->twin()->circle();      sl->mark() = sl->twin()->mark() = E.shalfloop()->mark();    }        CGAL_forall_svertices(sv, E) {      D.set_first_out_edge(VM[sv], EM[E.first_out_edge(sv)]);      D.set_face(VM[sv], FM[sv->incident_sface()]);      VM[sv]->mark() = sv->mark();    }        CGAL_forall_shalfedges(se, E) {      EM[se]->mark() = EM[se]->twin()->mark() = se->mark();      D.set_source(EM[se], VM[se->source()]);      D.set_prev(EM[se], EM[se->sprev()]);       D.set_next(EM[se], EM[se->snext()]);      D.set_face(EM[se], FM[se->incident_sface()]);      EM[se]->circle() = se->circle();    }        CGAL_forall_sfaces(sf, E) {      FM[sf]->mark() = sf->mark();      SFace_cycle_const_iterator sfc;      for(sfc = sf->sface_cycles_begin(); sfc != sf->sface_cycles_end(); ++sfc) {	if(sfc.is_svertex())	  D.store_sm_boundary_object(VM[SVertex_const_handle(sfc)], FM[sf]);	else if(sfc.is_shalfedge())	  D.store_sm_boundary_object(EM[SHalfedge_const_handle(sfc)], FM[sf]);	else if(sfc.is_shalfloop())	  D.store_sm_boundary_object(LM[SHalfloop_const_handle(sfc)], FM[sf]);	else CGAL_assertion_msg(0,"damn wrong handle.");      }    }        return vout;  }  #ifdef CGAL_NEF_EXPERIMENTAL_CODE  template<typename Selection, typename Association>  Sphere_map* create_edge_edge_overlay( Halfedge_const_handle e0,					Halfedge_const_handle e1,					const Point_3& p,					const Selection& BOP, bool inv,					Association& ) {        std::cerr << "edge_edge " << p << std::endl;    SM_const_decorator E(&*e1->source());    if(E.is_isolated(e0)) {      if(E.is_isolated(e1)) {	CGAL_assertion_msg(false, "not implemented, yet");      } else {	std::swap(e0, e1);	inv = !inv;	E = SM_const_decorator(&*e1->source());      }    }        Vertex_handle v(create_from_edge(e0,p));    v->mark() = BOP(v->mark(), e1->mark(), inv);    SM_decorator D(&*v);    SVertex_handle sv[4];    sv[0] = sv[1] = v->svertices_begin();    ++sv[1];    SM_point_locator PL(&*v);    Object_handle o2 = PL.locate(e1->point());    Object_handle o3 = PL.locate(e1->twin()->point());    sv[2] = D.new_svertex(e1->point());    sv[3] = D.new_svertex(e1->twin()->point());        Vector_3 vec0 = sv[0]->point() - CGAL::ORIGIN;    Vector_3 vec1 = sv[2]->point() - CGAL::ORIGIN;    Plane_3 mid_plane(Point_3(0,0,0), cross_product(vec0, vec1));    bool splitted[2];    splitted[0] = splitted[1] = false;    bool on_sface[2];    SHalfedge_handle se0, se1;    SFace_handle sf0, sf1;    SHalfedge_around_svertex_circulator       seb[2], see[2];    SHalfedge_around_svertex_const_circulator       scb[2], sce[2];    on_sface[0] = CGAL::assign(sf0, o2);    on_sface[1] = CGAL::assign(sf1, o3);

⌨️ 快捷键说明

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