From 9c1c14a8e1edfff8dee153f13f843d2fa56780c2 Mon Sep 17 00:00:00 2001 From: apo Date: Thu, 28 Jul 2005 05:12:19 +0000 Subject: [PATCH] To introduce new way of points coordinates handling - special structures TPointCoords and TNamedPointCoords are designed and used in TMesh and TGaussMesh structures respectively --- src/CONVERTOR/VISU_Convertor_impl.cxx | 590 +++++++++++++++++--------- src/CONVERTOR/VISU_Convertor_impl.hxx | 97 +++-- src/VISU_I/VISU_CorbaMedConvertor.cxx | 180 +++++--- src/VISU_I/VISU_CorbaMedConvertor.hxx | 42 +- 4 files changed, 612 insertions(+), 297 deletions(-) diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index aab17891..95381c6d 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -57,8 +57,8 @@ static float ERR_SIZE_CALC = 1.00; static int MYVTKDEBUG = 0; #ifdef _DEBUG_ -static int MYDEBUG = 1; -static int MYDEBUGWITHFILES = 0; +static int MYDEBUG = 0; +static int MYDEBUGWITHFILES = 1; #else static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; @@ -68,9 +68,20 @@ static int MYDEBUGWITHFILES = 0; namespace VISU { //--------------------------------------------------------------- - TSource::TSource(): + TIsVTKDone::TIsVTKDone(): + myIsVTKDone(false) + {} + + + //--------------------------------------------------------------- + TSizeCounter::TSizeCounter(): myNbCells(0), - myCellsSize(0), + myCellsSize(0) + {} + + + //--------------------------------------------------------------- + TSource::TSource(): mySource(vtkUnstructuredGrid::New()) { mySource->Delete(); @@ -78,30 +89,70 @@ namespace VISU //--------------------------------------------------------------- + TAppendFilter::TAppendFilter(): + myFilter(vtkAppendFilter::New()) + { + myFilter->Delete(); + } + + + //--------------------------------------------------------------- + TPointCoords + ::TPointCoords(): + myPoints(vtkPoints::New()) + { + myPoints->Delete(); + } + void - TPoints - ::Init(vtkIdType theNbCells, + TPointCoords + ::Init(vtkIdType theNbPoints, vtkIdType theDim) { myDim = theDim; - myNbCells = theNbCells; - myCoord.resize(theNbCells*theDim); + myNbPoints = theNbPoints; + myCoord.resize(theNbPoints*theDim); + myPoints->SetNumberOfPoints(theNbPoints); } - TCPointSlice - TPoints - ::GetPointSlice(vtkIdType theCellId) const + TCCoordSlice + TPointCoords + ::GetCoordSlice(vtkIdType theNodeId) const { - return TCPointSlice(myCoord,std::slice(theCellId*myDim,myDim,1)); + return TCCoordSlice(myCoord,std::slice(theNodeId*myDim,myDim,1)); } - TPointSlice - TPoints - ::GetPointSlice(vtkIdType theCellId) + TCoordSlice + TPointCoords + ::GetCoordSlice(vtkIdType theNodeId) + { + return TCoordSlice(myCoord,std::slice(theNodeId*myDim,myDim,1)); + } + + + //--------------------------------------------------------------- + void + TNamedPointCoords + ::Init(vtkIdType theNbPoints, + vtkIdType theDim) { - return TPointSlice(myCoord,std::slice(theCellId*myDim,myDim,1)); + TPointCoords::Init(theNbPoints,theDim); + myPointsDim.resize(theDim); } + std::string& + TNamedPointCoords + ::GetName(vtkIdType theDim) + { + return myPointsDim[theDim]; + } + + const std::string& + TNamedPointCoords + ::GetName(vtkIdType theDim) const + { + return myPointsDim[theDim]; + } //--------------------------------------------------------------- TMeshImpl::TMeshImpl(): @@ -135,11 +186,8 @@ namespace VISU //--------------------------------------------------------------- TProfileImpl::TProfileImpl(): - myIsAll(true), - myAppendFilter(vtkAppendFilter::New()) - { - myAppendFilter->Delete(); - } + myIsAll(true) + {} //--------------------------------------------------------------- @@ -239,20 +287,18 @@ namespace //--------------------------------------------------------------- enum ECoordName{eX, eY, eZ, eNone}; - typedef VISU::TCoord (*TGetCoord)(const VISU::TPointsCoord&, int); + typedef VISU::TCoord (*TGetCoord)(const VISU::TCCoordSlice& theCoordSlice); - template + template VISU::TCoord - GetCoord(const VISU::TPointsCoord& thePointsCoord, - int theStartPos) + GetCoord(const VISU::TCCoordSlice& theCoordSlice) { - return thePointsCoord[theStartPos+TheCoordId]; + return theCoordSlice[TCoordId]; } template<> VISU::TCoord - GetCoord(const VISU::TPointsCoord& thePointsCoord, - int theStartPos) + GetCoord(const VISU::TCCoordSlice& theCoordSlice) { return 0.0; } @@ -304,83 +350,87 @@ namespace class TCoordHelper{ - const VISU::TPointsCoord& myPointsCoord; TGetCoord* myGetCoord; public: - TCoordHelper(const VISU::TPointsCoord& thePointsCoord, - TGetCoord* theGetCoord): - myPointsCoord(thePointsCoord), + TCoordHelper(TGetCoord* theGetCoord): myGetCoord(theGetCoord) {} - virtual ~TCoordHelper(){} + + virtual + ~TCoordHelper() + {} + VISU::TCoord - GetCoord(int theStartPos, int theCoodId) + GetCoord(VISU::TCCoordSlice& theCoordSlice, + int theCoordId) { - return (*myGetCoord[theCoodId])(myPointsCoord,theStartPos); + return (*myGetCoord[theCoordId])(theCoordSlice); } }; typedef std::auto_ptr TCoordHelperPtr; + //--------------------------------------------------------------- void GetPoints(VISU::TVTKSource& theSource, VISU::PMeshImpl theMesh) { TVTKPoints& aPoints = theMesh->myPoints; + const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords; if(!theMesh->myIsVTKDone){ TCoordHelperPtr aCoordHelperPtr; - const VISU::TPointsCoord& anArray = theMesh->myPointsCoord; { int aMeshDimension = theMesh->myDim; bool anIsDimPresent[3] = {false, false, false}; for(int iDim = 0; iDim < aMeshDimension; iDim++){ - string aDimName = theMesh->myPointsDim[iDim]; - if(aDimName == "x" || aDimName == "X") + const std::string& aName = aCoords.GetName(iDim); + if(aName == "x" || aName == "X") anIsDimPresent[eX] = true; - else if(aDimName == "y" || aDimName == "Y") + else if(aName == "y" || aName == "Y") anIsDimPresent[eY] = true; - else if(aDimName == "z" || aDimName == "Z") + else if(aName == "z" || aName == "Z") anIsDimPresent[eZ] = true; } switch(aMeshDimension){ case 3: - aCoordHelperPtr.reset(new TCoordHelper(anArray,aXYZGetCoord)); + aCoordHelperPtr.reset(new TCoordHelper(aXYZGetCoord)); break; case 2: if(anIsDimPresent[eY] && anIsDimPresent[eZ]) - aCoordHelperPtr.reset(new TCoordHelper(anArray,aYZGetCoord)); + aCoordHelperPtr.reset(new TCoordHelper(aYZGetCoord)); else if(anIsDimPresent[eX] && anIsDimPresent[eZ]) - aCoordHelperPtr.reset(new TCoordHelper(anArray,aXZGetCoord)); + aCoordHelperPtr.reset(new TCoordHelper(aXZGetCoord)); else - aCoordHelperPtr.reset(new TCoordHelper(anArray,aXYGetCoord)); + aCoordHelperPtr.reset(new TCoordHelper(aXYGetCoord)); break; case 1: if(anIsDimPresent[eY]) - aCoordHelperPtr.reset(new TCoordHelper(anArray,aYGetCoord)); + aCoordHelperPtr.reset(new TCoordHelper(aYGetCoord)); else if(anIsDimPresent[eZ]) - aCoordHelperPtr.reset(new TCoordHelper(anArray,aZGetCoord)); + aCoordHelperPtr.reset(new TCoordHelper(aZGetCoord)); else - aCoordHelperPtr.reset(new TCoordHelper(anArray,aXGetCoord)); + aCoordHelperPtr.reset(new TCoordHelper(aXGetCoord)); break; } } - vtkIdType iEnd = theMesh->myPointsCoord.size(); - vtkIdType aNbPoints = iEnd / theMesh->myDim; + vtkIdType aNbPoints = aCoords.GetNbPoints(); aPoints->SetNumberOfPoints(aNbPoints); - + INITMSG(MYDEBUG,"GetPoints - aNbPoints = "<myDataSize/theField->myNbComp; string aFieldName = GenerateFieldName(theField,theValForTime); - INITMSG(MYDEBUG,"GetTimeStamp2 - aNbTuples = "<> There is no elements for the GEOM("<second; + + vtkCellArray* aConnectivity = vtkCellArray::New(); + aConnectivity->Allocate(aCellsSize,0); + vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); + aCellTypesArray->SetNumberOfComponents(1); + aCellTypesArray->SetNumberOfTuples(aNbCells); + + if(theSubProfile->myStatus == eAddAll){ + VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin(); + for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){ + const TConnect& anArray = aCell2Connect[anId]; + PrintCells(aConnId,aConnectivity,anArray); + aCellTypesArray->SetValue(anId,(unsigned char)aGeom); + aConnId += aNbNodes; + anId++; + } + }else{ + VISU::TSubMeshID::const_iterator anIter = aSubMeshID.begin(); + for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){ + vtkIdType aSubId = *anIter; + const TConnect& anArray = aCell2Connect[aSubId]; + PrintCells(aConnId,aConnectivity,anArray); + aCellTypesArray->SetValue(anId,(unsigned char)aGeom); + aConnId += aNbNodes; + anId++; + } + } + + vtkIdType *pts = 0, npts = 0; + vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + + aCellLocationsArray->SetNumberOfComponents(1); + aCellLocationsArray->SetNumberOfTuples(aNbCells); + aConnectivity->InitTraversal(); + for(int i=0; aConnectivity->GetNextCell(npts,pts); i++) + aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts)); + theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity); + + aCellLocationsArray->Delete(); + aCellTypesArray->Delete(); + aConnectivity->Delete(); + } + + + //--------------------------------------------------------------- + void + GetMeshOnSubProfile(PMeshImpl theMesh, + PMeshOnEntityImpl theMeshOnEntity, + PProfileImpl theProfile, + PSubProfileImpl theSubProfile) + { + INITMSG(MYDEBUG,"GetMeshOnSubProfile - aGeom = "<myGeom<mySource; + if(theSubProfile->myIsVTKDone) + return; + + GetPoints(aSource,theMesh); + INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<GetNumberOfPoints()<GetNumberOfCells()<myIsVTKDone = true; + } + + + //--------------------------------------------------------------- + void + GetMeshOnProfile(PMeshImpl theMesh, + PMeshOnEntityImpl theMeshOnEntity, + PProfileImpl theProfile) + { + if(theProfile->myIsVTKDone) + return; + + TVTKAppendFilter& anAppendFilter = theProfile->myFilter; + if(theProfile->myIsAll){ + TVTKSource& aSource = theMeshOnEntity->mySource; + anAppendFilter->AddInput(aSource.GetPointer()); + }else{ + const TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile; + TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin(); + for(; anIter != aGeom2SubProfile.end(); anIter++){ + PSubProfileImpl aSubProfile = anIter->second; + if(aSubProfile->myStatus == eRemoveAll) + continue; + + GetMeshOnSubProfile(theMesh, + theMeshOnEntity, + theProfile, + aSubProfile); + + TVTKSource& aSource = aSubProfile->mySource; + anAppendFilter->AddInput(aSource.GetPointer()); + } + } + anAppendFilter->Update(); // Fix on VTK + + theProfile->myIsVTKDone = true; + } + + + //--------------------------------------------------------------- + void + GetSource(VISU::TVTKSource& theSource, + PGaussSubMeshImpl theGaussSubMesh, + PMeshOnEntityImpl theMeshOnEntity) + { + const TPointCoords& aCoords = theGaussSubMesh->myPointCoords; + vtkIdType aNbPoints = aCoords.GetNbPoints(); + vtkIdType aDim = aCoords.GetDim(); + + vtkIdType aNbCells = theGaussSubMesh->myNbCells; + vtkIdType aCellsSize = theGaussSubMesh->myCellsSize; + + vtkCellArray* aConnectivity = vtkCellArray::New(); + aConnectivity->Allocate(aCellsSize,0); + vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); + aCellTypesArray->SetNumberOfComponents(1); + aCellTypesArray->SetNumberOfTuples(aNbCells); + + const TVTKPoints& aPoints = aCoords.GetPoints(); + vtkIdList *anIdList = vtkIdList::New(); + anIdList->SetNumberOfIds(1); + for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){ + TCCoordSlice aSlice = aCoords.GetCoordSlice(aPointId); + + float aCoords[3] = {0.0, 0.0, 0.0}; + for(vtkIdType aDimId = 0; aDimId < aDim; aDimId++) + aCoords[aDimId] = aSlice[aDimId]; + + aPoints->SetPoint(aPointId,aCoords); + + anIdList->SetId(0,aPointId); + aConnectivity->InsertNextCell(anIdList); + aCellTypesArray->SetValue(aPointId,(unsigned char)VTK_VERTEX); + } + anIdList->Delete(); + + vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + aCellLocationsArray->SetNumberOfComponents(1); + aCellLocationsArray->SetNumberOfTuples(aNbCells); + + vtkIdType *pts = 0, npts = 0; + aConnectivity->InitTraversal(); + for(int i = 0; aConnectivity->GetNextCell(npts,pts); i++) + aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts)); + + TVTKSource& aSource = theGaussSubMesh->mySource; + aSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity); + aSource->SetPoints(aPoints.GetPointer()); + + aCellLocationsArray->Delete(); + aCellTypesArray->Delete(); + aConnectivity->Delete(); + } + + + //--------------------------------------------------------------- + void + GetGaussSubMesh(PMeshImpl theMesh, + PMeshOnEntityImpl theMeshOnEntity, + PGaussMeshImpl theGaussMesh, + PGaussSubMeshImpl theGaussSubMesh) + { + PGaussImpl aGauss = theGaussSubMesh->myGauss; + INITMSG(MYDEBUG,"GetGaussSubMesh - aGeom = "<myGeom<mySource; + if(theGaussSubMesh->myIsVTKDone) + return; + + GetSource(aSource,theGaussSubMesh,theMeshOnEntity); + INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<GetNumberOfPoints()<GetNumberOfCells()<myIsVTKDone = true; + } + + + //--------------------------------------------------------------- + void + GetGaussMesh(PMeshImpl theMesh, + PMeshOnEntityImpl theMeshOnEntity, + PGaussMeshImpl theGaussMesh) + { + if(theGaussMesh->myIsVTKDone) + return; + + TVTKAppendFilter& anAppendFilter = theGaussMesh->myFilter; + const TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh; + TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin(); + for(; anIter != aGeom2GaussSubMesh.end(); anIter++){ + PGaussSubMeshImpl aGaussSubMesh = anIter->second; + if(aGaussSubMesh->myStatus == eRemoveAll) + continue; + + GetGaussSubMesh(theMesh, + theMeshOnEntity, + theGaussMesh, + aGaussSubMesh); + + TVTKSource& aSource = aGaussSubMesh->mySource; + anAppendFilter->AddInput(aSource.GetPointer()); + } + anAppendFilter->Update(); // Fix on VTK + + theGaussMesh->myIsVTKDone = true; } + + } +//--------------------------------------------------------------- VISU_Convertor_impl ::VISU_Convertor_impl() { myIsDone = false; } + +//--------------------------------------------------------------- VISU_Convertor_impl ::~VISU_Convertor_impl() {} + +//--------------------------------------------------------------- VISU_Convertor::TOutput* VISU_Convertor_impl ::GetMeshOnEntity(const string& theMeshName, @@ -764,6 +1059,8 @@ VISU_Convertor_impl return aSource.GetPointer(); } + +//--------------------------------------------------------------- VISU_Convertor::TOutput* VISU_Convertor_impl ::GetMeshOnGroup(const string& theMeshName, @@ -808,122 +1105,7 @@ VISU_Convertor_impl } -void -GetCells(VISU::TVTKSource& theSource, - PSubProfileImpl theSubProfile, - PMeshOnEntityImpl theMeshOnEntity) -{ - vtkIdType aNbCells = theSubProfile->myNbCells; - vtkIdType aCellsSize = theSubProfile->myCellsSize; - vtkIdType aGeom = theSubProfile->myGeom; - vtkIdType aNbNodes = VTKGeom2NbNodes(aGeom); - - const TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID; - const TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect; - TGeom2Cell2Connect::const_iterator aConnectIter = aGeom2Cell2Connect.find(aGeom); - if(aConnectIter == aGeom2Cell2Connect.end()) - EXCEPTION(runtime_error,"GetCells >> There is no elements for the GEOM("<second; - - vtkCellArray* aConnectivity = vtkCellArray::New(); - aConnectivity->Allocate(aCellsSize,0); - vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); - aCellTypesArray->SetNumberOfComponents(1); - aCellTypesArray->SetNumberOfTuples(aNbCells); - - if(theSubProfile->myStatus == eAddAll){ - VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin(); - for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){ - const TConnect& anArray = aCell2Connect[anId]; - PrintCells(aConnId,aConnectivity,anArray); - aCellTypesArray->SetValue(anId,(unsigned char)aGeom); - aConnId += aNbNodes; - anId++; - } - }else{ - VISU::TSubMeshID::const_iterator anIter = aSubMeshID.begin(); - for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){ - vtkIdType aSubId = *anIter; - const TConnect& anArray = aCell2Connect[aSubId]; - PrintCells(aConnId,aConnectivity,anArray); - aCellTypesArray->SetValue(anId,(unsigned char)aGeom); - aConnId += aNbNodes; - anId++; - } - } - - vtkIdType *pts = 0, npts = 0; - vtkIntArray* aCellLocationsArray = vtkIntArray::New(); - - aCellLocationsArray->SetNumberOfComponents(1); - aCellLocationsArray->SetNumberOfTuples(aNbCells); - aConnectivity->InitTraversal(); - for(int i=0; aConnectivity->GetNextCell(npts,pts); i++) - aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts)); - theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity); - - aCellLocationsArray->Delete(); - aCellTypesArray->Delete(); - aConnectivity->Delete(); -} - - -void -GetMeshOnSubProfile(PMeshImpl theMesh, - PMeshOnEntityImpl theMeshOnEntity, - PProfileImpl theProfile, - PSubProfileImpl theSubProfile) -{ - INITMSG(MYDEBUG,"GetMeshOnSubProfile - aGeom = "<myGeom<mySource; - if(theSubProfile->myIsVTKDone) - return; - - GetPoints(aSource,theMesh); - INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<GetNumberOfPoints()<GetNumberOfCells()<myIsVTKDone = true; -} - - -void -GetMeshOnProfile(PMeshImpl theMesh, - PMeshOnEntityImpl theMeshOnEntity, - PProfileImpl theProfile) -{ - if(theProfile->myIsVTKDone) - return; - - TVTKAppendFilter& anAppendFilter = theProfile->myAppendFilter; - if(theProfile->myIsAll){ - TVTKSource& aSource = theMeshOnEntity->mySource; - anAppendFilter->AddInput(aSource.GetPointer()); - }else{ - const TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile; - TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin(); - for(; anIter != aGeom2SubProfile.end(); anIter++){ - PSubProfileImpl aSubProfile = anIter->second; - if(aSubProfile->myStatus == eRemoveAll) - continue; - - GetMeshOnSubProfile(theMesh, - theMeshOnEntity, - theProfile, - aSubProfile); - - TVTKSource& aSource = aSubProfile->mySource; - anAppendFilter->AddInput(aSource.GetPointer()); - } - } - anAppendFilter->Update(); // Fix on VTK - theProfile->myIsVTKDone = true; -} - - +//--------------------------------------------------------------- VISU_Convertor::TOutput* VISU_Convertor_impl ::GetTimeStampOnMesh(const string& theMeshName, @@ -937,9 +1119,13 @@ VISU_Convertor_impl "; theFieldName = '"<FindAttribute(anAttr,"AttributeName")) { SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); @@ -211,6 +232,8 @@ namespace{ return ""; } + + //--------------------------------------------------------------- void GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize, SALOME_MED::MESH_ptr theMEDMesh, @@ -233,6 +256,7 @@ namespace{ } + //--------------------------------------------------------------- void GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize, SALOME_MED::FAMILY_ptr theMEDFamily) @@ -254,6 +278,7 @@ namespace{ } + //--------------------------------------------------------------- void GetCellsSize(VISU::PCMesh theMesh, SALOME_MED::MESH_ptr theMEDMesh, @@ -262,17 +287,14 @@ namespace{ TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[theEntity]; if(theEntity == NODE_ENTITY){ - theMesh->myNbPoints = theMEDMesh->getNumberOfNodes(); aMeshOnEntity->myNbCells = theMesh->myNbPoints; aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints; vtkIdType aNbCells, aCellsSize; GetCellsSize(aNbCells,aCellsSize,theMEDMesh,CELL_ENTITY); if(aNbCells > 0){ - TMeshOnEntityMap::iterator aIter = aMeshOnEntityMap.find(CELL_ENTITY); if (aIter != aMeshOnEntityMap.end()){ VISU::PCMeshOnEntity aMeshOnCells = aIter->second; - aMeshOnCells->myEntity = VISU::CELL_ENTITY; aMeshOnCells->myMeshName = theMesh->myName; aMeshOnCells->myNbCells = aNbCells; @@ -287,6 +309,7 @@ namespace{ } +//--------------------------------------------------------------- VISU_Convertor* VISU_MEDFieldConvertor::Build() { @@ -307,11 +330,14 @@ VISU_MEDFieldConvertor::Build() CORBA::String_var aFieldName = myField->getName(); PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh()); + aMesh->myNbPoints = aMEDMesh->getNumberOfNodes(); aMesh->myDim = aMEDMesh->getSpaceDimension(); - aMesh->myPointsDim.resize(aMesh->myDim); aMesh->myName = aMeshName.in(); aMesh->myMesh = aMEDMesh; + TNamedPointCoords& aCoords = aMesh->myNamedPointCoords; + aCoords.Init(aMesh->myNbPoints,aMesh->myDim); + if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<myMesh; - int iNumElemEnd = aMedMesh->getNumberOfNodes(); - TPointsCoord& aPointsCoord = theMesh->myPointsCoord; + int aDim = theMesh->myDim; + TNamedPointCoords& aCoords = theMesh->myNamedPointCoords; + int aNbElem = aCoords.GetNbPoints(); - if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "<> There is no points in the mesh !!!"); - aPointsCoord.resize(theMesh->myDim*iNumElemEnd,0.0); - SALOME_MED::double_array_var coord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE); - if(!isPointsLoaded){ - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh->myDim; iDim < theMesh->myDim; iDim++, iNumElem2Dim++) - aPointsCoord[iNumElem2Dim] = coord[iNumElem2Dim]; + SALOME_MED::double_array_var aCCoord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE); + if(!theMesh->myIsCDone){ + for(int iElem = 0, anId = 0; iElem < aNbElem; iElem++){ + VISU::TCoordSlice aCoordSlice = aCoords.GetCoordSlice(iElem); + for(int iDim = 0; iDim < aDim; iDim++) + aCoordSlice[iDim] = aCCoord[anId++]; + } if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY"); TCell2Connect& aCell2Connect = aMeshOnEntity->myGeom2Cell2Connect[VTK_VERTEX]; - aCell2Connect.resize(iNumElemEnd); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - aCell2Connect[iNumElem] = TConnect(1,iNumElem); + aCell2Connect.resize(aNbElem); + for(int iElem = 0; iElem < aNbElem; iElem++) + aCell2Connect[iElem] = TConnect(1,iElem); + + theMesh->myIsCDone = true; } - if(aFamily){ - if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily Geom2SubMeshID"); - - SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily; - CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements(); - TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[VTK_VERTEX]; - if(!anIsOnAllElements){ - SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes(); - SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]); - int iNumElemEndTmp = iNumElemEnd; - iNumElemEnd = aCellNumForType->length(); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) { - int tmp = aCellNumForType[iNumElem]-1; - if(0 > tmp || tmp >= iNumElemEndTmp) { - static QString aString; - aString.sprintf("LoadPoints >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEnd,iNumElem,tmp); - throw std::runtime_error(aString.latin1()); + if(aFamily){ + if(!aFamily->myIsCDone){ + if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily Geom2SubMeshID"); + + SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily; + CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements(); + TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[VTK_VERTEX]; + + if(!anIsOnAllElements){ + SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes(); + SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]); + int aMaxElemId = aNbElem; + aNbElem = aCellNumForType->length(); + for(int iElem = 0; iElem < aNbElem; iElem++){ + int aTmp = aCellNumForType[iElem]-1; + if(0 > aTmp || aTmp >= aMaxElemId){ + static QString aString; + aString.sprintf("LoadPoints - aMaxElemId(%d) <= aCellNumForType[%d]=%d < 0",aMaxElemId,iElem,aTmp); + throw std::runtime_error(aString.latin1()); + } + aSubMeshID.push_back(aTmp); + } + }else{ + for(int iElem = 0; iElem < aNbElem; iElem++){ + aSubMeshID.push_back(iElem); } - aSubMeshID.push_back(tmp); - } - }else{ - for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++){ - aSubMeshID.push_back(iNumElem); } + + aFamily->myIsCDone = true; } } + return 1; } +//--------------------------------------------------------------- int VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh, VISU::PCMeshOnEntity theMeshOnEntity, @@ -983,7 +1043,8 @@ VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh, const TEntity& aVEntity = theMeshOnEntity->myEntity; int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems); const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(aVEntity); - int aNbPoints = theMesh->myPointsCoord.size()/theMesh->myDim; + const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords; + int aNbPoints = aCoords.GetNbPoints(); if(!isCellsLoaded){ for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++){ SALOME_MED::medGeometryElement aGeom = aGeomElems[iGeom]; @@ -1098,7 +1159,10 @@ ImportField(TArray& theArray, if(theField->myEntity == NODE_ENTITY){ TValForCellsWithType& aValForCellsWithType = theValForTime->myValForCells[VTK_VERTEX]; - int iNumElemEnd = theMesh->myPointsCoord.size()/theMesh->myDim*theField->myNbComp; + + const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords; + int aNbPoints = aCoords.GetNbPoints(); + int iNumElemEnd = aNbPoints*theField->myNbComp; if(MYDEBUG) MESSAGE("ImportField - iNumElemEnd = "< -namespace VISU{ +namespace VISU +{ + //--------------------------------------------------------------- + struct TIsCDone: virtual TBaseStructure + { + bool myIsCDone; + TIsCDone(): + myIsCDone(false) + {} + }; - struct TCMesh: TMeshImpl{ + + //--------------------------------------------------------------- + struct TCMesh: virtual TMeshImpl, virtual TIsCDone + { SALOME_MED::MESH_var myMesh; }; typedef SharedPtr PCMesh; - struct TCMeshOnEntity: TMeshOnEntityImpl{ + + //--------------------------------------------------------------- + struct TCMeshOnEntity: virtual TMeshOnEntityImpl, virtual TIsCDone + { SALOME_MED::SUPPORT_var mySupport; typedef std::pair TIndexAndSize; typedef std::map TCellsFirstIndex; @@ -50,21 +65,32 @@ namespace VISU{ }; typedef SharedPtr PCMeshOnEntity; - struct TCFamily: TFamilyImpl{ + + //--------------------------------------------------------------- + struct TCFamily: virtual TFamilyImpl, virtual TIsCDone + { SALOME_MED::FAMILY_var myFamily; }; typedef SharedPtr PCFamily; - struct TCGroup: TGroupImpl{ + + //--------------------------------------------------------------- + struct TCGroup: virtual TGroupImpl + { SALOME_MED::GROUP_var myGroup; }; typedef SharedPtr PCGroup; - struct TCField: TFieldImpl{ - }; + + //--------------------------------------------------------------- + struct TCField: virtual TFieldImpl + {}; typedef SharedPtr PCField; - struct TCValForTime: TValForTimeImpl{ + + //--------------------------------------------------------------- + struct TCValForTime: virtual TValForTimeImpl + { SALOME_MED::FIELD_var myField; }; typedef SharedPtr PCValForTime; -- 2.39.2