marks_of_halfspheres is now only computed when needed.

This commit is contained in:
Peter Hachenberger 2004-01-21 14:33:58 +00:00
parent a03ebeb4bd
commit f09c39385a
6 changed files with 74 additions and 66 deletions

View File

@ -31,6 +31,7 @@
#include <CGAL/Nef_2/geninfo.h>
#include <CGAL/Nef_S2/Sphere_geometry.h>
#include <CGAL/Nef_3/SNC_SM_decorator.h>
#include <CGAL/Nef_3/SNC_SM_point_locator.h>
#include <CGAL/Nef_3/SNC_SM_io_parser.h>
#include <CGAL/Nef_3/Normalizing.h>
#undef _DEBUG
@ -279,6 +280,7 @@ public:
typedef SNC_SM_decorator<Refs_> Base;
typedef SNC_SM_decorator<Refs_> Decorator;
typedef SNC_SM_overlayer<Refs_> Self;
typedef CGAL::SNC_SM_point_locator<SNC_structure> SM_point_locator;
#define USING(t) typedef typename Refs_::t t
USING(Vertex_handle);
@ -570,7 +572,7 @@ public:
template <typename Below_accessor>
void complete_face_support(SVertex_iterator v_start, SVertex_iterator v_end,
const Below_accessor& D, int pos) const;
Below_accessor& D, std::vector<Mark>& mohs, int offset);
void dump(std::ostream& os = std::cerr) const
{ SNC_SM_io_parser<Refs_>::dump(center_vertex(),os); }
@ -838,8 +840,15 @@ subdivide(Vertex_handle v0, Vertex_handle v1)
TRACEN(PH(u) << " with circle " << circle(u));
}
complete_face_support(svertices_begin(), v, O, +1);
complete_face_support(v, svertices_end(), O, -1);
std::vector<Mark> mohs(4);
SM_point_locator L0(PI[0].center_vertex());
SM_point_locator L1(PI[1].center_vertex());
L0.init_marks_of_halfspheres(mohs, 0);
L1.init_marks_of_halfspheres(mohs, 2);
complete_face_support(svertices_begin(), v, O, mohs, 1);
complete_face_support(v, svertices_end(), O, mohs, 0);
/* DEBUG CODE: to do: have all svertices a halfedge below associated? */
TRACEN("Vertex info after swep");
@ -1007,7 +1016,7 @@ template <typename Refs_>
template <typename Below_accessor>
void SNC_SM_overlayer<Refs_>::
complete_face_support(SVertex_iterator v_start, SVertex_iterator v_end,
const Below_accessor& D, int pos) const
Below_accessor& D, std::vector<Mark>& mohs, int offset)
{ TRACEN("complete_face_support");
for (SVertex_iterator v = v_start; v != v_end; ++v) {
TRACEN("VERTEX = "<<PH(v));
@ -1036,10 +1045,10 @@ complete_face_support(SVertex_iterator v_start, SVertex_iterator v_end,
}
}
else {
m_buffer[i] = PI[i].mark_of_halfsphere(-pos);
m_buffer[i] = mohs[offset+2*i];
TRACEN("no initial support");
}
// m_buffer[i] = PI[i].mark_of_halfsphere(-pos);
// m_buffer[i] = mohs[offset+2*i];
}
} else if ( e_below != SHalfedge_handle() ) {
for (int i=0; i<2; ++i) {
@ -1048,7 +1057,7 @@ complete_face_support(SVertex_iterator v_start, SVertex_iterator v_end,
}
} else { // e_below does not exist
CGAL_nef3_assertion( point(v).hz() == 0 &&
( pos > 0 ? (point(v).hx() >= 0) : (point(v).hx()<=0)) );
( offset > 0 ? (point(v).hx() >= 0) : (point(v).hx()<=0)) );
for (int i=0; i<2; ++i)
m_buffer[i] = incident_mark(previous(first_out_edge(v)),i);
} TRACEN(" faces right and below "<<m_buffer[0]<<" "<<m_buffer[1]);
@ -1253,15 +1262,6 @@ select(const Selection& SP) const
mark(f) = SP(mark(f,0),mark(f,1));
discard_info(f);
}
mark_of_halfsphere(-1) = SP(PI[0].mark_of_halfsphere(-1),
PI[1].mark_of_halfsphere(-1));
mark_of_halfsphere(+1) = SP(PI[0].mark_of_halfsphere(+1),
PI[1].mark_of_halfsphere(+1));
TRACEN(PI[0].mark_of_halfsphere(-1) << "," << PI[1].mark_of_halfsphere(-1) << "=>" << mark_of_halfsphere(-1));
TRACEN(PI[0].mark_of_halfsphere(+1) << "," << PI[1].mark_of_halfsphere(+1) << "=>" << mark_of_halfsphere(+1));
}
template <typename Refs_>

