]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Fix for Bug GVIEW10709 BR-D5-38-2003_Base
authorapo <apo@opencascade.com>
Mon, 5 Dec 2005 15:26:46 +0000 (15:26 +0000)
committerapo <apo@opencascade.com>
Mon, 5 Dec 2005 15:26:46 +0000 (15:26 +0000)
   wrong presentation of quadratic mesh elements

src/SVTK/SALOME_Actor.cxx
src/SVTK/SVTK_Actor.cxx
src/SVTK/SVTK_Actor.h

index 66a7350109d6d2b1d953a814071e71f25086423e..5e4064ddd415b6e146ae68951c1e1eec5d26cc1f 100644 (file)
@@ -165,10 +165,12 @@ SALOME_Actor
     myPassFilter.push_back(VTKViewer_PassThroughFilter::New());
 
   myPreHighlightActor->Delete();
+  myPreHighlightActor->Initialize();
   myPreHighlightActor->PickableOff();
   myPreHighlightActor->SetVisibility( false );
 
   myHighlightActor->Delete();
+  myHighlightActor->Initialize();
   myHighlightActor->PickableOff();
   myHighlightActor->SetVisibility( false );
 
index b633626b2426d034ad5813a116174b0862934503..f78ecc1e81814a03df4042062acecf9768e32d61 100644 (file)
@@ -61,7 +61,8 @@ CopyPoints(vtkUnstructuredGrid* theGrid, vtkDataSet *theSourceDataSet)
 vtkStandardNewMacro(SVTK_Actor);
 
 SVTK_Actor
