Graphite  Version 3
An experimental 3D geometry processing program
mesh_subdivision.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000-2022 Inria
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * * Neither the name of the ALICE Project-Team nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Contact: Bruno Levy
30  *
31  * https://www.inria.fr/fr/bruno-levy
32  *
33  * Inria,
34  * Domaine de Voluceau,
35  * 78150 Le Chesnay - Rocquencourt
36  * FRANCE
37  *
38  */
39 
40 #ifndef GEOGRAM_MESH_MESH_SUBDIVISION
41 #define GEOGRAM_MESH_MESH_SUBDIVISION
42 
47 #include <geogram/basic/common.h>
48 #include <geogram/basic/numeric.h>
49 #include <geogram/basic/memory.h>
50 
51 namespace GEO {
52 
53  class Mesh;
54 
60  class GEOGRAM_API MeshSplitCallbacks {
61  public:
67 
72 
78 
84  virtual void scale_vertex(index_t v, double s);
85 
90  virtual void zero_vertex(index_t v);
91 
98  virtual void madd_vertex(
99  index_t v1, double s, index_t v2
100  );
101 
102  protected:
103  Mesh* mesh_;
104  };
105 
116  void GEOGRAM_API mesh_split_triangles(
117  Mesh& M, index_t facets_begin = 0, index_t facets_end = index_t(-1),
118  MeshSplitCallbacks* cb = nullptr
119  );
120 
130  void GEOGRAM_API mesh_split_quads(
131  Mesh& M, index_t facets_begin = 0, index_t facets_end = index_t(-1),
132  MeshSplitCallbacks* cb = nullptr
133  );
134 
143  void GEOGRAM_API mesh_split_catmull_clark(
144  Mesh& M, MeshSplitCallbacks* cb = nullptr
145  );
146 
159  Mesh& M, index_t facets_begin = 0, index_t facets_end = index_t(-1),
160  MeshSplitCallbacks* cb = nullptr
161  );
162 
163 }
164 
165 #endif
A set of callbacks that specify how vertices attributes should be interpolated by subdivision functio...
MeshSplitCallbacks(Mesh *mesh)
MeshSplitCallbacks constructor.
virtual void scale_vertex(index_t v, double s)
Scales a vertex (v *= s).
virtual void zero_vertex(index_t v)
Zeroes all attributes of a vertex.
virtual ~MeshSplitCallbacks()
MeshSplitCallbacks destructor.
virtual void madd_vertex(index_t v1, double s, index_t v2)
Adds a scaled vertex to another one (v1 += s*v2).
virtual index_t create_vertex()
Creates a new vertex.
Represents a mesh.
Definition: mesh.h:2693
Common include file, providing basic definitions. Should be included before anything else by all head...
Types and functions for memory manipulation.
Global Vorpaline namespace.
void mesh_triangulate_center_vertex(Mesh &M, index_t facets_begin=0, index_t facets_end=index_t(-1), MeshSplitCallbacks *cb=nullptr)
Splits each n-sided facet of a surface into n triangles by inserting a vertex in the center.
void mesh_split_triangles(Mesh &M, index_t facets_begin=0, index_t facets_end=index_t(-1), MeshSplitCallbacks *cb=nullptr)
Splits each triangle of a surface mesh into four.
void mesh_split_catmull_clark(Mesh &M, MeshSplitCallbacks *cb=nullptr)
Splits a mesh using Catmull-Clark subdivision rule.
geo_index_t index_t
The type for storing and manipulating indices.
Definition: numeric.h:329
void mesh_split_quads(Mesh &M, index_t facets_begin=0, index_t facets_end=index_t(-1), MeshSplitCallbacks *cb=nullptr)
Splits each facet of a surface mesh into quads.
Types and functions for numbers manipulation.