]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
POST-PROCESSOR 2005, T1.5, 2D fields displaed in 3D - new pipeline (Plot#D) is introduced
authorapo <apo@opencascade.com>
Wed, 20 Apr 2005 05:46:35 +0000 (05:46 +0000)
committerapo <apo@opencascade.com>
Wed, 20 Apr 2005 05:46:35 +0000 (05:46 +0000)
src/PIPELINE/Makefile.in
src/PIPELINE/VISUPipeLine.cxx
src/PIPELINE/VISU_CutPlanesPL.cxx
src/PIPELINE/VISU_CutPlanesPL.hxx
src/PIPELINE/VISU_PipeLine.hxx
src/PIPELINE/VISU_Plot3DPL.cxx [new file with mode: 0644]
src/PIPELINE/VISU_Plot3DPL.hxx [new file with mode: 0644]

index f4ba169472c82dda3e7bed67b2a80069f6881431..db0e8fcac7d236936bcd6afcba0f8ea675ea21ca 100644 (file)
@@ -51,7 +51,7 @@ LIB_SRC = VISU_PipeLine.cxx VISU_PipeLineUtils.cxx \
        VISU_VectorsPL.cxx VISU_StreamLinesPL.cxx \
        VISU_LookupTable.cxx VISU_ScalarBarActor.cxx \
        VISU_Extractor.cxx VISU_FieldTransform.cxx \
-       VISU_UsedPointsFilter.cxx \
+       VISU_UsedPointsFilter.cxx VISU_Plot3DPL.cxx \
        SALOME_ExtractGeometry.cxx
 
 # Executables targets
index 9c26e3ff03d3a71e6431e2ce27e88100375d6a62..25a236c56b0e37218274ce83a50443e8b8256734 100644 (file)
@@ -33,8 +33,9 @@
 #include "VISU_DeformedShapePL.hxx"
 #include "VISU_VectorsPL.hxx"
 #include "VISU_StreamLinesPL.hxx"
+#include "VISU_Plot3DPL.hxx"
 
-typedef VISU_ScalarMapPL TPresent;
+typedef VISU_Plot3DPL TPresent;
 
 #include <vtkUnstructuredGrid.h>
 #include <vtkDataSetMapper.h>
@@ -112,8 +113,9 @@ int main(int argc, char** argv){
          aPresent->Build();
          aPresent->Init();
          aPresent->SetSourceRange();
-         //aPresent->SetPartDefault(0);
-         //aPresent->SetScalarMin(0.01);
+         //aPresent->SetNumberOfContours(50);
+         //aPresent->SetNbParts(1);
+         //aPresent->SetOrientation(VISU_CutPlanesPL::XY,0.0,0.0);
          //aPresent->SetScaling(VTK_SCALE_LOG10);
          aPresent->Update();
          
@@ -127,9 +129,10 @@ int main(int argc, char** argv){
 
          ren->AddActor(anActor);
          ren->AddActor2D(aScalarBar);
-         ren->ResetCameraClippingRange();
          
          renWin->Render();
+         ren->ResetCamera();
+
          iren->Start();
          return 0;
        }
index 0904935b4775580784824865a5262155c33df34f..e57995584d9ec7bdf126c9aa917f6574de8343b2 100644 (file)
@@ -236,7 +236,10 @@ int VISU_CutPlanesPL::IsPartDefault(int thePartNumber){
 }
 
 
-void VISU_CutPlanesPL::GetDir(float theDir[3], float theAng[3], const PlaneOrientation& theBasePlane){
+void VISU_CutPlanesPL::GetDir(float theDir[3], 
+                             const float theAng[3], 
+                             const PlaneOrientation& theBasePlane)
+{
   int iPlane = 0;
   float aRx[3][3], aRy[3][3], aRz[3][3], aRotation[3][3];
   switch(theBasePlane){
index 094c9463b34fe179e0b2be47ff41c28b3c051c15..170df02e7cc57a75f5d05c33e75f00834e011dfa 100644 (file)
@@ -76,7 +76,9 @@ public:
   static void CorrectPnt(float thePnt[3], const float BoundPrj[6]);
   static void GetBoundProject(float BoundPrj[3], const float BoundBox[6], const float Dir[3]);
 
-  static void GetDir(float theDir[3], float theAng[3], const PlaneOrientation& theBasePlane);
+  static void GetDir(float theDir[3], 
+                    const float theAng[3], 
+                    const PlaneOrientation& theBasePlane);
 
   static void ClearAppendPolyData(vtkAppendPolyData *theAppendPolyData);
 
index 0f1670ced333d1f24f4f81e50f239778ff723288..75b8cf5d4380adc40a75dd45655363ac2c32725e 100644 (file)
@@ -47,8 +47,13 @@ public:
       r->Delete();
     return *this;
   }
-  TVTKSmartPtr& operator=(T* r){ vtkSmartPointer<T>::operator=(r); return *this;}
-  T* Get() const { return GetPointer();}
+  TVTKSmartPtr& operator=(T* r){ 
+    vtkSmartPointer<T>::operator=(r); 
+    return *this;
+  }
+  operator T* () const { 
+    return GetPointer();
+  }
 };
 
 class vtkDataSetMapper;
diff --git a/src/PIPELINE/VISU_Plot3DPL.cxx b/src/PIPELINE/VISU_Plot3DPL.cxx
new file mode 100644 (file)
index 0000000..0f4e02c
--- /dev/null
@@ -0,0 +1,286 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  Copyright (C) 2003  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 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  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 
+//
+//
+// File:    VISU_PipeLine.cxx
+// Author:  Alexey PETROV
+// Module : VISU
+
+
+#include "VISU_Plot3DPL.hxx"
+#include "VISU_CutPlanesPL.hxx"
+#include "VISU_PipeLineUtils.hxx"
+#include "SALOME_GeometryFilter.h"
+
+#include <vtkAppendPolyData.h>
+#include <vtkCutter.h>
+#include <vtkPlane.h>
+
+#include <vtkCellDataToPointData.h>
+#include <vtkGeometryFilter.h>
+#include <vtkContourFilter.h>
+#include <vtkWarpScalar.h>
+#include <vtkOutlineFilter.h>
+
+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),
+  myOrientation(VISU_CutPlanesPL::YZ),
+  myIsRelative(true),
+  myPosition(0.5)
+{
+  myAngle[0] = myAngle[1] = myAngle[2];
+  SetNumberOfContours(32);
+}
+
+VISU_Plot3DPL::~VISU_Plot3DPL()
+{
+}
+
+void 
+VISU_Plot3DPL::
+ShallowCopy(VISU_PipeLine *thePipeLine)
+{
+  VISU_ScalarMapPL::ShallowCopy(thePipeLine);
+  //if(VISU_Plot3DPL *aPipeLine = dynamic_cast<VISU_Plot3DPL*>(thePipeLine)){
+  //}
+}
+
+VISU_CutPlanesPL::PlaneOrientation 
+VISU_Plot3DPL::
+GetOrientation(vtkDataSet* theDataSet)
+{
+  theDataSet->Update();
+
+  float aBounds[6];
+  theDataSet->GetBounds(aBounds);
+  float aDelta[3] = {aBounds[1] - aBounds[0], aBounds[3] - aBounds[2], aBounds[5] - aBounds[4]};
+
+  if(aDelta[0] >= aDelta[1] && aDelta[0] >= aDelta[2])
+    if(aDelta[1] >= aDelta[2])
+      return VISU_CutPlanesPL::XY;
+    else
+      return VISU_CutPlanesPL::ZX;
+
+  if(aDelta[1] >= aDelta[0] && aDelta[1] >= aDelta[2])
+    if(aDelta[0] >= aDelta[2])
+      return VISU_CutPlanesPL::XY;
+    else
+      return VISU_CutPlanesPL::YZ;
+
+  if(aDelta[2] >= aDelta[0] && aDelta[2] >= aDelta[1])
+    if(aDelta[0] >= aDelta[1])
+      return VISU_CutPlanesPL::ZX;
+    else
+      return VISU_CutPlanesPL::YZ;
+
+  return VISU_CutPlanesPL::XY;
+}
+
+float
+VISU_Plot3DPL::
+GetScaleFactor(vtkDataSet* theDataSet)
+{
+  theDataSet->Update();
+  float aLength = theDataSet->GetLength();
+
+  float aScalarRange[2];
+  GetSourceRange(aScalarRange);
+
+  static float EPS = 0.3;
+  float aRange = aScalarRange[1] - aScalarRange[0];
+  if(aRange > 0.0)
+    return aLength / aRange * EPS;
+
+  return 0.0;
+}
+
+void
+VISU_Plot3DPL::
+Init()
+{
+  VISU_ScalarMapPL::Init();
+
+  myOrientation = GetOrientation(GetInput2());
+  SetScaleFactor(GetScaleFactor(GetInput2()));
+}
+
+VISU_ScalarMapPL::THook* 
+VISU_Plot3DPL::
+DoHook()
+{
+  return myAppendPolyData->GetOutput();
+}
+
+void 
+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 anOrigin[3];
+  VISU::Mul(aDir,GetPlanePosition(),anOrigin);
+
+  vtkUnstructuredGrid* anUnstructuredGrid = 
+    myFieldTransform->GetUnstructuredGridOutput();
+  vtkCutter *aCutPlane = vtkCutter::New();
+  aCutPlane->SetInput(anUnstructuredGrid);
+
+  vtkPlane *aPlane = vtkPlane::New();
+  aPlane->SetOrigin(anOrigin); 
+  aPlane->SetNormal(aDir);
+
+  aCutPlane->SetCutFunction(aPlane);
+  aPlane->Delete();
+
+  vtkPolyData* aPolyData = aCutPlane->GetOutput();
+  aPolyData->Update();
+  if(aPolyData->GetNumberOfCells() == 0){
+    myGeometryFilter->SetInput(anUnstructuredGrid);
+    aPolyData = myGeometryFilter->GetOutput();
+  }
+  myWarpScalar->SetInput(aPolyData);
+  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);
+
+  VISU_ScalarMapPL::Update();
+}
+
+void 
+VISU_Plot3DPL::
+SetNumberOfContours(int theNumber)
+{
+  myContourFilter->SetNumberOfContours(theNumber);
+}
+
+int 
+VISU_Plot3DPL::
+GetNumberOfContours() const
+{
+  return myContourFilter->GetNumberOfContours();
+}
+
+void 
+VISU_Plot3DPL::
+SetScaleFactor(float theScaleFactor)
+{
+  myWarpScalar->SetScaleFactor(theScaleFactor);
+}
+
+float 
+VISU_Plot3DPL::
+GetScaleFactor() const
+{
+  return myWarpScalar->GetScaleFactor();
+}
+
+void 
+VISU_Plot3DPL::
+SetPlanePosition(float thePosition,
+                bool theIsRelative)
+{
+  myIsRelative = theIsRelative;
+  myPosition = thePosition;
+}
+
+bool
+VISU_Plot3DPL::
+IsPositionRelative() const
+{
+  return myIsRelative;
+}
+
+VISU_CutPlanesPL::PlaneOrientation 
+VISU_Plot3DPL::
+GetPlaneOrientation() const
+{
+  return myOrientation;
+}
+
+void
+VISU_Plot3DPL::
+SetOrientation(VISU_CutPlanesPL::PlaneOrientation theOrientation, 
+              float theXAngle, 
+              float theYAngle)
+{
+  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;
+}
+
+float 
+VISU_Plot3DPL::
+GetPlanePosition() const
+{
+  if(!myIsRelative)
+    return myPosition;
+
+  float aBounds[6];
+  GetInput2()->GetBounds(aBounds);
+
+  float aDir[3];
+  VISU_CutPlanesPL::GetDir(aDir,myAngle,myOrientation);
+
+  float aBoundPrj[3];
+  VISU_CutPlanesPL::GetBoundProject(aBoundPrj,aBounds,aDir);
+
+  return aBoundPrj[0] + aBoundPrj[2]*myPosition;
+}
diff --git a/src/PIPELINE/VISU_Plot3DPL.hxx b/src/PIPELINE/VISU_Plot3DPL.hxx
new file mode 100644 (file)
index 0000000..7924c25
--- /dev/null
@@ -0,0 +1,108 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  Copyright (C) 2003  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 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  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 
+//
+//
+// File:    VISU_CutPlanesPL.hxx
+// Author:  Alexey PETROV
+// Module : VISU
+
+#ifndef VISU_Plot3DPL_HeaderFile
+#define VISU_Plot3DPL_HeaderFile
+
+#include "VISU_ScalarMapPL.hxx"
+#include "VISU_CutPlanesPL.hxx"
+
+class vtkWarpScalar;
+class vtkContourFilter;
+class vtkGeometryFilter;
+class vtkCellDataToPointData;
+
+class VISU_Plot3DPL : public VISU_ScalarMapPL{
+protected:
+  VISU_Plot3DPL();
+  VISU_Plot3DPL(const VISU_Plot3DPL&);
+
+public:
+  vtkTypeMacro(VISU_Plot3DPL,VISU_ScalarMapPL);
+  static VISU_Plot3DPL* New();
+  virtual ~VISU_Plot3DPL();
+
+  virtual 
+  void
+  ShallowCopy(VISU_PipeLine *thePipeLine);
+
+  VISU_CutPlanesPL::PlaneOrientation 
+  GetPlaneOrientation() const;
+
+  void
+  SetOrientation(VISU_CutPlanesPL::PlaneOrientation theOrientation, 
+                float theXAngle = 0.0, 
+                float theYAngle = 0.0);
+
+  float
+  GetPlanePosition() const;
+
+  bool
+  IsPositionRelative() const;
+
+  void
+  SetPlanePosition(float thePosition,
+                  bool theIsRelative);
+
+  void 
+  SetScaleFactor(float theScaleFactor);
+
+  float 
+  GetScaleFactor() const;
+
+  void
+  SetNumberOfContours(int theNumber);
+
+  int
+  GetNumberOfContours() const;
+
+public:
+  virtual void Init();
+  virtual void Update();
+  
+  static 
+  VISU_CutPlanesPL::PlaneOrientation 
+  GetOrientation(vtkDataSet* theDataSet);
+
+  float 
+  GetScaleFactor(vtkDataSet* theDataSet);
+
+protected:
+  virtual THook* DoHook();
+
+  float myAngle[3];
+  bool myIsRelative;
+  float myPosition;
+  VISU_CutPlanesPL::PlaneOrientation myOrientation;
+
+  TVTKSmartPtr<vtkCellDataToPointData> myCellDataToPointData;
+  TVTKSmartPtr<vtkAppendPolyData> myAppendPolyData;
+  TVTKSmartPtr<vtkGeometryFilter> myGeometryFilter;
+  TVTKSmartPtr<vtkContourFilter> myContourFilter;
+  TVTKSmartPtr<vtkWarpScalar> myWarpScalar;
+};
+
+#endif