X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_DeviceActor.cxx;h=a1d8edf752d5f87625bfacd09802efac143b308b;hb=985e3a36299a495197a5cfab7ab31d17365f3e1f;hp=7a88f701b6751579b33bba7b74e96f3924701c0b;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6;p=modules%2Fsmesh.git diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx index 7a88f701b..a1d8edf75 100644 --- a/src/OBJECT/SMESH_DeviceActor.cxx +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // 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. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -63,6 +63,8 @@ #include +#include + #include "utilities.h" #ifdef _DEBUG_ @@ -90,6 +92,7 @@ SMESH_DeviceActor myProperty = vtkProperty::New(); myMapper = VTKViewer_PolyDataMapper::New(); + myPlaneCollection = vtkPlaneCollection::New(); vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor, myPolygonOffsetUnits); @@ -119,13 +122,13 @@ SMESH_DeviceActor // Orientation of faces myIsFacesOriented = false; - vtkFloatingPointType anRGB[3] = { 1, 1, 1 }; + double 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()); + myFaceOrientationDataMapper->SetInputConnection(myFaceOrientationFilter->GetOutputPort()); myFaceOrientation = vtkActor::New(); myFaceOrientation->SetMapper(myFaceOrientationDataMapper); @@ -138,33 +141,29 @@ SMESH_DeviceActor { if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<Delete(); - myMapper->Delete(); - myShrinkFilter->Delete(); + myProperty->Delete(); - myExtractUnstructuredGrid->Delete(); + myExtractGeometry->Delete(); myMergeFilter->Delete(); + myExtractUnstructuredGrid->Delete(); - myGeomFilter->Delete(); + // Orientation of faces + myFaceOrientationFilter->Delete(); + myFaceOrientationDataMapper->RemoveAllInputs(); + myFaceOrientationDataMapper->Delete(); + myFaceOrientation->Delete(); - myExtractGeometry->Delete(); + myGeomFilter->Delete(); myTransformFilter->Delete(); - for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){ + for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++) myPassFilter[i]->Delete(); - } - - // Orientation of faces - myFaceOrientationFilter->Delete(); - - myFaceOrientationDataMapper->RemoveAllInputs(); - myFaceOrientationDataMapper->Delete(); - myFaceOrientation->Delete(); + myShrinkFilter->Delete(); } @@ -212,9 +211,9 @@ SMESH_DeviceActor { int anId = 0; if(theIsImplicitFunctionUsed) - myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() ); + myPassFilter[ anId ]->SetInputConnection( myExtractGeometry->GetOutputPort() ); else - myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() ); + myPassFilter[ anId ]->SetInputConnection( myMergeFilter->GetOutputPort() ); myIsImplicitFunctionUsed = theIsImplicitFunctionUsed; SetStoreClippingMapping(myStoreClippingMapping); @@ -229,38 +228,51 @@ SMESH_DeviceActor //myIsShrinkable = theGrid->GetNumberOfCells() > 10; myIsShrinkable = true; - myExtractUnstructuredGrid->SetInput(theGrid); + myExtractUnstructuredGrid->SetInputData(theGrid); - myMergeFilter->SetGeometry(myExtractUnstructuredGrid->GetOutput()); + myMergeFilter->SetGeometryConnection(myExtractUnstructuredGrid->GetOutputPort()); + + //Pass diameters of the balls + if(myMapper->GetBallEnabled()) { + myMergeFilter->SetScalarsConnection(myExtractUnstructuredGrid->GetOutputPort()); + } - myExtractGeometry->SetInput(myMergeFilter->GetOutput()); + myExtractGeometry->SetInputConnection(myMergeFilter->GetOutputPort()); int anId = 0; SetImplicitFunctionUsed(myIsImplicitFunctionUsed); - myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() ); + myPassFilter[ anId + 1]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() ); anId++; // 1 - myTransformFilter->SetInput( myPassFilter[ anId ]->GetOutput() ); + myTransformFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() ); anId++; // 2 - myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() ); - myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() ); + myPassFilter[ anId ]->SetInputConnection( myTransformFilter->GetOutputPort() ); + myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() ); anId++; // 3 - myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() ); + myGeomFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() ); anId++; // 4 - myPassFilter[ anId ]->SetInput( myGeomFilter->GetOutput() ); - myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() ); + myPassFilter[ anId ]->SetInputConnection( myGeomFilter->GetOutputPort() ); + myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() ); anId++; // 5 - myMapper->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() ); + myMapper->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() ); + if( myPlaneCollection->GetNumberOfItems() ) + myMapper->SetClippingPlanes( myPlaneCollection ); vtkLODActor::SetMapper( myMapper ); Modified(); } } +void +SMESH_DeviceActor +::SetPlaneCollection( vtkPlaneCollection* theCollection ) +{ + myPlaneCollection = theCollection; +} VTKViewer_ExtractUnstructuredGrid* SMESH_DeviceActor @@ -299,34 +311,46 @@ SMESH_DeviceActor vtkIdType aNbCells = aGrid->GetNumberOfCells(); aScalars->SetNumberOfComponents(1); aScalars->SetNumberOfTuples(aNbCells); + double* range;// = aScalars->GetRange(); myVisualObj->UpdateFunctor(theFunctor); using namespace SMESH::Controls; - if(NumericalFunctor* aNumericalFunctor = dynamic_cast(theFunctor.get())){ + 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); } - }else if(Predicate* aPredicate = dynamic_cast(theFunctor.get())){ + range = aScalars->GetRange(); + if ( range[1] - range[0] < ( qMax(qAbs(range[0]),qAbs(range[1])) + 1e-100 ) * 1e-6 ) + { + range[1] = range[0]; + for(vtkIdType i = 0; i < aNbCells; i++) + aScalars->SetValue(i,range[0]); + } + } + 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); } + range = aScalars->GetRange(); } aDataSet->GetCellData()->SetScalars(aScalars); aScalars->Delete(); - - theLookupTable->SetRange(aScalars->GetRange()); + + theLookupTable->SetRange( range ); theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors()); theLookupTable->Build(); - myMergeFilter->SetScalars(aDataSet); + myMergeFilter->SetScalarsData(aDataSet); aDataSet->Delete(); } GetMapper()->SetScalarVisibility(anIsInitialized); @@ -406,7 +430,7 @@ SMESH_DeviceActor theLookupTable->SetRange(aScalars->GetRange()); theLookupTable->Build(); - myMergeFilter->SetScalars(aDataSet); + myMergeFilter->SetScalarsData(aDataSet); aDataSet->Delete(); } else if (MultiConnection2D* aMultiConnection2D = dynamic_cast(theFunctor.get())){ @@ -466,7 +490,7 @@ SMESH_DeviceActor theLookupTable->SetRange(aScalars->GetRange()); theLookupTable->Build(); - myMergeFilter->SetScalars(aDataSet); + myMergeFilter->SetScalarsData(aDataSet); aDataSet->Delete(); } } @@ -604,10 +628,10 @@ SMESH_DeviceActor ::SetShrink() { if ( !myIsShrinkable ) return; - if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() ) + if ( vtkAlgorithmOutput* aDataSet = myPassFilter[ 0 ]->GetOutputPort() ) { - myShrinkFilter->SetInput( aDataSet ); - myPassFilter[ 1 ]->SetInput( myShrinkFilter->GetOutput() ); + myShrinkFilter->SetInputConnection( aDataSet ); + myPassFilter[ 1 ]->SetInputConnection( myShrinkFilter->GetOutputPort() ); myIsShrunk = true; } } @@ -617,9 +641,9 @@ SMESH_DeviceActor ::UnShrink() { if ( !myIsShrunk ) return; - if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() ) + if ( vtkAlgorithmOutput* aDataSet = myPassFilter[ 0 ]->GetOutputPort() ) { - myPassFilter[ 1 ]->SetInput( aDataSet ); + myPassFilter[ 1 ]->SetInputConnection( aDataSet ); myPassFilter[ 1 ]->Modified(); myIsShrunk = false; Modified(); @@ -631,37 +655,37 @@ void SMESH_DeviceActor ::SetFacesOriented(bool theIsFacesOriented) { - if ( vtkDataSet* aDataSet = myTransformFilter->GetOutput() ) + if ( vtkAlgorithmOutput* aDataSet = myTransformFilter->GetOutputPort() ) { myIsFacesOriented = theIsFacesOriented; if( theIsFacesOriented ) - myFaceOrientationFilter->SetInput( aDataSet ); + myFaceOrientationFilter->SetInputConnection( aDataSet ); UpdateFaceOrientation(); } } void SMESH_DeviceActor -::SetFacesOrientationColor(vtkFloatingPointType theColor[3]) +::SetFacesOrientationColor(double r,double g,double b) { - myFaceOrientation->GetProperty()->SetColor( theColor ); + myFaceOrientation->GetProperty()->SetColor( r, g, b ); } void SMESH_DeviceActor -::GetFacesOrientationColor(vtkFloatingPointType theColor[3]) +::GetFacesOrientationColor(double& r,double& g,double& b) { - myFaceOrientation->GetProperty()->GetColor( theColor ); + myFaceOrientation->GetProperty()->GetColor( r, g, b ); } void SMESH_DeviceActor -::SetFacesOrientationScale(vtkFloatingPointType theScale) +::SetFacesOrientationScale(double theScale) { myFaceOrientationFilter->SetOrientationScale( theScale ); } -vtkFloatingPointType +double SMESH_DeviceActor ::GetFacesOrientationScale() { @@ -784,13 +808,13 @@ SMESH_DeviceActor return aRetID; } -vtkFloatingPointType* +double* SMESH_DeviceActor ::GetNodeCoord(int theObjID) { vtkDataSet* aDataSet = myMergeFilter->GetOutput(); vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID); - vtkFloatingPointType* aCoord = (anID >=0) ? aDataSet->GetPoint(anID) : NULL; + double* aCoord = (anID >=0) ? aDataSet->GetPoint(anID) : NULL; if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<