Create Surface_Mesh from Alpha_Shape

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Create Surface_Mesh from Alpha_Shape

Riedel, Torge

Hi,

 

one more – hopefully simple to answer – question:

 

Having an alpha shape object (CGAL::Alpha_shape_3) in hand, how to create a Surface_Mesh from the alpha shape?

 

I’m still searching on my own in the docs, but hope to find a faster answer here on the list.

 

Kind regards

Torge


CENIT AG, Industriestrasse 52-54, 70565 Stuttgart, Tel.: +49 711 7825-30, Fax: +49 711 7825-4000, Internet: www.cenit.com
Geschaeftsstellen: Berlin, Frankfurt, Hamburg, Hannover, Muenchen, Oelsnitz, Ratingen, Saarbruecken
Vorstandsmitglieder: Kurt Bengel, Matthias Schmidt
Aufsichtsratsmitglieder: Andreas Schmidt (Vorsitzender des Aufsichtsrats), Hubert Leypoldt, Andreas Karrer
Bankverbindungen:
Deutsche Bank (BLZ 600 700 70) Kto. 1661 040 IBAN : DE85 6007 0070 0166 1040 00 SWIFT-CODE : DEUTDESS,
Commerzbank (BLZ 600 400 71) Kto. 532 015 500 IBAN : DE83 6004 0071 0532 0155 00 SWIFT-Code : COBADEFF600,
Registergericht: Amtsgericht Stuttgart
Handelsregister: HRB Nr. 19117
Umsatzsteuer: ID-Nr. DE 147 862 777
Reply | Threaded
Open this post in threaded view
|

Re: Create Surface_Mesh from Alpha_Shape

nolvis
    Mesh out_mesh; // surface mesh data structure
    std::vector<Alpha_shape_3::Facet > Facets;
    alpha_shape.get_alpha_shape_facets(std::back_inserter(Facets),
Alpha_shape_3::REGULAR);
    for (auto i = 0; i < Facets.size(); i++)
    {

      //checks for exterior cells
      if (alpha_shape.classify(Facets[i].first) != Alpha_shape_3::EXTERIOR)
{
        Facets[i] = alpha_shape.mirror_facet(Facets[i]);
      }

      CGAL_assertion(alpha_shape.classify(Facets[i].first) ==
Alpha_shape_3::EXTERIOR);

      // gets indices of alpha shape and gets consistent orientation
      int indices[3] = { (Facets[i].second + 1) % 4, (Facets[i].second + 2)
% 4, (Facets[i].second + 3) % 4 };
      if (Facets[i].second % 2 == 0) {
        std::swap(indices[0], indices[1]);
      }

      // adds data to cgal mesh
      for (auto j = 0; j < 3; ++j) {
        out_mesh.add_vertex(Facets[i].first->vertex(indices[j])->point());
      }
      auto v0 = static_cast<vertex_descriptor>(3 * i);
      auto v1 = static_cast<vertex_descriptor>(3 * i + 1);
      auto v2 = static_cast<vertex_descriptor>(3 * i + 2);
      out_mesh.add_face(v0, v1, v2);
    }



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

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