View File

@ -20,6 +20,7 @@
#ifndef CGAL_SNC_SM_POINT_LOCATOR_H
#define CGAL_SNC_SM_POINT_LOCATOR_H
#include <vector>
#include <CGAL/basic.h>
#include <CGAL/Unique_hash_map.h>
#include <CGAL/Nef_2/geninfo.h>
@ -457,7 +458,7 @@ public:
return h;
}
void init_marks_of_halfspheres();
void init_marks_of_halfspheres(std::vector<Mark>& mohs, int offset);
/*{\Mop initializes the default marks of the sphere map.}*/
// C++ is really friendly:
@ -484,15 +485,16 @@ public:
template <typename D>
void SNC_SM_point_locator<D>::init_marks_of_halfspheres()
void SNC_SM_point_locator<D>::init_marks_of_halfspheres(std::vector<Mark>& mohs, int offset)
{ TRACEN("init_marks_of_halfspheres " << center_vertex()->point());
Sphere_point y_minus(0,-1,0);
SObject_handle h = locate(y_minus);
SFace_const_handle f;
if ( assign(f,h) ) {
TRACEN("on face " << mark(f));
mark_of_halfsphere(-1) = mark_of_halfsphere(+1) = mark(f);
TRACEN(mark_of_halfsphere(-1) << " " << mark_of_halfsphere(+1));
mohs[offset] = mohs[offset+1] = mark(f);
// TRACEN(mark_of_halfsphere(-1) << " " << mark_of_halfsphere(+1));
return;
}
@ -503,9 +505,9 @@ void SNC_SM_point_locator<D>::init_marks_of_halfspheres()
TRACEN("on edge "<<op);
if ( (op.x() > 0) || (op.x() == 0) && (op.z() < 0) ) e = twin(e);
// if ( (op.z() < 0) || (op.z() == 0) && (op.x() > 0) ) e = twin(e);
mark_of_halfsphere(+1) = mark(face(e));
mark_of_halfsphere(-1) = mark(face(twin(e)));
TRACEN(mark_of_halfsphere(-1) << " " << mark_of_halfsphere(+1));
mohs[offset+1] = mark(face(e));
mohs[offset] = mark(face(twin(e)));
// TRACEN(mark(face(e)) << " " << mark(face(twin(e)));
return;
}
@ -516,9 +518,9 @@ void SNC_SM_point_locator<D>::init_marks_of_halfspheres()
TRACEN("on loop "<<op);
if ( (op.x() > 0) || ((op.x() == 0) && (op.z() < 0)) ) l = twin(l);
// if ( (op.z() < 0) || (op.z() == 0) && (op.x() > 0) ) l = twin(l);
mark_of_halfsphere(+1) = mark(face(l));
mark_of_halfsphere(-1) = mark(face(twin(l)));
TRACEN(mark_of_halfsphere(-1) << " " << mark_of_halfsphere(+1));
mohs[offset+1] = mark(face(l));
mohs[offset] = mark(face(twin(l)));
// TRACEN(mark_of_halfsphere(-1) << " " << mark_of_halfsphere(+1));
return;
}
@ -529,21 +531,21 @@ void SNC_SM_point_locator<D>::init_marks_of_halfspheres()
if ( assign(v,h) ) {
CGAL_nef3_assertion(point(v)==y_minus);
if(is_isolated(v))
mark_of_halfsphere(+1) = mark_of_halfsphere(-1) = mark(face(v));
mohs[offset+1] = mohs[offset] = mark(face(v));
else {
e = out_wedge(v,left,collinear);
if ( collinear ) mark_of_halfsphere(+1) = mark(face(twin(e)));
else mark_of_halfsphere(+1) = mark(face(e));
if ( collinear ) mohs[offset+1] = mark(face(twin(e)));
else mohs[offset+1] = mark(face(e));
e = out_wedge(v,right,collinear);
if ( collinear ) mark_of_halfsphere(-1) = mark(face(twin(e)));
else mark_of_halfsphere(-1) = mark(face(e));
if ( collinear ) mohs[offset] = mark(face(twin(e)));
else mohs[offset] = mark(face(e));
}
TRACEN(mark_of_halfsphere(-1) << " " << mark_of_halfsphere(+1));
// TRACEN(mark_of_halfsphere(-1) << " " << mark_of_halfsphere(+1));
return;
}
/*
TRACEN("1 dimensional object");
mark_of_halfsphere(-1) = mark_of_halfsphere(+1) = 0;
mohs[offset] = mohs[offset+1] = 0;
*/
CGAL_nef3_assertion_msg(0,"damn wrong type");
return;

