30template<
short_t d,
class T>
33 bool consistent =
true;
34 consistent = consistent && _checkTopologyWithBases();
38template<
short_t d,
class T>
41 const indexType sz = size();
45 for( indexType i = 0; i< sz; ++i )
46 mesh.addVertex( nodes.row(i).transpose() );
48 for( indexType i = 0; i< sz; ++i )
49 for( indexType j = i+1; j< sz; ++j )
54template<
short_t d,
class T>
55bool gsMPBESBasis<d,T>::isConnected(indexType i,indexType j)
const
57 std::vector<indexType> locals_i,locals_j;
58 m_mapper->targetToSource(i,locals_i);
59 m_mapper->targetToSource(j,locals_j);
60 indexType sz_i = locals_i.size(), sz_j = locals_j.size();
62 if( sz_i==1 && sz_j==1 )
63 return isLocallyConnected(locals_i[0],locals_j[0]);
65 if( sz_i==1 || sz_j==1 )
67 std::vector<indexType> & lookthrough=locals_j;
68 indexType element = sz_i==1 ? locals_i[0] : locals_j[0];
74 bool connected =
false;
75 for(
unsigned i2 = 0; i2<lookthrough.size(); ++i2 )
76 if( isLocallyConnected(element,lookthrough[i2]) )
84 std::vector<indexType> setIntersection(sz_i+sz_j);
85 std::vector<indexType>::iterator it;
86 it=std::set_intersection (locals_i.begin(), locals_i.end(), locals_j.begin(), locals_j.end(), setIntersection.begin());
87 indexType sz_intersect = it-setIntersection.begin();
88 setIntersection.resize(sz_intersect);
90 if( sz_intersect == sz_i-1 || sz_intersect == sz_j-1 )
93 if( sz_intersect == 0 )
95 bool connected,allConnected=
true;
96 for( indexType i3 = 0; i3< sz_i; ++i3 )
99 for( indexType j3 = 0; j3< sz_j; ++j3 )
100 if( isLocallyConnected(locals_i[i3],locals_j[j3]) )
114 for( indexType j4 = 0; j4< sz_j; ++j4 )
117 for( indexType i5 = 0; i5< sz_i; ++i5 )
118 if( isLocallyConnected(locals_i[i5],locals_j[j4]) )
136template<
short_t d,
class T>
140 for (BasisIter it=m_bases.begin();it!=m_bases.end();++it)
143 end=start+(*it)->size()-1;
144 (*it)->uniformRefine(numKnots,mul);
150template<
short_t d,
class T>
153 index_t start, end = -1, geoDim=coefs.cols(), totalLength = 0;
154 std::vector<gsMatrix<T> *> newCoefs;
155 for (BasisIter it=m_bases.begin();it!=m_bases.end();++it)
158 end=start+(*it)->size()-1;
161 *it_coef << coefs.block(start,0,end-start+1,geoDim);
162 (*it)->uniformRefine_withCoefs(*it_coef, numKnots,mul);
163 newCoefs.push_back(it_coef);
164 totalLength+=it_coef->rows();
166 coefs.resize(totalLength,geoDim);
168 for(ConstMatrixPtrIter it=newCoefs.begin();it!=newCoefs.end();++it)
171 end=start+(*it)->rows()-1;
172 coefs.block(start,0,end-start+1,geoDim)<<**it;
179template<
short_t d,
class T>
182 for (
size_t i = 0; i < nPatches(); ++i)
183 m_bases[i]->degreeElevate(amount);
188template<
short_t d,
class T>
191 for (
size_t i = 0; i < nPatches(); ++i)
192 m_bases[i]->degreeElevate(amount, dir);
197template<
short_t d,
class T>
200 std::vector<gsMatrix<T> *> coefs;
201 for (
size_t i = 0; i < nPatches(); ++i)
202 coefs.push_back(NULL);
203 repairPatches(coefs,startFromPatch);
206template<
short_t d,
class T>
210 bool special = isSpecialVertex(pc);
211 if( special && m_topol.getInterface(ps,interface) )
213 for(
unsigned i=0;i<m_distances.size();++i)
214 if(m_distances[i].isDistancesOfInterface(interface))
215 m_distances[i].setParamDist(m_minDist,pc,*
this);
221template<
short_t d,
class T>
224 std::vector<std::vector<patchCorner> >cornerLists;
225 std::vector<patchSide> psides;
226 m_topol.getEVs(cornerLists);
227 for(
unsigned i=0;i<cornerLists.size();++i)
228 for(
unsigned j=0;j<cornerLists[i].size();++j)
232 for(
unsigned k=0;k<psides.size();++k)
233 smoothCornerEdge(pc,psides[k],
false);
238template<
short_t d,
class T>
241 std::vector<gsMatrix<T> *> patchCoefs;
242 unsigned geoDim = localCoef.cols();
244 for (
size_t i = 0; i < nPatches(); ++i)
247 end+=m_bases[i]->size();
249 *localMat << localCoef.block(start,0,end-start+1,geoDim);
250 patchCoefs.push_back(localMat);
252 repairPatches(patchCoefs,startFromPatch);
253 unsigned totalSize=0;
254 for (
size_t i = 0; i < nPatches(); ++i)
256 totalSize+=m_bases[i]->size();
258 localCoef.resize(totalSize,geoDim);
260 for (
size_t i = 0; i < nPatches(); i++)
263 end+=m_bases[i]->size();
264 localCoef.block(start,0,end-start+1,geoDim) << *patchCoefs[i];
268template<
short_t d,
class T>
271 typedef typename std::vector<std::pair<patchSide,T> >::const_iterator cWeightPairIter;
272 for(cWeightPairIter it=m_patchSideWeights.begin();it!=m_patchSideWeights.end();++it)
278template<
short_t d,
class T>
281 typedef typename std::vector<std::pair<patchSide,T> >::iterator weightPairIter;
283 for(weightPairIter it=m_patchSideWeights.begin();it!=m_patchSideWeights.end();++it)
289 if(!found && m_topol.isInterface(ps))
291 m_patchSideWeights.push_back(std::make_pair(ps,weight));
297template<
short_t d,
class T>
301 std::vector<std::vector<patchCorner> > vertexLists;
302 m_topol.getEVs(vertexLists);
303 for(
unsigned i = 0;i<vertexLists.size();++i)
304 for(
unsigned j=0;j<vertexLists[i].size();++j)
305 m_vertices.push_back(std::make_pair(vertexLists[i][j],
true));
306 m_topol.getOVs(vertexLists);
307 for(
unsigned i = 0;i<vertexLists.size();++i)
308 for(
unsigned j=0;j<vertexLists[i].size();++j)
309 m_vertices.push_back(std::make_pair(vertexLists[i][j],
false));
312template<
short_t d,
class T>
316 for(std::vector<boundaryInterface>::const_iterator iter = m_topol.iBegin();
317 iter!=m_topol.iEnd();++iter)
328 m_distances.push_back(dist);
332template<
short_t d,
class T>
335 std::vector<patchCorner> vertexList;
336 m_topol.getCornerList(pc,vertexList);
337 for(
unsigned i = 0;i<vertexList.size();++i)
340 for(
unsigned j = 0;j<m_vertices.size();++j)
341 if(m_vertices[j].first==vertexList[i])
343 m_vertices[j].second=
true;
347 m_vertices.push_back(std::make_pair(vertexList[i],
true));
349 std::vector<patchSide> sides;
351 for(
unsigned i = 0;i<sides.size();++i)
354 if(m_topol.getInterface(sides[i],interface))
355 for(
unsigned j=0;j<m_distances.size();++j)
356 if(m_distances[j].isDistancesOfInterface(interface))
357 m_distances[j].setParamDist(m_minDist,pc,*
this);
361template<
short_t d,
class T>
364 typedef std::vector<std::pair<patchCorner,bool> >::const_iterator cvertices_iter;
365 for(cvertices_iter iter=m_vertices.begin(); iter!=m_vertices.end();++iter)
366 if(pc==(*iter).first)
371template<
short_t d,
class T>
376 bool special = isSpecialVertex(pc);
377 if( special && m_topol.getInterface(ps,interface) )
379 for(
unsigned i=0;i<m_distances.size();++i)
380 if(m_distances[i].isDistancesOfInterface(interface))
381 param = m_distances[i].getParamDist(pc,*
this);
384 param = findParameter(ps,pc,m_minDist);
388 const unsigned degree = std::min<index_t>(deg,m_incrSmoothnessDegree+1);
389 for(
unsigned i=0;i<m_vertices.size();++i)
390 if(pc==m_vertices[i].first)
391 param = findParameter(ps,pc,degree);
396template<
short_t d,
class T>
399 interface(iface),corner1(pc1),corner2(pc2)
402 const unsigned patch = ps.
patch;
403 const boxSide& side = ps.side();
404 const index_t deg=
basis.degree(patch,1-side.direction());
408 std::vector<patchSide> psides;
410 psides.erase(std::remove(psides.begin(), psides.end(), ps), psides.end());
413 psides.erase(std::remove(psides.begin(), psides.end(), ps), psides.end());
416 const unsigned degree = std::min<index_t>(deg,
basis.getIncrSmoothnessDegree()+1);
417 const index_t dist=std::max<index_t>(degree,
basis.getMinDist());
421 parametricDistance1=
basis.findParameter(interface.
first(),pc1,val1);
422 parametricDistance2=
basis.findParameter(interface.
first(),pc1,val2);
425template<
short_t d,
class T>
428 std::vector<patchCorner> cornerList;
429 basis.getTopol().getCornerList(corner1,cornerList);
430 if( std::find(cornerList.begin(), cornerList.end(), pc)!=cornerList.end() )
432 if(
basis.isSpecialVertex(pc))
434 if(corner1.patch==interface.first().patch)
435 parametricDistance1=
basis.findParameter(interface.first(),corner1,absoluteVal);
437 parametricDistance1=
basis.findParameter(interface.second(),corner1,absoluteVal);
442 basis.getTopol().getCornerList(corner2,cornerList);
443 if( std::find(cornerList.begin(), cornerList.end(), pc)!=cornerList.end() )
444 if(
basis.isSpecialVertex(pc))
446 if(corner2.patch==interface.first().patch)
447 parametricDistance2=
basis.findParameter(interface.first(),corner2,absoluteVal);
449 parametricDistance2=
basis.findParameter(interface.second(),corner2,absoluteVal);
454template<
short_t d,
class T>
458 std::vector<patchCorner> cornerList;
459 basis.getTopol().getCornerList(corner1,cornerList);
460 if( std::find(cornerList.begin(), cornerList.end(), pc)!=cornerList.end() )
461 param = parametricDistance1;
464 basis.getTopol().getCornerList(corner2,cornerList);
465 if( std::find(cornerList.begin(), cornerList.end(), pc)!=cornerList.end() )
466 param = parametricDistance2;
471template<
short_t d,
class T>
476 index_t dir = side.direction();
477 index_t par = side.parameter();
478 pars(dir) = par==0 ? false :
true;
483 bool leftSpecialVert =
basis.isSpecialVertex(pc1);
484 bool rightSpecialVert =
basis.isSpecialVertex(pc2);
485 bool leftInter =
basis.getTopol().isInterface(ls);
486 bool rightInter =
basis.getTopol().isInterface(rs);
487 unsigned leftDist = dist;
488 unsigned rightDist = dist;
489 if(leftSpecialVert&&rightSpecialVert)
491 if(leftDist+rightDist<=max)
502 else if(leftSpecialVert&&rightInter)
505 left=max-degree<leftDist?max-degree:leftDist;
507 else if(rightSpecialVert&&leftInter)
510 right=max-degree<rightDist?max-degree:rightDist;
512 else if(rightSpecialVert)
514 right=max<rightDist?max:rightDist;
517 else if(leftSpecialVert)
519 left=max<leftDist?max:leftDist;
Struct which represents a certain side of a box.
Definition gsBoundary.h:85
bool parameter() const
Returns the parameter value (false=0=start, true=1=end) that corresponds to this side.
Definition gsBoundary.h:128
short_t direction() const
Returns the parametric direction orthogonal to this side.
Definition gsBoundary.h:113
const gsBasis< T > & basis(const index_t k) const
Helper which casts and returns the k-th piece of this function set as a gsBasis.
Definition gsFunctionSet.hpp:33
Purely abstract class gsMappedBasis, which gives means of combining basis functions to new,...
Definition gsMPBESBasis.h:47
bool setWeight(const patchSide &ps, const T weight)
Definition gsMPBESBasis.hpp:279
void degreeIncrease(index_t amount=1, index_t dir=-1, bool updateBasis=true)
Definition gsMPBESBasis.hpp:189
void setC0(patchCorner pc)
Definition gsMPBESBasis.hpp:333
T getWeight(const patchSide &ps) const
Definition gsMPBESBasis.hpp:269
void uniformRefine_withCoefs(gsMatrix< T > &localCoefs, index_t numKnots=1, index_t mul=1, bool updateBasis=true)
Definition gsMPBESBasis.hpp:151
virtual void repairPatches(std::vector< gsMatrix< T > * > &coefs, index_t startFromPatch=-1)=0
void _setDistanceOfAllVertices()
initializes the m_distances field
Definition gsMPBESBasis.hpp:313
void _initVertices()
initializes the m_vertices field
Definition gsMPBESBasis.hpp:298
void uniformRefine(index_t numKnots=1, index_t mul=1, bool updateBasis=true)
Definition gsMPBESBasis.hpp:137
void smoothEverything()
Definition gsMPBESBasis.hpp:222
bool isSpecialVertex(const patchCorner &pc) const
gives back true, if the given patchCorner is a special vertex
Definition gsMPBESBasis.hpp:362
void smoothCornerEdge(const patchCorner &pc, const patchSide &ps, bool updateBasis=true)
Definition gsMPBESBasis.hpp:207
bool _check() const
Checks the gsMappedBasis for consistency.
Definition gsMPBESBasis.hpp:31
T getParametricDistanceOfVertex(const patchCorner &pc, const patchSide &ps) const
gives back the parametric c^0 distance of the edge ps starting from corner pc
Definition gsMPBESBasis.hpp:372
void degreeElevate(index_t amount=1, bool updateBasis=true)
Definition gsMPBESBasis.hpp:180
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Class Representing a triangle mesh with 3D vertices.
Definition gsMesh.h:32
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
#define index_t
Definition gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of Basis abstract interface.
The G+Smo namespace, containing all definitions for the library.
void freeAll(It begin, It end)
Frees all pointers in the range [begin end)
Definition gsMemory.h:312
Struct which represents an interface between two patches.
Definition gsBoundary.h:650
patchSide & first()
first, returns the first patchSide of this interface
Definition gsBoundary.h:776
patchSide & second()
second, returns the second patchSide of this interface
Definition gsBoundary.h:782
Private stract that has the purpose of storing distance information of c^0 parts around special verti...
Definition gsMPBESBasis.h:342
void _determineValues(patchSide side, patchSide ls, patchSide rs, index_t dist, unsigned degree, unsigned max, unsigned &left, unsigned &right, const gsMPBESBasis< d, T > &basis) const
determines the right values for the two distances, only used in the constructer
Definition gsMPBESBasis.hpp:472
T getParamDist(const patchCorner &pc, const gsMPBESBasis< d, T > &basis) const
gets the parametric distance from the corner pc
Definition gsMPBESBasis.hpp:455
void setParamDist(unsigned absoluteVal, const patchCorner &pc, const gsMPBESBasis< d, T > &basis)
Definition gsMPBESBasis.hpp:426
distances(const boundaryInterface &iface, const patchCorner &pc1, const patchCorner &pc2, const gsMPBESBasis< d, T > &basis)
Definition gsMPBESBasis.hpp:397
Struct which represents a certain corner of a patch.
Definition gsBoundary.h:393
void getContainingSides(short_t dim, std::vector< patchSide > &sides) const
returns a vector of patchSides that contain this corner
Definition gsBoundary.h:416
Struct which represents a certain side of a patch.
Definition gsBoundary.h:232
index_t patch
The index of the patch.
Definition gsBoundary.h:234