Subject: CGAL users discussion list
List archive
Re: [cgal-discuss] Constraints not recreated after writing / reading to / from file
Chronological Thread
- From: Andreas Fabri <>
- To:
- Subject: Re: [cgal-discuss] Constraints not recreated after writing / reading to / from file
- Date: Tue, 23 Apr 2019 10:44:57 +0200
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=None ; spf=None
- Ironport-phdr: 9a23:OMEuyBT9OluCB/9WSwIkBvxbhNpsv+yvbD5Q0YIujvd0So/mwa6ybByN2/xhgRfzUJnB7Loc0qyK6vmmBTxLucrJ8ChbNsAVD1ld0YRetjdjKfbNMVf8Iv/uYn5yN+V5f3ghwUuGN1NIEt31fVzYry76xzcTHhLiKVg9fbytScbdgMutyu+95YDYbRlWizqhe7NyKwi9oRnMusUMjoZuN7s9xgHGr3ZLdOha2WxlLk+Xkxrg+8u85pFu/zlMt/4768JMTaD2dLkkQLJFCzgrL3o779DxuxnZSguP6HocUmEInRdNHgPI8hL0UIrvvyXjruZy1zWUMsPwTbAvRDSt9LxrRwPyiCcGLDE27mfagdFtga1BoRKhoxt/w5PIYIyQKfFzcL/Rcc8cSGFcWMtaSi5PDZ6mb4YXEuQPI+hYoYn+qVUAoxSxCgujC//0xzBSmnP7x7c33/gvHAzE2gErAtIAsG7TrNXwLKofTea1w7TSzTrddfxWwir25ojSfR86u/GMXK97fM3LxkkpCgzFlEufppb+Pz+P2OQCqXOU7/BhVe+0hG4otQZxoj2xyccwkInIhowVxUrY+iVlx4Y1P925RFRnbt6jFZtdrieXPJZ4TMMlRmFnoic6yrsetJ69ZicF048oxxrBZPCdb4eI5RfjWeCMKjl7nHJoYL2yiheo/US91uHxVtO43VdXoiZfj9XBuXQA2wTX58SbUPdw/Uas1SyR2wzP9O1IO104mKnVJpMn37U+jIAcsV7ZES/zgEj2jLGZdkEj+uWw6enreLDmppiBO4J2iAzyKKEulda+AeQ8KwQOWHWb+fim2L3k4035QK9GjvsonanFqJzaJMIbqbClAwJN3Ysu6gyzAyq63NkYh3UKLU9JdAiag4XmP1zCOPX4Au2+g1Sonjdr3ffGPrj5D5rXKHjMja3hcqhn5E5H0gYzw8pQ6IlOCrEAO//zVVH+tNvdDhAnLwy02ebmCNtn2YwCRWKPBbWZMaPIvVCU4eIvJvGAZJUJtzblN/gl+/nugGclll8SZ6ap2YIbZ225HvR9P0qZfGHsgswaHGcRvgs+SfTqh0eYXT5SYXayRaM86SshBIKoF4eQDryq1beO1SP+EpxNbX1dEXiNF23pfsOKQaQiciWXd+ZnniYJXKPpZYYrzxDm4Ab8x6BqJ/GS9CQSr5PL29Vy4uDPjwA8/DdoCN6MlWqKSjcnzSszWzYq0fUn8gRGwVCZ3P0g2qEKJZlo//pMFzwCG9vcwuh9UY6gBUTEeY7WFxCjS9SiRDYsUpQ23d9IZUthSY370kLzmhGyCrpQrISlQYQu+/iFjXf8IMNw12zX2qAqk148U41EMmj03vcupTiWPJbAlgCir4jvcK0d2CDX82LZlDiBsUZdXRJqQKvMVmwYfFqQptP8tBvP
Hello, You use undocumented functions. You should use operator<<() and operator>>() instead. Note that for Constrained_triangulation_plus_2 reading from a
file does Best, Andreas
On 4/22/2019 4:01 PM, malcolm wrote:
Hi, I am using the file_output and file_input methods to write the and read the triangulation data from a file. After the triangulation is read from the file, I see the vertices are recreated but the constraints are not. Here's my code: #include <CGAL\Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Constrained_Delaunay_triangulation_2.h> #include <CGAL/Triangulation_vertex_base_with_info_2.h> #include <fstream> typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Exact_predicates_tag Itag; typedef CGAL::Triangulation_vertex_base_2<Kernel> Vb; typedef CGAL::Constrained_triangulation_face_base_2<Kernel> Fb; typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds; typedef CGAL::Constrained_Delaunay_triangulation_2<Kernel, Tds, Itag> Delaunay; typedef Kernel::Point_2 CGAL_Point; int main() { Delaunay T; auto v1 = T.insert(CGAL_Point(10, 13)); auto v2 = T.insert(CGAL_Point(5, 43)); auto v3 = T.insert(CGAL_Point(24, 3)); T.insert_constraint(v1, v2); T.insert_constraint(v2, v3); // write triangulation data to file const char* filename = "Data.txt"; std::filebuf fb; fb.open(filename, std::ios::out); std::ostream oFile(&fb); T.file_output(oFile); fb.close(); // clear triangulation T.clear(); //read triangulation data from the earlier file fb.open(filename, std::ios::in); std::istream iFile(&fb); T.file_input(iFile); fb.close(); // print the vertex coordinates, this works fine for (auto itr = T.finite_vertices_begin(); itr != T.finite_vertices_end(); itr++) { printf("\nPoint: %f, %f", itr->point().x(), itr->point().y()); } // the loop below is never entered for (auto itr = T.constrained_edges_begin(); itr != T.constrained_edges_end(); ++itr) { auto face = itr->first; auto sec = itr->second; auto v1 = face->vertex(face->ccw(sec)); auto v2 = face->vertex(face->cw(sec)); printf("\nConstraint point1: %f, %f", v1->point().x(), v1->point().y()); printf("\nConstraint point2: %f, %f", v2->point().x(), v2->point().y()); } return 0; } I have also checked the contents of the file. It reads: 4 4 2 10 13 5 43 24 3 0 2 3 2 1 3 1 0 3 1 2 0 1 2 3 2 0 3 0 1 3 0 2 1 C N N N C C N N N N N C Clearly the constrained edged are written to the file. What am I missing? Why are these not recreated in the triangulation? -- Sent from: http://cgal-discuss.949826.n4.nabble.com/ -- Andreas Fabri, PhD Chief Officer, GeometryFactory Editor, The CGAL Project phone: +33.492.954.912 skype: andreas.fabri |
- [cgal-discuss] Constraints not recreated after writing / reading to / from file, malcolm, 04/22/2019
- Re: [cgal-discuss] Constraints not recreated after writing / reading to / from file, Andreas Fabri, 04/23/2019
- Re: [cgal-discuss] Constraints not recreated after writing / reading to / from file, malcolm, 04/25/2019
- Re: [cgal-discuss] Constraints not recreated after writing / reading to / from file, Andreas Fabri, 04/23/2019
Archive powered by MHonArc 2.6.18.