--- /dev/null
+// VISU OBJECT : interactive object for VISU entities implementation
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File: VISU_PrsMergerPL.cxx
+// Author: Eugeny Nikolaev
+// Module : VISU
+
+#include "VISU_PrsMergerPL.hxx"
+#include "VISU_MeshPL.hxx"
+#include "VISU_ScalarMapPL.hxx"
+#include "VISU_MergeFilter.hxx"
+#include "VISU_IDMapper.hxx"
+#include "VTKViewer_AppendFilter.h"
+
+#include "VISU_PipeLineUtils.hxx"
+
+#include <vtkMapper.h>
+#include <vtkDataSet.h>
+#include <vtkObjectFactory.h>
+#include <vtkMergeFilter.h>
+#include <vtkDataSetMapper.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkObject.h>
+#include <vtkFloatArray.h>
+#include <vtkPointData.h>
+#include <vtkCellData.h>
+#include <vtkCellType.h>
+#include <vtkCell.h>
+
+#include <vector>
+#include <set>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+using namespace std;
+
+vtkStandardNewMacro(VISU_PrsMergerPL);
+
+VISU_PrsMergerPL
+::VISU_PrsMergerPL():
+ myMergeFilter(VISU_MergeFilter::New())
+{
+ myScalars = NULL;
+ myIsModified = true;
+
+ myMergeFilter->Delete();
+ myMeshGeometryList.clear();
+}
+
+VISU_PrsMergerPL
+::~VISU_PrsMergerPL()
+{
+ myMeshGeometryList.clear();
+}
+
+void
+VISU_PrsMergerPL
+::RemoveAllGeom()
+{
+ myMeshGeometryList.clear();
+ myIsModified = true;
+}
+
+void
+VISU_PrsMergerPL
+::ShallowCopy(VISU_PipeLine *thePipeLine)
+{
+ VISU_PrsMergerPL* aPipeLine = dynamic_cast<VISU_PrsMergerPL*>(thePipeLine);
+ if(this == aPipeLine){
+ myIsModified = true;
+ Superclass::ShallowCopy(thePipeLine);
+ return;
+ }
+ if(aPipeLine){
+ int aNbGeoms = aPipeLine->GetNbGeometry();
+ if (MYDEBUG) MESSAGE("aNbGeoms="<<aNbGeoms);
+ myMeshGeometryList.clear();
+ for(int i=0; i<aNbGeoms; i++){
+ AddBackGeometry(aPipeLine->GetGeometry(i));
+ }
+ SetScalars(aPipeLine->GetScalars());
+ }
+ Superclass::ShallowCopy(thePipeLine);
+}
+
+bool
+VISU_PrsMergerPL
+::SetGeometry(VISU_PipeLine* theGeometry)
+{
+ myMeshGeometryList.clear();
+ if(this->checkGeometry(theGeometry)){
+ myMeshGeometryList.push_back(theGeometry);
+ if (MYDEBUG) MESSAGE("this->GetGeometry(0)->GetIDMapper()="<<this->GetGeometry(0)->GetIDMapper());
+ myIsModified = true;
+ return true;
+ } else
+ return false;
+
+}
+
+int
+VISU_PrsMergerPL
+::AddBackGeometry(VISU_PipeLine* theGeometry)
+{
+ if(theGeometry == NULL) return -1;
+ int aGeomNum = this->GetGeometryNumber(theGeometry);
+ if(aGeomNum == -1){
+ if(this->checkGeometry(theGeometry)){
+ myMeshGeometryList.push_back(theGeometry);
+ myIsModified = true;
+ return (myMeshGeometryList.size()-1);
+ } else {
+ return -1;
+ }
+ } else {
+ return aGeomNum;
+ }
+}
+
+int
+VISU_PrsMergerPL
+::GetGeometryNumber(VISU_PipeLine* theGeometry)
+{
+ TPipeLine aPipeLine = theGeometry;
+ TPipeLines::const_iterator aIter = myMeshGeometryList.begin();
+ for(int i=0;aIter != myMeshGeometryList.end();aIter++,i++){
+ if( theGeometry == (*aIter).GetPointer() )
+ return i;
+ }
+
+ return -1;
+}
+
+void
+VISU_PrsMergerPL
+::RemoveGeometryById(int theId)
+{
+ if(theId >=0 && theId < myMeshGeometryList.size()){
+ TPipeLines::iterator aIter = myMeshGeometryList.begin();
+ for(;aIter != myMeshGeometryList.end();aIter++){
+ if( myMeshGeometryList[theId] == (*aIter)){
+ myMeshGeometryList.erase(aIter);
+ break;
+ }
+ }
+ }
+}
+
+VISU_PipeLine*
+VISU_PrsMergerPL
+::GetGeometry(int theId)
+{
+ if(theId >=0 && theId < myMeshGeometryList.size()){
+ return myMeshGeometryList[theId].GetPointer();
+ }
+ else
+ return NULL;
+}
+
+VISU_PipeLine*
+VISU_PrsMergerPL
+::GetScalars()
+{
+ return myScalars.GetPointer();
+}
+
+int
+VISU_PrsMergerPL
+::GetNbGeometry()
+{
+ return myMeshGeometryList.size();
+}
+
+bool
+VISU_PrsMergerPL
+::SetScalars(VISU_PipeLine* theInput)
+{
+ if ( this->checkScalars( theInput ) ){
+ myScalars = theInput;
+ VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars());
+ aScalarMap->Build();
+ aScalarMap->Init();
+ aScalarMap->Update();
+ myIsModified = true;
+ //SetInput(theInput->GetInput());
+ return true;
+ } else
+ return false;
+}
+
+void
+VISU_PrsMergerPL
+::Update()
+{
+ VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars());
+ VISU_PrsMergerPL* aPrsMerger = dynamic_cast<VISU_PrsMergerPL*>(this->GetScalars());
+ if(aScalarMap != NULL && aPrsMerger == NULL){
+ SetInput(myScalars->GetInput());
+ Superclass::Update();
+ }
+}
+
+void
+VISU_PrsMergerPL
+::SetInitialRange()
+{
+ myMapper->UseLookupTableScalarRangeOff();
+ VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars());
+ if(aScalarMap != NULL){
+ myScalarRanges = aScalarMap->GetScalarRange();
+ }
+}
+
+VISU_ScalarMapPL::THook*
+VISU_PrsMergerPL
+::DoHook()
+{
+ if(!myIsModified) return myOutput;
+
+ myOutput = NULL;
+ myIsModified = false;
+
+ if(myMeshGeometryList.size() != 0)
+ {
+ // Build mesh
+ typedef std::vector<int> TVec;
+
+ TVec aObjIds;// object ids from geometries
+ int anbGeoms;
+ int aGeomNbCells,aAllGeomNbCells,aScalarNbCells;
+ int aScalarNodeTuplesNum,aScalarCellTuplesNum;
+ vtkFloatArray* aOutputCellScalars;
+ VTKViewer_AppendFilter* aMergeGeoms;
+
+ aAllGeomNbCells = 0;
+
+ aMergeGeoms = VTKViewer_AppendFilter::New();
+ myMergeFilter->SetGeometry(aMergeGeoms->GetOutput());
+ VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars());
+ VISU_PrsMergerPL* aPrsMergerPL = dynamic_cast<VISU_PrsMergerPL*>(this->GetScalars());
+ if (aPrsMergerPL) {
+ if (MYDEBUG) MESSAGE("ERROR...");
+ if (MYDEBUG) MESSAGE("\t this=" << this << " aPrsMergerPL=" << aPrsMergerPL);
+ }
+ if(aScalarMap != NULL){
+ myMergeFilter->SetScalars(aScalarMap->GetOutput());
+ }
+
+ anbGeoms = this->GetNbGeometry();
+
+ for(int i=0; i < anbGeoms; i++) {
+ VISU_PipeLine* aCurrGeometry = this->GetGeometry(i);
+ if (aCurrGeometry) {
+ aCurrGeometry->Update();
+ const VISU::PIDMapper& aGM = aCurrGeometry->GetIDMapper();
+ int aNbCells = aGM->GetVTKOutput()->GetNumberOfCells();
+ if (aNbCells >0 )
+ if (aGM->GetVTKOutput()->GetCell(0)->GetCellType() == VTK_VERTEX )
+ continue;
+ aMergeGeoms->AddInput(aGM->GetVTKOutput());
+ aAllGeomNbCells += aNbCells;
+ for(int j=0; j < aNbCells; j++)
+ aObjIds.push_back(aGM->GetElemObjID(j));
+ }
+ }
+ aMergeGeoms->Update();
+ myMergeFilter->Update();
+
+ if (MYDEBUG){
+ // Geometry debug information
+ for(int i=0; i< anbGeoms; i++){
+ VISU_PipeLine* aCurrGeometry = this->GetGeometry(i);
+ const VISU::PIDMapper& aGeomMapper = aCurrGeometry->GetIDMapper();
+ aGeomNbCells = aGeomMapper->GetVTKOutput()->GetNumberOfCells();
+ cout << "Input Geometry[" << i << "]:" << endl;
+ cout << "\tnumber of points:" << aGeomMapper->GetVTKOutput()->GetNumberOfPoints() << endl;
+ cout << "\tnumber of cells :" << aGeomMapper->GetVTKOutput()->GetNumberOfCells() << " cell type=" << aGeomMapper->GetVTKOutput()->GetCell(0)->GetCellType() << endl;
+ int aNbCells = aGeomNbCells;
+ for(int i=0; i<aNbCells; i++){
+ int anObjID = aGeomMapper->GetElemObjID(i);
+ int aVTKID = aGeomMapper->GetElemVTKID(anObjID);
+ cout <<"\t\t" << anObjID << ";"<<aVTKID<<endl;
+ }
+ }
+ }
+
+ const VISU::PIDMapper& aScalarMapper = myScalars->GetIDMapper();
+
+ // Scalars debug information
+ if (MYDEBUG){
+ int aNbCells = aScalarMapper->GetVTKOutput()->GetNumberOfCells();
+ cout << "myScalars:" << endl;
+ cout << "\tnumber of points:" << aScalarMapper->GetVTKOutput()->GetNumberOfPoints() << endl;
+ cout << "\tnumber of cells :" << aNbCells << endl;
+ for(int i=0; i<aNbCells; i++){
+ int anObjID = aScalarMapper->GetElemObjID(i);
+ int aVTKID = aScalarMapper->GetElemVTKID(anObjID);
+ cout <<"\t\t" << anObjID << ";"<<aVTKID<<endl;
+ }
+ }
+
+ aScalarCellTuplesNum = aScalarMapper->GetVTKOutput()->GetCellData()->GetNumberOfTuples();
+
+ if (aScalarCellTuplesNum > 0) {
+ // copy scalars from cell data
+ if(myMergeFilter->GetOutput()->GetCellData()->GetNumberOfTuples() == 0 ){
+
+ vtkCellData* cdM = myMergeFilter->GetOutput()->GetCellData();
+ aOutputCellScalars = vtkFloatArray::New();
+ aOutputCellScalars->SetNumberOfTuples(aAllGeomNbCells);
+
+ if(MYDEBUG) cout << "Output:" << endl;
+
+ TVec::const_iterator aIdsIter = aObjIds.begin();
+ for(int i=0; aIdsIter != aObjIds.end(); aIdsIter++){
+ int anObjID = *aIdsIter;
+ int aVTKID = aScalarMapper->GetElemVTKID(anObjID);
+ float* aTuple = aScalarMapper->GetVTKOutput()->GetCellData()->GetTuple(aVTKID);
+ if(MYDEBUG)
+ cout <<"\t\t" << anObjID << ";"<<aVTKID<<";"<<i<<endl;
+ aOutputCellScalars->SetTuple(i,aTuple);
+ i++;
+ }
+ cdM->SetScalars(aOutputCellScalars);
+ aOutputCellScalars->Delete();
+ }
+ }
+
+
+ if (MYDEBUG) cout << "\tmyMergeFilter->GetUnstructuredGridOutput()="
+ <<myMergeFilter->GetUnstructuredGridOutput()<<endl;
+
+ SetInput(myMergeFilter->GetUnstructuredGridOutput());
+
+ if (MYDEBUG) cout << "\tmyMergeFilter->GetOutput()="
+ <<myMergeFilter->GetOutput()<<endl;
+
+ aMergeGeoms->Delete();
+ myOutput = myMergeFilter->GetOutput();
+
+ return myOutput;
+ }
+ else
+ {
+ if(myScalars != NULL)
+ {
+ VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars());
+ VISU_PrsMergerPL* aPrsMerger = dynamic_cast<VISU_PrsMergerPL*>(this->GetScalars());
+ if(aPrsMerger != NULL){
+ myOutput = NULL;
+ return myOutput;
+ }
+ if(aScalarMap != NULL){
+ SetInput(aScalarMap->GetInput());
+ vtkDataSet* aOut = aScalarMap->GetOutput();
+ myOutput = aOut;
+
+ return myOutput;
+ }
+
+ return myOutput;
+ }
+ else
+ return myOutput;
+ }
+
+ return myOutput;
+}
+
+bool
+VISU_PrsMergerPL
+::checkGeometry(const VISU_PipeLine* thePipeLine)
+{
+ const VISU::PIDMapper& aMapper = thePipeLine->GetIDMapper();
+ int aNbPoints = aMapper->GetVTKOutput()->GetNumberOfPoints();
+ if (this->GetNbGeometry() > 0){
+ const VISU::PIDMapper& aMapper2 = this->GetGeometry(0)->GetIDMapper();
+ int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints();
+ if(aNbPoints2 != aNbPoints)
+ return false;
+ } else if (this->GetScalars()) {
+ const VISU::PIDMapper& aMapper2 = this->GetScalars()->GetIDMapper();
+ int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints();
+ if(aNbPoints2 != aNbPoints)
+ return false;
+ }
+ return true;
+}
+
+bool
+VISU_PrsMergerPL
+::checkScalars(const VISU_PipeLine* thePipeLine)
+{
+ const VISU::PIDMapper& aMapper = thePipeLine->GetIDMapper();
+ int aNbPoints = aMapper->GetVTKOutput()->GetNumberOfPoints();
+ if (this->GetNbGeometry() > 0){
+ const VISU::PIDMapper& aMapper2 = this->GetGeometry(0)->GetIDMapper();
+ int aNbPoints2 = aMapper2->GetVTKOutput()->GetNumberOfPoints();
+ if(aNbPoints2 != aNbPoints)
+ return false;
+ }
+ return true;
+}
--- /dev/null
+// VISU OBJECT : interactive object for VISU entities implementation
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File: VISU_PrsMergerPL.hxx
+// Author: Eugeny Nikolaev
+// Module : VISU
+
+#ifndef VISU_PrsMergerPL_HeaderFile
+#define VISU_PrsMergerPL_HeaderFile
+
+#include "VISU_ScalarMapPL.hxx"
+
+class VISU_MergeFilter;
+
+class VISU_PrsMergerPL : public VISU_ScalarMapPL
+{
+ typedef VISU_ScalarMapPL TSupperClass;
+
+protected:
+ VISU_PrsMergerPL();
+ VISU_PrsMergerPL(const VISU_PrsMergerPL&);
+
+ virtual
+ ~VISU_PrsMergerPL();
+
+public:
+
+ typedef TVTKSmartPtr<VISU_PipeLine> TPipeLine;
+ typedef std::vector<TPipeLine> TPipeLines;
+
+ vtkTypeMacro(VISU_PrsMergerPL,TSupperClass);
+
+ static
+ VISU_PrsMergerPL*
+ New();
+
+ virtual
+ void
+ ShallowCopy(VISU_PipeLine *thePipeLine);
+
+ /*!
+ * Add geometry of presentation to myMeshGeometryList.
+ * \retval TRUE - if geometry and scalars on the common mesh, esle FALSE.
+ */
+ virtual
+ bool
+ SetGeometry(VISU_PipeLine* theGeometry);
+
+ /*!
+ * Add geometry to back of myMeshGeometryList.
+ * \retval index of added geometry. (must be >= 0)
+ * \retval -1, if geometry not added.
+ */
+ virtual
+ int
+ AddBackGeometry(VISU_PipeLine* theGeometry);
+
+ /*!
+ * Get geometry id of myMeshGeometryList.
+ * \retval index of geometry. (must be >= 0)
+ * \retval -1 - if geometry not exists.
+ */
+ virtual
+ int
+ GetGeometryNumber(VISU_PipeLine* theGeometry);
+
+ /*!
+ * Remove geometry with id = theId from myMeshGeometryList.
+ * the id in [0,...]
+ */
+ virtual
+ void
+ RemoveGeometryById(int theId);
+
+ /*! Removes all geometries.
+ */
+ virtual
+ void
+ RemoveAllGeom();
+
+ /*!
+ * Gets geometry of presentation by id.
+ * \retval VISU_MeshPL - pointer
+ * the id in [0,...]
+ */
+ virtual
+ VISU_PipeLine*
+ GetGeometry(int theId=0);
+
+ /*!
+ * Gets number of geometrys
+ * \retval int - number
+ */
+ virtual
+ int
+ GetNbGeometry();
+
+ /*!
+ * Sets scalar values and ids by VISU_ScalarMapPL object.
+ * \retval TRUE - if scalars and geometry on the common mesh, esle FALSE.
+ */
+ virtual
+ bool
+ SetScalars(VISU_PipeLine* theInput);
+
+ /*!
+ * Gets input VISU_ScalarMapPL, which contain scalar values and ids.
+ */
+ virtual
+ VISU_PipeLine*
+ GetScalars();
+
+ /*!
+ * Calculate presentation, by merging of Geometry and Scalar Values.
+ */
+ virtual
+ void
+ Update();
+
+ /*!
+ * Set ranges of scalar values by input myScalars ranges.
+ */
+ void SetInitialRange();
+
+protected:
+ virtual
+ THook*
+ DoHook();
+
+ TPipeLines myMeshGeometryList;
+
+ TPipeLine myScalars;
+
+ TVTKSmartPtr<VISU_MergeFilter> myMergeFilter;
+
+ vtkFloatingPointType* myScalarRanges;
+
+private:
+
+ /*!
+ * Check if thePipeLine and "first element of list myMeshGeometryList" or
+ * "myScalars", has
+ * common DataPoints (simple check number of points).
+ * \retval TRUE - if has common points, esle FALSE.
+ */
+ bool
+ checkGeometry(const VISU_PipeLine* thePipeLine);
+
+
+ /*!
+ * Check if thePipeLine and first element of list myMeshGeometryList, has
+ * common DataPoints (simple check number of points).
+ * \retval TRUE - if has common points, esle FALSE.
+ */
+ bool
+ checkScalars(const VISU_PipeLine* thePipeLine);
+
+ bool myIsModified;
+ VISU_ScalarMapPL::THook* myOutput;
+
+};
+
+#endif
--- /dev/null
+// VISU OBJECT : interactive object for VISU entities implementation
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File : VISU_PrsMerger_i.cc
+// Author : Eugeny Nikolaev
+// Module : VISU
+
+#include "VISU_PrsMerger_i.hh"
+#include "VISU_PrsMergerPL.hxx"
+#include "VISU_MeshPL.hxx"
+#include "VISU_ScalarMapPL.hxx"
+#include "VISU_Convertor.hxx"
+
+#include "VISU_Result_i.hh"
+#include "VISU_ScalarMapAct.h"
+#include "VISU_ScalarMap_i.hh"
+#include "SUIT_ResourceMgr.h"
+
+#include <vtkUnstructuredGrid.h>
+#include <vtkProperty.h>
+#include <vtkMapper.h>
+
+using namespace VISU;
+using namespace std;
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+static int INCMEMORY = 4;
+
+int VISU::PrsMerger_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
+ const char* theFieldName, int theIteration, int isMemoryCheck)
+{
+ try{
+ float aSize = INCMEMORY*
+ theResult->GetInput()->GetTimeStampSize(theMeshName,(VISU::TEntity)theEntity,theFieldName,theIteration);
+ bool aResult = true;
+ if(isMemoryCheck){
+ aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
+ MESSAGE("PrsMerger_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<aResult);
+ }
+ return aResult;
+ }catch(std::exception& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was occured!");
+ }
+ return 0;
+}
+
+int VISU::PrsMerger_i::myNbPresent = 0;
+QString VISU::PrsMerger_i::GenerateName() { return VISU::GenerateName("PrsMerger.Shape",myNbPresent++);}
+
+const string VISU::PrsMerger_i::myComment = "PRSMERGER";
+const char* VISU::PrsMerger_i::GetComment() const { return myComment.c_str();}
+
+VISU::PrsMerger_i::
+PrsMerger_i(Result_i* theResult,
+ bool theAddToStudy) :
+ PrsObject_i(theResult->GetStudyDocument()),
+ Prs3d_i(theResult,theAddToStudy),
+ ColoredPrs3d_i(theResult,theAddToStudy),
+ ScalarMap_i(theResult,theAddToStudy),
+ myPrsMergerPL(NULL),
+ myScalarsPL(VISU_ScalarMapPL::New())
+{
+}
+
+VISU::PrsMerger_i::
+PrsMerger_i(Result_i* theResult,
+ SALOMEDS::SObject_ptr theSObject):
+ PrsObject_i(theResult->GetStudyDocument()),
+ Prs3d_i(theResult,theSObject),
+ ColoredPrs3d_i(theResult,theSObject),
+ ScalarMap_i(theResult,theSObject),
+ myPrsMergerPL(NULL),
+ myScalarsPL(VISU_ScalarMapPL::New())
+{
+}
+
+VISU::Storable* VISU::PrsMerger_i::Create(const char* theMeshName, VISU::Entity theEntity,
+ const char* theFieldName, int theIteration)
+{
+ if (MYDEBUG) MESSAGE("PrsMerger_i::Create");
+ myIsColored = true;
+ myColor.R = myColor.G = myColor.B = 0.5;
+ VISU::Storable* aRes = TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
+ this->SetScalarMap(theMeshName,theEntity,theFieldName,theIteration);
+
+ return aRes;
+}
+
+VISU::Storable* VISU::PrsMerger_i::Restore(const Storable::TRestoringMap& theMap)
+{
+ if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::Restore");
+
+ TSuperClass::Restore(theMap);
+
+ SetScalarMap(myMeshName.c_str(),
+ VISU::Entity(myEntity),
+ myFieldName.c_str(),
+ myIteration);
+ // myMeshName = VISU::Storable::FindValue(theMap,"myMeshName").latin1();
+ QStringList aStrSubMeshName = QStringList::split("|",VISU::Storable::FindValue(theMap,"myGeomNameList") );
+ QStringList aStrEntity = QStringList::split("|",VISU::Storable::FindValue(theMap,"myGeomEntityList") );
+ int aC1 = aStrSubMeshName.count();
+ int aC2 = aStrEntity.count();
+ if(aC1 != aC2){
+ // warning situation
+ return this;
+ }
+ for(int i=0;i < aC2;i++){
+ std::string aSubMeshName = aStrSubMeshName[i];
+ int aEntity = aStrEntity[i].toInt();
+ if(aEntity == -1){
+ // add group
+ AddMeshOnGroup(myMeshName.c_str(),
+ aSubMeshName.c_str());
+ } else if (aEntity >= 0){
+ // entity and family
+ if(aSubMeshName == ""){
+ // entity
+ SetMeshOnEntity(myMeshName.c_str(),
+ VISU::Entity(aEntity));
+ } else {
+ // family
+ SetFamilyOnEntity(myMeshName.c_str(),
+ VISU::Entity(aEntity),
+ aSubMeshName.c_str());
+ }
+
+ }
+ }
+
+ return this;
+}
+
+void VISU::PrsMerger_i::ToStream(std::ostringstream& theStr)
+{
+ if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::ToStream:");
+ TSuperClass::ToStream(theStr);
+
+ QString aStrSubMeshName,aStrEntity;
+ TNameAndEntityList::iterator aIter = myGeomNameEntityList.begin();
+ for(;aIter!=myGeomNameEntityList.end();aIter++){
+ std::string aStr = aIter->first + "|";
+ aStrSubMeshName.append(aStr.c_str());
+ aStrEntity.append(QString::number(aIter->second) + "|");
+ }
+
+ Storable::DataToStream( theStr, "myMeshName", myMeshName.c_str() );
+ Storable::DataToStream( theStr, "myGeomNameList", aStrSubMeshName.latin1());
+ Storable::DataToStream( theStr, "myGeomEntityList", aStrEntity.latin1());
+
+}
+
+void VISU::PrsMerger_i::clearMeshList()
+{
+ VISU_PrsMergerPL::TPipeLines::const_iterator aIter = myMeshPLList.begin();
+ for(int i=0;aIter != myMeshPLList.end();aIter++,i++){
+ ((*aIter).GetPointer())->Delete();
+ }
+ myMeshPLList.clear();
+ myGeomNameEntityList.clear();
+}
+
+void VISU::PrsMerger_i::RemoveAllGeom()
+{
+ clearMeshList();
+ myPrsMergerPL->RemoveAllGeom();
+}
+
+
+VISU::PrsMerger_i::~PrsMerger_i(){
+ if(MYDEBUG) if (MYDEBUG) MESSAGE("PrsMerger_i::~PrsMerger_i()");
+ this->clearMeshList();
+}
+
+void
+VISU::PrsMerger_i
+::SameAs(const Prs3d_i* theOrigin)
+{
+ if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::SameAs:");
+
+ TSuperClass::SameAs(theOrigin);
+
+ if(const PrsMerger_i* aPrs3d = dynamic_cast<const PrsMerger_i*>(theOrigin)){
+ PrsMerger_i* anOrigin = const_cast<PrsMerger_i*>(aPrs3d);
+ this->SetScalarMap(myMeshName.c_str(),VISU::Entity(myEntity),myFieldName.c_str(),myIteration);
+ string_array_var aGroupNames = anOrigin->getGroupNames();
+ for(int i=0;i<aGroupNames->length();i++){
+ this->AddMeshOnGroup(myMeshName.c_str(),aGroupNames[i]);
+ }
+ Update();
+ }
+}
+
+VISU_Actor*
+VISU::PrsMerger_i
+::CreateActor(const Handle(SALOME_InteractiveObject)& theIO, bool toSupressShrinking)
+{
+ if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::CreateActor:");
+ return VISU::ScalarMap_i::CreateActor(theIO, true);
+}
+
+VISU_Actor* VISU::PrsMerger_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+{
+ return CreateActor(theIO, false);
+}
+
+void VISU::PrsMerger_i::UpdateActor(VISU_Actor* theActor) {
+ if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::UpdateActor");
+ TSuperClass::UpdateActor(theActor);
+}
+
+void
+VISU::PrsMerger_i::
+SetMeshOnGroup(const char* theMeshName,
+ const char* theGroupName)
+{
+ if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::SetMeshOnGroup:");
+ VISU::PIDMapper anIDMapper;
+ anIDMapper = myResult->GetInput()->GetMeshOnGroup(theMeshName,theGroupName);
+
+ VISU_MeshPL* aTmpMesh = VISU_MeshPL::New();
+ aTmpMesh->SetIDMapper(anIDMapper);
+
+ if(myPrsMergerPL->SetGeometry(aTmpMesh)){
+ this->clearMeshList();
+ myMeshPLList.push_back(aTmpMesh);
+ TPairStringAndInt aPair((std::string)theGroupName,-1);
+ myGeomNameEntityList.push_back(aPair);
+ }
+ else
+ aTmpMesh->Delete();
+}
+
+CORBA::Long
+VISU::PrsMerger_i::
+AddMeshOnGroup(const char* theMeshName,
+ const char* theGroupName)
+{
+ if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::AddMeshOnGroup |"<< theGroupName <<"|");
+ CORBA::Long aRetVal = -1;
+ VISU::PIDMapper anIDMapper;
+ anIDMapper = myResult->GetInput()->GetMeshOnGroup(theMeshName,theGroupName);
+
+ VISU_MeshPL* aTmpMesh = VISU_MeshPL::New();
+ aTmpMesh->SetIDMapper(anIDMapper);
+
+ aRetVal = myPrsMergerPL->AddBackGeometry(aTmpMesh);
+
+ if(aRetVal >-1 ){
+ myMeshPLList.push_back(aTmpMesh);
+ TPairStringAndInt aPair((std::string)theGroupName,-1);
+ myGeomNameEntityList.push_back(aPair);
+ }
+ else
+ aTmpMesh->Delete();
+
+ if (MYDEBUG) MESSAGE("AddMeshOnGroup nbGeoms after ="<<myPrsMergerPL->GetNbGeometry());
+
+ return aRetVal;
+}
+
+void
+VISU::PrsMerger_i::
+SetFamilyOnEntity(const char* theMeshName,
+ const VISU::Entity theEntity,
+ const char* theFamilyName)
+{
+ VISU::PIDMapper anIDMapper;
+ anIDMapper = myResult->GetInput()->GetFamilyOnEntity(theMeshName,(VISU::TEntity)theEntity,theFamilyName);
+
+
+ VISU_MeshPL* aTmpMesh = VISU_MeshPL::New();
+ aTmpMesh->SetIDMapper(anIDMapper);
+
+ if(myPrsMergerPL->SetGeometry(aTmpMesh)){
+ myMeshPLList.push_back(aTmpMesh);
+ TPairStringAndInt aPair((std::string)theFamilyName,(int)theEntity);
+ myGeomNameEntityList.push_back(aPair);
+ }
+ else
+ aTmpMesh->Delete();
+}
+
+void
+VISU::PrsMerger_i::
+SetMeshOnEntity(const char* theMeshName,
+ const VISU::Entity theEntity)
+{
+ VISU::PIDMapper anIDMapper;
+ anIDMapper = myResult->GetInput()->GetMeshOnEntity(theMeshName,(VISU::TEntity)theEntity);
+ VISU_MeshPL* aTmpMesh = VISU_MeshPL::New();
+ aTmpMesh->SetIDMapper(anIDMapper);
+
+ if(myPrsMergerPL->SetGeometry(aTmpMesh)){
+ myMeshPLList.push_back(aTmpMesh);
+ TPairStringAndInt aPair("",(int)theEntity);
+ myGeomNameEntityList.push_back(aPair);
+ }
+ else
+ aTmpMesh->Delete();
+}
+
+void
+VISU::PrsMerger_i::
+SetScalarMap(const char* theMeshName,
+ const VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theStampsNum)
+{
+ if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::SetScalarMap");
+ VISU::PIDMapper anIDMapper;
+ anIDMapper = myResult->GetInput()->GetTimeStampOnMesh(theMeshName,(VISU::TEntity)theEntity,theFieldName,int(theStampsNum));
+ myScalarsPL->SetIDMapper(anIDMapper);
+ myPrsMergerPL->SetScalars(myScalarsPL);
+}
+
+void
+VISU::PrsMerger_i::
+SetScalarMap(VISU_PipeLine* thePipeLine)
+{
+ if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::SetScalarMap");
+ VISU_ScalarMapPL* aInputScalars = dynamic_cast<VISU_ScalarMapPL*>(thePipeLine);
+ VISU::PIDMapper anIDMapper = aInputScalars->GetIDMapper();
+ myScalarsPL->SetIDMapper(anIDMapper);
+ if(aInputScalars)
+ myPrsMergerPL->SetScalars(myScalarsPL);
+}
+
+void
+VISU::PrsMerger_i::
+RemoveGeometryByName(const char* theName)
+{
+ // not implemented yet.
+}
+
+void
+VISU::PrsMerger_i::
+RemoveGeometryById(CORBA::Long theId)
+{
+ if(myGeomNameEntityList.size() != myMeshPLList.size()){
+ // warning situation. Some information lost
+ // check myGeomNameEntityList and myMeshPLList
+ }
+
+ if(theId >=0 && (int)theId < myMeshPLList.size()){
+ VISU_PrsMergerPL::TPipeLines::iterator aIter = myMeshPLList.begin();
+ for(;aIter != myMeshPLList.end();aIter++){
+ if( myMeshPLList[theId] == (*aIter)){
+ myMeshPLList.erase(aIter);
+ break;
+ }
+ }
+ }
+ if(theId >=0 && (int)theId < myGeomNameEntityList.size()){
+ TNameAndEntityList::iterator aIter = myGeomNameEntityList.begin();
+ for(;aIter != myGeomNameEntityList.end();aIter++){
+ if( myGeomNameEntityList[theId] == (*aIter) ){
+ myGeomNameEntityList.erase(aIter);
+ break;
+ }
+ }
+ }
+ myPrsMergerPL->RemoveGeometryById((int)theId);
+}
+
+void
+VISU::PrsMerger_i
+::DoHook(){
+ if(!myPipeLine) myPipeLine = VISU_PrsMergerPL::New();
+ myPrsMergerPL = dynamic_cast<VISU_PrsMergerPL*>(myPipeLine);
+ myPipeLine->GetMapper()->SetScalarVisibility(IsColored());
+ TSuperClass::DoHook();
+}
+
+CORBA::Long
+VISU::PrsMerger_i
+::GetNumberOfGeom()
+{
+ if(myPrsMergerPL)
+ return myPrsMergerPL->GetNbGeometry();
+ else
+ return 0;
+}
+
+string_array*
+VISU::PrsMerger_i
+::getGroupNames()
+{
+ string_array_var myseq = new string_array;
+ if(myPrsMergerPL){
+ vector<string> aGroupNames;
+ TNameAndEntityList::const_iterator aIter = myGeomNameEntityList.begin();
+ for(;aIter!=myGeomNameEntityList.end();aIter++){
+ TPairStringAndInt aPair = (*aIter);
+ if(aPair.second == -1)
+ aGroupNames.push_back(aPair.first);
+ }
+ myseq->length(aGroupNames.size());
+ vector<string>::const_iterator aNamesIter = aGroupNames.begin();
+ for(int i=0;aNamesIter!=aGroupNames.end();i++,aNamesIter++){
+ myseq[i] = CORBA::string_dup((*aNamesIter).c_str());
+ }
+ }
+ return myseq._retn();
+}
--- /dev/null
+// VISU OBJECT : interactive object for VISU entities implementation
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File : VISU_PrsMerger_i.hh
+// Author : Eugeny Nikolaev
+// Module : VISU
+
+#ifndef VISU_PrsMerger_i_HeaderFile
+#define VISU_PrsMerger_i_HeaderFile
+#include "VISU_ScalarMap_i.hh"
+#include "VISU_PrsMergerPL.hxx"
+
+#include "VISUConfig.hh"
+
+class VISU_MeshPL;
+
+namespace VISU{
+
+ class PrsMerger_i : public virtual POA_VISU::PrsMerger,
+ public virtual ScalarMap_i
+ {
+
+ /*!
+ * eON_GROUP - mesh created on group
+ * eFAMILY_ON_ENTITY - mesh created on family on entity
+ * eON_ENTITY - mesh created on entity (default value)
+ */
+ enum EMeshGeomPlace {eON_GROUP=1,eFAMILY_ON_ENTITY=2,eON_ENTITY=3};
+
+ static int myNbPresent;
+ PrsMerger_i();
+ PrsMerger_i(const PrsMerger_i&);
+
+ public:
+
+ typedef ScalarMap_i TSuperClass;
+ typedef std::pair<std::string,int> TPairStringAndInt;
+ typedef std::vector<TPairStringAndInt> TNameAndEntityList;
+
+ explicit
+ PrsMerger_i(Result_i* theResult,
+ bool theAddToStudy);
+ explicit
+ PrsMerger_i(Result_i* theResult,
+ SALOMEDS::SObject_ptr theSObject);
+ virtual void SameAs(const Prs3d_i* theOrigin);
+ virtual ~PrsMerger_i();
+
+ virtual VISU::VISUType GetType() { return VISU::TPRSMERGER;};
+
+ virtual CORBA::Boolean IsColored() { return myIsColored; }
+ virtual void ShowColored(CORBA::Boolean theColored) { myIsColored = theColored; }
+
+ virtual SALOMEDS::Color GetColor() { return myColor;}
+ virtual void SetColor(const SALOMEDS::Color& theColor) { myColor = theColor;}
+
+ typedef VISU::PrsMerger TInterface;
+
+ VISU_PrsMergerPL* GetPrsMergerPL(){ return myPrsMergerPL;}
+
+ protected:
+ virtual void DoHook();
+ void clearMeshList();
+
+ VISU_PrsMergerPL* myPrsMergerPL;
+ VISU_PrsMergerPL::TPipeLines myMeshPLList;
+ VISU_ScalarMapPL* myScalarsPL;
+
+ SALOMEDS::Color myColor;
+ bool myIsColored;
+
+ /*! Warning! This variable must be maked as list, if
+ * you we will need in different mesh entities (ENTITY,FAMILY,GROUP) as geometries.
+ */
+ TNameAndEntityList myGeomNameEntityList;
+
+ public:
+ static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
+ const char* theFieldName, int theIteration, int isMemoryCheck = true);
+
+ virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity,
+ const char* theFieldName, int theIteration);
+
+ virtual void ToStream(std::ostringstream& theStr);
+
+ virtual Storable* Restore(const Storable::TRestoringMap& theMap);
+
+ static const std::string myComment;
+ virtual const char* GetComment() const;
+ virtual QString GenerateName();
+
+ virtual
+ VISU_Actor*
+ CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
+
+ virtual
+ VISU_Actor*
+ CreateActor(const Handle(SALOME_InteractiveObject)& theIO, bool toSupressShrinking);
+
+ virtual void UpdateActor(VISU_Actor* theActor) ;
+
+ /*!
+ * Sets geometry of mesh as group
+ */
+ virtual void SetMeshOnGroup(const char* theMeshName,
+ const char* theGroupName);
+
+ /*!
+ * Add geometry of mesh as group
+ * \retval the id of added group.
+ */
+ virtual CORBA::Long AddMeshOnGroup(const char* theMeshName,
+ const char* theGroupName);
+
+ /*!
+ * Remove geometry from list by Name
+ */
+ virtual void RemoveGeometryByName(const char* theName);
+
+ /*!
+ * Removes geometry from list by id
+ * Note: theId number in [0,...]
+ *
+ * Waring: if you delete not 0 element, others indexes will be increased.
+ * Example:
+ * 0,1,2,3,4 - indexes
+ * remove 2 index
+ * new sequence:
+ * 0,1,2,3,4 , where are 0 = 0, 1 = 1, 3 = 2, 4 = 3.
+ */
+ virtual void RemoveGeometryById(CORBA::Long theId);
+
+
+ /*!
+ * Sets geometry of mesh as family on entity
+ */
+ virtual void SetFamilyOnEntity(const char* theMeshName,
+ const VISU::Entity theEntity,
+ const char* theFamilyName);
+
+ /*!
+ * Sets geometry of mesh as mesh on entity
+ */
+ virtual void SetMeshOnEntity(const char* theMeshName,
+ const VISU::Entity theEntity);
+
+
+ /*!
+ * Sets scalars as scalar map
+ */
+ virtual void SetScalarMap(const char* theMeshName,
+ const VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theStampsNum);
+
+ /*!
+ * Get number of geometries.
+ */
+ CORBA::Long GetNumberOfGeom();
+
+
+ /*!
+ * Get group names.
+ */
+ string_array* getGroupNames();
+
+ /*!
+ * Sets scalars as scalar map
+ */
+ void SetScalarMap(VISU_PipeLine* thePipeLine);
+
+ /*!
+ * Removes all geometries.
+ */
+ virtual void RemoveAllGeom();
+
+
+ /*! Warning!
+ * see \a myGeomNameEntityList
+ */
+ virtual CORBA::Long GetMeshGeometryPlace(CORBA::Long theId){return CORBA::Long(1);};// must bee filled
+
+ };
+
+}
+
+#endif