X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_DeviceActor.cxx;h=4be8cadec51d855ad2af99e58b2fdf3d1a0c9b83;hp=52a34f63de2b65db6217214395cb0576727e404e;hb=9357f5c87098aff2b95b754d69f66c76d2df9c24;hpb=b5e77ba5e9b02af05c0b57d13c614c470f96bcff diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx index 52a34f63d..4be8cadec 100644 --- a/src/OBJECT/SMESH_DeviceActor.cxx +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -1,41 +1,41 @@ -// SMESH OBJECT : interactive object for SMESH visualization +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File : SMESH_Actor.cxx -// Author : Nicolas REJNERI -// 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 $ - +// SMESH OBJECT : interactive object for SMESH visualization +// File : SMESH_DeviceActor.cxx +// Author : +// Module : SMESH +// #include "SMESH_DeviceActor.h" #include "SMESH_ExtractGeometry.h" #include "SMESH_ControlsDef.hxx" #include "SMESH_ActorUtils.h" +#include "SMESH_FaceOrientationFilter.h" +#include "VTKViewer_CellLocationsArray.h" +#include "VTKViewer_PolyDataMapper.h" -#include "SALOME_Transform.h" -#include "SALOME_TransformFilter.h" -#include "SALOME_PassThroughFilter.h" -#include "SALOME_ExtractUnstructuredGrid.h" +#include +#include +#include // VTK Includes #include @@ -55,11 +55,13 @@ #include #include -#include #include #include #include +#include + +#include #include "utilities.h" @@ -75,81 +77,128 @@ using namespace std; vtkStandardNewMacro(SMESH_DeviceActor); -SMESH_DeviceActor::SMESH_DeviceActor(){ - if(MYDEBUG) MESSAGE("SMESH_DeviceActor"); - myIsShrunk = false; +SMESH_DeviceActor +::SMESH_DeviceActor() +{ + if(MYDEBUG) MESSAGE("SMESH_DeviceActor - "<UseLookupTableScalarRangeOn(); myMapper->SetColorModeToMapScalars(); myShrinkFilter = vtkShrinkFilter::New(); - myExtractGeometry = SMESH_ExtractGeometry::New(); - myExtractGeometry->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(vtkPassThroughFilter::New()); + + // Orientation of faces + myIsFacesOriented = false; + + vtkFloatingPointType anRGB[3] = { 1, 1, 1 }; + SMESH::GetColor( "SMESH", "orientation_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) ); + + myFaceOrientationFilter = SMESH_FaceOrientationFilter::New(); + + myFaceOrientationDataMapper = vtkPolyDataMapper::New(); + myFaceOrientationDataMapper->SetInput(myFaceOrientationFilter->GetOutput()); + + myFaceOrientation = vtkActor::New(); + myFaceOrientation->SetMapper(myFaceOrientationDataMapper); + myFaceOrientation->GetProperty()->SetColor(anRGB[0], anRGB[1], anRGB[2]); } -SMESH_DeviceActor::~SMESH_DeviceActor(){ - if(MYDEBUG) MESSAGE("~SMESH_DeviceActor"); +SMESH_DeviceActor +::~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(); } + + // Orientation of faces + myFaceOrientationFilter->Delete(); + + myFaceOrientationDataMapper->RemoveAllInputs(); + myFaceOrientationDataMapper->Delete(); + + myFaceOrientation->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); } -void SMESH_DeviceActor::Init(TVisualObjPtr theVisualObj, - vtkImplicitBoolean* theImplicitBoolean) +void +SMESH_DeviceActor +::Init(TVisualObjPtr theVisualObj, + vtkImplicitBoolean* theImplicitBoolean) { myVisualObj = theVisualObj; myExtractGeometry->SetImplicitFunction(theImplicitBoolean); @@ -157,7 +206,25 @@ void SMESH_DeviceActor::Init(TVisualObjPtr theVisualObj, } -void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){ +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; myIsShrinkable = true; @@ -169,11 +236,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 @@ -182,17 +248,13 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){ anId++; // 3 myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() ); - myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() ); anId++; // 4 myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() ); myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() ); - myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() ); - myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() ); anId++; // 5 myMapper->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() ); - myMapper->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() ); vtkLODActor::SetMapper( myMapper ); Modified(); @@ -200,25 +262,37 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){ } -SALOME_ExtractUnstructuredGrid* SMESH_DeviceActor::GetExtractUnstructuredGrid(){ +VTKViewer_ExtractUnstructuredGrid* +SMESH_DeviceActor +::GetExtractUnstructuredGrid() +{ return myExtractUnstructuredGrid; } -vtkUnstructuredGrid* SMESH_DeviceActor::GetUnstructuredGrid(){ +vtkUnstructuredGrid* +SMESH_DeviceActor +::GetUnstructuredGrid() +{ myExtractUnstructuredGrid->Update(); return myExtractUnstructuredGrid->GetOutput(); } -void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor, - vtkScalarBarActor* theScalarBarActor, - vtkLookupTable* theLookupTable) +void +SMESH_DeviceActor +::SetControlMode(SMESH::Controls::FunctorPtr theFunctor, + vtkScalarBarActor* theScalarBarActor, + vtkLookupTable* theLookupTable) { bool anIsInitialized = theFunctor; if(anIsInitialized){ vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New(); + + SetStoreIDMapping(true); + myExtractUnstructuredGrid->Update(); vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput(); + aDataSet->ShallowCopy(aGrid); vtkDoubleArray *aScalars = vtkDoubleArray::New(); @@ -231,24 +305,25 @@ void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor, using namespace SMESH::Controls; if(NumericalFunctor* aNumericalFunctor = dynamic_cast(theFunctor.get())){ for(vtkIdType i = 0; i < aNbCells; i++){ - vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i); - vtkIdType anObjId = myVisualObj->GetElemObjId(anId); - double aValue = aNumericalFunctor->GetValue(anObjId); - aScalars->SetValue(i,aValue); + vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i); + vtkIdType anObjId = myVisualObj->GetElemObjId(anId); + double aValue = aNumericalFunctor->GetValue(anObjId); + aScalars->SetValue(i,aValue); } }else if(Predicate* aPredicate = dynamic_cast(theFunctor.get())){ for(vtkIdType i = 0; i < aNbCells; i++){ - vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i); - vtkIdType anObjId = myVisualObj->GetElemObjId(anId); - bool aValue = aPredicate->IsSatisfy(anObjId); - aScalars->SetValue(i,aValue); + vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i); + vtkIdType anObjId = myVisualObj->GetElemObjId(anId); + bool aValue = aPredicate->IsSatisfy(anObjId); + aScalars->SetValue(i,aValue); } } aDataSet->GetCellData()->SetScalars(aScalars); aScalars->Delete(); - + theLookupTable->SetRange(aScalars->GetRange()); + theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors()); theLookupTable->Build(); myMergeFilter->SetScalars(aDataSet); @@ -258,15 +333,16 @@ void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor, theScalarBarActor->SetVisibility(anIsInitialized); } -void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor, - SMESH_DeviceActor* theDeviceActor, - vtkScalarBarActor* theScalarBarActor, - vtkLookupTable* theLookupTable) +void +SMESH_DeviceActor +::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor, + 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; @@ -299,27 +375,27 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor Length2D::TValues::const_iterator anIter = aValues.begin(); for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){ - const Length2D::Value& aValue = *anIter; - int aNode[2] = { - myVisualObj->GetNodeVTKId(aValue.myPntId[0]), - myVisualObj->GetNodeVTKId(aValue.myPntId[1]) - }; - if(aNode[0] >= 0 && aNode[1] >= 0){ - anIdList->SetId( 0, aNode[0] ); - anIdList->SetId( 1, aNode[1] ); - aConnectivity->InsertNextCell( anIdList ); - aCellTypesArray->InsertNextValue( VTK_LINE ); - aScalars->SetValue(aVtkId,aValue.myLength); - } + const Length2D::Value& aValue = *anIter; + int aNode[2] = { + myVisualObj->GetNodeVTKId(aValue.myPntId[0]), + myVisualObj->GetNodeVTKId(aValue.myPntId[1]) + }; + if(aNode[0] >= 0 && aNode[1] >= 0){ + anIdList->SetId( 0, aNode[0] ); + anIdList->SetId( 1, aNode[1] ); + aConnectivity->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_LINE ); + aScalars->SetValue(aVtkId,aValue.myLength); + } } - vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New(); aCellLocationsArray->SetNumberOfComponents( 1 ); aCellLocationsArray->SetNumberOfTuples( aNbCells ); aConnectivity->InitTraversal(); for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ ) - aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) ); + aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) ); aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity ); SetUnstructuredGrid(aDataSet); @@ -359,27 +435,27 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor MultiConnection2D::MValues::const_iterator anIter = aValues.begin(); for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){ - const MultiConnection2D::Value& aValue = (*anIter).first; - int aNode[2] = { - myVisualObj->GetNodeVTKId(aValue.myPntId[0]), - myVisualObj->GetNodeVTKId(aValue.myPntId[1]) - }; - if(aNode[0] >= 0 && aNode[1] >= 0){ - anIdList->SetId( 0, aNode[0] ); - anIdList->SetId( 1, aNode[1] ); - aConnectivity->InsertNextCell( anIdList ); - aCellTypesArray->InsertNextValue( VTK_LINE ); - aScalars->SetValue(aVtkId,(*anIter).second); - } + const MultiConnection2D::Value& aValue = (*anIter).first; + int aNode[2] = { + myVisualObj->GetNodeVTKId(aValue.myPntId[0]), + myVisualObj->GetNodeVTKId(aValue.myPntId[1]) + }; + if(aNode[0] >= 0 && aNode[1] >= 0){ + anIdList->SetId( 0, aNode[0] ); + anIdList->SetId( 1, aNode[1] ); + aConnectivity->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_LINE ); + aScalars->SetValue(aVtkId,(*anIter).second); + } } - vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New(); aCellLocationsArray->SetNumberOfComponents( 1 ); aCellLocationsArray->SetNumberOfTuples( aNbCells ); aConnectivity->InitTraversal(); for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ ) - aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) ); + aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) ); aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity ); SetUnstructuredGrid(aDataSet); @@ -398,24 +474,26 @@ 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(); + if ( dynamic_cast(theFunctor.get()) || + dynamic_cast(theFunctor.get()) ) { + Predicate* aFreePredicate = dynamic_cast(theFunctor.get()); + 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); - if(aFreeBorders->IsSatisfy(anObjId)) - myExtractUnstructuredGrid->RegisterCell(i); + vtkIdType anObjId = myVisualObj->GetElemObjId(i); + if(aFreePredicate->IsSatisfy(anObjId)) + myExtractUnstructuredGrid->RegisterCell(i); } if(!myExtractUnstructuredGrid->IsCellsRegistered()) myExtractUnstructuredGrid->RegisterCell(-1); @@ -443,19 +521,19 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor for(; anIter != aBorders.end(); anIter++){ const FreeEdges::Border& aBorder = *anIter; int aNode[2] = { - myVisualObj->GetNodeVTKId(aBorder.myPntId[0]), - myVisualObj->GetNodeVTKId(aBorder.myPntId[1]) + myVisualObj->GetNodeVTKId(aBorder.myPntId[0]), + myVisualObj->GetNodeVTKId(aBorder.myPntId[1]) }; //cout<<"aNode = "<= 0 && aNode[1] >= 0){ - anIdList->SetId( 0, aNode[0] ); - anIdList->SetId( 1, aNode[1] ); - aConnectivity->InsertNextCell( anIdList ); - aCellTypesArray->InsertNextValue( VTK_LINE ); + anIdList->SetId( 0, aNode[0] ); + anIdList->SetId( 1, aNode[1] ); + aConnectivity->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_LINE ); } } - vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New(); aCellLocationsArray->SetNumberOfComponents( 1 ); aCellLocationsArray->SetNumberOfTuples( aNbCells ); @@ -467,29 +545,50 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor SetUnstructuredGrid(aDataSet); aDataSet->Delete(); + }else if(FreeNodes* aFreeNodes = dynamic_cast(theFunctor.get())){ + myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); + vtkIdType aNbNodes = myVisualObj->GetNbEntities(SMDSAbs_Node); + for( vtkIdType i = 0; i < aNbNodes; i++ ){ + vtkIdType anObjId = myVisualObj->GetNodeObjId(i); + if(aFreeNodes->IsSatisfy(anObjId)) + myExtractUnstructuredGrid->RegisterCell(i); + } + if(!myExtractUnstructuredGrid->IsCellsRegistered()) + myExtractUnstructuredGrid->RegisterCell(-1); + SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); } } -unsigned long int SMESH_DeviceActor::GetMTime(){ +unsigned long int +SMESH_DeviceActor +::GetMTime() +{ unsigned long mTime = this->Superclass::GetMTime(); mTime = max(mTime,myExtractGeometry->GetMTime()); mTime = max(mTime,myExtractUnstructuredGrid->GetMTime()); mTime = max(mTime,myMergeFilter->GetMTime()); mTime = max(mTime,myGeomFilter->GetMTime()); mTime = max(mTime,myTransformFilter->GetMTime()); + mTime = max(mTime,myFaceOrientationFilter->GetMTime()); return mTime; } -void SMESH_DeviceActor::SetTransform(SALOME_Transform* theTransform){ +void +SMESH_DeviceActor +::SetTransform(VTKViewer_Transform* theTransform) +{ myTransformFilter->SetTransform(theTransform); } -void SMESH_DeviceActor::SetShrink() { +void +SMESH_DeviceActor +::SetShrink() +{ if ( !myIsShrinkable ) return; if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() ) { @@ -499,7 +598,10 @@ void SMESH_DeviceActor::SetShrink() { } } -void SMESH_DeviceActor::UnShrink() { +void +SMESH_DeviceActor +::UnShrink() +{ if ( !myIsShrunk ) return; if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() ) { @@ -511,37 +613,125 @@ void SMESH_DeviceActor::UnShrink() { } -void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){ +void +SMESH_DeviceActor +::SetFacesOriented(bool theIsFacesOriented) +{ + if ( vtkDataSet* aDataSet = myPassFilter[ 1 ]->GetOutput() ) + { + myIsFacesOriented = theIsFacesOriented; + if( theIsFacesOriented ) + myFaceOrientationFilter->SetInput( aDataSet ); + UpdateFaceOrientation(); + } +} + +void +SMESH_DeviceActor +::SetFacesOrientationColor(vtkFloatingPointType theColor[3]) +{ + myFaceOrientation->GetProperty()->SetColor( theColor ); +} + +void +SMESH_DeviceActor +::GetFacesOrientationColor(vtkFloatingPointType theColor[3]) +{ + myFaceOrientation->GetProperty()->GetColor( theColor ); +} + +void +SMESH_DeviceActor +::SetFacesOrientationScale(vtkFloatingPointType theScale) +{ + myFaceOrientationFilter->SetOrientationScale( theScale ); +} + +vtkFloatingPointType +SMESH_DeviceActor +::GetFacesOrientationScale() +{ + return myFaceOrientationFilter->GetOrientationScale(); +} + +void +SMESH_DeviceActor +::SetFacesOrientation3DVectors(bool theState) +{ + myFaceOrientationFilter->Set3dVectors( theState ); +} + +bool +SMESH_DeviceActor +::GetFacesOrientation3DVectors() +{ + return myFaceOrientationFilter->Get3dVectors(); +} + +void +SMESH_DeviceActor +::UpdateFaceOrientation() +{ + bool aShowFaceOrientation = myIsFacesOriented; + aShowFaceOrientation &= GetVisibility(); + aShowFaceOrientation &= myRepresentation == eSurface; + myFaceOrientation->SetVisibility(aShowFaceOrientation); +} + + +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); } + SetMarkerEnabled(theMode == ePoint); myRepresentation = theMode; + UpdateFaceOrientation(); GetProperty()->Modified(); myMapper->Modified(); Modified(); } -void SMESH_DeviceActor::SetVisibility(int theMode){ - if(!myExtractUnstructuredGrid->GetInput() || GetUnstructuredGrid()->GetNumberOfCells()){ +void +SMESH_DeviceActor +::SetVisibility(int theMode) +{ + if(!myExtractUnstructuredGrid->GetInput() || + GetUnstructuredGrid()->GetNumberOfCells()) + { vtkLODActor::SetVisibility(theMode); }else{ vtkLODActor::SetVisibility(false); } + UpdateFaceOrientation(); } -int SMESH_DeviceActor::GetVisibility(){ +int +SMESH_DeviceActor +::GetVisibility() +{ if(!GetUnstructuredGrid()->GetNumberOfCells()){ vtkLODActor::SetVisibility(false); } @@ -549,73 +739,125 @@ int SMESH_DeviceActor::GetVisibility(){ } -int SMESH_DeviceActor::GetNodeObjId(int theVtkID){ - vtkIdType anID = myExtractGeometry->GetNodeObjId(theVtkID); +void +SMESH_DeviceActor +::AddToRender(vtkRenderer* theRenderer) +{ + theRenderer->AddActor(this); + theRenderer->AddActor(myFaceOrientation); +} + +void +SMESH_DeviceActor +::RemoveFromRender(vtkRenderer* theRenderer) +{ + theRenderer->RemoveActor(this); + theRenderer->RemoveActor(myFaceOrientation); +} + + +int +SMESH_DeviceActor +::GetNodeObjId(int theVtkID) +{ + vtkIdType anID = theVtkID; + + if(IsImplicitFunctionUsed()) + anID = myExtractGeometry->GetNodeObjId(theVtkID); + vtkIdType aRetID = myVisualObj->GetNodeObjId(anID); - if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<