]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To implement mapping of parent mesh elements
authorapo <apo@opencascade.com>
Wed, 5 Oct 2005 05:46:17 +0000 (05:46 +0000)
committerapo <apo@opencascade.com>
Wed, 5 Oct 2005 05:46:17 +0000 (05:46 +0000)
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_MedConvertor.cxx
src/CONVERTOR/VISU_MedConvertor.hxx
src/OBJECT/VISU_GaussPtsAct.cxx
src/OBJECT/VISU_GaussPtsAct.h
src/PIPELINE/SALOME_ExtractGeometry.cxx
src/PIPELINE/SALOME_ExtractGeometry.h
src/PIPELINE/VISU_PipeLine.cxx
src/VVTK/VVTK_ViewWindow.cxx

index 3ce4bec024144c8ae218a9401207fe09971b8e8a..d3889ae1e0dd8d0d8efff1252e5758740d3a9663 100644 (file)
@@ -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);
   }
 
   //---------------------------------------------------------------
index 9cb56ad7903c5e1cd536fb26a17fd322a888ac09..2ba123d9f9da63b2748c26bb66a6f16567bd88ca 100644 (file)
@@ -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);
   }
 }
 
index ee063780bc5fbe2b7f842c340aeaf9bbb60d1a11..61bb67e18d16864bdf013c57c0e499354245f8df 100644 (file)
@@ -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);
index 668696cf6eb77c00892e452db01497abee60c620..2f53679fd2d085c7fa4ae1193e1d93bb3e78ae2b 100644 (file)
@@ -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: "<<aCellID;
-         //aStr<<"\nParentCellName: '"<<aParent->GetElemName(aCellID)<<"'";
+         std::string aParentName = aParent->GetElemName(aCellID);
+         if(aParentName != "")
+           aStr<<"\nParentCellName: '"<<aParentName<<"'";
          aStr<<"\nLocalPntID: "<<aLocalPntID;
 
          vtkDataSet* aDataSet = GetInput();
@@ -661,9 +662,8 @@ VISU_GaussPtsAct
       }
       return bRet;
     }
-    //
+
     vtkIdType aVtkId = myPointPicker->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: "<<anObjId;
-                       
-                       VISU::TGaussPointID aGaussPointID = myGaussPointsPL->GetObjID(anObjId);
-                       VISU::TCellID aCellID = aGaussPointID.first;
-                       VISU::TLocalPntID aLocalPntID = aGaussPointID.second;
-                       aStr<<"\nParentCellID: "<<aCellID;
-                       aStr<<"\nLocalPntID: "<<aLocalPntID;
-                       
-                       vtkDataSet* aDataSet = GetInput();
-                       vtkCellData* aCellData = aDataSet->GetCellData();
-                       if(vtkDataArray *aScalarArray = aCellData->GetScalars()){
-                         float aVal = aScalarArray->GetTuple1(aVtkId);
-                         aStr<<"\nScalar: "<<aVal;
-                         
-                         mySphereSource->SetCenter(aNodeCoord);
-                         float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray);
-                         mySphereSource->SetRadius(aRadius);
-                       }
-                       
-                       if(vtkDataArray *aVectorArray = aCellData->GetVectors()){
-                         float* aVal = aVectorArray->GetTuple3(aVtkId);
-                         aStr<<"\nVector: {"<<aVal[0]<<"; "<<aVal[1]<<"; "<<aVal[2]<<"}";
-                       }
-                       
-                       std::string aString = aStr.str();
-                       myTextMapper->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);
   }
 }
 //----------------------------------------------------------------
index 330f9b031e82425ea5d855bc2e0045a8a175ed66..e05af940ef3379d269611d5ffa158285823f67bd 100644 (file)
@@ -257,7 +257,8 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor
   void
   SetPickingSettings(VISU_PickingSettings* thePickingSettings);
 
-  void UpdatePickingSettings();
+  void
+  UpdatePickingSettings();
 
   virtual
   void
