29 #ifndef SCIRUN_CORE_DATATYPES_BUNDLE_H
30 #define SCIRUN_CORE_DATATYPES_BUNDLE_H 1
49 virtual Bundle* clone()
const;
57 bool isField(
const std::string& name)
const;
58 FieldHandle getField(
const std::string& name)
const;
59 size_t numFields()
const;
60 std::vector<FieldHandle> getFields()
const;
61 std::vector<std::string> getFieldNames()
const;
63 bool isMatrix(
const std::string& name)
const;
65 size_t numMatrices()
const;
66 std::vector<MatrixHandle> getMatrices()
const;
67 std::vector<std::string> getMatrixNames()
const;
69 bool isString(
const std::string& name)
const;
71 size_t numStrings()
const;
72 std::vector<StringHandle> getStrings()
const;
73 std::vector<std::string> getStringNames()
const;
75 bool remove(
const std::string&
name);
77 #ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
84 void merge(SCIRun::LockingHandle<Bundle> C);
87 void transposeNrrd(
bool on);
99 std::string getFieldName(
int index)
100 {
return(getName<Field>(index)); }
112 std::string getMatrixName(
int index);
115 LockingHandle<NrrdData> getNrrd(
const std::string& name);
118 void setNrrd(
const std::string& name, LockingHandle<NrrdData> &nrrd)
119 { set<NrrdData>(
name,nrrd); }
121 void remNrrd(
const std::string& name)
124 bool isNrrd(
const std::string& name);
130 std::string getNrrdName(
int index);
143 LockingHandle<ColorMap> getColorMap(
const std::string& name)
144 {
return(get<ColorMap>(name)); }
146 void setColorMap(
const std::string& name, LockingHandle<ColorMap> &colormap)
147 { set<ColorMap>(
name,colormap); }
149 void remColorMap(
const std::string& name)
152 bool isColorMap(
const std::string& name)
153 {
return(is<ColorMap>(name)); }
156 {
return(num<ColorMap>()); }
158 std::string getColorMapName(
int index)
159 {
return(getName<ColorMap>(index)); }
171 LockingHandle<Bundle> getBundle(
const std::string& name)
172 {
return(get<Bundle>(name)); }
174 void setBundle(
const std::string& name, LockingHandle<Bundle> &bundle)
175 { set<Bundle>(
name,bundle); }
177 void remBundle(
const std::string& name)
180 bool isBundle(
const std::string& name)
181 {
return(is<Bundle>(name)); }
184 {
return(num<Bundle>()); }
186 std::string getBundleName(
int index)
187 {
return(getName<Bundle>(index)); }
190 std::string getHandleName(
int index)
191 {
return bundleName_[
static_cast<size_t>(index)]; }
194 LockingHandle<PropertyManager> gethandle(
int index)
195 {
return bundle_[
static_cast<size_t>(index)]; }
198 std::string getHandleType(
int index);
200 virtual std::string dynamic_type_name()
const {
return type_id.type; }
205 template<
class PTYPE>
216 std::map<std::string, Core::Datatypes::DatatypeHandle>
bundle_;
221 #ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
222 inline void Bundle::transposeNrrd(
bool transpose)
224 transposeNrrd_ = transpose;
229 template<
class T>
inline std::string Bundle::getName(
int index)
233 for (p=0;p<bundleName_.size();p++)
235 if (SCI_DATATYPE_CAST<T*>(
bundle_[p].get_rep()) != 0) cnt++;
236 if (index == cnt)
break;
238 if ((p < bundleName_.size())&&(cnt==index))
return bundleName_[p];
239 return(std::string(
""));
242 template<
class PTYPE>
inline bool Bundle::NrrdToMatrixHelper(
245 if (dataH->nrrd_->dim == 1)
247 int cols = dataH->nrrd_->axis[0].size;
251 PTYPE *val =
reinterpret_cast<PTYPE*
>(dataH->nrrd_->data);
252 double *
data = matrix->get_data_pointer();
254 for(
int c=0; c<cols; c++)
264 if (dataH->nrrd_->dim == 2)
268 int rows = dataH->nrrd_->axis[1].size;
269 int cols = dataH->nrrd_->axis[0].size;
273 PTYPE *val =
reinterpret_cast<PTYPE*
>(dataH->nrrd_->data);
274 double *data = matrix->get_data_pointer();
278 for(
int r=0; r<rows; r++)
280 for(
int c=0; c<cols; c++)
290 int cols = dataH->nrrd_->axis[1].size;
291 int rows = dataH->nrrd_->axis[0].size;
295 PTYPE *val =
reinterpret_cast<PTYPE*
>(dataH->nrrd_->data);
296 double *data = matrix->get_data_pointer();
298 for(
int c=0; c<cols; c++)
300 for(
int r=0; r<rows; r++)
boost::shared_ptr< Matrix > MatrixHandle
Definition: MatrixFwd.h:44
Eigen::MatrixXd DenseMatrix
Definition: EigenDenseMatrixTests.cc:33
Definition: Persistent.h:89
#define SCISHARE
Definition: share.h:39
boost::shared_ptr< Bundle > BundleHandle
Definition: Bundle.h:219
Definition: Datatype.h:41
ColumnMatrixGeneric< double > ColumnMatrix
Definition: MatrixFwd.h:48
const char * name[]
Definition: BoostGraphExampleTests.cc:87
boost::shared_ptr< String > StringHandle
Definition: DatatypeFwd.h:58
dictionary data
Definition: eabLatVolData.py:11
LockingHandle< NrrdData > NrrdDataHandle
Definition: NrrdData.h:108
DenseMatrixGeneric< double > DenseMatrix
Definition: MatrixFwd.h:48
boost::shared_ptr< Field > FieldHandle
Definition: DatatypeFwd.h:65
Definition: Persistent.h:64
boost::shared_ptr< Datatype > DatatypeHandle
Definition: DatatypeFwd.h:44
int size
Definition: eabLatVolData.py:2
std::map< std::string, Core::Datatypes::DatatypeHandle > bundle_
Definition: Bundle.h:216