View File

@ -804,8 +804,8 @@ create_SM_on_infibox(Point_3 center, Sphere_point* SP, int size,
SD.link_as_face_cycle(SD.twin(she[0]),sf[1]);
SD.link_as_face_cycle(SD.twin(she[1]),sf[2]);
SM_point_locator L(v);
L.init_marks_of_halfspheres();
// SM_point_locator L(v);
// L.init_marks_of_halfspheres();
}
// ----------------------------------------------------------------------------
@ -863,8 +863,8 @@ create_box_corner(int x, int y, int z, bool space, bool boundary) const {
// SD.mark_of_halfsphere(-1) = (x<0 && y>0 && z>0);
// SD.mark_of_halfsphere(+1) = (x>0 && y>0 && z<0);
/* TODO: to check if the commented code above could be wrong */
SM_point_locator L(v);
L.init_marks_of_halfspheres();
// SM_point_locator L(v);
// L.init_marks_of_halfspheres();
return v;
}
@ -927,8 +927,8 @@ create_extended_box_corner(int x,int y,int z,bool space,bool boundary) const {
// SD.mark_of_halfsphere(-1) = (x<0 && y>0 && z>0);
// SD.mark_of_halfsphere(+1) = (x>0 && y>0 && z<0);
/* TODO: to check if the commented code above could be wrong */
SM_point_locator L(v);
L.init_marks_of_halfspheres();
// SM_point_locator L(v);
// L.init_marks_of_halfspheres();
return v;
}
@ -961,6 +961,7 @@ create_from_facet(Halffacet_handle f, const Point_3& p) const
D.mark(f2) = mark(volume(twin(f)));
D.mark(l) = mark(f);
#ifdef CGAL_NEF3_BUGGY_CODE
/*
Sphere_point q(0,-1,0);
CGAL::Oriented_side os = c.oriented_side(q);
switch ( os ) {
@ -976,10 +977,11 @@ create_from_facet(Halffacet_handle f, const Point_3& p) const
if ( c.a()>=0 && c.c()<=0 ) // normal(c) dx<=0&&dz>=0
D.mark_of_halfsphere(-1) = true;
}
*/
/* TODO: to find why the code chuck above is wrong */
#endif // CGAL_NEF3_BUGGY_CODE
SM_point_locator L(v);
L.init_marks_of_halfspheres();
// SM_point_locator L(v);
// L.init_marks_of_halfspheres();
return v;
}
@ -1053,8 +1055,8 @@ create_from_edge(Halfedge_handle e,
}
TRACEN(" ");
SM_point_locator L(v);
L.init_marks_of_halfspheres();
// SM_point_locator L(v);
// L.init_marks_of_halfspheres();
/*
CGAL_nef3_forall_shalfedges(eee,D)
@ -1139,8 +1141,8 @@ clone_SM( typename SNC_::Vertex_handle vin) {
}
}
D.mark_of_halfsphere(-1) = E.mark_of_halfsphere(-1);
D.mark_of_halfsphere(+1) = E.mark_of_halfsphere(+1);
// D.mark_of_halfsphere(-1) = E.mark_of_halfsphere(-1);
// D.mark_of_halfsphere(+1) = E.mark_of_halfsphere(+1);
return vout;
}
@ -1243,8 +1245,8 @@ create_edge_facet_overlay( typename SNC_::Halfedge_handle e,
}
}
SM_point_locator L(D.center_vertex());
L.init_marks_of_halfspheres();
// SM_point_locator L(D.center_vertex());
// L.init_marks_of_halfspheres();
return D.center_vertex();
}

View File

@ -140,7 +140,6 @@ public:
USING(Line_3);
USING(Plane_3);
USING(Vector_3);
USING(Direction_3);
USING(Sphere_kernel);
USING(Sphere_point);
@ -750,7 +749,7 @@ public:
Halffacet_handle res = facet(sh);
Direction_3 ed(segment(e).direction());
Vector_3 ed(segment(e).direction());
Vector_3 ev(segment(e).direction()), rv(ray.direction());
SHalfedge_around_svertex_circulator sh(SD.first_out_edge(e)), send(sh);
Vector_3 vec0(cross_product(ev,plane(res).orthogonal_vector()));
@ -864,8 +863,8 @@ public:
SFace_handle f = SD.new_face();
SD.mark(f) = mark(c);
TRACEN("volume "<<&*c<<" marked as "<<mark(c));
SM_point_locator PL(v);
PL.init_marks_of_halfspheres(); // necessary to init default marks
// SM_point_locator PL(v);
// PL.init_marks_of_halfspheres(); // necessary to init default marks
return v;
}
@ -1171,11 +1170,13 @@ public:
void compute_all_marks_of_halfspheres() {
Vertex_handle v;
// Vertex_handle v;
/*
CGAL_nef3_forall_vertices(v,*this) {
SM_point_locator L(v);
L.init_marks_of_halfspheres();
}
}
*/
}
bool is_valid( bool verb = false, int level = 0) {
@ -1211,15 +1212,15 @@ public:
Points.push_back(point(vi));
Mark m1 = SD.mark_of_halfsphere(-1);
Mark m2 = SD.mark_of_halfsphere(+1);
SM_point_locator PL(vi);
PL.init_marks_of_halfspheres();
valid = valid && (SD.mark_of_halfsphere(-1) == m1);
valid = valid && (SD.mark_of_halfsphere(+1) == m2);
// Mark m1 = SD.mark_of_halfsphere(-1);
// Mark m2 = SD.mark_of_halfsphere(+1);
// SM_point_locator PL(vi);
// PL.init_marks_of_halfspheres();
// valid = valid && (SD.mark_of_halfsphere(-1) == m1);
// valid = valid && (SD.mark_of_halfsphere(+1) == m2);
TRACEN(m1 << "," << m2 << " should have been " <<
SD.mark_of_halfsphere(-1) << "," << SD.mark_of_halfsphere(+1));
// TRACEN(m1 << "," << m2 << " should have been " <<
// SD.mark_of_halfsphere(-1) << "," << SD.mark_of_halfsphere(+1));
valid = valid && (++count <= max);
}

