26 |
DataTagged::DataTagged() |
DataTagged::DataTagged() |
27 |
: DataAbstract(FunctionSpace()) |
: DataAbstract(FunctionSpace()) |
28 |
{ |
{ |
29 |
|
// default constructor |
30 |
|
|
31 |
// create a scalar default value |
// create a scalar default value |
32 |
m_data.resize(1,0.,1); |
m_data.resize(1,0.,1); |
33 |
DataArrayView temp(m_data,DataArrayView::ShapeType()); |
DataArrayView temp(m_data,DataArrayView::ShapeType()); |
40 |
const FunctionSpace& what) |
const FunctionSpace& what) |
41 |
: DataAbstract(what) |
: DataAbstract(what) |
42 |
{ |
{ |
43 |
|
// constructor |
44 |
|
|
45 |
// initialise the array of data values |
// initialise the array of data values |
46 |
// the default value is always the first item in the values list |
// the default value is always the first item in the values list |
47 |
int len = defaultValue.noValues(); |
int len = defaultValue.noValues(); |
64 |
const ValueType& data) |
const ValueType& data) |
65 |
: DataAbstract(what) |
: DataAbstract(what) |
66 |
{ |
{ |
67 |
|
// alternative constructor |
68 |
|
// not unit_tested tested yet |
69 |
|
|
70 |
// copy the data |
// copy the data |
71 |
m_data=data; |
m_data=data; |
72 |
|
|
85 |
m_data(other.m_data), |
m_data(other.m_data), |
86 |
m_offsetLookup(other.m_offsetLookup) |
m_offsetLookup(other.m_offsetLookup) |
87 |
{ |
{ |
88 |
|
// copy constructor |
89 |
|
|
90 |
// create the data view |
// create the data view |
91 |
DataArrayView temp(m_data,other.getPointDataView().getShape()); |
DataArrayView temp(m_data,other.getPointDataView().getShape()); |
92 |
setPointDataView(temp); |
setPointDataView(temp); |
95 |
DataTagged::DataTagged(const DataConstant& other) |
DataTagged::DataTagged(const DataConstant& other) |
96 |
: DataAbstract(other.getFunctionSpace()) |
: DataAbstract(other.getFunctionSpace()) |
97 |
{ |
{ |
98 |
|
// copy constructor |
99 |
|
|
100 |
// fill the default value with the constant value item from "other" |
// fill the default value with the constant value item from "other" |
101 |
const DataArrayView& value=other.getPointDataView(); |
const DataArrayView& value=other.getPointDataView(); |
102 |
int len = value.noValues(); |
int len = value.noValues(); |
114 |
const DataArrayView::RegionType& region) |
const DataArrayView::RegionType& region) |
115 |
: DataAbstract(other.getFunctionSpace()) |
: DataAbstract(other.getFunctionSpace()) |
116 |
{ |
{ |
117 |
|
// slice constructor |
118 |
|
|
119 |
// get the shape of the slice to copy from other |
// get the shape of the slice to copy from other |
120 |
DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region)); |
DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region)); |
121 |
DataArrayView::RegionLoopRangeType region_loop_range=getSliceRegionLoopRange(region); |
DataArrayView::RegionLoopRangeType region_loop_range=getSliceRegionLoopRange(region); |
236 |
} |
} |
237 |
|
|
238 |
void |
void |
239 |
|
DataTagged::setTaggedValues(const TagListType& tagKeys, |
240 |
|
const ValueListType& values) |
241 |
|
{ |
242 |
|
addTaggedValues(tagKeys,values); |
243 |
|
} |
244 |
|
|
245 |
|
void |
246 |
DataTagged::setTaggedValue(int tagKey, |
DataTagged::setTaggedValue(int tagKey, |
247 |
const DataArrayView& value) |
const DataArrayView& value) |
248 |
{ |
{ |
264 |
} |
} |
265 |
|
|
266 |
void |
void |
267 |
|
DataTagged::addTaggedValues(const TagListType& tagKeys, |
268 |
|
const ValueListType& values) |
269 |
|
{ |
270 |
|
if (values.size()==0) { |
271 |
|
// copy the current default value for each of the tags |
272 |
|
TagListType::const_iterator iT; |
273 |
|
for (iT=tagKeys.begin();iT!=tagKeys.end();iT++) { |
274 |
|
// the point data view for DataTagged points at the default value |
275 |
|
addTaggedValue(*iT,getPointDataView()); |
276 |
|
} |
277 |
|
} else if (values.size()==1 && tagKeys.size()>1) { |
278 |
|
// assume the one given value will be used for all tag values |
279 |
|
TagListType::const_iterator iT; |
280 |
|
for (iT=tagKeys.begin();iT!=tagKeys.end();iT++) { |
281 |
|
addTaggedValue(*iT,values[0]); |
282 |
|
} |
283 |
|
} else { |
284 |
|
if (tagKeys.size()!=values.size()) { |
285 |
|
stringstream temp; |
286 |
|
temp << "Error - (addTaggedValue) Number of tags: " << tagKeys.size() |
287 |
|
<< " doesn't match number of values: " << values.size(); |
288 |
|
throw DataException(temp.str()); |
289 |
|
} else { |
290 |
|
for (int i=0;i<tagKeys.size();i++) { |
291 |
|
addTaggedValue(tagKeys[i],values[i]); |
292 |
|
} |
293 |
|
} |
294 |
|
} |
295 |
|
} |
296 |
|
|
297 |
|
void |
298 |
DataTagged::addTaggedValue(int tagKey, |
DataTagged::addTaggedValue(int tagKey, |
299 |
const DataArrayView& value) |
const DataArrayView& value) |
300 |
{ |
{ |
324 |
} |
} |
325 |
} |
} |
326 |
} |
} |
|
|
|
|
void |
|
|
DataTagged::setTaggedValues(const TagListType& tagKeys, |
|
|
const ValueListType& values) |
|
|
{ |
|
|
addTaggedValues(tagKeys,values); |
|
|
} |
|
|
|
|
|
void |
|
|
DataTagged::addTaggedValues(const TagListType& tagKeys, |
|
|
const ValueListType& values) |
|
|
{ |
|
|
if (values.size()==0) { |
|
|
// copy the default value for each of the tags |
|
|
TagListType::const_iterator iT; |
|
|
for (iT=tagKeys.begin();iT!=tagKeys.end();iT++) { |
|
|
// the point data view for DataTagged points at the default value |
|
|
addTaggedValue(*iT,getPointDataView()); |
|
|
} |
|
|
} else if (values.size()==1 && tagKeys.size()>1) { |
|
|
// assume the one value will be used for all tag values |
|
|
TagListType::const_iterator iT; |
|
|
for (iT=tagKeys.begin();iT!=tagKeys.end();iT++) { |
|
|
addTaggedValue(*iT,values[0]); |
|
|
} |
|
|
} else { |
|
|
if (tagKeys.size()!=values.size()) { |
|
|
stringstream temp; |
|
|
temp << "Error - (addTaggedValue) Number of tags: " << tagKeys.size() |
|
|
<< " doesn't match the number of values: " << values.size(); |
|
|
throw DataException(temp.str()); |
|
|
} else { |
|
|
for (int i=0;i<tagKeys.size();i++) { |
|
|
addTaggedValue(tagKeys[i],values[i]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
327 |
|
|
328 |
double* |
double* |
329 |
DataTagged::getSampleDataByTag(int tag) |
DataTagged::getSampleDataByTag(int tag) |