X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPIPELINE%2FVISU_Plot3DPL.cxx;h=8c3d9aeac9cfb9693c3e56e537d53b88805d3f4a;hb=b72efbc8c240695bff8372b19c333a6a542cf909;hp=2b87e56f32ba96130af4c7a0868ce2f8f0164a7b;hpb=e967b0415406f4f86ca2c9489abc8554b4c15dae;p=modules%2Fvisu.git diff --git a/src/PIPELINE/VISU_Plot3DPL.cxx b/src/PIPELINE/VISU_Plot3DPL.cxx index 2b87e56f..8c3d9aea 100644 --- a/src/PIPELINE/VISU_Plot3DPL.cxx +++ b/src/PIPELINE/VISU_Plot3DPL.cxx @@ -1,6 +1,6 @@ -// VISU OBJECT : interactive object for VISU entities implementation +// Copyright (C) 2007-2008 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,14 +17,13 @@ // 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 -// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// VISU OBJECT : interactive object for VISU entities implementation // File: VISU_PipeLine.cxx // Author: Alexey PETROV // Module : VISU - - +// #include "VISU_Plot3DPL.hxx" #include "VISU_CutPlanesPL.hxx" #include "VISU_PipeLineUtils.hxx" @@ -39,35 +38,72 @@ #include #include -using namespace std; +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_Plot3DPL); -VISU_Plot3DPL::VISU_Plot3DPL(): - myCellDataToPointData(vtkCellDataToPointData::New(),true), - myAppendPolyData(vtkAppendPolyData::New(),true), - myGeometryFilter(vtkGeometryFilter::New(),true), - myContourFilter(vtkContourFilter::New(),true), - myWarpScalar(vtkWarpScalar::New(),true), + +//---------------------------------------------------------------------------- +VISU_Plot3DPL +::VISU_Plot3DPL(): + myCellDataToPointData(vtkCellDataToPointData::New()), + myAppendPolyData(vtkAppendPolyData::New()), + myGeometryFilter(vtkGeometryFilter::New()), + myContourFilter(vtkContourFilter::New()), + myWarpScalar(vtkWarpScalar::New()), myOrientation(VISU_CutPlanesPL::YZ), myIsRelative(true), myIsContour(false), myPosition(0.5), - myScaleFactor(1.) + myScaleFactor(1.0), + myMapScaleFactor(1.0) { - myAngle[0] = myAngle[1] = myAngle[2] = 0.; + SetIsShrinkable(false); + SetIsFeatureEdgesAllowed(false); + + myCellDataToPointData->Delete(); + myAppendPolyData->Delete(); + myGeometryFilter->Delete(); + myContourFilter->Delete(); + myWarpScalar->Delete(); + + myAngle[0] = myAngle[1] = myAngle[2] = 0.0; + SetNumberOfContours(32); - myIsShrinkable = false; } -VISU_Plot3DPL::~VISU_Plot3DPL() + +//---------------------------------------------------------------------------- +VISU_Plot3DPL +::~VISU_Plot3DPL() +{} + + +//---------------------------------------------------------------------------- +unsigned long int +VISU_Plot3DPL +::GetMTime() { + unsigned long int aTime = Superclass::GetMTime(); + + aTime = std::max(aTime, myCellDataToPointData->GetMTime()); + aTime = std::max(aTime, myAppendPolyData->GetMTime()); + aTime = std::max(aTime, myGeometryFilter->GetMTime()); + aTime = std::max(aTime, myContourFilter->GetMTime()); + aTime = std::max(aTime, myWarpScalar->GetMTime()); + + return aTime; } + +//---------------------------------------------------------------------------- void -VISU_Plot3DPL:: -ShallowCopy(VISU_PipeLine *thePipeLine) +VISU_Plot3DPL +::DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput) { + Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); + if(VISU_Plot3DPL *aPipeLine = dynamic_cast(thePipeLine)){ SetOrientation (aPipeLine->GetPlaneOrientation(), aPipeLine->GetRotateX(), aPipeLine->GetRotateY()); @@ -77,12 +113,13 @@ ShallowCopy(VISU_PipeLine *thePipeLine) SetContourPrs( aPipeLine->GetIsContourPrs() ); SetNumberOfContours( aPipeLine->GetNumberOfContours() ); } - VISU_ScalarMapPL::ShallowCopy(thePipeLine); } + +//---------------------------------------------------------------------------- VISU_CutPlanesPL::PlaneOrientation -VISU_Plot3DPL:: -GetOrientation(vtkDataSet* theDataSet) +VISU_Plot3DPL +::GetOrientation(vtkDataSet* theDataSet) { theDataSet->Update(); @@ -111,15 +148,18 @@ GetOrientation(vtkDataSet* theDataSet) return VISU_CutPlanesPL::XY; } + +//---------------------------------------------------------------------------- vtkFloatingPointType -VISU_Plot3DPL:: -GetScaleFactor(vtkDataSet* theDataSet) +VISU_Plot3DPL +::GetScaleFactor( VISU_ColoredPL* theColoredPL, + vtkDataSet* theDataSet ) { theDataSet->Update(); vtkFloatingPointType aLength = theDataSet->GetLength(); // diagonal length vtkFloatingPointType aScalarRange[2]; - GetSourceRange(aScalarRange); + theColoredPL->GetSourceRange(aScalarRange); static vtkFloatingPointType EPS = 0.3; vtkFloatingPointType aRange = aScalarRange[1]; @@ -129,26 +169,32 @@ GetScaleFactor(vtkDataSet* theDataSet) return 0.0; } + +//---------------------------------------------------------------------------- void -VISU_Plot3DPL:: -Init() +VISU_Plot3DPL +::Init() { - VISU_ScalarMapPL::Init(); + Superclass::Init(); - myOrientation = GetOrientation(GetInput2()); - SetScaleFactor(GetScaleFactor(GetInput2())); + myOrientation = GetOrientation(GetMergedInput()); + SetScaleFactor( GetScaleFactor( this, GetMergedInput() ) ); } -VISU_ScalarMapPL::THook* -VISU_Plot3DPL:: -DoHook() + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_Plot3DPL +::InsertCustomPL() { return myAppendPolyData->GetOutput(); } + +//---------------------------------------------------------------------------- void -VISU_Plot3DPL:: -Update() +VISU_Plot3DPL +::Update() { vtkFloatingPointType aPlaneNormal[3]; vtkFloatingPointType anOrigin[3]; @@ -156,13 +202,12 @@ Update() vtkPolyData* aPolyData = 0; vtkCutter *aCutPlane = 0; - vtkUnstructuredGrid* anUnstructuredGrid = - myFieldTransform->GetUnstructuredGridOutput(); + vtkDataSet* aDataSet = GetMergedInput(); if ( !IsPlanarInput() ) { aCutPlane = vtkCutter::New(); - aCutPlane->SetInput(anUnstructuredGrid); + aCutPlane->SetInput(aDataSet); vtkPlane *aPlane = vtkPlane::New(); aPlane->SetOrigin(anOrigin); @@ -176,13 +221,13 @@ Update() } if ( !aPolyData || aPolyData->GetNumberOfCells() == 0 ) { - myGeometryFilter->SetInput(anUnstructuredGrid); + myGeometryFilter->SetInput(aDataSet); aPolyData = myGeometryFilter->GetOutput(); aPolyData->Update(); } if ( !myIsContour ) // surface prs { - if(aPolyData->GetCellData()->GetNumberOfArrays()) { + if(VISU::IsDataOnCells(aPolyData)) { myCellDataToPointData->SetInput(aPolyData); myCellDataToPointData->PassCellDataOn(); myWarpScalar->SetInput(myCellDataToPointData->GetPolyDataOutput()); @@ -191,7 +236,7 @@ Update() } else // contour prs { - if(aPolyData->GetCellData()->GetNumberOfArrays()) { + if(VISU::IsDataOnCells(aPolyData)) { myCellDataToPointData->SetInput(aPolyData); myCellDataToPointData->PassCellDataOn(); myContourFilter->SetInput(myCellDataToPointData->GetOutput()); @@ -205,7 +250,7 @@ Update() myWarpScalar->SetInput(myContourFilter->GetOutput()); } - VISU_CutPlanesPL::ClearAppendPolyData(myAppendPolyData); + VISU_CutPlanesPL::ClearAppendPolyData(myAppendPolyData.GetPointer()); myAppendPolyData->AddInput(myWarpScalar->GetPolyDataOutput()); if ( aCutPlane ) @@ -213,62 +258,135 @@ Update() myWarpScalar->SetNormal(aPlaneNormal); - VISU_ScalarMapPL::Update(); + Superclass::Update(); } + +//---------------------------------------------------------------------------- +unsigned long int +VISU_Plot3DPL +::GetMemorySize() +{ + unsigned long int aSize = Superclass::GetMemorySize(); + + if(vtkDataObject* aDataObject = myGeometryFilter->GetInput()) + aSize += aDataObject->GetActualMemorySize() * 1024; + + if(myCellDataToPointData->GetInput()) + if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput()) + aSize += aDataSet->GetActualMemorySize() * 1024; + + if(vtkDataObject* aDataObject = myContourFilter->GetInput()) + aSize += aDataObject->GetActualMemorySize() * 1024; + + if(vtkDataObject* aDataObject = myWarpScalar->GetInput()) + aSize += aDataObject->GetActualMemorySize() * 1024; + + int anEnd = myAppendPolyData->GetNumberOfInputConnections(0); + for(int anId = 0; anId < anEnd; anId++){ + if(vtkDataObject* aDataObject = myAppendPolyData->GetInput(anId)) + aSize += aDataObject->GetActualMemorySize() * 1024; + } + + return aSize; +} + + +//---------------------------------------------------------------------------- void -VISU_Plot3DPL:: -SetNumberOfContours(int theNumber) +VISU_Plot3DPL +::SetNumberOfContours(int theNumber) { myContourFilter->SetNumberOfContours(theNumber); } + +//---------------------------------------------------------------------------- int -VISU_Plot3DPL:: -GetNumberOfContours() const +VISU_Plot3DPL +::GetNumberOfContours() { return myContourFilter->GetNumberOfContours(); } + +//---------------------------------------------------------------------------- void -VISU_Plot3DPL:: -SetScaleFactor(vtkFloatingPointType theScaleFactor) +VISU_Plot3DPL +::SetScaleFactor(vtkFloatingPointType theScaleFactor) { myScaleFactor = theScaleFactor; - myWarpScalar->SetScaleFactor(theScaleFactor); + myWarpScalar->SetScaleFactor(theScaleFactor*myMapScaleFactor); } + +//---------------------------------------------------------------------------- vtkFloatingPointType -VISU_Plot3DPL:: -GetScaleFactor() const +VISU_Plot3DPL +::GetScaleFactor() { return myScaleFactor; } + +//---------------------------------------------------------------------------- void VISU_Plot3DPL:: -SetPlanePosition(vtkFloatingPointType thePosition, - bool theIsRelative) +SetContourPrs(bool theIsContourPrs ) +{ + if(myIsContour == theIsContourPrs) + return; + + myIsContour = theIsContourPrs; + Modified(); +} + + +//---------------------------------------------------------------------------- +bool +VISU_Plot3DPL +::GetIsContourPrs() +{ + return myIsContour; +} + + +//---------------------------------------------------------------------------- +void +VISU_Plot3DPL +::SetPlanePosition(vtkFloatingPointType thePosition, + bool theIsRelative) { + bool anIsSameValue = VISU::CheckIsSameValue(myIsRelative, theIsRelative); + anIsSameValue &= (myPosition == thePosition); + if(anIsSameValue) + return; + myIsRelative = theIsRelative; myPosition = thePosition; + Modified(); } + +//---------------------------------------------------------------------------- bool -VISU_Plot3DPL:: -IsPositionRelative() const +VISU_Plot3DPL +::IsPositionRelative() { return myIsRelative; } + +//---------------------------------------------------------------------------- VISU_CutPlanesPL::PlaneOrientation -VISU_Plot3DPL:: -GetPlaneOrientation() const +VISU_Plot3DPL +::GetPlaneOrientation() { return myOrientation; } +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_Plot3DPL:: GetRotateX() @@ -281,6 +399,8 @@ GetRotateX() return 0; } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_Plot3DPL:: GetRotateY(){ @@ -292,28 +412,41 @@ GetRotateY(){ return 0; } + +//---------------------------------------------------------------------------- void VISU_Plot3DPL:: SetOrientation(VISU_CutPlanesPL::PlaneOrientation theOrientation, vtkFloatingPointType theXAngle, vtkFloatingPointType theYAngle) { + bool anIsSameValue = VISU::CheckIsSameValue(GetRotateX(), theXAngle); + anIsSameValue &= VISU::CheckIsSameValue(GetRotateY(), theYAngle); + anIsSameValue &= (myOrientation == theOrientation); + if(anIsSameValue) + return; + switch(theOrientation){ case VISU_CutPlanesPL::XY: myAngle[0] = theXAngle; break; case VISU_CutPlanesPL::YZ: myAngle[1] = theXAngle; break; case VISU_CutPlanesPL::ZX: myAngle[2] = theXAngle; break; } + switch(theOrientation){ case VISU_CutPlanesPL::XY: myAngle[1] = theYAngle; break; case VISU_CutPlanesPL::YZ: myAngle[2] = theYAngle; break; case VISU_CutPlanesPL::ZX: myAngle[0] = theYAngle; break; } + myOrientation = theOrientation; + Modified(); } + +//---------------------------------------------------------------------------- vtkFloatingPointType -VISU_Plot3DPL:: -GetPlanePosition() const +VISU_Plot3DPL +::GetPlanePosition() { return myPosition; } @@ -322,10 +455,11 @@ GetPlanePosition() const //function : GetBasePlane //purpose : //======================================================================= - -void VISU_Plot3DPL::GetBasePlane(vtkFloatingPointType theOrigin[3], - vtkFloatingPointType theNormal[3], - bool theCenterOrigine ) const +void +VISU_Plot3DPL +::GetBasePlane(vtkFloatingPointType theOrigin[3], + vtkFloatingPointType theNormal[3], + bool theCenterOrigine ) { VISU_CutPlanesPL::GetDir(theNormal,myAngle,myOrientation); @@ -341,7 +475,7 @@ void VISU_Plot3DPL::GetBasePlane(vtkFloatingPointType theOrigin[3], if ( theCenterOrigine ) { // move theOrigin to the center of aBounds projections to the plane - GetInput2()->GetBounds(aBounds); + GetMergedInput()->GetBounds(aBounds); vtkFloatingPointType boundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]}, {aBounds[1],aBounds[2],aBounds[4]}, @@ -369,9 +503,10 @@ void VISU_Plot3DPL::GetBasePlane(vtkFloatingPointType theOrigin[3], //function : GetMinMaxPosition //purpose : return absolute position range //======================================================================= - -void VISU_Plot3DPL::GetMinMaxPosition( vtkFloatingPointType& minPos, - vtkFloatingPointType& maxPos ) const +void +VISU_Plot3DPL +::GetMinMaxPosition( vtkFloatingPointType& minPos, + vtkFloatingPointType& maxPos ) { vtkFloatingPointType aBounds[6], aBoundPrj[3], aNormal[3]; VISU_CutPlanesPL::GetDir(aNormal,myAngle,myOrientation); @@ -386,9 +521,12 @@ void VISU_Plot3DPL::GetMinMaxPosition( vtkFloatingPointType& minPos, //purpose : //======================================================================= -void VISU_Plot3DPL::SetMapScale(vtkFloatingPointType theMapScale) +void +VISU_Plot3DPL +::SetMapScale(vtkFloatingPointType theMapScale) { - VISU_ScalarMapPL::SetMapScale(theMapScale); + myMapScaleFactor = theMapScale; + Superclass::SetMapScale(theMapScale); if ( myIsContour ) { vtkFloatingPointType aRange[2];