Salome HOME
PV 5.4 : Porting to OpenGL2
[modules/paravis.git] / src / Plugins / MEDReader / IO / vtkExtractCellType.cxx
index de68490db686357433b845fcb56872c283f7bb68..d79200a2d68ce97ede5811bcaa7959377198521b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2010-2016  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -23,6 +23,7 @@
 #include "MEDFileFieldOverView.hxx"
 
 #include "vtkAdjacentVertexIterator.h"
+#include "vtkDataArrayTemplate.h"
 #include "vtkIntArray.h"
 #include "vtkCellData.h"
 #include "vtkPointData.h"
@@ -210,14 +211,29 @@ const ExtractCellTypeStatus& vtkExtractCellType::vtkExtractCellTypeInternal::get
 
 bool vtkExtractCellType::vtkExtractCellTypeInternal::getStatusOfEntryStr(const char *entry) const
 {
-  const ExtractCellTypeStatus& elt(getEntry(entry));
-  return elt.getStatus();
+  try 
+    {
+      const ExtractCellTypeStatus& elt(getEntry(entry));
+      return elt.getStatus();
+    }  
+  catch (INTERP_KERNEL::Exception e)
+    {      
+      //std::cerr << vtkDebugMacro"Exception has been thrown in vtkExtractCellType::vtkExtractCellTypeInternal::getStatusOfEntryStr : " << e.what() << std::endl;
+      return false;
+    }
 }
 
 void vtkExtractCellType::vtkExtractCellTypeInternal::setStatusOfEntryStr(const char *entry, bool status) const
 {
-  const ExtractCellTypeStatus& elt(getEntry(entry));
-  elt.setStatus(status);
+  try 
+    {
+      const ExtractCellTypeStatus& elt(getEntry(entry));
+      elt.setStatus(status);
+    }
+  catch (INTERP_KERNEL::Exception e)
+    {      
+      //std::cerr << "Exception has been thrown in vtkExtractCellType::vtkExtractCellTypeInternal::setStatusOfEntryStr : " << e.what() << std::endl;
+    }
 }
 
 void vtkExtractCellType::vtkExtractCellTypeInternal::printMySelf(std::ostream& os) const
@@ -325,13 +341,13 @@ int vtkExtractCellType::RequestInformation(vtkInformation *request, vtkInformati
              const std::map<int,INTERP_KERNEL::NormalizedCellType>::const_iterator it(m.find(vtkCt));
              if(it==m.end())
                {
-                 const unsigned char *pos(std::find(ParaMEDMEM::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE,ParaMEDMEM::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE+ParaMEDMEM::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH,vtkCt));
-                 if(pos==ParaMEDMEM::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE+ParaMEDMEM::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH)
+                 const unsigned char *pos(std::find(MEDCoupling::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE,MEDCoupling::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE+MEDCoupling::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH,vtkCt));
+                 if(pos==MEDCoupling::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE+MEDCoupling::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE_LGTH)
                    {
                      vtkDebugMacro("vtkExtractCellType::RequestInformation : cell #" << cellId << " has unrecognized type !");
                      return 0;
                    }
-                 m[vtkCt]=(INTERP_KERNEL::NormalizedCellType)std::distance(ParaMEDMEM::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE,pos);
+                 m[vtkCt]=(INTERP_KERNEL::NormalizedCellType)std::distance(MEDCoupling::MEDMeshMultiLev::PARAMEDMEM_2_VTKTYPE,pos);
             }
            }
          this->Internal->loadFrom(m);
@@ -353,8 +369,8 @@ int vtkExtractCellType::RequestInformation(vtkInformation *request, vtkInformati
 
 vtkDataSet *FilterFamilies(vtkDataSet *input, const std::vector<int>& idsToKeep, bool insideOut)
 {
-  static const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_DELETE;
-  static const char ZE_SELECTION_ARR_NAME[]="@@ZeSelection@@";
+  const int VTK_DATA_ARRAY_DELETE=vtkDataArrayTemplate<double>::VTK_DATA_ARRAY_DELETE;
+  const char ZE_SELECTION_ARR_NAME[]="@@ZeSelection@@";
   vtkDataSet *output(input->NewInstance());
   output->ShallowCopy(input);
   vtkSmartPointer<vtkThreshold> thres(vtkSmartPointer<vtkThreshold>::New());
@@ -456,6 +472,8 @@ int vtkExtractCellType::GetGeoTypesArrayStatus(const char *name)
 void vtkExtractCellType::SetGeoTypesStatus(const char *name, int status)
 {
   //std::cerr << "vtkExtractCellType::SetGeoTypesStatus(" << name << "," << status << ")" << std::endl;
+  if (GetNumberOfGeoTypesArrays()<1)
+    return;
   this->Internal->setStatusOfEntryStr(name,(bool)status);
   if(std::string(name)==GetGeoTypesArrayName(GetNumberOfGeoTypesArrays()-1))
     {