From 751073e29fb4f1b9c26b3c9ac36372d6990215dc Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 31 Aug 2005 04:30:20 +0000 Subject: [PATCH] Minor changes --- src/CONVERTOR/VISU_Convertor.hxx | 1 - src/CONVERTOR/VISU_Convertor_impl.cxx | 184 +++++++++++++------------- src/CONVERTOR/VISU_Convertor_impl.hxx | 20 ++- src/CONVERTOR/VISU_MedConvertor.cxx | 59 +++------ src/VISU_I/VISU_CorbaMedConvertor.cxx | 3 - 5 files changed, 127 insertions(+), 140 deletions(-) diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index dcf3b10c..8097a660 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -222,7 +222,6 @@ namespace VISU //--------------------------------------------------------------- - typedef std::pair TFamilyAndEntity; typedef std::set TFamilySet; struct TGroup: virtual TBaseStructure diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 0cc816a3..82568e22 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -59,7 +59,7 @@ static int MYVTKDEBUG = 0; #ifdef _DEBUG_ static int MYDEBUG = 1; -static int MYDEBUGWITHFILES = 0; +static int MYDEBUGWITHFILES = 1; #else static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; @@ -342,7 +342,6 @@ namespace VISU ::TGaussMeshImpl() {} - //--------------------------------------------------------------- TGaussPointID TGaussMeshImpl ::GetObjID(int theVtkI) const @@ -360,21 +359,41 @@ namespace VISU return aRetVID; } + //--------------------------------------------------------------- - pair + vtkIdType TMeshOnEntityImpl - ::GetCellsDims(const string& theFamilyName) const + ::GetElemVTKID(vtkIdType theID) const { - if(theFamilyName == "") - return make_pair(myNbCells,myCellsSize); + TObj2VTKID::const_iterator anIter = std::find(myObj2VTKID.begin(), + myObj2VTKID.end(), + theID); + if(anIter != myObj2VTKID.end()) + return *anIter; + return -1; + } - TFamilyMap::const_iterator aFamilyMapIter = myFamilyMap.find(theFamilyName); - if(aFamilyMapIter == myFamilyMap.end()) - throw std::runtime_error("GetCellsDims >> There is no family on the mesh with entity !!!"); + vtkIdType + TMeshOnEntityImpl + ::GetElemObjID(vtkIdType theID) const + { + return myObj2VTKID[theID]; + } - PFamilyImpl aFamily = aFamilyMapIter->second; - return make_pair(aFamily->myNbCells,aFamily->myCellsSize); + //--------------------------------------------------------------- + TNbASizeCells + TGroupImpl + ::GetNbASizeCells() const + { + vtkIdType aNbCells = 0, aCellsSize = 0; + TFamilySet::const_iterator anIter = myFamilySet.begin(); + for(; anIter == myFamilySet.end(); anIter++){ + PFamilyImpl aFamily = *anIter; + aNbCells += aFamily->myNbCells; + aCellsSize += aFamily->myCellsSize; + } + return make_pair(aNbCells,aCellsSize); } @@ -691,53 +710,30 @@ namespace //--------------------------------------------------------------- void GetCellsOnEntity(const TVTKSource& theSource, - const PMeshOnEntityImpl& theMeshOnEntity, - const std::string& theFamilyName = "") + const PMeshOnEntityImpl& theMeshOnEntity) { - //Check on existing family - PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName); - //Main part of code - pair aCellsDim = theMeshOnEntity->GetCellsDims(theFamilyName); - int aNbCells = aCellsDim.first, aCellsSize = aCellsDim.second; + INITMSG(MYDEBUG,"GetCellsOnEntity"<myNbCells; + vtkIdType aCellsSize = theMeshOnEntity->myCellsSize; + vtkCellArray* aConnectivity = vtkCellArray::New(); aConnectivity->Allocate(aCellsSize,0); vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); aCellTypesArray->SetNumberOfComponents(1); aCellTypesArray->SetNumberOfTuples(aNbCells); - INITMSG(MYDEBUG,"GetCellsOnEntity - isFamilyPresent = "<myGeom2Cell2Connect; VISU::TGeom2Cell2Connect::const_iterator aGeom2Cell2ConnectIter = aGeom2Cell2Connect.begin(); - for(int i = 0, j = 0; aGeom2Cell2ConnectIter != aGeom2Cell2Connect.end(); aGeom2Cell2ConnectIter++){ + for(vtkIdType i = 0, j = 0; aGeom2Cell2ConnectIter != aGeom2Cell2Connect.end(); aGeom2Cell2ConnectIter++){ const VISU::TCell2Connect& anArray = aGeom2Cell2ConnectIter->second; vtkIdType aGeom = aGeom2Cell2ConnectIter->first; INITMSG(MYDEBUG,"aGeom = "<> There is no elements on the family !!!"); - - VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aGeom); - if(aGeom2SubMeshIDIter == aGeom2SubMeshID.end()) - continue; - - const VISU::TSubMeshID& aSubMeshID = aGeom2SubMeshIDIter->second; - - INITMSG(MYDEBUG,"aSubMeshID.size() = "<SetValue(j++,(unsigned char)aGeom); - } + for(vtkIdType k = 0, kEnd = anArray.size(); k < kEnd; k++, i++){ + PrintCells(i,aConnectivity,anArray[k]); + aCellTypesArray->SetValue(j++,(unsigned char)aGeom); } } vtkIdType *pts = 0, npts = 0; @@ -748,7 +744,9 @@ namespace for(int i=0; aConnectivity->GetNextCell(npts,pts); i++) aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts)); theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity); + if(MYVTKDEBUG) aConnectivity->DebugOn(); + aCellLocationsArray->Delete(); aCellTypesArray->Delete(); aConnectivity->Delete(); @@ -757,51 +755,44 @@ namespace //--------------------------------------------------------------- void - GetCellsOnGroup(const TVTKSource& theSource, - const PMeshImpl& theMesh, - const TFamilySet& theFamilySet) + GetCellsOnFamily(const TVTKSource& theSource, + const PMeshOnEntityImpl& theMeshOnEntity, + const PFamilyImpl& theFamily) { - //Calculate dimentions of the group - INITMSG(MYDEBUG,"GetCellsOnGroup\n"); - int aNbCells = 0, aCellsSize = 0; - VISU::TFamilySet::const_iterator aFamilyIter = theFamilySet.begin(); - for(; aFamilyIter != theFamilySet.end(); aFamilyIter++){ - VISU::PFamilyImpl aFamily = *aFamilyIter; - aCellsSize += aFamily->myCellsSize; - aNbCells += aFamily->myNbCells; - } + INITMSG(MYDEBUG,"GetCellsOnFamily"<myNbCells; + vtkIdType aCellsSize = theFamily->myCellsSize; + vtkCellArray* aConnectivity = vtkCellArray::New(); aConnectivity->Allocate(aCellsSize,0); vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); aCellTypesArray->SetNumberOfComponents(1); aCellTypesArray->SetNumberOfTuples(aNbCells); - aFamilyIter = theFamilySet.begin(); - for(int i = 0, j = 0; aFamilyIter != theFamilySet.end(); aFamilyIter++){ - VISU::PFamilyImpl aFamily = *aFamilyIter; - const std::string& aFamilyName = aFamily->myName; - const VISU::TEntity& anEntity = aFamily->myEntity; - PMeshOnEntityImpl aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; - const VISU::TGeom2Cell2Connect &aGeom2Cell2Connect = aMeshOnEntity->myGeom2Cell2Connect; - VISU::TGeom2Cell2Connect::const_iterator aGeom2Cell2ConnectIter = aGeom2Cell2Connect.begin(); - for(; aGeom2Cell2ConnectIter != aGeom2Cell2Connect.end(); aGeom2Cell2ConnectIter++){ - const VISU::TCell2Connect& anArray = aGeom2Cell2ConnectIter->second; - vtkIdType aGeom = aGeom2Cell2ConnectIter->first; - INITMSG(MYDEBUG,"aGeom = "<myGeom2SubMeshID; - if(aGeom2SubMeshID.empty()) - EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!"); - - VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aGeom); - if(aGeom2SubMeshIDIter != aGeom2SubMeshID.end()){ - const VISU::TSubMeshID& aSubMeshID = aGeom2SubMeshIDIter->second; - INITMSG(MYDEBUG,"aSubMeshID.size() = "<SetValue(j++,(unsigned char)aGeom); - } - } + + const VISU::TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect; + VISU::TGeom2Cell2Connect::const_iterator aGeom2Cell2ConnectIter = aGeom2Cell2Connect.begin(); + for(vtkIdType i = 0, j = 0; aGeom2Cell2ConnectIter != aGeom2Cell2Connect.end(); aGeom2Cell2ConnectIter++){ + const VISU::TCell2Connect& anArray = aGeom2Cell2ConnectIter->second; + vtkIdType aGeom = aGeom2Cell2ConnectIter->first; + const VISU::TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID; + if(aGeom2SubMeshID.empty()) + EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!"); + + VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aGeom); + if(aGeom2SubMeshIDIter == aGeom2SubMeshID.end()) + continue; + + const VISU::TSubMeshID& aSubMeshID = aGeom2SubMeshIDIter->second; + + INITMSG(MYDEBUG,"aGeom = "<myIsVTKDone){ if(MYVTKDEBUG) aSource->DebugOn(); + GetMeshOnEntity(theMeshName,theEntity); + LoadFamilyOnEntity(aMesh,aMeshOnEntity,aFamily); GetPoints(aSource,aMesh); - GetCellsOnEntity(aSource,aMeshOnEntity,theFamilyName); + GetCellsOnFamily(aSource,aMeshOnEntity,aFamily); aFamily->myIsVTKDone = true; if(MYDEBUGWITHFILES){ std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); std::string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1(); - std::string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-"; + std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-"; aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-Conv.vtk"; VISU::WriteToFile(aSource.GetPointer(),aFileName); } @@ -1475,7 +1471,7 @@ VISU_Convertor_impl if(MYDEBUGWITHFILES){ std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); std::string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1(); - std::string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-"; + std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-"; aFileName += aMeshName + "-" + aGroupName + "-Conv.vtk"; VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName); } @@ -1550,7 +1546,7 @@ VISU_Convertor_impl if(MYDEBUGWITHFILES){ string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1(); - string aPrefix = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-"; + string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-"; string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk"; VISU::WriteToFile(aSource.GetPointer(),aFileName); @@ -1647,7 +1643,7 @@ VISU_Convertor_impl if(MYDEBUGWITHFILES){ string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1(); - string aPrefix = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-"; + string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-"; string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk"; VISU::WriteToFile(aSource.GetPointer(),aFileName); @@ -1915,7 +1911,9 @@ VISU_Convertor_impl PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup); vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord); - vtkIdType aNbCells = aGroup->myNbCells, aCellsSize = aGroup->myCellsSize; + TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells(); + vtkIdType aNbCells = aNbASizeCells.first; + vtkIdType aCellsSize = aNbASizeCells.second; vtkIdType aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType); vtkIdType aLocationsSize = aNbCells*sizeof(int); float aNbCellsPerPoint = aCellsSize / aNbCells - 1; diff --git a/src/CONVERTOR/VISU_Convertor_impl.hxx b/src/CONVERTOR/VISU_Convertor_impl.hxx index 398bd585..7e5eed04 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.hxx +++ b/src/CONVERTOR/VISU_Convertor_impl.hxx @@ -168,7 +168,6 @@ namespace VISU //--------------------------------------------------------------- typedef TVector TSubMeshID; - typedef std::map TGeom2SubMeshID; typedef enum {eRemoveAll, eAddAll, eAddPart, eNone} ESubMeshStatus; struct TSubProfileImpl: virtual TSubProfile, virtual TSource @@ -190,7 +189,7 @@ namespace VISU //--------------------------------------------------------------- typedef std::map TElemObj2VTKID; - typedef std::vector TSubProfileArr; + typedef TVector TSubProfileArr; typedef std::map TGeom2SubProfile; struct TProfileImpl: virtual TProfile, virtual TAppendFilter @@ -258,7 +257,7 @@ namespace VISU //--------------------------------------------------------------- - typedef std::vector TGaussSubMeshArr; + typedef TVector TGaussSubMeshArr; typedef std::map TGeom2GaussSubMesh; struct TGaussMeshImpl: virtual TGaussMesh, virtual TAppendFilter @@ -280,12 +279,17 @@ namespace VISU typedef TVector TCell2Connect; typedef std::map TGeom2Cell2Connect; + typedef TVector TObj2VTKID; + struct TMeshOnEntityImpl: virtual TMeshOnEntity, virtual TSource { TGeom2Cell2Connect myGeom2Cell2Connect; - std::pair - GetCellsDims(const std::string& theFamilyName = "") const; + virtual + vtkIdType + GetElemObjID(int theVtkI) const; + + TObj2VTKID myObj2VTKID; }; typedef SharedPtr PMeshOnEntityImpl; @@ -309,8 +313,12 @@ namespace VISU //--------------------------------------------------------------- - struct TGroupImpl: virtual TGroup, virtual TAppendFilter, virtual TSizeCounter + typedef std::pair TNbASizeCells; + + struct TGroupImpl: virtual TGroup, virtual TAppendFilter { + TNbASizeCells + GetNbASizeCells() const; }; typedef SharedPtr PGroupImpl; diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 95daccbd..9b199fa1 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -721,18 +721,10 @@ namespace "- aFamilyName = '"<myNbCells += aFamily->myNbCells; - aGroup->myCellsSize += aFamily->myCellsSize; } } - if(!aFamilySet.empty() && aGroup->myNbCells > 0){ - BEGMSG(MY_GROUP_DEBUG, - "- myNbCells = "<myNbCells<< - "; myCellsSize = "<myCellsSize<< - "\n"); + if(!aFamilySet.empty()) aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup)); - } } } @@ -1224,6 +1216,7 @@ VISU_MedConvertor } }} } + theMeshOnEntity->myIsDone = true; return 1; @@ -1262,48 +1255,40 @@ VISU_MedConvertor TInt anId = theFamily->myId; const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo; + TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID; + const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size; MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin(); TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect; - for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){ const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first; - int aVGeom = MEDGeomToVTK(aMGeom); - INITMSG(MYDEBUG,"aMGeom = "<GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom); - TInt aNbElem = aPolygoneInfo->GetNbElem(); - - TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aVGeom]; - for(int iElem = 0; iElem < aNbElem; iElem++) - if(aPolygoneInfo->GetFamNum(iElem) == anId) - aSubMeshID.push_back(iElem); - + anElemInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom); break; } case MED::ePOLYEDRE: { - MED::PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom); - TInt aNbElem = aPolyedreInfo->GetNbElem(); - - TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aVGeom]; - for(int iElem = 0; iElem < aNbElem; iElem++) - if(aPolyedreInfo->GetFamNum(iElem) == anId) - aSubMeshID.push_back(iElem); - + anElemInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom); break; } default: { - int aVNbNodes = VTKGeom2NbNodes(aVGeom); - - MED::PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom); - TInt aNbElem = aCellInfo->GetNbElem(); - - TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aVGeom]; - for(int iElem = 0; iElem < aNbElem; iElem++) - if(aCellInfo->GetFamNum(iElem) == anId) - aSubMeshID.push_back(iElem); + anElemInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom); + break; }} + if(anElemInfo){ + if(TInt aNbElem = anElemInfo->GetNbElem()){ + TSubMeshID aSubMeshID; + for(TInt iElem = 0; iElem < aNbElem; iElem++) + if(anElemInfo->GetFamNum(iElem) == anId) + aSubMeshID.push_back(iElem); + if(!aSubMeshID.empty()){ + TInt aVGeom = MEDGeomToVTK(aMGeom); + INITMSG(MYDEBUG,"aMGeom = "<myIsDone = true; diff --git a/src/VISU_I/VISU_CorbaMedConvertor.cxx b/src/VISU_I/VISU_CorbaMedConvertor.cxx index 56f5c2b3..676609c5 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.cxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.cxx @@ -679,9 +679,6 @@ VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED) if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup - aFamilyName = '"<myNbCells += aFamily->myNbCells; - aGroup->myCellsSize += aFamily->myCellsSize; } } -- 2.39.2