From 2ccd52af6380c0f11e1f9713ab68e7fa2d529087 Mon Sep 17 00:00:00 2001 From: Peter Hachenberger Date: Wed, 19 Mar 2003 16:37:04 +0000 Subject: [PATCH] Bug fix: Pluecker lines didN't work with Kernel, which finds negative values as an gcd. A false value for "inverted" was returned. Now, "inverted is calculated, before the Pluecker values are normalized. --- .../include/CGAL/Nef_3/Infimaximal_box.h | 201 +++++++++++++++++- .../include/CGAL/Nef_3/Pluecker_line_3.h | 57 ++--- .../include/CGAL/Nef_3/SNC_constructor.h | 113 ++++++---- .../Nef_3/include/CGAL/Nef_3/SNC_decorator.h | 20 +- .../Nef_3/include/CGAL/Nef_3/SNC_structure.h | 2 + .../include/CGAL/Nef_3/SNC_visualizor_OGL.h | 25 +-- 6 files changed, 308 insertions(+), 110 deletions(-) diff --git a/Packages/Nef_3/include/CGAL/Nef_3/Infimaximal_box.h b/Packages/Nef_3/include/CGAL/Nef_3/Infimaximal_box.h index ffd33985a7c..8c0742f8b4c 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/Infimaximal_box.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/Infimaximal_box.h @@ -35,12 +35,17 @@ #include #include +#include + CGAL_BEGIN_NAMESPACE template class Infimaximal_box { - typedef typename Kernel::Point_3 Point_3; + typedef typename Kernel::RT NT; + typedef Kernel Standard_kernel; + typedef typename Kernel::Point_3 Point_3; + typedef Point_3 Standard_point; public: static bool is_standard(Point_3& p) { @@ -51,13 +56,21 @@ class Infimaximal_box { return p; } + static Point_3 box_point(Point_3& p, NT d=10000) { + return p; + } + + static Standard_point standard_point(Point_3 p, NT d=1) { + return p; + } + static int degree(const typename Kernel::RT& n) { return 0; } - template - static Point_3 target_for_ray_shot(SNC_structure_* sncp, Point_3& p) { - return sncp->vertices_last(); + template + static Point_3 target_for_ray_shot(SNC_decorator_& deco, Point_3& p) { + return deco.vertices_begin()->point(); } }; @@ -65,8 +78,15 @@ class Infimaximal_box { template class Infimaximal_box { - typedef typename Kernel::Point_3 Point_3; - typedef typename Kernel::RT::NT NT; + typedef typename Kernel::RT RT; + typedef typename Kernel::RT::NT NT; + typedef typename Kernel::Standard_kernel Standard_kernel; + typedef typename Standard_kernel::Point_3 Standard_point; + typedef typename Kernel::Point_3 Point_3; + typedef typename Kernel::Plane_3 Plane_3; + typedef typename Kernel::Vector_3 Vector_3; + + enum Boundary { EXCLUDED=0, INCLUDED=1 }; public: static bool is_standard(Point_3& p) { @@ -84,19 +104,182 @@ class Infimaximal_box { return Point_3(p.hx()(deg),p.hy()(deg),p.hz()(deg),p.hw()[0]); } - static int degree(const typename Kernel::RT& n) { + static int degree(const RT& n) { return n.degree(); } - template - static Point_3 target_for_ray_shot(SNC_structure_* sncp, Point_3 p) { + template + static Point_3 target_for_ray_shot(SNC_decorator_& deco, Point_3 p) { return Kernel::epoint(0, p.hx()[0], 0, p.hy()[0], p.hw()[0], 0, p.hw()[0]); } + static Standard_point standard_point(Point_3 p, NT d=1) { + return Standard_point(p.hx().eval_at(d), + p.hy().eval_at(d), + p.hz().eval_at(d), + p.hw().eval_at(1)); + } + + + static Point_3 box_point(Point_3 p, NT d=10000) { + return Point_3(p.hx().eval_at(d), + p.hy().eval_at(d), + p.hz().eval_at(d), + p.hw().eval_at(1)); + } + static Point_3 create_extended_point(NT x, NT y, NT z) { return Kernel::epoint(x,0,y,0,z,0,1); } + + /* + template + static void create_vertices_of_box_with_plane(const Plane_3& h, Boundary b, SNC_structure_& snc) { + + typedef typename SNC_structure_::Sphere_point Sphere_point; + + Point_3 loc(-h.d(),0,0,h.a()); + Vector_3 orth = h.orthogonal_vector(); + + NT orth_coords[3]; + orth_coords[0] = orth.hx()[0]; + orth_coords[1] = orth.hy()[0]; + orth_coords[2] = orth.hz()[0]; + + int add_corners = 0; + while(orth_coords[add_corners] == 0) add_corners++; + CGAL_assertion(add_corners < 3); + + std::list points; + for(int dir=0; dir<3;++dir) { + + NT cnst[3]; + for(int i=0; i<3;i++) + cnst[i] = (i==dir? -h.d()[0] : 0); + + NT cross[4][4]; + cross[0][dir] = -orth_coords[(dir+1)%3]-orth_coords[(dir+2)%3]; + cross[1][dir] = orth_coords[(dir+1)%3]-orth_coords[(dir+2)%3]; + cross[2][dir] = orth_coords[(dir+1)%3]+orth_coords[(dir+2)%3]; + cross[3][dir] = -orth_coords[(dir+1)%3]+orth_coords[(dir+2)%3]; + + for(int i=0;i<4;++i) + cross[i][3] = orth_coords[dir]; + + cross[0][(dir+1)%3] = cross[3][(dir+1)%3] = orth_coords[dir]; + cross[1][(dir+1)%3] = cross[2][(dir+1)%3] = -orth_coords[dir]; + + cross[0][(dir+2)%3] = cross[1][(dir+2)%3] = orth_coords[dir]; + cross[2][(dir+2)%3] = cross[3][(dir+2)%3] = -orth_coords[dir]; + + for(int i=0; i<4; ++i) + if(CGAL_NTS abs(RT(cnst[dir],cross[i][dir])) < CGAL_NTS abs(RT(0,orth_coords[dir])) || + (CGAL_NTS abs(RT(cnst[dir],cross[i][dir])) == CGAL_NTS abs(RT(0,orth_coords[dir])) && dir == add_corners)) + points.push_back(Kernel::epoint(cross[i][0],cnst[0],cross[i][1],cnst[1],cross[i][2],cnst[2],cross[i][3])); + + } + + for(int i=0;i<2;i++) + orth_coords[i] = CGAL_NTS abs(orth_coords[i]); + + int max = 0; + if(orth_coords[1] > orth_coords[0]) + max = 1; + if(orth_coords[2] > orth_coords[max]) + max = 2; + + int min = 0; + if(orth_coords[1] < orth_coords[0]) + min = 1; + if(orth_coords[2] < orth_coords[min]) + min = 2; + + SNC_constructor C(snc); + points.sort(circle_lt(max)); + + typename std::list::const_iterator p,prev,next; + for(p=points.begin();p!=points.end();p++) + TRACEN(*p); + + for(p=points.begin();p!=points.end();p++){ + + if(p==points.begin()) prev = --points.end(); + else { prev = p; prev--;} + if(p==--points.end()) next=points.begin(); + else {next = p; ++next;} + TRACEN("points " << *prev << " " << *p << " " << *next); + + Vector_3 v= *prev - *p; + Sphere_point sp1(v); + sp1 = sp1.normalized(); + CGAL_assertion(sp1.hx().degree() == 0); + CGAL_assertion(sp1.hy().degree() == 0); + CGAL_assertion(sp1.hz().degree() == 0); + CGAL_assertion(sp1.hw().degree() == 0); + + v= *next - *p; + Sphere_point sp2(v); + sp2 = sp2.normalized(); + CGAL_assertion(sp2.hx().degree() == 0); + CGAL_assertion(sp2.hy().degree() == 0); + CGAL_assertion(sp2.hz().degree() == 0); + CGAL_assertion(sp2.hw().degree() == 0); + + TRACEN("sps " << sp1 << " " << sp2); + TRACEN(orth_coords[min] << "|" << orth_coords[(min+1)%3] << "|" << orth_coords[(min+2)%3]); + + if(orth_coords[min]==0 && orth_coords[(min+1)%3] == orth_coords[(min+2)%3] && h.d() == 0) + C.create_degenerate_corner_frame_point(*p,sp1,sp2,min, max, (b==INCLUDED)); + else if(CGAL_NTS abs(p->hx()) == CGAL_NTS abs(p->hy()) && CGAL_NTS abs(p->hz()) == CGAL_NTS abs(p->hy())) + C.create_corner_frame_point(*p,sp1,sp2,max,(b==INCLUDED)); + else + C.create_frame_point(*p,sp1,sp2,h,(b==INCLUDED)); + } + + RT sum= h.a()+h.b()+h.c(); + if(h.d()!=0 || sum!= 0) { + TRACEN(sum); + C.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) { + TRACEN(sum); + C.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) { + TRACEN(sum); + C.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) { + TRACEN(sum); + C.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) { + TRACEN(sum); + C.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) { + TRACEN(sum); + C.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) { + TRACEN(sum); + C.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) { + TRACEN(sum); + C.create_extended_box_corner(-1,-1,-1, (sum<0 || (sum == 0 && h.d()<0))); + } + } + */ + }; CGAL_END_NAMESPACE diff --git a/Packages/Nef_3/include/CGAL/Nef_3/Pluecker_line_3.h b/Packages/Nef_3/include/CGAL/Nef_3/Pluecker_line_3.h index 63b27e8f2e0..822571c6a46 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/Pluecker_line_3.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/Pluecker_line_3.h @@ -37,6 +37,8 @@ #define _DEBUG 61 #include +// #include + CGAL_BEGIN_NAMESPACE /*{\Manpage{Pluecker_line_3}{R}{Straight lines in 3-space}{pl}}*/ @@ -53,16 +55,18 @@ class Pluecker_line_3 { typedef R_ R; /*{\Mtypemember the standard kernel type.}*/ typedef typename R::RT RT; - typedef typename RT::NT NT; /*{\Mtypemember the ring type.}*/ typedef typename R::Point_3 Point_3; /*{\Mtypemember the point type of the standard kernel.}*/ typedef typename R::Line_3 Line_3; /*{\Mtypemember the line type of the standard kernel.}*/ -typedef const NT* const_iterator; /*{\Mtypemember iterator over Pluecker coefficients.}*/ typedef Pluecker_line_3 Self; -NT c_[6]; +// typedef Infimaximal_box::value_type, R> Infi_box; +// typedef typename Infi_box::NT NT; +typedef const RT* const_iterator; + +RT c_[6]; public: /*{\Mcreation 3}*/ @@ -71,31 +75,28 @@ Pluecker_line_3() {} initializes it to some line.}*/ Pluecker_line_3(const Line_3& l) -/*{\Mcreate creates an instance |\Mvar| of type |\Mname| and + /*{\Mcreate creates an instance |\Mvar| of type |\Mname| and initializes it to |l|.}*/ { - TRACEN("Vorsicht"); Point_3 p(l.point(0)), q(l.point(1)); - c_[0] = (p.hx()*q.hy() - p.hy()*q.hx()).eval_at(1); - c_[1] = (p.hx()*q.hz() - p.hz()*q.hx()).eval_at(1); - c_[2] = (p.hy()*q.hz() - p.hz()*q.hy()).eval_at(1); - c_[3] = (p.hx()*q.hw() - p.hw()*q.hx()).eval_at(1); - c_[4] = (p.hy()*q.hw() - p.hw()*q.hy()).eval_at(1); - c_[5] = (p.hz()*q.hw() - p.hw()*q.hz()).eval_at(1); + c_[0] = p.hx()*q.hy() - p.hy()*q.hx(); + c_[1] = p.hx()*q.hz() - p.hz()*q.hx(); + c_[2] = p.hy()*q.hz() - p.hz()*q.hy(); + c_[3] = p.hx()*q.hw() - p.hw()*q.hx(); + c_[4] = p.hy()*q.hw() - p.hw()*q.hy(); + c_[5] = p.hz()*q.hw() - p.hw()*q.hz(); } Pluecker_line_3(const Point_3& p, const Point_3& q) /*{\Mcreate creates an instance |\Mvar| of type |\Mname| and initializes it to the oriented line through |p| and |q|.}*/ { - TRACEN("Pluecker"); - - c_[0] = (p.hx()*q.hy() - p.hy()*q.hx()).eval_at(1); - c_[1] = (p.hx()*q.hz() - p.hz()*q.hx()).eval_at(1); - c_[2] = (p.hy()*q.hz() - p.hz()*q.hy()).eval_at(1); - c_[3] = (p.hx()*q.hw() - p.hw()*q.hx()).eval_at(1); - c_[4] = (p.hy()*q.hw() - p.hw()*q.hy()).eval_at(1); - c_[5] = (p.hz()*q.hw() - p.hw()*q.hz()).eval_at(1); + c_[0] = p.hx()*q.hy() - p.hy()*q.hx(); + c_[1] = p.hx()*q.hz() - p.hz()*q.hx(); + c_[2] = p.hy()*q.hz() - p.hz()*q.hy(); + c_[3] = p.hx()*q.hw() - p.hw()*q.hx(); + c_[4] = p.hy()*q.hw() - p.hw()*q.hy(); + c_[5] = p.hz()*q.hw() - p.hw()*q.hz(); } @@ -124,7 +125,7 @@ Self& operator=(const Self& l) { if (&l!=this) std::copy(l.begin(),l.end(),c_); return *this; } -const NT& operator[](unsigned i) const +const RT& operator[](unsigned i) const /*{\Marrop returns constant access to the $i$th Pluecker coefficient.}*/ { CGAL_assertion(i<6); return c_[i]; } @@ -132,7 +133,8 @@ int sign() const /*{\Mop returns the sign of the first nonzero Pluecker coefficient within the ordered tuple of coefficients.}*/ { for (unsigned i=0; i<6; ++i) - if (c_[i]!=0) return CGAL_NTS sign(c_[i]); + if (c_[i]!=RT(0)) return CGAL_NTS sign(c_[i]); + CGAL_nef3_assertion_msg(0,"Pluecker line 0 0 0 0 0 0 shouldn't appear!!!"); return CGAL_NTS sign(c_[5]); } @@ -149,7 +151,7 @@ coefficients by their common gcd.}*/ if(i>5) return; - NT D = c_[i]; + RT D = c_[i]; CGAL_assertion(D!=0); for(++i; i<6; ++i) @@ -166,7 +168,7 @@ void negate() Pluecker_line_3 opposite() const /*{\Mop returns the line opposite to |\Mvar|. }*/ { Pluecker_line_3 res; - std::negate N; + std::negate N; std::transform(begin(), end(), res.c_, N); return res; } @@ -176,8 +178,8 @@ static int cmp(const Pluecker_line_3& l1, /*{\Mstatic returns the lexicographic order on lines defined on their Pluecker coefficient tuples.}*/ { for (unsigned i=0; i<5; ++i) { - typename R::RT::NT diff = l1[i]-l2[i]; - if ( diff != typename R::RT::NT(0) ) return CGAL_NTS sign(diff); + typename R::RT diff = l1[i]-l2[i]; + if ( diff != typename R::RT(0) ) return CGAL_NTS sign(diff); } return CGAL_NTS sign(l1[5]-l2[5]); } @@ -185,7 +187,7 @@ on their Pluecker coefficient tuples.}*/ }; // Pluecker_line_3 /*{\Mimplementation The Pluecker coefficients of a line are stored -in a six-tuple of |NT| coefficients.}*/ +in a six-tuple of |RT| coefficients.}*/ template @@ -208,9 +210,10 @@ std::ostream& operator<<(std::ostream& os, const Pluecker_line_3& l) template Pluecker_line_3 categorize(const Pluecker_line_3& l, int& inverted) { Pluecker_line_3 res(l); - res.normalize(); if ( res.sign()<0 ) { res.negate(); inverted=1; } else inverted=-1; + res.normalize(); + CGAL_assertion(res.sign()!=0); return res; } diff --git a/Packages/Nef_3/include/CGAL/Nef_3/SNC_constructor.h b/Packages/Nef_3/include/CGAL/Nef_3/SNC_constructor.h index 1ab580017b8..1eea2b744af 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_constructor.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_constructor.h @@ -124,7 +124,9 @@ class SNC_constructor : public SNC_decorator public: typedef SNC_structure_ SNC_structure; typedef typename SNC_structure_::Sphere_kernel Sphere_kernel; + typedef typename Infi_box::Standard_kernel Standard_kernel; typedef typename SNC_structure_::Kernel Kernel; + typedef typename Kernel::RT RT; typedef CGAL::SNC_constructor Self; typedef CGAL::SNC_decorator Base; typedef CGAL::SNC_decorator SNC_decorator; @@ -201,6 +203,7 @@ public: USING(Sphere_direction); USING(Mark); + USING(Infi_box); #undef USING #define DECUSING(t) typedef typename SM_decorator::t t @@ -336,7 +339,8 @@ public: if(!Infi_box::is_standard(p)) return Halffacet_handle(); - Segment_3 ray( p, Infi_box::target_for_ray_shot(sncp(),p)); + SNC_decorator SD(*this); + Segment_3 ray( p, Infi_box::target_for_ray_shot(SD,p)); SNC_ray_shooter rs(*sncp()); Object_handle o = rs.shoot(ray); @@ -365,16 +369,20 @@ public: return f_below; } - void create_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, Plane_3 h, bool boundary) const; - void create_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, int max, bool boundary) const; - void create_degenerate_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, int min, int max, bool boundary) const; + void create_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, + Plane_3 h, bool boundary) const; + void create_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, + int max, bool boundary) const; + void create_degenerate_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, + int min,int max,bool boundary) const; }; // SNC_constructor template void SNC_constructor:: -create_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, Plane_3 h, bool boundary) const { +create_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, + Plane_3 h, bool boundary) const { int max = 0; if(CGAL_NTS abs(p.hx()) > CGAL_NTS abs(p.hy())) @@ -382,7 +390,7 @@ create_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, Plane_3 h, bool boundary if(CGAL_NTS abs(p.hx()) > CGAL_NTS abs(p.hz())) max = 2; - TRACEN("create frame point " << p << std::endl << sp1 << std::endl << sp2 << " max " << max); + TRACEN("create frame point "); Vertex_handle v=sncp()->new_vertex(p, boundary); SM_decorator SD(v); @@ -404,9 +412,7 @@ create_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, Plane_3 h, bool boundary } else SP[3] = -Vector_3(SP[1]); - - - typedef typename Kernel::RT RT; + RT delta = h.a()*SP[1].hx()+h.b()*SP[1].hy()+h.c()*SP[1].hz(); CGAL_nef3_assertion(delta !=0); bool fmark0 = (delta < 0); @@ -422,9 +428,9 @@ create_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, Plane_3 h, bool boundary SHalfedge_handle she[5]; for(int si=0; si<3;++si) { she[si]=SD.new_edge_pair(sv[si], sv[(si+1)%3]); - SD.circle(she[si])= Sphere_circle(Plane_3(SP[si],SP[(si+1)%3],Point_3(0,0,0))); + SD.circle(she[si])= + Sphere_circle(Plane_3(SP[si],SP[(si+1)%3],Point_3(0,0,0))); SD.circle(SD.twin(she[si])) = SD.circle(she[si]).opposite(); - TRACEN("circles " << SD.circle(she[si]) << " " << SD.circle(she[si]).opposite() << ": " << SP[si] << " " << SP[(si+1)%3]); SD.mark(she[si]) = boundary; } @@ -433,13 +439,11 @@ create_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, Plane_3 h, bool boundary SD.circle(she[3])= Sphere_circle(Plane_3(SP[0],SP[3],Point_3(0,0,0))); SD.circle(SD.twin(she[3])) = SD.circle(she[3]).opposite(); - TRACEN("circles2 " << SD.circle(she[3]) << " " << SD.circle(she[3]).opposite()); SD.mark(she[3]) = boundary; // SD.mark(SD.twin(she[3])) = !fmark0; SD.circle(she[4])= Sphere_circle(Plane_3(SP[2],SP[3],Point_3(0,0,0))); SD.circle(SD.twin(she[4])) = SD.circle(she[4]).opposite(); - TRACEN("circles3 " << SD.circle(she[4]) << " " << SD.circle(she[4]).opposite()); SD.mark(she[4]) = boundary; // SD.mark(SD.twin(she[4])) = !fmark0; @@ -461,9 +465,10 @@ create_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, Plane_3 h, bool boundary template void SNC_constructor:: -create_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, int max, bool boundary) const { +create_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, + int max, bool boundary) const { - TRACEN("create corner frame point " << p << std::endl << sp1 << std::endl << sp2); + TRACEN("create corner frame point "); Vertex_handle v=sncp()->new_vertex(p, boundary); SM_decorator SD(v); @@ -474,7 +479,7 @@ create_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, int max, bool bou SD.mark(sf[0])=SD.mark(sf[1])=1; SD.mark(sf[2])=0; - typename Kernel::RT::NT vp[3]; + RT vp[3]; vp[0] = -v->point().hx()[1]; vp[1] = -v->point().hy()[1]; vp[2] = -v->point().hz()[1]; @@ -482,9 +487,21 @@ create_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, int max, bool bou TRACEN("create spoints"); Sphere_point SP[5]; switch(max) { - case 0: SP[0] = Sphere_point(0,vp[1],0); SP[3]= Sphere_point(0,0,vp[2]); SP[4] = Sphere_point(vp[0],0,0); break; - case 1: SP[0] = Sphere_point(vp[0],0,0); SP[3]= Sphere_point(0,0,vp[2]); SP[4] = Sphere_point(0,vp[1],0); break; - case 2: SP[0] = Sphere_point(vp[0],0,0); SP[3]= Sphere_point(0,vp[1],0); SP[4] = Sphere_point(0,0,vp[2]); break; + case 0: + SP[0] = Sphere_point(0,vp[1],0); + SP[3]= Sphere_point(0,0,vp[2]); + SP[4] = Sphere_point(vp[0],0,0); + break; + case 1: + SP[0] = Sphere_point(vp[0],0,0); + SP[3]= Sphere_point(0,0,vp[2]); + SP[4] = Sphere_point(0,vp[1],0); + break; + case 2: + SP[0] = Sphere_point(vp[0],0,0); + SP[3]= Sphere_point(0,vp[1],0); + SP[4] = Sphere_point(0,0,vp[2]); + break; default: CGAL_nef3_assertion_msg(0,"wrong value"); } @@ -515,9 +532,9 @@ create_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, int max, bool bou SHalfedge_handle she[6]; for(int si=0; si<4;++si) { she[si]=SD.new_edge_pair(sv[si], sv[(si+1)%4]); - SD.circle(she[si])= Sphere_circle(Plane_3(SP[si],SP[(si+1)%4],Point_3(0,0,0))); + SD.circle(she[si])= + Sphere_circle(Plane_3(SP[si],SP[(si+1)%4],Point_3(0,0,0))); SD.circle(SD.twin(she[si])) = SD.circle(she[si]).opposite(); - // TRACEN("circles " << SD.circle(she[si]) << " " << SD.circle(she[si]).opposite()); SD.mark(she[si]) = boundary; } @@ -528,13 +545,11 @@ create_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, int max, bool bou TRACEN("2"); SD.circle(SD.twin(she[4]))= Sphere_circle(Plane_3(SP[1],SP[4],Point_3(0,0,0))); SD.circle(she[4]) = SD.circle(SD.twin(she[4])).opposite(); - // TRACEN("circles2 " << SD.circle(she[4]) << " " << SD.circle(she[4]).opposite()); SD.mark(she[4]) = boundary; TRACEN("3"); SD.circle(she[5])= Sphere_circle(Plane_3(SP[4],SP[2],Point_3(0,0,0))); - SD.circle(SD.twin(she[5])) = SD.circle(she[5]).opposite(); - // TRACEN("circles2 " << SD.circle(she[5]) << " " << SD.circle(she[5]).opposite()); + SD.circle(SD.twin(she[5])) = SD.circle(she[5]).opposite(); SD.mark(she[5]) = 1; TRACEN("link faces"); @@ -554,9 +569,10 @@ create_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, int max, bool bou template void SNC_constructor:: -create_degenerate_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, int min, int max, bool boundary) const { +create_degenerate_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, + int min, int max, bool boundary) const { - TRACEN("create degenerate corner frame point " << p << std::endl << sp1 << std::endl << sp2); + TRACEN("create degenerate corner frame point "); Vertex_handle v=sncp()->new_vertex(p, boundary); SM_decorator SD(v); @@ -567,10 +583,10 @@ create_degenerate_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, int mi SD.mark(sf[0])=SD.mark(sf[1])=1; SD.mark(sf[2])=0; - typename Kernel::RT::NT vp[3]; - vp[0] = -v->point().hx()[1]; - vp[1] = -v->point().hy()[1]; - vp[2] = -v->point().hz()[1]; + RT vp[3]; + vp[0] = -p.hx()[1]; + vp[1] = -p.hy()[1]; + vp[2] = -p.hz()[1]; TRACEN("create spoints"); Sphere_point SP[4]; @@ -609,9 +625,9 @@ create_degenerate_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, int mi SHalfedge_handle she[5]; for(int si=0; si<3;++si) { she[si]=SD.new_edge_pair(sv[si], sv[(si+1)%3]); - SD.circle(she[si])= Sphere_circle(Plane_3(SP[si],SP[(si+1)%3],Point_3(0,0,0))); + SD.circle(she[si])= + Sphere_circle(Plane_3(SP[si],SP[(si+1)%3],Point_3(0,0,0))); SD.circle(SD.twin(she[si])) = SD.circle(she[si]).opposite(); - TRACEN("circles " << SD.circle(she[si]) << " " << SD.circle(she[si]).opposite() << ": " << SP[si] << " " << SP[(si+1)%3]); SD.mark(she[si]) = boundary; } @@ -620,12 +636,10 @@ create_degenerate_corner_frame_point(Point_3 p, Point_3 sp1, Point_3 sp2, int mi SD.circle(SD.twin(she[3]))= Sphere_circle(Plane_3(SP[1],SP[3],Point_3(0,0,0))); SD.circle(she[3]) = SD.circle(SD.twin(she[3])).opposite(); - TRACEN("circles2 " << SD.circle(she[3]) << " " << SD.circle(she[3]).opposite()); SD.mark(she[3]) = boundary; SD.circle(she[4])= Sphere_circle(Plane_3(SP[3],SP[2],Point_3(0,0,0))); SD.circle(SD.twin(she[4])) = SD.circle(she[4]).opposite(); - TRACEN("circles3 " << SD.circle(she[4]) << " " << SD.circle(she[4]).opposite()); SD.mark(she[4]) = boundary; SD.link_as_face_cycle(SD.twin(she[0]),sf[0]); @@ -699,7 +713,7 @@ create_box_corner(int x, int y, int z, bool space, bool boundary) const { template typename SNC_::Vertex_handle SNC_constructor:: -create_extended_box_corner(int x, int y, int z, bool space, bool boundary) const { +create_extended_box_corner(int x,int y,int z, bool space, bool boundary) const { CGAL_nef3_assertion(CGAL_NTS abs(x) == CGAL_NTS abs(y) && CGAL_NTS abs(y) == CGAL_NTS abs(z)); @@ -833,7 +847,9 @@ create_from_edge(Halfedge_handle e, SHalfedge_handle eee; TRACEN("---------------------" << point(vertex(e))); CGAL_nef3_forall_shalfedges(eee,EE) - TRACEN("|" << EE.circle(eee) <<"|" << EE.mark(eee) << " " << EE.mark(EE.face(eee))); + TRACEN("|" << EE.circle(eee) << + "|" << EE.mark(eee) << + " " << EE.mark(EE.face(eee))); TRACEN(" "); SHalfedge_around_svertex_const_circulator ec1(E.out_edges(e)), ee(ec1); @@ -854,7 +870,9 @@ create_from_edge(Halfedge_handle e, ec1 = E.out_edges(e); SHalfedge_around_svertex_circulator ec2(D.out_edges(v1)); CGAL_For_all(ec1,ee) { - TRACEN("|" << E.circle(ec1) <<"|" << E.mark(ec1) << " " << E.mark(E.face(ec1))); + TRACEN("|" << E.circle(ec1) << + "|" << E.mark(ec1) << + " " << E.mark(E.face(ec1))); D.mark(ec2) = E.mark(ec1); D.circle(ec2) = E.circle(ec1); D.circle(D.twin(ec2)) = E.circle(E.twin(ec1)); @@ -868,7 +886,9 @@ create_from_edge(Halfedge_handle e, L.init_marks_of_halfspheres(); CGAL_nef3_forall_shalfedges(eee,D) - TRACEN("|" << D.circle(eee) <<"|" << D.mark(eee) << " " << D.mark(D.face(eee))); + TRACEN("|" << D.circle(eee) << + "|" << D.mark(eee) << + " " << D.mark(D.face(eee))); TRACEN("---------------------"); return v; @@ -891,7 +911,7 @@ pair_up_halfedges() const Halfedge_key_lt; typedef std::list Halfedge_list; - typedef CGAL::Pluecker_line_3 Pluecker_line_3; + typedef CGAL::Pluecker_line_3 Pluecker_line_3; typedef CGAL::Pluecker_line_lt Pluecker_line_lt; typedef std::map< Pluecker_line_3, Halfedge_list, Pluecker_line_lt> Pluecker_line_map; @@ -903,14 +923,17 @@ pair_up_halfedges() const Halfedge_iterator e; CGAL_nef3_forall_halfedges(e,*sncp()) { Point_3 p = point(vertex(e)); - Pluecker_line_3 l(p, p + Vector_3(tmp_point(e))); + Pluecker_line_3 l(Infi_box::standard_point(p), + Infi_box::standard_point(p + Vector_3(tmp_point(e)))); int inverted; l = categorize(l,inverted); if(D.is_edge_on_infibox(e)) M2[l].push_back(Halfedge_key(p,inverted,e,D)); else M[l].push_back(Halfedge_key(p,inverted,e,D)); - TRACEN(" ("< #include #include -#include #include #ifdef CGAL_NEF3_SM_VISUALIZOR #include @@ -114,6 +113,7 @@ public: USING(Sphere_circle); USING(Mark); USING(Size_type); + USING(Infi_box); #undef USING #define DECUSING(t) typedef typename SM_decorator::t t @@ -121,8 +121,6 @@ public: DECUSING(SHalfedge_around_svertex_circulator); #undef DECUSING - typedef Infimaximal_box::value_type, Kernel> Infi_box; - typedef void* GenPtr; SNC_decorator() : sncp_() {} @@ -383,12 +381,12 @@ public: bool is_sedge_on_infibox(SHalfedge_handle sh) { Point_3 p = point(vertex(sh)); TRACEN("Point " << p); - if(p.hx().degree()==0 && p.hy().degree()==0 && p.hz().degree()==0) + if(Infi_box::degree(p.hx())==0 && Infi_box::degree(p.hy())==0 && Infi_box::degree(p.hz())==0) return false; Sphere_circle c(sh->tmp_circle()); TRACEN("Circle " << c << " has signum " << sign_of(c)); RT R(0,CGAL_NTS abs(p.hw()[0])); - CGAL_assertion(p.hw().degree() == 0); + CGAL_assertion(Infi_box::degree(p.hw()) == 0); SM_decorator SD(vertex(sh)); if((c.a() == 0 && c.b() == 0 && CGAL_NTS abs(p.hz())== R) || @@ -405,12 +403,12 @@ public: Point_3 p = point(vertex(e)); - if(p.hx().degree()==0 && p.hy().degree()==0 && p.hz().degree()==0) + if(Infi_box::degree(p.hx())==0 && Infi_box::degree(p.hy())==0 && Infi_box::degree(p.hz())==0) return false; Vector_3 v(tmp_point(e)); RT Outer(0,CGAL_NTS abs(p.hw()[0])); - CGAL_assertion(p.hw().degree() ==0); + CGAL_assertion(Infi_box::degree(p.hw()) ==0); if(CGAL_NTS abs(p.hx()) == Outer && ((p.hx() > 0 && v.hx() > 0)||(p.hx() < 0 && v.hx() < 0))) return false; @@ -483,10 +481,10 @@ public: CGAL_nef3_assertion( ray.target() == point(v)); Sphere_point sp(ray.source() - point(v)); TRACEN( "Locating " << sp <<" in " << point(v)); - CGAL_assertion(sp.hx().degree() < 2 && - sp.hy().degree() < 2 && - sp.hz().degree() < 2 && - sp.hw().degree() == 0); + CGAL_assertion(Infi_box::degree(sp.hx()) < 2 && + Infi_box::degree(sp.hy()) < 2 && + Infi_box::degree(sp.hz()) < 2 && + Infi_box::degree(sp.hw()) == 0); sp = Infi_box::simplify(sp); TRACEN( "Locating " << sp <<" in " << point(v)); SM_point_locator L(v); diff --git a/Packages/Nef_3/include/CGAL/Nef_3/SNC_structure.h b/Packages/Nef_3/include/CGAL/Nef_3/SNC_structure.h index 9deb1ca0078..5011cf93788 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_structure.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_structure.h @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -115,6 +116,7 @@ public: typedef typename Kernel::RT RT; typedef typename Items::Sphere_kernel Sphere_kernel; + typedef Infimaximal_box::value_type, Kernel> Infi_box; typedef typename Kernel::Point_3 Point_3; /*{\Mtypemember embedding vertices.}*/ diff --git a/Packages/Nef_3/include/CGAL/Nef_3/SNC_visualizor_OGL.h b/Packages/Nef_3/include/CGAL/Nef_3/SNC_visualizor_OGL.h index 2ff86a69a64..78a67c3ee0a 100644 --- a/Packages/Nef_3/include/CGAL/Nef_3/SNC_visualizor_OGL.h +++ b/Packages/Nef_3/include/CGAL/Nef_3/SNC_visualizor_OGL.h @@ -854,27 +854,16 @@ public: void draw(Vertex_handle v) const { - Point_3 p = point(v); - Point_3 sp(p.hx().eval_at(10000), - p.hy().eval_at(10000), - p.hz().eval_at(10000), - p.hw().eval_at(10000)); - TRACEN("vertex " << sp); - ppoly_->push_back(double_point(sp), mark(v)); + Point_3 bp = Infi_box::box_point(point(v)); + TRACEN("vertex " << bp); + ppoly_->push_back(double_point(bp), mark(v)); } void draw(Halfedge_handle e) const { Point_3 s = point(source(e)); Point_3 t = point(target(e)); - Segment_3 seg(Point_3(s.hx().eval_at(10000), - s.hy().eval_at(10000), - s.hz().eval_at(10000), - s.hw().eval_at(10000)), - Point_3(t.hx().eval_at(10000), - t.hy().eval_at(10000), - t.hz().eval_at(10000), - t.hw().eval_at(10000))); + Segment_3 seg(Infi_box::box_point(s),Infi_box::box_point(t)); TRACEN("edge " << seg); ppoly_->push_back(double_segment(seg), mark(e)); } @@ -889,11 +878,7 @@ public: SHalfedge_handle h = fc; SHalfedge_around_facet_circulator hc(h), he(hc); CGAL_For_all(hc,he){ // all vertex coordinates in facet cycle - Point_3 p = point(source(hc)); - Point_3 sp(p.hx().eval_at(10000), - p.hy().eval_at(10000), - p.hz().eval_at(10000), - p.hw().eval_at(1)); + Point_3 sp = Infi_box::box_point(point(source(hc))); TRACEN(" ");TRACEN("facet" << sp); g.push_back_vertex(double_point(sp)); }