myWarpScalar(vtkWarpScalar::New(),true),
myOrientation(VISU_CutPlanesPL::YZ),
myIsRelative(true),
+ myIsContour(false),
myPosition(0.5)
{
- myAngle[0] = myAngle[1] = myAngle[2];
+ myAngle[0] = myAngle[1] = myAngle[2] = 0.;
SetNumberOfContours(32);
}
ShallowCopy(VISU_PipeLine *thePipeLine)
{
VISU_ScalarMapPL::ShallowCopy(thePipeLine);
- //if(VISU_Plot3DPL *aPipeLine = dynamic_cast<VISU_Plot3DPL*>(thePipeLine)){
- //}
+ if(VISU_Plot3DPL *aPipeLine = dynamic_cast<VISU_Plot3DPL*>(thePipeLine)){
+ SetOrientation (aPipeLine->GetPlaneOrientation(),
+ aPipeLine->GetRotateX(), aPipeLine->GetRotateY());
+ SetPlanePosition (aPipeLine->GetPlanePosition(),
+ aPipeLine->IsPositionRelative() );
+ SetScaleFactor( aPipeLine->GetScaleFactor() );
+ SetContourPrs( aPipeLine->GetIsContourPrs() );
+ SetNumberOfContours( aPipeLine->GetNumberOfContours() );
+ }
}
VISU_CutPlanesPL::PlaneOrientation
GetScaleFactor(vtkDataSet* theDataSet)
{
theDataSet->Update();
- float aLength = theDataSet->GetLength();
+ float aLength = theDataSet->GetLength(); // diagonal length
float aScalarRange[2];
GetSourceRange(aScalarRange);
static float EPS = 0.3;
- float aRange = aScalarRange[1] - aScalarRange[0];
+ float aRange = aScalarRange[1];
if(aRange > 0.0)
return aLength / aRange * EPS;
VISU_Plot3DPL::
Update()
{
- VISU_CutPlanesPL::ClearAppendPolyData(myAppendPolyData);
-
- float aDir[3];
- VISU_CutPlanesPL::GetDir(aDir,myAngle,myOrientation);
-
- float aBounds[6];
- GetInput2()->GetBounds(aBounds);
-
- float aBoundPrj[3];
- VISU_CutPlanesPL::GetBoundProject(aBoundPrj,aBounds,aDir);
-
+ float aPlaneNormal[3];
float anOrigin[3];
- VISU::Mul(aDir,GetPlanePosition(),anOrigin);
+ GetBasePlane( anOrigin, aPlaneNormal );
vtkUnstructuredGrid* anUnstructuredGrid =
myFieldTransform->GetUnstructuredGridOutput();
vtkPlane *aPlane = vtkPlane::New();
aPlane->SetOrigin(anOrigin);
- aPlane->SetNormal(aDir);
+ aPlane->SetNormal(aPlaneNormal);
aCutPlane->SetCutFunction(aPlane);
aPlane->Delete();
+ VISU_CutPlanesPL::ClearAppendPolyData(myAppendPolyData);
+
vtkPolyData* aPolyData = aCutPlane->GetOutput();
aPolyData->Update();
+
if(aPolyData->GetNumberOfCells() == 0){
myGeometryFilter->SetInput(anUnstructuredGrid);
aPolyData = myGeometryFilter->GetOutput();
}
- myWarpScalar->SetInput(aPolyData);
+ if ( !myIsContour ) // surface prs
+ {
+ myWarpScalar->SetInput(aPolyData);
+ }
+ else // contour prs
+ {
+ if(aPolyData->GetCellData()->GetNumberOfArrays()) {
+ myCellDataToPointData->SetInput(aPolyData);
+ myCellDataToPointData->PassCellDataOn();
+ myContourFilter->SetInput(myCellDataToPointData->GetOutput());
+ }else
+ myContourFilter->SetInput(aPolyData);
+
+ float aScalarRange[2];
+ GetSourceRange(aScalarRange);
+
+ myContourFilter->GenerateValues(GetNumberOfContours(),aScalarRange);
+ myWarpScalar->SetInput(myContourFilter->GetOutput());
+ }
myAppendPolyData->AddInput(myWarpScalar->GetPolyDataOutput());
-
- float aScalarRange[2];
- GetSourceRange(aScalarRange);
-
- if(aPolyData->GetCellData()->GetNumberOfArrays()){
- myCellDataToPointData->SetInput(aPolyData);
- myCellDataToPointData->PassCellDataOn();
- myContourFilter->SetInput(myCellDataToPointData->GetOutput());
- }else
- myContourFilter->SetInput(aPolyData);
-
- myContourFilter->GenerateValues(GetNumberOfContours(),aScalarRange);
- myAppendPolyData->AddInput(myContourFilter->GetOutput());
aCutPlane->Delete();
- myWarpScalar->SetNormal(aDir);
+ myWarpScalar->SetNormal(aPlaneNormal);
VISU_ScalarMapPL::Update();
}
VISU_Plot3DPL::
GetPlanePosition() const
{
- if(!myIsRelative)
- return myPosition;
+ return myPosition;
+}
- float aBounds[6];
- GetInput2()->GetBounds(aBounds);
+//=======================================================================
+//function : GetBasePlane
+//purpose :
+//=======================================================================
- float aDir[3];
- VISU_CutPlanesPL::GetDir(aDir,myAngle,myOrientation);
+void VISU_Plot3DPL::GetBasePlane(float theOrigin[3],
+ float theNormal[3],
+ bool theCenterOrigine ) const
+{
+ VISU_CutPlanesPL::GetDir(theNormal,myAngle,myOrientation);
+
+ float aPosition = myPosition;
+ float aBounds[6], aBoundPrj[3];
+ if ( myIsRelative )
+ {
+ GetInput()->GetBounds(aBounds);
+ VISU_CutPlanesPL::GetBoundProject(aBoundPrj,aBounds,theNormal);
+ aPosition = aBoundPrj[0] + aBoundPrj[2]*myPosition;
+ }
+ VISU::Mul(theNormal,aPosition,theOrigin);
+
+ if ( theCenterOrigine ) {
+ // move theOrigin to the center of aBounds projections to the plane
+ GetInput2()->GetBounds(aBounds);
+ float boundPoints[8][3] = {
+ {aBounds[0],aBounds[2],aBounds[4]},
+ {aBounds[1],aBounds[2],aBounds[4]},
+ {aBounds[0],aBounds[3],aBounds[4]},
+ {aBounds[1],aBounds[3],aBounds[4]},
+ {aBounds[0],aBounds[2],aBounds[5]},
+ {aBounds[1],aBounds[2],aBounds[5]},
+ {aBounds[0],aBounds[3],aBounds[5]},
+ {aBounds[1],aBounds[3],aBounds[5]}};
+ float newOrigin[3] = { 0,0,0 };
+ for(int i = 0; i < 8; i++) {
+ float proj[3];
+ vtkPlane::ProjectPoint( boundPoints[i], theOrigin, theNormal, proj );
+ newOrigin[0] += proj[0];
+ newOrigin[1] += proj[1];
+ newOrigin[2] += proj[2];
+ }
+ theOrigin[0] = newOrigin[0] / 8.;
+ theOrigin[1] = newOrigin[1] / 8.;
+ theOrigin[2] = newOrigin[2] / 8.;
+ }
+}
- float aBoundPrj[3];
- VISU_CutPlanesPL::GetBoundProject(aBoundPrj,aBounds,aDir);
+//=======================================================================
+//function : GetMinMaxPosition
+//purpose : return absolute position range
+//=======================================================================
- return aBoundPrj[0] + aBoundPrj[2]*myPosition;
+void VISU_Plot3DPL::GetMinMaxPosition( float& minPos, float& maxPos ) const
+{
+ float aBounds[6], aBoundPrj[3], aNormal[3];
+ VISU_CutPlanesPL::GetDir(aNormal,myAngle,myOrientation);
+ GetInput()->GetBounds(aBounds);
+ VISU_CutPlanesPL::GetBoundProject(aBoundPrj,aBounds,aNormal);
+ minPos = aBoundPrj[0];
+ maxPos = aBoundPrj[1];
}
+