Geogram  Version 1.9.1
A programming library of geometric algorithms
mesh_param_validator.h
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_PARAM_VALIDATOR
41 #define GEOGRAM_MESH_MESH_PARAM_VALIDATOR
42 
43 #include <geogram/basic/common.h>
44 #include <geogram/parameterization/mesh_segmentation.h>
45 #include <geogram/basic/geometry.h>
47 
53 namespace GEO {
54 
55  class Mesh;
56 
61  class GEOGRAM_API ParamValidator {
62  public:
67 
72 
76  ParamValidator(const ParamValidator& rhs) = delete;
77 
81  ParamValidator& operator=(const ParamValidator& rhs) = delete;
82 
93  bool chart_is_valid(Mesh& chart);
94 
101  double chart_scaling(Mesh& chart);
102 
111 
119  double fill_ratio() const {
120  return fill_ratio_;
121  }
122 
131  double overlap_ratio() const {
132  return overlap_ratio_;
133  }
134 
143  double get_max_overlap_ratio() const {
144  return max_overlap_ratio_;
145  }
146 
155  void set_max_overlap_ratio(double x) {
156  max_overlap_ratio_ = x;
157  }
158 
168  double get_max_scaling() const {
169  return max_scaling_;
170  }
171 
180  void set_max_scaling(double x) {
181  max_scaling_ = x;
182  }
183 
191  double get_min_fill_ratio() const {
192  return min_fill_ratio_;
193 
194  }
195 
204  void set_min_fill_ratio(double x) {
205  min_fill_ratio_ = x;
206  }
207 
213  void set_verbose(bool x) {
214  verbose_ = x;
215  }
216 
217  protected:
218 
225  void begin_rasterizer(Mesh& mesh, Attribute<double>& tex_coord);
226 
233 
242  const vec2& p1, const vec2& p2, const vec2& p3
243  );
244 
251  void transform(const vec2& p, int& x, int& y);
252 
253  private:
257  int graph_size_;
258 
263  Numeric::uint8* graph_mem_;
264 
269  int* x_left_;
270 
275  int* x_right_;
276 
280  double user_x_min_;
281 
285  double user_y_min_;
286 
290  double user_width_;
291 
295  double user_height_;
296 
300  double user_size_;
301 
305  double fill_ratio_;
306 
310  double overlap_ratio_;
311 
315  double max_overlap_ratio_;
316 
320  double max_scaling_;
321 
325  double min_fill_ratio_;
326 
330  bool verbose_;
331  };
332 
333 }
334 
335 #endif
Generic mechanism for attributes.
Represents a mesh.
Definition: mesh.h:2701
Tests whether texture coordinates attached to a surface mesh define a valid parameterization.
void end_rasterizer()
Terminates the software rasterizer.
~ParamValidator()
ParamValidator destructor.
void rasterize_triangle(const vec2 &p1, const vec2 &p2, const vec2 &p3)
Rasterizes a triangle.
double fill_ratio() const
Gets the computed filling ratio.
void transform(const vec2 &p, int &x, int &y)
Transforms a 2d point from parameter space to raterizer coordinates.
double get_max_scaling() const
Gets the maximum scaling.
bool chart_is_valid(Mesh &chart)
Tests whether a Mesh and associated texture coordinates defines a valid parameterization.
ParamValidator(const ParamValidator &rhs)=delete
Forbids copy.
ParamValidator()
ParamValidator constructor.
double get_max_overlap_ratio() const
Gets the maximum overlapping ratio.
void set_min_fill_ratio(double x)
Sets the minimum filling ratio.
ParamValidator & operator=(const ParamValidator &rhs)=delete
Forbids copy.
void compute_fill_and_overlap_ratio(Mesh &chart)
Computes the filling and overlapping ratio of a parameterized chart.
double chart_scaling(Mesh &chart)
Computes the scaling induced by the parameterization.
void set_max_scaling(double x)
Sets the maximum scaling.
double get_min_fill_ratio() const
Gets the minimum filling ratio.
double overlap_ratio() const
Gets the computed overlap ratio.
void set_max_overlap_ratio(double x)
Sets the maximum overlapping ratio.
void set_verbose(bool x)
Enables or disables messages.
void begin_rasterizer(Mesh &mesh, Attribute< double > &tex_coord)
Initializes the software rasterizer for a chart.
Common include file, providing basic definitions. Should be included before anything else by all head...
Geometric functions in 2d and 3d.
uint8_t uint8
Definition: numeric.h:135
Global Vorpaline namespace.
Definition: basic.h:55