CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
4.96k stars 1.39k forks source link

How to open *.cgal type files? #5249

Closed SY524044272-python closed 3 years ago

SY524044272-python commented 3 years ago

I use Surface_mesh_skeletonization/simple_mcfskel_sm_example.cpp as example。 But I found that I cannot output the code in bold font normally。Cannot output normally from the sixth line。 can someone help me ?

   Skeleton skeleton;
CGAL::extract_mean_curvature_flow_skeleton(tmesh, skeleton);
std::cout << "Number of vertices of the skeleton: " << boost::num_vertices(skeleton) << "\n";
std::cout << "Number of edges of the skeleton: " << boost::num_edges(skeleton) << "\n";
**// Output all the edges of the skeleton.
std::ofstream output("skel-sm.cgal");
for (Skeleton_edge e : CGAL::make_range(edges(skeleton)))
{
    const Point& s = skeleton[source(e, skeleton)].point;
    const Point& t = skeleton[target(e, skeleton)].point;
    output << "2 " << s << " " << t << "\n";
}
output.close();
// Output skeleton points and the corresponding surface points
output.open("correspondance-sm.cgal");
for (Skeleton_vertex v : CGAL::make_range(vertices(skeleton)))
    for (vertex_descriptor vd : skeleton[v].vertices)
        output << "2 " << skeleton[v].point << "  " << get(CGAL::vertex_point, tmesh, vd) << "\n";
sloriot commented 3 years ago

The CGAL polyhedron contained in the demo/Polyhedron shipped with a CGAL release can open those files. A precompiled version for windows is available here and requires some extra dlls.

SY524044272-python commented 3 years ago

hello,Sebastien Loriot.When I run the program,the . cgal file will be generated successfully under the current directory folder. I think the . cgal file is an intermediate file and will not affect the program operation. But the following lines of code are not working properly:

for (Skeleton_edge e : CGAL::make_range(edges(skeleton))) { const Point& s = skeleton[source(e, skeleton)].point; const Point& t = skeleton[target(e, skeleton)].point; output << "2 " << s << " " << t << "\n"; }

I don't understand why

sloriot commented 3 years ago

I don't understand your question. What did not work? The generation of the file or opening it in the demo? Did you generation program ended correctly?

sloriot commented 3 years ago

What is your question?

SY524044272-python commented 3 years ago

hello,Sebastien Loriot. I think I was a little confused just now. Now the program can run normally, and two cgal type files are generated.

you know,I want to extract the skeleton from the model. Just like the example mentioned in the CGAL document, as shown below. image You just gave me a program that can display 3D graphics, and I successfully displayed my model through Polyhedron_3.exe. However, I cannot use it to open *.cgal file,which is the skeleton of my 3D model.as shown below.The problem is shown in the figure below. image image

sloriot commented 3 years ago

Use polylines_io_plugin in the list or change the extension of the file from .cgal to .polylines.txt

SY524044272-python commented 3 years ago

thank you, sloriot ! I think I have solved this question. By the way, I have another question. if I have a 3D model Point(x,y,z) but it is so thin that almost a two-dimensional shape. Can I use CGAL::extract_mean_curvature_flow_skeleton() to extract the skeleton to instead 2D skeleton of this 3D model?

sloriot commented 3 years ago

I never tried but you should try and see what it does.