X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPIPELINE%2FVISU_GaussPointsPL.cxx;h=06c33ffc3db9f0311fe08501a166dd753e3ee9d8;hb=439b08cf2772b48bb44ef35eb23279505cbf2278;hp=8d1d0dff678a95319de15b0e816b5d19e30b9478;hpb=953451df51750a1d9910c0325f01d5ca7b6e0330;p=modules%2Fvisu.git diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index 8d1d0dff..06c33ffc 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -1,6 +1,6 @@ -// VISU OBJECT : interactive object for VISU entities implementation +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// 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 @@ -17,22 +17,24 @@ // 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 -// -// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + +// VISU OBJECT : interactive object for VISU entities implementation // File: VISU_GaussPoints.cxx // Author: Alexey PETROV // Module : VISU - - +// #include "VISU_GaussPointsPL.hxx" +#include "VISU_PointSpriteMapperHolder.hxx" +#include "VISU_OpenGLPointSpriteMapper.hxx" #include "VISU_DeformedShapePL.hxx" +#include "VISU_FieldTransform.hxx" +#include "VISU_LookupTable.hxx" + #include "VISU_PipeLineUtils.hxx" -#include "SALOME_ExtractGeometry.h" -#include "VISU_DeformedShapePL.hxx" -#include "VISU_OpenGLPointSpriteMapper.hxx" -#include "VTKViewer_PassThroughFilter.h" +#include "VISU_AppendFilter.hxx" +#include "VISU_GaussMergeFilter.hxx" #include #include @@ -43,6 +45,7 @@ #include #include #include +#include //---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_GaussPointsPL); @@ -50,38 +53,36 @@ vtkStandardNewMacro(VISU_GaussPointsPL); //---------------------------------------------------------------------------- VISU_GaussPointsPL ::VISU_GaussPointsPL(): - myIsDeformed(false), myScaleFactor(0.0), - myResolution( 8 ), - myMagnificationIncrement(2) + myMagnificationIncrement(2), + myAppendFilter(VISU_AppendFilter::New()), + myMergeFilter(VISU_GaussMergeFilter::New()) { - myExtractGeometry->SetExtractInside(0); - - myPSMapper = VISU_OpenGLPointSpriteMapper::New(); - myPSMapper->SetColorModeToMapScalars(); - myPSMapper->ScalarVisibilityOn(); - - myGeomFilter = vtkGeometryFilter::New(); + SetIsShrinkable(false); + SetIsFeatureEdgesAllowed(false); myWarpVector = vtkWarpVector::New(); - myCellDataToPointData = vtkCellDataToPointData::New(); - myCellDataToPointData->SetPassCellData(true); myGlyph = vtkGlyph3D::New(); myGlyph->SetScaleModeToScaleByScalar(); myGlyph->SetColorModeToColorByScalar(); myGlyph->ClampingOn(); - myExtractor->SetInput( myExtractGeometry->GetOutput() ); - myFieldTransform->SetInput( myExtractor->GetOutput() ); - - myCellDataToPointData->SetInput( myFieldTransform->GetUnstructuredGridOutput() ); - mySphereSource = vtkSphereSource::New(); + mySphereSource->SetThetaResolution( 8 ); + mySphereSource->SetPhiResolution( 8 ); myGlyph->SetSource( mySphereSource->GetOutput() ); - for(int i = 0; i < 2; i++) - myPassFilter.push_back(VTKViewer_PassThroughFilter::New()); + for(int i = 0; i < 3; i++) + myPassFilter.push_back(vtkPassThroughFilter::New()); + + myPrimitiveType = VISU_OpenGLPointSpriteMapper::PointSprite; + + myAppendFilter->SetMergingInputs(true); + myAppendFilter->Delete(); + + myMergeFilter->SetMergingInputs(true); + myMergeFilter->Delete(); } @@ -89,54 +90,113 @@ VISU_GaussPointsPL VISU_GaussPointsPL ::~VISU_GaussPointsPL() { - if (this->myPSMapper) - { - this->myPSMapper->Delete(); - this->myPSMapper = NULL; - } - if (this->myGeomFilter) - { - this->myGeomFilter->Delete(); - this->myGeomFilter = NULL; - } - myWarpVector->Delete(); - myCellDataToPointData->Delete(); - myGlyph->Delete(); mySphereSource->Delete(); - for(int i = 0; i < 2; i++) + for(int i = 0; i < 3; i++) myPassFilter[i]->Delete(); } +//---------------------------------------------------------------------------- +unsigned long int +VISU_GaussPointsPL +::GetMTime() +{ + unsigned long int aTime = Superclass::GetMTime(); + + aTime = std::max(aTime, myWarpVector->GetMTime()); + aTime = std::max(aTime, myGlyph->GetMTime()); + aTime = std::max(aTime, mySphereSource->GetMTime()); + aTime = std::max(aTime, myAppendFilter->GetMTime()); + aTime = std::max(aTime, myMergeFilter->GetMTime()); + + for(int i = 0; i < 3; i++) + aTime = std::max(aTime, myPassFilter[i]->GetMTime()); + + return aTime; +} + + +//---------------------------------------------------------------------------- +void +VISU_GaussPointsPL +::OnCreateMapperHolder() +{ + myPointSpriteMapperHolder = VISU_PointSpriteMapperHolder::New(); + myPointSpriteMapperHolder->Delete(); + + SetMapperHolder(myPointSpriteMapperHolder.GetPointer()); +} + + //---------------------------------------------------------------------------- void -CopyGlyph( vtkGlyph3D* source, vtkGlyph3D* dest ) +VISU_GaussPointsPL +::SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theIDMapper) { - dest->SetRange( source->GetRange() ); - dest->SetScaling( source->GetScaling() ); - dest->SetClamping( source->GetClamping() ); - dest->SetScaleMode( source->GetScaleMode() ); - dest->SetColorMode( source->GetColorMode() ); - dest->SetScaleFactor( source->GetScaleFactor() ); + GetPointSpriteMapperHolder()->SetGaussPtsIDMapper(theIDMapper); +} + + +//---------------------------------------------------------------------------- +const VISU::PGaussPtsIDMapper& +VISU_GaussPointsPL +::GetGaussPtsIDMapper() +{ + return GetPointSpriteMapperHolder()->GetGaussPtsIDMapper(); +} + + +//---------------------------------------------------------------------------- +VISU_PointSpriteMapperHolder* +VISU_GaussPointsPL +::GetPointSpriteMapperHolder() +{ + GetMapperHolder(); + + return myPointSpriteMapperHolder.GetPointer(); +} + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_GaussPointsPL +::GetParentMesh() +{ + VISU::TNamedIDMapper* aNamedIDMapper = GetGaussPtsIDMapper()->GetParent(); + return aNamedIDMapper->GetOutput(); +} + +//---------------------------------------------------------------------------- +void +CopyGlyph( vtkGlyph3D* theSource, vtkGlyph3D* theDestination ) +{ + vtkFloatingPointType* aSourceRange = theSource->GetRange(); + vtkFloatingPointType* aDestinationRange = theDestination->GetRange(); + if(!VISU::CheckIsSameRange(aDestinationRange, aSourceRange)) + theDestination->SetRange( aSourceRange ); + + theDestination->SetScaling( theSource->GetScaling() ); + theDestination->SetClamping( theSource->GetClamping() ); + theDestination->SetScaleMode( theSource->GetScaleMode() ); + theDestination->SetColorMode( theSource->GetColorMode() ); + theDestination->SetScaleFactor( theSource->GetScaleFactor() ); } //---------------------------------------------------------------------------- void VISU_GaussPointsPL -::ShallowCopy(VISU_PipeLine *thePipeLine) +::DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput) { - if(VISU_GaussPointsPL *aPipeLine = dynamic_cast(thePipeLine)){ - // To restore mapper input from pipeline - vtkPolyData* aDatsSet = myPSMapper->GetInput(); - myPSMapper->ShallowCopy(aPipeLine->GetPSMapper()); - myPSMapper->SetInput(aDatsSet); + Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); + VISU_MergedPL::DoShallowCopy(thePipeLine, theIsCopyInput); + if(VISU_GaussPointsPL *aPipeLine = dynamic_cast(thePipeLine)){ SetPrimitiveType(aPipeLine->GetPrimitiveType()); SetBicolor(aPipeLine->GetBicolor()); SetClamp(aPipeLine->GetClamp()); @@ -151,43 +211,33 @@ VISU_GaussPointsPL SetIsDeformed( aPipeLine->GetIsDeformed() ); SetScale( aPipeLine->GetScale() ); - mySphereSource->SetRadius( aPipeLine->mySphereSource->GetRadius() ); + vtkFloatingPointType aRadius = aPipeLine->mySphereSource->GetRadius(); + if(!VISU::CheckIsSameValue(mySphereSource->GetRadius(), aRadius)) + mySphereSource->SetRadius( aRadius ); + CopyGlyph( aPipeLine->myGlyph, this->myGlyph ); } - Superclass::ShallowCopy(thePipeLine); } //---------------------------------------------------------------------------- -VISU_PipeLine::TMapper* -VISU_GaussPointsPL -::GetMapper() -{ - return GetPSMapper(); -} - VISU_OpenGLPointSpriteMapper* VISU_GaussPointsPL -::GetPSMapper() +::GetPointSpriteMapper() { - if(GetInput()){ - if(!myPSMapper->GetInput()){ - GetInput2()->Update(); - Build(); - Init(); - } - myPSMapper->Update(); - } - return myPSMapper; + return GetPointSpriteMapperHolder()->GetPointSpriteMapper(); } -vtkDataSet* + +//---------------------------------------------------------------------------- +vtkPolyData* VISU_GaussPointsPL ::GetPickableDataSet() { - return myGeomFilter->GetOutput(); + return myPassFilter[1]->GetPolyDataOutput(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL @@ -195,173 +245,184 @@ VISU_GaussPointsPL { Superclass::Init(); + //SetExtractInside(false); + vtkDataSet* aDataSet = GetParentMesh(); - float aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet ); + vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet ); - float* aScalarRange = GetScalarRange(); + vtkFloatingPointType* aScalarRange = GetScalarRange(); static double EPS = 1.0 / VTK_LARGE_FLOAT; if(fabs(aScalarRange[1]) > EPS) SetScale( aScaleFactor / aScalarRange[1] ); else SetScale(0.0); - - // Deformed Shape - myPassFilter[0]->SetInput(myCellDataToPointData->GetUnstructuredGridOutput()); - - myGeomFilter->SetInput( myPassFilter[0]->GetOutput() ); - - // Geometrical Sphere - myPassFilter[1]->SetInput(myGeomFilter->GetOutput()); - - myPSMapper->SetInput( myPassFilter[1]->GetPolyDataOutput() ); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::Build() { + Superclass::Build(); + + SetSourceGeometry(); + + vtkDataSet* aDataSet = GetFieldTransformFilter()->GetOutput(); + + myMergeFilter->SetGeometry(myAppendFilter->GetOutput()); + + myMergeFilter->SetScalars(aDataSet); + myMergeFilter->SetVectors(aDataSet); + + myMergeFilter->RemoveFields(); + myMergeFilter->AddField("VISU_FIELD", aDataSet); + myMergeFilter->AddField("VISU_POINTS_MAPPER", aDataSet); + myMergeFilter->AddField("VISU_INPUTS_MAPPER", aDataSet); + myMergeFilter->AddField("VISU_CELLS_MAPPER", aDataSet); + + myMergeFilter->SetGaussPtsIDMapper(GetGaussPtsIDMapper()); + + myPassFilter[0]->SetInput(InsertCustomPL()); + + myPassFilter[1]->SetInput(myPassFilter[0]->GetOutput()); + + // Geometrical Sphere + myPassFilter[2]->SetInput(myPassFilter[1]->GetOutput()); + + GetPointSpriteMapper()->SetInput( myPassFilter[2]->GetPolyDataOutput() ); + + // Update according the current state + SetIsDeformed(GetIsDeformed()); + + SetPrimitiveType(GetPrimitiveType()); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::Update() { - //cout << "VISU_GaussPointsPL::Update()" << endl; - float* aScalarRange = GetScalarRange(); - mySourceScalarRange[0] = aScalarRange[0]; - mySourceScalarRange[1] = aScalarRange[1]; - myDeltaScalarRange = aScalarRange[1] - aScalarRange[0]; + if(IsExternalGeometryUsed() || GetNumberOfGeometry() > 1 ){ + myMergeFilter->Update(); + myPassFilter[0]->SetInput(myMergeFilter->GetOutput()); + } + else{ + myPassFilter[0]->SetInput(GetFieldTransformFilter()->GetOutput()); + } SetAverageCellSize( VISU_DeformedShapePL::GetScaleFactor( GetParentMesh() ) ); - vtkMapper* aMapper = GetMapper(); - vtkDataSet* aDataSet = aMapper->GetInput(); - vtkCellData* aCellData = aDataSet->GetCellData(); - myScalarArray = aCellData->GetScalars(); + this->UpdateGlyph(); - myPSMapper->SetLookupTable( myMapperTable ); - myPSMapper->SetScalarRange( aScalarRange ); + Superclass::Update(); + +} - this->UpdateGlyph(); - VISU_ScalarMapPL::Update(); +//---------------------------------------------------------------------------- +unsigned long int +VISU_GaussPointsPL +::GetMemorySize() +{ + unsigned long int aSize = Superclass::GetMemorySize(); + + if(GetIsDeformed()) + if(vtkDataSet* aDataSet = myWarpVector->GetOutput()) + aSize += aDataSet->GetActualMemorySize() * 1024; + + if(GetPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere) + if(vtkDataSet* aDataSet = myGlyph->GetOutput()) + aSize += aDataSet->GetActualMemorySize() * 1024; + + return aSize; } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::UpdateGlyph() { - //cout << "VISU_GaussPointsPL::UpdateGlyph()" << endl; - - float* aScalarRange = GetScalarRange(); + vtkFloatingPointType* aScalarRange = GetScalarRange(); - if( myPSMapper->GetPointSpriteMode() == 0 ) // Results + if( GetPointSpriteMapper()->GetPointSpriteMode() == 0 ) // Results { - //cout << "Results" << endl; myGlyph->ClampingOn(); myGlyph->SetScaleModeToScaleByScalar(); myGlyph->SetColorModeToColorByScalar(); - float aRange = 0; - float aMinSize = GetMinSize(); - float aMaxSize = GetMaxSize(); - if( fabs( aMaxSize - aMinSize ) > 0.0001 ) - aRange = ( aScalarRange[1] - aScalarRange[0] ) / ( aMaxSize - aMinSize ); - float aMinRange = aScalarRange[0] - aMinSize * aRange; - float aMaxRange = aMinRange + aRange; - - myGlyph->SetRange( aMinRange, aMaxRange ); - myGlyph->SetScaleFactor( 1.0 ); + vtkFloatingPointType aScaleFactor = 0.0; + vtkFloatingPointType aMinSize = GetMinSize(); + vtkFloatingPointType aMaxSize = GetMaxSize(); + if(!VISU::CheckIsSameValue(aMaxSize, aMinSize)) + aScaleFactor = ( aScalarRange[1] - aScalarRange[0] ) / ( aMaxSize - aMinSize ); + + vtkFloatingPointType aMinRange = aScalarRange[0] - aMinSize * aScaleFactor; + vtkFloatingPointType aMaxRange = aMinRange + aScaleFactor; + vtkFloatingPointType aRange[2] = {aMinRange, aMaxRange}; + + if(!VISU::CheckIsSameRange(myGlyph->GetRange(), aRange)) + myGlyph->SetRange( aRange ); + + if(!VISU::CheckIsSameValue(myGlyph->GetScaleFactor(), 1.0)) + myGlyph->SetScaleFactor( 1.0 ); } - else if( myPSMapper->GetPointSpriteMode() == 1 ) // Geometry + else if( GetPointSpriteMapper()->GetPointSpriteMode() == 1 ) // Geometry { - //cout << "Geometry" << endl; myGlyph->ClampingOff(); myGlyph->SetScaleModeToDataScalingOff(); myGlyph->SetColorModeToColorByScale(); - myGlyph->SetScaleFactor( GetSize() ); + vtkFloatingPointType aScaleFactor = GetSize(); + if(!VISU::CheckIsSameValue(myGlyph->GetScaleFactor(), aScaleFactor)) + myGlyph->SetScaleFactor( aScaleFactor ); } - else if( myPSMapper->GetPointSpriteMode() == 2 ) // Outside + else if( GetPointSpriteMapper()->GetPointSpriteMode() == 2 ) // Outside { - //cout << "Outside" << endl; myGlyph->ClampingOff(); myGlyph->SetScaleModeToDataScalingOff(); myGlyph->SetColorModeToColorByScalar(); - myGlyph->SetScaleFactor( GetSize() ); + vtkFloatingPointType aScaleFactor = GetSize(); + if(!VISU::CheckIsSameValue(myGlyph->GetScaleFactor(), aScaleFactor)) + myGlyph->SetScaleFactor( aScaleFactor ); } - mySphereSource->SetRadius( GetMagnification() * GetAverageCellSize() / 2. ); + vtkFloatingPointType aRadius = GetMagnification() * GetAverageCellSize() / 2.0; + if(!VISU::CheckIsSameValue(mySphereSource->GetRadius(), aRadius)) + mySphereSource->SetRadius( aRadius ); } + //---------------------------------------------------------------------------- VISU::TGaussPointID VISU_GaussPointsPL -::GetObjID(vtkIdType theID) const +::GetObjID(vtkIdType theID) { - return myGaussPtsIDMapper->GetObjID(theID); + return GetGaussPtsIDMapper()->GetObjID(theID); } -float* -VISU_GaussPointsPL -::GetNodeCoord(int theObjID) -{ - vtkIdType anID = GetNodeVTKID(theObjID); - vtkDataSet* aDataSet = myGeomFilter->GetInput(); - return aDataSet->GetPoint(anID); -} - -void -VISU_GaussPointsPL -::SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper) -{ - myGaussPtsIDMapper = theGaussPtsIDMapper; - SetIDMapper(myGaussPtsIDMapper); -} - -const VISU::PGaussPtsIDMapper& -VISU_GaussPointsPL -::GetGaussPtsIDMapper() const -{ - return myGaussPtsIDMapper; -} - -VISU::TVTKOutput* -VISU_GaussPointsPL -::GetParentMesh() const -{ - VISU::TNamedIDMapper* aNamedIDMapper = myGaussPtsIDMapper->GetParent(); - return aNamedIDMapper->GetVTKOutput(); -} //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::SetIsDeformed( bool theIsDeformed ) { - if( theIsDeformed ) - { - myWarpVector->SetInput( myCellDataToPointData->GetUnstructuredGridOutput() ); - myPassFilter[0]->SetInput(myWarpVector->GetOutput()); - } - else - myPassFilter[0]->SetInput(myCellDataToPointData->GetUnstructuredGridOutput()); - - myIsDeformed = theIsDeformed; - - Modified(); + if(theIsDeformed){ + myWarpVector->SetInput( myPassFilter[0]->GetPolyDataOutput() ); + myPassFilter[1]->SetInput(myWarpVector->GetOutput()); + }else + myPassFilter[1]->SetInput(myPassFilter[0]->GetOutput()); } //---------------------------------------------------------------------------- bool VISU_GaussPointsPL -::GetIsDeformed() const +::GetIsDeformed() { - return myIsDeformed; + return myPassFilter[1]->GetInput() != myPassFilter[0]->GetOutput(); } //---------------------------------------------------------------------------- @@ -372,10 +433,8 @@ VISU_GaussPointsPL if(GetBicolor() == theBicolor) return; - myMapperTable->SetBicolor( theBicolor ); - myBarTable->SetBicolor( theBicolor ); - - Modified(); + GetMapperTable()->SetBicolor( theBicolor ); + GetBarTable()->SetBicolor( theBicolor ); } //---------------------------------------------------------------------------- @@ -383,7 +442,7 @@ bool VISU_GaussPointsPL ::GetBicolor() { - return myMapperTable->GetBicolor(); + return GetMapperTable()->GetBicolor(); } //---------------------------------------------------------------------------- @@ -391,8 +450,15 @@ void VISU_GaussPointsPL ::SetIsColored(bool theIsColored) { - myPSMapper->SetPointSpriteMode( theIsColored ? 0 : 1 ); // Results / Geometry - Modified(); + GetPointSpriteMapper()->SetPointSpriteMode( theIsColored ? 0 : 1 ); // Results / Geometry +} + +//---------------------------------------------------------------------------- +bool +VISU_GaussPointsPL +::GetIsColored() +{ + return GetPointSpriteMapper()->GetPointSpriteMode() == 0; } //---------------------------------------------------------------------------- @@ -402,225 +468,278 @@ VISU_GaussPointsPL { if( thePrimitiveType == VISU_OpenGLPointSpriteMapper::GeomSphere ) { - myGlyph->SetInput( myGeomFilter->GetOutput() ); - myPassFilter[1]->SetInput(myGlyph->GetOutput()); + myGlyph->SetInput( myPassFilter[1]->GetOutput() ); + myPassFilter[2]->SetInput(myGlyph->GetOutput()); } else - myPassFilter[1]->SetInput(myGeomFilter->GetOutput()); - - myPSMapper->SetPrimitiveType( thePrimitiveType ); + myPassFilter[2]->SetInput(myPassFilter[1]->GetOutput()); - Modified(); + GetPointSpriteMapper()->SetPrimitiveType( thePrimitiveType ); + + myPrimitiveType = thePrimitiveType; } + //---------------------------------------------------------------------------- int VISU_GaussPointsPL ::GetPrimitiveType() -{ - return myPSMapper->GetPrimitiveType(); +{ + return myPrimitiveType; } + //---------------------------------------------------------------------------- -float +vtkFloatingPointType VISU_GaussPointsPL ::GetMaximumSupportedSize() { - return myPSMapper->GetMaximumSupportedSize(); + return GetPointSpriteMapper()->GetMaximumSupportedSize(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL -::SetClamp(float theClamp) +::SetClamp(vtkFloatingPointType theClamp) { - myPSMapper->SetPointSpriteClamp( theClamp ); - Modified(); + GetPointSpriteMapper()->SetPointSpriteClamp( theClamp ); } + //---------------------------------------------------------------------------- -float +vtkFloatingPointType VISU_GaussPointsPL ::GetClamp() { - return myPSMapper->GetPointSpriteClamp(); + return GetPointSpriteMapper()->GetPointSpriteClamp(); } //---------------------------------------------------------------------------- void VISU_GaussPointsPL -::SetSize(float theSize) +::SetSize(vtkFloatingPointType theSize) { - myPSMapper->SetPointSpriteSize( theSize ); - Modified(); + GetPointSpriteMapper()->SetPointSpriteSize( theSize ); } + //---------------------------------------------------------------------------- -float +vtkFloatingPointType VISU_GaussPointsPL ::GetSize() { - return myPSMapper->GetPointSpriteSize(); + return GetPointSpriteMapper()->GetPointSpriteSize(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL -::SetMinSize(float theMinSize) +::SetMinSize(vtkFloatingPointType theMinSize) { - myPSMapper->SetPointSpriteMinSize( theMinSize ); - Modified(); + GetPointSpriteMapper()->SetPointSpriteMinSize( theMinSize ); } + //---------------------------------------------------------------------------- -float +vtkFloatingPointType VISU_GaussPointsPL ::GetMinSize() { - return myPSMapper->GetPointSpriteMinSize(); + return GetPointSpriteMapper()->GetPointSpriteMinSize(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL -::SetMaxSize(float theMaxSize) +::SetMaxSize(vtkFloatingPointType theMaxSize) { - myPSMapper->SetPointSpriteMaxSize( theMaxSize ); - Modified(); + GetPointSpriteMapper()->SetPointSpriteMaxSize( theMaxSize ); } + //---------------------------------------------------------------------------- -float +vtkFloatingPointType VISU_GaussPointsPL ::GetMaxSize() { - return myPSMapper->GetPointSpriteMaxSize(); + return GetPointSpriteMapper()->GetPointSpriteMaxSize(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL -::SetMagnification(float theMagnification) +::SetMagnification(vtkFloatingPointType theMagnification) { - myPSMapper->SetPointSpriteMagnification( theMagnification ); - Modified(); + GetPointSpriteMapper()->SetPointSpriteMagnification( theMagnification ); } + //---------------------------------------------------------------------------- -float +vtkFloatingPointType VISU_GaussPointsPL ::GetMagnification() { - return myPSMapper->GetPointSpriteMagnification(); + return GetPointSpriteMapper()->GetPointSpriteMagnification(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL -::SetMagnificationIncrement(float theIncrement) +::SetMagnificationIncrement(vtkFloatingPointType theIncrement) { + if(VISU::CheckIsSameValue(myMagnificationIncrement, theIncrement)) + return; + myMagnificationIncrement = theIncrement; + Modified(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL -::SetAlphaThreshold(float theAlphaThreshold) +::SetAlphaThreshold(vtkFloatingPointType theAlphaThreshold) { - myPSMapper->SetPointSpriteAlphaThreshold( theAlphaThreshold ); - Modified(); + GetPointSpriteMapper()->SetPointSpriteAlphaThreshold( theAlphaThreshold ); } + //---------------------------------------------------------------------------- -float +vtkFloatingPointType VISU_GaussPointsPL ::GetAlphaThreshold() { - return myPSMapper->GetPointSpriteAlphaThreshold(); + return GetPointSpriteMapper()->GetPointSpriteAlphaThreshold(); } + +//---------------------------------------------------------------------------- +void +VISU_GaussPointsPL +::SetOpacity(vtkFloatingPointType theOpacity) +{ + GetPointSpriteMapper()->SetPointSpriteOpacity( theOpacity ); +} + + +//---------------------------------------------------------------------------- +vtkFloatingPointType +VISU_GaussPointsPL +::GetOpacity() +{ + return GetPointSpriteMapper()->GetPointSpriteOpacity(); +} + + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::SetResolution(int theResolution) { - myResolution = theResolution; - mySphereSource->SetThetaResolution( myResolution ); - mySphereSource->SetPhiResolution( myResolution ); + mySphereSource->SetThetaResolution( theResolution ); + mySphereSource->SetPhiResolution( theResolution ); +} + + +//---------------------------------------------------------------------------- +int +VISU_GaussPointsPL +::GetResolution() +{ + return mySphereSource->GetThetaResolution(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::ChangeMagnification( bool up ) { - float anIncrement = up ? myMagnificationIncrement : 1.0 / myMagnificationIncrement; + vtkFloatingPointType anIncrement = up ? myMagnificationIncrement : 1.0 / myMagnificationIncrement; SetMagnification( GetMagnification() * anIncrement ); } + //---------------------------------------------------------------------------- -float +vtkFloatingPointType VISU_GaussPointsPL ::GetPointSize(vtkIdType theID, vtkDataArray* theScalarArray) { - float aMaxSize = GetAverageCellSize() * GetMaxSize(); - float aMinSize = GetAverageCellSize() * GetMinSize(); - float aDelta = aMaxSize - aMinSize; - float aVal = theScalarArray->GetTuple1(theID); + vtkFloatingPointType aMaxSize = GetAverageCellSize() * GetMaxSize(); + vtkFloatingPointType aMinSize = GetAverageCellSize() * GetMinSize(); + vtkFloatingPointType aDelta = aMaxSize - aMinSize; + vtkFloatingPointType aVal = theScalarArray->GetTuple1(theID); + + vtkFloatingPointType* aScalarRange = GetScalarRange(); + vtkFloatingPointType aDeltaScalarRange = aScalarRange[1] - aScalarRange[0]; - return aMinSize + aDelta*(aVal - mySourceScalarRange[0])/myDeltaScalarRange; + // to avoid FPE if the minimum is equal to maximum + if( aDeltaScalarRange < 1.0 / VTK_LARGE_FLOAT ) + return aMinSize; + + return aMinSize + aDelta*(aVal - aScalarRange[0]) / aDeltaScalarRange; } + //---------------------------------------------------------------------------- -float +vtkFloatingPointType VISU_GaussPointsPL ::GetMaxPointSize() { return GetAverageCellSize() * GetMaxSize(); } + //---------------------------------------------------------------------------- -float +vtkFloatingPointType VISU_GaussPointsPL ::GetPointSize(vtkIdType theID) { vtkMapper* aMapper = GetMapper(); vtkDataSet* aDataSet = aMapper->GetInput(); - vtkCellData* aCellData = aDataSet->GetCellData(); - vtkDataArray* aScalarArray = aCellData->GetScalars(); - return GetPointSize(theID,aScalarArray); + vtkPointData* aPointData = aDataSet->GetPointData(); + vtkDataArray* aScalarArray = aPointData->GetScalars(); + return GetPointSize(theID, aScalarArray); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL -::SetAverageCellSize(float theAverageCellSize) +::SetAverageCellSize(vtkFloatingPointType theAverageCellSize) { - myPSMapper->SetAverageCellSize( theAverageCellSize ); - Modified(); + GetPointSpriteMapper()->SetAverageCellSize( theAverageCellSize ); } + //---------------------------------------------------------------------------- -float +vtkFloatingPointType VISU_GaussPointsPL ::GetAverageCellSize() { - return myPSMapper->GetAverageCellSize(); + return GetPointSpriteMapper()->GetAverageCellSize(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::SetImageData(vtkImageData* theImageData) { - myPSMapper->SetImageData( theImageData ); + GetPointSpriteMapper()->SetImageData( theImageData ); } + //---------------------------------------------------------------------------- vtkSmartPointer VISU_GaussPointsPL ::MakeTexture( const char* theMainTexture, - const char* theAlphaTexture ) + const char* theAlphaTexture ) { if( !theMainTexture || !theAlphaTexture ) return 0; @@ -678,22 +797,114 @@ VISU_GaussPointsPL return aCompositeImageData; } -void VISU_GaussPointsPL::SetScale( float theScale ) + +void +VISU_GaussPointsPL +::SetScale( vtkFloatingPointType theScale ) { + if(VISU::CheckIsSameValue(myWarpVector->GetScaleFactor(), theScale)) + return; + myWarpVector->SetScaleFactor( theScale ); - myScaleFactor = GetScale(); - Modified(); + myScaleFactor = theScale; } -float VISU_GaussPointsPL::GetScale() + +vtkFloatingPointType +VISU_GaussPointsPL +::GetScale() { return myWarpVector->GetScaleFactor(); } -void VISU_GaussPointsPL::SetMapScale( float theMapScale ) + +void +VISU_GaussPointsPL +::SetMapScale( vtkFloatingPointType theMapScale ) +{ + Superclass::SetMapScale( theMapScale ); + + vtkFloatingPointType aMapScale = myScaleFactor * theMapScale; + if(VISU::CheckIsSameValue(myWarpVector->GetScaleFactor(), aMapScale)) + return; + + myWarpVector->SetScaleFactor( aMapScale ); +} + +void +VISU_GaussPointsPL +::SetSourceGeometry() { - VISU_ScalarMapPL::SetMapScale( theMapScale ); + if(IsExternalGeometryUsed()){ + ClearGeometry(); + myAppendFilter->AddInput(GetFieldTransformFilter()->GetOutput()); + } +} - myWarpVector->SetScaleFactor( myScaleFactor * theMapScale ); - Modified(); +vtkDataSet* +VISU_GaussPointsPL +::InsertCustomPL() +{ + return GetMergedInput(); +} + +int +VISU_GaussPointsPL +::AddGeometry(vtkDataSet* theGeometry, const VISU::TName& theGeomName) +{ + // Fix for issue 0020167 (like in VISU_ScalarMapPL) + if(!IsExternalGeometryUsed()) + ClearGeometry(); + AddGeometryName(theGeomName); + myAppendFilter->AddInput(theGeometry); + return GetNumberOfGeometry(); +} + +vtkDataSet* +VISU_GaussPointsPL +::GetGeometry(int theGeomNumber, VISU::TName& theGeomName) +{ + theGeomName = GetGeometryName(theGeomNumber); + return vtkDataSet::SafeDownCast(myAppendFilter->GetInput(theGeomNumber)); +} + +int +VISU_GaussPointsPL +::GetNumberOfGeometry() +{ + return myAppendFilter->GetNumberOfInputConnections(0); +} + +bool +VISU_GaussPointsPL +::IsExternalGeometryUsed() +{ + return myAppendFilter->GetInput() != GetFieldTransformFilter()->GetOutput(); +} + +void +VISU_GaussPointsPL +::ClearGeometry() +{ + ClearGeometryNames(); + myAppendFilter->RemoveAllInputs(); +} + +void +VISU_GaussPointsPL +::GetSourceRange(vtkFloatingPointType theRange[2]) +{ + if(!IsExternalGeometryUsed()) + Superclass::GetSourceRange(theRange); + else + GetMergedInput()->GetScalarRange( theRange ); +} + +vtkPointSet* +VISU_GaussPointsPL +::GetMergedInput() +{ + if(myMergeFilter->GetInput()) + myMergeFilter->Update(); + return myMergeFilter->GetOutput(); }