Graphite  Version 3
An experimental 3D geometry processing program
mesh_grob_surface_commands.h
Go to the documentation of this file.
1 /*
2  * OGF/Graphite: Geometry and Graphics Programming Library + Utilities
3  * Copyright (C) 2000-2009 INRIA - Project ALICE
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  * If you modify this software, you should include a notice giving the
20  * name of the person performing the modification, the date of modification,
21  * and the reason for such modification.
22  *
23  * Contact: Bruno Levy - levy@loria.fr
24  *
25  * Project ALICE
26  * LORIA, INRIA Lorraine,
27  * Campus Scientifique, BP 239
28  * 54506 VANDOEUVRE LES NANCY CEDEX
29  * FRANCE
30  *
31  * Note that the GNU General Public License does not permit incorporating
32  * the Software into proprietary programs.
33  *
34  * As an exception to the GPL, Graphite can be linked with the following
35  * (non-GPL) libraries:
36  * Qt, SuperLU, WildMagic and CGAL
37  */
38 
39 
40 #ifndef H_OGF_MESH_COMMANDS_MESH_GROB_SURFACE_COMMANDS_H
41 #define H_OGF_MESH_COMMANDS_MESH_GROB_SURFACE_COMMANDS_H
42 
43 #include <OGF/mesh/common/common.h>
45 #include <geogram/parameterization/mesh_atlas_maker.h>
46 #include <geogram/parameterization/mesh_segmentation.h>
47 
53 namespace OGF {
54 
58  gom_class MESH_API MeshGrobSurfaceCommands :
59  public MeshGrobCommands {
60 
61  public:
62 
67 
72 
73  gom_slots:
74 
91  void repair_surface(
92  double epsilon = 1e-6,
93  double min_comp_area = 0.03,
94  double max_hole_area = 1e-3,
95  double max_hole_edges = 2000,
96  double max_degree3_dist = 0.0,
97  bool remove_intersections = false
98  );
99 
100  /**********************************************************/
101 
109  void merge_vertices(double epsilon = 0.0);
110 
111  /**********************************************************/
112 
119  void expand_border(double margin=0.05);
120 
121  /**********************************************************/
122 
129  void fill_holes(index_t max_nb_vertices=0);
130 
131 
132  /**********************************************************/
133 
139 
140  /**********************************************************/
141 
148  void remove_invisible_facets(double min_visibility = 0.005);
149 
150 
151  /**********************************************************/
152 
179  const NewMeshGrobName& remesh_name = "remesh",
180  unsigned int nb_points = 30000,
181  double tri_shape_adapt = 1.0,
182  double tri_size_adapt = 0.0,
183  bool adjust = true,
184  double adjust_max_edge_distance = 0.5,
185  unsigned int normal_iter = 3,
186  unsigned int Lloyd_iter = 5,
187  unsigned int Newton_iter = 30,
188  unsigned int Newton_m = 7,
189  unsigned int LFS_samples = 10000
190  );
191 
192  /**********************************************************/
193 
214  const NewMeshGrobName& surface_name = "remesh",
215  unsigned int nb_points = 30000,
216  bool refine = false,
217  double max_dist = 0.5,
218  double normal_anisotropy = 5.0,
219  unsigned int nb_Lloyd_iter = 5,
220  unsigned int nb_Newton_iter = 30,
221  unsigned int nb_LpCVT_iter = 10,
222  unsigned int Newton_m = 7,
223  bool RVC_centroids = false
224  );
225 
226  /**********************************************************/
227 
239  const NewMeshGrobName& surface_name = "remesh",
240  double rel_edge_len = 1.0,
241  bool sharp_features = true,
242  bool optimize_parity = false,
243  double max_scaling_corr = 1.0
244  );
245 
246  /**********************************************************/
247 
260  const MeshGrobName& other,
261  const NewMeshGrobName& result = "result",
262  bool pre_process=false,
263  bool post_process=false
264  );
265 
266 
279  const MeshGrobName& other,
280  const NewMeshGrobName& result = "result",
281  bool pre_process=false,
282  bool post_process=false
283  );
284 
297  const MeshGrobName& other,
298  const NewMeshGrobName& result = "result",
299  bool pre_process=false,
300  bool post_process=false
301  );
302 
315  gom_arg_attribute(operation, handler, "combo_box")
316  gom_arg_attribute(operation, values, "A+B;A*B;A-B;B-A")
317  MeshGrob* compute_boolean_operation(
318  const MeshGrobName& other,
319  const NewMeshGrobName& result = "result",
320  const std::string& operation = "A+B",
321  bool pre_process=false,
322  bool post_process=false
323  );
324 
335  void intersect(
336  bool remove_internal_shells = true,
337  bool simplify_coplanar_facets = true,
338  double coplanar_angle_tolerance = 0.001,
339  bool interpolate_attributes = false
340  );
341 
342  /**********************************************************/
343 
354  void decimate(
355  index_t nb_bins = 100,
356  bool remove_deg3_vrtx = true,
357  bool keep_borders = true,
358  bool repair = true
359  );
360 
361  /**********************************************************/
362 
369  void split_triangles(index_t nb_times=1);
370 
376  void split_quads(index_t nb_times=1);
377 
378 
385  void split_catmull_clark(index_t nb_times=1);
386 
392  void tessellate_facets(index_t max_vertices_per_facet=4);
393 
394 
399  void triangulate() {
401  }
402 
403 
410 
411 
416  void smooth();
417 
418  /**********************************************************/
419 
420  enum Parameterizer {
421  LSCM, SpectralLSCM, ABFplusplus
422  };
423 
428  void segment(
429  MeshSegmenter segmenter=SEGMENT_GEOMETRIC_VSA_L2,
430  index_t nb_segments=10
431  );
432 
437  void get_charts();
438 
444 
451  void unglue_sharp_edges(double angle_threshold=90);
452 
458 
474  bool detect_sharp_edges = false,
475  double sharp_edges_threshold = 45.0,
476  ChartParameterizer param=PARAM_ABF,
477  ChartPacker pack=PACK_XATLAS,
478  bool verbose=false
479  );
480 
481 
488  ChartPacker pack=PACK_XATLAS
489  );
490 
501  const std::string& attribute="tex_coord",
502  ChartParameterizer param=PARAM_LSCM,
503  bool verbose=false
504  );
505 
519  const MeshGrobName& surface,
520  index_t size=1024,
521  const NewImageFileName& image="normals.png",
522  index_t nb_dilate=2,
523  const std::string& tex_coord="tex_coord"
524  );
525 
526 
541  const MeshGrobName& surface,
542  const std::string& color="color",
543  index_t size=1024,
544  const NewImageFileName& image="colors.png",
545  index_t nb_dilate=2,
546  const std::string& attribute="tex_coord"
547  );
548 
549 
567  const MeshGrobName& src_surface,
568  const ImageFileName& src_texture,
569  const std::string& src_tex_coord="tex_coord",
570  index_t size=1024,
571  const NewImageFileName& image="texture.png",
572  index_t nb_dilate=2,
573  const std::string& tex_coord="tex_coord"
574  );
575 
576 
577  };
578 }
579 #endif
580 
Base class for Commands related with a MeshGrob object.
Commands that manipulate surface meshes.
~MeshGrobSurfaceCommands() override
MeshGrobSurfaceCommands destructor.
void fill_holes(index_t max_nb_vertices=0)
Fills the holes of the surface.
void triangulate_center_vertex()
Triangulates all the facets by inserting a vertex in the center of each facet.
MeshGrob * compute_union(const MeshGrobName &other, const NewMeshGrobName &result="result", bool pre_process=false, bool post_process=false)
Computes the union between two meshes.
MeshGrob * compute_difference(const MeshGrobName &other, const NewMeshGrobName &result="result", bool pre_process=false, bool post_process=false)
Computes the difference between two meshes.
MeshGrobSurfaceCommands()
MeshGrobSurfaceCommands constructor.
void get_charts()
Gets the charts attribute from a parameterized mesh.
void remove_invisible_facets(double min_visibility=0.005)
Removes all facets that have visibility smaller than a given threshold.
void remesh_smooth(const NewMeshGrobName &remesh_name="remesh", unsigned int nb_points=30000, double tri_shape_adapt=1.0, double tri_size_adapt=0.0, bool adjust=true, double adjust_max_edge_distance=0.5, unsigned int normal_iter=3, unsigned int Lloyd_iter=5, unsigned int Newton_iter=30, unsigned int Newton_m=7, unsigned int LFS_samples=10000)
Remeshes a (smooth) surface.
void remesh_feature_sensitive(const NewMeshGrobName &surface_name="remesh", unsigned int nb_points=30000, bool refine=false, double max_dist=0.5, double normal_anisotropy=5.0, unsigned int nb_Lloyd_iter=5, unsigned int nb_Newton_iter=30, unsigned int nb_LpCVT_iter=10, unsigned int Newton_m=7, bool RVC_centroids=false)
Remeshes a surface that has sharp features.
void merge_vertices(double epsilon=0.0)
Merges vertices that are at the same location or within tolerance.
void bake_colors(const MeshGrobName &surface, const std::string &color="color", index_t size=1024, const NewImageFileName &image="colors.png", index_t nb_dilate=2, const std::string &attribute="tex_coord")
Bakes colors from a surface to the texture atlas.
void bake_texture(const MeshGrobName &src_surface, const ImageFileName &src_texture, const std::string &src_tex_coord="tex_coord", index_t size=1024, const NewImageFileName &image="texture.png", index_t nb_dilate=2, const std::string &tex_coord="tex_coord")
Bakes texture from a textured surface to an atlas.
void remove_charts()
Removes the charts attribute.
gom_arg_attribute(operation, handler, "combo_box") gom_arg_attribute(operation
Computes a boolean operation between two meshes.
MeshGrob * compute_intersection(const MeshGrobName &other, const NewMeshGrobName &result="result", bool pre_process=false, bool post_process=false)
Computes the intersection between two meshes.
void unglue_sharp_edges(double angle_threshold=90)
Unglues facet edges based on specified angle.
void parameterize_chart(const std::string &attribute="tex_coord", ChartParameterizer param=PARAM_LSCM, bool verbose=false)
Computes texture coordinates of a single unfoldable surface.
void unglue_charts()
Unglues facet edges adjacent to two different charts.
void remesh_quad_dominant(const NewMeshGrobName &surface_name="remesh", double rel_edge_len=1.0, bool sharp_features=true, bool optimize_parity=false, double max_scaling_corr=1.0)
Generates a quad-dominant mesh.
void segment(MeshSegmenter segmenter=SEGMENT_GEOMETRIC_VSA_L2, index_t nb_segments=10)
Segments a mesh.
void bake_normals(const MeshGrobName &surface, index_t size=1024, const NewImageFileName &image="normals.png", index_t nb_dilate=2, const std::string &tex_coord="tex_coord")
Bakes normals from a surface to the texture atlas.
void make_texture_atlas(bool detect_sharp_edges=false, double sharp_edges_threshold=45.0, ChartParameterizer param=PARAM_ABF, ChartPacker pack=PACK_XATLAS, bool verbose=false)
Computes texture coordinates of a surface.
void pack_texture_space(ChartPacker pack=PACK_XATLAS)
Packs charts in texture space.
void smooth()
Smooths the mesh by optimizing the vertices that are not selected. Selected vertices are locked.
void expand_border(double margin=0.05)
Preprocessing for remesh_feature_sensitive.
void fix_facets_orientation()
Fixes facets orientation based on computed visibility.
A Grob wrapper around Geogram's Mesh class.
Definition: mesh_grob.h:56
A template class for strings that need to have a specific type in the GOM system.
Definition: properties.h:218
Base class for Commands related with a MeshGrob object.
ChartParameterizer
Parameterizer used to flatten individual charts.
geo_index_t index_t
The type for storing and manipulating indices.
Definition: numeric.h:329
void tessellate_facets(Mesh &M, index_t max_nb_vertices)
Subdivides the facets with more than nb_vertices.
ChartPacker
Packer used to organize the charts in texture space.
Global Graphite namespace.
Definition: common.h:76
Definitions common to all include files in the mesh library.