]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
VISU 2008 - Introduction of the Feature Edges presentation mode
authorouv <ouv@opencascade.com>
Tue, 8 Jul 2008 07:44:38 +0000 (07:44 +0000)
committerouv <ouv@opencascade.com>
Tue, 8 Jul 2008 07:44:38 +0000 (07:44 +0000)
src/SVTK/SVTK_DeviceActor.cxx
src/SVTK/SVTK_DeviceActor.h

index a3bb037730cf4a8d353b54196fd75b41c5ec9c0c..e025131f3d28da4d112aa34e461d9d677526d4ce 100644 (file)
@@ -36,6 +36,7 @@
 // VTK Includes
 #include <vtkObjectFactory.h>
 #include <vtkShrinkFilter.h>
+#include <vtkFeatureEdges.h>
 
 #include <vtkPolyData.h>
 #include <vtkUnstructuredGrid.h>
@@ -58,6 +59,9 @@ SVTK_DeviceActor
   myIsShrunk = false;
   myIsShrinkable = true;
 
+  myIsFeatureEdgesAllowed = false;
+  myIsFeatureEdgesEnabled = false;
+
   myIsShaded = true;
   myProperty = vtkProperty::New();
   myRepresentation = SVTK::Representation::Surface;
@@ -70,6 +74,8 @@ SVTK_DeviceActor
 
   myShrinkFilter = vtkShrinkFilter::New();
 
+  myFeatureEdges = vtkFeatureEdges::New();
+
   myGeomFilter = VTKViewer_GeometryFilter::New();
 
   myTransformFilter = VTKViewer_TransformFilter::New();
@@ -94,6 +100,8 @@ SVTK_DeviceActor
 
   myShrinkFilter->Delete();
 
+  myFeatureEdges->Delete();
+
   for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++)
     myPassFilter[i]->Delete();
 }
@@ -192,6 +200,9 @@ SVTK_DeviceActor
   if(myIsShrunk)
     mTime = max(mTime,myShrinkFilter->GetMTime());
 
+  if(myIsFeatureEdgesEnabled)
+    mTime = max(mTime,myFeatureEdges->GetMTime());
+
   for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++)
     max(mTime,myPassFilter[i]->GetMTime());
 
@@ -300,6 +311,148 @@ SVTK_DeviceActor
   myShrinkFilter->SetShrinkFactor(theValue);
 }
 
