return new DataArrayInt32(*this);
}
-void DataArrayInt::writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const
-{
- static const char SPACE[4]={' ',' ',' ',' '};
- checkAllocated();
- std::string idt(indent,' ');
- ofs << idt << "<DataArray type=\"" << type << "\" Name=\"" << nameInFile << "\" NumberOfComponents=\"" << getNumberOfComponents() << "\"";
- if(byteArr)
- {
- ofs << " format=\"appended\" offset=\"" << byteArr->getNumberOfTuples() << "\">";
- if(std::string(type)=="Int32")
- {
- const char *data(reinterpret_cast<const char *>(begin()));
- std::size_t sz(getNbOfElems()*sizeof(int));
- byteArr->insertAtTheEnd(data,data+sz);
- byteArr->insertAtTheEnd(SPACE,SPACE+4);
- }
- else if(std::string(type)=="Int8")
- {
- INTERP_KERNEL::AutoPtr<char> tmp(new char[getNbOfElems()]);
- std::copy(begin(),end(),(char *)tmp);
- byteArr->insertAtTheEnd((char *)tmp,(char *)tmp+getNbOfElems());
- byteArr->insertAtTheEnd(SPACE,SPACE+4);
- }
- else if(std::string(type)=="UInt8")
- {
- INTERP_KERNEL::AutoPtr<unsigned char> tmp(new unsigned char[getNbOfElems()]);
- std::copy(begin(),end(),(unsigned char *)tmp);
- byteArr->insertAtTheEnd((unsigned char *)tmp,(unsigned char *)tmp+getNbOfElems());
- byteArr->insertAtTheEnd(SPACE,SPACE+4);
- }
- else
- throw INTERP_KERNEL::Exception("DataArrayInt::writeVTK : Only Int32, Int8 and UInt8 supported !");
- }
- else
- {
- ofs << " RangeMin=\"" << getMinValueInArray() << "\" RangeMax=\"" << getMaxValueInArray() << "\" format=\"ascii\">\n" << idt;
- std::copy(begin(),end(),std::ostream_iterator<int>(ofs," "));
- }
- ofs << std::endl << idt << "</DataArray>\n";
-}
-
/*!
* Computes distribution of values of \a this one-dimensional array between given value
* ranges (casts). This method is typically useful for entity number splitting by types,
MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
+ MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const;
protected:
template<class ALG>
void switchOnTupleAlg(T val, std::vector<bool>& vec, ALG algo) const;
MEDCOUPLING_EXPORT int intValue() const;
MEDCOUPLING_EXPORT DataArrayInt32 *deepCopy() const;//ok
MEDCOUPLING_EXPORT DataArrayInt32 *buildNewEmptyInstance() const { return DataArrayInt32::New(); }//ok
- MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const;
MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArrBg, const int *indArrEnd);
MEDCOUPLING_EXPORT void transformWithIndArr(const MapKeyVal<int>& m);
MEDCOUPLING_EXPORT DataArrayInt32 *transformWithIndArrR(const int *indArr2Bg, const int *indArrEnd) const;
stream << "]";
}
+ template<class T>
+ void DataArrayDiscrete<T>::writeVTK(std::ostream& ofs, int indent, const std::string& type, const std::string& nameInFile, DataArrayByte *byteArr) const
+ {
+ static const char SPACE[4]={' ',' ',' ',' '};
+ DataArrayTemplate<T>::checkAllocated();
+ std::string idt(indent,' ');
+ ofs << idt << "<DataArray type=\"" << type << "\" Name=\"" << nameInFile << "\" NumberOfComponents=\"" << DataArrayTemplate<T>::getNumberOfComponents() << "\"";
+ if(byteArr)
+ {
+ ofs << " format=\"appended\" offset=\"" << byteArr->getNumberOfTuples() << "\">";
+ if(std::string(type)==Traits<T>::VTKReprStr)
+ {
+ const char *data(reinterpret_cast<const char *>(DataArrayTemplate<T>::begin()));
+ std::size_t sz(DataArrayTemplate<T>::getNbOfElems()*sizeof(T));
+ byteArr->insertAtTheEnd(data,data+sz);
+ byteArr->insertAtTheEnd(SPACE,SPACE+4);
+ }
+ else if(std::string(type)=="Int8")
+ {
+ INTERP_KERNEL::AutoPtr<char> tmp(new char[DataArrayTemplate<T>::getNbOfElems()]);
+ std::copy(DataArrayTemplate<T>::begin(),DataArrayTemplate<T>::end(),(char *)tmp);
+ byteArr->insertAtTheEnd((char *)tmp,(char *)tmp+DataArrayTemplate<T>::getNbOfElems());
+ byteArr->insertAtTheEnd(SPACE,SPACE+4);
+ }
+ else if(std::string(type)=="UInt8")
+ {
+ INTERP_KERNEL::AutoPtr<unsigned char> tmp(new unsigned char[DataArrayTemplate<T>::getNbOfElems()]);
+ std::copy(DataArrayTemplate<T>::begin(),DataArrayTemplate<T>::end(),(unsigned char *)tmp);
+ byteArr->insertAtTheEnd((unsigned char *)tmp,(unsigned char *)tmp+DataArrayTemplate<T>::getNbOfElems());
+ byteArr->insertAtTheEnd(SPACE,SPACE+4);
+ }
+ else
+ {
+ std::ostringstream oss;
+ oss << Traits<T>::ArrayTypeName << "::writeVTK : Only " << Traits<T>::VTKReprStr << ", Int8 and UInt8 supported !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ }
+ else
+ {
+ ofs << " RangeMin=\"" << DataArrayTemplate<T>::getMinValueInArray() << "\" RangeMax=\"" << DataArrayTemplate<T>::getMaxValueInArray() << "\" format=\"ascii\">\n" << idt;
+ std::copy(DataArrayTemplate<T>::begin(),DataArrayTemplate<T>::end(),std::ostream_iterator<int>(ofs," "));
+ }
+ ofs << std::endl << idt << "</DataArray>\n";
+ }
+
////////////////////////////////////
/*!
const char Traits<int>::ReprStr[]="int";
+const char Traits<int>::VTKReprStr[]="Int32";
+
const char Traits<char>::ArrayTypeName[]="DataArrayChar";
const char Traits<Int64>::ArrayTypeName[]="DataArrayInt64";
const char Traits<Int64>::NPYStr[]="INT64";
const char Traits<Int64>::ReprStr[]="int64";
+
+const char Traits<Int64>::VTKReprStr[]="Int64";
static const char FieldTypeName[];
static const char NPYStr[];
static const char ReprStr[];
+ static const char VTKReprStr[];
typedef DataArrayInt32 ArrayType;
typedef DataArrayInt32 ArrayTypeCh;
typedef MEDCouplingFieldInt FieldType;
static const char FieldTypeName[];
static const char NPYStr[];
static const char ReprStr[];
+ static const char VTKReprStr[];
typedef DataArrayInt64 ArrayType;
typedef DataArrayInt64 ArrayTypeCh;
//typedef MEDCouplingFieldInt64 FieldType;