17 #ifndef vtkToDax_Containers_h
18 #define vtkToDax_Containers_h
31 template<
typename VTKArrayType>
44 template<
typename CellType>
56 template <
typename DaxValueType,
typename VTKArrayType>
57 class ArrayContainerControl<DaxValueType,
vtkToDax::vtkArrayContainerTag<VTKArrayType> >
61 dax::VectorTraits<DaxValueType>::NUM_COMPONENTS>::VTKComponentType
70 static const int NUM_COMPONENTS = dax::VectorTraits<ValueType>::NUM_COMPONENTS;
84 this->ReleaseResources();
89 if (this->NumberOfValues > 0)
91 DAX_ASSERT_CONT(this->Array != NULL);
92 AllocatorType allocator;
93 allocator.
deallocate(this->Array, this->NumberOfValues);
95 this->NumberOfValues = 0;
99 DAX_ASSERT_CONT(this->Array == NULL);
105 if (this->NumberOfValues == numberOfValues)
return;
107 this->ReleaseResources();
110 if (numberOfValues > 0)
112 AllocatorType allocator;
113 this->Array = allocator.
allocate(numberOfValues);
114 this->NumberOfValues = numberOfValues;
119 DAX_ASSERT_CONT(this->NumberOfValues == 0);
122 catch (
const std::bad_alloc&)
126 this->NumberOfValues = 0;
127 throw dax::cont::ErrorControlOutOfMemory(
128 "Could not allocate basic control array.");
134 return this->NumberOfValues;
139 if (numberOfValues > this->GetNumberOfValues())
141 throw dax::cont::ErrorControlBadValue(
142 "Shrink method cannot be used to grow array.");
145 this->NumberOfValues = numberOfValues;
150 return PortalType(this->Array, this->NumberOfValues);
155 return PortalConstType(this->Array, this->NumberOfValues);
159 ArrayContainerControl(
const ArrayContainerControl<ValueType, vtkToDax::vtkPointsContainerTag> &src) VTK_DELETE_FUNCTION;
160 void operator=(
const ArrayContainerControl<ValueType, vtkToDax::vtkPointsContainerTag> &src) VTK_DELETE_FUNCTION;
163 dax::Id NumberOfValues;
166 template <
typename ValueT>
167 class ArrayContainerControl<ValueT,
vtkToDax::vtkPointsContainerTag>
187 this->ReleaseResources();
192 if (this->NumberOfValues > 0)
194 DAX_ASSERT_CONT(this->Array != NULL);
195 AllocatorType allocator;
196 allocator.
deallocate(this->Array, this->NumberOfValues);
198 this->NumberOfValues = 0;
202 DAX_ASSERT_CONT(this->Array == NULL);
208 if (this->NumberOfValues == numberOfValues)
return;
210 this->ReleaseResources();
213 if (numberOfValues > 0)
215 AllocatorType allocator;
216 this->Array = allocator.
allocate(numberOfValues);
217 this->NumberOfValues = numberOfValues;
222 DAX_ASSERT_CONT(this->NumberOfValues == 0);
225 catch (
const std::bad_alloc&)
229 this->NumberOfValues = 0;
230 throw dax::cont::ErrorControlOutOfMemory(
231 "Could not allocate basic control array.");
237 return this->NumberOfValues;
242 if (numberOfValues > this->GetNumberOfValues())
244 throw dax::cont::ErrorControlBadValue(
245 "Shrink method cannot be used to grow array.");
248 this->NumberOfValues = numberOfValues;
253 return PortalType(this->Array, this->NumberOfValues);
258 return PortalConstType(this->Array, this->NumberOfValues);
262 ArrayContainerControl(
const ArrayContainerControl<ValueType, vtkToDax::vtkPointsContainerTag> &src) VTK_DELETE_FUNCTION;
263 void operator=(
const ArrayContainerControl<ValueType, vtkToDax::vtkPointsContainerTag> &src) VTK_DELETE_FUNCTION;
266 dax::Id NumberOfValues;
269 template <
typename ValueT,
typename CellType>
270 class ArrayContainerControl<ValueT,
vtkToDax::vtkTopologyContainerTag<CellType> >
289 this->ReleaseResources();
294 if (this->NumberOfValues > 0)
296 DAX_ASSERT_CONT(this->Array != NULL);
297 AllocatorType allocator;
298 allocator.
deallocate(this->Array, this->NumberOfValues);
300 this->NumberOfValues = 0;
304 DAX_ASSERT_CONT(this->Array == NULL);
310 if (this->NumberOfValues == numberOfValues)
return;
312 this->ReleaseResources();
315 if (numberOfValues > 0)
317 AllocatorType allocator;
318 this->Array = allocator.
allocate(numberOfValues);
319 this->NumberOfValues = numberOfValues;
324 DAX_ASSERT_CONT(this->NumberOfValues == 0);
327 catch (
const std::bad_alloc&)
331 this->NumberOfValues = 0;
332 throw dax::cont::ErrorControlOutOfMemory(
333 "Could not allocate basic control array.");
339 return this->NumberOfValues;
344 if (numberOfValues > this->GetNumberOfValues())
346 throw dax::cont::ErrorControlBadValue(
347 "Shrink method cannot be used to grow array.");
350 this->NumberOfValues = numberOfValues;
355 return PortalType(this->Array, this->NumberOfValues);
360 return PortalConstType(this->Array, this->NumberOfValues);
364 ArrayContainerControl(
const ArrayContainerControl<ValueType, vtkToDax::vtkPointsContainerTag> &src) VTK_DELETE_FUNCTION;
365 void operator=(
const ArrayContainerControl<ValueType, vtkToDax::vtkPointsContainerTag> &src) VTK_DELETE_FUNCTION;
368 dax::Id NumberOfValues;
375 #endif //vtkToDax_CONTAINERS_H
void deallocate(self::pointer p, self::size_type)
void Shrink(dax::Id numberOfValues)
pointer allocate(size_type n, self::const_pointer hint=0)
PortalConstType GetPortalConst() const
void Allocate(dax::Id numberOfValues)
void Shrink(dax::Id numberOfValues)
void Allocate(dax::Id numberOfValues)
vtkToDax::vtkTopologyPortal< const ValueType, CellType::NUM_POINTS > PortalConstType
vtkToDax::vtkArrayPortal< DaxValueType, VTKComponentType > PortalType
PortalConstType GetPortalConst() const
void Allocate(dax::Id numberOfValues)
void Shrink(dax::Id numberOfValues)
vtkToDax::vtkArrayPortal< const DaxValueType, const VTKComponentType > PortalConstType
dax::Id GetNumberOfValues() const
PortalConstType GetPortalConst() const
dax::Id GetNumberOfValues() const
vtkToDax::vtkTopologyPortal< ValueType, CellType::NUM_POINTS > PortalType
dax::Id GetNumberOfValues() const
vtkToDax::vtkPointsPortal< const ValueType > PortalConstType
vtkToDax::vtkPointsPortal< ValueType > PortalType