X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPlugins%2FParaMEDCorba%2FVTKMEDCouplingMultiFieldsClient.cxx;h=499503df3dd3a38f055cbb40945c192cdfa41e34;hb=e2c075bb656e4e5b0d8e6fcb7e06b5c25f903dee;hp=f1eb2295dd6b81d0916fcf9c47f12694c91f1276;hpb=89c33033151baa33eeac8fb09d9c0488acb43c35;p=modules%2Fparavis.git diff --git a/src/Plugins/ParaMEDCorba/VTKMEDCouplingMultiFieldsClient.cxx b/src/Plugins/ParaMEDCorba/VTKMEDCouplingMultiFieldsClient.cxx index f1eb2295..499503df 100644 --- a/src/Plugins/ParaMEDCorba/VTKMEDCouplingMultiFieldsClient.cxx +++ b/src/Plugins/ParaMEDCorba/VTKMEDCouplingMultiFieldsClient.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2012 CEA/DEN, EDF R&D +// Copyright (C) 2010-2013 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 @@ -40,7 +40,7 @@ const double ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::EPS_TIME=1e-7; ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::MEDCouplingMultiFieldsFetcher(int bufferingPolicy, - SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_ptr mfieldsPtr):_effective_pol(bufferingPolicy),_mfields_ptr_released(false) + SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_ptr mfieldsPtr):_effective_pol(bufferingPolicy),_mfields_ptr_released(false) { _mfields_ptr=SALOME_MED::MEDCouplingMultiFieldsCorbaInterface::_duplicate(mfieldsPtr); _mfields_ptr->Register(); @@ -49,15 +49,15 @@ ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::MEDCouplingMultiFieldsFetcher(int ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::~MEDCouplingMultiFieldsFetcher() { for(std::vector::iterator it=_meshes.begin();it!=_meshes.end();it++) - { - if(*it) - (*it)->Delete(); - } + { + if(*it) + (*it)->Delete(); + } for(std::vector::iterator it2=_arrays.begin();it2!=_arrays.end();it2++) - { - if(*it2) - (*it2)->Delete(); - } + { + if(*it2) + (*it2)->Delete(); + } if(!_mfields_ptr_released) _mfields_ptr->UnRegister(); } @@ -70,36 +70,36 @@ std::vector ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::getTimeStepsF _time_label_per_field.resize(nbOfFields); SALOME_MED::MEDCouplingFieldOverTimeCorbaInterface_var fotPtr=SALOME_MED::MEDCouplingFieldOverTimeCorbaInterface::_narrow(_mfields_ptr); if(CORBA::is_nil(fotPtr)) - { - for(CORBA::Long i=0;i=10) - { - fetchAll(); - return ; - } + { + fetchAll(); + return ; + } if(_effective_pol>=1 && _effective_pol<=9) - { - fetchMeshes(); - return ; - } + { + fetchMeshes(); + return ; + } } vtkDataSet *ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::buildDataSetOnTime(double time) @@ -112,34 +112,34 @@ vtkDataSet *ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::buildDataSetOnTime(do vtkDataSet *ret0=_meshes[meshId]; std::string clsName=ret0->GetClassName(); if(clsName=="vtkUnstructuredGrid") - { - vtkUnstructuredGrid *ret1=vtkUnstructuredGrid::New(); - ret1->DeepCopy(ret0); - if(_is_meshes_polyhedron[meshId])//bug VTK polyhedron - {//bug VTK polyhedron part - ret1->Faces->UnRegister(ret1); - ret1->Faces=vtkIdTypeArray::New(); - ret1->Faces->DeepCopy(((vtkUnstructuredGrid *)ret0)->GetFaces()); - ret1->Faces->Register(ret1); - ret1->Faces->Delete(); - ret1->FaceLocations->UnRegister(ret1); - ret1->FaceLocations=vtkIdTypeArray::New(); - ret1->FaceLocations->DeepCopy(((vtkUnstructuredGrid *)ret0)->GetFaceLocations()); - ret1->FaceLocations->Register(ret1); - ret1->FaceLocations->Delete(); - }//end bug VTK polyhedron part - appendFieldValueOnAlreadyFetchedData(ret1,fieldId); - applyBufferingPolicy(); - return ret1; - } + { + vtkUnstructuredGrid *ret1=vtkUnstructuredGrid::New(); + ret1->DeepCopy(ret0); + if(_is_meshes_polyhedron[meshId])//bug VTK polyhedron + {//bug VTK polyhedron part + ret1->Faces->UnRegister(ret1); + ret1->Faces=vtkIdTypeArray::New(); + ret1->Faces->DeepCopy(((vtkUnstructuredGrid *)ret0)->GetFaces()); + ret1->Faces->Register(ret1); + ret1->Faces->Delete(); + ret1->FaceLocations->UnRegister(ret1); + ret1->FaceLocations=vtkIdTypeArray::New(); + ret1->FaceLocations->DeepCopy(((vtkUnstructuredGrid *)ret0)->GetFaceLocations()); + ret1->FaceLocations->Register(ret1); + ret1->FaceLocations->Delete(); + }//end bug VTK polyhedron part + appendFieldValueOnAlreadyFetchedData(ret1,fieldId); + applyBufferingPolicy(); + return ret1; + } if(clsName=="vtkRectilinearGrid") - { - vtkRectilinearGrid *ret1=vtkRectilinearGrid::New(); - ret1->DeepCopy(ret0); - appendFieldValueOnAlreadyFetchedData(ret1,fieldId); - applyBufferingPolicy(); - return ret1; - } + { + vtkRectilinearGrid *ret1=vtkRectilinearGrid::New(); + ret1->DeepCopy(ret0); + appendFieldValueOnAlreadyFetchedData(ret1,fieldId); + applyBufferingPolicy(); + return ret1; + } return 0; } @@ -161,20 +161,20 @@ void ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::retrievesMainTinyInfo() int offsetTime=0; int offsetArrays=0; for(int i=0;igetTinyInfo(i,tinyL,tinyD,tinyS); - _info_per_field[i]._type=(*tinyL)[0]; - _info_per_field[i]._name=(*tinyS)[0]; - delete tinyL; - delete tinyD; - delete tinyS; - } + { + _mfields_ptr->getTinyInfo(i,tinyL,tinyD,tinyS); + _info_per_field[i]._type=(*tinyL)[0]; + _info_per_field[i]._name=(*tinyS)[0]; + delete tinyL; + delete tinyD; + delete tinyS; + } } void ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::fetchAll() @@ -199,13 +199,13 @@ void ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::fetchAll() fetchMeshes(); int nbOfArrays=_arrays.size(); for(int i=0;igetArray(i); - if(_arrays[i]) - _arrays[i]->Delete(); - _arrays[i]=ParaMEDMEM2VTK::BuildFromMEDCouplingFieldDoubleArr(daPtr); - daPtr->UnRegister(); - } + { + SALOME_MED::DataArrayDoubleCorbaInterface_var daPtr=_mfields_ptr->getArray(i); + if(_arrays[i]) + _arrays[i]->Delete(); + _arrays[i]=ParaMEDMEM2VTK::BuildFromMEDCouplingFieldDoubleArr(daPtr); + daPtr->UnRegister(); + } unregisterRemoteServantIfAllFetched(); } @@ -216,15 +216,15 @@ void ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::fetchMeshes() { int nbOfMeshes=_meshes.size(); for(int i=0;igetMeshWithId(i); - if(_meshes[i]) - _meshes[i]->Delete(); - bool polyh=false;//bug VTK - _meshes[i]=ParaMEDMEM2VTK::BuildFromMEDCouplingMeshInstance(mPtr,polyh);//bug VTK - _is_meshes_polyhedron[i]=polyh;//bug VTK - mPtr->UnRegister(); - } + { + SALOME_MED::MEDCouplingMeshCorbaInterface_var mPtr=_mfields_ptr->getMeshWithId(i); + if(_meshes[i]) + _meshes[i]->Delete(); + bool polyh=false;//bug VTK + _meshes[i]=ParaMEDMEM2VTK::BuildFromMEDCouplingMeshInstance(mPtr,polyh);//bug VTK + _is_meshes_polyhedron[i]=polyh;//bug VTK + mPtr->UnRegister(); + } unregisterRemoteServantIfAllFetched(); } @@ -237,65 +237,65 @@ void ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::fetchDataIfNeeded(int fieldI std::vector arrayIds=_array_ids_per_field[fieldId]; int meshId=_mesh_id_per_field[fieldId]; if(!_meshes[meshId]) - { - SALOME_MED::MEDCouplingMeshCorbaInterface_var mPtr=_mfields_ptr->getMeshWithId(meshId); - bool polyh=false;//bug VTK - _meshes[meshId]=ParaMEDMEM2VTK::BuildFromMEDCouplingMeshInstance(mPtr,polyh);//bug VTK - _is_meshes_polyhedron[meshId]=polyh;//bug VTK - mPtr->UnRegister(); - } + { + SALOME_MED::MEDCouplingMeshCorbaInterface_var mPtr=_mfields_ptr->getMeshWithId(meshId); + bool polyh=false;//bug VTK + _meshes[meshId]=ParaMEDMEM2VTK::BuildFromMEDCouplingMeshInstance(mPtr,polyh);//bug VTK + _is_meshes_polyhedron[meshId]=polyh;//bug VTK + mPtr->UnRegister(); + } for(std::vector::const_iterator it=arrayIds.begin();it!=arrayIds.end();it++) + { + if(!_arrays[*it]) { - if(!_arrays[*it]) - { - SALOME_MED::DataArrayDoubleCorbaInterface_var daPtr=_mfields_ptr->getArray(*it); - _arrays[*it]=ParaMEDMEM2VTK::BuildFromMEDCouplingFieldDoubleArr(daPtr); - daPtr->UnRegister(); - } + SALOME_MED::DataArrayDoubleCorbaInterface_var daPtr=_mfields_ptr->getArray(*it); + _arrays[*it]=ParaMEDMEM2VTK::BuildFromMEDCouplingFieldDoubleArr(daPtr); + daPtr->UnRegister(); } + } unregisterRemoteServantIfAllFetched(); } void ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::unregisterRemoteServantIfAllFetched() { for(std::vector::iterator it=_meshes.begin();it!=_meshes.end();it++) - { - if((*it)==0) - return ; - } + { + if((*it)==0) + return ; + } for(std::vector::iterator it2=_arrays.begin();it2!=_arrays.end();it2++) - { - if((*it2)==0) - return ; - } + { + if((*it2)==0) + return ; + } if(!_mfields_ptr_released) - { - _mfields_ptr_released=true; - _mfields_ptr->UnRegister(); - } + { + _mfields_ptr_released=true; + _mfields_ptr->UnRegister(); + } } void ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::applyBufferingPolicy() { if(_effective_pol==0) - {// - for(std::vector::iterator it=_meshes.begin();it!=_meshes.end();it++) - { - if(*it) - { - (*it)->Delete(); - *it=0; - } - } - for(std::vector::iterator it2=_arrays.begin();it2!=_arrays.end();it2++) - { - if(*it2) - { - (*it2)->Delete(); - *it2=0; - } - } + {// + for(std::vector::iterator it=_meshes.begin();it!=_meshes.end();it++) + { + if(*it) + { + (*it)->Delete(); + *it=0; + } + } + for(std::vector::iterator it2=_arrays.begin();it2!=_arrays.end();it2++) + { + if(*it2) + { + (*it2)->Delete(); + *it2=0; + } } + } //else nothing to do let the plugin bufferize } @@ -305,15 +305,15 @@ void ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::appendFieldValueOnAlreadyFet vtkDoubleArray *arr=_arrays[_array_ids_per_field[fieldId].front()]; arr->SetName(info._name.c_str()); if(info._type==0)//ON_CELLS - { - ds->GetCellData()->AddArray(arr); - return ; - } + { + ds->GetCellData()->AddArray(arr); + return ; + } if(info._type==1)//ON_NODES - { - ds->GetPointData()->AddArray(arr); - return ; - } + { + ds->GetPointData()->AddArray(arr); + return ; + } } int ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::getPosGivenTimeLabel(double t) @@ -324,7 +324,7 @@ int ParaMEDMEM2VTK::MEDCouplingMultiFieldsFetcher::getPosGivenTimeLabel(double t return i; //2nd chance std::vector::iterator it=std::find_if(_time_label_per_field.begin(),_time_label_per_field.end(), - std::bind2nd(std::greater(),t)); + std::bind2nd(std::greater(),t)); if(it!=_time_label_per_field.end() && it!=_time_label_per_field.end()) return std::distance(_time_label_per_field.begin(),it); //