G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsParametrization.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsCore/gsLinearAlgebra.h>
17 #include <gsIO/gsOptionList.h>
19 
20 namespace gismo
21 {
45 template<class T>
47 {
48 public:
49  typedef gsPoint<2, T> Point2D;
50 
51  // if we use std::vector with static Eigen classes, the second template parameter is needed
52  typedef std::vector<Point2D, typename Point2D::aalloc> VectorType;
53 
54  typedef memory::shared_ptr<gsParametrization<T> > uPtr;
55 
56 protected:
58  VectorType m_parameterPoints;
59  gsOptionList m_options;
60 
61 public:
62 
64  explicit gsParametrization(const gsMesh<T> &mesh, const gsOptionList & list = defaultOptions());
65 
66  virtual ~gsParametrization() {} // Prevent -Wdelete-non-virtual-dtor warning.
67 
70 
72  virtual void compute();
73 
79 
85 
90  virtual gsMesh<T> createFlatMesh() const;
91 
97  void writeTexturedMesh(std::string filename) const;
98 
100  virtual void restrictMatrices(gsMatrix<T>& , const gsMatrix<T>&,
101  real_t = 0, real_t = 1) const
102  {}
103 
104  gsOptionList& options() { return m_options; }
105 
106  gsParametrization<T>& setOptions(const gsOptionList& list);
107 
108 protected:
109 
128  {
129 
130  public:
147  LocalNeighbourhood(const gsHalfEdgeMesh<T> &meshInfo,
148  const size_t vertexIndex,
149  const bool innerVertex = 1);
150 
156  size_t getVertexIndex() const;
157 
165  size_t getNumberOfNeighbours() const;
166 
174  const std::list<size_t> getVertexIndicesOfNeighbours() const;
175 
184  const std::list<T> &getAngles() const;
185 
194  T getInnerAngle() const;
195 
203  std::list<T> getNeighbourDistances() const;
204 
205  private:
206  size_t m_vertexIndex;
208  std::list<T> m_angles;
209  std::list<T> m_neighbourDistances;
210  };
211 
222  {
223 
224  public:
236  LocalParametrization(const gsHalfEdgeMesh<T> &meshInfo,
237  const LocalNeighbourhood &localNeighbourhood,
238  const size_t parametrizationMethod = 2);
239 
246  const std::vector<T> &getLambdas() const;
247 
248  private:
256  void calculateLambdas(const size_t N, VectorType& points);
257 
258  size_t m_vertexIndex;
259  std::vector<T> m_lambdas;
260 
261  };
262 
286  {
287 
288  public:
292  //Neighbourhood() { }
293 
303  explicit Neighbourhood(const gsHalfEdgeMesh<T> &meshInfo,
304  const size_t parametrizationMethod = 2);
305 
313  const std::vector<T> &getLambdas(const size_t i) const;
314 
322  const std::vector<index_t>
323  getBoundaryCorners(const size_t method, const T range = 0.1, const size_t number = 4) const;
324 
328  static const Point2D findPointOnBoundary(T w, size_t index);
329 
330  private:
331  std::vector<T> midpoints(const size_t numberOfCorners, const T length) const;
332  void searchAreas(const T range,
333  std::vector<std::pair<T, size_t> > &sortedAngles,
334  std::vector<index_t> &corners) const;
335  void takeCornersWithSmallestAngles(size_t number,
336  std::vector<std::pair<T, size_t> > &sortedAngles,
337  std::vector<index_t> &corners) const;
338 
339  protected:
340  const gsHalfEdgeMesh<T> & m_basicInfos;
341  std::vector<LocalParametrization> m_localParametrizations;
342  std::vector<LocalNeighbourhood> m_localBoundaryNeighbourhoods;
343  };
344 
345 
346 protected:
354  const Point2D &getParameterPoint(size_t vertexIndex) const;
355 
370  void constructAndSolveEquationSystem(const Neighbourhood &neighbourhood, const size_t n, const size_t N);
371 
372  std::vector<size_t> indices(const gsMatrix<T>& vertices) const
373  {
374  std::vector<size_t> result;
375  GISMO_ASSERT(vertices.rows() == 3, "three rows expected in vertices");
376  for(index_t c=0; c<vertices.cols(); c++)
377  {
378  result.push_back(m_mesh.findVertex(vertices(0, c), vertices(1, c), vertices(2, c), true));
379  }
380  return result;
381  }
382 
383  void calculate(const size_t boundaryMethod,
384  const size_t paraMethod,
385  const std::vector<index_t> &cornersInput,
386  const T rangeInput,
387  const size_t numberInput);
388 
389  T findLengthOfPositionPart(const size_t position,
390  const size_t numberOfPositions,
391  const std::vector<index_t> &bounds,
392  const std::vector<T> &lengths);
393 
394  bool rangeCheck(const std::vector<index_t> &corners, const size_t minimum, const size_t maximum);
395 
396 public:
397 
398  const gsHalfEdgeMesh<T> & mesh() const {return m_mesh;}
399 
400  const VectorType & pointParameters() const
401  {
402  return m_parameterPoints;
403  }
404 
405 }; // class gsParametrization
406 
407 } // namespace gismo
408 
409 #ifndef GISMO_BUILD_LIB
410 #include GISMO_HPP_HEADER(gsParametrization.hpp)
411 #endif
Class that maintains parametrization This class Parametrization stores the mesh information and the t...
Definition: gsParametrization.h:46
const std::list< T > & getAngles() const
Get angles.
Definition: gsParametrization.hpp:757
Provides declaration of the gsHalfEdgeMesh class.
Class that maintains neighbourhood information of triangle mesh. Represents the neighbourhood propert...
Definition: gsParametrization.h:285
size_t getVertexIndex() const
Get vertex index.
Definition: gsParametrization.hpp:739
const Point2D & getParameterPoint(size_t vertexIndex) const
Get parameter point Returns the parameter point with given vertex index.
Definition: gsParametrization.hpp:157
const std::vector< T > & getLambdas() const
Get lambdas The lambdas are returned.
Definition: gsParametrization.hpp:604
void writeTexturedMesh(std::string filename) const
Definition: gsParametrization.hpp:204
T getInnerAngle() const
Get inner angle.
Definition: gsParametrization.hpp:763
Class that maintains the local neighbourhood properties.
Definition: gsParametrization.h:127
std::vector< T > m_lambdas
lambdas
Definition: gsParametrization.h:259
gsHalfEdgeMesh< T >::Chain m_neighbours
chain of neighbours
Definition: gsParametrization.h:207
#define index_t
Definition: gsConfig.h:32
gsMatrix< T > createUVmatrix()
Definition: gsParametrization.hpp:163
std::list< T > getNeighbourDistances() const
Get neighbour distances.
Definition: gsParametrization.hpp:774
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
LocalParametrization(const gsHalfEdgeMesh< T > &meshInfo, const LocalNeighbourhood &localNeighbourhood, const size_t parametrizationMethod=2)
Constructor Using this constructor one needs to input mesh information, a local neighbourhood and a p...
Definition: gsParametrization.hpp:524
void calculateLambdas(const size_t N, VectorType &points)
Calculate lambdas The lambdas according to Floater&#39;s algorithm are calculated.
Definition: gsParametrization.hpp:616
virtual gsMesh< T > createFlatMesh() const
Definition: gsParametrization.hpp:185
const std::list< size_t > getVertexIndicesOfNeighbours() const
Get vertex indices of neighbours.
Definition: gsParametrization.hpp:751
Class Representing a triangle mesh with 3D vertices.
Definition: gsMesh.h:31
virtual void restrictMatrices(gsMatrix< T > &, const gsMatrix< T > &, real_t=0, real_t=1) const
It might make sense in the derived classes to restrict the parameters to [0, 1]^2.
Definition: gsParametrization.h:100
Provides a list of labeled parameters/options that can be set and accessed easily.
Class maintains local parametrization This class represents a local parametrization for a point in th...
Definition: gsParametrization.h:221
const std::vector< T > & getLambdas(const size_t i) const
Get vector of lambdas.
Definition: gsParametrization.hpp:279
gsMatrix< T > createXYZmatrix()
Definition: gsParametrization.hpp:174
Neighbourhood(const gsHalfEdgeMesh< T > &meshInfo, const size_t parametrizationMethod=2)
Default constructor.
Definition: gsParametrization.hpp:263
std::list< T > m_neighbourDistances
list of distances to neighbours
Definition: gsParametrization.h:209
size_t m_vertexIndex
vertex index
Definition: gsParametrization.h:258
size_t m_vertexIndex
vertex index
Definition: gsParametrization.h:206
static gsOptionList defaultOptions()
Returns the list of default options for gsParametrization.
Definition: gsParametrization.hpp:35
A Point in T^d, with an index number.
Definition: gsPoint.h:26
LocalNeighbourhood(const gsHalfEdgeMesh< T > &meshInfo, const size_t vertexIndex, const bool innerVertex=1)
Constructor.
Definition: gsParametrization.hpp:681
Class that maintains chain of halfedges.
Definition: gsHalfEdgeMesh.h:156
void constructAndSolveEquationSystem(const Neighbourhood &neighbourhood, const size_t n, const size_t N)
Constructs linear equation system and solves it.
Definition: gsParametrization.hpp:122
const std::vector< index_t > getBoundaryCorners(const size_t method, const T range=0.1, const size_t number=4) const
Get boundary corners depending on the method.
Definition: gsParametrization.hpp:285
This is the main header file that collects wrappers of Eigen for linear algebra.
Class which holds a list of parameters/options, and provides easy access to them. ...
Definition: gsOptionList.h:32
virtual void compute()
Main function which performs the computation.
Definition: gsParametrization.hpp:224
const gsHalfEdgeMesh< T > m_mesh
mesh information
Definition: gsParametrization.h:57
std::list< T > m_angles
list of angles between neighbours
Definition: gsParametrization.h:208
gsHalfEdgeMesh is a gsMesh implementation that handles Halfedges
Definition: gsHalfEdgeMesh.h:46
size_t getNumberOfNeighbours() const
Get number of neighbours.
Definition: gsParametrization.hpp:745
VectorType m_parameterPoints
parameter points
Definition: gsParametrization.h:58
gsParametrization(const gsMesh< T > &mesh, const gsOptionList &list=defaultOptions())
Constructor using the input mesh and (possibly) options.
Definition: gsParametrization.hpp:49