Salome HOME
Windows porting (disable export to JPEG feature on Windows where libgd is unavailable)
[samples/sierpinsky.git] / src / Sierpinsky / SIERPINSKY_Gen_i.cxx
index 41ea3cd3b26b0ddc66980224b33c0efc1fa369e8..6f62bb404ba5cb86acfe92e9185e7bf9b8a27e0e 100644 (file)
@@ -27,9 +27,9 @@
 #include "SIERPINSKY_Gen_i.hxx"
 #include "SIERPINSKY_version.h"
 #include <MED_Factory.hxx>
+#ifndef WIN32
 #include <gd.h>
-
-using namespace MED;
+#endif
 
 /*!
  * Engine factory
@@ -122,6 +122,7 @@ void SIERPINSKY_Gen_i::NextPoint( CORBA::Double  theX,     CORBA::Double  theY,
  */
 CORBA::Boolean SIERPINSKY_Gen_i::ExportToJPEG( const char* theFileName, CORBA::Long theSize )
 {
+#ifndef WIN32
   if ( theSize <= 0 ) return false;
 
   // open file
@@ -147,6 +148,10 @@ CORBA::Boolean SIERPINSKY_Gen_i::ExportToJPEG( const char* theFileName, CORBA::L
   gdImageDestroy( image );
   
   return true;
+#else
+  printf("Warning: ExportToJPEG() is not supported on Windows!");
+  return false;
+#endif
 }
   
 /*!
@@ -154,7 +159,7 @@ CORBA::Boolean SIERPINSKY_Gen_i::ExportToJPEG( const char* theFileName, CORBA::L
  */
 CORBA::Boolean SIERPINSKY_Gen_i::ExportToMED( const char* theFileName, CORBA::Double theSize )
 {
-  TErr anError;
+  MED::TErr anError;
   
   // if file already exists - remove it (MED cannot overwrite files correctly)
   FILE* aFile = fopen( theFileName, "rb" );
@@ -164,16 +169,16 @@ CORBA::Boolean SIERPINSKY_Gen_i::ExportToMED( const char* theFileName, CORBA::Do
   }
   
   // create MED 2.2 file
-  PWrapper aMed = CrWrapper( theFileName, MED::eV2_2 );
+  MED::PWrapper aMed = MED::CrWrapper( theFileName, MED::eV2_2 );
 
   // create 2D mesh
-  PMeshInfo aMesh = aMed->CrMeshInfo( 2, 2, "Sierpinsky" );
+  MED::PMeshInfo aMesh = aMed->CrMeshInfo( 2, 2, "Sierpinsky" );
   aMed->SetMeshInfo( aMesh, &anError );
   if ( anError < 0 ) return false;
 
   // create nodes
-  TFloatVector nodes;
-  TIntVector   connect;
+  MED::TFloatVector nodes;
+  MED::TIntVector   connect;
   std::list<MyPoint>::const_iterator iter;
   int ind = 1;
   for ( iter = myPoints.begin(); iter != myPoints.end(); ++iter ) {
@@ -181,11 +186,19 @@ CORBA::Boolean SIERPINSKY_Gen_i::ExportToMED( const char* theFileName, CORBA::Do
     nodes.push_back( (*iter).myY * theSize );
     connect.push_back( ind++ );
   }
-  PNodeInfo aNodes = aMed->CrNodeInfo( aMesh, nodes, MED::eFULL_INTERLACE, MED::eCART, TStringVector(2), TStringVector(2), TIntVector( myPoints.size() ), TIntVector() );
+  MED::PNodeInfo aNodes = aMed->CrNodeInfo( aMesh, nodes, 
+                                           MED::eFULL_INTERLACE, MED::eCART, 
+                                           MED::TStringVector(2),
+                                           MED::TStringVector(2), 
+                                           MED::TIntVector( myPoints.size() ),
+                                           MED::TIntVector() );
   aMed->SetNodeInfo( aNodes, &anError );
   if ( anError < 0 ) return false;
 
-  PCellInfo aCells = aMed->CrCellInfo( aMesh, MED::eMAILLE, MED::ePOINT1, connect, eNOD, TIntVector( myPoints.size() ), TIntVector( myPoints.size() ) );
+  MED::PCellInfo aCells = aMed->CrCellInfo( aMesh, MED::eMAILLE, MED::ePOINT1, 
+                                           connect, MED::eNOD, 
+                                           MED::TIntVector( myPoints.size() ), 
+                                           MED::TIntVector( myPoints.size() ) );
   aMed->SetCellInfo( aCells, &anError );
   if ( anError < 0 ) return false;