From 1331449729b9f12ee8380d9bb3865a7a16abe820 Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 5 Oct 2005 05:46:17 +0000 Subject: [PATCH] To implement mapping of parent mesh elements --- src/CONVERTOR/VISU_Convertor_impl.cxx | 5 +- src/CONVERTOR/VISU_MedConvertor.cxx | 31 ++--- src/CONVERTOR/VISU_MedConvertor.hxx | 3 +- src/OBJECT/VISU_GaussPtsAct.cxx | 177 ++++-------------------- src/OBJECT/VISU_GaussPtsAct.h | 3 +- src/PIPELINE/SALOME_ExtractGeometry.cxx | 67 +++------ src/PIPELINE/SALOME_ExtractGeometry.h | 22 ++- src/PIPELINE/VISU_PipeLine.cxx | 9 +- src/VVTK/VVTK_ViewWindow.cxx | 6 +- 9 files changed, 89 insertions(+), 234 deletions(-) diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 3ce4bec0..d3889ae1 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -581,11 +581,12 @@ namespace VISU TMeshOnEntityImpl ::GetElemName(vtkIdType theObjID) const { + vtkIdType aVTKId = GetElemVTKID(theObjID); vtkIdType anInputID; const TVTKAppendFilter& anAppendFilter = GetFilter(); - vtkIdType aID = anAppendFilter->GetCellInputID(theObjID,anInputID); + vtkIdType aSubID = anAppendFilter->GetCellInputID(aVTKId,anInputID); const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputID]; - return aSubMesh->GetElemName(aID); + return aSubMesh->GetElemName(aSubID); } //--------------------------------------------------------------- diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 9cb56ad7..2ba123d9 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -65,7 +65,6 @@ static int MY_GROUP_DEBUG = 0; #define _LOAD_FAMILIES_ #define _EDF_NODE_IDS_ -#define _NAME_MAPPING_ 0 namespace { @@ -1067,21 +1066,17 @@ namespace TNamedPointCoords::Init(theNbPoints,theDim,theNodeInfo->myElemNum); else TNamedPointCoords::Init(theNbPoints,theDim); - - if(_NAME_MAPPING_ && theNodeInfo->IsElemNames() && theNbPoints > 0){ - myPointNames.resize(theNbPoints); - for(vtkIdType anID = 0; anID < theNbPoints; anID++) - myPointNames[anID] = theNodeInfo->GetElemName(anID); - } + if(theNodeInfo->IsElemNames()) + myNodeInfo = theNodeInfo; } std::string TMEDNamedPointCoords ::GetNodeName(vtkIdType theObjID) const { - if(myPointNames.empty()) - return TNamedPointCoords::GetNodeName(theObjID); - return myPointNames[theObjID]; + if(myNodeInfo) + return myNodeInfo->GetElemName(theObjID); + return TNamedPointCoords::GetNodeName(theObjID); } @@ -1120,13 +1115,8 @@ namespace { myIsElemNum = theElemInfo->IsElemNum(); myElemNum = theElemInfo->myElemNum; - if(_NAME_MAPPING_ && theElemInfo->IsElemNames()){ - TInt aNbElem = theElemInfo->GetNbElem(); - myElemNames.resize(aNbElem); - for(TInt anID = 0; anID < aNbElem; anID++){ - myElemNames[anID] = theElemInfo->GetElemName(anID); - } - } + if(theElemInfo->IsElemNames()) + myElemInfo = theElemInfo; } vtkIdType @@ -1143,10 +1133,9 @@ namespace TMEDSubMesh ::GetElemName(vtkIdType theObjID) const { - if(myElemNames.empty()) - return TSubMeshImpl::GetElemName(theObjID); - else - return myElemNames[theObjID]; + if(myElemInfo) + return myElemInfo->GetElemName(theObjID); + return TSubMeshImpl::GetElemName(theObjID); } } diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index ee063780..61bb67e1 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -24,6 +24,7 @@ namespace VISU //--------------------------------------------------------------- class TMEDNamedPointCoords: public virtual TNamedPointCoords { + MED::PNodeInfo myNodeInfo; TNames myPointNames; public: void @@ -112,7 +113,7 @@ namespace VISU MED::EBooleen myIsElemNum; MED::TElemNum myElemNum; - TNames myElemNames; + MED::PElemInfo myElemInfo; void Init(const MED::PElemInfo& theElemInfo); diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 668696cf..2f53679f 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -81,9 +81,8 @@ static int MYDEBUG = 0; static int MYDEBUG1 = 0; static int MYDEBUG2 = 0; #endif -//modified by NIZNHY-PKV Tue Oct 4 16:00:12 2005f -static float s_Radius=0; -//modified by NIZNHY-PKV Tue Oct 4 16:00:15 2005t + + //---------------------------------------------------------------- vtkStandardNewMacro( VISU_OutsideCursorSettings ); vtkStandardNewMacro( VISU_PickingSettings ); @@ -563,7 +562,9 @@ VISU_GaussPtsAct VISU::TCellID aCellID = aGaussPointID.first; VISU::TLocalPntID aLocalPntID = aGaussPointID.second; aStr<<"\nParentCellID: "<GetElemName(aCellID)<<"'"; + std::string aParentName = aParent->GetElemName(aCellID); + if(aParentName != "") + aStr<<"\nParentCellName: '"<GetPointId(); - printf(" * Highlight() aVtkId=%d\n", aVtkId); if( aVtkId >= 0 && theSelector->IsValid( this, aVtkId, true ) && hasIO()) { vtkIdType anObjId = GetNodeObjId( aVtkId ); if(anObjId >= 0){ @@ -699,11 +699,7 @@ VISU_GaussPtsAct if(vtkDataArray* aScalarArray = aCellData->GetScalars()){ float aVal = aScalarArray->GetTuple1(aVtkId); float aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray); - //modified by NIZNHY-PKV Tue Oct 4 16:00:45 2005f - s_Radius=aRadius; - //modified by NIZNHY-PKV Tue Oct 4 16:00:47 2005t mySphereSourceSelected->SetRadius(aRadius); - // if(theSelector->HasIndex(myIO)){ mySphereActorSelected->SetVisibility(1); GetScalarBarCtrl()->SetIsMarked(true); @@ -744,159 +740,44 @@ VISU_GaussPtsAct GetScalarBarCtrl()->SetIsMarked(false); GetScalarBarCtrl()->Update(); } - }// if( !isRectangle ) - // - else { - if( vtkDataSet* aDataSet = GetInput() ) { - float x1 = theSelectionEvent->myX; - float y1 = theSelectionEvent->myY; - float x2 = theSelectionEvent->myLastX; - float y2 = theSelectionEvent->myLastY; - - int aNbPnts=aDataSet->GetNumberOfPoints(); - for(int i = 0; i < aNbPnts && !bRet; i++){ - float aPoint[3]; - aDataSet->GetPoint( i, aPoint ); - - float aPnt[3]; - aRenderer->SetWorldPoint( aPoint[0], aPoint[1], aPoint[2], 1.0 ); - aRenderer->WorldToDisplay(); - aRenderer->GetDisplayPoint( aPnt ); - - if( aPnt[0] > x2 && aPnt[0] < x1 && aPnt[1] > y1 && aPnt[1] < y2 ) { - float aDisp[3]; - aRenderer->SetWorldPoint( aPoint[0], aPoint[1], aPoint[2], 1.0 ); - aRenderer->WorldToDisplay(); - aRenderer->GetDisplayPoint( aDisp ); - - if( myPointPicker->Pick( aDisp[0], aDisp[1], 0.0, aRenderer ) ) { - if( vtkActorCollection* anActorCollection = myPointPicker->GetActors() ) { - if( anActorCollection->IsItemPresent( this ) ) { - float aPickedPoint[3]; - myPointPicker->GetMapperPosition( aPickedPoint ); - vtkIdType aVtkId = aDataSet->FindPoint( aPickedPoint ); - if( aVtkId >= 0 && theSelector->IsValid( this, aVtkId, true ) ) { - vtkIdType anObjId = GetNodeObjId( aVtkId ); - - if( anObjId >= 0 ) { - // - bool bIsAdded=false; - bRet=!bRet; // true - // - if( theSelector->IsSelected( myIO ) ) { - theSelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift); - } - else { - if(!theSelectionEvent->myIsShift) - theSelector->ClearIObjects(); - - theSelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift); - theSelector->AddIObject( this ); - bIsAdded=!bIsAdded; - } - // - if (bIsAdded){ - float* aNodeCoord = GetNodeCoord(anObjId); - anIteractor->FlyTo (aRenderer, aNodeCoord); - aRenderer->ResetCameraClippingRange(); - // To calculate display (2D) position of the annotation - float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.0}; - aRenderer->SetWorldPoint(aWorldCoord); - aRenderer->WorldToDisplay(); - float aSelectionPoint[3]; - aRenderer->GetDisplayPoint(aSelectionPoint); - myTextActor->SetPosition(aSelectionPoint); - // - // annotation text - { - std::ostringstream aStr; - aStr<<"Global ID: "<GetObjID(anObjId); - VISU::TCellID aCellID = aGaussPointID.first; - VISU::TLocalPntID aLocalPntID = aGaussPointID.second; - aStr<<"\nParentCellID: "<GetCellData(); - if(vtkDataArray *aScalarArray = aCellData->GetScalars()){ - float aVal = aScalarArray->GetTuple1(aVtkId); - aStr<<"\nScalar: "<SetCenter(aNodeCoord); - float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray); - mySphereSource->SetRadius(aRadius); - } - - if(vtkDataArray *aVectorArray = aCellData->GetVectors()){ - float* aVal = aVectorArray->GetTuple3(aVtkId); - aStr<<"\nVector: {"<SetInput(aString.c_str()); - }// annotation text - // - float aColor[3]={1.,1.,1.}; - mySphereActor->GetProperty()->SetColor(aColor); - // shoe sphere - myTextActor->SetVisibility(1); - mySphereActor->SetVisibility(1); - // - return bRet; - }// if (bIsAdded){ - }// if( anObjId >= 0 ) - } - } - } - } - } - } - } - }//else ... if(!isRectangle ) + } //myTextActor->SetVisibility(aTextVisibility); //mySphereActor->SetVisibility(aSphereVisibility); return bRet; } + + //================================================================== // function : highlight // purpose : //================================================================== -void VISU_GaussPtsAct::highlight(bool theHighlight, - SVTK_Selector* theSelector) +void +VISU_GaussPtsAct +::highlight(bool theHighlight, + SVTK_Selector* theSelector) { - Superclass::highlight(theHighlight, theSelector); - // TColStd_IndexedMapOfInteger aMapIndex; theSelector->GetIndex( getIO(), aMapIndex ); int aNbOfParts = aMapIndex.Extent(); - if (!aNbOfParts){ + if(!aNbOfParts){ mySphereActorSelected->SetVisibility(0); - } - else if (aNbOfParts==1){ + }else if(aNbOfParts == 1){ int anObjId = aMapIndex(1); - vtkIdType aVtkId; - float* aNodeCoord = GetNodeCoord(anObjId); - printf(" *highlight() anObjId=%d { %f, %f, %f }\n", - anObjId, aNodeCoord[0], aNodeCoord[1], aNodeCoord[2]); - mySphereSourceSelected->SetCenter(aNodeCoord); - //mySphereSourceSelected->SetRadius(s_Radius); - // - - aVtkId=myGaussPointsPL->GetElemVTKID(anObjId); - printf(" aVtkId=%d\n", aVtkId); - vtkDataSet* aDataSet = GetInput(); - vtkCellData* aCellData = aDataSet->GetCellData(); - if(vtkDataArray* aScalarArray = aCellData->GetScalars()){ - float aVal = aScalarArray->GetTuple1(aVtkId); - float aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray); - mySphereSourceSelected->SetRadius(aRadius); - // - GetScalarBarCtrl()->SetMarkValue(aVal); + vtkIdType aVtkId = GetNodeVTKID(anObjId); + if(aVtkId >= 0){ + float* aNodeCoord = GetNodeCoord(anObjId); + mySphereSourceSelected->SetCenter(aNodeCoord); + + vtkDataSet* aDataSet = GetInput(); + vtkCellData* aCellData = aDataSet->GetCellData(); + if(vtkDataArray* aScalarArray = aCellData->GetScalars()){ + float aVal = aScalarArray->GetTuple1(aVtkId); + float aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray); + mySphereSourceSelected->SetRadius(aRadius); + GetScalarBarCtrl()->SetMarkValue(aVal); + } + mySphereActorSelected->SetVisibility(1); } - - mySphereActorSelected->SetVisibility(1); } } //---------------------------------------------------------------- diff --git a/src/OBJECT/VISU_GaussPtsAct.h b/src/OBJECT/VISU_GaussPtsAct.h index 330f9b03..e05af940 100644 --- a/src/OBJECT/VISU_GaussPtsAct.h +++ b/src/OBJECT/VISU_GaussPtsAct.h @@ -257,7 +257,8 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor void SetPickingSettings(VISU_PickingSettings* thePickingSettings); - void UpdatePickingSettings(); + void + UpdatePickingSettings(); virtual void diff --git a/src/PIPELINE/SALOME_ExtractGeometry.cxx b/src/PIPELINE/SALOME_ExtractGeometry.cxx index 896fcea7..2c6f1ccf 100755 --- a/src/PIPELINE/SALOME_ExtractGeometry.cxx +++ b/src/PIPELINE/SALOME_ExtractGeometry.cxx @@ -99,58 +99,39 @@ SALOME_ExtractGeometry { return myStoreMapping; } -//modified by NIZNHY-PKV Tue Oct 4 16:52:22 2005f + + //---------------------------------------------------------------------------- vtkIdType SALOME_ExtractGeometry -::GetElemVTKId(int theObjID) +::GetElemVTKId(vtkIdType theID) { - if (myElemVTK2ObjIds.empty()) - return theObjID; + if(myElemVTK2ObjIds.empty()) + return theID; - int i, aNb; - vtkIdType anObjId, aVTKId=-1; - // - aNb=myElemVTK2ObjIds.size(); - for (i=0; iGetNodeVTKID(theID); + vtkIdType anID = myIDMapper->GetNodeVTKID(theID); + return myExtractGeometry->GetNodeVTKId(anID); } float* @@ -429,10 +430,8 @@ vtkIdType VISU_PipeLine ::GetElemVTKID(vtkIdType theID) { - vtkIdType anID = myExtractGeometry->GetElemVTKId(theID); - return myIDMapper->GetElemVTKID(anID); - - //return myIDMapper->GetElemVTKID(theID); + vtkIdType anID = myIDMapper->GetElemVTKID(theID); + return myExtractGeometry->GetElemVTKId(anID); } vtkCell* diff --git a/src/VVTK/VVTK_ViewWindow.cxx b/src/VVTK/VVTK_ViewWindow.cxx index 9d29b8a7..d2a1e564 100755 --- a/src/VVTK/VVTK_ViewWindow.cxx +++ b/src/VVTK/VVTK_ViewWindow.cxx @@ -93,6 +93,7 @@ VVTK_ViewWindow myMainWindow1->Initialize(anIteractor,aRenderer); myView1 = new SVTK_View(myMainWindow1); + SVTK_ViewWindow::Initialize(myView1,theModel); } { myMainWindow2 = myMainWindow1->CreateMainWindow2(aSplitter, @@ -120,13 +121,10 @@ VVTK_ViewWindow myMainWindow2->Initialize(anIteractor,aRenderer); myView2 = new SVTK_View(myMainWindow2); + SVTK_ViewWindow::Initialize(myView2,theModel); } aSelector->Delete(); - SVTK_ViewWindow::Initialize(myView1,theModel); - connect(myView2,SIGNAL(selectionChanged()), - theModel,SLOT(onSelectionChanged())); - myMainWindow = myMainWindow1; myView = myView1; } -- 2.39.2