From cb67efe27c86cba7ecabdab6972633def9f8c258 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 22 Aug 2007 11:13:36 +0000 Subject: [PATCH] Join modifications from V3_2_0_maintainance (mergeto_BR_Dev_For_4_0_22May07 - T32x_16Aug2007_16h00m) --- src/CONVERTOR/Makefile.am | 2 + src/CONVERTOR/VISU_MergeFilter.hxx | 7 +- src/CONVERTOR/VISU_UsedPointsFilter.cxx | 108 ++++++++++++++++++ src/CONVERTOR/VISU_UsedPointsFilter.hxx | 46 ++++++++ src/PIPELINE/Makefile.am | 4 +- src/PIPELINE/VISU_MaskPointsFilter.cxx | 70 ++++++++++++ ...tsFilter.hxx => VISU_MaskPointsFilter.hxx} | 39 +++---- src/PIPELINE/VISU_PipeLineUtils.hxx | 16 --- src/PIPELINE/VISU_ScalarMapPL.cxx | 2 +- src/PIPELINE/VISU_ScalarMapPL.hxx | 2 +- src/PIPELINE/VISU_StreamLinesPL.cxx | 22 ++-- src/PIPELINE/VISU_StreamLinesPL.hxx | 13 ++- src/PIPELINE/VISU_UsedPointsFilter.cxx | 97 ---------------- src/PIPELINE/VISU_VectorsPL.cxx | 39 +++++-- src/PIPELINE/VISU_VectorsPL.hxx | 3 + src/VISUGUI/VISU_msg_en.po | 6 + src/VISUGUI/VisuGUI.cxx | 97 +++++++++++++--- src/VISUGUI/VisuGUI.h | 2 + src/VISUGUI/VisuGUI_ActionsDef.h | 1 + src/VISU_I/VISU_StreamLines_i.cc | 2 +- 20 files changed, 392 insertions(+), 186 deletions(-) create mode 100644 src/CONVERTOR/VISU_UsedPointsFilter.cxx create mode 100644 src/CONVERTOR/VISU_UsedPointsFilter.hxx create mode 100644 src/PIPELINE/VISU_MaskPointsFilter.cxx rename src/PIPELINE/{VISU_UsedPointsFilter.hxx => VISU_MaskPointsFilter.hxx} (61%) delete mode 100644 src/PIPELINE/VISU_UsedPointsFilter.cxx diff --git a/src/CONVERTOR/Makefile.am b/src/CONVERTOR/Makefile.am index b26b7f12..3176453e 100644 --- a/src/CONVERTOR/Makefile.am +++ b/src/CONVERTOR/Makefile.am @@ -43,6 +43,7 @@ salomeinclude_HEADERS= \ VISU_AppendPolyData.hxx \ VISU_AppendFilterUtilities.hxx \ VISU_ExtractUnstructuredGrid.hxx \ + VISU_UsedPointsFilter.hxx \ VISU_CommonCellsFilter.hxx \ VISUConvertor.hxx @@ -62,6 +63,7 @@ dist_libVisuConvertor_la_SOURCES= \ VISU_AppendFilterUtilities.cxx \ VISU_MergeFilter.cxx \ VISU_MergeFilterUtilities.cxx \ + VISU_UsedPointsFilter.cxx \ VISU_CommonCellsFilter.cxx libVisuConvertor_la_CPPFLAGS= \ diff --git a/src/CONVERTOR/VISU_MergeFilter.hxx b/src/CONVERTOR/VISU_MergeFilter.hxx index 26a31a5e..09981c9b 100644 --- a/src/CONVERTOR/VISU_MergeFilter.hxx +++ b/src/CONVERTOR/VISU_MergeFilter.hxx @@ -31,7 +31,8 @@ #include "VISU_Convertor.hxx" -#include +//#include +#include namespace VISU { @@ -40,11 +41,11 @@ namespace VISU //------------------------------------------------------------------------------ -class VISU_CONVERTOR_EXPORT VISU_MergeFilter : public vtkDataSetAlgorithm +class VISU_CONVERTOR_EXPORT VISU_MergeFilter : public vtkPointSetAlgorithm { public: static VISU_MergeFilter *New(); - vtkTypeMacro(VISU_MergeFilter, vtkDataSetAlgorithm); + vtkTypeMacro(VISU_MergeFilter, vtkPointSetAlgorithm); // Description: // Specify object from which to extract geometry information. diff --git a/src/CONVERTOR/VISU_UsedPointsFilter.cxx b/src/CONVERTOR/VISU_UsedPointsFilter.cxx new file mode 100644 index 00000000..8392385f --- /dev/null +++ b/src/CONVERTOR/VISU_UsedPointsFilter.cxx @@ -0,0 +1,108 @@ +// VISU CONVERTOR : +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_UsedPointsFilter.cxx +// Author : +// Module : VISU + + +#include "VISU_UsedPointsFilter.hxx" + +#include +#include +#include +#include +#include +#include + +#include + +vtkStandardNewMacro(VISU_UsedPointsFilter); + + +VISU_UsedPointsFilter::VISU_UsedPointsFilter() +{ +} + +VISU_UsedPointsFilter::~VISU_UsedPointsFilter() +{ +} + +void VISU_UsedPointsFilter::Execute(){ + vtkDataSet *anInput = this->GetInput(); + vtkUnstructuredGrid *anOutput = this->GetOutput(); + + typedef std::map TId2IdMap; + TId2IdMap aId2IdMap; + + vtkPointData *aPointData = anOutput->GetPointData(); + aPointData->CopyAllocate(anInput->GetPointData()); + + vtkPoints* aUsedPoints = vtkPoints::New(); + vtkIdList *anIdList = vtkIdList::New(); + vtkIdType iEnd = anInput->GetNumberOfPoints(); + for(vtkIdType aPointId = 0; aPointId < iEnd; aPointId++){ + anInput->GetPointCells(aPointId,anIdList); + if(anIdList->GetNumberOfIds() > 0){ + vtkIdType aNewPointId = aUsedPoints->InsertNextPoint(anInput->GetPoint(aPointId)); + aPointData->CopyData(anInput->GetPointData(), aPointId, aNewPointId); + aId2IdMap[aPointId] = aNewPointId; + } + } + aPointData->Squeeze(); + anOutput->SetPoints(aUsedPoints); + aUsedPoints->Delete(); + anIdList->Delete(); + + vtkCellData *aCellData = anOutput->GetCellData(); + aCellData->CopyAllocate(anInput->GetCellData()); + + anOutput->Allocate(anInput->GetNumberOfCells()); + vtkIdList *anOldPointsIds = vtkIdList::New(); + vtkIdList *aNewPointsIds = vtkIdList::New(); + aNewPointsIds->Allocate(VTK_CELL_SIZE); + iEnd = anInput->GetNumberOfCells(); + for(vtkIdType aCellId = 0; aCellId < iEnd; aCellId++){ + anInput->GetCellPoints(aCellId, anOldPointsIds); + vtkIdType aNbPointsInCell = anOldPointsIds->GetNumberOfIds(); + aNewPointsIds->Reset(); + for(vtkIdType i = 0; i < aNbPointsInCell; i++){ + vtkIdType anOldId = anOldPointsIds->GetId(i); + TId2IdMap::iterator anIter = aId2IdMap.find(anOldId); + if(anIter == aId2IdMap.end()) + goto NEXT_CELL; + vtkIdType aNewId = anIter->second; + aNewPointsIds->InsertNextId(aNewId); + } + { + vtkIdType aNewCellId = anOutput->InsertNextCell(anInput->GetCellType(aCellId), aNewPointsIds); + aCellData->CopyData(anInput->GetCellData(), aCellId, aNewCellId); + } + NEXT_CELL: + continue; + } + aCellData->Squeeze(); + anOldPointsIds->Delete(); + aNewPointsIds->Delete(); + anOutput->Squeeze(); +} + diff --git a/src/CONVERTOR/VISU_UsedPointsFilter.hxx b/src/CONVERTOR/VISU_UsedPointsFilter.hxx new file mode 100644 index 00000000..a6e082f2 --- /dev/null +++ b/src/CONVERTOR/VISU_UsedPointsFilter.hxx @@ -0,0 +1,46 @@ +// VISU CONVERTOR : +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_UsedPointsFilter.hxx +// Author : +// Module : VISU + +#ifndef VISU_UsedPointsFilter_HeaderFile +#define VISU_UsedPointsFilter_HeaderFile + +#include + +class VISU_UsedPointsFilter : public vtkDataSetToUnstructuredGridFilter +{ +public: + vtkTypeMacro(VISU_UsedPointsFilter,vtkDataSetToUnstructuredGridFilter); + static VISU_UsedPointsFilter *New(); + +protected: + VISU_UsedPointsFilter(); + ~VISU_UsedPointsFilter(); + + virtual void Execute(); +}; + +#endif + diff --git a/src/PIPELINE/Makefile.am b/src/PIPELINE/Makefile.am index 9c291cf8..bb169513 100644 --- a/src/PIPELINE/Makefile.am +++ b/src/PIPELINE/Makefile.am @@ -49,7 +49,7 @@ salomeinclude_HEADERS= \ VISU_ScalarBarActor.hxx \ VISU_Extractor.hxx \ VISU_FieldTransform.hxx \ - VISU_UsedPointsFilter.hxx \ + VISU_MaskPointsFilter.hxx \ VISU_GaussPointsPL.hxx \ VISU_Plot3DPL.hxx \ VISU_OpenGLPointSpriteMapper.hxx \ @@ -84,7 +84,7 @@ dist_libVisuPipeLine_la_SOURCES= \ VISU_ScalarBarActor.cxx \ VISU_Extractor.cxx \ VISU_FieldTransform.cxx \ - VISU_UsedPointsFilter.cxx \ + VISU_MaskPointsFilter.cxx \ VISU_GaussPointsPL.cxx \ VISU_Plot3DPL.cxx \ SALOME_ExtractGeometry.cxx \ diff --git a/src/PIPELINE/VISU_MaskPointsFilter.cxx b/src/PIPELINE/VISU_MaskPointsFilter.cxx new file mode 100644 index 00000000..c879e29c --- /dev/null +++ b/src/PIPELINE/VISU_MaskPointsFilter.cxx @@ -0,0 +1,70 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: VISU_StreamLinesPL.cxx +// Author: Alexey PETROV +// Module : VISU + + +#include "VISU_MaskPointsFilter.hxx" + +#include +#include +#include +#include +#include +#include + +vtkStandardNewMacro(VISU_MaskPointsFilter); + +VISU_MaskPointsFilter::VISU_MaskPointsFilter(){ + PercentsOfUsedPoints = 1.0; +} + +VISU_MaskPointsFilter::~VISU_MaskPointsFilter(){} + +void VISU_MaskPointsFilter::Execute(){ + vtkPointSet *anInput = this->GetInput(), *anOutput = this->GetOutput(); + anOutput->GetPointData()->CopyAllOff(); + anOutput->GetCellData()->CopyAllOff(); + anOutput->CopyStructure(anInput); + + vtkPoints* aPoints = vtkPoints::New(); + vtkIdList *anIdList = vtkIdList::New(); + vtkIdType iEnd = anInput->GetNumberOfPoints(); + for(vtkIdType i = 0; i < iEnd; i++){ + anInput->GetPointCells(i,anIdList); + if(anIdList->GetNumberOfIds() > 0) + aPoints->InsertNextPoint(anInput->GetPoint(i)); + } + vtkPoints* aNewPoints = vtkPoints::New(); + iEnd = aPoints->GetNumberOfPoints(); + if (PercentsOfUsedPoints > 0){ + vtkIdType anOffset = vtkIdType(1.0/PercentsOfUsedPoints); + if(anOffset < 1) anOffset = 1; + for(vtkIdType i = 0; i < iEnd; i += anOffset) + aNewPoints->InsertNextPoint(aPoints->GetPoint(i)); + } + anOutput->SetPoints(aNewPoints); + aNewPoints->Delete(); + aPoints->Delete(); +} diff --git a/src/PIPELINE/VISU_UsedPointsFilter.hxx b/src/PIPELINE/VISU_MaskPointsFilter.hxx similarity index 61% rename from src/PIPELINE/VISU_UsedPointsFilter.hxx rename to src/PIPELINE/VISU_MaskPointsFilter.hxx index 380e0fc9..38d87923 100644 --- a/src/PIPELINE/VISU_UsedPointsFilter.hxx +++ b/src/PIPELINE/VISU_MaskPointsFilter.hxx @@ -17,42 +17,33 @@ // 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // -// File: VISU_UsedPointsFilter.hxx +// File: VISU_MaskPointsFilter.hxx // Author: Alexey PETROV // Module : VISU -#ifndef VISU_UsedPointsFilter_HeaderFile -#define VISU_UsedPointsFilter_HeaderFile +#ifndef VISU_MaskPointsFilter_HeaderFile +#define VISU_MaskPointsFilter_HeaderFile -#include +#include +class VISU_MaskPointsFilter : public vtkPointSetToPointSetFilter{ +protected: + VISU_MaskPointsFilter(); + VISU_MaskPointsFilter(const VISU_MaskPointsFilter&); -//---------------------------------------------------------------------------- -class VISU_UsedPointsFilter : public vtkPointSetAlgorithm -{ -public: - vtkTypeMacro(VISU_UsedPointsFilter, vtkPointSetAlgorithm); + virtual void Execute(); + float PercentsOfUsedPoints; - static - VISU_UsedPointsFilter* - New(); +public: + vtkTypeMacro(VISU_MaskPointsFilter,vtkPointSetToPointSetFilter); + static VISU_MaskPointsFilter* New(); + virtual ~VISU_MaskPointsFilter(); vtkSetMacro(PercentsOfUsedPoints,float); vtkGetMacro(PercentsOfUsedPoints,float); - -protected: - VISU_UsedPointsFilter(); - VISU_UsedPointsFilter(const VISU_UsedPointsFilter&); - - virtual - ~VISU_UsedPointsFilter(); - - int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); - - float PercentsOfUsedPoints; }; #endif diff --git a/src/PIPELINE/VISU_PipeLineUtils.hxx b/src/PIPELINE/VISU_PipeLineUtils.hxx index 2fcb4bca..65909900 100644 --- a/src/PIPELINE/VISU_PipeLineUtils.hxx +++ b/src/PIPELINE/VISU_PipeLineUtils.hxx @@ -88,22 +88,6 @@ namespace VISU theOutputFilter->SetInput(theDataSet); } - //---------------------------------------------------------------------------- - template - void - ToCellCenters(TOutputFilter* theOutputFilter, - vtkCellCenters *theCellCenters, - vtkDataSet* theDataSet) - - { - if(VISU::IsDataOnCells(theDataSet)){ - theCellCenters->SetInput(theDataSet); - theCellCenters->VertexCellsOn(); - theOutputFilter->SetInput(theCellCenters->GetOutput()); - }else - theOutputFilter->SetInput(theDataSet); - } - //---------------------------------------------------------------------------- //! Checks whether the float values are the same or not bool VISU_PIPELINE_EXPORT diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index 2856a298..a4df7b39 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -212,7 +212,7 @@ VISU_ScalarMapPL //---------------------------------------------------------------------------- -vtkDataSet* +vtkPointSet* VISU_ScalarMapPL ::GetMergedInput() { diff --git a/src/PIPELINE/VISU_ScalarMapPL.hxx b/src/PIPELINE/VISU_ScalarMapPL.hxx index 13020793..eda0bea1 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.hxx +++ b/src/PIPELINE/VISU_ScalarMapPL.hxx @@ -77,7 +77,7 @@ public: //---------------------------------------------------------------------------- virtual - vtkDataSet* + vtkPointSet* GetMergedInput(); protected: diff --git a/src/PIPELINE/VISU_StreamLinesPL.cxx b/src/PIPELINE/VISU_StreamLinesPL.cxx index 97d9abfb..375d99ac 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.cxx +++ b/src/PIPELINE/VISU_StreamLinesPL.cxx @@ -26,13 +26,15 @@ #include "VISU_StreamLinesPL.hxx" -#include "VISU_Extractor.hxx" -#include "VISU_FieldTransform.hxx" -#include "VISU_UsedPointsFilter.hxx" -#include "VTKViewer_GeometryFilter.h" +#include "VISU_Extractor.hxx" +//#include "VISU_FieldTransform.hxx" +//#include "VISU_UsedPointsFilter.hxx" +#include "VISU_MaskPointsFilter.hxx" #include "VISU_PipeLineUtils.hxx" +#include "VTKViewer_GeometryFilter.h" + #include #include @@ -64,7 +66,7 @@ VISU_StreamLinesPL myStream = vtkStreamLine::New(); myCenters = vtkCellCenters::New(); myGeomFilter = VTKViewer_GeometryFilter::New(); - myPointsFilter = VISU_UsedPointsFilter::New(); + myPointsFilter = VISU_MaskPointsFilter::New(); myPercents = 0.3; mySource = NULL; } @@ -184,11 +186,11 @@ VISU_StreamLinesPL ::SetParams(vtkFloatingPointType theIntStep, vtkFloatingPointType thePropogationTime, vtkFloatingPointType theStepLength, - vtkDataSet* theSource, + vtkPointSet* theSource, vtkFloatingPointType thePercents, int theDirection) { - vtkDataSet* aDataSet = theSource? theSource: GetMergedInput(); + vtkPointSet* aDataSet = theSource? theSource: GetMergedInput(); aDataSet->Update(); vtkIdType aNbOfPoints = aDataSet->GetNumberOfPoints(); @@ -236,7 +238,7 @@ VISU_StreamLinesPL //---------------------------------------------------------------------------- -vtkDataSet* +vtkPointSet* VISU_StreamLinesPL ::GetSource() { @@ -288,12 +290,12 @@ VISU_StreamLinesPL //---------------------------------------------------------------------------- size_t VISU_StreamLinesPL -::IsPossible(vtkDataSet* theDataSet, +::IsPossible(vtkPointSet* theDataSet, vtkFloatingPointType thePercents) { vtkFloatingPointType aStepLength = GetBaseStepLength(theDataSet); vtkFloatingPointType aBasePropTime = GetBasePropagationTime(theDataSet); - VISU_UsedPointsFilter *aPointsFilter = VISU_UsedPointsFilter::New(); + VISU_MaskPointsFilter *aPointsFilter = VISU_MaskPointsFilter::New(); aPointsFilter->SetInput(theDataSet); vtkDataSet* aDataSet = aPointsFilter->GetOutput(); aDataSet->Update(); diff --git a/src/PIPELINE/VISU_StreamLinesPL.hxx b/src/PIPELINE/VISU_StreamLinesPL.hxx index ed762a9b..7909b760 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.hxx +++ b/src/PIPELINE/VISU_StreamLinesPL.hxx @@ -32,9 +32,10 @@ #include class vtkDataSet; +class vtkPointSet; class vtkCellCenters; class VTKViewer_GeometryFilter; -class VISU_UsedPointsFilter; +class VISU_MaskPointsFilter; //---------------------------------------------------------------------------- @@ -52,12 +53,12 @@ public: SetParams(vtkFloatingPointType theIntStep, vtkFloatingPointType thePropogationTime, vtkFloatingPointType theStepLength, - vtkDataSet* theSource = NULL, + vtkPointSet* theSource = NULL, vtkFloatingPointType thePercents = 0.3, int theDirection = VTK_INTEGRATE_BOTH_DIRECTIONS); virtual - vtkDataSet* + vtkPointSet* GetSource(); virtual @@ -186,7 +187,7 @@ public: static size_t - IsPossible(vtkDataSet* theDataSet, + IsPossible(vtkPointSet* theDataSet, vtkFloatingPointType thePercents = 0.3); protected: @@ -232,10 +233,10 @@ protected: vtkDataSet* theDataSet); vtkStreamLine* myStream; - vtkDataSet* mySource; + vtkPointSet* mySource; vtkCellCenters* myCenters; VTKViewer_GeometryFilter *myGeomFilter; - VISU_UsedPointsFilter *myPointsFilter; + VISU_MaskPointsFilter *myPointsFilter; vtkFloatingPointType myPercents; }; diff --git a/src/PIPELINE/VISU_UsedPointsFilter.cxx b/src/PIPELINE/VISU_UsedPointsFilter.cxx deleted file mode 100644 index b88d18ed..00000000 --- a/src/PIPELINE/VISU_UsedPointsFilter.cxx +++ /dev/null @@ -1,97 +0,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.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// -// File: VISU_StreamLinesPL.cxx -// Author: Alexey PETROV -// Module : VISU - - -#include "VISU_UsedPointsFilter.hxx" - -#include "VISU_ConvertorUtils.hxx" - -#include -#include -#include -#include -#include -#include - -#include -#include - - -//---------------------------------------------------------------------------- -vtkStandardNewMacro(VISU_UsedPointsFilter); - - -//---------------------------------------------------------------------------- -VISU_UsedPointsFilter::VISU_UsedPointsFilter() -{ - PercentsOfUsedPoints = 1.0; -} - -//---------------------------------------------------------------------------- -VISU_UsedPointsFilter::~VISU_UsedPointsFilter() -{} - - -//---------------------------------------------------------------------------- -int VISU_UsedPointsFilter::RequestData (vtkInformation *vtkNotUsed(request), - vtkInformationVector **inputVector, - vtkInformationVector *outputVector) -{ - // get the info objects - vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); - vtkInformation *outInfo = outputVector->GetInformationObject(0); - - // get the input and ouptut - vtkDataSet *input = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); - vtkPointSet *output = vtkPointSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); - - ////////// - output->GetPointData()->CopyAllOff(); - output->GetCellData()->CopyAllOff(); - output->CopyStructure(input); - - vtkPoints* aPoints = vtkPoints::New(); - vtkIdList *anIdList = vtkIdList::New(); - vtkIdType iEnd = input->GetNumberOfPoints(); - for (vtkIdType i = 0; i < iEnd; i++) { - input->GetPointCells(i, anIdList); - if (anIdList->GetNumberOfIds() > 0) - aPoints->InsertNextPoint(input->GetPoint(i)); - } - vtkPoints* aNewPoints = vtkPoints::New(); - iEnd = aPoints->GetNumberOfPoints(); - if (PercentsOfUsedPoints > 0) { - vtkIdType anOffset = vtkIdType(1.0/PercentsOfUsedPoints); - if (anOffset < 1) anOffset = 1; - for (vtkIdType i = 0; i < iEnd; i += anOffset) - aNewPoints->InsertNextPoint(aPoints->GetPoint(i)); - } - output->SetPoints(aNewPoints); - aNewPoints->Delete(); - aPoints->Delete(); - - return 1; -} diff --git a/src/PIPELINE/VISU_VectorsPL.cxx b/src/PIPELINE/VISU_VectorsPL.cxx index 36a3014f..73153dfc 100644 --- a/src/PIPELINE/VISU_VectorsPL.cxx +++ b/src/PIPELINE/VISU_VectorsPL.cxx @@ -28,6 +28,7 @@ #include "VISU_VectorsPL.hxx" #include "VISU_FieldTransform.hxx" #include "VISU_PipeLineUtils.hxx" +#include "VISU_UsedPointsFilter.hxx" #include "VTKViewer_TransformFilter.h" #include "VTKViewer_Transform.h" @@ -41,8 +42,24 @@ //---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_VectorsPL); - //---------------------------------------------------------------------------- +template +void ToCellCenters(TOutputFilter *theOutputFilter, + vtkCellCenters *theCellCenters, + vtkDataSet* theDataSet, + VISU_UsedPointsFilter* theUsedPointsFilter) +{ + if(VISU::IsDataOnCells(theDataSet)){ + theCellCenters->SetInput(theDataSet); + theCellCenters->VertexCellsOn(); + theOutputFilter->SetInput(theCellCenters->GetOutput()); + }else { + theUsedPointsFilter->SetInput(theDataSet); + theOutputFilter->SetInput(theUsedPointsFilter->GetOutput()); + } +} + + VISU_VectorsPL ::VISU_VectorsPL() { @@ -57,6 +74,8 @@ VISU_VectorsPL myCenters = vtkCellCenters::New(); myTransformFilter = VTKViewer_TransformFilter::New(); + + myUsedPointsFilter = VISU_UsedPointsFilter::New(); } @@ -76,6 +95,8 @@ VISU_VectorsPL myLineSource->Delete(); myTransformFilter->Delete(); + + myUsedPointsFilter->Delete(); } @@ -202,17 +223,19 @@ VISU_VectorsPL ::Build() { Superclass::Build(); - - VISU::ToCellCenters(myBaseGlyph, - myCenters, - GetMergedInput()); + + ToCellCenters(myBaseGlyph, + myCenters, + GetMergedInput(), + myUsedPointsFilter); myBaseGlyph->SetVectorModeToUseVector(); myBaseGlyph->SetScaleModeToScaleByVector(); myBaseGlyph->SetColorModeToColorByScalar(); - VISU::ToCellCenters(myTransformFilter, - myCenters, - GetMergedInput()); + ToCellCenters(myTransformFilter, + myCenters, + GetMergedInput(), + myUsedPointsFilter); myTransformedGlyph->SetInput(myTransformFilter->GetOutput()); myTransformedGlyph->SetVectorModeToUseVector(); myTransformedGlyph->SetScaleModeToScaleByVector(); diff --git a/src/PIPELINE/VISU_VectorsPL.hxx b/src/PIPELINE/VISU_VectorsPL.hxx index cbdcd300..9bf2a43c 100644 --- a/src/PIPELINE/VISU_VectorsPL.hxx +++ b/src/PIPELINE/VISU_VectorsPL.hxx @@ -40,6 +40,7 @@ class vtkLineSource; class vtkGlyph3D; +class VISU_UsedPointsFilter; //---------------------------------------------------------------------------- class VISU_PIPELINE_EXPORT VISU_VectorsPL : public VISU_DeformedShapePL @@ -139,6 +140,8 @@ protected: vtkCellCenters* myCenters; VTKViewer_TransformFilter *myTransformFilter; + + VISU_UsedPointsFilter* myUsedPointsFilter; }; diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 6478722c..19b1cc9a 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -34,6 +34,9 @@ msgstr "Warning" msgid "INF_DONE" msgstr " done" +msgid "INF_FAILED" +msgstr " failed!" + msgid "WRN_STUDY_LOCKED" msgstr "Current Study is locked" @@ -440,6 +443,9 @@ msgstr "Import TimeStamp" msgid "VisuGUI::MEN_IMPORT_MED_FIELD" msgstr "Import Field" +msgid "VisuGUI::MEN_LOAD_COMPONENT_DATA" +msgstr "Load Component Data" + msgid "VisuGUI::MEN_DELETE_OBJS" msgstr "Delete" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 7955acb0..9e512fe4 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -405,11 +405,9 @@ VisuGUI // The same in SUPERVISION: NPAL14522 { SALOMEDS::SComponent_ptr aSComp = aSObject->GetFatherComponent(); - //std::string aCompIOR; CORBA::String_var aCompIOR; if (!aSComp->ComponentIOR(aCompIOR)) { // not loaded CORBA::String_var aCompDataType = aSComp->ComponentDataType(); - //std::string aCompDataType = aSComp->ComponentDataType(); // obtain a driver by a component data type // like it is done in SALOMEDS_DriverFactory_i::GetDriverByType @@ -417,10 +415,8 @@ VisuGUI SALOME_LifeCycleCORBA * LCC = getApp()->lcc(); try { CORBA::Object_var - //anEngineObj = LCC->FindOrLoad_Component("FactoryServer", aCompDataType.c_str()); anEngineObj = LCC->FindOrLoad_Component("FactoryServer", aCompDataType); if (CORBA::is_nil(anEngineObj)) - //anEngineObj = LCC->FindOrLoad_Component("FactoryServerPy", aCompDataType.c_str()); anEngineObj = LCC->FindOrLoad_Component("FactoryServerPy", aCompDataType); if (!CORBA::is_nil(anEngineObj)) @@ -429,7 +425,6 @@ VisuGUI if (!CORBA::is_nil(anEngine)) { // try to load SALOMEDS::StudyBuilder_ptr aStudyBuilder = aStudy->NewBuilder(); - //aStudyBuilder->LoadWith(aSComp, aDriverIOR.in()); aStudyBuilder->LoadWith(aSComp, anEngine); } } @@ -461,6 +456,67 @@ VisuGUI QApplication::restoreOverrideCursor(); } +void VisuGUI::OnLoadComponentData() +{ + _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); + if (CheckLock(aCStudy,GetDesktop(this))) + return; + SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy); + + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + SALOME_ListIO aListIO; + aSelectionMgr->selectedObjects(aListIO); + + SALOME_ListIteratorOfListIO It (aListIO); + QApplication::setOverrideCursor(Qt::waitCursor); + for (; It.More(); It.Next()) { + Handle(SALOME_InteractiveObject) anIO = It.Value(); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry()); + if (!aSObject->_is_nil()) { + + // try to load a component data from an opened (presumably) study + // The same in SUPERVISION: NPAL14522 + { + SALOMEDS::SComponent_ptr aSComp = aSObject->GetFatherComponent(); + CORBA::String_var aCompIOR; + if (!aSComp->ComponentIOR(aCompIOR)) { // not loaded + CORBA::String_var aCompDataType = aSComp->ComponentDataType(); + + QString anInfo ("Loading "); + anInfo = anInfo + aCompDataType.in() + " Component Data ..."; + application()->putInfo( anInfo ); + + // obtain a driver by a component data type + // like it is done in SALOMEDS_DriverFactory_i::GetDriverByType + SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_nil(); + SALOME_LifeCycleCORBA * LCC = getApp()->lcc(); + try { + CORBA::Object_var + anEngineObj = LCC->FindOrLoad_Component("FactoryServer", aCompDataType); + if (CORBA::is_nil(anEngineObj)) + anEngineObj = LCC->FindOrLoad_Component("FactoryServerPy", aCompDataType); + + if (!CORBA::is_nil(anEngineObj)) + anEngine = SALOMEDS::Driver::_narrow(anEngineObj); + + if (!CORBA::is_nil(anEngine)) { + // try to load + SALOMEDS::StudyBuilder_ptr aStudyBuilder = aStudy->NewBuilder(); + aStudyBuilder->LoadWith(aSComp, anEngine); + } + + application()->putInfo( anInfo + tr("INF_DONE")); + } + catch (...) { + application()->putInfo( anInfo + tr("INF_FAILED")); + } + } + } + } + } + QApplication::restoreOverrideCursor(); +} + void CreateCurves( SalomeApp_Module* theModule, VISU::CutLines_i* thePrs, @@ -2059,6 +2115,10 @@ VisuGUI tr("MEN_IMPORT_MED_FIELD"), "", 0, aParent, false, this, SLOT(OnImportMedField())); + createAction( VISU_LOAD_COMPONENT_DATA, tr("MEN_LOAD_COMPONENT_DATA"), QIconSet(), + tr("MEN_LOAD_COMPONENT_DATA"), "", 0, aParent, false, + this, SLOT(OnLoadComponentData())); + createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(), tr("MEN_CREATE_PRS"), "", 0, aParent, false, this, SLOT(OnCreateMesh())); @@ -2782,6 +2842,14 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q if (aListIO.Extent() != 1) return; + // Check if the object's data is loaded + _PTR(SComponent) aSComp = aSObject->GetFatherComponent(); + std::string aCompIOR; + if (!aSComp->ComponentIOR(aCompIOR)) { // not loaded + //std::string aCompDataType = aSComp->ComponentDataType(); + action( VISU_LOAD_COMPONENT_DATA )->addTo(theMenu); // "Load Component Data" + } + VISU::VISUType aType = VISU::Storable::RestoringMap2Type( aMap ); if (aType == VISU::TANIMATION) { action( VISU_SHOW_ANIMATION )->addTo(theMenu); @@ -2796,24 +2864,19 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q if (!CORBA::is_nil(anObject)) { SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject); if (!CORBA::is_nil(aMED.in())) { - action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu); + action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu); // "Import Structure" } - SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); // "Import Structure" + SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); if (!CORBA::is_nil(aField)) { action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp" } } else { - _PTR(SObject) aSFather = aSObject->GetFather(); - if (aSFather) { - _PTR(GenericAttribute) anAttr; - aSFather->FindAttribute(anAttr, "AttributeName"); - if (anAttr) { - _PTR(AttributeName) aName (anAttr); - std::string aValue = aName->Value(); - if (strcmp(aValue.c_str(), "MEDFIELD") == 0) { - action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field" - } + _PTR(SObject) aSFather1 = aSObject->GetFather(); + if (aSFather1) { + std::string aValue = aSFather1->GetName(); + if (strcmp(aValue.c_str(), "MEDFIELD") == 0) { + action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field" } } } diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 50be5f8d..b5a5bfeb 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -91,6 +91,8 @@ protected slots: void OnExportTableToFile(); void OnImportMedField(); + void OnLoadComponentData(); + void OnCreateMesh(); void OnCreateScalarMap(); void OnCreateDeformedShape(); diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 33e2a811..40ef7783 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -28,6 +28,7 @@ #define VISU_IMPORT_MED_STRUCTURE 4004 #define VISU_IMPORT_MED_TIMESTAMP 4005 #define VISU_IMPORT_MED_FIELD 4006 +#define VISU_LOAD_COMPONENT_DATA 4007 #define VISU_SCALAR_MAP 4011 #define VISU_DEFORMED_SHAPE 4012 diff --git a/src/VISU_I/VISU_StreamLines_i.cc b/src/VISU_I/VISU_StreamLines_i.cc index 86f4cbe0..62757e1c 100644 --- a/src/VISU_I/VISU_StreamLines_i.cc +++ b/src/VISU_I/VISU_StreamLines_i.cc @@ -252,7 +252,7 @@ VISU::StreamLines_i Execute() { myPrs3dServant = NULL; - vtkDataSet* aSource = NULL; + vtkPointSet* aSource = NULL; if (!CORBA::is_nil(myPrs3d)){ myPrs3dServant = dynamic_cast(VISU::GetServant(myPrs3d).in()); if(myPrs3dServant){ -- 2.39.2