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.
This commit is contained in:
Peter Hachenberger 2003-03-19 16:37:04 +00:00
parent f277b01d29
commit 2ccd52af63
6 changed files with 308 additions and 110 deletions

View File

@ -35,12 +35,17 @@
#include <CGAL/Simple_homogeneous.h>
#include <CGAL/Extended_homogeneous_3.h>
#include <CGAL/Nef_S2/Sphere_point.h>
CGAL_BEGIN_NAMESPACE
template <class T, class Kernel>
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 <typename SNC_structure_>
static Point_3 target_for_ray_shot(SNC_structure_* sncp, Point_3& p) {
return sncp->vertices_last();
template <typename SNC_decorator_>
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 Kernel>
class Infimaximal_box<Tag_true, Kernel > {
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<Tag_true, Kernel > {
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 <typename SNC_structure_>
static Point_3 target_for_ray_shot(SNC_structure_* sncp, Point_3 p) {
template <typename SNC_decorator_>
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 <typename SNC_structure_>
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<Point_3> 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<SNC_structure_> C(snc);
points.sort(circle_lt<Point_3>(max));
typename std::list<Point_3>::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

View File

@ -37,6 +37,8 @@
#define _DEBUG 61
#include <CGAL/Nef_3/debug.h>
// #include <CGAL/Nef_3/Infimaximal_box.h>
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<R> Self;
NT c_[6];
// typedef Infimaximal_box<typename Is_extended_kernel<R>::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<R> opposite() const
/*{\Mop returns the line opposite to |\Mvar|. }*/
{ Pluecker_line_3<R> res;
std::negate<NT> N;
std::negate<RT> N;
std::transform(begin(), end(), res.c_, N);
return res;
}
@ -176,8 +178,8 @@ static int cmp(const Pluecker_line_3<R>& 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 <typename R>
@ -208,9 +210,10 @@ std::ostream& operator<<(std::ostream& os, const Pluecker_line_3<R>& l)
template <typename R>
Pluecker_line_3<R> categorize(const Pluecker_line_3<R>& l, int& inverted)
{ Pluecker_line_3<R> res(l);
res.normalize();
if ( res.sign()<0 ) { res.negate(); inverted=1; }
else inverted=-1;
res.normalize();
CGAL_assertion(res.sign()!=0);
return res;
}

View File

@ -124,7 +124,9 @@ class SNC_constructor : public SNC_decorator<SNC_structure_>
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<SNC_structure> Self;
typedef CGAL::SNC_decorator<SNC_structure> Base;
typedef CGAL::SNC_decorator<SNC_structure> 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<SNC>
template <typename SNC_>
void
SNC_constructor<SNC_>::
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 <typename SNC_>
void
SNC_constructor<SNC_>::
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 <typename SNC_>
void
SNC_constructor<SNC_>::
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_>
typename SNC_::Vertex_handle
SNC_constructor<SNC_>::
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_key> Halfedge_list;
typedef CGAL::Pluecker_line_3<Kernel> Pluecker_line_3;
typedef CGAL::Pluecker_line_3<Standard_kernel> 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(" ("<<p<<") ("<<p+ Vector_3(tmp_point(e))<<") "<< " (" << tmp_point(e) << ") " << &*e<<" |"<<l << " " << inverted);
TRACEN(" ("<<Infi_box::standard_point(p)<<") ("<<
Infi_box::standard_point(p+ Vector_3(tmp_point(e)))<<") "<<
" (" << tmp_point(e) << ") " << &*e<<" |"<<l << " " << inverted);
}
typename Pluecker_line_map::iterator it;
@ -980,7 +1003,8 @@ link_shalfedges_to_facet_cycles() const
if( Dt.circle(cet) != D.circle(ce).opposite() )
TRACEN("assertion failed!");
TRACEN("vertices " << point(vertex(e)) << " " << point(vertex(et)) << std::endl);
TRACEN("vertices " << point(vertex(e)) <<
" " << point(vertex(et)) << std::endl);
SHalfedge_around_svertex_circulator sc(D.first_out_edge(e));
SHalfedge_around_svertex_circulator sct(Dt.first_out_edge(et));
@ -1042,7 +1066,10 @@ categorize_facet_cycles_and_create_facets() const
Sphere_circle c(tmp_circle(e));
Plane_3 h = c.plane_through(point(vertex(e)));
SM_decorator SD(vertex(e));
TRACEN(point(target(SD.source(e))) << " - " << point(vertex(e)) << " - " << point(target(SD.target(e))) << " has plane " << h << " has circle " << tmp_circle(e) << " has signum " << sign_of(h));
TRACEN(point(target(SD.source(e))) << " - " << point(vertex(e)) << " - " <<
point(target(SD.target(e))) <<
" has plane " << h << " has circle " << tmp_circle(e) <<
" has signum " << sign_of(h));
if ( sign_of(h)<0 ) continue;
// CGAL_nef3_assertion( h == normalized(h));
M[normalized(h)].push_back(SObject_handle(twin(e)));

View File

@ -40,7 +40,6 @@
#include <CGAL/Nef_3/SNC_SM_overlayer.h>
#include <CGAL/Nef_3/SNC_SM_io_parser.h>
#include <CGAL/Nef_3/SNC_ray_shooter.h>
#include <CGAL/Nef_3/Infimaximal_box.h>
#include <CGAL/IO/Verbose_ostream.h>
#ifdef CGAL_NEF3_SM_VISUALIZOR
#include <CGAL/Nef_3/SNC_SM_visualizor.h>
@ -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<typename Is_extended_kernel<Kernel>::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);

View File

@ -38,6 +38,7 @@
#include <CGAL/Nef_3/SNC_iteration.h>
#include <CGAL/Nef_3/SNC_items.h>
#include <CGAL/Nef_3/nef3_assertions.h>
#include <CGAL/Nef_3/Infimaximal_box.h>
#include <CGAL/Nef_2/iterator_tools.h>
#include <CGAL/Union_find.h>
#include <list>
@ -115,6 +116,7 @@ public:
typedef typename Kernel::RT RT;
typedef typename Items::Sphere_kernel Sphere_kernel;
typedef Infimaximal_box<typename Is_extended_kernel<Kernel>::value_type, Kernel> Infi_box;
typedef typename Kernel::Point_3 Point_3;
/*{\Mtypemember embedding vertices.}*/

View File

@ -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));
}