32 typedef typename std::vector<gsFunction<T>*> FunctionContainer;
33 typedef typename FunctionContainer::iterator fiterator;
34 typedef typename FunctionContainer::const_iterator const_fiterator;
37 typedef memory::shared_ptr< gsPiecewiseFunction >
Ptr;
40 typedef memory::unique_ptr< gsPiecewiseFunction >
uPtr;
45 { m_funcs.reserve(2+npieces); }
49 m_funcs.push_back(func.
clone().release());
53 gsPiecewiseFunction(
const gsPiecewiseFunction & other) : Base()
55 m_funcs.resize(other.m_funcs.size() );
56 cloneAll( other.m_funcs.begin(), other.m_funcs.end(),
60 gsPiecewiseFunction(FunctionContainer & funcs) : Base()
65 ~gsPiecewiseFunction()
70 #if EIGEN_HAS_RVALUE_REFERENCES
71 gsPiecewiseFunction(gsPiecewiseFunction&& other)
73 : m_funcs(
give(other.m_funcs)) {}
76 gsPiecewiseFunction&
operator= (
const gsPiecewiseFunction& other )
79 m_funcs.resize(other.m_funcs.size() );
80 cloneAll( other.m_funcs.begin(), other.m_funcs.end(),
86 gsPiecewiseFunction&
operator= ( gsPiecewiseFunction&& other )
89 m_funcs =
give(other.m_funcs);
93 gsPiecewiseFunction &
operator= ( gsPiecewiseFunction other )
104 m_funcs.swap( other.m_funcs );
115 m_funcs.push_back( func.
clone().release() );
120 m_funcs.push_back( func );
123 void addPiecePointer(
typename gsFunction<T>::uPtr func)
125 m_funcs.push_back(func.release());
130 GISMO_ASSERT(static_cast<size_t>(i) < m_funcs.size(),
"Wrong piece index");
136 std::ostream &
print(std::ostream &os)
const
138 os <<
"Piecewise Function with "<<m_funcs.size() <<
" pieces.\n";
144 return pwf.
print(os);
162 FunctionContainer m_funcs;
void addPiece(const gsFunction< T > &func)
Add a piece.
Definition: gsPiecewiseFunction.h:113
memory::unique_ptr< gsPiecewiseFunction > uPtr
Unique pointer for gsPiecewiseFunction.
Definition: gsPiecewiseFunction.h:40
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
void eval_into(const gsMatrix< T > &, gsMatrix< T > &) const
Evaluate the function at points u into result.
Definition: gsPiecewiseFunction.h:154
#define short_t
Definition: gsConfig.h:35
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsPiecewiseFunction.h:136
const gsFunction< T > & piece(const index_t i) const
Returns the piece(s) of the function(s) at subdomain k.
Definition: gsPiecewiseFunction.h:128
S give(S &x)
Definition: gsMemory.h:266
#define index_t
Definition: gsConfig.h:32
A function from a n-dimensional domain to an m-dimensional image.
Definition: gsFunction.h:59
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
void cloneAll(It start, It end, ItOut out)
Clones all pointers in the range [start end) and stores new raw pointers in iterator out...
Definition: gsMemory.h:295
short_t domainDim() const
Dimension of the (source) domain.
Definition: gsPiecewiseFunction.h:109
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
void freeAll(It begin, It end)
Frees all pointers in the range [begin end)
Definition: gsMemory.h:312
uPtr clone()
Clone methode. Produceds a deep copy inside a uPtr.
void clear()
Clear (delete) all functions.
Definition: gsPiecewiseFunction.h:148
index_t nPieces() const
Number of pieces in the domain of definition.
Definition: gsPiecewiseFunction.h:157
void swap(gsPiecewiseFunction &other)
Swap with another gsPiecewiseFunction.
Definition: gsPiecewiseFunction.h:102
A function depending on an index i, typically referring to a patch/sub-domain. On each patch a differ...
Definition: gsPiecewiseFunction.h:28
memory::shared_ptr< gsPiecewiseFunction > Ptr
Shared pointer for gsPiecewiseFunction.
Definition: gsPiecewiseFunction.h:37
index_t size() const
size
Definition: gsPiecewiseFunction.h:134
gsPiecewiseFunction & operator=(gsPiecewiseFunction other)
Assignment operator (uses copy-and-swap idiom)
Definition: gsPiecewiseFunction.h:94
short_t targetDim() const
Dimension of the target space.
Definition: gsPiecewiseFunction.h:110