]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
PAL18313 4.x Mandriva 64 porting: CRASH after trying to create presentation after...
authoreap <eap@opencascade.com>
Tue, 19 Feb 2008 08:30:03 +0000 (08:30 +0000)
committereap <eap@opencascade.com>
Tue, 19 Feb 2008 08:30:03 +0000 (08:30 +0000)
       fix defining VTK type for int field

src/VISU_I/VISU_CorbaMedConvertor.cxx

index 11427b1a9b0b1198d74ce49dbf0d7b526512a9dd..aea4b36ce887d7d6606dbe4c9d7f89e36c10d3fa 100644 (file)
@@ -673,8 +673,16 @@ VISU_MEDFieldConvertor
 
   vtkIdType aDataType = VTK_DOUBLE;
   SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(myField);
-  if(aFieldDouble->_is_nil())
-    aDataType = VTK_LONG;
+  if(aFieldDouble->_is_nil()) {
+    // PAL18313: Mandriva 64 porting: CRASH at creating presentation on "Import Structure".
+    if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h)
+      aDataType = VTK_LONG;
+    else if (sizeof(int) == 4)
+      aDataType = VTK_INT;
+    else {
+      throw std::runtime_error("Can't map CORBA::Long to a VTK type");
+    }
+  }
   aField->Init(myField->getNumberOfComponents(), aDataType);
 
   if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
@@ -1069,8 +1077,17 @@ VISU_MEDConvertor
 
          vtkIdType aDataType = VTK_DOUBLE;
          SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
-         if(aFieldDouble->_is_nil())
-           aDataType = VTK_LONG;
+         if(aFieldDouble->_is_nil()) {
+            // PAL18313: Mandriva 64 porting: CRASH at creating presentation on "Import Structure".
+            if (sizeof(long) == 4 ) // Size of CORBA::Long is always 4 (see CORBA_basetypes.h)
+              aDataType = VTK_LONG;
+            else if (sizeof(int) == 4)
+              aDataType = VTK_INT;
+            else {
+              MESSAGE("Can't map CORBA::Long to a VTK type, for Field " << aFieldName);
+              continue;
+            }
+          }
          aField->Init(aMEDField->getNumberOfComponents(), aDataType);
 
          if(MYDEBUG)