Beispiel #1
0
int main()
{
  CMap_3 cm;

  // Create one combinatorial hexahedron.
  Dart_handle dh1 = CGAL::make_combinatorial_hexahedron(cm);

  // Add two edges along two opposite facets.
  CGAL_assertion( CGAL::is_insertable_cell_1_in_cell_2
                        (cm,cm.beta(dh1,1),cm.beta(dh1,0)) );

  CGAL::insert_cell_1_in_cell_2(cm,cm.beta(dh1,1),cm.beta(dh1,0));
  CGAL_assertion( cm.is_valid() );

  Dart_handle dh2=cm.beta(dh1,2,1,1,2);

  CGAL_assertion( CGAL::is_insertable_cell_1_in_cell_2
                        (cm,dh2,cm.beta(dh2,1,1)) );
  
  CGAL::insert_cell_1_in_cell_2(cm,dh2,cm.beta(dh2,1,1));
  CGAL_assertion( cm.is_valid() );

  // Insert a facet along these two new edges plus two initial edges
  // of the hexahedron.
  std::vector<Dart_handle> path;
  path.push_back(cm.beta(dh1,1));
  path.push_back(cm.beta(dh1,0,2,1));
  path.push_back(cm.beta(dh2,0));
  path.push_back(cm.beta(dh2,2,1));
  
  CGAL_assertion( (CGAL::is_insertable_cell_2_in_cell_3
		   (cm,path.begin(),path.end())) );

  Dart_handle dh3=CGAL::insert_cell_2_in_cell_3(cm,path.begin(),path.end());
  CGAL_assertion( cm.is_valid() );
  
  // Display the combinatorial map characteristics.
  cm.display_characteristics(std::cout) << ", valid=" << 
    cm.is_valid() << std::endl;

  // We use the removal operations to get back to the initial hexahedron.
  CGAL_assertion( (CGAL::is_removable<CMap_3, 2>(cm,dh3)) );
  CGAL::remove_cell<CMap_3,2>(cm,dh3);
  CGAL_assertion( cm.is_valid() );

  CGAL_assertion( (CGAL::is_removable<CMap_3, 1>(cm,cm.beta(dh1,1))) );
  CGAL::remove_cell<CMap_3,1>(cm,cm.beta(dh1,1));
  CGAL_assertion( cm.is_valid() );
  
  CGAL_assertion( (CGAL::is_removable<CMap_3, 1>(cm,cm.beta(dh2,0))) );
  CGAL::remove_cell<CMap_3,1>(cm,cm.beta(dh2,0));
  CGAL_assertion( cm.is_valid() );
  
  // Display the combinatorial map characteristics.
  cm.display_characteristics(std::cout) << ", valid=" 
					<< cm.is_valid() << std::endl;

  return EXIT_SUCCESS;
}
Beispiel #2
0
int main()
{
  CMap_3 cmap;

  // Create two tetrahedra.
  Dart_handle d1 = cmap.make_combinatorial_tetrahedron();
  Dart_handle d2 = cmap.make_combinatorial_tetrahedron();

  // Display the vertices of each volume by iterating on darts.
  std::cout<<"********Volumes********"<<std::endl;
  std::for_each(cmap.one_dart_per_cell<3>().begin(),
                cmap.one_dart_per_cell<3>().end(),
                Display_vertices_of_cell<CMap_3,3>(cmap));

  // 3-Sew the 2 tetrahedra along one facet
  cmap.sew<3>(d1, d2);

  // Display the vertices of each face by iterating on darts.
  std::cout<<"********Faces********"<<std::endl;
  std::for_each(cmap.one_dart_per_cell<2>().begin(),
                cmap.one_dart_per_cell<2>().end(),
                Display_vertices_of_cell<CMap_3,2>(cmap));

    // We display the map characteristics.
  std::cout<<"CMap characteristics: ";
  cmap.display_characteristics(std::cout) << ", valid=" << cmap.is_valid()
                                          << std::endl << std::endl;

  std::vector<CMap_3::Dart*> toremove;

  // Copy in vector toremove one dart per face
  std::copy(boost::transform_iterator<Take_adress<CMap_3::Dart>,
                                      CMap_3::One_dart_per_cell_range<2>::iterator>
            (cmap.one_dart_per_cell<2>().begin(),
             Take_adress<CMap_3::Dart>()),
            boost::transform_iterator<Take_adress<CMap_3::Dart>,
                                      CMap_3::One_dart_per_cell_range<2>::iterator>
            (cmap.one_dart_per_cell<2>().end(),
             Take_adress<CMap_3::Dart>()),
            back_inserter(toremove));

  // Remove each face sequentially.
  std::for_each(toremove.begin(), toremove.end(), Remove_face<CMap_3>(cmap));

  return EXIT_SUCCESS;
}