From c0df6c43a36a44a8c1efefa8fe545c9126f67be0 Mon Sep 17 00:00:00 2001 From: ouv Date: Tue, 8 Jul 2008 08:42:38 +0000 Subject: [PATCH] VISU 2008 - Introduction of the Feature Edges presentation mode --- idl/VISU_Gen.idl | 1 + resources/SalomeApp.xml | 6 ++ src/OBJECT/VISU_Actor.cxx | 129 ++++++++++++++++++++++++++ src/OBJECT/VISU_Actor.h | 53 +++++++++++ src/OBJECT/VISU_MeshAct.cxx | 66 +++++++++++++ src/OBJECT/VISU_MeshAct.h | 23 +++++ src/PIPELINE/VISU_CutLinesPL.cxx | 1 + src/PIPELINE/VISU_CutPlanesPL.cxx | 1 + src/PIPELINE/VISU_DeformedShapePL.cxx | 1 + src/PIPELINE/VISU_GaussPointsPL.cxx | 1 + src/PIPELINE/VISU_IsoSurfacesPL.cxx | 1 + src/PIPELINE/VISU_MeshPL.cxx | 1 + src/PIPELINE/VISU_PipeLine.cxx | 23 ++++- src/PIPELINE/VISU_PipeLine.hxx | 7 ++ src/PIPELINE/VISU_Plot3DPL.cxx | 1 + src/PIPELINE/VISU_ScalarMapPL.cxx | 1 + src/PIPELINE/VISU_StreamLinesPL.cxx | 1 + src/PIPELINE/VISU_VectorsPL.cxx | 1 + src/VISU_I/VISU_Mesh_i.cc | 9 ++ 19 files changed, 326 insertions(+), 1 deletion(-) diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index d6ae2db1..f068b4ef 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -346,6 +346,7 @@ module VISU { SHADED, INSIDEFRAME, SURFACEFRAME, + FEATURE_EDGES, SHRINK }; diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index 21d28a2e..7bd7d5e5 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -27,6 +27,12 @@ + + + + + + diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index 5621c531..dfab3808 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -58,6 +58,7 @@ #include #include #include +#include #include #include @@ -104,6 +105,9 @@ VISU_Actor myAnnotationMapper(vtkTextMapper::New()), myAnnotationActor(vtkTextActor::New()), myTextActor(VISU_FramedTextActor::New()), + myIsFeatureEdgesAllowed(false), + myIsFeatureEdgesEnabled(false), + myFeatureEdges(vtkFeatureEdges::New()), myLastSelectionMode(ActorSelection), myIsSubElementsHighlighted(false) { @@ -125,6 +129,8 @@ VISU_Actor myTextActor->SetVisibility(false); myTextActor->SetPickable(false); + myFeatureEdges->Delete(); + myEventCallbackCommand->Delete(); myEventCallbackCommand->SetClientData(this); myEventCallbackCommand->SetCallback(VISU_Actor::ProcessEvents); @@ -148,6 +154,15 @@ VISU_Actor SetShrink(); else UnShrink(); + + SetFeatureEdgesAllowed(theActor->IsFeatureEdgesAllowed()); + SetFeatureEdgesEnabled(theActor->IsFeatureEdgesEnabled()); + SetFeatureEdgesAngle(theActor->GetFeatureEdgesAngle()); + bool aFeatureEdges = false, aBoundaryEdges = false, aManifoldEdges = false, aNonManifoldEdges = false; + theActor->GetFeatureEdgesFlags( aFeatureEdges, aBoundaryEdges, aManifoldEdges, aNonManifoldEdges ); + SetFeatureEdgesFlags( aFeatureEdges, aBoundaryEdges, aManifoldEdges, aNonManifoldEdges ); + SetFeatureEdgesColoring(theActor->GetFeatureEdgesColoring()); + SetOpacity(theActor->GetOpacity()); SetLineWidth(theActor->GetLineWidth()); SetPosition(theActor->GetPosition()); @@ -250,6 +265,7 @@ VISU_Actor if(vtkMapper *aMapper = myPipeLine->GetMapper()){ if(vtkDataSet *aDataSet = aMapper->GetInput()){ SetShrinkable(thePipeLine->IsShrinkable()); + SetFeatureEdgesAllowed(thePipeLine->IsFeatureEdgesAllowed()); SetMapperInput(aDataSet); } } @@ -279,7 +295,10 @@ VISU_Actor { Superclass::SetRepresentation(theMode); if(myRepresentation == VTK_POINTS) + { UnShrink(); + SetFeatureEdgesEnabled( false ); + } } @@ -348,6 +367,111 @@ VISU_Actor } +//---------------------------------------------------------------------------- +bool +VISU_Actor +::IsFeatureEdgesAllowed() +{ + return myIsFeatureEdgesAllowed; +} + +void +VISU_Actor +::SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed) +{ + myIsFeatureEdgesAllowed = theIsFeatureEdgesAllowed; +} + +bool +VISU_Actor +::IsFeatureEdgesEnabled() +{ + return myIsFeatureEdgesEnabled; +} + +void +VISU_Actor +::SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled) +{ + if ( !myIsFeatureEdgesAllowed || myIsFeatureEdgesEnabled == theIsFeatureEdgesEnabled ) + return; + + if ( vtkPolyData* aPolyData = myPassFilter[ 2 ]->GetPolyDataOutput() ) + { + if( theIsFeatureEdgesEnabled ) + { + myFeatureEdges->SetInput( aPolyData ); + myPassFilter[ 3 ]->SetInput( myFeatureEdges->GetOutput() ); + myIsFeatureEdgesEnabled = true; + } + else + { + myPassFilter[3]->SetInput( aPolyData ); + myPassFilter[3]->Modified(); + myIsFeatureEdgesEnabled = false; + Modified(); + } + myIsFeatureEdgesEnabled = theIsFeatureEdgesEnabled; + } +} + +vtkFloatingPointType +VISU_Actor +::GetFeatureEdgesAngle() +{ + return myFeatureEdges->GetFeatureAngle(); +} + +void +VISU_Actor +::SetFeatureEdgesAngle(vtkFloatingPointType theValue) +{ + myFeatureEdges->SetFeatureAngle(theValue); + Modified(); +} + +void +VISU_Actor +::GetFeatureEdgesFlags(bool& theIsFeatureEdges, + bool& theIsBoundaryEdges, + bool& theIsManifoldEdges, + bool& theIsNonManifoldEdges) +{ + theIsFeatureEdges = myFeatureEdges->GetFeatureEdges(); + theIsBoundaryEdges = myFeatureEdges->GetBoundaryEdges(); + theIsManifoldEdges = myFeatureEdges->GetManifoldEdges(); + theIsNonManifoldEdges = myFeatureEdges->GetNonManifoldEdges(); +} + +void +VISU_Actor +::SetFeatureEdgesFlags(bool theIsFeatureEdges, + bool theIsBoundaryEdges, + bool theIsManifoldEdges, + bool theIsNonManifoldEdges) +{ + myFeatureEdges->SetFeatureEdges(theIsFeatureEdges); + myFeatureEdges->SetBoundaryEdges(theIsBoundaryEdges); + myFeatureEdges->SetManifoldEdges(theIsManifoldEdges); + myFeatureEdges->SetNonManifoldEdges(theIsNonManifoldEdges); + Modified(); +} + +bool +VISU_Actor +::GetFeatureEdgesColoring() +{ + return myFeatureEdges->GetColoring(); +} + +void +VISU_Actor +::SetFeatureEdgesColoring(bool theIsColoring) +{ + myFeatureEdges->SetColoring(theIsColoring); + Modified(); +} + //---------------------------------------------------------------------------- void VISU_Actor @@ -447,6 +571,11 @@ VISU_Actor aSize += aDataSet->GetActualMemorySize() * 1024; } + if(IsFeatureEdgesEnabled()){ + vtkPolyData* aPolyData = myFeatureEdges->GetOutput(); + aSize += aPolyData->GetActualMemorySize() * 1024; + } + return aSize; } diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index e4e26779..70f438ec 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -48,6 +48,7 @@ class VTKViewer_ShrinkFilter; class VISU_PipeLine; class vtkPlane; class vtkImplicitFunctionCollection; +class vtkFeatureEdges; class VISU_FramedTextActor; @@ -62,6 +63,7 @@ namespace SVTK namespace Representation { const Type Surfaceframe = Insideframe + 1; + const Type FeatureEdges = Insideframe + 2; } } @@ -164,6 +166,53 @@ class VTKOCC_EXPORT VISU_Actor : vtkFloatingPointType GetShrinkFactor(); + //---------------------------------------------------------------------------- + virtual + bool + IsFeatureEdgesAllowed(); + + virtual + void + SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed); + + virtual + bool + IsFeatureEdgesEnabled(); + + virtual + void + SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled); + + virtual + vtkFloatingPointType + GetFeatureEdgesAngle(); + + virtual + void + SetFeatureEdgesAngle(vtkFloatingPointType theAngle = 30.0); + + 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); + //---------------------------------------------------------------------------- virtual void @@ -328,6 +377,10 @@ class VTKOCC_EXPORT VISU_Actor : vtkSmartPointer myTextActor; + vtkSmartPointer myFeatureEdges; + bool myIsFeatureEdgesAllowed; + bool myIsFeatureEdgesEnabled; + Selection_Mode myLastSelectionMode; bool myIsSubElementsHighlighted; }; diff --git a/src/OBJECT/VISU_MeshAct.cxx b/src/OBJECT/VISU_MeshAct.cxx index cf2e7cfc..486498da 100644 --- a/src/OBJECT/VISU_MeshAct.cxx +++ b/src/OBJECT/VISU_MeshAct.cxx @@ -212,6 +212,64 @@ VISU_MeshAct myEdgeActor->UnShrink(); } +//---------------------------------------------------------------------------- +void +VISU_MeshAct +::SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed) +{ + Superclass::SetFeatureEdgesAllowed(theIsFeatureEdgesAllowed); + + mySurfaceActor->SetFeatureEdgesAllowed(theIsFeatureEdgesAllowed); +} + +void +VISU_MeshAct +::SetFeatureEdgesAngle(vtkFloatingPointType theValue) +{ + Superclass::SetFeatureEdgesAngle(theValue); + + mySurfaceActor->SetFeatureEdgesAngle(theValue); +} + +void +VISU_MeshAct +::SetFeatureEdgesFlags(bool theIsFeatureEdges, + bool theIsBoundaryEdges, + bool theIsManifoldEdges, + bool theIsNonManifoldEdges) +{ + Superclass::SetFeatureEdgesFlags(theIsFeatureEdges, + theIsBoundaryEdges, + theIsManifoldEdges, + theIsNonManifoldEdges); + + mySurfaceActor->SetFeatureEdgesFlags(theIsFeatureEdges, + theIsBoundaryEdges, + theIsManifoldEdges, + theIsNonManifoldEdges); +} + +void +VISU_MeshAct +::SetFeatureEdgesColoring(bool theIsColoring) +{ + Superclass::SetFeatureEdgesColoring(theIsColoring); + + mySurfaceActor->SetFeatureEdgesColoring(theIsColoring); +} + +//---------------------------------------------------------------------------- +void +VISU_MeshAct +::SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled) +{ + if(theIsFeatureEdgesEnabled && myRepresentation == VTK_POINTS) + return; + + Superclass::SetFeatureEdgesEnabled(theIsFeatureEdgesEnabled); + + mySurfaceActor->SetFeatureEdgesEnabled(theIsFeatureEdgesEnabled); +} //---------------------------------------------------------------------------- void @@ -288,6 +346,10 @@ VISU_MeshAct myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren); myEdgeActor->RenderOpaqueGeometry(ren); break; + case FeatureEdges : + mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); + mySurfaceActor->RenderOpaqueGeometry(ren); + break; } return 1; } @@ -322,6 +384,10 @@ VISU_MeshAct myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren); myEdgeActor->RenderTranslucentGeometry(ren); break; + case FeatureEdges : + mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren); + mySurfaceActor->RenderTranslucentGeometry(ren); + break; } return 1; } diff --git a/src/OBJECT/VISU_MeshAct.h b/src/OBJECT/VISU_MeshAct.h index 5a5778d3..86ea7308 100644 --- a/src/OBJECT/VISU_MeshAct.h +++ b/src/OBJECT/VISU_MeshAct.h @@ -99,6 +99,29 @@ class VTKOCC_EXPORT VISU_MeshAct : public VISU_DataSetActor void UnShrink(); + virtual + void + SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed); + + virtual + void + SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled); + + virtual + void + SetFeatureEdgesAngle(vtkFloatingPointType theAngle = 30.0); + + virtual + void + SetFeatureEdgesFlags(bool theIsFeatureEdges, + bool theIsBoundaryEdges, + bool theIsManifoldEdges, + bool theIsNonManifoldEdges); + + virtual + void + SetFeatureEdgesColoring(bool theIsColoring); + //! Gets memory size used by the instance (bytes). virtual unsigned long int diff --git a/src/PIPELINE/VISU_CutLinesPL.cxx b/src/PIPELINE/VISU_CutLinesPL.cxx index 3bad32d1..927a0afb 100644 --- a/src/PIPELINE/VISU_CutLinesPL.cxx +++ b/src/PIPELINE/VISU_CutLinesPL.cxx @@ -41,6 +41,7 @@ VISU_CutLinesPL ::VISU_CutLinesPL() { SetIsShrinkable(false); + SetIsFeatureEdgesAllowed(false); myCondition = 1; myPosition = 0; diff --git a/src/PIPELINE/VISU_CutPlanesPL.cxx b/src/PIPELINE/VISU_CutPlanesPL.cxx index 22493a10..c9f840f3 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.cxx +++ b/src/PIPELINE/VISU_CutPlanesPL.cxx @@ -46,6 +46,7 @@ VISU_CutPlanesPL ::VISU_CutPlanesPL() { SetIsShrinkable(false); + SetIsFeatureEdgesAllowed(false); myAppendPolyData = vtkAppendPolyData::New(); diff --git a/src/PIPELINE/VISU_DeformedShapePL.cxx b/src/PIPELINE/VISU_DeformedShapePL.cxx index 816c474b..713dabcb 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.cxx +++ b/src/PIPELINE/VISU_DeformedShapePL.cxx @@ -42,6 +42,7 @@ VISU_DeformedShapePL myScaleFactor(0.0) { SetIsShrinkable(true); + SetIsFeatureEdgesAllowed(false); myWarpVector = vtkWarpVector::New(); myCellDataToPointData = vtkCellDataToPointData::New(); diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index ea42aaca..0f5ba427 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -60,6 +60,7 @@ VISU_GaussPointsPL myMergeFilter(VISU_GaussMergeFilter::New()) { SetIsShrinkable(false); + SetIsFeatureEdgesAllowed(false); myWarpVector = vtkWarpVector::New(); diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.cxx b/src/PIPELINE/VISU_IsoSurfacesPL.cxx index 602affdf..c133cad4 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.cxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.cxx @@ -43,6 +43,7 @@ VISU_IsoSurfacesPL ::VISU_IsoSurfacesPL() { SetIsShrinkable(false); + SetIsFeatureEdgesAllowed(false); myContourFilter = vtkContourFilter::New(); diff --git a/src/PIPELINE/VISU_MeshPL.cxx b/src/PIPELINE/VISU_MeshPL.cxx index 66317af0..056a5452 100644 --- a/src/PIPELINE/VISU_MeshPL.cxx +++ b/src/PIPELINE/VISU_MeshPL.cxx @@ -44,6 +44,7 @@ VISU_MeshPL VISU_UnstructuredGridPL(this) { SetIsShrinkable(true); + SetIsFeatureEdgesAllowed(true); } diff --git a/src/PIPELINE/VISU_PipeLine.cxx b/src/PIPELINE/VISU_PipeLine.cxx index 4128c982..0761bbd5 100644 --- a/src/PIPELINE/VISU_PipeLine.cxx +++ b/src/PIPELINE/VISU_PipeLine.cxx @@ -47,7 +47,8 @@ static int MYDEBUG = 0; //---------------------------------------------------------------------------- VISU_PipeLine ::VISU_PipeLine(): - myIsShrinkable(true) + myIsShrinkable(true), + myIsFeatureEdgesAllowed(true) { if(MYDEBUG) MESSAGE("VISU_PipeLine::VISU_PipeLine - "< myMapperHolder; bool myIsShrinkable; + bool myIsFeatureEdgesAllowed; }; #endif diff --git a/src/PIPELINE/VISU_Plot3DPL.cxx b/src/PIPELINE/VISU_Plot3DPL.cxx index 7696d62e..d4a30427 100644 --- a/src/PIPELINE/VISU_Plot3DPL.cxx +++ b/src/PIPELINE/VISU_Plot3DPL.cxx @@ -59,6 +59,7 @@ VISU_Plot3DPL myScaleFactor(1.0) { SetIsShrinkable(false); + SetIsFeatureEdgesAllowed(false); myCellDataToPointData->Delete(); myAppendPolyData->Delete(); diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index a8784c81..c14ce395 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -54,6 +54,7 @@ VISU_ScalarMapPL myMergeFilter(VISU_MergeFilter::New()) { SetIsShrinkable(true); + SetIsFeatureEdgesAllowed(false); myAppendFilter->SetMergingInputs(true); myAppendFilter->Delete(); diff --git a/src/PIPELINE/VISU_StreamLinesPL.cxx b/src/PIPELINE/VISU_StreamLinesPL.cxx index b596155e..82c05009 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.cxx +++ b/src/PIPELINE/VISU_StreamLinesPL.cxx @@ -62,6 +62,7 @@ VISU_StreamLinesPL ::VISU_StreamLinesPL() { SetIsShrinkable(false); + SetIsFeatureEdgesAllowed(false); myStream = vtkStreamLine::New(); myCenters = vtkCellCenters::New(); diff --git a/src/PIPELINE/VISU_VectorsPL.cxx b/src/PIPELINE/VISU_VectorsPL.cxx index 5192eefb..c7e4ad38 100644 --- a/src/PIPELINE/VISU_VectorsPL.cxx +++ b/src/PIPELINE/VISU_VectorsPL.cxx @@ -64,6 +64,7 @@ VISU_VectorsPL ::VISU_VectorsPL() { SetIsShrinkable(false); + SetIsFeatureEdgesAllowed(false); myBaseGlyph = vtkGlyph3D::New(); myTransformedGlyph = vtkGlyph3D::New(); diff --git a/src/VISU_I/VISU_Mesh_i.cc b/src/VISU_I/VISU_Mesh_i.cc index 70707f2f..088a3acf 100644 --- a/src/VISU_I/VISU_Mesh_i.cc +++ b/src/VISU_I/VISU_Mesh_i.cc @@ -531,6 +531,15 @@ VISU::Mesh_i anActor->GetSurfaceProperty()->SetColor(myCellColor.R, myCellColor.G, myCellColor.B); anActor->GetEdgeProperty()->SetColor(myLinkColor.R, myLinkColor.G, myLinkColor.B); anActor->GetNodeProperty()->SetColor(myNodeColor.R, myNodeColor.G, myNodeColor.B); + + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + anActor->SetFeatureEdgesEnabled( myPresentType == VISU::FEATURE_EDGES ); + anActor->SetFeatureEdgesAngle( aResourceMgr->doubleValue("VISU", "feature_edges_angle", 0.0) ); + anActor->SetFeatureEdgesFlags( aResourceMgr->booleanValue("VISU", "feature_edges", false), + aResourceMgr->booleanValue("VISU", "boundary_edges", false), + aResourceMgr->booleanValue("VISU", "manifold_edges", false), + aResourceMgr->booleanValue("VISU", "non_manifold_edges", false) ); + anActor->SetFeatureEdgesColoring( aResourceMgr->booleanValue("VISU", "feature_edges_coloring", false) ); } } -- 2.39.2