Salome HOME
Little refactoring of progeny mechanism to avoid if.
[modules/med.git] / src / MEDLoader / MEDFileMeshLL.cxx
index 4d32f5c12eb9991c414bbc83f8bb5718cf0c6307..bd8aff2c43787e62328672ba2703859bb02c38f4 100644 (file)
@@ -45,7 +45,7 @@ std::size_t MEDFileMeshL2::getHeapMemorySizeWithoutChildren() const
   return 0;
 }
 
-std::vector<const BigMemoryObject *> MEDFileMeshL2::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDFileMeshL2::getDirectChildrenWithNull() const
 {
   return std::vector<const BigMemoryObject *>();
 }
@@ -87,7 +87,7 @@ int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, Para
       throw INTERP_KERNEL::Exception(oss.str().c_str());
     }
   switch(type_maillage)
-    {
+  {
     case MED_UNSTRUCTURED_MESH:
       meshType=UNSTRUCTURED;
       break;
@@ -96,7 +96,7 @@ int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, Para
         med_grid_type gt;
         MEDmeshGridTypeRd(fid,mname.c_str(),&gt);
         switch(gt)
-          {
+        {
           case MED_CARTESIAN_GRID:
             meshType=CARTESIAN;
             break;
@@ -105,12 +105,12 @@ int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, Para
             break;
           default:
             throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
-          }
+        }
         break;
       }
     default:
       throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized mesh type !");
-    }
+  }
   med_int numdt,numit;
   med_float dtt;
   MEDmeshComputationStepInfo(fid,mname.c_str(),1,&numdt,&numit,&dtt);
@@ -153,11 +153,11 @@ std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId,
   INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
   INTERP_KERNEL::AutoPtr<char> univTmp=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
   if(MEDmeshInfo(fid,mId,nameTmp,&spaceDim,&Mdim,&type_maillage,_description.getPointer(),_dt_unit.getPointer(),
-                 &stype,&nstep,&axistype,axisname,axisunit)!=0)
+      &stype,&nstep,&axistype,axisname,axisunit)!=0)
     throw INTERP_KERNEL::Exception("A problem has been detected when trying to get info on mesh !");
   MEDmeshUniversalNameRd(fid,nameTmp,_univ_name.getPointer());
   switch(type_maillage)
-    {
+  {
     case MED_UNSTRUCTURED_MESH:
       meshType=UNSTRUCTURED;
       break;
@@ -166,7 +166,7 @@ std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId,
         med_grid_type gt;
         MEDmeshGridTypeRd(fid,mName.c_str(),&gt);
         switch(gt)
-          {
+        {
           case MED_CARTESIAN_GRID:
             meshType=CARTESIAN;
             break;
@@ -175,12 +175,12 @@ std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId,
             break;
           default:
             throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getAxisInfoOnMesh : unrecognized structured mesh type ! Supported are :\n - cartesian\n - curve linear\n");
-          }
+        }
         break;
       }
     default:
       throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized mesh type !");
-    }
+  }
   //
   std::vector<std::string> infosOnComp(naxis);
   for(int i=0;i<naxis;i++)
@@ -428,7 +428,7 @@ void MEDFileCMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int
 med_data_type MEDFileCMeshL2::GetDataTypeCorrespondingToSpaceId(int id)
 {
   switch(id)
-    {
+  {
     case 0:
       return MED_COORDINATE_AXIS1;
     case 1:
@@ -437,7 +437,7 @@ med_data_type MEDFileCMeshL2::GetDataTypeCorrespondingToSpaceId(int id)
       return MED_COORDINATE_AXIS3;
     default:
       throw INTERP_KERNEL::Exception("Invalid meshdim detected in Cartesian Grid !");
-    }
+  }
 }
 
 MEDFileCLMeshL2::MEDFileCLMeshL2()
@@ -512,6 +512,18 @@ void MEDFileUMeshPermCompute::updateTime() const
   _num_time=_st->_num->getTimeOfThis();
 }
 
+std::vector<const BigMemoryObject *> MEDFileUMeshPermCompute::getDirectChildrenWithNull() const
+{
+  std::vector<const BigMemoryObject *> ret;
+  ret.push_back((const MEDCouplingUMesh *)_m);
+  return ret;
+}
+
+std::size_t MEDFileUMeshPermCompute::getHeapMemorySizeWithoutChildren() const
+{
+  return sizeof(MEDFileUMeshPermCompute);
+}
+
 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshSplitL1& other):RefCountObject(other),_m_by_types(other._m_by_types),_fam(other._fam),_num(other._num),_names(other._names),_rev_num(other._rev_num),_m(this)
 {
 }
@@ -593,18 +605,15 @@ std::size_t MEDFileUMeshSplitL1::getHeapMemorySizeWithoutChildren() const
   return 0;
 }
 
-std::vector<const BigMemoryObject *> MEDFileUMeshSplitL1::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDFileUMeshSplitL1::getDirectChildrenWithNull() const
 {
   std::vector<const BigMemoryObject *> ret;
   ret.push_back(&_m_by_types);
-  if((const DataArrayInt*)_fam)
-    ret.push_back((const DataArrayInt*)_fam);
-  if((const DataArrayInt*)_num)
-    ret.push_back((const DataArrayInt*)_num);
-  if((const DataArrayInt*)_rev_num)
-    ret.push_back((const DataArrayInt*)_rev_num);
-  if((const DataArrayAsciiChar*)_names)
-    ret.push_back((const DataArrayAsciiChar*)_names);
+  ret.push_back(&_m);
+  ret.push_back((const DataArrayInt*)_fam);
+  ret.push_back((const DataArrayInt*)_num);
+  ret.push_back((const DataArrayInt*)_rev_num);
+  ret.push_back((const DataArrayAsciiChar*)_names);
   return ret;
 }
 
@@ -862,7 +871,7 @@ void MEDFileUMeshSplitL1::eraseFamilyField()
  * This method ignores _m and _m_by_types.
  */
 void MEDFileUMeshSplitL1::setGroupsFromScratch(const std::vector<const MEDCouplingUMesh *>& ms, std::map<std::string,int>& familyIds,
-                                               std::map<std::string, std::vector<std::string> >& groups) throw(INTERP_KERNEL::Exception)
+                                               std::map<std::string, std::vector<std::string> >& groups)
 {
   std::vector< DataArrayInt * > corr;
   _m=MEDCouplingUMesh::FuseUMeshesOnSameCoords(ms,0,corr);
@@ -1199,18 +1208,12 @@ std::size_t MEDFileUMeshAggregateCompute::getHeapMemorySizeWithoutChildren() con
   return ret;
 }
 
-std::vector<const BigMemoryObject *> MEDFileUMeshAggregateCompute::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDFileUMeshAggregateCompute::getDirectChildrenWithNull() const
 {
   std::vector<const BigMemoryObject *> ret;
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
-    {
-      const MEDCoupling1GTUMesh *cur(*it);
-      if(cur)
-        ret.push_back(cur);
-    }
-  const MEDCouplingUMesh *m(_m);
-  if(m)
-    ret.push_back(m);
+    ret.push_back((const MEDCoupling1GTUMesh *)*it);
+  ret.push_back((const MEDCouplingUMesh *)_m);
   return ret;
 }
 
@@ -1293,7 +1296,6 @@ bool MEDFileUMeshAggregateCompute::empty() const
     return ((const MEDCouplingUMesh *)_m)==0;
   //else _mp_time>=_m_time)
   return _m_parts.empty();
-  
 }
 
 int MEDFileUMeshAggregateCompute::getMeshDimension() const