'before_mergefrom_BR_mergefrom_BR_Dev_For_4_0'.
Sprout from BR_Dev_For_4_0 2007-04-25 09:22:23 UTC abd <abd@opencascade.com> 'Fix global links to local for correct work on any station'
Delete:
src/PIPELINE/VISU_PrsMergerPL.cxx
src/PIPELINE/VISU_PrsMergerPL.hxx
src/VISU_I/VISU_PrsMerger_i.cc
src/VISU_I/VISU_PrsMerger_i.hh
+++ /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_IDMapper.hxx"
-#include "VTKViewer_AppendFilter.h"
-
-#include "VISU_AppendFilter.hxx"
-#include "VISU_MergeFilter.hxx"
-
-#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():
- myAppendFilter(VISU_AppendFilter::New()),
- myMergeFilter(VISU_MergeFilter::New()),
- myScalars(NULL)
-{
- myAppendFilter->SetMergingInputs(true);
- myAppendFilter->Delete();
-
- myMergeFilter->SetMergingInputs(true);
- myMergeFilter->Delete();
-}
-
-VISU_PrsMergerPL
-::~VISU_PrsMergerPL()
-{}
-
-void
-VISU_PrsMergerPL
-::RemoveAllGeom()
-{
- myMeshGeometryList.clear();
- this->Execute();
-}
-
-void
-VISU_PrsMergerPL
-::ShallowCopy(VISU_PipeLine *thePipeLine)
-{
- if (MYDEBUG) MESSAGE("ShallowCopy");
- VISU_PrsMergerPL* aPipeLine = dynamic_cast<VISU_PrsMergerPL*>(thePipeLine);
- if(this == aPipeLine){
- TSupperClass::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),false);
- }
- SetScalars(aPipeLine->GetScalars(),true);
- }
- TSupperClass::ShallowCopy(thePipeLine);
-}
-
-bool
-VISU_PrsMergerPL
-::SetGeometry(VISU_PipeLine* theGeometry,bool theUpdate)
-{
- if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::SetGeometry()");
- myMeshGeometryList.clear();
-
- if(this->checkGeometry(theGeometry)){
- myMeshGeometryList.push_back(theGeometry);
- if (MYDEBUG) MESSAGE("this->GetGeometry(0)->GetIDMapper()="<<this->GetGeometry(0)->GetIDMapper());
-
- if(theUpdate)
- this->Execute();
-
- return true;
- } else
- return false;
-
-}
-
-int
-VISU_PrsMergerPL
-::AddBackGeometry(VISU_PipeLine* theGeometry,bool theUpdate)
-{
- if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::AddBackGeometry() "<<theGeometry);
- if(theGeometry == NULL) return -1;
- int aGeomNum = this->GetGeometryNumber(theGeometry);
- if(aGeomNum == -1){
- bool aCheckGeom = this->checkGeometry(theGeometry);
- if(aCheckGeom){
- myMeshGeometryList.push_back(theGeometry);
-
- if(theUpdate)
- this->Execute();
-
- 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);
- this->Execute();
- 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,bool theUpdate)
-{
- if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::SetScalars()");
- if ( this->checkScalars( theInput ) ){
- myScalars = theInput;
- VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars());
- myScalarRanges = aScalarMap->GetScalarRange();
- if(theUpdate)
- this->Execute();
- return true;
- } else
- return false;
-}
-
-void
-VISU_PrsMergerPL
-::Init()
-{
- Superclass::Init();
- if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Init() this="<<this);
- this->Execute();
-}
-
-void
-VISU_PrsMergerPL
-::Update()
-{
- if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Update()");
- Superclass::Update();
- Execute();
-}
-
-void
-VISU_PrsMergerPL
-::Build()
-{
- if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Build()");
- TSupperClass::Build(); // call DoHook method
-}
-
-void
-VISU_PrsMergerPL
-::SetInitialRange()
-{
- myMapper->UseLookupTableScalarRangeOff();
-}
-
-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;
-// }
- if(aNbPoints < 1)
- 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;
-// }
- if(aNbPoints < 1)
- return false;
- return true;
-}
-
-void
-VISU_PrsMergerPL
-::Execute(){
- /* Where are next situations:
- * 1. Timestamp on entity=NODE
- * 1.1 Group Cell - OK
- * 1.2 Group Cell + Point - ERR (remove points groups)
- * 1.3 Group Node - ERR (remove points groups)
- * 2. Timesatamp on entity=CELL
- * 2.1 Group Cell - OK
- * 2.2 Group Point - ERR (remove points groups)
- */
- if(MYDEBUG) MESSAGE("VISU_PrsMergerPL::Execute()");
-
- myAppendFilter->RemoveAllInputs();
- if(!myMeshGeometryList.empty()){
- const VISU::PIDMapper& aScalarsIDMapper = myScalars->GetIDMapper();
- VISU::TVTKOutput* aScalarsOutput = aScalarsIDMapper->GetVTKOutput();
-
- // copy points to output from input first geometry
-
- VISU::TVTKOutput* aGeomOutput = NULL;
- vtkIdType aNbGeoms = this->GetNbGeometry();
- for(vtkIdType aGeomId = 0; aGeomId < aNbGeoms; aGeomId++){
- VISU_PipeLine* aGeomPipeLine = this->GetGeometry(aGeomId);
- const VISU::PIDMapper& aGeomIDMapper = aGeomPipeLine->GetIDMapper();
- aGeomOutput = aGeomIDMapper->GetVTKOutput();
- vtkIdType aNbCells = aGeomOutput->GetNumberOfCells();
-// if(aNbCells > 0)
-// if(aGeomOutput->GetCell(0)->GetCellType() == VTK_VERTEX )
-// continue;
-
- myAppendFilter->AddInput(aGeomOutput);
- }
-
- myAppendFilter->SetSharedPointsDataSet(aGeomOutput);
- myAppendFilter->Update();
-
- vtkUnstructuredGrid* aGeomDataSet = myAppendFilter->GetOutput();
- myMergeFilter->SetGeometry(aGeomDataSet);
-
- //copy array values
- myMergeFilter->SetScalars(aScalarsOutput);
- myMergeFilter->SetVectors(aScalarsOutput);
-
- myMergeFilter->RemoveFields();
- myMergeFilter->AddField("VISU_FIELD", aScalarsOutput);
- myMergeFilter->AddField("VISU_CELLS_MAPPER", aScalarsOutput);
- myMergeFilter->AddField("VISU_POINTS_MAPPER", aScalarsOutput);
-
- myMergeFilter->Update();
- SetInput(myMergeFilter->GetOutput());
- }else{
- if(myScalars != NULL){
- if(VISU_ScalarMapPL* aScalarMap = dynamic_cast<VISU_ScalarMapPL*>(this->GetScalars()))
- SetInput(aScalarMap->GetInput());
- }
- }
-}
+++ /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 "VISUPipeline.hxx"
-
-#include "VISU_ScalarMapPL.hxx"
-
-class VISU_AppendFilter;
-class VISU_MergeFilter;
-
-
-class VISU_PIPELINE_EXPORT 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.
- * \params theGeometry - visu pipeline with geometry.
- * \params theUpdate - update pipeline if true.
- * \retval TRUE - if geometry and scalars on the common mesh, esle FALSE.
- */
- virtual
- bool
- SetGeometry(VISU_PipeLine* theGeometry,bool theUpdate=true);
-
- /*!
- * Add geometry to back of myMeshGeometryList.
- * \params theInput - visu pipeline with geometry.
- * \params theUpdate - update pipeline if true.
- * \retval index of added geometry. (must be >= 0)
- * \retval -1, if geometry not added.
- */
- virtual
- int
- AddBackGeometry(VISU_PipeLine* theGeometry,bool theUpdate=true);
-
- /*!
- * 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.
- * \params theInput - visu pipeline with scalar values
- * \params theUpdate - update pipeline if true.
- * \retval TRUE - if scalars and geometry on the common mesh, esle FALSE.
- */
- virtual
- bool
- SetScalars(VISU_PipeLine* theInput,bool theUpdate=false);
-
- /*!
- * Gets input VISU_ScalarMapPL, which contain scalar values and ids.
- */
- virtual
- VISU_PipeLine*
- GetScalars();
-
- virtual
- void
- Init();
-
- virtual
- void
- Build();
-
- /*!
- * Calculate presentation, by merging of Geometry and Scalar Values.
- */
- virtual
- void
- Update();
-
- /*!
- * Set ranges of scalar values by input myScalars ranges.
- */
- void SetInitialRange();
-
-protected:
- TPipeLines myMeshGeometryList;
- vtkSmartPointer<VISU_AppendFilter> myAppendFilter;
- vtkSmartPointer<VISU_MergeFilter> myMergeFilter;
-
- vtkFloatingPointType* myScalarRanges;
- TPipeLine myScalars;
-
-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);
-
- void
- Execute();
-};
-
-#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 "SUIT_Session.h"
-#include "SALOME_Event.hxx"
-#include "SalomeApp_Study.h"
-#include "SalomeApp_Application.h"
-
-#include <vtkUnstructuredGrid.h>
-#include <vtkCellType.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("ScalarMap",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;
- }
- if(aC1 == 1)
- if(aStrSubMeshName[0] == QString("NULL"))
- 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
-::SetMapScale(double theMapScale)
-{
- myPrsMergerPL->SetMapScale(theMapScale);
-}
-
-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();
-
- UpdateIcon();
-}
-
-
-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: this="<<this);
-
- TSuperClass::SameAs(theOrigin);
-
- if(const PrsMerger_i* aPrs3d = dynamic_cast<const PrsMerger_i*>(theOrigin)){
- PrsMerger_i* anOrigin = const_cast<PrsMerger_i*>(aPrs3d);
- if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::SameAs: theOrigin="<<anOrigin);
- this->SetScalarMap(myMeshName.c_str(),VISU::Entity(myEntity),myFieldName.c_str(),myIteration);
- string_array_var aGroupNames = anOrigin->getGroupNames();
- RemoveAllGeom();
- for(int i=0;i<aGroupNames->length();i++){
- this->AddMeshOnGroup(myMeshName.c_str(),aGroupNames[i]);
- }
- Update();
- }
-}
-
-void VISU::PrsMerger_i::Update()
-{
- TSuperClass::Update();
-}
-
-VISU_Actor*
-VISU::PrsMerger_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO, bool toSupressShrinking)
-{
- if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::CreateActor this="<<this);
- return VISU::ScalarMap_i::CreateActor(theIO, toSupressShrinking);
-}
-
-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 this="<<this);
-
- 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();
-
- UpdateIcon();
-}
-
-CORBA::Long
-VISU::PrsMerger_i::
-AddMeshOnGroup(const char* theMeshName,
- const char* theGroupName)
-{
- if (MYDEBUG) MESSAGE("VISU::PrsMerger_i::AddMeshOnGroup |"<< theGroupName <<"| this="<<this);
- CORBA::Long aRetVal = -1;
- VISU::PIDMapper anIDMapper;
- anIDMapper = myResult->GetInput()->GetMeshOnGroup(theMeshName,theGroupName);
- if(!anIDMapper)
- MESSAGE("Warning: There are no mesh with group=|"<<theGroupName<<"|");
- if (MYDEBUG) MESSAGE("AddMeshOnGroup nbGeoms defore ="<<myPrsMergerPL->GetNbGeometry());
-
- bool isGroupInList = false;
- TNameAndEntityList::const_iterator aIter = myGeomNameEntityList.begin();
- for(;aIter!=myGeomNameEntityList.end();aIter++){
- if(aIter->first == std::string(theGroupName))
- {
- isGroupInList = true;
- break;
- }
- }
-
- if(!isGroupInList){
- 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();
-
- UpdateIcon();
-
- }
-
- 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 this="<<this);
- VISU::PIDMapper anIDMapper;
- anIDMapper = myResult->GetInput()->GetTimeStampOnMesh(theMeshName,(VISU::TEntity)theEntity,theFieldName,int(theStampsNum));
-
- myEntity = (VISU::TEntity)theEntity;
- myFieldName = theFieldName;
- myIteration = 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();
-}
-
-const char*
-VISU::PrsMerger_i
-::GetIconName()
-{
- if (!GetNumberOfGeom())
- return "ICON_TREE_SCALAR_MAP";
- else
- return "ICON_TREE_SCALAR_MAP_GROUPS";
-}
-
-void VISU::PrsMerger_i
-::UpdateIcon()
-{
- if (mySObject->_is_nil())
- return;
-
- SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
-
- // Check if the icon needs to be updated, update if necessary
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributePixMap_var aPixmap;
-
- anAttr = aStudyBuilder->FindOrCreateAttribute( mySObject, "AttributePixMap" );
- aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
-
- if ( aPixmap->GetPixMap() != (std::string)GetIconName() )
- aPixmap->SetPixMap(GetIconName());
-
- // Update Object Browser
- SUIT_Session* aSession = SUIT_Session::session();
- QPtrList<SUIT_Application> anApplications = aSession->applications();
- QPtrListIterator<SUIT_Application> anIter (anApplications);
- while (SUIT_Application* aSApp = anIter.current()) {
- SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSApp);
- if (!anApp) return;
- SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy());
- if (!aStudy) return;
- if (_PTR(Study) aCStudy = aStudy->studyDS()) {
- if (myStudy->StudyId() == aCStudy->StudyId()) {
- anApp->updateObjectBrowser();
- break;
- }
- }
- ++anIter;
- }
-}
-
-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();
-}
-
-bool
-VISU::PrsMerger_i
-::CheckGroup(const char* theGroupName)
-{
- if (MYDEBUG) MESSAGE("PrsMerger_i::CheckGroup :|"<<theGroupName<<"|");
- string aMeshName = myMeshName;
- string aGroupName = theGroupName;
-
- VISU::PIDMapper anIDMapper;
- anIDMapper = myResult->GetInput()->GetMeshOnGroup(aMeshName,theGroupName);
- if (MYDEBUG) MESSAGE("anIDMapper="<<anIDMapper);
- if(!anIDMapper) return false;
-
- bool aAllPoints = true;
- int aNbCellsInGeom = anIDMapper->GetVTKOutput()->GetNumberOfCells();
- if(aNbCellsInGeom>0){
- int aVtkCellType = anIDMapper->GetVTKOutput()->GetCellType(0);
- if (MYDEBUG) MESSAGE("CellType="<<aVtkCellType);
- switch(myEntity){
- case NODE_ENTITY:
- // Warning. May be unstable. Created for NPAL15200
- aAllPoints = false;
- break;
- case CELL_ENTITY:
- if(aVtkCellType != VTK_LINE &&
- aVtkCellType != VTK_POLY_LINE &&
- aVtkCellType != VTK_VERTEX &&
- aVtkCellType != VTK_PIXEL)
- aAllPoints = false;
- break;
- case EDGE_ENTITY:
- if(aVtkCellType == VTK_LINE ||
- aVtkCellType == VTK_POLY_LINE)
- aAllPoints = false;
- break;
- case FACE_ENTITY:
- if(aVtkCellType == VTK_TRIANGLE ||
- aVtkCellType == VTK_TRIANGLE_STRIP ||
- aVtkCellType == VTK_POLYGON ||
- aVtkCellType == VTK_QUAD)
- aAllPoints = false;
- break;
- }
- }
-
- if (MYDEBUG) MESSAGE("return="<<!aAllPoints);
- return (!aAllPoints);
-}
-
+++ /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_I.hxx"
-
-#include "VISU_ScalarMap_i.hh"
-#include "VISU_PrsMergerPL.hxx"
-
-#include "VISUConfig.hh"
-
-class VISU_MeshPL;
-
-namespace VISU{
-
- class VISU_I_EXPORT PrsMerger_i : public virtual POA_VISU::ScalarMap,
- 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;
-
- public:
- PrsMerger_i();
- PrsMerger_i(const PrsMerger_i&);
-
- 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;}
-
- VISU_PrsMergerPL* GetPrsMergerPL(){ return myPrsMergerPL;}
-
- virtual void Update();
-
- protected:
- virtual void DoHook();
- virtual const char* GetIconName();
- void UpdateIcon();
- 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);
-
- virtual
- void
- SetMapScale(double theMapScale = 1.0);
-
- 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,
- 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
-
- /*!
- * Return true, if group is good, esle false.
- * May be used, if SetScalarMap(...) olready .
- */
- bool CheckGroup(const char* theGroupName);
-
- };
-
-}
-
-#endif