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
72 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);
104 m_funcs.swap( other.m_funcs );
115 m_funcs.push_back( func.
clone().release() );
120 m_funcs.push_back( 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;
uPtr clone()
Clone methode. Produceds a deep copy inside a uPtr.
A function from a n-dimensional domain to an m-dimensional image.
Definition gsFunction.h:60
memory::unique_ptr< gsFunction > uPtr
Unique pointer for gsFunction.
Definition gsFunction.h:68
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
A function depending on an index i, typically referring to a patch/sub-domain. On each patch a differ...
Definition gsPiecewiseFunction.h:29
memory::shared_ptr< gsPiecewiseFunction > Ptr
Shared pointer for gsPiecewiseFunction.
Definition gsPiecewiseFunction.h:37
void swap(gsPiecewiseFunction &other)
Swap with another gsPiecewiseFunction.
Definition gsPiecewiseFunction.h:102
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
memory::unique_ptr< gsPiecewiseFunction > uPtr
Unique pointer for gsPiecewiseFunction.
Definition gsPiecewiseFunction.h:40
index_t size() const
size
Definition gsPiecewiseFunction.h:134
void addPiece(const gsFunction< T > &func)
Add a piece.
Definition gsPiecewiseFunction.h:113
index_t nPieces() const
Number of pieces in the domain of definition.
Definition gsPiecewiseFunction.h:157
short_t domainDim() const
Dimension of the (source) domain.
Definition gsPiecewiseFunction.h:109
void clear()
Clear (delete) all functions.
Definition gsPiecewiseFunction.h:148
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
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
#define index_t
Definition gsConfig.h:32
#define GISMO_NO_IMPLEMENTATION
Definition gsDebug.h:129
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
The G+Smo namespace, containing all definitions for the library.
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
S give(S &x)
Definition gsMemory.h:266
void freeAll(It begin, It end)
Frees all pointers in the range [begin end)
Definition gsMemory.h:312