Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Arrangement to file not working

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Arrangement to file not working


Chronological Thread 
  • From: Efi Fogel <>
  • To:
  • Subject: Re: [cgal-discuss] Arrangement to file not working
  • Date: Sat, 5 Dec 2015 11:39:30 +0200
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:pN1neRC7fkkxtFz1ShItUyQJP3N1i/DPJgcQr6AfoPdwSP7zpcbcNUDSrc9gkEXOFd2CrakU1ayO6+jJYi8p39WoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kO74TNaIBjjLw09fr2zQd6MyZzvn8mJuLTtICxwzAKnZr1zKBjk5S7wjeIxxbVYF6Aq1xHSqWFJcekFjUlhJFaUggqurpzopM0roGxtvek8/ZtATbniZPZ/CqdJCSwvdWEz/szi8xfZChCe42MVFWQQnB0PCAfM6FT2X4z6rzDh5dZ6jSKVNMmzQbEvUim59I9qTgXpgWEJLW0X6mbS3+F+jep1px2so1QrzoDVboaaOf5WcabUfNdcTm1ECJUCHxddC5+xOtNcR9EKOvxV+tHw

Hi Mateus,

You have encountered a bug (or perhaps two) in the exporter and importer of polycurves.
The relevant code resides in include/CGAL/Arr_geometry_traits/Polycurve_2.h
Attached is a patch, so that you can fix the code immediately.
The next release of CGAL will include the fix.

Thank you,
Efi

   ____  _        ____             _
  /_____/_) o    /__________  __  //
 (____ (   (    (    (_/ (_/-(-'_(/
                         _/



On Fri, Dec 4, 2015 at 2:37 PM, Mateus Bellomo <> wrote:
I'm not sure about that: the kernel is the CGAL::Cartesian<Number_type> ?

I'm sending the .cpp and CMakeLists attached.

Thank you

2015-12-04 5:33 GMT-02:00 Sebastien Loriot (GeometryFactory) <>:
What kernel are you using?
Please provide a complete example we can compile and run.

Sebastien.


On 12/04/2015 03:40 AM, Mateus Bellomo wrote:
Hello

I'm trying to use the I/O functions to write and read an arrangement to
a file. The problem is that when I try to read the arrangement from the
file the program get stucked. I'm using a very simple program to test
and I already checked the file generated by write and it is not empty.
My .cpp code:

   Arrangement_2 arr1,arr2;
   Point_2 p1 (1 , 3 ) , p2 (3 , 5 ) ;
   XSegment_2 s1 (p1 , p2 ) ;

   Arrangement_2::Halfedge_handle e1 = arr1.insert_in_face_interior( s1
,arr1.unbounded_face( ) ) ;
   Vertex_handle v1 = e1->source();

   ofstream out_file("arr_ex_io.dat");
   out_file << arr1;
   out_file.close();


   ifstream in_file("arr_ex_io.dat");
   in_file >> arr2;
   in_file.close();


Anyone had the same problem? Thanks in advance


--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss




diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Polycurve_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Polycurve_2.h
index fb4cf5f..28774dd 100644
--- a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Polycurve_2.h
+++ b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Polycurve_2.h
@@ -441,22 +441,16 @@ template <typename SubcurveType_2, typename PointType_2>
 std::ostream& operator<<(std::ostream & os,
                          const Polycurve_2<SubcurveType_2, PointType_2>& cv)
 {
-  typedef SubcurveType_2                          Subcurve_type_2;
-  typedef PointType_2                            Point_type_2;
+  typedef SubcurveType_2                                Subcurve_type_2;
+  typedef PointType_2                                   Point_type_2;
+  typedef Polycurve_2<Subcurve_type_2, Point_type_2>    Curve_2;
 
-  typedef Polycurve_2<Subcurve_type_2, Point_type_2> Curve_2;
+  // Export the number of subcurves.
+  os << cv.number_of_subcurves();
 
+  // Export the subcurves.
   typename Curve_2::Subcurve_const_iterator iter = cv.begin_subcurves();
-  while (iter != cv.end_subcurves()) {
-    if (iter == cv.begin_subcurves()) {
-      os << " " << *iter;
-      ++iter;
-    }
-    else {
-      os << " <-> " << *iter;
-      ++iter;
-    }
-  }
+  while (iter != cv.end_subcurves()) os << " " << *iter++;
   return (os);
 }
 
@@ -467,30 +461,18 @@ std::istream& operator>>(std::istream& is,
 {
   typedef SubcurveType_2                                Subcurve_type_2;
   typedef PointType_2                                   Point_type_2;
-
   typedef Polycurve_2<Subcurve_type_2, Point_type_2>    Curve_2;
 
-  // Read the number of input points.
-  unsigned int n_pts;
-  is >> n_pts;
-  CGAL_precondition_msg(n_pts > 1, "Input must contain at least two points");
-
-  // Read m_num_pts points to a list.
-  Point_type_2 p;
-  std::list<Point_type_2> pts;
-  for (unsigned int i = 0; i < n_pts; ++i) {
-    is >> p;
-    pts.push_back(p);
-  }
+  // Import the number of curves.
+  size_t num;
+  is >> num;
 
+  // Import the subcurves.
   std::list<Subcurve_type_2> subcurves;
-  typename std::list<Point_type_2>::iterator curr = pts.begin();
-  typename std::list<Point_type_2>::iterator next = pts.begin();
-  ++next;
-  while (next != pts.end()) {
-    subcurves.push_back(Subcurve_type_2(*curr, *next));
-    ++curr;
-    ++next;
+  for (size_t i = 0; i < num; ++i) {
+    Subcurve_type_2 subcurve;
+    is >> subcurve;
+    subcurves.push_back(subcurve);
   }
 
   // Create the polycurve curve.



Archive powered by MHonArc 2.6.18.

Top of Page