Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / PIPELINE / VISUPipeLine.cxx
index 6595ae839612ab43a52db4e9d76947c31722f8da..d1ac8fe3f9f25b176508c889eda26470f9f6c7e3 100644 (file)
@@ -1,23 +1,23 @@
 //  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 
+//  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.hxx
 #include "VISU_DeformedShapePL.hxx"
 #include "VISU_VectorsPL.hxx"
 #include "VISU_StreamLinesPL.hxx"
+#include "VISU_GaussPointsPL.hxx"
+#include "VISU_Plot3DPL.hxx"
 
-typedef VISU_ScalarMapPL TPresent;
+typedef VISU_GaussPointsPL TPresent;
 
 #include <vtkUnstructuredGrid.h>
 #include <vtkDataSetMapper.h>
 
 #include <vtkRenderWindowInteractor.h>
-#include <vtkRenderWindow.h> 
+#include <vtkRenderWindow.h>
+#include <vtkImageData.h>
 #include <vtkRenderer.h>
 #include <vtkCamera.h>
 #include <vtkActor.h>
 
+#include <vtkProperty.h>
+
 #include "utilities.h"
 
 using namespace std;
 
 static int isOnlyMesh = false;
 
-int main(int argc, char** argv){ 
+int main(int argc, char** argv){
   try{
     if(argc > 1){
       vtkRenderWindow *renWin = vtkRenderWindow::New();
@@ -61,6 +66,9 @@ int main(int argc, char** argv){
       vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
       iren->SetRenderWindow(renWin);
       VISU_Convertor* aConvertor = CreateConvertor(argv[1]);
+      aConvertor->BuildEntities();
+      aConvertor->BuildFields();
+      aConvertor->BuildMinMax();
       const VISU::TMeshMap& aMeshMap = aConvertor->GetMeshMap();
       VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
       if(aMeshMapIter == aMeshMap.end()) return 0;
@@ -71,19 +79,22 @@ int main(int argc, char** argv){
       if(isOnlyMesh){
        const VISU::TEntity& anEntity = VISU::CELL_ENTITY;
        aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity);
-       vtkUnstructuredGrid* aDataSet = aConvertor->GetMeshOnEntity(aMeshName,anEntity);
-       
+
+       VISU::PIDMapper anIDMapper = 
+         aConvertor->GetMeshOnEntity(aMeshName,anEntity);
+       VISU::TVTKOutput* aDataSet = anIDMapper->GetVTKOutput();
+
        VISU_MeshPL* aPresent = VISU_MeshPL::New();
        aPresent->SetInput(aDataSet);
        aPresent->Build();
-       
+
        vtkActor* aActor = vtkActor::New();
        aActor->SetMapper(aPresent->GetMapper());
        aActor->GetProperty()->SetRepresentation(VTK_WIREFRAME);
        //ren->ResetCameraClippingRange();
-       
+
        ren->AddActor(aActor);
-       
+
        renWin->Render();
        iren->Start();
        return 0;
@@ -97,37 +108,57 @@ int main(int argc, char** argv){
        VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
        for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
          const VISU::PField aField = aFieldMapIter->second;
-         if(aField->myNbComp == 1) continue;
+         /*
+         if(aField->myNbComp == 1) 
+           continue;
+         */
          const string& aFieldName = aFieldMapIter->first;
          const VISU::TValField& aValField = aField->myValField;
          VISU::TValField::const_iterator aValFieldIter = aValField.begin();
          if(aValFieldIter == aValField.end()) return 0;
          int aTimeStamp = aValFieldIter->first;
-         vtkUnstructuredGrid* aDataSet = aConvertor->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
-         
+
          TPresent* aPresent = TPresent::New();
-         aPresent->SetInput(aDataSet);
+         VISU::PIDMapper anIDMapper;
+         if(anEntity != VISU::NODE_ENTITY){
+           VISU::PGaussPtsIDMapper aGaussPtsIDMapper = aConvertor->GetTimeStampOnGaussPts(aMeshName,anEntity,aFieldName,aTimeStamp);
+           aPresent->SetGaussPtsIDMapper(aGaussPtsIDMapper);
+         }else{
+           continue;
+           VISU::PIDMapper anIDMapper = aConvertor->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
+           aPresent->SetIDMapper(anIDMapper);
+         }
+
          aPresent->Build();
          aPresent->Init();
-         aPresent->SetSourceRange();
-         //aPresent->SetPartDefault(0);
-         //aPresent->SetScalarMin(0.01);
-         //aPresent->SetScaling(VTK_SCALE_LOG10);
+
+         char aMainTexture[80];
+         strcpy( aMainTexture, getenv( "VISU_ROOT_DIR" ) );
+         strcat( aMainTexture, "/share/salome/resources/sprite_texture.vti" );
+         //cout << aMainTexture << endl;
+
+         char anAlphaTexture[80];
+         strcpy( anAlphaTexture, getenv( "VISU_ROOT_DIR" ) );
+         strcat( anAlphaTexture, "/share/salome/resources/sprite_alpha.vti" );
+         //cout << anAlphaTexture << endl;
+
+         vtkSmartPointer<vtkImageData> aTextureValue = VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture );
+         aPresent->SetImageData( aTextureValue.GetPointer() );
+
          aPresent->Update();
-         
+
          vtkActor* anActor = vtkActor::New();
          anActor->SetMapper(aPresent->GetMapper());
-         
+
          VISU_ScalarBarActor * aScalarBar = VISU_ScalarBarActor::New();
          aScalarBar->SetLookupTable(aPresent->GetBarTable());
 
-         aPresent->Build();
-
          ren->AddActor(anActor);
          ren->AddActor2D(aScalarBar);
-         ren->ResetCameraClippingRange();
-         
+
          renWin->Render();
+         ren->ResetCamera();
+
          iren->Start();
          return 0;
        }
@@ -137,6 +168,6 @@ int main(int argc, char** argv){
     MESSAGE("Follow exception was occured :\n"<<exc.what());
   }catch(...){
     MESSAGE("Unknown exception was occured in VISU_Convertor_impl");
-  } 
+  }
   return 1;
 }