Midpoint subdivision for triangle meshes

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

Midpoint subdivision for triangle meshes

meder411
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


Reply | Threaded
Open this post in threaded view
|

Re: Midpoint subdivision for triangle meshes

MaelRL
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


Reply | Threaded
Open this post in threaded view
|

Re: Midpoint subdivision for triangle meshes

meder411
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 <[hidden email]> 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