From: ouv Date: Tue, 8 Jul 2008 07:44:38 +0000 (+0000) Subject: VISU 2008 - Introduction of the Feature Edges presentation mode X-Git-Tag: TG_VISU2008_14_07_08~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2cad0cc815874ecfba13f3dad3690c25af47b942;p=modules%2Fgui.git VISU 2008 - Introduction of the Feature Edges presentation mode --- diff --git a/src/SVTK/SVTK_DeviceActor.cxx b/src/SVTK/SVTK_DeviceActor.cxx index a3bb03773..e025131f3 100644 --- a/src/SVTK/SVTK_DeviceActor.cxx +++ b/src/SVTK/SVTK_DeviceActor.cxx @@ -36,6 +36,7 @@ // VTK Includes #include #include +#include #include #include @@ -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 diff --git a/src/SVTK/SVTK_DeviceActor.h b/src/SVTK/SVTK_DeviceActor.h index 47fc3e12d..0fdd18b9f 100644 --- a/src/SVTK/SVTK_DeviceActor.h +++ b/src/SVTK/SVTK_DeviceActor.h @@ -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 myPassFilter; vtkShrinkFilter* myShrinkFilter; + vtkFeatureEdges* myFeatureEdges; vtkDataSetMapper* myMapper; bool myIsShrinkable; bool myIsShrunk; + bool myIsFeatureEdgesAllowed; + bool myIsFeatureEdgesEnabled; + bool myIsResolveCoincidentTopology; vtkFloatingPointType myPolygonOffsetFactor; vtkFloatingPointType myPolygonOffsetUnits;