]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Recover the executable after wrong commitment
authorapo <apo@opencascade.com>
Thu, 1 Dec 2005 09:44:07 +0000 (09:44 +0000)
committerapo <apo@opencascade.com>
Thu, 1 Dec 2005 09:44:07 +0000 (09:44 +0000)
src/PIPELINE/VISUPipeLine.cxx

index cfcb1141d5e54ae60e815111efff17969ad851c3..115a5539bf0f71b07cd1fc9eca63e22e18d43da8 100644 (file)
-////////////////////////////////////////////////////////////////////
-#include<stdio.h>
-//
-//====================================================================
-// function: main
-// purpose:
-//====================================================================
-int main( int argc, char *argv[] )
-{
-  return 0;
+//  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.hxx
+// Author:  Alexey PETROV
+// Module : VISU
+
+#include "VISU_Convertor.hxx"
+#include "VISU_MeshPL.hxx"
+#include "VISU_ScalarMapPL.hxx"
+#include "VISU_IsoSurfacesPL.hxx"
+#include "VISU_CutPlanesPL.hxx"
+#include "VISU_CutLinesPL.hxx"
+#include "VISU_DeformedShapePL.hxx"
+#include "VISU_VectorsPL.hxx"
+#include "VISU_StreamLinesPL.hxx"
+#include "VISU_GaussPointsPL.hxx"
+#include "VISU_Plot3DPL.hxx"
+
+typedef VISU_GaussPointsPL TPresent;
+
+#include <vtkUnstructuredGrid.h>
+#include <vtkDataSetMapper.h>
+
+#include <vtkRenderWindowInteractor.h>
+#include <vtkRenderWindow.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){
+  try{
+    if(argc > 1){
+      vtkRenderWindow *renWin = vtkRenderWindow::New();
+      vtkRenderer *ren = vtkRenderer::New();
+      renWin->AddRenderer(ren);
+      ren->GetActiveCamera()->ParallelProjectionOn();
+      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;
+      const string& aMeshName = aMeshMapIter->first;
+      const VISU::PMesh aMesh = aMeshMapIter->second;
+      const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+      VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
+      if(isOnlyMesh){
+       const VISU::TEntity& anEntity = VISU::CELL_ENTITY;
+       aMeshOnEntityMapIter = aMeshOnEntityMap.find(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;
+      }
+      //Import fields
+      aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
+      for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++) {
+       const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
+       const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
+       const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+       VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
+       for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
+         const VISU::PField aField = aFieldMapIter->second;
+         /*
+         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;
+
+         TPresent* aPresent = TPresent::New();
+         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();
+
+         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;
+
+         aPresent->SetImageData( VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture ) );
+
+         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);
+
+         renWin->Render();
+         ren->ResetCamera();
+
+         iren->Start();
+         return 0;
+       }
+      }
+    }
+  }catch(std::exception& exc){
+    MESSAGE("Follow exception was occured :\n"<<exc.what());
+  }catch(...){
+    MESSAGE("Unknown exception was occured in VISU_Convertor_impl");
+  }
+  return 1;
 }