Guest User

polytope_distance_d.cpp

a guest
May 8th, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.95 KB | None | 0 0
  1. /*
  2.  
  3. Use the following input file for the program
  4. $ cat input | ./test
  5.  
  6. -731.881 -1269.91 19.4598
  7. -400.371 -1269.91 28.8654
  8. -418.045 -1040.68 21.817
  9. -502.333 -786.248 12.1586
  10. -669.351 -897.239 10.59
  11. -731.881 -938.793 10.0027
  12. -731.881 -1269.91 41.8424
  13. -731.881 -809.848 26.3075
  14. -440.816 -745.367 12.7363
  15. -731.881 -928.878 11.2564
  16. -377.473 -939.518 1.55859
  17.  
  18. */
  19.  
  20. #include <iostream>
  21. #include <cassert>
  22. #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
  23. #include <CGAL/Polytope_distance_d.h>
  24. #include <CGAL/Polytope_distance_d_traits_3.h>
  25.  
  26. typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
  27. typedef Kernel::Point_3                                   Point;
  28. typedef CGAL::Polytope_distance_d_traits_3<Kernel>        Traits;
  29. typedef CGAL::Polytope_distance_d<Traits>                 Polytope_distance;
  30.  
  31.  
  32. int main()
  33. {
  34.   Point P[11];
  35.   Point *Q = P+10;
  36.  
  37.   for(int i = 0; i < 11; ++i) {
  38.     std::cin >> P[i];
  39.     std::cout << P[i] << std::endl;
  40.   }
  41.  
  42.   Polytope_distance pd(P, P+10, Q, Q+1); // Doesn't work
  43.   //Polytope_distance pd(Q, Q+1, P, P+10); // Works
  44.   assert (pd.is_valid());
  45.  
  46.   // get squared distance
  47.   std::cout << "Squared distance: " <<
  48.     CGAL::to_double (pd.squared_distance_numerator()) /
  49.     CGAL::to_double (pd.squared_distance_denominator()) << std::endl;
  50.  
  51.   // get points that realize the distance
  52.   Polytope_distance::Coordinate_iterator  coord_it;
  53.  
  54.   std::cout << "p:"; // homogeneous point from first polyhedron
  55.   for (coord_it = pd.realizing_point_p_coordinates_begin();
  56.        coord_it != pd.realizing_point_p_coordinates_end();
  57.        ++coord_it)
  58.     std::cout << " " << *coord_it;
  59.   std::cout << std::endl;
  60.  
  61.   std::cout << "q:"; // homogeneous point from second polyhedron
  62.   for (coord_it = pd.realizing_point_q_coordinates_begin();
  63.        coord_it != pd.realizing_point_q_coordinates_end();
  64.        ++coord_it)
  65.     std::cout << " " << *coord_it;
  66.   std::cout << std::endl;
  67.  
  68.   return 0;
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment