bioprocessing 6.0.4
parameterizeddata.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1999-2001 CEA
3 *
4 * This software and supporting documentation were developed by
5 * CEA/DSV/SHFJ
6 * 4 place du General Leclerc
7 * 91401 Orsay cedex
8 * France
9 *
10 */
11
12#ifndef BIOPROCESSING_DATA_PARAMETERIZEDDATA_H
13#define BIOPROCESSING_DATA_PARAMETERIZEDDATA_H
14
15#include <cartobase/object/syntax.h> // SyntaxSet
16#include <soma-io/io/formatdictionary_d.h> // soma::FormatDictionary
17#include <aims/io/fileFormat.h> // aims::FileFormat, aims::FileFormatDictionary
18#include <cartodata/volume/volume.h>
19#include <string>
20#include <vector>
21
22
23namespace carto {
24 template <class DataType>
25 inline void toTypedVector(std::vector<carto::Object> src, std::vector<DataType> & dest) {
26 size_t i;
27
28 if (dest.capacity() < src.size())
29 dest.resize(src.size());
30
31 std::vector<carto::Object>::iterator it, ie = src.end();
32 for (it = src.begin(), i=0; it != ie; ++it, ++i) {
33 carto::object_to(*it, dest[i]);
34 }
35 }
36
37 template <class DataType>
38 inline std::vector<DataType> toTypedVector(std::vector<carto::Object> v) {
39 std::vector<DataType> n(v.size());
41
42 return n;
43 }
44
45 template <class DataType>
46 inline void toObjectVector(std::vector<DataType> src, std::vector<carto::Object> & dest) {
47 size_t i;
48
49 if (dest.capacity() < src.size())
50 dest.resize(src.size());
51
52 typename std::vector<DataType>::iterator it, ie = src.end();
53 for (it = src.begin(), i=0; it != ie; ++it, ++i) {
54 dest[i] = carto::Object::value(*it);
55 }
56 }
57
58
59 template <class DataType>
60 inline std::vector<carto::Object> toObjectVector(std::vector<DataType> v) {
61 std::vector<carto::Object> n(v.size());
63
64 return n;
65 }
66}
67
68// -----------------------------------------------------------------------------
69// ParameterizedHelper class
70// -----------------------------------------------------------------------------
71template <class DataType>
73
74 public :
75 static void setParameters(carto::VolumeRef<DataType> vol,
76 std::vector<std::string> & parameters);
77
78 static std::vector<std::string> getParameters(
79 carto::VolumeRef<DataType> vol);
80
81 static std::vector<int> getOriginalSizes(
82 carto::VolumeRef<DataType> vol);
83
84 static int indexOf(carto::VolumeRef<DataType> vol,
85 const std::string & parameter);
86
87
88 static DataType & valueOf(
89 carto::VolumeRef<DataType> vol,
90 const std::string & parameter,
91 int x = 0, int y = 0, int z = 0);
92};
93
94#endif
static std::vector< std::string > getParameters(carto::VolumeRef< DataType > vol)
static std::vector< int > getOriginalSizes(carto::VolumeRef< DataType > vol)
static void setParameters(carto::VolumeRef< DataType > vol, std::vector< std::string > &parameters)
static int indexOf(carto::VolumeRef< DataType > vol, const std::string &parameter)
static DataType & valueOf(carto::VolumeRef< DataType > vol, const std::string &parameter, int x=0, int y=0, int z=0)
void toTypedVector(std::vector< carto::Object > src, std::vector< DataType > &dest)
void toObjectVector(std::vector< DataType > src, std::vector< carto::Object > &dest)