return const_cast<DataArrayInt *>(pfl);
}
-void MEDCoupling1GTUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception)
+void MEDCoupling1GTUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=buildUnstructured();
- m->writeVTKLL(ofs,cellData,pointData);
+ m->writeVTKLL(ofs,cellData,pointData,byteData);
}
std::string MEDCoupling1GTUMesh::getVTKDataSetType() const throw(INTERP_KERNEL::Exception)
MEDCOUPLING_EXPORT std::vector<int> getDistributionOfTypes() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT std::string getVTKDataSetType() const throw(INTERP_KERNEL::Exception);
//
MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
setTime(tinyInfoD[0],tinyInfo[3],tinyInfo[4]);
}
-void MEDCouplingCMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingCMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const throw(INTERP_KERNEL::Exception)
{
std::ostringstream extent;
DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array};
for(int i=0;i<3;i++)
{
if(thisArr[i])
- thisArr[i]->writeVTK(ofs,8,"Array");
+ thisArr[i]->writeVTK(ofs,8,"Array",byteData);
else
{
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coo=DataArrayDouble::New(); coo->alloc(1,1);
coo->setIJ(0,0,0.);
- coo->writeVTK(ofs,8,"Array");
+ coo->writeVTK(ofs,8,"Array",byteData);
}
}
ofs << " </Coordinates>\n";
MEDCouplingCMesh();
MEDCouplingCMesh(const MEDCouplingCMesh& other, bool deepCpy);
~MEDCouplingCMesh();
- void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception);
+ void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const throw(INTERP_KERNEL::Exception);
std::string getVTKDataSetType() const throw(INTERP_KERNEL::Exception);
private:
DataArrayDouble *_x_array;
}
}
-void MEDCouplingCurveLinearMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingCurveLinearMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const throw(INTERP_KERNEL::Exception)
{
std::ostringstream extent;
int meshDim=(int)_structure.size();
ofs << " </CellData>\n";
ofs << " <Points>\n";
if(getSpaceDimension()==3)
- _coords->writeVTK(ofs,8,"Points");
+ _coords->writeVTK(ofs,8,"Points",byteData);
else
{
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coo=_coords->changeNbOfComponents(3,0.);
- coo->writeVTK(ofs,8,"Points");
+ coo->writeVTK(ofs,8,"Points",byteData);
}
ofs << " </Points>\n";
ofs << " </Piece>\n";
MEDCouplingCurveLinearMesh();
MEDCouplingCurveLinearMesh(const MEDCouplingCurveLinearMesh& other, bool deepCpy);
~MEDCouplingCurveLinearMesh();
- void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception);
+ void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const throw(INTERP_KERNEL::Exception);
std::string getVTKDataSetType() const throw(INTERP_KERNEL::Exception);
private:
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
std::copy(a1Ptr,a1Ptr+szIds,_mesh3D_ids->getPointer());
}
-void MEDCouplingExtrudedMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingExtrudedMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=buildUnstructured();
- m->writeVTKLL(ofs,cellData,pointData);
+ m->writeVTKLL(ofs,cellData,pointData,byteData);
}
void MEDCouplingExtrudedMesh::reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception)
const int *conn2D, const int *conn2DIndx) throw(INTERP_KERNEL::Exception);
void computeBaryCenterOfFace(const std::vector<int>& nodalConnec, int lev1DId);
~MEDCouplingExtrudedMesh();
- void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception);
+ void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const throw(INTERP_KERNEL::Exception);
std::string getVTKDataSetType() const throw(INTERP_KERNEL::Exception);
private:
MEDCouplingUMesh *_mesh2D;
return ret.str();
}
-void MEDCouplingFieldDouble::writeVTK(const char *fileName) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingFieldDouble::writeVTK(const char *fileName, bool isBinary) const throw(INTERP_KERNEL::Exception)
{
std::vector<const MEDCouplingFieldDouble *> fs(1,this);
- MEDCouplingFieldDouble::WriteVTK(fileName,fs);
+ MEDCouplingFieldDouble::WriteVTK(fileName,fs,isBinary);
}
bool MEDCouplingFieldDouble::isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const throw(INTERP_KERNEL::Exception)
* \warning All the fields must be named and lie on the same non NULL mesh.
* \param [in] fileName - the name of a VTK file to write in.
* \param [in] fs - the fields to write.
+ * \param [in] isBinary - specifies the VTK format of the written file. By default true (Binary mode)
* \throw If \a fs[ 0 ] == NULL.
* \throw If the fields lie not on the same mesh.
* \throw If the mesh is not set.
* \ref cpp_mcfielddouble_WriteVTK "Here is a C++ example".<br>
* \ref py_mcfielddouble_WriteVTK "Here is a Python example".
*/
-void MEDCouplingFieldDouble::WriteVTK(const char *fileName, const std::vector<const MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception)
+void MEDCouplingFieldDouble::WriteVTK(const char *fileName, const std::vector<const MEDCouplingFieldDouble *>& fs, bool isBinary) throw(INTERP_KERNEL::Exception)
{
if(fs.empty())
return;
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::WriteVTK : Fields are not lying on a same mesh ! Expected by VTK ! MEDCouplingFieldDouble::setMesh or MEDCouplingFieldDouble::changeUnderlyingMesh can help to that.");
if(!m)
throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::WriteVTK : Fields are lying on a same mesh but it is empty !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayByte> byteArr;
+ if(isBinary)
+ { byteArr=DataArrayByte::New(); byteArr->alloc(0,1); }
std::ostringstream coss,noss;
for(std::size_t i=0;i<nfs;i++)
{
}
TypeOfField typ=cur->getTypeOfField();
if(typ==ON_CELLS)
- cur->getArray()->writeVTK(coss,8,cur->getName().c_str());
+ cur->getArray()->writeVTK(coss,8,cur->getName().c_str(),byteArr);
else if(typ==ON_NODES)
- cur->getArray()->writeVTK(noss,8,cur->getName().c_str());
+ cur->getArray()->writeVTK(noss,8,cur->getName().c_str(),byteArr);
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::WriteVTK : only node and cell fields supported for the moment !");
}
- m->writeVTKAdvanced(fileName,coss.str(),noss.str());
+ m->writeVTKAdvanced(fileName,coss.str(),noss.str(),byteArr);
}
void MEDCouplingFieldDouble::reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception)
void copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const;
std::string advancedRepr() const;
- void writeVTK(const char *fileName) const throw(INTERP_KERNEL::Exception);
+ void writeVTK(const char *fileName, bool isBinary=true) const throw(INTERP_KERNEL::Exception);
bool isEqualIfNotWhy(const MEDCouplingField *other, double meshPrec, double valsPrec, std::string& reason) const throw(INTERP_KERNEL::Exception);
bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
bool areCompatibleForMerge(const MEDCouplingField *other) const;
MEDCouplingFieldDouble *operator^(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
const MEDCouplingFieldDouble &operator^=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
static MEDCouplingFieldDouble *PowFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
- static void WriteVTK(const char *fileName, const std::vector<const MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception);
+ static void WriteVTK(const char *fileName, const std::vector<const MEDCouplingFieldDouble *>& fs, bool isBinary=true) throw(INTERP_KERNEL::Exception);
public:
const MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() const { return _time_discr; }
MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() { return _time_discr; }
#include "BBTree.txx"
#include "GenMathFormulae.hxx"
+#include "InterpKernelAutoPtr.hxx"
#include "InterpKernelExprParser.hxx"
#include <set>
return ret.str();
}
-void DataArrayDouble::writeVTK(std::ostream& ofs, int indent, const char *nameInFile) const throw(INTERP_KERNEL::Exception)
+void DataArrayDouble::writeVTK(std::ostream& ofs, int indent, const char *nameInFile, DataArrayByte *byteArr) const throw(INTERP_KERNEL::Exception)
{
+ static const char SPACE[4]={' ',' ',' ',' '};
+ checkAllocated();
std::string idt(indent,' ');
ofs.precision(17);
ofs << idt << "<DataArray type=\"Float32\" Name=\"" << nameInFile << "\" NumberOfComponents=\"" << getNumberOfComponents() << "\"";
- ofs << " format=\"ascii\" RangeMin=\"" << getMinValueInArray() << "\" RangeMax=\"" << getMaxValueInArray() << "\">\n" << idt;
- std::copy(begin(),end(),std::ostream_iterator<double>(ofs," "));
+ if(byteArr)
+ {
+ ofs << " format=\"appended\" offset=\"" << byteArr->getNumberOfTuples() << "\">";
+ INTERP_KERNEL::AutoPtr<float> tmp(new float[getNbOfElems()]);
+ std::copy(begin(),end(),(float *)tmp);
+ const char *data(reinterpret_cast<const char *>((float *)tmp));
+ std::size_t sz(getNbOfElems()*sizeof(float));
+ byteArr->insertAtTheEnd(data,data+sz);
+ byteArr->insertAtTheEnd(SPACE,SPACE+4);
+ }
+ else
+ {
+ ofs << " RangeMin=\"" << getMinValueInArray() << "\" RangeMax=\"" << getMaxValueInArray() << "\" format=\"ascii\">\n" << idt;
+ std::copy(begin(),end(),std::ostream_iterator<double>(ofs," "));
+ }
ofs << std::endl << idt << "</DataArray>\n";
}
return ret.str();
}
-void DataArrayInt::writeVTK(std::ostream& ofs, int indent, const char *type, const char *nameInFile) const throw(INTERP_KERNEL::Exception)
+void DataArrayInt::writeVTK(std::ostream& ofs, int indent, const char *type, const char *nameInFile, DataArrayByte *byteArr) const throw(INTERP_KERNEL::Exception)
{
+ static const char SPACE[4]={' ',' ',' ',' '};
checkAllocated();
std::string idt(indent,' ');
ofs << idt << "<DataArray type=\"" << type << "\" Name=\"" << nameInFile << "\" NumberOfComponents=\"" << getNumberOfComponents() << "\"";
- ofs << " format=\"ascii\" RangeMin=\"" << getMinValueInArray() << "\" RangeMax=\"" << getMaxValueInArray() << "\">\n" << idt;
- std::copy(begin(),end(),std::ostream_iterator<int>(ofs," "));
+ 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";
}
};
class DataArrayInt;
+ class DataArrayByte;
class DataArray : public RefCountObject, public TimeLabel
{
MEDCOUPLING_EXPORT bool isMonotonic(bool increasing, double eps) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT std::string repr() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT std::string reprZip() const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const char *nameInFile) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const char *nameInFile, DataArrayByte *byteArr) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void iota(int init=0) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT std::string repr() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT std::string reprZip() const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const char *type, const char *nameInFile) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void writeVTK(std::ostream& ofs, int indent, const char *type, const char *nameInFile, DataArrayByte *byteArr) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static DataArrayChar *Meld(const DataArrayChar *a1, const DataArrayChar *a2) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static DataArrayChar *Meld(const std::vector<const DataArrayChar *>& arr) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void useArray(const char *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo) throw(INTERP_KERNEL::Exception);
+ template<class InputIterator>
+ void insertAtTheEnd(InputIterator first, InputIterator last) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void useExternalArrayWithRWAccess(const char *array, int nbOfTuple, int nbOfCompo) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void updateTime() const { }
MEDCOUPLING_EXPORT MemArray<char>& accessToMemArray() { return _mem; }
template<class InputIterator>
void DataArrayDouble::insertAtTheEnd(InputIterator first, InputIterator last) throw(INTERP_KERNEL::Exception)
{
- int nbCompo=getNumberOfComponents();
+ int nbCompo(getNumberOfComponents());
if(nbCompo==1)
_mem.insertAtTheEnd(first,last);
else if(nbCompo==0)
template<class InputIterator>
void DataArrayInt::insertAtTheEnd(InputIterator first, InputIterator last) throw(INTERP_KERNEL::Exception)
{
- int nbCompo=getNumberOfComponents();
+ int nbCompo(getNumberOfComponents());
if(nbCompo==1)
_mem.insertAtTheEnd(first,last);
else if(nbCompo==0)
else
throw INTERP_KERNEL::Exception("DataArrayInt::insertAtTheEnd : not available for DataArrayInt with number of components different than 1 !");
}
+
+ template<class InputIterator>
+ void DataArrayChar::insertAtTheEnd(InputIterator first, InputIterator last) throw(INTERP_KERNEL::Exception)
+ {
+ int nbCompo(getNumberOfComponents());
+ if(nbCompo==1)
+ _mem.insertAtTheEnd(first,last);
+ else if(nbCompo==0)
+ {
+ _info_on_compo.resize(1);
+ _mem.insertAtTheEnd(first,last);
+ }
+ else
+ throw INTERP_KERNEL::Exception("DataArrayChar::insertAtTheEnd : not available for DataArrayChar with number of components different than 1 !");
+ }
}
#endif
* \param [in] fileName - the name of the file to write in.
* \throw If \a fileName is not a writable file.
*/
-void MEDCouplingMesh::writeVTK(const char *fileName) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingMesh::writeVTK(const char *fileName, bool isBinary) const throw(INTERP_KERNEL::Exception)
{
std::string cda,pda;
- writeVTKAdvanced(fileName,cda,pda);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayByte> byteArr;
+ if(isBinary)
+ { byteArr=DataArrayByte::New(); byteArr->alloc(0,1); }
+ writeVTKAdvanced(fileName,cda,pda,byteArr);
}
-void MEDCouplingMesh::writeVTKAdvanced(const char *fileName, const std::string& cda, const std::string& pda) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingMesh::writeVTKAdvanced(const char *fileName, const std::string& cda, const std::string& pda, DataArrayByte *byteData) const throw(INTERP_KERNEL::Exception)
{
std::ofstream ofs(fileName);
- ofs << "<VTKFile type=\"" << getVTKDataSetType() << "\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
- writeVTKLL(ofs,cda,pda);
- ofs << "</VTKFile>\n";
- ofs.close();
+ ofs << "<VTKFile type=\"" << getVTKDataSetType() << "\" version=\"0.1\" byte_order=\"" << MEDCouplingByteOrderStr() << "\">\n";
+ writeVTKLL(ofs,cda,pda,byteData);
+ if(byteData)
+ {
+ ofs << "<AppendedData encoding=\"raw\">\n_1234";
+ ofs << std::flush; ofs.close();
+ std::ofstream ofs2(fileName,std::ios_base::binary | std::ios_base::app);
+ ofs2.write(byteData->begin(),byteData->getNbOfElems()); ofs2 << std::flush; ofs2.close();
+ std::ofstream ofs3(fileName,std::ios_base::app); ofs3 << "\n </AppendedData>\n</VTKFile>\n"; ofs3.close();
+ }
+ else
+ {
+ ofs << "</VTKFile>\n";
+ ofs.close();
+ }
}
typedef enum
{
UNSTRUCTURED = 5,
- UNSTRUCTURED_DESC = 6,
CARTESIAN = 7,
EXTRUDED = 8,
CURVE_LINEAR = 9,
SINGLE_STATIC_GEO_TYPE_UNSTRUCTURED = 10,
SINGLE_DYNAMIC_GEO_TYPE_UNSTRUCTURED = 11
} MEDCouplingMeshType;
+ // -- WARNING this enum must be synchronized with MEDCouplingCommon.i file ! --
class DataArrayInt;
+ class DataArrayByte;
class DataArrayDouble;
class MEDCouplingUMesh;
class MEDCouplingFieldDouble;
virtual void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const = 0;
virtual void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& littleStrings) = 0;
- void writeVTK(const char *fileName) const throw(INTERP_KERNEL::Exception);
+ void writeVTK(const char *fileName, bool isBinary=true) const throw(INTERP_KERNEL::Exception);
/// @cond INTERNAL
- void writeVTKAdvanced(const char *fileName, const std::string& cda, const std::string& pda) const throw(INTERP_KERNEL::Exception);
+ void writeVTKAdvanced(const char *fileName, const std::string& cda, const std::string& pda, DataArrayByte *byteData) const throw(INTERP_KERNEL::Exception);
/// @endcond
- virtual void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const throw(INTERP_KERNEL::Exception) = 0;
virtual void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception) = 0;
protected:
MEDCouplingMesh();
#include "MEDCouplingPointSet.hxx"
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MEDCoupling1GTUMesh.hxx"
#include "MEDCouplingUMesh.hxx"
-#include "MEDCouplingUMeshDesc.hxx"
#include "MEDCouplingMemArray.hxx"
#include "PlanarIntersector.txx"
#include "InterpKernelGeo2DQuadraticPolygon.hxx"
{
case UNSTRUCTURED:
return MEDCouplingUMesh::New();
- case UNSTRUCTURED_DESC:
- return MEDCouplingUMeshDesc::New();
+ case SINGLE_STATIC_GEO_TYPE_UNSTRUCTURED:
+ return MEDCoupling1SGTUMesh::New();
+ case SINGLE_DYNAMIC_GEO_TYPE_UNSTRUCTURED:
+ return MEDCoupling1DGTUMesh::New();
default:
throw INTERP_KERNEL::Exception("Invalid type of mesh specified");
}
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::FillInCompact3DMode : Invalid spaceDim specified : must be 2 or 3 !");
}
-void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const throw(INTERP_KERNEL::Exception)
{
int nbOfCells=getNumberOfCells();
if(nbOfCells<=0)
ofs << " </CellData>\n";
ofs << " <Points>\n";
if(getSpaceDimension()==3)
- _coords->writeVTK(ofs,8,"Points");
+ _coords->writeVTK(ofs,8,"Points",byteData);
else
{
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coo=_coords->changeNbOfComponents(3,0.);
- coo->writeVTK(ofs,8,"Points");
+ coo->writeVTK(ofs,8,"Points",byteData);
}
ofs << " </Points>\n";
ofs << " <Cells>\n";
}
}
types->transformWithIndArr(PARAMEDMEM2VTKTYPETRADUCER,PARAMEDMEM2VTKTYPETRADUCER+INTERP_KERNEL::NORM_MAXTYPE);
- types->writeVTK(ofs,8,"UInt8","types");
- offsets->writeVTK(ofs,8,"Int32","offsets");
+ types->writeVTK(ofs,8,"UInt8","types",byteData);
+ offsets->writeVTK(ofs,8,"Int32","offsets",byteData);
if(szFaceOffsets!=0)
{//presence of Polyhedra
connectivity->reAlloc(szConn);
- faceoffsets->writeVTK(ofs,8,"Int32","faceoffsets");
+ faceoffsets->writeVTK(ofs,8,"Int32","faceoffsets",byteData);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> faces=DataArrayInt::New(); faces->alloc(szFaceOffsets,1);
w1=faces->getPointer();
for(int i=0;i<nbOfCells;i++)
w6=w5+1;
}
}
- faces->writeVTK(ofs,8,"Int32","faces");
+ faces->writeVTK(ofs,8,"Int32","faces",byteData);
}
- connectivity->writeVTK(ofs,8,"Int32","connectivity");
+ connectivity->writeVTK(ofs,8,"Int32","connectivity",byteData);
ofs << " </Cells>\n";
ofs << " </Piece>\n";
ofs << " </" << getVTKDataSetType() << ">\n";
MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings);
MEDCOUPLING_EXPORT std::string getVTKDataSetType() const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception);
//tools
MEDCOUPLING_EXPORT static int AreCellsEqual(const int *conn, const int *connI, int cell1, int cell2, int compType);
CPPUNIT_ASSERT(!((dbl->reprZip().find("Number of components : 1"))==std::string::npos));
std::ostringstream ret;
- dbl->writeVTK(ret,2,"file.tmp");
+ dbl->writeVTK(ret,2,"file.tmp",0);
CPPUNIT_ASSERT(!((ret.str().find("<DataArray"))==std::string::npos));
CPPUNIT_ASSERT(!((ret.str().find("Float32"))==std::string::npos));
CPPUNIT_ASSERT(!((ret.str().find("16 15 14 13 12 11 10"))==std::string::npos));
typedef enum
{
UNSTRUCTURED = 5,
- UNSTRUCTURED_DESC = 6,
CARTESIAN = 7,
EXTRUDED = 8,
- CURVE_LINEAR = 9
+ CURVE_LINEAR = 9,
+ SINGLE_STATIC_GEO_TYPE_UNSTRUCTURED = 10,
+ SINGLE_DYNAMIC_GEO_TYPE_UNSTRUCTURED = 11
} MEDCouplingMeshType;
class DataArrayInt;
virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const throw(INTERP_KERNEL::Exception);
virtual std::string simpleRepr() const throw(INTERP_KERNEL::Exception);
virtual std::string advancedRepr() const throw(INTERP_KERNEL::Exception);
- void writeVTK(const char *fileName) const throw(INTERP_KERNEL::Exception);
+ void writeVTK(const char *fileName, bool isBinary=true) const throw(INTERP_KERNEL::Exception);
// tools
virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const throw(INTERP_KERNEL::Exception);
void copyAllTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const throw(INTERP_KERNEL::Exception);
std::string advancedRepr() const throw(INTERP_KERNEL::Exception);
- void writeVTK(const char *fileName) const throw(INTERP_KERNEL::Exception);
+ void writeVTK(const char *fileName, bool isBinary=true) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const;
MEDCouplingFieldDouble *deepCpy() const;
return MEDCouplingFieldDouble::MergeFields(tmp);
}
- static void WriteVTK(const char *fileName, PyObject *li) throw(INTERP_KERNEL::Exception)
+ static void WriteVTK(const char *fileName, PyObject *li, bool isBinary=true) throw(INTERP_KERNEL::Exception)
{
std::vector<const MEDCouplingFieldDouble *> tmp;
convertFromPyObjVectorOfObj<const ParaMEDMEM::MEDCouplingFieldDouble *>(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp);
- MEDCouplingFieldDouble::WriteVTK(fileName,tmp);
+ MEDCouplingFieldDouble::WriteVTK(fileName,tmp,isBinary);
}
}
};