libsurf
Programmer's Documentation

cascademesh.h (r6227/r5385)
1 
2 /* Copyright (C) 2015 David Eller <david@larosterna.com>
3  *
4  * Commercial License Usage
5  * Licensees holding valid commercial licenses may use this file in accordance
6  * with the terms contained in their respective non-exclusive license agreement.
7  * For further information contact david@larosterna.com .
8  *
9  * GNU General Public License Usage
10  * Alternatively, this file may be used under the terms of the GNU General
11  * Public License version 3.0 as published by the Free Software Foundation and
12  * appearing in the file gpl.txt included in the packaging of this file.
13  */
14 
15 #ifndef SURF_CASCADEMESH_H
16 #define SURF_CASCADEMESH_H
17 
18 #include "surface.h"
19 
31 {
32  public:
33 
35  CascadeMesh() : m_psf(0), m_nrows(0), m_ncols(0),
36  m_maxkinsert(5), m_gentris(true) {}
37 
39  CascadeMesh(const Surface *srf, const PointGrid<2> & g);
40 
42  void generate(Real stretchlimit = 20., uint kmax = 5,
43  bool generateTriangles = true);
44 
46  const PointList<2> uvpoints() const {return m_ppt;}
47 
49  void exportMesh(PointList<2> & qts, Indices & tri) const;
50 
52  void exportMesh(PointList<2> & qts, PointList<3> & pts,
53  Indices & tri) const;
54 
55  private:
56 
58  void init(const PointGrid<2> & g);
59 
61  const Vct2 & qgrid(uint i, uint j) const {
62  assert(i < m_nrows and j < m_ncols);
63  return m_ppt[j*m_nrows + i];
64  }
65 
67  const Vct3 & pgrid(uint i, uint j) const {
68  assert(i < m_nrows and j < m_ncols);
69  return m_vtx[j*m_nrows + i];
70  }
71 
73  uint injectPoint(const Vct2 & q) {
74  m_ppt.push_back(q);
75  m_vtx.push_back( m_psf->eval(q[0], q[1]) );
76  return m_ppt.size()-1;
77  }
78 
80  void injectPoints(uint irow, uint jcol, uint k, Indices & a);
81 
83  void injectPoints(uint irow, uint jcol, uint k);
84 
86  void addTriangle(uint a, uint b, uint c);
87 
89  void addBlock23(const uint a[2], const uint b[3]);
90 
92  void addBlock22(const uint a[2], const uint b[2]);
93 
95  Real stretchp(uint irow, uint jcol) const;
96 
98  Real stretch(uint irow, uint jcol) const;
99 
101  Real wrap(uint jcol) const;
102 
104  void processColumn(uint jcol, Real mxst);
105 
106  private:
107 
110 
113 
115  const Surface *m_psf;
116 
118  uint m_nrows, m_ncols;
119 
121  Indices m_itri;
122 
125 
127  bool m_gentris;
128 };
129 
130 #endif
uint size() const
uint push_back(const value_type &x)
void init(const PointGrid< 2 > &g)
initialize from grid
Definition: cascademesh.cpp:35
Specialized semi-structured triangle mesh generator.
Definition: cascademesh.h:30
void addBlock22(const uint a[2], const uint b[2])
generate triangles for a block
Definition: cascademesh.cpp:282
void addBlock23(const uint a[2], const uint b[3])
generate triangles for a block
Definition: cascademesh.cpp:275
void processColumn(uint jcol, Real mxst)
refine a single column
Definition: cascademesh.cpp:111
Real stretchp(uint irow, uint jcol) const
determine actual stretch ratio of a single patch
Definition: cascademesh.cpp:91
CascadeMesh()
empty cascade
Definition: cascademesh.h:35
void generate(Real stretchlimit=20., uint kmax=5, bool generateTriangles=true)
generate mesh with stretch below limit
Definition: cascademesh.cpp:54
PointList< 2 > m_ppt
list of points in parameter plane
Definition: cascademesh.h:109
bool m_gentris
whether to generate triangles or just points
Definition: cascademesh.h:127
uint injectPoint(const Vct2 &q)
insert point and return index
Definition: cascademesh.h:73
Indices m_itri
triangles
Definition: cascademesh.h:121
uint m_nrows
dimensions of the grid used for initialization
Definition: cascademesh.h:118
const PointList< 2 > uvpoints() const
access uv-plane points after mesh generation
Definition: cascademesh.h:46
void addTriangle(uint a, uint b, uint c)
generate a single triangles, flip direction if necessary
Definition: cascademesh.cpp:256
void exportMesh(PointList< 2 > &qts, Indices &tri) const
export mesh after processing
Definition: cascademesh.cpp:62
Real stretch(uint irow, uint jcol) const
determine worst stretch at vertex row
Definition: cascademesh.cpp:78
PointList< 3 > m_vtx
points in 3D space
Definition: cascademesh.h:112
virtual Vct3 eval(Real u, Real v) const =0
evaluation interface
const Vct3 & pgrid(uint i, uint j) const
access point of the original grid
Definition: cascademesh.h:67
Surface interface.
Definition: surface.h:37
uint m_maxkinsert
maximum allowed insertion level
Definition: cascademesh.h:124
Real wrap(uint jcol) const
wrap distance for column jcol
Definition: cascademesh.cpp:100
const Vct2 & qgrid(uint i, uint j) const
access point of the original grid
Definition: cascademesh.h:61
void injectPoints(uint irow, uint jcol, uint k, Indices &a)
insert 2^k - 1 points in row irow
Definition: cascademesh.cpp:226
const Surface * m_psf
surface to use
Definition: cascademesh.h:115
Generated on Wed Jan 19 2022 03:03:14 for libsurf by   doxygen 1.8.5