Пример #1
0
void		TriFanBuilder::AddTriToFanPool(CDT::Face_handle inFace)
{
//	if (inFace->info().flag)
//		printf("WARNING: flag is NOT set up right.\n");
	inFace->info().flag = true;
	vertices.insert(inFace->vertex(0));
	vertices.insert(inFace->vertex(1));
	vertices.insert(inFace->vertex(2));
//	faces.insert(inFace);
}
Пример #2
0
void		TriFanBuilder::GetRemainingTriangles(list<CDT::Vertex_handle>& out_handles)
{
	out_handles.clear();
	CDT::Face_handle	f;
	while(1)
	{
		f = GetNextRemainingTriangle();
		if(f == NULL)
			break;
		for (int v = 2; v >= 0; --v)
		{
			out_handles.push_back(f->vertex(v));
		}
	}
}
void constrained_delaunay_triangulation(LCC_3 &lcc, Dart_handle d1)
{
  CGAL::set_ascii_mode(std::cout);
  std::cout<<"Vertices: ";
  for (LCC_3::Vertex_attribute_const_range::iterator
         v=lcc.vertex_attributes().begin(),
         vend=lcc.vertex_attributes().end(); v!=vend; ++v)
    std::cout << lcc.point_of_vertex_attribute(v) << "; ";
  std::cout<<std::endl;
 
  LCC_3::Vector normal = CGAL::compute_normal_of_cell_2(lcc,d1);
  P_traits cdt_traits(normal);
  CDT cdt(cdt_traits); 
    
  //inserting the constraints edge by edge
  LCC_3::Dart_of_orbit_range<1>::iterator
    it(lcc.darts_of_orbit<1>(d1).begin());

  CDT::Vertex_handle previous=LCC_3::null_handle, first=LCC_3::null_handle,
    vh=LCC_3::null_handle;

   for (LCC_3::Dart_of_orbit_range<1>::iterator
          itend(lcc.darts_of_orbit<1>(d1).end()); it!=itend; ++it)
   {     
     vh = cdt.insert(lcc.point(it));
     vh->info()=it;
     if( first==NULL ){
       first=vh;
     }
     if( previous!=NULL){
       CGAL_assertion( previous !=vh );
       cdt.insert_constraint(previous,vh);
     }

     previous=vh;
   }
   cdt.insert_constraint(previous,first);
   CGAL_assertion(cdt.is_valid());
   
   // sets mark is_external
   for( CDT::All_faces_iterator fit = cdt.all_faces_begin(),
          fitend = cdt.all_faces_end(); fit != fitend; ++fit)
   {
     fit->info().is_external = false;
     fit->info().exist_edge[0]=false;
     fit->info().exist_edge[1]=false;
     fit->info().exist_edge[2]=false;
   }
	
   std::queue<CDT::Face_handle> face_queue;
      
   face_queue.push(cdt.infinite_vertex()->face());
   while(! face_queue.empty() )
   {
     CDT::Face_handle fh = face_queue.front();
     face_queue.pop();
     if(!fh->info().is_external)
     {
       fh->info().is_external = true;
       for(int i = 0; i <3; ++i)
       {
         if(!cdt.is_constrained(std::make_pair(fh, i)))
         {
           face_queue.push(fh->neighbor(i));
         }
       }
     }
   }

   for( CDT::Finite_edges_iterator eit = cdt.finite_edges_begin(),
          eitend = cdt.finite_edges_end(); eit != eitend; ++eit)
   {
     CDT::Face_handle fh = eit->first;
     int index = eit->second;
     CDT::Face_handle opposite_fh = fh->neighbor(index);
     if(cdt.is_constrained(std::make_pair(fh, index)))
     {
       fh->info().exist_edge[index]=true;
       opposite_fh->info().exist_edge[cdt.mirror_index(fh,index)]=true;
       
       if ( !fh->info().is_external && number_of_existing_edge(fh)==2 )
         face_queue.push(fh);
       if ( !opposite_fh->info().is_external &&
            number_of_existing_edge(opposite_fh)==2 )
         face_queue.push(opposite_fh);
     }
   }
   
   while( !face_queue.empty() )
   {
     CDT::Face_handle fh = face_queue.front();
     face_queue.pop();
     CGAL_assertion( number_of_existing_edge(fh)>=2 ); // i.e. ==2 or ==3
     CGAL_assertion( !fh->info().is_external );
     
     if (number_of_existing_edge(fh)==2)
     {
       int index = get_free_edge(fh);
       CDT::Face_handle opposite_fh = fh->neighbor(index);

       CGAL_assertion( !fh->info().exist_edge[index] );
       CGAL_assertion( !opposite_fh->info().
                       exist_edge[cdt.mirror_index(fh,index)] );
       
       const CDT::Vertex_handle va = fh->vertex(cdt. cw(index));
       const CDT::Vertex_handle vb = fh->vertex(cdt.ccw(index));
       
       Dart_handle ndart=
         CGAL::insert_cell_1_in_cell_2(lcc,va->info(),vb->info());         
       va->info()=lcc.beta<2>(ndart);

       fh->info().exist_edge[index]=true;
       opposite_fh->info().exist_edge[cdt.mirror_index(fh,index)]=true;
       
       if ( !opposite_fh->info().is_external &&
            number_of_existing_edge(opposite_fh)==2 )
         face_queue.push(opposite_fh);
     }
   }   
}