#include <vtkPlane.h>
#include <vtkExtractGeometry.h>
#include <vtkImplicitBoolean.h>
+#include <vtkImplicitFunction.h>
#include <vtkImplicitFunctionCollection.h>
#include <vtkMath.h>
static int MYDEBUG = 0;
#endif
-VISU_PipeLine::VISU_PipeLine()
+VISU_PipeLine
+::VISU_PipeLine():
+ myMapper(vtkDataSetMapper::New()),
+ myExtractGeometry(SALOME_ExtractGeometry::New())
{
- if(MYDEBUG) MESSAGE("VISU_PipeLine - "<<this);
+ if(MYDEBUG) MESSAGE("VISU_PipeLine::VISU_PipeLine - "<<this);
+ SetDebug(MYVTKDEBUG);
+
+ myMapper->Delete();
+
// Clipping planes
- myExtractGeometry = SALOME_ExtractGeometry::New();
- //myExtractGeometry->SetReleaseDataFlag(true);
myExtractGeometry->Delete();
- //myExtractGeometry->DebugOn();
+ myExtractGeometry->SetStoreMapping(true);
vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New();
- myExtractGeometry->SetImplicitBoolean(anImplicitBoolean);
+ myExtractGeometry->SetImplicitFunction(anImplicitBoolean);
anImplicitBoolean->SetOperationTypeToIntersection();
anImplicitBoolean->Delete();
- // Mapper
- myMapper = TMapper::New();
- myInput = NULL;
-
myIsShrinkable = false;
- SetDebug(MYVTKDEBUG);
}
-VISU_PipeLine::~VISU_PipeLine()
+VISU_PipeLine
+::~VISU_PipeLine()
{
- if(MYDEBUG) MESSAGE("~VISU_PipeLine - "<<this);
- myMapper->Delete();
+ if(MYDEBUG) MESSAGE("VISU_PipeLine::~VISU_PipeLine - "<<this);
}
-void VISU_PipeLine::ShallowCopy(VISU_PipeLine *thePipeLine){
- SetInput(thePipeLine->GetInput());
- myMapper->ShallowCopy(thePipeLine->GetMapper());
- myExtractGeometry->SetImplicitBoolean(thePipeLine->myExtractGeometry->GetImplicitBoolean());
+// Turn debugging output on.
+void
+VISU_PipeLine
+::DebugOn()
+{
+ myExtractGeometry->DebugOn();
+ Superclass::DebugOn();
+}
+
+// Turn debugging output off.
+void
+VISU_PipeLine
+::DebugOff()
+{
+ myExtractGeometry->DebugOff();
+ Superclass::DebugOff();
+}
+
+void
+VISU_PipeLine
+::ShallowCopy(VISU_PipeLine *thePipeLine)
+{
+ SetImplicitFunction(thePipeLine->GetImplicitFunction());
+
+ // To restore mapper input from pipeline
+ vtkDataSet* aDatsSet = myMapper->GetInput();
+ GetMapper()->ShallowCopy(thePipeLine->GetMapper());
+ myMapper->SetInput(aDatsSet);
+
Build();
}
-void VISU_PipeLine::SameAs(VISU_PipeLine *thePipeLine){
+void
+VISU_PipeLine
+::SameAs(VISU_PipeLine *thePipeLine)
+{
ShallowCopy(thePipeLine);
- myExtractGeometry->SetImplicitBoolean(vtkImplicitBoolean::New());
- myExtractGeometry->GetImplicitBoolean()->Delete();
+ SetImplicitFunction(vtkImplicitBoolean::New());
+ GetImplicitFunction()->Delete();
}
-TInput* VISU_PipeLine::GetInput() const
+TInput*
+VISU_PipeLine
+::GetInput() const
{
- return myInput;
+ return myInput.GetPointer();
}
-TInput* VISU_PipeLine::GetInput2() const
+vtkDataSet*
+VISU_PipeLine
+::GetOutput()
+{
+ return GetMapper()->GetInput();
+}
+
+TInput*
+VISU_PipeLine
+::GetInput2() const
{
vtkUnstructuredGrid* aDataSet = myExtractGeometry->GetOutput();
aDataSet->Update();
return aDataSet;
}
-void VISU_PipeLine::SetInput(TInput* theInput)
+void
+VISU_PipeLine
+::SetInput(TInput* theInput)
{
+ if(theInput)
+ theInput->Update();
+
myExtractGeometry->SetInput(theInput);
- if((myInput = theInput))
- myInput->Update();
+ myInput = theInput;
Modified();
}
-VISU_PipeLine::TMapper* VISU_PipeLine::GetMapper()
+VISU_PipeLine::TMapper*
+VISU_PipeLine
+::GetMapper()
{
if(GetInput()){
if(!myMapper->GetInput()){
}
myMapper->Update();
}
- return myMapper;
+ return myMapper.GetPointer();
}
-void VISU_PipeLine::Update()
+void
+VISU_PipeLine
+::Update()
{
myMapper->Update();
}
-int VISU_PipeLine::CheckAvailableMemory(const float& theSize)
+int
+VISU_PipeLine
+::CheckAvailableMemory(const float& theSize)
{
try{
if(theSize > ULONG_MAX) return 0;
return 0;
}
-float VISU_PipeLine::GetAvailableMemory(float theSize, float theMinSize)
+float
+VISU_PipeLine
+::GetAvailableMemory(float theSize,
+ float theMinSize)
{
while(!CheckAvailableMemory(theSize))
if(theSize > theMinSize)
}
//------------------------ Clipping planes -----------------------------------
-
-bool VISU_PipeLine::AddClippingPlane(vtkPlane* thePlane)
+bool
+VISU_PipeLine
+::AddClippingPlane(vtkPlane* thePlane)
{
if (thePlane) {
if (vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()) {
return true;
}
-vtkPlane* VISU_PipeLine::GetClippingPlane(vtkIdType theID) const
+vtkPlane*
+VISU_PipeLine
+::GetClippingPlane(vtkIdType theID) const
{
vtkPlane* aPlane = NULL;
if(theID >= 0 && theID < GetNumberOfClippingPlanes()){
return aPlane;
}
-void VISU_PipeLine::RemoveAllClippingPlanes()
+void
+VISU_PipeLine
+::RemoveAllClippingPlanes()
{
if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
}
}
-vtkIdType VISU_PipeLine::GetNumberOfClippingPlanes() const
+vtkIdType
+VISU_PipeLine
+::GetNumberOfClippingPlanes() const
{
if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
return 0;
}
-static void ComputeBoundsParam (vtkDataSet* theDataSet,
- float theDirection[3], float theMinPnt[3],
- float& theMaxBoundPrj, float& theMinBoundPrj)
+static
+void
+ComputeBoundsParam (vtkDataSet* theDataSet,
+ float theDirection[3],
+ float theMinPnt[3],
+ float& theMaxBoundPrj,
+ float& theMinBoundPrj)
{
float aBounds[6];
theDataSet->GetBounds(aBounds);
theMinPnt[2] = aMinPnt[2];
}
-static void DistanceToPosition (vtkDataSet* theDataSet,
- float theDirection[3], float theDist, float thePos[3])
+static
+void
+DistanceToPosition(vtkDataSet* theDataSet,
+ float theDirection[3],
+ float theDist,
+ float thePos[3])
{
float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
}
-static void PositionToDistance (vtkDataSet* theDataSet,
- float theDirection[3], float thePos[3], float& theDist)
+static
+void
+PositionToDistance (vtkDataSet* theDataSet,
+ float theDirection[3],
+ float thePos[3],
+ float& theDist)
{
float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
}
-void VISU_PipeLine::SetPlaneParam (float theDir[3], float theDist, vtkPlane* thePlane)
+void
+VISU_PipeLine
+::SetPlaneParam(float theDir[3],
+ float theDist,
+ vtkPlane* thePlane)
{
thePlane->SetNormal(theDir);
float anOrigin[3];
thePlane->SetOrigin(anOrigin);
}
-void VISU_PipeLine::GetPlaneParam (float theDir[3], float& theDist, vtkPlane* thePlane)
+void
+VISU_PipeLine
+::GetPlaneParam(float theDir[3],
+ float& theDist,
+ vtkPlane* thePlane)
{
thePlane->GetNormal(theDir);
//function : IsPlanarInput
//purpose :
//=======================================================================
-bool VISU_PipeLine::IsPlanarInput() const
+bool
+VISU_PipeLine
+::IsPlanarInput() const
{
float aBounds[6];
GetInput()->GetBounds( aBounds ); // xmin,xmax, ymin,ymax, zmin,zmax
return false;
}
+
+//=======================================================================
+vtkIdType
+VISU_PipeLine
+::GetNodeObjID(vtkIdType theID)
+{
+ vtkIdType anID = myExtractGeometry->GetNodeObjId(theID);
+ return myIDMapper->GetNodeObjID(anID);
+}
+
+vtkIdType
+VISU_PipeLine
+::GetNodeVTKID(vtkIdType theID)
+{
+ vtkIdType anID = myIDMapper->GetNodeVTKID(theID);
+ return myExtractGeometry->GetNodeVTKId(anID);
+}
+
+float*
+VISU_PipeLine
+::GetNodeCoord(int theObjID)
+{
+ return myIDMapper->GetNodeCoord(theObjID);
+}
+
+//=======================================================================
+vtkIdType
+VISU_PipeLine
+::GetElemObjID(vtkIdType theID)
+{
+ vtkIdType anID = myExtractGeometry->GetElemObjId(theID);
+ return myIDMapper->GetElemObjID(anID);
+}
+
+vtkIdType
+VISU_PipeLine
+::GetElemVTKID(vtkIdType theID)
+{
+ vtkIdType anID = myIDMapper->GetElemVTKID(theID);
+ return myExtractGeometry->GetElemVTKId(anID);
+}
+
+vtkCell*
+VISU_PipeLine
+::GetElemCell(vtkIdType theObjID)
+{
+ return myIDMapper->GetElemCell(theObjID);
+}
+
+//=======================================================================
+void
+VISU_PipeLine
+::SetIDMapper(const VISU::PIDMapper& theIDMapper)
+{
+ myIDMapper = theIDMapper;
+ SetInput(myIDMapper->GetVTKOutput());
+}
+
+const VISU::PIDMapper&
+VISU_PipeLine
+::GetIDMapper() const
+{
+ return myIDMapper;
+}
+
+//=======================================================================
+void
+VISU_PipeLine
+::SetImplicitFunction(vtkImplicitFunction *theFunction)
+{
+ myExtractGeometry->SetImplicitFunction(theFunction);
+}
+
+vtkImplicitFunction *
+VISU_PipeLine
+::GetImplicitFunction()
+{
+ return myExtractGeometry->GetImplicitFunction();
+}
+
+SALOME_ExtractGeometry*
+VISU_PipeLine
+::GetExtractGeometryFilter()
+{
+ return myExtractGeometry.GetPointer();
+}