From 37704cb67b2656b6bd1d307def0686e515f0b484 Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 26 Aug 2005 08:28:05 +0000 Subject: [PATCH] To customize VISU::ScalarMap_i::Build method --- src/CONVERTOR/VISU_Convertor.hxx | 36 ++++++- src/CONVERTOR/VISU_Convertor_impl.cxx | 148 ++++++++++++++++++++------ src/CONVERTOR/VISU_Convertor_impl.hxx | 60 ++++++++--- src/CONVERTOR/VISU_MedConvertor.cxx | 100 +++++++++++++---- src/CONVERTOR/VISU_MedConvertor.hxx | 43 ++++---- src/VISU_I/VISU_CorbaMedConvertor.cxx | 13 +-- src/VISU_I/VISU_CorbaMedConvertor.hxx | 73 ++++++++----- src/VISU_I/VISU_GaussPoints_i.cc | 17 ++- 8 files changed, 372 insertions(+), 118 deletions(-) diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index ab518de3..2426356d 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -39,6 +39,8 @@ #include "MED_SharedPtr.hxx" #include "MED_Vector.hxx" +#include + class vtkUnstructuredGrid; namespace VISU @@ -83,6 +85,12 @@ namespace VISU struct TValForTime; typedef SharedPtr PValForTime; + struct TMeshValForTime; + typedef SharedPtr PMeshValForTime; + + struct TGaussPtsValForTime; + typedef SharedPtr PGaussPtsValForTime; + typedef std::string TName; typedef TVector TNames; @@ -152,11 +160,14 @@ namespace VISU struct TGaussSubMesh: virtual TBaseStructure { PSubProfile mySubProfile; - PGauss myGauss; }; //--------------------------------------------------------------- + typedef vtkIdType TCellID; + typedef vtkIdType TLocalPntID; + typedef std::pair TGaussPointID; + struct TGaussMesh: virtual TBaseStructure {}; @@ -205,7 +216,7 @@ namespace VISU //--------------------------------------------------------------- - typedef std::map TValField; + typedef std::map TValField; struct TField: virtual TIntId { @@ -231,11 +242,23 @@ namespace VISU TName myMeshName; TName myFieldName; TTime myTime; - + }; + + + //--------------------------------------------------------------- + struct TMeshValForTime: virtual TValForTime + { PProfile myProfile; + }; + + + struct TGaussPtsValForTime: virtual TValForTime + { PGaussMesh myGaussMesh; }; + + //--------------------------------------------------------------- PFamily FindFamily(VISU::PMesh theMesh, const std::string& theFamilyName); @@ -315,6 +338,13 @@ public: const std::string& theFieldName, int theStampsNum) = 0; + virtual + TOutput* + GetGaussPointsOnMesh(const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theStampsNum) = 0; + virtual float GetTimeStampSize(const std::string& theMeshName, diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 1abe7336..4f96c751 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -57,7 +57,7 @@ static float ERR_SIZE_CALC = 1.00; static int MYVTKDEBUG = 0; #ifdef _DEBUG_ -static int MYDEBUG = 0; +static int MYDEBUG = 1; static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; @@ -213,18 +213,29 @@ namespace VISU myStatus(eNone) {} + TGaussPointID + TGaussSubMeshImpl + ::GetObjID(vtkIdType theID) const + { + TCellID aCellID = theID / myGauss->myNbPoints; + TLocalPntID aLocalPntID = theID % myGauss->myNbPoints; + + return TGaussPointID(aCellID,aLocalPntID); + } //--------------------------------------------------------------- bool operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight) { - PGaussImpl aLeft(theLeft->myGauss), aRight(theRight->myGauss); + PGaussSubMeshImpl aLeft(theLeft), aRight(theRight); + const PGaussImpl& aGaussLeft = aLeft->myGauss; + const PGaussImpl& aGaussRight = aRight->myGauss; - if(aLeft->myGeom != aRight->myGeom) - return aLeft->myGeom < aRight->myGeom; + if(aGaussLeft->myGeom != aGaussRight->myGeom) + return aGaussLeft->myGeom < aGaussRight->myGeom; - if(aLeft->myName != aRight->myName) - return aLeft->myName < aRight->myName; + if(aGaussLeft->myName != aGaussRight->myName) + return aGaussLeft->myName < aGaussRight->myName; return theLeft->mySubProfile < theRight->mySubProfile; } @@ -303,7 +314,7 @@ namespace VISU ::GetCompValueSliceArr(vtkIdType theElemId) const { TCValueSliceArr aValueSliceArr(myNbComp); - vtkIdType anId = theElemId*myStep; + vtkIdType anId = theElemId; for(vtkIdType aCompId = 0; aCompId < myNbComp; aCompId++){ aValueSliceArr[aCompId] = TCValueSlice(myValue,std::slice(anId,myNbGauss,myNbGauss)); @@ -349,12 +360,18 @@ namespace VISU TValForTimeImpl ::GetNbGauss(vtkIdType theGeom) const { - PGaussMeshImpl aGaussMesh = myGaussMesh; - if(aGaussMesh){ + return myNbGauss; + } + + int + TGaussPtsValForTimeImpl + ::GetNbGauss(vtkIdType theGeom) const + { + if(PGaussMeshImpl aGaussMesh = myGaussMesh){ const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh; TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.find(theGeom); if(anIter != aGeom2GaussSubMesh.end()){ - PGaussSubMesh aGaussSubMesh = anIter->second; + PGaussSubMeshImpl aGaussSubMesh = anIter->second; PGaussImpl aGauss = aGaussSubMesh->myGauss; return aGauss->myNbPoints; } @@ -938,7 +955,7 @@ namespace void GetTimeStampOnGaussMesh(const TVTKSource& theSource, const PFieldImpl& theField, - const PValForTimeImpl& theValForTime) + const PGaussPtsValForTimeImpl& theValForTime) { int aNbTuples = theSource->GetNumberOfPoints(); std::string aFieldName = GenerateFieldName(theField,theValForTime); @@ -1320,16 +1337,17 @@ VISU_Convertor_impl PMeshImpl aMesh = boost::get<0>(aFindTimeStamp); PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp); PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp); - PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp); + PGaussPtsValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp); PFieldImpl aField = boost::get<3>(aFindTimeStamp); //Main part of code - const TVTKSource& aSource = aValForTime->GetSource(); + TSource& aMeshSource = aValForTime->myMeshSource; + const TVTKSource& aSource = aMeshSource.GetSource(); #ifndef _DEXCEPT_ try{ #endif - if(!aValForTime->myIsVTKDone){ - LoadFieldOnMesh(aMesh,aMeshOnEntity,aField,aValForTime); + if(!aMeshSource.myIsVTKDone){ + LoadValForTimeOnMesh(aMesh,aMeshOnEntity,aField,aValForTime); try{ LoadMeshOnEntity(aVTKMeshOnEntity); @@ -1344,24 +1362,92 @@ VISU_Convertor_impl GetMeshOnEntity(aVTKMeshOnEntity->myMeshName,aVTKMeshOnEntity->myEntity); PProfileImpl aProfile = aValForTime->myProfile; + GetMeshOnProfile(aMesh,aVTKMeshOnEntity,aProfile); + + const TVTKAppendFilter& anAppendFilter = aProfile->GetFilter(); + aSource->ShallowCopy(anAppendFilter->GetOutput()); + GetTimeStampOnProfile(aSource,aField,aValForTime); + + aMeshSource.myIsVTKDone = true; + + 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 aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + + aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk"; + VISU::WriteToFile(aSource.GetPointer(),aFileName); + } + if(MYVTKDEBUG){ + GetTimeStampSize(theMeshName,theEntity,theFieldName,theStampsNum); + aSource->Update(); + if(theEntity == VISU::NODE_ENTITY) + BEGMSG(MYVTKDEBUG,"GetPointData() = "<GetPointData()->GetActualMemorySize()*1000)<myIsDone) + TSource& aMeshSource = theValForTime->myMeshSource; + if(aMeshSource.myIsDone) return 0; SALOME_MED::FIELD_var aMEDField = theValForTime->myField; @@ -1230,7 +1231,7 @@ VISU_MEDConvertor::LoadField(VISU::PCMesh theMesh, ::ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity); } - theValForTime->myIsDone = true; + aMeshSource.myIsDone = true; return 1; } diff --git a/src/VISU_I/VISU_CorbaMedConvertor.hxx b/src/VISU_I/VISU_CorbaMedConvertor.hxx index 376eff77..35ff1aca 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.hxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.hxx @@ -79,7 +79,7 @@ namespace VISU //--------------------------------------------------------------- - struct TCValForTime: virtual TValForTimeImpl + struct TCValForTime: virtual TGaussPtsValForTimeImpl { SALOME_MED::FIELD_var myField; }; @@ -94,36 +94,61 @@ class VISU_MEDConvertor: public VISU_Convertor_impl{ VISU_MEDConvertor() {}; public: - VISU_MEDConvertor(SALOMEDS::SObject_ptr theMedSObject) : mySObject(SALOMEDS::SObject::_duplicate(theMedSObject)) {} - virtual VISU_Convertor* Build(); - - protected: + VISU_MEDConvertor(SALOMEDS::SObject_ptr theMedSObject): + mySObject(SALOMEDS::SObject::_duplicate(theMedSObject)) + {} - VISU_Convertor* Build(SALOME_MED::MED_ptr theMED); - VISU_Convertor* Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator); + virtual + VISU_Convertor* + Build(); - virtual int LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, - const std::string& theFamilyName = ""); + protected: - virtual int LoadMeshOnGroup(VISU::PMeshImpl theMesh, - const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet); + VISU_Convertor* + Build(SALOME_MED::MED_ptr theMED); + + VISU_Convertor* + Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator); - virtual int LoadFieldOnMesh(VISU::PMeshImpl theMesh, - VISU::PMeshOnEntityImpl theMeshOnEntity, - VISU::PFieldImpl theField, - VISU::PValForTimeImpl theValForTime); + virtual + int + LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity, + const std::string& theFamilyName = ""); + + virtual + int + LoadMeshOnGroup(VISU::PMeshImpl theMesh, + const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet); + + virtual + int + LoadValForTimeOnMesh(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFieldImpl theField, + VISU::PValForTimeImpl theValForTime); + + virtual + int + LoadValForTimeOnGaussPts(VISU::PMeshImpl theMesh, + VISU::PMeshOnEntityImpl theMeshOnEntity, + VISU::PFieldImpl theField, + VISU::PValForTimeImpl theValForTime) + {} - int LoadPoints(VISU::PCMesh theMesh, - const std::string& theFamilyName = "") ; + int + LoadPoints(VISU::PCMesh theMesh, + const std::string& theFamilyName = "") ; - int LoadCellsOnEntity(VISU::PCMesh theMesh, - VISU::PCMeshOnEntity theMeshOnEntity, - const std::string& theFamilyName = ""); + int + LoadCellsOnEntity(VISU::PCMesh theMesh, + VISU::PCMeshOnEntity theMeshOnEntity, + const std::string& theFamilyName = ""); - int LoadField(VISU::PCMesh theMesh, - VISU::PCMeshOnEntity theMeshOnEntity, - VISU::PField theField, - VISU::PCValForTime theValForTime); + int + LoadField(VISU::PCMesh theMesh, + VISU::PCMeshOnEntity theMeshOnEntity, + VISU::PField theField, + VISU::PCValForTime theValForTime); }; diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index 81d2c463..71c175e5 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -123,8 +123,21 @@ VISU::GaussPoints_i } -void VISU::GaussPoints_i::DoSetInput(Result_i* theResult){ - ScalarMap_i::DoSetInput(theResult); +void +VISU::GaussPoints_i +::DoSetInput(Result_i* theResult) +{ + if(theResult->GetInput() == NULL) + throw std::runtime_error("Mesh_i::Build - theResult->GetInput() == NULL !!!"); + myField = theResult->GetInput()->GetField(myMeshName,myEntity,myFieldName); + if(myField == NULL) + throw std::runtime_error("There is no Field with the parameters !!!"); + VISU_Convertor::TOutput *anOutput = + theResult->GetInput()->GetGaussPointsOnMesh(myMeshName,myEntity,myFieldName,myIteration); + if(anOutput == NULL) + throw std::runtime_error("There is no TimeStamp with the parameters !!!"); + myScalarMapPL->SetInput(anOutput); + myScalarMapPL->Build(); } -- 2.39.2