View File

@ -1918,10 +1918,12 @@ public:
CGAL_nef3_assertion(OK);
/*
for(i = 0; i<v; i++) {
SM_point_locator PL(V[i]);
PL.init_marks_of_halfspheres();
}
*/
CGAL_nef3_assertion(OK);
@ -2362,10 +2364,12 @@ public:
}
/*
for(i = 0; i<v+addInfiBox*8; i++) {
SM_point_locator PL(V[i]);
PL.init_marks_of_halfspheres();
}
*/
delete[] V;
delete[] E;

View File

@ -48,7 +48,6 @@ struct Facet_plane_3 {
typedef Kernel_traits< Plane> KernelTraits;
typedef typename KernelTraits::Kernel Kernel;
typedef typename Kernel::Vector_3 Vector;
typedef typename Kernel::Direction_3 Direction;
typedef typename Facet::Halfedge_around_facet_const_circulator
Halfedge_circulator;
typedef typename Facet::Halfedge Halfedge;
@ -67,8 +66,8 @@ struct Facet_plane_3 {
Vector plane_orthogonal_vector;
normal_vector_newell_3( point_cir, point_cir, plane_orthogonal_vector);
TRACEN( *point_cir);
TRACEN(Plane( *point_cir, Direction( plane_orthogonal_vector)));
return( Plane( *point_cir, Direction( plane_orthogonal_vector)));
TRACEN(Plane( *point_cir, Vector( plane_orthogonal_vector)));
return( Plane( *point_cir, Vector( plane_orthogonal_vector)));
}
};
@ -200,8 +199,8 @@ void polyhedron_3_to_nef_3(Polyhedron_& P, SNC_structure& S)
SM.mark(fext) = false;
SM.check_integrity_and_topological_planarity();
SM_point_locator L(nv);
L.init_marks_of_halfspheres();
// SM_point_locator L(nv);
// L.init_marks_of_halfspheres();
}
}