]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Bug NPAL15851
authorenk <enk@opencascade.com>
Mon, 3 Dec 2007 08:23:05 +0000 (08:23 +0000)
committerenk <enk@opencascade.com>
Mon, 3 Dec 2007 08:23:05 +0000 (08:23 +0000)
   EDF PAL 408: Gauss Points: "Build Presentation on Groups" Feature

18 files changed:
src/CONVERTOR/Makefile.am
src/CONVERTOR/VISU_GaussMergeFilter.cxx [new file with mode: 0644]
src/CONVERTOR/VISU_GaussMergeFilter.hxx [new file with mode: 0644]
src/CONVERTOR/VISU_MergeFilterUtilities.cxx
src/CONVERTOR/VISU_MergeFilterUtilities.hxx
src/PIPELINE/VISU_ColoredPL.cxx
src/PIPELINE/VISU_ColoredPL.hxx
src/PIPELINE/VISU_GaussPointsPL.cxx
src/PIPELINE/VISU_GaussPointsPL.hxx
src/PIPELINE/VISU_ScalarMapPL.cxx
src/VISUGUI/VisuGUI_InputPane.cxx
src/VISU_I/VISU_ColoredPrs3d_i.cc
src/VISU_I/VISU_ColoredPrs3d_i.hh
src/VISU_I/VISU_DumpPython.cc
src/VISU_I/VISU_GaussPoints_i.cc
src/VISU_I/VISU_GaussPoints_i.hh
src/VISU_I/VISU_ScalarMap_i.cc
src/VISU_I/VISU_ScalarMap_i.hh

index a8df0bb0f380ec7297ae576bea40712768f6d51e..f0782c7caae0ee6137f773e38d0193495bdcb87d 100644 (file)
@@ -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 (file)
index 0000000..a27a1f4
--- /dev/null
@@ -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 <vtkObjectFactory.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkPolyData.h>
+#include <vtkCellData.h>
+#include <vtkPointData.h>
+#include <vtkIdList.h>
+#include <vtkCell.h>
+#include <vtkFloatArray.h>
+
+#include <vtkExecutive.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+#include <vtkStreamingDemandDrivenPipeline.h>
+
+
+//------------------------------------------------------------------------------
+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<vtkUnstructuredGrid*>(this->GetInput())){
+    vtkPolyData *anOutput = dynamic_cast<vtkPolyData*>(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<vtkIntArray*>(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;i<nbPoints;i++,aDataCellPointer++){
+         VISU::TGaussPointID aGPID = myGaussPtsIDMapper->GetObjID(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<vtkPointSet*>(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;aTupleId<aNbTuples;aTupleId++){
+         VISU::TObjectId& anObjectId = anIntersection[aTupleId];
+         
+         vtkIdType aCellId = aDataCellId2TupleIdMap[anObjectId];
+         vtkCell *aCell = GetScalars()->GetCell(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 (file)
index 0000000..52cace4
--- /dev/null
@@ -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 <vtkDataSetAlgorithm.h>
+#include <vtkPointSetAlgorithm.h>
+
+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
+
+
index 362ebba2a3ae24c1c6cb444d4540a15ea52784bb..488463696a9adf42b87fd34be88e554c3e2f9f19 100644 (file)
 
 namespace
 {
-  //---------------------------------------------------------------
-  typedef int TCellId;
-  typedef int TEntityId;
-  typedef std::pair<TCellId, TEntityId> TObjectId;
-
-  typedef std::set<TObjectId> TObjectIdSet;
-  typedef std::vector<TObjectId> TObjectIdArray;
-
-  typedef int TTupleId;
-  typedef std::map<TObjectId, TTupleId> 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<class TGetFieldData>
-  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<vtkIntArray*>(anIDMapper);
-      }
-    }
-    return NULL;
-  }
-
-
-  //---------------------------------------------------------------
-  template<class TGetFieldData>
-  vtkIntArray*
-  GetIDMapper(vtkDataSet* theIDMapperDataSet,
-             TGetFieldData theGetFieldData,
-             const char* theFieldName)
-  {
-    vtkFieldData *aFieldData = theGetFieldData(theIDMapperDataSet);
-    vtkDataArray *anIDMapper = aFieldData->GetArray(theFieldName);
-    return dynamic_cast<vtkIntArray*>(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<class TDataSet>
+  
   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<class TGetFieldData>
+  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<vtkIntArray*>(anIDMapper);
+      }
+    }
+    return NULL;
+  }
+
+
+  //---------------------------------------------------------------
+  template<class TGetFieldData>
+  vtkIntArray*
+  GetIDMapper(vtkDataSet* theIDMapperDataSet,
+             TGetFieldData theGetFieldData,
+             const char* theFieldName)
+  {
+    vtkFieldData *aFieldData = theGetFieldData(theIDMapperDataSet);
+    vtkDataArray *anIDMapper = aFieldData->GetArray(theFieldName);
+    return dynamic_cast<vtkIntArray*>(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);
   }
-
-
-  //---------------------------------------------------------------
 }
index e29abbabd701a8d02b1acb9c37a8e4337f6e5184..09b7b4db043114915c5f578fb62cee2006dd4ef1 100644 (file)
 #define VISU_MergeFilterUtilities_H
 
 #include <string>
+#include <vtkDataSet.h>
 
 class vtkDataSet;
 class vtkPolyData;
 class vtkUnstructuredGrid;
+class vtkIntArray;
+
+using namespace std;
+#include <set>
+#include <vector>
+#include <map>
 
 namespace VISU
 {
   class TFieldList;
 
+  typedef int TCellId;
+  typedef int TEntityId;
+  typedef std::pair<TCellId, TEntityId> TObjectId;
+
+  typedef std::set<TObjectId> TObjectIdSet;
+  typedef std::vector<TObjectId> TObjectIdArray;
+
+  typedef int TTupleId;
+  typedef std::map<TObjectId, TTupleId> 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<class TGetFieldData>
+  vtkIntArray*
+  GetIDMapper(VISU::TFieldList* theFieldList,
+             TGetFieldData theGetFieldData,
+             const char* theFieldName);
+
+  template<class TGetFieldData>
+  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
   {
index 49600e845e7c9a7d0b2bf8a039fe72602e98fa18..5b7b0e3c278ac788ddc90316438873ce5318268f 100644 (file)
@@ -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();
+    }
   }
 }
 
index 3743750af2e63becf748066625bf475f932c49e1..c22351b86169e115fce9aa1a49bf9145679b0a94 100644 (file)
@@ -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<VISU_LookupTable> myBarTable;
   vtkSmartPointer<VISU_Extractor> myExtractor;
   vtkSmartPointer<VISU_FieldTransform> myFieldTransform;
+  
 };
   
 #endif