index 896fcea72c66d5299a8324e6db8d8b9251871f09..2c6f1ccf619684e451b86d29ab66f5cba81e1406 100755 (executable)
@@ -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; i<aNb; ++i){
-#if defined __GNUC_2__
-    anObjId=myElemVTK2ObjIds[i];
-#else
-    anObjId=myElemVTK2ObjIds.at(i);
-#endif
-    if (anObjId==theObjID){
-      aVTKId=i;
-      return aVTKId;
-    }
-  }
-  return aVTKId;
+  vtkIdType iEnd = myElemVTK2ObjIds.size();
+  for(vtkIdType i = 0; i < iEnd; i++)
+    if(myElemVTK2ObjIds[i] == theID)
+      return i;
+
+  return -1;
 }
 
 vtkIdType
 SALOME_ExtractGeometry
-::GetNodeVTKId(int theObjID)
+::GetNodeVTKId(vtkIdType theID)
 {
-  if (myNodeVTK2ObjIds.empty())
-    return theObjID;
+  if (myElemVTK2ObjIds.empty())
+    return theID;
 
-  int i, aNb;
-  vtkIdType anObjId, aVTKId=-1;
-  //
-  aNb=myNodeVTK2ObjIds.size();
-  for (i=0; i<aNb; ++i){
-#if defined __GNUC_2__
-    anObjId=myNodeVTK2ObjIds[i];
-#else
-    anObjId=myNodeVTK2ObjIds.at(i);
-#endif
-    if (anObjId==theObjID){
-      aVTKId=i;
-      return aVTKId;
-    }
-  }
-  return aVTKId;
+  vtkIdType iEnd = myNodeVTK2ObjIds.size();
+  for(vtkIdType i = 0; i < iEnd; i++)
+    if(myNodeVTK2ObjIds[i] == theID)
+      return i;
+
+  return -1;
 }
-//modified by NIZNHY-PKV Tue Oct  4 16:52:24 2005t
+
 
 //----------------------------------------------------------------------------
 vtkIdType
@@ -160,9 +141,6 @@ SALOME_ExtractGeometry
   if (myElemVTK2ObjIds.empty())
     return theVtkID;
 
-  if (theVtkID < 0 || myElemVTK2ObjIds.size() <= theVtkID)
-    return -1;
-
 #if defined __GNUC_2__
   return myElemVTK2ObjIds[theVtkID];
 #else
@@ -178,9 +156,6 @@ SALOME_ExtractGeometry
   if (myNodeVTK2ObjIds.empty())
     return theVtkID;
 
-  if (theVtkID < 0 || myNodeVTK2ObjIds.size() <= theVtkID)
-    return -1;
-
 #if defined __GNUC_2__
   return myNodeVTK2ObjIds[theVtkID];
 #else
index 2cb9fb32e186ca5c49ad111b4e10b3fc96a1dda9..d348fe602fab400b139e5c2cb8ec3b8bee57ca06 100755 (executable)
@@ -50,12 +50,22 @@ public:
   void
   SetStoreMapping(bool theStoreMapping);
 
-  virtual vtkIdType GetNodeObjId(int theID);
-  virtual vtkIdType GetElemObjId(int theID);
-  //pkvf
-  virtual vtkIdType GetNodeVTKId(int theID);
-  virtual vtkIdType GetElemVTKId(int theID);
-  //pkvt
+  virtual 
+  vtkIdType 
+  GetNodeObjId(vtkIdType theID);
+
+  virtual
+  vtkIdType
+  GetElemObjId(vtkIdType theID);
+
+  virtual
+  vtkIdType
+  GetNodeVTKId(vtkIdType theID);
+
+  virtual
+  vtkIdType
+  GetElemVTKId(vtkIdType theID);
+
 protected:
   SALOME_ExtractGeometry();
   ~SALOME_ExtractGeometry();
index 3b88c987e9f1c665c0fff68a799700a94ab722b7..263b1028792177d572a78e5d39ad51146302bd32 100644 (file)
@@ -406,7 +406,8 @@ vtkIdType
 VISU_PipeLine
 ::GetNodeVTKID(vtkIdType theID)
 {
-  return myIDMapper->GetNodeVTKID(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* 
index 9d29b8a79d51b0884f639fbe4aa42cb64ed2d2e3..d2a1e564ebee0ada782568d0ba4d2cfaf6bb277e 100755 (executable)
@@ -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;
   }