// Author : Alexey PETROV
// Module : VISU
-#include "VISU_Convertor.hxx"
#include "VISU_ConvertorUtils.hxx"
-#include <vtkCellType.h>
+#include <vtkUnstructuredGridWriter.h>
+#include <vtkTimerLog.h>
-using namespace std;
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
-#define MED2VTK(MEDTYPE,VTKTYPE,VTKNBNODES) \
- {MEDTYPE,#MEDTYPE,getNbMedNodes(MEDTYPE),VTKTYPE,#VTKTYPE,VTKNBNODES}
-Med2vtk med2vtk[MED_NBR_GEOMETRIE_MAILLE] = {
- MED2VTK(MED_POINT1,VTK_VERTEX,1),
- MED2VTK(MED_SEG2,VTK_LINE,2),
- MED2VTK(MED_SEG3,VTK_LINE,2),
- MED2VTK(MED_TRIA3,VTK_TRIANGLE,3),
- MED2VTK(MED_TRIA6,VTK_TRIANGLE,3),
- MED2VTK(MED_QUAD4,VTK_QUAD,4),
- MED2VTK(MED_QUAD8,VTK_QUAD,4),
- MED2VTK(MED_TETRA4,VTK_TETRA,4),
- MED2VTK(MED_TETRA10,VTK_TETRA,4),
- MED2VTK(MED_HEXA8,VTK_HEXAHEDRON,8),
- MED2VTK(MED_HEXA20,VTK_HEXAHEDRON,8),
- MED2VTK(MED_PENTA6,VTK_WEDGE,6),
- MED2VTK(MED_PENTA15,VTK_WEDGE,6),
- MED2VTK(MED_PYRA5,VTK_PYRAMID,5),
- MED2VTK(MED_PYRA13,VTK_PYRAMID,5)
-};
-#undef MED2VTK
+namespace VISU
+{
-extern "C" {
- int getNbMedConnect(int theMedType, int theMedEntity, int theMeshDim){
- int anElemDim = theMedType / 100, nsup = 0;
- if(theMedEntity == VISU::CELL_ENTITY && anElemDim < theMeshDim) nsup = 1;
- return nsup + theMedType % 100;
+ void
+ WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName)
+ {
+ vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New();
+ //aWriter->SetFileType(VTK_BINARY);
+ aWriter->SetFileName(theFileName.c_str());
+ aWriter->SetInput(theDataSet);
+ aWriter->Write();
+ aWriter->Delete();
}
- int getNbMedNodes(int geom){
- return geom % 100;
- }
- int getIdMedType(int medType){
- for(int i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
- if(med2vtk[i].medType == medType) return i;
- return -1;
+ TTimerLog
+ ::TTimerLog(int theIsDebug,
+ const std::string& theName):
+ myIsDebug(MYDEBUG + theIsDebug),
+ myTimerLog(vtkTimerLog::New()),
+ myPrefixPrinter(myIsDebug == 1),
+ myName(theName)
+ {
+ myCPUTime = myTimerLog->GetCPUTime();
+ BEGMSG(myIsDebug > 1,"{\n");
}
- int med2vtkCellType(int medType){
- for(int i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
- if(med2vtk[i].medType == medType) return med2vtk[i].vtkType;
- return -1;
- }
-
- int vtk2medCellType(int vtkType){
- for(int i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
- if(med2vtk[i].vtkType == vtkType) return med2vtk[i].medType;
- return -1;
+ TTimerLog
+ ::~TTimerLog()
+ {
+ myCPUTime = myTimerLog->GetCPUTime() - myCPUTime;
+
+ if(myIsDebug > 1){
+ BEGMSG(myIsDebug,"} = "<<myCPUTime<<" secs ("<<myName<<")\n");
+ }else{
+ BEGMSG(myIsDebug,myName<<" takes "<<myCPUTime<<" secs\n");
+ }
+
+ myTimerLog->Delete();
+ myTimerLog = NULL;
}
+
}