index 38d8f8e268b9013ca0b88a535c7b354f82c932a7..ea42aaca6fe06f4a97b0187a5c9c0beac273cebd 100644 (file)
@@ -34,6 +34,8 @@
 #include "VISU_LookupTable.hxx"
 
 #include "VISU_PipeLineUtils.hxx"
+#include "VISU_AppendFilter.hxx"
+#include "VISU_GaussMergeFilter.hxx"
 
 #include <vtkPointSource.h>
 #include <vtkElevationFilter.h>
@@ -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();
+}
index cdb2378e23d60a1f8308932c1ce1640022ab35d9..051362357ff8325393e766182e7cd9b1f011cc8a 100644 (file)
@@ -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<VISU_AppendFilter>      myAppendFilter;
+  vtkSmartPointer<VISU_GaussMergeFilter>  myMergeFilter;
+
 private:
   VISU_GaussPointsPL(const VISU_GaussPointsPL&);  // Not implemented.
   void operator=(const VISU_GaussPointsPL&);  // Not implemented.
index 55352b8e9c9276efa08a6556ba523a56b7aa3a37..a8784c811a2ee3154c3bd036e4adb6687e5c6917 100644 (file)
@@ -144,17 +144,6 @@ VISU_ScalarMapPL
                bool theIsCopyInput)
 {
   Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
-  if(this != thePipeLine){
-    if(VISU_ScalarMapPL *aPipeLine = dynamic_cast<VISU_ScalarMapPL*>(thePipeLine)){
-      if(aPipeLine->IsExternalGeometryUsed()){
-       ClearGeometry();
-       int aNbOfGeometry = aPipeLine->GetNumberOfGeometry();
-       for(int aGeomNumber = 0; aGeomNumber < aNbOfGeometry; aGeomNumber++)
-         AddGeometry(aPipeLine->GetGeometry(aGeomNumber));
-      }else
-       SetSourceGeometry();
-    }
-  }
 }
 
 
