From: ouv Date: Fri, 17 Dec 2010 15:31:41 +0000 (+0000) Subject: Fix of bug TC6.2.0: SIGSEGV at presentation creation for Iso Surfaces, Deformed Shape... X-Git-Tag: RELIQUAT_6x_15112010~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5157162c24bb6f03226a64e412cceb966216170e;p=modules%2Fvisu.git Fix of bug TC6.2.0: SIGSEGV at presentation creation for Iso Surfaces, Deformed Shape, Stream Lines, Deformed Shape and Scalar Map --- diff --git a/src/PIPELINE/Makefile.am b/src/PIPELINE/Makefile.am index ee6aa5b6..6aec80a1 100644 --- a/src/PIPELINE/Makefile.am +++ b/src/PIPELINE/Makefile.am @@ -71,7 +71,8 @@ salomeinclude_HEADERS= \ VISU_ElnoAssembleFilter.hxx \ VISU_DeformationPL.hxx \ VISU_OptionalDeformationPL.hxx \ - VISU_XYPlotActor.hxx + VISU_XYPlotActor.hxx \ + VISU_CellDataToPointData.hxx dist_libVisuPipeLine_la_SOURCES= \ VISU_MapperHolder.cxx \ @@ -118,7 +119,8 @@ dist_libVisuPipeLine_la_SOURCES= \ VISU_ElnoAssembleFilter.cxx \ VISU_DeformationPL.cxx \ VISU_OptionalDeformationPL.cxx\ - VISU_XYPlotActor.cxx + VISU_XYPlotActor.cxx \ + VISU_CellDataToPointData.cxx libVisuPipeLine_la_CPPFLAGS= \ $(VTK_INCLUDES) \ diff --git a/src/PIPELINE/VISU_CellDataToPointData.cxx b/src/PIPELINE/VISU_CellDataToPointData.cxx new file mode 100644 index 00000000..46e22d31 --- /dev/null +++ b/src/PIPELINE/VISU_CellDataToPointData.cxx @@ -0,0 +1,137 @@ +/*========================================================================= + + Program: Visualization Toolkit + Module: $RCSfile$ + + Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen + All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + + Note from SALOME: + This file is a part of VTK library + It has been renamed and modified for SALOME project + +=========================================================================*/ + +#include "VISU_CellDataToPointData.hxx" + +#include +#include +#include +#include +#include +#include +#include + +vtkCxxRevisionMacro(VISU_CellDataToPointData, "$Revision$"); +vtkStandardNewMacro(VISU_CellDataToPointData); + +//---------------------------------------------------------------------------- +// Instantiate object so that cell data is not passed to output. +VISU_CellDataToPointData::VISU_CellDataToPointData() +{ + this->PassCellData = 0; +} + +#define VTK_MAX_CELLS_PER_POINT 4096 + +//---------------------------------------------------------------------------- +int VISU_CellDataToPointData::RequestData( + vtkInformation*, + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) +{ + vtkInformation* info = outputVector->GetInformationObject(0); + vtkDataSet *output = vtkDataSet::SafeDownCast( + info->Get(vtkDataObject::DATA_OBJECT())); + + vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); + vtkDataSet *input = vtkDataSet::SafeDownCast( + inInfo->Get(vtkDataObject::DATA_OBJECT())); + + vtkIdType cellId, ptId; + vtkIdType numCells, numPts; + vtkCellData *inPD=input->GetCellData(); + vtkPointData *outPD=output->GetPointData(); + vtkIdList *cellIds; + double weight; + double *weights; + + vtkDebugMacro(<<"Mapping cell data to point data"); + + // First, copy the input to the output as a starting point + output->CopyStructure( input ); + + cellIds = vtkIdList::New(); + cellIds->Allocate(VTK_MAX_CELLS_PER_POINT); + + if ( (numPts=input->GetNumberOfPoints()) < 1 ) + { + vtkDebugMacro(<<"No input point data!"); + cellIds->Delete(); + return 1; + } + weights = new double[VTK_MAX_CELLS_PER_POINT]; + + // Pass the point data first. The fields and attributes + // which also exist in the cell data of the input will + // be over-written during CopyAllocate + output->GetPointData()->CopyGlobalIdsOff(); + output->GetPointData()->PassData(input->GetPointData()); + output->GetPointData()->CopyFieldOff("vtkGhostLevels"); + + // notice that inPD and outPD are vtkCellData and vtkPointData; respectively. + // It's weird, but it works. + outPD->InterpolateAllocate(inPD,numPts); + + int abort=0; + vtkIdType progressInterval=numPts/20 + 1; + for (ptId=0; ptId < numPts && !abort; ptId++) + { + if ( !(ptId % progressInterval) ) + { + this->UpdateProgress(static_cast(ptId)/numPts); + abort = GetAbortExecute(); + } + + input->GetPointCells(ptId, cellIds); + numCells = cellIds->GetNumberOfIds(); + if ( numCells > 0 ) + { + weight = 1.0 / numCells; + for (cellId=0; cellId < numCells; cellId++) + { + weights[cellId] = weight; + } + outPD->InterpolatePoint(inPD, ptId, cellIds, weights); + } + else + { + outPD->NullPoint(ptId); + } + } + + if ( !this->PassCellData ) + { + output->GetCellData()->CopyAllOff(); + output->GetCellData()->CopyFieldOn("vtkGhostLevels"); + } + output->GetCellData()->PassData(input->GetCellData()); + + cellIds->Delete(); + delete [] weights; + + return 1; +} + +//---------------------------------------------------------------------------- +void VISU_CellDataToPointData::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os,indent); + + os << indent << "Pass Cell Data: " << (this->PassCellData ? "On\n" : "Off\n"); +} diff --git a/src/PIPELINE/VISU_CellDataToPointData.hxx b/src/PIPELINE/VISU_CellDataToPointData.hxx new file mode 100644 index 00000000..ed4fb38c --- /dev/null +++ b/src/PIPELINE/VISU_CellDataToPointData.hxx @@ -0,0 +1,74 @@ +/*========================================================================= + + Program: Visualization Toolkit + Module: $RCSfile$ + + Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen + All rights reserved. + See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notice for more information. + +=========================================================================*/ +// .NAME VISU_CellDataToPointData - map cell data to point data +// .SECTION Description +// VISU_CellDataToPointData is a filter that transforms cell data (i.e., data +// specified per cell) into point data (i.e., data specified at cell +// points). The method of transformation is based on averaging the data +// values of all cells using a particular point. Optionally, the input cell +// data can be passed through to the output as well. + +// .SECTION Caveats +// This filter is an abstract filter, that is, the output is an abstract type +// (i.e., vtkDataSet). Use the convenience methods (e.g., +// GetPolyDataOutput(), GetStructuredPointsOutput(), etc.) to get the type +// of output you want. + +// .SECTION See Also +// vtkPointData vtkCellData vtkPointDataToCellData + +// note from SALOME: +// This file is a part of VTK library +// It has been renamed and modified for SALOME project + +#ifndef __VISU_CellDataToPointData_h +#define __VISU_CellDataToPointData_h + +#include + +class vtkDataSet; + +class VTK_GRAPHICS_EXPORT VISU_CellDataToPointData : public vtkDataSetAlgorithm +{ +public: + static VISU_CellDataToPointData *New(); + vtkTypeRevisionMacro(VISU_CellDataToPointData,vtkDataSetAlgorithm); + void PrintSelf(ostream& os, vtkIndent indent); + + // Description: + // Control whether the input cell data is to be passed to the output. If + // on, then the input cell data is passed through to the output; otherwise, + // only generated point data is placed into the output. + vtkSetMacro(PassCellData,int); + vtkGetMacro(PassCellData,int); + vtkBooleanMacro(PassCellData,int); + +protected: + VISU_CellDataToPointData(); + ~VISU_CellDataToPointData() {}; + + virtual int RequestData(vtkInformation* request, + vtkInformationVector** inputVector, + vtkInformationVector* outputVector); + + int PassCellData; +private: + VISU_CellDataToPointData(const VISU_CellDataToPointData&); // Not implemented. + void operator=(const VISU_CellDataToPointData&); // Not implemented. +}; + +#endif + + diff --git a/src/PIPELINE/VISU_DeformationPL.cxx b/src/PIPELINE/VISU_DeformationPL.cxx index 0fbaa6c0..f55e795f 100755 --- a/src/PIPELINE/VISU_DeformationPL.cxx +++ b/src/PIPELINE/VISU_DeformationPL.cxx @@ -31,7 +31,6 @@ #include #include #include -#include #include #ifdef _DEBUG_ static int MYDEBUG = 0; @@ -53,7 +52,7 @@ VISU_DeformationPL::VISU_DeformationPL(): myVectorMergeFilter->SetMergingInputs(true); myInputPassFilter = vtkPassThroughFilter::New(); myOutputPassFiler = vtkPassThroughFilter::New(); - myCellDataToPointData = vtkCellDataToPointData::New(); + myCellDataToPointData = VISU_CellDataToPointData::New(); myCellDataToPointData->PassCellDataOn(); myInputPassFilter->SetInput(vtkUnstructuredGrid::New()); diff --git a/src/PIPELINE/VISU_DeformationPL.hxx b/src/PIPELINE/VISU_DeformationPL.hxx index e8d66576..69c75c90 100755 --- a/src/PIPELINE/VISU_DeformationPL.hxx +++ b/src/PIPELINE/VISU_DeformationPL.hxx @@ -32,7 +32,7 @@ class vtkDataSet; class VISU_MergeFilter; class vtkPassThroughFilter; class vtkWarpVector; -class vtkCellDataToPointData; +class VISU_CellDataToPointData; class VISU_PIPELINE_EXPORT VISU_DeformationPL { @@ -74,7 +74,7 @@ protected: vtkSmartPointer myVectorMergeFilter; vtkPassThroughFilter *myInputPassFilter; vtkPassThroughFilter *myOutputPassFiler; - vtkCellDataToPointData *myCellDataToPointData; + VISU_CellDataToPointData *myCellDataToPointData; private: vtkFloatingPointType myScaleFactor; diff --git a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx index 4f2891c9..f533608d 100644 --- a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx +++ b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx @@ -39,7 +39,6 @@ #include #include #include -#include #include #include @@ -74,7 +73,7 @@ VISU_DeformedShapeAndScalarMapPL myScalarsFieldTransform = VISU_FieldTransform::New(); - myCellDataToPointData = vtkCellDataToPointData::New(); + myCellDataToPointData = VISU_CellDataToPointData::New(); myScalarsElnoDisassembleFilter = VISU_ElnoDisassembleFilter::New(); vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New(); diff --git a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.hxx b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.hxx index a59794db..0817c6a9 100644 --- a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.hxx +++ b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.hxx @@ -31,7 +31,7 @@ class VISU_MergeFilter; class vtkWarpVector; class vtkUnstructuredGrid; -class vtkCellDataToPointData; +class VISU_CellDataToPointData; class vtkPointDataToCellData; class VISU_ElnoDisassembleFilter; class SALOME_ExtractGeometry; @@ -168,7 +168,7 @@ private: vtkWarpVector *myWarpVector; VISU_MergeFilter *myScalarsMergeFilter; vtkSmartPointer myScalars; - vtkCellDataToPointData* myCellDataToPointData; + VISU_CellDataToPointData* myCellDataToPointData; VISU_FieldTransform* myScalarsFieldTransform; VISU_Extractor* myScalarsExtractor; VISU_ElnoDisassembleFilter* myScalarsElnoDisassembleFilter; diff --git a/src/PIPELINE/VISU_DeformedShapePL.cxx b/src/PIPELINE/VISU_DeformedShapePL.cxx index 3312723f..f33dc132 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.cxx +++ b/src/PIPELINE/VISU_DeformedShapePL.cxx @@ -46,7 +46,7 @@ VISU_DeformedShapePL SetIsFeatureEdgesAllowed(true); myWarpVector = vtkWarpVector::New(); - myCellDataToPointData = vtkCellDataToPointData::New(); + myCellDataToPointData = VISU_CellDataToPointData::New(); } diff --git a/src/PIPELINE/VISU_DeformedShapePL.hxx b/src/PIPELINE/VISU_DeformedShapePL.hxx index ccbeb582..1176b554 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.hxx +++ b/src/PIPELINE/VISU_DeformedShapePL.hxx @@ -31,7 +31,7 @@ #include "VISUPipeline.hxx" #include "VISU_ScalarMapPL.hxx" -class vtkCellDataToPointData; +class VISU_CellDataToPointData; class SALOME_Transform; class vtkWarpVector; @@ -102,7 +102,7 @@ protected: vtkFloatingPointType myScaleFactor; vtkFloatingPointType myMapScaleFactor; vtkWarpVector *myWarpVector; - vtkCellDataToPointData* myCellDataToPointData; + VISU_CellDataToPointData* myCellDataToPointData; private: VISU_DeformedShapePL(const VISU_DeformedShapePL&); // Not implemented. diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.cxx b/src/PIPELINE/VISU_IsoSurfacesPL.cxx index ae875a05..99ee33f0 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.cxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.cxx @@ -51,7 +51,7 @@ VISU_IsoSurfacesPL myContourFilter = vtkContourFilter::New(); - myCellDataToPointData = vtkCellDataToPointData::New(); + myCellDataToPointData = VISU_CellDataToPointData::New(); } diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.hxx b/src/PIPELINE/VISU_IsoSurfacesPL.hxx index 81651dd0..195a985a 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.hxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.hxx @@ -32,7 +32,7 @@ #include "VISU_ScalarMapPL.hxx" class vtkContourFilter; -class vtkCellDataToPointData; +class VISU_CellDataToPointData; //---------------------------------------------------------------------------- @@ -120,7 +120,7 @@ protected: int myNbParts; vtkFloatingPointType myRange[2]; bool myIsRangeFixed; - vtkCellDataToPointData* myCellDataToPointData; + VISU_CellDataToPointData* myCellDataToPointData; vtkContourFilter *myContourFilter; private: diff --git a/src/PIPELINE/VISU_OptionalDeformationPL.cxx b/src/PIPELINE/VISU_OptionalDeformationPL.cxx index ae8527c3..58ddb5e2 100755 --- a/src/PIPELINE/VISU_OptionalDeformationPL.cxx +++ b/src/PIPELINE/VISU_OptionalDeformationPL.cxx @@ -29,7 +29,6 @@ #include #include #include -#include #ifdef _DEBUG_ static int MYDEBUG = 0; #else diff --git a/src/PIPELINE/VISU_PipeLineUtils.hxx b/src/PIPELINE/VISU_PipeLineUtils.hxx index c3aef9e3..ca2e2d54 100644 --- a/src/PIPELINE/VISU_PipeLineUtils.hxx +++ b/src/PIPELINE/VISU_PipeLineUtils.hxx @@ -30,13 +30,13 @@ #include "VISUPipeline.hxx" #include "VISU_ConvertorUtils.hxx" +#include "VISU_CellDataToPointData.hxx" #include #include #include #include -#include #include #include #include @@ -76,7 +76,7 @@ namespace VISU template void CellDataToPoint(TOutputFilter* theOutputFilter, - vtkCellDataToPointData *theCellDataToPointData, + VISU_CellDataToPointData *theCellDataToPointData, vtkDataSet* theDataSet) { diff --git a/src/PIPELINE/VISU_Plot3DPL.cxx b/src/PIPELINE/VISU_Plot3DPL.cxx index 08846958..dbb39bf0 100644 --- a/src/PIPELINE/VISU_Plot3DPL.cxx +++ b/src/PIPELINE/VISU_Plot3DPL.cxx @@ -33,7 +33,6 @@ #include #include -#include #include #include #include @@ -47,7 +46,7 @@ vtkStandardNewMacro(VISU_Plot3DPL); //---------------------------------------------------------------------------- VISU_Plot3DPL ::VISU_Plot3DPL(): - myCellDataToPointData(vtkCellDataToPointData::New()), + myCellDataToPointData(VISU_CellDataToPointData::New()), myAppendPolyData(vtkAppendPolyData::New()), myGeometryFilter(vtkGeometryFilter::New()), myContourFilter(vtkContourFilter::New()), diff --git a/src/PIPELINE/VISU_Plot3DPL.hxx b/src/PIPELINE/VISU_Plot3DPL.hxx index ab3d2594..cb98e963 100644 --- a/src/PIPELINE/VISU_Plot3DPL.hxx +++ b/src/PIPELINE/VISU_Plot3DPL.hxx @@ -35,7 +35,7 @@ class vtkWarpScalar; class vtkContourFilter; class vtkGeometryFilter; -class vtkCellDataToPointData; +class VISU_CellDataToPointData; //---------------------------------------------------------------------------- @@ -150,7 +150,7 @@ protected: vtkFloatingPointType myPosition, myScaleFactor, myMapScaleFactor; VISU_CutPlanesPL::PlaneOrientation myOrientation; - vtkSmartPointer myCellDataToPointData; + vtkSmartPointer myCellDataToPointData; vtkSmartPointer myAppendPolyData; vtkSmartPointer myGeometryFilter; vtkSmartPointer myContourFilter;