Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Midpoint subdivision for triangle meshes

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Midpoint subdivision for triangle meshes


Chronological Thread 
  • From: Marc Eder <>
  • To:
  • Subject: Re: [cgal-discuss] Midpoint subdivision for triangle meshes
  • Date: Wed, 16 Oct 2019 18:43:14 -0400
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:BdTcwBNChcsrMw83SwYl6mtUPXoX/o7sNwtQ0KIMzox0Iv//rarrMEGX3/hxlliBBdydt6sfzbWI+Pm4EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCezbL9oLhi7rArdutQKjYB/Nqs/1xzFr2dSde9L321oP1WTnxj95se04pFu9jlbtuwi+cBdT6j0Zrw0QrNEAjsoNWA1/9DrugLYTQST/HscU34ZnQRODgPY8Rz1RJbxsi/9tupgxCmXOND9QL4oVTi+6apgVRnlgzoFOTEk6mHaksN/jKxZrxyhqRJxwJPabp+JO/dlZKzRYckXSHBdUspNVSFMBJ63YYsVD+oGOOZVt47zqEEUrRSiGAKiC/7gxSFShnTr2qA61vouHhzY0ww6BN8BrG/UoM/oNKcUTe+51rfHwijeb/5P3zr29YbGchckof6WXLJwd9LcyU81GAzelVqQrZLqMymJ2eQKtmiX9+tgVeS1i24msQ59uDavxt00hobViYIa0FTE+T9+wIYvKt20UEF7Yd+4EJtQqiGVLJF6Td8lQ2Ftvisx174IuYajcSQU1JgqwwTTZv+HfoSS/B7vSvudLS13iX9lfr+0mgy8/lK6yuLmU8m5yFZKoTRBktnLrn0N0gbc6smDSvdk8EahwyuD2xnd6uxLIU04j6XbK5kmwr4/kpocr17PETPxmEXzlKOWd0Mk9fa06+n/fLnqupuRO5V3hwz+KKgihNKzDfkiPgUBX2WX4eG826fi/U39TrVKlPo2kqzBvZDfO8sUu7C2AxVO34k/8BazFSqm0NIEknUdMl1KZQ+Hg5DzO17SOPD4Eeu/g1O0nTh3yPDJJLnhDozQIXjCi7fuYat961VHyAco1tBe55dUCqkbL/7pW0/xssbYDh4jPACuzebnEoY164UFRGjaArOFKLiA9hiT9+c3Kq+NYpUUsXDzMb8+9vv2hDg4n1EaOqKm1J9SZHGjFel9OBalZi/njd4FVGsLpQEjV/fCiVuYUDcVaWzhcbg742QeAZitRarPS5rl1LmM0CqhNpZNIH1AARaBHWq+JNbMYOsFdC/HepwpqTcDT7X0E9Z8hyHrjxfzzv9cFsSR+iAcssi+ht185umWigtrsDIoUoKS1GaCS2wylWQNFWdvjfJP5Hdlw1LG6pBWxvlRFNhd/fRMC11oPoWa0upxTd3+R1CYJ4vbeBOdWtyjRAoJYJcp2dZXORR2AJO/iBuF0ia3UecY

Thank you, Mael! That was exactly what I was looking for. I didn't understand how masks worked. For anyone else's reference, here is a simple midpoint subdivision mask for CGAL's Surface_mesh class. I did away with the templating for my own needs, but obviously that extra generalizability can be worked back in. All this subdivision does is subdivide triangle faces into 4 equal sub-triangles. There is no interpolation on the vertices whatsoever.


// Includes
#include <CGAL/Surface_mesh.h>
#include <CGAL/subdivision_method_3.h>

// Mask class
class MidpointSubdivisionMask {
  typedef SurfaceMesh CGAL::Surface_mesh<CGAL::Simple_cartesian<double>::Point_3>;
  typedef typename boost::graph_traits<SurfaceMesh>::vertex_descriptor
      vertex_descriptor;
  typedef typename boost::graph_traits<SurfaceMesh>::halfedge_descriptor
      halfedge_descriptor;
  typedef typename boost::property_map<SurfaceMesh, CGAL::vertex_point_t>::type
      Vertex_pmap;
  typedef typename boost::property_traits<Vertex_pmap>::value_type Point;
  typedef typename boost::property_traits<Vertex_pmap>::reference Point_ref;
  SurfaceMesh &pmesh;
  Vertex_pmap vpm;

 public:
  MidpointSubdivisionMask(SurfaceMesh &pmesh)
      : pmesh(pmesh), vpm(get(CGAL::vertex_point, pmesh)) {}
  void edge_node(halfedge_descriptor hd, Point &pt) {
    Point_ref p1 = get(vpm, target(hd, pmesh));
    Point_ref p2 = get(vpm, target(opposite(hd, pmesh), pmesh));
    pt = Point((p1[0] + p2[0]) / 2, (p1[1] + p2[1]) / 2, (p1[2] + p2[2]) / 2);
  }
  void vertex_node(vertex_descriptor vd, Point &pt) {
    Point_ref S = get(vpm, vd);
    pt          = Point(S[0], S[1], S[2]);
  }
  void border_node(halfedge_descriptor hd, Point &ept, Point &vpt) {
    this->edge_node(hd, ept);
    this->vertex_node(target(hd, pmesh), vpt);
  }
};

//---------------------------------
// To call it
// Do something to create the mesh
SurfaceMesh mesh;

// Number of subdivisions
const size_t order = 1;

// Subdivide
CGAL::Subdivision_method_3::PTQ(
     this->_mesh, MidpointSubdivisionMask(this->_mesh),
     CGAL::Subdivision_method_3::parameters::number_of_iterations(order));

On Wed, Oct 16, 2019 at 2:55 AM Mael <> wrote:
Hello,

Have you looked at the following example :
https://doc.cgal.org/latest/Subdivision_method_3/Subdivision_method_3_2Customized_subdivision_8cpp-example.html
? You can customize your Loop subdivision's mask, e.g. to have vertices
not moving and new subdividing points being middle of existing edges,
which is what you wish to have if I understand correctly.

Best,
Mael

On 15/10/2019 17:23, meder411 wrote:
> I am looking for a way to perform midpoint subdivision on a triangular mesh.
> The basic idea is that I want to do Loop subdivision without interpolating
> the new vertices. Is this implemented somewhere? I was looking at the
> `ptq_1step` function  here
> <https://github.com/CGAL/cgal/blob/master/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h#L181>
> , but it seems to use internal capabilities that are not exposed through the
> API. Additionally, I don't need any sort of mask. What would the best way to
> go about implementing this be?
>
>
>
> --
> 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




--
Marc Eder
Ph.D. Candidate, Computer Science
University of North Carolina at Chapel Hill



Archive powered by MHonArc 2.6.18.

Top of Page