#include "VTKViewer_TransformFilter.h"
#include "VTKViewer_Transform.h"
+#include "SALOME_ExtractGeometry.h"
+
+#include <vtkPlane.h>
+#include <vtkImplicitBoolean.h>
+#include <vtkImplicitFunction.h>
+#include <vtkImplicitFunctionCollection.h>
+
#include <vtkWarpVector.h>
#include <vtkUnstructuredGrid.h>
#include <vtkPointDataToCellData.h>
* \li myScalars is vtk shared pointer to vtkUnstructuredGrid - scalars data
*/
VISU_ScalarMapOnDeformedShapePL
-::VISU_ScalarMapOnDeformedShapePL()
+::VISU_ScalarMapOnDeformedShapePL():
+ myScalarsExtractGeometry(SALOME_ExtractGeometry::New())
{
+ myCellDataToPointData = VISU_CellDataToPointData::New();
+
myWarpVector = vtkWarpVector::New();
- myScalarsMergeFilter = VISU_MergeFilter::New();
- myScalarsMergeFilter->SetMergingInputs(true);
+ myScalarsExtractGeometry->SetInput(myMergeFilter->GetOutput());
+ vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New();
+ myScalarsExtractGeometry->SetImplicitFunction(anImplicitBoolean);
+ anImplicitBoolean->SetOperationTypeToIntersection();
+ anImplicitBoolean->Delete();
myScalarsExtractor = VISU_Extractor::New();
myScalarsFieldTransform = VISU_FieldTransform::New();
- myCellDataToPointData = VISU_CellDataToPointData::New();
-
- myScalars = myMergeFilter->GetOutput();
+ myScalarsMergeFilter = VISU_MergeFilter::New();
+ myScalarsMergeFilter->SetMergingInputs(true);
}
/*!
myScalarsMergeFilter->Delete();
+ myScalarsExtractGeometry->Delete();
+
myScalarsExtractor->Delete();
myScalarsFieldTransform->Delete();
myCellDataToPointData->Delete();
}
+/*!
+ * Copy information about pipline.
+ * Copy scale and scalars.
+ */
+void
+VISU_ScalarMapOnDeformedShapePL
+::ShallowCopy(VISU_PipeLine *thePipeLine)
+{
+ VISU_ScalarMapOnDeformedShapePL *aPipeLine = dynamic_cast<VISU_ScalarMapOnDeformedShapePL*>(thePipeLine);
+ if(aPipeLine){
+ SetScale(aPipeLine->GetScale());
+ SetScalars(aPipeLine->GetScalars());
+ }
+ Superclass::ShallowCopy(thePipeLine);
+}
+
+//=======================================================================
+void
+VISU_ScalarMapOnDeformedShapePL
+::SetImplicitFunction(vtkImplicitFunction *theFunction)
+{
+ Superclass::SetImplicitFunction(theFunction);
+
+ myScalarsExtractGeometry->SetImplicitFunction(theFunction);
+}
+
+
+void
+VISU_ScalarMapOnDeformedShapePL
+::RemoveAllClippingPlanes()
+{
+ Superclass::RemoveAllClippingPlanes();
+
+ if(vtkImplicitBoolean* aBoolean = myScalarsExtractGeometry->GetImplicitBoolean()){
+ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+ aFunction->RemoveAllItems();
+ aBoolean->Modified(); // VTK bug
+ }
+}
+
+
+bool
+VISU_ScalarMapOnDeformedShapePL
+::AddClippingPlane(vtkPlane* thePlane)
+{
+ Superclass::AddClippingPlane(thePlane);
+
+ if (thePlane) {
+ if (vtkImplicitBoolean* aBoolean = myScalarsExtractGeometry->GetImplicitBoolean()) {
+ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+ aFunction->AddItem(thePlane);
+
+ // Check, that at least one cell present after clipping.
+ // This check was introduced because of bug IPAL8849.
+ if (GetScalarsClippedInput()->GetNumberOfCells() < 1)
+ return false;
+ }
+ }
+ return true;
+}
+
+
+VISU_PipeLine::TInput*
+VISU_ScalarMapOnDeformedShapePL
+::GetScalarsClippedInput()
+{
+ if(myScalarsExtractGeometry->GetInput())
+ myScalarsExtractGeometry->Update();
+ return myScalarsExtractGeometry->GetOutput();
+}
+
//=======================================================================
void
VISU_ScalarMapOnDeformedShapePL
SetScale(VISU_DeformedShapePL::GetDefaultScale(this));
}
-/*!
- * Copy information about pipline.
- * Copy scale and scalars.
- */
-void
-VISU_ScalarMapOnDeformedShapePL
-::ShallowCopy(VISU_PipeLine *thePipeLine)
-{
- VISU_ScalarMapOnDeformedShapePL *aPipeLine = dynamic_cast<VISU_ScalarMapOnDeformedShapePL*>(thePipeLine);
- if(aPipeLine){
- SetScale(aPipeLine->GetScale());
- SetScalars(aPipeLine->GetScalars());
- }
- Superclass::ShallowCopy(thePipeLine);
-}
-
/*!
* Set scalars.
* Sets vtkDataSet with scalars values to VISU_Extractor filter for scalars extraction.
*/
void
VISU_ScalarMapOnDeformedShapePL
-::SetScalars(vtkDataSet *theScalars)
+::SetScalars(TInput *theScalars)
{
- myScalars = theScalars;
+ myScalarsExtractGeometry->SetInput(theScalars);
}
/*!
* Get pointer to input scalars.
*/
-vtkPointSet*
+VISU_PipeLine::TInput*
VISU_ScalarMapOnDeformedShapePL
::GetScalars()
{
- return myScalars.GetPointer();
+ vtkDataSet* aDataSet = myScalarsExtractGeometry->GetInput();
+ return dynamic_cast<VISU_PipeLine::TInput*>(aDataSet);
}
+
/*!
* Sets scale for deformed shape
*/