17 #include <gsUnstructuredSplines/src/gsMPBESUtils.h>
19 #define TO_INCRSMOOTHNESS(x) static_cast<gsMPBESBasis<d,T> *>(x)
24 template<
short_t d,
class T>
25 gsMPBESSpline<d,T>::gsMPBESSpline(
const gsMPBESBasis<d,T> & basis,
const gsMatrix<T> & coefs )
31 template<
short_t d,
class T>
32 gsMPBESSpline<d,T>::gsMPBESSpline( gsMultiPatch<T>
const & mp,
index_t incrSmoothness,
index_t minEVDistance ) : Base()
35 std::vector<gsMatrix<T> * > coefs;
36 for(
size_t i = 0;i<mp.nPatches();++i)
37 coefs.push_back(
new gsMatrix<T>(mp.patch(i).coefs()) );
38 m_mbases=getCompBasisFromMultiPatch_withCoefs<d>(mp,coefs,incrSmoothness,minEVDistance);
42 gsMatrix<T> localCoefs;
43 localCoefs.resize(m_mbases->localSize(),geoDim);
44 for(
size_t i = 0;i<mp.nPatches();i++)
47 end+=m_mbases->localSize(i);
48 localCoefs.block(start,0,end-start+1,geoDim) << *(coefs[i]);
50 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
54 template<
short_t d,
class T>
55 gsMPBESSpline<d,T>::gsMPBESSpline(gsMultiPatch<T>
const & mp,
56 std::vector<patchCorner> C0List,
62 std::vector<gsMatrix<T> * > coefs;
63 for(
size_t i = 0;i<mp.nPatches();++i)
64 coefs.push_back(
new gsMatrix<T>(mp.patch(i).coefs()) );
65 m_mbases=getCompBasisFromMultiPatch<d,T>(mp);
68 for(
unsigned i=0;i<C0List.size();i++)
70 TO_INCRSMOOTHNESS(m_mbases)->setC0(C0List[i]);
72 TO_INCRSMOOTHNESS(m_mbases)->updateTopol();
74 gsMatrix<T> localCoefs;
75 localCoefs.resize(m_mbases->localSize(),geoDim);
76 for(
size_t i = 0;i<mp.nPatches();i++)
79 end+=m_mbases->localSize(i);
80 localCoefs.block(start,0,end-start+1,geoDim) << *(coefs[i]);
82 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
85 template<
short_t d,
class T>
86 void gsMPBESSpline<d,T>::setCornerC0(patchCorner
const & pc)
88 gsMatrix<T> localCoefs;
89 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
90 TO_INCRSMOOTHNESS(m_mbases)->setC0(pc);
91 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
94 template<
short_t d,
class T>
95 void gsMPBESSpline<d,T>::smoothCornerEdge(
const patchCorner& pc,
const patchSide& ps,
bool updateBasis)
97 gsMatrix<T> localCoefs;
98 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
99 TO_INCRSMOOTHNESS(m_mbases)->smoothCornerEdge(pc,ps,updateBasis);
100 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
103 template<
short_t d,
class T>
104 void gsMPBESSpline<d,T>::smoothEverything()
106 gsMatrix<T> localCoefs;
107 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
108 TO_INCRSMOOTHNESS(m_mbases)->smoothEverything();
109 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
112 template<
short_t d,
class T>
113 void gsMPBESSpline<d,T>::uniformRefine(
index_t numKnots,
index_t mul)
115 gsMatrix<T> localCoefs;
116 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
117 TO_INCRSMOOTHNESS(m_mbases)->uniformRefine_withCoefs(localCoefs, numKnots,mul,
true);
118 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
121 template<
short_t d,
class T>
122 void gsMPBESSpline<d,T>::refine(
const index_t patch,
const gsMatrix<T> &boxes)
124 gsMatrix<T> localCoefs;
125 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
127 TO_INCRSMOOTHNESS(m_mbases)->refine_withCoefs(localCoefs, patch, boxes,
true);
129 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
133 template<
short_t d,
class T>
134 void gsMPBESSpline<d,T>::refineElements(
const index_t patch, std::vector<index_t>
const & boxes)
136 gsMatrix<T> localCoefs;
137 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
138 TO_INCRSMOOTHNESS(m_mbases)->refineElements_withCoefs(localCoefs, patch, boxes,
true);
139 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
142 template<
short_t d,
class T>
143 void gsMPBESSpline<d,T>::refineElements(std::vector<std::vector<index_t> >
const & boxes)
145 GISMO_ASSERT(boxes.size()==m_mbases->nPatches(),
"number of refinementvectors and number of patches must agree");
146 gsMatrix<T> localCoefs;
147 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
148 for(
unsigned i = 0;i<boxes.size();++i)
150 TO_INCRSMOOTHNESS(m_mbases)->refineElements_withCoefs(localCoefs, i, boxes[i],
false);
152 TO_INCRSMOOTHNESS(m_mbases)->repairPatches(localCoefs);
153 TO_INCRSMOOTHNESS(m_mbases)->updateTopol();
154 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
157 template<
short_t d,
class T>
158 void gsMPBESSpline<d,T>::uniformRefineAndSmooth(
index_t numKnots)
160 gsMatrix<T> localCoefs;
161 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
162 TO_INCRSMOOTHNESS(m_mbases)->uniformRefine_withCoefs(localCoefs, numKnots,
false);
163 TO_INCRSMOOTHNESS(m_mbases)->smoothEverything();
164 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
167 template<
short_t d,
class T>
168 void gsMPBESSpline<d,T>::refineAndSmooth(
const index_t patch,
const gsMatrix<T> &boxes)
170 gsMatrix<T> localCoefs;
171 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
172 TO_INCRSMOOTHNESS(m_mbases)->refine_withCoefs(localCoefs, patch,boxes,
false);
173 TO_INCRSMOOTHNESS(m_mbases)->smoothEverything();
174 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
177 template<
short_t d,
class T>
178 void gsMPBESSpline<d,T>::refineElementsAndSmooth(
const index_t patch, std::vector<index_t>
const & boxes)
180 gsMatrix<T> localCoefs;
181 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
182 TO_INCRSMOOTHNESS(m_mbases)->refineElements_withCoefs(localCoefs, patch,boxes,
false);
183 TO_INCRSMOOTHNESS(m_mbases)->smoothEverything();
184 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
189 #undef TO_INCRSMOOTHNESS
#define short_t
Definition: gsConfig.h:35
#define index_t
Definition: gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
void freeAll(It begin, It end)
Frees all pointers in the range [begin end)
Definition: gsMemory.h:312
Provides declaration of Basis abstract interface.
#define GISMO_ERROR(message)
Definition: gsDebug.h:118