mirror of https://github.com/CGAL/cgal
simplified insert_outside_affine_hull, therefore changed also update_ghost_faces
This commit is contained in:
parent
ac2bea87f4
commit
33c460e584
|
|
@ -181,12 +181,13 @@ void set_radius(double radius){
|
|||
Vertex_handle insert(const Point &p, Face_handle f = Face_handle() );
|
||||
Vertex_handle insert_first(const Point &p);
|
||||
Vertex_handle insert_second(const Point &p);
|
||||
Vertex_handle insert_outside_affine_hull_regular(const Point& p,bool plane=false);
|
||||
//Vertex_handle insert_outside_affine_hull_regular(const Point& p,bool plane=false);
|
||||
Vertex_handle insert_outside_affine_hull_regular(const Point& p);
|
||||
//Vertex_handle insert_hole_approach_2(const Point &p, Locate_type lt, Face_handle loc, int li) ;
|
||||
Vertex_handle insert_in_plane_triangulation(const Point &p, Locate_type lt, Face_handle loc);
|
||||
|
||||
bool test_conflict(const Point &p, Face_handle fh) const;
|
||||
bool update_ghost_faces(Vertex_handle v=Vertex_handle());
|
||||
bool update_ghost_faces(Vertex_handle v=Vertex_handle(), bool first = false);
|
||||
|
||||
//REMOVAL
|
||||
void remove_degree_3(Vertex_handle v, Face_handle f = Face_handle());
|
||||
|
|
@ -568,7 +569,8 @@ is_valid(bool verbose, int level ) const //int level
|
|||
case 2 :
|
||||
for(All_faces_iterator it=all_faces_begin(); it!=all_faces_end(); it++) {
|
||||
Orientation s = orientation(it->vertex(0)->point(), it->vertex(1)->point(), it->vertex(2)->point());
|
||||
result = result && ( s == LEFT_TURN || it->is_ghost());
|
||||
//result = result && ( s == LEFT_TURN || it->is_ghost());
|
||||
result = result && (s != NEGATIVE || it->is_ghost());
|
||||
CGAL_triangulation_assertion(result);
|
||||
}
|
||||
|
||||
|
|
@ -661,47 +663,6 @@ insert_in_plane_triangulation(const Point &p, Locate_type lt, Face_handle loc){
|
|||
CGAL_triangulation_precondition(!test_dim_up(p));
|
||||
CGAL_triangulation_precondition(dimension()==1);
|
||||
|
||||
/*
|
||||
Face_handle f = edges_begin()->first;
|
||||
Face_handle loc;
|
||||
//existing points coplanar with sphere?
|
||||
Orientation pqr = orientation(f->vertex(0)->point(),
|
||||
f->vertex(1)->point(),
|
||||
f->neighbor(0)->vertex(1)->point());
|
||||
if( pqr != ON_ORIENTED_BOUNDARY ){
|
||||
Edges_iterator eit=edges_begin();
|
||||
do{
|
||||
Face_handle f=eit->first;
|
||||
Vertex_handle v1 = f->vertex(0);
|
||||
Vertex_handle v2 = f -> vertex(1);
|
||||
if(orientation(v1->point(), v2->point(), p)==RIGHT_TURN){
|
||||
loc = f;
|
||||
break;
|
||||
|
||||
} eit++;
|
||||
}while( eit!=edges_end());
|
||||
}
|
||||
else {
|
||||
|
||||
Edges_iterator eit=edges_begin();
|
||||
Point po = Point(0,0,0);
|
||||
|
||||
do{
|
||||
Face_handle f=eit->first;
|
||||
Vertex_handle v1 = f->vertex(0);
|
||||
Vertex_handle v2 = f -> vertex(1);
|
||||
|
||||
//ERROR
|
||||
bool conflict = Base::collinear_between(v1->point(), v2->point(), p);
|
||||
//Orientation o=coplanar_orientation(v1->point(), v2->point(), p);
|
||||
//if(o ==RIGHT_TURN){
|
||||
if(conflict){
|
||||
loc = f;
|
||||
break;
|
||||
|
||||
} eit++;
|
||||
}while( eit!=edges_end());
|
||||
}*/
|
||||
|
||||
Vertex_handle v0 = loc->vertex(0);
|
||||
Vertex_handle v1 = loc->vertex(1);
|
||||
|
|
@ -722,7 +683,7 @@ insert_in_plane_triangulation(const Point &p, Locate_type lt, Face_handle loc){
|
|||
|
||||
delete_face(loc);
|
||||
|
||||
|
||||
update_ghost_faces(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
@ -756,9 +717,8 @@ typename Regular_triangulation_on_sphere_2<Gt,Tds>::Vertex_handle
|
|||
Regular_triangulation_on_sphere_2<Gt,Tds>::
|
||||
insert(const Point &p, Locate_type lt, Face_handle loc, int li) {
|
||||
|
||||
//!!!!!!!!!!!!TODO point is valide!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
Vertex_handle v;
|
||||
|
||||
switch (dimension()){
|
||||
case -2 :
|
||||
return insert_first(p);
|
||||
|
|
@ -770,22 +730,19 @@ insert(const Point &p, Locate_type lt, Face_handle loc, int li) {
|
|||
return insert_outside_affine_hull_regular(p);
|
||||
|
||||
|
||||
case 1:
|
||||
case 1:{
|
||||
if(test_dim_up(p)){
|
||||
Face_handle f=all_edges_begin()->first;
|
||||
Vertex_handle v1=f->vertex(0);
|
||||
Vertex_handle v2=f->vertex(1);
|
||||
Vertex_handle v3=f->neighbor(0)->vertex(1);
|
||||
Orientation orient=orientation(v1->point(),v2->point(),v3->point()) ;
|
||||
v = insert_outside_affine_hull_regular(p,orient==COLLINEAR);
|
||||
return v;
|
||||
return insert_outside_affine_hull_regular(p);
|
||||
}
|
||||
else {
|
||||
v= insert_in_plane_triangulation(p,lt,loc);
|
||||
return v;
|
||||
else
|
||||
return insert_in_plane_triangulation(p,lt,loc);
|
||||
}
|
||||
|
||||
case 2:
|
||||
case 2:{
|
||||
std::vector<Face_handle> faces;
|
||||
std::vector<Edge> edges;
|
||||
faces.reserve(32);
|
||||
|
|
@ -796,20 +753,21 @@ insert(const Point &p, Locate_type lt, Face_handle loc, int li) {
|
|||
v->set_point(p);
|
||||
delete_faces(faces.begin(), faces.end());
|
||||
|
||||
|
||||
//if( lt != FACE )
|
||||
if( lt != FACE )
|
||||
update_ghost_faces(v);
|
||||
|
||||
return v;
|
||||
}
|
||||
}
|
||||
CGAL_assertion(false);
|
||||
return v;
|
||||
}
|
||||
|
||||
template <class Gt, class Tds >
|
||||
typename Triangulation_on_sphere_2<Gt,Tds>::Vertex_handle
|
||||
Regular_triangulation_on_sphere_2<Gt,Tds>::
|
||||
insert_outside_affine_hull_regular(const Point& p,bool plane)
|
||||
insert_outside_affine_hull_regular(const Point& p)
|
||||
{
|
||||
|
||||
if(dimension()==0){
|
||||
Vertex_handle v = vertices_begin();
|
||||
Vertex_handle u=v->face()->neighbor(0)->vertex(0);
|
||||
|
|
@ -820,60 +778,31 @@ insert_outside_affine_hull_regular(const Point& p,bool plane)
|
|||
nv=Base::tds().insert_dim_up(v,false);
|
||||
else
|
||||
nv=Base::tds().insert_dim_up(v,true);
|
||||
|
||||
nv->set_point(p);
|
||||
|
||||
Face_handle f=all_edges_begin()->first;
|
||||
CGAL_triangulation_assertion( orientation(f->vertex(0)->point(), f->vertex(1)->point(),
|
||||
f->neighbor(0)->vertex(1)->point()) != RIGHT_TURN );
|
||||
|
||||
CGAL_triangulation_assertion( orientation(all_edges_begin()->first->vertex(0)->point(),
|
||||
all_edges_begin()->first->vertex(1)->point(),
|
||||
all_edges_begin()->first->neighbor(0)->vertex(1)->point())
|
||||
!= RIGHT_TURN );
|
||||
|
||||
//seting ghost edge if needed
|
||||
bool done=false;
|
||||
All_edges_iterator eit=all_edges_begin();
|
||||
do{
|
||||
Face_handle f=eit->first;
|
||||
Face_handle fn=f->neighbor(0);
|
||||
Point q=fn->vertex(1)->point();
|
||||
if(collinear_between(f->vertex(0)->point(),f->vertex(1)->point(),q)){
|
||||
f->ghost()=true;
|
||||
}
|
||||
else{
|
||||
f->ghost()=false;
|
||||
}
|
||||
++eit;
|
||||
}while( eit!=all_edges_end() && !done );
|
||||
|
||||
update_ghost_faces(nv);
|
||||
return nv;
|
||||
}
|
||||
|
||||
else{ //dimension=1
|
||||
else{ //dimension 1
|
||||
bool conform = false;
|
||||
Face_handle f = (all_edges_begin())->first;
|
||||
|
||||
if(plane){//points coplanar with geom_traits->sphere
|
||||
Vertex_handle v1 = f->vertex(0);
|
||||
Vertex_handle v2 = f->vertex(1);
|
||||
Orientation orient = orientation( f->vertex(0)->point(),f->vertex(1)->point(),p);
|
||||
//conform = ( orient == COUNTERCLOCKWISE);
|
||||
conform = (orient != CLOCKWISE);
|
||||
}
|
||||
|
||||
else{//three vertices non-coplanar with geom_traits->sphere
|
||||
Face_handle fn=f->neighbor(0);
|
||||
|
||||
const Point p0=f->vertex(0)->point();
|
||||
const Point p1=f->vertex(1)->point();
|
||||
const Point p2=fn->vertex(1)->point();
|
||||
|
||||
Orientation orient = orientation(p0, p1, p2);
|
||||
Orientation orient2 = power_test(p0, p1, p2, p);
|
||||
CGAL_triangulation_assertion(orient);
|
||||
CGAL_triangulation_assertion(orient!=NEGATIVE);
|
||||
|
||||
if(orient2==POSITIVE)
|
||||
conform =true;
|
||||
|
||||
}
|
||||
|
||||
//find smalest vertex
|
||||
Vertex_handle w=vertices_begin();
|
||||
All_vertices_iterator vi;
|
||||
|
|
@ -883,39 +812,25 @@ insert_outside_affine_hull_regular(const Point& p,bool plane)
|
|||
}
|
||||
|
||||
|
||||
|
||||
//Vertex_handle v = this->_tds.insert_dim_up( f->vertex(0), conform);
|
||||
Vertex_handle v = this->_tds.insert_dim_up( w, conform);
|
||||
v->set_point(p);
|
||||
|
||||
this->_ghost=all_faces_begin();
|
||||
|
||||
|
||||
//seting ghost faces if needed
|
||||
All_faces_iterator fit;
|
||||
for(fit =all_faces_begin(); fit !=all_faces_end(); fit++) {
|
||||
//if(orientation(fit)==NEGATIVE){
|
||||
if(orientation(fit)!=POSITIVE){
|
||||
fit->ghost()=true;
|
||||
this->_ghost=fit;
|
||||
}
|
||||
}
|
||||
update_ghost_faces(v, true);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template < class Gt, class Tds >
|
||||
bool
|
||||
Regular_triangulation_on_sphere_2<Gt,Tds>::
|
||||
update_ghost_faces(Vertex_handle v)
|
||||
update_ghost_faces(Vertex_handle v, bool first)
|
||||
{
|
||||
bool neg_found=false;
|
||||
if(dimension()==1){
|
||||
All_edges_iterator eit=all_edges_begin();
|
||||
do{
|
||||
for (; eit!=all_edges_end(); eit++){
|
||||
Face_handle f=eit->first;
|
||||
Face_handle fn=f->neighbor(0);
|
||||
Point q=fn->vertex(1)->point();
|
||||
|
|
@ -925,34 +840,41 @@ update_ghost_faces(Vertex_handle v)
|
|||
}
|
||||
else
|
||||
f->ghost()=false;
|
||||
++eit;
|
||||
}while( eit!=all_edges_end());
|
||||
}
|
||||
}
|
||||
else{//dimension==2
|
||||
if (first){ //first time dimension 2
|
||||
All_faces_iterator fi = all_faces_begin();
|
||||
for(;fi!=all_faces_end();fi++){
|
||||
if(orientation(fi)!=POSITIVE){
|
||||
fi->ghost()=true;
|
||||
neg_found=true;
|
||||
this->_ghost=fi;
|
||||
}
|
||||
else
|
||||
fi->ghost()=false;
|
||||
}
|
||||
}
|
||||
|
||||
else { //not first
|
||||
Face_circulator fc=incident_faces(v,v->face());
|
||||
Face_circulator done(fc);
|
||||
|
||||
do{
|
||||
//if(orientation(fc)==NEGATIVE){
|
||||
if(orientation(fc)!=POSITIVE){
|
||||
fc->ghost()=true;
|
||||
neg_found=true;
|
||||
this->_ghost=fc;
|
||||
}
|
||||
else{
|
||||
else
|
||||
fc->ghost()=false;
|
||||
}
|
||||
}while(++fc!=done);
|
||||
}
|
||||
|
||||
}
|
||||
return neg_found;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------REMOVAL----------------------------------------------------//
|
||||
template < class Gt, class Tds >
|
||||
void
|
||||
|
|
|
|||
|
|
@ -356,6 +356,11 @@ Orientation coplanar_orientation(const Point& p, const Point& q,const Point& r,
|
|||
return _tds.mirror_index(v,i);
|
||||
}
|
||||
|
||||
Edge mirror_edge(const Edge e) const
|
||||
{
|
||||
return _tds.mirror_edge(e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------TEMPLATE MEMBERS--------------------------------------*/
|
||||
|
|
@ -561,15 +566,15 @@ locate_edge(const Point& p, Locate_type& lt, int& li, bool plane)const
|
|||
f=eit->first;
|
||||
Vertex_handle v1 = f->vertex(0);
|
||||
Vertex_handle v2 = f -> vertex(1);
|
||||
if(!f->is_ghost())
|
||||
//if(!f->is_ghost())
|
||||
if(orientation(v1->point(), v2->point(), p)==RIGHT_TURN){
|
||||
lt=EDGE;
|
||||
li=2;
|
||||
test_distance( p, (*eit).first, lt, li);
|
||||
return (*eit).first;
|
||||
}
|
||||
if(f->is_ghost())
|
||||
loc = f;
|
||||
//if(f->is_ghost())
|
||||
//loc = f;
|
||||
}//end for
|
||||
|
||||
test_distance(p, loc, lt, li);
|
||||
|
|
@ -591,7 +596,6 @@ switch (dimension()){
|
|||
|
||||
case 0:
|
||||
case 1:{
|
||||
show_face(f);
|
||||
Vertex_handle v0 = f->vertex(0);
|
||||
Vertex_handle v1= f->neighbor(0)->vertex(0);
|
||||
if (is_too_close(v0->point(),p)||is_too_close(v1->point(),p) )
|
||||
|
|
|
|||
|
|
@ -88,17 +88,6 @@ bool are_equal(RTOS triA, RTOS triB){
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
|
|
@ -131,14 +120,9 @@ int main(int argc, char* argv[])
|
|||
points.resize(5);
|
||||
|
||||
Vertex_handle v1 = rtos.insert(p1);
|
||||
rtos.is_valid();
|
||||
Vertex_handle v4 = rtos.insert(p4);
|
||||
rtos.is_valid();
|
||||
Vertex_handle v4 = rtos.insert(p4);
|
||||
Vertex_handle v2 = rtos.insert(p2);
|
||||
rtos.show_all();
|
||||
|
||||
Vertex_handle v5 = rtos.insert(p5);
|
||||
rtos.show_all();
|
||||
Vertex_handle v5 = rtos.insert(p5);
|
||||
Vertex_handle v3 = rtos.insert(p3);
|
||||
rtos.is_valid();
|
||||
|
||||
|
|
@ -156,7 +140,7 @@ std::random_shuffle(points.begin(), points.end());
|
|||
std::cout<<points.at(i)<<std::endl;
|
||||
rtos2.insert(points.at(i));
|
||||
}
|
||||
|
||||
rtos2.is_valid();
|
||||
are_equal(rtos, rtos2);
|
||||
//rtos.remove(v1);
|
||||
//rtos.remove(v2);
|
||||
|
|
@ -188,19 +172,23 @@ std::random_shuffle(points.begin(), points.end());
|
|||
|
||||
Point_3 p27 = Point_3(radius, 0 ,0);
|
||||
points2.push_back(p27);
|
||||
Vertex_handle v0 = rtos.insert(p0);
|
||||
|
||||
// Vertex_handle v0 = rtos.insert(p0);
|
||||
|
||||
|
||||
Vertex_handle v21 = rtos.insert(p21);
|
||||
Vertex_handle v22 = rtos.insert(p22);
|
||||
Vertex_handle v23 = rtos.insert(p23);
|
||||
rtos.show_vertex(v23);
|
||||
rtos.show_all();
|
||||
Vertex_handle v26 = rtos.insert(p26);
|
||||
|
||||
|
||||
|
||||
Vertex_handle v24 = rtos.insert(p24);
|
||||
Vertex_handle v25 = rtos.insert(p25);
|
||||
Vertex_handle v26 = rtos.insert(p26);
|
||||
rtos.is_valid();
|
||||
//Vertex_handle v = rtos.insert(p26);
|
||||
Vertex_handle v0 = rtos.insert(p0);
|
||||
//Vertex_handle v27 = rtos.insert(p27);
|
||||
rtos.is_valid();
|
||||
|
||||
|
|
|
|||
|
|
@ -33,18 +33,6 @@ typedef RTOS::Edge Edge;
|
|||
|
||||
|
||||
|
||||
bool is_ok(K::Point_3 p, std::vector<K::Point_3> po, double minDist2, int ind)
|
||||
{
|
||||
bool ok= true;
|
||||
for(int j= 0; j<ind; j++){
|
||||
|
||||
if( squared_distance(p, po.at(j))<=minDist2 ){
|
||||
ok = false;
|
||||
}
|
||||
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool has_face(Face_handle fh, Vertex_handle v0, Vertex_handle v1, Vertex_handle v2){
|
||||
|
|
@ -52,8 +40,6 @@ bool has_face(Face_handle fh, Vertex_handle v0, Vertex_handle v1, Vertex_handle
|
|||
|
||||
|
||||
for(int i=0;i<=2; i++){
|
||||
std::cout<<v0->point()<<std::endl;
|
||||
std::cout<<fh->vertex(i)->point()<<std::endl;
|
||||
test1 = (v0->point()==fh->vertex(i)->point());
|
||||
if(test1)
|
||||
break;
|
||||
|
|
@ -104,7 +90,7 @@ bool are_equal(RTOS triA, RTOS triB){
|
|||
int main(){
|
||||
int nu_of_pts;
|
||||
double radius;
|
||||
nu_of_pts =100000;
|
||||
nu_of_pts =10000;
|
||||
radius=6000000;
|
||||
//radius = 1;
|
||||
//double minDist = radius*2e-25;
|
||||
|
|
@ -165,18 +151,15 @@ int main(){
|
|||
|
||||
t.start();
|
||||
//====insert new points============
|
||||
rtos.insert(points.begin(),points.end());
|
||||
|
||||
|
||||
for (int count=0; count<nu_of_pts; count++) {
|
||||
//std::cout<< "================= point number "<< count+1 <<" =================="<<std::endl;
|
||||
K::Point_3 p = points.at(count);
|
||||
Vertex_handle v = rtos.insert(p);
|
||||
vertices.push_back(v);
|
||||
|
||||
}
|
||||
//rtos.is_valid();
|
||||
t.stop();
|
||||
std::cout<<"running time"<< t.time()<<std::endl;
|
||||
|
||||
rtos.is_valid();
|
||||
|
||||
/*
|
||||
|
||||
//*****second triangulation*******
|
||||
std::random_shuffle(points.begin(), points.end());
|
||||
|
|
|
|||
Loading…
Reference in New Issue