-::SVTK_Actor()
+::SVTK_Actor():
+  myUnstructuredGrid(vtkUnstructuredGrid::New())
 {
   if(MYDEBUG) INFOS("SVTK_Actor - "<<this);
 
@@ -70,7 +71,7 @@ SVTK_Actor
 
   Visibility = Pickable = false;
 
-  myUnstructuredGrid = vtkUnstructuredGrid::New();
+  myUnstructuredGrid->Delete();
   myUnstructuredGrid->Allocate();
 
   myIsShrunk = false;
@@ -79,12 +80,45 @@ SVTK_Actor
 
   myMapper = vtkDataSetMapper::New();
 
-  myMapper->SetInput(myUnstructuredGrid);
+  SetResolveCoincidentTopology(false);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_Actor
+::Initialize()
+{
+  myMapper->SetInput(GetSource());
   Superclass::InitPipeLine(myMapper);
+}
 
-  SetResolveCoincidentTopology(false);
+
+//----------------------------------------------------------------------------
+void
+SVTK_Actor
+::SetSource(vtkUnstructuredGrid* theUnstructuredGrid)
+{
+  if(GetSource() == theUnstructuredGrid)
+    return;
+
+  myUnstructuredGrid = theUnstructuredGrid;
+
+  myMapper->SetInput(theUnstructuredGrid);
+
+  Superclass::InitPipeLine(myMapper);
+
+  Modified();
+}
+
+vtkUnstructuredGrid*
+SVTK_Actor
+::GetSource()
+{
+  return myUnstructuredGrid.GetPointer();
 }
 
+
+//----------------------------------------------------------------------------
 void
 SVTK_Actor
 ::SetShrinkFactor(float theValue)
@@ -127,13 +161,9 @@ SVTK_Actor
 {
   if(MYDEBUG) INFOS("~SVTK_Actor()");
 
-  myMapper->RemoveAllInputs();
   myMapper->Delete();
 
-  myShrinkFilter->UnRegisterAllOutputs();
   myShrinkFilter->Delete();
-
-  myUnstructuredGrid->Delete();
 }
 
 
@@ -155,13 +185,13 @@ SVTK_Actor
   myUnstructuredGrid->Reset();
 
   vtkDataSet *aSourceDataSet = theMapActor->GetInput();
-  CopyPoints(myUnstructuredGrid,aSourceDataSet);
+  CopyPoints(GetSource(),aSourceDataSet);
 
   int aNbOfParts = theMapIndex.Extent();
   for(int ind = 1; ind <= aNbOfParts; ind++){
     int aPartId = theMapIndex( ind );
-    vtkCell* aCell = theMapActor->GetElemCell(aPartId);
-    myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
+    if(vtkCell* aCell = theMapActor->GetElemCell(aPartId))
+      myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
   }
 
   UnShrink();
@@ -186,9 +216,10 @@ SVTK_Actor
     aPoints->SetNumberOfPoints(aNbOfParts);
     for(int i = 0; i < aNbOfParts; i++){
       int aPartId = theMapIndex( i+1 );
-      float* aCoord = theMapActor->GetNodeCoord(aPartId);
-      aPoints->SetPoint(i,aCoord);
-      myUnstructuredGrid->InsertNextCell(VTK_VERTEX,1,&i);
+      if(float* aCoord = theMapActor->GetNodeCoord(aPartId)){
+       aPoints->SetPoint(i,aCoord);
+       myUnstructuredGrid->InsertNextCell(VTK_VERTEX,1,&i);
+      }
     }
     myUnstructuredGrid->SetPoints(aPoints);
     aPoints->Delete();
@@ -209,7 +240,7 @@ SVTK_Actor
   myUnstructuredGrid->Reset();
 
   vtkDataSet *aSourceDataSet = theMapActor->GetInput();
-  CopyPoints(myUnstructuredGrid,aSourceDataSet);
+  CopyPoints(GetSource(),aSourceDataSet);
 
   int iEnd = theMapIndex.Extent();
   int aCellId = -1, aCellCounter = 0;
@@ -222,18 +253,19 @@ SVTK_Actor
   }
 
   if(aCellCounter == 1){
-    vtkCell* aCell = theMapActor->GetElemCell(aCellId);
-    if(aCell->GetCellType() <= VTK_LINE){
-      myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
-    }else{
-      int aNbOfParts = aCell->GetNumberOfEdges();
-      for(int i = 1; i <= iEnd; i++){
-        int aPartId = theMapIndex(i);
-       if( aPartId < 0){
-          aPartId = -aPartId-1;
-         if(0 > aPartId || aPartId >= aNbOfParts) break;
-         vtkCell* anEdgeCell = aCell->GetEdge(aPartId);
-         myUnstructuredGrid->InsertNextCell(VTK_LINE,anEdgeCell->GetPointIds());
+    if(vtkCell* aCell = theMapActor->GetElemCell(aCellId)){
+      if(aCell->GetCellType() <= VTK_LINE){
+       myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
+      }else{
+       int aNbOfParts = aCell->GetNumberOfEdges();
+       for(int i = 1; i <= iEnd; i++){
+         int aPartId = theMapIndex(i);
+         if( aPartId < 0){
+           aPartId = -aPartId-1;
+           if(0 > aPartId || aPartId >= aNbOfParts) break;
+           if(vtkCell* anEdgeCell = aCell->GetEdge(aPartId))
+             myUnstructuredGrid->InsertNextCell(VTK_LINE,anEdgeCell->GetPointIds());
+         }
        }
       }
     }
index d43ca24d699b0826ad26babd5f582bfb1934442e..cfb4d4b94a14d3274f1b07a683a64b68644c11a1 100644 (file)
@@ -40,21 +40,46 @@ public:
 
   vtkTypeMacro(SVTK_Actor,VTKViewer_Actor);
 
-  void  SetShrinkFactor(float value);
-  virtual void SetShrink(); 
-  virtual void UnShrink(); 
+  //! Initialiaze the instance completely
+  void
+  Initialize();
+
+  //! Allows to set an external source 
+  void
+  SetSource(vtkUnstructuredGrid* theUnstructuredGrid);
+
+  //! Get its internal data set
+  vtkUnstructuredGrid*
+  GetSource();
+
+  //! To manage shrink functionality
+  void
+  SetShrinkFactor(float value);
+
+  //! To manage shrink functionality
+  virtual
+  void
+  SetShrink(); 
+
+  //! To manage shrink functionality
+  virtual
+  void
+  UnShrink(); 
 
   //! Allow to recostruct selected cells from source SALOME_Actor and map of subindexes
-  void MapCells(SALOME_Actor* theMapActor, 
-               const TColStd_IndexedMapOfInteger& theMapIndex);
+  void
+  MapCells(SALOME_Actor* theMapActor, 
+          const TColStd_IndexedMapOfInteger& theMapIndex);
 
   //! Allow to recostruct selected points from source SALOME_Actor and map of subindexes
-  void MapPoints(SALOME_Actor* theMapActor, 
-                const TColStd_IndexedMapOfInteger& theMapIndex);
+  void 
+  MapPoints(SALOME_Actor* theMapActor, 
+           const TColStd_IndexedMapOfInteger& theMapIndex);
 
   //! Allow to recostruct selected edges from source SALOME_Actor and map of subindexes
-  void MapEdge(SALOME_Actor* theMapActor, 
-              const TColStd_IndexedMapOfInteger& theMapIndex);
+  void 
+  MapEdge(SALOME_Actor* theMapActor, 
+         const TColStd_IndexedMapOfInteger& theMapIndex);
 
   const TColStd_IndexedMapOfInteger&
   GetMapIndex() const;
@@ -62,7 +87,7 @@ public:
  protected:
   TColStd_IndexedMapOfInteger myMapIndex;
 
-  vtkUnstructuredGrid* myUnstructuredGrid;
+  vtkSmartPointer<vtkUnstructuredGrid> myUnstructuredGrid;
   vtkDataSetMapper* myMapper;
   vtkRenderer* myRenderer;