35 const unsigned d = basis.dim();
47 std::vector<vtx> map(1ULL<<d);
51 std::vector<std::vector<unsigned> > neighbour(1ULL<<d,
52 std::vector<unsigned>() );
59 for (
unsigned dim = 0; dim < d; dim++)
63 const unsigned tmp = counter | (1<< dim) ;
64 neighbour[counter].push_back(tmp);
73 for (; domIter->good(); domIter->next())
77 const T vol = domIter->volume();
87 for (
unsigned dim = 0; dim < d; dim++)
89 vv(dim) = ( cur(dim) ? upp(dim) : low(dim) );
92 vtx v = addVertex(vv);
100 for (
size_t index = 0; index != neighbour.size(); index++)
102 const std::vector<unsigned> & v = neighbour[index];
104 for (
size_t ngh = 0; ngh != v.size(); ngh++)
107 addLine( map[index], map[v[ngh]], midPts );
125 VertexHandle v = this->makeVertex(x,y,z);
126 v->setId(m_vertex.size());
127 m_vertex.push_back(v );
133 typename gsMesh<T>::VertexHandle gsMesh<T>::addVertex(gsVector<T>
const & u)
135 VertexHandle v = this->makeVertex(u);
136 v->setId(m_vertex.size());
137 m_vertex.push_back(v);
143 void gsMesh<T>::addEdge(VertexHandle v0, VertexHandle v1)
145 m_edge.push_back( Edge(v0,v1) );
150 void gsMesh<T>::addEdge(
int const vind0,
int const vind1)
152 GISMO_ASSERT( (
size_t)vind0 < numVertices(),
"Invalid vertex index "
153 << vind0 <<
"(numVertices="<< numVertices() <<
").");
154 GISMO_ASSERT( (
size_t)vind1 < numVertices(),
"Invalid vertex index "
155 << vind1 <<
"(numVertices="<< numVertices() <<
").");
157 addEdge(m_vertex[vind0], m_vertex[vind1]);
162 void gsMesh<T>::addEdge(gsVector<T>
const & u0,
163 gsVector<T>
const & u1 )
165 addEdge( addVertex(u0), addVertex(u1) );
170 typename gsMesh<T>::FaceHandle gsMesh<T>::addFace(std::vector<VertexHandle>
const & vert)
172 FaceHandle f = this->makeFace( vert );
173 f->setId(m_face.size());
180 typename gsMesh<T>::FaceHandle gsMesh<T>::addFace(VertexHandle
const & v0, VertexHandle
const & v1,
181 VertexHandle
const & v2)
183 FaceHandle f = this->makeFace( v0, v1, v2 );
184 f->setId(m_face.size());
191 typename gsMesh<T>::FaceHandle gsMesh<T>::addFace(VertexHandle
const & v0, VertexHandle
const & v1,
192 VertexHandle
const & v2, VertexHandle
const & v3)
194 FaceHandle f = this->makeFace( v0,v1,v2,v3 );
195 f->setId(m_face.size());
202 typename gsMesh<T>::FaceHandle gsMesh<T>::addFace(std::vector<int>
const & vert)
204 std::vector<VertexHandle> pvert;
205 pvert.reserve(vert.size());
206 for ( std::vector<int>::const_iterator it = vert.begin();
207 it!= vert.end(); ++it )
208 pvert.push_back( m_vertex[*it] );
210 FaceHandle f = this->makeFace( pvert );
211 f->setId(m_face.size());
218 typename gsMesh<T>::FaceHandle gsMesh<T>::addFace(
const int v0,
const int v1,
const int v2)
220 FaceHandle f = this->makeFace( m_vertex[v0],m_vertex[v1],m_vertex[v2] );
221 f->setId(m_face.size());
228 typename gsMesh<T>::FaceHandle gsMesh<T>::addFace(
const int v0,
const int v1,
const int v2,
const int v3)
230 FaceHandle f = this->makeFace( m_vertex[v0],m_vertex[v1],m_vertex[v2],m_vertex[v3] );
231 f->setId(m_face.size());
238 std::ostream &gsMesh<T>::print(std::ostream &os)
const
240 os<<
"gsMesh with "<<numVertices()<<
" vertices, "<<numEdges()<<
241 " edges and "<<numFaces()<<
" faces.\n";
252 gsDebug <<
"Cleaning the gsMesh\n";
268 std::vector<size_t> uniquemap;
269 uniquemap.reserve(m_vertex.size());
270 for(
size_t i = 0; i < m_vertex.size(); i++)
273 for(
size_t j = 0; j < i; j++)
275 if(*(m_vertex[i]) == *(m_vertex[j]))
281 uniquemap.push_back(buddy);
284 for(
size_t i = 0; i != m_face.size(); i++)
286 for (
size_t j = 0; j != m_face[i]->vertices.size(); j++)
288 m_face[i]->vertices[j] = m_vertex[uniquemap[m_face[i]->vertices[j]->getId()]];
292 for(
size_t i = 0; i < m_edge.size(); i++)
294 m_edge[i].source = m_vertex[uniquemap[m_edge[i].source->getId()]];
295 m_edge[i].target = m_vertex[uniquemap[m_edge[i].target->getId()]];
298 std::set<size_t> uniqueset(uniquemap.begin(), uniquemap.end());
299 std::vector<VertexHandle> uvertex;
300 uvertex.reserve(uniqueset.size());
301 for(
size_t i = 0; i < uniquemap.size(); i++) {
302 if(uniqueset.find(i) != uniqueset.end())
305 m_vertex[i]->setId(uvertex.size());
306 uvertex.push_back(m_vertex[i]);
311 m_vertex[i] =
nullptr;
314 m_vertex.swap(uvertex);
322 m_vertex.reserve(vertex);
323 m_face.reserve(face);
324 m_edge.reserve(edge);
331 const index_t cols = points.cols();
332 if ( cols < 2 )
return;
334 const bool zzero = ( points.rows()==2 );
337 v0 = addVertex( points(0,0), points(1,0), zzero ? (T)0 : points(2,0) );
339 for (
index_t i = 1; i<cols; ++i)
341 v1 = addVertex( points(0, i), points(1, i), zzero ? (T)0 : points(2,0) );
351 const T h = (*v1 - start).norm() / (T)(midPts + 1);
356 for (
int i = 0; i<midPts; ++i )
358 next = addVertex(start + (T)(i+1)*h*step);
A fixed-size, statically allocated 3D vector.
Definition: gsVector.h:218
bool nextCubePoint(Vec &cur, const Vec &end)
Iterate in lexigographic order through the points of the integer lattice contained in the cube [0...
Definition: gsCombinatorics.h:327
#define gsDebug
Definition: gsDebug.h:61
Provides declaration of Basis abstract interface.
#define index_t
Definition: gsConfig.h:32
Provides combinatorial unitilies.
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
Class Representing a triangle mesh with 3D vertices.
Definition: gsMesh.h:31
gsMesh & cleanMesh()
reorders the vertices of all faces of an .stl mesh, such that only 1 vertex is used instead of #(adja...
Definition: gsMesh.hpp:250
Provides declaration of DomainIterator abstract interface.
void freeAll(It begin, It end)
Frees all pointers in the range [begin end)
Definition: gsMemory.h:312
void addLine(gsMatrix< T > const &points)
Definition: gsMesh.hpp:329
virtual domainIter makeDomainIterator() const
Create a domain iterator for the computational mesh of this basis, that points to the first element o...
Definition: gsBasis.hpp:493
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
gsVertex class that represents a 3D vertex for a gsMesh.
Definition: gsVertex.h:26