regular triangulation passes test (but output is not updated yet)

This commit is contained in:
Daniel Russel 2007-02-03 02:44:51 +00:00
parent 03410dee13
commit c0f30b87a7
6 changed files with 146 additions and 57 deletions

View File

@ -241,8 +241,46 @@ struct Regular_triangulation_3_types
typedef CGAL::Regular_triangulation_3<typename Traits::Instantaneous_kernel, TDS> Default_triangulation;
template <class KRT>
struct Mirroring_visitor {
//friend class CGAL::Delaunay_triangulation_3<typename P::Instantaneous_kernel, TDS>;
};
CGAL_KINETIC_END_INTERNAL_NAMESPACE
CGAL_KINETIC_BEGIN_NAMESPACE
/*!
redundant_cells_ maps each cell with redundant points to the ids of the points in that cell
redundant_points_ maps each redundant point to a certificate
*/
template <class TraitsT,
class VisitorT= Regular_triangulation_visitor_base_3,
class TriangulationT= typename internal::Regular_triangulation_3_types<TraitsT>::Default_triangulation>
class Regular_triangulation_3:
public Ref_counted<Regular_triangulation_3<TraitsT, VisitorT, TriangulationT> >
{
private:
typedef Regular_triangulation_3<TraitsT, VisitorT, TriangulationT> This;
public:
typedef TraitsT Traits;
typedef typename Traits::Active_points_3_table::Key Point_key; //here
protected:
typedef typename Traits::Active_points_3_table MPT; // here
typedef typename Traits::Simulator Simulator;
typedef typename Traits::Simulator::Event_key Event_key;
typedef typename Traits::Simulator::Time Time;
typedef typename Traits::Kinetic_kernel::Certificate Root_stack;
typedef TriangulationT Delaunay;
typedef internal::Regular_triangulation_3_types<TraitsT> Types;
struct Delaunay_visitor {
template <class Point_key, class Cell_handle>
void pre_insert_vertex(Point_key v, Cell_handle h) {
v_.pre_insert_vertex(v, h);
@ -310,51 +348,13 @@ struct Regular_triangulation_3_types
v_.post_move(k,h);
}
Mirroring_visitor(KRT* krt, typename KRT::Visitor v): krt_(krt), v_(v){}
Delaunay_visitor(This* krt, VisitorT v): krt_(krt), v_(v){}
KRT* krt_;
typename KRT::Visitor v_;
This* krt_;
VisitorT v_;
};
//friend class CGAL::Delaunay_triangulation_3<typename P::Instantaneous_kernel, TDS>;
};
CGAL_KINETIC_END_INTERNAL_NAMESPACE
CGAL_KINETIC_BEGIN_NAMESPACE
/*!
redundant_cells_ maps each cell with redundant points to the ids of the points in that cell
redundant_points_ maps each redundant point to a certificate
*/
template <class TraitsT,
class VisitorT= Regular_triangulation_visitor_base_3,
class TriangulationT= typename internal::Regular_triangulation_3_types<TraitsT>::Default_triangulation>
class Regular_triangulation_3:
public Ref_counted<Regular_triangulation_3<TraitsT, VisitorT, TriangulationT> >
{
private:
typedef Regular_triangulation_3<TraitsT, VisitorT, TriangulationT> This;
public:
typedef TraitsT Traits;
typedef typename Traits::Active_points_3_table::Key Point_key; //here
protected:
typedef typename Traits::Active_points_3_table MPT; // here
typedef typename Traits::Simulator Simulator;
typedef typename Traits::Simulator::Event_key Event_key;
typedef typename Traits::Simulator::Time Time;
typedef typename Traits::Kinetic_kernel::Certificate Root_stack;
typedef TriangulationT Delaunay;
typedef internal::Regular_triangulation_3_types<TraitsT> Types;
typedef typename Types::template Mirroring_visitor<This> Delaunay_visitor;
friend class internal::Regular_triangulation_3_types<TraitsT>::Mirroring_visitor<This>;
friend class Delaunay_visitor;
typedef typename Delaunay::Facet Facet;
typedef typename Delaunay::Edge Edge;
@ -506,6 +506,14 @@ public:
void write(std::ostream &out) const {
if (triangulation().dimension() != 3) return;
kdel_.write(out);
for (typename Triangulation::Finite_vertices_iterator vit= triangulation().finite_vertices_begin();
vit != triangulation().finite_vertices_end(); ++vit) {
if (kdel_.is_degree_4(vit)) {
out << vit->point() << ": " << vit->info() << std::endl;
} else if (!kdel_.is_degree_4(vit) && vit->info() != Event_key()) {
out << vit->point() << "******: " << vit->info() << std::endl;
}
}
out << "Redundant points: ";
for (typename RPMap::const_iterator it= redundant_points_.begin(); it != redundant_points_.end();
++it) {
@ -524,6 +532,7 @@ public:
out << it->second << " ";
}
out << std::endl;
}
@ -728,6 +737,7 @@ protected:
CGAL_assertion(vit->info() != Event_key() || !k.is_valid());
}
else {
CGAL_assertion_code(Point_key k= vit->point());
CGAL_assertion(vit->info() == Event_key());
}
CGAL_assertion(redundant_points_.find(vit->point())== redundant_points_.end());
@ -894,6 +904,7 @@ protected:
}
void handle_vertex(typename Triangulation::Vertex_handle vh, Root_stack &s) {
CGAL_KINETIC_LOG(LOG_LOTS, "Updating vertex " << vh->point() << std::endl);
if (s.will_fail()) {
Time t= s.failure_time();
s.pop_failure_time();
@ -904,6 +915,7 @@ protected:
}
void handle_vertex(typename Triangulation::Vertex_handle vh) {
CGAL_KINETIC_LOG(LOG_LOTS, "Handling vertex " << vh->point() << std::endl);
if (vh== triangulation().infinite_vertex()) return;
CGAL_precondition( internal::has_degree_4(triangulation(), vh));
CGAL_precondition( vh->info() == Event_key());
@ -962,10 +974,14 @@ protected:
void destroy_cell(typename Triangulation::Cell_handle h) {
CGAL_KINETIC_LOG(LOG_LOTS, "Cleaning cell " << h->vertex(0)->point()
<< " " << h->vertex(1)->point() << " " << h->vertex(2)->point()
<< " " << h->vertex(3)->point() << std::endl);
for (unsigned int i=0; i<4; ++i) {
if (h->vertex(i)->info() != Event_key()) {
CGAL_KINETIC_LOG(LOG_LOTS, "Cleaning vertex " << h->vertex(i)->point() << std::endl);
kdel_.simulator()->delete_event(h->vertex(i)->info());
h->vertex(i)->info() == Event_key();
h->vertex(i)->info() = Event_key();
}
}
typename RCMap::iterator beg= redundant_cells_.lower_bound(h);
@ -977,6 +993,9 @@ protected:
}
void create_cell(typename Triangulation::Cell_handle h) {
CGAL_KINETIC_LOG(LOG_LOTS, "Creating cell " << h->vertex(0)->point()
<< " " << h->vertex(1)->point() << " " << h->vertex(2)->point()
<< " " << h->vertex(3)->point() << std::endl);
for (unsigned int i=0; i< 4; ++i){
if (h->vertex(i)->info() == Event_key() && kdel_.is_degree_4(h->vertex(i))){
handle_vertex(h->vertex(i));

View File

@ -820,7 +820,7 @@ public:
CGAL_KINETIC_LOG(LOG_LOTS, "making certificate for edge ");
CGAL_KINETIC_LOG_WRITE(LOG_LOTS, triangulation_.write_edge(e, LOG_STREAM));
CGAL_KINETIC_LOG(LOG_LOTS, std::endl);
CGAL_precondition(triangulation_.has_degree_3(e));
CGAL_precondition(is_degree_3(e));
CGAL_precondition_code(Facet_circulator fc= triangulation_.incident_facets(e));
CGAL_precondition_code(Facet_circulator fe= fc);
CGAL_precondition_code(do {
@ -854,10 +854,15 @@ public:
make_certificate(e, simulation_traits_object().simulator_handle()->current_time());
}
void make_certificate( const Facet &e,
const typename Simulator::Time &st) {
CGAL_precondition(!has_event(e));
CGAL_KINETIC_LOG(LOG_LOTS, "making certificate for facet ");
CGAL_KINETIC_LOG_WRITE(LOG_LOTS, triangulation_.write_facet(e, LOG_STREAM ));
//triangulation_.write_facet(e, log_lots());
CGAL_KINETIC_LOG(LOG_LOTS, std::endl);
@ -984,11 +989,47 @@ private:
}
void create_edge_flips(Vertex_handle v) {
CGAL_precondition(!is_degree_4(v));
std::vector<Cell_handle> ics;
triangulation().incident_cells(v, std::back_inserter(ics));
for (unsigned int i=0; i< ics.size(); ++i) {
int j;
bool ret=ics[i]->has_vertex(v, j);
CGAL_assertion(ret);
for (int k=0; k<4 ; ++k) {
if (k==j) continue;
Edge e(ics[i], j, k);
if (is_degree_3(e) && !has_event(e) && !has_degree_4_vertex(e)) {
// rather than make_certificate due to ordering dependencies
make_edge_flip(e);
}
}
}
}
void suppress_edge_flips(Vertex_handle v) {
CGAL_precondition(is_degree_4(v));
std::vector<Cell_handle> ics;
triangulation().incident_cells(v, std::back_inserter(ics));
for (unsigned int i=0; i< ics.size(); ++i) {
int j;
bool ret=ics[i]->has_vertex(v, j);
CGAL_assertion(ret);
for (int k=0; k<4 ; ++k) {
if (k==j) continue;
Edge e(ics[i], j, k);
if (has_event(e)) {
simulator()->delete_event(triangulation_.label(e));
triangulation().set_label(e, Event_key());
}
}
}
}
void make_edge_flip(Edge &edge) {
CGAL_KINETIC_LOG(LOG_LOTS, "Making edge flip ");
//triangulation_.write_edge(edge, log_lots() );
CGAL_KINETIC_LOG_WRITE(LOG_LOTS, triangulation_.write_labeled_edge(edge, LOG_STREAM ));
CGAL_KINETIC_LOG(LOG_LOTS,std::endl);
CGAL_assertion(triangulation_.has_degree_3(edge));
typename Simulator::Event_key k= typename Simulator::Event_key();
@ -1008,12 +1049,12 @@ private:
CGAL_KINETIC_LOG(LOG_LOTS, "Making up edge event.\n");
make_certificate(edge);
}
}
void make_not_edge_flip(Edge &edge, Cell_handle h) {
if (true) {
CGAL_KINETIC_LOG(LOG_LOTS, "Making edge ");
//triangulation_.write_labeled_edge(edge, log_lots() );
CGAL_KINETIC_LOG_WRITE(LOG_LOTS, triangulation_.write_labeled_edge(edge, LOG_STREAM ));
CGAL_KINETIC_LOG(LOG_LOTS, " not an edge flip.\n");
}
CGAL_assertion(is_degree_3(edge) || print());
@ -1086,6 +1127,14 @@ private:
{
if (triangulation_.dimension() != 3) return true;
std::set<Point_key> pks;
for (Finite_vertices_iterator eit = triangulation_.finite_vertices_begin();
eit != triangulation_.finite_vertices_end(); ++eit) {
CGAL_assertion_code(Point_key k= eit->point());
CGAL_assertion(pks.find(k) == pks.end());
pks.insert(k);
}
if (!has_certificates()) {
for (All_edges_iterator eit = triangulation_.all_edges_begin();
eit != triangulation_.all_edges_end(); ++eit) {
@ -1103,7 +1152,7 @@ private:
eit != triangulation_.all_edges_end(); ++eit) {
bool isd3= is_degree_3(*eit);
bool hd4= has_degree_4_vertex(*eit);
if (!isd3/* || hd4*/) {
if (!isd3 || hd4) {
if (has_event(*eit)) {
std::cerr << "Edge should not have certificate ";
triangulation_.write_labeled_edge(*eit, std::cerr);
@ -1111,7 +1160,7 @@ private:
simulator()->audit_event(triangulation_.label(*eit));
CGAL_assertion(0);
}
} else if (!hd4 && isd3) {
} else if ( isd3) {
if (!has_event(*eit)) {
std::cerr << "Edge should have certificate ";
triangulation_.write_labeled_edge(*eit, std::cerr);
@ -1204,6 +1253,15 @@ private:
}
}
for (unsigned int i=0; i<4; ++i) {
Vertex_handle vh= h->vertex(i);
if (is_degree_4(vh)) {
suppress_edge_flips(vh);
} else {
create_edge_flips(vh);
}
}
v_.create_cell(h);
}
void handle_changed_cell(Cell_handle) {

View File

@ -27,6 +27,8 @@
CGAL_KINETIC_BEGIN_INTERNAL_NAMESPACE
template <class KK>
struct Cartesian_side_of_oriented_sphere_3
{

View File

@ -79,7 +79,7 @@ protected:
//------------------------------------------------------------------
// the method for subdivision; it guarantees that the first interval
// contains only one root
void subdivide() {
void subdivide() const {
if (intervals_.empty() ) { return; }
while ( intervals_.back().lbc_ - intervals_.back().ubc_!=1 ) {
@ -304,9 +304,9 @@ protected:
void clean() const {
current_=Root();
finish_=Root();
p_=Polynomial();
root_counter_=Root_count();
//finish_=Root();
//p_=Polynomial();
//root_counter_=Root_count();
done_=true;
}

View File

@ -4,4 +4,13 @@
-3208113025/1073741824+2370861105/2147483648*t , 1232376365/536870912-2303977265/1073741824*t , -32881665/67108864+1641742195/2147483648*t , 3950535805/1073741824+672982815/536870912*t
-795713035/1073741824+1090287165/536870912*t , -4808385095/1073748124-4896776825/2147483648*t , -630902835/536870912+763476195/1073741824*t , 1658750225/536870912+3406044455/2147483648*t
2438968515/1073741824+3681819045/2147483648*t , 2296028925/1073748124+86524915/2147483648*t , -1659680135/1073741824-256262365/1073741824*t , 4969623645/1073741824+160762305/2147483648*t
3468769205/1073741824-3570285195/2147483648*t , -5196882595/1073741824-654223245/268435456*t , -373218095/536870912+1174854945/1073741824*t , 1170783695/1073741824+22026395/33554432*t
1299835245/536870912-179421955/134217728*t , -1815752935/536870912-1872750445/1073741824*t , 8466035/1073741824+2278420335/2147483648*t , 398357525/1073741824+1702247505/2147483648*t
-796406715/268435456-3896362155/2147483648*t , -4368294455/1073741824-2095403945/1073741824*t , -349051165/1073741824-2225158655/2147483648*t , 524152915/134217728+977828195/536870912*t
4103930155/1073741824-1917156935/1073741824*t , 1447870335/1073741824-727341635/536870912*t , 3511867305/1073741824-779664835/536870912*t , 151069505/67108864+5003164455/2147483648*t
-2737540015/1073741824+819268375/1073741824*t , 751806795/536870912-276720025/268435456*t , 402619515/536870912+1509951875/1073741824*t , 469558045/536870912+141312735/268435456*t
-238278475/536870912-179282775/536870912*t , -1170169665/536870912+749560935/2147483648*t , 3839849715/1073741824-102816295/134217728*t , 1010700445/536870912+183243895/268435456*t
109373475/67108864+4552498465/2147483648*t , 3374597235/1073741824-2476215405/1073741824*t , 82544905/33554432+1764926225/2147483648*t , 3222322565/1073741824+821929875/536870912*t
1864148645/1073741824+2367426995/2147483648*t , -91915585/1073741824+2586172245/2147483648*t , 336122465/1073741824+1516499615/1073741824*t , 3398543895/1073741824+1249649025/536870912*t
-1278923285/1073741824+1624478065/2147483648*t , -1530470855/1073741824-3658034475/2147483648*t , -1309229105/1073741824-385444205/1073741824*t , +2504547825/536870912+131899625/67108864*t
-629664685/1073741824+3818522245/2147483648*t , -1149873905/536870912-1922223915/1073741824*t , 1584661005/536870912+29788845/536870912*t , 1005478335/268435456+199788725/2147483648*t

View File

@ -9,6 +9,7 @@ sired. Make the tables simply an event manager rather than owning the points (so
- make sorting general- solve linking first
- times can generate certificate func and solve. Queue checks if they are dirty (a point changed--when check? that is hard--maybe collapse to front of interval if need exact and is dirty) and reinserts them if they are. Points are ref counted pointers. With interval rep and way to generate exact. Then just insert notifications. Dirty is keept by generation count per point. Time is k ints, k points, inexact func, interval--broken-what if time moves up? Need linear scans.
- popping too early means that I always isolate one root ahead, stop doing that or make root stack lazy. This is hard as the end can always kill a root and I need to answer empty() queries accurately
- Delaunay/Regular 3D does all sorts of extra walking around the mesh.
Easy:
- pull static_pred/IP into kinetic pred to get result types right and things