Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Constraints not recreated after writing / reading to / from file

Subject: CGAL users discussion list

List archive

[cgal-discuss] Constraints not recreated after writing / reading to / from file


Chronological Thread 
  • From: malcolm <>
  • To:
  • Subject: [cgal-discuss] Constraints not recreated after writing / reading to / from file
  • Date: Mon, 22 Apr 2019 09:01:18 -0500 (CDT)
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Fail ; spf=Pass
  • Ironport-phdr: 9a23:kOoAnhZFnZVUIPlQ+x+j3pn/LSx+4OfEezUN459isYplN5qZoMW4bnLW6fgltlLVR4KTs6sC17OP9fy+EjJcqdbZ6TZeKcQKD0dEwewt3CUYSPafDkP6KPO4JwcbJ+9lEGFfwnegLEJOE9z/bVCB6le77DoVBwmtfVEtfre9FYHdldm42P6v8JPPfQpImCC9YbRvJxmqsAndrMYbjZZ/JqorxRbEo3REduVZyGh1IV6fgwvw6t2/8ZJ+7yhcoe4t+9JFXa7nY6k2ULtUASg8PWso/sPrrx7DTQWO5nsYTGoblwdDDhbG4h/nQJr/qzP2ueVh1iaUO832Vq00Vi+576h3Uh/oiTwIOCA//WrKl8F/lqNboBampxxi347ZZZyeOfRicq/Be94RWGxMVdtTWSNcGIOxd4UBAeofM+hbsofyqEcBoxSlCAmwBu7j1iNEimPq0aEk1ekqDAHI3BYnH9ILqHnUqc/6NKMOXuCyyKnIyCjIYvRT2Tjn7IjHbhchofWJXb5qbcXe01MvFx3fgVWUqYzlOCiY2fgXvGiG9OpvS+yuhHQnqg1rvjevwcIsh5DPi4kIxF7E8iB5z5w0Jd2+UEN7Z8SrH4BLuCGeKYR6WN8tQ2ZtuCs817YIuoa7cTAXxJkjwxPTcfKKfouS7h/gVeudOzZ1iXNjdbminRi961Kgxff5VsSs0FZFsC5Fkt7Uu3AL2BHf8M6HReFm8Ui63TaAyRrf5f1DIUAxjabbKpghzaAslpcLrEjOGiv7lF/4gaKVbEkp+eml5/7mb7jnvpOcMpV7igD6MqQggMy/BuE4PxALX2eB/eSzyLrj/Un8QLlQkvI5iLPZsI7AKsQfpq65BBRY3Zo55BaiFDepztoZkmMHLV5fZB2HiI3pN0nUIP/kFfe/n0iskDBzyv/aMb3uGJHNImHen7fgZrZy91NcyBEozd1E/JJVCrQBIOrpVUPrtdzYCAU5Mw2uzOr9BtV9zNBWZWXaCaCQNObesESD+/k0C+iKfo4c/jjneNY/4Pu7iHY9klgZeOH92JITY3e8G7JtKl+HaH7shf8KGHoRsxU3Xarhj1jUAm0bXGq7Q69pvmJzM4mhF4qWHtn80ozE5z+yG9htXk4DD1mNFXnycIDdB6UHYT+JL9Bog3oPUr3zF9Z8hyHrjxfzzv9cFsSR+iAcssu+ht4poevanxs2+Hp/CMHPijjRHVExpXsBQnoN5I46uVZ0kwvR2qFlmPFHHM0V7PRMAF83

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/



Archive powered by MHonArc 2.6.18.

Top of Page