int main( int argc, char** argv )
{
  if (argc<2 || argc>3)
  {
    std::cout<<"Usage: simplification_Linear_cell_complex inofffile [outofffile]"<<std::endl;
    return EXIT_FAILURE;
  }

  LCC lcc;
  CGAL::read_off(argv[1], lcc);

  lcc.display_characteristics(std::cout)<<", is_valid="<<CGAL::is_valid(lcc)<<std::endl;

  // This is a stop predicate (defines when the algorithm terminates).
  // In this example, the simplification stops when the number of undirected edges
  // left in the surface mesh drops below the specified number (1000)
  SMS::Count_stop_predicate<LCC> stop(1000);
  // This the actual call to the simplification algorithm.
  // The surface mesh and stop conditions are mandatory arguments.
  // The index maps are needed because the vertices and edges
  // of this surface mesh lack an "id()" field.
  int r = SMS::edge_collapse
    (lcc
     ,stop
     ,CGAL::parameters::halfedge_index_map(get(CGAL::halfedge_index, lcc))
          .vertex_index_map(get(boost::vertex_index, lcc))
          .get_cost(SMS::Edge_length_cost<LCC>())
          .get_placement(SMS::Midpoint_placement<LCC>())
     );

  std::cout << "\nFinished...\n" << r << " edges removed.\n"
            << (lcc.number_of_darts()/2) << " final edges.\n" ;

  lcc.display_characteristics(std::cout)<<", is_valid="<<CGAL::is_valid(lcc)<<std::endl;

  CGAL::write_off((argc > 2 ? argv[2] : "out.off"), lcc);
  return EXIT_SUCCESS;
}
void run_test()
{
  typedef typename LCC::Point Point;
  typedef typename LCC::Dart_handle Dart_handle;
  
  LCC lcc;
  
  Dart_handle dh1 = lcc.
    make_hexahedron(Point(0,0,0),Point(1,0,0),
                    Point(1,2,0),Point(0,2,0),
                    Point(0,3,4),Point(0,0,4),
                    Point(6,0,4),Point(6,3,4));
  Dart_handle dh2 = lcc.
    make_hexahedron(Point(0,-5,0),Point(2,-5,0),
                    Point(2,-2,0),Point(0,-2,0),
                    Point(1,-1,5),Point(1,-2,5),
                    Point(5,-2,5),Point(5,-2,5));
  Dart_handle dh3 = lcc.
    make_hexahedron(Point(1,0,5),Point(0,0,6),
                    Point(0,2,5),Point(1,2,6),
                    Point(1,3,8),Point(0,0,8),
                    Point(5,0,9),Point(7,3,9));
  
  lcc.template sew<3>(dh1,lcc.other_orientation
                      (lcc.template opposite<2>
                       (lcc.next(lcc.next(lcc.template opposite<2>(dh2))))));
  lcc.template sew<3>(lcc.template opposite<2>(lcc.next(dh1)),
                      lcc.other_orientation(lcc.template opposite<2>(lcc.previous(dh3))));

  lcc.insert_cell_1_in_cell_2(lcc.next(dh1),
                              Alpha1<LCC>::run(lcc, lcc.previous(dh1)));
  dh2=lcc.template opposite<2>(lcc.next(lcc.next
                                        (lcc.template opposite<2>(dh1))));
  lcc.insert_cell_1_in_cell_2(dh2, Alpha1<LCC>::run
                              (lcc, lcc.next(lcc.next(dh2))));

  std::vector<Dart_handle> path;
  path.push_back(lcc.next(dh1));
  path.push_back(lcc.next(lcc.template opposite<2>(lcc.previous(dh1))));
  path.push_back(lcc.previous(dh2));
  path.push_back(lcc.next(lcc.template opposite<2>(dh2)));
  lcc.insert_cell_2_in_cell_3(path.begin(),path.end());

  lcc.display_characteristics(std::cout) << ", valid=" 
                                         << lcc.is_valid() << std::endl;  
}
Ejemplo n.º 3
0
int main()
{
  LCC lcc;
  Dart_handle dh1=
    lcc.make_hexahedron(Point(0,0,0), Point(5,0,0),
                        Point(5,5,0), Point(0,5,0),
                        Point(0,5,4), Point(0,0,4),
                        Point(5,0,4), Point(5,5,4));
  Dart_handle dh2=
    lcc.make_hexahedron(Point(5,0,0), Point(10,0,0),
                        Point(10,5,0), Point(5,5,0),
                        Point(5,5,4), Point(5,0,4),
                        Point(10,0,4), Point(10,5,4));

  lcc.sew<3>(lcc.beta(dh1, 1, 1, 2), lcc.beta(dh2, 2));
  
  lcc.display_characteristics(std::cout)<<", valid=" 
                                        <<lcc.is_valid()<<std::endl;
  CGAL::draw(lcc);

  return EXIT_SUCCESS;
}