+/*!
+  \return true if feature edges are allowed for this actor
+*/
+bool
+SVTK_DeviceActor
+::IsFeatureEdgesAllowed() 
+{ 
+  return myIsFeatureEdgesAllowed;
+}
+
+/*!
+  Allows feature edges for this actor on or off
+  \param theIsFeatureEdgesAllowed - flag which allows feature edges for this actor on or off
+*/
+void
+SVTK_DeviceActor
+::SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed)
+{
+  myIsFeatureEdgesAllowed = theIsFeatureEdgesAllowed;
+}
+
+/*!
+  \return true if feature edges are enabled
+*/
+bool
+SVTK_DeviceActor
+::IsFeatureEdgesEnabled()
+{
+  return myIsFeatureEdgesEnabled;
+}
+
+/*!
+  Enables feature edges on or off
+  \param theIsFeatureEdgesEnabled - flag which enables feature edges on or off
+*/
+void
+SVTK_DeviceActor
+::SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled)
+{
+  if ( !myIsFeatureEdgesAllowed || myIsFeatureEdgesEnabled == theIsFeatureEdgesEnabled ) 
+    return;
+
+  if ( vtkPolyData* aPolyData = myPassFilter[ 2 ]->GetPolyDataOutput() )
+  {
+    if( theIsFeatureEdgesEnabled )
+    {
+      aPolyData->Update();
+      myFeatureEdges->SetInput( aPolyData );
+      myPassFilter[ 3 ]->SetInput( myFeatureEdges->GetOutput() );
+      myIsFeatureEdgesEnabled = true;
+    }
+    else
+    {
+      myPassFilter[3]->SetInput( aPolyData );
+      myIsFeatureEdgesEnabled = false;
+    }
+    myIsFeatureEdgesEnabled = theIsFeatureEdgesEnabled;
+  }
+}
+
+/*!
+  \return angle of feature edges' filter
+*/
+vtkFloatingPointType
+SVTK_DeviceActor
+::GetFeatureEdgesAngle()
+{
+  return myFeatureEdges->GetFeatureAngle();
+}
+
+/*!
+  Sets angle of feature edges' filter
+  \param theAngle angle of feature edges' filter
+*/
+void
+SVTK_DeviceActor
+::SetFeatureEdgesAngle(vtkFloatingPointType theAngle)
+{
+  myFeatureEdges->SetFeatureAngle(theAngle);
+}
+
+/*!
+  Gets information about kinds of edges which are displayed by feature edges' filter
+  \param theIsFeatureEdges flag which shows whether feature edges are displayed
+  \param theIsBoundaryEdges flag which shows whether boundary edges are displayed
+  \param theIsManifoldEdges flag which shows whether manifold edges are displayed
+  \param theIsNonManifoldEdges flag which shows whether non-manifold edges are displayed
+*/
+void
+SVTK_DeviceActor
+::GetFeatureEdgesFlags(bool& theIsFeatureEdges,
+                      bool& theIsBoundaryEdges,
+                      bool& theIsManifoldEdges,
+                      bool& theIsNonManifoldEdges)
+{
+  theIsFeatureEdges = myFeatureEdges->GetFeatureEdges();
+  theIsBoundaryEdges = myFeatureEdges->GetBoundaryEdges();
+  theIsManifoldEdges = myFeatureEdges->GetManifoldEdges();
+  theIsNonManifoldEdges = myFeatureEdges->GetNonManifoldEdges();
+}
+
+/*!
+  Sets different kinds of edges to be displayed by feature edges' filter
+  \param theIsFeatureEdges flag which displays feature edges
+  \param theIsBoundaryEdges flag which displays boundary edges
+  \param theIsManifoldEdges flag which displays manifold edges
+  \param theIsNonManifoldEdges flag which displays non-manifold edges
+*/
+void
+SVTK_DeviceActor
+::SetFeatureEdgesFlags(bool theIsFeatureEdges,
+                      bool theIsBoundaryEdges,
+                      bool theIsManifoldEdges,
+                      bool theIsNonManifoldEdges)
+{
+  myFeatureEdges->SetFeatureEdges(theIsFeatureEdges);
+  myFeatureEdges->SetBoundaryEdges(theIsBoundaryEdges);
+  myFeatureEdges->SetManifoldEdges(theIsManifoldEdges);
+  myFeatureEdges->SetNonManifoldEdges(theIsNonManifoldEdges);
+}
+
+/*!
+  \return feature edges' coloring flag
+*/
+bool
+SVTK_DeviceActor
+::GetFeatureEdgesColoring()
+{
+  return myFeatureEdges->GetColoring();
+}
+
+/*!
+  Sets feature edges' coloring flag
+  \param theIsColoring feature edges' coloring flag
+*/
+void
+SVTK_DeviceActor
+::SetFeatureEdgesColoring(bool theIsColoring)
+{
+  myFeatureEdges->SetColoring(theIsColoring);
+}
+
 /*!
   Set representation (VTK_SURFACE, VTK_POINTS, VTK_WIREFRAME and so on)
   param theMode - new mode
index 47fc3e12d1e7e1f847d719b6569a4fe7953cf0b0..0fdd18b9f88e1d60a76ef5dcfb5eef42efd07ab2 100644 (file)
@@ -44,6 +44,7 @@ class VTKViewer_GeometryFilter;
 class vtkCell;
 class vtkDataSet;
 class vtkShrinkFilter;
+class vtkFeatureEdges;
 class vtkDataSetMapper;
 class vtkPassThroughFilter;
 
@@ -148,6 +149,54 @@ class SVTK_EXPORT SVTK_DeviceActor: public vtkLODActor
   UnShrink(); 
   //@}
 
+  /** @name For feature edges management purpose */
+  //@{
+  virtual
+  bool
+  IsFeatureEdgesAllowed();
+
+  virtual
+  void
+  SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed);
+
+  virtual
+  bool
+  IsFeatureEdgesEnabled();
+
+  virtual
+  void
+  SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled);
+
+  virtual
+  vtkFloatingPointType
+  GetFeatureEdgesAngle();
+
+  virtual
+  void
+  SetFeatureEdgesAngle(vtkFloatingPointType theAngle); 
+
+  virtual
+  void
+  GetFeatureEdgesFlags(bool& theIsFeatureEdges,
+                      bool& theIsBoundaryEdges,
+                      bool& theIsManifoldEdges,
+                      bool& theIsNonManifoldEdges);
+  virtual
+  void
+  SetFeatureEdgesFlags(bool theIsFeatureEdges,
+                      bool theIsBoundaryEdges,
+                      bool theIsManifoldEdges,
+                      bool theIsNonManifoldEdges);
+
+  virtual
+  bool
+  GetFeatureEdgesColoring();
+
+  virtual
+  void
+  SetFeatureEdgesColoring(bool theIsColoring);
+  //@}
+
   /** @name For representation mamnagement purpose */
   virtual
   void 
@@ -190,11 +239,15 @@ class SVTK_EXPORT SVTK_DeviceActor: public vtkLODActor
   VTKViewer_TransformFilter *myTransformFilter;
   std::vector<vtkPassThroughFilter*> myPassFilter;
   vtkShrinkFilter* myShrinkFilter;
+  vtkFeatureEdges* myFeatureEdges;
   vtkDataSetMapper* myMapper;
 
   bool myIsShrinkable;
   bool myIsShrunk;
   
+  bool myIsFeatureEdgesAllowed;
+  bool myIsFeatureEdgesEnabled;
+
   bool myIsResolveCoincidentTopology;
   vtkFloatingPointType myPolygonOffsetFactor;
   vtkFloatingPointType myPolygonOffsetUnits;