From e98b9871ae5331028b53c10c53f83e95009a1bd9 Mon Sep 17 00:00:00 2001 From: enk Date: Mon, 3 Dec 2007 08:23:05 +0000 Subject: [PATCH] Bug NPAL15851 EDF PAL 408: Gauss Points: "Build Presentation on Groups" Feature --- src/CONVERTOR/Makefile.am | 6 +- src/CONVERTOR/VISU_GaussMergeFilter.cxx | 386 ++++++++++++++++++++ src/CONVERTOR/VISU_GaussMergeFilter.hxx | 138 +++++++ src/CONVERTOR/VISU_MergeFilterUtilities.cxx | 274 ++++++-------- src/CONVERTOR/VISU_MergeFilterUtilities.hxx | 66 +++- src/PIPELINE/VISU_ColoredPL.cxx | 9 + src/PIPELINE/VISU_ColoredPL.hxx | 31 ++ src/PIPELINE/VISU_GaussPointsPL.cxx | 109 +++++- src/PIPELINE/VISU_GaussPointsPL.hxx | 40 ++ src/PIPELINE/VISU_ScalarMapPL.cxx | 11 - src/VISUGUI/VisuGUI_InputPane.cxx | 23 +- src/VISU_I/VISU_ColoredPrs3d_i.cc | 42 +++ src/VISU_I/VISU_ColoredPrs3d_i.hh | 32 ++ src/VISU_I/VISU_DumpPython.cc | 13 +- src/VISU_I/VISU_GaussPoints_i.cc | 48 +++ src/VISU_I/VISU_GaussPoints_i.hh | 16 + src/VISU_I/VISU_ScalarMap_i.cc | 42 --- src/VISU_I/VISU_ScalarMap_i.hh | 11 - 18 files changed, 1050 insertions(+), 247 deletions(-) create mode 100644 src/CONVERTOR/VISU_GaussMergeFilter.cxx create mode 100644 src/CONVERTOR/VISU_GaussMergeFilter.hxx diff --git a/src/CONVERTOR/Makefile.am b/src/CONVERTOR/Makefile.am index a8df0bb0..f0782c7c 100644 --- a/src/CONVERTOR/Makefile.am +++ b/src/CONVERTOR/Makefile.am @@ -45,7 +45,8 @@ salomeinclude_HEADERS= \ VISU_ExtractUnstructuredGrid.hxx \ VISU_UsedPointsFilter.hxx \ VISU_CommonCellsFilter.hxx \ - VISUConvertor.hxx + VISUConvertor.hxx \ + VISU_GaussMergeFilter.hxx dist_libVisuConvertor_la_SOURCES= \ VISU_IDMapper.cxx \ @@ -64,7 +65,8 @@ dist_libVisuConvertor_la_SOURCES= \ VISU_MergeFilter.cxx \ VISU_MergeFilterUtilities.cxx \ VISU_UsedPointsFilter.cxx \ - VISU_CommonCellsFilter.cxx + VISU_CommonCellsFilter.cxx \ + VISU_GaussMergeFilter.cxx libVisuConvertor_la_CPPFLAGS= \ -ftemplate-depth-32 \ diff --git a/src/CONVERTOR/VISU_GaussMergeFilter.cxx b/src/CONVERTOR/VISU_GaussMergeFilter.cxx new file mode 100644 index 00000000..a27a1f4c --- /dev/null +++ b/src/CONVERTOR/VISU_GaussMergeFilter.cxx @@ -0,0 +1,386 @@ +// SALOME VTKViewer : build VTK viewer into Salome desktop +// +// 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 : +// Author : +// Module : SALOME +// $Header$ + +#include "VISU_GaussMergeFilter.hxx" +#include "VISU_MergeFilterUtilities.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + + +//------------------------------------------------------------------------------ +vtkStandardNewMacro(VISU_GaussMergeFilter); + +//------------------------------------------------------------------------------ +VISU_GaussMergeFilter +::VISU_GaussMergeFilter(): + myIsMergingInputs(false) +{ + this->FieldList = new VISU::TFieldList; + this->SetNumberOfInputPorts(6); +} + +//------------------------------------------------------------------------------ +VISU_GaussMergeFilter::~VISU_GaussMergeFilter() +{ + delete this->FieldList; +} + +//------------------------------------------------------------------------------ +void VISU_GaussMergeFilter::SetGeometry(vtkDataSet *input) +{ + this->Superclass::SetInput(input); +} + +//------------------------------------------------------------------------------ +vtkDataSet *VISU_GaussMergeFilter::GetGeometry() +{ + if (this->GetNumberOfInputConnections(0) < 1) + { + return NULL; + } + return vtkDataSet::SafeDownCast( + this->GetExecutive()->GetInputData(0, 0)); +} + +//------------------------------------------------------------------------------ +void VISU_GaussMergeFilter::SetScalars(vtkDataSet *input) +{ + this->SetInput(1, input); +} + +//------------------------------------------------------------------------------ +vtkDataSet *VISU_GaussMergeFilter::GetScalars() +{ + if (this->GetNumberOfInputConnections(1) < 1) + { + return NULL; + } + return vtkDataSet::SafeDownCast( + this->GetExecutive()->GetInputData(1, 0)); +} + +//------------------------------------------------------------------------------ +void VISU_GaussMergeFilter::SetVectors(vtkDataSet *input) +{ + this->SetInput(2, input); +} + +//------------------------------------------------------------------------------ +vtkDataSet *VISU_GaussMergeFilter::GetVectors() +{ + if (this->GetNumberOfInputConnections(2) < 1) + { + return NULL; + } + return vtkDataSet::SafeDownCast( + this->GetExecutive()->GetInputData(2, 0)); +} + +//------------------------------------------------------------------------------ +void VISU_GaussMergeFilter::SetNormals(vtkDataSet *input) +{ + this->SetInput(3, input); +} + +//------------------------------------------------------------------------------ +vtkDataSet *VISU_GaussMergeFilter::GetNormals() +{ + if (this->GetNumberOfInputConnections(3) < 1) + { + return NULL; + } + return vtkDataSet::SafeDownCast( + this->GetExecutive()->GetInputData(3, 0)); +} + +//------------------------------------------------------------------------------ +void VISU_GaussMergeFilter::SetTCoords(vtkDataSet *input) +{ + this->SetInput(4, input); +} + +//------------------------------------------------------------------------------ +vtkDataSet *VISU_GaussMergeFilter::GetTCoords() +{ + if (this->GetNumberOfInputConnections(4) < 1) + { + return NULL; + } + return vtkDataSet::SafeDownCast( + this->GetExecutive()->GetInputData(4, 0)); +} + +//------------------------------------------------------------------------------ +void VISU_GaussMergeFilter::SetTensors(vtkDataSet *input) +{ + this->SetInput(5, input); +} + +//------------------------------------------------------------------------------ +vtkDataSet *VISU_GaussMergeFilter::GetTensors() +{ + if (this->GetNumberOfInputConnections(5) < 1) + { + return NULL; + } + return vtkDataSet::SafeDownCast( + this->GetExecutive()->GetInputData(5, 0)); +} + +//------------------------------------------------------------------------------ +void VISU_GaussMergeFilter::AddField(const char* name, vtkDataSet* input) +{ + this->FieldList->Add(name, input); +} + +//------------------------------------------------------------------------------ +void VISU_GaussMergeFilter::RemoveFields() +{ + delete this->FieldList; + this->FieldList = new VISU::TFieldList; +} + + +//--------------------------------------------------------------- +void +VISU_GaussMergeFilter +::SetMergingInputs(bool theIsMergingInputs) +{ + if(myIsMergingInputs == theIsMergingInputs) + return; + + myIsMergingInputs = theIsMergingInputs; + Modified(); +} + + +//--------------------------------------------------------------- +bool +VISU_GaussMergeFilter +::IsMergingInputs() +{ + return myIsMergingInputs; +} + + +//--------------------------------------------------------------- +int +VISU_GaussMergeFilter +::RequestData(vtkInformation *theRequest, + vtkInformationVector **theInputVector, + vtkInformationVector *theOutputVector) +{ + if(vtkUnstructuredGrid *anInput = dynamic_cast(this->GetInput())){ + vtkPolyData *anOutput = dynamic_cast(this->GetOutput()); + return ExecuteGauss(anInput, + anOutput); + } + + return Superclass::RequestData(theRequest, + theInputVector, + theOutputVector); +} + +//---------------------------------------------------------------------------- +// Trick: Abstract data types that may or may not be the same type +// (structured/unstructured), but the points/cells match up. +// Output/Geometry may be structured while ScalarInput may be +// unstructured (but really have same triagulation/topology as geometry). +// Just request all the input. Always generate all of the output (todo). +int +VISU_GaussMergeFilter +::RequestUpdateExtent(vtkInformation *vtkNotUsed(request), + vtkInformationVector **inputVector, + vtkInformationVector *vtkNotUsed(outputVector)) +{ + vtkInformation *inputInfo; + int idx; + + for (idx = 0; idx < 6; ++idx) + { + inputInfo = inputVector[idx]->GetInformationObject(0); + if (inputInfo) + { + inputInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER(), + 0); + inputInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES(), + 1); + inputInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_GHOST_LEVELS(), + 0); + inputInfo->Set(vtkStreamingDemandDrivenPipeline::EXACT_EXTENT(), 1); + } + } + return 1; +} + + +//---------------------------------------------------------------------------- +int +VISU_GaussMergeFilter +::FillInputPortInformation(int port, vtkInformation *info) +{ + int retval = this->Superclass::FillInputPortInformation(port, info); + if (port > 0) + { + info->Set(vtkAlgorithm::INPUT_IS_OPTIONAL(), 1); + } + return retval; +} + +//---------------------------------------------------------------------------- +int +VISU_GaussMergeFilter +::FillOutputPortInformation(int port, vtkInformation *info) +{ + info->Set(vtkDataObject::DATA_TYPE_NAME(),"vtkPolyData"); + return 1; +} + +void +VISU_GaussMergeFilter +::SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theIDMapper) +{ + myGaussPtsIDMapper = theIDMapper; +} + + +const VISU::PGaussPtsIDMapper& +VISU_GaussMergeFilter +::GetGaussPtsIDMapper() +{ + return myGaussPtsIDMapper; +} + +bool +VISU_GaussMergeFilter +::ExecuteGauss(vtkUnstructuredGrid* theInput, + vtkPolyData* theOutput) +{ + if(IsMergingInputs()){ + vtkCellData *aCellData = theInput->GetCellData(); + if(vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER")){ + vtkIntArray *aGeometryCellMapper = dynamic_cast(aCellMapper); + + vtkIntArray* aDataPointMapper = GetIDMapper(FieldList, + VISU::TGetPointData(), + "VISU_POINTS_MAPPER"); + + vtkIntArray* aDataCellIds = vtkIntArray::New(); + + int nbPoints = aDataPointMapper->GetNumberOfTuples(); + aDataCellIds->SetNumberOfComponents(2); + aDataCellIds->SetNumberOfTuples(nbPoints); + int* aDataCellPointer = aDataCellIds->GetPointer(0); + { + int nbPoints = aDataPointMapper->GetNumberOfTuples(); + for(int i=0;iGetObjID(i); + vtkIdType aCellId = aGPID.first; + *aDataCellPointer = aCellId; + aDataCellPointer++; + *aDataCellPointer = 3; // it's a entity CELL + } + } + /* + vtkIntArray* anCellArr = GetIDMapper(FieldList, + VISU::TGetCellData(), + "VISU_CELLS_MAPPER"); + vtkIntArray* anPMArr = GetIDMapper(FieldList, + VISU::TGetPointData(), + "VISU_POINTS_MAPPER"); + + vtkDataArray* anFArr = GetIDMapper(FieldList, + VISU::TGetPointData(), + "VISU_FIELD"); + */ + if(VISU::IsDifferent(aDataCellIds, aGeometryCellMapper)){ + VISU::TObjectIdArray anIntersection; + VISU::GetIntersection(aDataCellIds, + aGeometryCellMapper, + anIntersection); + + vtkIdType aNbTuples = anIntersection.size(); + + VISU::TObjectId2TupleIdMap aDataCellId2TupleIdMap; + VISU::GetObjectId2TupleIdMap(aDataCellIds, aDataCellId2TupleIdMap); + + vtkPointSet* aScalarsDataSet = dynamic_cast(GetScalars()); + vtkPoints* aDataPoints = aScalarsDataSet->GetPoints(); + vtkPoints* anOutputPoints = vtkPoints::New(aDataPoints->GetDataType()); + + anOutputPoints->SetNumberOfPoints(aNbTuples); + theOutput->SetPoints(anOutputPoints); + anOutputPoints->Delete(); + + vtkCellData* anInputCellData = aScalarsDataSet->GetCellData(); + vtkPointData* anInputPointData = aScalarsDataSet->GetPointData(); + + theOutput->Allocate(aNbTuples); + vtkCellData* anOutputCellData = theOutput->GetCellData(); + vtkPointData* anOutputPointData = theOutput->GetPointData(); + + anOutputCellData->CopyAllocate(anInputCellData,aNbTuples); + anOutputPointData->CopyAllocate(anInputPointData,aNbTuples); + + vtkIdList *aCellIds = vtkIdList::New(); + vtkFloatingPointType aCoords[3]; + for(int aTupleId=0;aTupleIdGetCell(aCellId); + + aCellIds->Reset(); + aCellIds->InsertNextId(aTupleId); + + vtkIdType aCellType = GetScalars()->GetCellType(aCellId); + vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds); + + anOutputCellData->CopyData(anInputCellData, aCellId, aNewCellId); + anOutputPointData->CopyData(anInputPointData, aCellId, aNewCellId); + + aDataPoints->GetPoint(aCellId, aCoords); + anOutputPoints->SetPoint(aNewCellId, aCoords); + } + } + } + } + return true; +} diff --git a/src/CONVERTOR/VISU_GaussMergeFilter.hxx b/src/CONVERTOR/VISU_GaussMergeFilter.hxx new file mode 100644 index 00000000..52cace44 --- /dev/null +++ b/src/CONVERTOR/VISU_GaussMergeFilter.hxx @@ -0,0 +1,138 @@ +// SALOME VTKViewer : build VTK viewer into Salome desktop +// +// 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 : +// Author : +// Module : SALOME +// $Header$ + +#ifndef VISU_GaussMergeFilter_H +#define VISU_GaussMergeFilter_H + +#include "VISU_Convertor.hxx" + +//#include +#include + +namespace VISU +{ + class TFieldList; +} + + +//------------------------------------------------------------------------------ +class VISU_CONVERTOR_EXPORT VISU_GaussMergeFilter : public vtkPointSetAlgorithm +{ +public: + static VISU_GaussMergeFilter *New(); + vtkTypeMacro(VISU_GaussMergeFilter, vtkPointSetAlgorithm); + + // Description: + // Specify object from which to extract geometry information. + void SetGeometry(vtkDataSet *input); + vtkDataSet *GetGeometry(); + + // Description: + // Specify object from which to extract scalar information. + void SetScalars(vtkDataSet *); + vtkDataSet *GetScalars(); + + // Description: + // Set / get the object from which to extract vector information. + void SetVectors(vtkDataSet *); + vtkDataSet *GetVectors(); + + // Description: + // Set / get the object from which to extract normal information. + void SetNormals(vtkDataSet *); + vtkDataSet *GetNormals(); + + // Description: + // Set / get the object from which to extract texture coordinates + // information. + void SetTCoords(vtkDataSet *); + vtkDataSet *GetTCoords(); + + // Description: + // Set / get the object from which to extract tensor data. + void SetTensors(vtkDataSet *); + vtkDataSet *GetTensors(); + + // Description: + // Set the object from which to extract a field and the name + // of the field + void AddField(const char* name, vtkDataSet* input); + + // Description: + // Removes all previously added fields + void RemoveFields(); + + // Description: + // Defines whether to perform merging of data with the geometry according to + // the ids of the cell or not + void + SetMergingInputs(bool theIsMergingInputs); + + bool + IsMergingInputs(); + + void + SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper); + + const VISU::PGaussPtsIDMapper& + GetGaussPtsIDMapper(); + +protected: + VISU_GaussMergeFilter(); + ~VISU_GaussMergeFilter(); + + virtual + int + RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); + + int + RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *); + + int + FillInputPortInformation(int port, vtkInformation *info); + + int + FillOutputPortInformation(int port, vtkInformation *info); + + VISU::TFieldList* FieldList; + bool myIsMergingInputs; + + VISU::PGaussPtsIDMapper myGaussPtsIDMapper; + + bool + ExecuteGauss(vtkUnstructuredGrid* theInput, + vtkPolyData* theOutput); + +private: + VISU_GaussMergeFilter(const VISU_GaussMergeFilter&); // Not implemented. + void operator=(const VISU_GaussMergeFilter&); // Not implemented. +}; + +#endif + + diff --git a/src/CONVERTOR/VISU_MergeFilterUtilities.cxx b/src/CONVERTOR/VISU_MergeFilterUtilities.cxx index 362ebba2..48846369 100644 --- a/src/CONVERTOR/VISU_MergeFilterUtilities.cxx +++ b/src/CONVERTOR/VISU_MergeFilterUtilities.cxx @@ -47,161 +47,12 @@ namespace { - //--------------------------------------------------------------- - typedef int TCellId; - typedef int TEntityId; - typedef std::pair TObjectId; - - typedef std::set TObjectIdSet; - typedef std::vector TObjectIdArray; - - typedef int TTupleId; - typedef std::map TObjectId2TupleIdMap; - - - //--------------------------------------------------------------- - void - GetObjectIdSet(vtkIntArray *theArray, - TObjectIdSet& theObjectIdSet) - { - theObjectIdSet.clear(); - int aMaxId = theArray->GetMaxId(); - int* aPointer = theArray->GetPointer(0); - int* anEndPointer = theArray->GetPointer(aMaxId + 1); - for(; aPointer != anEndPointer; aPointer += 2){ - TCellId aCellId = *aPointer; - TEntityId anEntityId = *(aPointer + 1); - TObjectId anObjectId(aCellId, anEntityId); - theObjectIdSet.insert(anObjectId); - } - } - - - //--------------------------------------------------------------- - void - GetObjectId2TupleIdMap(vtkIntArray *theArray, - TObjectId2TupleIdMap& theObjectId2TupleIdMap) - { - theObjectId2TupleIdMap.clear(); - int* aPointer = theArray->GetPointer(0); - int aNbTuples = theArray->GetNumberOfTuples(); - for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++, aPointer += 2){ - TCellId aCellId = *aPointer; - TEntityId anEntityId = *(aPointer + 1); - TObjectId anObjectId(aCellId, anEntityId); - theObjectId2TupleIdMap[anObjectId] = aTupleId; - } - } - - - //--------------------------------------------------------------- - typedef vtkFieldData* (vtkDataSet::* TGetFieldData)(); - - //--------------------------------------------------------------- - struct TGetCellData - { - vtkFieldData* - operator()(vtkDataSet* theDataSet) - { - return theDataSet->GetCellData(); - } - }; - - - //--------------------------------------------------------------- - struct TGetPointData - { - vtkFieldData* - operator()(vtkDataSet* theDataSet) - { - return theDataSet->GetPointData(); - } - }; - - - //--------------------------------------------------------------- - template - vtkIntArray* - GetIDMapper(VISU::TFieldList* theFieldList, - TGetFieldData theGetFieldData, - const char* theFieldName) - { - VISU::TFieldListIterator anIter(theFieldList); - for(anIter.Begin(); !anIter.End() ; anIter.Next()){ - const char* aFieldName = anIter.Get()->GetName(); - if(strcmp(aFieldName, theFieldName) == 0){ - vtkDataSet* aDataSet = anIter.Get()->Ptr; - vtkFieldData *aFieldData = theGetFieldData(aDataSet); - vtkDataArray *anIDMapper = aFieldData->GetArray(theFieldName); - return dynamic_cast(anIDMapper); - } - } - return NULL; - } - - - //--------------------------------------------------------------- - template - vtkIntArray* - GetIDMapper(vtkDataSet* theIDMapperDataSet, - TGetFieldData theGetFieldData, - const char* theFieldName) - { - vtkFieldData *aFieldData = theGetFieldData(theIDMapperDataSet); - vtkDataArray *anIDMapper = aFieldData->GetArray(theFieldName); - return dynamic_cast(anIDMapper); - } - - - //--------------------------------------------------------------- - bool - IsDifferent(vtkIntArray *theFirstIDMapper, - vtkIntArray *theSecondIDMapper) - { - vtkIdType aFirstNbTuples = theFirstIDMapper->GetNumberOfTuples(); - vtkIdType aSecondNbTuples = theSecondIDMapper->GetNumberOfTuples(); - if(aFirstNbTuples != aSecondNbTuples) - return true; - - int aMaxId = theFirstIDMapper->GetMaxId(); - int* aFirstPointer = theFirstIDMapper->GetPointer(0); - int* aSecondPointer = theSecondIDMapper->GetPointer(0); - for(int anId = 0; anId <= aMaxId; anId++){ - if(*aFirstPointer++ != *aSecondPointer++) - return true; - } - - return false; - } - - - //--------------------------------------------------------------- - inline - void - GetIntersection(vtkIntArray *theFirstIDMapper, - vtkIntArray *theSecondIDMapper, - TObjectIdArray& theResult) - { - TObjectIdSet aFirstObjectIdSet; - GetObjectIdSet(theFirstIDMapper, aFirstObjectIdSet); - - TObjectIdSet aSecondObjectIdSet; - GetObjectIdSet(theSecondIDMapper, aSecondObjectIdSet); - - size_t aMaxLength = std::max(aFirstObjectIdSet.size(), aSecondObjectIdSet.size()); - theResult.resize(aMaxLength); - TObjectIdArray::iterator anArrayIter = theResult.begin(); - anArrayIter = std::set_intersection(aFirstObjectIdSet.begin(), - aFirstObjectIdSet.end(), - aSecondObjectIdSet.begin(), - aSecondObjectIdSet.end(), - anArrayIter); - theResult.erase(anArrayIter, theResult.end()); - } - + using namespace VISU; + //--------------------------------------------------------------- template + void CopyDataOnCells(TDataSet *theInput, vtkIntArray *theGeometryCellMapper, @@ -351,7 +202,6 @@ namespace theOutput->GetPointData()->ShallowCopy(theScalarsDataSet->GetPointData()); } - //--------------------------------------------------------------- typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)(); typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkDataArray*); @@ -583,10 +433,123 @@ namespace } } - namespace VISU { + //--------------------------------------------------------------- + void + GetObjectIdSet(vtkIntArray *theArray, + TObjectIdSet& theObjectIdSet) + { + theObjectIdSet.clear(); + int aMaxId = theArray->GetMaxId(); + int* aPointer = theArray->GetPointer(0); + int* anEndPointer = theArray->GetPointer(aMaxId + 1); + for(; aPointer != anEndPointer; aPointer += 2){ + TCellId aCellId = *aPointer; + TEntityId anEntityId = *(aPointer + 1); + TObjectId anObjectId(aCellId, anEntityId); + theObjectIdSet.insert(anObjectId); + } + } + + + //--------------------------------------------------------------- + void + GetObjectId2TupleIdMap(vtkIntArray *theArray, + TObjectId2TupleIdMap& theObjectId2TupleIdMap) + { + theObjectId2TupleIdMap.clear(); + int* aPointer = theArray->GetPointer(0); + int aNbTuples = theArray->GetNumberOfTuples(); + for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++, aPointer += 2){ + TCellId aCellId = *aPointer; + TEntityId anEntityId = *(aPointer + 1); + TObjectId anObjectId(aCellId, anEntityId); + theObjectId2TupleIdMap[anObjectId] = aTupleId; + } + } + + + //--------------------------------------------------------------- + template + vtkIntArray* + GetIDMapper(VISU::TFieldList* theFieldList, + TGetFieldData theGetFieldData, + const char* theFieldName) + { + VISU::TFieldListIterator anIter(theFieldList); + for(anIter.Begin(); !anIter.End() ; anIter.Next()){ + const char* aFieldName = anIter.Get()->GetName(); + if(strcmp(aFieldName, theFieldName) == 0){ + vtkDataSet* aDataSet = anIter.Get()->Ptr; + vtkFieldData *aFieldData = theGetFieldData(aDataSet); + vtkDataArray *anIDMapper = aFieldData->GetArray(theFieldName); + return dynamic_cast(anIDMapper); + } + } + return NULL; + } + + + //--------------------------------------------------------------- + template + vtkIntArray* + GetIDMapper(vtkDataSet* theIDMapperDataSet, + TGetFieldData theGetFieldData, + const char* theFieldName) + { + vtkFieldData *aFieldData = theGetFieldData(theIDMapperDataSet); + vtkDataArray *anIDMapper = aFieldData->GetArray(theFieldName); + return dynamic_cast(anIDMapper); + } + + + //--------------------------------------------------------------- + bool + IsDifferent(vtkIntArray *theFirstIDMapper, + vtkIntArray *theSecondIDMapper) + { + vtkIdType aFirstNbTuples = theFirstIDMapper->GetNumberOfTuples(); + vtkIdType aSecondNbTuples = theSecondIDMapper->GetNumberOfTuples(); + if(aFirstNbTuples != aSecondNbTuples) + return true; + + int aMaxId = theFirstIDMapper->GetMaxId(); + int* aFirstPointer = theFirstIDMapper->GetPointer(0); + int* aSecondPointer = theSecondIDMapper->GetPointer(0); + for(int anId = 0; anId <= aMaxId; anId++){ + if(*aFirstPointer++ != *aSecondPointer++) + return true; + } + + return false; + } + + + //--------------------------------------------------------------- + void + GetIntersection(vtkIntArray *theFirstIDMapper, + vtkIntArray *theSecondIDMapper, + TObjectIdArray& theResult) + { + TObjectIdSet aFirstObjectIdSet; + GetObjectIdSet(theFirstIDMapper, aFirstObjectIdSet); + + TObjectIdSet aSecondObjectIdSet; + GetObjectIdSet(theSecondIDMapper, aSecondObjectIdSet); + + size_t aMaxLength = std::max(aFirstObjectIdSet.size(), aSecondObjectIdSet.size()); + theResult.resize(aMaxLength); + TObjectIdArray::iterator anArrayIter = theResult.begin(); + anArrayIter = std::set_intersection(aFirstObjectIdSet.begin(), + aFirstObjectIdSet.end(), + aSecondObjectIdSet.begin(), + aSecondObjectIdSet.end(), + anArrayIter); + theResult.erase(anArrayIter, theResult.end()); + } + //--------------------------------------------------------------- bool Execute(vtkUnstructuredGrid *theInput, @@ -633,7 +596,4 @@ namespace VISU theIsMergingInputs, theOutput); } - - - //--------------------------------------------------------------- } diff --git a/src/CONVERTOR/VISU_MergeFilterUtilities.hxx b/src/CONVERTOR/VISU_MergeFilterUtilities.hxx index e29abbab..09b7b4db 100644 --- a/src/CONVERTOR/VISU_MergeFilterUtilities.hxx +++ b/src/CONVERTOR/VISU_MergeFilterUtilities.hxx @@ -30,15 +30,80 @@ #define VISU_MergeFilterUtilities_H #include +#include class vtkDataSet; class vtkPolyData; class vtkUnstructuredGrid; +class vtkIntArray; + +using namespace std; +#include +#include +#include namespace VISU { class TFieldList; + typedef int TCellId; + typedef int TEntityId; + typedef std::pair TObjectId; + + typedef std::set TObjectIdSet; + typedef std::vector TObjectIdArray; + + typedef int TTupleId; + typedef std::map TObjectId2TupleIdMap; + + //--------------------------------------------------------------- + typedef vtkFieldData* (vtkDataSet::* TGetFieldData)(); + + //--------------------------------------------------------------- + struct TGetCellData + { + vtkFieldData* + operator()(vtkDataSet* theDataSet) + { + return (vtkFieldData*)(theDataSet->GetCellData()); + } + }; + + + //--------------------------------------------------------------- + struct TGetPointData + { + vtkFieldData* + operator()(vtkDataSet* theDataSet) + { + return (vtkFieldData*)(theDataSet->GetPointData()); + } + }; + + void + GetObjectId2TupleIdMap(vtkIntArray *theArray, + TObjectId2TupleIdMap& theObjectId2TupleIdMap); + + template + vtkIntArray* + GetIDMapper(VISU::TFieldList* theFieldList, + TGetFieldData theGetFieldData, + const char* theFieldName); + + template + vtkIntArray* + GetIDMapper(vtkDataSet* theIDMapperDataSet, + TGetFieldData theGetFieldData, + const char* theFieldName); + + bool + IsDifferent(vtkIntArray *theFirstIDMapper, + vtkIntArray *theSecondIDMapper); + + void + GetIntersection(vtkIntArray *theFirstIDMapper, + vtkIntArray *theSecondIDMapper, + TObjectIdArray& theResult); //--------------------------------------------------------------- bool @@ -65,7 +130,6 @@ namespace VISU TFieldList* theFieldList, bool theIsMergingInputs); - //--------------------------------------------------------------- class TFieldNode { diff --git a/src/PIPELINE/VISU_ColoredPL.cxx b/src/PIPELINE/VISU_ColoredPL.cxx index 49600e84..5b7b0e3c 100644 --- a/src/PIPELINE/VISU_ColoredPL.cxx +++ b/src/PIPELINE/VISU_ColoredPL.cxx @@ -94,6 +94,15 @@ VISU_ColoredPL SetNbColors(aPipeLine->GetNbColors()); SetScaling(aPipeLine->GetScaling()); SetMapScale(aPipeLine->GetMapScale()); + if(this != thePipeLine){ + if(aPipeLine->IsExternalGeometryUsed()){ + ClearGeometry(); + int aNbOfGeometry = aPipeLine->GetNumberOfGeometry(); + for(int aGeomNumber = 0; aGeomNumber < aNbOfGeometry; aGeomNumber++) + AddGeometry(aPipeLine->GetGeometry(aGeomNumber)); + }else + SetSourceGeometry(); + } } } diff --git a/src/PIPELINE/VISU_ColoredPL.hxx b/src/PIPELINE/VISU_ColoredPL.hxx index 3743750a..c22351b8 100644 --- a/src/PIPELINE/VISU_ColoredPL.hxx +++ b/src/PIPELINE/VISU_ColoredPL.hxx @@ -119,6 +119,36 @@ public: void SetSourceRange(); +public: + + virtual + void + SetSourceGeometry()=0; + + virtual + int + AddGeometry(vtkDataSet* theGeometry)=0; + + virtual + vtkDataSet* + GetGeometry(int theGeomNumber)=0; + + virtual + int + GetNumberOfGeometry()=0; + + virtual + bool + IsExternalGeometryUsed()=0; + + virtual + void + ClearGeometry()=0; + + virtual + vtkPointSet* + GetMergedInput()=0; + protected: //---------------------------------------------------------------------------- VISU_ColoredPL(); @@ -161,6 +191,7 @@ private: vtkSmartPointer myBarTable; vtkSmartPointer myExtractor; vtkSmartPointer myFieldTransform; + }; #endif diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index 38d8f8e2..ea42aaca 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -34,6 +34,8 @@ #include "VISU_LookupTable.hxx" #include "VISU_PipeLineUtils.hxx" +#include "VISU_AppendFilter.hxx" +#include "VISU_GaussMergeFilter.hxx" #include #include @@ -53,7 +55,9 @@ vtkStandardNewMacro(VISU_GaussPointsPL); VISU_GaussPointsPL ::VISU_GaussPointsPL(): myScaleFactor(0.0), - myMagnificationIncrement(2) + myMagnificationIncrement(2), + myAppendFilter(VISU_AppendFilter::New()), + myMergeFilter(VISU_GaussMergeFilter::New()) { SetIsShrinkable(false); @@ -71,8 +75,14 @@ VISU_GaussPointsPL for(int i = 0; i < 3; i++) myPassFilter.push_back(vtkPassThroughFilter::New()); - + myPrimitiveType = VISU_OpenGLPointSpriteMapper::PointSprite; + + myAppendFilter->SetMergingInputs(true); + myAppendFilter->Delete(); + + myMergeFilter->SetMergingInputs(true); + myMergeFilter->Delete(); } @@ -101,6 +111,8 @@ VISU_GaussPointsPL aTime = std::max(aTime, myWarpVector->GetMTime()); aTime = std::max(aTime, myGlyph->GetMTime()); aTime = std::max(aTime, mySphereSource->GetMTime()); + aTime = std::max(aTime, myAppendFilter->GetMTime()); + aTime = std::max(aTime, myMergeFilter->GetMTime()); for(int i = 0; i < 3; i++) aTime = std::max(aTime, myPassFilter[i]->GetMTime()); @@ -253,14 +265,30 @@ VISU_GaussPointsPL { Superclass::Build(); - // Deformed Shape - myPassFilter[0]->SetInput(GetFieldTransformFilter()->GetOutput()); + SetSourceGeometry(); + + vtkDataSet* aDataSet = GetFieldTransformFilter()->GetOutput(); + + myMergeFilter->SetGeometry(myAppendFilter->GetOutput()); + + myMergeFilter->SetScalars(aDataSet); + myMergeFilter->SetVectors(aDataSet); + + myMergeFilter->RemoveFields(); + myMergeFilter->AddField("VISU_FIELD", aDataSet); + myMergeFilter->AddField("VISU_POINTS_MAPPER", aDataSet); + myMergeFilter->AddField("VISU_INPUTS_MAPPER", aDataSet); + myMergeFilter->AddField("VISU_CELLS_MAPPER", aDataSet); + + myMergeFilter->SetGaussPtsIDMapper(GetGaussPtsIDMapper()); + + myPassFilter[0]->SetInput(InsertCustomPL()); myPassFilter[1]->SetInput(myPassFilter[0]->GetOutput()); // Geometrical Sphere myPassFilter[2]->SetInput(myPassFilter[1]->GetOutput()); - + GetPointSpriteMapper()->SetInput( myPassFilter[2]->GetPolyDataOutput() ); // Update according the current state @@ -275,11 +303,20 @@ void VISU_GaussPointsPL ::Update() { + if(IsExternalGeometryUsed() || GetNumberOfGeometry() > 1 ){ + myMergeFilter->Update(); + myPassFilter[0]->SetInput(myMergeFilter->GetOutput()); + } + else{ + myPassFilter[0]->SetInput(GetFieldTransformFilter()->GetOutput()); + } + SetAverageCellSize( VISU_DeformedShapePL::GetScaleFactor( GetParentMesh() ) ); this->UpdateGlyph(); Superclass::Update(); + } @@ -770,3 +807,65 @@ VISU_GaussPointsPL myWarpVector->SetScaleFactor( aMapScale ); } + +void +VISU_GaussPointsPL +::SetSourceGeometry() +{ + if(IsExternalGeometryUsed()){ + ClearGeometry(); + myAppendFilter->AddInput(GetFieldTransformFilter()->GetOutput()); + } +} + +vtkDataSet* +VISU_GaussPointsPL +::InsertCustomPL() +{ + return GetMergedInput(); +} + +int +VISU_GaussPointsPL +::AddGeometry(vtkDataSet* theGeometry) +{ + myAppendFilter->AddInput(theGeometry); + return GetNumberOfGeometry(); +} + +vtkDataSet* +VISU_GaussPointsPL +::GetGeometry(int theGeomNumber) +{ + return vtkDataSet::SafeDownCast(myAppendFilter->GetInput(theGeomNumber)); +} + +int +VISU_GaussPointsPL +::GetNumberOfGeometry() +{ + return myAppendFilter->GetNumberOfInputConnections(0); +} + +bool +VISU_GaussPointsPL +::IsExternalGeometryUsed() +{ + return myAppendFilter->GetInput() != GetFieldTransformFilter()->GetOutput(); +} + +void +VISU_GaussPointsPL +::ClearGeometry() +{ + myAppendFilter->RemoveAllInputs(); +} + +vtkPointSet* +VISU_GaussPointsPL +::GetMergedInput() +{ + if(myMergeFilter->GetInput()) + myMergeFilter->Update(); + return myMergeFilter->GetOutput(); +} diff --git a/src/PIPELINE/VISU_GaussPointsPL.hxx b/src/PIPELINE/VISU_GaussPointsPL.hxx index cdb2378e..05136235 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.hxx +++ b/src/PIPELINE/VISU_GaussPointsPL.hxx @@ -43,10 +43,13 @@ class vtkDataArray; class vtkImageData; class vtkPointSet; class vtkPassThroughFilter; +class vtkDataSet; class vtkWarpVector; class SALOME_Transform; +class VISU_AppendFilter; +class VISU_GaussMergeFilter; //---------------------------------------------------------------------------- //! Pipeline for the Gauss Points presentation. @@ -275,6 +278,36 @@ public: void SetMapScale( vtkFloatingPointType theMapScale = 1.0 ); +public: + + virtual + void + SetSourceGeometry(); + + virtual + int + AddGeometry(vtkDataSet* theGeometry); + + virtual + vtkDataSet* + GetGeometry(int theGeomNumber); + + virtual + int + GetNumberOfGeometry(); + + virtual + bool + IsExternalGeometryUsed(); + + virtual + void + ClearGeometry(); + + virtual + vtkPointSet* + GetMergedInput(); + protected: //---------------------------------------------------------------------------- VISU_GaussPointsPL(); @@ -290,6 +323,10 @@ protected: void Build(); + virtual + vtkDataSet* + InsertCustomPL(); + virtual void DoShallowCopy(VISU_PipeLine *thePipeLine, @@ -309,6 +346,9 @@ private: int myPrimitiveType; + vtkSmartPointer myAppendFilter; + vtkSmartPointer myMergeFilter; + private: VISU_GaussPointsPL(const VISU_GaussPointsPL&); // Not implemented. void operator=(const VISU_GaussPointsPL&); // Not implemented. diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index 55352b8e..a8784c81 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -144,17 +144,6 @@ VISU_ScalarMapPL bool theIsCopyInput) { Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); - if(this != thePipeLine){ - if(VISU_ScalarMapPL *aPipeLine = dynamic_cast(thePipeLine)){ - if(aPipeLine->IsExternalGeometryUsed()){ - ClearGeometry(); - int aNbOfGeometry = aPipeLine->GetNumberOfGeometry(); - for(int aGeomNumber = 0; aGeomNumber < aNbOfGeometry; aGeomNumber++) - AddGeometry(aPipeLine->GetGeometry(aGeomNumber)); - }else - SetSourceGeometry(); - } - } } diff --git a/src/VISUGUI/VisuGUI_InputPane.cxx b/src/VISUGUI/VisuGUI_InputPane.cxx index 90915b17..3b90cc17 100644 --- a/src/VISUGUI/VisuGUI_InputPane.cxx +++ b/src/VISUGUI/VisuGUI_InputPane.cxx @@ -513,9 +513,9 @@ void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs ) if(myAllGroups->count() < 1){ myAllGroups->insertItem( tr("NO_GROUPS") ); myUseGroupsGroupBox->setEnabled(false); - }else if(VISU::ScalarMap_i* aPrs = dynamic_cast(thePrs)){ - const VISU::ScalarMap_i::TGroupNames& aGroupNames = aPrs->GetGroupNames(); - VISU::ScalarMap_i::TGroupNames::const_iterator anIter = aGroupNames.begin(); + }else{ + const VISU::ColoredPrs3d_i::TGroupNames& aGroupNames = thePrs->GetGroupNames(); + VISU::ColoredPrs3d_i::TGroupNames::const_iterator anIter = aGroupNames.begin(); for(; anIter != aGroupNames.end(); anIter++){ const std::string aGroupName = *anIter; mySelectedGroups->insertItem(QString(aGroupName)); @@ -529,15 +529,14 @@ void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs ) //--------------------------------------------------------------- int VisuGUI_InputPane::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) { - if(VISU::ScalarMap_i* aPrs = dynamic_cast(thePrs)){ - if(myUseGroupsGroupBox->isChecked()){ - aPrs->RemoveAllGeom(); - for(int i = 0; i < mySelectedGroups->count(); i++) - aPrs->AddMeshOnGroup(mySelectedGroups->text(i) ); - }else - aPrs->SetSourceGeometry(); - } - + + if(myUseGroupsGroupBox->isChecked()){ + thePrs->RemoveAllGeom(); + for(int i = 0; i < mySelectedGroups->count(); i++) + thePrs->AddMeshOnGroup(mySelectedGroups->text(i) ); + }else + thePrs->SetSourceGeometry(); + thePrs->SetResultObject( myResult ); thePrs->SetMeshName( myMeshName->text().latin1() ); diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 65e2dd08..118e2272 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -673,6 +673,8 @@ VISU::ColoredPrs3d_i myIsTimeStampFixed = anOrigin->IsTimeStampFixed(); SetHolderEntry( anOrigin->GetHolderEntry() ); + + myGroupNames = anOrigin->GetGroupNames(); } } @@ -1445,6 +1447,19 @@ VISU::ColoredPrs3d_i myLabelColor[1] = VISU::Storable::FindValue(theMap,"myLabelColor[1]").toFloat(); myLabelColor[2] = VISU::Storable::FindValue(theMap,"myLabelColor[2]").toFloat(); + bool anIsExists; + QString aGeomNames = VISU::Storable::FindValue(theMap, "myGeomNameList", &anIsExists); + if(anIsExists){ + QStringList aGeomNameList = QStringList::split("|", aGeomNames); + int aNbOfGroups = aGeomNameList.count(); + if(aNbOfGroups > 0){ + RemoveAllGeom(); + for(int aGroupNum = 0; aGroupNum < aNbOfGroups; aGroupNum++){ + QString aGroupName = aGeomNameList[aGroupNum]; + AddMeshOnGroup(aGroupName.latin1()); + } + } + } return this; } @@ -1490,6 +1505,33 @@ VISU::ColoredPrs3d_i Storable::DataToStream( theStr, "myLabelColor[0]", myLabelColor[0] ); Storable::DataToStream( theStr, "myLabelColor[1]", myLabelColor[1] ); Storable::DataToStream( theStr, "myLabelColor[2]", myLabelColor[2] ); + + std::ostringstream aGeomNameList; + std::string aMeshName = GetCMeshName(); + const TGroupNames& aGroupNames = GetGroupNames(); + TGroupNames::const_iterator anIter = aGroupNames.begin(); + for(; anIter != aGroupNames.end(); anIter++){ + const std::string& aGroupName = *anIter; + aGeomNameList< + class VISU_ColoredPL; namespace VISU @@ -333,6 +335,33 @@ namespace VISU const char* GetIconName() = 0; + + //---------------------------------------------------------------------------- + //! Sets initial source geometry + virtual + void + SetSourceGeometry()=0; + + //! Add geometry of mesh as group. \retval the id of added group. + virtual + void + AddMeshOnGroup(const char* theGroupName)=0; + + //! Removes all geometries. + virtual + void + RemoveAllGeom()=0; + + typedef std::string TGroupName; + typedef std::set TGroupNames; + + const TGroupNames& + GetGroupNames(); + + //! Gets number of geometries + bool + IsGroupsUsed(); + //---------------------------------------------------------------------------- public: /*! @@ -535,6 +564,8 @@ namespace VISU std::string GetActorEntry(); + TGroupNames myGroupNames; + private: bool myIsRestored; Storable::TRestoringMap myRestoringMap; @@ -582,6 +613,7 @@ namespace VISU VISU_ColoredPL* myColoredPL; bool myIsFixedRange; + }; diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc index 0495c377..aea67bc0 100644 --- a/src/VISU_I/VISU_DumpPython.cc +++ b/src/VISU_I/VISU_DumpPython.cc @@ -305,6 +305,13 @@ namespace VISU else theStr<GetGroupNames(); + VISU::ColoredPrs3d_i::TGroupNames::const_iterator anIter = aGroupNames.begin(); + for(; anIter != aGroupNames.end(); anIter++){ + const std::string& aGroupName = *anIter; + theStr<GetGroupNames(); - VISU::ScalarMap_i::TGroupNames::const_iterator anIter = aGroupNames.begin(); - for(; anIter != aGroupNames.end(); anIter++){ - const std::string& aGroupName = *anIter; - theStr<GetMagnificationIncrement(); } +//---------------------------------------------------------------------------- +void +VISU::GaussPoints_i +::SetSourceGeometry() +{ + int aNbGroups = myGroupNames.size(); + if(aNbGroups != 0){ + GetSpecificPL()->SetSourceGeometry(); + myGroupNames.clear(); + /*UpdateIcon();*/ + } +} + +//---------------------------------------------------------------------------- +void +VISU::GaussPoints_i +::AddMeshOnGroup(const char* theGroupName) +{ + VISU::Result_i::PInput anInput = GetCResult()->GetInput(); + VISU::PUnstructuredGridIDMapper anIDMapper = anInput->GetMeshOnGroup(GetCMeshName(), theGroupName); + if(anIDMapper){ + int aNbGroups = myGroupNames.size(); + if(myGroupNames.find(theGroupName) == myGroupNames.end()){ + GetSpecificPL()->AddGeometry(anIDMapper->GetOutput()); + myGroupNames.insert(theGroupName); + /* + if(aNbGroups == 0) + UpdateIcon(); + */ + } + } +} + + +//---------------------------------------------------------------------------- +void +VISU::GaussPoints_i +::RemoveAllGeom() +{ + int aNbGroups = myGroupNames.size(); + GetSpecificPL()->ClearGeometry(); + myGroupNames.clear(); + /* + if(aNbGroups != 0) + UpdateIcon(); + */ +} + //---------------------------------------------------------------------------- void VISU::GaussPoints_i diff --git a/src/VISU_I/VISU_GaussPoints_i.hh b/src/VISU_I/VISU_GaussPoints_i.hh index 767e4c52..13dc605f 100644 --- a/src/VISU_I/VISU_GaussPoints_i.hh +++ b/src/VISU_I/VISU_GaussPoints_i.hh @@ -269,6 +269,22 @@ namespace VISU { return myGaussPointsPL; } + + //---------------------------------------------------------------------------- + //! Sets initial source geometry + virtual + void + SetSourceGeometry(); + + //! Add geometry of mesh as group. \retval the id of added group. + virtual + void + AddMeshOnGroup(const char* theGroupName); + + //! Removes all geometries. + virtual + void + RemoveAllGeom(); protected: //! Redefines VISU_ColoredPrs3d_i::DoSetInput diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index 8a719f63..900e3621 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -191,8 +191,6 @@ VISU::ScalarMap_i SetScaling(anOrigin->GetScaling()); - myGroupNames = anOrigin->GetGroupNames(); - Update(); } } @@ -240,20 +238,6 @@ VISU::ScalarMap_i SetScaling(VISU::Scaling(VISU::Storable::FindValue(theMap,"myScaling").toInt())); - bool anIsExists; - QString aGeomNames = VISU::Storable::FindValue(theMap, "myGeomNameList", &anIsExists); - if(anIsExists){ - QStringList aGeomNameList = QStringList::split("|", aGeomNames); - int aNbOfGroups = aGeomNameList.count(); - if(aNbOfGroups > 0){ - RemoveAllGeom(); - for(int aGroupNum = 0; aGroupNum < aNbOfGroups; aGroupNum++){ - QString aGroupName = aGeomNameList[aGroupNum]; - AddMeshOnGroup(aGroupName.latin1()); - } - } - } - // Check if the icon needs to be updated, update if necessary SALOMEDS::Study_var aStudy = theSObject->GetStudy(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); @@ -276,16 +260,6 @@ VISU::ScalarMap_i TSuperClass::ToStream(theStr); Storable::DataToStream( theStr, "myScaling", GetScaling() ); - - std::ostringstream aGeomNameList; - std::string aMeshName = GetCMeshName(); - const TGroupNames& aGroupNames = GetGroupNames(); - TGroupNames::const_iterator anIter = aGroupNames.begin(); - for(; anIter != aGroupNames.end(); anIter++){ - const std::string& aGroupName = *anIter; - aGeomNameList< TGroupNames; - - const TGroupNames& - GetGroupNames(); - - //! Gets number of geometries - bool - IsGroupsUsed(); - private: VISU_ScalarMapPL* myScalarMapPL; - TGroupNames myGroupNames; }; } -- 2.39.2