index 90915b17368a767caef253587430e35c6f6e4c04..3b90cc1786e21b0d050cfcbd5e3a8339f942f1e9 100644 (file)
@@ -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<VISU::ScalarMap_i*>(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<VISU::ScalarMap_i*>(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() );
index 65e2dd082619fd25c5fa46fe28c7a58ade184fba..118e2272008c0b480b9430ddb7b7e5ace0d2f712 100644 (file)
@@ -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<<aGroupName<<"|";   
+  }
+  Storable::DataToStream(theStr, "myGeomNameList",  aGeomNameList.str());
+}
+
+//----------------------------------------------------------------------------
+const VISU::ColoredPrs3d_i
+::TGroupNames&
+VISU::ColoredPrs3d_i
+::GetGroupNames()
+{
+  return myGroupNames;
+}
+
+//----------------------------------------------------------------------------
+bool
+VISU::ColoredPrs3d_i
+::IsGroupsUsed()
+{
+  return !myGroupNames.empty();
 }
 
 
index 63d54e63cd2a1d299159de958df244602efbc2dc..60fae1545646b981b432081b884951d783ba7584 100644 (file)
@@ -32,6 +32,8 @@
 #include "VISU_BoostSignals.h"
 #include "SALOME_GenericObjPointer.hh"
 
+#include <set>
+
 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<TGroupName> 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;
+
   };
 
 
index 0495c37748c5c44e61387c62996f4f63e77094b6..aea67bc018a99c96bcf6ac2e5e88351c5bb46f0f 100644 (file)
@@ -305,6 +305,13 @@ namespace VISU
     else
       theStr<<thePrefix<<theName<<".SetSourceRange()"<<endl;
 
+    const VISU::ColoredPrs3d_i::TGroupNames aGroupNames = theServant->GetGroupNames();
+    VISU::ColoredPrs3d_i::TGroupNames::const_iterator anIter = aGroupNames.begin();
+    for(; anIter != aGroupNames.end(); anIter++){
+      const std::string& aGroupName = *anIter;
+      theStr<<thePrefix<<theName<<".AddMeshOnGroup('"<<aGroupName<<"')"<<endl;
+    }
+    
     return thePrefix;
   }
 
@@ -405,12 +412,6 @@ namespace VISU
     }
     theStr<<thePrefix<<theName<<".SetScaling("<<aParam<<")"<<endl;
 
-    const VISU::ScalarMap_i::TGroupNames aGroupNames = theServant->GetGroupNames();
-    VISU::ScalarMap_i::TGroupNames::const_iterator anIter = aGroupNames.begin();
-    for(; anIter != aGroupNames.end(); anIter++){
-      const std::string& aGroupName = *anIter;
-      theStr<<thePrefix<<theName<<".AddMeshOnGroup('"<<aGroupName<<"')"<<endl;
-    }
     return thePrefix;
   }
 
index 48331e5dacff4ff9ee2d02905aae97bb985a4ed8..fdbd8b681b6df7a78e3e699f0a71511cde1bbfd7 100644 (file)
@@ -697,6 +697,54 @@ VISU::GaussPoints_i
   return myGaussPointsPL->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
index 767e4c5287e350fa63851cbf867c4b95eed29b2a..13dc605f38f39e55a32068bf23a1bfd64dfef15e 100644 (file)
@@ -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
index 8a719f63c395c5d7ee6d45eb794fba71f5d550f3..900e36210ba3f5f4c92ef87cefee53600b5c895a 100644 (file)
@@ -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<<aGroupName<<"|";   
-  }
-  Storable::DataToStream(theStr, "myGeomNameList",  aGeomNameList.str());
 }
 
 
@@ -308,22 +282,6 @@ VISU::ScalarMap_i
                   (GetSpecificPL(), &VISU_ColoredPL::SetScaling, theScaling));
 }
 
-//----------------------------------------------------------------------------
-const VISU::ScalarMap_i::TGroupNames&
-VISU::ScalarMap_i
-::GetGroupNames()
-{
-  return myGroupNames;
-}
-
-//----------------------------------------------------------------------------
-bool
-VISU::ScalarMap_i
-::IsGroupsUsed()
-{
-  return !myGroupNames.empty();
-}
-
 //----------------------------------------------------------------------------
 void
 VISU::ScalarMap_i
index d52a2fb5704d3012b23e84c5d0525824593f4c67..5eff7e7606cbc51bdfc3aa432535bbdf8b6e6036 100644 (file)
@@ -183,19 +183,8 @@ namespace VISU
     void
     UpdateActor(VISU_Actor* theActor);
 
-    typedef std::string TGroupName;
-    typedef std::set<TGroupName> TGroupNames;
-    
-    const TGroupNames&
-    GetGroupNames();
-
-    //! Gets number of geometries
-    bool 
-    IsGroupsUsed();
-
   private:
     VISU_ScalarMapPL* myScalarMapPL;
-    TGroupNames myGroupNames;
   };
 }