-// 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
// 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_PipeLine.cxx
// Author: Alexey PETROV
// Module : VISU
-
-
+//
#include "VISU_CutPlanesPL.hxx"
+#include "VISU_FieldTransform.hxx"
#include "VISU_PipeLineUtils.hxx"
#include "VTKViewer_GeometryFilter.h"
+#include "VISU_MapperHolder.hxx"
+#include "VISU_DeformationPL.hxx"
#include <vtkAppendPolyData.h>
#include <vtkCutter.h>
#include <vtkPlane.h>
-using namespace std;
+//#include <vtkUnstructuredGrid.h>
static vtkFloatingPointType EPS = 1.0E-3;
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_CutPlanesPL);
+
+//----------------------------------------------------------------------------
VISU_CutPlanesPL
-::VISU_CutPlanesPL()
+::VISU_CutPlanesPL():
+ VISU_OptionalDeformationPL()
{
+ if(MYDEBUG) MESSAGE("VISU_CutPlanesPL()::VISU_CutPlanesPL() - "<<this);
+
+ SetIsShrinkable(false);
+ SetIsFeatureEdgesAllowed(false);
+
+ SetElnoDisassembleState( true );
+
myAppendPolyData = vtkAppendPolyData::New();
- myIsShrinkable = false;
myNbParts = 10;
myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0;
myAng[1][0] = myAng[1][1] = myAng[1][2] = 0.0;
+ UseDeformation(false);
}
+
+//----------------------------------------------------------------------------
VISU_CutPlanesPL
::~VISU_CutPlanesPL()
{
+ if(MYDEBUG) MESSAGE("VISU_CutPlanesPL()::~VISU_CutPlanesPL() - "<<this);
myAppendPolyData->Delete();
+ myAppendPolyData = NULL;
}
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_CutPlanesPL
+::GetMTime()
+{
+ unsigned long int aTime = Superclass::GetMTime();
+
+ if(IsDeformed()) {
+ aTime = std::max(aTime, VISU_OptionalDeformationPL::GetMTime());
+ }
+
+ aTime = std::max(aTime, myAppendPolyData->GetMTime());
+
+ return aTime;
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
-::ShallowCopy(VISU_PipeLine *thePipeLine)
+::DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput)
{
+ Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
+
if(VISU_CutPlanesPL *aPipeLine = dynamic_cast<VISU_CutPlanesPL*>(thePipeLine)){
+
SetOrientation(aPipeLine->GetPlaneOrientation(),
- aPipeLine->GetRotateX(),aPipeLine->GetRotateY());
+ aPipeLine->GetRotateX(),
+ aPipeLine->GetRotateY());
+
SetDisplacement(aPipeLine->GetDisplacement());
+
SetNbParts(aPipeLine->GetNbParts());
- for (int i = 0, iend = GetNbParts(); i < iend; i++)
- if(!aPipeLine->IsPartDefault(i)) SetPartPosition(i, aPipeLine->GetPartPosition(i));
+ for (int i = 0, iEnd = GetNbParts(); i < iEnd; i++)
+ if(!aPipeLine->IsPartDefault(i))
+ SetPartPosition(i, aPipeLine->GetPartPosition(i));
}
- VISU_ScalarMapPL::ShallowCopy(thePipeLine);
}
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::Init()
{
- VISU_ScalarMapPL::Init();
-
+ Superclass::Init();
SetNbParts(10);
myBasePlane[0] = YZ;
myDisplacement[0] = 0.5;
myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0;
+ SetScale(VISU_DeformationPL::GetDefaultScaleFactor(this));
}
-VISU_ScalarMapPL::THook*
+
+//----------------------------------------------------------------------------
+vtkDataSet*
VISU_CutPlanesPL
-::DoHook()
+::InsertCustomPL()
{
- return myAppendPolyData->GetOutput();
+ return GetWarpVectorOutput();
}
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::Update()
{
ClearAppendPolyData(myAppendPolyData);
+
+
+ if(!myVectorialField || !IsDeformed()){
+ SetMergeFilterInput(GetMergedInput(),GetMergedInput());
+ }
+
+
+ if(VISU::IsDataOnCells(GetMergedInput()))
+ GetMapper()->SetScalarModeToUseCellData();
+ else
+ GetMapper()->SetScalarModeToUsePointData();
+
SetPartPosition();
+
vtkFloatingPointType aDir[3];
- GetDir(aDir,myAng[0],myBasePlane[0]);
+ GetDir(aDir,
+ myAng[0],
+ myBasePlane[0]);
+
vtkFloatingPointType aBounds[6];
- GetInput2()->GetBounds(aBounds);
- vtkDataSet* aDataSet = myFieldTransform->GetUnstructuredGridOutput();
- CutWithPlanes(myAppendPolyData,aDataSet,myNbParts,aDir,aBounds,
- myPartPosition,myPartCondition,myDisplacement[0]);
- VISU_ScalarMapPL::Update();
+ vtkDataSet* aFilterOutput = GetMergeFilterOutput();
+
+ aFilterOutput->GetBounds(aBounds);
+
+ CutWithPlanes(myAppendPolyData,
+ aFilterOutput,
+ myNbParts,
+ aDir,
+ aBounds,
+ myPartPosition,
+ myPartCondition,
+ myDisplacement[0]);
+
+
+
+ SetWarpVectorInput(myAppendPolyData->GetOutput());
+ Superclass::Update();
}
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_CutPlanesPL
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ if(vtkDataSet* aDataSet = myAppendPolyData->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ int anEnd = myAppendPolyData->GetNumberOfInputConnections(0);
+ for(int anId = 0; anId < anEnd; anId++)
+ if(vtkDataSet* aDataSet = myAppendPolyData->GetInput(anId))
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ return aSize;
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::SetPartPosition(int theNum)
VISU_CutPlanesPL
::ClearAppendPolyData(vtkAppendPolyData *theAppendPolyData)
{
- int iEnd = theAppendPolyData->GetNumberOfInputs();
- for(int i = iEnd-1; i >= 0; i--)
- theAppendPolyData->RemoveInput(theAppendPolyData->GetInput(i));
+ theAppendPolyData->RemoveAllInputs();
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType*
VISU_CutPlanesPL::
GetRx(vtkFloatingPointType theRx[3][3],
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType*
VISU_CutPlanesPL
::GetRy(vtkFloatingPointType theRy[3][3],
}
+//----------------------------------------------------------------------------
vtkFloatingPointType*
VISU_CutPlanesPL
::GetRz(vtkFloatingPointType theRz[3][3],
}
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::CorrectPnt(vtkFloatingPointType thePnt[3],
}
}
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::GetBoundProject(vtkFloatingPointType BoundPrj[3],
}
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::SetOrientation(const VISU_CutPlanesPL::PlaneOrientation& theOrient,
}
+//----------------------------------------------------------------------------
const VISU_CutPlanesPL::PlaneOrientation&
VISU_CutPlanesPL
::GetPlaneOrientation(int theNum)
return 0;
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_CutPlanesPL
::GetRotateY(int theNum)
}
+//----------------------------------------------------------------------------
+vtkFloatingPointType
+VISU_CutPlanesPL
+::GetDisplacement(int theNum)
+{
+ return myDisplacement[theNum];
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
-::SetNbParts(int theNb)
+::SetDisplacement(vtkFloatingPointType theDisp,
+ int theNum)
{
- myNbParts = theNb;
- myPartPosition.resize(myNbParts);
- myPartCondition.resize(myNbParts,1);
+ if(VISU::CheckIsSameValue(myDisplacement[theNum], theDisp))
+ return;
+
+ myDisplacement[theNum] = theDisp;
Modified();
}
+//----------------------------------------------------------------------------
+void
+VISU_CutPlanesPL
+::SetNbParts(int theNbParts)
+{
+ if(theNbParts > 0 && GetNbParts() != theNbParts){
+ myPartPosition.resize(theNbParts);
+ myPartCondition.resize(theNbParts, 1);
+ myNbParts = theNbParts;
+ Modified();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+int
+VISU_CutPlanesPL
+::GetNbParts()
+{
+ return myPartPosition.size();
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::SetPartPosition(int thePartNumber,
vtkFloatingPointType thePartPosition)
{
- if(thePartNumber >= myNbParts) return;
+ if(thePartNumber >= myNbParts)
+ return;
+
+ bool anIsSameValue = VISU::CheckIsSameValue(myPartPosition[thePartNumber], thePartPosition);
+ anIsSameValue &= VISU::CheckIsSameValue(myPartCondition[thePartNumber], 0);
+ if(anIsSameValue)
+ return;
+
myPartPosition[thePartNumber] = thePartPosition;
myPartCondition[thePartNumber] = 0;
Modified();
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_CutPlanesPL
::GetPartPosition(int thePartNumber,
int theNum)
{
- if(thePartNumber >= myNbParts) return 0;
+ if(thePartNumber >= myNbParts)
+ return 0;
+
vtkFloatingPointType aPosition = myPartPosition[thePartNumber];
if(myPartCondition[thePartNumber]){
vtkFloatingPointType aDir[3], aBounds[6], aBoundPrj[3];
- GetInput2()->GetBounds(aBounds);
- GetDir(aDir,myAng[theNum],myBasePlane[theNum]);
- GetBoundProject(aBoundPrj,aBounds,aDir);
- if (myNbParts > 1){
+ if(!IsDeformed())
+ GetMergedInput()->GetBounds(aBounds);
+ else
+ GetMergeFilterOutput()->GetBounds(aBounds);
+
+
+ GetDir(aDir,
+ myAng[theNum],
+ myBasePlane[theNum]);
+
+ GetBoundProject(aBoundPrj,
+ aBounds,
+ aDir);
+
+ if(myNbParts > 1){
vtkFloatingPointType aDBoundPrj = aBoundPrj[2]/(myNbParts - 1);
vtkFloatingPointType aDisplacement = aDBoundPrj * myDisplacement[theNum];
vtkFloatingPointType aStartPosition = aBoundPrj[0] - 0.5*aDBoundPrj + aDisplacement;
}else
aPosition = aBoundPrj[0] + aBoundPrj[2]*myDisplacement[theNum];
}
+
return aPosition;
}
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::SetPartDefault(int thePartNumber)
{
- if(thePartNumber >= myNbParts) return;
+ if(thePartNumber >= myNbParts)
+ return;
+
+ bool anIsSameValue = VISU::CheckIsSameValue(myPartPosition[thePartNumber], GetPartPosition(thePartNumber));
+ anIsSameValue &= VISU::CheckIsSameValue(myPartCondition[thePartNumber], 1);
+ if(anIsSameValue)
+ return;
+
myPartPosition[thePartNumber] = GetPartPosition(thePartNumber);
myPartCondition[thePartNumber] = 1;
Modified();
}
+
+
+//----------------------------------------------------------------------------
int
VISU_CutPlanesPL
::IsPartDefault(int thePartNumber)
{
- if(thePartNumber >= myNbParts) return 1;
+ if(thePartNumber >= myNbParts)
+ return 1;
+
return myPartCondition[thePartNumber];
}
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::GetDir(vtkFloatingPointType theDir[3],
iPlane = 1;
break;
}
+
for(int i = 0; i < 3; i++)
theDir[i] = aRotation[i][iPlane];
}
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::CutWithPlane(vtkAppendPolyData* theAppendPolyData,
aCutPlane->SetCutFunction(aPlane);
aPlane->Delete();
theAppendPolyData->AddInput(aCutPlane->GetOutput());
- aCutPlane->Register(theAppendPolyData);
aCutPlane->Delete();
}
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::CutWithPlanes(vtkAppendPolyData* theAppendPolyData,
int theNbPlanes,
vtkFloatingPointType theDir[3],
vtkFloatingPointType theBounds[6],
- const vector<vtkFloatingPointType>& thePlanePosition,
- const vector<int>& thePlaneCondition,
+ const std::vector<vtkFloatingPointType>& thePlanePosition,
+ const std::vector<int>& thePlaneCondition,
vtkFloatingPointType theDisplacement)
{
vtkFloatingPointType aBoundPrj[3], aOrig[3], aPosition;
aPolyData->Update();
theAppendPolyData->Update();
}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_CutPlanesPL::SetVectorialField(VISU::PUnstructuredGridIDMapper theMapper)
+{
+ if(myVectorialField == theMapper)
+ return;
+
+ if(CheckCanDeformate(theMapper->GetOutput())){
+ myVectorialField = theMapper;
+
+ SetMergeFilterInput(GetMergedInput(),theMapper->GetOutput());
+ }
+ else
+ UseDeformation(false);
+
+ Modified();
+}
+
+//----------------------------------------------------------------------------
+VISU::PUnstructuredGridIDMapper VISU_CutPlanesPL::
+getVectorialField()
+{
+ return myVectorialField;
+}
+
+//----------------------------------------------------------------------------
+void VISU_CutPlanesPL::SetMapScale(vtkFloatingPointType theMapScale){
+ Superclass::SetMapScale(theMapScale);
+ if(IsDeformed())
+ VISU_OptionalDeformationPL::SetMapScale(theMapScale);
+}