X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_DeviceActor.cxx;h=28670e6bef7302f017887740615bed1380d270df;hp=52a34f63de2b65db6217214395cb0576727e404e;hb=4ff5bd61540272713e48de1eee75625028c32155;hpb=b5e77ba5e9b02af05c0b57d13c614c470f96bcff diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx index 52a34f63d..28670e6be 100644 --- a/src/OBJECT/SMESH_DeviceActor.cxx +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -21,10 +21,10 @@ // // // -// File : SMESH_Actor.cxx -// Author : Nicolas REJNERI +// File : SMESH_DeviceActor.cxx +// Author : // Module : SMESH -// $Header$Header: /home/server/cvs/SMESH/SMESH_SRC/src/OBJECT/SMESH_DeviceActor.cxx,v 1.7 2005/02/02 12:17:51 apo Exp $ +// $Header$ #include "SMESH_DeviceActor.h" @@ -32,10 +32,10 @@ #include "SMESH_ControlsDef.hxx" #include "SMESH_ActorUtils.h" -#include "SALOME_Transform.h" -#include "SALOME_TransformFilter.h" -#include "SALOME_PassThroughFilter.h" -#include "SALOME_ExtractUnstructuredGrid.h" +#include +#include +#include +#include // VTK Includes #include @@ -75,8 +75,10 @@ using namespace std; vtkStandardNewMacro(SMESH_DeviceActor); -SMESH_DeviceActor::SMESH_DeviceActor(){ - if(MYDEBUG) MESSAGE("SMESH_DeviceActor"); +SMESH_DeviceActor::SMESH_DeviceActor() +{ + if(MYDEBUG) MESSAGE("SMESH_DeviceActor - "<SetStoreMapping(true); + myStoreClippingMapping = false; - myExtractUnstructuredGrid = SALOME_ExtractUnstructuredGrid::New(); - myExtractUnstructuredGrid->SetStoreMapping(true); + myExtractGeometry = SMESH_ExtractGeometry::New(); + myExtractGeometry->SetReleaseDataFlag(true); + myIsImplicitFunctionUsed = false; + myExtractUnstructuredGrid = VTKViewer_ExtractUnstructuredGrid::New(); + myMergeFilter = vtkMergeFilter::New(); - myStoreMapping = false; - myGeomFilter = SALOME_GeometryFilter::New(); + myGeomFilter = VTKViewer_GeometryFilter::New(); - myTransformFilter = SALOME_TransformFilter::New(); + myTransformFilter = VTKViewer_TransformFilter::New(); for(int i = 0; i < 6; i++) - myPassFilter.push_back(SALOME_PassThroughFilter::New()); + myPassFilter.push_back(VTKViewer_PassThroughFilter::New()); } SMESH_DeviceActor::~SMESH_DeviceActor(){ - if(MYDEBUG) MESSAGE("~SMESH_DeviceActor"); + if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<Delete(); - myMapper->RemoveAllInputs(); myMapper->Delete(); - myShrinkFilter->UnRegisterAllOutputs(); myShrinkFilter->Delete(); - myExtractUnstructuredGrid->UnRegisterAllOutputs(); myExtractUnstructuredGrid->Delete(); - myMergeFilter->UnRegisterAllOutputs(); myMergeFilter->Delete(); - myGeomFilter->UnRegisterAllOutputs(); myGeomFilter->Delete(); - myExtractGeometry->UnRegisterAllOutputs(); myExtractGeometry->Delete(); - myTransformFilter->UnRegisterAllOutputs(); myTransformFilter->Delete(); for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){ - myPassFilter[i]->UnRegisterAllOutputs(); myPassFilter[i]->Delete(); } } -void SMESH_DeviceActor::SetStoreMapping(int theStoreMapping){ - myStoreMapping = theStoreMapping; - Modified(); +void +SMESH_DeviceActor:: +SetStoreGemetryMapping(bool theStoreMapping) +{ + myGeomFilter->SetStoreMapping(theStoreMapping); + SetStoreClippingMapping(theStoreMapping); +} + + +void +SMESH_DeviceActor:: +SetStoreClippingMapping(bool theStoreMapping) +{ + myStoreClippingMapping = theStoreMapping; + myExtractGeometry->SetStoreMapping(theStoreMapping && myIsImplicitFunctionUsed); + SetStoreIDMapping(theStoreMapping); +} + + +void +SMESH_DeviceActor:: +SetStoreIDMapping(bool theStoreMapping) +{ + myExtractUnstructuredGrid->SetStoreMapping(theStoreMapping); } @@ -157,6 +174,21 @@ void SMESH_DeviceActor::Init(TVisualObjPtr theVisualObj, } +void +SMESH_DeviceActor:: +SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed) +{ + int anId = 0; + if(theIsImplicitFunctionUsed) + myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() ); + else + myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() ); + + myIsImplicitFunctionUsed = theIsImplicitFunctionUsed; + SetStoreClippingMapping(myStoreClippingMapping); +} + + void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){ if(theGrid){ //myIsShrinkable = theGrid->GetNumberOfCells() > 10; @@ -169,11 +201,10 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){ myExtractGeometry->SetInput(myMergeFilter->GetOutput()); int anId = 0; - myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() ); + SetImplicitFunctionUsed(myIsImplicitFunctionUsed); myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() ); anId++; // 1 - myGeomFilter->SetStoreMapping( myStoreMapping ); myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() ); anId++; // 2 @@ -200,7 +231,7 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){ } -SALOME_ExtractUnstructuredGrid* SMESH_DeviceActor::GetExtractUnstructuredGrid(){ +VTKViewer_ExtractUnstructuredGrid* SMESH_DeviceActor::GetExtractUnstructuredGrid(){ return myExtractUnstructuredGrid; } @@ -218,7 +249,11 @@ void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor, bool anIsInitialized = theFunctor; if(anIsInitialized){ vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New(); + + SetStoreIDMapping(true); + myExtractUnstructuredGrid->Update(); vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput(); + aDataSet->ShallowCopy(aGrid); vtkDoubleArray *aScalars = vtkDoubleArray::New(); @@ -259,14 +294,13 @@ void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor, } void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor, - SMESH_DeviceActor* theDeviceActor, vtkScalarBarActor* theScalarBarActor, vtkLookupTable* theLookupTable) { bool anIsInitialized = theFunctor; myExtractUnstructuredGrid->ClearRegisteredCells(); myExtractUnstructuredGrid->ClearRegisteredCellsWithType(); - myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::ePassAll); + myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll); myVisualObj->UpdateFunctor(theFunctor); using namespace SMESH::Controls; @@ -398,22 +432,20 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor theScalarBarActor->SetVisibility(anIsInitialized); } -void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor, - SMESH_DeviceActor* theDeviceActor) +void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor) { myExtractUnstructuredGrid->ClearRegisteredCells(); myExtractUnstructuredGrid->ClearRegisteredCellsWithType(); - myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::ePassAll); + myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll); myVisualObj->UpdateFunctor(theFunctor); using namespace SMESH::Controls; if(FreeBorders* aFreeBorders = dynamic_cast(theFunctor.get())){ - myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); - myExtractUnstructuredGrid->ClearRegisteredCells(); - vtkUnstructuredGrid* aGrid = theDeviceActor->GetUnstructuredGrid(); + myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); + vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid(); vtkIdType aNbCells = aGrid->GetNumberOfCells(); for( vtkIdType i = 0; i < aNbCells; i++ ){ - vtkIdType anObjId = theDeviceActor->GetElemObjId(i); + vtkIdType anObjId = myVisualObj->GetElemObjId(i); if(aFreeBorders->IsSatisfy(anObjId)) myExtractUnstructuredGrid->RegisterCell(i); } @@ -484,7 +516,7 @@ unsigned long int SMESH_DeviceActor::GetMTime(){ } -void SMESH_DeviceActor::SetTransform(SALOME_Transform* theTransform){ +void SMESH_DeviceActor::SetTransform(VTKViewer_Transform* theTransform){ myTransformFilter->SetTransform(theTransform); } @@ -511,19 +543,27 @@ void SMESH_DeviceActor::UnShrink() { } -void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){ +void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){ switch(theMode){ - case ePoint: + case ePoint: myGeomFilter->SetInside(true); + myGeomFilter->SetWireframeMode(false); GetProperty()->SetRepresentation(0); break; - case eInsideframe: + case eWireframe: + myGeomFilter->SetInside(false); + myGeomFilter->SetWireframeMode(true); + GetProperty()->SetRepresentation(theMode); + break; + case eInsideframe: myGeomFilter->SetInside(true); + myGeomFilter->SetWireframeMode(true); GetProperty()->SetRepresentation(1); break; - default : - GetProperty()->SetRepresentation(theMode); + case eSurface: myGeomFilter->SetInside(false); + myGeomFilter->SetWireframeMode(false); + GetProperty()->SetRepresentation(theMode); } myRepresentation = theMode; GetProperty()->Modified(); @@ -533,7 +573,9 @@ void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){ void SMESH_DeviceActor::SetVisibility(int theMode){ - if(!myExtractUnstructuredGrid->GetInput() || GetUnstructuredGrid()->GetNumberOfCells()){ + if(!myExtractUnstructuredGrid->GetInput() || + GetUnstructuredGrid()->GetNumberOfCells()) + { vtkLODActor::SetVisibility(theMode); }else{ vtkLODActor::SetVisibility(false); @@ -550,14 +592,18 @@ int SMESH_DeviceActor::GetVisibility(){ int SMESH_DeviceActor::GetNodeObjId(int theVtkID){ - vtkIdType anID = myExtractGeometry->GetNodeObjId(theVtkID); + vtkIdType anID = theVtkID; + + if(IsImplicitFunctionUsed()) + anID = myExtractGeometry->GetNodeObjId(theVtkID); + vtkIdType aRetID = myVisualObj->GetNodeObjId(anID); - if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<