G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsSurface.hpp
Go to the documentation of this file.
1 
15 #pragma once
16 
18 #include <gsUtils/gsMesh/gsMesh.h>
19 
20 
21 namespace gismo
22 {
23 
24 template<class T>
25 void gsSurface<T>::toMesh(gsMesh<T> & msh, int npoints) const
26 {
27  const gsMatrix<T> param = this->parameterRange();
28  gsMatrix<T> cp;
29  gsGridIterator<T,CUBE> pIter(param, npoints);
30  for(; pIter; ++pIter)
31  {
32  this->eval_into( *pIter, cp);
33  msh.addVertex( cp );
34  }
35 
36  const typename gsGridIterator<T,CUBE>::point_index np = pIter.numPointsCwise();
37  for(index_t j = 0; j + 1 != np[1]; j++)
38  for(index_t i= 0; i + 1 != np[0]; i++)
39  {
40  const index_t ind1 = j * np[0] + i;
41  const index_t ind2 = ind1 + np[0];
42  //msh.addFace(ind1, ind1+1, ind2+1, ind2);
43  msh.addFace(ind1 , ind1+1, ind2+1);
44  msh.addFace(ind2+1, ind2 , ind1 );
45  }
46 }
47 
48 /*
49  gsVector<unsigned> v;
50  v.setZero(2);
51  do
52  {
53  msh.addFace(v[0], v[0]+1, v[1]+1, v[1]);
54  }
55  while( nextLexicographic(v, np) );
56 */
57 
58 } // namespace gismo
#define index_t
Definition: gsConfig.h:32
Provides declaration of the Mesh class.
Provides iteration over integer or numeric points in a (hyper-)cube.