CHECK_MED
+AM_CONDITIONAL(MED_ENABLE_MULTIPR, [test "$ENABLE_MULTIPR" = yes])
+
echo
echo ---------------------------------------------
echo Summary
TFIELD, /*!< Field represents the results of calculations (it can be scalar or vector values), grouped together under one physical concept. */
TTIMESTAMP, /*!<Time stamp represents a subfield: the results of calculations are taken in one definite moment. */
TANIMATION, /*!< Represents Animation object. */
+ TCOLOREDPRS3DHOLDER, /*!< Colored 3D presentation holder */
+ TCOLOREDPRS3DCACHE, /*!< Colored 3D presentation cache */
+ TPART, /*!< MULTIPR: part of a mesh */
TALL
};
};
//-------------------------------------------------------
+ interface Result;
/*! \brief 3D presentation interface
*
* This is a root class for all 3D presentations, which can be displayed in %VISU module.
*/
- interface Prs3d : PrsObject, SALOME::GenericObj {
- //interface Prs3d : PrsObject{
+ interface Prs3d : PrsObject, SALOME::GenericObj
+ {
+ /*!
+ * Applies a set basic input parameters to the 3D presentation
+ * \return True of the set of input parameters is correct and was succesfully applied,
+ * False otherwise
+ */
+ boolean Apply(in boolean theReInit);
+
+ //! Sets Result object used by presentation to obtain its input
+ void SetResultObject(in Result theResult);
+
+ //! Gets Result object used by presentation to obtain its input
+ Result GetResultObject();
+
+ //! Sets name of the mesh used by presentation to obtain its input
+ void SetMeshName(in string theMeshName);
+
+ //! Gets name of the mesh used by presentation to obtain its input
+ string GetMeshName();
+
+ /*!
+ * Move the 3D presentation according to the given offset parameters
+ */
void SetOffset(in float theDx, in float theDy, in float theDz);
+
+
+ /*!
+ * Gets offset parameters for the 3D presentation
+ */
void GetOffset(out float theDx, out float theDy, out float theDz);
+
+ /*!
+ * Gets memory size actually used by the presentation (Mb).
+ */
+ float GetMemorySize();
};
/*!
* bar is displayed along with each colored field presentation and serves for
* consulting the correspondance between colors and data values.
*/
- interface ColoredPrs3d : Prs3d {
+ interface ColoredPrs3d : Prs3d
+ {
+ /*! Sets Entity input parameter that defines where the parent mesh to be taken from.
+ */
+ void SetEntity(in Entity theEntity);
+ /*! Gets Entity input parameter that defines where the parent mesh is taken from.
+ */
+ Entity GetEntity();
+
+ /*! Sets name of field input parameter that defines what phisical data to be retrived.
+ */
+ void SetFieldName(in string theName);
+ /*! Gets name of field input parameter that defines what phisical data is retrived.
+ */
+ string GetFieldName();
+
+ /*! Sets number of timestamp input parameter that defines what time of phisical data to be retrived.
+ */
+ void SetTimeStampNumber(in long theTimeStampNumber);
+ /*! Gets number of timestamp input parameter that defines what time of phisical data is retrived.
+ */
+ long GetTimeStampNumber();
+
+ /*! Defines timestamp representation.
+ */
+ struct TimeStampInfo
+ {
+ string myTime;
+ long myNumber;
+ };
+
+ /*! Defines representation range of timestamps.
+ */
+ typedef sequence<TimeStampInfo> TimeStampsRange;
+
+ /*! Gets available range of timestamps.
+ */
+ TimeStampsRange GetTimeStampsRange();
+
+ /*! Defines whether this presentation is bound to timestamp or not.
+ */
+ boolean IsTimeStampFixed();
+
/*! Sets the method of coloring of the elements composing a 3D presentation.
*/
void SetScalarMode(in long theScalarMode);
*/
double GetMax();
+ /*!
+ * Gets the min boundary of the scalar bar from source data.
+ */
+ double GetSourceMin();
+
+ /*!
+ * Gets the max boundary of the scalar bar from source data.
+ */
+ double GetSourceMax();
+
+ /*!
+ * Defines whether the scalar range corresponds to the source data or not.
+ */
+ boolean IsRangeFixed();
+
/*! \brief Position of the scalar bar.
*
* Sets the position of the scalar bar origin on the screen.
};
+ //-------------------------------------------------------
+ interface View3D;
+ interface ColoredPrs3dCache;
+
+ /*! \brief %ColoredPrs3dHolder interface.
+ * Interface of 3d presentation's holder, which represents colored 3d presentations,
+ * created on fields. It is publishing in the object browser in a separate folder
+ * and can be controled by viewer's slider.
+ */
+ interface ColoredPrs3dHolder : PrsObject, SALOME::GenericObj
+ {
+ /*!
+ * Presentation input parameters.
+ */
+ struct BasicInput
+ {
+ Result myResult;
+ string myMeshName;
+ Entity myEntity;
+ string myFieldName;
+ long myTimeStampNumber;
+ };
+
+ /*!
+ * Apply input parameters to last visited presentation in the cache.
+ */
+ boolean Apply(in ColoredPrs3d thePrs3d,
+ in BasicInput theInput,
+ in View3D theView3D);
+
+ /*!
+ * Gets the last visited presentation in the cache.
+ */
+ ColoredPrs3d GetDevice();
+
+ /*!
+ * Gets type of the managed presentations.
+ */
+ VISUType GetPrsType();
+
+ /*!
+ * Gets TimeStampsRange information from the last visited presentation.
+ */
+ ColoredPrs3d::TimeStampsRange GetTimeStampsRange();
+
+ /*!
+ * Gets input parameters of the last visited presentation.
+ */
+ BasicInput GetBasicInput();
+
+ /*!
+ * Gets a %ColoredPrs3dCache, to which the holder belongs
+ */
+ ColoredPrs3dCache GetCache();
+
+ /*!
+ * Gets memory size actually used by the holder (Mb).
+ */
+ float GetMemorySize();
+ };
+
+
+ //-------------------------------------------------------
+ /*! \brief %ColoredPrs3dCache interface.
+ * This interface is responsible for memory management of 3d presentations.
+ * One cache corresponds to one study.
+ */
+ interface ColoredPrs3dCache : RemovableObject, SALOME::GenericObj
+ {
+ /*! This enumeration contains the cache memory modes. */
+ enum MemoryMode {
+ MINIMAL, /*!< Minimal memory mode (default behaviour). */
+ LIMITED /*!< Limited memory mode (fixed memory size for presentations). */
+ };
+
+ /*! This enumeration defines how to enlarge the cache limited memory. */
+ enum EnlargeType {
+ NO_ENLARGE, /*!< No need to enlarge (default behaviour). */
+ ENLARGE, /*!< Enlarge limited memory. */
+ IMPOSSIBLE /*!< Impossible to enlarge (not enough free memory). */
+ };
+
+ /*! Sets a memory mode.*/
+ void SetMemoryMode(in MemoryMode theMode);
+
+ /*! Gets a memory mode.*/
+ MemoryMode GetMemoryMode();
+
+ /*! Sets a memory size for limited mode (Mb). */
+ void SetLimitedMemory(in float theMemorySize);
+
+ /*! Gets a memory size for limited mode (Mb). */
+ float GetLimitedMemory();
+
+ /*!
+ * Gets memory size actually used by the cache system (Mb).
+ */
+ float GetMemorySize();
+
+ /*! Creates %ColoredPrs3dHolder.*/
+ ColoredPrs3dHolder CreateHolder(in VISUType theType,
+ in ColoredPrs3dHolder::BasicInput theInput);
+
+ /*! Gets a memory which is required to create a holder. */
+ EnlargeType GetRequiredMemory(in VISUType theType,
+ in ColoredPrs3dHolder::BasicInput theInput,
+ out float theRequiredMemory);
+ };
+
+
//-------------------------------------------------------
/*! \brief Interface of the %Scalar Map
*
*/
void SetRange(in double theMin, in double theMax);
+ /*!
+ * Sets scalar range that corresponds to the source data.
+ */
+ void SetSourceRange();
+
/*! %Orientation of the scalar bar (to provide backward compatibility). */
enum Orientation {
HORIZONTAL, /*!< Horizontal orientation of the scalar bar.*/
Orientation GetBarOrientation();
/*!
- * PrsMerger method:
- * Set mesh on group as geometry of presentation.(clear all previously added groups).
- * \param theMeshName - mesh name
- * \param theGroupName - group name
- */
- void SetMeshOnGroup(in string theMeshName,
- in string theGroupName);
-
- /*!
- * PrsMerger method:
* Add group as geometry of presentation.
* \param theMeshName - mesh name
* \param theGroupName - group name
*/
- long AddMeshOnGroup(in string theMeshName,
- in string theGroupName);
-
+ void AddMeshOnGroup(in string theGroupName);
+
- /*!
- * PrsMerger method:
- * Set scalar map of presentation.
- * \param theMeshName - mesh name
- * \param theFieldName - the name of scalar field
- * \param theStampsNum - the iteration number for scalar field
- * \param theEntity - entity of scalar field
- */
- void SetScalarMap(in string theMeshName,
- in Entity theEntity,
- in string theFieldName,
- in long theStampsNum);
-
/*!
* PrsMerger method:
* Remove all groups.(The scalar map will be placed on all mesh).
*/
interface ScalarMapOnDeformedShape : ScalarMap {
- /*!
- * Sets the source ranges of pipeline
- */
- void SetSourceRange(in double theMinRange,in double theMaxRange);
- /*!
- * Gets the minimum source range of pipeline
- */
- double GetSourceRangeMin();
- /*!
- * Gets the maximum source range of pipeline
- */
- double GetSourceRangeMax();
-
/*!
* Sets the scale of the presentatable object.
* \param theScale Double value defining the scale of this presentable object.
//-------------------------------------------------------
interface ViewManager;
- interface View3D;
/*! \brief %VISU_Gen interface
*
in string theSubMeshName,
in string theNewName);
+ /*!
+ * Creates a VISU 3D presentation according to the given type
+ * \param theType Type that defines what kind of 3D presentation should be created
+ */
+ Prs3d CreatePrs3d(in VISUType theType, in SALOMEDS::Study theStudy);
+
/*!
* Creates a mesh on the basis of the data generated in other sources (MED object or file).
* \param theResult Data generated in other sources. (MED object or file)
*/
ScalarMap ScalarMapOnField(in Result theResult, in string theMeshName,
in Entity theEntity, in string theFieldName,
- in double theIteration);
+ in long theIteration);
/*!
* Creates a Gauss Points presentation.
*/
GaussPoints GaussPointsOnField(in Result theResult, in string theMeshName,
in Entity theEntity, in string theFieldName,
- in double theIteration);
+ in long theIteration);
/*!
* Creates a deformed shape presentation.
*/
DeformedShape DeformedShapeOnField(in Result theResult, in string theMeshName,
in Entity theEntity, in string theFieldName,
- in double theIteration);
+ in long theIteration);
/*!
* Creates a deformed shape presentation.
*/
ScalarMapOnDeformedShape ScalarMapOnDeformedShapeOnField(in Result theResult, in string theMeshName,
in Entity theEntity, in string theFieldName,
- in double theIteration);
+ in long theIteration);
/*!
* Creates a vector presentation.
*/
Vectors VectorsOnField(in Result theResult, in string theMeshName,
in Entity theEntity, in string theFieldName,
- in double theIteration);
+ in long theIteration);
/*!
* Creates an iso surface presentation.
*/
IsoSurfaces IsoSurfacesOnField(in Result theResult, in string theMeshName,
in Entity theEntity, in string theFieldName,
- in double theIteration);
+ in long theIteration);
/*!
* Creates an stream lines presentation.
*/
StreamLines StreamLinesOnField(in Result theResult, in string theMeshName,
in Entity theEntity, in string theFieldName,
- in double theIteration);
+ in long theIteration);
/*!
* Creates a presentation of cut planes.
*/
CutPlanes CutPlanesOnField(in Result theResult, in string theMeshName,
in Entity theEntity, in string theFieldName,
- in double theIteration);
+ in long theIteration);
/*!
* Creates a presentation of cut lines.
*/
CutLines CutLinesOnField(in Result theResult, in string theMeshName,
in Entity theEntity, in string theFieldName,
- in double theIteration);
+ in long theIteration);
/*!
* Creates a Plot3D presentation.
*/
Plot3D Plot3DOnField(in Result theResult, in string theMeshName,
in Entity theEntity, in string theFieldName,
- in double theIteration);
+ in long theIteration);
/*!
* Creates a table presentation.
void DeleteResult(in Result theResult);
void DeletePrs3d(in Prs3d thePrs3d);
+
+ /*!
+ * Get or create %ColoredPrs3dCache object.
+ */
+ ColoredPrs3dCache GetColoredPrs3dCache(in SALOMEDS::Study theStudy);
};
/*! \brief %View interface
Visu_tree_isosurfaces_gr.png \
Visu_tree_isosurfaces.png \
Visu_tree_mesh.png \
+Visu_tree_multipr_full.png \
+Visu_tree_multipr_hide.png \
+Visu_tree_multipr_low.png \
+Visu_tree_multipr_medium.png \
Visu_tree_plot3d_gr.png \
Visu_tree_plot3d.png \
Visu_tree_result.png \
Visu_tree_visu.png \
Visu_vectors.png \
Visu_vvtk_switch.png \
-Visu_wireframe.png
-
+Visu_wireframe.png \
+Visu_slider_more.png \
+Visu_slider_avi.png \
+Visu_slider_first.png \
+Visu_slider_previous.png \
+Visu_slider_play.png \
+Visu_slider_pause.png \
+Visu_slider_next.png \
+Visu_slider_last.png
+
EXTRA_DIST+= VISUCatalog.xml.in
nodist_salomeres_DATA=VISUCatalog.xml
<parameter name="recorder_fps" value="17.3" />
<parameter name="recorder_quality" value="100" />
<parameter name="recorder_progressive" value="true" />
+ <parameter name="cache_memory_mode" value="1" />
+ <parameter name="cache_memory_limit" value="512" />
</section>
<section name="resources">
<!-- Module resources -->
lib_LTLIBRARIES = libVisuConvertor.la
salomeinclude_HEADERS= \
+ VISU_TypeList.hxx \
VISU_IDMapper.hxx \
- VISU_Convertor.hxx \
- VISU_ConvertorDef.hxx \
- VISU_Convertor_impl.hxx \
- VISU_ConvertorUtils.hxx \
+ VISU_ConvertorDef.hxx \
+ VISU_Structures.hxx \
+ VISU_Convertor.hxx \
+ VISU_ConvertorDef_impl.hxx \
+ VISU_Structures_impl.hxx \
+ VISU_MeshValue.hxx \
+ VISU_PointCoords.hxx \
+ VISU_Convertor_impl.hxx \
+ VISU_ConvertorUtils.hxx \
VISU_MergeFilter.hxx \
- VISU_ExtractUnstructuredGrid.hxx \
VISU_AppendFilter.hxx \
+ VISU_AppendPolyData.hxx \
+ VISU_AppendFilterUtilities.hxx \
+ VISU_ExtractUnstructuredGrid.hxx \
VISU_CommonCellsFilter.hxx \
VISUConvertor.hxx
dist_libVisuConvertor_la_SOURCES= \
VISU_IDMapper.cxx \
+ VISU_Structures.cxx \
VISU_Convertor.cxx \
+ VISU_Structures_impl.cxx \
+ VISU_MeshValue.cxx \
+ VISU_PointCoords.cxx \
VISU_Convertor_impl.cxx \
+ VISU_MedConvertor.cxx \
VISU_ConvertorUtils.cxx \
VISU_ExtractUnstructuredGrid.cxx \
- VISU_MergeFilter.cxx \
- VISU_MedConvertor.cxx \
VISU_AppendFilter.cxx \
+ VISU_AppendPolyData.cxx \
+ VISU_AppendFilterUtilities.cxx \
+ VISU_MergeFilter.cxx \
+ VISU_MergeFilterUtilities.cxx \
VISU_CommonCellsFilter.cxx
libVisuConvertor_la_CPPFLAGS= \
static int MYDEBUG = 0;
#endif
-//#define _DEXCEPT_
+//#define _DEBUG_ID_MAPPING_
+#define _DEXCEPT_
typedef vtkUnstructuredGrid TOutput;
//aCon->GetSize();
//return;
aCon->BuildEntities();
+ aCon->BuildGroups();
aCon->BuildFields();
aCon->BuildMinMax();
const VISU::TMeshMap& aMeshMap = aCon->GetMeshMap();
if(anEntity != VISU::NODE_ENTITY){
VISU::PGaussPtsIDMapper aGaussMesh =
aCon->GetTimeStampOnGaussPts(aMeshName,anEntity,aFieldName,aTimeStamp);
- VISU::TVTKOutput* aDataSet = aGaussMesh->GetVTKOutput();
- /*
+#ifdef _DEBUG_ID_MAPPING_
+ vtkDataSet* aDataSet = aGaussMesh->GetOutput();
+ aDataSet->Update();
int aNbCells = aDataSet->GetNumberOfCells();
+ cout<<"aNbCells = "<<aNbCells<<endl;
for(int anCellId = 0; anCellId < aNbCells; anCellId++){
VISU::TGaussPointID anObjID = aGaussMesh->GetObjID(anCellId);
- cout<<anObjID.first<<"; "<<anObjID.second<<endl;
+ cout<<anObjID.first<<"; "<<anObjID.second<<"; "<<aGaussMesh->GetNodeVTKID(anObjID.first)<<endl;
+ vtkFloatingPointType* aCoord = aGaussMesh->GetNodeCoord(anCellId);
+ cout<<aCoord[0]<<"; "<<aCoord[1]<<"; "<<aCoord[2]<<endl;
}
- */
+#endif
}else{
+ //continue;
VISU::PIDMapper anIDMapper =
aCon->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
- VISU::TVTKOutput* aDataSet = anIDMapper->GetVTKOutput();
- /*
+#ifdef _DEBUG_ID_MAPPING_
+ vtkDataSet* aDataSet = anIDMapper->GetOutput();
+ aDataSet->Update();
int aNbCells = aDataSet->GetNumberOfCells();
for(int anCellId = 0; anCellId < aNbCells; anCellId++){
int anObjID = anIDMapper->GetElemObjID(anCellId);
int aVTKID = anIDMapper->GetElemVTKID(anObjID);
cout<<anObjID<<"; "<<aVTKID<<endl;
}
- */
+#endif
}
//goto OK;
}
for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
VISU::PIDMapper anIDMapper = aCon->GetMeshOnEntity(aMeshName,anEntity);
- VISU::TVTKOutput* aDataSet = anIDMapper->GetVTKOutput();
- {
- /*
- int aNbCells, anCellId, anObjID, aVTKID;
- aNbCells = aDataSet->GetNumberOfCells();
- for(anCellId = 0; anCellId < aNbCells; anCellId++){
- anObjID = anIDMapper->GetElemObjID(anCellId);
- aVTKID = anIDMapper->GetElemVTKID(anObjID);
- cout<<anObjID<<"; "<<aVTKID<<endl;
- }
- */
+#ifdef _DEBUG_ID_MAPPING_
+ vtkDataSet* aDataSet = anIDMapper->GetOutput();
+ int aNbCells, anCellId, anObjID, aVTKID;
+ aNbCells = aDataSet->GetNumberOfCells();
+ for(anCellId = 0; anCellId < aNbCells; anCellId++){
+ anObjID = anIDMapper->GetElemObjID(anCellId);
+ aVTKID = anIDMapper->GetElemVTKID(anObjID);
+ cout<<anObjID<<"; "<<aVTKID<<endl;
}
+#endif
}
//Import families
#include "VISU_AppendFilter.hxx"
-#include <vtkCell.h>
-#include <vtkCellData.h>
-#include <vtkDataSetAttributes.h>
-#include <vtkDataSetCollection.h>
#include <vtkObjectFactory.h>
-#include <vtkPointData.h>
-#include <vtkUnstructuredGrid.h>
-
-#include <vtkPoints.h>
-#include <vtkIntArray.h>
-
-#include <algorithm>
-#include <vector>
-#include <map>
+//---------------------------------------------------------------
vtkCxxRevisionMacro(VISU_AppendFilter, "$Revision$");
vtkStandardNewMacro(VISU_AppendFilter);
+
+//---------------------------------------------------------------
VISU_AppendFilter
::VISU_AppendFilter():
- myIsMergingInputs(false)
+ TAppendFilterHelper(this)
{}
+
+//---------------------------------------------------------------
VISU_AppendFilter
::~VISU_AppendFilter()
{}
-void
-VISU_AppendFilter
-::SetSharedPointsDataSet(vtkPointSet* thePointsDataSet)
-{
- if(GetSharedPointsDataSet() == thePointsDataSet)
- return;
-
- mySharedPointsDataSet = thePointsDataSet;
-
- Modified();
-}
-
-vtkPointSet*
-VISU_AppendFilter
-::GetSharedPointsDataSet()
-{
- return mySharedPointsDataSet.GetPointer();
-}
-
-void
-VISU_AppendFilter
-::SetMergingInputs(bool theIsMergingInputs)
-{
- if(myIsMergingInputs == theIsMergingInputs)
- return;
-
- myIsMergingInputs = theIsMergingInputs;
- Modified();
-}
-
-bool
-VISU_AppendFilter
-::IsMergingInputs()
-{
- return myIsMergingInputs;
-}
-
-
-namespace
-{
- typedef vtkIdType TCellId;
- typedef vtkIdType TInputId;
- typedef std::pair<TInputId, TCellId> TInputCellId;
-
- typedef vtkIdType TObjectId;
- typedef std::map<TObjectId, TInputCellId> TObject2InputIdMap;
-
- void
- DoMergingInputs(vtkCellData *theCellData,
- TInputId theInputId,
- TObject2InputIdMap& theResult)
- {
- if(vtkDataArray *aDataArray = theCellData->GetArray("VISU_CELLS_MAPPER")){
- if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(aDataArray)){
- int aMaxId = anIntArray->GetMaxId();
- int* aPointer = anIntArray->GetPointer(0);
- int* anEndPointer = anIntArray->GetPointer(aMaxId + 1);
- for(vtkIdType aCellId = 0; aPointer != anEndPointer; aPointer++, aCellId++){
- TObjectId anObjectId = *aPointer;
- TObject2InputIdMap::iterator anIter = theResult.find(anObjectId);
- if(anIter != theResult.end())
- continue;
- TInputCellId anInputCellId(theInputId, aCellId);
- theResult.insert(anIter, TObject2InputIdMap::value_type(anObjectId, anInputCellId));
- }
- }
- }
- }
-
- struct TFillFieldList
- {
- vtkDataSetAttributes::FieldList myFieldList;
- bool myIsFirstCellData;
-
- TFillFieldList(vtkIdType theNbInputs):
- myFieldList(theNbInputs),
- myIsFirstCellData(true)
- {}
-
- void
- operator()(TInputId theInputId, vtkDataSet* theDataSet)
- {
- vtkCellData *aCellData = theDataSet->GetCellData();
- if(myIsFirstCellData){
- myFieldList.InitializeFieldList(aCellData);
- myIsFirstCellData = false;
- }else{
- myFieldList.IntersectFieldList(aCellData);
- }
- }
-
- virtual
- vtkIdType
- GetNbCells() const = 0;
- };
-
- struct TCellCounter: TFillFieldList
- {
- vtkIdType myNbCells;
-
- TCellCounter(vtkIdType theNbInputs):
- TFillFieldList(theNbInputs),
- myNbCells(0)
- {}
-
- void
- operator()(TInputId theInputId, vtkDataSet* theDataSet)
- {
- TFillFieldList::operator()(theInputId, theDataSet);
- myNbCells += theDataSet->GetNumberOfCells();
- }
-
- virtual
- vtkIdType
- GetNbCells() const
- {
- return myNbCells;
- }
- };
- struct TCellIdMerger: TFillFieldList
- {
- TObject2InputIdMap myObject2InputIdMap;
-
- TCellIdMerger(vtkIdType theNbInputs):
- TFillFieldList(theNbInputs)
- {}
-
- void
- operator()(TInputId theInputId, vtkDataSet* theDataSet)
- {
- TFillFieldList::operator()(theInputId, theDataSet);
- vtkCellData *aCellData = theDataSet->GetCellData();
- DoMergingInputs(aCellData, theInputId, myObject2InputIdMap);
- }
-
- virtual
- vtkIdType
- GetNbCells() const
- {
- return myObject2InputIdMap.size();
- }
- };
-
- template<class TFunctor>
- void
- ForEachInput(vtkAppendFilter* theFilter, TFunctor& theFunctor)
- {
- for(vtkIdType anInputId = 0; anInputId < theFilter->GetNumberOfInputConnections(0); anInputId++){
- if(vtkDataSet *aDataSet = theFilter->GetInput(anInputId)){
- if(aDataSet->GetNumberOfPoints() <= 0 && aDataSet->GetNumberOfCells() <= 0){
- continue; //no input, just skip
- }
- theFunctor(anInputId, aDataSet);
- }//if non-empty dataset
- }//for all inputs
- }
-}
-
-
-void
+//---------------------------------------------------------------
+int
VISU_AppendFilter
-::Execute()
+::RequestData(vtkInformation *theRequest,
+ vtkInformationVector **theInputVector,
+ vtkInformationVector *theOutputVector)
{
- if(GetSharedPointsDataSet()){
- vtkPoints* aPoints = GetSharedPointsDataSet()->GetPoints();
- if(aPoints->GetNumberOfPoints() < 1)
- return;
-
- vtkUnstructuredGrid *anOutput = this->GetOutput();
- if(IsMergingInputs()){
- TCellIdMerger aFunctor(this->GetNumberOfInputConnections(0));
- ForEachInput<TCellIdMerger>(this, aFunctor);
-
- vtkDataSetAttributes::FieldList& aFieldList = aFunctor.myFieldList;
- TObject2InputIdMap& anObject2InputIdMap = aFunctor.myObject2InputIdMap;
- vtkIdType aNbCells = aFunctor.GetNbCells();
- if(aNbCells < 1)
- return;
-
- // Now can allocate memory
- anOutput->Allocate(aNbCells);
- vtkCellData *anOutputCellData = anOutput->GetCellData();
- anOutputCellData->CopyAllocate(aFieldList, aNbCells);
-
- // Append each input dataset together
- // 1.points
- anOutput->SetPoints(GetSharedPointsDataSet()->GetPoints());
- anOutput->GetPointData()->PassData(GetSharedPointsDataSet()->GetPointData());
-
- // 2.cells
- vtkIdList *anIdList = vtkIdList::New();
- anIdList->Allocate(VTK_CELL_SIZE);
- TObject2InputIdMap::const_iterator anIter = anObject2InputIdMap.begin();
- TObject2InputIdMap::const_iterator anEndIter = anObject2InputIdMap.end();
- for(; anIter != anEndIter; anIter++){
- //TObjectId anObjectId = anIter->first;
- const TInputCellId& anInputCellId = anIter->second;
- TInputId anInputId = anInputCellId.first;
- if(vtkDataSet *aDataSet = this->GetInput(anInputId)){
- TCellId aCellId = anInputCellId.second;
- aDataSet->GetCellPoints(aCellId, anIdList);
-
- vtkIdType aCellType = aDataSet->GetCellType(aCellId);
- vtkIdType aNewCellId = anOutput->InsertNextCell(aCellType, anIdList);
-
- vtkCellData *aCellData = aDataSet->GetCellData();
- anOutputCellData->CopyData(aFieldList, aCellData, anInputId, aCellId, aNewCellId);
- }
- }
- anIdList->Delete();
- }else{
- TCellCounter aFunctor(this->GetNumberOfInputConnections(0));
- ForEachInput<TCellCounter>(this, aFunctor);
-
- vtkDataSetAttributes::FieldList& aFieldList = aFunctor.myFieldList;
- vtkIdType aNbCells = aFunctor.GetNbCells();
- if(aNbCells < 1)
- return;
-
- // Now can allocate memory
- anOutput->Allocate(aNbCells);
- vtkCellData *anOutputCellData = anOutput->GetCellData();
- anOutputCellData->CopyAllocate(aFieldList, aNbCells);
-
- // Append each input dataset together
- // 1.points
- anOutput->SetPoints(GetSharedPointsDataSet()->GetPoints());
- anOutput->GetPointData()->PassData(GetSharedPointsDataSet()->GetPointData());
-
- // 2.cells
- vtkIdList *anIdList = vtkIdList::New();
- anIdList->Allocate(VTK_CELL_SIZE);
- for(vtkIdType anInputId = 0; anInputId < this->GetNumberOfInputConnections(0); anInputId++) {
- if(vtkDataSet *aDataSet = this->GetInput(anInputId)){
- vtkIdType aNbCells = aDataSet->GetNumberOfCells();
- vtkCellData *aCellData = aDataSet->GetCellData();
- // copy cell and cell data
- for(vtkIdType aCellId = 0; aCellId < aNbCells; aCellId++){
- aDataSet->GetCellPoints(aCellId, anIdList);
- vtkIdType aCellType = aDataSet->GetCellType(aCellId);
- vtkIdType aNewCellId = anOutput->InsertNextCell(aCellType, anIdList);
- anOutputCellData->CopyData(aFieldList, aCellData, anInputId, aCellId, aNewCellId);
- }
- }
- }
- anIdList->Delete();
- }
- }else
- Superclass::Execute();
+ bool anIsExecuted = false;
+ if(GetNumberOfInputConnections(0) > 1 || IsMergingInputs() || IsMappingInputs())
+ anIsExecuted = VISU::UnstructuredGridRequestData(theInputVector,
+ this->GetNumberOfInputConnections(0),
+ theOutputVector,
+ GetSharedPointSet(),
+ IsMergingInputs(),
+ IsMappingInputs());
+ if(!anIsExecuted)
+ anIsExecuted = Superclass::RequestData(theRequest,
+ theInputVector,
+ theOutputVector);
+
+ return anIsExecuted;
}
#ifndef VISU_APPENDFILTER_H
#define VISU_APPENDFILTER_H
-#include <vtkAppendFilter.h>
-#include <vtkSmartPointer.h>
+#include "VISU_AppendFilterUtilities.hxx"
-class vtkPointSet;
+#include <vtkAppendFilter.h>
/*! \brief This class used same as vtkAppendFilter. See documentation on VTK for more information.
*/
-class VISU_AppendFilter : public vtkAppendFilter
+class VISU_AppendFilter : public vtkAppendFilter,
+ public VISU::TAppendFilterHelper
{
public:
/*! \fn static VISU_AppendFilter *New()
*/
vtkTypeRevisionMacro(VISU_AppendFilter, vtkAppendFilter);
- void
- SetSharedPointsDataSet(vtkPointSet* thePointsDataSet);
-
- vtkPointSet*
- GetSharedPointsDataSet();
-
- void
- SetMergingInputs(bool theIsMergingInputs);
-
- bool
- IsMergingInputs();
-
protected:
/*! \fn VISU_AppendFilter();
* \brief Constructor
*/
VISU_AppendFilter();
+
/*! \fn ~VISU_AppendFilter();
* \brief Destructor.
*/
~VISU_AppendFilter();
- /*! \fn void Execute();
- * \brief Filter culculation method.
- */
- virtual void Execute();
- bool myIsMergingInputs;
- vtkSmartPointer<vtkPointSet> mySharedPointsDataSet;
+ virtual
+ int
+ RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
};
#endif
--- /dev/null
+// SALOME OBJECT : kernel of SALOME component
+//
+// 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_GeometryFilter.cxx
+// Author :
+// Module : SALOME
+// $Header$
+
+#include "VISU_AppendFilterUtilities.hxx"
+#include "VISU_ConvertorUtils.hxx"
+
+#include <vtkCell.h>
+#include <vtkCellData.h>
+#include <vtkPointData.h>
+
+#include <vtkDataSetCollection.h>
+#include <vtkObjectFactory.h>
+
+#include <vtkUnstructuredGrid.h>
+#include <vtkPolyData.h>
+
+#include <vtkInformationVector.h>
+#include <vtkInformation.h>
+#include <vtkExecutive.h>
+
+#include <vtkPoints.h>
+#include <vtkIntArray.h>
+
+#include <algorithm>
+#include <vector>
+#include <map>
+
+namespace
+{
+ //---------------------------------------------------------------
+ typedef vtkIdType TCellId;
+ typedef vtkIdType TInputId;
+ typedef std::pair<TInputId, TCellId> TInputCellId;
+
+ typedef std::pair<vtkIdType, vtkIdType> TObjectId;
+ typedef std::map<TObjectId, TInputCellId> TObject2InputIdMap;
+
+
+ //---------------------------------------------------------------
+ void
+ DoMergingInputs(vtkCellData *theCellData,
+ TInputId theInputId,
+ TObject2InputIdMap& theResult)
+ {
+ if(vtkDataArray *aDataArray = theCellData->GetArray("VISU_CELLS_MAPPER")){
+ if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(aDataArray)){
+ int *aPointer = anIntArray->GetPointer(0);
+ int aNbCells = anIntArray->GetNumberOfTuples();
+ for(vtkIdType aCellId = 0; aCellId < aNbCells; aCellId++){
+ int aObjId = *aPointer++;
+ int anEntity = *aPointer++;
+ TObjectId anObjectId(aObjId, anEntity);
+ TObject2InputIdMap::iterator anIter = theResult.find(anObjectId);
+ if(anIter != theResult.end())
+ continue;
+ TInputCellId anInputCellId(theInputId, aCellId);
+ theResult.insert(anIter, TObject2InputIdMap::value_type(anObjectId, anInputCellId));
+ }
+ }
+ }
+ }
+
+
+ //---------------------------------------------------------------
+ struct TFillFieldList
+ {
+ vtkDataSetAttributes::FieldList myFieldList;
+ bool myIsFirstCellData;
+
+ TFillFieldList(vtkIdType theNbInputs):
+ myFieldList(theNbInputs),
+ myIsFirstCellData(true)
+ {}
+
+ void
+ operator()(TInputId theInputId, vtkDataSet* theDataSet)
+ {
+ vtkCellData *aCellData = theDataSet->GetCellData();
+ if(myIsFirstCellData){
+ myFieldList.InitializeFieldList(aCellData);
+ myIsFirstCellData = false;
+ }else{
+ myFieldList.IntersectFieldList(aCellData);
+ }
+ }
+
+ virtual
+ vtkIdType
+ GetNbCells() const = 0;
+ };
+
+
+ //---------------------------------------------------------------
+ struct TCellCounter: TFillFieldList
+ {
+ vtkIdType myNbCells;
+
+ TCellCounter(vtkIdType theNbInputs):
+ TFillFieldList(theNbInputs),
+ myNbCells(0)
+ {}
+
+ void
+ operator()(TInputId theInputId, vtkDataSet* theDataSet)
+ {
+ TFillFieldList::operator()(theInputId, theDataSet);
+ myNbCells += theDataSet->GetNumberOfCells();
+ }
+
+ virtual
+ vtkIdType
+ GetNbCells() const
+ {
+ return myNbCells;
+ }
+ };
+
+
+ //---------------------------------------------------------------
+ struct TCellIdMerger: TFillFieldList
+ {
+ TObject2InputIdMap myObject2InputIdMap;
+
+ TCellIdMerger(vtkIdType theNbInputs):
+ TFillFieldList(theNbInputs)
+ {}
+
+ void
+ operator()(TInputId theInputId, vtkDataSet* theDataSet)
+ {
+ TFillFieldList::operator()(theInputId, theDataSet);
+ vtkCellData *aCellData = theDataSet->GetCellData();
+ DoMergingInputs(aCellData, theInputId, myObject2InputIdMap);
+ }
+
+ virtual
+ vtkIdType
+ GetNbCells() const
+ {
+ return myObject2InputIdMap.size();
+ }
+ };
+
+
+ //---------------------------------------------------------------
+ template<class TFunctor>
+ void
+ ForEachInput(vtkInformationVector **theInputVector,
+ vtkIdType theNumberOfInputConnections,
+ TFunctor& theFunctor)
+ {
+ for(vtkIdType anInputId = 0; anInputId < theNumberOfInputConnections; anInputId++)
+ if(vtkDataSet *aDataSet = VISU::GetInput(theInputVector, anInputId))
+ if(aDataSet->GetNumberOfPoints() > 0 && aDataSet->GetNumberOfCells() > 0)
+ theFunctor(anInputId, aDataSet);
+ }
+
+
+ //---------------------------------------------------------------
+ template<class TDataSet>
+ bool
+ RequestData(vtkInformationVector **theInputVector,
+ vtkIdType theNumberOfInputConnections,
+ vtkInformationVector *theOutputVector,
+ vtkPointSet* theSharedPointSet,
+ bool theIsMergingInputs,
+ bool theIsMappingInputs)
+ {
+ if(theSharedPointSet){
+ vtkPoints* aPoints = theSharedPointSet->GetPoints();
+ if(aPoints->GetNumberOfPoints() < 1)
+ return true;
+
+ TDataSet* anOutput = TDataSet::SafeDownCast(VISU::GetOutput(theOutputVector));
+ vtkIdType anNbInputs = theNumberOfInputConnections;
+ if(theIsMergingInputs){
+ TCellIdMerger aFunctor(anNbInputs);
+ ForEachInput<TCellIdMerger>(theInputVector, anNbInputs, aFunctor);
+
+ vtkDataSetAttributes::FieldList& aFieldList = aFunctor.myFieldList;
+ TObject2InputIdMap& anObject2InputIdMap = aFunctor.myObject2InputIdMap;
+ vtkIdType aNbCells = aFunctor.GetNbCells();
+ if(aNbCells < 1)
+ return true;
+
+ // Now can allocate memory
+ anOutput->Allocate(aNbCells);
+ vtkCellData *anOutputCellData = anOutput->GetCellData();
+ anOutputCellData->CopyAllocate(aFieldList, aNbCells);
+
+ // Append each input dataset together
+ // 1.points
+ anOutput->SetPoints(theSharedPointSet->GetPoints());
+ anOutput->GetPointData()->PassData(theSharedPointSet->GetPointData());
+
+ // 2.cells
+ vtkIdList *anIdList = vtkIdList::New();
+ anIdList->Allocate(VTK_CELL_SIZE);
+ TObject2InputIdMap::const_iterator anIter = anObject2InputIdMap.begin();
+ TObject2InputIdMap::const_iterator anEndIter = anObject2InputIdMap.end();
+ for(; anIter != anEndIter; anIter++){
+ //TObjectId anObjectId = anIter->first;
+ const TInputCellId& anInputCellId = anIter->second;
+ TInputId anInputId = anInputCellId.first;
+ if(vtkDataSet *aDataSet = VISU::GetInput(theInputVector, anInputId)){
+ TCellId aCellId = anInputCellId.second;
+ aDataSet->GetCellPoints(aCellId, anIdList);
+
+ vtkIdType aCellType = aDataSet->GetCellType(aCellId);
+ vtkIdType aNewCellId = anOutput->InsertNextCell(aCellType, anIdList);
+
+ vtkCellData *aCellData = aDataSet->GetCellData();
+ anOutputCellData->CopyData(aFieldList, aCellData, anInputId, aCellId, aNewCellId);
+ }
+ }
+ anIdList->Delete();
+
+ if(theIsMappingInputs){
+ vtkIntArray *aDataArray = vtkIntArray::New();
+ aDataArray->SetName("VISU_INPUTS_MAPPER");
+ aDataArray->SetNumberOfComponents(2);
+ aDataArray->SetNumberOfTuples(aNbCells);
+
+ vtkIdType aTupleId = 0;
+ TObject2InputIdMap::const_iterator anIter = anObject2InputIdMap.begin();
+ TObject2InputIdMap::const_iterator anEndIter = anObject2InputIdMap.end();
+ for(vtkIdType aCellId = 0; anIter != anEndIter; anIter++, aCellId++){
+ const TInputCellId& anInputCellId = anIter->second;
+ TInputId anInputId = anInputCellId.first;
+ TCellId aCellId = anInputCellId.second;
+ aDataArray->SetValue(aTupleId++, anInputId);
+ aDataArray->SetValue(aTupleId++, aCellId);
+ }
+
+ anOutputCellData->AddArray(aDataArray);
+ aDataArray->Delete();
+ }
+
+ return true;
+ }else{
+ TCellCounter aFunctor(anNbInputs);
+ ForEachInput<TCellCounter>(theInputVector, anNbInputs, aFunctor);
+
+ vtkDataSetAttributes::FieldList& aFieldList = aFunctor.myFieldList;
+ vtkIdType aNbCells = aFunctor.GetNbCells();
+ if(aNbCells < 1)
+ return true;
+
+ // Now can allocate memory
+ anOutput->Allocate(aNbCells);
+ vtkCellData *anOutputCellData = anOutput->GetCellData();
+ anOutputCellData->CopyAllocate(aFieldList, aNbCells);
+
+ // Append each input dataset together
+ // 1.points
+ anOutput->SetPoints(theSharedPointSet->GetPoints());
+ anOutput->GetPointData()->PassData(theSharedPointSet->GetPointData());
+
+ // 2.cells
+ vtkIdList *anIdList = vtkIdList::New();
+ anIdList->Allocate(VTK_CELL_SIZE);
+ for(vtkIdType anInputId = 0; anInputId < anNbInputs; anInputId++){
+ if(vtkDataSet *aDataSet = VISU::GetInput(theInputVector, anInputId)){
+ vtkIdType aNbCells = aDataSet->GetNumberOfCells();
+ vtkCellData *aCellData = aDataSet->GetCellData();
+ // copy cell and cell data
+ for(vtkIdType aCellId = 0; aCellId < aNbCells; aCellId++){
+ aDataSet->GetCellPoints(aCellId, anIdList);
+
+ vtkIdType aCellType = aDataSet->GetCellType(aCellId);
+ vtkIdType aNewCellId = anOutput->InsertNextCell(aCellType, anIdList);
+
+ anOutputCellData->CopyData(aFieldList, aCellData, anInputId, aCellId, aNewCellId);
+ }
+ }
+ }
+ anIdList->Delete();
+
+ if(theIsMappingInputs){
+ vtkIntArray *aDataArray = vtkIntArray::New();
+ aDataArray->SetName("VISU_INPUTS_MAPPER");
+ aDataArray->SetNumberOfComponents(2);
+ aDataArray->SetNumberOfTuples(aNbCells);
+
+ vtkIdType aTupleId = 0;
+ for(vtkIdType anInputId = 0; anInputId < anNbInputs; anInputId++){
+ if(vtkDataSet *aDataSet = VISU::GetInput(theInputVector, anInputId)){
+ vtkIdType aNbCells = aDataSet->GetNumberOfCells();
+ for(vtkIdType aCellId = 0; aCellId < aNbCells; aCellId++){
+ aDataArray->SetValue(aTupleId++, aCellId);
+ aDataArray->SetValue(aTupleId++, anInputId);
+ }
+ }
+ }
+
+ anOutputCellData->AddArray(aDataArray);
+ aDataArray->Delete();
+ }
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ //---------------------------------------------------------------
+}
+
+
+namespace VISU
+{
+ //---------------------------------------------------------------
+ TAppendFilterHelper
+ ::TAppendFilterHelper(vtkObject* theParent):
+ myIsMergingInputs(false),
+ myIsMappingInputs(false),
+ myParent(*theParent)
+ {}
+
+
+ //---------------------------------------------------------------
+ void
+ TAppendFilterHelper
+ ::SetSharedPointSet(vtkPointSet* thePointSet)
+ {
+ if(GetSharedPointSet() == thePointSet)
+ return;
+
+ mySharedPointSet = thePointSet;
+
+ myParent.Modified();
+ }
+
+
+ //---------------------------------------------------------------
+ vtkPointSet*
+ TAppendFilterHelper
+ ::GetSharedPointSet()
+ {
+ return mySharedPointSet.GetPointer();
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ TAppendFilterHelper
+ ::SetMappingInputs(bool theIsMappingInputs)
+ {
+ if(myIsMappingInputs == theIsMappingInputs)
+ return;
+
+ myIsMappingInputs = theIsMappingInputs;
+ myParent.Modified();
+ }
+
+
+ //---------------------------------------------------------------
+ bool
+ TAppendFilterHelper
+ ::IsMappingInputs()
+ {
+ return myIsMappingInputs;
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ TAppendFilterHelper
+ ::SetMergingInputs(bool theIsMergingInputs)
+ {
+ if(myIsMergingInputs == theIsMergingInputs)
+ return;
+
+ myIsMergingInputs = theIsMergingInputs;
+ myParent.Modified();
+ }
+
+
+ //---------------------------------------------------------------
+ bool
+ TAppendFilterHelper
+ ::IsMergingInputs()
+ {
+ return myIsMergingInputs;
+ }
+
+
+ //---------------------------------------------------------------
+ bool
+ UnstructuredGridRequestData(vtkInformationVector **theInputVector,
+ vtkIdType theNumberOfInputConnections,
+ vtkInformationVector *theOutputVector,
+ vtkPointSet* theSharedPointSet,
+ bool theIsMergingInputs,
+ bool theIsMappingInputs)
+ {
+ return RequestData<vtkUnstructuredGrid>(theInputVector,
+ theNumberOfInputConnections,
+ theOutputVector,
+ theSharedPointSet,
+ theIsMergingInputs,
+ theIsMappingInputs);
+ }
+
+
+ //---------------------------------------------------------------
+ bool
+ PolyDataRequestData(vtkInformationVector **theInputVector,
+ vtkIdType theNumberOfInputConnections,
+ vtkInformationVector *theOutputVector,
+ vtkPointSet* theSharedPointSet,
+ bool theIsMergingInputs,
+ bool theIsMappingInputs)
+ {
+ return RequestData<vtkPolyData>(theInputVector,
+ theNumberOfInputConnections,
+ theOutputVector,
+ theSharedPointSet,
+ theIsMergingInputs,
+ theIsMappingInputs);
+ }
+
+
+ //---------------------------------------------------------------
+}
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// 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
+//
+#ifndef VISU_APPENDFILTERUTILITIES_H
+#define VISU_APPENDFILTERUTILITIES_H
+
+class vtkInformationVector;
+class vtkPointSet;
+class vtkObject;
+
+#include <vtkSmartPointer.h>
+
+namespace VISU
+{
+ //---------------------------------------------------------------
+ class TAppendFilterHelper
+ {
+ TAppendFilterHelper(TAppendFilterHelper&);
+
+ public:
+ void
+ SetSharedPointSet(vtkPointSet* thePointSet);
+
+ vtkPointSet*
+ GetSharedPointSet();
+
+ void
+ SetMappingInputs(bool theMappingInputs);
+
+ bool
+ IsMappingInputs();
+
+ void
+ SetMergingInputs(bool theIsMergingInputs);
+
+ bool
+ IsMergingInputs();
+
+ protected:
+ TAppendFilterHelper(vtkObject* theParent);
+
+ vtkSmartPointer<vtkPointSet> mySharedPointSet;
+ bool myIsMergingInputs;
+ bool myIsMappingInputs;
+ vtkObject& myParent;
+ };
+
+
+ //---------------------------------------------------------------
+ bool
+ UnstructuredGridRequestData(vtkInformationVector **theInputVector,
+ vtkIdType theNumberOfInputConnections,
+ vtkInformationVector *theOutputVector,
+ vtkPointSet* theSharedPointSet,
+ bool theIsMergingInputs,
+ bool theIsMappingInputs);
+
+ //---------------------------------------------------------------
+ bool
+ PolyDataRequestData(vtkInformationVector **theInputVector,
+ vtkIdType theNumberOfInputConnections,
+ vtkInformationVector *theOutputVector,
+ vtkPointSet* theSharedPointSet,
+ bool theIsMergingInputs,
+ bool theIsMappingInputs);
+}
+
+#endif
--- /dev/null
+// SALOME OBJECT : kernel of SALOME component
+//
+// 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 : VTKViewer_GeometryFilter.cxx
+// Author :
+// Module : SALOME
+// $Header$
+
+#include "VISU_AppendPolyData.hxx"
+
+#include <vtkObjectFactory.h>
+
+//---------------------------------------------------------------
+vtkCxxRevisionMacro(VISU_AppendPolyData, "$Revision$");
+vtkStandardNewMacro(VISU_AppendPolyData);
+
+
+//---------------------------------------------------------------
+VISU_AppendPolyData
+::VISU_AppendPolyData():
+ TAppendFilterHelper(this)
+{}
+
+
+//---------------------------------------------------------------
+VISU_AppendPolyData
+::~VISU_AppendPolyData()
+{}
+
+
+//---------------------------------------------------------------
+int
+VISU_AppendPolyData
+::RequestData(vtkInformation *theRequest,
+ vtkInformationVector **theInputVector,
+ vtkInformationVector *theOutputVector)
+{
+ bool anIsExecuted = false;
+ if(GetNumberOfInputConnections(0) > 1 || IsMergingInputs() || IsMappingInputs())
+ anIsExecuted = VISU::PolyDataRequestData(theInputVector,
+ this->GetNumberOfInputConnections(0),
+ theOutputVector,
+ GetSharedPointSet(),
+ IsMergingInputs(),
+ IsMappingInputs());
+ if(!anIsExecuted)
+ anIsExecuted = Superclass::RequestData(theRequest,
+ theInputVector,
+ theOutputVector);
+
+ return anIsExecuted;
+}
+
+
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// 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
+//
+#ifndef VISU_APPENDPOLYDATA_H
+#define VISU_APPENDPOLYDATA_H
+
+#include <vtkAppendPolyData.h>
+
+#include "VISU_AppendFilterUtilities.hxx"
+
+/*! \brief This class used same as vtkAppendFilter. See documentation on VTK for more information.
+ */
+class VISU_AppendPolyData : public vtkAppendPolyData,
+ public VISU::TAppendFilterHelper
+{
+public:
+ /*! \fn static VTKViewer_AppendFilter *New()
+ */
+ static VISU_AppendPolyData *New();
+
+ /*! \fn vtkTypeRevisionMacro(VTKViewer_AppendFilter, vtkAppendFilter)
+ * \brief VTK type revision macros.
+ */
+ vtkTypeRevisionMacro(VISU_AppendPolyData, vtkAppendPolyData);
+
+protected:
+ /*! \fn VTKViewer_AppendFilter();
+ * \brief Constructor
+ */
+ VISU_AppendPolyData();
+
+ /*! \fn ~VTKViewer_AppendFilter();
+ * \brief Destructor.
+ */
+ ~VISU_AppendPolyData();
+
+ virtual
+ int
+ RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
+};
+
+#endif
// Copyright : Open CASCADE
#include "VISU_CommonCellsFilter.hxx"
+#include "VISU_ConvertorDef.hxx"
// VTK product headers
#include <vtkUnstructuredGrid.h>
#include <algorithm>
#include <vector>
#include <map>
+#include <set>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+// TTimerLog
+#include "VISU_ConvertorUtils.hxx"
namespace
{
- typedef std::vector<int> TSortedArray;
+ typedef std::pair<int,int> TPair;// pair first - object id, second - entity
+ //
+ typedef std::vector<int> TSortedArrayOne;
+ typedef std::set<TPair> TSortedArrayPair;
+ typedef std::set<int> TIdSet;
typedef std::map<int,int> TId2IdMap;
inline
void
- GetSortedArray(vtkIntArray *theArray,
- TSortedArray& theSortedArray)
+ GetSortedArrayAsPair(vtkIntArray *theArray,
+ TSortedArrayPair& theSortedArray)
+ {
+ TSortedArrayPair aSortedArray;
+ int nbComp = theArray->GetNumberOfComponents();
+ if(nbComp == 2){
+ int aMaxId = theArray->GetNumberOfTuples()*theArray->GetNumberOfComponents();
+ int* aPointer = theArray->GetPointer(0);
+ int* anEndPointer = theArray->GetPointer(aMaxId + 1);
+ for(;aPointer<anEndPointer;){
+ TPair aPair;
+ aPair.first = *aPointer;
+ aPointer++;
+ aPair.second = *aPointer;
+ aPointer++;
+ aSortedArray.insert(aPair);
+ }
+ } else if (nbComp == 1) {
+ int aMaxId = theArray->GetNumberOfTuples();
+ int* aPointer = theArray->GetPointer(0);
+ int* anEndPointer = theArray->GetPointer(aMaxId + 1);
+ for(;aPointer<anEndPointer;){
+ TPair aPair;
+ aPair.first = *aPointer;
+ aPointer++;
+ aPair.second = (int)VISU::NODE_ENTITY;
+ aSortedArray.insert(aPair);
+ }
+
+ }
+ theSortedArray.swap(aSortedArray);
+ }
+
+ inline
+ void
+ GetSortedArrayOne(vtkIntArray *theArray,
+ TSortedArrayOne& theSortedArray)
{
int aMaxId = theArray->GetMaxId();
int* aPointer = theArray->GetPointer(0);
int* anEndPointer = theArray->GetPointer(aMaxId + 1);
- TSortedArray aSortedArray(aPointer, anEndPointer);
+ TSortedArrayOne aSortedArray(aPointer, anEndPointer);
std::sort(aSortedArray.begin(), aSortedArray.end());
theSortedArray.swap(aSortedArray);
}
void
GetIdsForCopy(vtkUnstructuredGrid *inputUGrid,
vtkIntArray* inputPointIds,
- TSortedArray& outputSortedArray)
+ TSortedArrayOne& outputSortedArray)
{
if(inputUGrid){
- TSortedArray aSortedPointIds;
- TSortedArray aOutputCellIds;
- GetSortedArray(inputPointIds,aSortedPointIds);
-
+ TSortedArrayOne aSortedPointIds;
+ TSortedArrayOne aOutputCellIds;
+ TIdSet aMapForSearch;
+ int nbTuples = inputPointIds->GetNumberOfTuples();
+ int nbComp = inputPointIds->GetNumberOfComponents();
+ int * aPtr = inputPointIds->GetPointer(0);
+ int * aPtrEnd = inputPointIds->GetPointer(nbTuples*nbComp+1);
+ if(nbComp == 1)
+ while(aPtr<aPtrEnd){
+ aMapForSearch.insert(*aPtr);
+ aPtr++;
+ }
+ else if (nbComp == 2)
+ while(aPtr<aPtrEnd){
+ aMapForSearch.insert(*aPtr);
+ aPtr++;aPtr++;
+ }
int nbInputCells = inputUGrid->GetNumberOfCells();
- TSortedArray aPointCellIds;
for(int idCell=0;idCell<nbInputCells;idCell++){
- aPointCellIds.clear();
vtkCell* aCell = inputUGrid->GetCell(idCell);
vtkIdList* ptIds = aCell->GetPointIds();
- int aMaxId = ptIds->GetNumberOfIds();
- int* aPointer = ptIds->GetPointer(0);
- int* anEndPointer = ptIds->GetPointer(aMaxId + 1);
- TSortedArray aSortedArray(aPointer, anEndPointer);
- std::sort(aSortedArray.begin(), aSortedArray.end());
-
- int aMaxLength = std::max(aSortedArray.size(), aSortedPointIds.size());
- TSortedArray anIntersectionArray(aMaxLength);
- TSortedArray::iterator anArrayIter = anIntersectionArray.begin();
- anArrayIter = std::set_intersection(aSortedArray.begin(),
- aSortedArray.end(),
- aSortedPointIds.begin(),
- aSortedPointIds.end(),
- anArrayIter);
- anIntersectionArray.erase(anArrayIter, anIntersectionArray.end());
- if(anIntersectionArray.size() == aSortedArray.size())
+ int nbPointsInCell = ptIds->GetNumberOfIds();
+ bool aGoodCell = true;
+ for(int i=0;i<nbPointsInCell;i++){
+ int aSearchingId = ptIds->GetId(i);
+ TIdSet::iterator aResult = aMapForSearch.find(aSearchingId);
+ if(aResult == aMapForSearch.end()){
+ aGoodCell = false;
+ break;
+ }
+ }
+ if(aGoodCell)
aOutputCellIds.push_back(idCell);
+ else
+ continue;
+
}
outputSortedArray.swap(aOutputCellIds);
void
CopyElementsToOutput(vtkUnstructuredGrid* theInputUG,
int& theNbElements,
- TSortedArray& theElementIdsForCopy,
+ TSortedArrayOne& theElementIdsForCopy,
TId2IdMap& theOldId2NewIdPointsMap,
- vtkIntArray* theOuputIDSArray,
vtkUnstructuredGrid* theOutputUG)
{
+ vtkIntArray* theOuputIDSArray = vtkIntArray::New();
+ theOuputIDSArray->SetName("VISU_CELLS_MAPPER");
+ theOuputIDSArray->SetNumberOfComponents(2);
+ theOuputIDSArray->SetNumberOfTuples(theNbElements);
+ int* aOuputIDSPtr = theOuputIDSArray->GetPointer(0);
+
vtkIntArray* aInputCellsMapper =
dynamic_cast<vtkIntArray*>(theInputUG->GetCellData()->GetArray("VISU_CELLS_MAPPER"));
int* aInputCellsMapperPointer = aInputCellsMapper->GetPointer(0);
const int aOldCellId = theElementIdsForCopy[aCellIndex];
theOutputUG->InsertNextCell(theInputUG->GetCellType(aOldCellId),
aNewPointIds);
- if(aInputCellsMapperPointer)
- theOuputIDSArray->InsertNextValue(aInputCellsMapperPointer[aOldCellId]);
- else
- theOuputIDSArray->InsertNextValue(aOldCellId);
+
+ *aOuputIDSPtr = aInputCellsMapperPointer[2*aOldCellId];
+ aOuputIDSPtr++;
+ *aOuputIDSPtr = aInputCellsMapperPointer[2*aOldCellId+1];
+ aOuputIDSPtr++;
aNewPointIds->Delete();
}
+
+ theOutputUG->GetCellData()->AddArray(theOuputIDSArray);
+
+ theOuputIDSArray->Delete();
}
}
VISU_CommonCellsFilter
::Execute()
{
+ VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_CommonCellsFilter::Execute");
vtkUnstructuredGrid* anInputProfileUG = this->GetProfileUG();
vtkUnstructuredGrid* anInputCellsUG = this->GetCellsUG();
vtkIntArray* aPointIDS =
dynamic_cast<vtkIntArray*>(aInputCellData->GetArray("VISU_CELLS_MAPPER"));
if(aPointIDS){
+ int* aPtr = aPointIDS->GetPointer(0);
aPointIdsForCopy->SetNumberOfIds(aPointIDS->GetNumberOfTuples());
for(int i=0;i<aPointIDS->GetNumberOfTuples();i++){
- aPointIdsForCopy->SetId(i,aPointIDS->GetValue(i));
+ aPointIdsForCopy->SetId(i,*aPtr);
+ aPtr++;aPtr++;
}
aOutputPointSet->SetNumberOfPoints(aPointIdsForCopy->GetNumberOfIds());
// aOutputPointSet copy points from anInputProfileUG to aOutputPointSet, which
//anOutput->GetPointData()->GetArray("VISU_CELLS_MAPPER")->SetName("VISU_POINTS_MAPPER");
// apply VISU_POINTS_MAPPER
+ int anEntity = int(VISU::NODE_ENTITY);
vtkIntArray* aNewPointsIdsArray = vtkIntArray::New();
aNewPointsIdsArray->SetName("VISU_POINTS_MAPPER");
- aNewPointsIdsArray->SetNumberOfComponents(1);
+ aNewPointsIdsArray->SetNumberOfComponents(2);
aNewPointsIdsArray->SetNumberOfTuples(aPointIdsForCopy->GetNumberOfIds());
- for(int i=0;i<aPointIdsForCopy->GetNumberOfIds();i++)
- aNewPointsIdsArray->SetValue(i,aPointIdsForCopy->GetId(i));
+ int *aPtr = aNewPointsIdsArray->GetPointer(0);
+ for(int i = 0; i < aPointIdsForCopy->GetNumberOfIds(); i++){
+ *aPtr++ = aPointIdsForCopy->GetId(i);
+ *aPtr++ = anEntity;
+ }
anOutput->GetPointData()->AddArray(aNewPointsIdsArray);
// Calculate output cells
int nbCells=0;
- TSortedArray aCellIdsForCopy;
+ TSortedArrayOne aCellIdsForCopy;
GetIdsForCopy(anInputCellsUG,aPointIDS,aCellIdsForCopy);
nbCells = aCellIdsForCopy.size();
// copy cells to output
int aAllocMem = nbCells;
anOutput->Allocate(aAllocMem);
- vtkIntArray* theOuputIDSArray = vtkIntArray::New();
- theOuputIDSArray->SetName("VISU_CELLS_MAPPER");
- theOuputIDSArray->SetNumberOfComponents(1);
- theOuputIDSArray->SetNumberOfTuples(aAllocMem);
-
+
if(nbCells>0 && anInputCellsUG)
CopyElementsToOutput(anInputCellsUG,
nbCells,
aCellIdsForCopy,
aOldId2NewIdPointsMap,
- theOuputIDSArray,
anOutput);
- anOutput->GetCellData()->AddArray(theOuputIDSArray);
-
- theOuputIDSArray->Delete();
+
aPointIdsForCopy->Delete();
}
}
#include <qstring.h>
-using namespace std;
-
-namespace VISU{
-
- inline
- int
- GetNbOfPoints(int theVTKCellType)
- {
- switch(theVTKCellType){
- case VTK_VERTEX : return 1;
- case VTK_LINE : return 2;
- case VTK_TRIANGLE : return 3;
- case VTK_QUAD : return 4;
- case VTK_TETRA : return 4;
- case VTK_HEXAHEDRON : return 8;
- case VTK_WEDGE : return 6;
- case VTK_PYRAMID : return 5;
- default: return -1;
- }
- }
-}
+#include <utility>
+//---------------------------------------------------------------
const VISU::TMeshMap&
VISU_Convertor
::GetMeshMap()
}
-string
+//---------------------------------------------------------------
+std::string
VISU_Convertor
::GenerateName(const VISU::TTime& aTime)
{
static QString aName;
- const string aUnits = aTime.second, tmp(aUnits.size(),' ');
+ const std::string aUnits = aTime.second, tmp(aUnits.size(), ' ');
if(aUnits == "" || aUnits == tmp)
- aName.sprintf("%g, -",aTime.first);
+ aName.sprintf("%g, -", aTime.first);
else
- aName.sprintf("%g, %s",aTime.first,aTime.second.c_str());
+ aName.sprintf("%g, %s", aTime.first, aTime.second.c_str());
aName = aName.simplifyWhiteSpace();
return aName.latin1();
}
-string
+
+//---------------------------------------------------------------
+std::string
VISU_Convertor
-::GenerateName(const string& theName,
+::GenerateName(const std::string& theName,
unsigned int theTimeId)
{
static QString aName;
if(iEnd > VtkHighLevelLength) iEnd = VtkHighLevelLength;
char* aNewName = new char[iEnd+1];
aNewName[iEnd] = '\0';
- strncpy(aNewName,aName,iEnd);
- replace(aNewName,aNewName+iEnd,' ','_');
+ strncpy(aNewName, aName, iEnd);
+ std::replace(aNewName, aNewName + iEnd, ' ', '_');
if(true || theTimeId == 0)
aName = aNewName;
else
delete[] aNewName;
return aName.latin1();
}
+
+
+//---------------------------------------------------------------
/*!
\file VISU_Convertor.hxx
- \brief The file contains definitions for basic classes of the VISU CONVERTER package
+ \brief The file represents definition of basic interface of the VISU CONVERTER package
*/
-#include "VISUConvertor.hxx"
-#include "VISU_IDMapper.hxx"
-#include "VISU_ConvertorDef.hxx"
-
-#include "MED_Vector.hxx"
-
-#include <map>
-#include <set>
-#include <utility>
-#include <string>
-#include <stdexcept>
-
-namespace VISU
-{
- using MED::TVector;
-
- //---------------------------------------------------------------
- typedef std::string TName;
-
- typedef TVector<TName> TNames;
-
- //---------------------------------------------------------------
- //! Define a basic class for all MED entites which can be identified by its number
- struct TIntId: virtual TBaseStructure
- {
- vtkIdType myId;
-
- TIntId(): myId(0)
- {}
- };
-
-
- //---------------------------------------------------------------
- typedef std::map<TEntity,PMeshOnEntity> TMeshOnEntityMap;
- typedef std::map<TName,PGroup> TGroupMap;
-
- //! Define a basic class which corresponds to MED MESH entity
- /*!
- This class in its turn contains map of TMeshOnEntity and TGroup substructures,
- also it keeps name and dimention of corresponding MED MESH entity.
- */
- struct TMesh: virtual TBaseStructure
- {
- TMeshOnEntityMap myMeshOnEntityMap; //!< Contains corresponding meshes for MED ENTITIES
- TGroupMap myGroupMap; //!< Contains map of bounded MED GROUPS
- TName myName; //! Name of the corresponding MED MESH
- int myDim; //! Dimension of the corresponding MED MESH
-
- std::string myGroupsEntry; //!< To simplify publication of the groups in a data tree
- std::string myFieldsEntry; //!< To simplify publication of the fiels in a data tree
-
- TMesh(): myDim(0)
- {}
- };
- typedef std::map<std::string,PMesh> TMeshMap;
-
-
- //---------------------------------------------------------------
- //! Define a basic class which corresponds to MED PROFILE entity
- struct TSubProfile: virtual TBaseStructure
- {};
-
-
- //---------------------------------------------------------------
- //! Define a containerfor MED PROFILE entities which belongs to the same MED ENTITY
- struct TProfile: virtual TNamedIDMapper
- {};
-
-
- //---------------------------------------------------------------
- VISU_CONVERTOR_EXPORT
- bool
- operator<(const PSubProfile& theLeft, const PSubProfile& theRight);
-
- typedef std::set<PSubProfile> TProfileKey;
- typedef std::map<TProfileKey,PProfile> TProfileMap;
-
-
- //---------------------------------------------------------------
- //! Define a basic class for MED GAUSS entity
- struct TGauss: virtual TBaseStructure
- {};
-
-
- //---------------------------------------------------------------
- //! Define a container for mesh generated from MED GAUSS and corresponding MED PROFILE
- struct TGaussSubMesh: virtual TBaseStructure
- {
- PSubProfile mySubProfile; //!< Keeps reference on what submesh the Gauss Points are located
- };
-
-
- //---------------------------------------------------------------
- //! Define a container for all TGaussSubMesh that belongs to the same MED ENTITY
- struct TGaussMesh: virtual TGaussPtsIDMapper
- {};
-
-
- //---------------------------------------------------------------
- VISU_CONVERTOR_EXPORT
- bool
- operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight);
-
- typedef std::set<PGaussSubMesh> TGaussKey;
- typedef std::map<TGaussKey,PGaussMesh> TGaussMeshMap;
-
-
- //---------------------------------------------------------------
-
- typedef std::map<TName,PFamily> TFamilyMap;
- typedef std::map<TName,PField> TFieldMap;
-
- //! Define a basic class which corresponds to MED ENTITY
- /*!
- This class in its turn contains map of TGaussMesh and TProfile substructures,
- also it keeps corresponding map of MED FAMILIES and FIELDS.
- */
- struct TMeshOnEntity: virtual TNamedIDMapper
- {
- TGaussMeshMap myGaussMeshMap; //!< Contains map of Gauss mesh which exist on it
- TProfileMap myProfileMap; //!< Contains map of Profile mesh which exist on it
-
- TFamilyMap myFamilyMap; //!< Contains map of MED FAMILIES which belongs to it
- TFieldMap myFieldMap; //!< Contains map of MED FIELDS which belongs to it
-
- TName myMeshName; //!< Contains name of the MED MESH where the it belongs to.
- TEntity myEntity; //!< Referes to MED ENTITY where the it belongs to.
- };
-
-
- //---------------------------------------------------------------
- //! Define a basic class for MED FAMILY entity
- struct TFamily: virtual TIntId,
- virtual TIDMapper
- {
- TEntity myEntity; //!< Referes to MED ENTITY where the TFamily belongs to.
- TName myName; //!< Contains name of the corresponding MED FAMILY
- };
-
-
- //---------------------------------------------------------------
-
- class FamilyCmp {
- public:
- bool operator() (const PFamily& theFamily1, const PFamily& theFamily2) const {
- return (theFamily1->myName < theFamily2->myName);
- }
- };
-
- typedef std::set<PFamily, FamilyCmp> TFamilySet;
-
- //! Define a basic class for MED GROUP entity
- struct TGroup: virtual TIDMapper
- {
- TFamilySet myFamilySet;
- };
-
-
- //---------------------------------------------------------------
- typedef std::map<vtkIdType,PValForTime> TValField;
- typedef std::pair<vtkFloatingPointType,vtkFloatingPointType> TMinMax;
-
- //! Define a basic class for MED FIELD entity
- struct TField: virtual TIntId
- {
- TEntity myEntity; //!< Referes to MED ENTITY where it belongs to.
- TName myName; //!< Contains name of the corresponding MED FIELD
- TName myMeshName; //!< Contains name of the MED MESH where it belongs to.
- TValField myValField; //!< Contains sequence of values for corresponding MED TIMESTAMPS
- TNames myCompNames; //!< Contains names of components of the MED FIELD
- TNames myUnitNames; //!< Contains names of units of the MED FIELD
- vtkIdType myNbComp; //!< Keeps number of components for the MED FIELD
-
- //! Calculate min/max values for each of the MED FIELD components among all its timestamps
- /*!
- Numeration of the components starts from 1.
- Zero component contains min/max value for modulus of corresponding vector
- */
- virtual
- TMinMax
- GetMinMax(vtkIdType theCompID) = 0;
-
- bool myIsMinMaxInitilized; //!< Is the min / max values are calculated
-
- TField():
- myNbComp(0),
- myIsMinMaxInitilized(false)
- {}
- };
-
-
- //---------------------------------------------------------------
- typedef std::pair<double,std::string> TTime;
-
- //! Define a basic class for MED TIMESTAMP entity
- struct TValForTime: virtual TIntId
- {
- TEntity myEntity; //!< Referes to MED ENTITY where it belongs to.
- TName myMeshName; //!< Contains name of the MED MESH where it belongs to.
- TName myFieldName; //!< Contains name of the MED FIELD where it belongs to.
- TTime myTime;
-
- PProfile myProfile; //!< Contains corresponding MED PROFILE where the MED TIEMSTMAP attached to
- PGaussMesh myGaussMesh;
- };
-
-
- //---------------------------------------------------------------
- //! The utility function allows to write vtkUnstructuredGrid to a file with defined name
- VISU_CONVERTOR_EXPORT
- void
- WriteToFile(vtkUnstructuredGrid* theDataSet,
- const std::string& theFileName);
-};
+#include "VISU_Structures.hxx"
//---------------------------------------------------------------
1. Perfrom parsing of MED file to get known what MED entities are pressent in it
2. Get VTK representation for any existing MED entity
Also, it can perform some additional work to calculate expected amount of memory to build defined VTK representation
-
*/
class VISU_CONVERTOR_EXPORT VISU_Convertor
{
-protected:
- std::string myName;
- VISU::TMeshMap myMeshMap;
- int myIsDone;
-
public:
virtual
~VISU_Convertor()
int
IsDone() const { return myIsDone; }
- //! Defines what subtype of vtkDataSet is used for MED to VTK mapping
- typedef VISU::TVTKOutput TOutput;
-
//! This method perform first parsing of MED file to get known what MED entities are pressent in it
virtual
VISU_Convertor*
//! Get amount of memory to build VTK representations for all existing MED entities
virtual
- vtkFloatingPointType
+ size_t
GetSize() = 0;
//! Get mesh for corresponding MED ENTITY
//! Get amount of memory to build mesh for corresponding MED ENTITY
virtual
- vtkFloatingPointType
+ size_t
GetMeshOnEntitySize(const std::string& theMeshName,
const VISU::TEntity& theEntity) = 0;
//! Get mesh for corresponding MED FAMILY
virtual
- VISU::PIDMapper
+ VISU::PUnstructuredGridIDMapper
GetFamilyOnEntity(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFamilyName) = 0;
//! Get amount of memory to build mesh for corresponding MED FAMILY
virtual
- vtkFloatingPointType
+ size_t
GetFamilyOnEntitySize(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFamilyName) = 0;
//! Get mesh for corresponding MED GROUP
virtual
- VISU::PIDMapper
+ VISU::PUnstructuredGridIDMapper
GetMeshOnGroup(const std::string& theMeshName,
const std::string& theGroupName) = 0;
//! Get amount of memory to build mesh for corresponding MED GROUP
virtual
- vtkFloatingPointType
+ size_t
GetMeshOnGroupSize(const std::string& theMeshName,
const std::string& theGroupName) = 0;
//! Get mesh with attached values for corresponding MED TIMESTAMP
virtual
- VISU::PIDMapper
+ VISU::PUnstructuredGridIDMapper
GetTimeStampOnMesh(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFieldName,
- int theStampsNum) = 0;
+ int theTimeStampNumber) = 0;
//! Get Gauss Points mesh with attached values for corresponding MED TIMESTAMP
virtual
GetTimeStampOnGaussPts(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFieldName,
- int theStampsNum) = 0;
+ int theTimeStampNumber) = 0;
- //! Get amount of memory to build mesh for corresponding MED TIMESTAMP
+ //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on mesh
virtual
- vtkFloatingPointType
- GetTimeStampSize(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName,
- int theStampsNum) = 0;
+ size_t
+ GetTimeStampOnMeshSize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theTimeStampNumber,
+ bool& theIsEstimated) = 0;
+
+ //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on Gauss Points
+ virtual
+ size_t
+ GetTimeStampOnGaussPtsSize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theTimeStampNumber,
+ bool& theIsEstimated) = 0;
//! Get amount of memory to build all MED TIMESTAMPS for corresponding MED FIELD
virtual
- vtkFloatingPointType
+ size_t
GetFieldOnMeshSize(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFieldName) = 0;
GetTimeStamp(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFieldName,
- int theStampsNum) = 0;
+ int theTimeStampNumber) = 0;
//! Allow to generate pretty name for MED TIMESTAMP
static
static
std::string
GenerateName(const std::string& theName, unsigned int theTimeId);
+
+protected:
+ std::string myName;
+ VISU::TMeshMap myMeshMap;
+ int myIsDone;
};
extern "C"
namespace VISU
{
- using MED::SharedPtr;
-
//---------------------------------------------------------------
enum TEntity {NODE_ENTITY, EDGE_ENTITY, FACE_ENTITY, CELL_ENTITY};
+
+ //---------------------------------------------------------------
+ //! Defines VISU enumeration of geometrical types
+ enum EGeometry {ePOINT1=1, eSEG2=102, eSEG3=103, eTRIA3=203,
+ eQUAD4=204, eTRIA6=206,eQUAD8=208, eTETRA4=304,
+ ePYRA5=305, ePENTA6=306, eHEXA8=308, eTETRA10=310,
+ ePYRA13=313, ePENTA15=315, eHEXA20=320,
+ ePOLYGONE=400, ePOLYEDRE=500, eNONE=-1};
+
+
+ //---------------------------------------------------------------
struct TMesh;
- typedef SharedPtr<TMesh> PMesh;
+ typedef MED::SharedPtr<TMesh> PMesh;
+
+ //---------------------------------------------------------------
struct TGaussSubMesh;
- typedef SharedPtr<TGaussSubMesh> PGaussSubMesh;
+ typedef MED::SharedPtr<TGaussSubMesh> PGaussSubMesh;
+
+ //---------------------------------------------------------------
struct TGaussMesh;
- typedef SharedPtr<TGaussMesh> PGaussMesh;
+ typedef MED::SharedPtr<TGaussMesh> PGaussMesh;
+
+ //---------------------------------------------------------------
struct TSubProfile;
- typedef SharedPtr<TSubProfile> PSubProfile;
+ typedef MED::SharedPtr<TSubProfile> PSubProfile;
+
+ //---------------------------------------------------------------
struct TProfile;
- typedef SharedPtr<TProfile> PProfile;
+ typedef MED::SharedPtr<TProfile> PProfile;
+
+ //---------------------------------------------------------------
struct TMeshOnEntity;
- typedef SharedPtr<TMeshOnEntity> PMeshOnEntity;
+ typedef MED::SharedPtr<TMeshOnEntity> PMeshOnEntity;
+
+ //---------------------------------------------------------------
struct TFamily;
- typedef SharedPtr<TFamily> PFamily;
+ typedef MED::SharedPtr<TFamily> PFamily;
+
+ //---------------------------------------------------------------
struct TGroup;
- typedef SharedPtr<TGroup> PGroup;
+ typedef MED::SharedPtr<TGroup> PGroup;
+
+ //---------------------------------------------------------------
struct TField;
- typedef SharedPtr<TField> PField;
+ typedef MED::SharedPtr<TField> PField;
+
+ //---------------------------------------------------------------
struct TGauss;
- typedef SharedPtr<TGauss> PGauss;
+ typedef MED::SharedPtr<TGauss> PGauss;
+
+ //---------------------------------------------------------------
struct TValForTime;
- typedef SharedPtr<TValForTime> PValForTime;
+ typedef MED::SharedPtr<TValForTime> PValForTime;
+
+ //---------------------------------------------------------------
struct TGrille;
- typedef SharedPtr<TGrille> PGrille;
+ typedef MED::SharedPtr<TGrille> PGrille;
+
+
+ //---------------------------------------------------------------
}
#endif
--- /dev/null
+// VISU CONVERTOR :
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File :
+// Author :
+// Module :
+
+#ifndef VISU_ConvertorDef_impl_HeaderFile
+#define VISU_ConvertorDef_impl_HeaderFile
+
+/*!
+ \file VISU_ConvertorDef_impl.hxx
+ \brief The file contains predeclarations for basic classes of the VISU CONVERTOR package
+*/
+
+#include "VISU_ConvertorDef.hxx"
+
+#include <vtkSmartPointer.h>
+
+class vtkCell;
+class vtkPoints;
+
+class vtkPolyData;
+class VISU_AppendPolyData;
+
+class vtkUnstructuredGrid;
+class VISU_AppendFilter;
+
+class VISU_MergeFilter;
+
+namespace VISU
+{
+ //---------------------------------------------------------------
+ typedef vtkSmartPointer<VISU_MergeFilter> PMergeFilter;
+
+
+ //---------------------------------------------------------------
+ typedef vtkSmartPointer<vtkPolyData> PPolyData;
+ typedef vtkSmartPointer<VISU_AppendPolyData> PAppendPolyData;
+
+ struct TAppendPolyDataHolder;
+ typedef MED::SharedPtr<TAppendPolyDataHolder> PAppendPolyDataHolder;
+
+ struct TPolyDataIDMapperImpl;
+ typedef MED::SharedPtr<TPolyDataIDMapperImpl> PPolyDataIDMapperImpl;
+
+
+ //---------------------------------------------------------------
+ typedef vtkSmartPointer<vtkUnstructuredGrid> PUnstructuredGrid;
+ typedef vtkSmartPointer<VISU_AppendFilter> PAppendFilter;
+
+ struct TAppendFilterHolder;
+ typedef MED::SharedPtr<TAppendFilterHolder> PAppendFilterHolder;
+
+ struct TUnstructuredGridIDMapperImpl;
+ typedef MED::SharedPtr<TUnstructuredGridIDMapperImpl> PUnstructuredGridIDMapperImpl;
+
+
+ //---------------------------------------------------------------
+ struct TPointCoords;
+ typedef MED::SharedPtr<TPointCoords> PPointCoords;
+
+
+ //---------------------------------------------------------------
+ struct TNamedPointCoords;
+ typedef MED::SharedPtr<TNamedPointCoords> PNamedPointCoords;
+
+
+ //---------------------------------------------------------------
+ struct TMeshValueBase;
+ typedef MED::SharedPtr<TMeshValueBase> PMeshValue;
+
+
+ //---------------------------------------------------------------
+ struct TMeshImpl;
+ typedef MED::SharedPtr<TMeshImpl> PMeshImpl;
+
+
+ //---------------------------------------------------------------
+ struct TSubProfileImpl;
+ typedef MED::SharedPtr<TSubProfileImpl> PSubProfileImpl;
+
+
+ //---------------------------------------------------------------
+ struct TProfileImpl;
+ typedef MED::SharedPtr<TProfileImpl> PProfileImpl;
+
+
+ //---------------------------------------------------------------
+ struct TGaussImpl;
+ typedef MED::SharedPtr<TGaussImpl> PGaussImpl;
+
+
+ //---------------------------------------------------------------
+ struct TGaussSubMeshImpl;
+ typedef MED::SharedPtr<TGaussSubMeshImpl> PGaussSubMeshImpl;
+
+
+ //---------------------------------------------------------------
+ struct TGaussMeshImpl;
+ typedef MED::SharedPtr<TGaussMeshImpl> PGaussMeshImpl;
+
+
+ //---------------------------------------------------------------
+ struct TGaussPtsIDFilter;
+ typedef MED::SharedPtr<TGaussPtsIDFilter> PGaussPtsIDFilter;
+
+
+ //---------------------------------------------------------------
+ struct TSubMeshImpl;
+ typedef MED::SharedPtr<TSubMeshImpl> PSubMeshImpl;
+
+
+ //---------------------------------------------------------------
+ struct TMeshOnEntityImpl;
+ typedef MED::SharedPtr<TMeshOnEntityImpl> PMeshOnEntityImpl;
+
+
+ //---------------------------------------------------------------
+ struct TFamilyImpl;
+ typedef MED::SharedPtr<TFamilyImpl> PFamilyImpl;
+
+
+ //---------------------------------------------------------------
+ struct TGroupImpl;
+ typedef MED::SharedPtr<TGroupImpl> PGroupImpl;
+
+
+ //---------------------------------------------------------------
+ struct TFieldImpl;
+ typedef MED::SharedPtr<TFieldImpl> PFieldImpl;
+
+
+ //---------------------------------------------------------------
+ struct TValForTimeImpl;
+ typedef MED::SharedPtr<TValForTimeImpl> PValForTimeImpl;
+}
+
+#endif
#include "VISU_ConvertorUtils.hxx"
+#include <vtkCellType.h>
+
#include <vtkUnstructuredGridWriter.h>
#include <vtkUnstructuredGrid.h>
+
+#include <vtkPolyDataWriter.h>
+#include <vtkPolyData.h>
+
+#include <vtkInformationVector.h>
+#include <vtkInformation.h>
+#include <vtkExecutive.h>
+
#include <vtkTimerLog.h>
#include <vtkPointData.h>
#include <vtkCellData.h>
namespace VISU
{
+ //---------------------------------------------------------------
+ vtkIdType
+ VISUGeom2NbNodes(EGeometry theGeom)
+ {
+ switch(theGeom){
+#ifndef VISU_ENABLE_QUADRATIC
+ case VISU::eSEG3:
+ return 2;
+ case VISU::eTRIA6:
+ return 3;
+ case VISU::eQUAD8:
+ return 4;
+ case VISU::eTETRA10:
+ return 4;
+ case VISU::eHEXA20:
+ return 8;
+ case VISU::ePENTA15:
+ return 6;
+ case VISU::ePYRA13:
+ return 5;
+#endif
+ case VISU::ePOLYGONE:
+ case VISU::ePOLYEDRE:
+ return -1;
+ default:
+ return theGeom % 100;
+ }
+ }
+
+
+ //---------------------------------------------------------------
+ vtkIdType
+ VISUGeom2VTK(EGeometry theGeom)
+ {
+ switch(theGeom){
+ case VISU::ePOINT1:
+ return VTK_VERTEX;
+ case VISU::eSEG2:
+ return VTK_LINE;
+ case VISU::eTRIA3:
+ return VTK_TRIANGLE;
+ case VISU::eQUAD4:
+ return VTK_QUAD;
+ case VISU::eTETRA4:
+ return VTK_TETRA;
+ case VISU::eHEXA8:
+ return VTK_HEXAHEDRON;
+ case VISU::ePENTA6:
+ return VTK_WEDGE;
+ case VISU::ePYRA5:
+ return VTK_PYRAMID;
+
+ case VISU::ePOLYGONE:
+ return VTK_POLYGON;
+ case VISU::ePOLYEDRE:
+ return VTK_CONVEX_POINT_SET;
+
+#ifndef VISU_ENABLE_QUADRATIC
+ case VISU::eSEG3:
+ return VTK_LINE;
+ case VISU::eTRIA6:
+ return VTK_TRIANGLE;
+ case VISU::eQUAD8:
+ return VTK_QUAD;
+ case VISU::eTETRA10:
+ return VTK_TETRA;
+ case VISU::eHEXA20:
+ return VTK_HEXAHEDRON;
+ case VISU::ePENTA15:
+ return VTK_WEDGE;
+ case VISU::ePYRA13:
+ return VTK_PYRAMID;
+
+#else
+
+ case VISU::eSEG3:
+#if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_EDGE;
+#else
+ return VTK_POLY_LINE;
+#endif
+
+ case VISU::eTRIA6:
+#if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_TRIANGLE;
+#else
+ return VTK_POLYGON;
+#endif
+
+ case VISU::eQUAD8:
+#if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_QUAD;
+#else
+ return VTK_POLYGON;
+#endif
+
+ case VISU::eTETRA10:
+#if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_TETRA;
+#else
+ return VTK_CONVEX_POINT_SET;
+#endif
+
+ case VISU::eHEXA20:
+#if defined(VTK_QUADRATIC_HEXAHEDRON) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_HEXAHEDRON;
+#else
+ return VTK_CONVEX_POINT_SET;
+#endif
+
+ case VISU::ePENTA15:
+#if defined(VTK_QUADRATIC_WEDGE) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_WEDGE;
+#else
+ return VTK_CONVEX_POINT_SET;
+#endif
+
+ case VISU::ePYRA13:
+#if defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_PYRAMID;
+#else
+ return VTK_CONVEX_POINT_SET;
+#endif
+
+#endif //VISU_ENABLE_QUADRATIC
+
+ default:
+ return -1;
+ }
+ }
+
//---------------------------------------------------------------
void
- WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName)
+ WriteToFile(vtkUnstructuredGrid* theDataSet,
+ const std::string& theFileName)
{
vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New();
//aWriter->SetFileType(VTK_BINARY);
}
+ //---------------------------------------------------------------
+ void
+ WriteToFile(vtkPolyData* theDataSet,
+ const std::string& theFileName)
+ {
+ vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New();
+ //aWriter->SetFileType(VTK_BINARY);
+ aWriter->SetFileName(theFileName.c_str());
+ aWriter->SetInput(theDataSet);
+ aWriter->Write();
+ aWriter->Delete();
+ }
+
+
//---------------------------------------------------------------
bool
IsDataOnPoints(vtkDataSet* theDataSet)
{
theDataSet->Update();
vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetPointData();
- if(aDataSetAttributes->GetArray("VISU_POINTS_MAPPER"))
- return aDataSetAttributes->GetNumberOfArrays() > 1;
- return aDataSetAttributes->GetNumberOfArrays() > 0;
+ return aDataSetAttributes->GetArray("VISU_FIELD") != NULL;
}
{
theDataSet->Update();
vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData();
- if(aDataSetAttributes->GetArray("VISU_CELLS_MAPPER"))
- return aDataSetAttributes->GetNumberOfArrays() > 1;
- return aDataSetAttributes->GetNumberOfArrays() > 0;
+ return aDataSetAttributes->GetArray("VISU_FIELD") != NULL;
+ }
+
+
+ //---------------------------------------------------------------
+ vtkIdType
+ GetVTKID(vtkDataArray *theIDDataArray, vtkIdType theID, int theEntity)
+ {
+ if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(theIDDataArray)){
+ int aNbTuples = anIntArray->GetNumberOfTuples();
+ int* aPointer = anIntArray->GetPointer(0);
+ for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
+ if(*aPointer == theID && *(aPointer + 1) == theEntity){
+ return aTupleId;
+ }
+ aPointer += 2;
+ }
+ }
+ return -1;
}
//---------------------------------------------------------------
vtkIdType
- GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID)
+ GetObjectID(vtkDataArray *theIDDataArray, vtkIdType theID)
+ {
+ if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(theIDDataArray)){
+ int aNbComp = anIntArray->GetNumberOfComponents();
+ int* aPointer = anIntArray->GetPointer(theID*aNbComp);
+ return *aPointer;
+ }
+ return -1;
+ }
+
+
+ //---------------------------------------------------------------
+ vtkIdType
+ GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID, int theEntity)
{
theDataSet->Update();
vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData();
if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")){
- if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(aDataArray)){
- int aMaxId = anIntArray->GetMaxId();
- int* aPointer = anIntArray->GetPointer(0);
- int* anEndPointer = anIntArray->GetPointer(aMaxId + 1);
- int* aPtr = std::find(aPointer, anEndPointer, theID);
- return aPtr - aPointer;
- }
+ if(theEntity < 0){
+ {
+ vtkIdType anID = GetVTKID(aDataArray, theID, VISU::CELL_ENTITY);
+ if(anID != -1)
+ return anID;
+ }
+ {
+ vtkIdType anID = GetVTKID(aDataArray, theID, VISU::FACE_ENTITY);
+ if(anID != -1)
+ return anID;
+ }
+ {
+ vtkIdType anID = GetVTKID(aDataArray, theID, VISU::EDGE_ENTITY);
+ if(anID != -1)
+ return anID;
+ }
+ {
+ vtkIdType anID = GetVTKID(aDataArray, theID, VISU::NODE_ENTITY);
+ if(anID != -1)
+ return anID;
+ }
+ }else
+ return GetVTKID(aDataArray, theID, theEntity);
}
return -1;
}
{
theDataSet->Update();
vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData();
- if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")){
- if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(aDataArray)){
- return anIntArray->GetValue(theID);
- }
- }
+ if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER"))
+ return GetObjectID(aDataArray, theID);
+
return -1;
}
+ //---------------------------------------------------------------
+ vtkCell*
+ GetElemCell(vtkDataSet *theDataSet, vtkIdType theObjID)
+ {
+ vtkIdType aVTKID = GetElemVTKID(theDataSet, theObjID);
+ return theDataSet->GetCell(aVTKID);
+ }
+
+
//---------------------------------------------------------------
vtkIdType
GetNodeVTKID(vtkDataSet *theDataSet, vtkIdType theID)
{
theDataSet->Update();
vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetPointData();
- if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_POINTS_MAPPER")){
- if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(aDataArray)){
- int aMaxId = anIntArray->GetMaxId();
- int* aPointer = anIntArray->GetPointer(0);
- int* anEndPointer = anIntArray->GetPointer(aMaxId + 1);
- int* aPtr = std::find(aPointer, anEndPointer, theID);
- return aPtr - aPointer;
- }
- }
+ if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_POINTS_MAPPER"))
+ return GetVTKID(aDataArray, theID, VISU::NODE_ENTITY);
+
return -1;
}
{
theDataSet->Update();
vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetPointData();
- if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_POINTS_MAPPER")){
+ if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_POINTS_MAPPER"))
+ return GetObjectID(aDataArray, theID);
+
+ return -1;
+ }
+
+
+ //---------------------------------------------------------------
+ vtkFloatingPointType*
+ GetNodeCoord(vtkDataSet *theDataSet, vtkIdType theObjID)
+ {
+ vtkIdType aVTKID = GetNodeVTKID(theDataSet, theObjID);
+ return theDataSet->GetPoint(aVTKID);
+ }
+
+
+ //---------------------------------------------------------------
+ TGaussPointID
+ GetObjID(vtkDataSet *theDataSet, vtkIdType theID)
+ {
+ theDataSet->Update();
+ vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData();
+ if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")){
if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(aDataArray)){
- return anIntArray->GetValue(theID);
+ vtkIdType anID = 2 * theID;
+ TCellID aCellID = anIntArray->GetValue(anID);
+ TLocalPntID aLocalPntID = anIntArray->GetValue(anID + 1);
+ return TGaussPointID(aCellID, aLocalPntID);
}
}
- return -1;
+ return TGaussPointID();
+ }
+
+
+ //---------------------------------------------------------------
+ TInputCellID
+ GetInputCellID(vtkDataSet *theDataSet, vtkIdType theObjID)
+ {
+ theDataSet->Update();
+ vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData();
+ if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_INPUTS_MAPPER")){
+ if(vtkIntArray *anIntArray = dynamic_cast<vtkIntArray*>(aDataArray)){
+ vtkIdType aVTKID = GetElemVTKID(theDataSet, theObjID);
+ vtkIdType aTupleID = 2 * aVTKID;
+ TCellID aCellID = anIntArray->GetValue(aTupleID);
+ TInputID anInputID = anIntArray->GetValue(aTupleID + 1);
+ return TInputCellID(anInputID, aCellID);
+ }
+ }
+ return TInputCellID();
+ }
+
+
+ //---------------------------------------------------------------
+ vtkDataSet*
+ GetInput(vtkInformationVector **theInputVector,
+ vtkIdType theInputId)
+ {
+ if(vtkInformation* anInformation = theInputVector[0]->GetInformationObject(theInputId))
+ return vtkDataSet::SafeDownCast(anInformation->Get(vtkDataObject::DATA_OBJECT()));
+ return NULL;
+ }
+
+
+ //---------------------------------------------------------------
+ vtkDataSet*
+ GetOutput(vtkInformationVector *theOutputVector)
+ {
+ if(vtkInformation* anInformation = theOutputVector->GetInformationObject(0))
+ return vtkDataSet::SafeDownCast(anInformation->Get(vtkDataObject::DATA_OBJECT()));
+ return NULL;
}
myTimerLog = NULL;
}
+
+ //---------------------------------------------------------------
}
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
-// File : VISU_Convertor_impl.hxx
+// File : VISU_ConvertorUtils.hxx
// Author : Alexey PETROV
// Module : VISU
#ifndef VISU_ConvertorUtils_HeaderFile
#define VISU_ConvertorUtils_HeaderFile
-#include <string>
-
-#include <vtkCellType.h>
-#include <vtkSystemIncludes.h>
-
#include "VISUConvertor.hxx"
+#include "VISU_ConvertorDef.hxx"
+#include "VISU_IDMapper.hxx"
#include "MED_Utilities.hxx"
+#include "VTKViewer.h"
+#include <vtkSystemIncludes.h>
+
+#include <string>
+
+class vtkInformationVector;
class vtkUnstructuredGrid;
+class vtkPolyData;
class vtkTimerLog;
class vtkDataSet;
+class vtkCell;
+
+#ifndef VISU_ENABLE_QUADRATIC
+ #define VISU_ENABLE_QUADRATIC
+ #define VISU_USE_VTK_QUADRATIC
+#endif
namespace MED
{
namespace VISU
{
-VISU_CONVERTOR_EXPORT
+ //---------------------------------------------------------------
+ //! Get number of nodes for defined geometrical type
+ vtkIdType
+ VISUGeom2NbNodes(EGeometry theGeom);
+
+
+ //---------------------------------------------------------------
+ //! Maps VISU geometrical type to VTK one
+ vtkIdType
+ VISUGeom2VTK(EGeometry theGeom);
+
+
+ //---------------------------------------------------------------
+ //! The utility function allows to write vtkUnstructuredGrid to a file with defined name
+ VISU_CONVERTOR_EXPORT
void
- WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName);
-VISU_CONVERTOR_EXPORT
+ WriteToFile(vtkUnstructuredGrid* theDataSet,
+ const std::string& theFileName);
+
+
+ //---------------------------------------------------------------
+ //! The utility function allows to write vtkPolyData to a file with defined name
+ VISU_CONVERTOR_EXPORT
+ void
+ WriteToFile(vtkPolyData* theDataSet,
+ const std::string& theFileName);
+
+
+ //---------------------------------------------------------------
+ VISU_CONVERTOR_EXPORT
bool
IsDataOnCells(vtkDataSet* theDataSet);
-VISU_CONVERTOR_EXPORT
+
+
+ //---------------------------------------------------------------
+ VISU_CONVERTOR_EXPORT
bool
IsDataOnPoints(vtkDataSet* theDataSet);
-VISU_CONVERTOR_EXPORT
+
+
+ //---------------------------------------------------------------
+ VISU_CONVERTOR_EXPORT
vtkIdType
- GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID);
-VISU_CONVERTOR_EXPORT
+ GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID, int theEntity = -1);
+
+
+ //---------------------------------------------------------------
+ VISU_CONVERTOR_EXPORT
vtkIdType
GetElemObjID(vtkDataSet *theDataSet, vtkIdType theID);
-VISU_CONVERTOR_EXPORT
+
+
+ //---------------------------------------------------------------
+ VISU_CONVERTOR_EXPORT
+ vtkCell*
+ GetElemCell(vtkDataSet *theDataSet, vtkIdType theObjID);
+
+
+ //---------------------------------------------------------------
+ VISU_CONVERTOR_EXPORT
vtkIdType
GetNodeVTKID(vtkDataSet *theDataSet, vtkIdType theID);
-VISU_CONVERTOR_EXPORT
+
+
+ //---------------------------------------------------------------
+ VISU_CONVERTOR_EXPORT
vtkIdType
GetNodeObjID(vtkDataSet *theDataSet, vtkIdType theID);
+
+ //---------------------------------------------------------------
+ VISU_CONVERTOR_EXPORT
+ vtkFloatingPointType*
+ GetNodeCoord(vtkDataSet *theDataSet, vtkIdType theObjID);
+
+ //---------------------------------------------------------------
+ VISU_CONVERTOR_EXPORT
+ TGaussPointID
+ GetObjID(vtkDataSet *theDataSet, vtkIdType theID);
+
+
+ //---------------------------------------------------------------
+ typedef vtkIdType TInputID;
+ typedef vtkIdType TCellID;
+ typedef std::pair<TInputID,TCellID> TInputCellID;
+
+ VISU_CONVERTOR_EXPORT
+ TInputCellID
+ GetInputCellID(vtkDataSet *theDataSet, vtkIdType theObjID);
+
+
+ VISU_CONVERTOR_EXPORT
+ vtkDataSet*
+ GetInput(vtkInformationVector **theInputVector,
+ vtkIdType theInputId = 0);
+
+ VISU_CONVERTOR_EXPORT
+ vtkDataSet*
+ GetOutput(vtkInformationVector *theOutputVector);
+
+ //---------------------------------------------------------------
+ //! The utility class that allows to perform perfomance mesurement
class VISU_CONVERTOR_EXPORT TTimerLog
{
int myIsDebug;
vtkTimerLog* myTimerLog;
MED::PrefixPrinter myPrefixPrinter;
public:
+
TTimerLog(int theIsDebug,
const std::string& theName);
~TTimerLog();
};
+
+ //---------------------------------------------------------------
}
#endif
// Module : VISU
#include "VISU_Convertor_impl.hxx"
-#include "VISU_ConvertorUtils.hxx"
-#include "VTKViewer_AppendFilter.h"
-#include "VTKViewer_CellLocationsArray.h"
-#include "VISU_MergeFilter.hxx"
+#include "VISU_Structures_impl.hxx"
+#include "VISU_PointCoords.hxx"
+#include "VISU_MeshValue.hxx"
+
+#include "VISU_AppendFilter.hxx"
+#include "VISU_AppendPolyData.hxx"
#include "VTKViewer_CellLocationsArray.h"
-#include "VISU_CommonCellsFilter.hxx"
-#include <vtkPoints.h>
+#include "VISU_ConvertorUtils.hxx"
+
#include <vtkUnstructuredGrid.h>
+#include <vtkPolyData.h>
+
+#include <vtkPoints.h>
+#include <vtkPointData.h>
+#include <vtkCellData.h>
#include <vtkIdList.h>
#include <vtkCellType.h>
#include <vtkCellArray.h>
-#include <vtkFloatArray.h>
-#include <vtkIntArray.h>
-#include <vtkUnsignedCharArray.h>
-#include <vtkPointData.h>
-#include <vtkCellData.h>
#include <vtkCellLinks.h>
+#include <vtkUnsignedCharArray.h>
#include <qstring.h>
#include <qfileinfo.h>
-#include <valarray>
#include <memory>
-using namespace std;
-using namespace VISU;
-
-static vtkFloatingPointType ERR_SIZE_CALC = 1.00;
-
-static int MYVTKDEBUG = 0;
-
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
-//#define _DEXCEPT_
-#else
-static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
-#endif
-
-namespace VISU
-{
- //---------------------------------------------------------------
- TIsVTKDone::TIsVTKDone():
- myIsVTKDone(false),
- myIsDone(false)
- {}
-
-
- //---------------------------------------------------------------
- TSizeCounter::TSizeCounter():
- myNbCells(0),
- myCellsSize(0)
- {}
-
-
- //---------------------------------------------------------------
- TSource::TSource()
- {}
-
- const TVTKSource&
- TSource
- ::GetSource() const
- {
- if(!mySource.GetPointer()){
- mySource = vtkUnstructuredGrid::New();
- mySource->Delete();
- }
- return mySource;
- }
-
- TVTKOutput*
- TSource
- ::GetVTKOutput()
- {
- return GetSource().GetPointer();
- }
-
-
- //---------------------------------------------------------------
- TAppendFilter::TAppendFilter()
- {}
-
- const TVTKAppendFilter&
- TAppendFilter
- ::GetFilter() const
- {
- if(!myFilter.GetPointer()){
- myFilter = VTKViewer_AppendFilter::New();
- myFilter->Delete();
- myFilter->SetDoMappingFlag(true);
- }
- return myFilter;
- }
-
- TVTKOutput*
- TAppendFilter
- ::GetVTKOutput()
- {
- GetFilter()->Update();
- return GetFilter()->GetOutput();
- }
-
-
- //---------------------------------------------------------------
- TMergeFilter::TMergeFilter()
- {}
-
- const TVTKMergeFilter&
- TMergeFilter
- ::GetFilter() const
- {
- if(!myFilter.GetPointer()){
- myFilter = VISU_MergeFilter::New();
- myFilter->Delete();
- }
- return myFilter;
- }
-
- TVTKOutput*
- TMergeFilter
- ::GetVTKOutput()
- {
- GetFilter()->Update();
- return GetFilter()->GetOutput();
- }
-
-
- //---------------------------------------------------------------
- TPointCoords
- ::TPointCoords():
- myPoints(vtkPoints::New())
- {
- myPoints->Delete();
- }
-
- void
- TPointCoords
- ::Init(vtkIdType theNbPoints,
- vtkIdType theDim)
- {
- myDim = theDim;
- myNbPoints = theNbPoints;
- myCoord.resize(theNbPoints*theDim);
- myPoints->SetNumberOfPoints(theNbPoints);
- }
-
- TCCoordSlice
- TPointCoords
- ::GetCoordSlice(vtkIdType theNodeId) const
- {
- return TCCoordSlice(myCoord,std::slice(theNodeId*myDim,myDim,1));
- }
-
- TCoordSlice
- TPointCoords
- ::GetCoordSlice(vtkIdType theNodeId)
- {
- return TCoordSlice(myCoord,std::slice(theNodeId*myDim,myDim,1));
- }
-
-
- //---------------------------------------------------------------
- void
- TNamedPointCoords
- ::Init(vtkIdType theNbPoints,
- vtkIdType theDim,
- const TVectorID& theVectorID)
- {
- TPointCoords::Init(theNbPoints,theDim);
- myPointsDim.resize(theDim);
- myVectorID = theVectorID;
-
- for(vtkIdType anID = 0, anEnd = theVectorID.size(); anID < anEnd; anID++)
- myObj2VTKID[theVectorID[anID]] = anID;
- }
-
- std::string&
- TNamedPointCoords
- ::GetName(vtkIdType theDim)
- {
- return myPointsDim[theDim];
- }
-
- const std::string&
- TNamedPointCoords
- ::GetName(vtkIdType theDim) const
- {
- return myPointsDim[theDim];
- }
-
- vtkIdType
- TNamedPointCoords
- ::GetObjID(vtkIdType theID) const
- {
- if(myVectorID.empty())
- return theID;
- else
- return myVectorID[theID];
- }
-
-
- vtkIdType
- TNamedPointCoords
- ::GetVTKID(vtkIdType theID) const
- {
- if(myObj2VTKID.empty())
- return theID;
- else{
- TObj2VTKID::const_iterator anIter = myObj2VTKID.find(theID);
- if(anIter != myObj2VTKID.end())
- return anIter->second;
- }
- return -1;
- }
-
- std::string
- TNamedPointCoords
- ::GetNodeName(vtkIdType theObjID) const
- {
- return "";
- }
-
- //---------------------------------------------------------------
- TMeshImpl::TMeshImpl():
- myPointsSource(vtkUnstructuredGrid::New()),
- myNbPoints(0)
- {
- vtkPoints* aPoints = vtkPoints::New();
- myPointsSource->SetPoints(aPoints);
- aPoints->Delete();
-
- myPointsSource->Delete();
- }
-
-
- //---------------------------------------------------------------
- TSubProfileImpl::TSubProfileImpl():
- myStatus(eNone),
- myGeom(eNONE)
- {}
-
-
- vtkIdType
- TSubProfileImpl
- ::GetElemObjID(vtkIdType theID) const
- {
- return theID;
- }
-
-
- //---------------------------------------------------------------
- bool
- operator<(const PSubProfile& theLeft, const PSubProfile& theRight)
- {
- PSubProfileImpl aLeft(theLeft), aRight(theRight);
-
- if(aLeft->myGeom != aRight->myGeom)
- return aLeft->myGeom < aRight->myGeom;
-
- if(aLeft->myStatus != aRight->myStatus)
- return aLeft->myStatus < aRight->myStatus;
-
- return aLeft->myName < aRight->myName;
- }
-
-
- //---------------------------------------------------------------
- TProfileImpl::TProfileImpl():
- myIsAll(true),
- myMeshOnEntity(NULL)
- {}
-
- vtkIdType
- TProfileImpl
- ::GetNodeObjID(vtkIdType theID) const
- {
- return myNamedPointCoords->GetObjID(theID);
- }
-
- vtkIdType
- TProfileImpl
- ::GetNodeVTKID(vtkIdType theID) const
- {
- return myNamedPointCoords->GetVTKID(theID);
- }
-
- vtkFloatingPointType*
- TProfileImpl
- ::GetNodeCoord(vtkIdType theObjID)
- {
- if(myIsAll)
- return myMeshOnEntity->GetNodeCoord(theObjID);
-
- vtkIdType aVtkID = GetNodeVTKID(theObjID);
- return GetFilter()->GetOutput()->GetPoint(aVtkID);
- }
-
- vtkIdType
- TProfileImpl
- ::GetElemObjID(vtkIdType theID) const
- {
- if(myIsAll)
- return myMeshOnEntity->GetElemObjID(theID);
-
- vtkIdType anInputID, aStartID, anInputDataSetID;
- const TVTKAppendFilter& anAppendFilter = GetFilter();
- anAppendFilter->GetCellInputID(theID,anInputID,aStartID,anInputDataSetID);
- PSubProfileImpl aSubProfileImpl = mySubProfileArr[anInputDataSetID];
- return aSubProfileImpl->GetElemObjID(anInputID);
- }
-
- vtkIdType
- TProfileImpl
- ::GetElemVTKID(vtkIdType theID) const
- {
- if(myIsAll)
- return myMeshOnEntity->GetElemVTKID(theID);
-
- if(myElemObj2VTKID.empty())
- return theID;
- else{
- TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
- if(anIter != myElemObj2VTKID.end())
- return anIter->second;
- }
- return -1;
- }
-
- vtkCell*
- TProfileImpl
- ::GetElemCell(vtkIdType theObjID)
- {
- if(myIsAll)
- return myMeshOnEntity->GetElemCell(theObjID);
-
- vtkIdType aVtkID = GetElemVTKID(theObjID);
- return GetFilter()->GetOutput()->GetCell(aVtkID);
- }
-
- TVTKOutput*
- TProfileImpl
- ::GetVTKOutput()
- {
- const TVTKAppendFilter& anAppendFilter = GetFilter();
- return anAppendFilter->GetOutput();
- }
-
- std::string
- TProfileImpl
- ::GetNodeName(vtkIdType theObjID) const
- {
- return myNamedPointCoords->GetNodeName(theObjID);
- }
-
- std::string
- TProfileImpl
- ::GetElemName(vtkIdType theObjID) const
- {
- if(myIsAll)
- return myMeshOnEntity->GetElemName(theObjID);
-
- vtkIdType aVTKId = GetElemVTKID(theObjID);
- vtkIdType anInputID, aStartID, anInputDataSetID;
- const TVTKAppendFilter& anAppendFilter = GetFilter();
- anAppendFilter->GetCellInputID(aVTKId,anInputID,aStartID,anInputDataSetID);
- PSubProfileImpl aSubProfileImpl = mySubProfileArr[anInputDataSetID];
- vtkIdType anEntityObjId = aSubProfileImpl->GetElemObjID(anInputID);
- return myMeshOnEntity->GetElemName(anEntityObjId);
- }
-
-
- //---------------------------------------------------------------
- TVTKOutput*
- TIDMapperFilter
- ::GetVTKOutput()
- {
- if(!myFilter.GetPointer()){
- const TVTKAppendFilter& anAppendFilter = myIDMapper->GetFilter();
- TVTKOutput* aGeometry = anAppendFilter->GetOutput();
-
- const TVTKSource& aSource = mySource.GetSource();
- TDataSet* aDataSet = aSource.GetPointer();
- aDataSet->ShallowCopy(aGeometry);
- const TVTKMergeFilter& aFilter = GetFilter();
- aFilter->SetGeometry(aGeometry);
- aFilter->SetScalars(aDataSet);
- aFilter->SetVectors(aDataSet);
- aFilter->AddField("VISU_FIELD",aDataSet);
- aFilter->AddField("VISU_CELLS_MAPPER",aDataSet);
- aFilter->AddField("VISU_POINTS_MAPPER",aDataSet);
- }
- return myFilter->GetOutput();
- }
-
- vtkIdType
- TIDMapperFilter
- ::GetNodeObjID(vtkIdType theID) const
- {
- return myIDMapper->GetNodeObjID(theID);
- }
-
- vtkIdType
- TIDMapperFilter
- ::GetNodeVTKID(vtkIdType theID) const
- {
- return myIDMapper->GetNodeVTKID(theID);
- }
-
- vtkFloatingPointType*
- TIDMapperFilter
- ::GetNodeCoord(vtkIdType theObjID)
- {
- return myIDMapper->GetNodeCoord(theObjID);
- }
-
- vtkIdType
- TIDMapperFilter
- ::GetElemObjID(vtkIdType theID) const
- {
- return myIDMapper->GetElemObjID(theID);
- }
-
- vtkIdType
- TIDMapperFilter
- ::GetElemVTKID(vtkIdType theID) const
- {
- return myIDMapper->GetElemVTKID(theID);
- }
-
- vtkCell*
- TIDMapperFilter
- ::GetElemCell(vtkIdType theObjID)
- {
- return myIDMapper->GetElemCell(theObjID);
- }
-
- //---------------------------------------------------------------
- TIDCommonCellsFilter
- ::TIDCommonCellsFilter():
- myIsSpecialKey(false)
- {}
-
- const TVTKCommonCellsFilter&
- TIDCommonCellsFilter
- ::GetFilter() const
- {
- if(!myFilter.GetPointer()){
- myFilter = VISU_CommonCellsFilter::New();
- myFilter->Delete();
- myMergeFilter = VISU_MergeFilter::New();
- myMergeFilter->Delete();
- }
- return myFilter;
- }
-
- TVTKOutput*
- TIDCommonCellsFilter
- ::GetVTKOutput()
- {
- if(!myFilter.GetPointer()){
- const TVTKAppendFilter& anAppendFilter = myIDMapper->GetFilter();
- TVTKOutput* aGeometry;
-
- const TVTKSource& aSource = mySource.GetSource();
- TDataSet* aDataSet;
- const TVTKCommonCellsFilter& aFilter = GetFilter();
-
- if(myIsSpecialKey){
- PNamedIDMapperMap::iterator aIter;
- aIter = myMappers.find(VISU::CELL_ENTITY);
- if(aIter!=myMappers.end()) aFilter->SetCellsUG((aIter->second)->GetVTKOutput());
- else {
- aIter = myMappers.find(VISU::FACE_ENTITY);
- if(aIter!=myMappers.end()) aFilter->SetCellsUG((aIter->second)->GetVTKOutput());
- else {
- aIter = myMappers.find(VISU::EDGE_ENTITY);
- if(aIter!=myMappers.end()) aFilter->SetCellsUG((aIter->second)->GetVTKOutput());
- }
- }
- }
-
- aGeometry = anAppendFilter->GetOutput();
- aDataSet = aSource.GetPointer();
- aDataSet->ShallowCopy(aGeometry);
-
- myMergeFilter->SetGeometry(aGeometry);
- myMergeFilter->SetScalars(aDataSet);
- myMergeFilter->SetVectors(aDataSet);
- myMergeFilter->AddField("VISU_FIELD",aDataSet);
- myMergeFilter->AddField("VISU_CELLS_MAPPER",aDataSet);
- myMergeFilter->AddField("VISU_POINTS_MAPPER",aDataSet);
-
- aFilter->SetProfileUG(myMergeFilter->GetOutput());
- }
- return myFilter->GetOutput();
- }
-
- //---------------------------------------------------------------
- void
- TGaussImpl
- ::LessThan(const PGaussImpl& theGauss,
- bool& theResult) const
- {
- theResult = false;
- }
-
-
- //---------------------------------------------------------------
- TGaussSubMeshImpl::TGaussSubMeshImpl():
- myStatus(eNone)
- {}
-
- TGaussPointID
- TGaussSubMeshImpl
- ::GetObjID(vtkIdType theID,
- vtkIdType theStartID) const
- {
- TCellID aCellID = theStartID + theID / myGauss->myNbPoints;
- TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
-
- return TGaussPointID(aCellID,aLocalPntID);
- }
-
- //---------------------------------------------------------------
- bool
- operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight)
- {
- PGaussSubMeshImpl aLeft(theLeft), aRight(theRight);
- const PGaussImpl& aGaussLeft = aLeft->myGauss;
- const PGaussImpl& aGaussRight = aRight->myGauss;
-
- if(aGaussLeft->myGeom != aGaussRight->myGeom)
- return aGaussLeft->myGeom < aGaussRight->myGeom;
-
- if(aLeft->mySubProfile != aRight->mySubProfile)
- return aLeft->mySubProfile < aRight->mySubProfile;
-
- bool aResult;
- aGaussLeft->LessThan(aGaussRight,aResult);
-
- return aResult;
- }
-
-
- //---------------------------------------------------------------
- TGaussMeshImpl
- ::TGaussMeshImpl():
- myParent(NULL)
- {}
-
- TGaussPointID
- TGaussMeshImpl
- ::GetObjID(vtkIdType theID) const
- {
- vtkIdType anInputID, aStartId, anInputDataSetID;
- const TVTKAppendFilter& anAppendFilter = GetFilter();
- anAppendFilter->GetCellInputID(theID,anInputID,aStartId,anInputDataSetID);
- const TGaussSubMeshImpl& aSubMeshImpl = myGaussSubMeshArr[anInputDataSetID];
-
- return aSubMeshImpl.GetObjID(anInputID,aStartId);
- }
-
- TVTKOutput*
- TGaussMeshImpl
- ::GetVTKOutput()
- {
- return mySource.GetVTKOutput();
- }
-
- TNamedIDMapper*
- TGaussMeshImpl::
- GetParent()
- {
- return myParent;
- }
-
-
- //---------------------------------------------------------------
- TGaussPointID
- TGaussPtsIDFilter
- ::GetObjID(vtkIdType theID) const
- {
- return myGaussPtsIDMapper->GetObjID(theID);
- }
-
- TNamedIDMapper*
- TGaussPtsIDFilter::
- GetParent()
- {
- return myGaussPtsIDMapper->GetParent();
- }
-
-
- //---------------------------------------------------------------
- vtkIdType
- TSubMeshImpl
- ::GetElemObjID(vtkIdType theID) const
- {
- return myStartID + theID;
- }
-
- std::string
- TSubMeshImpl
- ::GetElemName(vtkIdType theObjID) const
- {
- return "";
- }
-
- //---------------------------------------------------------------
- vtkIdType
- TMeshOnEntityImpl
- ::GetNodeVTKID(vtkIdType theID) const
- {
- return myNamedPointCoords->GetVTKID(theID);
- }
-
- vtkIdType
- TMeshOnEntityImpl
- ::GetNodeObjID(vtkIdType theID) const
- {
- return myNamedPointCoords->GetObjID(theID);
- }
-
- vtkIdType
- TMeshOnEntityImpl
- ::GetElemVTKID(vtkIdType theID) const
- {
- VISU::TVTKOutput* anOutput = GetFilter()->GetOutput();
- return VISU::GetElemVTKID(anOutput, theID);
- }
-
- vtkIdType
- TMeshOnEntityImpl
- ::GetElemObjID(vtkIdType theID) const
- {
- VISU::TVTKOutput* anOutput = GetFilter()->GetOutput();
- return VISU::GetElemObjID(anOutput, theID);
- }
-
- std::string
- TMeshOnEntityImpl
- ::GetNodeName(vtkIdType theObjID) const
- {
- return myNamedPointCoords->GetNodeName(theObjID);
- }
-
- std::string
- TMeshOnEntityImpl
- ::GetElemName(vtkIdType theObjID) const
- {
- vtkIdType aVTKId = GetElemVTKID(theObjID);
- vtkIdType anInputID, aStartId, anInputDataSetID;
- const TVTKAppendFilter& anAppendFilter = GetFilter();
- anAppendFilter->GetCellInputID(aVTKId,anInputID,aStartId,anInputDataSetID);
- const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputDataSetID];
- return aSubMesh->GetElemName(anInputID);
- }
-
- //---------------------------------------------------------------
- vtkIdType
- TFamilyImpl
- ::GetElemVTKID(vtkIdType theID) const
- {
- if(myElemObj2VTKID.empty())
- return theID;
- else{
- TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
- if(anIter != myElemObj2VTKID.end())
- return anIter->second;
- }
- return -1;
- }
-
- vtkIdType
- TFamilyImpl
- ::GetElemObjID(vtkIdType theID) const
- {
- return myMeshID[theID];
- }
-
- vtkIdType
- TFamilyImpl
- ::GetNodeObjID(vtkIdType theID) const
- {
- return myNamedPointCoords->GetObjID(theID);
- }
-
- vtkIdType
- TFamilyImpl
- ::GetNodeVTKID(vtkIdType theID) const
- {
- return myNamedPointCoords->GetVTKID(theID);
- }
-
- TVTKOutput*
- TFamilyImpl
- ::GetVTKOutput()
- {
- return TSource::GetVTKOutput();
- }
-
-
- //---------------------------------------------------------------
- TNbASizeCells
- TGroupImpl
- ::GetNbASizeCells() const
- {
- vtkIdType aNbCells = 0, aCellsSize = 0;
- TFamilySet::const_iterator anIter = myFamilySet.begin();
- for(; anIter != myFamilySet.end(); anIter++){
- PFamilyImpl aFamily = *anIter;
- aNbCells += aFamily->myNbCells;
- aCellsSize += aFamily->myCellsSize;
- }
- return make_pair(aNbCells,aCellsSize);
- }
-
- vtkIdType
- TGroupImpl
- ::GetElemVTKID(vtkIdType theID) const
- {
- if(myElemObj2VTKID.empty())
- return theID;
- else{
- TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
- if(anIter != myElemObj2VTKID.end())
- return anIter->second;
- }
- return -1;
- }
-
- vtkIdType
- TGroupImpl
- ::GetElemObjID(vtkIdType theID) const
- {
- vtkIdType anInputID, aStartId, anInputDataSetID;
- const TVTKAppendFilter& anAppendFilter = GetFilter();
- anAppendFilter->GetCellInputID(theID,anInputID,aStartId,anInputDataSetID);
- const PFamilyImpl& aFamily = myFamilyArr[anInputDataSetID];
- return aFamily->GetElemObjID(anInputID);
- }
-
- vtkIdType
- TGroupImpl
- ::GetNodeObjID(vtkIdType theID) const
- {
- return myNamedPointCoords->GetObjID(theID);
- }
-
- vtkIdType
- TGroupImpl
- ::GetNodeVTKID(vtkIdType theID) const
- {
- return myNamedPointCoords->GetVTKID(theID);
- }
-
-
- //---------------------------------------------------------------
- TFieldImpl
- ::TFieldImpl():
- myDataSize(0)
- {}
-
- void
- TFieldImpl
- ::InitArrays(vtkIdType theNbComp)
- {
- myNbComp = theNbComp;
- myCompNames.resize(theNbComp);
- myUnitNames.resize(theNbComp);
- myMinMaxArr.resize(theNbComp + 1);
- for(vtkIdType iComp = 0; iComp <= theNbComp; iComp++){
- TMinMax& aMinMax = myMinMaxArr[iComp];
- aMinMax.first = VTK_LARGE_FLOAT;
- aMinMax.second = -VTK_LARGE_FLOAT;
- }
- }
-
- TMinMax
- TFieldImpl
- ::GetMinMax(vtkIdType theCompID)
- {
- return myMinMaxArr[theCompID];
- }
-
-
- //---------------------------------------------------------------
- void
- TMeshValue
- ::Init(vtkIdType theNbElem,
- vtkIdType theNbGauss,
- vtkIdType theNbComp)
- {
- myNbElem = theNbElem;
- myNbGauss = theNbGauss;
- myNbComp = theNbComp;
-
- myStep = theNbComp*theNbGauss;
-
- myValue.resize(theNbElem*myStep);
- }
-
- TCValueSliceArr
- TMeshValue
- ::GetGaussValueSliceArr(vtkIdType theElemId) const
- {
- TCValueSliceArr aValueSliceArr(myNbGauss);
- vtkIdType anId = theElemId*myStep;
- for(vtkIdType aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
- aValueSliceArr[aGaussId] =
- TCValueSlice(myValue,std::slice(anId,myNbComp,1));
- anId += myNbComp;
- }
- return aValueSliceArr;
- }
-
- TValueSliceArr
- TMeshValue
- ::GetGaussValueSliceArr(vtkIdType theElemId)
- {
- TValueSliceArr aValueSliceArr(myNbGauss);
- vtkIdType anId = theElemId*myStep;
- for(vtkIdType aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
- aValueSliceArr[aGaussId] =
- TValueSlice(myValue,std::slice(anId,myNbComp,1));
- anId += myNbComp;
- }
- return aValueSliceArr;
- }
-
- TCValueSliceArr
- TMeshValue
- ::GetCompValueSliceArr(vtkIdType theElemId) const
- {
- TCValueSliceArr aValueSliceArr(myNbComp);
- vtkIdType anId = theElemId*myStep;
- for(vtkIdType aCompId = 0; aCompId < myNbComp; aCompId++){
- aValueSliceArr[aCompId] =
- TCValueSlice(myValue,std::slice(anId,myNbGauss,myNbComp));
- anId += 1;
- }
- return aValueSliceArr;
- }
-
- TValueSliceArr
- TMeshValue
- ::GetCompValueSliceArr(vtkIdType theElemId)
- {
- TValueSliceArr aValueSliceArr(myNbComp);
- vtkIdType anId = theElemId*myStep;
- for(vtkIdType aCompId = 0; aCompId < myNbComp; aCompId++){
- aValueSliceArr[aCompId] =
- TValueSlice(myValue,std::slice(anId,myNbGauss,myNbComp));
- anId += 1;
- }
- return aValueSliceArr;
- }
-
-
- //---------------------------------------------------------------
- TValForTimeImpl
- ::TValForTimeImpl():
- myGaussPtsIDFilter(new TGaussPtsIDFilter()),
- myIDMapperFilter(new TIDCommonCellsFilter())
- {}
-
- const TMeshValue&
- TValForTimeImpl
- ::GetMeshValue(EGeometry theGeom) const
- {
- TGeom2Value::const_iterator anIter = myGeom2Value.find(theGeom);
- if(anIter == myGeom2Value.end())
- EXCEPTION(runtime_error,"TValForTimeImpl::GetMeshValue - myGeom2Value.find(theGeom) fails");
- return anIter->second;
- }
-
- TMeshValue&
- TValForTimeImpl
- ::GetMeshValue(EGeometry theGeom)
- {
- return myGeom2Value[theGeom];
- }
-
- int
- TValForTimeImpl
- ::GetNbGauss(EGeometry theGeom) const
- {
- TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.find(theGeom);
- if(anIter == myGeom2NbGauss.end()){
- //EXCEPTION(runtime_error,"TValForTimeImpl::GetNbGauss - myGeom2NbGauss.find(theGeom) fails");
- return 1;
- }
- return anIter->second;
- }
-
-
- //---------------------------------------------------------------
- vtkIdType
- VISUGeom2NbNodes(EGeometry theGeom)
- {
- switch(theGeom){
-#ifndef VISU_ENABLE_QUADRATIC
- case VISU::eSEG3:
- return 2;
- case VISU::eTRIA6:
- return 3;
- case VISU::eQUAD8:
- return 4;
- case VISU::eTETRA10:
- return 4;
- case VISU::eHEXA20:
- return 8;
- case VISU::ePENTA15:
- return 6;
- case VISU::ePYRA13:
- return 5;
-#endif
- case VISU::ePOLYGONE:
- case VISU::ePOLYEDRE:
- return -1;
- default:
- return theGeom % 100;
- }
- }
-
- vtkIdType
- VISUGeom2VTK(EGeometry theGeom)
- {
- switch(theGeom){
- case VISU::ePOINT1:
- return VTK_VERTEX;
- case VISU::eSEG2:
- return VTK_LINE;
- case VISU::eTRIA3:
- return VTK_TRIANGLE;
- case VISU::eQUAD4:
- return VTK_QUAD;
- case VISU::eTETRA4:
- return VTK_TETRA;
- case VISU::eHEXA8:
- return VTK_HEXAHEDRON;
- case VISU::ePENTA6:
- return VTK_WEDGE;
- case VISU::ePYRA5:
- return VTK_PYRAMID;
-
- case VISU::ePOLYGONE:
- return VTK_POLYGON;
- case VISU::ePOLYEDRE:
- return VTK_CONVEX_POINT_SET;
-
-#ifndef VISU_ENABLE_QUADRATIC
- case VISU::eSEG3:
- return VTK_LINE;
- case VISU::eTRIA6:
- return VTK_TRIANGLE;
- case VISU::eQUAD8:
- return VTK_QUAD;
- case VISU::eTETRA10:
- return VTK_TETRA;
- case VISU::eHEXA20:
- return VTK_HEXAHEDRON;
- case VISU::ePENTA15:
- return VTK_WEDGE;
- case VISU::ePYRA13:
- return VTK_PYRAMID;
-
-#else
-
- case VISU::eSEG3:
-#if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)
- return VTK_QUADRATIC_EDGE;
-#else
- return VTK_POLY_LINE;
-#endif
-
- case VISU::eTRIA6:
-#if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)
- return VTK_QUADRATIC_TRIANGLE;
-#else
- return VTK_POLYGON;
-#endif
-
- case VISU::eQUAD8:
-#if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)
- return VTK_QUADRATIC_QUAD;
-#else
- return VTK_POLYGON;
-#endif
-
- case VISU::eTETRA10:
-#if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)
- return VTK_QUADRATIC_TETRA;
-#else
- return VTK_CONVEX_POINT_SET;
-#endif
-
- case VISU::eHEXA20:
-#if defined(VTK_QUADRATIC_HEXAHEDRON) && defined(VISU_USE_VTK_QUADRATIC)
- return VTK_QUADRATIC_HEXAHEDRON;
-#else
- return VTK_CONVEX_POINT_SET;
-#endif
+static vtkFloatingPointType ERR_SIZE_CALC = 1.00;
- case VISU::ePENTA15:
-#if defined(VTK_QUADRATIC_WEDGE) && defined(VISU_USE_VTK_QUADRATIC)
- return VTK_QUADRATIC_WEDGE;
-#else
- return VTK_CONVEX_POINT_SET;
-#endif
+static int MYVTKDEBUG = 0;
- case VISU::ePYRA13:
-#if defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)
- return VTK_QUADRATIC_PYRAMID;
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+static int MYDEBUGWITHFILES = 0;
+//#define _DEXCEPT_
#else
- return VTK_CONVEX_POINT_SET;
+static int MYDEBUG = 0;
+static int MYDEBUGWITHFILES = 0;
#endif
-#endif //VISU_ENABLE_QUADRATIC
-
- default:
- return -1;
- }
- }
-}
-
namespace
{
}
- //---------------------------------------------------------------
- enum ECoordName{eX, eY, eZ, eNone};
- typedef VISU::TCoord (*TGetCoord)(const VISU::TCCoordSlice& theCoordSlice);
-
- template<ECoordName TCoordId>
- VISU::TCoord
- GetCoord(const VISU::TCCoordSlice& theCoordSlice)
- {
- return theCoordSlice[TCoordId];
- }
-
- template<>
- VISU::TCoord
- GetCoord<eNone>(const VISU::TCCoordSlice& theCoordSlice)
- {
- return 0.0;
- }
-
-
- TGetCoord aXYZGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eY>,
- &GetCoord<eZ>
- };
-
-
- TGetCoord aXYGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eY>,
- &GetCoord<eNone>
- };
-
- TGetCoord aYZGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eX>,
- &GetCoord<eY>
- };
-
- TGetCoord aXZGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eNone>,
- &GetCoord<eY>
- };
-
-
- TGetCoord aXGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eNone>,
- &GetCoord<eNone>
- };
-
- TGetCoord aYGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eX>,
- &GetCoord<eNone>
- };
-
- TGetCoord aZGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eNone>,
- &GetCoord<eX>
- };
-
-
- class TCoordHelper{
- TGetCoord* myGetCoord;
- public:
- TCoordHelper(TGetCoord* theGetCoord):
- myGetCoord(theGetCoord)
- {}
-
- virtual
- ~TCoordHelper()
- {}
-
- VISU::TCoord
- GetCoord(VISU::TCCoordSlice& theCoordSlice,
- int theCoordId)
- {
- return (*myGetCoord[theCoordId])(theCoordSlice);
- }
- };
- typedef std::auto_ptr<TCoordHelper> TCoordHelperPtr;
-
-
- //---------------------------------------------------------------
- vtkUnstructuredGrid*
- GetPointsSource(const PMeshImpl& theMesh)
- {
- TVTKSource& aPointSource = theMesh->myPointsSource;
- if(!theMesh->myIsVTKDone){
- const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
- TCoordHelperPtr aCoordHelperPtr;
- {
- int aMeshDimension = theMesh->myDim;
- bool anIsDimPresent[3] = {false, false, false};
- for(int iDim = 0; iDim < aMeshDimension; iDim++){
- std::string aName = aCoords.GetName(iDim);
- if ( aName.size() > 1 ) // PAL13021 (PAL12148), aName has size 8 or 16
- aName = aName.substr(0,1);
- if(aName == "x" || aName == "X")
- anIsDimPresent[eX] = true;
- else if(aName == "y" || aName == "Y")
- anIsDimPresent[eY] = true;
- else if(aName == "z" || aName == "Z")
- anIsDimPresent[eZ] = true;
- }
-
- switch(aMeshDimension){
- case 3:
- aCoordHelperPtr.reset(new TCoordHelper(aXYZGetCoord));
- break;
- case 2:
- if(anIsDimPresent[eY] && anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(aYZGetCoord));
- else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(aXZGetCoord));
- else
- aCoordHelperPtr.reset(new TCoordHelper(aXYGetCoord));
- break;
- case 1:
- if(anIsDimPresent[eY])
- aCoordHelperPtr.reset(new TCoordHelper(aYGetCoord));
- else if(anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(aZGetCoord));
- else
- aCoordHelperPtr.reset(new TCoordHelper(aXGetCoord));
- break;
- }
- }
-
- vtkPoints* aPoints = aPointSource->GetPoints();
- vtkIdType aNbPoints = aCoords.GetNbPoints();
- aPoints->SetNumberOfPoints(aNbPoints);
-
- INITMSG(MYDEBUG,"GetPointsSource - aNbPoints = "<<aNbPoints<<
- "; aDim = "<<theMesh->myDim<<
- endl);
-
- for(vtkIdType aNodeId = 0; aNodeId < aNbPoints; aNodeId++){
- TCCoordSlice aCoordSlice = aCoords.GetCoordSlice(aNodeId);
- aPoints->SetPoint(aNodeId,
- aCoordHelperPtr->GetCoord(aCoordSlice,eX),
- aCoordHelperPtr->GetCoord(aCoordSlice,eY),
- aCoordHelperPtr->GetCoord(aCoordSlice,eZ));
- }
-
- vtkIdType aNbTuples = aNbPoints;
- vtkIntArray *aDataArray = vtkIntArray::New();
- aDataArray->SetName("VISU_POINTS_MAPPER");
- aDataArray->SetNumberOfComponents(1);
- aDataArray->SetNumberOfTuples(aNbTuples);
- for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
- vtkIdType anObjID = aCoords.GetObjID(aTupleId);
- aDataArray->SetValue(aTupleId, anObjID);
- }
- aPointSource->GetPointData()->AddArray(aDataArray);
- aDataArray->Delete();
-
- theMesh->myIsVTKDone = true;
-
- if(MYVTKDEBUG) aPoints->DebugOn();
- }
-
- return aPointSource.GetPointer();
- }
-
-
//---------------------------------------------------------------
void
PrintCells(int& theStartId,
//---------------------------------------------------------------
void
- GetCellsOnSubMesh(const TVTKSource& theSource,
- const PMeshOnEntityImpl& theMeshOnEntity,
- const PSubMeshImpl& theSubMesh,
+ GetCellsOnSubMesh(const VISU::PUnstructuredGrid& theSource,
+ const VISU::PMeshOnEntityImpl& theMeshOnEntity,
+ const VISU::PSubMeshImpl& theSubMesh,
const vtkIdType theGeom)
{
+ VISU::TTimerLog aTimerLog(MYDEBUG,"GetCellsOnSubMesh");
const VISU::TCell2Connect& anArray = theSubMesh->myCell2Connect;
vtkIdType aCellsSize = theSubMesh->myCellsSize;
vtkIdType aNbCells = theSubMesh->myNbCells;
{
int aNbTuples = aNbCells;
+ int anEntity = int(theMeshOnEntity->myEntity);
vtkIntArray *aDataArray = vtkIntArray::New();
aDataArray->SetName("VISU_CELLS_MAPPER");
- aDataArray->SetNumberOfComponents(1);
+ aDataArray->SetNumberOfComponents(2);
aDataArray->SetNumberOfTuples(aNbTuples);
+ int *aDataArrayPtr = aDataArray->GetPointer(0);
for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
int anObjID = theSubMesh->GetElemObjID(aTupleId);
- aDataArray->SetValue(aTupleId, anObjID);
+ *aDataArrayPtr++ = anObjID;
+ *aDataArrayPtr++ = anEntity;
}
theSource->GetCellData()->AddArray(aDataArray);
aDataArray->Delete();
//---------------------------------------------------------------
void
- GetCellsOnFamily(const TVTKSource& theSource,
- const PMeshOnEntityImpl& theMeshOnEntity,
- const PFamilyImpl& theFamily)
+ GetCellsOnFamily(const VISU::PUnstructuredGrid& theSource,
+ const VISU::PMeshOnEntityImpl& theMeshOnEntity,
+ const VISU::PFamilyImpl& theFamily)
{
INITMSG(MYDEBUG,"GetCellsOnFamily"<<endl);
aCellTypesArray->SetNumberOfComponents(1);
aCellTypesArray->SetNumberOfTuples(aNbCells);
- TSubMeshID& aMeshID = theFamily->myMeshID;
+ VISU::TSubMeshID& aMeshID = theFamily->myMeshID;
aMeshID.resize(aNbCells);
vtkIntArray *aDataArray = vtkIntArray::New();
+ int anEntity = int(theMeshOnEntity->myEntity);
aDataArray->SetName("VISU_CELLS_MAPPER");
- aDataArray->SetNumberOfComponents(1);
+ aDataArray->SetNumberOfComponents(2);
aDataArray->SetNumberOfTuples(aNbCells);
+ int *aDataArrayPtr = aDataArray->GetPointer(0);
VISU::TID2ID& anElemObj2VTKID = theFamily->myElemObj2VTKID;
const VISU::TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
if(aGeom2SubMeshID.empty())
- EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!");
+ EXCEPTION(std::runtime_error,"GetCells >> There is no elements on the family !!!");
VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aEGeom);
if(aGeom2SubMeshIDIter == aGeom2SubMeshID.end())
PrintCells(aCellId, aConnectivity, anArray[anID]);
aCellTypesArray->SetValue(aCellId, (unsigned char)aVGeom);
vtkIdType anObjID = aSubMesh.GetElemObjID(anID);
- aDataArray->SetValue(aCellId, anObjID);
anElemObj2VTKID[anObjID] = aCellId;
aMeshID[aCellId] = anObjID;
+ *aDataArrayPtr++ = anObjID;
+ *aDataArrayPtr++ = anEntity;
}
}
}
- //---------------------------------------------------------------
- std::string
- GenerateFieldName(const PFieldImpl& theField,
- const PValForTimeImpl& theValForTime)
- {
- const VISU::TTime& aTime = theValForTime->myTime;
- string aFieldName = theField->myMeshName + ", " + theField->myName + ": " +
- VISU_Convertor::GenerateName(aTime);
- return aFieldName;
- }
-
-
- //---------------------------------------------------------------
- void
- GetTimeStampOnProfile(const TVTKSource& theSource,
- const PFieldImpl& theField,
- const PValForTimeImpl& theValForTime,
- const VISU::TEntity& theEntity)
- {
- int aNbTuples = theField->myDataSize/theField->myNbComp;
- std::string aFieldName = GenerateFieldName(theField,theValForTime);
-
- vtkDataSetAttributes* aDataSetAttributes;
- switch(theEntity){
- case VISU::NODE_ENTITY :
- aDataSetAttributes = theSource->GetPointData();
- break;
- default:
- aDataSetAttributes = theSource->GetCellData();
- }
-
- int aNbComp = theField->myNbComp;
- vtkFloatArray *aFloatArray = vtkFloatArray::New();
-
- switch(aNbComp) {
- case 1:
- aFloatArray->SetNumberOfComponents(1);
- aDataSetAttributes->SetScalars(aFloatArray);
- break;
- default:
- aFloatArray->SetNumberOfComponents(3);
- aDataSetAttributes->SetVectors(aFloatArray);
- }
-
- aFloatArray->SetNumberOfTuples(aNbTuples);
- aFloatArray->SetName(aFieldName.c_str());
-
- vtkFloatArray *aDataArray = vtkFloatArray::New();
- aDataArray->SetNumberOfComponents(aNbComp);
- aDataArray->SetNumberOfTuples(aNbTuples);
- aDataArray->SetName("VISU_FIELD");
- aDataSetAttributes->AddArray(aDataArray);
-
- INITMSG(MYDEBUG,"GetTimeStampOnProfile "<<
- "- theEntity = "<<theEntity<<
- "; aNbTuples = "<<aNbTuples<<
- "; aNbComp = "<<aNbComp<<
- endl);
-
- int aSize = max(3,aNbComp);
- TVector<vtkFloatingPointType> aDataValues(aSize,0.0);
-
- TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
- TGeom2Value::const_iterator anIter = aGeom2Value.begin();
- for(int aTupleId = 0; anIter != aGeom2Value.end(); anIter++){
- EGeometry aEGeom = anIter->first;
- const TMeshValue& aMeshValue = anIter->second;
-
- int aNbElem = aMeshValue.myNbElem;
- int aNbGauss = aMeshValue.myNbGauss;
- INITMSG(MYDEBUG,
- "- aEGeom = "<<aEGeom<<
- "; aNbElem = "<<aNbElem<<
- "; aNbGauss = "<<aNbGauss<<
- endl);
-
- for(int iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
- TCValueSliceArr aValueSliceArr = aMeshValue.GetCompValueSliceArr(iElem);
- for(int iComp = 0; iComp < aNbComp; iComp++){
- const TCValueSlice& aValueSlice = aValueSliceArr[iComp];
- aDataValues[iComp] = 0.0;
- for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
- aDataValues[iComp] += aValueSlice[iGauss];
- }
- aDataValues[iComp] /= aNbGauss;
- }
- aFloatArray->SetTuple(aTupleId,&aDataValues[0]);
- aDataArray->SetTuple(aTupleId,&aDataValues[0]);
- }
- }
-
- aFloatArray->Delete();
- aDataArray->Delete();
-
- }
-
-
//---------------------------------------------------------------
void
- GetCells(const TVTKSource& theSource,
- const PSubProfileImpl& theSubProfile,
- const PProfileImpl& theProfile,
- const PMeshOnEntityImpl& theMeshOnEntity)
+ GetCells(const VISU::PUnstructuredGrid& theSource,
+ const VISU::PSubProfileImpl& theSubProfile,
+ const VISU::PProfileImpl& theProfile,
+ const VISU::PMeshOnEntityImpl& theMeshOnEntity)
{
vtkIdType aNbCells = theSubProfile->myNbCells;
vtkIdType aCellsSize = theSubProfile->myCellsSize;
INITMSG(MYDEBUG,"GetCells - aVGeom = "<<aVGeom<<endl);
- const TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID;
+ const VISU::TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID;
const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.find(aEGeom);
if(anIter == aGeom2SubMesh.end())
- EXCEPTION(runtime_error,"GetCells >> There is no elements for the GEOM("<<aEGeom<<")");
+ EXCEPTION(std::runtime_error,"GetCells >> There is no elements for the GEOM("<<aEGeom<<")");
const VISU::TSubMeshImpl& aSubMesh = anIter->second;
- const TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect;
+ const VISU::TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect;
vtkCellArray* aConnectivity = vtkCellArray::New();
aConnectivity->Allocate(aCellsSize,0);
aCellTypesArray->SetNumberOfComponents(1);
aCellTypesArray->SetNumberOfTuples(aNbCells);
- if(theSubProfile->myStatus == eAddAll){
+ if(theSubProfile->myStatus == VISU::eAddAll){
VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin();
for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){
- const TConnect& anArray = aCell2Connect[anId];
+ const VISU::TConnect& anArray = aCell2Connect[anId];
PrintCells(aConnId,aConnectivity,anArray);
aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
aConnId += aNbNodes;
VISU::TSubMeshID::const_iterator anIter = aSubMeshID.begin();
for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){
vtkIdType aSubId = *anIter;
- const TConnect& anArray = aCell2Connect[aSubId];
+ const VISU::TConnect& anArray = aCell2Connect[aSubId];
PrintCells(aConnId,aConnectivity,anArray);
aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
aConnId += aNbNodes;
{
int aNbTuples = aNbCells;
+ int anEntity = int(theMeshOnEntity->myEntity);
vtkIntArray *aDataArray = vtkIntArray::New();
aDataArray->SetName("VISU_CELLS_MAPPER");
- aDataArray->SetNumberOfComponents(1);
+ aDataArray->SetNumberOfComponents(2);
aDataArray->SetNumberOfTuples(aNbTuples);
+ int *aDataArrayPtr = aDataArray->GetPointer(0);
for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
int anObjID = theSubProfile->GetElemObjID(aTupleId);
- aDataArray->SetValue(aTupleId, anObjID);
+ *aDataArrayPtr++ = anObjID;
+ *aDataArrayPtr++ = anEntity;
}
theSource->GetCellData()->AddArray(aDataArray);
aDataArray->Delete();
//---------------------------------------------------------------
void
- GetMeshOnSubProfile(const PMeshImpl& theMesh,
- const PMeshOnEntityImpl& theMeshOnEntity,
- const PProfileImpl& theProfile,
- const PSubProfileImpl& theSubProfile)
+ GetMeshOnSubProfile(const VISU::PMeshImpl& theMesh,
+ const VISU::PMeshOnEntityImpl& theMeshOnEntity,
+ const VISU::PProfileImpl& theProfile,
+ const VISU::PSubProfileImpl& theSubProfile)
{
INITMSG(MYDEBUG,"GetMeshOnSubProfile - aEGeom = "<<theSubProfile->myGeom<<endl);
- const TVTKSource& aSource = theSubProfile->GetSource();
+ const VISU::PUnstructuredGrid& aSource = theSubProfile->GetSource();
if(theSubProfile->myIsVTKDone)
return;
- aSource->ShallowCopy(GetPointsSource(theMesh));
+ aSource->ShallowCopy(theMesh->GetPointSet());
INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
GetCells(aSource,theSubProfile,theProfile,theMeshOnEntity);
BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
//---------------------------------------------------------------
bool
- GetMeshOnProfile(const PMeshImpl& theMesh,
- const PMeshOnEntityImpl& theMeshOnEntity,
- const PProfileImpl& theProfile)
+ GetMeshOnProfile(const VISU::PMeshImpl& theMesh,
+ const VISU::PMeshOnEntityImpl& theMeshOnEntity,
+ const VISU::PProfileImpl& theProfile)
{
- INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<<theMeshOnEntity->myEntity<<endl);
-
- if(theProfile->myMeshOnEntity && theProfile->myMeshOnEntity != theMeshOnEntity.get())
- return false;
-
if(theProfile->myIsVTKDone)
return true;
- const TVTKAppendFilter& anAppendFilter = theProfile->GetFilter();
- anAppendFilter->SetSharedPointsDataSet(GetPointsSource(theMesh));
+ if(theProfile->myMeshOnEntity && theProfile->myMeshOnEntity != theMeshOnEntity.get())
+ return false;
+
+ VISU::TTimerLog aTimerLog(MYDEBUG,"GetMeshOnProfile");
+ INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<<theMeshOnEntity->myEntity<<std::endl);
+
+ const VISU::PAppendFilter& anAppendFilter = theProfile->GetFilter();
+ anAppendFilter->SetSharedPointSet(theMesh->GetPointSet());
if(theProfile->myIsAll){
- TVTKOutput* aDataSet = theMeshOnEntity->GetVTKOutput();
+ vtkUnstructuredGrid* aDataSet = theMeshOnEntity->GetUnstructuredGridOutput();
anAppendFilter->AddInput(aDataSet);
}else{
- const TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
+ const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
- TID2ID& anElemObj2VTKID = theProfile->myElemObj2VTKID;
+ VISU::TID2ID& anElemObj2VTKID = theProfile->myElemObj2VTKID;
- TSubProfileArr& aSubProfileArr = theProfile->mySubProfileArr;
+ VISU::TSubProfileArr& aSubProfileArr = theProfile->mySubProfileArr;
aSubProfileArr.resize(aGeom2SubProfile.size());
- TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
+ VISU::TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
for(vtkIdType anInputID = 0, aCellID = 0; anIter != aGeom2SubProfile.end(); anIter++){
- PSubProfileImpl aSubProfile = anIter->second;
- if(aSubProfile->myStatus == eRemoveAll)
+ VISU::PSubProfileImpl aSubProfile = anIter->second;
+ if(aSubProfile->myStatus == VISU::eRemoveAll)
continue;
GetMeshOnSubProfile(theMesh,
theProfile,
aSubProfile);
- const TVTKSource& aSource = aSubProfile->GetSource();
+ const VISU::PUnstructuredGrid& aSource = aSubProfile->GetSource();
anAppendFilter->AddInput(aSource.GetPointer());
vtkIdType aNbCells = aSource->GetNumberOfCells();
}
- //---------------------------------------------------------------
- void
- GetTimeStampOnGaussMesh(const TVTKSource& theSource,
- const PFieldImpl& theField,
- const PValForTimeImpl& theValForTime)
- {
- int aNbTuples = theSource->GetNumberOfPoints();
- std::string aFieldName = GenerateFieldName(theField,theValForTime);
-
- vtkDataSetAttributes* aDataSetAttributes;
- switch(theField->myEntity){
- case VISU::NODE_ENTITY :
- aDataSetAttributes = theSource->GetPointData();
- break;
- default:
- aDataSetAttributes = theSource->GetCellData();
- }
-
- int aNbComp = theField->myNbComp;
- vtkFloatArray *aFloatArray = vtkFloatArray::New();
- switch(aNbComp){
- case 1:
- aFloatArray->SetNumberOfComponents(1);
- aDataSetAttributes->SetScalars(aFloatArray);
- break;
- default:
- aFloatArray->SetNumberOfComponents(3);
- aDataSetAttributes->SetVectors(aFloatArray);
- }
- aFloatArray->SetNumberOfTuples(aNbTuples);
- aFloatArray->SetName(aFieldName.c_str());
-
- vtkFloatArray *aDataArray = vtkFloatArray::New();
- aDataArray->SetNumberOfComponents(aNbComp);
- aDataArray->SetNumberOfTuples(aNbTuples);
- aDataArray->SetName("VISU_FIELD");
- aDataSetAttributes->AddArray(aDataArray);
-
- INITMSG(MYDEBUG,"GetTimeStampOnGaussMesh "<<
- "- aNbTuples = "<<aNbTuples<<
- "; aNbComp = "<<aNbComp<<
- endl);
-
- int aSize = max(3,aNbComp);
- TVector<vtkFloatingPointType> aDataValues(aSize,0.0);
-
- const TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
-
- PGaussMeshImpl aGaussMesh = theValForTime->myGaussMesh;
- const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
- TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
- for(int aTupleId = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
- EGeometry aEGeom = anIter->first;
-
- PGaussSubMeshImpl aGaussSubMesh = anIter->second;
- if(!aGaussSubMesh->myIsDone)
- continue;
-
- TGeom2Value::const_iterator anIter2 = aGeom2Value.find(aEGeom);
- if(anIter2 == aGeom2Value.end()){
- EXCEPTION(runtime_error,
- "GetTimeStampOnGaussMesh >> Can't find values for corresponding Gauss Points SubMesh");
- }
- const TMeshValue& aMeshValue = anIter2->second;
- int aNbGauss = aMeshValue.myNbGauss;
- int aNbElem = aMeshValue.myNbElem;
-
- if(aNbGauss < 1)
- continue;
-
- const TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
-
- INITMSG(MYDEBUG,
- "- aEGeom = "<<aEGeom<<
- "; aNbElem = "<<aNbElem<<
- "; aNbGauss = "<<aNbGauss<<
- "; aCoords.GetNbPoints() = "<<aCoords.GetNbPoints()<<
- endl);
-
- if(aCoords.GetNbPoints() == aNbElem*aNbGauss){
- for(int iElem = 0; iElem < aNbElem; iElem++){
- TCValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem);
- for(int iGauss = 0; iGauss < aNbGauss; iGauss++, aTupleId++){
- const TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
- for(int iComp = 0; iComp < aNbComp; iComp++){
- aDataValues[iComp] = aValueSlice[iComp];
- }
- aFloatArray->SetTuple(aTupleId,&aDataValues[0]);
- aDataArray->SetTuple(aTupleId,&aDataValues[0]);
- }
- }
- }else{
- for(int iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
- TCValueSliceArr aValueSliceArr = aMeshValue.GetCompValueSliceArr(iElem);
- for(int iComp = 0; iComp < aNbComp; iComp++){
- const TCValueSlice& aValueSlice = aValueSliceArr[iComp];
- aDataValues[iComp] = 0.0;
- for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
- aDataValues[iComp] += aValueSlice[iGauss];
- }
- aDataValues[iComp] /= aNbGauss;
- }
- aFloatArray->SetTuple(aTupleId,&aDataValues[0]);
- aDataArray->SetTuple(aTupleId,&aDataValues[0]);
- }
- }
- }
- //theSource->Update();
-
- aFloatArray->Delete();
- aDataArray->Delete();
- }
-
-
//---------------------------------------------------------------
void
- GetSource(const TVTKSource& theSource,
- const PGaussSubMeshImpl& theGaussSubMesh,
- const PMeshOnEntityImpl& theMeshOnEntity)
+ GetGaussSubMeshSource(const VISU::PPolyData& theSource,
+ const VISU::PGaussSubMeshImpl& theGaussSubMesh,
+ const VISU::PMeshOnEntityImpl& theMeshOnEntity)
{
- const TPointCoords& aCoords = theGaussSubMesh->myPointCoords;
- vtkIdType aNbPoints = aCoords.GetNbPoints();
- vtkIdType aDim = aCoords.GetDim();
-
- vtkIdType aNbCells = theGaussSubMesh->myNbCells;
- vtkIdType aCellsSize = theGaussSubMesh->myCellsSize;
-
vtkCellArray* aConnectivity = vtkCellArray::New();
- aConnectivity->Allocate(aCellsSize,0);
- vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
- aCellTypesArray->SetNumberOfComponents(1);
- aCellTypesArray->SetNumberOfTuples(aNbCells);
+ vtkIdType aCellsSize = theGaussSubMesh->myCellsSize;
+ aConnectivity->Allocate(aCellsSize, 0);
- const TVTKPoints& aPoints = aCoords.GetPoints();
vtkIdList *anIdList = vtkIdList::New();
anIdList->SetNumberOfIds(1);
+
+ const VISU::TPointCoords& aCoords = theGaussSubMesh->myPointCoords;
+ vtkIdType aNbPoints = aCoords.GetNbPoints();
for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
- TCCoordSlice aSlice = aCoords.GetCoordSlice(aPointId);
-
- vtkFloatingPointType aCoords[3] = {0.0, 0.0, 0.0};
- for(vtkIdType aDimId = 0; aDimId < aDim; aDimId++)
- aCoords[aDimId] = aSlice[aDimId];
-
- aPoints->SetPoint(aPointId,aCoords);
-
- anIdList->SetId(0,aPointId);
+ anIdList->SetId(0, aPointId);
aConnectivity->InsertNextCell(anIdList);
- aCellTypesArray->SetValue(aPointId,(unsigned char)VTK_VERTEX);
}
anIdList->Delete();
- VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
- aCellLocationsArray->SetNumberOfComponents(1);
- aCellLocationsArray->SetNumberOfTuples(aNbCells);
-
- vtkIdType *pts = 0, npts = 0;
- aConnectivity->InitTraversal();
- for(int i = 0; aConnectivity->GetNextCell(npts,pts); i++)
- aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
-
- const TVTKSource& aSource = theGaussSubMesh->GetSource();
- aSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
- aSource->SetPoints(aPoints.GetPointer());
+ const VISU::PPolyData& aSource = theGaussSubMesh->GetSource();
+ aSource->ShallowCopy(aCoords.GetPointSet());
+ aSource->SetVerts(aConnectivity);
- aCellLocationsArray->Delete();
- aCellTypesArray->Delete();
aConnectivity->Delete();
+
+ {
+ vtkIdType aNbTuples = aNbPoints;
+ vtkIntArray *aDataArray = vtkIntArray::New();
+ aDataArray->SetName("VISU_POINTS_MAPPER");
+ aDataArray->SetNumberOfComponents(2);
+ aDataArray->SetNumberOfTuples(aNbTuples);
+ int *aDataArrayPtr = aDataArray->GetPointer(0);
+ for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
+ vtkIdType aGlobalID = theGaussSubMesh->GetGlobalID(aTupleId);
+ *aDataArrayPtr++ = aGlobalID;
+ *aDataArrayPtr++ = 0;
+ }
+ aSource->GetPointData()->AddArray(aDataArray);
+ aDataArray->Delete();
+ }
+
+ {
+ vtkIdType aNbTuples = aNbPoints;
+ vtkIntArray *aDataArray = vtkIntArray::New();
+ aDataArray->SetName("VISU_CELLS_MAPPER");
+ aDataArray->SetNumberOfComponents(2);
+ aDataArray->SetNumberOfTuples(aNbTuples);
+ int *aDataArrayPtr = aDataArray->GetPointer(0);
+ for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
+ VISU::TGaussPointID aGaussPointID = theGaussSubMesh->GetObjID(aTupleId);
+ *aDataArrayPtr++ = aGaussPointID.first;
+ *aDataArrayPtr++ = aGaussPointID.second;
+ }
+ aSource->GetCellData()->AddArray(aDataArray);
+ aDataArray->Delete();
+ }
}
//---------------------------------------------------------------
void
- GetGaussSubMesh(const PMeshImpl& theMesh,
- const PMeshOnEntityImpl& theMeshOnEntity,
- const PGaussMeshImpl& theGaussMesh,
- const PGaussSubMeshImpl& theGaussSubMesh)
+ GetGaussSubMesh(const VISU::PMeshImpl& theMesh,
+ const VISU::PMeshOnEntityImpl& theMeshOnEntity,
+ const VISU::PGaussMeshImpl& theGaussMesh,
+ const VISU::PGaussSubMeshImpl& theGaussSubMesh)
{
- PGaussImpl aGauss = theGaussSubMesh->myGauss;
- INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<<aGauss->myGeom<<endl);
+ VISU::PGaussImpl aGauss = theGaussSubMesh->myGauss;
if(!theGaussSubMesh->myIsDone)
return;
if(theGaussSubMesh->myIsVTKDone)
return;
- const TVTKSource& aSource = theGaussSubMesh->GetSource();
- GetSource(aSource,theGaussSubMesh,theMeshOnEntity);
+ VISU::TTimerLog aTimerLog(MYDEBUG,"GetGaussSubMesh");
+ INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<<aGauss->myGeom<<endl);
+
+ const VISU::PPolyData& aSource = theGaussSubMesh->GetSource();
+ GetGaussSubMeshSource(aSource, theGaussSubMesh, theMeshOnEntity);
+
INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
//---------------------------------------------------------------
void
- BuildGaussMesh(const PMeshImpl& theMesh,
- const PMeshOnEntityImpl& theMeshOnEntity,
- const PGaussMeshImpl& theGaussMesh)
+ BuildGaussMesh(const VISU::PMeshImpl& theMesh,
+ const VISU::PMeshOnEntityImpl& theMeshOnEntity,
+ const VISU::PGaussMeshImpl& theGaussMesh)
{
if(theGaussMesh->myIsVTKDone)
return;
- INITMSG(MYDEBUG,"BuildGaussMesh"<<endl);
- const TVTKAppendFilter& anAppendFilter = theGaussMesh->GetFilter();
- const TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
- TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
- for(; anIter != aGeom2GaussSubMesh.end(); anIter++){
- PGaussSubMeshImpl aGaussSubMesh = anIter->second;
- if(aGaussSubMesh->myStatus == eRemoveAll)
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGaussMesh");
+ const VISU::PAppendPolyData& anAppendFilter = theGaussMesh->GetFilter();
+ const VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
+ VISU::TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
+ for(vtkIdType aStartID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
+ VISU::PGaussSubMeshImpl aGaussSubMesh = anIter->second;
+ if(aGaussSubMesh->myStatus == VISU::eRemoveAll)
continue;
-
+
+ aGaussSubMesh->myStartID = aStartID;
+
GetGaussSubMesh(theMesh,
theMeshOnEntity,
theGaussMesh,
aGaussSubMesh);
- const TVTKSource& aSource = aGaussSubMesh->GetSource();
-
+ const VISU::PPolyData& aSource = aGaussSubMesh->GetSource();
+ aStartID += aSource->GetNumberOfCells();
+
anAppendFilter->AddInput(aSource.GetPointer());
}
anAppendFilter->Update(); // Fix on VTK
- theMeshOnEntity->GetVTKOutput()->Update();
+ theMeshOnEntity->GetOutput()->Update();
vtkDataSet* aSource = anAppendFilter->GetOutput();
INITMSGA(MYDEBUG,0,"aNbPoints - "<<aSource->GetNumberOfPoints()<<endl);
//---------------------------------------------------------------
VISU::PNamedIDMapper
VISU_Convertor_impl
-::GetMeshOnEntity(const string& theMeshName,
+::GetMeshOnEntity(const std::string& theMeshName,
const VISU::TEntity& theEntity)
{
INITMSG(MYDEBUG,"GetMeshOnEntity"<<
TFindMeshOnEntity aFindMeshOnEntity =
FindMeshOnEntity(theMeshName,theEntity);
- PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
- PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
+ VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
+ VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
//Main part of code
#ifndef _DEXCEPT_
try{
#endif
if(!aMeshOnEntity->myIsVTKDone){
- const TVTKAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter();
+ VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetMeshOnEntity");
+ const VISU::PAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter();
if(MYVTKDEBUG) anAppendFilter->DebugOn();
LoadMeshOnEntity(aMesh,aMeshOnEntity);
- anAppendFilter->SetSharedPointsDataSet(GetPointsSource(aMesh));
+ anAppendFilter->SetSharedPointSet(aMesh->GetPointSet());
- const TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
- TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
+ const VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
+ VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
+
+ VISU::TID2ID& anElemObj2VTKID = aMeshOnEntity->myElemObj2VTKID;
+ VISU::TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr;
+ aSubMeshArr.resize(aGeom2SubMesh.size());
for(vtkIdType anID = 0, aCellID = 0; anIter != aGeom2SubMesh.end(); anIter++, anID++){
- EGeometry aEGeom = anIter->first;
+ VISU::EGeometry aEGeom = anIter->first;
vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
- PSubMeshImpl aSubMesh = anIter->second;
+ VISU::PSubMeshImpl aSubMesh = anIter->second;
//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
aSubMesh->myIsStructured = aMesh->myIsStructured;
aSubMesh->myObjID2StructureID = aMesh->myObjID2StructureID;
//ENK: 23.11.2006
- const TVTKSource& aSource = aSubMesh->GetSource();
- aSource->ShallowCopy(GetPointsSource(aMesh));
+ const VISU::PUnstructuredGrid& aSource = aSubMesh->GetSource();
+ aSource->ShallowCopy(aMesh->GetPointSet());
aSubMesh->myStartID = aCellID;
GetCellsOnSubMesh(aSource, aMeshOnEntity, aSubMesh, aVGeom);
anAppendFilter->AddInput(aSource.GetPointer());
- aCellID += aSource->GetNumberOfCells();
+
+ vtkIdType aNbCells = aSource->GetNumberOfCells();
+ for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
+ vtkIdType anObjID = aSubMesh->GetElemObjID(aCell);
+ anElemObj2VTKID[anObjID] = aCellID;
+ }
+
+ aSubMeshArr[anID] = aSubMesh;
}
aMeshOnEntity->myNamedPointCoords = aMesh->myNamedPointCoords;
+
//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
aMeshOnEntity->myIsStructured = aMesh->myIsStructured;
aMeshOnEntity->myType = aMesh->myType;
aMeshOnEntity->myGrilleStructure = aMesh->myGrilleStructure;
aMeshOnEntity->myObjID2StructureID = aMesh->myObjID2StructureID;
//ENK: 23.11.2006
+
aMeshOnEntity->myIsVTKDone = true;
if(MYDEBUGWITHFILES){
std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
- std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
- aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-Conv.vtk";
+ std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
+ aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-MeshOnEntity.vtk";
VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
}
//---------------------------------------------------------------
-VISU::PIDMapper
+VISU::PUnstructuredGridIDMapper
VISU_Convertor_impl
::GetFamilyOnEntity(const std::string& theMeshName,
const VISU::TEntity& theEntity,
TFindFamilyOnEntity aFindFamilyOnEntity =
FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
- PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);;
- PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
- PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
+ VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);;
+ VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
+ VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
//Main part of code
#ifndef _DEXCEPT_
try{
#endif
if(!aFamily->myIsVTKDone){
- const TVTKSource& aSource = aFamily->GetSource();
+ const VISU::PUnstructuredGrid& aSource = aFamily->GetSource();
if(MYVTKDEBUG) aSource->DebugOn();
GetMeshOnEntity(theMeshName,theEntity);
LoadFamilyOnEntity(aMesh,aMeshOnEntity,aFamily);
- aSource->ShallowCopy(GetPointsSource(aMesh));
+ aSource->ShallowCopy(aMesh->GetPointSet());
GetCellsOnFamily(aSource,aMeshOnEntity,aFamily);
aFamily->myNamedPointCoords = aMesh->myNamedPointCoords;
if(MYDEBUGWITHFILES){
std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
std::string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1();
- std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
- aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-Conv.vtk";
+ std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
+ aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-FamilyOnEntity.vtk";
VISU::WriteToFile(aSource.GetPointer(),aFileName);
}
//---------------------------------------------------------------
-VISU::PIDMapper
+VISU::PUnstructuredGridIDMapper
VISU_Convertor_impl
-::GetMeshOnGroup(const string& theMeshName,
- const string& theGroupName)
+::GetMeshOnGroup(const std::string& theMeshName,
+ const std::string& theGroupName)
{
INITMSG(MYDEBUG,"GetMeshOnGroup\n");
INITMSGA(MYDEBUG,0,
//Cheching possibility do the query
TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
- PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
- PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
+ VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
+ VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
//Main part of code
#ifndef _DEXCEPT_
try{
#endif
if(!aGroup->myIsVTKDone){
- const TVTKAppendFilter& anAppendFilter = aGroup->GetFilter();
+ const VISU::PAppendFilter& anAppendFilter = aGroup->GetFilter();
const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
LoadMeshOnGroup(aMesh,aFamilySet);
- anAppendFilter->SetSharedPointsDataSet(GetPointsSource(aMesh));
+ anAppendFilter->SetSharedPointSet(aMesh->GetPointSet());
- TFamilySet::const_iterator anIter = aFamilySet.begin();
+ VISU::TFamilySet::const_iterator anIter = aFamilySet.begin();
- TID2ID& anElemObj2VTKID = aGroup->myElemObj2VTKID;
- TFamilyArr& aFamilyArr = aGroup->myFamilyArr;
+ VISU::TID2ID& anElemObj2VTKID = aGroup->myElemObj2VTKID;
+ VISU::TFamilyArr& aFamilyArr = aGroup->myFamilyArr;
aFamilyArr.resize(aFamilySet.size());
for(vtkIdType anID = 0; anIter != aFamilySet.end(); anIter++, anID++){
- PFamilyImpl aFamily = *anIter;
+ VISU::PFamilyImpl aFamily = *anIter;
const std::string& aFamilyName = aFamily->myName;
const VISU::TEntity& anEntity = aFamily->myEntity;
VISU::PIDMapper anIDMapper = GetFamilyOnEntity(theMeshName,anEntity,aFamilyName);
- VISU::TVTKOutput* anOutput = anIDMapper->GetVTKOutput();
+ vtkDataSet* anOutput = anIDMapper->GetOutput();
anAppendFilter->AddInput(anOutput);
vtkIdType aStartID = anElemObj2VTKID.size();
if(MYDEBUGWITHFILES){
std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
std::string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1();
- std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
- aFileName += aMeshName + "-" + aGroupName + "-Conv.vtk";
+ std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
+ aFileName += aMeshName + "-" + aGroupName + "-MeshOnGroup.vtk";
VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
}
}
//---------------------------------------------------------------
-VISU::TVTKOutput*
+vtkUnstructuredGrid*
VISU_Convertor_impl
::GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh,
const VISU::PMeshOnEntityImpl& theMeshOnEntity,
const VISU::PFieldImpl& theField,
const VISU::PValForTimeImpl& theValForTime,
- const VISU::PIDCommonCellsFilter& theIDMapperFilter,
+ const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper,
const VISU::PProfileImpl& theProfile,
const VISU::TEntity& theEntity)
{
- TVTKOutput* anOutput = NULL;
-#ifndef _DEXCEPT_
- try{
-#endif
- // load points if theMeshOnEntity->myEntity == NODE_ENTITY
- // load all coordinates itc.
-
- LoadMeshOnEntity(theMesh,theMeshOnEntity);
- GetMeshOnEntity(theMeshOnEntity->myMeshName,theMeshOnEntity->myEntity);
- if(GetMeshOnProfile(theMesh,theMeshOnEntity,theProfile)){
-
- bool isNeedInCells = false;
- theIDMapperFilter->myIDMapper = theProfile;
-
- if(theMeshOnEntity->myEntity == VISU::NODE_ENTITY){
-
- // add geometry elements to output,
- // if timestamp on NODE_ENTITY and
- // on profiles with status eAddPart
- TGeom2SubProfile::const_iterator anIter = theProfile->myGeom2SubProfile.begin();
- for(; anIter != (theProfile->myGeom2SubProfile).end(); anIter++){
- const EGeometry aGeom = anIter->first;
- const PSubProfileImpl aSubProfile = anIter->second;
- if(aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1){
- isNeedInCells = true;
- break;
- }
- }
- if(isNeedInCells){
- theIDMapperFilter->myIsSpecialKey = true;
- GetTimeStampOnNodalProfile(theMesh,theIDMapperFilter,theField,theValForTime,theEntity);
- anOutput = theIDMapperFilter->GetVTKOutput();
- }
- }
-
- if(!isNeedInCells){
- anOutput = theIDMapperFilter->GetVTKOutput();
- const TVTKSource& aSource = theIDMapperFilter->mySource.GetSource();
- ::GetTimeStampOnProfile(aSource,theField,theValForTime,theEntity);
- }
- }
-#ifndef _DEXCEPT_
- }catch(std::exception& exc){
- MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
- return NULL;
- }
-#endif
+ LoadMeshOnEntity(theMesh, theMeshOnEntity);
+ GetMeshOnEntity(theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity);
+ GetMeshOnProfile(theMesh, theMeshOnEntity, theProfile);
+
+ theUnstructuredGridIDMapper->myIDMapper = theProfile;
+ vtkUnstructuredGrid* anOutput = theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
+ const VISU::PUnstructuredGrid& aSource = theUnstructuredGridIDMapper->mySource.GetSource();
+ VISU::GetTimeStampOnProfile(aSource, theField, theValForTime, theEntity);
return anOutput;
}
-void
-VISU_Convertor_impl
-::GetTimeStampOnNodalProfile(const VISU::PMeshImpl& theMesh,
- const VISU::PIDCommonCellsFilter& theIDMapperFilter,
- const VISU::PFieldImpl& theField,
- const VISU::PValForTimeImpl& theValForTime,
- const VISU::TEntity& theEntity)
-{
- INITMSG(MYDEBUG,"GetTimeStampOnNodalProfile");
- const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
- VISU::TMeshOnEntityMap::const_iterator aIter = aMeshOnEntityMap.begin();
- for(;aIter!=aMeshOnEntityMap.end();aIter++){
- VISU::TEntity aEntity = aIter->first;
- if(aEntity != NODE_ENTITY){
- VISU::PNamedIDMapper aMapper = GetMeshOnEntity(theMesh->myName,aEntity);
- if(aMapper)
- theIDMapperFilter->myMappers[aEntity] = aMapper;
- }
- }
-
- theIDMapperFilter->GetVTKOutput();
- const TVTKSource& aSource = theIDMapperFilter->mySource.GetSource();
- ::GetTimeStampOnProfile(aSource,theField,theValForTime,theEntity);
-
-}
-
//---------------------------------------------------------------
-VISU::PIDMapper
+VISU::PUnstructuredGridIDMapper
VISU_Convertor_impl
-::GetTimeStampOnMesh(const string& theMeshName,
+::GetTimeStampOnMesh(const std::string& theMeshName,
const VISU::TEntity& theEntity,
- const string& theFieldName,
+ const std::string& theFieldName,
int theStampsNum)
{
INITMSG(MYDEBUG,"GetTimeStampOnMesh"<<
theFieldName,
theStampsNum);
- PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
- PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
- PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
- PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
- PFieldImpl aField = boost::get<3>(aFindTimeStamp);
+ VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
+ VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
+ VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
+ VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
+ VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
//Main part of code
- PIDCommonCellsFilter anIDMapperFilter = aValForTime->myIDMapperFilter;
+ VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
#ifndef _DEXCEPT_
try{
#endif
- if(!anIDMapperFilter->myIsVTKDone){
- LoadValForTimeOnMesh(aMesh,aMeshOnEntity,aField,aValForTime);
-
- TVTKOutput* anOutput = GetTimeStampOnProfile(aMesh,
- aVTKMeshOnEntity,
- aField,
- aValForTime,
- anIDMapperFilter,
- aValForTime->myProfile,
- aMeshOnEntity->myEntity);
- if(!anOutput)
+ if(!anUnstructuredGridIDMapper->myIsVTKDone){
+ VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnMesh");
+ LoadValForTimeOnMesh(aMesh, aMeshOnEntity, aField, aValForTime);
+
+ vtkUnstructuredGrid* anOutput = NULL;
+ try{
+ anOutput = GetTimeStampOnProfile(aMesh,
+ aVTKMeshOnEntity,
+ aField,
+ aValForTime,
+ anUnstructuredGridIDMapper,
+ aValForTime->myProfile,
+ aMeshOnEntity->myEntity);
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
anOutput = GetTimeStampOnProfile(aMesh,
aMeshOnEntity,
aField,
aValForTime,
- anIDMapperFilter,
+ anUnstructuredGridIDMapper,
aValForTime->myProfile,
aVTKMeshOnEntity->myEntity);
+ }
//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
- anIDMapperFilter->myIsStructured = aMesh->myIsStructured;
- anIDMapperFilter->myType = aMesh->myType;
- anIDMapperFilter->myGrilleStructure = aMesh->myGrilleStructure;
- anIDMapperFilter->myObjID2StructureID = aMesh->myObjID2StructureID;
+ anUnstructuredGridIDMapper->myIsStructured = aMesh->myIsStructured;
+ anUnstructuredGridIDMapper->myType = aMesh->myType;
+ anUnstructuredGridIDMapper->myGrilleStructure = aMesh->myGrilleStructure;
+ anUnstructuredGridIDMapper->myObjID2StructureID = aMesh->myObjID2StructureID;
//ENK: 23.11.2006
- anIDMapperFilter->myIsVTKDone = true;
+
+ anUnstructuredGridIDMapper->myIsVTKDone = true;
if(MYDEBUGWITHFILES){
- string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
- string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1();
- string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-";
- string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
- aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk";
+ std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
+ std::string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1();
+ std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
+ std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
+ aFieldName + dtos("-%d", theStampsNum) + "-TimeStampOnMesh.vtk";
VISU::WriteToFile(anOutput,aFileName);
}
if(MYVTKDEBUG){
- GetTimeStampSize(theMeshName,theEntity,theFieldName,theStampsNum);
+ GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
anOutput->Update();
if(theEntity == VISU::NODE_ENTITY)
BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
}
- }
+ }
#ifndef _DEXCEPT_
- }catch(std::exception& exc){
+ }catch(std::exception& exc){
throw;
}catch(...){
throw;
}
#endif
- return anIDMapperFilter;
+ return anUnstructuredGridIDMapper;
}
//---------------------------------------------------------------
VISU::PGaussPtsIDMapper
VISU_Convertor_impl
-::GetTimeStampOnGaussPts(const string& theMeshName,
+::GetTimeStampOnGaussPts(const std::string& theMeshName,
const VISU::TEntity& theEntity,
- const string& theFieldName,
+ const std::string& theFieldName,
int theStampsNum)
{
INITMSG(MYDEBUG,"GetTimeStampOnGaussPts"<<
"; theStampsNum = "<<theStampsNum<<
endl);
+ if(theEntity == VISU::NODE_ENTITY)
+ EXCEPTION(std::runtime_error, "It is impossible to reate Gauss Points on NODE_ENTITY !!!");
+
//Cheching possibility do the query
TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
theEntity,
theFieldName,
theStampsNum);
- PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
- PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
- PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
- PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
- PFieldImpl aField = boost::get<3>(aFindTimeStamp);
+ VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
+ VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
+ VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
+ VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
+ VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
//Main part of code
- PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
+ VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
#ifndef _DEXCEPT_
try{
#endif
if(!aGaussPtsIDFilter->myIsVTKDone){
- LoadValForTimeOnGaussPts(aMesh,aMeshOnEntity,aField,aValForTime);
+ VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnGaussPts");
+ LoadValForTimeOnGaussPts(aMesh, aMeshOnEntity, aField, aValForTime);
- GetMeshOnEntity(aVTKMeshOnEntity->myMeshName,aVTKMeshOnEntity->myEntity);
+ GetMeshOnEntity(aVTKMeshOnEntity->myMeshName, aVTKMeshOnEntity->myEntity);
- PProfileImpl aProfile = aValForTime->myProfile;
- GetMeshOnProfile(aMesh,aVTKMeshOnEntity,aProfile);
+ VISU::PProfileImpl aProfile = aValForTime->myProfile;
+ GetMeshOnProfile(aMesh, aVTKMeshOnEntity, aProfile);
- PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh;
- TSource& aGaussPtsSource = aGaussMesh->mySource;
- if(!aGaussPtsSource.myIsVTKDone){
- BuildGaussMesh(aMesh,aVTKMeshOnEntity,aGaussMesh);
+ VISU::PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh;
+ if(!aGaussMesh->myIsVTKDone){
+ BuildGaussMesh(aMesh, aVTKMeshOnEntity, aGaussMesh);
aGaussMesh->myParent = aProfile.get();
- aGaussPtsSource.myIsVTKDone = true;
+ aGaussMesh->myIsVTKDone = true;
}
aGaussPtsIDFilter->myIDMapper = aGaussMesh;
aGaussPtsIDFilter->myGaussPtsIDMapper = aGaussMesh;
- TVTKOutput* anOutput = aGaussPtsIDFilter->GetVTKOutput();
- const TVTKSource& aSource = aGaussPtsIDFilter->mySource.GetSource();
- GetTimeStampOnGaussMesh(aSource,aField,aValForTime);
+ vtkPolyData* anOutput = aGaussPtsIDFilter->GetPolyDataOutput();
+ const VISU::PPolyData& aSource = aGaussPtsIDFilter->mySource.GetSource();
+ VISU::GetTimeStampOnGaussMesh(aSource, aField, aValForTime);
aGaussPtsIDFilter->myIsVTKDone = true;
if(MYDEBUGWITHFILES){
- string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
- string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1();
- string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-";
- string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
- aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk";
- VISU::WriteToFile(anOutput,aFileName);
+ std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
+ std::string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1();
+ std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
+ std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
+ aFieldName + dtos("-%d",theStampsNum) + "-TimeStampOnGaussPts.vtk";
+ VISU::WriteToFile(anOutput, aFileName);
}
if(MYVTKDEBUG){
- GetTimeStampSize(theMeshName,theEntity,theFieldName,theStampsNum);
+ GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
anOutput->Update();
if(theEntity == VISU::NODE_ENTITY)
BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
//---------------------------------------------------------------
VISU::PMeshImpl
VISU_Convertor_impl
-::FindMesh(const string& theMeshName)
+::FindMesh(const std::string& theMeshName)
{
GetMeshMap();
- TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName);
+ VISU::TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName);
if(aMeshMapIter == myMeshMap.end())
- EXCEPTION(runtime_error,"FindMesh >> There is no mesh with the name - '"<<theMeshName<<"'!!!");
+ EXCEPTION(std::runtime_error,"FindMesh >> There is no mesh with the name - '"<<theMeshName<<"'!!!");
- PMeshImpl aMesh = aMeshMapIter->second;
+ VISU::PMeshImpl aMesh = aMeshMapIter->second;
return aMesh;
}
//---------------------------------------------------------------
VISU_Convertor_impl::TFindMeshOnEntity
VISU_Convertor_impl
-::FindMeshOnEntity(const string& theMeshName,
- const VISU::TEntity& theEntity,
- bool checkExists)
+::FindMeshOnEntity(const std::string& theMeshName,
+ const VISU::TEntity& theEntity)
{
- PMeshOnEntityImpl aMeshOnEntity;
- PMeshImpl aMesh = FindMesh(theMeshName);
+ VISU::PMeshImpl aMesh = FindMesh(theMeshName);
VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
- if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()){
- if(!checkExists){
- EXCEPTION(runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
- } else {
- return TFindMeshOnEntity(aMesh,aMeshOnEntity);
- }
- }
+ if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
+ EXCEPTION(std::runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
- aMeshOnEntity = aMeshOnEntityMapIter->second;
+ VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
return TFindMeshOnEntity(aMesh,
aMeshOnEntity);
//---------------------------------------------------------------
VISU_Convertor_impl::TFindFamilyOnEntity
VISU_Convertor_impl
-::FindFamilyOnEntity(const string& theMeshName,
+::FindFamilyOnEntity(const std::string& theMeshName,
const VISU::TEntity& theEntity,
- const string& theFamilyName)
+ const std::string& theFamilyName)
{
if(theFamilyName != ""){
- PMeshImpl aMesh = FindMesh(theMeshName);
+ VISU::PMeshImpl aMesh = FindMesh(theMeshName);
VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
- EXCEPTION(runtime_error,"FindFamilyOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
+ EXCEPTION(std::runtime_error,"FindFamilyOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
- PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
+ VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
- TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
- TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName);
+ VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+ VISU::TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName);
if(aFamilyMapIter != aFamilyMap.end()){
- const PFamily& aFamily = aFamilyMapIter->second;
+ const VISU::PFamily& aFamily = aFamilyMapIter->second;
return TFindFamilyOnEntity(aMesh,
aMeshOnEntity,
aFamily);
//---------------------------------------------------------------
-vtkFloatingPointType
+size_t
VISU_Convertor_impl
::GetSize()
{
- vtkFloatingPointType aResult = 0.0;
+ size_t aResult = 0;
const VISU::TMeshMap& aMeshMap = GetMeshMap();
VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
- const string& aMeshName = aMeshMapIter->first;
+ const std::string& aMeshName = aMeshMapIter->first;
const VISU::PMesh aMesh = aMeshMapIter->second;
const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
- const string& aFieldName = aFieldMapIter->first;
+ const std::string& aFieldName = aFieldMapIter->first;
const VISU::PField aField = aFieldMapIter->second;
const VISU::TValField& aValField = aField->myValField;
VISU::TValField::const_iterator aValFieldIter = aValField.begin();
const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
- const string& aGroupName = aGroupMapIter->first;
+ const std::string& aGroupName = aGroupMapIter->first;
aResult += GetMeshOnGroupSize(aMeshName,aGroupName);
}
//Import families
const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
- const string& aFamilyName = aFamilyMapIter->first;
+ const std::string& aFamilyName = aFamilyMapIter->first;
aResult += GetFamilyOnEntitySize(aMeshName,anEntity,aFamilyName);
}
//Import mesh on entity
//---------------------------------------------------------------
-vtkFloatingPointType
+size_t
VISU_Convertor_impl
::GetMeshOnEntitySize(const std::string& theMeshName,
const VISU::TEntity& theEntity)
{
TFindMeshOnEntity aFindMeshOnEntity =
- FindMeshOnEntity(theMeshName,theEntity);
+ FindMeshOnEntity(theMeshName, theEntity);
- PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
- PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
+ VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
+ VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
- vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
- vtkIdType aNbCells = aMeshOnEntity->myNbCells;
- vtkIdType aCellsSize = aMeshOnEntity->myCellsSize;
+ size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
+ size_t aNbCells = aMeshOnEntity->myNbCells;
+ size_t aCellsSize = aMeshOnEntity->myCellsSize;
- vtkIdType aConnectivitySize = aCellsSize*sizeof(vtkIdType);
- vtkIdType aTypesSize = aNbCells*sizeof(char);
- vtkIdType aLocationsSize = aNbCells*sizeof(int);
+ size_t aConnectivitySize = aCellsSize*sizeof(vtkIdType);
+ size_t aTypesSize = aNbCells*sizeof(char);
+ size_t aLocationsSize = aNbCells*sizeof(int);
vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
- vtkIdType aLinksSize = aMesh->myNbPoints *
+ size_t aLinksSize = aMesh->GetNbPoints() *
(vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
aLinksSize = 0;
- vtkIdType aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
+ size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
MSG(MYDEBUG,"GetMeshOnEntitySize "<<
"- aResult = "<<vtkFloatingPointType(aResult)<<
BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
}
- aResult = vtkIdType(aResult*ERR_SIZE_CALC);
+ aResult = size_t(aResult*ERR_SIZE_CALC);
return aResult;
}
//---------------------------------------------------------------
-vtkFloatingPointType
+size_t
VISU_Convertor_impl
::GetFamilyOnEntitySize(const std::string& theMeshName,
const VISU::TEntity& theEntity,
{
TFindFamilyOnEntity aFindFamilyOnEntity =
FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
- PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);
- PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
- PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
+ VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);
+ VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
+ VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
- vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
- vtkIdType aNbCells = aFamily->myNbCells;
- vtkIdType aCellsSize = aFamily->myCellsSize;
+ size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
+ size_t aNbCells = aFamily->myNbCells;
+ size_t aCellsSize = aFamily->myCellsSize;
- vtkIdType aConnectivitySize = aCellsSize*sizeof(vtkIdType);
- vtkIdType aTypesSize = aNbCells*sizeof(char);
- vtkIdType aLocationsSize = aNbCells*sizeof(int);
+ size_t aConnectivitySize = aCellsSize*sizeof(vtkIdType);
+ size_t aTypesSize = aNbCells*sizeof(char);
+ size_t aLocationsSize = aNbCells*sizeof(int);
vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
- vtkIdType aLinksSize = aMesh->myNbPoints *
+ size_t aLinksSize = aMesh->GetNbPoints() *
(vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
aLinksSize = 0;
- vtkIdType aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
+ size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
MSG(MYDEBUG,"GetFamilyOnEntitySize "<<
"- aResult = "<<vtkFloatingPointType(aResult)<<
BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
}
- aResult = vtkIdType(aResult*ERR_SIZE_CALC);
+ aResult = size_t(aResult*ERR_SIZE_CALC);
return aResult;
}
::FindMeshOnGroup(const std::string& theMeshName,
const std::string& theGroupName)
{
- PMeshImpl aMesh = FindMesh(theMeshName);
+ VISU::PMeshImpl aMesh = FindMesh(theMeshName);
VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName);
if(aGroupMapIter == aGroupMap.end())
- EXCEPTION(runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<<theGroupName<<"'");
+ EXCEPTION(std::runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<<theGroupName<<"'");
VISU::PGroupImpl aGroup = aGroupMapIter->second;
return TFindMeshOnGroup(aMesh,aGroup);
}
-vtkFloatingPointType
+size_t
VISU_Convertor_impl
::GetMeshOnGroupSize(const std::string& theMeshName,
const std::string& theGroupName)
{
TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
- PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
- PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
-
- vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
- TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells();
- vtkIdType aNbCells = aNbASizeCells.first;
- vtkIdType aCellsSize = aNbASizeCells.second;
- vtkIdType aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
- vtkIdType aLocationsSize = aNbCells*sizeof(int);
+ VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
+ VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
+
+ size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
+ VISU::TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells();
+ size_t aNbCells = aNbASizeCells.first;
+ size_t aCellsSize = aNbASizeCells.second;
+ size_t aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
+ size_t aLocationsSize = aNbCells*sizeof(int);
vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
- vtkIdType aLinksSize = aMesh->myNbPoints *
+ size_t aLinksSize = aMesh->GetNbPoints() *
(vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
aLinksSize = 0;
- vtkIdType aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
+ size_t aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
if(MYDEBUG){
MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aPointsSize = "<<vtkFloatingPointType(aPointsSize));
MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<vtkFloatingPointType(aConnectivityAndTypesSize));
MSG(MYDEBUG,"GetMeshOnGroupSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"
<<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
- aResult = vtkIdType(aResult*ERR_SIZE_CALC);
+ aResult = size_t(aResult*ERR_SIZE_CALC);
return aResult;
}
VISU_Convertor_impl::TFindField
VISU_Convertor_impl
-::FindField(const string& theMeshName,
+::FindField(const std::string& theMeshName,
const VISU::TEntity& theEntity,
- const string& theFieldName)
+ const std::string& theFieldName)
{
TFindMeshOnEntity aFindMeshOnEntity =
FindMeshOnEntity(theMeshName,theEntity);
- PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
- PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
+ VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
+ VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
- PMeshOnEntityImpl aVTKMeshOnEntity;
+ VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
if(theEntity == VISU::NODE_ENTITY){
if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) != aMeshOnEntityMap.end())
aVTKMeshOnEntity = aMeshOnEntityMap[VISU::CELL_ENTITY];
VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find(theFieldName);
if(aFieldIter == aFieldMap.end())
- EXCEPTION(runtime_error,"FindField >> There is no field on the mesh!!!");
+ EXCEPTION(std::runtime_error,"FindField >> There is no field on the mesh!!!");
- PFieldImpl aField = aFieldIter->second;
+ VISU::PFieldImpl aField = aFieldIter->second;
return TFindField(aMesh,
aMeshOnEntity,
}
-vtkFloatingPointType
+size_t
VISU_Convertor_impl
::GetFieldOnMeshSize(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFieldName)
{
TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
- PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
- PFieldImpl aField = boost::get<3>(aFindField);
+ VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
+ VISU::PFieldImpl aField = boost::get<3>(aFindField);
- vtkFloatingPointType aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
- vtkFloatingPointType aFieldOnMeshSize = vtkFloatingPointType(aField->myDataSize*sizeof(vtkFloatingPointType)*aField->myValField.size()*ERR_SIZE_CALC);
- vtkFloatingPointType aResult = aMeshSize + aFieldOnMeshSize;
+ size_t aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
+ size_t aFieldOnMeshSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType)*aField->myValField.size()*ERR_SIZE_CALC);
+ size_t aResult = aMeshSize + aFieldOnMeshSize;
if(MYDEBUG)
MSG(MYVTKDEBUG,"GetFieldOnMeshSize - aFieldOnMeshSize = "<<vtkFloatingPointType(aFieldOnMeshSize));
MSG(MYDEBUG,"GetFieldOnMeshSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"<<theMeshName<<
int theStampsNum)
{
TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
- PField aField = boost::get<3>(aFindField);
+ VISU::PField aField = boost::get<3>(aFindField);
VISU::TValField& aValField = aField->myValField;
VISU::TValField::const_iterator aValFieldIter= aValField.find(theStampsNum);
if(aValFieldIter == aValField.end())
- EXCEPTION(runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!");
+ EXCEPTION(std::runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!");
- PMeshImpl aMesh = boost::get<0>(aFindField);
- PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField);
- PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
- PValForTimeImpl aValForTime = aValFieldIter->second;
+ VISU::PMeshImpl aMesh = boost::get<0>(aFindField);
+ VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField);
+ VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
+ VISU::PValForTimeImpl aValForTime = aValFieldIter->second;
return TFindTimeStamp(aMesh,
aMeshOnEntity,
}
-vtkFloatingPointType
+size_t
VISU_Convertor_impl
::GetTimeStampSize(const std::string& theMeshName,
const VISU::TEntity& theEntity,
{
TFindTimeStamp aFindTimeStamp =
FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
- PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
- PFieldImpl aField = boost::get<3>(aFindTimeStamp);
+ VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
+ VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
- vtkFloatingPointType aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
- vtkFloatingPointType aTimeStampSize = vtkFloatingPointType(aField->myDataSize*sizeof(vtkFloatingPointType) * ERR_SIZE_CALC);
- vtkFloatingPointType aResult = aMeshSize + aTimeStampSize;
+ size_t aMeshSize = GetMeshOnEntitySize(theMeshName, aVTKMeshOnEntity->myEntity);
+ size_t aTimeStampSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType) * ERR_SIZE_CALC);
+ size_t aResult = aMeshSize + aTimeStampSize;
MSG(MYDEBUG && MYVTKDEBUG,"GetTimeStampSize - aTimeStampSize = "<<vtkFloatingPointType(aTimeStampSize));
MSG(MYDEBUG,"GetTimeStampSize - aResult = "<<vtkFloatingPointType(aResult)<<
}
+size_t
+VISU_Convertor_impl
+::GetTimeStampOnMeshSize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theTimeStampNumber,
+ bool& theIsEstimated)
+{
+ size_t aSize = 0;
+
+ //Cheching possibility do the query
+ TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber);
+
+ VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
+ VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
+ if(anUnstructuredGridIDMapper->myIsVTKDone){
+ VISU::PIDMapper anIDMapper = GetTimeStampOnMesh(theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber);
+ anIDMapper->GetOutput();
+ aSize += anIDMapper->GetMemorySize();
+ }else
+ aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber);
+
+ theIsEstimated = !(anUnstructuredGridIDMapper->myIsVTKDone);
+
+ //cout<<"VISU_Convertor_impl::GetTimeStampOnMeshSize - "<<aSize<<"; "<<(anIDMapperFilter->myIsVTKDone)<<endl;
+ return aSize;
+}
+
+
+size_t
+VISU_Convertor_impl
+::GetTimeStampOnGaussPtsSize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theTimeStampNumber,
+ bool& theIsEstimated)
+{
+ size_t aSize = 0;
+
+ //Cheching possibility do the query
+ TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber);
+
+ VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
+ VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
+ if(aGaussPtsIDFilter->myIsVTKDone){
+ VISU::PGaussPtsIDMapper aGaussPtsIDMapper = GetTimeStampOnGaussPts(theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber);
+ aGaussPtsIDMapper->GetOutput();
+ aSize += aGaussPtsIDMapper->GetMemorySize();
+ }else
+ aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber);
+
+ theIsEstimated = !(aGaussPtsIDFilter->myIsVTKDone);
+
+ //cout<<"VISU_Convertor_impl::GetTimeStampOnGaussPtsSize - "<<aSize<<"; "<<(aGaussPtsIDFilter->myIsVTKDone)<<endl;
+ return aSize;
+}
+
+
const VISU::PField
VISU_Convertor_impl
-::GetField(const string& theMeshName,
+::GetField(const std::string& theMeshName,
VISU::TEntity theEntity,
- const string& theFieldName)
+ const std::string& theFieldName)
{
TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
- PField aField = boost::get<3>(aFindField);
+ VISU::PField aField = boost::get<3>(aFindField);
return aField;
}
{
TFindTimeStamp aFindTimeStamp =
FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
- PValForTime aValForTime = boost::get<4>(aFindTimeStamp);
+ VISU::PValForTime aValForTime = boost::get<4>(aFindTimeStamp);
return aValForTime;
}
#ifndef VISU_Convertor_impl_HeaderFile
#define VISU_Convertor_impl_HeaderFile
-#include <vtkSmartPointer.h>
-
-#include <boost/tuple/tuple.hpp>
-
-class vtkCell;
-class vtkPoints;
-class vtkUnstructuredGrid;
-class VTKViewer_AppendFilter;
-class VISU_MergeFilter;
-class VISU_CommonCellsFilter;
-
-#include "VISUConvertor.hxx"
#include "VISU_Convertor.hxx"
-#include "MED_SliceArray.hxx"
-
-#ifndef VISU_ENABLE_QUADRATIC
-#define VISU_ENABLE_QUADRATIC
-#define VISU_USE_VTK_QUADRATIC
-#endif
-
-namespace VISU
-{
- //! Defines VISU enumeration of geometrical types
- enum EGeometry {ePOINT1=1, eSEG2=102, eSEG3=103, eTRIA3=203,
- eQUAD4=204, eTRIA6=206,eQUAD8=208, eTETRA4=304,
- ePYRA5=305, ePENTA6=306, eHEXA8=308, eTETRA10=310,
- ePYRA13=313, ePENTA15=315, eHEXA20=320,
- ePOLYGONE=400, ePOLYEDRE=500, eNONE=-1};
-
- //! Get number of nodes for defined geometrical type
- VISU_CONVERTOR_EXPORT vtkIdType
- VISUGeom2NbNodes(EGeometry theGeom);
-
- //! Maps VISU geometrical type to VTK one
- VISU_CONVERTOR_EXPORT vtkIdType
- VISUGeom2VTK(EGeometry theGeom);
-
- //---------------------------------------------------------------
- using MED::TCSlice;
- using MED::TSlice;
-
- typedef vtkUnstructuredGrid TDataSet;
-
- typedef vtkSmartPointer<TDataSet> TVTKSource;
- typedef vtkSmartPointer<vtkPoints> TVTKPoints;
- typedef vtkSmartPointer<VISU_MergeFilter> TVTKMergeFilter;
- typedef vtkSmartPointer<VISU_CommonCellsFilter> TVTKCommonCellsFilter;
-
- typedef vtkSmartPointer<VTKViewer_AppendFilter> TVTKAppendFilter;
-
- typedef vtkFloatingPointType TCoord;
-
- //---------------------------------------------------------------
- //! Define an utility base class which is repsonsible for preventing repetion
- struct VISU_CONVERTOR_EXPORT TIsVTKDone: virtual TBaseStructure
- {
- TIsVTKDone();
- bool myIsDone; //!< Say, is the corresponding MED entity already loaded into intermediate data structure
- bool myIsVTKDone; //!< Say, is the corresponding intermediate data structure already mapped into VTK representation
- };
-
-
- //---------------------------------------------------------------
- //! Define an utility base class which allow to keep calculated number of cells and their size
- struct VISU_CONVERTOR_EXPORT TSizeCounter: virtual TIsVTKDone
- {
- TSizeCounter();
- vtkIdType myNbCells; //!< Number of cells contained into corresponding sublclass
- vtkIdType myCellsSize; //!< Size of cells contained into corresponding sublclass
- };
-
-
- //---------------------------------------------------------------
- //! Define a container for VTK representation
- class VISU_CONVERTOR_EXPORT TSource: public virtual TSizeCounter
- {
- protected:
- mutable TVTKSource mySource;
- public:
- TSource();
-
- //! This method allow to create corresponding VTK data set by demand (not at once)
- const TVTKSource&
- GetSource() const;
-
- //! Reimplement the TIDMapper::GetVTKOutput
- virtual
- TVTKOutput*
- GetVTKOutput();
- };
-
-
- //---------------------------------------------------------------
- //! Define a container for VTK representation
- /*!
- This container allow to combine other VTK representation into single one.
- */
- class VISU_CONVERTOR_EXPORT TAppendFilter: public virtual TIsVTKDone,
- public virtual TIDMapper
- {
- protected:
- mutable TVTKAppendFilter myFilter;
- public:
- TAppendFilter();
-
- //! This method allow to create corresponding VTK filter by demand (not at once)
- const TVTKAppendFilter&
- GetFilter() const;
-
- //! Reimplement the TIDMapper::GetVTKOutput
- virtual
- TVTKOutput*
- GetVTKOutput();
- };
- typedef SharedPtr<TAppendFilter> PAppendFilter;
-
-
- //---------------------------------------------------------------
- //! Define a container for VTK representation
- /*!
- This container allow to assign data to mesh and represent them into single VTK representation
- */
- class VISU_CONVERTOR_EXPORT TMergeFilter: public virtual TIsVTKDone,
- public virtual TIDMapper
- {
- protected:
- mutable TVTKMergeFilter myFilter;
- public:
- TMergeFilter();
-
- //! This method allow to create corresponding VTK filter by demand (not at once)
- const TVTKMergeFilter&
- GetFilter() const;
-
- //! Reimplement the TIDMapper::GetVTKOutput
- virtual
- TVTKOutput*
- GetVTKOutput();
- };
- typedef SharedPtr<TMergeFilter> PMergeFilter;
-
-
- //---------------------------------------------------------------
- typedef TVector<TCoord> TCoordArray;
- typedef TSlice<TCoordArray> TCoordSlice;
- typedef TCSlice<TCoordArray> TCCoordSlice;
-
- //! This class is responsible for representation of mesh nodes
- class VISU_CONVERTOR_EXPORT TPointCoords: public virtual TBaseStructure
- {
- protected:
- vtkIdType myDim; //!< Dimension of the nodal coordinates
- vtkIdType myNbPoints; //!< Number of nodes in corresponding mesh
-
- //! An container for coordinates of the nodes
- /*!
- Usage of slices allow to minimize amount of memory to store the nodal coordinates and
- provide unifirm way of conversation with this coordinates (independant from mesh dimension)
- */
- TCoordArray myCoord;
- TVTKPoints myPoints; //!< VTK representation for the mesh nodes
-
- public:
- TPointCoords();
-
- //! To initilize the class
- void
- Init(vtkIdType theNbPoints,
- vtkIdType theDim);
-
- //! Get slice of coordinates for defined node (const version)
- TCCoordSlice
- GetCoordSlice(vtkIdType theNodeId) const;
-
- //! Get slice of coordinates for defined node
- TCoordSlice
- GetCoordSlice(vtkIdType theNodeId);
-
- vtkIdType
- GetNbPoints() const { return myNbPoints; }
-
- vtkIdType
- GetDim() const { return myDim; }
-
- vtkIdType
- size() const { return GetNbPoints(); }
-
- const TVTKPoints&
- GetPoints() const { return myPoints;}
- };
- typedef SharedPtr<TPointCoords> PPointCoords;
-
-
- //---------------------------------------------------------------
- typedef TVector<vtkIdType> TVectorID;
- typedef std::map<vtkIdType,vtkIdType> TObj2VTKID;
-
- //! This class is responsible for representation of mesh nodes
- /*!
- In additition to its base functionlity it support mapping of VTK to object numeration and
- keeps names for each of nodes.
- */
- class VISU_CONVERTOR_EXPORT TNamedPointCoords: public virtual TPointCoords
- {
- protected:
- typedef TVector<std::string> TPointsDim;
- TPointsDim myPointsDim; //!< Keeps name of each dimension
- TVectorID myVectorID; //!< Keeps object¶ numeration
- TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one
-
- public:
-
- //! To initilize the class (numeration of the nodes can be missed)
- void
- Init(vtkIdType theNbPoints,
- vtkIdType theDim,
- const TVectorID& theVectorID = TVectorID());
-
- //! Get name for defined dimension
- std::string&
- GetName(vtkIdType theDim);
-
- //! Get name for defined dimension (const version)
- const std::string&
- GetName(vtkIdType theDim) const;
-
- //! Get object number for node by its VTK one
- virtual
- vtkIdType
- GetObjID(vtkIdType theID) const;
-
- //! Get VTK number for node by its object one
- virtual
- vtkIdType
- GetVTKID(vtkIdType theID) const;
-
- //! Get name of node by its object number
- virtual
- std::string
- GetNodeName(vtkIdType theObjID) const;
- };
- typedef SharedPtr<TNamedPointCoords> PNamedPointCoords;
-
-
- //---------------------------------------------------------------
- //! Specialize TMesh to provide VTK mapping for nodes
- struct VISU_CONVERTOR_EXPORT TMeshImpl: virtual TMesh,
- virtual TIsVTKDone
- {
- PNamedPointCoords myNamedPointCoords; //!< Keeps intermediate representation of the nodes
-
- TVTKSource myPointsSource; //!< Keeps VTK representation of the nodes
- vtkIdType myNbPoints; //!< Keeps number of the nodes
-
- TMeshImpl();
- };
- typedef SharedPtr<TMeshImpl> PMeshImpl;
-
-
- //---------------------------------------------------------------
- typedef TVector<vtkIdType> TSubMeshID;
- typedef enum {eRemoveAll, eAddAll, eAddPart, eNone} ESubMeshStatus;
-
- //! Specialize TSubProfile to provide VTK mapping
- struct VISU_CONVERTOR_EXPORT TSubProfileImpl: virtual TSubProfile,
- virtual TSource
- {
- TSubProfileImpl();
-
- EGeometry myGeom; //!< Defines to what geometrical type the MED PROFILE belong to
- std::string myName; //!< Keeps its name
-
- //! Get object number of mesh cell by its VTK one
- virtual
- vtkIdType
- GetElemObjID(int theVtkI) const;
-
- //! Keeps status of the structure
- /*!
- In some cases MED file does not use MED PROFILES, but at VISU creates corresponding data strucutre
- in order to construct mesh for MED TIEMSTAMPS in uniform way.
- */
- ESubMeshStatus myStatus;
- TSubMeshID mySubMeshID; //!< Keeps numbers of mesh cell which contain the MED PROFILE
- };
- typedef SharedPtr<TSubProfileImpl> PSubProfileImpl;
-
-
- //---------------------------------------------------------------
- struct TMeshOnEntityImpl;
-
- typedef std::map<vtkIdType,vtkIdType> TID2ID;
- typedef TVector<PSubProfileImpl> TSubProfileArr;
- typedef std::map<EGeometry,PSubProfileImpl> TGeom2SubProfile;
-
- //! Specialize TProfile to provide VTK mapping for MED TIMESTAMP mesh
- struct VISU_CONVERTOR_EXPORT TProfileImpl: virtual TProfile,
- virtual TAppendFilter
- {
- TProfileImpl();
- bool myIsAll; //!< Say, whether the MED TIMESTAMP defined on all MED ENTITY or not
-
- //! Reimplement the TIDMapper::GetNodeObjID
- virtual
- vtkIdType
- GetNodeObjID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetNodeVTKID
- virtual
- vtkIdType
- GetNodeVTKID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetNodeCoord
- virtual
- vtkFloatingPointType*
- GetNodeCoord(vtkIdType theObjID);
-
- //! Reimplement the TIDMapper::GetElemObjID
- virtual
- vtkIdType
- GetElemObjID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetElemVTKID
- virtual
- vtkIdType
- GetElemVTKID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetElemCell
- virtual
- vtkCell*
- GetElemCell(vtkIdType theObjID);
-
- //! Reimplement the TIDMapper::GetVTKOutput
- virtual
- TVTKOutput*
- GetVTKOutput();
-
- //! Reimplement the TNamedIDMapper::GetNodeName
- virtual
- std::string
- GetNodeName(vtkIdType theObjID) const;
-
- //! Reimplement the TNamedIDMapper::GetElemName
- virtual
- std::string
- GetElemName(vtkIdType theObjID) const;
-
- TID2ID myElemObj2VTKID; //!< Keeps object to VTK numeration mapping
- TSubProfileArr mySubProfileArr; //!< Keeps sequence of TSubProfiles as they were added into TAppendFilter
- PNamedPointCoords myNamedPointCoords; //!< Keeps reference on the same TNamedPointCoords as TMesh
- TMeshOnEntityImpl* myMeshOnEntity; //<! Keeps backward reference to corresponding MED ENTITY mesh
-
- TSource mySource; //!< Keeps VTK representation of the MED TIMESTAMP mesh
- TGeom2SubProfile myGeom2SubProfile; //!< Keeps TSubProfiles according to their geometrical type
- };
- typedef SharedPtr<TProfileImpl> PProfileImpl;
-
-
- //---------------------------------------------------------------
- //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
- struct VISU_CONVERTOR_EXPORT TIDMapperFilter: virtual TMergeFilter
- {
- PAppendFilter myIDMapper; //!< Responsible for numbering
- TSource mySource; //!< Keeps assigned data
-
- //! Reimplement the TIDMapper::GetNodeObjID
- virtual
- vtkIdType
- GetNodeObjID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetNodeVTKID
- virtual
- vtkIdType
- GetNodeVTKID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetNodeCoord
- virtual
- vtkFloatingPointType*
- GetNodeCoord(vtkIdType theObjID);
-
- //! Reimplement the TIDMapper::GetElemObjID
- virtual
- vtkIdType
- GetElemObjID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetElemVTKID
- virtual
- vtkIdType
- GetElemVTKID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetElemCell
- virtual
- vtkCell*
- GetElemCell(vtkIdType theObjID);
-
- //! Reimplement the TIDMapper::GetVTKOutput
- virtual
- TVTKOutput*
- GetVTKOutput();
- };
- typedef SharedPtr<TIDMapperFilter> PIDMapperFilter;
-
- typedef std::map<VISU::TEntity,VISU::PNamedIDMapper> PNamedIDMapperMap;
- //---------------------------------------------------------------
- //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
- struct TIDCommonCellsFilter: virtual TIDMapperFilter
- {
- protected:
- mutable TVTKCommonCellsFilter myFilter;
- mutable TVTKMergeFilter myMergeFilter;
- public:
-
- TIDCommonCellsFilter();
-
- //! This method allow to create corresponding VTK filter by demand (not at once)
- const TVTKCommonCellsFilter&
- GetFilter() const;
-
- //! if false, TIDCommonCellsFilter - same as TIDMapperFilter
- //! if true, TIDCommonCellsFilter - use VISU_CommonCellsFilter
- bool myIsSpecialKey;
-
- //! Vector of id mappers, which consist of meshonentity in next sequence:
- //! CELL_ENTITY,FACE_ENTITY,EDGE_ENTITY
- PNamedIDMapperMap myMappers;
- //! Reimplement the TIDMapperFilter::GetVTKOutput
- virtual
- TVTKOutput*
- GetVTKOutput();
- };
- typedef SharedPtr<TIDCommonCellsFilter> PIDCommonCellsFilter;
-
-
- //---------------------------------------------------------------
- struct TGaussImpl;
- typedef SharedPtr<TGaussImpl> PGaussImpl;
-
- //! Specialize TGauss to provide more detail information of the MED GAUSS entity for VTK mapping
- struct VISU_CONVERTOR_EXPORT TGaussImpl: virtual TGauss
- {
- EGeometry myGeom; //!< Define, to which geometrical type the MED GAUSS entity belongs
- std::string myName; //!< Keeps name of the MED GAUSS entity
- vtkIdType myNbPoints; //<! Keeps number of points for the MED GAUSS entity
-
- //! To define a way to implement more detail comparision of the TGaussSubMesh instances
- virtual
- void
- LessThan(const PGaussImpl& theGauss,
- bool& theResult) const;
- };
-
+#include "VISU_ConvertorDef_impl.hxx"
- //---------------------------------------------------------------
- //! Specialize TGaussSubMesh to provide VTK mapping for the entity
- struct VISU_CONVERTOR_EXPORT TGaussSubMeshImpl: virtual TGaussSubMesh,
- virtual TSource
- {
- TGaussSubMeshImpl();
-
- //! To implement the TGaussPtsIDMapper::GetObjID
- virtual
- TGaussPointID
- GetObjID(vtkIdType theID,
- vtkIdType theStartID) const;
-
- PGaussImpl myGauss; //<! Keep reference to corresponding TGauss structure
-
- //! Keeps status of the structure
- /*!
- In some cases MED file does not use MED GAUSS, but at VISU creates corresponding data strucutre
- in order to construct mesh for MED TIEMSTAMPS in uniform way.
- */
- ESubMeshStatus myStatus;
-
- TPointCoords myPointCoords; //!< Keeps coordinates of Gauss Points
- };
- typedef SharedPtr<TGaussSubMeshImpl> PGaussSubMeshImpl;
-
-
- //---------------------------------------------------------------
- typedef TVector<PGaussSubMeshImpl> TGaussSubMeshArr;
- typedef std::map<EGeometry,PGaussSubMeshImpl> TGeom2GaussSubMesh;
-
- //! Specialize TGaussMesh to provide VTK mapping for the entity
- struct VISU_CONVERTOR_EXPORT TGaussMeshImpl: virtual TGaussMesh,
- virtual TAppendFilter
- {
- TGaussMeshImpl();
-
- //! Reimplement the TGaussPtsIDMapper::GetObjID
- virtual
- TGaussPointID
- GetObjID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetVTKOutput
- virtual
- TVTKOutput*
- GetVTKOutput();
-
- //! Reimplement the TGaussPtsIDMapper::GetParent
- virtual
- TNamedIDMapper*
- GetParent();
-
- TSource mySource; //!< Keeps VTK representation of the Gauss Points
- TNamedIDMapper* myParent; //!< Refer to parent mesh
- TGaussSubMeshArr myGaussSubMeshArr; //!< Keeps sequence of TGaussSubMesh as they were added into TAppendFilter
- TGeom2GaussSubMesh myGeom2GaussSubMesh; //!< Keeps TGaussSubMesh according to their geometrical type
- };
- typedef SharedPtr<TGaussMeshImpl> PGaussMeshImpl;
-
-
- //---------------------------------------------------------------
- //! Specialize TGaussPtsIDMapper to provide VTK mapping for MED TIMESTAMP mesh
- struct VISU_CONVERTOR_EXPORT TGaussPtsIDFilter: virtual TIDMapperFilter,
- virtual TGaussPtsIDMapper
- {
- PGaussPtsIDMapper myGaussPtsIDMapper;
-
- //! Reimplement the TGaussPtsIDMapper::GetObjID
- virtual
- TGaussPointID
- GetObjID(vtkIdType theID) const;
-
- //! Reimplement the TGaussPtsIDMapper::GetParent
- virtual
- TNamedIDMapper*
- GetParent();
- };
- typedef SharedPtr<TGaussPtsIDFilter> PGaussPtsIDFilter;
-
-
- //---------------------------------------------------------------
- typedef TVector<vtkIdType> TConnect;
- typedef TVector<TConnect> TCell2Connect;
-
- //! The class is responsible for mapping of cells of defined geometrical type
- struct VISU_CONVERTOR_EXPORT TSubMeshImpl: virtual TSource,
- virtual TStructured // ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
- {
-
- //! To implement the TIDMapper::GetElemObjID
- virtual
- vtkIdType
- GetElemObjID(vtkIdType theID) const;
-
- //! To implement the TNamedIDMapper::GetElemName
- virtual
- std::string
- GetElemName(vtkIdType theObjID) const;
-
- vtkIdType myStartID;
- TCell2Connect myCell2Connect; //!< Contains connectivity for the cells
- };
- typedef SharedPtr<TSubMeshImpl> PSubMeshImpl;
-
-
- //---------------------------------------------------------------
- typedef std::map<EGeometry,PSubMeshImpl> TGeom2SubMesh;
- typedef TVector<PSubMeshImpl> TSubMeshArr;
-
- //! Specialize TMeshOnEntity to provide VTK mapping for the entity
- struct VISU_CONVERTOR_EXPORT TMeshOnEntityImpl: virtual TMeshOnEntity,
- virtual TAppendFilter,
- virtual TSizeCounter
- {
- //! Reimplement the TIDMapper::GetNodeVTKID
- virtual
- vtkIdType
- GetNodeVTKID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetNodeObjID
- virtual
- vtkIdType
- GetNodeObjID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetElemVTKID
- virtual
- vtkIdType
- GetElemVTKID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetElemObjID
- virtual
- vtkIdType
- GetElemObjID(vtkIdType theID) const;
-
- //! Reimplement the TNamedIDMapper::GetNodeName
- virtual
- std::string
- GetNodeName(vtkIdType theObjID) const;
-
- //! Reimplement the TNamedIDMapper::GetElemName
- virtual
- std::string
- GetElemName(vtkIdType theObjID) const;
-
- TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
- TSubMeshArr mySubMeshArr; //!< Keeps sequence of TSubMeshImpl as they were added into TAppendFilter
- PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
-
- TGeom2SubMesh myGeom2SubMesh; //!< Keeps TSubMeshImpl according to their geometrical type
- };
- typedef SharedPtr<TMeshOnEntityImpl> PMeshOnEntityImpl;
-
-
- //---------------------------------------------------------------
- typedef std::map<EGeometry,TSubMeshID> TGeom2SubMeshID;
-
- //! Specialize TFamily to provide VTK mapping for the entity
- struct VISU_CONVERTOR_EXPORT TFamilyImpl: virtual TFamily,
- virtual TSource
- {
- //! Reimplement the TIDMapper::GetNodeObjID
- vtkIdType
- GetNodeObjID(vtkIdType theID) const ;
-
- //! Reimplement the TIDMapper::GetNodeVTKID
- virtual
- vtkIdType
- GetNodeVTKID(vtkIdType theID) const ;
-
- //! Reimplement the TIDMapper::GetElemVTKID
- virtual
- vtkIdType
- GetElemVTKID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetElemObjID
- virtual
- vtkIdType
- GetElemObjID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetVTKOutput
- virtual
- TVTKOutput*
- GetVTKOutput();
-
- PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
- TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
- TSubMeshID myMeshID; //!< Keeps numbers of mesh elements that belongs to the MED FAMILY
-
- TGeom2SubMeshID myGeom2SubMeshID; //!< Keeps TSubMeshID according to their geometrical type
- };
- typedef SharedPtr<TFamilyImpl> PFamilyImpl;
-
-
- //---------------------------------------------------------------
- typedef std::pair<vtkIdType,vtkIdType> TNbASizeCells;
- typedef TVector<PFamilyImpl> TFamilyArr;
-
- //! Specialize TGroup to provide VTK mapping for the entity
- struct VISU_CONVERTOR_EXPORT TGroupImpl: virtual TGroup,
- virtual TAppendFilter
- {
- //! Calculate pair of values - number of cells and its size
- TNbASizeCells
- GetNbASizeCells() const;
-
- //! Reimplement the TIDMapper::GetElemVTKID
- virtual
- vtkIdType
- GetElemVTKID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetElemObjID
- virtual
- vtkIdType
- GetElemObjID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetNodeObjID
- virtual
- vtkIdType
- GetNodeObjID(vtkIdType theID) const;
-
- //! Reimplement the TIDMapper::GetNodeVTKID
- virtual
- vtkIdType
- GetNodeVTKID(vtkIdType theID) const;
-
- TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
- TFamilyArr myFamilyArr; //!< Keeps sequence of TFamily as they were added into TAppendFilter
- PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
- };
- typedef SharedPtr<TGroupImpl> PGroupImpl;
-
-
- //---------------------------------------------------------------
- typedef TVector<TMinMax> TMinMaxArr;
-
- //! Specialize TField to provide VTK mapping for the entity
- struct VISU_CONVERTOR_EXPORT TFieldImpl: virtual TField
- {
- vtkIdType myDataSize; //!< Keeps size of the assigned data
-
- TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD
-
- //! Implement the TField::GetMinMax
- virtual
- TMinMax
- GetMinMax(vtkIdType theCompID);
-
- //! To initialize the data structure
- void
- InitArrays(vtkIdType theNbComp);
-
- TFieldImpl();
- };
- typedef SharedPtr<TFieldImpl> PFieldImpl;
-
-
- //---------------------------------------------------------------
- typedef TVector<vtkFloatingPointType> TValue;
- typedef TSlice<TValue> TValueSlice;
- typedef TCSlice<TValue> TCValueSlice;
-
- typedef TVector<TCValueSlice> TCValueSliceArr;
- typedef TVector<TValueSlice> TValueSliceArr;
-
- //! Define a container to get access to data assigned to mesh
- struct VISU_CONVERTOR_EXPORT TMeshValue
- {
- TValue myValue; //!< Keeps all values as one dimensional sequence
-
- vtkIdType myNbElem; //!< Defines number of mesh elements where the data assigned to
- vtkIdType myNbComp; //!< Keeps number of components of corresponding MED FIELD
- vtkIdType myNbGauss; //!< Defines number of Gauss Points
- vtkIdType myStep; //! Internal variable
-
- //! To intitilize the data strucutre
- void
- Init(vtkIdType theNbElem,
- vtkIdType theNbGauss,
- vtkIdType theNbComp);
-
- //! To get assigned values first by Gauss Points and then by components (constant version)
- TCValueSliceArr
- GetGaussValueSliceArr(vtkIdType theElemId) const;
-
- //! To get assigned values first by Gauss Points and then by components
- TValueSliceArr
- GetGaussValueSliceArr(vtkIdType theElemId);
-
- //! To get assigned values first by components and then by Gauss Points (constant version)
- TCValueSliceArr
- GetCompValueSliceArr(vtkIdType theElemId) const;
-
- //! To get assigned values first by components and then by Gauss Points
- TValueSliceArr
- GetCompValueSliceArr(vtkIdType theElemId);
- };
-
-
- //---------------------------------------------------------------
- typedef std::map<EGeometry,TMeshValue> TGeom2Value;
- typedef std::map<EGeometry,vtkIdType> TGeom2NbGauss;
-
- //! Specialize TValForTime to provide VTK mapping for the entity
- struct VISU_CONVERTOR_EXPORT TValForTimeImpl: virtual TValForTime
- {
- PGaussPtsIDFilter myGaussPtsIDFilter; //!< Keep VTK representation for mesh and data on Gauss Points
- PIDCommonCellsFilter myIDMapperFilter; //!< Keep VTK representation for ordinary mesh and data
- TGeom2Value myGeom2Value; //!< Keep value that is assigned to the mesh
- TGeom2NbGauss myGeom2NbGauss; //!< Keep number of Gauss Points
-
- TValForTimeImpl();
-
- //! Get mesh data for defined geometrical type (constant version)
- const TMeshValue&
- GetMeshValue(EGeometry theGeom) const;
-
- //! Get mesh data for defined geometrical type
- TMeshValue&
- GetMeshValue(EGeometry theGeom);
-
- //! Get number of Gauss Points for defined geometrical type
- virtual
- int
- GetNbGauss(EGeometry theGeom) const;
- };
- typedef SharedPtr<TValForTimeImpl> PValForTimeImpl;
-}
+#include <boost/tuple/tuple.hpp>
+//---------------------------------------------------------------
//! This class perfroms mapping of intermediate data strucutres into corresponding VTK representation
/*!
It implements VISU_Convertor public interface and declare new pure virtual functions
//! Implemention of the VISU_Convertor::GetSize
virtual
- vtkFloatingPointType
+ size_t
GetSize();
//! Implemention of the VISU_Convertor::GetMeshOnEntity
//! Implemention of the VISU_Convertor::GetMeshOnEntitySize
virtual
- vtkFloatingPointType
+ size_t
GetMeshOnEntitySize(const std::string& theMeshName,
const VISU::TEntity& theEntity);
//! Implemention of the VISU_Convertor::GetFamilyOnEntity
virtual
- VISU::PIDMapper
+ VISU::PUnstructuredGridIDMapper
GetFamilyOnEntity(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFamilyName);
//! Implemention of the VISU_Convertor::GetFamilyOnEntitySize
virtual
- vtkFloatingPointType
+ size_t
GetFamilyOnEntitySize(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFamilyName);
//! Implemention of the VISU_Convertor::GetMeshOnGroup
virtual
- VISU::PIDMapper
+ VISU::PUnstructuredGridIDMapper
GetMeshOnGroup(const std::string& theMeshName,
const std::string& theGroupName);
//! Implemention of the VISU_Convertor::GetMeshOnGroupSize
virtual
- vtkFloatingPointType
+ size_t
GetMeshOnGroupSize(const std::string& theMeshName,
const std::string& theGroupName);
//! Implemention of the VISU_Convertor::GetTimeStampOnMesh
virtual
- VISU::PIDMapper
+ VISU::PUnstructuredGridIDMapper
GetTimeStampOnMesh(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFieldName,
- int theStampsNum);
+ int theTimeStampNumber);
- //! Implemention of the VISU_Convertor::GetTimeStampSize
+ //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on mesh
virtual
- vtkFloatingPointType
- GetTimeStampSize(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName,
- int theStampsNum);
+ size_t
+ GetTimeStampOnMeshSize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theTimeStampNumber,
+ bool& theIsEstimated);
+
+ //! Get amount of memory to build vtkDataSet for corresponding MED TIMESTAMP on Gauss Points
+ virtual
+ size_t
+ GetTimeStampOnGaussPtsSize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theTimeStampNumber,
+ bool& theIsEstimated);
//! Implemention of the VISU_Convertor::GetTimeStampOnGaussPts
virtual
GetTimeStampOnGaussPts(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFieldName,
- int theStampsNum);
+ int theTimeStampNumber);
//! Implemention of the VISU_Convertor::GetFieldOnMeshSize
virtual
- vtkFloatingPointType
+ size_t
GetFieldOnMeshSize(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFieldName);
FindMesh(const std::string& theMeshName);
//! An utility method to find TMeshOnEntity by name of its parent mesh and entity
- typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl> TFindMeshOnEntity;
+ typedef boost::tuple<VISU::PMeshImpl,
+ VISU::PMeshOnEntityImpl> TFindMeshOnEntity;
TFindMeshOnEntity
FindMeshOnEntity(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- bool checkExists=false);
+ const VISU::TEntity& theEntity);
//! An utility method to find TFamily by name of its parent mesh, corresponding entity and its name
- typedef boost::tuple<VISU::PMeshImpl,VISU::PMeshOnEntityImpl,VISU::PFamilyImpl> TFindFamilyOnEntity;
+ typedef boost::tuple<VISU::PMeshImpl,
+ VISU::PMeshOnEntityImpl,VISU::PFamilyImpl> TFindFamilyOnEntity;
TFindFamilyOnEntity
FindFamilyOnEntity(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFamilyName);
//! An utility method to find Group by name of its parent mesh and its name
- typedef boost::tuple<VISU::PMeshImpl,VISU::PGroupImpl> TFindMeshOnGroup;
+ typedef boost::tuple<VISU::PMeshImpl,
+ VISU::PGroupImpl> TFindMeshOnGroup;
TFindMeshOnGroup
FindMeshOnGroup(const std::string& theMeshName,
const std::string& theGroupName);
const std::string& theFieldName,
int theStampsNum);
- VISU::TVTKOutput*
+ vtkUnstructuredGrid*
GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh,
const VISU::PMeshOnEntityImpl& theMeshOnEntity,
const VISU::PFieldImpl& theField,
const VISU::PValForTimeImpl& theValForTime,
- const VISU::PIDCommonCellsFilter& theIDMapperFilter,
+ const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter,
const VISU::PProfileImpl& theProfile,
const VISU::TEntity& theEntity);
-
- void
- GetTimeStampOnNodalProfile(const VISU::PMeshImpl& theMesh,
- const VISU::PIDCommonCellsFilter& theIDMapperFilter,
- const VISU::PFieldImpl& theField,
- const VISU::PValForTimeImpl& theValForTime,
- const VISU::TEntity& theEntity);
-
protected:
+ //! Implemention of the VISU_Convertor::GetTimeStampSize
+ virtual
+ size_t
+ GetTimeStampSize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theStampsNum);
+
//! To fill intermeiate representation of TMeshOnEntity from a MED source
virtual
int
#include "VISU_IDMapper.hxx"
#include <vtkUnstructuredGrid.h>
+#include <vtkPolyData.h>
+#include <vtkDataSet.h>
namespace VISU
{
::GetNodeCoord(vtkIdType theObjID)
{
vtkIdType aVTKID = GetNodeVTKID(theObjID);
- return GetVTKOutput()->GetPoint(aVTKID);
+ return GetOutput()->GetPoint(aVTKID);
}
vtkIdType
::GetElemCell(int theObjID)
{
vtkIdType aVtkID = GetElemVTKID(theObjID);
- return GetVTKOutput()->GetCell(aVtkID);
+ return GetOutput()->GetCell(aVtkID);
}
vtkIdType
{
return theID;
}
+ //---------------------------------------------------------------
+
+
+ vtkDataSet*
+ TUnstructuredGridIDMapper
+ ::GetOutput()
+ {
+ return GetUnstructuredGridOutput();
+ }
+ //---------------------------------------------------------------
+
+
+ vtkDataSet*
+ TPolyDataIDMapper
+ ::GetOutput()
+ {
+ return GetPolyDataOutput();
+ }
+
+
+ //---------------------------------------------------------------
}
#include <map>
class vtkUnstructuredGrid;
+class vtkPolyData;
+class vtkDataSet;
class vtkCell;
namespace VISU
std::string myEntry; //!< To simplify publication of the object tree
};
- typedef SharedPtr<TBaseStructure> PBaseStructure;
+ typedef MED::SharedPtr<TBaseStructure> PBaseStructure;
//---------------------------------------------------------------
- typedef vtkUnstructuredGrid TVTKOutput;
-
//! Defines a basic abstract interface for VTK to object ID's and backward mapping
/*!
Where object ID means ID which attached to corresponding MED entity.
//! Get VTK representation of mesh for corresponding MED entity
virtual
- TVTKOutput*
- GetVTKOutput() = 0;
+ vtkDataSet*
+ GetOutput() = 0;
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize() = 0;
};
- typedef SharedPtr<TIDMapper> PIDMapper;
+ typedef MED::SharedPtr<TIDMapper> PIDMapper;
+
+
+ //---------------------------------------------------------------
+ struct TUnstructuredGridIDMapper: virtual TIDMapper
+ {
+ //! Get VTK representation of mesh for corresponding MED entity
+ virtual
+ vtkUnstructuredGrid*
+ GetUnstructuredGridOutput() = 0;
+
+ //! Reimplement the TIDMapper::GetOutput
+ virtual
+ vtkDataSet*
+ GetOutput();
+ };
+ typedef MED::SharedPtr<TUnstructuredGridIDMapper> PUnstructuredGridIDMapper;
//---------------------------------------------------------------
/*!
This class defines some additional methods that allow get names for corresponding mesh elements
*/
- struct TNamedIDMapper: virtual TIDMapper
+ struct TNamedIDMapper: virtual TUnstructuredGridIDMapper
{
//! Get name of mesh node for corresponding object ID
virtual
std::string
GetElemName(vtkIdType theObjID) const = 0;
};
- typedef SharedPtr<TNamedIDMapper> PNamedIDMapper;
+ typedef MED::SharedPtr<TNamedIDMapper> PNamedIDMapper;
+
+
+ //---------------------------------------------------------------
+ struct TPolyDataIDMapper: virtual TIDMapper
+ {
+ //! Get VTK representation of mesh for corresponding MED entity
+ virtual
+ vtkPolyData*
+ GetPolyDataOutput() = 0;
+
+ //! Reimplement the TIDMapper::GetOutput
+ virtual
+ vtkDataSet*
+ GetOutput();
+ };
+ typedef MED::SharedPtr<TPolyDataIDMapper> PPolyDataIDMapper;
//---------------------------------------------------------------
//! Defines a type that represent complex ID for defined Gauss Point
typedef std::pair<TCellID,TLocalPntID> TGaussPointID;
- struct TGaussPtsIDMapper: virtual TIDMapper
+ struct TGaussPtsIDMapper: virtual TPolyDataIDMapper
{
//! Gets complex Gauss Point ID by its VTK ID
virtual
TNamedIDMapper*
GetParent() = 0;
};
- typedef SharedPtr<TGaussPtsIDMapper> PGaussPtsIDMapper;
+ typedef MED::SharedPtr<TGaussPtsIDMapper> PGaussPtsIDMapper;
//---------------------------------------------------------------
}
#include "VISU_MedConvertor.hxx"
-#include "VISU_Convertor.hxx"
#include "VISU_ConvertorUtils.hxx"
#include "MED_Factory.hxx"
#include <vtkCellType.h>
-using namespace std;
-using namespace VISU;
-
using MED::TInt;
using MED::TFloat;
using MED::EBooleen;
#define _LOAD_FAMILIES_
#define _EDF_NODE_IDS_
-//namespace
-//{
+namespace
+{
//---------------------------------------------------------------
vtkIdType
MEDGeom2NbNodes(MED::EGeometrieElement theMEDGeomType)
{
switch(theMEDEntity){
case MED::eNOEUD: return VISU::NODE_ENTITY;
- case MED::eARETE: return EDGE_ENTITY;
- case MED::eFACE: return FACE_ENTITY;
- case MED::eMAILLE: return CELL_ENTITY;
+ case MED::eARETE: return VISU::EDGE_ENTITY;
+ case MED::eFACE: return VISU::FACE_ENTITY;
+ case MED::eMAILLE: return VISU::CELL_ENTITY;
}
return VISU::TEntity(-1);
}
//---------------------------------------------------------------
MED::EEntiteMaillage
- VTKEntityToMED(TEntity theVTKEntity)
+ VTKEntityToMED(VISU::TEntity theVTKEntity)
{
switch(theVTKEntity){
case VISU::NODE_ENTITY: return MED::eNOEUD;
- case EDGE_ENTITY: return MED::eARETE;
- case FACE_ENTITY: return MED::eFACE;
- case CELL_ENTITY: return MED::eMAILLE;
+ case VISU::EDGE_ENTITY: return MED::eARETE;
+ case VISU::FACE_ENTITY: return MED::eFACE;
+ case VISU::CELL_ENTITY: return MED::eMAILLE;
}
return MED::EEntiteMaillage(-1);
}
//---------------------------------------------------------------
- PMEDSubProfile
+ VISU::PMEDSubProfile
CrSubProfile(const MED::PWrapper& theMEDWrapper,
const MED::PMeshInfo& theMeshInfo,
MED::EEntiteMaillage theMEntity,
VISU::EGeometry aEGeom = MEDGeom2VISU(theMGeom);
vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
- PMEDSubProfile aSubProfile(new TMEDSubProfile());
+ VISU::PMEDSubProfile aSubProfile(new VISU::TMEDSubProfile());
aSubProfile->myGeom = aEGeom;
aSubProfile->myMGeom = theMGeom;
- aSubProfile->myStatus = eAddAll;
+ aSubProfile->myStatus = VISU::eAddAll;
MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(theMGeom);
if(aTimeStampIter == theGeom2Size.end())
- aSubProfile->myStatus = eRemoveAll;
+ aSubProfile->myStatus = VISU::eRemoveAll;
else{
MED::TGeom2Profile::const_iterator aProfileIter = theGeom2Profile.find(theMGeom);
if(aProfileIter != theGeom2Profile.end()){
MED::PProfileInfo aProfileInfo = aProfileIter->second;
aSubProfile->myName = aProfileInfo->GetName();
- aSubProfile->myStatus = eAddPart;
+ aSubProfile->myStatus = VISU::eAddPart;
const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
TInt aNbElem = anElemNum.size();
//---------------------------------------------------------------
- TProfileKey
+ VISU::TProfileKey
GetProfileKey(const MED::PWrapper& theMEDWrapper,
const MED::PMeshInfo& theMeshInfo,
- const MED::TTimeStampVal& theTimeStampVal,
+ const MED::PTimeStampValueBase& theTimeStampValue,
const VISU::TMEDMeshOnEntity& theMeshOnEntity,
MED::EEntiteMaillage theMEntity,
const MED::TGeom2Size& theGeom2Size)
{
INITMSG(MYDEBUG,"GetProfileKey"<<endl);
- TProfileKey aProfileKey;
- const MED::TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile();
+ VISU::TProfileKey aProfileKey;
+ const MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->GetGeom2Profile();
const MED::TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
MED::TGeom2Size::const_iterator anIter = aGeom2Size.begin();
for(; anIter != aGeom2Size.end(); anIter++){
MED::EGeometrieElement aMGeom = anIter->first;
- PSubProfile aSubProfile = CrSubProfile(theMEDWrapper,
- theMeshInfo,
- theMEntity,
- aMGeom,
- theGeom2Size,
- aGeom2Profile);
+ VISU::PSubProfile aSubProfile = CrSubProfile(theMEDWrapper,
+ theMeshInfo,
+ theMEntity,
+ aMGeom,
+ theGeom2Size,
+ aGeom2Profile);
aProfileKey.insert(aSubProfile);
}
void
InitProfile(const MED::PWrapper& theMEDWrapper,
const MED::PMeshInfo& theMeshInfo,
- MED::TTimeStampVal& theTimeStampVal,
+ MED::PTimeStampValueBase& theTimeStampValue,
VISU::TMEDMeshOnEntity& theMeshOnEntity,
MED::EEntiteMaillage theMEntity,
const MED::TGeom2Size& theGeom2Size,
VISU::TMEDValForTime& theValForTime)
{
- TTimerLog aTimerLog(MYDEBUG,"InitProfile");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"InitProfile");
INITMSG(MYDEBUG,"InitProfile"<<endl);
- TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
+ VISU::TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
- TProfileKey aProfileKey = GetProfileKey(theMEDWrapper,
+ VISU::TProfileKey aProfileKey = GetProfileKey(theMEDWrapper,
theMeshInfo,
- theTimeStampVal,
+ theTimeStampValue,
theMeshOnEntity,
theMEntity,
theGeom2Size);
- TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
+ VISU::TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
if(anIter != aProfileMap.end()){
theValForTime.myProfile = anIter->second;
INITMSG(MYDEBUG,"aProfileMap.find(aProfileKey)"<<endl);
}else{
- PMEDProfile aProfile(new TMEDProfile());
- TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+ VISU::PMEDProfile aProfile(new VISU::TMEDProfile());
+ VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
- TProfileKey::const_iterator anIter = aProfileKey.begin();
+ VISU::TProfileKey::const_iterator anIter = aProfileKey.begin();
for(; anIter != aProfileKey.end(); anIter++){
- PMEDSubProfile aSubProfile(*anIter);
+ VISU::PMEDSubProfile aSubProfile(*anIter);
- if(aProfile->myIsAll && aSubProfile->myStatus != eAddAll)
+ if(aProfile->myIsAll && aSubProfile->myStatus != VISU::eAddAll)
aProfile->myIsAll = false;
VISU::EGeometry aEGeom = aSubProfile->myGeom;
//---------------------------------------------------------------
- TGaussKey
- GetGaussKey(const MED::TTimeStampVal& theTimeStampVal,
+ VISU::TGaussKey
+ GetGaussKey(const MED::PTimeStampValueBase& theTimeStampValue,
const VISU::TMEDMeshOnEntity& theMeshOnEntity,
const MED::TGeom2Size& theGeom2Size,
VISU::TMEDValForTime& theValForTime)
{
- TTimerLog aTimerLog(MYDEBUG,"GetGaussKey");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"GetGaussKey");
INITMSG(MYDEBUG,"GetGaussKey"<<endl);
- TGaussKey aGaussKey;
- PMEDProfile aProfile = theValForTime.myProfile;
- TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+ VISU::TGaussKey aGaussKey;
+ VISU::PMEDProfile aProfile = theValForTime.myProfile;
+ VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
- const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo();
+ const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampValue->GetTimeStampInfo();
const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
const MED::TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size;
MED::EGeometrieElement aMGeom = anIter->first;
VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
- TGeom2SubProfile::iterator anIter2 = aGeom2SubProfile.find(aEGeom);
+ VISU::TGeom2SubProfile::iterator anIter2 = aGeom2SubProfile.find(aEGeom);
if(anIter2 == aGeom2SubProfile.end()){
INITMSG(MYDEBUG,"anIter2 == aGeom2SubProfile.end!!"<<endl);
continue;
}
- PMEDSubProfile aSubProfile = anIter2->second;
+ VISU::PMEDSubProfile aSubProfile = anIter2->second;
MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(aMGeom);
if(aTimeStampIter != theGeom2Size.end()){
TInt aNbCells = aTimeStampIter->second;
- if(aSubProfile->myStatus == eAddPart)
+ if(aSubProfile->myStatus == VISU::eAddPart)
aNbCells = aSubProfile->myNbCells;
- PMEDGaussSubMesh aGaussSubMesh(new TMEDGaussSubMesh());
+ VISU::PMEDGaussSubMesh aGaussSubMesh(new VISU::TMEDGaussSubMesh());
aGaussSubMesh->mySubProfile = aSubProfile;
aGaussSubMesh->myStatus = aSubProfile->myStatus;
- PMEDGauss aGauss(new TMEDGauss());
+ VISU::PMEDGauss aGauss(new VISU::TMEDGauss());
aGaussSubMesh->myGauss = aGauss;
aGauss->myGeom = aEGeom;
aGauss->myNbPoints = 1;
//---------------------------------------------------------------
void
- InitGaussMesh(MED::TTimeStampVal& theTimeStampVal,
+ InitGaussMesh(MED::PTimeStampValueBase& theTimeStampValue,
VISU::TMEDMeshOnEntity& theMeshOnEntity,
const MED::TGeom2Size& theGeom2Size,
VISU::TMEDValForTime& theValForTime)
{
- TTimerLog aTimerLog(MYDEBUG,"InitGaussMesh");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"InitGaussMesh");
INITMSG(MYDEBUG,"InitGaussMesh"<<endl);
if(theMeshOnEntity.myEntity == VISU::NODE_ENTITY)
return;
- TGaussMeshMap& aGaussMeshMap = theMeshOnEntity.myGaussMeshMap;
+ VISU::TGaussMeshMap& aGaussMeshMap = theMeshOnEntity.myGaussMeshMap;
- TGaussKey aGaussKey = GetGaussKey(theTimeStampVal,
- theMeshOnEntity,
- theGeom2Size,
- theValForTime);
+ VISU::TGaussKey aGaussKey = GetGaussKey(theTimeStampValue,
+ theMeshOnEntity,
+ theGeom2Size,
+ theValForTime);
- TGaussMeshMap::const_iterator anIter = aGaussMeshMap.find(aGaussKey);
+ VISU::TGaussMeshMap::const_iterator anIter = aGaussMeshMap.find(aGaussKey);
if(anIter != aGaussMeshMap.end()){
theValForTime.myGaussMesh = anIter->second;
INITMSG(MYDEBUG,"aGaussMeshMap.find(aGaussKey)"<<endl);
}else{
- PMEDGaussMesh aGaussMesh(new TMEDGaussMesh());
- TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
+ VISU::PMEDGaussMesh aGaussMesh(new VISU::TMEDGaussMesh());
+ VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
{
- TGaussKey::const_iterator anIter = aGaussKey.begin();
+ VISU::TGaussKey::const_iterator anIter = aGaussKey.begin();
for(; anIter != aGaussKey.end(); anIter++){
- PMEDGaussSubMesh aGaussSubMesh(*anIter);
- PMEDGauss aGauss = aGaussSubMesh->myGauss;
+ VISU::PMEDGaussSubMesh aGaussSubMesh(*anIter);
+ VISU::PMEDGauss aGauss = aGaussSubMesh->myGauss;
VISU::EGeometry aEGeom = aGauss->myGeom;
aGeom2GaussSubMesh[aEGeom] = aGaussSubMesh;
}
}
{
- TGaussSubMeshArr& aGaussSubMeshArr = aGaussMesh->myGaussSubMeshArr;
+ VISU::TGaussSubMeshArr& aGaussSubMeshArr = aGaussMesh->myGaussSubMeshArr;
aGaussSubMeshArr.resize(aGeom2GaussSubMesh.size());
- TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
+ VISU::TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
for(TInt anID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++, anID++){
- const PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
+ const VISU::PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
aGaussSubMeshArr[anID] = aGaussSubMesh;
}
}
- INITMSG(MYDEBUG,"aGaussMeshMap[aGaussKey] = aGaussMesh"<<endl);
+ INITMSG(MYDEBUG,"aGaussMeshMap[aGaussKey] = aGaussMesh"<<std::endl);
aGaussMeshMap[aGaussKey] = aGaussMesh;
theValForTime.myGaussMesh = aGaussMesh;
}
void
InitGaussProfile(const MED::PWrapper& theMEDWrapper,
const MED::PMeshInfo& theMeshInfo,
- MED::TTimeStampVal& theTimeStampVal,
+ MED::PTimeStampValueBase& theTimeStampValue,
VISU::TMEDMeshOnEntity& theMeshOnEntity,
MED::EEntiteMaillage theMEntity,
const MED::TGeom2Size& theGeom2Size,
VISU::TMEDValForTime& theValForTime)
{
- TTimerLog aTimerLog(MYDEBUG,"InitGaussProfile");
- INITMSG(MYDEBUG,"InitGaussProfile"<<endl);
+ VISU::TTimerLog aTimerLog(MYDEBUG,"InitGaussProfile");
+ INITMSG(MYDEBUG,"InitGaussProfile"<<std::endl);
// The order of the function calls is important
InitProfile(theMEDWrapper,
theMeshInfo,
- theTimeStampVal,
+ theTimeStampValue,
theMeshOnEntity,
theMEntity,
theGeom2Size,
theValForTime);
- InitGaussMesh(theTimeStampVal,
+ InitGaussMesh(theTimeStampValue,
theMeshOnEntity,
theGeom2Size,
theValForTime);
//---------------------------------------------------------------
void
- BuildMeshOnEntityMap(PMEDMesh theMesh,
+ BuildMeshOnEntityMap(VISU::PMEDMesh theMesh,
const MED::TEntityInfo& theEntityInfo,
const MED::PNodeInfo& theNodeInfo,
const MED::PWrapper& theMEDWrapper)
{
- TTimerLog aTimerLog(MYDEBUG,"BuildMeshOnEntityMap");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMeshOnEntityMap");
INITMSG(MYDEBUG,"BuildMeshOnEntityMap"<<endl);
MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
const std::string& aMeshName = theMesh->myName;
- TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
MED::TEntityInfo::const_iterator anEntityIter = theEntityInfo.begin();
for(; anEntityIter != theEntityInfo.end(); anEntityIter++){
const MED::EEntiteMaillage& aMEntity = anEntityIter->first;
const MED::TGeom2Size& aGeom2Size = anEntityIter->second;
- TEntity aVEntity = MEDEntityToVTK(aMEntity);
- PMEDMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TMEDMeshOnEntity());
+ VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ VISU::PMEDMeshOnEntity aMeshOnEntity =
+ aMeshOnEntityMap[aVEntity](new VISU::TMEDMeshOnEntity());
aMeshOnEntity->myEntity = aVEntity;
aMeshOnEntity->myMeshName = aMeshName;
aMeshOnEntity->myGeom2Size = aGeom2Size;
- TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
+ VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
INITMSG(MYDEBUG,
"- aMEntity = "<<aMEntity<<
INITMSG(MYDEBUG,
"- myNbCells = "<<aMeshOnEntity->myNbCells<<
"; myCellsSize = "<<aMeshOnEntity->myCellsSize<<
- endl);;
+ std::endl);
}else{
MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
//---------------------------------------------------------------
void
- BuildMeshGrilleOnEntityMap(PMEDMesh theMesh,
+ BuildMeshGrilleOnEntityMap(VISU::PMEDMesh theMesh,
const MED::TEntityInfo& theEntityInfo,
const MED::PGrilleInfo& theGrilleInfo,
const MED::PWrapper& theMEDWrapper)
{
- TTimerLog aTimerLog(MYDEBUG,"BuildMeshGrilleOnEntityMap");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMeshGrilleOnEntityMap");
INITMSG(MYDEBUG,"BuildMeshGrilleOnEntityMap"<<endl);
MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
const std::string& aMeshName = theMesh->myName;
- TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
MED::TEntityInfo::const_iterator anEntityIter = theEntityInfo.begin();
//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
}
int iii=0;
- TVectorID aIndexes;
switch(theMesh->myDim){
case 1:
for(int i=1;i<=iMax;i++)
const MED::EEntiteMaillage& aMEntity = anEntityIter->first;
const MED::TGeom2Size& aGeom2Size = anEntityIter->second;
- TEntity aVEntity = MEDEntityToVTK(aMEntity);
- PMEDMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TMEDMeshOnEntity());
+ VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ VISU::PMEDMeshOnEntity aMeshOnEntity =
+ aMeshOnEntityMap[aVEntity](new VISU::TMEDMeshOnEntity());
aMeshOnEntity->myEntity = aVEntity;
aMeshOnEntity->myMeshName = aMeshName;
aMeshOnEntity->myGeom2Size = aGeom2Size;
- TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
+ VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
INITMSG(MYDEBUG,
"- aMEntity = "<<aMEntity<<
aFamilyID2CellsSize[aFamId] += aVNbNodes + 1;
}
}
-
}
-
}
-
-
}
//---------------------------------------------------------------
void
- BuildFieldMap(PMEDMesh theMesh,
+ BuildFieldMap(VISU::PMEDMesh theMesh,
const MED::TEntityInfo& theEntityInfo,
MED::PWrapper theMEDWrapper)
{
- TTimerLog aTimerLog(MYDEBUG,"BuildFieldMap");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildFieldMap");
TInt aNbFields = theMEDWrapper->GetNbFields();
MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
const std::string& aMeshName = theMesh->myName;
INITMSG(MYDEBUG,"BuildFieldMap: aNbFields = "<<aNbFields<<"\n");
for(TInt iField = 1; iField <= aNbFields; iField++){
- TTimerLog aTimerLog(MYDEBUG,"GetPFieldInfo");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"GetPFieldInfo");
MED::PFieldInfo aFieldInfo = theMEDWrapper->GetPFieldInfo(aMeshInfo,iField);
TInt aNbComp = aFieldInfo->GetNbComp();
std::string aFieldName = aFieldInfo->GetName();
if(aNbTimeStamps < 1)
continue;
- TEntity aVEntity = MEDEntityToVTK(aMEntity);
- PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
- TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
- PMEDField aField = aFieldMap[aFieldName](new TMEDField());
+ VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ vtkIdType aDataType = VTK_DOUBLE;
+ if(aFieldInfo->GetType() != MED::eFLOAT64)
+ aDataType = VTK_INT;
+ VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
+ VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+ VISU::PMEDField aField = aFieldMap[aFieldName](new VISU::TMEDField());
aField->myId = iField;
- aField->InitArrays(aNbComp);
+ aField->Init(aNbComp, aDataType);
aField->myEntity = aVEntity;
aField->myName = aFieldName;
aField->myMeshName = aMeshName;
}
for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){
- TTimerLog aTimerLog(MYDEBUG,"GetPTimeStampInfo");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"GetPTimeStampInfo");
MED::PTimeStampInfo aTimeStampInfo = theMEDWrapper->GetPTimeStampInfo(aFieldInfo,
aMEntity,
aGeom2Size,
TFloat aDt = aTimeStampInfo->GetDt();
std::string anUnitDt = aTimeStampInfo->GetUnitDt();
- TValField& aValField = aField->myValField;
- PMEDValForTime aValForTime = aValField[iTimeStamp](new TMEDValForTime());
+ VISU::TValField& aValField = aField->myValField;
+ VISU::PMEDValForTime aValForTime = aValField[iTimeStamp](new VISU::TMEDValForTime());
aValForTime->myId = iTimeStamp;
aValForTime->myFieldName = aField->myName;
aValForTime->myEntity = aField->myEntity;
aValForTime->myTime = VISU::TTime(aDt,anUnitDt);
INITMSG(MYDEBUG,"aDt = '"<<aDt<<", "<<anUnitDt<<"'\n");
- TGeom2NbGauss& aVGeom2NbGauss = aValForTime->myGeom2NbGauss;
+ VISU::TGeom2NbGauss& aVGeom2NbGauss = aValForTime->myGeom2NbGauss;
const MED::TGeom2NbGauss& aMGeom2NbGauss = aTimeStampInfo->myGeom2NbGauss;
MED::TGeom2NbGauss::const_iterator anIter = aMGeom2NbGauss.begin();
for(; anIter != aMGeom2NbGauss.end(); anIter++){
const MED::EGeometrieElement& aMGeom = anIter->first;
- EGeometry aEGeom = MEDGeom2VISU(aMGeom);
+ VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
TInt aNbGauss = anIter->second;
aVGeom2NbGauss[aEGeom] = aNbGauss;
}
//---------------------------------------------------------------
void
- BuildFamilyMap(PMEDMesh theMesh,
+ BuildFamilyMap(VISU::PMEDMesh theMesh,
const MED::TEntityInfo& theEntityInfo,
const MED::TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo,
const MED::TFamilyInfoSet& theFamilyInfoSet,
MED::PWrapper theMEDWrapper)
{
- TTimerLog aTimerLog(MYDEBUG,"BuildFamilyMap");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildFamilyMap");
INITMSG(MYDEBUG,"BuildFamilyMap\n");
MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
const MED::EEntiteMaillage& aMEntity = aEntity2FamilySetIter->first;
const MED::TFamilyTSizeSet& aFamilyTSizeSet = aEntity2FamilySetIter->second;
- TEntity aVEntity = MEDEntityToVTK(aMEntity);
- PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
- const TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
- TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+ VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
+ const VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
+ VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
if(aFamilyTSizeSet.empty())
continue;
std::string aFamilyName = aFamilyInfo->GetName();
- PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily());
+ VISU::PMEDFamily aFamily = aFamilyMap[aFamilyName](new VISU::TMEDFamily());
aFamily->myId = anId;
aFamily->myEntity = aVEntity;
aFamily->myName = aFamilyName;
aFamily->myNbCells = aSize;
aFamily->myCellsSize = 0;
- TFamilyID2CellsSize::const_iterator anIter = aFamilyID2CellsSize.find(anId);
+ VISU::TFamilyID2CellsSize::const_iterator anIter = aFamilyID2CellsSize.find(anId);
if(anIter != aFamilyID2CellsSize.end())
aFamily->myCellsSize = anIter->second;
* Build grille family map
*/
void
- BuildGrilleFamilyMap(PMEDMesh theMesh,
+ BuildGrilleFamilyMap(VISU::PMEDMesh theMesh,
const MED::TEntityInfo& theEntityInfo,
const MED::TFamilyInfoSet& theFamilyInfoSet,
MED::PWrapper theMEDWrapper)
{
- TTimerLog aTimerLog(MYDEBUG,"BuildGrilleFamilyMap");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGrilleFamilyMap");
INITMSG(MYDEBUG,"BuildGrilleFamilyMap\n");
- TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
MED::TEntityInfo::const_iterator aEntityIter = theEntityInfo.begin();
const MED::TFamilyID2NbCells& aFam2NbCells = MED::GetFamilyID2NbCells(aGrilleInfo);
MED::TFamilyInfoSet::const_iterator aFamInter = theFamilyInfoSet.begin();
- for(;aFamInter != theFamilyInfoSet.end();aFamInter++){
- TInt anId = (*aFamInter)->GetId();
+ for(; aFamInter != theFamilyInfoSet.end(); aFamInter++){
+ const MED::PFamilyInfo& aFamilyInfo = *aFamInter;
+ TInt anId = aFamilyInfo->GetId();
if(anId == 0)
continue;
- std::string aFamilyName = (*aFamInter)->GetName();
+ std::string aFamilyName = aFamilyInfo->GetName();
const MED::EEntiteMaillage& aMEntity = MED::GetEntityByFamilyId(aGrilleInfo,
anId);
- TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
- PMEDMeshOnEntity aMeshOnEntity;
- TMeshOnEntityMap::iterator aMeshOnEntityIter = aMeshOnEntityMap.find(aVEntity);
+ VISU::PMEDMeshOnEntity aMeshOnEntity;
+ VISU::TMeshOnEntityMap::iterator aMeshOnEntityIter = aMeshOnEntityMap.find(aVEntity);
if(aMeshOnEntityIter != aMeshOnEntityMap.end())
aMeshOnEntity = aMeshOnEntityIter->second;
- TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+ VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
- PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily());
+ VISU::PMEDFamily aFamily = aFamilyMap[aFamilyName](new VISU::TMEDFamily());
aFamily->myId = anId;
aFamily->myEntity = aVEntity;
aFamily->myName = aFamilyName;
aFamily->myNbCells = 0;
aFamily->myCellsSize = 0;
- TFamilyID2CellsSize::iterator aFamilyid2CellsSizeIter = (aMeshOnEntity->myFamilyID2CellsSize).find(anId);
+ const VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize;
+ VISU::TFamilyID2CellsSize::const_iterator aFamilyid2CellsSizeIter = aFamilyID2CellsSize.find(anId);
if(aFamilyid2CellsSizeIter != (aMeshOnEntity->myFamilyID2CellsSize).end())
aFamily->myCellsSize = aFamilyid2CellsSizeIter->second;
MED::TFamilyID2NbCells::const_iterator aFam2NbCellsIter = aFam2NbCells.find(anId);
INITMSG(MY_FAMILY_DEBUG,
"- aFamilyName =|"<<aFamily->myName<<"|"
<< "; myId = "<<aFamily->myId
- << "; aNbAttr = "<<(*aFamInter)->GetNbAttr()
- << "; aNbGroup = "<<(*aFamInter)->GetNbGroup()
+ << "; aNbAttr = "<<aFamilyInfo->GetNbAttr()
+ << "; aNbGroup = "<<aFamilyInfo->GetNbGroup()
<< "; aVEntity = "<<aVEntity
<< "; myNbCells = "<<aFamily->myNbCells
<< "; myCellsSize = "<<aFamily->myCellsSize
//---------------------------------------------------------------
void
- BuildGroupMap(PMEDMesh theMesh,
+ BuildGroupMap(VISU::PMEDMesh theMesh,
const MED::TFamilyInfoSet& theFamilyInfoSet)
{
- TTimerLog aTimerLog(MYDEBUG,"BuildGroupMap");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGroupMap");
INITMSG(MYDEBUG,"BuildGroupMap\n");
- TGroupMap& aGroupMap = theMesh->myGroupMap;
+ VISU::TGroupMap& aGroupMap = theMesh->myGroupMap;
MED::TGroupInfo aGroupInfo = MED::GetGroupInfo(theFamilyInfoSet);
MED::TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin();
for(; aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){
const std::string& aGroupName = aGroupInfoIter->first;
INITMSG(MY_GROUP_DEBUG,"aGroupName = '"<<aGroupName<<"'\n");
- PMEDGroup aGroup(new TMEDGroup());
- TFamilySet& aFamilySet = aGroup->myFamilySet;
+ VISU::PMEDGroup aGroup(new VISU::TMEDGroup());
+ VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
const MED::TFamilyInfoSet& aFamilyInfoSet = aGroupInfoIter->second;
MED::TFamilyInfoSet::const_iterator aFamilyIter = aFamilyInfoSet.begin();
const MED::PFamilyInfo& aFamilyInfo = *aFamilyIter;
std::string aFamilyName = aFamilyInfo->GetName();
- TEntity aVEntity = TEntity(-1);
- PMEDFamily aFamily;
+ VISU::TEntity aVEntity = VISU::TEntity(-1);
+ VISU::PMEDFamily aFamily;
// Find aVisuEntity
- const TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
- TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin();
+ const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin();
for(; aMeshOnEntityIter != aMeshOnEntityMap.end(); aMeshOnEntityIter++){
- const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second;
- const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
- TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
+ const VISU::PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second;
+ const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+ VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
const std::string& aName = aFamilyMapIter->first;
if(aName == aFamilyName){
}
+ //---------------------------------------------------------------
+ struct TSetIsDone
+ {
+ bool& myIsDone;
+ TSetIsDone(bool& theIsDone):
+ myIsDone(theIsDone)
+ {}
+
+ ~TSetIsDone()
+ {
+ myIsDone = true;
+ }
+
+ };
+
+
+ //---------------------------------------------------------------
+}
+
+namespace VISU
+{
//---------------------------------------------------------------
void
TMEDNamedPointCoords
- ::Init(vtkIdType theNbPoints,
- vtkIdType theDim,
- const MED::PNodeInfo& theNodeInfo)
+ ::Init(const MED::PNodeInfo& theNodeInfo,
+ MED::EVersion theVersion)
{
+ TMEDCoordHolder* aCoordHolder = new TMEDCoordHolder();
+ TInt aNbElem = theNodeInfo->GetNbElem();
+ TInt aDim = theNodeInfo->GetMeshInfo()->GetDim();
+ aCoordHolder->Init(aNbElem, aDim, theNodeInfo->myCoord);
+ TNamedPointCoords::Init(PCoordHolder(aCoordHolder));
+ myVersion = theVersion;
+
+ for(TInt iDim = 0; iDim < aDim; iDim++)
+ myPointsDim[iDim] = theNodeInfo->GetCoordName(iDim);
+
+ myIsElemNum = theNodeInfo->IsElemNum();
if(theNodeInfo->IsElemNum())
- TNamedPointCoords::Init(theNbPoints,theDim,theNodeInfo->myElemNum);
- else
- TNamedPointCoords::Init(theNbPoints,theDim);
+ myElemNum = theNodeInfo->myElemNum;
+
+ myIsElemNames = theNodeInfo->IsElemNames();
if(theNodeInfo->IsElemNames())
- myNodeInfo = theNodeInfo;
+ myElemNames = theNodeInfo->myElemNames;
}
void
TMEDNamedPointCoords
- ::Init(vtkIdType theNbPoints,
- vtkIdType theDim,
- const MED::PGrilleInfo& theInfo)
+ ::Init(const MED::PGrilleInfo& theGrilleInfo)
+ {
+ TMEDCoordHolder* aCoordHolder = new TMEDCoordHolder();
+ TInt aNbElem = theGrilleInfo->GetNbNodes();
+ TInt aDim = theGrilleInfo->GetMeshInfo()->GetDim();
+ MED::PNodeCoord aCoord(new MED::TNodeCoord(aNbElem * aDim));
+ aCoordHolder->Init(aNbElem, aDim, aCoord);
+ TNamedPointCoords::Init(PCoordHolder(aCoordHolder));
+
+ for(TInt iDim = 0; iDim < aDim; iDim++)
+ myPointsDim[iDim] = theGrilleInfo->GetCoordName(iDim);
+
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ VISU::TCoordSlice aVCoordSlice = GetCoordSlice(iElem);
+ MED::TNodeCoord aMCoord = theGrilleInfo->GetCoord(iElem);
+ for(TInt iDim = 0; iDim < aDim; iDim++){
+ aVCoordSlice[iDim] = aMCoord[iDim];
+ }
+ }
+ }
+
+ vtkIdType
+ TMEDNamedPointCoords
+ ::GetObjID(vtkIdType theID) const
+ {
+ if(myIsElemNum)
+ return (*myElemNum)[theID];
+ return TNamedPointCoords::GetObjID(theID);
+ }
+
+
+ vtkIdType
+ TMEDNamedPointCoords
+ ::GetVTKID(vtkIdType theID) const
+ {
+ if(myIsElemNum){
+ // To prepare corresponding mapper engine
+ if(myObj2VTKID.empty()){
+ vtkIdType anEnd = myElemNum->size();
+ for(vtkIdType anID = 0; anID < anEnd; anID++)
+ myObj2VTKID[(*myElemNum)[anID]] = anID;
+ }
+ TObj2VTKID::const_iterator anIter = myObj2VTKID.find(theID);
+ if(anIter != myObj2VTKID.end())
+ return anIter->second;
+ return -1;
+ }
+ return TNamedPointCoords::GetVTKID(theID);
+ }
+
+ MED::TInt
+ GetPNOMLength(MED::EVersion theVersion)
{
- TNamedPointCoords::Init(theNbPoints,theDim);
+ if(theVersion == MED::eV2_1)
+ return MED::GetPNOMLength<MED::eV2_1>();
+ return MED::GetPNOMLength<MED::eV2_2>();
}
std::string
TMEDNamedPointCoords
::GetNodeName(vtkIdType theObjID) const
{
- if(myNodeInfo)
- return myNodeInfo->GetElemName(theObjID);
+ if(myIsElemNames)
+ return GetString(theObjID, GetPNOMLength(myVersion), *myElemNames);
return TNamedPointCoords::GetNodeName(theObjID);
}
+ unsigned long int
+ TMEDNamedPointCoords
+ ::GetMemorySize()
+ {
+ size_t aSize = TNamedPointCoords::GetMemorySize();
+
+ if(myElemNum){
+ aSize += myObj2VTKID.size() * sizeof(vtkIdType) * 2;
+ aSize += myElemNum->size() * sizeof(MED::TInt);
+ }
+
+ if(myIsElemNames)
+ aSize += myElemNames->size() * sizeof(char);
+ return aSize;
+ }
+
//---------------------------------------------------------------
vtkIdType
{
if(mySubMeshID.empty())
if(myIsElemNum)
- return myElemNum[theID];
+ return (*myElemNum)[theID];
else
return theID;
return mySubMeshID[theID];
}
+ unsigned long int
+ TMEDSubProfile
+ ::GetMemorySize()
+ {
+ size_t aSize = TSubProfileImpl::GetMemorySize();
+ if(myIsElemNum)
+ aSize += myElemNum->size() * sizeof(MED::TInt);
+ return aSize;
+ }
+
//---------------------------------------------------------------
void
//---------------------------------------------------------------
TGaussPointID
TMEDGaussSubMesh
- ::GetObjID(vtkIdType theID,
- vtkIdType theStartID) const
+ ::GetObjID(vtkIdType theID) const
{
TCellID aCellID = theID / myGauss->myNbPoints;
TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
if(myIsElemNum)
- aCellID = myElemNum[aCellID];
+ aCellID = (*myElemNum)[aCellID];
else
- aCellID += theStartID;
+ aCellID += myStartID;
- return TGaussPointID(aCellID,aLocalPntID);
+ return TGaussPointID(aCellID, aLocalPntID);
}
+ unsigned long int
+ TMEDGaussSubMesh
+ ::GetMemorySize()
+ {
+ size_t aSize = TGaussSubMeshImpl::GetMemorySize();
+ if(myIsElemNum)
+ aSize += myElemNum->size() * sizeof(MED::TInt);
+ return aSize;
+ }
+
//---------------------------------------------------------------
void
TMEDSubMesh
- ::Init(const MED::PElemInfo& theElemInfo)
+ ::Init(const MED::PElemInfo& theElemInfo,
+ MED::EVersion theVersion)
{
myIsElemNum = theElemInfo->IsElemNum();
-
if(myIsElemNum)
myElemNum = theElemInfo->myElemNum;
+ myIsElemNames = theElemInfo->IsElemNames();
if(theElemInfo->IsElemNames())
- myElemInfo = theElemInfo;
+ myElemNames = theElemInfo->myElemNames;
}
void
TMEDSubMesh
::Init(const MED::PGrilleInfo& theGrilleInfo)
- {
- myIsElemNum = MED::eFAUX;
- // must be implemented
- }
+ {}
vtkIdType
TMEDSubMesh
::GetElemObjID(vtkIdType theID) const
{
if(myIsElemNum)
- return myElemNum[theID];
+ return (*myElemNum)[theID];
else
return TSubMeshImpl::GetElemObjID(theID);
}
TMEDSubMesh
::GetElemName(vtkIdType theObjID) const
{
- if(myElemInfo)
- return myElemInfo->GetElemName(theObjID);
+ if(myIsElemNames)
+ return GetString(theObjID, GetPNOMLength(myVersion), *myElemNames);
return TSubMeshImpl::GetElemName(theObjID);
}
- struct TSetIsDone
+ unsigned long int
+ TMEDSubMesh
+ ::GetMemorySize()
{
- bool& myIsDone;
- TSetIsDone(bool& theIsDone):
- myIsDone(theIsDone)
- {}
+ size_t aSize = TSubMeshImpl::GetMemorySize();
- ~TSetIsDone()
- {
- myIsDone = true;
- }
+ if(myIsElemNum)
+ aSize += myElemNum->size() * sizeof(MED::TInt);
- };
-//}
+ if(myIsElemNames)
+ aSize += myElemNames->size() * sizeof(char);
+
+ return aSize;
+ }
+
+
+ //---------------------------------------------------------------
+}
//---------------------------------------------------------------
return this;
TSetIsDone aSetIsDone(myIsEntitiesDone);
- TTimerLog aTimerLog(MYDEBUG,"BuildEntities");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildEntities");
TInt aNbMeshes = myMed->GetNbMeshes();
- TMeshMap& aMeshMap = myMeshMap;
+ VISU::TMeshMap& aMeshMap = myMeshMap;
INITMSG(MYDEBUG,"BuildEntities aNbMeshes = "<<aNbMeshes<<"\n");
#ifndef _DEXCEPT_
try{
#endif
- TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh);
std::string aMeshName = aMeshInfo->GetName();
MED::EMaillage aType = aMeshInfo->GetType();
// creating TMesh structure and TMeshOnEntityMap
- PMEDMesh aMesh = aMeshMap[aMeshName](new TMEDMesh());
+ VISU::PMEDMesh aMesh = aMeshMap[aMeshName](new VISU::TMEDMesh());
aMesh->myDim = aDim;
aMesh->myName = aMeshName;
aMesh->myMeshInfo = aMeshInfo;
- aMesh->myNamedPointCoords(new TMEDNamedPointCoords());
+ aMesh->myNamedPointCoords(new VISU::TMEDNamedPointCoords());
INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<
"; aDim = "<<aDim<<"\n");
return this;
TSetIsDone aSetIsDone(myIsFieldsDone);
- TTimerLog aTimerLog(MYDEBUG,"BuildFields");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildFields");
TInt aNbMeshes = myMed->GetNbMeshes();
- TMeshMap& aMeshMap = myMeshMap;
+ VISU::TMeshMap& aMeshMap = myMeshMap;
INITMSG(MYDEBUG,"BuildFields - aNbMeshes = "<<aNbMeshes<<"\n");
#ifndef _DEXCEPT_
try{
#endif
- TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh);
std::string aMeshName = aMeshInfo->GetName();
- TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
+ VISU::TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
if(anIter == aMeshMap.end())
continue;
- PMEDMesh aMesh = anIter->second;
+ VISU::PMEDMesh aMesh = anIter->second;
INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
#ifndef _DEXCEPT_
}
+//---------------------------------------------------------------
+template<class TimeStampValueType>
+void
+BuildTimeStampMinMax(MED::SharedPtr<TimeStampValueType> theTimeStampValue,
+ const MED::TGeom2Gauss& theGeom2Gauss,
+ VISU::TMinMaxArr& theMinMaxArr,
+ TInt theNbComp,
+ TInt theNbComp2)
+{
+ const typename TimeStampValueType::TTGeom2Value& aGeom2Value = theTimeStampValue->myGeom2Value;
+ typename TimeStampValueType::TTGeom2Value::const_iterator anIter = aGeom2Value.begin();
+ for(; anIter != aGeom2Value.end(); anIter++){
+ const typename TimeStampValueType::TTMeshValue& aMMeshValue = anIter->second;
+ MED::EGeometrieElement aMGeom = anIter->first;
+
+ TInt aNbElem = aMMeshValue.myNbElem;
+ TInt aNbGauss = aMMeshValue.myNbGauss;
+
+ MED::TGeom2Gauss::const_iterator aGaussIter = theGeom2Gauss.find(aMGeom);
+ if(aGaussIter == theGeom2Gauss.end())
+ aNbGauss = 1;
+
+ INITMSG(MYDEBUG,
+ "- aMGeom = "<<aMGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ endl);
+
+ // To calculate min/max per components
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ typename TimeStampValueType::TTMeshValue::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
+ for(TInt iComp = 0; iComp < theNbComp; iComp++){
+ const typename TimeStampValueType::TTMeshValue::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
+ VISU::TMinMax& aMinMax = theMinMaxArr[iComp+1];
+ vtkFloatingPointType& aMin = aMinMax.first;
+ vtkFloatingPointType& aMax = aMinMax.second;
+ for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+ const vtkFloatingPointType& aVal = aMValueSlice[iGauss];
+ aMin = min(aMin,aVal);
+ aMax = max(aMax,aVal);
+ }
+ }
+ }
+
+ // To calculate min/max per vector modulus
+ VISU::TMinMax& aMinMax = theMinMaxArr[0];
+ vtkFloatingPointType& aMin = aMinMax.first;
+ vtkFloatingPointType& aMax = aMinMax.second;
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ typename TimeStampValueType::TTMeshValue::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
+ for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+ const typename TimeStampValueType::TTMeshValue::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
+ vtkFloatingPointType aValue = 0.0;
+ for(TInt iComp = 0; iComp < theNbComp2; iComp++){
+ vtkFloatingPointType aVal = aMValueSlice[iComp];
+ aValue += aVal*aVal;
+ }
+ aValue = sqrt(aValue);
+ aMin = min(aMin,aValue);
+ aMax = max(aMax,aValue);
+ }
+ }
+ }
+}
+
+
//---------------------------------------------------------------
VISU_Convertor*
VISU_MedConvertor
return this;
TSetIsDone aSetIsDone(myIsMinMaxDone);
- TTimerLog aTimerLog(MYDEBUG,"BuildMinMax");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax");
MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(myMed);
MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(myMed);
TInt aNbMeshes = myMed->GetNbMeshes();
- TMeshMap& aMeshMap = myMeshMap;
+ VISU::TMeshMap& aMeshMap = myMeshMap;
INITMSG(MYDEBUG,"BuildMinMax - aNbMeshes = "<<aNbMeshes<<"\n");
#ifndef _DEXCEPT_
try{
#endif
- TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPMeshInfo");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPMeshInfo");
MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh);
std::string aMeshName = aMeshInfo->GetName();
- TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
+ VISU::TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
if(anIter == aMeshMap.end())
continue;
- PMEDMesh aMesh = anIter->second;
+ VISU::PMEDMesh aMesh = anIter->second;
#ifndef _DEXCEPT_
try{
MED::TEntityInfo anEntityInfo = myMed->GetEntityInfo(aMeshInfo);
for(TInt iField = 1; iField <= aNbFields; iField++){
- TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPFieldInfo()");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPFieldInfo()");
MED::PFieldInfo aFieldInfo = myMed->GetPFieldInfo(aMeshInfo,iField);
std::string aFieldName = aFieldInfo->GetName();
INITMSG(MYDEBUG,"- aFieldName = '"<<aFieldName<<"'\n");
if(aNbTimeStamps < 1)
continue;
- TEntity aVEntity = MEDEntityToVTK(aMEntity);
- PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
- TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
- PMEDField aField = aFieldMap[aFieldName];
+ VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ VISU::PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity];
+ VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+ VISU::PMEDField aField = aFieldMap[aFieldName];
TInt aNbComp = aField->myNbComp;
int aNbComp2 = aNbComp;
else if(aNbComp > 4)
aNbComp2 = 3;
- TMinMaxArr& aMinMaxArr = aField->myMinMaxArr;
+ VISU::TMinMaxArr& aMinMaxArr = aField->myMinMaxArr;
TSetIsDone aSetIsDone(aField->myIsMinMaxInitilized);
for(TInt iTimeStamp = aNbTimeStamps; iTimeStamp >= 1; iTimeStamp--){
- TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPTimeStampInfo()");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPTimeStampInfo()");
INITMSG(MYDEBUG,"- iTimeStamp = "<<iTimeStamp<<endl);
#ifndef _DEXCEPT_
try{
OCC_CATCH_SIGNALS;
#else
- CASCatch_TRY{
- try{
+ CASCatch_TRY{
+ try{
#endif
#endif
- MED::PTimeStampInfo aTimeStampInfo = myMed->GetPTimeStampInfo(aFieldInfo,
- aMEntity,
- aGeom2Size,
- iTimeStamp);
-
- MED::PTimeStampVal aTimeStampVal = myMed->GetPTimeStampVal(aTimeStampInfo,
- aMKey2Profile,
- aKey2Gauss);
-
- const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss();
-
- const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal;
-
- const MED::TGeom2Value& aGeom2Value = aTimeStampValRef.myGeom2Value;
- MED::TGeom2Value::const_iterator anIter = aGeom2Value.begin();
- for(; anIter != aGeom2Value.end(); anIter++){
- const MED::TMeshValue& aMMeshValue = anIter->second;
- MED::EGeometrieElement aMGeom = anIter->first;
-
- TInt aNbElem = aMMeshValue.myNbElem;
- TInt aNbGauss = aMMeshValue.myNbGauss;
+ MED::PTimeStampInfo aTimeStampInfo =
+ myMed->GetPTimeStampInfo(aFieldInfo,
+ aMEntity,
+ aGeom2Size,
+ iTimeStamp);
- MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
- if(aGaussIter == aGeom2Gauss.end())
- aNbGauss = 1;
-
- INITMSG(MYDEBUG,
- "- aMGeom = "<<aMGeom<<
- "; aNbElem = "<<aNbElem<<
- "; aNbGauss = "<<aNbGauss<<
- endl);
-
- // To calculate min/max per components
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
- for(TInt iComp = 0; iComp < aNbComp; iComp++){
- const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
- TMinMax& aMinMax = aMinMaxArr[iComp+1];
- vtkFloatingPointType& aMin = aMinMax.first;
- vtkFloatingPointType& aMax = aMinMax.second;
- for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
- const vtkFloatingPointType& aVal = aMValueSlice[iGauss];
- aMin = min(aMin,aVal);
- aMax = max(aMax,aVal);
- }
- }
- }
+ MED::PTimeStampValueBase aTimeStampValue =
+ myMed->GetPTimeStampValue(aTimeStampInfo,
+ aMKey2Profile,
+ aKey2Gauss);
+
+ const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo->GetGeom2Gauss();
+
+ if(aFieldInfo->GetType() == MED::eFLOAT64)
+ BuildTimeStampMinMax<MED::TFloatTimeStampValue>(aTimeStampValue,
+ aGeom2Gauss,
+ aMinMaxArr,
+ aNbComp,
+ aNbComp2);
+ else
+ BuildTimeStampMinMax<MED::TIntTimeStampValue>(aTimeStampValue,
+ aGeom2Gauss,
+ aMinMaxArr,
+ aNbComp,
+ aNbComp2);
- // To calculate min/max per vector modulus
- TMinMax& aMinMax = aMinMaxArr[0];
- vtkFloatingPointType& aMin = aMinMax.first;
- vtkFloatingPointType& aMax = aMinMax.second;
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
- for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
- const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
- vtkFloatingPointType aValue = 0.0;
- for(TInt iComp = 0; iComp < aNbComp2; iComp++){
- vtkFloatingPointType aVal = aMValueSlice[iComp];
- aValue += aVal*aVal;
- }
- aValue = sqrt(aValue);
- aMin = min(aMin,aValue);
- aMax = max(aMax,aValue);
- }
- }
- }
#ifndef _DEXCEPT_
#ifdef NO_CAS_CATCH
- }catch(Standard_Failure){
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- MSG(MYDEBUG,"Follow signal was occured in:\n"<<aFail->GetMessageString());
- }catch(std::exception& exc){
- MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
- }catch(...){
- MSG(MYDEBUG,"Unknown exception !!!");
- }
+ }catch(Standard_Failure){
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ MSG(MYDEBUG,"Follow signal was occured in:\n"<<aFail->GetMessageString());
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
+ }catch(...){
+ MSG(MYDEBUG,"Unknown exception !!!");
+ }
#else
}catch(std::exception& exc){
MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
return this;
TSetIsDone aSetIsDone(myIsGroupsDone);
- TTimerLog aTimerLog(MYDEBUG,"BuildGroups");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGroups");
TInt aNbMeshes = myMed->GetNbMeshes();
- TMeshMap& aMeshMap = myMeshMap;
+ VISU::TMeshMap& aMeshMap = myMeshMap;
INITMSG(MYDEBUG,"BuildGroups - aNbMeshes = "<<aNbMeshes<<"\n");
#ifndef _DEXCEPT_
try{
#endif
- TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"GetPMeshInfo");
MED::PMeshInfo aMeshInfo = myMed->GetPMeshInfo(iMesh);
std::string aMeshName = aMeshInfo->GetName();
- TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
+ VISU::TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName);
if(anIter == aMeshMap.end())
continue;
- PMEDMesh aMesh = anIter->second;
+ VISU::PMEDMesh aMesh = anIter->second;
INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<"'\n");
MED::TEntityInfo anEntityInfo = myMed->GetEntityInfo(aMeshInfo);
MED::TEntity2TGeom2ElemInfo anEntity2TGeom2ElemInfo =
- MED::GetEntity2TGeom2ElemInfo(myMed,aMeshInfo,anEntityInfo);
+ MED::GetEntity2TGeom2ElemInfo(myMed, aMeshInfo, anEntityInfo);
#ifndef _DEXCEPT_
try{
#endif
- MED::TFamilyInfoSet aFamilyInfoSet = MED::GetFamilyInfoSet(myMed,aMeshInfo);
+ MED::TFamilyInfoSet aFamilyInfoSet = MED::GetFamilyInfoSet(myMed, aMeshInfo);
if(aType == MED::eNON_STRUCTURE)
BuildFamilyMap(aMesh,
::LoadMeshOnEntity(VISU::PMeshImpl theMesh,
VISU::PMeshOnEntityImpl theMeshOnEntity)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnEntity");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnEntity");
INITMSG(MYDEBUG,"LoadMeshOnEntity"<<endl);
- const TEntity& anEntity = theMeshOnEntity->myEntity;
+ const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
if(anEntity == VISU::NODE_ENTITY){
- isPointsUpdated += LoadPoints(myMed,theMesh);
+ isPointsUpdated += LoadPoints(myMed, theMesh);
}else{
- isPointsUpdated += LoadPoints(myMed,theMesh);
- isCellsOnEntityUpdated += LoadCellsOnEntity(myMed,theMesh,theMeshOnEntity);
+ isPointsUpdated += LoadPoints(myMed, theMesh);
+ isCellsOnEntityUpdated += LoadCellsOnEntity(myMed, theMesh, theMeshOnEntity);
}
return (isPointsUpdated || isCellsOnEntityUpdated);
VISU::PMeshOnEntityImpl theMeshOnEntity,
VISU::PFamilyImpl theFamily)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadFamilyOnEntity");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadFamilyOnEntity");
INITMSG(MYDEBUG,"LoadFamilyOnEntity"<<endl);
- const TEntity& anEntity = theMeshOnEntity->myEntity;
+ const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
if(anEntity == VISU::NODE_ENTITY){
- isPointsUpdated += LoadPointsOnFamily(myMed,theMesh,theFamily);
+ isPointsUpdated += LoadPointsOnFamily(myMed, theMesh, theFamily);
}else{
- isPointsUpdated += LoadPoints(myMed,theMesh);
- isCellsOnEntityUpdated += LoadCellsOnFamily(myMed,theMesh,theMeshOnEntity,theFamily);
+ isPointsUpdated += LoadPoints(myMed, theMesh);
+ isCellsOnEntityUpdated += LoadCellsOnFamily(myMed, theMesh, theMeshOnEntity, theFamily);
}
return (isPointsUpdated || isCellsOnEntityUpdated);
::LoadMeshOnGroup(VISU::PMeshImpl theMesh,
const VISU::TFamilySet& theFamilySet)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnGroup");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnGroup");
INITMSG(MYDEBUG,"LoadMeshOnGroup"<<endl);
int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
- TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
+ VISU::TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
for(; aFamilyIter != theFamilySet.end(); aFamilyIter++){
- PMEDFamily aFamily = *aFamilyIter;
- const TEntity& anEntity = aFamily->myEntity;
- const PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
- isPointsUpdated += LoadPoints(myMed,theMesh);
+ VISU::PMEDFamily aFamily = *aFamilyIter;
+ const VISU::TEntity& anEntity = aFamily->myEntity;
+ const VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
+ isPointsUpdated += LoadPoints(myMed, theMesh);
if(anEntity == VISU::NODE_ENTITY){
- isPointsUpdated += LoadPointsOnFamily(myMed,theMesh,aFamily);
+ isPointsUpdated += LoadPointsOnFamily(myMed, theMesh, aFamily);
}else{
isCellsOnEntityUpdated += LoadCellsOnFamily(myMed,theMesh,aMeshOnEntity,aFamily);
}
VISU::PFieldImpl theField,
VISU::PValForTimeImpl theValForTime)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnMesh");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnMesh");
INITMSG(MYDEBUG,"LoadValForTimeOnMesh"<<endl);
- const TEntity& anEntity = theMeshOnEntity->myEntity;
+ const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
isPointsUpdated += LoadPoints(myMed,theMesh);
if(anEntity != VISU::NODE_ENTITY)
VISU::PFieldImpl theField,
VISU::PValForTimeImpl theValForTime)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnGaussPts");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnGaussPts");
INITMSG(MYDEBUG,"LoadValForTimeOnGaussPts"<<endl);
- const TEntity& anEntity = theMeshOnEntity->myEntity;
+ const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
if(anEntity != VISU::NODE_ENTITY)
isCellsOnEntityUpdated += LoadCellsOnEntity(myMed,theMesh,theMeshOnEntity);
::LoadPoints(const MED::PWrapper& theMed,
VISU::PMEDMesh theMesh)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadPoints");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadPoints");
try{
//Check on existing family
- PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
+ VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
aMeshOnEntity->myMeshName = theMesh->myName;
aMeshOnEntity->myEntity = VISU::NODE_ENTITY;
//Main part of code
MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo);
TInt aNbElem = aNodeInfo->GetNbElem();
- TInt aDim = theMesh->myDim;
-
- PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
- TMEDNamedPointCoords& aCoords = aNamedPointCoords;
- aCoords.Init(aNbElem,aDim,aNodeInfo);
- for(int iDim = 0; iDim < aDim; iDim++)
- aCoords.GetName(iDim) = aNodeInfo->GetCoordName(iDim);
+ VISU::PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
+ aNamedPointCoords->Init(aNodeInfo, theMed->GetVersion());
- for(int iElem = 0; iElem < aNbElem; iElem++){
- TCoordSlice aVCoordSlice = aCoords.GetCoordSlice(iElem);
- MED::TCCoordSlice aMCoordSlice = aNodeInfo->GetCoordSlice(iElem);
- for(int iDim = 0; iDim < aDim; iDim++)
- aVCoordSlice[iDim] = aMCoordSlice[iDim];
- }
-
- TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
- PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new TMEDSubMesh());
+ VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
+ VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new VISU::TMEDSubMesh());
- aSubMesh->Init(MED::PElemInfo(aNodeInfo));
+ aSubMesh->Init(MED::PElemInfo(aNodeInfo), theMed->GetVersion());
aSubMesh->myNbCells = theMesh->myNbPoints;
aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
- TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
aCell2Connect.resize(aNbElem);
for (int iElem = 0; iElem < aNbElem; iElem++)
aCell2Connect[iElem] = VISU::TConnect(1,iElem);
//Main part of code
MED::PGrilleInfo aGrilleInfo = theMed->GetPGrilleInfo(theMesh->myMeshInfo);
TInt aNbElem = aGrilleInfo->GetNbNodes();
- TInt aDim = theMesh->myDim;
-
- PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
- TMEDNamedPointCoords& aCoords = aNamedPointCoords;
- aCoords.Init(aNbElem,aDim,aGrilleInfo);
- for(int iDim = 0; iDim < aDim; iDim++)
- aCoords.GetName(iDim) = aGrilleInfo->GetCoordName(iDim);
-
- for(int iElem = 0; iElem < aNbElem; iElem++){
- TCoordSlice aVCoordSlice = aCoords.GetCoordSlice(iElem);
- MED::TNodeCoord aMCoord = aGrilleInfo->GetCoord(iElem);
- for(int iDim = 0; iDim < aDim; iDim++){
- aVCoordSlice[iDim] = aMCoord[iDim];
- }
- }
+ VISU::PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
+ aNamedPointCoords->Init(aGrilleInfo);
- TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
- PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new TMEDSubMesh());
+ VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
+ VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new VISU::TMEDSubMesh());
aSubMesh->Init(aGrilleInfo);
aSubMesh->myNbCells = theMesh->myNbPoints;
aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
- TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
aCell2Connect.resize(aNbElem);
- for (int iElem = 0; iElem < aNbElem; iElem++)
+ for(int iElem = 0; iElem < aNbElem; iElem++)
aCell2Connect[iElem] = VISU::TConnect(1,iElem);
}
const VISU::PMEDMesh theMesh,
const VISU::PMEDFamily theFamily)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadPointsOnFamily");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadPointsOnFamily");
try{
if(theFamily->myIsDone)
return 0;
MED::EMaillage aType = aMeshInfo->GetType();
//Main part of code
- if(aType==MED::eNON_STRUCTURE){
+ if(aType == MED::eNON_STRUCTURE){
MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo);
TInt aNbElem = aNodeInfo->GetNbElem();
if(aNbElem > 0){
TInt anId = theFamily->myId;
- TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
+ VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
for(TInt iElem = 0; iElem < aNbElem; iElem++)
if(aNodeInfo->GetFamNum(iElem) == anId)
aSubMeshID.push_back(iElem);
if(aNbElem > 0){
TInt anId = theFamily->myId;
- TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
+ VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
for(TInt iElem = 0; iElem < aNbElem; iElem++)
if(aGrilleInfo->GetFamNumNode(iElem) == anId)
aSubMeshID.push_back(iElem);
const VISU::PMEDMesh theMesh,
const VISU::PMEDMeshOnEntity theMeshOnEntity)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnEntity");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnEntity");
#ifndef _DEXCEPT_
try{
#endif
- const TEntity& aVEntity = theMeshOnEntity->myEntity;
+ const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity);
INITMSG(MYDEBUG,"LoadCellsOnEntity - aVEntity = "<<aVEntity<<"\n");
const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
- TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
+ VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
TInt aNbElem = aGeom2SizeIter->second;//aGrilleInfo->GetNbCells();
if(aNbElem > 0){
- PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
+ VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh());
aSubMesh->Init(aGrilleInfo);
aSubMesh->myNbCells = aNbElem;
aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
- TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
aCell2Connect.resize(aNbElem);
TInt aMNbNodes = MEDGeom2NbNodes(aMGeom);
- TVector<TInt> aConnect(aMNbNodes);
+ VISU::TVector<TInt> aConnect(aMNbNodes);
for(TInt iElem = 0; iElem < aNbElem; iElem++) {
MED::TIntVector aConn = aGrilleInfo->GetConn(iElem);
- TConnect& anArray = aCell2Connect[iElem];
+ VISU::TConnect& anArray = aCell2Connect[iElem];
anArray.resize(aVNbNodes);
if(anIsNodeNum){
const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
- TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
+ VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
MED::PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
TInt aNbElem = aPolygoneInfo->GetNbElem();
if(aNbElem > 0){
- PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
+ VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh());
- aSubMesh->Init(MED::PElemInfo(aPolygoneInfo));
+ aSubMesh->Init(MED::PElemInfo(aPolygoneInfo),theMed->GetVersion());
aSubMesh->myNbCells = aNbElem;
- TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
aCell2Connect.resize(aNbElem);
for(TInt iElem = 0; iElem < aNbElem; iElem++) {
MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem);
TInt aNbConn = aPolygoneInfo->GetNbConn(iElem);
aSubMesh->myCellsSize += aNbConn;
- TConnect& anArray = aCell2Connect[iElem];
+ VISU::TConnect& anArray = aCell2Connect[iElem];
anArray.resize(aNbConn);
for(TInt iConn = 0; iConn < aNbConn; iConn++)
anArray[iConn] = aConnSlice[iConn] - 1;
TInt aNbElem = aPolyedreInfo->GetNbElem();
if(aNbElem > 0){
- PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
+ VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh());
- aSubMesh->Init((MED::PElemInfo)aPolyedreInfo);
+ aSubMesh->Init(MED::PElemInfo(aPolyedreInfo),theMed->GetVersion());
aSubMesh->myNbCells = aNbElem;
- TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
aCell2Connect.resize(aNbElem);
for(TInt iElem = 0; iElem < aNbElem; iElem++){
MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(iElem);
- TConnect& anArray = aCell2Connect[iElem];
+ VISU::TConnect& anArray = aCell2Connect[iElem];
typedef std::set<TInt> TConnectSet;
TConnectSet aConnectSet;
TInt aNbFaces = aConnSliceArr.size();
TInt aNbElem = aCellInfo->GetNbElem();
if(aNbElem > 0){
- PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh());
+ VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh());
- aSubMesh->Init((MED::PElemInfo)aCellInfo);
+ aSubMesh->Init(MED::PElemInfo(aCellInfo), theMed->GetVersion());
aSubMesh->myNbCells = aNbElem;
aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
- TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
aCell2Connect.resize(aNbElem);
TInt aMNbNodes = MEDGeom2NbNodes(aMGeom);
- TVector<TInt> aConnect(aMNbNodes);
+ VISU::TVector<TInt> aConnect(aMNbNodes);
for(TInt iElem = 0; iElem < aNbElem; iElem++) {
MED::TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem);
- TConnect& anArray = aCell2Connect[iElem];
+ VISU::TConnect& anArray = aCell2Connect[iElem];
anArray.resize(aVNbNodes);
if(anIsNodeNum){
const VISU::PMEDMeshOnEntity theMeshOnEntity,
const VISU::PMEDFamily theFamily)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnFamily");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnFamily");
#ifndef _DEXCEPT_
try{
#endif
- const TEntity& aVEntity = theMeshOnEntity->myEntity;
+ const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity);
INITMSG(MYDEBUG,"LoadCellsOnFamily - aVEntity = "<<aVEntity<<"\n");
TInt anId = theFamily->myId;
const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
- TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
+ VISU::TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
MED::EMaillage aType = aMeshInfo->GetType();
const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
}}
if(anElemInfo){
if(TInt aNbElem = anElemInfo->GetNbElem()){
- TSubMeshID aSubMeshID;
+ VISU::TSubMeshID aSubMeshID;
for(TInt iElem = 0; iElem < aNbElem; iElem++)
if(anElemInfo->GetFamNum(iElem) == anId)
aSubMeshID.push_back(iElem);
if(!aSubMeshID.empty()){
VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"\n");
- aGeom2SubMeshID.insert(TGeom2SubMeshID::value_type(aEGeom,aSubMeshID));
+ aGeom2SubMeshID.insert(VISU::TGeom2SubMeshID::value_type(aEGeom,aSubMeshID));
}
}
}
if(anElemInfo){
TInt aNbElem = anElemInfo->GetNbCells();
if(aNbElem>0 && (aMGeom == anElemInfo->GetGeom()) ){
- TSubMeshID aSubMeshID;
+ VISU::TSubMeshID aSubMeshID;
for(TInt iElem = 0; iElem < aNbElem; iElem++)
if(anElemInfo->GetFamNum(iElem) == anId)
aSubMeshID.push_back(iElem);
if(!aSubMeshID.empty()){
VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"\n");
- aGeom2SubMeshID.insert(TGeom2SubMeshID::value_type(aEGeom,aSubMeshID));
+ aGeom2SubMeshID.insert(VISU::TGeom2SubMeshID::value_type(aEGeom,aSubMeshID));
}
}
}
void
LoadProfile(const MED::PWrapper& theMed,
VISU::PMEDMesh theMesh,
- MED::TTimeStampVal& theTimeStampVal,
+ MED::PTimeStampValueBase theTimeStampValue,
VISU::TMEDValForTime& theValForTime,
VISU::TMEDMeshOnEntity& theMeshOnEntity)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadProfile");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadProfile");
INITMSG(MYDEBUG,"LoadProfile"<<endl);
- PMEDProfile aProfile = theValForTime.myProfile;
+ VISU::PMEDProfile aProfile = theValForTime.myProfile;
if(aProfile->myIsDone)
return;
- const TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
- const MED::TGeom2Profile& aGeom2Profile = theTimeStampVal.GetGeom2Profile();
+ const VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+ const MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->GetGeom2Profile();
MED::TGeom2Profile::const_iterator anIter = aGeom2Profile.begin();
for(; anIter != aGeom2Profile.end(); anIter++){
MED::PProfileInfo aProfileInfo = anIter->second;
MED::EGeometrieElement aMGeom = anIter->first;
VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
- TGeom2SubProfile::const_iterator anIter2 = aGeom2SubProfile.find(aEGeom);
+ VISU::TGeom2SubProfile::const_iterator anIter2 = aGeom2SubProfile.find(aEGeom);
if(anIter2 != aGeom2SubProfile.end()){
- PMEDSubProfile aSubProfile = anIter2->second;
+ VISU::PMEDSubProfile aSubProfile = anIter2->second;
MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
if(!anElemNum.empty()){
- TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
+ VISU::TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
TInt aSize = anElemNum.size();
aSubMeshID.resize(aSize);
for(TInt anId = 0; anId < aSize; anId++)
{
const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
- TEntity aVEntity = theMeshOnEntity.myEntity;
+ VISU::TEntity aVEntity = theMeshOnEntity.myEntity;
MED::EEntiteMaillage aMEntity = VTKEntityToMED(aVEntity);
- const TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
- TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
+ const VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+ VISU::TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
for(; anIter != aGeom2SubProfile.end(); anIter++){
- const PMEDSubProfile& aSubProfile = anIter->second;
+ const VISU::PMEDSubProfile& aSubProfile = anIter->second;
MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
MED::PElemInfo anElemInfo;
anElemInfo = theMed->GetPElemInfo(aMeshInfo,aMEntity,aMGeom);
void
LoadGaussMesh(const MED::PWrapper& theMed,
VISU::PMEDMesh theMesh,
- MED::TTimeStampVal& theTimeStampVal,
+ MED::PTimeStampValueBase theTimeStampValue,
VISU::TMEDValForTime& theValForTime,
VISU::TMEDMeshOnEntity& theMeshOnEntity)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadGaussMesh");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadGaussMesh");
INITMSG(MYDEBUG,"LoadGaussMesh"<<endl);
// this part of code must be reimplemented in connection with GRILLE structures
if(theMesh->myMeshInfo->GetType() == MED::eSTRUCTURE)
- EXCEPTION(runtime_error,"LoadGaussMesh - Gauss Points localization error!!!");
+ EXCEPTION(std::runtime_error,"LoadGaussMesh - Gauss Points localization error!!!");
- PMEDGaussMesh aGaussMesh = theValForTime.myGaussMesh;
+ VISU::PMEDGaussMesh aGaussMesh = theValForTime.myGaussMesh;
if(!aGaussMesh || aGaussMesh->myIsDone)
return;
const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo);
- TEntity aVEntity = theMeshOnEntity.myEntity;
+ VISU::TEntity aVEntity = theMeshOnEntity.myEntity;
MED::EEntiteMaillage aMEntity = VTKEntityToMED(aVEntity);
- const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
- const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampVal.GetTimeStampInfo();
+ const VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
+ const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampValue->GetTimeStampInfo();
const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss();
- TGeom2GaussSubMesh::const_iterator aSubMeshIter = aGeom2GaussSubMesh.begin();
+ VISU::TGeom2GaussSubMesh::const_iterator aSubMeshIter = aGeom2GaussSubMesh.begin();
for(; aSubMeshIter != aGeom2GaussSubMesh.end(); aSubMeshIter++){
- PMEDGaussSubMesh aGaussSubMesh = aSubMeshIter->second;
+ VISU::PMEDGaussSubMesh aGaussSubMesh = aSubMeshIter->second;
VISU::EGeometry aEGeom = aSubMeshIter->first;
if(aGaussSubMesh->myIsDone)
continue;
- PMEDSubProfile aSubProfile = aGaussSubMesh->mySubProfile;
- const TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
+ VISU::PMEDSubProfile aSubProfile = aGaussSubMesh->mySubProfile;
+ const VISU::TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
MED::PPolygoneInfo aPolygoneInfo;
aGaussSubMesh->myElemNum = anElemInfo->myElemNum;
std::string aName;
- MED::TGaussCoord aGaussCoord;
bool anIsGaussCoord3D = false;
+ MED::PGaussCoord aGaussCoordPtr(new MED::TGaussCoord());
+ MED::TGaussCoord& aGaussCoord = *aGaussCoordPtr;
MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
if(aGaussIter != aGeom2Gauss.end()){
- PMEDGauss aGauss = aGaussSubMesh->myGauss;
+ VISU::PMEDGauss aGauss = aGaussSubMesh->myGauss;
MED::PGaussInfo aGaussInfo = aGauss->myGaussInfo;
if(aGaussInfo){
aName = aGaussInfo->GetName();
}
if(anIsGaussCoord3D){
- TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
- TInt aNbGauss = aGaussCoord.GetNbGauss();
- TInt aNbElem = aGaussCoord.GetNbElem();
- TInt aDim = aGaussCoord.GetDim();
- vtkIdType aNbCells = aNbElem*aNbGauss;
- aCoords.Init(aNbCells,aDim);
- for(TInt anElemId = 0, aNodeId = 0; anElemId < aNbElem; anElemId++){
- MED::TCoordSliceArr aCoordSliceArr = aGaussCoord.GetCoordSliceArr(anElemId);
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++, aNodeId++){
- MED::TCoordSlice aCoordSlice = aCoordSliceArr[aGaussId];
- TCoordSlice aSlice = aCoords.GetCoordSlice(aNodeId);
- for(TInt aDimId = 0; aDimId < aDim; aDimId++)
- aSlice[aDimId] = aCoordSlice[aDimId];
- }
- }
+ VISU::TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
+ VISU::TMEDGaussCoordHolder* aCoordHolder = new VISU::TMEDGaussCoordHolder();
+ aCoordHolder->Init(aGaussCoordPtr);
+ aCoords.Init(VISU::PCoordHolder(aCoordHolder));
- aGaussSubMesh->myIsDone = true;;
+ aGaussSubMesh->myIsDone = true;
+ TInt aNbGauss = aGaussCoord.GetNbGauss();
+ TInt aNbElem = aGaussCoord.GetNbElem();
+ TInt aNbCells = aNbElem*aNbGauss;
+
INITMSG(MYDEBUG,
"- aEGeom = "<<aEGeom<<
"; aName = '"<<aName<<"'"<<
"; aNbCells = "<<aNbCells<<
endl);
}else
- EXCEPTION(runtime_error,"LoadGaussMesh - Gauss Points localization error!!!");
+ EXCEPTION(std::runtime_error,"LoadGaussMesh - Gauss Points localization error!!!");
}
aGaussMesh->myIsDone = true;
}
+//---------------------------------------------------------------
+template<class TimeStampValueType>
+void
+FillValForTime(MED::SharedPtr<TimeStampValueType> theTimeStampValue,
+ const VISU::TGeom2SubProfile& theGeom2SubProfile,
+ VISU::PMEDValForTime theValForTime,
+ VISU::PMEDField theField)
+{
+ theField->myDataSize = 0;
+ TInt aNbComp = theField->myNbComp;
+
+ VISU::TGeom2SubProfile::const_iterator anIter = theGeom2SubProfile.begin();
+ for(; anIter != theGeom2SubProfile.end(); anIter++){
+ VISU::EGeometry aEGeom = anIter->first;
+ VISU::PMEDSubProfile aSubProfile(anIter->second);
+
+ TInt aNbElem = aSubProfile->myNbCells;
+ theField->myDataSize += aNbElem * aNbComp;
+
+ if(aSubProfile->myStatus != VISU::eRemoveAll){
+ TInt aNbGauss = theValForTime->GetNbGauss(aEGeom);
+
+ INITMSG(MYDEBUG,
+ "- aEGeom = "<<aEGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ endl);
+
+ VISU::PMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
+ typedef typename TimeStampValueType::TElement TElement;
+ typedef VISU::TTMEDMeshValue<TElement> TVMeshValue;
+ TVMeshValue* aMeshValue = new TVMeshValue();
+
+ MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
+ typedef typename TimeStampValueType::PTMeshValue PTMeshValue;
+ PTMeshValue aMeshValuePtr = theTimeStampValue->GetMeshValuePtr(aMGeom);
+ aMeshValue->Init(aNbElem, aNbGauss, aNbComp, aMeshValuePtr);
+ aVMeshValue.reset(aMeshValue);
+ }
+ }
+}
+
//---------------------------------------------------------------
int
LoadValForTime(const MED::PWrapper& theMed,
bool theIsGauss,
bool& theIsDone)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadValForTime");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadValForTime");
INITMSG(MYDEBUG,"LoadValForTime - theIsGauss = "<<theIsGauss<<endl);
//Check on loading already done
MED::TKey2Gauss aKey2Gauss = GetKey2Gauss(theMed);
MED::TMKey2Profile aMKey2Profile = GetMKey2Profile(theMed);
- MED::PTimeStampVal aTimeStampVal =
- theMed->GetPTimeStampVal(aTimeStampInfo,
- aMKey2Profile,
- aKey2Gauss);
-
+ MED::PTimeStampValueBase aTimeStampValue =
+ theMed->GetPTimeStampValue(aTimeStampInfo,
+ aMKey2Profile,
+ aKey2Gauss);
+
InitGaussProfile(theMed,
aMeshInfo,
- aTimeStampVal,
+ aTimeStampValue,
theMeshOnEntity,
aMEntity,
aGeom2Size,
LoadProfile(theMed,
theMesh,
- aTimeStampVal,
+ aTimeStampValue,
theValForTime,
theMeshOnEntity);
if(theIsGauss)
LoadGaussMesh(theMed,
theMesh,
- aTimeStampVal,
+ aTimeStampValue,
theValForTime,
theMeshOnEntity);
- PMEDProfile aProfile = theValForTime->myProfile;
- TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
-
- TInt aNbComp = theField->myNbComp;
+ VISU::PMEDProfile aProfile = theValForTime->myProfile;
+ VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
INITMSGA(MYDEBUG,0,
"- aMeshName = '"<<aMeshName<<"'"<<
"; aFieldName = '"<<aFieldInfo->GetName()<<"'"<<
"; aMEntity = "<<aMEntity<<
- "; aNbComp = "<<aNbComp<<
+ "; aNbComp = "<<theField->myNbComp<<
endl);
- theField->myDataSize = 0;
-
- const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal;
- TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
- for(; anIter != aGeom2SubProfile.end(); anIter++){
- VISU::EGeometry aEGeom = anIter->first;
- PMEDSubProfile aSubProfile(anIter->second);
-
- TInt aNbElem = aSubProfile->myNbCells;
- theField->myDataSize += aNbElem*aNbComp;
-
- if(aSubProfile->myStatus != eRemoveAll){
- TInt aNbGauss = theValForTime->GetNbGauss(aEGeom);
-
- INITMSG(MYDEBUG,
- "- aEGeom = "<<aEGeom<<
- "; aNbElem = "<<aNbElem<<
- "; aNbGauss = "<<aNbGauss<<
- endl);
-
- TMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
- aVMeshValue.Init(aNbElem,aNbGauss,aNbComp);
-
- MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
- const MED::TMeshValue& aMMeshValue = aTimeStampValRef.GetMeshValue(aMGeom);
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- TValueSliceArr aVValueSliceArr = aVMeshValue.GetGaussValueSliceArr(iElem);
- MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
- ADDMSG(MYVALUEDEBUG,"{");
- for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
- TValueSlice& aVValueSlice = aVValueSliceArr[iGauss];
- const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
- for(TInt iComp = 0; iComp < aNbComp; iComp++){
- aVValueSlice[iComp] = aMValueSlice[iComp];
- ADDMSG(MYVALUEDEBUG,aVValueSlice[iComp]<<" ");
- }
- ADDMSG(MYVALUEDEBUG,"| ");
- }
- ADDMSG(MYVALUEDEBUG,"} ");
- }
- ADDMSG(MYDEBUG,"\n");
- }
- }
-
+ if(aFieldInfo->GetType() == MED::eFLOAT64)
+ FillValForTime<MED::TFloatTimeStampValue>(aTimeStampValue,
+ aGeom2SubProfile,
+ theValForTime,
+ theField);
+ else
+ FillValForTime<MED::TIntTimeStampValue>(aTimeStampValue,
+ aGeom2SubProfile,
+ theValForTime,
+ theField);
theIsDone = true;
return 1;
VISU::PMEDField theField,
VISU::PMEDValForTime theValForTime)
{
- PIDMapperFilter anIDMapperFilter = theValForTime->myIDMapperFilter;
+ VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = theValForTime->myUnstructuredGridIDMapper;
return LoadValForTime(theMed,
theMesh,
theMeshOnEntity,
theField,
theValForTime,
false,
- anIDMapperFilter->myIsVTKDone);
+ anUnstructuredGridIDMapper->myIsVTKDone);
}
VISU::PMEDField theField,
VISU::PMEDValForTime theValForTime)
{
- PGaussPtsIDFilter aGaussPtsIDFilter = theValForTime->myGaussPtsIDFilter;
+ VISU::PGaussPtsIDFilter aGaussPtsIDFilter = theValForTime->myGaussPtsIDFilter;
return LoadValForTime(theMed,
theMesh,
theMeshOnEntity,
#define VISU_MedConvertor_HeaderFile
#include "VISU_Convertor_impl.hxx"
+#include "VISU_Structures_impl.hxx"
+#include "VISU_PointCoords.hxx"
+#include "VISU_MeshValue.hxx"
#include "MED_Wrapper.hxx"
#include "MED_Common.hxx"
#include "MED_Structures.hxx"
+#include "MED_GaussUtils.hxx"
#include <boost/thread/mutex.hpp>
#include <qfileinfo.h>
namespace VISU
{
- typedef TVector<TName> TNames;
+ //---------------------------------------------------------------
+ struct TMEDCoordHolder: TCoordHolder<MED::PNodeCoord>
+ {
+ virtual
+ const TCoord*
+ GetPointer() const
+ {
+ return &(*myCoord)[0];
+ }
+
+ virtual
+ TCoord*
+ GetPointer()
+ {
+ return &(*myCoord)[0];
+ }
+ };
+
+
+ //---------------------------------------------------------------
+ struct TMEDGaussCoordHolder: TCoordHolderBase
+ {
+ MED::PGaussCoord myGaussCoord;
+
+ //! To initilize the instance
+ void
+ Init(const MED::PGaussCoord& theGaussCoord)
+ {
+ MED::TInt aNbGauss = theGaussCoord->GetNbGauss();
+ MED::TInt aNbElem = theGaussCoord->GetNbElem();
+ MED::TInt aDim = theGaussCoord->GetDim();
+ MED::TInt aNbCells = aNbElem * aNbGauss;
+ TCoordHolderBase::Init(aNbCells, aDim);
+ myGaussCoord = theGaussCoord;
+ }
+
+ //! Get slice of coordinates for defined node (const version)
+ virtual
+ TCCoordSlice
+ GetCoordSlice(vtkIdType theNodeId) const
+ {
+ MED::TInt anElemId = theNodeId / myGaussCoord->GetNbGauss();
+ MED::TCCoordSliceArr aCoordSliceArr = myGaussCoord->GetCoordSliceArr(anElemId);
+ MED::TInt aGaussId = theNodeId % myGaussCoord->GetNbGauss();
+ return aCoordSliceArr[aGaussId];
+ }
+
+ //! Get slice of coordinates for defined node
+ virtual
+ TCoordSlice
+ GetCoordSlice(vtkIdType theNodeId)
+ {
+ MED::TInt anElemId = theNodeId / myGaussCoord->GetNbGauss();
+ MED::TCoordSliceArr aCoordSliceArr = myGaussCoord->GetCoordSliceArr(anElemId);
+ MED::TInt aGaussId = theNodeId % myGaussCoord->GetNbGauss();
+ return aCoordSliceArr[aGaussId];
+ }
+
+ virtual
+ unsigned char*
+ GetValuePtr()
+ {
+ return myGaussCoord->GetValuePtr();
+ }
+ };
+
+
+ //---------------------------------------------------------------
+ template<class TValueType>
+ struct TTMEDMeshValue: TTMeshValueHolder<TValueType,
+ MED::SharedPtr<MED::TTMeshValue<MED::TVector<TValueType> > > >
+ {
+ virtual
+ const TValueType*
+ GetPointer() const
+ {
+ return this->myContainer->GetPointer();
+ }
+
+ virtual
+ TValueType*
+ GetPointer()
+ {
+ return this->myContainer->GetPointer();
+ }
+ };
+
//---------------------------------------------------------------
+ typedef std::map<vtkIdType, vtkIdType> TObj2VTKID;
+
class TMEDNamedPointCoords: public virtual TNamedPointCoords
{
- MED::PNodeInfo myNodeInfo;
- TNames myPointNames;
+ MED::EBooleen myIsElemNum; //!< Keeps whether the numeration exists or not
+ MED::PElemNum myElemNum; //!< Keeps objects numeration
+ mutable TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one
+
+ MED::EVersion myVersion;
+ MED::PString myElemNames; //!< Keeps whether the names exists or not
+ MED::EBooleen myIsElemNames; //!< Keeps objects names
+
public:
+ TMEDNamedPointCoords():
+ myIsElemNum(MED::eFAUX),
+ myIsElemNames(MED::eFAUX)
+ {}
+
void
- Init(vtkIdType theNbPoints,
- vtkIdType theDim,
- const MED::PNodeInfo& theNodeInfo);
+ Init(const MED::PNodeInfo& theNodeInfo,
+ MED::EVersion theVersion);
void
- Init(vtkIdType theNbPoints,
- vtkIdType theDim,
- const MED::PGrilleInfo& theGrilleInfo);
+ Init(const MED::PGrilleInfo& theGrilleInfo);
+
+ //! Get object number for node by its VTK one
+ virtual
+ vtkIdType
+ GetObjID(vtkIdType theID) const;
+
+ //! Get VTK number for node by its object one
+ virtual
+ vtkIdType
+ GetVTKID(vtkIdType theID) const;
+ //! Get name of node by its object number
virtual
std::string
GetNodeName(vtkIdType theObjID) const;
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
};
- typedef SharedPtr<TMEDNamedPointCoords> PMEDNamedPointCoords;
+ typedef MED::SharedPtr<TMEDNamedPointCoords> PMEDNamedPointCoords;
//---------------------------------------------------------------
MED::PMeshInfo myMeshInfo;
MED::TEntityInfo myEntityInfo;
};
- typedef SharedPtr<TMEDMesh> PMEDMesh;
+ typedef MED::SharedPtr<TMEDMesh> PMEDMesh;
//---------------------------------------------------------------
{}
MED::EBooleen myIsElemNum;
- MED::TElemNum myElemNum;
+ MED::PElemNum myElemNum;
virtual
vtkIdType
GetElemObjID(vtkIdType theID) const;
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
};
- typedef SharedPtr<TMEDSubProfile> PMEDSubProfile;
+ typedef MED::SharedPtr<TMEDSubProfile> PMEDSubProfile;
//---------------------------------------------------------------
struct TMEDProfile: virtual TProfileImpl
{};
- typedef SharedPtr<TMEDProfile> PMEDProfile;
+ typedef MED::SharedPtr<TMEDProfile> PMEDProfile;
//---------------------------------------------------------------
LessThan(const PGaussImpl& theGauss,
bool& theResult) const;
};
- typedef SharedPtr<TMEDGauss> PMEDGauss;
+ typedef MED::SharedPtr<TMEDGauss> PMEDGauss;
//---------------------------------------------------------------
{}
MED::EBooleen myIsElemNum;
- MED::TElemNum myElemNum;
+ MED::PElemNum myElemNum;
virtual
TGaussPointID
- GetObjID(vtkIdType theID,
- vtkIdType theStartID) const;
+ GetObjID(vtkIdType theID) const;
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
};
- typedef SharedPtr<TMEDGaussSubMesh> PMEDGaussSubMesh;
+ typedef MED::SharedPtr<TMEDGaussSubMesh> PMEDGaussSubMesh;
//---------------------------------------------------------------
struct TMEDGaussMesh: virtual TGaussMeshImpl
{};
- typedef SharedPtr<TMEDGaussMesh> PMEDGaussMesh;
+ typedef MED::SharedPtr<TMEDGaussMesh> PMEDGaussMesh;
//---------------------------------------------------------------
struct TMEDSubMesh: virtual TSubMeshImpl
{
TMEDSubMesh():
- myIsElemNum(MED::eFAUX)
+ myIsElemNum(MED::eFAUX),
+ myIsElemNames(MED::eFAUX)
{}
MED::EBooleen myIsElemNum;
- MED::TElemNum myElemNum;
- MED::PElemInfo myElemInfo;
+ MED::PElemNum myElemNum;
+
+ MED::EVersion myVersion;
+ MED::PString myElemNames;
+ MED::EBooleen myIsElemNames;
void
- Init(const MED::PElemInfo& theElemInfo);
+ Init(const MED::PElemInfo& theElemInfo,
+ MED::EVersion theVersion);
void
Init(const MED::PGrilleInfo& theGrilleInfo);
virtual
std::string
GetElemName(vtkIdType theObjID) const;
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
};
- typedef SharedPtr<TMEDSubMesh> PMEDSubMesh;
+ typedef MED::SharedPtr<TMEDSubMesh> PMEDSubMesh;
//---------------------------------------------------------------
TFamilyID2CellsSize myFamilyID2CellsSize;
MED::TGeom2Size myGeom2Size;
};
- typedef SharedPtr<TMEDMeshOnEntity> PMEDMeshOnEntity;
+ typedef MED::SharedPtr<TMEDMeshOnEntity> PMEDMeshOnEntity;
//---------------------------------------------------------------
struct TMEDFamily: virtual TFamilyImpl
{};
- typedef SharedPtr<TMEDFamily> PMEDFamily;
+ typedef MED::SharedPtr<TMEDFamily> PMEDFamily;
//---------------------------------------------------------------
struct TMEDGroup: virtual TGroupImpl
{};
- typedef SharedPtr<TMEDGroup> PMEDGroup;
+ typedef MED::SharedPtr<TMEDGroup> PMEDGroup;
//---------------------------------------------------------------
struct TMEDField: virtual TFieldImpl
{};
- typedef SharedPtr<TMEDField> PMEDField;
+ typedef MED::SharedPtr<TMEDField> PMEDField;
//---------------------------------------------------------------
struct TMEDValForTime: virtual TValForTimeImpl
{};
- typedef SharedPtr<TMEDValForTime> PMEDValForTime;
+ typedef MED::SharedPtr<TMEDValForTime> PMEDValForTime;
}
// $Header$
#include "VISU_MergeFilter.hxx"
+#include "VISU_MergeFilterUtilities.hxx"
-#include <vtkCellData.h>
#include <vtkObjectFactory.h>
-#include <vtkPointData.h>
-#include <vtkPolyData.h>
-#include <vtkRectilinearGrid.h>
-#include <vtkStructuredGrid.h>
-#include <vtkStructuredPoints.h>
#include <vtkUnstructuredGrid.h>
+#include <vtkPolyData.h>
-#include <vtkIdList.h>
-#include <vtkCell.h>
-
-#include <algorithm>
-#include <vector>
-#include <map>
-
-namespace VISU
-{
-
- class TFieldNode
- {
- public:
- TFieldNode(const char* name, vtkDataSet* ptr=0)
- {
- int length = static_cast<int>(strlen(name));
- if (length > 0) {
- this->Name = new char[length+1];
- strcpy(this->Name, name);
- } else {
- this->Name = 0;
- }
- this->Ptr = ptr;
- this->Next = 0;
- }
- ~TFieldNode()
- {
- delete[] this->Name;
- }
-
- const char* GetName()
- {
- return Name;
- }
- vtkDataSet* Ptr;
- TFieldNode* Next;
- private:
- TFieldNode(const TFieldNode&) {}
- void operator=(const TFieldNode&) {}
- char* Name;
- };
-
- class TFieldList
- {
- public:
- TFieldList()
- {
- this->First = 0;
- this->Last = 0;
- }
- ~TFieldList()
- {
- TFieldNode* node = this->First;
- TFieldNode* next;
- while(node){
- next = node->Next;
- delete node;
- node = next;
- }
- }
-
-
- void Add(const char* name, vtkDataSet* ptr)
- {
- TFieldNode* newNode = new TFieldNode(name, ptr);
- if (!this->First) {
- this->First = newNode;
- this->Last = newNode;
- } else {
- this->Last->Next = newNode;
- this->Last = newNode;
- }
- }
+#include <vtkExecutive.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+#include <vtkStreamingDemandDrivenPipeline.h>
- friend class TFieldListIterator;
-
- private:
- TFieldNode* First;
- TFieldNode* Last;
- };
-
- class TFieldListIterator
- {
- public:
- TFieldListIterator(TFieldList* list)
- {
- this->List = list;
- this->Position = 0;
- }
- void Begin()
- {
- this->Position = this->List->First;
- }
- void Next()
- {
- if (this->Position) {
- this->Position = this->Position->Next;
- }
- }
- int End()
- {
- return this->Position ? 0 : 1;
- }
- TFieldNode* Get()
- {
- return this->Position;
- }
-
- private:
- TFieldNode* Position;
- TFieldList* List;
- };
-
-}
//------------------------------------------------------------------------------
vtkStandardNewMacro(VISU_MergeFilter);
//------------------------------------------------------------------------------
-
-// Create object with no input or output.
-VISU_MergeFilter::VISU_MergeFilter():
+VISU_MergeFilter
+::VISU_MergeFilter():
myIsMergingInputs(false)
{
this->FieldList = new VISU::TFieldList;
+ this->SetNumberOfInputPorts(6);
}
+//------------------------------------------------------------------------------
VISU_MergeFilter::~VISU_MergeFilter()
{
delete this->FieldList;
}
+//------------------------------------------------------------------------------
+void VISU_MergeFilter::SetGeometry(vtkDataSet *input)
+{
+ this->Superclass::SetInput(input);
+}
+
+//------------------------------------------------------------------------------
+vtkDataSet *VISU_MergeFilter::GetGeometry()
+{
+ if (this->GetNumberOfInputConnections(0) < 1)
+ {
+ return NULL;
+ }
+ return vtkDataSet::SafeDownCast(
+ this->GetExecutive()->GetInputData(0, 0));
+}
+
+//------------------------------------------------------------------------------
void VISU_MergeFilter::SetScalars(vtkDataSet *input)
{
- this->vtkProcessObject::SetNthInput(1, input);
+ this->SetInput(1, input);
}
+
+//------------------------------------------------------------------------------
vtkDataSet *VISU_MergeFilter::GetScalars()
{
- if (this->NumberOfInputs < 2)
+ if (this->GetNumberOfInputConnections(1) < 1)
{
return NULL;
}
- return (vtkDataSet *)(this->Inputs[1]);
+ return vtkDataSet::SafeDownCast(
+ this->GetExecutive()->GetInputData(1, 0));
}
+//------------------------------------------------------------------------------
void VISU_MergeFilter::SetVectors(vtkDataSet *input)
{
- this->vtkProcessObject::SetNthInput(2, input);
+ this->SetInput(2, input);
}
+
+//------------------------------------------------------------------------------
vtkDataSet *VISU_MergeFilter::GetVectors()
{
- if (this->NumberOfInputs < 3)
+ if (this->GetNumberOfInputConnections(2) < 1)
{
return NULL;
}
- return (vtkDataSet *)(this->Inputs[2]);
+ return vtkDataSet::SafeDownCast(
+ this->GetExecutive()->GetInputData(2, 0));
}
+//------------------------------------------------------------------------------
void VISU_MergeFilter::SetNormals(vtkDataSet *input)
{
- this->vtkProcessObject::SetNthInput(3, input);
+ this->SetInput(3, input);
}
+
+//------------------------------------------------------------------------------
vtkDataSet *VISU_MergeFilter::GetNormals()
{
- if (this->NumberOfInputs < 4)
+ if (this->GetNumberOfInputConnections(3) < 1)
{
return NULL;
}
- return (vtkDataSet *)(this->Inputs[3]);
+ return vtkDataSet::SafeDownCast(
+ this->GetExecutive()->GetInputData(3, 0));
}
+//------------------------------------------------------------------------------
void VISU_MergeFilter::SetTCoords(vtkDataSet *input)
{
- this->vtkProcessObject::SetNthInput(4, input);
+ this->SetInput(4, input);
}
+
+//------------------------------------------------------------------------------
vtkDataSet *VISU_MergeFilter::GetTCoords()
{
- if (this->NumberOfInputs < 5)
+ if (this->GetNumberOfInputConnections(4) < 1)
{
return NULL;
}
- return (vtkDataSet *)(this->Inputs[4]);
+ return vtkDataSet::SafeDownCast(
+ this->GetExecutive()->GetInputData(4, 0));
}
+//------------------------------------------------------------------------------
void VISU_MergeFilter::SetTensors(vtkDataSet *input)
{
- this->vtkProcessObject::SetNthInput(5, input);
+ this->SetInput(5, input);
}
+
+//------------------------------------------------------------------------------
vtkDataSet *VISU_MergeFilter::GetTensors()
{
- if (this->NumberOfInputs < 6)
+ if (this->GetNumberOfInputConnections(5) < 1)
{
return NULL;
}
- return (vtkDataSet *)(this->Inputs[5]);
+ return vtkDataSet::SafeDownCast(
+ this->GetExecutive()->GetInputData(5, 0));
}
+//------------------------------------------------------------------------------
void VISU_MergeFilter::AddField(const char* name, vtkDataSet* input)
{
this->FieldList->Add(name, input);
}
+//------------------------------------------------------------------------------
void VISU_MergeFilter::RemoveFields()
{
delete this->FieldList;
this->FieldList = new VISU::TFieldList;
}
-namespace
-{
- typedef std::vector<int> TSortedArray;
-
- inline
- void
- GetSortedArray(vtkIntArray *theArray,
- TSortedArray& theSortedArray)
- {
- int aMaxId = theArray->GetMaxId();
- int* aPointer = theArray->GetPointer(0);
- int* anEndPointer = theArray->GetPointer(aMaxId + 1);
- TSortedArray aSortedArray(aPointer, anEndPointer);
- std::sort(aSortedArray.begin(), aSortedArray.end());
- theSortedArray.swap(aSortedArray);
- }
-
- typedef std::map<int,int> TId2IdMap;
-
- template <class TNumericType>
- void DeepCopySwitchOnOutput(TNumericType *theInputPtr,
- TNumericType *theOutputPtr,
- const TSortedArray& theIntersection,
- const TId2IdMap& theObj2VTKMap,
- vtkIdType theNbComp)
- {
- vtkIdType aNbIds = theIntersection.size();
- for(vtkIdType aTargetTupleId = 0; aTargetTupleId < aNbIds; aTargetTupleId++){
- vtkIdType aTargetId = aTargetTupleId*theNbComp;
- vtkIdType anObjId = theIntersection[aTargetTupleId];
- TId2IdMap::const_iterator anIter = theObj2VTKMap.find(anObjId);
- vtkIdType aSourceTupleId = anIter->second;
- vtkIdType aSourceId = aSourceTupleId*theNbComp;
- for(vtkIdType aComp = 0; aComp < theNbComp; aComp++){
- theOutputPtr[aTargetId++] = theInputPtr[aSourceId++];
- }
- }
- }
-
- typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)();
- typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkDataArray*);
-
- inline
- void
- CopyArray(vtkDataArray* theDataArray,
- vtkDataSetAttributes* theOutput,
- TSetAttribute theSetAttribute,
- vtkIdType theFixedNbTuples)
- {
- if(theDataArray){
- vtkIdType aNbTuples = theDataArray->GetNumberOfTuples();
- if(theFixedNbTuples == aNbTuples)
- (theOutput->*theSetAttribute)(theDataArray);
- }
- }
-
- inline
- void
- CopyAttribute(vtkDataSetAttributes* theInput,
- TGetAttribute theGetAttribute,
- vtkDataSetAttributes* theOutput,
- TSetAttribute theSetAttribute,
- vtkIdType theFixedNbTuples)
- {
- CopyArray((theInput->*theGetAttribute)(),
- theOutput, theSetAttribute,
- theFixedNbTuples);
- }
-
- vtkDataArray*
- DeepCopyArray(vtkDataArray* theDataArray,
- vtkDataSetAttributes* theOutput,
- TSetAttribute theSetAttribute,
- const TSortedArray& theIntersection,
- const TId2IdMap& theObj2VTKMap)
- {
- vtkDataArray *aDataArray = NULL;
- if(theDataArray){
- void *anInputPtr = theDataArray->GetVoidPointer(0);
- vtkIdType aNbTuples = theIntersection.size();
- vtkIdType aNbComp = theDataArray->GetNumberOfComponents();
-
- aDataArray = vtkDataArray::CreateDataArray(theDataArray->GetDataType());
- aDataArray->SetNumberOfComponents(aNbComp);
- aDataArray->SetNumberOfTuples(aNbTuples);
- void *anOutputPtr = aDataArray->GetVoidPointer(0);
-
- switch(theDataArray->GetDataType()){
- vtkTemplateMacro5(DeepCopySwitchOnOutput,
- (VTK_TT*)anInputPtr,
- (VTK_TT*)anOutputPtr,
- theIntersection,
- theObj2VTKMap,
- aNbComp);
- default:
- vtkGenericWarningMacro(<<"Unsupported data type!");
- }
-
- (theOutput->*theSetAttribute)(aDataArray);
- aDataArray->Delete();
- }
- return aDataArray;
- }
-
- void
- DeepCopyAttribute(vtkDataSetAttributes* theInput,
- TGetAttribute theGetAttribute,
- vtkDataSetAttributes* theOutput,
- TSetAttribute theSetAttribute,
- const TSortedArray& theIntersection,
- const TId2IdMap& theObj2VTKMap)
- {
- DeepCopyArray((theInput->*theGetAttribute)(),
- theOutput,
- theSetAttribute,
- theIntersection,
- theObj2VTKMap);
- }
-
- inline
- void
- DeepCopyDataSetAttribute(vtkDataSet* theInput,
- TGetAttribute theGetAttribute,
- vtkDataSet* theOutput,
- TSetAttribute theSetAttribute,
- const TSortedArray& theIntersection,
- const TId2IdMap& theObj2VTKMap)
- {
- CopyAttribute(theInput->GetPointData(),
- theGetAttribute,
- theOutput->GetPointData(),
- theSetAttribute,
- theInput->GetNumberOfPoints());
- DeepCopyAttribute(theInput->GetCellData(),
- theGetAttribute,
- theOutput->GetCellData(),
- theSetAttribute,
- theIntersection,
- theObj2VTKMap);
- }
-
- inline
- void
- DeepCopyField(vtkDataSetAttributes* theInput,
- const char* theFieldName,
- vtkDataSetAttributes* theOutput,
- const TSortedArray& theIntersection,
- const TId2IdMap& theObj2VTKMap)
- {
- vtkDataArray* aDataArray =
- DeepCopyArray(theInput->GetArray(theFieldName),
- theOutput,
- &vtkFieldData::AddArray,
- theIntersection,
- theObj2VTKMap);
- if(aDataArray)
- aDataArray->SetName(theFieldName);
- }
-
- inline
- void
- CopyField(vtkDataSetAttributes* theInput,
- const char* theFieldName,
- vtkDataSetAttributes* theOutput,
- vtkIdType theFixedNbTuples)
- {
- CopyArray(theInput->GetArray(theFieldName),
- theOutput,
- &vtkDataSetAttributes::AddArray,
- theFixedNbTuples);
- }
-
- inline
- void
- DeepCopyDataSetField(vtkDataSet* theInput,
- const char* theFieldName,
- vtkDataSet* theOutput,
- const TSortedArray& theIntersection,
- const TId2IdMap& theObj2VTKMap)
- {
- CopyField(theInput->GetPointData(), theFieldName,
- theOutput->GetPointData(),
- theInput->GetNumberOfPoints());
- DeepCopyField(theInput->GetCellData(), theFieldName,
- theOutput->GetCellData(),
- theIntersection, theObj2VTKMap);
- }
-
- inline
- void
- DeepCopyDataSetAttributes(VISU_MergeFilter *theFilter,
- vtkDataSet *theFilterOutput,
- VISU::TFieldList* theFieldList,
- const TSortedArray& theIntersection,
- const TId2IdMap& theObj2VTKMap)
- {
- if(vtkDataSet* aDataSet = theFilter->GetScalars())
- DeepCopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetScalars,
- theFilterOutput,
- &vtkDataSetAttributes::SetScalars,
- theIntersection,
- theObj2VTKMap);
-
- if(vtkDataSet* aDataSet = theFilter->GetVectors())
- DeepCopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetVectors,
- theFilterOutput,
- &vtkDataSetAttributes::SetVectors,
- theIntersection,
- theObj2VTKMap);
-
- if(vtkDataSet* aDataSet = theFilter->GetNormals())
- DeepCopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetNormals,
- theFilterOutput,
- &vtkDataSetAttributes::SetNormals,
- theIntersection,
- theObj2VTKMap);
-
- if(vtkDataSet* aDataSet = theFilter->GetTCoords())
- DeepCopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetTCoords,
- theFilterOutput,
- &vtkDataSetAttributes::SetTCoords,
- theIntersection,
- theObj2VTKMap);
-
- if(vtkDataSet* aDataSet = theFilter->GetTensors())
- DeepCopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetTensors,
- theFilterOutput,
- &vtkDataSetAttributes::SetTensors,
- theIntersection,
- theObj2VTKMap);
-
- VISU::TFieldListIterator anIter(theFieldList);
- for(anIter.Begin(); !anIter.End() ; anIter.Next()){
- vtkDataSet *aDataSet = anIter.Get()->Ptr;
- const char* aFieldName = anIter.Get()->GetName();
- DeepCopyDataSetField(aDataSet,
- aFieldName,
- theFilterOutput,
- theIntersection,
- theObj2VTKMap);
- }
- }
-
- inline
- void
- GetIdsForCopy(vtkUnstructuredGrid *inputUGrid,
- vtkIntArray* inputPointIds,
- TSortedArray& outputSortedArray)
- {
- if(inputUGrid){
- TSortedArray aSortedPointIds;
- TSortedArray aOutputCellIds;
- GetSortedArray(inputPointIds,aSortedPointIds);
-
- int nbInputCells = inputUGrid->GetNumberOfCells();
-
- TSortedArray aPointCellIds;
- for(int idCell=0;idCell<nbInputCells;idCell++){
- aPointCellIds.clear();
- vtkCell* aCell = inputUGrid->GetCell(idCell);
- vtkIdList* ptIds = aCell->GetPointIds();
- int aMaxId = ptIds->GetNumberOfIds();
- int* aPointer = ptIds->GetPointer(0);
- int* anEndPointer = ptIds->GetPointer(aMaxId + 1);
- TSortedArray aSortedArray(aPointer, anEndPointer);
- std::sort(aSortedArray.begin(), aSortedArray.end());
-
- int aMaxLength = std::max(aSortedArray.size(), aSortedPointIds.size());
- TSortedArray anIntersectionArray(aMaxLength);
- TSortedArray::iterator anArrayIter = anIntersectionArray.begin();
- anArrayIter = std::set_intersection(aSortedArray.begin(),
- aSortedArray.end(),
- aSortedPointIds.begin(),
- aSortedPointIds.end(),
- anArrayIter);
- anIntersectionArray.erase(anArrayIter, anIntersectionArray.end());
- if(anIntersectionArray.size() == aSortedArray.size())
- aOutputCellIds.push_back(idCell);
- }
-
- outputSortedArray.swap(aOutputCellIds);
- }
- }
-
- inline
- void
- CopyElementsToOutput(vtkUnstructuredGrid* theInputUG,
- int& theNbElements,
- TSortedArray& theElementIdsForCopy,
- TId2IdMap& theOldId2NewIdPointsMap,
- vtkIntArray* theOuputIDSArray,
- vtkUnstructuredGrid* theOutputUG)
- {
- vtkIntArray* aInputCellsMapper =
- dynamic_cast<vtkIntArray*>(theInputUG->GetCellData()->GetArray("VISU_CELLS_MAPPER"));
-
- int* aInputCellsMapperPointer = aInputCellsMapper->GetPointer(0);
-
- for(int aCellIndex=0;aCellIndex<theNbElements;aCellIndex++){
- int aCellId = theElementIdsForCopy[aCellIndex];
- vtkIdList* aOldPointIds = theInputUG->GetCell(aCellId)->GetPointIds();
- vtkIdList* aNewPointIds = vtkIdList::New();
- int nbPointIds = aOldPointIds->GetNumberOfIds();
- aNewPointIds->SetNumberOfIds(nbPointIds);
- for(int j=0;j<nbPointIds;j++){
- int aOldId = aOldPointIds->GetId(j);
- int aNewId = theOldId2NewIdPointsMap[aOldId];
- aNewPointIds->SetId(j,aNewId);
- }
- const int aOldCellId = theElementIdsForCopy[aCellIndex];
- theOutputUG->InsertNextCell(theInputUG->GetCellType(aOldCellId),
- aNewPointIds);
- if(aInputCellsMapperPointer)
- theOuputIDSArray->InsertNextValue(aInputCellsMapperPointer[aOldCellId]);
- else
- theOuputIDSArray->InsertNextValue(aOldCellId);
-
- aNewPointIds->Delete();
- }
- theOutputUG->GetCellData()->AddArray(theOuputIDSArray);
- }
-
-
-}
+//---------------------------------------------------------------
void
VISU_MergeFilter
::SetMergingInputs(bool theIsMergingInputs)
myIsMergingInputs = theIsMergingInputs;
Modified();
}
+
+//---------------------------------------------------------------
bool
VISU_MergeFilter
::IsMergingInputs()
}
-void VISU_MergeFilter::Execute()
+//---------------------------------------------------------------
+int
+VISU_MergeFilter
+::RequestData(vtkInformation *theRequest,
+ vtkInformationVector **theInputVector,
+ vtkInformationVector *theOutputVector)
{
- vtkUnstructuredGrid *anInput = this->GetInput();
- vtkUnstructuredGrid *anOutput = this->GetOutput();
-
- vtkPointData *aPointData = anInput->GetPointData();
- vtkDataSet* aInputScalars = this->GetScalars();
- int nbPointsInScalars = aInputScalars->GetNumberOfPoints();
- int nbPointsInGeometr = anInput->GetNumberOfPoints();
- vtkCellData *aCellData = anInput->GetCellData();
-
- vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER");
- vtkIntArray *aGeometryPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
- vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER");
- vtkIntArray *aGeometryCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper);
- if(aGeometryCellMapper && (nbPointsInScalars == nbPointsInGeometr)){
- vtkIntArray* aDataCellMapper = NULL;
- VISU::TFieldListIterator anIter(this->FieldList);
- for(anIter.Begin(); !anIter.End() ; anIter.Next()){
- vtkCellData *aCellData = anIter.Get()->Ptr->GetCellData();
- const char* aFieldName = anIter.Get()->GetName();
- if(strcmp(aFieldName, "VISU_CELLS_MAPPER") == 0){
- vtkDataArray *aCellMapper_tmp = aCellData->GetArray(aFieldName);
- aDataCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper_tmp);
- break;
- }
- }
-
- bool anIsDifferent = aDataCellMapper &&
- aDataCellMapper->GetNumberOfTuples() != aGeometryCellMapper->GetNumberOfTuples();
- if(anIsDifferent || IsMergingInputs()){
- TSortedArray aGeometryCellArray;
- GetSortedArray(aGeometryCellMapper, aGeometryCellArray);
-
- TSortedArray aDataCellArray;
- GetSortedArray(aDataCellMapper, aDataCellArray);
-
- int aMaxLength = std::max(aGeometryCellArray.size(), aDataCellArray.size());
- TSortedArray anIntersectionArray(aMaxLength);
- TSortedArray::iterator anArrayIter = anIntersectionArray.begin();
- anArrayIter = std::set_intersection(aGeometryCellArray.begin(),
- aGeometryCellArray.end(),
- aDataCellArray.begin(),
- aDataCellArray.end(),
- anArrayIter);
-
- anIntersectionArray.erase(anArrayIter, anIntersectionArray.end());
-
- bool anIsCompletelyCoincide =
- anIntersectionArray.size() == aGeometryCellArray.size() &&
- anIntersectionArray.size() == aDataCellArray.size();
-
- if(!anIsCompletelyCoincide || IsMergingInputs()){
- {
- TId2IdMap anObj2VTKGeometryMap;
- vtkIdType aNbCells = aGeometryCellMapper->GetNumberOfTuples();
- for(int aCellId = 0; aCellId < aNbCells; aCellId++){
- vtkIdType anObjID = aGeometryCellMapper->GetValue(aCellId);
- anObj2VTKGeometryMap[anObjID] = aCellId;
- }
-
- vtkIdType aNbTuples = anIntersectionArray.size();
- anOutput->Allocate(aNbTuples);
- vtkIdList *aCellIds = vtkIdList::New();
- for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
- vtkIdType anObjID = anIntersectionArray[aTupleId];
- vtkIdType aCellId = anObj2VTKGeometryMap[anObjID];
- vtkCell *aCell = anInput->GetCell(aCellId);
- aCellIds->Reset();
- vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
- for(vtkIdType aPointId = 0; aPointId < aNbPointIds; aPointId++)
- aCellIds->InsertNextId(aCell->GetPointIds()->GetId(aPointId));
- anOutput->InsertNextCell(anInput->GetCellType(aCellId), aCellIds);
- }
- aCellIds->Delete();
- anOutput->SetPoints(anInput->GetPoints());
- }
- {
- TId2IdMap anObj2VTKDataMap;
- vtkIdType aNbCells = aDataCellMapper->GetNumberOfTuples();
- for(int aCellId = 0; aCellId < aNbCells; aCellId++){
- vtkIdType anObjID = aDataCellMapper->GetValue(aCellId);
- anObj2VTKDataMap[anObjID] = aCellId;
- }
-
- DeepCopyDataSetAttributes(this,
- anOutput,
- this->FieldList,
- anIntersectionArray,
- anObj2VTKDataMap);
- }
- return;
- }
- }
- } else if (aGeometryCellMapper && (nbPointsInScalars < nbPointsInGeometr)) {
-
- vtkPointData* aInputScalarsPointData = aInputScalars->GetPointData();
-
- vtkIntArray* aDataPointMapper = NULL;
- VISU::TFieldListIterator anIter(this->FieldList);
- for(anIter.Begin(); !anIter.End() ; anIter.Next()){
- const char* aFieldName = anIter.Get()->GetName();
- if(strcmp(aFieldName, "VISU_POINTS_MAPPER") == 0){
- vtkDataArray *aPointMapper = aInputScalarsPointData->GetArray(aFieldName);
- aDataPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
- break;
- }
- }
- vtkIntArray* aDataCellMapper = NULL;
- VISU::TFieldListIterator anIter2(this->FieldList);
- for(anIter2.Begin(); !anIter2.End() ; anIter2.Next()){
- vtkCellData *aCellData = anIter2.Get()->Ptr->GetCellData();
- const char* aFieldName = anIter2.Get()->GetName();
- if(strcmp(aFieldName, "VISU_CELLS_MAPPER") == 0){
- vtkDataArray *aCellMapper_tmp = aInputScalarsPointData->GetArray(aFieldName);
- aDataCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper_tmp);
- break;
- }
- }
+ if(vtkUnstructuredGrid *anInput = dynamic_cast<vtkUnstructuredGrid*>(this->GetInput())){
+ vtkUnstructuredGrid *anOutput = dynamic_cast<vtkUnstructuredGrid*>(this->GetOutput());
+ return VISU::Execute(anInput,
+ anOutput,
+ this->GetScalars(),
+ this->GetVectors(),
+ this->GetNormals(),
+ this->GetTCoords(),
+ this->GetTensors(),
+ this->FieldList,
+ IsMergingInputs());
+ }else if(vtkPolyData *anInput = dynamic_cast<vtkPolyData*>(this->GetInput())){
+ vtkPolyData *anOutput = dynamic_cast<vtkPolyData*>(this->GetOutput());
+ return VISU::Execute(anInput,
+ anOutput,
+ this->GetScalars(),
+ this->GetVectors(),
+ this->GetNormals(),
+ this->GetTCoords(),
+ this->GetTensors(),
+ this->FieldList,
+ IsMergingInputs());
+ }
- bool anIsDifferent = aDataPointMapper &&
- aDataPointMapper->GetNumberOfTuples() != aGeometryPointMapper->GetNumberOfTuples();
- if(anIsDifferent){
- TSortedArray aGeometryPointArray;
- GetSortedArray(aGeometryPointMapper, aGeometryPointArray);
-
- TSortedArray aDataPointArray;
- GetSortedArray(aDataPointMapper, aDataPointArray);
+ return Superclass::RequestData(theRequest,
+ theInputVector,
+ theOutputVector);
+}
- int aMaxLength = std::max(aGeometryPointArray.size(), aDataPointArray.size());
- TSortedArray anIntersectionArray(aMaxLength);
- TSortedArray::iterator anArrayIter = anIntersectionArray.begin();
- anArrayIter = std::set_intersection(aGeometryPointArray.begin(),
- aGeometryPointArray.end(),
- aDataPointArray.begin(),
- aDataPointArray.end(),
- anArrayIter);
-
- anIntersectionArray.erase(anArrayIter, anIntersectionArray.end());
-
+//----------------------------------------------------------------------------
+// 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_MergeFilter
+::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)
{
- TId2IdMap anObj2VTKGeometryMap;
- vtkIdType aNbCells = aDataPointMapper/*aGeometryPointMapper*/->GetNumberOfTuples();
- for(int aCellId = 0; aCellId < aNbCells; aCellId++){
- vtkIdType anObjID = aDataPointMapper/*aGeometryPointMapper*/->GetValue(aCellId);
- anObj2VTKGeometryMap[anObjID] = aCellId;
- }
-
- vtkIdType aNbTuples = anIntersectionArray.size();
-
- if ( aNbTuples == nbPointsInScalars ){
- vtkUnstructuredGrid* aUnstructuredScalars = dynamic_cast<vtkUnstructuredGrid*>(aInputScalars);
- if(aUnstructuredScalars)
- anOutput->SetPoints(aUnstructuredScalars->GetPoints());
- anOutput->GetPointData()->ShallowCopy(aInputScalars->GetPointData());
-
- // Calculate output cells
- int nbCells=0;
- TSortedArray aCellIdsForCopy;
- GetIdsForCopy(anInput,aDataPointMapper,aCellIdsForCopy);
- nbCells = aCellIdsForCopy.size();
-
- // copy cells to output
- anOutput->Allocate(nbCells);
- vtkIntArray* theOuputIDSArray = vtkIntArray::New();
- theOuputIDSArray->SetName("VISU_CELLS_MAPPER");
- theOuputIDSArray->SetNumberOfComponents(1);
- theOuputIDSArray->SetNumberOfTuples(nbCells);
-
- if(nbCells>0)
- CopyElementsToOutput(anInput,
- nbCells,
- aCellIdsForCopy,
- anObj2VTKGeometryMap,
- theOuputIDSArray,
- anOutput);
- theOuputIDSArray->Delete();
- return;
-
- } else {
- // not implemented yet
- }
-
-
-
+ 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);
}
-
}
- }
-
- anOutput->CopyStructure(anInput);
- this->BasicExecute(anOutput);
+ return 1;
}
-namespace
-{
- inline
- void
- CopyDataSetAttribute(vtkDataSet *theInput,
- TGetAttribute theGetAttribute,
- vtkDataSet *theOutput,
- TSetAttribute theSetAttribute,
- vtkIdType theNbPoints,
- vtkIdType theNbCells)
- {
- CopyAttribute(theInput->GetPointData(),
- theGetAttribute,
- theOutput->GetPointData(),
- theSetAttribute,
- theNbPoints);
- CopyAttribute(theInput->GetCellData(),
- theGetAttribute,
- theOutput->GetCellData(),
- theSetAttribute,
- theNbCells);
- }
-
- inline
- void
- CopyDataSetField(vtkDataSet* theInput,
- const char* theFieldName,
- vtkDataSet* theOutput,
- vtkIdType theNbPoints,
- vtkIdType theNbCells)
- {
- CopyField(theInput->GetPointData(), theFieldName,
- theOutput->GetPointData(),
- theNbPoints);
- CopyField(theInput->GetCellData(), theFieldName,
- theOutput->GetCellData(),
- theNbCells);
- }
-}
-
-void VISU_MergeFilter::BasicExecute(vtkDataSet *output)
+//----------------------------------------------------------------------------
+int
+VISU_MergeFilter
+::FillInputPortInformation(int port, vtkInformation *info)
{
- vtkIdType numPts, numCells;
-
- vtkDebugMacro(<<"Merging data!");
-
- if ( (numPts = output->GetNumberOfPoints()) < 1 )
+ int retval = this->Superclass::FillInputPortInformation(port, info);
+ if (port > 0)
{
- vtkWarningMacro(<<"Nothing to merge!");
+ info->Set(vtkAlgorithm::INPUT_IS_OPTIONAL(), 1);
}
- numCells = output->GetNumberOfCells();
-
- // merge data only if it is consistent
- if(vtkDataSet* aDataSet = this->GetScalars())
- CopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetScalars,
- output,
- &vtkDataSetAttributes::SetScalars,
- numPts,
- numCells);
-
- if(vtkDataSet* aDataSet = this->GetVectors())
- CopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetVectors,
- output,
- &vtkDataSetAttributes::SetVectors,
- numPts,
- numCells);
-
- if(vtkDataSet* aDataSet = this->GetNormals())
- CopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetNormals,
- output,
- &vtkDataSetAttributes::SetNormals,
- numPts,
- numCells);
-
- if(vtkDataSet* aDataSet = this->GetTCoords())
- CopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetTCoords,
- output,
- &vtkDataSetAttributes::SetTCoords,
- numPts,
- numCells);
-
- if(vtkDataSet* aDataSet = this->GetTensors())
- CopyDataSetAttribute(aDataSet,
- &vtkDataSetAttributes::GetTensors,
- output,
- &vtkDataSetAttributes::SetTensors,
- numPts,
- numCells);
-
- VISU::TFieldListIterator anIter(this->FieldList);
- for(anIter.Begin(); !anIter.End() ; anIter.Next()){
- vtkDataSet *aDataSet = anIter.Get()->Ptr;
- const char* aFieldName = anIter.Get()->GetName();
- CopyDataSetField(aDataSet,
- aFieldName,
- output,
- numPts,
- numCells);
- }
+ return retval;
}
+
#ifndef VISU_MergeFilter_H
#define VISU_MergeFilter_H
-#include <vtkUnstructuredGridToUnstructuredGridFilter.h>
+#include "VISU_Convertor.hxx"
-class vtkDataSet;
+#include <vtkDataSetAlgorithm.h>
namespace VISU
{
class TFieldList;
}
-// Following class was redefined in order to fix VTK bug
-// (see code for more details)
-class VISU_MergeFilter : public vtkUnstructuredGridToUnstructuredGridFilter
+//------------------------------------------------------------------------------
+class VISU_CONVERTOR_EXPORT VISU_MergeFilter : public vtkDataSetAlgorithm
{
public:
static VISU_MergeFilter *New();
- vtkTypeMacro(VISU_MergeFilter,vtkUnstructuredGridToUnstructuredGridFilter);
+ vtkTypeMacro(VISU_MergeFilter, vtkDataSetAlgorithm);
// Description:
// Specify object from which to extract geometry information.
- void SetGeometry(vtkUnstructuredGrid *input) {this->SetInput(input);};
- vtkUnstructuredGrid *GetGeometry() {return this->GetInput();};
+ void SetGeometry(vtkDataSet *input);
+ vtkDataSet *GetGeometry();
// Description:
// Specify object from which to extract scalar information.
VISU_MergeFilter();
~VISU_MergeFilter();
- // Usual data generation method
- void BasicExecute(vtkDataSet *output);
- void Execute();
+ virtual
+ int
+ RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
+
+ int
+ RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
+
+ int
+ FillInputPortInformation(int port, vtkInformation *info);
VISU::TFieldList* FieldList;
bool myIsMergingInputs;
--- /dev/null
+// 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_MergeFilterUtilities.hxx"
+
+#include <vtkCellData.h>
+#include <vtkObjectFactory.h>
+#include <vtkPointData.h>
+#include <vtkPolyData.h>
+#include <vtkRectilinearGrid.h>
+#include <vtkStructuredGrid.h>
+#include <vtkStructuredPoints.h>
+#include <vtkUnstructuredGrid.h>
+
+#include <vtkIdList.h>
+#include <vtkCell.h>
+
+#include <algorithm>
+#include <vector>
+#include <set>
+#include <map>
+
+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());
+ }
+
+
+ //---------------------------------------------------------------
+ template<class TDataSet>
+ void
+ CopyDataOnCells(TDataSet *theInput,
+ vtkIntArray *theGeometryCellMapper,
+ vtkIntArray *theDataCellMapper,
+ vtkDataSet* theScalarsDataSet,
+ vtkDataSet* theVectorsDataSet,
+ vtkDataSet* theNormalsDataSet,
+ vtkDataSet* theTCoordsDataSet,
+ vtkDataSet* theTensorsDataSet,
+ VISU::TFieldList* theFieldList,
+ TDataSet *theOutput)
+ {
+ if(IsDifferent(theGeometryCellMapper, theDataCellMapper)){
+ TObjectIdArray anIntersection;
+ GetIntersection(theGeometryCellMapper,
+ theDataCellMapper,
+ anIntersection);
+
+ TObjectId2TupleIdMap aGeomObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(theGeometryCellMapper, aGeomObjectId2TupleIdMap);
+
+ TObjectId2TupleIdMap aDataObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(theDataCellMapper, aDataObjectId2TupleIdMap);
+
+ vtkCellData *aCellData = theScalarsDataSet->GetCellData();
+ vtkCellData *anOutputCellData = theOutput->GetCellData();
+ anOutputCellData->CopyAllocate(aCellData);
+
+ vtkIdType aNbTuples = anIntersection.size();
+ theOutput->Allocate(aNbTuples);
+ vtkIdList *aCellIds = vtkIdList::New();
+ for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
+ TObjectId& anObjectId = anIntersection[aTupleId];
+ vtkIdType aCellId = aGeomObjectId2TupleIdMap[anObjectId];
+ vtkCell *aCell = theInput->GetCell(aCellId);
+ aCellIds->Reset();
+ vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
+ for(vtkIdType anId = 0; anId < aNbPointIds; anId++)
+ aCellIds->InsertNextId(aCell->GetPointIds()->GetId(anId));
+ vtkIdType aCellType = theInput->GetCellType(aCellId);
+ vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
+ vtkIdType aDataCellId = aDataObjectId2TupleIdMap[anObjectId];
+ anOutputCellData->CopyData(aCellData, aDataCellId, aNewCellId);
+ }
+ aCellIds->Delete();
+
+ theOutput->SetPoints(theInput->GetPoints());
+ }else{
+ theOutput->CopyStructure(theInput);
+ theOutput->GetCellData()->ShallowCopy(theScalarsDataSet->GetCellData());
+ }
+ theOutput->GetPointData()->ShallowCopy(theInput->GetPointData());
+ }
+
+
+ //---------------------------------------------------------------
+ template<class TDataSet>
+ void
+ CopyDataOnPoints(TDataSet *theInput,
+ vtkIntArray *theGeometryPointMapper,
+ vtkIntArray *theDataPointMapper,
+ vtkDataSet* theScalarsDataSet,
+ vtkDataSet* theVectorsDataSet,
+ vtkDataSet* theNormalsDataSet,
+ vtkDataSet* theTCoordsDataSet,
+ vtkDataSet* theTensorsDataSet,
+ VISU::TFieldList* theFieldList,
+ TDataSet *theOutput)
+ {
+ if(IsDifferent(theGeometryPointMapper, theDataPointMapper)){
+ TObjectId2TupleIdMap aDataObjectId2PointIdMap;
+ GetObjectId2TupleIdMap(theDataPointMapper, aDataObjectId2PointIdMap);
+
+ vtkCellData *aCellData = theInput->GetCellData();
+ vtkCellData *anOutputCellData = theOutput->GetCellData();
+ anOutputCellData->CopyAllocate(aCellData);
+
+ vtkIdList *aCellIds = vtkIdList::New();
+ int aNbCells = theInput->GetNumberOfCells();
+ theOutput->Allocate(aNbCells);
+ for(int aCellId = 0; aCellId < aNbCells; aCellId++){
+ aCellIds->Reset();
+ vtkCell *aCell = theInput->GetCell(aCellId);
+ vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
+ for(vtkIdType anId = 0; anId < aNbPointIds; anId++){
+ vtkIdType aPointId = aCell->GetPointIds()->GetId(anId);
+ int* aPointer = theGeometryPointMapper->GetPointer(aPointId * 2);
+ TCellId aCellId = *aPointer;
+ TEntityId anEntityId = *(aPointer + 1);
+ TObjectId anObjectId(aCellId, anEntityId);
+ TObjectId2TupleIdMap::iterator anIter = aDataObjectId2PointIdMap.find(anObjectId);
+ if(anIter != aDataObjectId2PointIdMap.end()){
+ aPointId = anIter->second;
+ aCellIds->InsertNextId(aPointId);
+ }else
+ goto PASS_INSERT_NEXT_CELL;
+ }
+ {
+ vtkIdType aCellType = theInput->GetCellType(aCellId);
+ vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
+ anOutputCellData->CopyData(aCellData, aCellId, aNewCellId);
+ }
+ PASS_INSERT_NEXT_CELL:
+ continue;
+ }
+ aCellIds->Delete();
+
+ // Copy geometry points
+ // 1. Create vtkPoints instance of the same data type
+ vtkPointSet* aScalarsDataSet = dynamic_cast<vtkPointSet*>(theScalarsDataSet);
+ vtkPoints* anGeometryPoints = theInput->GetPoints();
+ vtkPoints* aDataPoints = aScalarsDataSet->GetPoints();
+ vtkPoints* anOutputPoints = vtkPoints::New(aDataPoints->GetDataType());
+ theOutput->SetPoints(anOutputPoints);
+ anOutputPoints->Delete();
+
+ // 2. Perform mapping of geometry points
+ TObjectId2TupleIdMap aGeomObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(theGeometryPointMapper, aGeomObjectId2TupleIdMap);
+
+ // 3. Loop over all data points
+ int aNbDataPoints = theDataPointMapper->GetNumberOfTuples();
+ anOutputPoints->SetNumberOfPoints(aNbDataPoints);
+ for(int aPointId = 0; aPointId < aNbDataPoints; aPointId++){
+ int* aPointer = theDataPointMapper->GetPointer(aPointId * 2);
+ TCellId aCellId = *aPointer;
+ TEntityId anEntityId = *(aPointer + 1);
+ TObjectId anObjectId(aCellId, anEntityId);
+ TObjectId2TupleIdMap::iterator anIter = aGeomObjectId2TupleIdMap.find(anObjectId);
+ if(anIter != aDataObjectId2PointIdMap.end()){
+ // If the point exists in the geometry put it to output
+ int aGeometryPointId = anIter->second;
+ vtkFloatingPointType aCoords[3];
+ anGeometryPoints->GetPoint(aGeometryPointId, aCoords);
+ anOutputPoints->SetPoint(aPointId, aCoords);
+ }else{
+ // If no, the point from data should be used
+ vtkFloatingPointType aCoords[3];
+ aDataPoints->GetPoint(aPointId, aCoords);
+ anOutputPoints->SetPoint(aPointId, aCoords);
+ }
+ }
+ }else{
+ theOutput->CopyStructure(theInput);
+ theOutput->GetCellData()->ShallowCopy(theInput->GetCellData());
+ }
+ theOutput->GetPointData()->ShallowCopy(theScalarsDataSet->GetPointData());
+ }
+
+
+ //---------------------------------------------------------------
+ typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)();
+ typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkDataArray*);
+
+ inline
+ void
+ CopyArray(vtkDataArray* theDataArray,
+ vtkDataSetAttributes* theOutput,
+ TSetAttribute theSetAttribute,
+ vtkIdType theFixedNbTuples)
+ {
+ if(theDataArray){
+ vtkIdType aNbTuples = theDataArray->GetNumberOfTuples();
+ if(theFixedNbTuples == aNbTuples)
+ (theOutput->*theSetAttribute)(theDataArray);
+ }
+ }
+
+
+ //---------------------------------------------------------------
+ inline
+ void
+ CopyAttribute(vtkDataSetAttributes* theInput,
+ TGetAttribute theGetAttribute,
+ vtkDataSetAttributes* theOutput,
+ TSetAttribute theSetAttribute,
+ vtkIdType theFixedNbTuples)
+ {
+ CopyArray((theInput->*theGetAttribute)(),
+ theOutput, theSetAttribute,
+ theFixedNbTuples);
+ }
+
+
+ //---------------------------------------------------------------
+ inline
+ void
+ CopyDataSetAttribute(vtkDataSet *theInput,
+ TGetAttribute theGetAttribute,
+ vtkDataSet *theOutput,
+ TSetAttribute theSetAttribute,
+ vtkIdType theNbPoints,
+ vtkIdType theNbCells)
+ {
+ CopyAttribute(theInput->GetPointData(),
+ theGetAttribute,
+ theOutput->GetPointData(),
+ theSetAttribute,
+ theNbPoints);
+ CopyAttribute(theInput->GetCellData(),
+ theGetAttribute,
+ theOutput->GetCellData(),
+ theSetAttribute,
+ theNbCells);
+ }
+
+
+ //---------------------------------------------------------------
+ inline
+ void
+ CopyField(vtkDataSetAttributes* theInput,
+ const char* theFieldName,
+ vtkDataSetAttributes* theOutput,
+ vtkIdType theFixedNbTuples)
+ {
+ CopyArray(theInput->GetArray(theFieldName),
+ theOutput,
+ &vtkDataSetAttributes::AddArray,
+ theFixedNbTuples);
+ }
+
+
+ //---------------------------------------------------------------
+ inline
+ void
+ CopyDataSetField(vtkDataSet* theInput,
+ const char* theFieldName,
+ vtkDataSet* theOutput,
+ vtkIdType theNbPoints,
+ vtkIdType theNbCells)
+ {
+ if(theInput){
+ CopyField(theInput->GetPointData(),
+ theFieldName,
+ theOutput->GetPointData(),
+ theNbPoints);
+ CopyField(theInput->GetCellData(),
+ theFieldName,
+ theOutput->GetCellData(),
+ theNbCells);
+ }
+ }
+
+ //---------------------------------------------------------------
+ void
+ BasicExecute(vtkDataSet *theInput,
+ vtkDataSet* theScalarsDataSet,
+ vtkDataSet* theVectorsDataSet,
+ vtkDataSet* theNormalsDataSet,
+ vtkDataSet* theTCoordsDataSet,
+ vtkDataSet* theTensorsDataSet,
+ VISU::TFieldList* theFieldList,
+ vtkDataSet *theOutput)
+ {
+ theOutput->CopyStructure(theInput);
+
+ vtkIdType aNbPoints = theInput->GetNumberOfPoints();
+ vtkIdType aNbCells = theInput->GetNumberOfCells();
+
+ // merge data only if it is consistent
+ if(theScalarsDataSet)
+ CopyDataSetAttribute(theScalarsDataSet,
+ &vtkDataSetAttributes::GetScalars,
+ theOutput,
+ &vtkDataSetAttributes::SetScalars,
+ aNbPoints,
+ aNbCells);
+
+ if(theVectorsDataSet)
+ CopyDataSetAttribute(theVectorsDataSet,
+ &vtkDataSetAttributes::GetVectors,
+ theOutput,
+ &vtkDataSetAttributes::SetVectors,
+ aNbPoints,
+ aNbCells);
+
+ if(theNormalsDataSet)
+ CopyDataSetAttribute(theNormalsDataSet,
+ &vtkDataSetAttributes::GetNormals,
+ theOutput,
+ &vtkDataSetAttributes::SetNormals,
+ aNbPoints,
+ aNbCells);
+
+ if(theTCoordsDataSet)
+ CopyDataSetAttribute(theTCoordsDataSet,
+ &vtkDataSetAttributes::GetTCoords,
+ theOutput,
+ &vtkDataSetAttributes::SetTCoords,
+ aNbPoints,
+ aNbCells);
+
+ if(theTensorsDataSet)
+ CopyDataSetAttribute(theTensorsDataSet,
+ &vtkDataSetAttributes::GetTensors,
+ theOutput,
+ &vtkDataSetAttributes::SetTensors,
+ aNbPoints,
+ aNbCells);
+
+ VISU::TFieldListIterator anIter(theFieldList);
+ for(anIter.Begin(); !anIter.End() ; anIter.Next()){
+ vtkDataSet *aDataSet = anIter.Get()->Ptr;
+ const char* aFieldName = anIter.Get()->GetName();
+ CopyDataSetField(aDataSet,
+ aFieldName,
+ theOutput,
+ aNbPoints,
+ aNbCells);
+ }
+ }
+
+
+ //---------------------------------------------------------------
+ template<class TDataSet>
+ bool
+ Execute(TDataSet *theInput,
+ vtkDataSet* theScalarsDataSet,
+ vtkDataSet* theVectorsDataSet,
+ vtkDataSet* theNormalsDataSet,
+ vtkDataSet* theTCoordsDataSet,
+ vtkDataSet* theTensorsDataSet,
+ VISU::TFieldList* theFieldList,
+ bool theIsMergingInputs,
+ TDataSet *theOutput)
+ {
+ if(theIsMergingInputs){
+ vtkCellData *aCellData = theInput->GetCellData();
+ if(vtkDataArray *aCellMapper = aCellData->GetArray("VISU_CELLS_MAPPER")){
+ bool anIsDataOnCells = false;
+ if(vtkDataSet* aDataSet = theScalarsDataSet)
+ if(vtkCellData* aCellData = aDataSet->GetCellData())
+ anIsDataOnCells = (aCellData->GetArray("VISU_FIELD") != NULL);
+ if(anIsDataOnCells){
+ vtkIntArray *aGeometryCellMapper = dynamic_cast<vtkIntArray*>(aCellMapper);
+ vtkIntArray* aDataCellMapper = GetIDMapper(theFieldList,
+ TGetCellData(),
+ "VISU_CELLS_MAPPER");
+ CopyDataOnCells(theInput,
+ aGeometryCellMapper,
+ aDataCellMapper,
+ theScalarsDataSet,
+ theVectorsDataSet,
+ theNormalsDataSet,
+ theTCoordsDataSet,
+ theTensorsDataSet,
+ theFieldList,
+ theOutput);
+ }else{
+ vtkPointData *aPointData = theInput->GetPointData();
+ vtkDataArray *aPointMapper = aPointData->GetArray("VISU_POINTS_MAPPER");
+ vtkIntArray *aGeometryPointMapper = dynamic_cast<vtkIntArray*>(aPointMapper);
+ vtkIntArray* aDataPointMapper = GetIDMapper(theFieldList,
+ TGetPointData(),
+ "VISU_POINTS_MAPPER");
+ CopyDataOnPoints(theInput,
+ aGeometryPointMapper,
+ aDataPointMapper,
+ theScalarsDataSet,
+ theVectorsDataSet,
+ theNormalsDataSet,
+ theTCoordsDataSet,
+ theTensorsDataSet,
+ theFieldList,
+ theOutput);
+ }
+ }
+ }else{
+ BasicExecute(theInput,
+ theScalarsDataSet,
+ theVectorsDataSet,
+ theNormalsDataSet,
+ theTCoordsDataSet,
+ theTensorsDataSet,
+ theFieldList,
+ theOutput);
+ }
+ return true;
+ }
+}
+
+
+namespace VISU
+{
+
+ //---------------------------------------------------------------
+ bool
+ Execute(vtkUnstructuredGrid *theInput,
+ vtkUnstructuredGrid *theOutput,
+ vtkDataSet* theScalarsDataSet,
+ vtkDataSet* theVectorsDataSet,
+ vtkDataSet* theNormalsDataSet,
+ vtkDataSet* theTCoordsDataSet,
+ vtkDataSet* theTensorsDataSet,
+ TFieldList* theFieldList,
+ bool theIsMergingInputs)
+ {
+ return ::Execute(theInput,
+ theScalarsDataSet,
+ theVectorsDataSet,
+ theNormalsDataSet,
+ theTCoordsDataSet,
+ theTensorsDataSet,
+ theFieldList,
+ theIsMergingInputs,
+ theOutput);
+ }
+
+
+ //---------------------------------------------------------------
+ bool
+ Execute(vtkPolyData *theInput,
+ vtkPolyData *theOutput,
+ vtkDataSet* theScalarsDataSet,
+ vtkDataSet* theVectorsDataSet,
+ vtkDataSet* theNormalsDataSet,
+ vtkDataSet* theTCoordsDataSet,
+ vtkDataSet* theTensorsDataSet,
+ TFieldList* theFieldList,
+ bool theIsMergingInputs)
+ {
+ return ::Execute(theInput,
+ theScalarsDataSet,
+ theVectorsDataSet,
+ theNormalsDataSet,
+ theTCoordsDataSet,
+ theTensorsDataSet,
+ theFieldList,
+ theIsMergingInputs,
+ theOutput);
+ }
+
+
+ //---------------------------------------------------------------
+}
--- /dev/null
+// 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_MergeFilterUtilities_H
+#define VISU_MergeFilterUtilities_H
+
+#include <string>
+
+class vtkDataSet;
+class vtkPolyData;
+class vtkUnstructuredGrid;
+
+namespace VISU
+{
+ class TFieldList;
+
+
+ //---------------------------------------------------------------
+ bool
+ Execute(vtkUnstructuredGrid *theInput,
+ vtkUnstructuredGrid *theOutput,
+ vtkDataSet* theScalarsDataSet,
+ vtkDataSet* theVectorsDataSet,
+ vtkDataSet* theNormalsDataSet,
+ vtkDataSet* theTCoordsDataSet,
+ vtkDataSet* theTensorsDataSet,
+ TFieldList* theFieldList,
+ bool theIsMergingInputs);
+
+
+ //---------------------------------------------------------------
+ bool
+ Execute(vtkPolyData *theInput,
+ vtkPolyData *theOutput,
+ vtkDataSet* theScalarsDataSet,
+ vtkDataSet* theVectorsDataSet,
+ vtkDataSet* theNormalsDataSet,
+ vtkDataSet* theTCoordsDataSet,
+ vtkDataSet* theTensorsDataSet,
+ TFieldList* theFieldList,
+ bool theIsMergingInputs);
+
+
+ //---------------------------------------------------------------
+ class TFieldNode
+ {
+ public:
+ TFieldNode(const char* name, vtkDataSet* ptr=0)
+ {
+ int length = static_cast<int>(strlen(name));
+ if (length > 0) {
+ this->Name = new char[length+1];
+ strcpy(this->Name, name);
+ } else {
+ this->Name = 0;
+ }
+ this->Ptr = ptr;
+ this->Next = 0;
+ }
+ ~TFieldNode()
+ {
+ delete[] this->Name;
+ }
+
+ const char* GetName()
+ {
+ return Name;
+ }
+ vtkDataSet* Ptr;
+ TFieldNode* Next;
+ private:
+ TFieldNode(const TFieldNode&) {}
+ void operator=(const TFieldNode&) {}
+ char* Name;
+ };
+
+
+ //---------------------------------------------------------------
+ class TFieldList
+ {
+ public:
+ TFieldList()
+ {
+ this->First = 0;
+ this->Last = 0;
+ }
+ ~TFieldList()
+ {
+ TFieldNode* node = this->First;
+ TFieldNode* next;
+ while(node){
+ next = node->Next;
+ delete node;
+ node = next;
+ }
+ }
+
+
+ void Add(const char* name, vtkDataSet* ptr)
+ {
+ TFieldNode* newNode = new TFieldNode(name, ptr);
+ if (!this->First) {
+ this->First = newNode;
+ this->Last = newNode;
+ } else {
+ this->Last->Next = newNode;
+ this->Last = newNode;
+ }
+ }
+
+ friend class TFieldListIterator;
+
+ private:
+ TFieldNode* First;
+ TFieldNode* Last;
+ };
+
+
+ //---------------------------------------------------------------
+ class TFieldListIterator
+ {
+ public:
+ TFieldListIterator(TFieldList* list)
+ {
+ this->List = list;
+ this->Position = 0;
+ }
+ void Begin()
+ {
+ this->Position = this->List->First;
+ }
+ void Next()
+ {
+ if (this->Position) {
+ this->Position = this->Position->Next;
+ }
+ }
+ int End()
+ {
+ return this->Position ? 0 : 1;
+ }
+ TFieldNode* Get()
+ {
+ return this->Position;
+ }
+
+ private:
+ TFieldNode* Position;
+ TFieldList* List;
+ };
+
+
+ //---------------------------------------------------------------
+}
+
+#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:
+// Author:
+// Module : VISU
+
+#include "VISU_MeshValue.hxx"
+#include "VISU_Structures_impl.hxx"
+#include "VISU_ConvertorUtils.hxx"
+
+#include "VISU_PointCoords.hxx"
+#include "VISU_TypeList.hxx"
+
+#include <vtkUnstructuredGrid.h>
+#include <vtkPolyData.h>
+
+#include <vtkPointData.h>
+#include <vtkCellData.h>
+
+#include <vtkCharArray.h>
+#include <vtkUnsignedCharArray.h>
+#include <vtkShortArray.h>
+#include <vtkUnsignedShortArray.h>
+#include <vtkIntArray.h>
+#include <vtkUnsignedIntArray.h>
+#include <vtkLongArray.h>
+#include <vtkUnsignedLongArray.h>
+#include <vtkFloatArray.h>
+#include <vtkDoubleArray.h>
+
+#include <string>
+#include <algorithm>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+namespace VISU
+{
+ //---------------------------------------------------------------
+ std::string
+ GenerateFieldName(const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime)
+ {
+ const VISU::TTime& aTime = theValForTime->myTime;
+ std::string aFieldName = theField->myMeshName + ", " + theField->myName + ": " +
+ VISU_Convertor::GenerateName(aTime);
+ return aFieldName;
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ TMeshValueBase
+ ::Init(vtkIdType theNbElem,
+ vtkIdType theNbGauss,
+ vtkIdType theNbComp)
+ {
+ myNbElem = theNbElem;
+ myNbGauss = theNbGauss;
+ myNbComp = theNbComp;
+ myStep = theNbComp*theNbGauss;
+ }
+
+ vtkIdType
+ TMeshValueBase
+ ::GetNbElem() const
+ {
+ return myNbElem;
+ }
+
+ vtkIdType
+ TMeshValueBase
+ ::GetNbComp() const
+ {
+ return myNbComp;
+ }
+
+ vtkIdType
+ TMeshValueBase
+ ::GetNbGauss() const
+ {
+ return myNbGauss;
+ }
+
+ size_t
+ TMeshValueBase
+ ::size() const
+ {
+ return myNbElem * myStep;
+ }
+
+
+ namespace TL
+ {
+ //----------------------------------------------------------------------------
+ typedef TList<char,
+ TList<unsigned char,
+ TList<short,
+ TList<unsigned short,
+ TList<int,
+ TList<unsigned int,
+ TList<long,
+ TList<unsigned long,
+ TList<float,
+ TList<double,
+ TNullType> > > > > > > > > >
+ TVTKBasicTypeList;
+
+
+ //----------------------------------------------------------------------------
+ typedef TList<vtkCharArray,
+ TList<vtkUnsignedCharArray,
+ TList<vtkShortArray,
+ TList<vtkUnsignedShortArray,
+ TList<vtkIntArray,
+ TList<vtkUnsignedIntArray,
+ TList<vtkLongArray,
+ TList<vtkUnsignedLongArray,
+ TList<vtkFloatArray,
+ TList<vtkDoubleArray,
+ TNullType> > > > > > > > > >
+ TVTKArrayTypeList;
+
+
+ typedef TList<TInt2Type<VTK_CHAR>,
+ TList<TInt2Type<VTK_UNSIGNED_CHAR>,
+ TList<TInt2Type<VTK_SHORT>,
+ TList<TInt2Type<VTK_UNSIGNED_SHORT>,
+ TList<TInt2Type<VTK_INT>,
+ TList<TInt2Type<VTK_UNSIGNED_INT>,
+ TList<TInt2Type<VTK_LONG>,
+ TList<TInt2Type<VTK_UNSIGNED_LONG>,
+ TList<TInt2Type<VTK_FLOAT>,
+ TList<TInt2Type<VTK_DOUBLE>,
+ TNullType> > > > > > > > > >
+ TVTKBasicEnumList;
+
+
+ //----------------------------------------------------------------------------
+ template <unsigned int type_enum>
+ struct TEnum2VTKBasicType
+ {
+ typedef typename TTypeAt<TVTKBasicTypeList, TIndexOf<TVTKBasicEnumList, TInt2Type<type_enum> >::value >::TResult TResult;
+ };
+
+ //----------------------------------------------------------------------------
+ template <unsigned int type_enum>
+ struct TEnum2VTKArrayType
+ {
+ typedef typename TTypeAt<TVTKArrayTypeList, TIndexOf<TVTKBasicEnumList, TInt2Type<type_enum> >::value >::TResult TResult;
+ };
+
+ //----------------------------------------------------------------------------
+ template <class T>
+ struct TVTKBasicType2Enum
+ {
+ typedef typename TTypeAt<TVTKBasicEnumList, TIndexOf<TVTKBasicTypeList, T>::value >::TResult TResult;
+ };
+
+ }
+
+
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ void
+ InitTimeStampOnProfile(const PUnstructuredGrid& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime,
+ const VISU::TEntity& theEntity);
+
+
+ //----------------------------------------------------------------------------
+ void
+ GetTimeStampOnProfile(const PUnstructuredGrid& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime,
+ const VISU::TEntity& theEntity)
+ {
+ vtkIdType aDataType = theField->GetDataType();
+ switch(aDataType){
+ case VTK_DOUBLE:
+ InitTimeStampOnProfile<VTK_DOUBLE>(theSource, theField, theValForTime, theEntity);
+ break;
+ case VTK_FLOAT:
+ InitTimeStampOnProfile<VTK_FLOAT>(theSource, theField, theValForTime, theEntity);
+ break;
+ case VTK_INT:
+ InitTimeStampOnProfile<VTK_INT>(theSource, theField, theValForTime, theEntity);
+ break;
+ case VTK_LONG:
+ InitTimeStampOnProfile<VTK_LONG>(theSource, theField, theValForTime, theEntity);
+ break;
+ default:
+ EXCEPTION(std::runtime_error,
+ "GetTimeStampOnProfile - handling unsupported data type - "<<aDataType);
+ }
+ }
+
+
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ struct TDataArrayHolder
+ {
+ typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
+ typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
+ TVTKDataArray* myDataArray;
+
+ TDataArrayHolder(TVTKDataArray* theDataArray):
+ myDataArray(theDataArray)
+ {}
+
+ void
+ WritePointer(TVTKDataArray* theDataArray,
+ vtkIdType theTupleId,
+ TVTKBasicType* thePointer)
+ {
+ vtkIdType aNumberOfComponents = theDataArray->GetNumberOfComponents();
+ vtkIdType aPosition = theTupleId * aNumberOfComponents;
+ TVTKBasicType *aPtr = theDataArray->WritePointer(aPosition, aNumberOfComponents);
+ for(vtkIdType anId = 0; anId < aNumberOfComponents; anId++)
+ *aPtr++ = *thePointer++;
+ }
+
+ virtual
+ void
+ SetTuple(vtkIdType theTupleId,
+ TVTKBasicType* thePointer)
+ {
+ this->WritePointer(myDataArray, theTupleId, thePointer);
+ }
+ };
+
+
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ struct TDataArrayHolder2: TDataArrayHolder<EDataType>
+ {
+ typedef TDataArrayHolder<EDataType> TSuperClass;
+ typedef typename TSuperClass::TVTKDataArray TVTKDataArray;
+ typedef typename TSuperClass::TVTKBasicType TVTKBasicType;
+ TVTKDataArray* myDataArray2;
+
+ TDataArrayHolder2(TVTKDataArray* theDataArray,
+ TVTKDataArray* theDataArray2):
+ TSuperClass(theDataArray),
+ myDataArray2(theDataArray2)
+ {}
+
+ virtual
+ void
+ SetTuple(vtkIdType theTupleId,
+ TVTKBasicType* thePointer)
+ {
+ this->WritePointer(this->myDataArray, theTupleId, thePointer);
+ this->WritePointer(this->myDataArray2, theTupleId, thePointer);
+ }
+ };
+
+
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ struct TTimeStampOnProfileInitArray
+ {
+ typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
+ typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
+ typedef TTMeshValue<TVTKBasicType> TMeshValue;
+ typedef MED::SharedPtr<TMeshValue> TMeshValuePtr;
+
+ typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
+ typedef MED::SharedPtr<TTDataArrayHolder> PDataArrayHolder;
+ PDataArrayHolder myDataArrayHolder;
+
+ TTimeStampOnProfileInitArray(const PDataArrayHolder& theDataArrayHolder):
+ myDataArrayHolder(theDataArrayHolder)
+ {}
+
+ void
+ Execute(const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime)
+ {
+ vtkIdType aNbComp = theField->myNbComp;
+ vtkIdType aSize = std::max(3, aNbComp);
+ TVector<TVTKBasicType> aDataValues(aSize);
+
+ const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
+ TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin();
+ for(int aTupleId = 0; anIter != aGeom2MeshValue.end(); anIter++){
+ EGeometry aEGeom = anIter->first;
+ const TMeshValuePtr aMeshValue = anIter->second;
+
+ vtkIdType aNbElem = aMeshValue->GetNbElem();
+ vtkIdType aNbGauss = aMeshValue->GetNbGauss();
+
+ INITMSG(MYDEBUG,
+ "- aEGeom = "<<aEGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ std::endl);
+
+ for(vtkIdType iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
+ typename TMeshValue::TCValueSliceArr aValueSliceArr = aMeshValue->GetCompValueSliceArr(iElem);
+ for(vtkIdType iComp = 0; iComp < aNbComp; iComp++){
+ const typename TMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[iComp];
+ aDataValues[iComp] = TVTKBasicType();
+ for(vtkIdType iGauss = 0; iGauss < aNbGauss; iGauss++){
+ aDataValues[iComp] += aValueSlice[iGauss];
+ }
+ aDataValues[iComp] /= aNbGauss;
+ }
+ this->myDataArrayHolder->SetTuple(aTupleId, &aDataValues[0]);
+ }
+ }
+ }
+ };
+
+
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ void
+ InitTimeStampOnProfile(const PUnstructuredGrid& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime,
+ const VISU::TEntity& theEntity)
+ {
+ vtkIdType aNbTuples = theField->myDataSize / theField->myNbComp;
+ std::string aFieldName = VISU::GenerateFieldName(theField, theValForTime);
+
+ vtkDataSetAttributes* aDataSetAttributes;
+ switch(theEntity){
+ case VISU::NODE_ENTITY :
+ aDataSetAttributes = theSource->GetPointData();
+ break;
+ default:
+ aDataSetAttributes = theSource->GetCellData();
+ }
+
+ typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
+ TVTKDataArray *aSelectedDataArray = TVTKDataArray::New();
+ vtkIdType aNbComp = theField->myNbComp;
+ switch(aNbComp) {
+ case 1:
+ aSelectedDataArray->SetNumberOfComponents(1);
+ aDataSetAttributes->SetScalars(aSelectedDataArray);
+ break;
+ default:
+ aSelectedDataArray->SetNumberOfComponents(3);
+ aDataSetAttributes->SetVectors(aSelectedDataArray);
+ }
+ aSelectedDataArray->SetNumberOfTuples(aNbTuples);
+ aSelectedDataArray->SetName(aFieldName.c_str());
+
+ TVTKDataArray *aFullDataArray = TVTKDataArray::New();
+ aFullDataArray->SetNumberOfComponents(aNbComp);
+ aFullDataArray->SetNumberOfTuples(aNbTuples);
+ aFullDataArray->SetName("VISU_FIELD");
+ aDataSetAttributes->AddArray(aFullDataArray);
+
+ INITMSG(MYDEBUG,"InitTimeStampOnProfile "<<
+ "- theEntity = "<<theEntity<<
+ "; aNbTuples = "<<aNbTuples<<
+ "; aNbComp = "<<aNbComp<<
+ std::endl);
+ TTimerLog aTimerLog(MYDEBUG,"InitTimeStampOnProfile");
+
+ const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
+ typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
+ typedef TTMeshValue<TVTKBasicType> TMeshValue;
+ typedef MED::SharedPtr<TMeshValue> TMeshValuePtr;
+
+ typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
+ typedef MED::SharedPtr<TTDataArrayHolder> PDataArrayHolder;
+
+ TMeshValuePtr aMeshValue = theValForTime->GetFirstMeshValue();
+ if(aGeom2MeshValue.size() == 1 && aMeshValue->GetNbGauss() == 1){
+ aFullDataArray->SetVoidArray(aMeshValue->GetPointer(),
+ aMeshValue->size(),
+ true);
+ INITMSG(MYDEBUG,"InitTimeStampOnProfile - aFullDataArray->SetVoidArray()"<<std::endl);
+ if(aNbComp == 1){
+ aSelectedDataArray->SetVoidArray(aMeshValue->GetPointer(),
+ aMeshValue->size(),
+ true);
+ INITMSG(MYDEBUG,"InitTimeStampOnProfile - aSelectedDataArray->SetVoidArray()"<<std::endl);
+ }else{
+ PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder(aSelectedDataArray));
+ TTimeStampOnProfileInitArray<EDataType>(aDataArrayHolder).Execute(theField, theValForTime);
+ }
+ }else{
+ typedef TDataArrayHolder2<EDataType> TTDataArrayHolder2;
+ PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder2(aSelectedDataArray, aFullDataArray));
+ TTimeStampOnProfileInitArray<EDataType>(aDataArrayHolder).Execute(theField, theValForTime);
+ }
+
+ aSelectedDataArray->Delete();
+ aFullDataArray->Delete();
+ }
+
+
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ void
+ InitTimeStampOnGaussMesh(const PPolyData& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime);
+
+ void
+ GetTimeStampOnGaussMesh(const PPolyData& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime)
+ {
+ vtkIdType aDataType = theField->GetDataType();
+ switch(aDataType){
+ case VTK_DOUBLE:
+ InitTimeStampOnGaussMesh<VTK_DOUBLE>(theSource, theField, theValForTime);
+ break;
+ case VTK_FLOAT:
+ InitTimeStampOnGaussMesh<VTK_FLOAT>(theSource, theField, theValForTime);
+ break;
+ case VTK_INT:
+ InitTimeStampOnGaussMesh<VTK_INT>(theSource, theField, theValForTime);
+ break;
+ case VTK_LONG:
+ InitTimeStampOnGaussMesh<VTK_LONG>(theSource, theField, theValForTime);
+ break;
+ default:
+ EXCEPTION(std::runtime_error,
+ "GetTimeStampOnGaussMesh - handling unsupported data type - "<<aDataType);
+ }
+ }
+
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ struct TTimeStampOnGaussMeshInitArray
+ {
+ typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
+ typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
+ typedef TTMeshValue<TVTKBasicType> TMeshValue;
+ typedef MED::SharedPtr<TMeshValue> TMeshValuePtr;
+
+ typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
+ typedef MED::SharedPtr<TTDataArrayHolder> PDataArrayHolder;
+ PDataArrayHolder myDataArrayHolder;
+
+ TTimeStampOnGaussMeshInitArray(const PDataArrayHolder& theDataArrayHolder):
+ myDataArrayHolder(theDataArrayHolder)
+ {}
+
+ void
+ Execute(const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime)
+ {
+ vtkIdType aNbComp = theField->myNbComp;
+ vtkIdType aSize = std::max(3, aNbComp);
+ TVector<TVTKBasicType> aDataValues(aSize);
+
+ const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
+
+ PGaussMeshImpl aGaussMesh = theValForTime->myGaussMesh;
+ const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
+ TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
+ for(int aTupleId = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
+ EGeometry aEGeom = anIter->first;
+
+ PGaussSubMeshImpl aGaussSubMesh = anIter->second;
+ if(!aGaussSubMesh->myIsDone)
+ continue;
+
+ TGeom2MeshValue::const_iterator anIter2 = aGeom2MeshValue.find(aEGeom);
+ if(anIter2 == aGeom2MeshValue.end()){
+ EXCEPTION(std::runtime_error,
+ "TTimeStampOnGaussMeshInitArray >> Can't find values for corresponding Gauss Points SubMesh");
+ }
+ TMeshValuePtr aMeshValue = anIter2->second;
+ vtkIdType aNbGauss = aMeshValue->GetNbGauss();
+ vtkIdType aNbElem = aMeshValue->GetNbElem();
+
+ if(aNbGauss < 1)
+ continue;
+
+ const TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
+
+ INITMSG(MYDEBUG,
+ "- aEGeom = "<<aEGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ "; aCoords.GetNbPoints() = "<<aCoords.GetNbPoints()<<
+ std::endl);
+
+ if(aCoords.GetNbPoints() == aNbElem*aNbGauss){
+ for(int iElem = 0; iElem < aNbElem; iElem++){
+ typename TMeshValue::TCValueSliceArr aValueSliceArr = aMeshValue->GetGaussValueSliceArr(iElem);
+ for(int iGauss = 0; iGauss < aNbGauss; iGauss++, aTupleId++){
+ const typename TMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
+ for(int iComp = 0; iComp < aNbComp; iComp++){
+ aDataValues[iComp] = aValueSlice[iComp];
+ }
+ this->myDataArrayHolder->SetTuple(aTupleId, &aDataValues[0]);
+ }
+ }
+ }else{
+ for(int iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
+ typename TMeshValue::TCValueSliceArr aValueSliceArr = aMeshValue->GetCompValueSliceArr(iElem);
+ for(int iComp = 0; iComp < aNbComp; iComp++){
+ const typename TMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[iComp];
+ aDataValues[iComp] = TVTKBasicType();
+ for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
+ aDataValues[iComp] += aValueSlice[iGauss];
+ }
+ aDataValues[iComp] /= aNbGauss;
+ }
+ this->myDataArrayHolder->SetTuple(aTupleId, &aDataValues[0]);
+ }
+ }
+ }
+ }
+ };
+
+
+ template<int EDataType>
+ void
+ InitTimeStampOnGaussMesh(const PPolyData& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime)
+ {
+ vtkIdType aNbTuples = theSource->GetNumberOfPoints();
+ std::string aFieldName = VISU::GenerateFieldName(theField, theValForTime);
+
+ vtkDataSetAttributes* aDataSetAttributes = theSource->GetPointData();
+
+ typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
+ TVTKDataArray *aSelectedDataArray = TVTKDataArray::New();
+ vtkIdType aNbComp = theField->myNbComp;
+ switch(aNbComp){
+ case 1:
+ aSelectedDataArray->SetNumberOfComponents(1);
+ aDataSetAttributes->SetScalars(aSelectedDataArray);
+ break;
+ default:
+ aSelectedDataArray->SetNumberOfComponents(3);
+ aDataSetAttributes->SetVectors(aSelectedDataArray);
+ }
+ aSelectedDataArray->SetNumberOfTuples(aNbTuples);
+ aSelectedDataArray->SetName(aFieldName.c_str());
+
+ TVTKDataArray *aFullDataArray = TVTKDataArray::New();
+ aFullDataArray->SetNumberOfComponents(aNbComp);
+ aFullDataArray->SetNumberOfTuples(aNbTuples);
+ aFullDataArray->SetName("VISU_FIELD");
+ aDataSetAttributes->AddArray(aFullDataArray);
+
+ INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh "<<
+ "- aNbTuples = "<<aNbTuples<<
+ "; aNbComp = "<<aNbComp<<
+ std::endl);
+ TTimerLog aTimerLog(MYDEBUG,"InitTimeStampOnGaussMesh");
+
+ const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
+ typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
+ typedef TTMeshValue<TVTKBasicType> TMeshValue;
+ typedef MED::SharedPtr<TMeshValue> TMeshValuePtr;
+
+ typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
+ typedef MED::SharedPtr<TTDataArrayHolder> PDataArrayHolder;
+
+ TMeshValuePtr aMeshValue = theValForTime->GetFirstMeshValue();
+ if(aGeom2MeshValue.size() == 1){
+ aFullDataArray->SetVoidArray(aMeshValue->GetPointer(),
+ aMeshValue->size(),
+ true);
+ INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh - aFullDataArray->SetVoidArray()"<<std::endl);
+ if(aNbComp == 1 || aNbComp == 3){
+ aSelectedDataArray->SetVoidArray(aMeshValue->GetPointer(),
+ aMeshValue->size(),
+ true);
+ INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh - aSelectedDataArray->SetVoidArray()"<<std::endl);
+ }else{
+ PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder(aSelectedDataArray));
+ TTimeStampOnGaussMeshInitArray<EDataType>(aDataArrayHolder).Execute(theField, theValForTime);
+ }
+ }else{
+ typedef TDataArrayHolder2<EDataType> TTDataArrayHolder2;
+ PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder2(aSelectedDataArray, aFullDataArray));
+ TTimeStampOnGaussMeshInitArray<EDataType>(aDataArrayHolder).Execute(theField, theValForTime);
+ }
+
+ aSelectedDataArray->Delete();
+ aFullDataArray->Delete();
+ }
+
+
+ //---------------------------------------------------------------
+}
--- /dev/null
+// VISU CONVERTOR :
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File : VISU_Convertor.hxx
+// Author : Alexey PETROV
+// Module : VISU
+
+#ifndef VISU_MeshValue_HeaderFile
+#define VISU_MeshValue_HeaderFile
+
+/*!
+ \file VISU_MeshValue.hxx
+ \brief The file contains declarations for basic interfaces that defines mesh value of mesh elements
+*/
+
+#include "VISU_Convertor.hxx"
+#include "VISU_ConvertorDef_impl.hxx"
+
+#include "MED_SliceArray.hxx"
+#include "MED_Vector.hxx"
+
+namespace VISU
+{
+ //---------------------------------------------------------------
+ //! Define a base class for the container to get access to data assigned to mesh
+ class TMeshValueBase
+ {
+ public:
+ //! To intitilize the data strucutre
+ void
+ Init(vtkIdType theNbElem,
+ vtkIdType theNbGauss,
+ vtkIdType theNbComp);
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize() const = 0;
+
+ //! Gets number of mesh elements where the data assigned to.
+ vtkIdType
+ GetNbElem() const;
+
+ //! Gets number of components of corresponding MED FIELD.
+ vtkIdType
+ GetNbComp() const;
+
+ //! Gets number of Gauss Points.
+ vtkIdType
+ GetNbGauss() const;
+
+ size_t
+ size() const;
+
+ protected:
+ vtkIdType myNbElem; //!< Defines number of mesh elements where the data assigned to
+ vtkIdType myNbComp; //!< Keeps number of components of corresponding MED FIELD
+ vtkIdType myNbGauss; //!< Defines number of Gauss Points
+ vtkIdType myStep; //!< Internal variable
+ };
+ typedef MED::SharedPtr<TMeshValueBase> PMeshValue;
+
+
+ //---------------------------------------------------------------
+ //! Define a container to get access to data assigned to mesh
+ template<class TValueType>
+ class TTMeshValue: public virtual TMeshValueBase
+ {
+ public:
+ typedef MED::TSlice<TValueType> TValueSlice;
+ typedef MED::TCSlice<TValueType> TCValueSlice;
+
+ typedef TVector<TCValueSlice> TCValueSliceArr;
+ typedef TVector<TValueSlice> TValueSliceArr;
+
+ virtual
+ const TValueType*
+ GetPointer() const = 0;
+
+ virtual
+ TValueType*
+ GetPointer() = 0;
+
+ //! To get assigned values first by Gauss Points and then by components (constant version)
+ TCValueSliceArr
+ GetGaussValueSliceArr(vtkIdType theElemId) const
+ {
+ TCValueSliceArr aValueSliceArr(this->myNbGauss);
+ vtkIdType anId = theElemId * this->myStep;
+ for(vtkIdType aGaussId = 0; aGaussId < this->myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TCValueSlice(this->GetPointer(),
+ this->size(),
+ std::slice(anId, this->myNbComp, 1));
+ anId += this->myNbComp;
+ }
+ return aValueSliceArr;
+ }
+
+ //! To get assigned values first by Gauss Points and then by components
+ TValueSliceArr
+ GetGaussValueSliceArr(vtkIdType theElemId)
+ {
+ TValueSliceArr aValueSliceArr(this->myNbGauss);
+ vtkIdType anId = theElemId * this->myStep;
+ for(vtkIdType aGaussId = 0; aGaussId < this->myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TValueSlice(this->GetPointer(),
+ this->size(),
+ std::slice(anId, this->myNbComp, 1));
+ anId += this->myNbComp;
+ }
+ return aValueSliceArr;
+ }
+
+ //! To get assigned values first by components and then by Gauss Points (constant version)
+ TCValueSliceArr
+ GetCompValueSliceArr(vtkIdType theElemId) const
+ {
+ TCValueSliceArr aValueSliceArr(this->myNbComp);
+ vtkIdType anId = theElemId * this->myStep;
+ for(vtkIdType aCompId = 0; aCompId < this->myNbComp; aCompId++){
+ aValueSliceArr[aCompId] =
+ TCValueSlice(this->GetPointer(),
+ this->size(),
+ std::slice(anId, this->myNbGauss, this->myNbComp));
+ anId += 1;
+ }
+ return aValueSliceArr;
+ }
+
+ //! To get assigned values first by components and then by Gauss Points
+ TValueSliceArr
+ GetCompValueSliceArr(vtkIdType theElemId)
+ {
+ TValueSliceArr aValueSliceArr(this->myNbComp);
+ vtkIdType anId = theElemId * this->myStep;
+ for(vtkIdType aCompId = 0; aCompId < this->myNbComp; aCompId++){
+ aValueSliceArr[aCompId] =
+ TValueSlice(this->GetPointer(),
+ this->size(),
+ std::slice(anId, this->myNbGauss, this->myNbComp));
+ anId += 1;
+ }
+ return aValueSliceArr;
+ }
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize() const
+ {
+ return this->size() * sizeof(TValueType);
+ }
+ };
+
+
+ //---------------------------------------------------------------
+ //! Define a container to get access to data assigned to mesh
+ template<class TValueType, class TContainerType>
+ class TTMeshValueHolder: public virtual TTMeshValue<TValueType>
+ {
+ public:
+ //! To initilize the class instance
+ void
+ Init(vtkIdType theNbElem,
+ vtkIdType theNbGauss,
+ vtkIdType theNbComp,
+ const TContainerType& theContainer)
+ {
+ TMeshValueBase::Init(theNbElem, theNbGauss, theNbComp);
+ myContainer = theContainer;
+ }
+
+ protected:
+ mutable TContainerType myContainer; //!< Keeps the mesh values container itself
+ };
+
+
+ //---------------------------------------------------------------
+ // Initilize corresponding vtkDataSetAttributes for TValForTime
+ void
+ GetTimeStampOnProfile(const PUnstructuredGrid& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime,
+ const VISU::TEntity& theEntity);
+
+
+ //---------------------------------------------------------------
+ // Initilize corresponding vtkDataSetAttributes for TValForTime
+ void
+ GetTimeStampOnGaussMesh(const PPolyData& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime);
+
+
+ //---------------------------------------------------------------
+}
+
+#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:
+// Author:
+// Module : VISU
+
+#include "VISU_PointCoords.hxx"
+#include "VISU_ConvertorUtils.hxx"
+
+#include <vtkUnstructuredGrid.h>
+#include <vtkPointData.h>
+#include <vtkIntArray.h>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+namespace VISU
+{
+ //---------------------------------------------------------------
+ void
+ TCoordHolderBase
+ ::Init(vtkIdType theNbPoints,
+ vtkIdType theDim)
+ {
+ myDim = theDim;
+ myNbPoints = theNbPoints;
+ }
+
+ vtkIdType
+ TCoordHolderBase
+ ::GetNbPoints() const
+ {
+ return myNbPoints;
+ }
+
+ vtkIdType
+ TCoordHolderBase
+ ::GetDim() const
+ {
+ return myDim;
+ }
+
+ size_t
+ TCoordHolderBase
+ ::size() const
+ {
+ return GetNbPoints() * GetDim();
+ }
+
+ unsigned long int
+ TCoordHolderBase
+ ::GetMemorySize()
+ {
+ return sizeof(TCoord) * size();
+ }
+
+
+ //---------------------------------------------------------------
+ TPointCoords
+ ::TPointCoords():
+ myPointSet(vtkUnstructuredGrid::New())
+ {
+ vtkPoints* aPoints = vtkPoints::New();
+ myPointSet->SetPoints(aPoints);
+ aPoints->SetDataType(VTK_DOUBLE);
+ aPoints->Delete();
+
+ myPointSet->Delete();
+ }
+
+ void
+ TPointCoords
+ ::Init(const PCoordHolder& theCoord)
+ {
+ myPointSet->GetPoints()->SetNumberOfPoints(theCoord->GetNbPoints());
+ myCoord = theCoord;
+ }
+
+ vtkIdType
+ TPointCoords
+ ::GetNbPoints() const
+ {
+ return myCoord->GetNbPoints();
+ }
+
+ vtkIdType
+ TPointCoords
+ ::GetDim() const
+ {
+ return myCoord->GetDim();
+ }
+
+ TCCoordSlice
+ TPointCoords
+ ::GetCoordSlice(vtkIdType theNodeId) const
+ {
+ return myCoord->GetCoordSlice(theNodeId);
+ }
+
+ TCoordSlice
+ TPointCoords
+ ::GetCoordSlice(vtkIdType theNodeId)
+ {
+ return myCoord->GetCoordSlice(theNodeId);
+ }
+
+ vtkIdType
+ TPointCoords
+ ::GetObjID(vtkIdType theID) const
+ {
+ return theID;
+ }
+
+ vtkIdType
+ TPointCoords
+ ::GetVTKID(vtkIdType theID) const
+ {
+ return theID;
+ }
+
+ void
+ TPointCoords
+ ::SetVoidArray() const
+ {
+ vtkDataArray* aDataArray = myPointSet->GetPoints()->GetData();
+ aDataArray->SetVoidArray(myCoord->GetValuePtr(), myCoord->size(), true);
+ }
+
+ vtkPointSet*
+ TPointCoords
+ ::GetPointSet() const
+ {
+ if(!myIsVTKDone){
+ TTimerLog aTimerLog(MYDEBUG,"TPointCoords::GetPoints()");
+ vtkIdType aNbPoints = GetNbPoints();
+ vtkIdType aDim = GetDim();
+
+ INITMSG(MYDEBUG,"TPointCoords::GetPoints - aNbPoints = "<<aNbPoints<<
+ "; aDim = "<<aDim<<
+ endl);
+
+ if(GetDim() == 3){
+ INITMSG(MYDEBUG,"TPointCoords::GetPoints - SetVoidArray()"<<endl);
+ SetVoidArray();
+ }else{
+ vtkPoints* aPoints = myPointSet->GetPoints();
+ for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
+ TCCoordSlice aSlice = GetCoordSlice(aPointId);
+
+ vtkFloatingPointType aCoords[3] = {0.0, 0.0, 0.0};
+ for(vtkIdType aDimId = 0; aDimId < aDim; aDimId++)
+ aCoords[aDimId] = aSlice[aDimId];
+
+ aPoints->SetPoint(aPointId, aCoords);
+ }
+ }
+
+ myIsVTKDone = true;
+ }
+
+ return myPointSet.GetPointer();
+ }
+
+ unsigned long int
+ TPointCoords
+ ::GetMemorySize()
+ {
+ size_t aSize = myCoord->GetMemorySize();
+ aSize += myPointSet->GetActualMemorySize() * 1024;
+ return aSize;
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ TNamedPointCoords
+ ::Init(const PCoordHolder& theCoord)
+ {
+ TPointCoords::Init(theCoord);
+ myPointsDim.resize(theCoord->GetDim());
+ }
+
+ std::string&
+ TNamedPointCoords
+ ::GetName(vtkIdType theDim)
+ {
+ return myPointsDim[theDim];
+ }
+
+ const std::string&
+ TNamedPointCoords
+ ::GetName(vtkIdType theDim) const
+ {
+ return myPointsDim[theDim];
+ }
+
+ std::string
+ TNamedPointCoords
+ ::GetNodeName(vtkIdType theObjID) const
+ {
+ return "";
+ }
+
+
+ //---------------------------------------------------------------
+ enum ECoordName{eX, eY, eZ, eNoneCoord};
+ typedef VISU::TCoord (*TGetCoord)(const VISU::TCCoordSlice& theCoordSlice);
+
+ template<ECoordName TCoordId>
+ VISU::TCoord
+ GetCoord(const VISU::TCCoordSlice& theCoordSlice)
+ {
+ return theCoordSlice[TCoordId];
+ }
+
+ template<>
+ VISU::TCoord
+ GetCoord<eNoneCoord>(const VISU::TCCoordSlice& theCoordSlice)
+ {
+ return 0.0;
+ }
+
+
+ TGetCoord aXYZGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eY>,
+ &GetCoord<eZ>
+ };
+
+
+ TGetCoord aXYGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eY>,
+ &GetCoord<eNoneCoord>
+ };
+
+ TGetCoord aYZGetCoord[3] = {
+ &GetCoord<eNoneCoord>,
+ &GetCoord<eX>,
+ &GetCoord<eY>
+ };
+
+ TGetCoord aXZGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eNoneCoord>,
+ &GetCoord<eY>
+ };
+
+
+ TGetCoord aXGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eNoneCoord>,
+ &GetCoord<eNoneCoord>
+ };
+
+ TGetCoord aYGetCoord[3] = {
+ &GetCoord<eNoneCoord>,
+ &GetCoord<eX>,
+ &GetCoord<eNoneCoord>
+ };
+
+ TGetCoord aZGetCoord[3] = {
+ &GetCoord<eNoneCoord>,
+ &GetCoord<eNoneCoord>,
+ &GetCoord<eX>
+ };
+
+
+ class TCoordHelper{
+ TGetCoord* myGetCoord;
+ public:
+ TCoordHelper(TGetCoord* theGetCoord):
+ myGetCoord(theGetCoord)
+ {}
+
+ virtual
+ ~TCoordHelper()
+ {}
+
+ VISU::TCoord
+ GetCoord(VISU::TCCoordSlice& theCoordSlice,
+ int theCoordId)
+ {
+ return (*myGetCoord[theCoordId])(theCoordSlice);
+ }
+ };
+ typedef std::auto_ptr<TCoordHelper> TCoordHelperPtr;
+
+
+ //---------------------------------------------------------------
+ vtkPointSet*
+ TNamedPointCoords
+ ::GetPointSet() const
+ {
+ if(!myIsVTKDone){
+ TTimerLog aTimerLog(MYDEBUG,"TNamedPointCoords::GetPoints()");
+ TCoordHelperPtr aCoordHelperPtr;
+ bool anIsDimPresent[3] = {false, false, false};
+ for(int iDim = 0; iDim < GetDim(); iDim++){
+ std::string aName = GetName(iDim);
+ if ( aName.size() > 1 ) // PAL13021 (PAL12148), aName has size 8 or 16
+ aName = aName.substr(0,1);
+ if(aName == "x" || aName == "X")
+ anIsDimPresent[eX] = true;
+ else if(aName == "y" || aName == "Y")
+ anIsDimPresent[eY] = true;
+ else if(aName == "z" || aName == "Z")
+ anIsDimPresent[eZ] = true;
+ }
+
+ switch(GetDim()){
+ case 3:
+ aCoordHelperPtr.reset(new TCoordHelper(aXYZGetCoord));
+ break;
+ case 2:
+ if(anIsDimPresent[eY] && anIsDimPresent[eZ])
+ aCoordHelperPtr.reset(new TCoordHelper(aYZGetCoord));
+ else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
+ aCoordHelperPtr.reset(new TCoordHelper(aXZGetCoord));
+ else
+ aCoordHelperPtr.reset(new TCoordHelper(aXYGetCoord));
+ break;
+ case 1:
+ if(anIsDimPresent[eY])
+ aCoordHelperPtr.reset(new TCoordHelper(aYGetCoord));
+ else if(anIsDimPresent[eZ])
+ aCoordHelperPtr.reset(new TCoordHelper(aZGetCoord));
+ else
+ aCoordHelperPtr.reset(new TCoordHelper(aXGetCoord));
+ break;
+ }
+
+ INITMSG(MYDEBUG,"TNamedPointCoords::GetPoints - aNbPoints = "<<GetNbPoints()<<
+ "; aDim = "<<GetDim()<<
+ endl);
+
+ if(anIsDimPresent[eX] && anIsDimPresent[eY] && anIsDimPresent[eZ]){
+ INITMSG(MYDEBUG,"TNamedPointCoords::GetPoints - SetVoidArray()"<<endl);
+ SetVoidArray();
+ }else{
+ vtkPoints* aPoints = myPointSet->GetPoints();
+ for(vtkIdType aNodeId = 0; aNodeId < GetNbPoints(); aNodeId++){
+ TCCoordSlice aCoordSlice = GetCoordSlice(aNodeId);
+ aPoints->SetPoint(aNodeId,
+ aCoordHelperPtr->GetCoord(aCoordSlice,eX),
+ aCoordHelperPtr->GetCoord(aCoordSlice,eY),
+ aCoordHelperPtr->GetCoord(aCoordSlice,eZ));
+ }
+ }
+
+ {
+ vtkIdType aNbTuples = GetNbPoints();
+ int anEntity = int(VISU::NODE_ENTITY);
+ vtkIntArray *aDataArray = vtkIntArray::New();
+ aDataArray->SetName("VISU_POINTS_MAPPER");
+ aDataArray->SetNumberOfComponents(2);
+ aDataArray->SetNumberOfTuples(aNbTuples);
+ int *aPtr = aDataArray->GetPointer(0);
+ for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
+ vtkIdType anObjID = GetObjID(aTupleId);
+ *aPtr++ = anObjID;
+ *aPtr++ = anEntity;
+ }
+ myPointSet->GetPointData()->AddArray(aDataArray);
+ aDataArray->Delete();
+ }
+
+ myIsVTKDone = true;
+ }
+
+ return myPointSet.GetPointer();
+ }
+
+ unsigned long int
+ TNamedPointCoords
+ ::GetMemorySize()
+ {
+ return TPointCoords::GetMemorySize();
+ }
+
+
+ //---------------------------------------------------------------
+}
--- /dev/null
+// VISU CONVERTOR :
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File : VISU_Convertor.hxx
+// Author : Alexey PETROV
+// Module : VISU
+
+#ifndef VISU_PointCoords_HeaderFile
+#define VISU_PointCoords_HeaderFile
+
+/*!
+ \file VISU_PointCoords.hxx
+ \brief The file contains declarations for basic interfaces that defines point coords of mesh elements
+*/
+
+#include "VISU_Convertor.hxx"
+#include "VISU_ConvertorDef_impl.hxx"
+
+#include "MED_SliceArray.hxx"
+#include "MED_Structures.hxx"
+
+#include <vtkSmartPointer.h>
+
+class vtkPointSet;
+
+namespace VISU
+{
+ //---------------------------------------------------------------
+ typedef vtkSmartPointer<vtkPointSet> PPointSet;
+
+ typedef MED::TFloat TCoord;
+ using MED::TCoordSlice;
+ using MED::TCCoordSlice;
+
+ //---------------------------------------------------------------
+ //! This class is responsible for keeping the mesh node coordinates
+ class TCoordHolderBase: public virtual TBaseStructure
+ {
+ public:
+ //! To initilize the instance
+ void
+ Init(vtkIdType theNbPoints,
+ vtkIdType theDim);
+
+ vtkIdType
+ GetNbPoints() const;
+
+ vtkIdType
+ GetDim() const;
+
+ size_t
+ size() const;
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ //! Get slice of coordinates for defined node (const version)
+ virtual
+ TCCoordSlice
+ GetCoordSlice(vtkIdType theNodeId) const = 0;
+
+ //! Get slice of coordinates for defined node
+ virtual
+ TCoordSlice
+ GetCoordSlice(vtkIdType theNodeId) = 0;
+
+ virtual
+ unsigned char*
+ GetValuePtr() = 0;
+
+ protected:
+ vtkIdType myDim; //!< Dimension of the nodal coordinates
+ vtkIdType myNbPoints; //!< Number of nodes in corresponding mesh
+ };
+ typedef MED::SharedPtr<TCoordHolderBase> PCoordHolder;
+
+
+ //---------------------------------------------------------------
+ template<class TContainerType>
+ class TCoordHolder: public virtual TCoordHolderBase
+ {
+ public:
+ //! To initilize the class instance
+ void
+ Init(vtkIdType theNbPoints,
+ vtkIdType theDim,
+ const TContainerType& theCoord)
+ {
+ TCoordHolderBase::Init(theNbPoints, theDim);
+ myCoord = theCoord;
+ }
+
+ //! Gets pointer to the first element in the node coordinates array
+ virtual
+ TCoord*
+ GetPointer() = 0;
+
+ //! Gets pointer to the first element in the node coordinates array (const version)
+ virtual
+ const TCoord*
+ GetPointer() const = 0;
+
+ //! Get slice of coordinates for defined node (const version)
+ virtual
+ TCCoordSlice
+ GetCoordSlice(vtkIdType theNodeId) const
+ {
+ return TCCoordSlice(this->GetPointer(),
+ this->size(),
+ std::slice(theNodeId * this->GetDim(), this->GetDim(), 1));
+ }
+
+ //! Get slice of coordinates for defined node
+ virtual
+ TCoordSlice
+ GetCoordSlice(vtkIdType theNodeId)
+ {
+ return TCoordSlice(this->GetPointer(),
+ this->size(),
+ std::slice(theNodeId * this->GetDim(), this->GetDim(), 1));
+ }
+
+ virtual
+ unsigned char*
+ GetValuePtr()
+ {
+ return (unsigned char*)this->GetPointer();
+ }
+
+ protected:
+ mutable TContainerType myCoord; //!< Keeps the node coordinates container itself
+ };
+
+
+ //---------------------------------------------------------------
+ //! This class is responsible for representation of mesh nodes
+ class TPointCoords: public virtual TIsVTKDone
+ {
+ public:
+ TPointCoords();
+
+ //! To initilize the class
+ void
+ Init(const PCoordHolder& theCoord);
+
+ vtkIdType
+ GetNbPoints() const;
+
+ vtkIdType
+ GetDim() const;
+
+ virtual
+ vtkPointSet*
+ GetPointSet() const; //!< Gets corresponding VTK structure
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ //! Get slice of coordinates for defined node (const version)
+ TCCoordSlice
+ GetCoordSlice(vtkIdType theNodeId) const;
+
+ //! Get slice of coordinates for defined node
+ TCoordSlice
+ GetCoordSlice(vtkIdType theNodeId);
+
+ //! Get object number for node by its VTK one
+ virtual
+ vtkIdType
+ GetObjID(vtkIdType theID) const;
+
+ //! Get VTK number for node by its object one
+ virtual
+ vtkIdType
+ GetVTKID(vtkIdType theID) const;
+
+ protected:
+ //! An container for coordinates of the nodes
+ /*!
+ Usage of slices allow to minimize amount of memory to store the nodal coordinates and
+ provide unifirm way of conversation with this coordinates (independant from mesh dimension)
+ */
+ PCoordHolder myCoord; //!< A pointer to the coordinates container holder
+ PPointSet myPointSet; //!< VTK representation for the mesh nodes
+
+ void
+ SetVoidArray() const; //!< Passes the MED node coordinates data directly to VTK
+ };
+
+
+ //---------------------------------------------------------------
+ //! This class is responsible for representation of mesh nodes
+ /*!
+ In additition to its base functionlity it support mapping of VTK to object numeration and
+ keeps names for each of nodes.
+ */
+ class TNamedPointCoords: public virtual TPointCoords
+ {
+ public:
+ //! To initilize the class (numeration of the nodes can be missed)
+ void
+ Init(const PCoordHolder& theCoord);
+
+ //! Get name for defined dimension
+ std::string&
+ GetName(vtkIdType theDim);
+
+ //! Get name for defined dimension (const version)
+ const std::string&
+ GetName(vtkIdType theDim) const;
+
+ //! Get name of node by its object number
+ virtual
+ std::string
+ GetNodeName(vtkIdType theObjID) const;
+
+ virtual
+ vtkPointSet*
+ GetPointSet() const; //!< Gets initialized corresponding VTK structure
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ protected:
+ typedef TVector<std::string> TPointsDim;
+ TPointsDim myPointsDim; //!< Keeps name of each dimension
+ };
+
+
+ //---------------------------------------------------------------
+}
+
+#endif
--- /dev/null
+//
+//
+// 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: Alexey PETROV
+// Module : VISU
+
+#include "VISU_Structures.hxx"
+
+
+namespace VISU
+{
+ //---------------------------------------------------------------
+ TIntId
+ ::TIntId():
+ myId(0)
+ {}
+
+
+ //---------------------------------------------------------------
+ TIsVTKDone
+ ::TIsVTKDone():
+ myIsVTKDone(false),
+ myIsDone(false)
+ {}
+
+
+ //---------------------------------------------------------------
+ TMesh
+ ::TMesh():
+ myDim(0)
+ {}
+
+
+ //---------------------------------------------------------------
+ TMeshOnEntity
+ ::TMeshOnEntity():
+ myEntity(TEntity(-1))
+ {}
+
+
+ //---------------------------------------------------------------
+ TFamily
+ ::TFamily():
+ myEntity(TEntity(-1))
+ {}
+
+
+ //---------------------------------------------------------------
+ TField
+ ::TField():
+ myNbComp(0),
+ myEntity(TEntity(-1)),
+ myIsMinMaxInitilized(false)
+ {}
+
+
+ //---------------------------------------------------------------
+
+ // MULTIPR
+ TPart
+ ::TPart():
+ myCurrentRes(0)
+ {}
+
+}
--- /dev/null
+//
+//
+// 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 : Alexey PETROV
+// Module : VISU
+
+#ifndef VISU_Structures_HeaderFile
+#define VISU_Structures_HeaderFile
+
+/*!
+ \file VISU_Structures.hxx
+ \brief The file contains definitions for basic classes of the VISU CONVERTER package
+*/
+
+#include "VISU_IDMapper.hxx"
+#include "VISU_ConvertorDef.hxx"
+
+#include "MED_Vector.hxx"
+
+#include <map>
+#include <set>
+#include <string>
+#include <stdexcept>
+
+namespace VISU
+{
+ using MED::TVector;
+
+ //---------------------------------------------------------------
+ typedef std::string TName;
+ typedef TVector<TName> TNames;
+
+ //---------------------------------------------------------------
+ //! Define a basic class for all MED entites which can be identified by its number
+ struct TIntId: virtual TBaseStructure
+ {
+ vtkIdType myId;
+
+ TIntId();
+ };
+
+
+ //---------------------------------------------------------------
+ //! Define an utility base class which is repsonsible for preventing repetion
+ struct TIsVTKDone: virtual TBaseStructure
+ {
+ mutable bool myIsDone; //!< Say, is the corresponding MED entity already loaded into intermediate data structure
+ mutable bool myIsVTKDone; //!< Say, is the corresponding intermediate data structure already mapped into VTK representation
+
+ TIsVTKDone();
+ };
+
+
+ //---------------------------------------------------------------
+ typedef std::map<TEntity, PMeshOnEntity> TMeshOnEntityMap;
+ typedef std::map<TName, PGroup> TGroupMap;
+
+ //! Define a basic class which corresponds to MED MESH entity
+ /*!
+ This class in its turn contains map of TMeshOnEntity and TGroup substructures,
+ also it keeps name and dimention of corresponding MED MESH entity.
+ */
+ struct TMesh: virtual TBaseStructure
+ {
+ TMeshOnEntityMap myMeshOnEntityMap; //!< Contains corresponding meshes for MED ENTITIES
+ TGroupMap myGroupMap; //!< Contains map of bounded MED GROUPS
+ TName myName; //! Name of the corresponding MED MESH
+ vtkIdType myDim; //! Dimension of the corresponding MED MESH
+
+ std::string myGroupsEntry; //!< To simplify publication of the groups in a data tree
+ std::string myFieldsEntry; //!< To simplify publication of the fiels in a data tree
+
+ // MULTIPR
+ std::string myPartsEntry; //!< To simplify publication of the parts in a data tree
+
+ TMesh();
+ };
+ typedef std::map<std::string, PMesh> TMeshMap;
+
+
+ //---------------------------------------------------------------
+ //! Define a basic class which corresponds to MED PROFILE entity
+ struct TSubProfile: virtual TBaseStructure
+ {};
+
+
+ //---------------------------------------------------------------
+ //! Define a containerfor MED PROFILE entities which belongs to the same MED ENTITY
+ struct TProfile: virtual TNamedIDMapper
+ {};
+
+
+ //---------------------------------------------------------------
+ bool
+ operator<(const PSubProfile& theLeft, const PSubProfile& theRight);
+
+ typedef std::set<PSubProfile> TProfileKey;
+ typedef std::map<TProfileKey, PProfile> TProfileMap;
+
+
+ //---------------------------------------------------------------
+ //! Define a basic class for MED GAUSS entity
+ struct TGauss: virtual TBaseStructure
+ {};
+
+
+ //---------------------------------------------------------------
+ //! Define a container for mesh generated from MED GAUSS and corresponding MED PROFILE
+ struct TGaussSubMesh: virtual TBaseStructure
+ {
+ PSubProfile mySubProfile; //!< Keeps reference on what submesh the Gauss Points are located
+ };
+
+
+ //---------------------------------------------------------------
+ //! Define a container for all TGaussSubMesh that belongs to the same MED ENTITY
+ struct TGaussMesh: virtual TGaussPtsIDMapper
+ {};
+
+
+ //---------------------------------------------------------------
+ bool
+ operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight);
+
+ typedef std::set<PGaussSubMesh> TGaussKey;
+ typedef std::map<TGaussKey, PGaussMesh> TGaussMeshMap;
+
+
+ //---------------------------------------------------------------
+
+ typedef std::map<TName, PFamily> TFamilyMap;
+ typedef std::map<TName, PField> TFieldMap;
+
+ //! Define a basic class which corresponds to MED ENTITY
+ /*!
+ This class in its turn contains map of TGaussMesh and TProfile substructures,
+ also it keeps corresponding map of MED FAMILIES and FIELDS.
+ */
+ struct TMeshOnEntity: virtual TNamedIDMapper
+ {
+ TGaussMeshMap myGaussMeshMap; //!< Contains map of Gauss mesh which exist on it
+ TProfileMap myProfileMap; //!< Contains map of Profile mesh which exist on it
+
+ TFamilyMap myFamilyMap; //!< Contains map of MED FAMILIES which belongs to it
+ TFieldMap myFieldMap; //!< Contains map of MED FIELDS which belongs to it
+
+ TName myMeshName; //!< Contains name of the MED MESH where the it belongs to.
+ TEntity myEntity; //!< Referes to MED ENTITY where the it belongs to.
+
+ TMeshOnEntity();
+ };
+
+
+ //---------------------------------------------------------------
+ //! Define a basic class for MED FAMILY entity
+ struct TFamily: virtual TIntId,
+ virtual TUnstructuredGridIDMapper
+ {
+ TEntity myEntity; //!< Referes to MED ENTITY where the TFamily belongs to.
+ TName myName; //!< Contains name of the corresponding MED FAMILY
+
+ TFamily();
+ };
+
+
+ //---------------------------------------------------------------
+ typedef std::set<PFamily> TFamilySet;
+
+ //! Define a basic class for MED GROUP entity
+ struct TGroup: virtual TUnstructuredGridIDMapper
+ {
+ TFamilySet myFamilySet;
+ };
+
+
+ //---------------------------------------------------------------
+ typedef std::map<vtkIdType, PValForTime> TValField;
+ typedef std::pair<vtkFloatingPointType, vtkFloatingPointType> TMinMax;
+
+ //! Define a basic class for MED FIELD entity
+ struct TField: virtual TIntId
+ {
+ TEntity myEntity; //!< Referes to MED ENTITY where it belongs to.
+ TName myName; //!< Contains name of the corresponding MED FIELD
+ TName myMeshName; //!< Contains name of the MED MESH where it belongs to.
+ TValField myValField; //!< Contains sequence of values for corresponding MED TIMESTAMPS
+ TNames myCompNames; //!< Contains names of components of the MED FIELD
+ TNames myUnitNames; //!< Contains names of units of the MED FIELD
+ vtkIdType myNbComp; //!< Keeps number of components for the MED FIELD
+
+ //! Calculate min/max values for each of the MED FIELD components among all its timestamps
+ /*!
+ Numeration of the components starts from 1.
+ Zero component contains min/max value for modulus of corresponding vector
+ */
+ virtual
+ TMinMax
+ GetMinMax(vtkIdType theCompID) = 0;
+
+ bool myIsMinMaxInitilized; //!< Is the min / max values are calculated
+
+ TField();
+ };
+
+ // MULTIPR
+ struct TPart: virtual TIntId
+ {
+ vtkIdType myCurrentRes; //!< Keeps current resolution fot this part
+
+ TPart();
+ };
+
+
+ //---------------------------------------------------------------
+ typedef std::pair<double, std::string> TTime;
+
+ //! Define a basic class for MED TIMESTAMP entity
+ struct TValForTime: virtual TIntId
+ {
+ TEntity myEntity; //!< Referes to MED ENTITY where it belongs to.
+ TName myMeshName; //!< Contains name of the MED MESH where it belongs to.
+ TName myFieldName; //!< Contains name of the MED FIELD where it belongs to.
+ TTime myTime;
+
+ PProfile myProfile; //!< Contains corresponding MED PROFILE where the MED TIEMSTMAP attached to
+ PGaussMesh myGaussMesh;
+ };
+
+
+ //---------------------------------------------------------------
+}
+
+
+#endif
--- /dev/null
+//
+//
+// 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: Alexey PETROV
+// Module : VISU
+
+#include "VISU_Structures_impl.hxx"
+#include "VISU_PointCoords.hxx"
+#include "VISU_MeshValue.hxx"
+
+#include "VISU_AppendFilter.hxx"
+#include "VISU_AppendPolyData.hxx"
+#include "VISU_MergeFilter.hxx"
+
+#include "VISU_ConvertorUtils.hxx"
+
+#include <vtkUnstructuredGrid.h>
+#include <vtkPolyData.h>
+#include <vtkCellType.h>
+
+namespace VISU
+{
+ //---------------------------------------------------------------
+ /*! Computes number of points by the given number of cells
+ * in assumption of regular hexahedral mesh structure
+ */
+ size_t
+ GetNumberOfPoints(size_t theNbCells)
+ {
+ return size_t(pow(pow(theNbCells, 1.0/3.0) + 1.0, 3.0));
+ }
+
+ //---------------------------------------------------------------
+ /*! Computes size dataset the given number of mesh macro metrics
+ * in assumption of regular hexahedral mesh structure
+ */
+ size_t
+ GetDataSetSize(size_t theNbOfPoints,
+ size_t theNbOfCells,
+ size_t theCellsSize,
+ bool theComputeLinks)
+ {
+ size_t aPointsSize = 3*theNbOfPoints*sizeof(VISU::TCoord);
+ size_t aConnectivityAndTypesSize = theCellsSize*sizeof(vtkIdType);
+ size_t aLocationsSize = theNbOfCells*sizeof(int);
+ vtkFloatingPointType aNbCellsPerPoint = theCellsSize / theNbOfCells - 1;
+ size_t aLinksSize = theNbOfPoints * (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
+ if(!theComputeLinks)
+ aLinksSize = 0;
+ size_t aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
+ return aResult;
+ }
+
+ //---------------------------------------------------------------
+ TSizeCounter
+ ::TSizeCounter():
+ myNbCells(0),
+ myCellsSize(0)
+ {}
+
+
+ //---------------------------------------------------------------
+ TPolyDataHolder
+ ::TPolyDataHolder()
+ {}
+
+ const PPolyData&
+ TPolyDataHolder
+ ::GetSource() const
+ {
+ if(!mySource.GetPointer()){
+ mySource = vtkPolyData::New();
+ mySource->Delete();
+ }
+ return mySource;
+ }
+
+ vtkPolyData*
+ TPolyDataHolder
+ ::GetPolyDataOutput()
+ {
+ return GetSource().GetPointer();
+ }
+
+ unsigned long int
+ TPolyDataHolder
+ ::GetMemorySize()
+ {
+ if(vtkDataSet* anOutput = GetPolyDataOutput()){
+ anOutput->Update();
+ return anOutput->GetActualMemorySize() * 1024;
+ }
+ if(myIsDone){
+ size_t aNbPoints = GetNumberOfPoints(myNbCells);
+ return GetDataSetSize(aNbPoints, myNbCells, myCellsSize, false);
+ }
+ throw std::runtime_error("TUnstructuredGridHolder::GetMemorySize - myIsDone == false !!!");
+ return 0;
+ }
+
+ //---------------------------------------------------------------
+ TUnstructuredGridHolder
+ ::TUnstructuredGridHolder()
+ {}
+
+ const PUnstructuredGrid&
+ TUnstructuredGridHolder
+ ::GetSource() const
+ {
+ if(!mySource.GetPointer()){
+ mySource = vtkUnstructuredGrid::New();
+ mySource->Delete();
+ }
+ return mySource;
+ }
+
+ vtkUnstructuredGrid*
+ TUnstructuredGridHolder
+ ::GetUnstructuredGridOutput()
+ {
+ return GetSource().GetPointer();
+ }
+
+ unsigned long int
+ TUnstructuredGridHolder
+ ::GetMemorySize()
+ {
+ if(vtkDataSet* anOutput = GetUnstructuredGridOutput()){
+ anOutput->Update();
+ return anOutput->GetActualMemorySize() * 1024;
+ }
+ if(myIsDone){
+ size_t aNbPoints = GetNumberOfPoints(myNbCells);
+ return GetDataSetSize(aNbPoints, myNbCells, myCellsSize, false);
+ }
+ throw std::runtime_error("TUnstructuredGridHolder::GetMemorySize - myIsDone == false !!!");
+ return 0;
+ }
+
+
+ //---------------------------------------------------------------
+ unsigned long int
+ TMemoryCheckIDMapper
+ ::GetMemorySize()
+ {
+ if(myIsVTKDone){
+ if(vtkDataSet* anOutput = GetOutput()){
+ anOutput->Update();
+ return anOutput->GetActualMemorySize() * 1024;
+ }
+ }
+ throw std::runtime_error("TMemoryCheckIDMapper::GetMemorySize - myIsVTKDone == false !!!");
+ return 0;
+ }
+
+
+ //---------------------------------------------------------------
+ TAppendFilterHolder
+ ::TAppendFilterHolder()
+ {}
+
+ const PAppendFilter&
+ TAppendFilterHolder
+ ::GetFilter() const
+ {
+ if(!myFilter.GetPointer()){
+ myFilter = VISU_AppendFilter::New();
+ myFilter->Delete();
+ myFilter->SetMappingInputs(true);
+ }
+ return myFilter;
+ }
+
+ vtkUnstructuredGrid*
+ TAppendFilterHolder
+ ::GetUnstructuredGridOutput()
+ {
+ GetFilter()->Update();
+ return GetFilter()->GetOutput();
+ }
+
+ //---------------------------------------------------------------
+ TAppendPolyDataHolder
+ ::TAppendPolyDataHolder()
+ {}
+
+ const PAppendPolyData&
+ TAppendPolyDataHolder
+ ::GetFilter() const
+ {
+ if(!myFilter.GetPointer()){
+ myFilter = VISU_AppendPolyData::New();
+ myFilter->SetMappingInputs(true);
+ myFilter->Delete();
+ }
+ return myFilter;
+ }
+
+ vtkPolyData*
+ TAppendPolyDataHolder
+ ::GetPolyDataOutput()
+ {
+ GetFilter()->Update();
+ return GetFilter()->GetOutput();
+ }
+
+
+ //---------------------------------------------------------------
+ TMergeFilterHolder
+ ::TMergeFilterHolder()
+ {}
+
+ const PMergeFilter&
+ TMergeFilterHolder
+ ::GetFilter() const
+ {
+ if(!myFilter.GetPointer()){
+ myFilter = VISU_MergeFilter::New();
+ myFilter->Delete();
+ }
+ return myFilter;
+ }
+
+ vtkDataSet*
+ TMergeFilterHolder
+ ::GetOutput()
+ {
+ GetFilter()->Update();
+ return GetFilter()->GetOutput();
+ }
+
+
+ //---------------------------------------------------------------
+ TMeshImpl
+ ::TMeshImpl():
+ myNbPoints(0)
+ {}
+
+ vtkIdType
+ TMeshImpl::
+ GetNbPoints() const
+ {
+ return myNbPoints;
+ }
+
+ vtkIdType
+ TMeshImpl::
+ GetDim() const
+ {
+ return myDim;
+ }
+
+ vtkPointSet*
+ TMeshImpl::
+ GetPointSet()
+ {
+ return myNamedPointCoords->GetPointSet();
+ }
+
+
+ //---------------------------------------------------------------
+ TSubProfileImpl::TSubProfileImpl():
+ myStatus(eNone),
+ myGeom(eNONE)
+ {}
+
+
+ vtkIdType
+ TSubProfileImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ return theID;
+ }
+
+ unsigned long int
+ TSubProfileImpl
+ ::GetMemorySize()
+ {
+ size_t aSize = TUnstructuredGridHolder::GetMemorySize();
+ aSize += sizeof(vtkIdType) * mySubMeshID.size();
+ return aSize;
+ }
+
+
+ //---------------------------------------------------------------
+ bool
+ operator<(const PSubProfile& theLeft, const PSubProfile& theRight)
+ {
+ PSubProfileImpl aLeft(theLeft), aRight(theRight);
+
+ if(aLeft->myGeom != aRight->myGeom)
+ return aLeft->myGeom < aRight->myGeom;
+
+ if(aLeft->myStatus != aRight->myStatus)
+ return aLeft->myStatus < aRight->myStatus;
+
+ return aLeft->myName < aRight->myName;
+ }
+
+
+ //---------------------------------------------------------------
+ TProfileImpl
+ ::TProfileImpl():
+ myIsAll(true),
+ myMeshOnEntity(NULL)
+ {}
+
+ vtkIdType
+ TProfileImpl
+ ::GetNodeObjID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetObjID(theID);
+ }
+
+ vtkIdType
+ TProfileImpl
+ ::GetNodeVTKID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetVTKID(theID);
+ }
+
+ vtkFloatingPointType*
+ TProfileImpl
+ ::GetNodeCoord(vtkIdType theObjID)
+ {
+ if(myIsAll)
+ return myMeshOnEntity->GetNodeCoord(theObjID);
+
+ vtkIdType aVtkID = GetNodeVTKID(theObjID);
+ return GetFilter()->GetOutput()->GetPoint(aVtkID);
+ }
+
+ vtkIdType
+ TProfileImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ return VISU::GetElemObjID(GetFilter()->GetOutput(), theID);
+ }
+
+ vtkIdType
+ TProfileImpl
+ ::GetElemVTKID(vtkIdType theID) const
+ {
+ return VISU::GetElemVTKID(GetFilter()->GetOutput(), theID);
+ }
+
+ vtkCell*
+ TProfileImpl
+ ::GetElemCell(vtkIdType theObjID)
+ {
+ if(myIsAll)
+ return myMeshOnEntity->GetElemCell(theObjID);
+
+ vtkIdType aVtkID = GetElemVTKID(theObjID);
+ return GetFilter()->GetOutput()->GetCell(aVtkID);
+ }
+
+ vtkUnstructuredGrid*
+ TProfileImpl
+ ::GetUnstructuredGridOutput()
+ {
+ const PAppendFilter& anAppendFilter = GetFilter();
+ return anAppendFilter->GetOutput();
+ }
+
+ unsigned long int
+ TProfileImpl
+ ::GetMemorySize()
+ {
+ size_t aSize = TAppendFilterHolder::GetMemorySize();
+ aSize += myNamedPointCoords->GetMemorySize();
+ aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType);
+ TGeom2SubProfile::const_iterator anIter = myGeom2SubProfile.begin();
+ TGeom2SubProfile::const_iterator anIterEnd = myGeom2SubProfile.end();
+ for(; anIter != anIterEnd; anIter++){
+ const PSubProfileImpl& aSubProfile = anIter->second;
+ aSize += aSubProfile->GetMemorySize();
+ aSize += sizeof(EGeometry);
+ }
+ return aSize;
+ }
+
+ std::string
+ TProfileImpl
+ ::GetNodeName(vtkIdType theObjID) const
+ {
+ return myNamedPointCoords->GetNodeName(theObjID);
+ }
+
+ std::string
+ TProfileImpl
+ ::GetElemName(vtkIdType theObjID) const
+ {
+ return myMeshOnEntity->GetElemName(theObjID);
+ }
+
+
+ //---------------------------------------------------------------
+ vtkIdType
+ TUnstructuredGridIDMapperImpl
+ ::GetNodeObjID(vtkIdType theID) const
+ {
+ return myIDMapper->GetNodeObjID(theID);
+ }
+
+ vtkIdType
+ TUnstructuredGridIDMapperImpl
+ ::GetNodeVTKID(vtkIdType theID) const
+ {
+ return myIDMapper->GetNodeVTKID(theID);
+ }
+
+ vtkFloatingPointType*
+ TUnstructuredGridIDMapperImpl
+ ::GetNodeCoord(vtkIdType theObjID)
+ {
+ return myIDMapper->GetNodeCoord(theObjID);
+ }
+
+ vtkIdType
+ TUnstructuredGridIDMapperImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ return myIDMapper->GetElemObjID(theID);
+ }
+
+ vtkIdType
+ TUnstructuredGridIDMapperImpl
+ ::GetElemVTKID(vtkIdType theID) const
+ {
+ return myIDMapper->GetElemVTKID(theID);
+ }
+
+ vtkCell*
+ TUnstructuredGridIDMapperImpl
+ ::GetElemCell(vtkIdType theObjID)
+ {
+ return myIDMapper->GetElemCell(theObjID);
+ }
+
+ vtkUnstructuredGrid*
+ TUnstructuredGridIDMapperImpl
+ ::GetUnstructuredGridOutput()
+ {
+ if(!myFilter.GetPointer()){
+ const PAppendFilter& anAppendFilter = myIDMapper->GetFilter();
+ vtkUnstructuredGrid* aGeometry = anAppendFilter->GetOutput();
+
+ const PUnstructuredGrid& aSource = mySource.GetSource();
+ vtkUnstructuredGrid* aDataSet = aSource.GetPointer();
+ aDataSet->ShallowCopy(aGeometry);
+
+ const PMergeFilter& aFilter = GetFilter();
+ aFilter->SetGeometry(aGeometry);
+ aFilter->SetScalars(aDataSet);
+ aFilter->SetVectors(aDataSet);
+ aFilter->AddField("VISU_FIELD",aDataSet);
+ aFilter->AddField("VISU_CELLS_MAPPER",aDataSet);
+ aFilter->AddField("VISU_POINTS_MAPPER",aDataSet);
+ }
+ return myFilter->GetUnstructuredGridOutput();
+ }
+
+ vtkDataSet*
+ TUnstructuredGridIDMapperImpl
+ ::GetOutput()
+ {
+ return GetUnstructuredGridOutput();
+ }
+
+ unsigned long int
+ TUnstructuredGridIDMapperImpl
+ ::GetMemorySize()
+ {
+ size_t aSize = myIDMapper->GetMemorySize();
+ aSize += mySource.GetMemorySize();
+ return aSize;
+ }
+
+
+ //---------------------------------------------------------------
+ vtkIdType
+ TPolyDataIDMapperImpl
+ ::GetNodeObjID(vtkIdType theID) const
+ {
+ return myIDMapper->GetNodeObjID(theID);
+ }
+
+ vtkIdType
+ TPolyDataIDMapperImpl
+ ::GetNodeVTKID(vtkIdType theID) const
+ {
+ return myIDMapper->GetNodeVTKID(theID);
+ }
+
+ vtkFloatingPointType*
+ TPolyDataIDMapperImpl
+ ::GetNodeCoord(vtkIdType theObjID)
+ {
+ return myIDMapper->GetNodeCoord(theObjID);
+ }
+
+ vtkIdType
+ TPolyDataIDMapperImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ return myIDMapper->GetElemObjID(theID);
+ }
+
+ vtkIdType
+ TPolyDataIDMapperImpl
+ ::GetElemVTKID(vtkIdType theID) const
+ {
+ return myIDMapper->GetElemVTKID(theID);
+ }
+
+ vtkCell*
+ TPolyDataIDMapperImpl
+ ::GetElemCell(vtkIdType theObjID)
+ {
+ return myIDMapper->GetElemCell(theObjID);
+ }
+
+ vtkPolyData*
+ TPolyDataIDMapperImpl
+ ::GetPolyDataOutput()
+ {
+ if(!myFilter.GetPointer()){
+ const PAppendPolyData& anAppendFilter = myIDMapper->GetFilter();
+ vtkPolyData* aGeometry = anAppendFilter->GetOutput();
+
+ const PPolyData& aSource = mySource.GetSource();
+ vtkPolyData* aDataSet = aSource.GetPointer();
+ aDataSet->ShallowCopy(aGeometry);
+
+ const PMergeFilter& aFilter = GetFilter();
+ aFilter->SetGeometry(aGeometry);
+ aFilter->SetScalars(aDataSet);
+ aFilter->SetVectors(aDataSet);
+ aFilter->AddField("VISU_FIELD",aDataSet);
+ aFilter->AddField("VISU_CELLS_MAPPER",aDataSet);
+ aFilter->AddField("VISU_POINTS_MAPPER",aDataSet);
+ }
+ return myFilter->GetPolyDataOutput();
+ }
+
+ vtkDataSet*
+ TPolyDataIDMapperImpl
+ ::GetOutput()
+ {
+ return GetPolyDataOutput();
+ }
+
+ unsigned long int
+ TPolyDataIDMapperImpl
+ ::GetMemorySize()
+ {
+ size_t aSize = myIDMapper->GetMemorySize();
+ aSize += mySource.GetMemorySize();
+ return aSize;
+ }
+
+
+ //---------------------------------------------------------------
+ TGaussImpl
+ ::TGaussImpl():
+ myGeom(EGeometry(-1)),
+ myNbPoints(0)
+ {}
+
+ void
+ TGaussImpl
+ ::LessThan(const PGaussImpl& theGauss,
+ bool& theResult) const
+ {
+ theResult = false;
+ }
+
+
+ //---------------------------------------------------------------
+ TGaussSubMeshImpl
+ ::TGaussSubMeshImpl():
+ myPointCoords(new TPointCoords()),
+ myStatus(eNone),
+ myStartID(0)
+ {}
+
+ TGaussPointID
+ TGaussSubMeshImpl
+ ::GetObjID(vtkIdType theID) const
+ {
+ TCellID aCellID = myStartID + theID / myGauss->myNbPoints;
+ TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
+
+ return TGaussPointID(aCellID, aLocalPntID);
+ }
+
+ vtkIdType
+ TGaussSubMeshImpl
+ ::GetGlobalID(vtkIdType theID) const
+ {
+ return myStartID + theID;
+ }
+
+ unsigned long int
+ TGaussSubMeshImpl
+ ::GetMemorySize()
+ {
+ size_t aSize = TPolyDataHolder::GetMemorySize();
+ aSize += myPointCoords->GetMemorySize();
+ return aSize;
+ }
+
+ //---------------------------------------------------------------
+ bool
+ operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight)
+ {
+ PGaussSubMeshImpl aLeft(theLeft), aRight(theRight);
+ const PGaussImpl& aGaussLeft = aLeft->myGauss;
+ const PGaussImpl& aGaussRight = aRight->myGauss;
+
+ if(aGaussLeft->myGeom != aGaussRight->myGeom)
+ return aGaussLeft->myGeom < aGaussRight->myGeom;
+
+ if(aLeft->mySubProfile != aRight->mySubProfile)
+ return aLeft->mySubProfile < aRight->mySubProfile;
+
+ bool aResult;
+ aGaussLeft->LessThan(aGaussRight,aResult);
+
+ return aResult;
+ }
+
+
+ //---------------------------------------------------------------
+ TGaussMeshImpl
+ ::TGaussMeshImpl():
+ myParent(NULL)
+ {}
+
+ TGaussPointID
+ TGaussMeshImpl
+ ::GetObjID(vtkIdType theID) const
+ {
+ const PAppendPolyData& aFilter = GetFilter();
+ return VISU::GetObjID(aFilter->GetOutput(), theID);
+ }
+
+ vtkPolyData*
+ TGaussMeshImpl
+ ::GetPolyDataOutput()
+ {
+ return TAppendPolyDataHolder::GetPolyDataOutput();
+ }
+
+ unsigned long int
+ TGaussMeshImpl
+ ::GetMemorySize()
+ {
+ size_t aSize = TAppendPolyDataHolder::GetMemorySize();
+ TGeom2GaussSubMesh::const_iterator anIter = myGeom2GaussSubMesh.begin();
+ TGeom2GaussSubMesh::const_iterator anIterEnd = myGeom2GaussSubMesh.end();
+ for(; anIter != anIterEnd; anIter++){
+ const PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
+ aSize += aGaussSubMesh->GetMemorySize();
+ aSize += sizeof(EGeometry);
+ }
+ return aSize;
+ }
+
+ TNamedIDMapper*
+ TGaussMeshImpl
+ ::GetParent()
+ {
+ return myParent;
+ }
+
+
+ //---------------------------------------------------------------
+ TGaussPointID
+ TGaussPtsIDFilter
+ ::GetObjID(vtkIdType theID) const
+ {
+ return myGaussPtsIDMapper->GetObjID(theID);
+ }
+
+ TNamedIDMapper*
+ TGaussPtsIDFilter
+ ::GetParent()
+ {
+ return myGaussPtsIDMapper->GetParent();
+ }
+
+ vtkPolyData*
+ TGaussPtsIDFilter
+ ::GetPolyDataOutput()
+ {
+ return TPolyDataIDMapperImpl::GetPolyDataOutput();
+ }
+
+ vtkDataSet*
+ TGaussPtsIDFilter
+ ::GetOutput()
+ {
+ return GetPolyDataOutput();
+ }
+
+
+ //---------------------------------------------------------------
+ TSubMeshImpl
+ ::TSubMeshImpl():
+ myStartID(0)
+ {}
+
+ vtkIdType
+ TSubMeshImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ return myStartID + theID;
+ }
+
+ std::string
+ TSubMeshImpl
+ ::GetElemName(vtkIdType theObjID) const
+ {
+ return "";
+ }
+
+ unsigned long int
+ TSubMeshImpl
+ ::GetMemorySize()
+ {
+ size_t aSize = TUnstructuredGridHolder::GetMemorySize();
+ for(size_t anId = 0; anId < myCell2Connect.size(); anId++){
+ const TConnect& aConnect = myCell2Connect[anId];
+ aSize += aConnect.size() * sizeof(vtkIdType);
+ }
+ return aSize;
+ }
+
+ //---------------------------------------------------------------
+ TMeshOnEntityImpl
+ ::TMeshOnEntityImpl()
+ {
+ const PAppendFilter& anAppendFilter = GetFilter();
+ anAppendFilter->SetMappingInputs(true);
+ }
+
+ vtkIdType
+ TMeshOnEntityImpl
+ ::GetNodeVTKID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetVTKID(theID);
+ }
+
+ vtkIdType
+ TMeshOnEntityImpl
+ ::GetNodeObjID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetObjID(theID);
+ }
+
+ vtkIdType
+ TMeshOnEntityImpl
+ ::GetElemVTKID(vtkIdType theID) const
+ {
+ return VISU::GetElemVTKID(GetFilter()->GetOutput(), theID);
+ }
+
+ vtkIdType
+ TMeshOnEntityImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ return VISU::GetElemObjID(GetFilter()->GetOutput(), theID);
+ }
+
+ std::string
+ TMeshOnEntityImpl
+ ::GetNodeName(vtkIdType theObjID) const
+ {
+ return myNamedPointCoords->GetNodeName(theObjID);
+ }
+
+ std::string
+ TMeshOnEntityImpl
+ ::GetElemName(vtkIdType theObjID) const
+ {
+ TInputCellID anInputCellID = VISU::GetInputCellID(GetFilter()->GetOutput(), theObjID);
+ const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputCellID.first];
+ return aSubMesh->GetElemName(anInputCellID.second);
+ }
+
+ vtkUnstructuredGrid*
+ TMeshOnEntityImpl
+ ::GetUnstructuredGridOutput()
+ {
+ return TAppendFilterHolder::GetUnstructuredGridOutput();
+ }
+
+ unsigned long int
+ TMeshOnEntityImpl
+ ::GetMemorySize()
+ {
+ size_t aSize = TAppendFilterHolder::GetMemorySize();
+ aSize += myNamedPointCoords->GetMemorySize();
+ aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType);
+ TGeom2SubMesh::const_iterator anIter = myGeom2SubMesh.begin();
+ TGeom2SubMesh::const_iterator anIterEnd = myGeom2SubMesh.end();
+ for(; anIter != anIterEnd; anIter++){
+ const PSubMeshImpl& aSubMesh = anIter->second;
+ aSize += aSubMesh->GetMemorySize();
+ aSize += sizeof(EGeometry);
+ }
+ return aSize;
+ }
+
+ //---------------------------------------------------------------
+ vtkIdType
+ TFamilyImpl
+ ::GetElemVTKID(vtkIdType theID) const
+ {
+ if(myElemObj2VTKID.empty())
+ return theID;
+ else{
+ TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
+ if(anIter != myElemObj2VTKID.end())
+ return anIter->second;
+ }
+ return -1;
+ }
+
+ vtkIdType
+ TFamilyImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ return myMeshID[theID];
+ }
+
+ vtkIdType
+ TFamilyImpl
+ ::GetNodeObjID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetObjID(theID);
+ }
+
+ vtkIdType
+ TFamilyImpl
+ ::GetNodeVTKID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetVTKID(theID);
+ }
+
+ vtkUnstructuredGrid*
+ TFamilyImpl
+ ::GetUnstructuredGridOutput()
+ {
+ return TUnstructuredGridHolder::GetUnstructuredGridOutput();
+ }
+
+ unsigned long int
+ TFamilyImpl
+ ::GetMemorySize()
+ {
+ size_t aSize = TUnstructuredGridHolder::GetMemorySize();
+ aSize += myNamedPointCoords->GetMemorySize();
+ aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType);
+ aSize += myMeshID.size() * sizeof(vtkIdType);
+ TGeom2SubMeshID::const_iterator anIter = myGeom2SubMeshID.begin();
+ TGeom2SubMeshID::const_iterator anIterEnd = myGeom2SubMeshID.end();
+ for(; anIter != anIterEnd; anIter++){
+ const TSubMeshID& aSubMeshID = anIter->second;
+ aSize += aSubMeshID.size() * sizeof(vtkIdType);
+ aSize += sizeof(EGeometry);
+ }
+ return aSize;
+ }
+
+
+ //---------------------------------------------------------------
+ TNbASizeCells
+ TGroupImpl
+ ::GetNbASizeCells() const
+ {
+ vtkIdType aNbCells = 0, aCellsSize = 0;
+ TFamilySet::const_iterator anIter = myFamilySet.begin();
+ for(; anIter != myFamilySet.end(); anIter++){
+ PFamilyImpl aFamily = *anIter;
+ aNbCells += aFamily->myNbCells;
+ aCellsSize += aFamily->myCellsSize;
+ }
+ return std::make_pair(aNbCells,aCellsSize);
+ }
+
+ vtkIdType
+ TGroupImpl
+ ::GetElemVTKID(vtkIdType theID) const
+ {
+ if(myElemObj2VTKID.empty())
+ return theID;
+ else{
+ TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
+ if(anIter != myElemObj2VTKID.end())
+ return anIter->second;
+ }
+ return -1;
+ }
+
+ vtkIdType
+ TGroupImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ return VISU::GetElemObjID(GetFilter()->GetOutput(), theID);
+ }
+
+ vtkIdType
+ TGroupImpl
+ ::GetNodeObjID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetObjID(theID);
+ }
+
+ vtkIdType
+ TGroupImpl
+ ::GetNodeVTKID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetVTKID(theID);
+ }
+
+ vtkUnstructuredGrid*
+ TGroupImpl
+ ::GetUnstructuredGridOutput()
+ {
+ return TAppendFilterHolder::GetUnstructuredGridOutput();
+ }
+
+ unsigned long int
+ TGroupImpl
+ ::GetMemorySize()
+ {
+ size_t aSize = TAppendFilterHolder::GetMemorySize();
+ aSize += myNamedPointCoords->GetMemorySize();
+ aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType);
+ for(size_t anId = 0; anId < myFamilyArr.size(); anId++){
+ const PFamilyImpl& aFamily = myFamilyArr[anId];
+ aSize += aFamily->GetMemorySize();
+ }
+ return aSize;
+ }
+
+
+
+ //---------------------------------------------------------------
+ TFieldImpl
+ ::TFieldImpl():
+ myDataSize(0),
+ myDataType(0)
+ {}
+
+ void
+ TFieldImpl
+ ::Init(vtkIdType theNbComp,
+ vtkIdType theDataType)
+ {
+ myNbComp = theNbComp;
+ myDataType = theDataType;
+ myCompNames.resize(theNbComp);
+ myUnitNames.resize(theNbComp);
+ myMinMaxArr.resize(theNbComp + 1);
+ for(vtkIdType iComp = 0; iComp <= theNbComp; iComp++){
+ TMinMax& aMinMax = myMinMaxArr[iComp];
+ aMinMax.first = VTK_LARGE_FLOAT;
+ aMinMax.second = -VTK_LARGE_FLOAT;
+ }
+ }
+
+ vtkIdType
+ TFieldImpl
+ ::GetDataType() const
+ {
+ return myDataType;
+ }
+
+ TMinMax
+ TFieldImpl
+ ::GetMinMax(vtkIdType theCompID)
+ {
+ return myMinMaxArr[theCompID];
+ }
+
+
+ //----------------------------------------------------------------------------
+ const PMeshValue&
+ TGeom2Value
+ ::GetMeshValue(EGeometry theGeom) const
+ {
+ TGeom2MeshValue::const_iterator anIter = myGeom2MeshValue.find(theGeom);
+ if(anIter == myGeom2MeshValue.end())
+ EXCEPTION(std::runtime_error,"TGeom2Value::GetMeshValue - myGeom2MeshValue.find(theGeom) fails");
+ return anIter->second;
+ }
+
+ PMeshValue&
+ TGeom2Value
+ ::GetMeshValue(EGeometry theGeom)
+ {
+ return myGeom2MeshValue[theGeom];
+ }
+
+
+ //----------------------------------------------------------------------------
+ TGeom2MeshValue&
+ TGeom2Value
+ ::GetGeom2MeshValue()
+ {
+ return myGeom2MeshValue;
+ }
+
+ const TGeom2MeshValue&
+ TGeom2Value
+ ::GetGeom2MeshValue() const
+ {
+ return myGeom2MeshValue;
+ }
+
+ PMeshValue
+ TGeom2Value
+ ::GetFirstMeshValue() const
+ {
+ if(myGeom2MeshValue.size() == 1)
+ return myGeom2MeshValue.begin()->second;
+ return PMeshValue();
+ }
+
+
+ //---------------------------------------------------------------
+ TValForTimeImpl
+ ::TValForTimeImpl():
+ myGaussPtsIDFilter(new TGaussPtsIDFilter()),
+ myUnstructuredGridIDMapper(new TUnstructuredGridIDMapperImpl())
+ {}
+
+ const PMeshValue&
+ TValForTimeImpl
+ ::GetMeshValue(EGeometry theGeom) const
+ {
+ return myGeom2Value.GetMeshValue(theGeom);
+ }
+
+ PMeshValue&
+ TValForTimeImpl
+ ::GetMeshValue(EGeometry theGeom)
+ {
+ return myGeom2Value.GetMeshValue(theGeom);
+ }
+
+ TGeom2MeshValue&
+ TValForTimeImpl
+ ::GetGeom2MeshValue()
+ {
+ return myGeom2Value.GetGeom2MeshValue();
+ }
+
+ const TGeom2MeshValue&
+ TValForTimeImpl
+ ::GetGeom2MeshValue() const
+ {
+ return myGeom2Value.GetGeom2MeshValue();
+ }
+
+ PMeshValue
+ TValForTimeImpl
+ ::GetFirstMeshValue() const
+ {
+ return myGeom2Value.GetFirstMeshValue();
+ }
+
+ int
+ TValForTimeImpl
+ ::GetNbGauss(EGeometry theGeom) const
+ {
+ TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.find(theGeom);
+ if(anIter == myGeom2NbGauss.end()){
+ return 1;
+ }
+ return anIter->second;
+ }
+
+ unsigned long int
+ TValForTimeImpl
+ ::GetMemorySize()
+ {
+ size_t aSize = sizeof(TValForTimeImpl);
+ const TGeom2MeshValue& aGeom2MeshValue = GetGeom2MeshValue();
+ TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin();
+ TGeom2MeshValue::const_iterator anIterEnd = aGeom2MeshValue.end();
+ for(; anIter != anIterEnd; anIter++){
+ const PMeshValue& aMeshValue = anIter->second;
+ aSize += aMeshValue->GetMemorySize();
+ aSize += sizeof(EGeometry);
+ }
+ return aSize;
+ }
+
+
+ //---------------------------------------------------------------
+}
--- /dev/null
+//
+//
+// 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 : Alexey PETROV
+// Module : VISU
+
+#ifndef VISU_Structures_impl_HeaderFile
+#define VISU_Structures_impl_HeaderFile
+
+/*!
+ \file VISU_Structures_impl.hxx
+ \brief The file contains definitions for basic classes of the implementation of VISU CONVERTER package
+*/
+
+#include "VISU_Structures.hxx"
+#include "VISU_ConvertorDef_impl.hxx"
+
+class vtkPointSet;
+
+
+namespace VISU
+{
+ //---------------------------------------------------------------
+ //! Define an utility base class which allow to keep calculated number of cells and their size
+ struct TSizeCounter: virtual TIsVTKDone
+ {
+ TSizeCounter();
+ vtkIdType myNbCells; //!< Number of cells contained into corresponding sublclass
+ vtkIdType myCellsSize; //!< Size of cells contained into corresponding sublclass
+ };
+
+
+ //---------------------------------------------------------------
+ //! Define a container for VTK representation
+ class TPolyDataHolder: public virtual TSizeCounter
+ {
+ protected:
+ mutable PPolyData mySource;
+ public:
+ TPolyDataHolder();
+
+ //! This method allow to create corresponding VTK data set by demand (not at once)
+ const PPolyData&
+ GetSource() const;
+
+ virtual
+ vtkPolyData*
+ GetPolyDataOutput();
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+ };
+
+
+ //---------------------------------------------------------------
+ //! Define a container for VTK representation
+ class TUnstructuredGridHolder: public virtual TSizeCounter
+ {
+ public:
+ TUnstructuredGridHolder();
+
+ //! This method allow to create corresponding VTK data set by demand (not at once)
+ const PUnstructuredGrid&
+ GetSource() const;
+
+ virtual
+ vtkUnstructuredGrid*
+ GetUnstructuredGridOutput();
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ protected:
+ mutable PUnstructuredGrid mySource;
+ };
+
+
+ //---------------------------------------------------------------
+ //! Define an intermediate class which unifies memory size calculation
+ struct TMemoryCheckIDMapper: public virtual TIsVTKDone,
+ public virtual TIDMapper
+ {
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+ };
+
+
+ //---------------------------------------------------------------
+ //! Define a container for VTK representation
+ /*!
+ This container allow to combine other VTK representation into single one.
+ */
+ class TAppendFilterHolder: public virtual TMemoryCheckIDMapper
+ {
+ protected:
+ mutable PAppendFilter myFilter;
+ public:
+ TAppendFilterHolder();
+
+ //! This method allow to create corresponding VTK filter by demand (not at once)
+ const PAppendFilter&
+ GetFilter() const;
+
+ //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
+ virtual
+ vtkUnstructuredGrid*
+ GetUnstructuredGridOutput();
+ };
+
+
+ //---------------------------------------------------------------
+ //! Define a container for VTK representation
+ /*!
+ This container allow to combine other VTK representation into single one.
+ */
+ class TAppendPolyDataHolder: public virtual TMemoryCheckIDMapper
+ {
+ protected:
+ mutable PAppendPolyData myFilter;
+ public:
+ TAppendPolyDataHolder();
+
+ //! This method allow to create corresponding VTK filter by demand (not at once)
+ const PAppendPolyData&
+ GetFilter() const;
+
+ //! Reimplement the TGaussPtsIDMapper::GetPolyDataOutput
+ virtual
+ vtkPolyData*
+ GetPolyDataOutput();
+ };
+
+
+ //---------------------------------------------------------------
+ //! Define a container for VTK representation
+ /*!
+ This container allow to assign data to mesh and represent them into single VTK representation
+ */
+ class TMergeFilterHolder: public virtual TMemoryCheckIDMapper
+ {
+ protected:
+ mutable PMergeFilter myFilter;
+ public:
+ TMergeFilterHolder();
+
+ //! This method allow to create corresponding VTK filter by demand (not at once)
+ const PMergeFilter&
+ GetFilter() const;
+
+ //! Gets output of the filter as vtkDataSet
+ virtual
+ vtkDataSet*
+ GetOutput();
+ };
+
+
+ //---------------------------------------------------------------
+ //! Specialize TMesh to provide VTK mapping for nodes
+ struct TMeshImpl: virtual TMesh,
+ virtual TIsVTKDone
+ {
+ PNamedPointCoords myNamedPointCoords; //!< Keeps intermediate representation of the nodes
+ vtkIdType myNbPoints; //!< Keeps number of the nodes
+
+ TMeshImpl();
+
+ vtkIdType
+ GetNbPoints() const;
+
+ vtkIdType
+ GetDim() const;
+
+ vtkPointSet*
+ GetPointSet(); //!< Gets initialized corresponding VTK structure
+ };
+
+
+ //---------------------------------------------------------------
+ typedef TVector<vtkIdType> TSubMeshID;
+ typedef enum {eRemoveAll, eAddAll, eAddPart, eNone} ESubMeshStatus;
+
+ //! Specialize TSubProfile to provide VTK mapping
+ struct TSubProfileImpl: virtual TSubProfile,
+ virtual TUnstructuredGridHolder
+ {
+ TSubProfileImpl();
+
+ EGeometry myGeom; //!< Defines to what geometrical type the MED PROFILE belong to
+ std::string myName; //!< Keeps its name
+
+ //! Get object number of mesh cell by its VTK one
+ virtual
+ vtkIdType
+ GetElemObjID(int theVtkI) const;
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ //! Keeps status of the structure
+ /*!
+ In some cases MED file does not use MED PROFILES, but at VISU creates corresponding data strucutre
+ in order to construct mesh for MED TIEMSTAMPS in uniform way.
+ */
+ ESubMeshStatus myStatus;
+ TSubMeshID mySubMeshID; //!< Keeps numbers of mesh cell which contain the MED PROFILE
+ };
+
+
+ //---------------------------------------------------------------
+ typedef std::map<vtkIdType,vtkIdType> TID2ID;
+ typedef TVector<PSubProfileImpl> TSubProfileArr;
+ typedef std::map<EGeometry,PSubProfileImpl> TGeom2SubProfile;
+
+ //! Specialize TProfile to provide VTK mapping for MED TIMESTAMP mesh
+ struct TProfileImpl: virtual TProfile,
+ virtual TAppendFilterHolder
+ {
+ TProfileImpl();
+ bool myIsAll; //!< Say, whether the MED TIMESTAMP defined on all MED ENTITY or not
+
+ //! Reimplement the TIDMapper::GetNodeObjID
+ virtual
+ vtkIdType
+ GetNodeObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeVTKID
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeCoord
+ virtual
+ vtkFloatingPointType*
+ GetNodeCoord(vtkIdType theObjID);
+
+ //! Reimplement the TIDMapper::GetElemObjID
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemVTKID
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemCell
+ virtual
+ vtkCell*
+ GetElemCell(vtkIdType theObjID);
+
+ //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
+ virtual
+ vtkUnstructuredGrid*
+ GetUnstructuredGridOutput();
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ //! Reimplement the TNamedIDMapper::GetNodeName
+ virtual
+ std::string
+ GetNodeName(vtkIdType theObjID) const;
+
+ //! Reimplement the TNamedIDMapper::GetElemName
+ virtual
+ std::string
+ GetElemName(vtkIdType theObjID) const;
+
+ TID2ID myElemObj2VTKID; //!< Keeps object to VTK numeration mapping
+ TSubProfileArr mySubProfileArr; //!< Keeps sequence of TSubProfiles as they were added into TAppendFilterHolder
+ PNamedPointCoords myNamedPointCoords; //!< Keeps reference on the same TNamedPointCoords as TMesh
+ TMeshOnEntityImpl* myMeshOnEntity; //<! Keeps backward reference to corresponding MED ENTITY mesh
+
+ TGeom2SubProfile myGeom2SubProfile; //!< Keeps TSubProfiles according to their geometrical type
+ };
+
+
+ //---------------------------------------------------------------
+ //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
+ struct TUnstructuredGridIDMapperImpl: virtual TMergeFilterHolder,
+ virtual TUnstructuredGridIDMapper
+ {
+ PAppendFilterHolder myIDMapper; //!< Responsible for numbering
+ TUnstructuredGridHolder mySource; //!< Keeps assigned data
+
+ //! Reimplement the TIDMapper::GetNodeObjID
+ virtual
+ vtkIdType
+ GetNodeObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeVTKID
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeCoord
+ virtual
+ vtkFloatingPointType*
+ GetNodeCoord(vtkIdType theObjID);
+
+ //! Reimplement the TIDMapper::GetElemObjID
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemVTKID
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemCell
+ virtual
+ vtkCell*
+ GetElemCell(vtkIdType theObjID);
+
+ //! Reimplement the TUnstructuredGridIDMapper::GetUnstructuredGridOutput
+ virtual
+ vtkUnstructuredGrid*
+ GetUnstructuredGridOutput();
+
+ //! Reimplement the TIDMapper::GetOutput
+ virtual
+ vtkDataSet*
+ GetOutput();
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+ };
+
+
+ //---------------------------------------------------------------
+ //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh
+ struct TPolyDataIDMapperImpl: virtual TMergeFilterHolder,
+ virtual TPolyDataIDMapper
+ {
+ PAppendPolyDataHolder myIDMapper; //!< Responsible for numbering
+ TPolyDataHolder mySource; //!< Keeps assigned data
+
+ //! Reimplement the TIDMapper::GetNodeObjID
+ virtual
+ vtkIdType
+ GetNodeObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeVTKID
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeCoord
+ virtual
+ vtkFloatingPointType*
+ GetNodeCoord(vtkIdType theObjID);
+
+ //! Reimplement the TIDMapper::GetElemObjID
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemVTKID
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemCell
+ virtual
+ vtkCell*
+ GetElemCell(vtkIdType theObjID);
+
+ //! Reimplement the TPolyDataIDMapper::GetPolyDataOutput
+ virtual
+ vtkPolyData*
+ GetPolyDataOutput();
+
+ //! Reimplement the TIDMapper::GetOutput
+ virtual
+ vtkDataSet*
+ GetOutput();
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+ };
+
+
+ //---------------------------------------------------------------
+ //! Specialize TGauss to provide more detail information of the MED GAUSS entity for VTK mapping
+ struct TGaussImpl: virtual TGauss
+ {
+ EGeometry myGeom; //!< Define, to which geometrical type the MED GAUSS entity belongs
+ std::string myName; //!< Keeps name of the MED GAUSS entity
+ vtkIdType myNbPoints; //<! Keeps number of points for the MED GAUSS entity
+
+ TGaussImpl();
+
+ //! To define a way to implement more detail comparision of the TGaussSubMesh instances
+ virtual
+ void
+ LessThan(const PGaussImpl& theGauss,
+ bool& theResult) const;
+ };
+
+
+ //---------------------------------------------------------------
+ //! Specialize TGaussSubMesh to provide VTK mapping for the entity
+ struct TGaussSubMeshImpl: virtual TGaussSubMesh,
+ virtual TPolyDataHolder
+ {
+ TGaussSubMeshImpl();
+
+ //! To implement the TGaussPtsIDMapper::GetObjID
+ virtual
+ TGaussPointID
+ GetObjID(vtkIdType theID) const;
+
+ virtual
+ vtkIdType
+ GetGlobalID(vtkIdType theID) const;
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ PGaussImpl myGauss; //<! Keep reference to corresponding TGauss structure
+
+ //! Keeps status of the structure
+ /*!
+ In some cases MED file does not use MED GAUSS, but at VISU creates corresponding data strucutre
+ in order to construct mesh for MED TIEMSTAMPS in uniform way.
+ */
+ ESubMeshStatus myStatus;
+
+ vtkIdType myStartID;
+ PPointCoords myPointCoords; //!< Keeps coordinates of Gauss Points
+ };
+
+
+ //---------------------------------------------------------------
+ typedef TVector<PGaussSubMeshImpl> TGaussSubMeshArr;
+ typedef std::map<EGeometry, PGaussSubMeshImpl> TGeom2GaussSubMesh;
+
+ //! Specialize TGaussMesh to provide VTK mapping for the entity
+ struct TGaussMeshImpl: virtual TGaussMesh,
+ virtual TAppendPolyDataHolder
+ {
+ TGaussMeshImpl();
+
+ //! Reimplement the TGaussPtsIDMapper::GetObjID
+ virtual
+ TGaussPointID
+ GetObjID(vtkIdType theID) const;
+
+ //! Reimplement the TGaussPtsIDMapper::GetPolyDataOutput
+ virtual
+ vtkPolyData*
+ GetPolyDataOutput();
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ //! Reimplement the TGaussPtsIDMapper::GetParent
+ virtual
+ TNamedIDMapper*
+ GetParent();
+
+ TNamedIDMapper* myParent; //!< Refer to parent mesh
+ TGaussSubMeshArr myGaussSubMeshArr; //!< Keeps sequence of TGaussSubMesh as they were added into TAppendFilterHolder
+ TGeom2GaussSubMesh myGeom2GaussSubMesh; //!< Keeps TGaussSubMesh according to their geometrical type
+ };
+
+
+ //---------------------------------------------------------------
+ //! Specialize TGaussPtsIDMapper to provide VTK mapping for MED TIMESTAMP mesh
+ struct TGaussPtsIDFilter: virtual TPolyDataIDMapperImpl,
+ virtual TGaussPtsIDMapper
+ {
+ PGaussPtsIDMapper myGaussPtsIDMapper;
+
+ //! Reimplement the TGaussPtsIDMapper::GetObjID
+ virtual
+ TGaussPointID
+ GetObjID(vtkIdType theID) const;
+
+ //! Reimplement the TGaussPtsIDMapper::GetParent
+ virtual
+ TNamedIDMapper*
+ GetParent();
+
+ //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
+ virtual
+ vtkPolyData*
+ GetPolyDataOutput();
+
+ //! Reimplement the TIDMapper::GetOutput
+ virtual
+ vtkDataSet*
+ GetOutput();
+ };
+
+
+ //---------------------------------------------------------------
+ typedef TVector<vtkIdType> TConnect;
+ typedef TVector<TConnect> TCell2Connect;
+
+ //! The class is responsible for mapping of cells of defined geometrical type
+ struct TSubMeshImpl: virtual TUnstructuredGridHolder
+ {
+ TSubMeshImpl();
+
+ //! To implement the TIDMapper::GetElemObjID
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const;
+
+ //! To implement the TNamedIDMapper::GetElemName
+ virtual
+ std::string
+ GetElemName(vtkIdType theObjID) const;
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ vtkIdType myStartID;
+ TCell2Connect myCell2Connect; //!< Contains connectivity for the cells
+ };
+
+
+ //---------------------------------------------------------------
+ typedef std::map<EGeometry,PSubMeshImpl> TGeom2SubMesh;
+ typedef TVector<PSubMeshImpl> TSubMeshArr;
+
+ //! Specialize TMeshOnEntity to provide VTK mapping for the entity
+ struct TMeshOnEntityImpl: virtual TMeshOnEntity,
+ virtual TAppendFilterHolder,
+ virtual TSizeCounter
+ {
+ TMeshOnEntityImpl();
+
+ //! Reimplement the TIDMapper::GetNodeVTKID
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeObjID
+ virtual
+ vtkIdType
+ GetNodeObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemVTKID
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemObjID
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const;
+
+ //! Reimplement the TNamedIDMapper::GetNodeName
+ virtual
+ std::string
+ GetNodeName(vtkIdType theObjID) const;
+
+ //! Reimplement the TNamedIDMapper::GetElemName
+ virtual
+ std::string
+ GetElemName(vtkIdType theObjID) const;
+
+ //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput
+ virtual
+ vtkUnstructuredGrid*
+ GetUnstructuredGridOutput();
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
+ TSubMeshArr mySubMeshArr; //!< Keeps sequence of TSubMeshImpl as they were added into TAppendFilterHolder
+ PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
+
+ TGeom2SubMesh myGeom2SubMesh; //!< Keeps TSubMeshImpl according to their geometrical type
+ };
+
+
+ //---------------------------------------------------------------
+ typedef std::map<EGeometry,TSubMeshID> TGeom2SubMeshID;
+
+ //! Specialize TFamily to provide VTK mapping for the entity
+ struct TFamilyImpl: virtual TFamily,
+ virtual TUnstructuredGridHolder
+ {
+ //! Reimplement the TIDMapper::GetNodeObjID
+ vtkIdType
+ GetNodeObjID(vtkIdType theID) const ;
+
+ //! Reimplement the TIDMapper::GetNodeVTKID
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID) const ;
+
+ //! Reimplement the TIDMapper::GetElemVTKID
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemObjID
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const;
+
+ //! Reimplement the TUnstructuredGridIDMapper::GetUnstructuredGridOutput
+ virtual
+ vtkUnstructuredGrid*
+ GetUnstructuredGridOutput();
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
+ TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
+ TSubMeshID myMeshID; //!< Keeps numbers of mesh elements that belongs to the MED FAMILY
+
+ TGeom2SubMeshID myGeom2SubMeshID; //!< Keeps TSubMeshID according to their geometrical type
+ };
+
+
+ //---------------------------------------------------------------
+ typedef std::pair<vtkIdType,vtkIdType> TNbASizeCells;
+ typedef TVector<PFamilyImpl> TFamilyArr;
+
+ //! Specialize TGroup to provide VTK mapping for the entity
+ struct TGroupImpl: virtual TGroup,
+ virtual TAppendFilterHolder
+ {
+ //! Calculate pair of values - number of cells and its size
+ TNbASizeCells
+ GetNbASizeCells() const;
+
+ //! Reimplement the TIDMapper::GetElemVTKID
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetElemObjID
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeObjID
+ virtual
+ vtkIdType
+ GetNodeObjID(vtkIdType theID) const;
+
+ //! Reimplement the TIDMapper::GetNodeVTKID
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID) const;
+
+ //! Reimplement the TUnstructuredGridIDMapper::GetUnstructuredGridOutput
+ virtual
+ vtkUnstructuredGrid*
+ GetUnstructuredGridOutput();
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping
+ TFamilyArr myFamilyArr; //!< Keeps sequence of TFamily as they were added into TAppendFilterHolder
+ PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping
+ };
+
+
+ //---------------------------------------------------------------
+ typedef TVector<TMinMax> TMinMaxArr;
+
+ //! Specialize TField to provide VTK mapping for the entity
+ struct TFieldImpl: virtual TField
+ {
+ TFieldImpl();
+
+ //! To initialize the data structure
+ void
+ Init(vtkIdType theNbComp,
+ vtkIdType theDataType);
+
+ //! Gets type idetificator of the mesh data.
+ vtkIdType
+ GetDataType() const;
+
+ //! Implement the TField::GetMinMax
+ virtual
+ TMinMax
+ GetMinMax(vtkIdType theCompID);
+
+ vtkIdType myDataSize; //!< Keeps size of the assigned data
+ vtkIdType myDataType; //!< Keeps type idetificator of the mesh data
+ TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD
+ };
+
+
+ //---------------------------------------------------------------
+ typedef std::map<EGeometry, PMeshValue> TGeom2MeshValue;
+
+ class TGeom2Value: public virtual TBaseStructure
+ {
+ TGeom2MeshValue myGeom2MeshValue;
+ public:
+
+ //! Gets mesh data for defined geometrical type (constant version)
+ const PMeshValue&
+ GetMeshValue(EGeometry theGeom) const;
+
+ //! Gets mesh data for defined geometrical type
+ PMeshValue&
+ GetMeshValue(EGeometry theGeom);
+
+ //! Gets container of the whole mesh data
+ TGeom2MeshValue&
+ GetGeom2MeshValue();
+
+ //! Gets container of the whole mesh data (constant version)
+ const TGeom2MeshValue&
+ GetGeom2MeshValue() const;
+
+ //! Gets mesh data for the first geometry
+ PMeshValue
+ GetFirstMeshValue() const;
+ };
+
+
+ //---------------------------------------------------------------
+ typedef std::map<EGeometry,vtkIdType> TGeom2NbGauss;
+
+ //! Specialize TValForTime to provide VTK mapping for the entity
+ struct TValForTimeImpl: virtual TValForTime
+ {
+ PGaussPtsIDFilter myGaussPtsIDFilter; //!< Keep VTK representation for mesh and data on Gauss Points
+ PUnstructuredGridIDMapperImpl myUnstructuredGridIDMapper; //!< Keep VTK representation for ordinary mesh and data
+ TGeom2Value myGeom2Value; //!< Keep value that is assigned to the mesh
+ TGeom2NbGauss myGeom2NbGauss; //!< Keep number of Gauss Points
+
+ TValForTimeImpl();
+
+ TGeom2MeshValue&
+ GetGeom2MeshValue();
+
+ const TGeom2MeshValue&
+ GetGeom2MeshValue() const;
+
+ //! Get mesh data for defined geometrical type (constant version)
+ const PMeshValue&
+ GetMeshValue(EGeometry theGeom) const;
+
+ //! Get mesh data for defined geometrical type
+ PMeshValue&
+ GetMeshValue(EGeometry theGeom);
+
+ //! Gets mesh data for the first geometry
+ PMeshValue
+ GetFirstMeshValue() const;
+
+ //! Get number of Gauss Points for defined geometrical type
+ virtual
+ int
+ GetNbGauss(EGeometry theGeom) const;
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+ };
+
+
+ //---------------------------------------------------------------
+}
+
+
+#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_ColoredPrs3dCache_i.hh
+// Author : Oleg UVAROV
+// Module : VISU
+
+#ifndef VISU_TypeList_HeaderFile
+#define VISU_TypeList_HeaderFile
+
+namespace VISU
+{
+ namespace TL
+ {
+ //----------------------------------------------------------------------------
+ template <class T, class U>
+ struct TList
+ {
+ typedef T THead;
+ typedef U TTail;
+ };
+
+ template <int v>
+ struct TInt2Type
+ {
+ enum { value = v };
+ };
+
+ struct TNullType {};
+
+ //----------------------------------------------------------------------------
+ template <class TypeList, unsigned int index>
+ struct TTypeAt;
+
+ template <class THead, class TTail>
+ struct TTypeAt<TList<THead, TTail>, 0>
+ {
+ typedef THead TResult;
+ };
+
+
+ template <class THead, class TTail, unsigned int index>
+ struct TTypeAt<TList<THead, TTail>, index>
+ {
+ typedef typename TTypeAt<TTail, index - 1>::TResult TResult;
+ };
+
+ //----------------------------------------------------------------------------
+ template <class TypeList, class T>
+ struct TIndexOf;
+
+ template <class T>
+ struct TIndexOf<TNullType, T>
+ {
+ enum { value = -1 };
+ };
+
+ template <class T, class TTail>
+ struct TIndexOf<TList<T, TTail>, T>
+ {
+ enum { value = 0 };
+ };
+
+ template <class THead, class TTail, class T>
+ struct TIndexOf<TList<THead, TTail>, T>
+ {
+ private:
+ enum { temp = TIndexOf<TTail, T>::value };
+ public:
+ enum { value = temp == -1? -1 : 1 + temp };
+ };
+
+ //----------------------------------------------------------------------------
+ }
+}
+
+#endif
return myVisuGen->MeshOnEntity(theResult,theMeshName,theEntity);
}
+ Prs3d_ptr VISU_Gen_i::CreatePrs3d(VISUType theType,
+ SALOMEDS::Study_ptr theStudy)
+ {
+ return myVisuGen->CreatePrs3d(theType,theStudy);
+ }
+
Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult,
const char* theMeshName,
VISU::Entity theEntity,
}
- ScalarMap_ptr VISU_Gen_i::ScalarMapOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ ScalarMap_ptr
+ VISU_Gen_i
+ ::ScalarMapOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
return myVisuGen->ScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
}
- GaussPoints_ptr VISU_Gen_i::GaussPointsOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ GaussPoints_ptr
+ VISU_Gen_i
+ ::GaussPointsOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
return myVisuGen->GaussPointsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
}
- DeformedShape_ptr VISU_Gen_i::DeformedShapeOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ DeformedShape_ptr
+ VISU_Gen_i
+ ::DeformedShapeOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
return myVisuGen->DeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
}
- ScalarMapOnDeformedShape_ptr VISU_Gen_i::ScalarMapOnDeformedShapeOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ ScalarMapOnDeformedShape_ptr
+ VISU_Gen_i
+ ::ScalarMapOnDeformedShapeOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
return myVisuGen->ScalarMapOnDeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
}
- Vectors_ptr VISU_Gen_i::VectorsOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ Vectors_ptr
+ VISU_Gen_i
+ ::VectorsOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
return myVisuGen->VectorsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
}
- IsoSurfaces_ptr VISU_Gen_i::IsoSurfacesOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ IsoSurfaces_ptr
+ VISU_Gen_i
+ ::IsoSurfacesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
return myVisuGen->IsoSurfacesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
}
- StreamLines_ptr VISU_Gen_i::StreamLinesOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ StreamLines_ptr
+ VISU_Gen_i
+ ::StreamLinesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
return myVisuGen->StreamLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
}
- CutPlanes_ptr VISU_Gen_i::CutPlanesOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ CutPlanes_ptr
+ VISU_Gen_i
+ ::CutPlanesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
return myVisuGen->CutPlanesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
}
- CutLines_ptr VISU_Gen_i::CutLinesOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ CutLines_ptr
+ VISU_Gen_i
+ ::CutLinesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
return myVisuGen->CutLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
}
- Plot3D_ptr VISU_Gen_i::Plot3DOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ Plot3D_ptr
+ VISU_Gen_i
+ ::Plot3DOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
return myVisuGen->Plot3DOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
}
return myVisuGen->DumpPython(theStudy, theIsPublished, theIsValidScript);
}
+ VISU::ColoredPrs3dCache_ptr
+ VISU_Gen_i::
+ GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy)
+ {
+ return myVisuGen->GetColoredPrs3dCache(theStudy);
+ }
};
#include "SALOME_Component_i.hxx"
-namespace VISU{
+namespace VISU
+{
class VISU_Gen_i : public virtual POA_VISU::VISU_Gen,
public virtual ::Engines_Component_i
{
virtual Result_ptr ImportMed(SALOMEDS::SObject_ptr theMedSObject);
virtual Result_ptr ImportMedField(SALOME_MED::FIELD_ptr theField);
+ Prs3d_ptr
+ CreatePrs3d(VISUType theType,
+ SALOMEDS::Study_ptr theStudy);
+
//Create Presentation Of Submeshes
virtual Mesh_ptr MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity);
virtual Mesh_ptr FamilyMeshOnEntity(Result_ptr theResult, const char* theMeshName,
const char* theGroupName, const char* theNewName);
//Create Presentation Of Results
- virtual ScalarMap_ptr ScalarMapOnField
- (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration);
- virtual GaussPoints_ptr GaussPointsOnField
- (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration);
- virtual DeformedShape_ptr DeformedShapeOnField
- (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration);
- virtual Vectors_ptr VectorsOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration);
- virtual IsoSurfaces_ptr IsoSurfacesOnField
- (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration);
- virtual CutPlanes_ptr CutPlanesOnField
- (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration);
- virtual CutLines_ptr CutLinesOnField
- (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration);
- virtual StreamLines_ptr StreamLinesOnField
- (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration);
- virtual Plot3D_ptr Plot3DOnField (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration);
- virtual ScalarMapOnDeformedShape_ptr ScalarMapOnDeformedShapeOnField
- (Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, CORBA::Double theIteration);
+ virtual
+ ScalarMap_ptr
+ ScalarMapOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration);
+
+ virtual
+ GaussPoints_ptr
+ GaussPointsOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration);
+
+ virtual
+ DeformedShape_ptr
+ DeformedShapeOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration);
+
+ virtual
+ Vectors_ptr
+ VectorsOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration);
+
+ virtual
+ IsoSurfaces_ptr
+ IsoSurfacesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration);
+
+ virtual
+ CutPlanes_ptr
+ CutPlanesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration);
+
+ virtual
+ CutLines_ptr
+ CutLinesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration);
+
+ virtual
+ StreamLines_ptr
+ StreamLinesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration);
+
+ virtual
+ Plot3D_ptr
+ Plot3DOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration);
+
+ virtual
+ ScalarMapOnDeformedShape_ptr
+ ScalarMapOnDeformedShapeOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration);
+
//Create Digital Presentation
virtual Table_ptr CreateTable(const char* theTableEntry);
virtual Curve_ptr CreateCurve(Table_ptr theTable, CORBA::Long theHRow, CORBA::Long theVRow);
virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
CORBA::Boolean theIsPublished,
CORBA::Boolean& theIsValidScript);
+
+ virtual
+ VISU::ColoredPrs3dCache_ptr
+ GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy);
};
};
VISU_GaussPtsActorFactory.h \
VISU_Event.h \
VISU_Actor.h \
+ VISU_DataSetActor.h \
VISU_MeshAct.h \
VISU_ScalarMapAct.h \
VISU_GaussPtsAct.h \
dist_libVisuObject_la_SOURCES = \
VISU_Actor.cxx \
+ VISU_DataSetActor.cxx \
VISU_MeshAct.cxx \
VISU_ScalarMapAct.cxx \
VISU_GaussPtsDeviceActor.cxx \
#include <vtkShrinkFilter.h>
#include <vtkShrinkPolyData.h>
-#include <vtkDataSetMapper.h>
#include <vtkGeometryFilter.h>
#include <vtkObjectFactory.h>
#include "utilities.h"
+#include "VISU_PipeLineUtils.hxx"
+
using namespace std;
static int MYVTKDEBUG = 0;
#ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
#endif
//#define ENABLE_ANNOTATION
//----------------------------------------------------------------------------
-vtkStandardNewMacro(VISU_Actor);
+//vtkStandardNewMacro(VISU_Actor);
//----------------------------------------------------------------------------
VISU_Actor
myIsVTKMapping(false),
myPrs3d(NULL),
myActorFactory(NULL),
- myMapper(vtkDataSetMapper::New()),
myIsShrunk(false),
myIsShrinkable(false),
myShrinkFilter(VTKViewer_ShrinkFilter::New()),
{
if(MYDEBUG) MESSAGE("VISU_Actor::VISU_Actor - this = "<<this);
- myMapper->Delete();
myShrinkFilter->Delete();
myStoreMapping = true;
//----------------------------------------------------------------------------
void
VISU_Actor
-::ShallowCopy(vtkProp *prop)
+::DeepCopy(VISU_Actor *theActor)
{
- VISU_Actor *anActor = VISU_Actor::SafeDownCast(prop);
- if(anActor != NULL){
- setName(anActor->getName());
- if(anActor->hasIO()) setIO(anActor->getIO());
- }
- Superclass::ShallowCopy(prop);
+ highlight(theActor->isHighlighted());
+ SetRepresentation(theActor->GetRepresentation());
+ SetShrinkable(theActor->IsShrunkable());
+ SetShrinkFactor(theActor->GetShrinkFactor());
+ if(theActor->IsShrunk())
+ SetShrink();
+ else
+ UnShrink();
+ SetOpacity(theActor->GetOpacity());
+ SetLineWidth(theActor->GetLineWidth());
+ SetPosition(theActor->GetPosition());
}
+
+//----------------------------------------------------------------------------
void
VISU_Actor
::ShallowCopyPL(VISU_PipeLine* thePipeLine)
{
- myPipeLine->ShallowCopy(thePipeLine);
-
- vtkDataSet* aDatsSet = myMapper->GetInput();
- GetMapper()->ShallowCopy(thePipeLine->GetMapper());
-
- // To restore mapper input from pipeline
- myMapper->SetInput(aDatsSet);
+ myPipeLine->ShallowCopy(thePipeLine, true);
}
//----------------------------------------------------------------------------
VISU_Actor
::UpdateFromFactory()
{
- myActorFactory->UpdateActor(this);
- Update();
+ if(myUpdateFromFactoryTime.GetMTime() < myActorFactory->GetMTime()){
+ myUpdateFromFactoryTime.Modified();
+ myActorFactory->UpdateActor(this);
+ Update();
+ }
}
void
}
//----------------------------------------------------------------------------
-void
-VISU_Actor
-::SetMapperInput(vtkDataSet* theDataSet)
-{
- myMapper->SetInput(theDataSet);
- SetMapper(myMapper.GetPointer());
-}
-
void
VISU_Actor
::SetPipeLine(VISU_PipeLine* thePipeLine)
if(vtkMapper *aMapper = myPipeLine->GetMapper()){
if(vtkDataSet *aDataSet = aMapper->GetInput()){
SetShrinkable(thePipeLine->IsShrinkable());
-
SetMapperInput(aDataSet);
}
}
return GetCurrentPL()->GetOutput();
}
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_Actor
+::GetMemorySize()
+{
+ static vtkFloatingPointType ERR_SIZE_CALC = 1.00;
+ vtkDataSet* aDataSet = GetMapper()->GetInput();
+ unsigned long int aSize = size_t(aDataSet->GetActualMemorySize() * 1024 * ERR_SIZE_CALC);
+
+ aDataSet = myGeomFilter->GetOutput();
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(IsShrunk()){
+ aDataSet = myShrinkFilter->GetOutput();
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+ }
+
+ return aSize;
+}
+
//----------------------------------------------------------------------------
vtkIdType
VISU_Actor
if(myIsVTKMapping)
return Superclass::GetNodeObjId(theID);
- vtkIdType anID = myGeomFilter->GetNodeObjId(theID);
-
- if(myIsShrunk)
- anID = myShrinkFilter->GetNodeObjId(anID);
-
- return GetCurrentPL()->GetNodeObjID(anID);
+ return VISU::GetNodeObjID(GetMapper()->GetInput(), theID);
}
vtkIdType
if(myIsVTKMapping)
return theID;
- return GetCurrentPL()->GetNodeVTKID(theID);
+ return VISU::GetNodeVTKID(GetMapper()->GetInput(), theID);
}
vtkFloatingPointType*
if(myIsVTKMapping)
return Superclass::GetNodeCoord(theObjID);
- return GetCurrentPL()->GetNodeCoord(theObjID);
+ return VISU::GetNodeCoord(GetInput(), theObjID);
}
if(myIsVTKMapping)
return Superclass::GetElemObjId(theID);
- vtkIdType anID = myGeomFilter->GetElemObjId(theID);
-
- if(myIsShrunk)
- anID = myShrinkFilter->GetElemObjId(anID);
-
- return GetCurrentPL()->GetElemObjID(anID);
+ return VISU::GetElemObjID(GetMapper()->GetInput(), theID);
}
vtkIdType
if(myIsVTKMapping)
return theID;
- return GetCurrentPL()->GetElemVTKID(theID);
+ return VISU::GetElemVTKID(GetMapper()->GetInput(), theID);
}
vtkCell*
if(myIsVTKMapping)
return Superclass::GetElemCell(theObjID);
- return GetCurrentPL()->GetElemCell(theObjID);
+ return VISU::GetElemCell(GetInput(), theObjID);
}
#include "SVTK_DeviceActor.h"
#include <string>
+#include <vtkTimeStamp.h>
#include <vtkSmartPointer.h>
class vtkProp;
class vtkProperty;
-class vtkDataSetMapper;
class vtkTextMapper;
class vtkTextActor;
class vtkInteractorStyle;
public:
vtkTypeMacro(VISU_Actor,SALOME_Actor);
- static
- VISU_Actor*
- New();
+ //static
+ //VISU_Actor*
+ //New();
+ //! Copies all properties from the given actor
+ virtual
void
- ShallowCopy(vtkProp *prop);
+ DeepCopy(VISU_Actor *theActor);
virtual
void
vtkDataSet*
GetInput();
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
//----------------------------------------------------------------------------
virtual
vtkIdType
virtual
void
- SetMapperInput(vtkDataSet* theDataSet);
+ SetMapperInput(vtkDataSet* theDataSet) = 0;
virtual
VISU_PipeLine*
bool myIsVTKMapping;
VISU::Prs3d_i* myPrs3d;
vtkSmartPointer<VISU_PipeLine> myPipeLine;
- vtkSmartPointer<vtkDataSetMapper> myMapper;
VISU::TActorFactory* myActorFactory;
+ vtkTimeStamp myUpdateFromFactoryTime;
boost::signal1<void,VISU_Actor*> myDestroySignal;
vtkSmartPointer<VTKViewer_ShrinkFilter> myShrinkFilter;
~TActorFactory()
{}
+ //! Gets know whether the factory instance can be used for actor management or not
+ virtual
+ bool
+ GetActiveState() = 0;
+
+ //! Return modified time of the factory
+ virtual
+ unsigned long int
+ GetMTime() = 0;
+
//! To update the actor
virtual
void
--- /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 :
+// Author :
+// Module : VISU
+
+#include "VISU_DataSetActor.h"
+#include "VISU_UnstructuredGridPL.hxx"
+#include "VISU_PipeLineUtils.hxx"
+
+#include <vtkDataSetMapper.h>
+#include <vtkObjectFactory.h>
+
+#include <boost/bind.hpp>
+
+using namespace std;
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(VISU_DataSetActor);
+
+//----------------------------------------------------------------------------
+VISU_DataSetActor
+::VISU_DataSetActor():
+ myMapper(vtkDataSetMapper::New())
+{
+ if(MYDEBUG) MESSAGE("VISU_DataSetActor::VISU_DataSetActor - this = "<<this);
+
+ myMapper->Delete();
+}
+
+//----------------------------------------------------------------------------
+VISU_DataSetActor
+::~VISU_DataSetActor()
+{
+ if(MYDEBUG) MESSAGE("~VISU_DataSetActor() - this = "<<this);
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_DataSetActor
+::ShallowCopyPL(VISU_PipeLine* thePipeLine)
+{
+ Superclass::ShallowCopyPL(thePipeLine);
+
+ if(VISU_UnstructuredGridPL* aPipeLine = dynamic_cast<VISU_UnstructuredGridPL*>(thePipeLine)){
+ vtkDataSetMapper* aTarget = GetDataSetMapper();
+ vtkDataSetMapper* aSource = aPipeLine->GetDataSetMapper();
+ VISU::CopyDataSetMapper(aTarget, aSource, true);
+ aTarget->SetLookupTable(aSource->GetLookupTable());
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_DataSetActor
+::SetMapperInput(vtkDataSet* theDataSet)
+{
+ myMapper->SetInput(theDataSet);
+ SetMapper(myMapper.GetPointer());
+}
+
+//----------------------------------------------------------------------------
+vtkDataSetMapper*
+VISU_DataSetActor
+::GetDataSetMapper()
+{
+ return myMapper.GetPointer();
+}
--- /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 :
+// Author :
+// Module : VISU
+
+#ifndef VISU_DATASETACTOR_H
+#define VISU_DATASETACTOR_H
+
+#include "VISU_Actor.h"
+
+class vtkDataSetMapper;
+
+#ifdef _WIN_32
+#define VTKOCC_EXPORT __declspec (dllexport)
+#else
+#define VTKOCC_EXPORT VTK_EXPORT
+#endif
+
+//----------------------------------------------------------------------------
+class VTKOCC_EXPORT VISU_DataSetActor : public VISU_Actor
+{
+ public:
+ vtkTypeMacro(VISU_DataSetActor,VISU_Actor);
+
+ static
+ VISU_DataSetActor*
+ New();
+
+ virtual
+ void
+ ShallowCopyPL(VISU_PipeLine* thePipeLine);
+
+ virtual
+ vtkDataSetMapper*
+ GetDataSetMapper();
+
+ //----------------------------------------------------------------------------
+ protected:
+ VISU_DataSetActor();
+
+ virtual
+ ~VISU_DataSetActor();
+
+ virtual
+ void
+ SetMapperInput(vtkDataSet* theDataSet);
+
+ //----------------------------------------------------------------------------
+ vtkSmartPointer<vtkDataSetMapper> myMapper;
+};
+
+#endif //VISU_DATASETACTOR_H
#include "VISU_ScalarBarCtrl.hxx"
#include "VISU_ScalarBarActor.hxx"
-#include "SALOME_ExtractGeometry.h"
-
#include "VISU_Event.h"
#include "SVTK_Actor.h"
#include <vtkTextMapper.h>
#include <vtkTextProperty.h>
-#include <vtkCellData.h>
#include <vtkPointData.h>
-
#include <vtkDataArray.h>
-#include <vtkFloatArray.h>
#include <vtkSphereSource.h>
#include <vtkPolyDataMapper.h>
#include <boost/bind.hpp>
#include <vtkUnstructuredGrid.h>
-#include <vtkDataSetMapper.h>
+#include <vtkPolyDataMapper.h>
#include <vtkRenderWindow.h>
#include <vtkCellArray.h>
#include <vtkCell.h>
myBarVisibility(true),
myPickingSettings(NULL),
myInsideCursorSettings(NULL),
- myCurrentPL(NULL)
+ myCurrentPL(NULL),
+ myMapper(vtkPolyDataMapper::New())
{
if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::VISU_GaussPtsAct - this = "<<this);
myCellActor->GetProperty()->SetDiffuse(0.0);
myScalarBarCtrl->Delete();
+
+ myMapper->Delete();
}
VISU_GaussPtsAct
return myGaussPointsPL.GetPointer();
}
+//----------------------------------------------------------------------------
+void
+VISU_GaussPtsAct
+::DeepCopy(VISU_Actor *theActor)
+{
+ if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor)){
+ Superclass::DeepCopy(theActor);
+ SetBarVisibility(anActor->GetBarVisibility());
+ }
+}
+
+//----------------------------------------------------------------------------
void
VISU_GaussPtsAct
::ShallowCopyPL(VISU_PipeLine* thePipeLine)
{
if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::ShallowCopyPL - this = "<<this);
-
+
Superclass::ShallowCopyPL(thePipeLine);
-
+
UpdateInsideCursorSettings();
-
+
Highlight(isHighlighted());
}
//----------------------------------------------------------------------------
+
vtkMapper*
VISU_GaussPtsAct
::GetMapper()
{
+ //vtkMapper* aMapper = myCurrentPL->GetPointSpriteMapper();
+ //aMapper->Update();
+ //return aMapper;
myMapper->Update();
- return Superclass::GetMapper();
+ return myMapper.GetPointer();
}
vtkFloatingPointType*
}
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_GaussPtsAct
+::GetMemorySize()
+{
+ vtkDataSet* aDataSet = myDeviceActor->GetMapper()->GetInput();
+ unsigned long int aSize = aDataSet->GetActualMemorySize() * 1024;
+
+ aSize += Superclass::GetMemorySize();
+
+ return aSize;
+}
+
//----------------------------------------------------------------------------
void
VISU_GaussPtsAct
CreatePipeLine(VISU_GaussPointsPL* thePipeLine)
{
VISU_GaussPointsPL* aPipeLine = VISU_GaussPointsPL::New();
- aPipeLine->SetGaussPtsIDMapper(thePipeLine->GetGaussPtsIDMapper());
- aPipeLine->ShallowCopy(thePipeLine);
+ aPipeLine->ShallowCopy(thePipeLine, true);
aPipeLine->Update();
return aPipeLine;
}
myDeviceActor->SetPipeLine(GetGaussPointsPL());
myCurrentPL = myDeviceActor->GetPipeLine();
+ //SetMapper(myCurrentPL->GetPointSpriteMapper());
+
myMapper->SetInput(myCurrentPL->GetPickableDataSet());
SetMapper(myMapper.GetPointer());
}
VISU_GaussPointsPL* theGaussPointsPL)
{
vtkFloatingPointType aRadius = 0.5;
- if(theGaussPointsPL->GetPSMapper()->GetPointSpriteMode() == 1) // Geometry mode
+ if(theGaussPointsPL->GetPointSpriteMapper()->GetPointSpriteMode() == 1) // Geometry mode
aRadius *= theGaussPointsPL->GetSize() * theGaussPointsPL->GetAverageCellSize();
else if(theGaussPointsPL->GetBicolor()){
vtkFloatingPointType aVal = theScalarArray->GetTuple1(theVTKID);
if(anIsChanged){
vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
vtkDataSet* aDataSet = GetInput();
- vtkCellData* aCellData = aDataSet->GetCellData();
- if(vtkDataArray *aScalarArray = aCellData->GetScalars()){
+ vtkPointData* aPointData = aDataSet->GetPointData();
+ if(vtkDataArray *aScalarArray = aPointData->GetScalars()){
vtkFloatingPointType aPyramidHeight = myPickingSettings->GetPyramidHeight();
aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
//vtkFloatingPointType aColor[3] = myPreHighlightActor->GetProperty()->GetColor();
anInteractor->SetDolly(aDollyWas);
anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
+ anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);
+
mySelectionMode = aSelectionMode;
ChangeZoom(myPickingSettings,
vtkFloatingPointType aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.};
//
vtkDataSet* aDataSet = GetInput();
- vtkCellData* aDataSetAttributes = aDataSet->GetCellData();
+ vtkPointData* aDataSetAttributes = aDataSet->GetPointData();
//
if(vtkDataArray* aScalarArray = aDataSetAttributes->GetScalars()){
vtkFloatingPointType aVal = aScalarArray->GetTuple1(aVtkId);
}
if(vtkDataArray* aFieldArray = aDataSetAttributes->GetArray("VISU_FIELD")){
- if(vtkFloatArray *aFloatArray = dynamic_cast<vtkFloatArray*>(aFieldArray)){
- int aNbComp = aFloatArray->GetNumberOfComponents();
- aStr<<"\nData: {";
- int anId = 0;
- while(anId < aNbComp){
- vtkFloatingPointType aComp = aFloatArray->GetComponent(aVtkId,anId++);
- aStr<<aComp;
- if(anId < aNbComp)
- aStr<<"; ";
- }
- aStr<<"}";
+ int aNbComp = aFieldArray->GetNumberOfComponents();
+ std::vector<vtkFloatingPointType> aTuple(aNbComp);
+ aFieldArray->GetTuple(aVtkId, &aTuple[0]);
+
+ aStr<<"\nData: {";
+ int anId = 0;
+ while(anId < aNbComp){
+ vtkFloatingPointType aComp = aTuple[anId++];
+ aStr<<aComp;
+ if(anId < aNbComp)
+ aStr<<"; ";
}
+ aStr<<"}";
}
//
// myTextActor
myCellSource->Reset();
myCellSource->Modified(); // a VTK bug
- myCellSource->SetPoints(aParent->GetVTKOutput()->GetPoints());
+ vtkUnstructuredGrid* aDataSet = aParent->GetUnstructuredGridOutput();
+ myCellSource->SetPoints(aDataSet->GetPoints());
VISU::TGaussPointID aGaussPointID = aGaussPtsIDMapper->GetObjID(anObjId);
vtkIdType aCellID = aGaussPointID.first;
VISU_GaussPointsPL* aPipeline = theActor->GetPipeLine();
- SALOME_ExtractGeometry* anExtractGeometry = aPipeline->GetExtractGeometryFilter();
- vtkImplicitFunction* anImplicitFunction = anExtractGeometry->GetImplicitFunction();
+ vtkImplicitFunction* anImplicitFunction = aPipeline->GetImplicitFunction();
- aPipeline->ShallowCopy(GetGaussPointsPL());
+ aPipeline->ShallowCopy(GetGaussPointsPL(), true);
aPipeline->SetImplicitFunction(anImplicitFunction); // To restore
Update();
}
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_GaussPtsAct
+::GetMTime()
+{
+ unsigned long int aTime = Superclass::GetMTime();
+ aTime = std::max(aTime, myGaussPointsPL->GetPointSpriteMapper()->GetMTime() );
+ return aTime;
+}
+
//==============================================================================
vtkStandardNewMacro(VISU_GaussPtsAct1);
myOutsideDeviceActor->SetPipeLine(aPipeLine);
aPipeLine->Delete();
- SALOME_ExtractGeometry* anExtractGeometry = aPipeLine->GetExtractGeometryFilter();
- anExtractGeometry->SetExtractBoundaryCells(true);
- anExtractGeometry->SetExtractInside(true);
+ aPipeLine->SetExtractBoundaryCells(true);
+ aPipeLine->SetExtractInside(true);
}
}
VISU_GaussPointsPL* aPipeline = myOutsideDeviceActor->GetPipeLine();
- SALOME_ExtractGeometry* anExtractGeometry = aPipeline->GetExtractGeometryFilter();
- vtkImplicitFunction* anImplicitFunction = anExtractGeometry->GetImplicitFunction();
+ vtkImplicitFunction* anImplicitFunction = aPipeline->GetImplicitFunction();
vtkFloatingPointType aMagnification = aPipeline->GetMagnification();
- aPipeline->ShallowCopy(GetGaussPointsPL());
+ aPipeline->ShallowCopy(GetGaussPointsPL(), true);
aPipeline->SetImplicitFunction(anImplicitFunction); // To restore
- anExtractGeometry->SetExtractBoundaryCells(true);
- anExtractGeometry->SetExtractInside(true);
+ aPipeline->SetExtractBoundaryCells(true);
+ aPipeline->SetExtractInside(true);
aPipeline->SetMagnification( aMagnification );
aPipeline->SetPrimitiveType( myOutsideCursorSettings->GetPrimitiveType() );
if( myOutsideCursorSettings->GetUniform() )
{
- myOutsideDeviceActor->GetPSMapper()->ScalarVisibilityOff();
- myOutsideDeviceActor->GetPSMapper()->SetPointSpriteMode( 1 ); // Geometry mode
+ myOutsideDeviceActor->GetPointSpriteMapper()->ScalarVisibilityOff();
+ myOutsideDeviceActor->GetPointSpriteMapper()->SetPointSpriteMode( 1 ); // Geometry mode
myOutsideDeviceActor->GetProperty()->SetColor( myOutsideCursorSettings->GetColor() );
}
else
{
- myOutsideDeviceActor->GetPSMapper()->SetPointSpriteMode( 2 ); // Outside cursor mode
- myOutsideDeviceActor->GetPSMapper()->SetColorModeToMapScalars();
- myOutsideDeviceActor->GetPSMapper()->ScalarVisibilityOn();
+ myOutsideDeviceActor->GetPointSpriteMapper()->SetPointSpriteMode( 2 ); // Outside cursor mode
+ myOutsideDeviceActor->GetPointSpriteMapper()->SetColorModeToMapScalars();
+ myOutsideDeviceActor->GetPointSpriteMapper()->ScalarVisibilityOn();
}
aPipeline->Update();
Superclass::OnInteractorEvent(theEvent);
}
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_GaussPtsAct1
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
+ if(IsSegmentationEnabled()){
+ aSize += myInsideDeviceActor->GetMemorySize();
+ aSize += myOutsideDeviceActor->GetMemorySize();
+ }
+ return aSize;
+}
+
+
//==============================================================================
vtkStandardNewMacro(VISU_GaussPtsAct2);
}
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_GaussPtsAct2
+::GetMemorySize()
+{
+ if(IsSegmentationEnabled())
+ return Superclass::GetMemorySize();
+ return 0;
+}
+
+
//----------------------------------------------------------------------------
void
VISU_GaussPtsAct2
class VISU_FramedTextActor;
class vtkUnstructuredGrid;
-class vtkDataSetMapper;
+class vtkPolyDataMapper;
class vtkDataArray;
class vtkInteractorObserver;
VISU_GaussPointsPL*
GetGaussPointsPL();
+ //! Copies all properties from the given actor
+ virtual
+ void
+ DeepCopy(VISU_Actor *theActor);
+
virtual
void
ShallowCopyPL(VISU_PipeLine* thePipeLine);
vtkDataSet*
GetInput();
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
//----------------------------------------------------------------------------
virtual
void
bool
GetBarVisibility();
- virtual void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
+ virtual
+ void
+ SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
//! Return the information about pipeline magnification changing.
/*! True indicates that magnification is increased, false - decreased. */
int
GetPickable();
+ //----------------------------------------------------------------------------
+ virtual
+ unsigned long int
+ GetMTime();
+
protected:
//----------------------------------------------------------------------------
VISU_GaussPtsAct();
VISU_GaussPointsPL* myCurrentPL;
vtkSmartPointer<VISU_GaussPointsPL> myGaussPointsPL;
+ vtkSmartPointer<vtkPolyDataMapper> myMapper;
+
vtkIdType myLastObjPointID;
vtkSmartPointer<VISU_FramedTextActor> myTextActor;
void
SetTransform(VTKViewer_Transform* theTransform);
- virtual void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
+ virtual
+ void
+ SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
protected:
//----------------------------------------------------------------------------
VISU_GaussPtsAct1();
void
SetVisibility(int theMode);
- virtual void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
+ virtual
+ void
+ SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
protected:
//----------------------------------------------------------------------------
VISU_GaussPtsAct2();
VISU_OpenGLPointSpriteMapper*
VISU_GaussPtsDeviceActor
-::GetPSMapper()
+::GetPointSpriteMapper()
{
return myMapper.GetPointer();
}
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_GaussPtsDeviceActor
+::GetMemorySize()
+{
+ vtkDataSet* aDataSet = GetMapper()->GetInput();
+ unsigned long int aSize = aDataSet->GetActualMemorySize() * 1024;
+
+ aSize += GetPipeLine()->GetMemorySize();
+
+ return aSize;
+}
+
+//----------------------------------------------------------------------------
int
VISU_GaussPtsDeviceActor
::GetPickable()
::SetPipeLine(VISU_GaussPointsPL* thePipeLine)
{
myPipeLine = thePipeLine;
- myMapper = thePipeLine->GetPSMapper();
+ myMapper = thePipeLine->GetPointSpriteMapper();
vtkPolyData* aDataSet = myMapper->GetInput();
int anId = 0;
VISU_GaussPtsDeviceActor
::ShallowCopyPL(VISU_GaussPointsPL* thePipeLine)
{
- myPipeLine->ShallowCopy(thePipeLine);
+ myPipeLine->ShallowCopy(thePipeLine, true);
}
ShallowCopyPL(VISU_GaussPointsPL* thePipeLine);
VISU_OpenGLPointSpriteMapper*
- GetPSMapper();
+ GetPointSpriteMapper();
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
virtual
int
GetPickable();
}
+//----------------------------------------------------------------------------
+void
+VISU_MeshAct
+::DeepCopy(VISU_Actor *theActor)
+{
+ if(VISU_MeshAct* anActor = dynamic_cast<VISU_MeshAct*>(theActor)){
+ Superclass::DeepCopy(theActor);
+ GetSurfaceProperty()->DeepCopy(anActor->GetSurfaceProperty());
+ GetEdgeProperty()->DeepCopy(anActor->GetEdgeProperty());
+ GetNodeProperty()->DeepCopy(anActor->GetNodeProperty());
+ }
+}
+
+
//----------------------------------------------------------------------------
void
VISU_MeshAct
myEdgeActor->SetRepresentation(SVTK::Representation::Wireframe);
}
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_MeshAct
+::GetMemorySize()
+{
+ vtkDataSet* aDataSet;
+ unsigned long int aSize = Superclass::GetMemorySize();
+ {
+ aDataSet = mySurfaceActor->GetInput();
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ aDataSet = mySurfaceActor->GetMapper()->GetInput();
+ aSize += aDataSet->GetActualMemorySize() * 1024 * 2;
+ }
+ {
+ aDataSet = myEdgeActor->GetInput();
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ aDataSet = myEdgeActor->GetMapper()->GetInput();
+ aSize += aDataSet->GetActualMemorySize() * 1024 * 2;
+ }
+ {
+ aDataSet = myNodeActor->GetInput();
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ aDataSet = myNodeActor->GetMapper()->GetInput();
+ aSize += aDataSet->GetActualMemorySize() * 1024 * 2;
+ }
+ return aSize;
+}
+
//----------------------------------------------------------------------------
int
VISU_MeshAct
#ifndef VISU_MeshAct_HeaderFile
#define VISU_MeshAct_HeaderFile
-#include "VISU_Actor.h"
+#include "VISU_DataSetActor.h"
+#include "SVTK_DeviceActor.h"
-class VTKOCC_EXPORT VISU_MeshAct : public VISU_Actor
+
+class VTKOCC_EXPORT VISU_MeshAct : public VISU_DataSetActor
{
public:
- vtkTypeMacro(VISU_MeshAct,VISU_Actor);
- static VISU_MeshAct* New();
+ vtkTypeMacro(VISU_MeshAct,VISU_DataSetActor);
+ static
+ VISU_MeshAct*
+ New();
+
+ //! Copies all properties from the given actor
+ virtual
+ void
+ DeepCopy(VISU_Actor *theActor);
//! Apply view transformation
virtual
void
UnShrink();
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
virtual
int
RenderOpaqueGeometry(vtkViewport *ren);
#include <vtkMapper.h>
#include <vtkDataSetMapper.h>
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_ScalarMapAct);
static vtkFloatingPointType EPS = 1.0 / VTK_LARGE_FLOAT;
+//----------------------------------------------------------------------------
VISU_ScalarMapAct
::VISU_ScalarMapAct()
{
m->Delete();
}
+//----------------------------------------------------------------------------
VISU_ScalarMapAct
::~VISU_ScalarMapAct()
{
return mySurfaceActor->GetProperty()->GetLineWidth();
}
+//----------------------------------------------------------------------------
+void
+VISU_ScalarMapAct
+::DeepCopy(VISU_Actor *theActor)
+{
+ if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
+ Superclass::DeepCopy(theActor);
+ SetBarVisibility(anActor->GetBarVisibility());
+ SetShading(anActor->IsShading());
+ }
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_ScalarMapAct
::AddToRender(vtkRenderer* theRenderer)
theRenderer->AddActor2D(myScalarBar);
}
+//----------------------------------------------------------------------------
void
VISU_ScalarMapAct
::RemoveFromRender(vtkRenderer* theRenderer)
Superclass::RemoveFromRender(theRenderer);
}
+//----------------------------------------------------------------------------
void
VISU_ScalarMapAct
::SetVisibility(int theMode)
myScalarBar->SetVisibility(myBarVisibility && theMode);
}
+//----------------------------------------------------------------------------
int
VISU_ScalarMapAct
::GetBarVisibility()
return myBarVisibility;
}
+//----------------------------------------------------------------------------
VISU_ScalarBarActor*
VISU_ScalarMapAct
::GetScalarBar()
return myScalarBar;
}
+//----------------------------------------------------------------------------
void
VISU_ScalarMapAct
::SetBarVisibility(bool theMode)
{
myBarVisibility = theMode;
- if(myScalarBar) myScalarBar->SetVisibility(myBarVisibility);
+ if(myScalarBar)
+ myScalarBar->SetVisibility(myBarVisibility);
}
+//----------------------------------------------------------------------------
void
VISU_ScalarMapAct
::SetRepresentation(int theMode)
}
+//----------------------------------------------------------------------------
void
VISU_ScalarMapAct
::SetShading(bool theOn)
}
}
+//----------------------------------------------------------------------------
bool
VISU_ScalarMapAct
::IsShading()
return 1;
}
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_ScalarMapAct
+::GetMemorySize()
+{
+ return Superclass::GetMemorySize();
+}
+
+//----------------------------------------------------------------------------
#ifndef VISU_ScalarMapAct_HeaderFile
#define VISU_ScalarMapAct_HeaderFile
-#include "VISU_Actor.h"
+#include "VISU_DataSetActor.h"
class VISU_ScalarBarActor;
-class VTKOCC_EXPORT VISU_ScalarMapAct : public VISU_Actor
+class VTKOCC_EXPORT VISU_ScalarMapAct : public VISU_DataSetActor
{
public:
- vtkTypeMacro(VISU_ScalarMapAct,VISU_Actor);
+ vtkTypeMacro(VISU_ScalarMapAct,VISU_DataSetActor);
static
VISU_ScalarMapAct*
~VISU_ScalarMapAct();
+ //! Copies all properties from the given actor
+ virtual
+ void
+ DeepCopy(VISU_Actor *theActor);
+
virtual
void
ShallowCopyPL(VISU_PipeLine* thePipeLine);
bool
IsShading();
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
protected:
VISU_ScalarMapAct();
::SetPipeLine(VISU_PipeLine* thePipeLine)
{
myVectorsPL = dynamic_cast<VISU_VectorsPL*>(thePipeLine);
- VISU_Actor::SetPipeLine(myVectorsPL);
- myVectorsPL->Delete();
+ VISU_Actor::SetPipeLine(myVectorsPL.GetPointer());
}
}
vtkLODActor::SetMapper(theMapper);
}
+
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_VectorsAct
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ aSize += GetPipeLine()->GetMemorySize();
+
+ return aSize;
+}
#include "VISU_ScalarMapAct.h"
+#include <vtkSmartPointer.h>
+
class VTKViewer_Transform;
class VISU_VectorsPL;
-class VTKOCC_EXPORT VISU_VectorsAct : public VISU_ScalarMapAct {
+class VTKOCC_EXPORT VISU_VectorsAct : public VISU_ScalarMapAct
+{
public:
vtkTypeMacro(VISU_VectorsAct,VISU_ScalarMapAct);
void
SetMapper(vtkMapper* theMapper);
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
protected:
VISU_VectorsAct();
~VISU_VectorsAct();
- VISU_VectorsPL* myVectorsPL;
+ vtkSmartPointer<VISU_VectorsPL> myVectorsPL;
};
#endif
lib_LTLIBRARIES= libVisuPipeLine.la
salomeinclude_HEADERS= \
- VISU_PipeLine.hxx \
+ VISU_MapperHolder.hxx \
+ VISU_DataSetMapperHolder.hxx \
+ VISU_PolyDataMapperHolder.hxx \
+ VISU_PointSpriteMapperHolder.hxx \
VISU_PipeLineUtils.hxx \
+ VISU_PipeLine.hxx \
+ VISU_ColoredPL.hxx \
+ VISU_UnstructuredGridPL.hxx \
VISU_MeshPL.hxx \
VISU_ScalarMapPL.hxx \
VISU_CutPlanesPL.hxx \
VISU_OpenGLPointSpriteMapper.hxx \
VISU_ImplicitFunctionWidget.hxx \
SALOME_ExtractGeometry.h \
+ SALOME_ExtractPolyDataGeometry.h \
VISU_ScalarBarCtrl.hxx \
VISU_PlanesWidget.hxx \
VISU_SphereWidget.hxx \
VISU_WidgetCtrl.hxx \
VISU_ScalarMapOnDeformedShapePL.hxx \
- VISU_PrsMergerPL.hxx \
VISUPipeline.hxx
dist_libVisuPipeLine_la_SOURCES= \
- VISU_PipeLine.cxx \
+ VISU_MapperHolder.cxx \
+ VISU_DataSetMapperHolder.cxx \
+ VISU_PolyDataMapperHolder.cxx \
+ VISU_PointSpriteMapperHolder.cxx \
VISU_PipeLineUtils.cxx \
+ VISU_PipeLine.cxx \
+ VISU_ColoredPL.cxx \
+ VISU_UnstructuredGridPL.cxx \
VISU_MeshPL.cxx \
VISU_ScalarMapPL.cxx \
VISU_CutPlanesPL.cxx \
VISU_GaussPointsPL.cxx \
VISU_Plot3DPL.cxx \
SALOME_ExtractGeometry.cxx \
+ SALOME_ExtractPolyDataGeometry.cxx \
VISU_OpenGLPointSpriteMapper.cxx \
VISU_ImplicitFunctionWidget.cxx \
VISU_PlanesWidget.cxx \
VISU_SphereWidget.cxx \
VISU_WidgetCtrl.cxx \
VISU_ScalarBarCtrl.cxx \
- VISU_ScalarMapOnDeformedShapePL.cxx \
- VISU_PrsMergerPL.cxx
+ VISU_ScalarMapOnDeformedShapePL.cxx
libVisuPipeLine_la_CPPFLAGS= \
$(VTK_INCLUDES) \
#include <vtkObjectFactory.h>
#include <vtkPointData.h>
#include <vtkUnstructuredGrid.h>
+
#include <vtkInformation.h>
#include <vtkInformationVector.h>
#include <vtkImplicitBoolean.h>
#include <vtkImplicitFunctionCollection.h>
-using namespace std;
-
#if defined __GNUC__
#if __GNUC__ == 2
#define __GNUC_2__
{}
-//----------------------------------------------------------------------------
-unsigned long int
-SALOME_ExtractGeometry
-::GetMTime()
-{
- unsigned long int aTime = vtkExtractGeometry::GetMTime();
- return aTime;
-}
-
-
//----------------------------------------------------------------------------
vtkImplicitBoolean*
SALOME_ExtractGeometry
::SetImplicitFunction(vtkImplicitFunction* theImplicitFunction)
{
myImplicitBoolean = dynamic_cast<vtkImplicitBoolean*>(theImplicitFunction);
- vtkExtractGeometry::SetImplicitFunction(theImplicitFunction);
+ Superclass::SetImplicitFunction(theImplicitFunction);
}
SALOME_ExtractGeometry
::SetStoreMapping(bool theStoreMapping)
{
- myStoreMapping = theStoreMapping;
- Modified();
+ if(myStoreMapping != theStoreMapping){
+ myStoreMapping = theStoreMapping;
+ Modified();
+ }
}
bool
SALOME_ExtractGeometry
::GetElemVTKId(vtkIdType theID)
{
- if(!myStoreMapping||myIsDoneShallowCopy){
+ if(!myStoreMapping || myIsDoneShallowCopy)
return theID;
- }
+
vtkIdType iEnd = myElemVTK2ObjIds.size();
for(vtkIdType i = 0; i < iEnd; i++)
if(myElemVTK2ObjIds[i] == theID)
SALOME_ExtractGeometry
::GetNodeVTKId(vtkIdType theID)
{
- if (!myStoreMapping||myIsDoneShallowCopy){
+ if(!myStoreMapping || myIsDoneShallowCopy)
return theID;
- }
+
vtkIdType iEnd = myNodeVTK2ObjIds.size();
for(vtkIdType i = 0; i < iEnd; i++)
if(myNodeVTK2ObjIds[i] == theID)
SALOME_ExtractGeometry
::GetElemObjId(int theVtkID)
{
- if (!myStoreMapping||myIsDoneShallowCopy){
+ if(!myStoreMapping || myIsDoneShallowCopy)
return theVtkID;
- }
- //
- if (theVtkID<myElemVTK2ObjIds.size()){
+
+ if(theVtkID < myElemVTK2ObjIds.size())
return myElemVTK2ObjIds[theVtkID];
- }
+
return -1;
}
SALOME_ExtractGeometry
::GetNodeObjId(int theVtkID)
{
- if (!myStoreMapping||myIsDoneShallowCopy){
+ if(!myStoreMapping || myIsDoneShallowCopy)
return theVtkID;
- }
- //
- if (theVtkID<myNodeVTK2ObjIds.size()){
+
+ if(theVtkID < myNodeVTK2ObjIds.size())
return myNodeVTK2ObjIds[theVtkID];
- }
+
return -1;
}
//----------------------------------------------------------------------------
int
SALOME_ExtractGeometry
-::RequestData(
- vtkInformation *vtkNotUsed(request),
- vtkInformationVector **inputVector,
- vtkInformationVector *outputVector)
+::RequestData(vtkInformation *request,
+ vtkInformationVector **inputVector,
+ vtkInformationVector *outputVector)
{
- vtkInformation* aRequest;
-
// get the info objects
vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
vtkInformation *outInfo = outputVector->GetInformationObject(0);
inInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
- //cout << "SALOME_ExtractGeometry::input"<<endl;input->Print(cout);
+
myElemVTK2ObjIds.clear();
myNodeVTK2ObjIds.clear();
//
myIsDoneShallowCopy = !this->ImplicitFunction;
- if(!myIsDoneShallowCopy && myImplicitBoolean.GetPointer()){
- if(vtkImplicitFunctionCollection* aFunction = myImplicitBoolean->GetFunction()){
+ if(!myIsDoneShallowCopy && myImplicitBoolean.GetPointer())
+ if(vtkImplicitFunctionCollection* aFunction = myImplicitBoolean->GetFunction())
myIsDoneShallowCopy = aFunction->GetNumberOfItems() == 0;
- }
- }
if(myIsDoneShallowCopy){
output->ShallowCopy(input);
- Modified();
return 1;
}
-
- return RequestData2(aRequest,inputVector,outputVector);
+
+ return RequestData2(request,inputVector,outputVector);
}
+
+//----------------------------------------------------------------------------
int
SALOME_ExtractGeometry
-::RequestData2(
- vtkInformation *vtkNotUsed(request),
- vtkInformationVector **inputVector,
- vtkInformationVector *outputVector)
+::RequestData2(vtkInformation *vtkNotUsed(request),
+ vtkInformationVector **inputVector,
+ vtkInformationVector *outputVector)
{
-
// get the info objects
vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
vtkInformation *outInfo = outputVector->GetInformationObject(0);
#ifndef SALOME_ExtractGeometry_H
#define SALOME_ExtractGeometry_H
-#include "VTKViewer.h"
-
#include <vtkExtractGeometry.h>
#include <vtkSmartPointer.h>
class SALOME_ExtractGeometry : public vtkExtractGeometry
{
public:
- vtkTypeMacro(SALOME_ExtractGeometry,vtkExtractGeometry);
+ vtkTypeMacro(SALOME_ExtractGeometry, vtkExtractGeometry);
- static SALOME_ExtractGeometry *New();
+ static
+ SALOME_ExtractGeometry*
+ New();
virtual
void
SetImplicitFunction(vtkImplicitFunction* theImplicitFunction);
- virtual
- unsigned long int
- GetMTime();
-
vtkImplicitBoolean*
GetImplicitBoolean();
bool
GetStoreMapping() const;
+
void
SetStoreMapping(bool theStoreMapping);
~SALOME_ExtractGeometry();
// Usual data generation method
- virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
- virtual int RequestData2(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
+ virtual
+ int
+ RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
+
+ virtual
+ int
+ RequestData2(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
private:
bool myStoreMapping;
bool myIsDoneShallowCopy;
+
typedef std::vector<vtkIdType> TVectorId;
TVectorId myElemVTK2ObjIds;
TVectorId myNodeVTK2ObjIds;
--- /dev/null
+// 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
+
+
+#include "SALOME_ExtractPolyDataGeometry.h"
+
+#include <vtkCellArray.h>
+#include <vtkCellData.h>
+#include <vtkFloatArray.h>
+#include <vtkImplicitFunction.h>
+#include <vtkObjectFactory.h>
+#include <vtkPointData.h>
+#include <vtkPolyData.h>
+
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+
+#include <vtkImplicitBoolean.h>
+#include <vtkImplicitFunctionCollection.h>
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(SALOME_ExtractPolyDataGeometry);
+
+
+//----------------------------------------------------------------------------
+SALOME_ExtractPolyDataGeometry
+::SALOME_ExtractPolyDataGeometry():
+ myStoreMapping(false),
+ myIsDoneShallowCopy(false)
+{}
+
+SALOME_ExtractPolyDataGeometry
+::~SALOME_ExtractPolyDataGeometry()
+{}
+
+
+//----------------------------------------------------------------------------
+vtkImplicitBoolean*
+SALOME_ExtractPolyDataGeometry
+::GetImplicitBoolean()
+{
+ return myImplicitBoolean.GetPointer();
+}
+
+
+void
+SALOME_ExtractPolyDataGeometry
+::SetImplicitFunction(vtkImplicitFunction* theImplicitFunction)
+{
+ myImplicitBoolean = dynamic_cast<vtkImplicitBoolean*>(theImplicitFunction);
+ Superclass::SetImplicitFunction(theImplicitFunction);
+}
+
+
+//----------------------------------------------------------------------------
+void
+SALOME_ExtractPolyDataGeometry
+::SetStoreMapping(bool theStoreMapping)
+{
+ if(myStoreMapping != theStoreMapping){
+ myStoreMapping = theStoreMapping;
+ Modified();
+ }
+}
+
+bool
+SALOME_ExtractPolyDataGeometry
+::GetStoreMapping() const
+{
+ return myStoreMapping;
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType
+SALOME_ExtractPolyDataGeometry
+::GetElemVTKId(vtkIdType theID)
+{
+ if(!myStoreMapping || myIsDoneShallowCopy)
+ return theID;
+
+ vtkIdType iEnd = myElemVTK2ObjIds.size();
+ for(vtkIdType i = 0; i < iEnd; i++)
+ if(myElemVTK2ObjIds[i] == theID)
+ return i;
+
+ return -1;
+}
+
+vtkIdType
+SALOME_ExtractPolyDataGeometry
+::GetNodeVTKId(vtkIdType theID)
+{
+ if(!myStoreMapping || myIsDoneShallowCopy)
+ return theID;
+
+ vtkIdType iEnd = myNodeVTK2ObjIds.size();
+ for(vtkIdType i = 0; i < iEnd; i++)
+ if(myNodeVTK2ObjIds[i] == theID)
+ return i;
+
+ return -1;
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType
+SALOME_ExtractPolyDataGeometry
+::GetElemObjId(int theVtkID)
+{
+ if(!myStoreMapping || myIsDoneShallowCopy)
+ return theVtkID;
+
+ if(theVtkID < myElemVTK2ObjIds.size())
+ return myElemVTK2ObjIds[theVtkID];
+
+ return -1;
+}
+
+
+vtkIdType
+SALOME_ExtractPolyDataGeometry
+::GetNodeObjId(int theVtkID)
+{
+ if(!myStoreMapping || myIsDoneShallowCopy)
+ return theVtkID;
+
+ if(theVtkID < myNodeVTK2ObjIds.size())
+ return myNodeVTK2ObjIds[theVtkID];
+
+ return -1;
+}
+
+
+//----------------------------------------------------------------------------
+int
+SALOME_ExtractPolyDataGeometry
+::RequestData(vtkInformation *request,
+ vtkInformationVector **inputVector,
+ vtkInformationVector *outputVector)
+{
+ myElemVTK2ObjIds.clear();
+ myNodeVTK2ObjIds.clear();
+ //
+ myIsDoneShallowCopy = !this->ImplicitFunction;
+
+ if(!myIsDoneShallowCopy && myImplicitBoolean.GetPointer()){
+ if(vtkImplicitFunctionCollection* aFunction = myImplicitBoolean->GetFunction()){
+ myIsDoneShallowCopy = aFunction->GetNumberOfItems() == 0;
+ }
+ }
+
+ if(myIsDoneShallowCopy){
+ GetOutput()->ShallowCopy(GetInput());
+ return 1;
+ }
+
+ return RequestData2(request,inputVector,outputVector);
+}
+
+
+//----------------------------------------------------------------------------
+int
+SALOME_ExtractPolyDataGeometry
+::RequestData2(vtkInformation *vtkNotUsed(request),
+ vtkInformationVector **inputVector,
+ vtkInformationVector *outputVector)
+{
+ // get the info objects
+ vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
+ vtkInformation *outInfo = outputVector->GetInformationObject(0);
+
+ // get the input and ouptut
+ vtkDataSet *input = vtkDataSet::SafeDownCast(
+ inInfo->Get(vtkDataObject::DATA_OBJECT()));
+ vtkPolyData *output = vtkPolyData::SafeDownCast(
+ outInfo->Get(vtkDataObject::DATA_OBJECT()));
+
+ vtkIdType ptId, numPts, numCells, i, cellId, newCellId, newId, *pointMap;
+ vtkIdList *cellPts;
+ vtkCell *cell;
+ int numCellPts;
+ vtkFloatingPointType *x;
+ vtkFloatingPointType multiplier;
+ vtkPoints *newPts;
+ vtkIdList *newCellPts;
+ vtkPointData *pd = input->GetPointData();
+ vtkCellData *cd = input->GetCellData();
+ vtkPointData *outputPD = output->GetPointData();
+ vtkCellData *outputCD = output->GetCellData();
+ int npts;
+ numCells = input->GetNumberOfCells();
+ numPts = input->GetNumberOfPoints();
+
+ if ( ! this->ImplicitFunction )
+ {
+ vtkErrorMacro(<<"No implicit function specified");
+ return 0;
+ }
+
+ newCellPts = vtkIdList::New();
+ newCellPts->Allocate(VTK_CELL_SIZE);
+
+ if ( this->ExtractInside )
+ {
+ multiplier = 1.0;
+ }
+ else
+ {
+ multiplier = -1.0;
+ }
+
+ // Loop over all points determining whether they are inside the
+ // implicit function. Copy the points and point data if they are.
+ //
+ pointMap = new vtkIdType[numPts]; // maps old point ids into new
+ for (i=0; i < numPts; i++)
+ {
+ pointMap[i] = -1;
+ }
+
+ output->Allocate(numCells/4); //allocate storage for geometry/topology
+ newPts = vtkPoints::New();
+ newPts->Allocate(numPts/4,numPts);
+ outputPD->CopyAllocate(pd);
+ outputCD->CopyAllocate(cd);
+ vtkFloatArray *newScalars = NULL;
+
+ if(myStoreMapping){
+ myElemVTK2ObjIds.reserve(numCells);
+ myNodeVTK2ObjIds.reserve(numPts);
+ }
+
+ if ( ! this->ExtractBoundaryCells )
+ {
+ for ( ptId=0; ptId < numPts; ptId++ )
+ {
+ x = input->GetPoint(ptId);
+ if ( (this->ImplicitFunction->FunctionValue(x)*multiplier) < 0.0 )
+ {
+ newId = newPts->InsertNextPoint(x);
+ pointMap[ptId] = newId;
+ if(myStoreMapping)
+ myNodeVTK2ObjIds.push_back(ptId);
+ outputPD->CopyData(pd,ptId,newId);
+ }
+ }
+ }
+ else
+ {
+ // To extract boundary cells, we have to create supplemental information
+ if ( this->ExtractBoundaryCells )
+ {
+ vtkFloatingPointType val;
+ newScalars = vtkFloatArray::New();
+ newScalars->SetNumberOfValues(numPts);
+
+ for (ptId=0; ptId < numPts; ptId++ )
+ {
+ x = input->GetPoint(ptId);
+ val = this->ImplicitFunction->FunctionValue(x) * multiplier;
+ newScalars->SetValue(ptId, val);
+ if ( val < 0.0 )
+ {
+ newId = newPts->InsertNextPoint(x);
+ pointMap[ptId] = newId;
+ if(myStoreMapping)
+ myNodeVTK2ObjIds.push_back(ptId);
+ outputPD->CopyData(pd,ptId,newId);
+ }
+ }
+ }
+ }
+
+ // Now loop over all cells to see whether they are inside implicit
+ // function (or on boundary if ExtractBoundaryCells is on).
+ //
+ for (cellId=0; cellId < numCells; cellId++)
+ {
+ cell = input->GetCell(cellId);
+ cellPts = cell->GetPointIds();
+ numCellPts = cell->GetNumberOfPoints();
+
+ newCellPts->Reset();
+ if ( ! this->ExtractBoundaryCells ) //requires less work
+ {
+ for ( npts=0, i=0; i < numCellPts; i++, npts++)
+ {
+ ptId = cellPts->GetId(i);
+ if ( pointMap[ptId] < 0 )
+ {
+ break; //this cell won't be inserted
+ }
+ else
+ {
+ newCellPts->InsertId(i,pointMap[ptId]);
+ }
+ }
+ } //if don't want to extract boundary cells
+
+ else //want boundary cells
+ {
+ for ( npts=0, i=0; i < numCellPts; i++ )
+ {
+ ptId = cellPts->GetId(i);
+ if ( newScalars->GetValue(ptId) <= 0.0 )
+ {
+ npts++;
+ }
+ }
+ if ( npts > 0 )
+ {
+ for ( i=0; i < numCellPts; i++ )
+ {
+ ptId = cellPts->GetId(i);
+ if ( pointMap[ptId] < 0 )
+ {
+ x = input->GetPoint(ptId);
+ newId = newPts->InsertNextPoint(x);
+ pointMap[ptId] = newId;
+ if(myStoreMapping)
+ myNodeVTK2ObjIds.push_back(ptId);
+ outputPD->CopyData(pd,ptId,newId);
+ }
+ newCellPts->InsertId(i,pointMap[ptId]);
+ }
+ }//a boundary or interior cell
+ }//if mapping boundary cells
+
+ if ( npts >= numCellPts || (this->ExtractBoundaryCells && npts > 0) )
+ {
+ newCellId = output->InsertNextCell(cell->GetCellType(),newCellPts);
+ if(myStoreMapping)
+ myElemVTK2ObjIds.push_back(cellId);
+ outputCD->CopyData(cd,cellId,newCellId);
+ }
+ }//for all cells
+
+ // Update ourselves and release memory
+ //
+ delete [] pointMap;
+ newCellPts->Delete();
+ output->SetPoints(newPts);
+ newPts->Delete();
+
+ if ( this->ExtractBoundaryCells )
+ {
+ newScalars->Delete();
+ }
+
+ output->Squeeze();
+ return 1;
+}
+
+
+//----------------------------------------------------------------------------
--- /dev/null
+// 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
+
+#ifndef SALOME_ExtractPolyDataGeometry_H
+#define SALOME_ExtractPolyDataGeometry_H
+
+#include <vtkExtractPolyDataGeometry.h>
+#include <vtkSmartPointer.h>
+
+#include <vector>
+
+class vtkImplicitBoolean;
+
+class SALOME_ExtractPolyDataGeometry : public vtkExtractPolyDataGeometry
+{
+public:
+ vtkTypeMacro(SALOME_ExtractPolyDataGeometry, vtkExtractPolyDataGeometry);
+
+ static
+ SALOME_ExtractPolyDataGeometry*
+ New();
+
+ virtual
+ void
+ SetImplicitFunction(vtkImplicitFunction* theImplicitFunction);
+
+ vtkImplicitBoolean*
+ GetImplicitBoolean();
+
+ bool
+ GetStoreMapping() const;
+
+ void
+ SetStoreMapping(bool theStoreMapping);
+
+ virtual
+ vtkIdType
+ GetNodeObjId(vtkIdType theID);
+
+ virtual
+ vtkIdType
+ GetElemObjId(vtkIdType theID);
+
+ virtual
+ vtkIdType
+ GetNodeVTKId(vtkIdType theID);
+
+ virtual
+ vtkIdType
+ GetElemVTKId(vtkIdType theID);
+
+protected:
+ SALOME_ExtractPolyDataGeometry();
+ ~SALOME_ExtractPolyDataGeometry();
+
+ virtual
+ int
+ RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
+
+ virtual
+ int
+ RequestData2(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
+
+private:
+ bool myStoreMapping;
+ bool myIsDoneShallowCopy;
+
+ typedef std::vector<vtkIdType> TVectorId;
+ TVectorId myElemVTK2ObjIds;
+ TVectorId myNodeVTK2ObjIds;
+
+ vtkSmartPointer<vtkImplicitBoolean> myImplicitBoolean;
+
+ SALOME_ExtractPolyDataGeometry(const SALOME_ExtractPolyDataGeometry&); // Not implemented.
+ void operator=(const SALOME_ExtractPolyDataGeometry&); // Not implemented.
+};
+
+#endif
+
+
// Author: Alexey PETROV
// Module : VISU
-#include "VISU_Convertor.hxx"
#include "VISU_MeshPL.hxx"
#include "VISU_ScalarMapPL.hxx"
-#include "VISU_PrsMergerPL.hxx"
#include "VISU_IsoSurfacesPL.hxx"
#include "VISU_CutPlanesPL.hxx"
#include "VISU_CutLinesPL.hxx"
#include "VISU_VectorsPL.hxx"
#include "VISU_StreamLinesPL.hxx"
#include "VISU_GaussPointsPL.hxx"
+#include "VISU_ScalarMapOnDeformedShapePL.hxx"
#include "VISU_Plot3DPL.hxx"
+#include "VISU_ScalarBarActor.hxx"
+
+#include "VISU_Convertor.hxx"
+#include "VISU_ConvertorUtils.hxx"
-typedef VISU_ScalarMapPL TPresent;
+typedef VISU_ScalarMapOnDeformedShapePL TPresent;
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
#include <vtkProperty.h>
-#include "utilities.h"
+static int isOnlyMesh = false;
-using namespace std;
+//#define _DEBUG_ID_MAPPING_
+
+//----------------------------------------------------------------------------
+template<class TPipeLine>
+VISU_ColoredPL*
+CreateColoredPL(VISU_Convertor* theConvertor,
+ const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theTimeStampNumber);
-static int isOnlyMesh = false;
-int main(int argc, char** argv){
+//----------------------------------------------------------------------------
+template<>
+VISU_ColoredPL*
+CreateColoredPL<VISU_GaussPointsPL>(VISU_Convertor* theConvertor,
+ const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theTimeStampNumber)
+{
+ VISU_GaussPointsPL* aPresent = VISU_GaussPointsPL::New();
+ VISU::PGaussPtsIDMapper aGaussPtsIDMapper =
+ theConvertor->GetTimeStampOnGaussPts(theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber);
+ aPresent->SetGaussPtsIDMapper(aGaussPtsIDMapper);
+
+ char aMainTexture[80];
+ strcpy( aMainTexture, getenv( "VISU_ROOT_DIR" ) );
+ strcat( aMainTexture, "/share/salome/resources/visu/sprite_texture.vti" );
+
+ char anAlphaTexture[80];
+ strcpy( anAlphaTexture, getenv( "VISU_ROOT_DIR" ) );
+ strcat( anAlphaTexture, "/share/salome/resources/visu/sprite_alpha.vti" );
+
+ vtkSmartPointer<vtkImageData> aTextureValue =
+ VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture );
+ aPresent->SetImageData( aTextureValue.GetPointer() );
+
+ aPresent->Update();
+
+#ifdef _DEBUG_ID_MAPPING_
+ vtkDataSet* aDataSet = aPresent->GetOutput();
+ aDataSet->Update();
+ int aNbCells = aDataSet->GetNumberOfCells();
+ cout<<"aNbCells = "<<aNbCells<<endl;
+ for(int anCellId = 0; anCellId < aNbCells; anCellId++){
+ vtkIdType anObjID = aPresent->GetNodeObjID(anCellId);
+ vtkIdType aVtkID = aPresent->GetNodeVTKID(anObjID);
+ cout<<anObjID<<"; "<<aVtkID<<"; - ";
+ vtkFloatingPointType* aCoord = aPresent->GetNodeCoord(anObjID);
+ cout<<aCoord[0]<<"; "<<aCoord[1]<<"; "<<aCoord[2]<<endl;
+ }
+#endif
+
+ return aPresent;
+}
+
+
+//----------------------------------------------------------------------------
+template<class TPipeLine>
+VISU_ColoredPL*
+CreateColoredPL(VISU_Convertor* theConvertor,
+ const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theTimeStampNumber)
+{
+ TPipeLine* aPresent = TPipeLine::New();
+ VISU::PUnstructuredGridIDMapper anUnstructuredGridIDMapper =
+ theConvertor->GetTimeStampOnMesh(theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber);
+ aPresent->SetUnstructuredGridIDMapper(anUnstructuredGridIDMapper);
+
+ //aPresent->ClearGeometry();
+ //{
+ // VISU::PUnstructuredGridIDMapper anIDMapper =
+ // theConvertor->GetMeshOnGroup(theMeshName,
+ // "groupe1");
+ // aPresent->AddGeometry(anIDMapper->GetOutput());
+ //}
+ //{
+ // VISU::PUnstructuredGridIDMapper anIDMapper =
+ // theConvertor->GetMeshOnGroup(theMeshName,
+ // "TUBEH ");
+ // aPresent->AddGeometry(anIDMapper->GetOutput());
+ //}
+ //{
+ // VISU::PUnstructuredGridIDMapper anIDMapper =
+ // theConvertor->GetMeshOnGroup(theMeshName,
+ // "STRI ");
+ // aPresent->AddGeometry(anIDMapper->GetOutput());
+ //}
+ aPresent->Update();
+ return aPresent;
+}
+
+
+//----------------------------------------------------------------------------
+int
+main(int argc, char** argv)
+{
try{
if(argc > 1){
vtkRenderWindow *renWin = vtkRenderWindow::New();
iren->SetRenderWindow(renWin);
VISU_Convertor* aConvertor = CreateConvertor(argv[1]);
aConvertor->BuildEntities();
+ aConvertor->BuildGroups();
aConvertor->BuildFields();
aConvertor->BuildMinMax();
const VISU::TMeshMap& aMeshMap = aConvertor->GetMeshMap();
VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
if(aMeshMapIter == aMeshMap.end()) return 0;
- const string& aMeshName = aMeshMapIter->first;
+ const std::string& aMeshName = aMeshMapIter->first;
const VISU::PMesh aMesh = aMeshMapIter->second;
const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
const VISU::TEntity& anEntity = VISU::CELL_ENTITY;
aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity);
- VISU::PIDMapper anIDMapper =
+ VISU::PNamedIDMapper anIDMapper =
aConvertor->GetMeshOnEntity(aMeshName,anEntity);
- VISU::TVTKOutput* aDataSet = anIDMapper->GetVTKOutput();
VISU_MeshPL* aPresent = VISU_MeshPL::New();
- aPresent->SetInput(aDataSet);
- aPresent->Build();
+ aPresent->SetUnstructuredGridIDMapper(anIDMapper);
vtkActor* aActor = vtkActor::New();
aActor->SetMapper(aPresent->GetMapper());
}
//Import fields
aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
- cout << "Input iteration:";
- int aIter;
- cin >> aIter;
- int aCount = 0;
for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++) {
const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
- for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++,aCount++){
+ for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
const VISU::PField aField = aFieldMapIter->second;
- if(aCount != aIter)
- continue;
// if(aField->myNbComp == 1)
// continue;
- const string& aFieldName = aFieldMapIter->first;
+ const std::string& aFieldName = aFieldMapIter->first;
const VISU::TValField& aValField = aField->myValField;
VISU::TValField::const_iterator aValFieldIter = aValField.begin();
if(aValFieldIter == aValField.end()) return 0;
int aTimeStamp = aValFieldIter->first;
- TPresent* aPresent = TPresent::New();
- VISU::PIDMapper anIDMapper = aConvertor->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
- aPresent->SetIDMapper(anIDMapper);
-
- aPresent->Build();
- aPresent->Init();
-
- char aMainTexture[80];
- strcpy( aMainTexture, getenv( "VISU_ROOT_DIR" ) );
- strcat( aMainTexture, "/share/salome/resources/visu/sprite_texture.vti" );
- //cout << aMainTexture << endl;
-
- char anAlphaTexture[80];
- strcpy( anAlphaTexture, getenv( "VISU_ROOT_DIR" ) );
- strcat( anAlphaTexture, "/share/salome/resources/visu/sprite_alpha.vti" );
- //cout << anAlphaTexture << endl;
+ VISU_ColoredPL* aPresent = NULL;
+ if(anEntity != VISU::NODE_ENTITY){
+ aPresent = CreateColoredPL<TPresent>(aConvertor,
+ aMeshName,
+ anEntity,
+ aFieldName,
+ aTimeStamp);
+ }else{
+ continue;
+ aPresent = CreateColoredPL<TPresent>(aConvertor,
+ aMeshName,
+ anEntity,
+ aFieldName,
+ aTimeStamp);
+ }
- aPresent->Update();
-
vtkActor* anActor = vtkActor::New();
anActor->SetMapper(aPresent->GetMapper());
}
}
}catch(std::exception& exc){
- MESSAGE("Follow exception was occured :\n"<<exc.what());
+ MSG(true, "Follow exception was occured :\n"<<exc.what());
}catch(...){
- MESSAGE("Unknown exception was occured in VISU_Convertor_impl");
+ MSG(true, "Unknown exception was occured in VISU_Convertor_impl");
}
return 1;
}
#define VISU_PIPELINE_EXPORT
#endif
-#endif
\ No newline at end of file
+#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_ColoredPL.cxx
+// Author: Alexey PETROV
+// Module : VISU
+
+
+#include "VISU_ColoredPL.hxx"
+#include "VISU_Extractor.hxx"
+#include "VISU_FieldTransform.hxx"
+#include "VISU_LookupTable.hxx"
+#include "VISU_MapperHolder.hxx"
+
+#include "VISU_PipeLineUtils.hxx"
+
+
+//----------------------------------------------------------------------------
+VISU_ColoredPL
+::VISU_ColoredPL():
+ myMapperTable(VISU_LookupTable::New()),
+ myBarTable(VISU_LookupTable::New()),
+ myExtractor(VISU_Extractor::New()),
+ myFieldTransform(VISU_FieldTransform::New())
+{
+ myMapperTable->Delete();
+ myMapperTable->SetScale(VTK_SCALE_LINEAR);
+ myMapperTable->SetHueRange(0.667, 0.0);
+
+ myBarTable->Delete();
+ myBarTable->SetScale(VTK_SCALE_LINEAR);
+ myBarTable->SetHueRange(0.667, 0.0);
+
+ myExtractor->Delete();
+
+ myFieldTransform->Delete();
+}
+
+
+VISU_ColoredPL
+::~VISU_ColoredPL()
+{}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_ColoredPL
+::DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput)
+{
+ Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
+
+ if(VISU_ColoredPL *aPipeLine = dynamic_cast<VISU_ColoredPL*>(thePipeLine)){
+ if(theIsCopyInput)
+ SetScalarRange(aPipeLine->GetScalarRange());
+ SetScalarMode(aPipeLine->GetScalarMode());
+ SetNbColors(aPipeLine->GetNbColors());
+ SetScaling(aPipeLine->GetScaling());
+ SetMapScale(aPipeLine->GetMapScale());
+ }
+}
+
+
+//----------------------------------------------------------------------------
+int
+VISU_ColoredPL
+::GetScalarMode()
+{
+ return myExtractor->GetScalarMode();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_ColoredPL
+::SetScalarMode(int theScalarMode,
+ vtkDataSet *theInput,
+ VISU_Extractor* theExtractor)
+{
+ if(theInput){
+ if(VISU::IsDataOnPoints(theInput)){
+ vtkPointData *aPointData = theInput->GetPointData();
+ if(!aPointData->GetAttribute(vtkDataSetAttributes::VECTORS)) {
+ if(theScalarMode == 0){
+ return;
+ }
+ }
+ } else {
+ vtkCellData *aCellData = theInput->GetCellData();
+ if(!aCellData->GetAttribute(vtkDataSetAttributes::VECTORS)){
+ if(theScalarMode==0){
+ return;
+ }
+ }
+ }
+ }
+
+ theExtractor->SetScalarMode(theScalarMode);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_ColoredPL
+::SetScalarMode(int theScalarMode)
+{
+ SetScalarMode(theScalarMode, GetInput(), myExtractor);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_ColoredPL
+::SetScalarRange(vtkFloatingPointType theRange[2])
+{
+ myFieldTransform->SetScalarRange(theRange);
+ myBarTable->SetRange(theRange);
+}
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType*
+VISU_ColoredPL
+::GetScalarRange()
+{
+ return myFieldTransform->GetScalarRange();
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_ColoredPL
+::SetScaling(int theScaling)
+{
+ if(GetScaling() == theScaling)
+ return;
+
+ myBarTable->SetScale(theScaling);
+
+ if(theScaling == VTK_SCALE_LOG10)
+ myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Log10));
+ else
+ myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Ident));
+}
+
+//----------------------------------------------------------------------------
+int
+VISU_ColoredPL
+::GetScaling()
+{
+ return myBarTable->GetScale();
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_ColoredPL
+::SetNbColors(int theNbColors)
+{
+ myMapperTable->SetNumberOfColors(theNbColors);
+ myBarTable->SetNumberOfColors(theNbColors);
+}
+
+int
+VISU_ColoredPL
+::GetNbColors()
+{
+ return myMapperTable->GetNumberOfColors();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_ColoredPL
+::Init()
+{
+ SetScalarMode(0);
+ SetSourceRange();
+}
+
+//----------------------------------------------------------------------------
+vtkPointSet*
+VISU_ColoredPL
+::GetClippedInput()
+{
+ if(GetFieldTransformFilter()->GetInput())
+ GetFieldTransformFilter()->Update();
+ return GetFieldTransformFilter()->GetUnstructuredGridOutput();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_ColoredPL
+::Build()
+{
+ myExtractor->SetInput(Superclass::GetClippedInput());
+ myFieldTransform->SetInput(myExtractor->GetOutput());
+
+ GetMapperHolder()->SetLookupTable(GetMapperTable());
+ GetMapper()->SetUseLookupTableScalarRange(true);
+ GetMapper()->SetColorModeToMapScalars();
+ GetMapper()->ScalarVisibilityOn();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_ColoredPL
+::Update()
+{
+ vtkFloatingPointType *aRange = GetScalarRange();
+ vtkFloatingPointType aScalarRange[2] = {aRange[0], aRange[1]};
+ if(myBarTable->GetScale() == VTK_SCALE_LOG10)
+ VISU_LookupTable::ComputeLogRange(aRange,aScalarRange);
+ myMapperTable->SetRange(aScalarRange);
+
+ myMapperTable->Build();
+ myBarTable->Build();
+
+ Superclass::Update();
+}
+
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_ColoredPL
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ if(vtkDataObject* aDataObject = myExtractor->GetInput())
+ aSize = aDataObject->GetActualMemorySize() * 1024;
+
+ if(vtkDataObject* aDataObject = myFieldTransform->GetInput())
+ aSize += aDataObject->GetActualMemorySize() * 1024;
+
+ return aSize;
+}
+
+
+//----------------------------------------------------------------------------
+VISU_LookupTable *
+VISU_ColoredPL
+::GetMapperTable()
+{
+ return myMapperTable.GetPointer();
+}
+
+
+//----------------------------------------------------------------------------
+VISU_LookupTable*
+VISU_ColoredPL
+::GetBarTable()
+{
+ return myBarTable.GetPointer();
+}
+
+
+//----------------------------------------------------------------------------
+VISU_Extractor*
+VISU_ColoredPL
+::GetExtractorFilter()
+{
+ return myExtractor.GetPointer();
+}
+
+
+//----------------------------------------------------------------------------
+VISU_FieldTransform*
+VISU_ColoredPL
+::GetFieldTransformFilter()
+{
+ return myFieldTransform.GetPointer();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_ColoredPL
+::SetMapScale(vtkFloatingPointType theMapScale)
+{
+ if(!VISU::CheckIsSameValue(myMapperTable->GetMapScale(), theMapScale)){
+ myMapperTable->SetMapScale(theMapScale);
+ myMapperTable->Build();
+ }
+}
+
+vtkFloatingPointType
+VISU_ColoredPL
+::GetMapScale()
+{
+ return myMapperTable->GetMapScale();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_ColoredPL
+::GetSourceRange(vtkFloatingPointType theRange[2])
+{
+ myExtractor->Update();
+ myExtractor->GetOutput()->GetScalarRange(theRange);
+}
+
+void
+VISU_ColoredPL
+::SetSourceRange()
+{
+ vtkFloatingPointType aRange[2];
+ GetSourceRange(aRange);
+ SetScalarRange(aRange);
+}
--- /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_ColoredPL.hxx
+// Author: Alexey PETROV
+// Module : VISU
+
+#ifndef VISU_ColoredPL_HeaderFile
+#define VISU_ColoredPL_HeaderFile
+
+#include "VISU_PipeLine.hxx"
+
+#include <vtkSmartPointer.h>
+
+class VISU_Extractor;
+class VISU_FieldTransform;
+class VISU_LookupTable;
+
+
+//----------------------------------------------------------------------------
+class VISU_ColoredPL : public VISU_PipeLine
+{
+public:
+ vtkTypeMacro(VISU_ColoredPL, VISU_PipeLine);
+
+ //----------------------------------------------------------------------------
+ virtual
+ int
+ GetScalarMode();
+
+ virtual
+ void
+ SetScalarMode(int theScalarMode = 0);
+
+ virtual
+ vtkFloatingPointType*
+ GetScalarRange();
+
+ virtual
+ void
+ SetScalarRange(vtkFloatingPointType theRange[2]);
+
+ virtual
+ void
+ SetScaling(int theScaling);
+
+ virtual
+ int
+ GetScaling();
+
+ virtual
+ void
+ SetNbColors(int theNbColors);
+
+ virtual
+ int
+ GetNbColors();
+
+ //----------------------------------------------------------------------------
+public:
+ virtual
+ void
+ Init();
+
+ virtual
+ void
+ Update();
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ virtual
+ VISU_LookupTable*
+ GetMapperTable();
+
+ virtual
+ VISU_LookupTable*
+ GetBarTable();
+
+ virtual
+ void
+ SetMapScale(vtkFloatingPointType theMapScale = 1.0);
+
+ virtual
+ vtkFloatingPointType
+ GetMapScale();
+
+ virtual
+ void
+ GetSourceRange(vtkFloatingPointType theRange[2]);
+
+ virtual
+ void
+ SetSourceRange();
+
+protected:
+ //----------------------------------------------------------------------------
+ VISU_ColoredPL();
+ VISU_ColoredPL(const VISU_ColoredPL&);
+
+ virtual
+ ~VISU_ColoredPL();
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ Build();
+
+ virtual
+ void
+ DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
+
+ //----------------------------------------------------------------------------
+ VISU_Extractor*
+ GetExtractorFilter();
+
+ VISU_FieldTransform*
+ GetFieldTransformFilter();
+
+ //----------------------------------------------------------------------------
+ virtual
+ vtkPointSet*
+ GetClippedInput();
+
+ //----------------------------------------------------------------------------
+ static
+ void
+ SetScalarMode(int theScalarMode,
+ vtkDataSet *theInput,
+ VISU_Extractor* theExtractor);
+
+private:
+ vtkSmartPointer<VISU_LookupTable> myMapperTable;
+ vtkSmartPointer<VISU_LookupTable> myBarTable;
+ vtkSmartPointer<VISU_Extractor> myExtractor;
+ vtkSmartPointer<VISU_FieldTransform> myFieldTransform;
+};
+
+#endif
#include "VISU_CutLinesPL.hxx"
+#include "VISU_FieldTransform.hxx"
#include "VISU_PipeLineUtils.hxx"
#include "VTKViewer_GeometryFilter.h"
#include <vtkAppendPolyData.h>
-using namespace std;
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_CutLinesPL);
+
+//----------------------------------------------------------------------------
VISU_CutLinesPL
::VISU_CutLinesPL()
{
+ SetIsShrinkable(false);
+
myCondition = 1;
myPosition = 0;
}
+
+//----------------------------------------------------------------------------
void
VISU_CutLinesPL
-::ShallowCopy(VISU_PipeLine *thePipeLine)
+::DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput)
{
+ Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
+
if(VISU_CutLinesPL *aPipeLine = dynamic_cast<VISU_CutLinesPL*>(thePipeLine)){
SetOrientation(aPipeLine->GetPlaneOrientation(1),
aPipeLine->GetRotateX(1),aPipeLine->GetRotateY(1),1);
else
SetPosition(aPipeLine->GetPosition());
}
- VISU_CutPlanesPL::ShallowCopy(thePipeLine);
}
+
+//----------------------------------------------------------------------------
void
VISU_CutLinesPL
::Init()
{
- VISU_CutPlanesPL::Init();
+ Superclass::Init();
myBasePlane[0] = XY;
myBasePlane[1] = YZ;
}
+//----------------------------------------------------------------------------
void
VISU_CutLinesPL
::SetPosition(vtkFloatingPointType thePosition)
myCondition = 0;
Modified();
}
+
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_CutLinesPL
::GetPosition()
{
vtkFloatingPointType aPosition = myPosition;
if(myCondition){
- vtkFloatingPointType aDir[3], aBounds[6], aBoundPrj[3];
- GetInput2()->GetBounds(aBounds);
- GetDir(aDir,myAng[0],myBasePlane[0]);
- GetBoundProject(aBoundPrj,aBounds,aDir);
- aPosition = aBoundPrj[0] + aBoundPrj[2]*myDisplacement[0];
+ vtkFloatingPointType aBounds[6];
+ GetMergedInput()->GetBounds(aBounds);
+
+ vtkFloatingPointType aDir[3];
+ GetDir(aDir,
+ myAng[0],
+ myBasePlane[0]);
+
+ vtkFloatingPointType aBoundPrj[3];
+ GetBoundProject(aBoundPrj,
+ aBounds,
+ aDir);
+
+ aPosition = aBoundPrj[0] + aBoundPrj[2] * myDisplacement[0];
}
return aPosition;
}
+
+//----------------------------------------------------------------------------
void
VISU_CutLinesPL
::SetDefault()
myCondition = 1;
Modified();
}
+
+
+//----------------------------------------------------------------------------
int
VISU_CutLinesPL
::IsDefault()
}
+//----------------------------------------------------------------------------
void
VISU_CutLinesPL
::Update()
{
ClearAppendPolyData(myAppendPolyData);
+
SetPartPosition(1);
+
vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New();
+
//Build base plane
- vtkFloatingPointType aDir[2][3], aBaseBounds[6];
- GetInput2()->GetBounds(aBaseBounds);
- GetDir(aDir[0],myAng[0],myBasePlane[0]);
- vtkUnstructuredGrid* anUnstructuredGrid =
- myFieldTransform->GetUnstructuredGridOutput();
- CutWithPlanes(anAppendPolyData,anUnstructuredGrid,1,aDir[0],aBaseBounds,
- myPosition,myCondition,myDisplacement[0]);
+ vtkFloatingPointType aBaseBounds[6];
+ GetMergedInput()->GetBounds(aBaseBounds);
+
+ vtkFloatingPointType aDir[2][3];
+ GetDir(aDir[0],
+ myAng[0],
+ myBasePlane[0]);
+
+ CutWithPlanes(anAppendPolyData,
+ GetMergedInput(),
+ 1,
+ aDir[0],
+ aBaseBounds,
+ myPosition,
+ myCondition,
+ myDisplacement[0]);
//Build lines
- vtkFloatingPointType aBounds[6];
vtkDataSet *aDataSet = anAppendPolyData->GetOutput();
aDataSet->Update();
+
if(aDataSet->GetNumberOfCells() == 0)
- aDataSet = anUnstructuredGrid;
+ aDataSet = GetMergedInput();
+
+ vtkFloatingPointType aBounds[6];
aDataSet->GetBounds(aBounds);
- GetDir(aDir[1],myAng[1],myBasePlane[1]);
- VISU_CutPlanesPL::CutWithPlanes(myAppendPolyData,aDataSet,GetNbParts(),aDir[1],aBounds,
- myPartPosition,myPartCondition,myDisplacement[1]);
- anAppendPolyData->Register(myAppendPolyData);
+
+ GetDir(aDir[1],
+ myAng[1],
+ myBasePlane[1]);
+
+ VISU_CutPlanesPL::CutWithPlanes(myAppendPolyData,
+ aDataSet,
+ GetNbParts(),
+ aDir[1],
+ aBounds,
+ myPartPosition,
+ myPartCondition,
+ myDisplacement[1]);
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myAppendPolyData.vtk";
+ // VISU::WriteToFile(myAppendPolyData->GetOutput(), aFileName);
+ //}
anAppendPolyData->Delete();
+
//Calculate values for building of table
vtkMath::Cross(aDir[0],aDir[1],myDirLn);
- for (int i=0; i<3 ; i++) {
+ for (int i = 0; i<3 ; i++) {
myRealDirLn[i] = myDirLn[i];
- if(myDirLn[i]<0) myDirLn[i] = (-1)*myDirLn[i];//enk:: correction of bug Bug PAL10401
+ if(myDirLn[i] < 0.0)
+ myDirLn[i] = -1.0*myDirLn[i];//enk:: correction of bug Bug PAL10401
}
- GetBoundProject(myBoundPrjLn, aBaseBounds, myDirLn);
- VISU::Mul(myDirLn,myBoundPrjLn[0],myBasePnt);
+
+ GetBoundProject(myBoundPrjLn,
+ aBaseBounds,
+ myDirLn);
+
+ VISU::Mul(myDirLn,
+ myBoundPrjLn[0],
+ myBasePnt);
- CorrectPnt(myBasePnt,aBaseBounds);
+ CorrectPnt(myBasePnt,
+ aBaseBounds);
- VISU_PrsMergerPL::Update();
+ VISU_ScalarMapPL::Update();
}
+//----------------------------------------------------------------------------
void
VISU_CutLinesPL
::CutWithPlanes(vtkAppendPolyData* theAppendPolyData,
int thePartCondition,
vtkFloatingPointType theDisplacement)
{
- vector<vtkFloatingPointType> aPartPosition(1,thePartPosition);
- vector<int> aPartCondition(1,thePartCondition);
- VISU_CutPlanesPL::CutWithPlanes(theAppendPolyData,theDataSet,theNbPlanes,theDir,theBounds,
- aPartPosition,aPartCondition,theDisplacement);
+ std::vector<vtkFloatingPointType> aPartPosition(1,thePartPosition);
+ std::vector<int> aPartCondition(1,thePartCondition);
+ VISU_CutPlanesPL::CutWithPlanes(theAppendPolyData,
+ theDataSet,
+ theNbPlanes,
+ theDir,
+ theBounds,
+ aPartPosition,
+ aPartCondition,
+ theDisplacement);
}
+
+
+//----------------------------------------------------------------------------
class vtkAppendPolyData;
-class VISU_PIPELINE_EXPORT VISU_CutLinesPL : public VISU_CutPlanesPL{
-protected:
- VISU_CutLinesPL();
- VISU_CutLinesPL(const VISU_CutLinesPL&);
+
+//----------------------------------------------------------------------------
+class VISU_PIPELINE_EXPORT VISU_CutLinesPL : public VISU_CutPlanesPL
+{
public:
vtkTypeMacro(VISU_CutLinesPL,VISU_CutPlanesPL);
VISU_CutLinesPL*
New();
- virtual
- void
- ShallowCopy(VISU_PipeLine *thePipeLine);
-
virtual
void
SetPosition(vtkFloatingPointType thePosition);
int thePlaneCondition,
vtkFloatingPointType theDisplacement);
- const vtkFloatingPointType*
- GetDirLn()
- {
- return myDirLn;
- }
-
+ //! Returns direction that is defined by position & orientation of the basic and tool planes
const vtkFloatingPointType*
GetRealDirLn()
{
return myRealDirLn;
}
+ /*!
+ Returns direction that corresponds to the myRealDirLn,
+ but has the same direction as main axis.
+ */
const vtkFloatingPointType*
- GetBoundPrjLn()
+ GetDirLn()
{
- return myBoundPrjLn;
+ return myDirLn;
}
+ /*!
+ Returns coordinates of 3D point that shows
+ where is the first intersection of the given mesh.
+ with the defined direction.
+ */
const vtkFloatingPointType*
GetBasePnt()
{
return myBasePnt;
}
+ /*!
+ Returns three floating point numbers that defines the following values:
+ 1. Distance between the initial point of intersection and origin of coordinates;
+ 2. Distance between the last point of intersection and origin of coordinates;
+ 3. Distance between the last point and initial points of intersection.
+ with the defined direction.
+ */
+ const vtkFloatingPointType*
+ GetBoundPrjLn()
+ {
+ return myBoundPrjLn;
+ }
+
protected:
+ VISU_CutLinesPL();
+ VISU_CutLinesPL(const VISU_CutLinesPL&);
+
+ virtual
+ void
+ DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
+
vtkFloatingPointType myDirLn[3];
vtkFloatingPointType myRealDirLn[3];
vtkFloatingPointType myBoundPrjLn[3];
#include "VISU_CutPlanesPL.hxx"
+#include "VISU_FieldTransform.hxx"
#include "VISU_PipeLineUtils.hxx"
#include "VTKViewer_GeometryFilter.h"
#include <vtkCutter.h>
#include <vtkPlane.h>
-using namespace std;
-
static vtkFloatingPointType EPS = 1.0E-3;
-static int MIN_NB_PLANES = 1;
-static int MAX_NB_PLANES = 100;
+
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_CutPlanesPL);
+
+//----------------------------------------------------------------------------
VISU_CutPlanesPL
::VISU_CutPlanesPL()
{
+ SetIsShrinkable(false);
+
myAppendPolyData = vtkAppendPolyData::New();
- myIsShrinkable = false;
myNbParts = 10;
myAng[1][0] = myAng[1][1] = myAng[1][2] = 0.0;
}
+
+//----------------------------------------------------------------------------
VISU_CutPlanesPL
::~VISU_CutPlanesPL()
{
myAppendPolyData->Delete();
+ myAppendPolyData = NULL;
}
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
-::ShallowCopy(VISU_PipeLine *thePipeLine)
+::DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput)
{
+ Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
+
if(VISU_CutPlanesPL *aPipeLine = dynamic_cast<VISU_CutPlanesPL*>(thePipeLine)){
+
SetOrientation(aPipeLine->GetPlaneOrientation(),
- aPipeLine->GetRotateX(),aPipeLine->GetRotateY());
+ aPipeLine->GetRotateX(),
+ aPipeLine->GetRotateY());
+
SetDisplacement(aPipeLine->GetDisplacement());
+
SetNbParts(aPipeLine->GetNbParts());
- for (int i = 0, iend = GetNbParts(); i < iend; i++)
- if(!aPipeLine->IsPartDefault(i)) SetPartPosition(i, aPipeLine->GetPartPosition(i));
+ for (int i = 0, iEnd = GetNbParts(); i < iEnd; i++)
+ if(!aPipeLine->IsPartDefault(i))
+ SetPartPosition(i, aPipeLine->GetPartPosition(i));
}
- Superclass::ShallowCopy(thePipeLine);
}
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::Init()
myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0;
}
-VISU_ScalarMapPL::THook*
+
+//----------------------------------------------------------------------------
+vtkDataSet*
VISU_CutPlanesPL
-::DoHook()
+::InsertCustomPL()
{
return myAppendPolyData->GetOutput();
}
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::Update()
{
ClearAppendPolyData(myAppendPolyData);
+
SetPartPosition();
+
vtkFloatingPointType aDir[3];
- GetDir(aDir,myAng[0],myBasePlane[0]);
+ GetDir(aDir,
+ myAng[0],
+ myBasePlane[0]);
+
vtkFloatingPointType aBounds[6];
- GetInput2()->GetBounds(aBounds);
- vtkDataSet* aDataSet = myFieldTransform->GetUnstructuredGridOutput();
- CutWithPlanes(myAppendPolyData,aDataSet,myNbParts,aDir,aBounds,
- myPartPosition,myPartCondition,myDisplacement[0]);
+ GetMergedInput()->GetBounds(aBounds);
+
+ CutWithPlanes(myAppendPolyData,
+ GetMergedInput(),
+ myNbParts,
+ aDir,
+ aBounds,
+ myPartPosition,
+ myPartCondition,
+ myDisplacement[0]);
Superclass::Update();
}
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_CutPlanesPL
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ if(vtkDataSet* aDataSet = myAppendPolyData->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ int anEnd = myAppendPolyData->GetNumberOfInputConnections(0);
+ for(int anId = 0; anId < anEnd; anId++)
+ if(vtkDataSet* aDataSet = myAppendPolyData->GetInput(anId))
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ return aSize;
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::SetPartPosition(int theNum)
theAppendPolyData->RemoveAllInputs();
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType*
VISU_CutPlanesPL::
GetRx(vtkFloatingPointType theRx[3][3],
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType*
VISU_CutPlanesPL
::GetRy(vtkFloatingPointType theRy[3][3],
}
+//----------------------------------------------------------------------------
vtkFloatingPointType*
VISU_CutPlanesPL
::GetRz(vtkFloatingPointType theRz[3][3],
}
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::CorrectPnt(vtkFloatingPointType thePnt[3],
}
}
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::GetBoundProject(vtkFloatingPointType BoundPrj[3],
}
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::SetOrientation(const VISU_CutPlanesPL::PlaneOrientation& theOrient,
}
+//----------------------------------------------------------------------------
const VISU_CutPlanesPL::PlaneOrientation&
VISU_CutPlanesPL
::GetPlaneOrientation(int theNum)
return 0;
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_CutPlanesPL
::GetRotateY(int theNum)
}
+//----------------------------------------------------------------------------
+vtkFloatingPointType
+VISU_CutPlanesPL
+::GetDisplacement(int theNum)
+{
+ return myDisplacement[theNum];
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
-::SetNbParts(int theNb)
+::SetDisplacement(vtkFloatingPointType theDisp,
+ int theNum)
{
- myNbParts = (theNb<MIN_NB_PLANES?MIN_NB_PLANES:(theNb>MAX_NB_PLANES?MAX_NB_PLANES:theNb));
- myPartPosition.resize(myNbParts);
- myPartCondition.resize(myNbParts,1);
+ myDisplacement[theNum] = theDisp;
Modified();
}
+//----------------------------------------------------------------------------
+void
+VISU_CutPlanesPL
+::SetNbParts(int theNb)
+{
+ if(theNb > 0){
+ myNbParts = theNb;
+ myPartPosition.resize(myNbParts);
+ myPartCondition.resize(myNbParts, 1);
+ Modified();
+ }
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::SetPartPosition(int thePartNumber,
vtkFloatingPointType thePartPosition)
{
- if(thePartNumber >= myNbParts) return;
+ if(thePartNumber >= myNbParts)
+ return;
+
myPartPosition[thePartNumber] = thePartPosition;
myPartCondition[thePartNumber] = 0;
Modified();
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_CutPlanesPL
::GetPartPosition(int thePartNumber,
int theNum)
{
- if(thePartNumber >= myNbParts) return 0;
+ if(thePartNumber >= myNbParts)
+ return 0;
+
vtkFloatingPointType aPosition = myPartPosition[thePartNumber];
if(myPartCondition[thePartNumber]){
vtkFloatingPointType aDir[3], aBounds[6], aBoundPrj[3];
- GetInput2()->GetBounds(aBounds);
- GetDir(aDir,myAng[theNum],myBasePlane[theNum]);
- GetBoundProject(aBoundPrj,aBounds,aDir);
- if (myNbParts > 1){
+ GetMergedInput()->GetBounds(aBounds);
+
+ GetDir(aDir,
+ myAng[theNum],
+ myBasePlane[theNum]);
+
+ GetBoundProject(aBoundPrj,
+ aBounds,
+ aDir);
+
+ if(myNbParts > 1){
vtkFloatingPointType aDBoundPrj = aBoundPrj[2]/(myNbParts - 1);
vtkFloatingPointType aDisplacement = aDBoundPrj * myDisplacement[theNum];
vtkFloatingPointType aStartPosition = aBoundPrj[0] - 0.5*aDBoundPrj + aDisplacement;
}else
aPosition = aBoundPrj[0] + aBoundPrj[2]*myDisplacement[theNum];
}
+
return aPosition;
}
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::SetPartDefault(int thePartNumber)
{
- if(thePartNumber >= myNbParts) return;
+ if(thePartNumber >= myNbParts)
+ return;
+
myPartPosition[thePartNumber] = GetPartPosition(thePartNumber);
myPartCondition[thePartNumber] = 1;
Modified();
}
+
+
+//----------------------------------------------------------------------------
int
VISU_CutPlanesPL
::IsPartDefault(int thePartNumber)
{
- if(thePartNumber >= myNbParts) return 1;
+ if(thePartNumber >= myNbParts)
+ return 1;
+
return myPartCondition[thePartNumber];
}
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::GetDir(vtkFloatingPointType theDir[3],
iPlane = 1;
break;
}
+
for(int i = 0; i < 3; i++)
theDir[i] = aRotation[i][iPlane];
}
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::CutWithPlane(vtkAppendPolyData* theAppendPolyData,
aCutPlane->SetCutFunction(aPlane);
aPlane->Delete();
theAppendPolyData->AddInput(aCutPlane->GetOutput());
- aCutPlane->Register(theAppendPolyData);
aCutPlane->Delete();
}
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::CutWithPlanes(vtkAppendPolyData* theAppendPolyData,
int theNbPlanes,
vtkFloatingPointType theDir[3],
vtkFloatingPointType theBounds[6],
- const vector<vtkFloatingPointType>& thePlanePosition,
- const vector<int>& thePlaneCondition,
+ const std::vector<vtkFloatingPointType>& thePlanePosition,
+ const std::vector<int>& thePlaneCondition,
vtkFloatingPointType theDisplacement)
{
vtkFloatingPointType aBoundPrj[3], aOrig[3], aPosition;
aPolyData->Update();
theAppendPolyData->Update();
}
+
+
+//----------------------------------------------------------------------------
#define VISU_CutPlanesPL_HeaderFile
#include "VISUPipeline.hxx"
-#include "VISU_PrsMergerPL.hxx"
+#include "VISU_ScalarMapPL.hxx"
#include <vector>
class vtkAppendPolyData;
-class VISU_PIPELINE_EXPORT VISU_CutPlanesPL : public VISU_PrsMergerPL{
-protected:
- VISU_CutPlanesPL();
- VISU_CutPlanesPL(const VISU_CutPlanesPL&);
+
+//----------------------------------------------------------------------------
+class VISU_PIPELINE_EXPORT VISU_CutPlanesPL : public VISU_ScalarMapPL
+{
public:
- vtkTypeMacro(VISU_CutPlanesPL,VISU_PrsMergerPL);
+ vtkTypeMacro(VISU_CutPlanesPL, VISU_ScalarMapPL);
static VISU_CutPlanesPL* New();
virtual
~VISU_CutPlanesPL();
- virtual
- void
- ShallowCopy(VISU_PipeLine *thePipeLine);
-
enum PlaneOrientation {XY, YZ, ZX};
virtual
virtual
vtkFloatingPointType
- GetDisplacement(int theNum = 0)
- {
- return myDisplacement[theNum];
- }
+ GetDisplacement(int theNum = 0);
virtual
void
SetDisplacement(vtkFloatingPointType theDisp,
- int theNum = 0)
- {
- myDisplacement[theNum] = theDisp;
- }
+ int theNum = 0);
virtual
void
int
IsPartDefault(int thePartNumber);
- /*!
- * The number of cut planes can be defined under existing conditions [1,100].
- * If setting value less than 1, the number of planes wil be setted to 1,
- * and if value more than 100, the number of planes wil be setted to 100.
- */
virtual
void
SetNbParts(int theNb);
void
Update();
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
virtual
vtkAppendPolyData*
GetAppendPolyData()
const std::vector<int>& thePlaneCondition,
vtkFloatingPointType theDisplacement);
protected:
+ VISU_CutPlanesPL();
+ VISU_CutPlanesPL(const VISU_CutPlanesPL&);
+
virtual
- THook*
- DoHook();
+ vtkDataSet*
+ InsertCustomPL();
+
+ virtual
+ void
+ DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
void
SetPartPosition(int theNum = 0);
--- /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_DataSetMapperHolder.cxx
+// Author: Alexey PETROV
+// Module : VISU
+
+
+#include "VISU_DataSetMapperHolder.hxx"
+#include "SALOME_ExtractGeometry.h"
+#include "VISU_LookupTable.hxx"
+
+#include "VISU_PipeLineUtils.hxx"
+
+#include <vtkDataSetMapper.h>
+#include <vtkUnstructuredGrid.h>
+
+#include <vtkPlane.h>
+#include <vtkImplicitBoolean.h>
+#include <vtkImplicitFunction.h>
+#include <vtkImplicitFunctionCollection.h>
+#include <vtkMath.h>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(VISU_DataSetMapperHolder);
+
+
+//----------------------------------------------------------------------------
+VISU_DataSetMapperHolder
+::VISU_DataSetMapperHolder():
+ myExtractGeometry(SALOME_ExtractGeometry::New())
+{
+ if(MYDEBUG) MESSAGE("VISU_DataSetMapperHolder::VISU_DataSetMapperHolder - "<<this);
+
+ // Clipping functionality
+ myExtractGeometry->Delete();
+ myExtractGeometry->SetStoreMapping(true);
+
+ vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New();
+ myExtractGeometry->SetImplicitFunction(anImplicitBoolean);
+ anImplicitBoolean->SetOperationTypeToIntersection();
+ anImplicitBoolean->Delete();
+}
+
+
+//----------------------------------------------------------------------------
+VISU_DataSetMapperHolder
+::~VISU_DataSetMapperHolder()
+{
+ if(MYDEBUG)
+ MESSAGE("VISU_DataSetMapperHolder::~VISU_DataSetMapperHolder - "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_DataSetMapperHolder
+::ShallowCopy(VISU_MapperHolder *theMapperHolder,
+ bool theIsCopyInput)
+{
+ if(VISU_DataSetMapperHolder* aMapperHolder = dynamic_cast<VISU_DataSetMapperHolder*>(theMapperHolder)){
+ if(theIsCopyInput)
+ SetUnstructuredGridIDMapper(aMapperHolder->GetUnstructuredGridIDMapper());
+
+ VISU::CopyDataSetMapper(GetDataSetMapper(),
+ aMapperHolder->GetDataSetMapper(),
+ theIsCopyInput);
+ }
+}
+
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_DataSetMapperHolder
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ if(myExtractGeometry->GetInput())
+ if(vtkDataSet* aDataSet = myExtractGeometry->GetOutput())
+ aSize = aDataSet->GetActualMemorySize() * 1024;
+
+ return aSize;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_DataSetMapperHolder
+::SetUnstructuredGridIDMapper(const VISU::PUnstructuredGridIDMapper& theIDMapper)
+{
+ myExtractGeometry->SetInput(theIDMapper->GetUnstructuredGridOutput());
+ myUnstructuredGridIDMapper = theIDMapper;
+ SetIDMapper(theIDMapper);
+}
+
+
+//----------------------------------------------------------------------------
+const VISU::PUnstructuredGridIDMapper&
+VISU_DataSetMapperHolder
+::GetUnstructuredGridIDMapper()
+{
+ return myUnstructuredGridIDMapper;
+}
+
+
+//----------------------------------------------------------------------------
+vtkUnstructuredGrid*
+VISU_DataSetMapperHolder
+::GetUnstructuredGridInput()
+{
+ if(myUnstructuredGridIDMapper)
+ return myUnstructuredGridIDMapper->GetUnstructuredGridOutput();
+
+ return NULL;
+}
+
+
+//----------------------------------------------------------------------------
+vtkPointSet*
+VISU_DataSetMapperHolder
+::GetClippedInput()
+{
+ if(myExtractGeometry->GetInput())
+ myExtractGeometry->Update();
+ return myExtractGeometry->GetOutput();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_DataSetMapperHolder
+::OnCreateMapper()
+{
+ myDataSetMapper = vtkDataSetMapper::New();
+ myDataSetMapper->Delete();
+ SetMapper(myDataSetMapper.GetPointer());
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_DataSetMapperHolder
+::SetDataSetMapper(vtkDataSetMapper* theMapper)
+{
+ myDataSetMapper = theMapper;
+ SetMapper(myDataSetMapper.GetPointer());
+}
+
+
+//----------------------------------------------------------------------------
+vtkDataSetMapper*
+VISU_DataSetMapperHolder
+::GetDataSetMapper()
+{
+ GetMapper();
+ return myDataSetMapper.GetPointer();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_DataSetMapperHolder
+::SetLookupTable(VISU_LookupTable* theLookupTable)
+{
+ myDataSetMapper->SetLookupTable(theLookupTable);
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_DataSetMapperHolder
+::GetNodeObjID(vtkIdType theID)
+{
+ vtkIdType anID = myExtractGeometry->GetNodeObjId(theID);
+ return Superclass::GetNodeObjID(anID);
+}
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_DataSetMapperHolder
+::GetNodeVTKID(vtkIdType theID)
+{
+ vtkIdType anID = Superclass::GetNodeVTKID(theID);
+ return myExtractGeometry->GetNodeVTKId(anID);
+}
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType*
+VISU_DataSetMapperHolder
+::GetNodeCoord(int theObjID)
+{
+ return Superclass::GetNodeCoord(theObjID);
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_DataSetMapperHolder
+::GetElemObjID(vtkIdType theID)
+{
+ vtkIdType anID = myExtractGeometry->GetElemObjId(theID);
+ return Superclass::GetElemObjID(anID);
+}
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_DataSetMapperHolder
+::GetElemVTKID(vtkIdType theID)
+{
+ vtkIdType anID = Superclass::GetElemVTKID(theID);
+ return myExtractGeometry->GetElemVTKId(anID);
+}
+
+//----------------------------------------------------------------------------
+vtkCell*
+VISU_DataSetMapperHolder
+::GetElemCell(vtkIdType theObjID)
+{
+ return Superclass::GetElemCell(theObjID);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_DataSetMapperHolder
+::SetImplicitFunction(vtkImplicitFunction *theFunction)
+{
+ myExtractGeometry->SetImplicitFunction(theFunction);
+}
+
+//----------------------------------------------------------------------------
+vtkImplicitFunction *
+VISU_DataSetMapperHolder
+::GetImplicitFunction()
+{
+ return myExtractGeometry->GetImplicitFunction();
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_DataSetMapperHolder
+::RemoveAllClippingPlanes()
+{
+ if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
+ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+ aFunction->RemoveAllItems();
+ aBoolean->Modified(); // VTK bug
+ }
+}
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_DataSetMapperHolder
+::GetNumberOfClippingPlanes()
+{
+ if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
+ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+ return aFunction->GetNumberOfItems();
+ }
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+bool
+VISU_DataSetMapperHolder
+::AddClippingPlane(vtkPlane* thePlane)
+{
+ if (thePlane) {
+ if (vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()) {
+ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+ aFunction->AddItem(thePlane);
+ // Check, that at least one cell present after clipping.
+ // This check was introduced because of bug IPAL8849.
+ vtkDataSet* aClippedDataSet = GetClippedInput();
+ if(aClippedDataSet->GetNumberOfCells() < 1)
+ return false;
+ }
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------------
+vtkPlane*
+VISU_DataSetMapperHolder
+::GetClippingPlane(vtkIdType theID)
+{
+ vtkPlane* aPlane = NULL;
+ if(theID >= 0 && theID < GetNumberOfClippingPlanes()){
+ if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
+ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+ vtkImplicitFunction* aFun = NULL;
+ aFunction->InitTraversal();
+ for(vtkIdType anID = 0; anID <= theID; anID++)
+ aFun = aFunction->GetNextItem();
+ aPlane = dynamic_cast<vtkPlane*>(aFun);
+ }
+ }
+ return aPlane;
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_DataSetMapperHolder
+::SetExtractInside(bool theMode)
+{
+ myExtractGeometry->SetExtractInside(theMode);
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_DataSetMapperHolder
+::SetExtractBoundaryCells(bool theMode)
+{
+ myExtractGeometry->SetExtractBoundaryCells(theMode);
+}
+
+
+//----------------------------------------------------------------------------
--- /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_DataSetMapperHolder.hxx
+// Author: Alexey PETROV
+// Module : VISU
+
+#ifndef VISU_DataSetMapperHolder_HeaderFile
+#define VISU_DataSetMapperHolder_HeaderFile
+
+#include "VISU_MapperHolder.hxx"
+
+class vtkDataSetMapper;
+class vtkUnstructuredGrid;
+class SALOME_ExtractGeometry;
+
+
+//----------------------------------------------------------------------------
+class VISU_DataSetMapperHolder : public VISU_MapperHolder
+{
+public:
+ vtkTypeMacro(VISU_DataSetMapperHolder, VISU_MapperHolder);
+
+ static
+ VISU_DataSetMapperHolder*
+ New();
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ ShallowCopy(VISU_MapperHolder *theMapperHolder,
+ bool theIsCopyInput);
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ //----------------------------------------------------------------------------
+ void
+ SetUnstructuredGridIDMapper(const VISU::PUnstructuredGridIDMapper& theIDMapper);
+
+ const VISU::PUnstructuredGridIDMapper&
+ GetUnstructuredGridIDMapper();
+
+ virtual
+ vtkUnstructuredGrid*
+ GetUnstructuredGridInput();
+
+ virtual
+ vtkDataSetMapper*
+ GetDataSetMapper();
+
+ //----------------------------------------------------------------------------
+ virtual
+ vtkIdType
+ GetNodeObjID(vtkIdType theID);
+
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID);
+
+ virtual
+ vtkFloatingPointType*
+ GetNodeCoord(vtkIdType theObjID);
+
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID);
+
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID);
+
+ virtual
+ vtkCell*
+ GetElemCell(vtkIdType theObjID);
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ SetImplicitFunction(vtkImplicitFunction *theFunction);
+
+ virtual
+ vtkImplicitFunction*
+ GetImplicitFunction();
+
+ virtual
+ void
+ SetExtractInside(bool theMode);
+
+ virtual
+ void
+ SetExtractBoundaryCells(bool theMode);
+
+ //----------------------------------------------------------------------------
+ // Clipping planes
+ virtual
+ void
+ RemoveAllClippingPlanes();
+
+ virtual
+ vtkIdType
+ GetNumberOfClippingPlanes();
+
+ virtual
+ bool
+ AddClippingPlane(vtkPlane* thePlane);
+
+ virtual
+ vtkPlane*
+ GetClippingPlane(vtkIdType theID);
+
+protected:
+ //----------------------------------------------------------------------------
+ VISU_DataSetMapperHolder();
+ VISU_DataSetMapperHolder(const VISU_DataSetMapperHolder&);
+
+ virtual
+ ~VISU_DataSetMapperHolder();
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ OnCreateMapper();
+
+ void
+ SetDataSetMapper(vtkDataSetMapper* theMapper);
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ SetLookupTable(VISU_LookupTable* theLookupTable);
+
+ virtual
+ vtkPointSet*
+ GetClippedInput();
+
+private:
+ //----------------------------------------------------------------------------
+ VISU::PUnstructuredGridIDMapper myUnstructuredGridIDMapper;
+ vtkSmartPointer<vtkDataSetMapper> myDataSetMapper;
+ vtkSmartPointer<SALOME_ExtractGeometry> myExtractGeometry; //!< Clipping
+};
+
+#endif
#include <vtkWarpVector.h>
+
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_DeformedShapePL);
+
+//----------------------------------------------------------------------------
VISU_DeformedShapePL
-::VISU_DeformedShapePL()
+::VISU_DeformedShapePL():
+ myScaleFactor(0.0)
{
+ SetIsShrinkable(true);
+
myWarpVector = vtkWarpVector::New();
myCellDataToPointData = vtkCellDataToPointData::New();
}
+
+//----------------------------------------------------------------------------
VISU_DeformedShapePL
::~VISU_DeformedShapePL()
{
- // commented: porting to vtk5.0
- // myWarpVector->UnRegisterAllOutputs();
myWarpVector->Delete();
- // commented: porting to vtk5.0
- // myCellDataToPointData->UnRegisterAllOutputs();
myCellDataToPointData->Delete();
}
+
+//----------------------------------------------------------------------------
void
VISU_DeformedShapePL
-::ShallowCopy(VISU_PipeLine *thePipeLine)
+::DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput)
{
+ Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
+
if(VISU_DeformedShapePL *aPipeLine = dynamic_cast<VISU_DeformedShapePL*>(thePipeLine)){
SetScale(aPipeLine->GetScale());
}
- TSupperClass::ShallowCopy(thePipeLine);
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_DeformedShapePL
::GetScaleFactor(vtkDataSet* theDataSet)
{
- if(!theDataSet) return 0.0;
+ if(!theDataSet)
+ return 0.0;
+
theDataSet->Update();
+
int aNbCells = theDataSet->GetNumberOfCells();
int aNbPoints = theDataSet->GetNumberOfPoints();
int aNbElem = aNbCells? aNbCells: aNbPoints;
+
vtkFloatingPointType* aBounds = theDataSet->GetBounds();
vtkFloatingPointType aVolume = 1, aVol, idim = 0;
for(int i = 0; i < 6; i += 2){
}
}
aVolume /= aNbElem;
- return pow(aVolume,vtkFloatingPointType(1.0/idim));
+ return pow(aVolume, vtkFloatingPointType(1.0/idim));
}
+//----------------------------------------------------------------------------
+vtkFloatingPointType
+VISU_DeformedShapePL
+::GetDefaultScale(VISU_ScalarMapPL* theScalarMapPL)
+{
+ vtkFloatingPointType aSourceRange[2];
+ theScalarMapPL->GetSourceRange(aSourceRange);
+
+ static vtkFloatingPointType EPS = 1.0 / VTK_LARGE_FLOAT;
+ if(fabs(aSourceRange[1]) > EPS){
+ vtkDataSet* aDataSet = theScalarMapPL->GetMergedInput();
+ vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor(aDataSet);
+ return aScaleFactor / aSourceRange[1];
+ }
+ return 0.0;
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_DeformedShapePL
::SetScale(vtkFloatingPointType theScale)
{
+ if(VISU::CheckIsSameValue(myWarpVector->GetScaleFactor(), theScale))
+ return;
+
myWarpVector->SetScaleFactor(theScale);
myScaleFactor = theScale;
- Modified();
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_DeformedShapePL
::GetScale()
return myScaleFactor;
}
+
+//----------------------------------------------------------------------------
void
VISU_DeformedShapePL
::Init()
{
- TSupperClass::Init();
- vtkFloatingPointType aScalarRange[2];
- GetSourceRange(aScalarRange);
-
- vtkDataSet* aDataSet = GetInput2();
- //vtkDataSet* aDataSet = GetScalars()->GetInput();
- vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet );
-
- static double EPS = 1.0 / VTK_LARGE_FLOAT;
- if(fabs(aScalarRange[1]) > EPS)
- SetScale(aScaleFactor / aScalarRange[1]);
- else
- SetScale(0.0);
+ Superclass::Init();
+
+ SetScale(VISU_DeformedShapePL::GetDefaultScale(this));
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_DeformedShapePL
+::Update()
+{
+ Superclass::Update();
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myWarpVector.vtk";
+ // VISU::WriteToFile(myWarpVector->GetUnstructuredGridOutput(), aFileName);
+ //}
}
-VISU_ScalarMapPL::THook*
+
+//----------------------------------------------------------------------------
+vtkDataSet*
VISU_DeformedShapePL
-::DoHook()
+::InsertCustomPL()
{
- VISU::CellDataToPoint(myWarpVector,myCellDataToPointData,GetInput2(),myFieldTransform);
+ VISU::CellDataToPoint(myWarpVector,
+ myCellDataToPointData,
+ GetMergedInput());
+
return myWarpVector->GetOutput();
}
-void
+
+//----------------------------------------------------------------------------
+unsigned long int
VISU_DeformedShapePL
-::Update()
+::GetMemorySize()
{
- TSupperClass::Update();
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ if(myWarpVector->GetInput())
+ if(vtkDataSet* aDataSet = myWarpVector->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(myCellDataToPointData->GetInput())
+ if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ return aSize;
}
+
+//----------------------------------------------------------------------------
void
VISU_DeformedShapePL
::SetMapScale(vtkFloatingPointType theMapScale)
{
- TSupperClass::SetMapScale(theMapScale);
+ Superclass::SetMapScale(theMapScale);
myWarpVector->SetScaleFactor(myScaleFactor*theMapScale);
- Modified();
}
+
+
+//----------------------------------------------------------------------------
#define VISU_DeformedShapePL_HeaderFile
#include "VISUPipeline.hxx"
-#include "VISU_PrsMergerPL.hxx"
+#include "VISU_ScalarMapPL.hxx"
class vtkCellDataToPointData;
class SALOME_Transform;
class vtkWarpVector;
-class VISU_PIPELINE_EXPORT VISU_DeformedShapePL : public VISU_PrsMergerPL
+//----------------------------------------------------------------------------
+class VISU_PIPELINE_EXPORT VISU_DeformedShapePL : public VISU_ScalarMapPL
{
- typedef VISU_PrsMergerPL TSupperClass;
-
-protected:
- VISU_DeformedShapePL();
- VISU_DeformedShapePL(const VISU_DeformedShapePL&);
-
- virtual
- ~VISU_DeformedShapePL();
-
public:
- vtkTypeMacro(VISU_DeformedShapePL,TSupperClass);
+ vtkTypeMacro(VISU_DeformedShapePL, VISU_ScalarMapPL);
static
VISU_DeformedShapePL*
New();
- virtual
- void
- ShallowCopy(VISU_PipeLine *thePipeLine);
-
virtual
void
SetScale(vtkFloatingPointType theScale);
void
Update();
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
virtual
void
SetMapScale(vtkFloatingPointType theMapScale = 1.0);
vtkFloatingPointType
GetScaleFactor(vtkDataSet* theDataSet);
+ static
+ vtkFloatingPointType
+ GetDefaultScale(VISU_ScalarMapPL* theScalarMapPL);
+
protected:
+ VISU_DeformedShapePL();
+ VISU_DeformedShapePL(const VISU_DeformedShapePL&);
+
virtual
- THook*
- DoHook();
+ ~VISU_DeformedShapePL();
+
+ virtual
+ vtkDataSet*
+ InsertCustomPL();
+
+ virtual
+ void
+ DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
vtkFloatingPointType myScaleFactor;
vtkWarpVector *myWarpVector;
#include <vtkObjectFactory.h>
#include <vtkUnstructuredGrid.h>
-#include <vtkFloatArray.h>
#include <vtkPointData.h>
#include <vtkCellData.h>
#include <vector>
#include <vtkInformationVector.h>
-using namespace std;
-
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_Extractor);
-VISU_Extractor::VISU_Extractor()
+//----------------------------------------------------------------------------
+VISU_Extractor
+::VISU_Extractor():
+ myScalarMode(1)
{
- myScalarMode = 1;
}
-VISU_Extractor::~VISU_Extractor()
+
+//----------------------------------------------------------------------------
+VISU_Extractor
+::~VISU_Extractor()
{}
-void VISU_Extractor::SetScalarMode(int theScalarMode)
+
+//----------------------------------------------------------------------------
+void
+VISU_Extractor
+::SetScalarMode(int theScalarMode)
{
if(myScalarMode != theScalarMode){
myScalarMode = theScalarMode;
}
}
-template<typename TypeData> int
-execute(int theNbElems,
- int theScalarMode,
- TypeData* theInputData,
- TypeData* theOutputData)
+//----------------------------------------------------------------------------
+int
+VISU_Extractor
+::GetScalarMode()
{
- if(theNbElems < 1 )
- return 0;
-
- if(theInputData->GetNumberOfArrays() < 1)
- return 1; // no fields output
-
- string aFieldName = "VISU_FIELD";
- vtkDataArray* aFieldArray = theInputData->GetArray(aFieldName.c_str());
- if(vtkFloatArray *aFloatArray = dynamic_cast<vtkFloatArray*>(aFieldArray)){
- int aNbComp = aFloatArray->GetNumberOfComponents();
- std::vector<vtkFloatingPointType> anArray(aNbComp < 3? 3: aNbComp);
- //
- vtkFloatArray *aScalars = vtkFloatArray::New();
- aScalars->SetNumberOfTuples(theNbElems);
- aScalars->SetNumberOfComponents(1);
- //
- if(!theScalarMode){
- for(int anId = 0; anId < theNbElems; anId++){
- aFloatArray->GetTuple(anId,&anArray[0]);
- vtkFloatingPointType aVector[3] = {anArray[0], anArray[1], anArray[2]};
- vtkFloatingPointType aScalar = sqrt(aVector[0]*aVector[0] + aVector[1]*aVector[1] + aVector[2]*aVector[2]);
- aScalars->SetTuple1(anId,aScalar);
- }
- }else{
- for(int anId = 0; anId < theNbElems; anId++){
- aFloatArray->GetTuple(anId,&anArray[0]);
- aScalars->SetTuple1(anId,anArray[theScalarMode - 1]);
- }
- }
- theOutputData->SetScalars(aScalars);
- aScalars->Delete();
+ return myScalarMode;
+}
+
+
+//----------------------------------------------------------------------------
+template<typename TValueType>
+void
+Module2Scalars(vtkDataArray *theInputDataArray,
+ TValueType* theOutputPtr,
+ vtkIdType theNbOfTuples)
+{
+ vtkIdType aNbComp = theInputDataArray->GetNumberOfComponents();
+ std::vector<vtkFloatingPointType> anArray(aNbComp < 3? 3: aNbComp);
+ for(vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++){
+ theInputDataArray->GetTuple(aTupleId, &anArray[0]);
+ vtkFloatingPointType aVector[3] = {anArray[0], anArray[1], anArray[2]};
+ vtkFloatingPointType aScalar = sqrt(aVector[0]*aVector[0] +
+ aVector[1]*aVector[1] +
+ aVector[2]*aVector[2]);
+ *theOutputPtr = TValueType(aScalar);
+ theOutputPtr++;
+ }
+}
+
+
+//----------------------------------------------------------------------------
+template<typename TValueType>
+void
+Component2Scalars(vtkDataArray *theInputDataArray,
+ TValueType* theInputPtr,
+ TValueType* theOutputPtr,
+ vtkIdType theNbOfTuples,
+ vtkIdType theComponentId)
+{
+ vtkIdType aNbComp = theInputDataArray->GetNumberOfComponents();
+ for(vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++){
+ *theOutputPtr = *(theInputPtr + theComponentId);
+ theInputPtr += aNbComp;
+ theOutputPtr++;
}
- return 1;
}
-// waiting for porting vtkSource to the new executive-based pipeline architecture.
-// int VISU_Extractor::RequestData(
-// vtkInformation *vtkNotUsed(request),
-// vtkInformationVector **inputVector,
-// vtkInformationVector *outputVector)
-void VISU_Extractor::Execute()
+
+//----------------------------------------------------------------------------
+template<typename TDataSetAttributesType> void
+ExecuteScalars(vtkIdType theNbOfTuples,
+ vtkIdType theScalarMode,
+ TDataSetAttributesType* theInputData,
+ TDataSetAttributesType* theOutputData)
{
- int aRet = 1;
-// waiting for porting vtkSource to the new executive-based pipeline architecture.
-// // get the info objects
-// vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
-// vtkInformation *outInfo = outputVector->GetInformationObject(0);
-
-// // get the input and ouptut
-// vtkDataSet *input = vtkDataSet::SafeDownCast(
-// inInfo->Get(vtkDataObject::DATA_OBJECT()));
-// vtkDataSet *output = vtkDataSet::SafeDownCast(
-// outInfo->Get(vtkDataObject::DATA_OBJECT()));
- vtkDataSet *input = this->GetInput();
- vtkDataSet *output = this->GetOutput();
- output->CopyStructure(input);
- if(VISU::IsDataOnPoints(input)){
- output->GetPointData()->CopyVectorsOn();
- output->GetPointData()->CopyScalarsOff();
-
- int aNbElems = input->GetNumberOfPoints();
- vtkPointData *inData = input->GetPointData(), *outData = output->GetPointData();
- if(!inData->GetAttribute(vtkDataSetAttributes::SCALARS))
- aRet = execute(aNbElems,myScalarMode,inData,outData);
- else
- output->GetPointData()->CopyScalarsOn();
- outData->PassData(inData);
- outData->AddArray(inData->GetArray("VISU_FIELD"));
+ if(theNbOfTuples < 1)
+ return;
+
+ vtkDataArray* aFieldArray = theInputData->GetArray("VISU_FIELD");
+ vtkIdType anInputDataType = aFieldArray->GetDataType();
+ vtkDataArray *anOutputScalars = vtkDataArray::CreateDataArray(anInputDataType);
+ anOutputScalars->SetNumberOfComponents(1);
+ anOutputScalars->SetNumberOfTuples(theNbOfTuples);
+
+ void *anInputPtr = aFieldArray->GetVoidPointer(0);
+ void *anOutputPtr = anOutputScalars->GetVoidPointer(0);
+
+ if(theScalarMode == 0){
+ switch(anInputDataType){
+ vtkTemplateMacro3(Module2Scalars,
+ aFieldArray,
+ (VTK_TT *)(anOutputPtr),
+ theNbOfTuples);
+ default:
+ break;
+ }
}else{
- output->GetCellData()->CopyVectorsOn();
- output->GetCellData()->CopyScalarsOff();
-
- int aNbElems = input->GetNumberOfCells();
- vtkCellData *inData = input->GetCellData(), *outData = output->GetCellData();
- if(inData->GetAttribute(vtkDataSetAttributes::VECTORS))
- aRet = execute(aNbElems,myScalarMode,inData,outData);
- else
- output->GetCellData()->CopyScalarsOn();
- outData->PassData(inData);
- outData->AddArray(inData->GetArray("VISU_FIELD"));
+ switch(anInputDataType){
+ vtkTemplateMacro5(Component2Scalars,
+ aFieldArray,
+ (VTK_TT *)(anInputPtr),
+ (VTK_TT *)(anOutputPtr),
+ theNbOfTuples,
+ theScalarMode - 1);
+ default:
+ break;
+ }
}
+
+ theOutputData->SetScalars(anOutputScalars);
+ anOutputScalars->Delete();
+}
- if(vtkDataArray *aDataArray = input->GetCellData()->GetArray("VISU_CELLS_MAPPER"))
- output->GetCellData()->AddArray(aDataArray);
- if(vtkDataArray *aDataArray = input->GetPointData()->GetArray("VISU_POINTS_MAPPER"))
- output->GetPointData()->AddArray(aDataArray);
+//---------------------------------------------------------------
+int
+VISU_Extractor
+::RequestData(vtkInformation *theRequest,
+ vtkInformationVector **theInputVector,
+ vtkInformationVector *theOutputVector)
+{
+ vtkDataSet *anInput = VISU::GetInput(theInputVector, 0);
+ vtkDataSet *anOutput = VISU::GetOutput(theOutputVector);
+
+ anOutput->CopyStructure(anInput);
+
+ vtkPointData *anInputPointData = anInput->GetPointData();
+ vtkPointData *anOutputPointData = anOutput->GetPointData();
+ anOutputPointData->PassData(anInputPointData);
+ if(VISU::IsDataOnPoints(anInput)){
+ int aNbElems = anInput->GetNumberOfPoints();
+ if(anInputPointData->GetAttribute(vtkDataSetAttributes::VECTORS))
+ ExecuteScalars(aNbElems, myScalarMode, anInputPointData, anOutputPointData);
+ }
+
+ vtkCellData *anInputCellData = anInput->GetCellData();
+ vtkCellData *anOutputCellData = anOutput->GetCellData();
+ anOutputCellData->PassData(anInputCellData);
+ if(VISU::IsDataOnCells(anInput)){
+ int aNbElems = anInput->GetNumberOfCells();
+ if(anInputCellData->GetAttribute(vtkDataSetAttributes::VECTORS))
+ ExecuteScalars(aNbElems, myScalarMode, anInputCellData, anOutputCellData);
+ }
+
+ return 1;
}
#ifndef VISU_Extractor_HeaderFile
#define VISU_Extractor_HeaderFile
-#include <vtkPointSetToPointSetFilter.h>
+#include "VISUPipeline.hxx"
+#include <vtkDataSetAlgorithm.h>
-class VTK_EXPORT VISU_Extractor : public vtkPointSetToPointSetFilter{
+
+//----------------------------------------------------------------------------
+class VISU_PIPELINE_EXPORT VISU_Extractor : public vtkDataSetAlgorithm
+{
public:
- vtkTypeMacro(VISU_Extractor,vtkPointSetToPointSetFilter);
- static VISU_Extractor *New();
+ vtkTypeMacro(VISU_Extractor, vtkDataSetAlgorithm);
+
+ static
+ VISU_Extractor
+ *New();
- virtual int GetScalarMode(){ return myScalarMode;}
- virtual void SetScalarMode(int theScalarMode = 0);
+ virtual
+ int
+ GetScalarMode();
+
+ virtual
+ void
+ SetScalarMode(int theScalarMode = 0);
protected:
VISU_Extractor();
VISU_Extractor(const VISU_Extractor&);
+
~VISU_Extractor();
- // waiting for porting vtkSource to the new executive-based pipeline architecture.
- //virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
- virtual void Execute();
+ virtual
+ int
+ RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
int myScalarMode;
};
#include "VISU_FieldTransform.hxx"
#include "VTKViewer_Transform.h"
+#include "VISU_PipeLineUtils.hxx"
#include <vtkObjectFactory.h>
-#include <vtkFloatArray.h>
#include <vtkPointData.h>
#include <vtkCellData.h>
#include <vtkDataSet.h>
static vtkFloatingPointType Tolerance = 1.0 / VTK_LARGE_FLOAT;
-using namespace std;
-
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_FieldTransform);
+//----------------------------------------------------------------------------
double
VISU_FieldTransform
::Ident(double theArg)
return theArg;
}
+//----------------------------------------------------------------------------
double
VISU_FieldTransform
::Log10(double theArg)
}
+//----------------------------------------------------------------------------
VISU_FieldTransform
::VISU_FieldTransform()
{
myScalarRange[1] = -VTK_LARGE_FLOAT;
}
+//----------------------------------------------------------------------------
VISU_FieldTransform
::~VISU_FieldTransform()
{
{
unsigned long aTime = Superclass::GetMTime();
if(myTransform)
- aTime = max(aTime,myTransform->GetMTime());
+ aTime = std::max(aTime, myTransform->GetMTime());
return aTime;
}
+//----------------------------------------------------------------------------
void
VISU_FieldTransform
::SetScalarTransform(TTransformFun theFunction)
Modified();
}
-void VISU_FieldTransform::SetSpaceTransform(VTKViewer_Transform* theTransform){
+//----------------------------------------------------------------------------
+void
+VISU_FieldTransform
+::SetSpaceTransform(VTKViewer_Transform* theTransform)
+{
if(myTransform == theTransform)
return;
}
+//----------------------------------------------------------------------------
void
VISU_FieldTransform
::SetScalarRange(vtkFloatingPointType theScalarRange[2])
{
- vtkFloatingPointType aDelta =
- fabs(myScalarRange[0] - theScalarRange[0]) +
- fabs(myScalarRange[1] - theScalarRange[1]);
- if(aDelta < Tolerance)
+ if(VISU::CheckIsSameRange(theScalarRange, myScalarRange))
return;
myScalarRange[0] = theScalarRange[0];
Modified();
}
+//----------------------------------------------------------------------------
void
VISU_FieldTransform
::SetScalarMin(vtkFloatingPointType theValue)
SetScalarRange(aScalarRange);
}
+//----------------------------------------------------------------------------
void
VISU_FieldTransform
::SetScalarMax(vtkFloatingPointType theValue)
SetScalarRange(aScalarRange);
}
+//----------------------------------------------------------------------------
+template<typename TValueType>
+void
+LinearTransformVectors(TValueType* theInputPtr,
+ TValueType* theOutputPtr,
+ vtkIdType theNbOfTuples,
+ vtkFloatingPointType theScale[3])
+{
+ for(vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++){
+ for(vtkIdType aComponentId = 0; aComponentId < 3; aComponentId++){
+ *theOutputPtr = TValueType(*theInputPtr * theScale[aComponentId]);
+ theOutputPtr++;
+ theInputPtr++;
+ }
+ }
+}
+
-template<typename TypeData> void
-ExecVectors(VISU_FieldTransform::TTransformFun theFunction,
- VTKViewer_Transform* theTransform,
- vtkFloatingPointType theScalarRange[2],
- int theNbOfTuples,
- TypeData* theInputData,
- TypeData* theOutputData)
+//----------------------------------------------------------------------------
+template<typename TValueType>
+void
+NonLinearTransformVectors(vtkDataArray *theInputVectors,
+ TValueType* theInputPtr,
+ TValueType* theOutputPtr,
+ vtkIdType theNbOfTuples,
+ vtkFloatingPointType theScale[3],
+ VISU_FieldTransform::TTransformFun theFunction,
+ vtkFloatingPointType theModifiedScalarMin,
+ vtkFloatingPointType theModifiedScalarDelta,
+ vtkFloatingPointType theSourceScalarMax)
{
- vtkDataArray *anInVectors = theInputData->GetVectors();
- if ( !anInVectors || theNbOfTuples < 1 )
+ for(vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++){
+ vtkFloatingPointType anInputVector[3];
+ theInputVectors->GetTuple(aTupleId, anInputVector);
+ vtkFloatingPointType aMagnification = vtkMath::Norm(anInputVector);
+ if(aMagnification > Tolerance)
+ aMagnification =
+ ((*theFunction)(aMagnification) - theModifiedScalarMin) /
+ theModifiedScalarDelta * theSourceScalarMax /
+ aMagnification;
+ if(aMagnification < 0.0)
+ aMagnification = 0.0;
+ for(vtkIdType aComponentId = 0; aComponentId < 3; aComponentId++){
+ *theOutputPtr = TValueType(*theInputPtr * aMagnification * theScale[aComponentId]);
+ theOutputPtr++;
+ theInputPtr++;
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+template<typename TDataSetAttributesType>
+void
+ExecuteVectors(VISU_FieldTransform::TTransformFun theFunction,
+ VTKViewer_Transform* theTransform,
+ vtkFloatingPointType theScalarRange[2],
+ vtkIdType theNbOfTuples,
+ TDataSetAttributesType* theInputData,
+ TDataSetAttributesType* theOutputData)
+{
+ vtkDataArray *anInputVectors = theInputData->GetVectors();
+ if(!anInputVectors || theNbOfTuples < 1)
return;
- vtkFloatArray *aNewVectors = vtkFloatArray::New();
- aNewVectors->SetNumberOfComponents(3);
- aNewVectors->SetNumberOfTuples(theNbOfTuples);
- vtkFloatingPointType aScalarRange[2] = {(*theFunction)(theScalarRange[0]),(*theFunction)(theScalarRange[1])};
- vtkFloatingPointType aDelta = aScalarRange[1] - aScalarRange[0];
+
+ vtkFloatingPointType aScalarRange[2];
+ aScalarRange[0] = (*theFunction)(theScalarRange[0]);
+ aScalarRange[1] = (*theFunction)(theScalarRange[1]);
+
+ vtkFloatingPointType aScalarDelta = aScalarRange[1] - aScalarRange[0];
vtkFloatingPointType aScale[3] = {1.0, 1.0, 1.0};
- static vtkFloatingPointType EPS = 1.0 / VTK_LARGE_FLOAT;
+
if(theTransform){
aScale[0] = theTransform->GetScale()[0];
aScale[1] = theTransform->GetScale()[1];
aScale[2] = theTransform->GetScale()[2];
}
+
+ vtkIdType anInputDataType = anInputVectors->GetDataType();
+ vtkDataArray *anOutputVectors = vtkDataArray::CreateDataArray(anInputDataType);
+ anOutputVectors->SetNumberOfComponents(3);
+ anOutputVectors->SetNumberOfTuples(theNbOfTuples);
+
+ void *anInputPtr = anInputVectors->GetVoidPointer(0);
+ void *anOutputPtr = anOutputVectors->GetVoidPointer(0);
+
if(theFunction == &(VISU_FieldTransform::Ident)){
- for (int aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++) {
- vtkFloatingPointType anInVec[3];
- anInVectors->GetTuple(aTupleId,anInVec);
- vtkFloatingPointType anNewVec[3];
- anNewVec[0] = anInVec[0]*aScale[0];
- anNewVec[1] = anInVec[1]*aScale[1];
- anNewVec[2] = anInVec[2]*aScale[2];
- aNewVectors->SetTuple(aTupleId,anNewVec);
- }
+ switch(anInputDataType){
+ vtkTemplateMacro4(LinearTransformVectors,
+ (VTK_TT *)(anInputPtr),
+ (VTK_TT *)(anOutputPtr),
+ theNbOfTuples,
+ aScale);
+ default:
+ break;
+ }
}else{
- for (int aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++) {
- vtkFloatingPointType anInVec[3];
- anInVectors->GetTuple(aTupleId,anInVec);
- vtkFloatingPointType aMagn = vtkMath::Norm(anInVec);
- if(aMagn > EPS)
- aMagn = ((*theFunction)(aMagn) - aScalarRange[0]) / aDelta * theScalarRange[1] / aMagn;
- if(aMagn < 0.0)
- aMagn = 0.0;
- vtkFloatingPointType anNewVec[3];
- anNewVec[0] = anInVec[0]*aMagn*aScale[0];
- anNewVec[1] = anInVec[1]*aMagn*aScale[1];
- anNewVec[2] = anInVec[2]*aMagn*aScale[2];
- aNewVectors->SetTuple(aTupleId,anNewVec);
- }
+ switch(anInputDataType){
+ vtkTemplateMacro9(NonLinearTransformVectors,
+ anInputVectors,
+ (VTK_TT *)(anInputPtr),
+ (VTK_TT *)(anOutputPtr),
+ theNbOfTuples,
+ aScale,
+ theFunction,
+ aScalarRange[0],
+ aScalarDelta,
+ theScalarRange[1]);
+ default:
+ break;
+ }
}
- theOutputData->SetVectors(aNewVectors);
- aNewVectors->Delete();
+
+ theOutputData->SetVectors(anOutputVectors);
+ anOutputVectors->Delete();
}
-template<typename TypeData> void
-ExecScalars(VISU_FieldTransform::TTransformFun theFunction,
- vtkFloatingPointType theScalarRange[2],
- int theNbOfTuples,
- TypeData* theInputData,
- TypeData* theOutputData)
+
+//----------------------------------------------------------------------------
+template<typename TValueType>
+void
+NonLinearTransformScalars(vtkDataArray *theInputScalars,
+ TValueType* theInputPtr,
+ TValueType* theOutputPtr,
+ vtkIdType theNbOfTuples,
+ VISU_FieldTransform::TTransformFun theFunction,
+ vtkFloatingPointType theModifiedScalarMin)
{
- vtkDataArray *anInScalars = theInputData->GetScalars();
- if ( !anInScalars || theNbOfTuples < 1 )
- return;
- vtkFloatArray *aNewScalars = vtkFloatArray::New();
- aNewScalars->SetNumberOfComponents(1);
- aNewScalars->SetNumberOfTuples(theNbOfTuples);
- vtkFloatingPointType aScalarRange[2] = {(*theFunction)(theScalarRange[0]),(*theFunction)(theScalarRange[1])};
- for (int aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++) {
- vtkFloatingPointType aScalar = (*theFunction)(anInScalars->GetTuple1(aTupleId));
- if(aScalar < aScalarRange[0])
- aScalar = aScalarRange[0];
- aNewScalars->SetTuple1(aTupleId,aScalar);
+ for(vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++){
+ vtkFloatingPointType aScalar = (*theFunction)(vtkFloatingPointType(*theInputPtr));
+ if(aScalar < theModifiedScalarMin)
+ aScalar = theModifiedScalarMin;
+ *theOutputPtr = TValueType(aScalar);
+ theOutputPtr++;
+ theInputPtr++;
}
- theOutputData->SetScalars(aNewScalars);
- aNewScalars->Delete();
}
-// waiting for porting vtkSource to the new executive-based pipeline architecture.
+
+//----------------------------------------------------------------------------
+template<typename TDataSetAttributesType>
+void
+ExecuteScalars(VISU_FieldTransform::TTransformFun theFunction,
+ vtkFloatingPointType theScalarRange[2],
+ vtkIdType theNbOfTuples,
+ TDataSetAttributesType* theInputData,
+ TDataSetAttributesType* theOutputData)
+{
+ vtkDataArray *anInputScalars = theInputData->GetScalars();
+ if(!anInputScalars || theNbOfTuples < 1)
+ return;
+
+ vtkFloatingPointType aScalarRange[2];
+ aScalarRange[0] = (*theFunction)(theScalarRange[0]);
+ aScalarRange[1] = (*theFunction)(theScalarRange[1]);
+
+ vtkIdType anInputDataType = anInputScalars->GetDataType();
+ vtkDataArray *anOutputScalars = vtkDataArray::CreateDataArray(anInputDataType);
+ anOutputScalars->SetNumberOfComponents(1);
+ anOutputScalars->SetNumberOfTuples(theNbOfTuples);
+
+ void *anInputPtr = anInputScalars->GetVoidPointer(0);
+ void *anOutputPtr = anOutputScalars->GetVoidPointer(0);
+
+ switch(anInputDataType){
+ vtkTemplateMacro6(NonLinearTransformScalars,
+ anInputScalars,
+ (VTK_TT *)(anInputPtr),
+ (VTK_TT *)(anOutputPtr),
+ theNbOfTuples,
+ theFunction,
+ aScalarRange[0]);
+ default:
+ break;
+ }
+
+ theOutputData->SetScalars(anOutputScalars);
+ anOutputScalars->Delete();
+}
+
+
+//----------------------------------------------------------------------------
int
VISU_FieldTransform
-::RequestData(
- vtkInformation *vtkNotUsed(request),
- vtkInformationVector **inputVector,
- vtkInformationVector *outputVector)
-// void VISU_FieldTransform::Execute()
+::RequestData(vtkInformation *vtkNotUsed(request),
+ vtkInformationVector **inputVector,
+ vtkInformationVector *outputVector)
{
// get the info objects
vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
inInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkDataSet *output = vtkDataSet::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
-// vtkDataSet *input = this->GetInput();
-// vtkDataSet *output = this->GetOutput();
output->CopyStructure(input);
if(myFunction != &Ident || (myTransform && !myTransform->IsIdentity())){
output->GetCellData()->CopyScalarsOff();
output->GetCellData()->CopyVectorsOff();
- ExecScalars(myFunction,myScalarRange,input->GetNumberOfPoints(),input->GetPointData(),output->GetPointData());
- ExecVectors(myFunction,myTransform,myScalarRange,input->GetNumberOfPoints(),input->GetPointData(),output->GetPointData());
+ ExecuteScalars(myFunction,
+ myScalarRange,
+ input->GetNumberOfPoints(),
+ input->GetPointData(),
+ output->GetPointData());
+
+ ExecuteVectors(myFunction,
+ myTransform,
+ myScalarRange,
+ input->GetNumberOfPoints(),
+ input->GetPointData(),
+ output->GetPointData());
+
+ ExecuteScalars(myFunction,
+ myScalarRange,
+ input->GetNumberOfCells(),
+ input->GetCellData(),
+ output->GetCellData());
+
+ ExecuteVectors(myFunction,
+ myTransform,
+ myScalarRange,
+ input->GetNumberOfCells(),
+ input->GetCellData(),
+ output->GetCellData());
+ }else{
+ output->GetPointData()->CopyAllOn();
+ output->GetCellData()->CopyAllOn();
- ExecScalars(myFunction,myScalarRange,input->GetNumberOfCells(),input->GetCellData(),output->GetCellData());
- ExecVectors(myFunction,myTransform,myScalarRange,input->GetNumberOfCells(),input->GetCellData(),output->GetCellData());
+ output->GetPointData()->PassData(input->GetPointData());
+ output->GetCellData()->PassData(input->GetCellData());
}
+
output->GetPointData()->PassData(input->GetPointData());
output->GetCellData()->PassData(input->GetCellData());
+ return 1;
}
+
+
+//----------------------------------------------------------------------------
#include <vtkDataSetAlgorithm.h>
-#include "VTKViewer.h"
+#include "VISUPipeline.hxx"
class VTKViewer_Transform;
-class VTK_EXPORT VISU_FieldTransform : public vtkDataSetAlgorithm
+class VISU_PIPELINE_EXPORT VISU_FieldTransform : public vtkDataSetAlgorithm
{
public:
- vtkTypeMacro(VISU_FieldTransform,vtkDataSetAlgorithm);
- static VISU_FieldTransform *New();
+ vtkTypeMacro(VISU_FieldTransform, vtkDataSetAlgorithm);
- virtual unsigned long GetMTime();
+ static
+ VISU_FieldTransform
+ *New();
+
+ virtual
+ unsigned long
+ GetMTime();
- static double Ident(double theArg);
- static double Log10(double theArg);
+ static
+ double
+ Ident(double theArg);
+
+ static
+ double
+ Log10(double theArg);
+
typedef double (*TTransformFun)(double);
- void SetScalarTransform(TTransformFun theFunction);
- TTransformFun GetScalarTransform() { return myFunction;}
- void SetSpaceTransform(VTKViewer_Transform* theTransform);
- VTKViewer_Transform* GetSpaceTransform() { return myTransform;}
+ void
+ SetScalarTransform(TTransformFun theFunction);
- vtkFloatingPointType* GetScalarRange(){ return myScalarRange; }
- void SetScalarRange(vtkFloatingPointType theScalarRange[2]);
- void SetScalarMin(vtkFloatingPointType theValue);
- void SetScalarMax(vtkFloatingPointType theValue);
+ TTransformFun
+ GetScalarTransform()
+ {
+ return myFunction;
+ }
+
+ void
+ SetSpaceTransform(VTKViewer_Transform* theTransform);
+
+ VTKViewer_Transform*
+ GetSpaceTransform()
+ {
+ return myTransform;
+ }
+
+ vtkFloatingPointType*
+ GetScalarRange()
+ {
+ return myScalarRange;
+ }
+
+ void
+ SetScalarRange(vtkFloatingPointType theScalarRange[2]);
+
+ void
+ SetScalarMin(vtkFloatingPointType theValue);
+
+ void
+ SetScalarMax(vtkFloatingPointType theValue);
protected:
VISU_FieldTransform();
- virtual ~VISU_FieldTransform();
- // waiting for porting vtkSource to the new executive-based pipeline architecture.
- virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
- // virtual void Execute();
-
- VISU_FieldTransform(const VISU_FieldTransform&) {};
- void operator=(const VISU_FieldTransform&) {};
+ virtual
+ ~VISU_FieldTransform();
+ virtual
+ int
+ RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
VTKViewer_Transform *myTransform;
TTransformFun myFunction;
vtkFloatingPointType myScalarRange[2];
+
+private:
+ VISU_FieldTransform(const VISU_FieldTransform&);
+ void operator=(const VISU_FieldTransform&);
};
#endif
#include "VISU_GaussPointsPL.hxx"
+#include "VISU_PointSpriteMapperHolder.hxx"
+#include "VISU_OpenGLPointSpriteMapper.hxx"
#include "VISU_DeformedShapePL.hxx"
+#include "VISU_FieldTransform.hxx"
+#include "VISU_LookupTable.hxx"
+
#include "VISU_PipeLineUtils.hxx"
-#include "SALOME_ExtractGeometry.h"
-#include "VISU_DeformedShapePL.hxx"
-#include "VISU_OpenGLPointSpriteMapper.hxx"
#include <vtkPointSource.h>
#include <vtkElevationFilter.h>
//----------------------------------------------------------------------------
VISU_GaussPointsPL
::VISU_GaussPointsPL():
- myIsDeformed(false),
myScaleFactor(0.0),
- myResolution( 8 ),
myMagnificationIncrement(2)
{
- myExtractGeometry->SetExtractInside(0);
-
- myPSMapper = VISU_OpenGLPointSpriteMapper::New();
- myPSMapper->SetColorModeToMapScalars();
- myPSMapper->ScalarVisibilityOn();
-
- myGeomFilter = vtkGeometryFilter::New();
+ SetIsShrinkable(false);
myWarpVector = vtkWarpVector::New();
- myCellDataToPointData = vtkCellDataToPointData::New();
- myCellDataToPointData->SetPassCellData(true);
myGlyph = vtkGlyph3D::New();
myGlyph->SetScaleModeToScaleByScalar();
myGlyph->SetColorModeToColorByScalar();
myGlyph->ClampingOn();
- myExtractor->SetInput( myExtractGeometry->GetOutput() );
- myFieldTransform->SetInput( myExtractor->GetOutput() );
-
- myCellDataToPointData->SetInput( myFieldTransform->GetUnstructuredGridOutput() );
-
mySphereSource = vtkSphereSource::New();
+ mySphereSource->SetThetaResolution( 8 );
+ mySphereSource->SetPhiResolution( 8 );
myGlyph->SetSource( mySphereSource->GetOutput() );
- for(int i = 0; i < 2; i++)
+ for(int i = 0; i < 3; i++)
myPassFilter.push_back(vtkPassThroughFilter::New());
}
VISU_GaussPointsPL
::~VISU_GaussPointsPL()
{
- if (this->myPSMapper)
- {
- this->myPSMapper->Delete();
- this->myPSMapper = NULL;
- }
- if (this->myGeomFilter)
- {
- this->myGeomFilter->Delete();
- this->myGeomFilter = NULL;
- }
-
myWarpVector->Delete();
- myCellDataToPointData->Delete();
-
myGlyph->Delete();
mySphereSource->Delete();
- for(int i = 0; i < 2; i++)
+ for(int i = 0; i < 3; i++)
myPassFilter[i]->Delete();
}
+//----------------------------------------------------------------------------
+void
+VISU_GaussPointsPL
+::OnCreateMapperHolder()
+{
+ myPointSpriteMapperHolder = VISU_PointSpriteMapperHolder::New();
+ myPointSpriteMapperHolder->Delete();
+
+ SetMapperHolder(myPointSpriteMapperHolder.GetPointer());
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_GaussPointsPL
+::SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theIDMapper)
+{
+ GetPointSpriteMapperHolder()->SetGaussPtsIDMapper(theIDMapper);
+}
+
+
+//----------------------------------------------------------------------------
+const VISU::PGaussPtsIDMapper&
+VISU_GaussPointsPL
+::GetGaussPtsIDMapper()
+{
+ return GetPointSpriteMapperHolder()->GetGaussPtsIDMapper();
+}
+
+
+//----------------------------------------------------------------------------
+VISU_PointSpriteMapperHolder*
+VISU_GaussPointsPL
+::GetPointSpriteMapperHolder()
+{
+ GetMapperHolder();
+
+ return myPointSpriteMapperHolder.GetPointer();
+}
+
+//----------------------------------------------------------------------------
+vtkDataSet*
+VISU_GaussPointsPL
+::GetParentMesh()
+{
+ VISU::TNamedIDMapper* aNamedIDMapper = GetGaussPtsIDMapper()->GetParent();
+ return aNamedIDMapper->GetOutput();
+}
+
//----------------------------------------------------------------------------
void
-CopyGlyph( vtkGlyph3D* source, vtkGlyph3D* dest )
+CopyGlyph( vtkGlyph3D* theSource, vtkGlyph3D* theDestination )
{
- dest->SetRange( source->GetRange() );
- dest->SetScaling( source->GetScaling() );
- dest->SetClamping( source->GetClamping() );
- dest->SetScaleMode( source->GetScaleMode() );
- dest->SetColorMode( source->GetColorMode() );
- dest->SetScaleFactor( source->GetScaleFactor() );
+ vtkFloatingPointType* aSourceRange = theSource->GetRange();
+ vtkFloatingPointType* aDestinationRange = theDestination->GetRange();
+ if(!VISU::CheckIsSameRange(aDestinationRange, aSourceRange))
+ theDestination->SetRange( aSourceRange );
+
+ theDestination->SetScaling( theSource->GetScaling() );
+ theDestination->SetClamping( theSource->GetClamping() );
+ theDestination->SetScaleMode( theSource->GetScaleMode() );
+ theDestination->SetColorMode( theSource->GetColorMode() );
+ theDestination->SetScaleFactor( theSource->GetScaleFactor() );
}
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
-::ShallowCopy(VISU_PipeLine *thePipeLine)
+::DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput)
{
- if(VISU_GaussPointsPL *aPipeLine = dynamic_cast<VISU_GaussPointsPL*>(thePipeLine)){
- // To restore mapper input from pipeline
- vtkPolyData* aDatsSet = myPSMapper->GetInput();
- myPSMapper->ShallowCopy(aPipeLine->GetPSMapper());
- myPSMapper->SetInput(aDatsSet);
+ Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
+ if(VISU_GaussPointsPL *aPipeLine = dynamic_cast<VISU_GaussPointsPL*>(thePipeLine)){
SetPrimitiveType(aPipeLine->GetPrimitiveType());
SetBicolor(aPipeLine->GetBicolor());
SetClamp(aPipeLine->GetClamp());
SetIsDeformed( aPipeLine->GetIsDeformed() );
SetScale( aPipeLine->GetScale() );
- mySphereSource->SetRadius( aPipeLine->mySphereSource->GetRadius() );
+ vtkFloatingPointType aRadius = aPipeLine->mySphereSource->GetRadius();
+ if(!VISU::CheckIsSameValue(mySphereSource->GetRadius(), aRadius))
+ mySphereSource->SetRadius( aRadius );
+
CopyGlyph( aPipeLine->myGlyph, this->myGlyph );
}
- Superclass::ShallowCopy(thePipeLine);
}
//----------------------------------------------------------------------------
-VISU_PipeLine::TMapper*
-VISU_GaussPointsPL
-::GetMapper()
-{
- return GetPSMapper();
-}
-
VISU_OpenGLPointSpriteMapper*
VISU_GaussPointsPL
-::GetPSMapper()
+::GetPointSpriteMapper()
{
- if(GetInput()){
- if(!myPSMapper->GetInput()){
- GetInput2()->Update();
- Build();
- Init();
- }
- myPSMapper->Update();
- }
- return myPSMapper;
+ return GetPointSpriteMapperHolder()->GetPointSpriteMapper();
}
-vtkDataSet*
+
+//----------------------------------------------------------------------------
+vtkPolyData*
VISU_GaussPointsPL
::GetPickableDataSet()
{
- return myGeomFilter->GetOutput();
+ return myPassFilter[1]->GetPolyDataOutput();
}
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
{
Superclass::Init();
+ SetExtractInside(false);
+
vtkDataSet* aDataSet = GetParentMesh();
vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet );
SetScale( aScaleFactor / aScalarRange[1] );
else
SetScale(0.0);
-
- // Deformed Shape
- myPassFilter[0]->SetInput(myCellDataToPointData->GetUnstructuredGridOutput());
-
- myGeomFilter->SetInput( myPassFilter[0]->GetOutput() );
-
- // Geometrical Sphere
- myPassFilter[1]->SetInput(myGeomFilter->GetOutput());
-
- myPSMapper->SetInput( myPassFilter[1]->GetPolyDataOutput() );
}
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
::Build()
{
+ Superclass::Build();
+
+ // Deformed Shape
+ myPassFilter[0]->SetInput(GetFieldTransformFilter()->GetOutput());
+
+ myPassFilter[1]->SetInput(myPassFilter[0]->GetOutput());
+
+ // Geometrical Sphere
+ myPassFilter[2]->SetInput(myPassFilter[1]->GetOutput());
+
+ GetPointSpriteMapper()->SetInput( myPassFilter[2]->GetPolyDataOutput() );
+
+ // Update according the current state
+ SetIsDeformed(GetIsDeformed());
+
+ SetPrimitiveType(GetPrimitiveType());
}
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
::Update()
{
- //cout << "VISU_GaussPointsPL::Update()" << endl;
- vtkFloatingPointType* aScalarRange = GetScalarRange();
- mySourceScalarRange[0] = aScalarRange[0];
- mySourceScalarRange[1] = aScalarRange[1];
- myDeltaScalarRange = aScalarRange[1] - aScalarRange[0];
-
SetAverageCellSize( VISU_DeformedShapePL::GetScaleFactor( GetParentMesh() ) );
- vtkMapper* aMapper = GetMapper();
- vtkDataSet* aDataSet = aMapper->GetInput();
- vtkCellData* aCellData = aDataSet->GetCellData();
- myScalarArray = aCellData->GetScalars();
+ this->UpdateGlyph();
- myPSMapper->SetLookupTable( myMapperTable );
- myPSMapper->SetScalarRange( aScalarRange );
+ Superclass::Update();
+}
- this->UpdateGlyph();
- VISU_ScalarMapPL::Update();
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_GaussPointsPL
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ if(GetIsDeformed())
+ if(vtkDataSet* aDataSet = myWarpVector->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(GetPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere)
+ if(vtkDataSet* aDataSet = myGlyph->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ return aSize;
}
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
::UpdateGlyph()
{
- //cout << "VISU_GaussPointsPL::UpdateGlyph()" << endl;
-
vtkFloatingPointType* aScalarRange = GetScalarRange();
- if( myPSMapper->GetPointSpriteMode() == 0 ) // Results
+ if( GetPointSpriteMapper()->GetPointSpriteMode() == 0 ) // Results
{
- //cout << "Results" << endl;
myGlyph->ClampingOn();
myGlyph->SetScaleModeToScaleByScalar();
myGlyph->SetColorModeToColorByScalar();
- vtkFloatingPointType aRange = 0;
+ vtkFloatingPointType aScaleFactor = 0.0;
vtkFloatingPointType aMinSize = GetMinSize();
vtkFloatingPointType aMaxSize = GetMaxSize();
- if( fabs( aMaxSize - aMinSize ) > 0.0001 )
- aRange = ( aScalarRange[1] - aScalarRange[0] ) / ( aMaxSize - aMinSize );
- vtkFloatingPointType aMinRange = aScalarRange[0] - aMinSize * aRange;
- vtkFloatingPointType aMaxRange = aMinRange + aRange;
-
- myGlyph->SetRange( aMinRange, aMaxRange );
- myGlyph->SetScaleFactor( 1.0 );
+ if(!VISU::CheckIsSameValue(aMaxSize, aMinSize))
+ aScaleFactor = ( aScalarRange[1] - aScalarRange[0] ) / ( aMaxSize - aMinSize );
+
+ vtkFloatingPointType aMinRange = aScalarRange[0] - aMinSize * aScaleFactor;
+ vtkFloatingPointType aMaxRange = aMinRange + aScaleFactor;
+ vtkFloatingPointType aRange[2] = {aMinRange, aMaxRange};
+
+ if(!VISU::CheckIsSameRange(myGlyph->GetRange(), aRange))
+ myGlyph->SetRange( aRange );
+
+ if(!VISU::CheckIsSameValue(myGlyph->GetScaleFactor(), 1.0))
+ myGlyph->SetScaleFactor( 1.0 );
}
- else if( myPSMapper->GetPointSpriteMode() == 1 ) // Geometry
+ else if( GetPointSpriteMapper()->GetPointSpriteMode() == 1 ) // Geometry
{
- //cout << "Geometry" << endl;
myGlyph->ClampingOff();
myGlyph->SetScaleModeToDataScalingOff();
myGlyph->SetColorModeToColorByScale();
- myGlyph->SetScaleFactor( GetSize() );
+ vtkFloatingPointType aScaleFactor = GetSize();
+ if(!VISU::CheckIsSameValue(myGlyph->GetScaleFactor(), aScaleFactor))
+ myGlyph->SetScaleFactor( aScaleFactor );
}
- else if( myPSMapper->GetPointSpriteMode() == 2 ) // Outside
+ else if( GetPointSpriteMapper()->GetPointSpriteMode() == 2 ) // Outside
{
- //cout << "Outside" << endl;
myGlyph->ClampingOff();
myGlyph->SetScaleModeToDataScalingOff();
myGlyph->SetColorModeToColorByScalar();
- myGlyph->SetScaleFactor( GetSize() );
+ vtkFloatingPointType aScaleFactor = GetSize();
+ if(!VISU::CheckIsSameValue(myGlyph->GetScaleFactor(), aScaleFactor))
+ myGlyph->SetScaleFactor( aScaleFactor );
}
- mySphereSource->SetRadius( GetMagnification() * GetAverageCellSize() / 2. );
+ vtkFloatingPointType aRadius = GetMagnification() * GetAverageCellSize() / 2.0;
+ if(!VISU::CheckIsSameValue(mySphereSource->GetRadius(), aRadius))
+ mySphereSource->SetRadius( aRadius );
}
+
//----------------------------------------------------------------------------
VISU::TGaussPointID
VISU_GaussPointsPL
-::GetObjID(vtkIdType theID) const
+::GetObjID(vtkIdType theID)
{
- return myGaussPtsIDMapper->GetObjID(theID);
+ return GetGaussPtsIDMapper()->GetObjID(theID);
}
-vtkFloatingPointType*
-VISU_GaussPointsPL
-::GetNodeCoord(int theObjID)
-{
- vtkIdType anID = GetNodeVTKID(theObjID);
- vtkDataSet* aDataSet = myGeomFilter->GetPolyDataInput(0);
- return aDataSet->GetPoint(anID);
-}
-
-void
-VISU_GaussPointsPL
-::SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper)
-{
- myGaussPtsIDMapper = theGaussPtsIDMapper;
- SetIDMapper(myGaussPtsIDMapper);
-}
-
-const VISU::PGaussPtsIDMapper&
-VISU_GaussPointsPL
-::GetGaussPtsIDMapper() const
-{
- return myGaussPtsIDMapper;
-}
-
-VISU::TVTKOutput*
-VISU_GaussPointsPL
-::GetParentMesh() const
-{
- VISU::TNamedIDMapper* aNamedIDMapper = myGaussPtsIDMapper->GetParent();
- return aNamedIDMapper->GetVTKOutput();
-}
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
::SetIsDeformed( bool theIsDeformed )
{
- if( theIsDeformed )
- {
- myWarpVector->SetInput( myCellDataToPointData->GetUnstructuredGridOutput() );
- myPassFilter[0]->SetInput(myWarpVector->GetOutput());
- }
- else
- myPassFilter[0]->SetInput(myCellDataToPointData->GetUnstructuredGridOutput());
-
- myIsDeformed = theIsDeformed;
-
- Modified();
+ if(theIsDeformed){
+ myWarpVector->SetInput( myPassFilter[0]->GetPolyDataOutput() );
+ myPassFilter[1]->SetInput(myWarpVector->GetOutput());
+ }else
+ myPassFilter[1]->SetInput(myPassFilter[0]->GetOutput());
}
//----------------------------------------------------------------------------
bool
VISU_GaussPointsPL
-::GetIsDeformed() const
+::GetIsDeformed()
{
- return myIsDeformed;
+ return myPassFilter[1]->GetInput() != myPassFilter[0]->GetOutput();
}
//----------------------------------------------------------------------------
if(GetBicolor() == theBicolor)
return;
- myMapperTable->SetBicolor( theBicolor );
- myBarTable->SetBicolor( theBicolor );
-
- Modified();
+ GetMapperTable()->SetBicolor( theBicolor );
+ GetBarTable()->SetBicolor( theBicolor );
}
//----------------------------------------------------------------------------
VISU_GaussPointsPL
::GetBicolor()
{
- return myMapperTable->GetBicolor();
+ return GetMapperTable()->GetBicolor();
}
//----------------------------------------------------------------------------
VISU_GaussPointsPL
::SetIsColored(bool theIsColored)
{
- myPSMapper->SetPointSpriteMode( theIsColored ? 0 : 1 ); // Results / Geometry
- Modified();
+ GetPointSpriteMapper()->SetPointSpriteMode( theIsColored ? 0 : 1 ); // Results / Geometry
+}
+
+//----------------------------------------------------------------------------
+bool
+VISU_GaussPointsPL
+::GetIsColored()
+{
+ return GetPointSpriteMapper()->GetPointSpriteMode() == 0;
}
//----------------------------------------------------------------------------
{
if( thePrimitiveType == VISU_OpenGLPointSpriteMapper::GeomSphere )
{
- myGlyph->SetInput( myGeomFilter->GetOutput() );
- myPassFilter[1]->SetInput(myGlyph->GetOutput());
+ myGlyph->SetInput( myPassFilter[1]->GetOutput() );
+ myPassFilter[2]->SetInput(myGlyph->GetOutput());
}
else
- myPassFilter[1]->SetInput(myGeomFilter->GetOutput());
+ myPassFilter[2]->SetInput(myPassFilter[1]->GetOutput());
- myPSMapper->SetPrimitiveType( thePrimitiveType );
-
- Modified();
+ GetPointSpriteMapper()->SetPrimitiveType( thePrimitiveType );
}
+
//----------------------------------------------------------------------------
int
VISU_GaussPointsPL
::GetPrimitiveType()
{
- return myPSMapper->GetPrimitiveType();
+ if( myPassFilter[2]->GetInput() != myPassFilter[1]->GetOutput() )
+ return VISU_OpenGLPointSpriteMapper::GeomSphere;
+
+ return GetPointSpriteMapper()->GetPrimitiveType();
}
+
//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_GaussPointsPL
::GetMaximumSupportedSize()
{
- return myPSMapper->GetMaximumSupportedSize();
+ return GetPointSpriteMapper()->GetMaximumSupportedSize();
}
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
::SetClamp(vtkFloatingPointType theClamp)
{
- myPSMapper->SetPointSpriteClamp( theClamp );
- Modified();
+ GetPointSpriteMapper()->SetPointSpriteClamp( theClamp );
}
+
//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_GaussPointsPL
::GetClamp()
{
- return myPSMapper->GetPointSpriteClamp();
+ return GetPointSpriteMapper()->GetPointSpriteClamp();
}
//----------------------------------------------------------------------------
VISU_GaussPointsPL
::SetSize(vtkFloatingPointType theSize)
{
- myPSMapper->SetPointSpriteSize( theSize );
- Modified();
+ GetPointSpriteMapper()->SetPointSpriteSize( theSize );
}
+
//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_GaussPointsPL
::GetSize()
{
- return myPSMapper->GetPointSpriteSize();
+ return GetPointSpriteMapper()->GetPointSpriteSize();
}
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
::SetMinSize(vtkFloatingPointType theMinSize)
{
- myPSMapper->SetPointSpriteMinSize( theMinSize );
- Modified();
+ GetPointSpriteMapper()->SetPointSpriteMinSize( theMinSize );
}
+
//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_GaussPointsPL
::GetMinSize()
{
- return myPSMapper->GetPointSpriteMinSize();
+ return GetPointSpriteMapper()->GetPointSpriteMinSize();
}
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
::SetMaxSize(vtkFloatingPointType theMaxSize)
{
- myPSMapper->SetPointSpriteMaxSize( theMaxSize );
- Modified();
+ GetPointSpriteMapper()->SetPointSpriteMaxSize( theMaxSize );
}
+
//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_GaussPointsPL
::GetMaxSize()
{
- return myPSMapper->GetPointSpriteMaxSize();
+ return GetPointSpriteMapper()->GetPointSpriteMaxSize();
}
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
::SetMagnification(vtkFloatingPointType theMagnification)
{
- myPSMapper->SetPointSpriteMagnification( theMagnification );
- Modified();
+ GetPointSpriteMapper()->SetPointSpriteMagnification( theMagnification );
}
+
//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_GaussPointsPL
::GetMagnification()
{
- return myPSMapper->GetPointSpriteMagnification();
+ return GetPointSpriteMapper()->GetPointSpriteMagnification();
}
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
::SetMagnificationIncrement(vtkFloatingPointType theIncrement)
{
+ if(VISU::CheckIsSameValue(myMagnificationIncrement, theIncrement))
+ return;
+
myMagnificationIncrement = theIncrement;
+ Modified();
}
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
::SetAlphaThreshold(vtkFloatingPointType theAlphaThreshold)
{
- myPSMapper->SetPointSpriteAlphaThreshold( theAlphaThreshold );
- Modified();
+ GetPointSpriteMapper()->SetPointSpriteAlphaThreshold( theAlphaThreshold );
}
+
//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_GaussPointsPL
::GetAlphaThreshold()
{
- return myPSMapper->GetPointSpriteAlphaThreshold();
+ return GetPointSpriteMapper()->GetPointSpriteAlphaThreshold();
}
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
::SetResolution(int theResolution)
{
- myResolution = theResolution;
- mySphereSource->SetThetaResolution( myResolution );
- mySphereSource->SetPhiResolution( myResolution );
+ mySphereSource->SetThetaResolution( theResolution );
+ mySphereSource->SetPhiResolution( theResolution );
}
+
+//----------------------------------------------------------------------------
+int
+VISU_GaussPointsPL
+::GetResolution()
+{
+ return mySphereSource->GetThetaResolution();
+}
+
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
SetMagnification( GetMagnification() * anIncrement );
}
+
//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_GaussPointsPL
vtkFloatingPointType aDelta = aMaxSize - aMinSize;
vtkFloatingPointType aVal = theScalarArray->GetTuple1(theID);
- return aMinSize + aDelta*(aVal - mySourceScalarRange[0])/myDeltaScalarRange;
+ vtkFloatingPointType* aScalarRange = GetScalarRange();
+ vtkFloatingPointType aDeltaScalarRange = aScalarRange[1] - aScalarRange[0];
+
+ return aMinSize + aDelta*(aVal - aScalarRange[0]) / aDeltaScalarRange;
}
+
//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_GaussPointsPL
return GetAverageCellSize() * GetMaxSize();
}
+
//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_GaussPointsPL
{
vtkMapper* aMapper = GetMapper();
vtkDataSet* aDataSet = aMapper->GetInput();
- vtkCellData* aCellData = aDataSet->GetCellData();
- vtkDataArray* aScalarArray = aCellData->GetScalars();
- return GetPointSize(theID,aScalarArray);
+ vtkPointData* aPointData = aDataSet->GetPointData();
+ vtkDataArray* aScalarArray = aPointData->GetScalars();
+ return GetPointSize(theID, aScalarArray);
}
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
::SetAverageCellSize(vtkFloatingPointType theAverageCellSize)
{
- myPSMapper->SetAverageCellSize( theAverageCellSize );
- Modified();
+ GetPointSpriteMapper()->SetAverageCellSize( theAverageCellSize );
}
+
//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_GaussPointsPL
::GetAverageCellSize()
{
- return myPSMapper->GetAverageCellSize();
+ return GetPointSpriteMapper()->GetAverageCellSize();
}
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
::SetImageData(vtkImageData* theImageData)
{
- myPSMapper->SetImageData( theImageData );
+ GetPointSpriteMapper()->SetImageData( theImageData );
}
+
//----------------------------------------------------------------------------
vtkSmartPointer<vtkImageData>
VISU_GaussPointsPL
return aCompositeImageData;
}
-void VISU_GaussPointsPL::SetScale( vtkFloatingPointType theScale )
+
+void
+VISU_GaussPointsPL
+::SetScale( vtkFloatingPointType theScale )
{
+ if(VISU::CheckIsSameValue(myWarpVector->GetScaleFactor(), theScale))
+ return;
+
myWarpVector->SetScaleFactor( theScale );
- myScaleFactor = GetScale();
- Modified();
+ myScaleFactor = theScale;
}
-vtkFloatingPointType VISU_GaussPointsPL::GetScale()
+
+vtkFloatingPointType
+VISU_GaussPointsPL
+::GetScale()
{
return myWarpVector->GetScaleFactor();
}
-void VISU_GaussPointsPL::SetMapScale( vtkFloatingPointType theMapScale )
+
+void
+VISU_GaussPointsPL
+::SetMapScale( vtkFloatingPointType theMapScale )
{
- VISU_ScalarMapPL::SetMapScale( theMapScale );
+ Superclass::SetMapScale( theMapScale );
- myWarpVector->SetScaleFactor( myScaleFactor * theMapScale );
- Modified();
+ vtkFloatingPointType aMapScale = myScaleFactor * theMapScale;
+ if(VISU::CheckIsSameValue(myWarpVector->GetScaleFactor(), aMapScale))
+ return;
+
+ myWarpVector->SetScaleFactor( aMapScale );
}
#define VISU_GaussPointsPL_HeaderFile
#include "VISUPipeline.hxx"
-#include "VISU_ScalarMapPL.hxx"
-#include "VISU_Convertor.hxx"
+#include "VISU_ColoredPL.hxx"
#include <vector>
class VISU_OpenGLPointSpriteMapper;
+class VISU_PointSpriteMapperHolder;
class vtkGeometryFilter;
class vtkGlyph3D;
class vtkPointSet;
class vtkPassThroughFilter;
-class vtkCellDataToPointData;
class vtkWarpVector;
class SALOME_Transform;
+
+//----------------------------------------------------------------------------
//! Pipeline for the Gauss Points presentation.
/*!
* This class uses the special mapper (VISU_OpenGLPointSpriteMapper)
* for rendering the Gauss Points as Point Sprites.
*/
-class VISU_PIPELINE_EXPORT VISU_GaussPointsPL : public VISU_ScalarMapPL
+class VISU_PIPELINE_EXPORT VISU_GaussPointsPL : public VISU_ColoredPL
{
-protected:
- VISU_GaussPointsPL();
-
- virtual
- ~VISU_GaussPointsPL();
-
public:
- vtkTypeMacro(VISU_GaussPointsPL,VISU_ScalarMapPL);
+ //----------------------------------------------------------------------------
+ vtkTypeMacro(VISU_GaussPointsPL, VISU_ColoredPL);
static
- VISU_GaussPointsPL* New();
+ VISU_GaussPointsPL*
+ New();
- virtual
- void
- ShallowCopy(VISU_PipeLine *thePipeLine);
+ //----------------------------------------------------------------------------
+ void
+ SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper);
- //! Get the native mapper.
- virtual
- TMapper*
- GetMapper();
+ const VISU::PGaussPtsIDMapper&
+ GetGaussPtsIDMapper();
+
+ VISU_PointSpriteMapperHolder*
+ GetPointSpriteMapperHolder();
//! Get the internal #VISU_OpenGLPointSpriteMapper.
VISU_OpenGLPointSpriteMapper*
- GetPSMapper();
+ GetPointSpriteMapper();
+
+ vtkDataSet*
+ GetParentMesh();
//! Get an intermediate dataset that can be picked
- vtkDataSet*
+ vtkPolyData*
GetPickableDataSet();
+ //----------------------------------------------------------------------------
//! Redefined method for initialization of the pipeline.
virtual
void
Init();
- //! Redefined method for building the pipeline.
- virtual
- void
- Build();
-
//! Redefined method for updating the pipeline.
virtual
void
Update();
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ //----------------------------------------------------------------------------
//! Update glyph.
void
UpdateGlyph();
virtual
VISU::TGaussPointID
- GetObjID(vtkIdType theID) const;
-
- virtual
- vtkFloatingPointType*
- GetNodeCoord(vtkIdType theObjID);
-
- void
- SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper);
-
- const VISU::PGaussPtsIDMapper&
- GetGaussPtsIDMapper() const;
-
- VISU::TVTKOutput*
- GetParentMesh() const;
+ GetObjID(vtkIdType theID);
//! Set the Bicolor mode.
/*!
void
SetIsColored(bool theIsColored);
+ bool
+ GetIsColored();
+
//! Set type of the primitives.
void
SetPrimitiveType(int thePrimitiveType);
//! Get resolution of the Geometrical Sphere.
int
- GetResolution() { return myResolution; }
+ GetResolution();
//! Method for changing the Magnification parameter.
void
const char* theAlphaTexture );
public:
- virtual void SetIsDeformed( bool theIsDeformed );
- virtual bool GetIsDeformed() const;
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ SetIsDeformed( bool theIsDeformed );
+
+ virtual
+ bool
+ GetIsDeformed();
+
+ virtual
+ void
+ SetScale( vtkFloatingPointType theScale );
+
+ virtual
+ vtkFloatingPointType
+ GetScale();
- virtual void SetScale( vtkFloatingPointType theScale );
- virtual vtkFloatingPointType GetScale();
- virtual void SetMapScale( vtkFloatingPointType theMapScale = 1.0 );
+ virtual
+ void
+ SetMapScale( vtkFloatingPointType theMapScale = 1.0 );
protected:
- bool myIsDeformed;
+ //----------------------------------------------------------------------------
+ VISU_GaussPointsPL();
+
+ virtual
+ ~VISU_GaussPointsPL();
+
+ virtual
+ void
+ OnCreateMapperHolder();
+
+ virtual
+ void
+ Build();
+
+ virtual
+ void
+ DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
+
+private:
+ //----------------------------------------------------------------------------
vtkFloatingPointType myScaleFactor;
vtkWarpVector *myWarpVector;
- vtkCellDataToPointData* myCellDataToPointData;
std::vector<vtkPassThroughFilter*> myPassFilter;
+ vtkSmartPointer<VISU_PointSpriteMapperHolder> myPointSpriteMapperHolder;
vtkGlyph3D* myGlyph;
vtkSphereSource* mySphereSource;
- int myResolution;
-
-protected:
- VISU_OpenGLPointSpriteMapper* myPSMapper;
- VISU::PGaussPtsIDMapper myGaussPtsIDMapper;
-
- vtkGeometryFilter* myGeomFilter;
-
- vtkDataArray *myScalarArray;
- vtkFloatingPointType mySourceScalarRange[2];
- vtkFloatingPointType myDeltaScalarRange;
- int myPrimitiveType;
vtkFloatingPointType myMagnificationIncrement;
};
#include "VISU_IsoSurfacesPL.hxx"
+#include "VISU_LookupTable.hxx"
+
#include "VISU_PipeLineUtils.hxx"
#include <vtkContourFilter.h>
+
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_IsoSurfacesPL);
+
+//----------------------------------------------------------------------------
VISU_IsoSurfacesPL
::VISU_IsoSurfacesPL()
{
+ SetIsShrinkable(false);
+
myContourFilter = vtkContourFilter::New();
+
myCellDataToPointData = vtkCellDataToPointData::New();
- myIsShrinkable = false;
}
+
+//----------------------------------------------------------------------------
VISU_IsoSurfacesPL
::~VISU_IsoSurfacesPL()
{
- // commented: porting to vtk5.0
- // myContourFilter->UnRegisterAllOutputs();
myContourFilter->Delete();
+ myContourFilter = NULL;
- // commented: porting to vtk5.0
- // myCellDataToPointData->UnRegisterAllOutputs();
myCellDataToPointData->Delete();
+ myCellDataToPointData = NULL;
}
+
+//----------------------------------------------------------------------------
void
VISU_IsoSurfacesPL
-::ShallowCopy(VISU_PipeLine *thePipeLine)
+::DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput)
{
+ Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
+
if(VISU_IsoSurfacesPL *aPipeLine = dynamic_cast<VISU_IsoSurfacesPL*>(thePipeLine)){
SetNbParts(aPipeLine->GetNbParts());
vtkFloatingPointType aRange[2] = {aPipeLine->GetMin(), aPipeLine->GetMax()};
SetRange(aRange);
}
- TSupperClass::ShallowCopy(thePipeLine);
}
+
+//----------------------------------------------------------------------------
int
VISU_IsoSurfacesPL
::GetNbParts()
{
return myContourFilter->GetNumberOfContours();
}
+
+
+//----------------------------------------------------------------------------
void
VISU_IsoSurfacesPL
::SetNbParts(int theNb)
}
+//----------------------------------------------------------------------------
void
VISU_IsoSurfacesPL
-::SetScaling(int theScaling)
+::SetScalarRange(vtkFloatingPointType theRange[2])
{
- TSupperClass::SetScaling(theScaling);
+ Superclass::SetScalarRange(theRange);
SetRange(myRange);
}
+
+
+//----------------------------------------------------------------------------
void
VISU_IsoSurfacesPL
::SetRange(vtkFloatingPointType theRange[2])
{
if(theRange[0] <= theRange[1]){
- myRange[0] = theRange[0]; myRange[1] = theRange[1];
- vtkFloatingPointType aRange[2] = {myRange[0], myRange[1]};
+ myRange[0] = theRange[0];
+ myRange[1] = theRange[1];
+ vtkFloatingPointType aRange[2] = {theRange[0], theRange[1]};
if(GetScaling() == VTK_SCALE_LOG10)
- VISU_LookupTable::ComputeLogRange(theRange,aRange);
- myContourFilter->GenerateValues(GetNbParts(),aRange);
- Modified();
+ VISU_LookupTable::ComputeLogRange(theRange, aRange);
+ myContourFilter->GenerateValues(GetNbParts(), aRange);
}
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_IsoSurfacesPL
::GetMin()
return myRange[0];
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_IsoSurfacesPL
::GetMax()
void
+//----------------------------------------------------------------------------
VISU_IsoSurfacesPL
::Init()
{
- TSupperClass::Init();
+ Superclass::Init();
SetNbParts(10);
+
vtkFloatingPointType aScalarRange[2];
GetSourceRange(aScalarRange);
SetRange(aScalarRange);
}
-VISU_ScalarMapPL::THook*
+//----------------------------------------------------------------------------
+void
+VISU_IsoSurfacesPL
+::Build()
+{
+ Superclass::Build();
+
+ VISU::CellDataToPoint(myContourFilter,
+ myCellDataToPointData,
+ GetMergedInput());
+}
+
+
+//----------------------------------------------------------------------------
+
+vtkDataSet*
VISU_IsoSurfacesPL
-::DoHook()
+::InsertCustomPL()
{
- VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,GetInput2(),myFieldTransform);
return myContourFilter->GetOutput();
}
-void
+//----------------------------------------------------------------------------
+unsigned long int
VISU_IsoSurfacesPL
-::Update()
+::GetMemorySize()
{
- TSupperClass::Update();
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ if(vtkDataSet* aDataSet = myContourFilter->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(myCellDataToPointData->GetInput())
+ if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ return aSize;
}
+
+//----------------------------------------------------------------------------
void
VISU_IsoSurfacesPL
::SetMapScale(vtkFloatingPointType theMapScale)
{
- TSupperClass::SetMapScale(theMapScale);
+ Superclass::SetMapScale(theMapScale);
vtkFloatingPointType aRange[2] = {GetMax() - theMapScale*(GetMax()-GetMin()), GetMax()};
vtkFloatingPointType aNewRange[2] = {aRange[0], aRange[1]};
if(GetScaling() == VTK_SCALE_LOG10)
VISU_LookupTable::ComputeLogRange(aRange,aNewRange);
- myContourFilter->GenerateValues(GetNbParts(),aNewRange);
- Modified();
+ myContourFilter->GenerateValues(GetNbParts(), aNewRange);
}
+
+
+//----------------------------------------------------------------------------
#define VISU_IsoSurfacesPL_HeaderFile
#include "VISUPipeline.hxx"
-#include "VISU_PrsMergerPL.hxx"
+#include "VISU_ScalarMapPL.hxx"
class vtkContourFilter;
class vtkCellDataToPointData;
-class VISU_PIPELINE_EXPORT VISU_IsoSurfacesPL : public VISU_PrsMergerPL
-{
- typedef VISU_ScalarMapPL TSupperClass;
-
-protected:
- VISU_IsoSurfacesPL();
- VISU_IsoSurfacesPL(const VISU_IsoSurfacesPL&);
-
- virtual
- ~VISU_IsoSurfacesPL();
+//----------------------------------------------------------------------------
+class VISU_PIPELINE_EXPORT VISU_IsoSurfacesPL : public VISU_ScalarMapPL
+{
public:
- vtkTypeMacro(VISU_IsoSurfacesPL,TSupperClass);
+ vtkTypeMacro(VISU_IsoSurfacesPL, VISU_ScalarMapPL);
static
VISU_IsoSurfacesPL*
New();
- virtual
- void
- ShallowCopy(VISU_PipeLine *thePipeLine);
-
virtual
int
GetNbParts();
virtual
void
- SetScaling(int theScaling = VTK_SCALE_LINEAR);
+ SetScalarRange(vtkFloatingPointType theRange[2]);
virtual
void
virtual
void
- Update();
+ Build();
+ //! Gets memory size used by the instance (bytes).
virtual
- THook*
- DoHook();
+ unsigned long int
+ GetMemorySize();
+
+ virtual
+ vtkDataSet*
+ InsertCustomPL();
virtual
void
SetMapScale(vtkFloatingPointType theMapScale = 1.0);
protected:
+ VISU_IsoSurfacesPL();
+ VISU_IsoSurfacesPL(const VISU_IsoSurfacesPL&);
+
+ virtual
+ ~VISU_IsoSurfacesPL();
+
+ virtual
+ void
+ DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
+
int myNbParts;
vtkFloatingPointType myRange[2];
vtkCellDataToPointData* myCellDataToPointData;
--- /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_MapperHolder.cxx
+// Author: Alexey PETROV
+// Module : VISU
+
+
+#include "VISU_MapperHolder.hxx"
+#include "VISU_PipeLine.hxx"
+
+#include "VISU_PipeLineUtils.hxx"
+
+#include <vtkDataSet.h>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+//----------------------------------------------------------------------------
+VISU_MapperHolder
+::VISU_MapperHolder():
+ myPipeLine(NULL)
+{
+ if(MYDEBUG)
+ MESSAGE("VISU_MapperHolder::VISU_MapperHolder - "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+VISU_MapperHolder
+::~VISU_MapperHolder()
+{
+ if(MYDEBUG)
+ MESSAGE("VISU_MapperHolder::~VISU_MapperHolder - "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_MapperHolder
+::ShallowCopy(VISU_MapperHolder *theMapperHolder,
+ bool theIsCopyInput)
+{
+ if(theIsCopyInput)
+ SetIDMapper(theMapperHolder->GetIDMapper());
+
+ VISU::CopyMapper(GetMapper(),
+ theMapperHolder->GetMapper(),
+ theIsCopyInput);
+}
+
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_MapperHolder
+::GetMemorySize()
+{
+ unsigned long int aSize = 0;
+
+ if(myMapper.GetPointer())
+ if(vtkDataSet* aDataSet = myMapper->GetInput())
+ aSize = aDataSet->GetActualMemorySize() * 1024;
+
+ if(myIDMapper)
+ aSize += myIDMapper->GetMemorySize();
+
+ return aSize;
+}
+
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_MapperHolder
+::GetMTime()
+{
+ unsigned long int aTime = Superclass::GetMTime();
+
+ if(myIDMapper)
+ if(vtkDataSet* aDataSet = myIDMapper->GetOutput())
+ aTime = std::max(aTime, aDataSet->GetMTime());
+
+ if(myMapper.GetPointer())
+ aTime = std::max(aTime, myMapper->GetMTime());
+
+ return aTime;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_MapperHolder
+::SetPipeLine(VISU_PipeLine* thePipeLine)
+{
+ myPipeLine = thePipeLine;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_MapperHolder
+::SetIDMapper(const VISU::PIDMapper& theIDMapper)
+{
+ if(myIDMapper == theIDMapper)
+ return;
+
+ myIDMapper = theIDMapper;
+
+ if(myPipeLine && GetInput())
+ if(!GetMapper()->GetInput()){
+ myPipeLine->Build();
+ myPipeLine->Init();
+ myPipeLine->Update();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+const VISU::PIDMapper&
+VISU_MapperHolder
+::GetIDMapper()
+{
+ return myIDMapper;
+}
+
+
+//----------------------------------------------------------------------------
+vtkDataSet*
+VISU_MapperHolder
+::GetInput()
+{
+ if(myIDMapper)
+ return myIDMapper->GetOutput();
+
+ return NULL;
+}
+
+
+//----------------------------------------------------------------------------
+vtkMapper*
+VISU_MapperHolder
+::GetMapper()
+{
+ if(!myMapper.GetPointer())
+ OnCreateMapper();
+
+ return myMapper.GetPointer();
+}
+
+
+//----------------------------------------------------------------------------
+vtkDataSet*
+VISU_MapperHolder
+::GetOutput()
+{
+ if(myMapper.GetPointer())
+ return myMapper->GetInput();
+
+ return NULL;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_MapperHolder
+::Update()
+{
+ if(myMapper.GetPointer())
+ return myMapper->Update();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_MapperHolder
+::SetMapper(vtkMapper* theMapper)
+{
+ myMapper = theMapper;
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_MapperHolder
+::GetNodeObjID(vtkIdType theID)
+{
+ return myIDMapper->GetNodeObjID(theID);
+}
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_MapperHolder
+::GetNodeVTKID(vtkIdType theID)
+{
+ return myIDMapper->GetNodeVTKID(theID);
+}
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType*
+VISU_MapperHolder
+::GetNodeCoord(vtkIdType theObjID)
+{
+ return myIDMapper->GetNodeCoord(theObjID);
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_MapperHolder
+::GetElemObjID(vtkIdType theID)
+{
+ return myIDMapper->GetElemObjID(theID);
+}
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_MapperHolder
+::GetElemVTKID(vtkIdType theID)
+{
+ return myIDMapper->GetElemVTKID(theID);
+}
+
+//----------------------------------------------------------------------------
+vtkCell*
+VISU_MapperHolder
+::GetElemCell(vtkIdType theObjID)
+{
+ return myIDMapper->GetElemCell(theObjID);
+}
+
+
+//----------------------------------------------------------------------------
--- /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_MapperHolder.hxx
+// Author: Alexey PETROV
+// Module : VISU
+
+#ifndef VISU_MapperHolder_HeaderFile
+#define VISU_MapperHolder_HeaderFile
+
+#include "VISU_IDMapper.hxx"
+
+#include <vtkObject.h>
+#include <vtkSmartPointer.h>
+
+class vtkCell;
+class vtkPlane;
+class vtkMapper;
+class vtkDataSet;
+class vtkPointSet;
+class vtkImplicitFunction;
+
+class VISU_PipeLine;
+class VISU_LookupTable;
+
+
+//----------------------------------------------------------------------------
+class VISU_MapperHolder : public vtkObject
+{
+public:
+ vtkTypeMacro(VISU_MapperHolder, vtkObject);
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ ShallowCopy(VISU_MapperHolder *theMapperHolder,
+ bool theIsCopyInput);
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ virtual
+ unsigned long int
+ GetMTime();
+
+ //----------------------------------------------------------------------------
+ void
+ SetPipeLine(VISU_PipeLine* thePipeLine);
+
+ const VISU::PIDMapper&
+ GetIDMapper();
+
+ virtual
+ vtkDataSet*
+ GetInput();
+
+ virtual
+ vtkMapper*
+ GetMapper();
+
+ virtual
+ vtkDataSet*
+ GetOutput();
+
+ virtual
+ void
+ Update();
+
+ //----------------------------------------------------------------------------
+ virtual
+ vtkIdType
+ GetNodeObjID(vtkIdType theID);
+
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID);
+
+ virtual
+ vtkFloatingPointType*
+ GetNodeCoord(vtkIdType theObjID);
+
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID);
+
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID);
+
+ virtual
+ vtkCell*
+ GetElemCell(vtkIdType theObjID);
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ SetImplicitFunction(vtkImplicitFunction *theFunction) = 0;
+
+ virtual
+ vtkImplicitFunction*
+ GetImplicitFunction() = 0;
+
+ //----------------------------------------------------------------------------
+ // Clipping planes
+ virtual
+ void
+ RemoveAllClippingPlanes() = 0;
+
+ virtual
+ vtkIdType
+ GetNumberOfClippingPlanes() = 0;
+
+ virtual
+ bool
+ AddClippingPlane(vtkPlane* thePlane) = 0;
+
+ virtual
+ vtkPlane*
+ GetClippingPlane(vtkIdType theID) = 0;
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ SetLookupTable(VISU_LookupTable* theLookupTable) = 0;
+
+ virtual
+ vtkPointSet*
+ GetClippedInput() = 0;
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ SetExtractInside(bool theMode) = 0;
+
+ virtual
+ void
+ SetExtractBoundaryCells(bool theMode) = 0;
+
+protected:
+ //----------------------------------------------------------------------------
+ VISU_MapperHolder();
+ VISU_MapperHolder(const VISU_MapperHolder&);
+
+ virtual
+ ~VISU_MapperHolder();
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ OnCreateMapper() = 0;
+
+ void
+ SetMapper(vtkMapper* theMapper);
+
+ void
+ SetIDMapper(const VISU::PIDMapper& theIDMapper);
+
+private:
+ //----------------------------------------------------------------------------
+ vtkSmartPointer<vtkMapper> myMapper;
+ VISU::PIDMapper myIDMapper;
+ VISU_PipeLine* myPipeLine;
+};
+
+#endif
//
//
//
-// File: VISU_PipeLine.cxx
+// File: VISU_MeshPL.cxx
// Author: Alexey PETROV
// Module : VISU
#include "VISU_MeshPL.hxx"
-#include "VTKViewer_GeometryFilter.h"
-#include <vtkProperty.h>
-#include <vtkObjectFactory.h>
+#include "VISU_DataSetMapperHolder.hxx"
+
#include <vtkDataSetMapper.h>
-#include <vtkUnstructuredGrid.h>
+#include <vtkObjectFactory.h>
+
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_MeshPL);
-VISU_MeshPL::VISU_MeshPL()
+
+//----------------------------------------------------------------------------
+VISU_MeshPL
+::VISU_MeshPL():
+ VISU_UnstructuredGridPL(this)
{
- myIsShrinkable = true;
+ SetIsShrinkable(true);
}
-void VISU_MeshPL::Build()
+
+//----------------------------------------------------------------------------
+void
+VISU_MeshPL
+::OnCreateMapperHolder()
{
- myMapper->SetInput(GetInput2());
+ VISU_UnstructuredGridPL::OnCreateMapperHolder();
}
-void VISU_MeshPL::Init()
+
+//----------------------------------------------------------------------------
+void
+VISU_MeshPL
+::Build()
{
+ GetDataSetMapperHolder()->GetDataSetMapper()->SetInput(GetClippedInput());
}
+
+
+//----------------------------------------------------------------------------
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
-// File: VISU_PipeLine.hxx
+// File: VISU_MeshPL.hxx
// Author: Alexey PETROV
// Module : VISU
#include "VISUPipeline.hxx"
#include "VISU_PipeLine.hxx"
+#include "VISU_UnstructuredGridPL.hxx"
-class VISU_PIPELINE_EXPORT VISU_MeshPL : public VISU_PipeLine{
+
+//----------------------------------------------------------------------------
+class VISU_PIPELINE_EXPORT VISU_MeshPL : public VISU_PipeLine,
+ public VISU_UnstructuredGridPL
+{
+public:
+ vtkTypeMacro(VISU_MeshPL, VISU_PipeLine);
+
+ //----------------------------------------------------------------------------
+ static
+ VISU_MeshPL*
+ New();
+
protected:
+ //----------------------------------------------------------------------------
VISU_MeshPL();
VISU_MeshPL(const VISU_MeshPL&);
-public:
- vtkTypeMacro(VISU_MeshPL,VISU_PipeLine);
- static VISU_MeshPL* New();
-
-public:
- virtual void Build();
- virtual void Init();
+
+ virtual
+ void
+ OnCreateMapperHolder();
+
+ virtual
+ void
+ Build();
};
#endif
#include <vtkCellArray.h>
#include <vtkCellData.h>
#include <vtkCommand.h>
-#include <vtkDataArray.h>
-#include <vtkFloatArray.h>
#include <vtkImageData.h>
#include <vtkMatrix4x4.h>
#include <vtkObjectFactory.h>
-#include <vtkOpenGLRenderer.h>
-#include <vtkOpenGLRenderWindow.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
#include <vtkPointData.h>
#include <vtkPolyData.h>
#include <vtkPolygon.h>
};
static bool IsARBInitialized = InitializeARB();
-static float Tolerance = 1.0 / VTK_LARGE_FLOAT;
+static vtkFloatingPointType Tolerance = 1.0 / VTK_LARGE_FLOAT;
//-----------------------------------------------------------------------------
// Construct empty object.
this->PointSpriteTexture = 0;
this->UseOpenGLMapper = false;
-
- this->TempMapper = vtkPolyDataMapper::New();
}
//-----------------------------------------------------------------------------
VISU_OpenGLPointSpriteMapper::~VISU_OpenGLPointSpriteMapper()
if( this->LastWindow )
this->ReleaseGraphicsResources(this->LastWindow);
-
- if( this->TempMapper )
- this->TempMapper->Delete();
}
-//-----------------------------------------------------------------------------
-void VISU_OpenGLPointSpriteMapper::ShallowCopy( vtkAbstractMapper* mapper )
-{
- VISU_OpenGLPointSpriteMapper* m = VISU_OpenGLPointSpriteMapper::SafeDownCast(mapper);
- if( m != NULL )
- {
- this->SetPrimitiveType( m->GetPrimitiveType() );
-
- this->SetPointSpriteMode( m->GetPointSpriteMode() );
-
- this->SetPointSpriteClamp( m->GetPointSpriteClamp() );
- this->SetPointSpriteSize( m->GetPointSpriteSize() );
- this->SetPointSpriteMinSize( m->GetPointSpriteMinSize() );
- this->SetPointSpriteMaxSize( m->GetPointSpriteMaxSize() );
- this->SetPointSpriteMagnification( m->GetPointSpriteMagnification() );
-
- this->SetImageData( m->GetImageData() );
- this->SetPointSpriteAlphaThreshold( m->GetPointSpriteAlphaThreshold() );
- }
- this->TempMapper->ShallowCopy( m );
- this->TempMapper->SetInput( this->GetInput() );
- Superclass::ShallowCopy( this->TempMapper );
-
-}
//-----------------------------------------------------------------------------
char* readFromFile( std::string fileName )
{
*/
free( shader );
}
+
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetShaderVariable( const char* variable, float value )
{
vglVertexAttrib1fARB( vglGetAttribLocationARB( this->VertexProgram, variable ), value );
}
+
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPrimitiveType( int thePrimitiveType )
{
this->PrimitiveType = thePrimitiveType;
}
+
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPointSpriteMode( int theMode )
{
this->PointSpriteMode = theMode;
this->Modified();
}
+
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPointSpriteClamp( float theClamp )
{
this->PointSpriteClamp = theClamp;
}
+
+//-----------------------------------------------------------------------------
+void VISU_OpenGLPointSpriteMapper::SetAverageCellSize(float theSize)
+{
+ if( fabs( this->AverageCellSize - theSize ) < Tolerance )
+ return;
+
+ this->AverageCellSize = theSize;
+}
+
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPointSpriteSize( float theSize )
{
this->PointSpriteSize = theSize;
}
+
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPointSpriteMinSize( float theMinSize )
{
this->PointSpriteMinSize = theMinSize;
}
+
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPointSpriteMaxSize( float theMaxSize )
{
this->PointSpriteMaxSize = theMaxSize;
}
+
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPointSpriteMagnification( float theMagnification )
{
this->PointSpriteMagnification = theMagnification;
}
+
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::SetPointSpriteAlphaThreshold( float theAlphaThreshold )
{
this->PointSpriteAlphaThreshold = theAlphaThreshold;
}
+
//-----------------------------------------------------------------------------
bool VISU_OpenGLPointSpriteMapper::InitExtensions()
{
act->GetProperty()->GetMTime() > this->BuildTime ||
ren->GetRenderWindow() != this->LastWindow)
{
+#ifdef _DEBUG_RENDERING_PERFORMANCE_
+ // To control when the mapper is recalculated
+ cout<<"VISU_OpenGLPointSpriteMapper::RenderPiece - "
+ <<(this->GetMTime() > this->BuildTime)<<"; "
+ <<(input->GetMTime() > this->BuildTime)<<"; "
+ <<(act->GetProperty()->GetMTime() > this->BuildTime)<<"; "
+ <<endl;
+#endif
// sets this->Colors as side effect
this->MapScalars( act->GetProperty()->GetOpacity() );
if( this->UsePointSprites ) //&& this->PrimitiveType == VISU_OpenGLPointSpriteMapper::PointSprite )
this->CleanupPointSprites();
}
+
//-----------------------------------------------------------------------------
float VISU_OpenGLPointSpriteMapper::GetMaximumSupportedSize()
{
return maximumSupportedSize;
}
+
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::InitPointSprites()
{
// Disable material properties
glDisable( GL_COLOR_MATERIAL );
}
+
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::CleanupPointSprites()
{
VISU_OpenGLPointSpriteMapper
::SetImageData( vtkImageData* theImageData )
{
- //cout << "VISU_OpenGLPointSpriteMapper::SetImageData " << theImageData << endl;
+ if(GetImageData() == theImageData)
+ return;
this->ImageData = theImageData;
+ this->Modified();
}
vtkImageData*
//-----------------------------------------------------------------------------
void VISU_OpenGLPointSpriteMapper::DrawPoints(vtkPoints *thePoints,
vtkUnsignedCharArray *theColors,
- vtkFloatArray *theAlpha,
- vtkIdType &theCellNum,
- int &theNoAbort,
vtkCellArray *theCells,
- vtkRenderer *theRenderer,
vtkActor* theActor)
{
//cout << "VISU_OpenGLPointSpriteMapper::DrawPoints" << endl;
}
//-----------------------------------------------------------------------------
-int VISU_OpenGLPointSpriteMapper::Draw(vtkRenderer *aren, vtkActor *act)
+int VISU_OpenGLPointSpriteMapper::Draw(vtkRenderer *theRenderer, vtkActor *theActor)
{
if( this->UseOpenGLMapper ||
this->PrimitiveType == VISU_OpenGLPointSpriteMapper::GeomSphere )
- return MAPPER_SUPERCLASS::Draw( aren, act );
+ return MAPPER_SUPERCLASS::Draw( theRenderer, theActor );
- vtkOpenGLRenderer *ren = (vtkOpenGLRenderer *)aren;
vtkUnsignedCharArray *colors = NULL;
- vtkFloatArray *alpha = NULL;
vtkPolyData *input = this->GetInput();
vtkPoints *points;
int noAbort = 1;
int cellScalars = 0;
- vtkIdType cellNum = 0;
float tran;
// get the transparency
- tran = act->GetProperty()->GetOpacity();
+ tran = theActor->GetProperty()->GetOpacity();
// if the primitives are invisable then get out of here
if (tran <= 0.0)
// we need to know the total number of cells so that we can report progress
this->TotalCells = input->GetVerts()->GetNumberOfCells();
- this->DrawPoints(points, colors, alpha, cellNum, noAbort, input->GetVerts(), ren, act);
+ this->DrawPoints(points, colors, input->GetVerts(), theActor);
this->UpdateProgress(1.0);
return noAbort;
class vtkCellArray;
class vtkPoints;
class vtkProperty;
-class vtkRenderWindow;
-class vtkOpenGLRenderer;
-class vtkOpenGLTexture;
-class vtkBMPReader;
class vtkImageData;
-class vtkFloatArray;
class vtkXMLImageDataReader;
#ifndef VTK_IMPLEMENT_MESA_CXX
static VISU_OpenGLPointSpriteMapper *New();
vtkTypeRevisionMacro(VISU_OpenGLPointSpriteMapper,MAPPER_SUPERCLASS);
- void ShallowCopy(vtkAbstractMapper*);
-
//! Set the initial point size to be used.
/*!
* This value forms the base upon which the distance attenuation acts.
* card for sprite display, then the quadratic factors are adjusted to
* bring the size down.
*/
- vtkSetMacro(DefaultPointSize, float);
-
//! Get the initial point size to be used.
vtkGetMacro(DefaultPointSize, float);
//! Set Average Cell Size.
- vtkSetMacro(AverageCellSize, float);
+ void
+ SetAverageCellSize(float theSize);
//! Get Average Cell Size.
vtkGetMacro(AverageCellSize, float);
~VISU_OpenGLPointSpriteMapper();
//! Internal method of the Point Sprites drawing.
- void DrawPoints(vtkPoints *p,
- vtkUnsignedCharArray *c,
- vtkFloatArray *alpha,
- vtkIdType &cellNum,
- int &noAbort,
- vtkCellArray *ca,
- vtkRenderer *ren,
- vtkActor *act);
+ void DrawPoints(vtkPoints *thePoints,
+ vtkUnsignedCharArray *theColors,
+ vtkCellArray *theCells,
+ vtkActor* theActor);
//! Initializing OpenGL extensions.
bool InitExtensions();
float AverageCellSize;
vtkSmartPointer<vtkImageData> ImageData;
- vtkPolyDataMapper* TempMapper;
};
#endif
#include "VISU_PipeLine.hxx"
-#include "VISU_PipeLineUtils.hxx"
-
-#include "SALOME_ExtractGeometry.h"
+#include "VISU_MapperHolder.hxx"
-#include <float.h>
+#include "VISU_PipeLineUtils.hxx"
#include <vtkObjectFactory.h>
-#include <vtkDataSetMapper.h>
-#include <vtkUnstructuredGrid.h>
-
#include <vtkPlane.h>
-#include <vtkExtractGeometry.h>
-#include <vtkImplicitBoolean.h>
-#include <vtkImplicitFunction.h>
-#include <vtkImplicitFunctionCollection.h>
-#include <vtkMath.h>
-static int MYVTKDEBUG = 0;
+#include <float.h>
+#include <algorithm>
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int MYDEBUG = 0;
#endif
+
+//----------------------------------------------------------------------------
VISU_PipeLine
::VISU_PipeLine():
- myMapper(vtkDataSetMapper::New()),
- myExtractGeometry(SALOME_ExtractGeometry::New())
+ myIsShrinkable(true)
{
if(MYDEBUG) MESSAGE("VISU_PipeLine::VISU_PipeLine - "<<this);
- SetDebug(MYVTKDEBUG);
- vtkObject::SetGlobalWarningDisplay(MYVTKDEBUG);
-
- myMapper->Delete();
-
- // Clipping planes
- myExtractGeometry->Delete();
- myExtractGeometry->SetStoreMapping(true);
-
- vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New();
- myExtractGeometry->SetImplicitFunction(anImplicitBoolean);
- anImplicitBoolean->SetOperationTypeToIntersection();
- anImplicitBoolean->Delete();
-
- myIsShrinkable = false;
-
}
+
+//----------------------------------------------------------------------------
VISU_PipeLine
::~VISU_PipeLine()
{
if(MYDEBUG) MESSAGE("VISU_PipeLine::~VISU_PipeLine - "<<this);
}
-// Turn debugging output on.
-void
+
+//----------------------------------------------------------------------------
+unsigned long int
VISU_PipeLine
-::DebugOn()
+::GetMTime()
{
- myExtractGeometry->DebugOn();
- Superclass::DebugOn();
+ unsigned long int aTime = Superclass::GetMTime();
+
+ if(myMapperHolder.GetPointer())
+ aTime = std::max(aTime, myMapperHolder->GetMTime());
+
+ return aTime;
}
-// Turn debugging output off.
-void
+
+//----------------------------------------------------------------------------
+unsigned long int
VISU_PipeLine
-::DebugOff()
+::GetMemorySize()
{
- myExtractGeometry->DebugOff();
- Superclass::DebugOff();
+ unsigned long int aSize = 0;
+
+ if(myMapperHolder.GetPointer())
+ aSize += myMapperHolder->GetMemorySize();
+
+ return aSize;
}
+
+//----------------------------------------------------------------------------
void
VISU_PipeLine
-::ShallowCopy(VISU_PipeLine *thePipeLine)
+::ShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput)
{
SetImplicitFunction(thePipeLine->GetImplicitFunction());
+ DoShallowCopy(thePipeLine, theIsCopyInput);
+ Update();
+}
- // To restore mapper input from pipeline
- vtkDataSet* aDatsSet = myMapper->GetInput();
- GetMapper()->ShallowCopy(thePipeLine->GetMapper());
- myMapper->SetInput(aDatsSet);
- Build();
+//----------------------------------------------------------------------------
+void
+VISU_PipeLine
+::DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput)
+{
+ GetMapperHolder()->ShallowCopy(thePipeLine->GetMapperHolder(),
+ theIsCopyInput);
}
+
+//----------------------------------------------------------------------------
void
VISU_PipeLine
::SameAs(VISU_PipeLine *thePipeLine)
{
- ShallowCopy(thePipeLine);
- SetImplicitFunction(vtkImplicitBoolean::New());
- GetImplicitFunction()->Delete();
+ DoShallowCopy(thePipeLine, false);
+ Update();
}
-TInput*
+
+//----------------------------------------------------------------------------
+VISU_MapperHolder*
VISU_PipeLine
-::GetInput() const
+::GetMapperHolder()
{
- return myInput.GetPointer();
+ if(!myMapperHolder.GetPointer())
+ OnCreateMapperHolder();
+
+ return myMapperHolder.GetPointer();
}
-vtkDataSet*
+
+//----------------------------------------------------------------------------
+const VISU::PIDMapper&
VISU_PipeLine
-::GetOutput()
+::GetIDMapper()
{
- return GetMapper()->GetInput();
+ return GetMapperHolder()->GetIDMapper();
}
-TInput*
+
+//----------------------------------------------------------------------------
+vtkDataSet*
VISU_PipeLine
-::GetInput2() const
+::GetInput()
{
- vtkUnstructuredGrid* aDataSet = myExtractGeometry->GetOutput();
- aDataSet->Update();
- return aDataSet;
+ return GetMapperHolder()->GetInput();
}
-void
+
+//----------------------------------------------------------------------------
+vtkMapper*
VISU_PipeLine
-::SetInput(TInput* theInput)
+::GetMapper()
{
- if(theInput)
- theInput->Update();
- myExtractGeometry->SetInput(theInput);
- myInput = theInput;
+ return GetMapperHolder()->GetMapper();
+}
- Modified();
+
+//----------------------------------------------------------------------------
+vtkDataSet*
+VISU_PipeLine
+::GetOutput()
+{
+ return GetMapperHolder()->GetOutput();
}
-VISU_PipeLine::TMapper*
+
+//----------------------------------------------------------------------------
+bool
VISU_PipeLine
-::GetMapper()
+::IsPlanarInput()
{
- if(GetInput()){
- if(!myMapper->GetInput()){
- GetInput2()->Update();
- Build();
- }
- myMapper->Update();
- }
- return myMapper.GetPointer();
+ vtkFloatingPointType aBounds[6];
+ GetInput()->GetBounds( aBounds ); // xmin,xmax, ymin,ymax, zmin,zmax
+ if (fabs( aBounds[0] - aBounds[1] ) <= FLT_MIN ||
+ fabs( aBounds[2] - aBounds[3] ) <= FLT_MIN ||
+ fabs( aBounds[4] - aBounds[5] ) <= FLT_MIN )
+ return true;
+
+ return false;
}
+
+//----------------------------------------------------------------------------
void
VISU_PipeLine
-::Update()
+::SetMapperHolder(VISU_MapperHolder* theHolder)
{
- myMapper->Update();
+ myMapperHolder = theHolder;
+ theHolder->SetPipeLine(this);
}
-int
+
+//----------------------------------------------------------------------------
+void
VISU_PipeLine
-::CheckAvailableMemory(const vtkFloatingPointType& theSize)
+::Init()
+{}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PipeLine
+::Update()
{
- try{
- if(theSize > ULONG_MAX) return 0;
- size_t aSize = size_t(theSize);
- char *aCheck = new char[aSize];
- if(aCheck) delete [] aCheck;
- if(MYDEBUG && aCheck == NULL)
- MESSAGE("CheckAvailableMemory("<<theSize<<") - cannot alloacate such amount of memory!!!");
- return aCheck != NULL;
- //return theSize < 1000*1024*1024;
- }catch(std::bad_alloc& exc){
- if(MYDEBUG)
- MESSAGE("CheckAvailableMemory("<<theSize<<") " << exc.what());
- } catch(...) {
- if(MYDEBUG)
- MESSAGE("CheckAvailableMemory("<<theSize<<") - unexpected exception was caught!!!");
- }
- return 0;
+ GetMapperHolder()->Update();
}
-vtkFloatingPointType
+
+//----------------------------------------------------------------------------
+vtkIdType
VISU_PipeLine
-::GetAvailableMemory(vtkFloatingPointType theSize,
- vtkFloatingPointType theMinSize)
+::GetNodeObjID(vtkIdType theID)
{
- while(!CheckAvailableMemory(theSize))
- if(theSize > theMinSize)
- theSize /= 2;
- else
- return 0;
- return theSize;
+ return GetMapperHolder()->GetNodeObjID(theID);
}
-//------------------------ Clipping planes -----------------------------------
-bool
+//----------------------------------------------------------------------------
+vtkIdType
VISU_PipeLine
-::AddClippingPlane(vtkPlane* thePlane)
+::GetNodeVTKID(vtkIdType theID)
{
- if (thePlane) {
- if (vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()) {
- vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
- aFunction->AddItem(thePlane);
-
- // Check, that at least one cell present after clipping.
- // This check was introduced because of bug IPAL8849.
- vtkUnstructuredGrid* aClippedGrid = GetInput2();
- if (aClippedGrid->GetNumberOfCells() < 1) {
- return false;
- }
- }
- }
- return true;
+ return GetMapperHolder()->GetNodeVTKID(theID);
}
-vtkPlane*
+//----------------------------------------------------------------------------
+vtkFloatingPointType*
VISU_PipeLine
-::GetClippingPlane(vtkIdType theID) const
-{
- vtkPlane* aPlane = NULL;
- if(theID >= 0 && theID < GetNumberOfClippingPlanes()){
- if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
- vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
- vtkImplicitFunction* aFun = NULL;
- aFunction->InitTraversal();
- for(vtkIdType anID = 0; anID <= theID; anID++)
- aFun = aFunction->GetNextItem();
- aPlane = dynamic_cast<vtkPlane*>(aFun);
- }
- }
- return aPlane;
+::GetNodeCoord(int theObjID)
+{
+ return GetMapperHolder()->GetNodeCoord(theObjID);
}
-void
+
+//----------------------------------------------------------------------------
+vtkIdType
VISU_PipeLine
-::RemoveAllClippingPlanes()
+::GetElemObjID(vtkIdType theID)
{
- if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
- vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
- aFunction->RemoveAllItems();
- aBoolean->Modified(); // VTK bug
- }
+ return GetMapperHolder()->GetElemObjID(theID);
}
+//----------------------------------------------------------------------------
vtkIdType
VISU_PipeLine
-::GetNumberOfClippingPlanes() const
+::GetElemVTKID(vtkIdType theID)
{
- if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){
- vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
- return aFunction->GetNumberOfItems();
- }
- return 0;
+ return GetMapperHolder()->GetElemVTKID(theID);
}
-static
-void
-ComputeBoundsParam (vtkDataSet* theDataSet,
- vtkFloatingPointType theDirection[3],
- vtkFloatingPointType theMinPnt[3],
- vtkFloatingPointType& theMaxBoundPrj,
- vtkFloatingPointType& theMinBoundPrj)
+//----------------------------------------------------------------------------
+vtkCell*
+VISU_PipeLine
+::GetElemCell(vtkIdType theObjID)
{
- vtkFloatingPointType aBounds[6];
- theDataSet->GetBounds(aBounds);
-
- //Enlarge bounds in order to avoid conflicts of precision
- for(int i = 0; i < 6; i += 2){
- static double EPS = 1.0E-3;
- vtkFloatingPointType aDelta = (aBounds[i+1] - aBounds[i])*EPS;
- aBounds[i] -= aDelta;
- aBounds[i+1] += aDelta;
- }
-
- vtkFloatingPointType aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
- {aBounds[1],aBounds[2],aBounds[4]},
- {aBounds[0],aBounds[3],aBounds[4]},
- {aBounds[1],aBounds[3],aBounds[4]},
- {aBounds[0],aBounds[2],aBounds[5]},
- {aBounds[1],aBounds[2],aBounds[5]},
- {aBounds[0],aBounds[3],aBounds[5]},
- {aBounds[1],aBounds[3],aBounds[5]}};
-
- int aMaxId = 0, aMinId = aMaxId;
- theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
- theMinBoundPrj = theMaxBoundPrj;
- for(int i = 1; i < 8; i++){
- vtkFloatingPointType aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
- if(theMaxBoundPrj < aTmp){
- theMaxBoundPrj = aTmp;
- aMaxId = i;
- }
- if(theMinBoundPrj > aTmp){
- theMinBoundPrj = aTmp;
- aMinId = i;
- }
- }
- vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId];
- theMinPnt[0] = aMinPnt[0];
- theMinPnt[1] = aMinPnt[1];
- theMinPnt[2] = aMinPnt[2];
+ return GetMapperHolder()->GetElemCell(theObjID);
}
-static
-void
-DistanceToPosition(vtkDataSet* theDataSet,
- vtkFloatingPointType theDirection[3],
- vtkFloatingPointType theDist,
- vtkFloatingPointType thePos[3])
-{
- vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
- ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
- vtkFloatingPointType aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
- thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
- thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
- thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
-}
-static
-void
-PositionToDistance (vtkDataSet* theDataSet,
- vtkFloatingPointType theDirection[3],
- vtkFloatingPointType thePos[3],
- vtkFloatingPointType& theDist)
+//----------------------------------------------------------------------------
+bool
+VISU_PipeLine
+::IsShrinkable()
{
- vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
- ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
- vtkFloatingPointType aPrj = vtkMath::Dot(theDirection,thePos);
- theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
+ return myIsShrinkable;
}
-void
+void
VISU_PipeLine
-::SetPlaneParam(vtkFloatingPointType theDir[3],
- vtkFloatingPointType theDist,
- vtkPlane* thePlane)
+::SetIsShrinkable(bool theIsShrinkable)
{
- thePlane->SetNormal(theDir);
- vtkFloatingPointType anOrigin[3];
- ::DistanceToPosition(GetInput(),theDir,theDist,anOrigin);
- thePlane->SetOrigin(anOrigin);
+ myIsShrinkable = theIsShrinkable;
}
+
+//----------------------------------------------------------------------------
void
VISU_PipeLine
-::GetPlaneParam(vtkFloatingPointType theDir[3],
- vtkFloatingPointType& theDist,
- vtkPlane* thePlane)
+::SetImplicitFunction(vtkImplicitFunction *theFunction)
{
- thePlane->GetNormal(theDir);
-
- vtkFloatingPointType anOrigin[3];
- thePlane->GetOrigin(anOrigin);
- ::PositionToDistance(GetInput(),theDir,anOrigin,theDist);
-}
+ GetMapperHolder()->SetImplicitFunction(theFunction);
+}
-//=======================================================================
-//function : IsPlanarInput
-//purpose :
-//=======================================================================
-bool
+//----------------------------------------------------------------------------
+vtkImplicitFunction *
VISU_PipeLine
-::IsPlanarInput() const
+::GetImplicitFunction()
{
- vtkFloatingPointType aBounds[6];
- GetInput()->GetBounds( aBounds ); // xmin,xmax, ymin,ymax, zmin,zmax
- if (fabs( aBounds[0] - aBounds[1] ) <= FLT_MIN ||
- fabs( aBounds[2] - aBounds[3] ) <= FLT_MIN ||
- fabs( aBounds[4] - aBounds[5] ) <= FLT_MIN )
- return true;
-
- return false;
+ return GetMapperHolder()->GetImplicitFunction();
}
-//=======================================================================
-vtkIdType
+//----------------------------------------------------------------------------
+void
VISU_PipeLine
-::GetNodeObjID(vtkIdType theID)
+::SetExtractInside(bool theMode)
{
- vtkIdType anID = myExtractGeometry->GetNodeObjId(theID);
- return myIDMapper->GetNodeObjID(anID);
+ GetMapperHolder()->SetExtractInside(theMode);
}
-vtkIdType
+//----------------------------------------------------------------------------
+void
VISU_PipeLine
-::GetNodeVTKID(vtkIdType theID)
+::SetExtractBoundaryCells(bool theMode)
{
- vtkIdType anID = myIDMapper->GetNodeVTKID(theID);
- return myExtractGeometry->GetNodeVTKId(anID);
+ GetMapperHolder()->SetExtractBoundaryCells(theMode);
}
-vtkFloatingPointType*
+
+//----------------------------------------------------------------------------
+void
VISU_PipeLine
-::GetNodeCoord(int theObjID)
+::RemoveAllClippingPlanes()
{
- return myIDMapper->GetNodeCoord(theObjID);
+ GetMapperHolder()->RemoveAllClippingPlanes();
}
-//=======================================================================
-vtkIdType
+//----------------------------------------------------------------------------
+vtkIdType
VISU_PipeLine
-::GetElemObjID(vtkIdType theID)
+::GetNumberOfClippingPlanes()
{
- vtkIdType anID = myExtractGeometry->GetElemObjId(theID);
- return myIDMapper->GetElemObjID(anID);
+ return GetMapperHolder()->GetNumberOfClippingPlanes();
}
-vtkIdType
+//----------------------------------------------------------------------------
+bool
VISU_PipeLine
-::GetElemVTKID(vtkIdType theID)
+::AddClippingPlane(vtkPlane* thePlane)
{
- vtkIdType anID = myIDMapper->GetElemVTKID(theID);
- return myExtractGeometry->GetElemVTKId(anID);
+ return GetMapperHolder()->AddClippingPlane(thePlane);
}
-vtkCell*
+//----------------------------------------------------------------------------
+vtkPlane*
VISU_PipeLine
-::GetElemCell(vtkIdType theObjID)
+::GetClippingPlane(vtkIdType theID)
{
- return myIDMapper->GetElemCell(theObjID);
+ return GetMapperHolder()->GetClippingPlane(theID);
}
-//=======================================================================
-void
+//----------------------------------------------------------------------------
+vtkDataSet*
VISU_PipeLine
-::SetIDMapper(const VISU::PIDMapper& theIDMapper)
+::GetClippedInput()
{
- myIDMapper = theIDMapper;
- SetInput(myIDMapper->GetVTKOutput());
+ return GetMapperHolder()->GetClippedInput();
}
-const VISU::PIDMapper&
+
+//----------------------------------------------------------------------------
+void
VISU_PipeLine
-::GetIDMapper() const
+::SetPlaneParam(vtkFloatingPointType theDir[3],
+ vtkFloatingPointType theDist,
+ vtkPlane* thePlane)
{
- return myIDMapper;
+ thePlane->SetNormal(theDir);
+
+ vtkFloatingPointType anOrigin[3];
+ VISU::DistanceToPosition(GetInput(),
+ theDir,
+ theDist,
+ anOrigin);
+
+ thePlane->SetOrigin(anOrigin);
}
-//=======================================================================
+
+//----------------------------------------------------------------------------
void
VISU_PipeLine
-::SetImplicitFunction(vtkImplicitFunction *theFunction)
+::GetPlaneParam(vtkFloatingPointType theDir[3],
+ vtkFloatingPointType& theDist,
+ vtkPlane* thePlane)
{
- myExtractGeometry->SetImplicitFunction(theFunction);
-}
+ thePlane->GetNormal(theDir);
-vtkImplicitFunction *
+ vtkFloatingPointType anOrigin[3];
+ thePlane->GetOrigin(anOrigin);
+
+ VISU::PositionToDistance(GetInput(),
+ theDir,
+ anOrigin,
+ theDist);
+}
+
+
+//----------------------------------------------------------------------------
+size_t
VISU_PipeLine
-::GetImplicitFunction()
+::CheckAvailableMemory(double theSize)
{
- return myExtractGeometry->GetImplicitFunction();
+ if(theSize < ULONG_MAX){
+ try{
+ size_t aSize = size_t(theSize);
+ if(char *aCheck = new char[aSize]){
+ delete [] aCheck;
+ return aSize;
+ }
+ }catch(std::bad_alloc& exc){
+ }catch(...){
+ }
+ }
+ return 0;
}
-SALOME_ExtractGeometry*
+
+//----------------------------------------------------------------------------
+size_t
VISU_PipeLine
-::GetExtractGeometryFilter()
+::GetAvailableMemory(size_t theSize,
+ size_t theMinSize)
{
- return myExtractGeometry.GetPointer();
-}
+ // Finds acceptable memory size by half-deflection methods
+ static double EPSILON = 2 * 1024;
+ double aMax = std::max(theSize, theMinSize);
+ double aMin = std::min(theSize, theMinSize);
+ //cout<<"GetAvailableMemory - "<<aMax<<"; "<<aMin;
+ while(!CheckAvailableMemory(aMax) && CheckAvailableMemory(aMin) && (aMax - aMin) > EPSILON){
+ double aRoot = (aMax + aMin) / 2.;
+ if(CheckAvailableMemory(aRoot))
+ aMin = aRoot;
+ else
+ aMax = aRoot;
+ }
+ //cout<<"; "<<aMax<<endl;
+ return (size_t)aMax;
+}
+
+
+//----------------------------------------------------------------------------
#ifndef VISU_PipeLine_HeaderFile
#define VISU_PipeLine_HeaderFile
-#include <vector>
-#include <vtkObject.h>
-#include <vtkSmartPointer.h>
-
#include "VISUPipeline.hxx"
#include "VISU_IDMapper.hxx"
+#include <vtkObject.h>
+#include <vtkSmartPointer.h>
+
class vtkCell;
+class vtkPlane;
+class vtkMapper;
class vtkDataSet;
+class vtkPointSet;
class vtkImplicitFunction;
-template <class T>
-class TVTKSmartPtr: public vtkSmartPointer<T>
-{
-public:
- TVTKSmartPtr()
- {}
-
- TVTKSmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer<T>(r)
- {
- if(r && theIsOwner)
- r->Delete();
- }
-
- TVTKSmartPtr& operator()(T* r, bool theIsOwner = false)
- {
- vtkSmartPointer<T>::operator=(r);
- if(r && theIsOwner)
- r->Delete();
- return *this;
- }
-
- TVTKSmartPtr& operator=(T* r)
- {
- vtkSmartPointer<T>::operator=(r);
- return *this;
- }
-
- operator T* () const
- {
- return vtkSmartPointer<T>::GetPointer();
- }
-};
-
-class vtkMapper;
-class vtkDataSetMapper;
-class vtkUnstructuredGrid;
-class vtkExtractGeometry;
-class vtkImplicitBoolean;
-class vtkPlane;
+class VISU_MapperHolder;
-class SALOME_ExtractGeometry;
-
-typedef VISU::TVTKOutput TInput;
+//----------------------------------------------------------------------------
+class VISU_PIPELINE_EXPORT VISU_PipeLine : public vtkObject
+{
+ friend class VISU_MapperHolder;
-class VISU_PIPELINE_EXPORT VISU_PipeLine : public vtkObject{
public:
- vtkTypeMacro(VISU_PipeLine,vtkObject);
- virtual
- ~VISU_PipeLine();
+ vtkTypeMacro(VISU_PipeLine, vtkObject);
+ //! Gets memory size used by the instance (bytes).
virtual
- void
- DebugOn();
+ unsigned long int
+ GetMemorySize();
virtual
- void
- DebugOff();
+ unsigned long int
+ GetMTime();
+ //----------------------------------------------------------------------------
virtual
void
- ShallowCopy(VISU_PipeLine *thePipeLine);
+ ShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
virtual
void
SameAs(VISU_PipeLine *thePipeLine);
-public:
- virtual
- void
- SetInput(TInput* theInput);
+ //----------------------------------------------------------------------------
+ void
+ SetMapperHolder(VISU_MapperHolder* theHolder);
- virtual
- TInput*
- GetInput() const;
+ VISU_MapperHolder*
+ GetMapperHolder();
+
+ const VISU::PIDMapper&
+ GetIDMapper();
virtual
vtkDataSet*
- GetOutput();
-
- bool
- IsPlanarInput() const;
-
- typedef vtkMapper TMapper;
+ GetInput();
virtual
- TMapper*
+ vtkMapper*
GetMapper();
virtual
- void
- Init() = 0;
+ vtkDataSet*
+ GetOutput();
+ //----------------------------------------------------------------------------
virtual
void
- Update();
-
- static
- int
- CheckAvailableMemory(const vtkFloatingPointType& theSize);
-
- static
- vtkFloatingPointType
- GetAvailableMemory(vtkFloatingPointType theSize = 16*1024*1024.0,
- vtkFloatingPointType theMinSize = 1024*1024.0);
-
- // Clipping planes
- void
- RemoveAllClippingPlanes();
-
- vtkIdType
- GetNumberOfClippingPlanes() const;
-
- bool
- AddClippingPlane(vtkPlane* thePlane);
-
- vtkPlane*
- GetClippingPlane(vtkIdType theID) const;
-
- void
- SetPlaneParam(vtkFloatingPointType theDir[3],
- vtkFloatingPointType theDist,
- vtkPlane* thePlane);
+ Init();
+ virtual
void
- GetPlaneParam(vtkFloatingPointType theDir[3],
- vtkFloatingPointType& theDist,
- vtkPlane* thePlane);
-
- bool
- IsShrinkable() { return myIsShrinkable; }
+ Update();
+ //----------------------------------------------------------------------------
virtual
vtkIdType
GetNodeObjID(vtkIdType theID);
vtkCell*
GetElemCell(vtkIdType theObjID);
- void
- SetIDMapper(const VISU::PIDMapper& theIDMapper);
+ //----------------------------------------------------------------------------
+ bool
+ IsPlanarInput();
- const VISU::PIDMapper&
- GetIDMapper()const;
+ bool
+ IsShrinkable();
+ //----------------------------------------------------------------------------
void
SetImplicitFunction(vtkImplicitFunction *theFunction);
vtkImplicitFunction*
GetImplicitFunction();
- SALOME_ExtractGeometry*
- GetExtractGeometryFilter();
+ void
+ SetExtractInside(bool theMode);
+
+ void
+ SetExtractBoundaryCells(bool theMode);
+
+ //----------------------------------------------------------------------------
+ void
+ RemoveAllClippingPlanes();
+
+ vtkIdType
+ GetNumberOfClippingPlanes();
+
+ bool
+ AddClippingPlane(vtkPlane* thePlane);
+
+ virtual
+ vtkPlane*
+ GetClippingPlane(vtkIdType theID);
+
+ virtual
+ void
+ SetPlaneParam(vtkFloatingPointType theDir[3],
+ vtkFloatingPointType theDist,
+ vtkPlane* thePlane);
+
+ virtual
+ void
+ GetPlaneParam(vtkFloatingPointType theDir[3],
+ vtkFloatingPointType& theDist,
+ vtkPlane* thePlane);
+
+ //----------------------------------------------------------------------------
+ static
+ size_t
+ CheckAvailableMemory(double theSize);
+
+ static
+ size_t
+ GetAvailableMemory(size_t theSize,
+ size_t theMinSize = 1024*1024);
protected:
+ //----------------------------------------------------------------------------
VISU_PipeLine();
- virtual
- TInput*
- GetInput2() const;
+ virtual
+ ~VISU_PipeLine();
+ //----------------------------------------------------------------------------
virtual
void
Build() = 0;
- bool myIsShrinkable;
+ virtual
+ void
+ OnCreateMapperHolder() = 0;
- TVTKSmartPtr<TInput> myInput;
- VISU::PIDMapper myIDMapper;
- TVTKSmartPtr<vtkDataSetMapper> myMapper;
+ virtual
+ void
+ DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
+
+ //----------------------------------------------------------------------------
+ vtkDataSet*
+ GetClippedInput();
- // Clipping planes
- TVTKSmartPtr<SALOME_ExtractGeometry> myExtractGeometry;
+ void
+ SetIsShrinkable(bool theIsShrinkable);
+
+private:
+ //----------------------------------------------------------------------------
+ vtkSmartPointer<VISU_MapperHolder> myMapperHolder;
+ bool myIsShrinkable;
};
#endif
#include "VISU_PipeLineUtils.hxx"
-void
-VISU::Mul(const vtkFloatingPointType A[3],
- vtkFloatingPointType b,
- vtkFloatingPointType C[3])
-{ // A*b;
- for(int i = 0; i < 3; i++) C[i] = A[i]*b;
-}
+#include "VISU_OpenGLPointSpriteMapper.hxx"
+
+#include <vtkDataSetMapper.h>
+#include <vtkPolyDataMapper.h>
+
+namespace VISU
+{
+ //----------------------------------------------------------------------------
+ void
+ Mul(const vtkFloatingPointType A[3],
+ vtkFloatingPointType b,
+ vtkFloatingPointType C[3])
+ { // A*b;
+ for(int i = 0; i < 3; i++)
+ C[i] = A[i]*b;
+ }
+
+
+ //----------------------------------------------------------------------------
+ void
+ Sub(const vtkFloatingPointType A[3],
+ const vtkFloatingPointType B[3],
+ vtkFloatingPointType C[3])
+ { //A-B
+ for(int i = 0; i < 3; i++)
+ C[i] = A[i] - B[i];
+ }
+
+
+ //----------------------------------------------------------------------------
+ bool
+ CheckIsSameValue(vtkFloatingPointType theTarget,
+ vtkFloatingPointType theSource)
+ {
+ static vtkFloatingPointType TOL = 10.0 / VTK_LARGE_FLOAT;
+ if(fabs(theTarget - theSource) < TOL)
+ return true;
+ return false;
+ }
+
+
+ //----------------------------------------------------------------------------
+ bool
+ CheckIsSameRange(vtkFloatingPointType* theTarget,
+ vtkFloatingPointType* theSource)
+ {
+ return CheckIsSameValue(theTarget[0], theSource[0]) &&
+ CheckIsSameValue(theTarget[1], theSource[1]);
+ }
+
+
+ //----------------------------------------------------------------------------
+ void
+ CopyMapper(vtkMapper* theTarget,
+ vtkMapper* theSource,
+ bool theIsCopyInput)
+ {
+ // To customize vtkMapper::ShallowCopy ...
+ theTarget->SetScalarVisibility(theSource->GetScalarVisibility());
+ if(theIsCopyInput){
+ vtkFloatingPointType* aScalarRange = theSource->GetScalarRange();
+ if(!CheckIsSameRange(theTarget->GetScalarRange(), aScalarRange))
+ theTarget->SetScalarRange(aScalarRange);
+ }
+ theTarget->SetColorMode(theSource->GetColorMode());
+ theTarget->SetScalarMode(theSource->GetScalarMode());
+ theTarget->SetImmediateModeRendering(theSource->GetImmediateModeRendering());
+ theTarget->SetUseLookupTableScalarRange(theSource->GetUseLookupTableScalarRange());
+ if(theSource->GetArrayAccessMode() == VTK_GET_ARRAY_BY_ID)
+ theTarget->ColorByArrayComponent(theSource->GetArrayId(), theSource->GetArrayComponent());
+ else
+ theTarget->ColorByArrayComponent(theSource->GetArrayName(), theSource->GetArrayComponent());
+
+ // To customize vtkAbstractMapper3D::ShallowCopy ...
+ theTarget->SetClippingPlanes(theSource->GetClippingPlanes());
+ }
+
+
+ //----------------------------------------------------------------------------
+ void
+ CopyDataSetMapper(vtkDataSetMapper* theTarget,
+ vtkDataSetMapper* theSource,
+ bool theIsCopyInput)
+ {
+ // To customize vtkDataSetMapper::ShallowCopy ...
+ //theTarget->SetInput(theSource->GetInput());
+ CopyMapper(theTarget, theSource, theIsCopyInput);
+ }
-void
-VISU::Sub(const vtkFloatingPointType A[3],
- const vtkFloatingPointType B[3],
- vtkFloatingPointType C[3])
-{ //A-B
- for(int i = 0; i < 3; i++) C[i] = A[i] - B[i];
-}
+ //----------------------------------------------------------------------------
+ void
+ CopyPolyDataMapper(vtkPolyDataMapper* theTarget,
+ vtkPolyDataMapper* theSource,
+ bool theIsCopyInput)
+ {
+ // To customize vtkPolyDataMapper::ShallowCopy ...
+ //theTarget->SetInput(theSource->GetInput());
+ theTarget->SetGhostLevel(theSource->GetGhostLevel());
+ theTarget->SetNumberOfPieces(theSource->GetNumberOfPieces());
+ theTarget->SetNumberOfSubPieces(theSource->GetNumberOfSubPieces());
+
+ CopyMapper(theTarget, theSource, theIsCopyInput);
+ }
+
+
+ //----------------------------------------------------------------------------
+ void
+ CopyPointSpriteDataMapper(VISU_OpenGLPointSpriteMapper* theTarget,
+ VISU_OpenGLPointSpriteMapper* theSource,
+ bool theIsCopyInput)
+ {
+ // To customize VISU_OpenGLPointSpriteMapper::ShallowCopy ...
+ theTarget->SetPrimitiveType( theSource->GetPrimitiveType() );
+
+ theTarget->SetPointSpriteMode( theSource->GetPointSpriteMode() );
+
+ theTarget->SetPointSpriteClamp( theSource->GetPointSpriteClamp() );
+ theTarget->SetPointSpriteSize( theSource->GetPointSpriteSize() );
+ theTarget->SetPointSpriteMinSize( theSource->GetPointSpriteMinSize() );
+ theTarget->SetPointSpriteMaxSize( theSource->GetPointSpriteMaxSize() );
+ theTarget->SetPointSpriteMagnification( theSource->GetPointSpriteMagnification() );
+
+ theTarget->SetImageData( theSource->GetImageData() );
+ theTarget->SetPointSpriteAlphaThreshold( theSource->GetPointSpriteAlphaThreshold() );
+
+ CopyPolyDataMapper(theTarget, theSource, theIsCopyInput);
+ }
+
+
+ //----------------------------------------------------------------------------
+ void
+ ComputeBoundsParam(vtkDataSet* theDataSet,
+ vtkFloatingPointType theDirection[3],
+ vtkFloatingPointType theMinPnt[3],
+ vtkFloatingPointType& theMaxBoundPrj,
+ vtkFloatingPointType& theMinBoundPrj)
+ {
+ vtkFloatingPointType aBounds[6];
+ theDataSet->GetBounds(aBounds);
+
+ //Enlarge bounds in order to avoid conflicts of precision
+ for(int i = 0; i < 6; i += 2){
+ static double EPS = 1.0E-3;
+ vtkFloatingPointType aDelta = (aBounds[i+1] - aBounds[i])*EPS;
+ aBounds[i] -= aDelta;
+ aBounds[i+1] += aDelta;
+ }
+
+ vtkFloatingPointType aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
+ {aBounds[1],aBounds[2],aBounds[4]},
+ {aBounds[0],aBounds[3],aBounds[4]},
+ {aBounds[1],aBounds[3],aBounds[4]},
+ {aBounds[0],aBounds[2],aBounds[5]},
+ {aBounds[1],aBounds[2],aBounds[5]},
+ {aBounds[0],aBounds[3],aBounds[5]},
+ {aBounds[1],aBounds[3],aBounds[5]}};
+
+ int aMaxId = 0, aMinId = aMaxId;
+ theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
+ theMinBoundPrj = theMaxBoundPrj;
+ for(int i = 1; i < 8; i++){
+ vtkFloatingPointType aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
+ if(theMaxBoundPrj < aTmp){
+ theMaxBoundPrj = aTmp;
+ aMaxId = i;
+ }
+ if(theMinBoundPrj > aTmp){
+ theMinBoundPrj = aTmp;
+ aMinId = i;
+ }
+ }
+ vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId];
+ theMinPnt[0] = aMinPnt[0];
+ theMinPnt[1] = aMinPnt[1];
+ theMinPnt[2] = aMinPnt[2];
+ }
+
+
+ //----------------------------------------------------------------------------
+ void
+ DistanceToPosition(vtkDataSet* theDataSet,
+ vtkFloatingPointType theDirection[3],
+ vtkFloatingPointType theDist,
+ vtkFloatingPointType thePos[3])
+ {
+ vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
+ ComputeBoundsParam(theDataSet,
+ theDirection,
+ aMinPnt,
+ aMaxBoundPrj,
+ aMinBoundPrj);
+ vtkFloatingPointType aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
+ thePos[0] = aMinPnt[0] - theDirection[0] * aLength;
+ thePos[1] = aMinPnt[1] - theDirection[1] * aLength;
+ thePos[2] = aMinPnt[2] - theDirection[2] * aLength;
+ }
+
+
+ //----------------------------------------------------------------------------
+ void
+ PositionToDistance(vtkDataSet* theDataSet,
+ vtkFloatingPointType theDirection[3],
+ vtkFloatingPointType thePos[3],
+ vtkFloatingPointType& theDist)
+ {
+ vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
+ ComputeBoundsParam(theDataSet,
+ theDirection,
+ aMinPnt,
+ aMaxBoundPrj,
+ aMinBoundPrj);
+ vtkFloatingPointType aPrj = vtkMath::Dot(theDirection,thePos);
+ theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
+ }
+
+
+ //----------------------------------------------------------------------------
+}
#define VISU_PipeLineUtils_HeaderFile
#include "VISUPipeline.hxx"
-#include "VISU_FieldTransform.hxx"
-#include "VISU_LookupTable.hxx"
-#include "VISU_Extractor.hxx"
#include "VISU_ConvertorUtils.hxx"
#include <vtkProperty.h>
#endif
+class VISU_OpenGLPointSpriteMapper;
+
namespace VISU
{
+ //----------------------------------------------------------------------------
void
Mul(const vtkFloatingPointType A[3],
vtkFloatingPointType b,
vtkFloatingPointType C[3]); // C = A * b
+
+ //----------------------------------------------------------------------------
void
Sub(const vtkFloatingPointType A[3],
const vtkFloatingPointType B[3],
vtkFloatingPointType C[3]); // C = A - B
- template<class TItem>
+
+ //----------------------------------------------------------------------------
+ template<class TOutputFilter>
void
- CellDataToPoint(TItem* theTItem,
- vtkCellDataToPointData *theFilter,
- vtkDataSet* theDataSet,
- VISU_FieldTransform *theFieldTransform)
+ CellDataToPoint(TOutputFilter* theOutputFilter,
+ vtkCellDataToPointData *theCellDataToPointData,
+ vtkDataSet* theDataSet)
+
{
if(VISU::IsDataOnCells(theDataSet)){
- theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
- theFilter->PassCellDataOn();
- theTItem->SetInput(theFilter->GetUnstructuredGridOutput());
+ theCellDataToPointData->SetInput(theDataSet);
+ theCellDataToPointData->PassCellDataOn();
+ theOutputFilter->SetInput(theCellDataToPointData->GetUnstructuredGridOutput());
}else
- theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput());
+ theOutputFilter->SetInput(theDataSet);
}
- template<class TItem>
+ //----------------------------------------------------------------------------
+ template<class TOutputFilter>
void
- ToCellCenters(TItem* theTItem,
- vtkCellCenters *theFilter,
- vtkDataSet* theDataSet,
- VISU_FieldTransform *theFieldTransform)
+ ToCellCenters(TOutputFilter* theOutputFilter,
+ vtkCellCenters *theCellCenters,
+ vtkDataSet* theDataSet)
+
{
if(VISU::IsDataOnCells(theDataSet)){
- theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
- theFilter->VertexCellsOn();
- theTItem->SetInput(theFilter->GetOutput());
+ theCellCenters->SetInput(theDataSet);
+ theCellCenters->VertexCellsOn();
+ theOutputFilter->SetInput(theCellCenters->GetOutput());
}else
- theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput());
+ theOutputFilter->SetInput(theDataSet);
}
+
+ //----------------------------------------------------------------------------
+ //! Checks whether the float values are the same or not
+ bool
+ CheckIsSameValue(vtkFloatingPointType theTarget,
+ vtkFloatingPointType theSource);
+
+ //! Checks whether the scalar range is the same or not
+ bool
+ CheckIsSameRange(vtkFloatingPointType* theTarget,
+ vtkFloatingPointType* theSource);
+
+ //! Customizes vtkMapper::ShallowCopy
+ void
+ CopyMapper(vtkMapper* theTarget,
+ vtkMapper* theSource,
+ bool theIsCopyInput);
+
+ //! Customizes vtkDataSetMapper::ShallowCopy
+ void
+ CopyDataSetMapper(vtkDataSetMapper* theTarget,
+ vtkDataSetMapper* theSource,
+ bool theIsCopyInput);
+
+ //! Customizes vtkPolyDataMapper::ShallowCopy
+ void
+ CopyPolyDataMapper(vtkPolyDataMapper* theTarget,
+ vtkPolyDataMapper* theSource,
+ bool theIsCopyInput);
+
+ //! Customizes VISU_OpenGLPointSpriteMapper::ShallowCopy
+ void
+ CopyPointSpriteDataMapper(VISU_OpenGLPointSpriteMapper* theTarget,
+ VISU_OpenGLPointSpriteMapper* theSource,
+ bool theIsCopyInput);
+
+
+ //----------------------------------------------------------------------------
+ void
+ ComputeBoundsParam(vtkDataSet* theDataSet,
+ vtkFloatingPointType theDirection[3],
+ vtkFloatingPointType theMinPnt[3],
+ vtkFloatingPointType& theMaxBoundPrj,
+ vtkFloatingPointType& theMinBoundPrj);
+
+
+ //----------------------------------------------------------------------------
+ void
+ DistanceToPosition(vtkDataSet* theDataSet,
+ vtkFloatingPointType theDirection[3],
+ vtkFloatingPointType theDist,
+ vtkFloatingPointType thePos[3]);
+
+
+ //----------------------------------------------------------------------------
+ void
+ PositionToDistance(vtkDataSet* theDataSet,
+ vtkFloatingPointType theDirection[3],
+ vtkFloatingPointType thePos[3],
+ vtkFloatingPointType& theDist);
}
#endif
#include <vtkWarpScalar.h>
#include <vtkOutlineFilter.h>
-using namespace std;
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_Plot3DPL);
-VISU_Plot3DPL::VISU_Plot3DPL():
- myCellDataToPointData(vtkCellDataToPointData::New(),true),
- myAppendPolyData(vtkAppendPolyData::New(),true),
- myGeometryFilter(vtkGeometryFilter::New(),true),
- myContourFilter(vtkContourFilter::New(),true),
- myWarpScalar(vtkWarpScalar::New(),true),
+
+//----------------------------------------------------------------------------
+VISU_Plot3DPL
+::VISU_Plot3DPL():
+ myCellDataToPointData(vtkCellDataToPointData::New()),
+ myAppendPolyData(vtkAppendPolyData::New()),
+ myGeometryFilter(vtkGeometryFilter::New()),
+ myContourFilter(vtkContourFilter::New()),
+ myWarpScalar(vtkWarpScalar::New()),
myOrientation(VISU_CutPlanesPL::YZ),
myIsRelative(true),
myIsContour(false),
myPosition(0.5),
- myScaleFactor(1.)
+ myScaleFactor(1.0)
{
- myAngle[0] = myAngle[1] = myAngle[2] = 0.;
+ SetIsShrinkable(false);
+
+ myCellDataToPointData->Delete();
+ myAppendPolyData->Delete();
+ myGeometryFilter->Delete();
+ myContourFilter->Delete();
+ myWarpScalar->Delete();
+
+ myAngle[0] = myAngle[1] = myAngle[2] = 0.0;
+
SetNumberOfContours(32);
- myIsShrinkable = false;
}
-VISU_Plot3DPL::~VISU_Plot3DPL()
+
+//----------------------------------------------------------------------------
+VISU_Plot3DPL
+::~VISU_Plot3DPL()
{
}
+
+//----------------------------------------------------------------------------
void
-VISU_Plot3DPL::
-ShallowCopy(VISU_PipeLine *thePipeLine)
+VISU_Plot3DPL
+::DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput)
{
+ Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
+
if(VISU_Plot3DPL *aPipeLine = dynamic_cast<VISU_Plot3DPL*>(thePipeLine)){
SetOrientation (aPipeLine->GetPlaneOrientation(),
aPipeLine->GetRotateX(), aPipeLine->GetRotateY());
SetContourPrs( aPipeLine->GetIsContourPrs() );
SetNumberOfContours( aPipeLine->GetNumberOfContours() );
}
- TSupperClass::ShallowCopy(thePipeLine);
}
+
+//----------------------------------------------------------------------------
VISU_CutPlanesPL::PlaneOrientation
-VISU_Plot3DPL::
-GetOrientation(vtkDataSet* theDataSet)
+VISU_Plot3DPL
+::GetOrientation(vtkDataSet* theDataSet)
{
theDataSet->Update();
return VISU_CutPlanesPL::XY;
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
-VISU_Plot3DPL::
-GetScaleFactor(vtkDataSet* theDataSet)
+VISU_Plot3DPL
+::GetScaleFactor(vtkDataSet* theDataSet)
{
theDataSet->Update();
vtkFloatingPointType aLength = theDataSet->GetLength(); // diagonal length
return 0.0;
}
+
+//----------------------------------------------------------------------------
void
-VISU_Plot3DPL::
-Init()
+VISU_Plot3DPL
+::Init()
{
- TSupperClass::Init();
+ Superclass::Init();
- myOrientation = GetOrientation(GetInput2());
- SetScaleFactor(GetScaleFactor(GetInput2()));
+ myOrientation = GetOrientation(GetMergedInput());
+ SetScaleFactor(GetScaleFactor(GetMergedInput()));
}
-VISU_ScalarMapPL::THook*
-VISU_Plot3DPL::
-DoHook()
+
+//----------------------------------------------------------------------------
+vtkDataSet*
+VISU_Plot3DPL
+::InsertCustomPL()
{
return myAppendPolyData->GetOutput();
}
+
+//----------------------------------------------------------------------------
void
-VISU_Plot3DPL::
-Update()
+VISU_Plot3DPL
+::Update()
{
vtkFloatingPointType aPlaneNormal[3];
vtkFloatingPointType anOrigin[3];
vtkPolyData* aPolyData = 0;
vtkCutter *aCutPlane = 0;
- vtkUnstructuredGrid* anUnstructuredGrid =
- myFieldTransform->GetUnstructuredGridOutput();
+ vtkDataSet* aDataSet = GetMergedInput();
if ( !IsPlanarInput() )
{
aCutPlane = vtkCutter::New();
- aCutPlane->SetInput(anUnstructuredGrid);
+ aCutPlane->SetInput(aDataSet);
vtkPlane *aPlane = vtkPlane::New();
aPlane->SetOrigin(anOrigin);
}
if ( !aPolyData || aPolyData->GetNumberOfCells() == 0 ) {
- myGeometryFilter->SetInput(anUnstructuredGrid);
+ myGeometryFilter->SetInput(aDataSet);
aPolyData = myGeometryFilter->GetOutput();
aPolyData->Update();
}
myWarpScalar->SetInput(myContourFilter->GetOutput());
}
- VISU_CutPlanesPL::ClearAppendPolyData(myAppendPolyData);
+ VISU_CutPlanesPL::ClearAppendPolyData(myAppendPolyData.GetPointer());
myAppendPolyData->AddInput(myWarpScalar->GetPolyDataOutput());
if ( aCutPlane )
myWarpScalar->SetNormal(aPlaneNormal);
- TSupperClass::Update();
+ Superclass::Update();
}
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_Plot3DPL
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ if(vtkDataObject* aDataObject = myGeometryFilter->GetInput())
+ aSize += aDataObject->GetActualMemorySize() * 1024;
+
+ if(myCellDataToPointData->GetInput())
+ if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(vtkDataObject* aDataObject = myContourFilter->GetInput())
+ aSize += aDataObject->GetActualMemorySize() * 1024;
+
+ if(vtkDataObject* aDataObject = myWarpScalar->GetInput())
+ aSize += aDataObject->GetActualMemorySize() * 1024;
+
+ int anEnd = myAppendPolyData->GetNumberOfInputConnections(0);
+ for(int anId = 0; anId < anEnd; anId++){
+ if(vtkDataObject* aDataObject = myAppendPolyData->GetInput(anId))
+ aSize += aDataObject->GetActualMemorySize() * 1024;
+ }
+
+ return aSize;
+}
+
+
+//----------------------------------------------------------------------------
void
-VISU_Plot3DPL::
-SetNumberOfContours(int theNumber)
+VISU_Plot3DPL
+::SetNumberOfContours(int theNumber)
{
myContourFilter->SetNumberOfContours(theNumber);
}
+
+//----------------------------------------------------------------------------
int
-VISU_Plot3DPL::
-GetNumberOfContours() const
+VISU_Plot3DPL
+::GetNumberOfContours()
{
return myContourFilter->GetNumberOfContours();
}
+
+//----------------------------------------------------------------------------
void
-VISU_Plot3DPL::
-SetScaleFactor(vtkFloatingPointType theScaleFactor)
+VISU_Plot3DPL
+::SetScaleFactor(vtkFloatingPointType theScaleFactor)
{
myScaleFactor = theScaleFactor;
myWarpScalar->SetScaleFactor(theScaleFactor);
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
-VISU_Plot3DPL::
-GetScaleFactor() const
+VISU_Plot3DPL
+::GetScaleFactor()
{
return myScaleFactor;
}
+
+//----------------------------------------------------------------------------
void
VISU_Plot3DPL::
-SetPlanePosition(vtkFloatingPointType thePosition,
- bool theIsRelative)
+SetContourPrs(bool theIsContourPrs )
+{
+ myIsContour = theIsContourPrs;
+ Modified();
+}
+
+
+//----------------------------------------------------------------------------
+bool
+VISU_Plot3DPL
+::GetIsContourPrs()
+{
+ return myIsContour;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_Plot3DPL
+::SetPlanePosition(vtkFloatingPointType thePosition,
+ bool theIsRelative)
{
myIsRelative = theIsRelative;
myPosition = thePosition;
+ Modified();
}
+
+//----------------------------------------------------------------------------
bool
-VISU_Plot3DPL::
-IsPositionRelative() const
+VISU_Plot3DPL
+::IsPositionRelative()
{
return myIsRelative;
}
+
+//----------------------------------------------------------------------------
VISU_CutPlanesPL::PlaneOrientation
-VISU_Plot3DPL::
-GetPlaneOrientation() const
+VISU_Plot3DPL
+::GetPlaneOrientation()
{
return myOrientation;
}
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_Plot3DPL::
GetRotateX()
return 0;
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_Plot3DPL::
GetRotateY(){
return 0;
}
+
+//----------------------------------------------------------------------------
void
VISU_Plot3DPL::
SetOrientation(VISU_CutPlanesPL::PlaneOrientation theOrientation,
case VISU_CutPlanesPL::ZX: myAngle[0] = theYAngle; break;
}
myOrientation = theOrientation;
+ Modified();
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
-VISU_Plot3DPL::
-GetPlanePosition() const
+VISU_Plot3DPL
+::GetPlanePosition()
{
return myPosition;
}
//function : GetBasePlane
//purpose :
//=======================================================================
-
-void VISU_Plot3DPL::GetBasePlane(vtkFloatingPointType theOrigin[3],
- vtkFloatingPointType theNormal[3],
- bool theCenterOrigine ) const
+void
+VISU_Plot3DPL
+::GetBasePlane(vtkFloatingPointType theOrigin[3],
+ vtkFloatingPointType theNormal[3],
+ bool theCenterOrigine )
{
VISU_CutPlanesPL::GetDir(theNormal,myAngle,myOrientation);
if ( theCenterOrigine ) {
// move theOrigin to the center of aBounds projections to the plane
- GetInput2()->GetBounds(aBounds);
+ GetMergedInput()->GetBounds(aBounds);
vtkFloatingPointType boundPoints[8][3] = {
{aBounds[0],aBounds[2],aBounds[4]},
{aBounds[1],aBounds[2],aBounds[4]},
//function : GetMinMaxPosition
//purpose : return absolute position range
//=======================================================================
-
-void VISU_Plot3DPL::GetMinMaxPosition( vtkFloatingPointType& minPos,
- vtkFloatingPointType& maxPos ) const
+void
+VISU_Plot3DPL
+::GetMinMaxPosition( vtkFloatingPointType& minPos,
+ vtkFloatingPointType& maxPos )
{
vtkFloatingPointType aBounds[6], aBoundPrj[3], aNormal[3];
VISU_CutPlanesPL::GetDir(aNormal,myAngle,myOrientation);
//purpose :
//=======================================================================
-void VISU_Plot3DPL::SetMapScale(vtkFloatingPointType theMapScale)
+void
+VISU_Plot3DPL
+::SetMapScale(vtkFloatingPointType theMapScale)
{
- TSupperClass::SetMapScale(theMapScale);
+ Superclass::SetMapScale(theMapScale);
if ( myIsContour ) {
vtkFloatingPointType aRange[2];
#define VISU_Plot3DPL_HeaderFile
#include "VISUPipeline.hxx"
-#include "VISU_PrsMergerPL.hxx"
+#include "VISU_ScalarMapPL.hxx"
#include "VISU_CutPlanesPL.hxx"
class vtkWarpScalar;
class vtkGeometryFilter;
class vtkCellDataToPointData;
-class VISU_PIPELINE_EXPORT VISU_Plot3DPL : public VISU_PrsMergerPL{
- typedef VISU_ScalarMapPL TSupperClass;
-protected:
- VISU_Plot3DPL();
- VISU_Plot3DPL(const VISU_Plot3DPL&);
+//----------------------------------------------------------------------------
+class VISU_PIPELINE_EXPORT VISU_Plot3DPL : public VISU_ScalarMapPL
+{
public:
- vtkTypeMacro(VISU_Plot3DPL,TSupperClass);
- static VISU_Plot3DPL* New();
- virtual ~VISU_Plot3DPL();
+ vtkTypeMacro(VISU_Plot3DPL, VISU_ScalarMapPL);
- virtual
- void
- ShallowCopy(VISU_PipeLine *thePipeLine);
+ static
+ VISU_Plot3DPL*
+ New();
+
+ virtual
+ ~VISU_Plot3DPL();
VISU_CutPlanesPL::PlaneOrientation
- GetPlaneOrientation() const;
+ GetPlaneOrientation();
vtkFloatingPointType
GetRotateX();
vtkFloatingPointType theYAngle = 0.0);
vtkFloatingPointType
- GetPlanePosition() const;
+ GetPlanePosition();
bool
- IsPositionRelative() const;
+ IsPositionRelative();
void
SetPlanePosition(vtkFloatingPointType thePosition,
SetScaleFactor(vtkFloatingPointType theScaleFactor);
vtkFloatingPointType
- GetScaleFactor() const;
+ GetScaleFactor();
void
- SetContourPrs (bool theIsContourPrs ) { myIsContour = theIsContourPrs; }
+ SetContourPrs(bool theIsContourPrs );
bool
- GetIsContourPrs() { return myIsContour; }
+ GetIsContourPrs();
void
SetNumberOfContours(int theNumber);
int
- GetNumberOfContours() const;
+ GetNumberOfContours();
- void GetBasePlane (vtkFloatingPointType theOrigin[3],
- vtkFloatingPointType theNormal[3],
- bool theCenterOrigine = false ) const;
+ void
+ GetBasePlane (vtkFloatingPointType theOrigin[3],
+ vtkFloatingPointType theNormal[3],
+ bool theCenterOrigine = false );
+
+ void
+ GetMinMaxPosition( vtkFloatingPointType& minPos,
+ vtkFloatingPointType& maxPos );
+
+public:
+ virtual
+ void
+ Init();
- void GetMinMaxPosition( vtkFloatingPointType& minPos,
- vtkFloatingPointType& maxPos ) const;
+ virtual
+ void
+ Update();
-public:
- virtual void Init();
- virtual void Update();
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
static
VISU_CutPlanesPL::PlaneOrientation
void SetMapScale(vtkFloatingPointType theMapScale);
protected:
- virtual THook* DoHook();
+ VISU_Plot3DPL();
+ VISU_Plot3DPL(const VISU_Plot3DPL&);
+
+ virtual
+ vtkDataSet*
+ InsertCustomPL();
+
+ virtual
+ void
+ DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
vtkFloatingPointType myAngle[3];
bool myIsRelative, myIsContour;
vtkFloatingPointType myPosition, myScaleFactor;
VISU_CutPlanesPL::PlaneOrientation myOrientation;
- TVTKSmartPtr<vtkCellDataToPointData> myCellDataToPointData;
- TVTKSmartPtr<vtkAppendPolyData> myAppendPolyData;
- TVTKSmartPtr<vtkGeometryFilter> myGeometryFilter;
- TVTKSmartPtr<vtkContourFilter> myContourFilter;
- TVTKSmartPtr<vtkWarpScalar> myWarpScalar;
+ vtkSmartPointer<vtkCellDataToPointData> myCellDataToPointData;
+ vtkSmartPointer<vtkAppendPolyData> myAppendPolyData;
+ vtkSmartPointer<vtkGeometryFilter> myGeometryFilter;
+ vtkSmartPointer<vtkContourFilter> myContourFilter;
+ vtkSmartPointer<vtkWarpScalar> myWarpScalar;
};
#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_PointSpriteMapperHolder.cxx
+// Author: Alexey PETROV
+// Module : VISU
+
+
+#include "VISU_PointSpriteMapperHolder.hxx"
+#include "VISU_OpenGLPointSpriteMapper.hxx"
+
+#include "VISU_PipeLineUtils.hxx"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(VISU_PointSpriteMapperHolder);
+
+
+//----------------------------------------------------------------------------
+VISU_PointSpriteMapperHolder
+::VISU_PointSpriteMapperHolder()
+{
+ if(MYDEBUG)
+ MESSAGE("VISU_PointSpriteMapperHolder::VISU_PointSpriteMapperHolder - "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+VISU_PointSpriteMapperHolder
+::~VISU_PointSpriteMapperHolder()
+{
+ if(MYDEBUG)
+ MESSAGE("VISU_PointSpriteMapperHolder::~VISU_PointSpriteMapperHolder - "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PointSpriteMapperHolder
+::ShallowCopy(VISU_MapperHolder *theMapperHolder,
+ bool theIsCopyInput)
+{
+ if(VISU_PointSpriteMapperHolder* aMapperHolder = dynamic_cast<VISU_PointSpriteMapperHolder*>(theMapperHolder)){
+ if(theIsCopyInput)
+ SetGaussPtsIDMapper(aMapperHolder->GetGaussPtsIDMapper());
+
+ VISU::CopyPointSpriteDataMapper(GetPointSpriteMapper(),
+ aMapperHolder->GetPointSpriteMapper(),
+ theIsCopyInput);
+ }
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PointSpriteMapperHolder
+::SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theIDMapper)
+{
+ myGaussPtsIDMapper = theIDMapper;
+ SetPolyDataIDMapper(theIDMapper);
+}
+
+
+//----------------------------------------------------------------------------
+const VISU::PGaussPtsIDMapper&
+VISU_PointSpriteMapperHolder
+::GetGaussPtsIDMapper()
+{
+ return myGaussPtsIDMapper;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PointSpriteMapperHolder
+::OnCreateMapper()
+{
+ myPointSpriteMapper = VISU_OpenGLPointSpriteMapper::New();
+ myPointSpriteMapper->Delete();
+ myPointSpriteMapper->SetColorModeToMapScalars();
+ myPointSpriteMapper->ScalarVisibilityOn();
+ SetPolyDataMapper(myPointSpriteMapper.GetPointer());
+}
+
+
+//----------------------------------------------------------------------------
+VISU_OpenGLPointSpriteMapper*
+VISU_PointSpriteMapperHolder
+::GetPointSpriteMapper()
+{
+ GetMapper();
+ return myPointSpriteMapper.GetPointer();
+}
+
+
+//----------------------------------------------------------------------------
--- /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_PointSpriteMapperHolder.hxx
+// Author: Alexey PETROV
+// Module : VISU
+
+#ifndef VISU_PointSpriteMapperHolder_HeaderFile
+#define VISU_PointSpriteMapperHolder_HeaderFile
+
+#include "VISU_PolyDataMapperHolder.hxx"
+
+class VISU_OpenGLPointSpriteMapper;
+
+
+//----------------------------------------------------------------------------
+class VISU_PointSpriteMapperHolder : public VISU_PolyDataMapperHolder
+{
+public:
+ vtkTypeMacro(VISU_PointSpriteMapperHolder, VISU_PolyDataMapperHolder);
+
+ static
+ VISU_PointSpriteMapperHolder*
+ New();
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ ShallowCopy(VISU_MapperHolder *theMapperHolder,
+ bool theIsCopyInput);
+
+ //----------------------------------------------------------------------------
+ void
+ SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper);
+
+ const VISU::PGaussPtsIDMapper&
+ GetGaussPtsIDMapper();
+
+ virtual
+ VISU_OpenGLPointSpriteMapper*
+ GetPointSpriteMapper();
+
+protected:
+ //----------------------------------------------------------------------------
+ VISU_PointSpriteMapperHolder();
+ VISU_PointSpriteMapperHolder(const VISU_PointSpriteMapperHolder&);
+
+ virtual
+ ~VISU_PointSpriteMapperHolder();
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ OnCreateMapper();
+
+private:
+ //----------------------------------------------------------------------------
+ VISU::PGaussPtsIDMapper myGaussPtsIDMapper;
+ vtkSmartPointer<VISU_OpenGLPointSpriteMapper> myPointSpriteMapper;
+};
+
+#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_PolyDataMapperHolder.cxx
+// Author: Alexey PETROV
+// Module : VISU
+
+
+#include "VISU_PolyDataMapperHolder.hxx"
+#include "SALOME_ExtractPolyDataGeometry.h"
+#include "VISU_LookupTable.hxx"
+
+#include "VISU_PipeLineUtils.hxx"
+
+#include <vtkPolyDataMapper.h>
+#include <vtkPolyData.h>
+
+#include <vtkPlane.h>
+#include <vtkImplicitBoolean.h>
+#include <vtkImplicitFunction.h>
+#include <vtkImplicitFunctionCollection.h>
+#include <vtkMath.h>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(VISU_PolyDataMapperHolder);
+
+
+//----------------------------------------------------------------------------
+VISU_PolyDataMapperHolder
+::VISU_PolyDataMapperHolder():
+ myExtractPolyDataGeometry(SALOME_ExtractPolyDataGeometry::New())
+{
+ if(MYDEBUG) MESSAGE("VISU_PolyDataMapperHolder::VISU_PolyDataMapperHolder - "<<this);
+
+ // Clipping functionality
+ myExtractPolyDataGeometry->Delete();
+ myExtractPolyDataGeometry->SetStoreMapping(true);
+
+ vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New();
+ myExtractPolyDataGeometry->SetImplicitFunction(anImplicitBoolean);
+ anImplicitBoolean->SetOperationTypeToIntersection();
+ anImplicitBoolean->Delete();
+}
+
+
+//----------------------------------------------------------------------------
+VISU_PolyDataMapperHolder
+::~VISU_PolyDataMapperHolder()
+{
+ if(MYDEBUG)
+ MESSAGE("VISU_PolyDataMapperHolder::~VISU_PolyDataMapperHolder - "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataMapperHolder
+::ShallowCopy(VISU_MapperHolder *theMapperHolder,
+ bool theIsCopyInput)
+{
+ if(VISU_PolyDataMapperHolder* aMapperHolder = dynamic_cast<VISU_PolyDataMapperHolder*>(theMapperHolder)){
+ if(theIsCopyInput)
+ SetPolyDataIDMapper(aMapperHolder->GetPolyDataIDMapper());
+
+ VISU::CopyPolyDataMapper(GetPolyDataMapper(),
+ aMapperHolder->GetPolyDataMapper(),
+ theIsCopyInput);
+ }
+}
+
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_PolyDataMapperHolder
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ if(myExtractPolyDataGeometry->GetInput())
+ if(vtkDataSet* aDataSet = myExtractPolyDataGeometry->GetOutput())
+ aSize = aDataSet->GetActualMemorySize() * 1024;
+
+ return aSize;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataMapperHolder
+::SetPolyDataIDMapper(const VISU::PPolyDataIDMapper& theIDMapper)
+{
+ myExtractPolyDataGeometry->SetInput(theIDMapper->GetPolyDataOutput());
+ myPolyDataIDMapper = theIDMapper;
+ SetIDMapper(theIDMapper);
+}
+
+
+//----------------------------------------------------------------------------
+const VISU::PPolyDataIDMapper&
+VISU_PolyDataMapperHolder
+::GetPolyDataIDMapper()
+{
+ return myPolyDataIDMapper;
+}
+
+
+//----------------------------------------------------------------------------
+vtkPolyData*
+VISU_PolyDataMapperHolder
+::GetPolyDataInput()
+{
+ if(myPolyDataIDMapper)
+ return myPolyDataIDMapper->GetPolyDataOutput();
+
+ return NULL;
+}
+
+
+//----------------------------------------------------------------------------
+vtkPointSet*
+VISU_PolyDataMapperHolder
+::GetClippedInput()
+{
+ if(myExtractPolyDataGeometry->GetInput())
+ myExtractPolyDataGeometry->Update();
+ return myExtractPolyDataGeometry->GetOutput();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataMapperHolder
+::OnCreateMapper()
+{
+ myPolyDataMapper = vtkPolyDataMapper::New();
+ myPolyDataMapper->Delete();
+ SetMapper(myPolyDataMapper.GetPointer());
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataMapperHolder
+::SetPolyDataMapper(vtkPolyDataMapper* theMapper)
+{
+ myPolyDataMapper = theMapper;
+ SetMapper(myPolyDataMapper.GetPointer());
+}
+
+
+//----------------------------------------------------------------------------
+vtkPolyDataMapper*
+VISU_PolyDataMapperHolder
+::GetPolyDataMapper()
+{
+ GetMapper();
+ return myPolyDataMapper.GetPointer();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataMapperHolder
+::SetLookupTable(VISU_LookupTable* theLookupTable)
+{
+ myPolyDataMapper->SetLookupTable(theLookupTable);
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_PolyDataMapperHolder
+::GetNodeObjID(vtkIdType theID)
+{
+ vtkIdType anID = myExtractPolyDataGeometry->GetNodeObjId(theID);
+ return Superclass::GetNodeObjID(anID);
+}
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_PolyDataMapperHolder
+::GetNodeVTKID(vtkIdType theID)
+{
+ vtkIdType anID = Superclass::GetNodeVTKID(theID);
+ return myExtractPolyDataGeometry->GetNodeVTKId(anID);
+}
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType*
+VISU_PolyDataMapperHolder
+::GetNodeCoord(vtkIdType theObjID)
+{
+ return Superclass::GetNodeCoord(theObjID);
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_PolyDataMapperHolder
+::GetElemObjID(vtkIdType theID)
+{
+ vtkIdType anID = myExtractPolyDataGeometry->GetElemObjId(theID);
+ return Superclass::GetElemObjID(anID);
+}
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_PolyDataMapperHolder
+::GetElemVTKID(vtkIdType theID)
+{
+ vtkIdType anID = Superclass::GetElemVTKID(theID);
+ return myExtractPolyDataGeometry->GetElemVTKId(anID);
+}
+
+//----------------------------------------------------------------------------
+vtkCell*
+VISU_PolyDataMapperHolder
+::GetElemCell(vtkIdType theObjID)
+{
+ return Superclass::GetElemCell(theObjID);
+}
+
+
+//------------------------ Clipping planes -----------------------------------
+bool
+VISU_PolyDataMapperHolder
+::AddClippingPlane(vtkPlane* thePlane)
+{
+ if (thePlane) {
+ if (vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()) {
+ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+ aFunction->AddItem(thePlane);
+ // Check, that at least one cell present after clipping.
+ // This check was introduced because of bug IPAL8849.
+ vtkDataSet* aClippedDataSet = GetClippedInput();
+ if(aClippedDataSet->GetNumberOfCells() < 1)
+ return false;
+ }
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------------
+vtkPlane*
+VISU_PolyDataMapperHolder
+::GetClippingPlane(vtkIdType theID)
+{
+ vtkPlane* aPlane = NULL;
+ if(theID >= 0 && theID < GetNumberOfClippingPlanes()){
+ if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){
+ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+ vtkImplicitFunction* aFun = NULL;
+ aFunction->InitTraversal();
+ for(vtkIdType anID = 0; anID <= theID; anID++)
+ aFun = aFunction->GetNextItem();
+ aPlane = dynamic_cast<vtkPlane*>(aFun);
+ }
+ }
+ return aPlane;
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataMapperHolder
+::RemoveAllClippingPlanes()
+{
+ if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){
+ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+ aFunction->RemoveAllItems();
+ aBoolean->Modified(); // VTK bug
+ }
+}
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_PolyDataMapperHolder
+::GetNumberOfClippingPlanes()
+{
+ if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){
+ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+ return aFunction->GetNumberOfItems();
+ }
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataMapperHolder
+::SetImplicitFunction(vtkImplicitFunction *theFunction)
+{
+ myExtractPolyDataGeometry->SetImplicitFunction(theFunction);
+}
+
+//----------------------------------------------------------------------------
+vtkImplicitFunction*
+VISU_PolyDataMapperHolder
+::GetImplicitFunction()
+{
+ return myExtractPolyDataGeometry->GetImplicitFunction();
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataMapperHolder
+::SetExtractInside(bool theMode)
+{
+ myExtractPolyDataGeometry->SetExtractInside(theMode);
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataMapperHolder
+::SetExtractBoundaryCells(bool theMode)
+{
+ myExtractPolyDataGeometry->SetExtractBoundaryCells(theMode);
+}
+
+
+//----------------------------------------------------------------------------
--- /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_PolyDataMapperHolder.hxx
+// Author: Alexey PETROV
+// Module : VISU
+
+#ifndef VISU_PolyDataMapperHolder_HeaderFile
+#define VISU_PolyDataMapperHolder_HeaderFile
+
+#include "VISU_MapperHolder.hxx"
+
+class vtkPolyDataMapper;
+class vtkPolyData;
+class SALOME_ExtractPolyDataGeometry;
+
+
+//----------------------------------------------------------------------------
+class VISU_PolyDataMapperHolder : public VISU_MapperHolder
+{
+public:
+ vtkTypeMacro(VISU_PolyDataMapperHolder, VISU_MapperHolder);
+
+ static
+ VISU_PolyDataMapperHolder*
+ New();
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ ShallowCopy(VISU_MapperHolder *theMapperHolder,
+ bool theIsCopyInput);
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ //----------------------------------------------------------------------------
+ void
+ SetPolyDataIDMapper(const VISU::PPolyDataIDMapper& theIDMapper);
+
+ const VISU::PPolyDataIDMapper&
+ GetPolyDataIDMapper();
+
+ virtual
+ vtkPolyData*
+ GetPolyDataInput();
+
+ virtual
+ vtkPolyDataMapper*
+ GetPolyDataMapper();
+
+ //----------------------------------------------------------------------------
+ virtual
+ vtkIdType
+ GetNodeObjID(vtkIdType theID);
+
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID);
+
+ virtual
+ vtkFloatingPointType*
+ GetNodeCoord(vtkIdType theObjID);
+
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID);
+
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID);
+
+ virtual
+ vtkCell*
+ GetElemCell(vtkIdType theObjID);
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ SetImplicitFunction(vtkImplicitFunction *theFunction);
+
+ virtual
+ vtkImplicitFunction*
+ GetImplicitFunction();
+
+ virtual
+ void
+ SetExtractInside(bool theMode);
+
+ virtual
+ void
+ SetExtractBoundaryCells(bool theMode);
+
+ //----------------------------------------------------------------------------
+ // Clipping planes
+ virtual
+ void
+ RemoveAllClippingPlanes();
+
+ virtual
+ vtkIdType
+ GetNumberOfClippingPlanes();
+
+ virtual
+ bool
+ AddClippingPlane(vtkPlane* thePlane);
+
+ virtual
+ vtkPlane*
+ GetClippingPlane(vtkIdType theID);
+
+protected:
+ //----------------------------------------------------------------------------
+ VISU_PolyDataMapperHolder();
+ VISU_PolyDataMapperHolder(const VISU_PolyDataMapperHolder&);
+
+ virtual
+ ~VISU_PolyDataMapperHolder();
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ OnCreateMapper();
+
+ void
+ SetPolyDataMapper(vtkPolyDataMapper* theMapper);
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ SetLookupTable(VISU_LookupTable* theLookupTable);
+
+ virtual
+ vtkPointSet*
+ GetClippedInput();
+
+private:
+ //----------------------------------------------------------------------------
+ VISU::PPolyDataIDMapper myPolyDataIDMapper;
+ vtkSmartPointer<vtkPolyDataMapper> myPolyDataMapper;
+ vtkSmartPointer<SALOME_ExtractPolyDataGeometry> myExtractPolyDataGeometry; //!< Clipping
+};
+
+#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_PolyDataPL.cxx
+// Author: Alexey PETROV
+// Module : VISU
+
+
+#include "VISU_PolyDataPL.hxx"
+#include "SALOME_ExtractPolyDataGeometry.h"
+
+#include "VISU_PipeLineUtils.hxx"
+
+#include <float.h>
+#include <algorithm>
+
+#include <vtkPolyDataMapper.h>
+#include <vtkPolyData.h>
+
+#include <vtkPlane.h>
+#include <vtkImplicitBoolean.h>
+#include <vtkImplicitFunction.h>
+#include <vtkImplicitFunctionCollection.h>
+#include <vtkMath.h>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//----------------------------------------------------------------------------
+VISU_PolyDataPL
+::VISU_PolyDataPL():
+ myExtractPolyDataGeometry(SALOME_ExtractPolyDataGeometry::New())
+{
+ if(MYDEBUG) MESSAGE("VISU_PolyDataPL::VISU_PolyDataPL - "<<this);
+
+ // Clipping functionality
+ myExtractPolyDataGeometry->Delete();
+ myExtractPolyDataGeometry->SetStoreMapping(true);
+
+ vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New();
+ myExtractPolyDataGeometry->SetImplicitFunction(anImplicitBoolean);
+ anImplicitBoolean->SetOperationTypeToIntersection();
+ anImplicitBoolean->Delete();
+}
+
+
+//----------------------------------------------------------------------------
+VISU_PolyDataPL
+::~VISU_PolyDataPL()
+{
+ if(MYDEBUG)
+ MESSAGE("VISU_PolyDataPL::~VISU_PolyDataPL - "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataPL
+::SetPolyDataIDMapper(const VISU::PPolyDataIDMapper& theIDMapper)
+{
+ myExtractPolyDataGeometry->SetInput(theIDMapper->GetPolyDataOutput());
+ myPolyDataIDMapper = theIDMapper;
+ SetIDMapper(theIDMapper);
+}
+
+
+//----------------------------------------------------------------------------
+const VISU::PPolyDataIDMapper&
+VISU_PolyDataPL
+::GetPolyDataIDMapper() const
+{
+ return myPolyDataIDMapper;
+}
+
+
+//----------------------------------------------------------------------------
+vtkPolyData*
+VISU_PolyDataPL
+::GetPolyDataInput()
+{
+ if(myPolyDataIDMapper)
+ return myPolyDataIDMapper->GetPolyDataOutput();
+
+ return NULL;
+}
+
+
+//----------------------------------------------------------------------------
+vtkPointSet*
+VISU_PolyDataPL
+::GetClippedInput() const
+{
+ vtkPolyData* aDataSet = myExtractPolyDataGeometry->GetOutput();
+ aDataSet->Update();
+ return aDataSet;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataPL
+::OnCreateMapper()
+{
+ myPolyDataMapper = vtkPolyDataMapper::New();
+ myPolyDataMapper->Delete();
+ SetMapper(myPolyDataMapper.GetPointer());
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataPL
+::SetPolyDataMapper(vtkPolyDataMapper* theMapper)
+{
+ myPolyDataMapper = theMapper;
+ SetMapper(theMapper);
+}
+
+
+//----------------------------------------------------------------------------
+vtkPolyDataMapper*
+VISU_PolyDataPL
+::GetPolyDataMapper()
+{
+ return myPolyDataMapper.GetPointer();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataPL
+::DoCopyMapper(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput)
+{
+ if(VISU_PolyDataPL* aPipeLine = dynamic_cast<VISU_PolyDataPL*>(thePipeLine)){
+ if(theIsCopyInput)
+ SetPolyDataIDMapper(aPipeLine->GetPolyDataIDMapper());
+ Update();
+ VISU::CopyPolyDataMapper(GetPolyDataMapper(),
+ aPipeLine->GetPolyDataMapper(),
+ theIsCopyInput);
+ }
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataPL
+::SetLookupTable(VISU_LookupTable* theLookupTable)
+{
+ myPolyDataMapper->SetLookupTable(theLookupTable);
+}
+
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_PolyDataPL
+::GetMemorySize()
+{
+ unsigned long int aSize = 0;
+ if(myExtractPolyDataGeometry->GetInput())
+ if(vtkDataSet* aDataSet = myExtractPolyDataGeometry->GetOutput())
+ aSize = aDataSet->GetActualMemorySize() * 1024;
+
+ aSize += Superclass::GetMemorySize();
+
+ return aSize;
+}
+
+
+//------------------------ Clipping planes -----------------------------------
+bool
+VISU_PolyDataPL
+::AddClippingPlane(vtkPlane* thePlane)
+{
+ if (thePlane) {
+ if (vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()) {
+ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+ aFunction->AddItem(thePlane);
+ // Check, that at least one cell present after clipping.
+ // This check was introduced because of bug IPAL8849.
+ vtkDataSet* aClippedDataSet = GetClippedInput();
+ if(aClippedDataSet->GetNumberOfCells() < 1)
+ return false;
+ }
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------------
+vtkPlane*
+VISU_PolyDataPL
+::GetClippingPlane(vtkIdType theID) const
+{
+ vtkPlane* aPlane = NULL;
+ if(theID >= 0 && theID < GetNumberOfClippingPlanes()){
+ if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){
+ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+ vtkImplicitFunction* aFun = NULL;
+ aFunction->InitTraversal();
+ for(vtkIdType anID = 0; anID <= theID; anID++)
+ aFun = aFunction->GetNextItem();
+ aPlane = dynamic_cast<vtkPlane*>(aFun);
+ }
+ }
+ return aPlane;
+}
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataPL
+::RemoveAllClippingPlanes()
+{
+ if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){
+ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+ aFunction->RemoveAllItems();
+ aBoolean->Modified(); // VTK bug
+ }
+}
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_PolyDataPL
+::GetNumberOfClippingPlanes() const
+{
+ if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){
+ vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction();
+ return aFunction->GetNumberOfItems();
+ }
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_PolyDataPL
+::GetNodeObjID(vtkIdType theID)
+{
+ vtkIdType anID = myExtractPolyDataGeometry->GetNodeObjId(theID);
+ return Superclass::GetNodeObjID(anID);
+}
+
+vtkIdType
+VISU_PolyDataPL
+::GetNodeVTKID(vtkIdType theID)
+{
+ vtkIdType anID = Superclass::GetNodeVTKID(theID);
+ return myExtractPolyDataGeometry->GetNodeVTKId(anID);
+}
+
+vtkFloatingPointType*
+VISU_PolyDataPL
+::GetNodeCoord(int theObjID)
+{
+ return Superclass::GetNodeCoord(theObjID);
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType
+VISU_PolyDataPL
+::GetElemObjID(vtkIdType theID)
+{
+ vtkIdType anID = myExtractPolyDataGeometry->GetElemObjId(theID);
+ return Superclass::GetElemObjID(anID);
+}
+
+vtkIdType
+VISU_PolyDataPL
+::GetElemVTKID(vtkIdType theID)
+{
+ vtkIdType anID = Superclass::GetElemVTKID(theID);
+ return myExtractPolyDataGeometry->GetElemVTKId(anID);
+}
+
+vtkCell*
+VISU_PolyDataPL
+::GetElemCell(vtkIdType theObjID)
+{
+ return Superclass::GetElemCell(theObjID);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_PolyDataPL
+::SetImplicitFunction(vtkImplicitFunction *theFunction)
+{
+ myExtractPolyDataGeometry->SetImplicitFunction(theFunction);
+}
+
+vtkImplicitFunction *
+VISU_PolyDataPL
+::GetImplicitFunction()
+{
+ return myExtractPolyDataGeometry->GetImplicitFunction();
+}
+
+SALOME_ExtractPolyDataGeometry*
+VISU_PolyDataPL
+::GetExtractPolyDataGeometryFilter()
+{
+ return myExtractPolyDataGeometry.GetPointer();
+}
+
+
+//----------------------------------------------------------------------------
--- /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_UnstructuredGripPL.hxx
+// Author: Alexey PETROV
+// Module : VISU
+
+#ifndef VISU_PolyDataPL_HeaderFile
+#define VISU_PolyDataPL_HeaderFile
+
+#include "VISU_ColoredPL.hxx"
+
+class vtkPolyDataMapper;
+class vtkPolyData;
+class SALOME_ExtractPolyDataGeometry;
+
+
+//----------------------------------------------------------------------------
+class VISU_PolyDataPL : public VISU_ColoredPL
+{
+public:
+ vtkTypeMacro(VISU_PolyDataPL, VISU_ColoredPL);
+
+ //----------------------------------------------------------------------------
+ virtual
+ vtkPolyDataMapper*
+ GetPolyDataMapper();
+
+ virtual
+ vtkPolyData*
+ GetPolyDataInput();
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ SetImplicitFunction(vtkImplicitFunction *theFunction);
+
+ virtual
+ vtkImplicitFunction*
+ GetImplicitFunction();
+
+ virtual
+ SALOME_ExtractPolyDataGeometry*
+ GetExtractPolyDataGeometryFilter();
+
+ //----------------------------------------------------------------------------
+ // Clipping planes
+ virtual
+ void
+ RemoveAllClippingPlanes();
+
+ virtual
+ vtkIdType
+ GetNumberOfClippingPlanes() const;
+
+ virtual
+ bool
+ AddClippingPlane(vtkPlane* thePlane);
+
+ virtual
+ vtkPlane*
+ GetClippingPlane(vtkIdType theID) const;
+
+ //----------------------------------------------------------------------------
+ virtual
+ vtkIdType
+ GetNodeObjID(vtkIdType theID);
+
+ virtual
+ vtkIdType
+ GetNodeVTKID(vtkIdType theID);
+
+ virtual
+ vtkFloatingPointType*
+ GetNodeCoord(vtkIdType theObjID);
+
+ virtual
+ vtkIdType
+ GetElemObjID(vtkIdType theID);
+
+ virtual
+ vtkIdType
+ GetElemVTKID(vtkIdType theID);
+
+ virtual
+ vtkCell*
+ GetElemCell(vtkIdType theObjID);
+
+ //----------------------------------------------------------------------------
+ void
+ SetPolyDataIDMapper(const VISU::PPolyDataIDMapper& theIDMapper);
+
+ const VISU::PPolyDataIDMapper&
+ GetPolyDataIDMapper() const;
+
+protected:
+ VISU_PolyDataPL();
+ VISU_PolyDataPL(const VISU_PolyDataPL&);
+
+ virtual
+ ~VISU_PolyDataPL();
+
+ virtual
+ void
+ DoCopyMapper(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
+
+ virtual
+ void
+ OnCreateMapper();
+
+ void
+ SetPolyDataMapper(vtkPolyDataMapper* theMapper);
+
+ virtual
+ void
+ SetLookupTable(VISU_LookupTable* theLookupTable);
+
+ virtual
+ vtkPointSet*
+ GetClippedInput() const;
+
+private:
+ VISU::PPolyDataIDMapper myPolyDataIDMapper;
+ vtkSmartPointer<vtkPolyDataMapper> myPolyDataMapper;
+ vtkSmartPointer<SALOME_ExtractPolyDataGeometry> myExtractPolyDataGeometry; //!< Clipping
+};
+
+#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_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
// Module : VISU
#include "VISU_ScalarMapOnDeformedShapePL.hxx"
+#include "VISU_FieldTransform.hxx"
+#include "VISU_Extractor.hxx"
+#include "VISU_LookupTable.hxx"
#include "VISU_DeformedShapePL.hxx"
-#include "VISU_MergeFilter.hxx"
-
-#include "VISU_PipeLineUtils.hxx"
#include "VTKViewer_TransformFilter.h"
#include "VTKViewer_Transform.h"
#include "VISU_MergeFilter.hxx"
+#include "VISU_PipeLineUtils.hxx"
+
#include <vtkWarpVector.h>
#include <vtkUnstructuredGrid.h>
#include <vtkCellDataToPointData.h>
#include <vtkPointDataToCellData.h>
-#include "VISU_Convertor.hxx"
-#include "VISU_ConvertorUtils.hxx"
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_ScalarMapOnDeformedShapePL)
+//----------------------------------------------------------------------------
/*!
* Constructor. Creating new instances of vtkWarpVector,vtkMergeFilter,vtkUnstructuredGrid
* Where:
* \li myDeformVectors is vtkWarpVector - deformation vectors data
- * \li myMergeFilter is vtkMergeFilter - merge filter.
+ * \li myScalarsMergeFilter is vtkMergeFilter - merge filter.
* Merge filter which unify the deformation and scalars
* \li myScalars is vtk shared pointer to vtkUnstructuredGrid - scalars data
*/
VISU_ScalarMapOnDeformedShapePL
-::VISU_ScalarMapOnDeformedShapePL()
+::VISU_ScalarMapOnDeformedShapePL():
+ myScaleFactor(0.0)
{
- myDeformVectors = vtkWarpVector::New();
- myMergeFilter = VISU_MergeFilter::New();
- myExtractorScalars = VISU_Extractor::New();
+ myWarpVector = vtkWarpVector::New();
+
+ myScalarsMergeFilter = VISU_MergeFilter::New();
+ myScalarsMergeFilter->SetMergingInputs(true);
+
+ myScalarsExtractor = VISU_Extractor::New();
+
+ myScalarsFieldTransform = VISU_FieldTransform::New();
+
myCellDataToPointData = vtkCellDataToPointData::New();
}
+//----------------------------------------------------------------------------
/*!
* Destructor.
* Delete all fields.
VISU_ScalarMapOnDeformedShapePL
::~VISU_ScalarMapOnDeformedShapePL()
{
- // commented: porting to vtk5.0
- // myDeformVectors->UnRegisterAllOutputs();
- myDeformVectors->Delete();
+ myWarpVector->Delete();
- // commented: porting to vtk5.0
- // myMergeFilter->UnRegisterAllOutputs();
- myMergeFilter->Delete();
+ myScalarsMergeFilter->Delete();
- // commented: porting to vtk5.0
- // myExtractorScalars->UnRegisterAllOutputs();
- myExtractorScalars->Delete();
+ myScalarsExtractor->Delete();
+
+ myScalarsFieldTransform->Delete();
- // commented: porting to vtk5.0
- // myCellDataToPointData->UnRegisterAllOutputs();
myCellDataToPointData->Delete();
}
+//----------------------------------------------------------------------------
/*!
* Initial method
*/
VISU_ScalarMapOnDeformedShapePL
::Init()
{
- if (GetScalarsUnstructuredGrid() == NULL) SetScalars(GetInput2());
-
Superclass::Init();
- vtkFloatingPointType aScalarRange[2];
- GetSourceRange(aScalarRange);
- static double EPS = 1.0 / VTK_LARGE_FLOAT;
- if(aScalarRange[1] > EPS)
- SetScale(VISU_DeformedShapePL::GetScaleFactor(GetInput2())/aScalarRange[1]);
- else
- SetScale(0.0);
-
- myMapper->SetColorModeToMapScalars();
- myMapper->ScalarVisibilityOn();
-
- // Sets input for field transformation filter
- myFieldTransform->SetInput(myExtractor->GetOutput());
-
+ SetScale(VISU_DeformedShapePL::GetDefaultScale(this));
}
+//----------------------------------------------------------------------------
/*!
* Build method
* Building of deformation and puts result to merge filter.
VISU_ScalarMapOnDeformedShapePL
::Build()
{
- // Set input for extractor
- myExtractor->SetInput(GetInput2());
-
- VISU::CellDataToPoint(myDeformVectors,myCellDataToPointData,
- GetInput2(),myFieldTransform);
+ Superclass::Build();
+}
+
+
+//----------------------------------------------------------------------------
+vtkDataSet*
+VISU_ScalarMapOnDeformedShapePL
+::InsertCustomPL()
+{
+ GetMapper()->SetColorModeToMapScalars();
+ GetMapper()->ScalarVisibilityOn();
+
+ VISU::CellDataToPoint(myWarpVector,
+ myCellDataToPointData,
+ GetMergedInput());
+ myScalars = GetMergedInput();
+
+ UpdateScalars();
+
+ myScalarsFieldTransform->SetInput(myScalarsExtractor->GetOutput());
+
// Sets geometry for merge filter
- myMergeFilter->SetGeometry(myDeformVectors->GetUnstructuredGridOutput());
- myMergeFilter->SetScalars(myExtractorScalars->GetOutput());
- myMergeFilter->AddField("VISU_CELLS_MAPPER", myExtractorScalars->GetOutput());
- myMergeFilter->Update();
+ myScalarsMergeFilter->SetGeometry(myWarpVector->GetUnstructuredGridOutput());
+
+ vtkDataSet* aScalarsDataSet = myScalarsFieldTransform->GetOutput();
+ myScalarsMergeFilter->SetScalars(aScalarsDataSet);
+ myScalarsMergeFilter->AddField("VISU_CELLS_MAPPER", aScalarsDataSet);
+ myScalarsMergeFilter->AddField("VISU_POINTS_MAPPER", aScalarsDataSet);
- // Sets data to mapper
- myMapper->SetInput(myMergeFilter->GetOutput());
+ return myScalarsMergeFilter->GetOutput();
}
+
+//----------------------------------------------------------------------------
/*!
* Update method
*/
VISU_ScalarMapOnDeformedShapePL
::Update()
{
- this->UpdateScalars();
-
- vtkFloatingPointType* aRange = GetScalarRange();
- vtkFloatingPointType aScalarRange[2] = {aRange[0], aRange[1]};
-
- if(myBarTable->GetScale() == VTK_SCALE_LOG10)
- VISU_LookupTable::ComputeLogRange(aRange,aScalarRange);
- myMapperTable->SetRange(aScalarRange);
+ Superclass::Update();
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myScalarsExtractor.vtk";
+ // VISU::WriteToFile(myScalarsExtractor->GetUnstructuredGridOutput(), aFileName);
+ //}
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myWarpVector.vtk";
+ // VISU::WriteToFile(myWarpVector->GetUnstructuredGridOutput(), aFileName);
+ //}
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myScalarsMergeFilter.vtk";
+ // VISU::WriteToFile(myScalarsMergeFilter->GetUnstructuredGridOutput(), aFileName);
+ //}
+}
- myMapperTable->Build();
- myBarTable->Build();
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_ScalarMapOnDeformedShapePL
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
- myMapper->SetLookupTable(myMapperTable);
- myMapper->SetScalarRange(aScalarRange);
+ if(vtkDataSet* aDataSet = myWarpVector->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
- VISU_PipeLine::Update();
+ if(vtkDataSet* aDataSet = myScalarsExtractor->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(vtkDataSet* aDataSet = myScalarsMergeFilter->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(myCellDataToPointData->GetInput())
+ if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ return aSize;
}
+//----------------------------------------------------------------------------
/*!
* Update scalars method.
* Put scalars to merge filter.
VISU_ScalarMapOnDeformedShapePL
::UpdateScalars()
{
- myExtractorScalars->Update();
+ vtkDataSet* aScalars = GetScalars();
+ myScalarsExtractor->SetInput(aScalars);
+
+ if(VISU::IsDataOnCells(aScalars))
+ GetMapper()->SetScalarModeToUseCellData();
+ else
+ GetMapper()->SetScalarModeToUsePointData();
}
+//----------------------------------------------------------------------------
/*!
* Copy information about pipline.
* Copy scale and scalars.
*/
void
VISU_ScalarMapOnDeformedShapePL
-::ShallowCopy(VISU_PipeLine *thePipeLine)
+::DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput)
{
- VISU_ScalarMapOnDeformedShapePL *aPipeLine = dynamic_cast<VISU_ScalarMapOnDeformedShapePL*>(thePipeLine);
- if(aPipeLine){
+ Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
+
+ if(VISU_ScalarMapOnDeformedShapePL *aPipeLine = dynamic_cast<VISU_ScalarMapOnDeformedShapePL*>(thePipeLine)){
SetScale(aPipeLine->GetScale());
- SetScalars(aPipeLine->GetScalarsUnstructuredGrid());
+ SetScalars(aPipeLine->GetScalars());
}
- Superclass::ShallowCopy(thePipeLine);
}
+//----------------------------------------------------------------------------
/*!
* Set scalars.
* Sets vtkDataSet with scalars values to VISU_Extractor filter for scalars extraction.
VISU_ScalarMapOnDeformedShapePL
::SetScalars(vtkDataSet *theScalars)
{
+ if(GetScalars() == theScalars)
+ return;
+
myScalars = theScalars;
- vtkUnstructuredGrid* aScalars = GetScalarsUnstructuredGrid();
- vtkCellData *aInCellData = GetInput()->GetCellData();
-
- std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-SetScalars.vtk";
- VISU::WriteToFile(aScalars, aFileName);
- if(aScalars->GetPointData()->GetScalars())
- myExtractorScalars->SetInput(aScalars);
- else if(aScalars->GetCellData()->GetScalars() &&
- !aInCellData->GetAttribute(vtkDataSetAttributes::VECTORS)){
- //Approximate cell data values to point data by vtkCellDataToPointData filter.
- vtkCellDataToPointData* aCellDataToPointData = vtkCellDataToPointData::New();
- aCellDataToPointData->SetInput(aScalars);
- aCellDataToPointData->Update();
- myExtractorScalars->SetInput(aCellDataToPointData->GetUnstructuredGridOutput());
- aCellDataToPointData->Delete();
- } else {
- myExtractorScalars->SetInput(aScalars);
- }
- Update();
- Modified();
+ UpdateScalars();
}
+//----------------------------------------------------------------------------
/*!
* Get pointer to input scalars.
*/
-vtkUnstructuredGrid*
+vtkDataSet*
VISU_ScalarMapOnDeformedShapePL
-::GetScalarsUnstructuredGrid()
+::GetScalars()
{
return myScalars.GetPointer();
}
+//----------------------------------------------------------------------------
/*!
* Sets scale for deformed shape
*/
VISU_ScalarMapOnDeformedShapePL
::SetScale(vtkFloatingPointType theScale)
{
- if(myScaleFactor == theScale) return;
+ if(VISU::CheckIsSameValue(myScaleFactor, theScale))
+ return;
+
+ myWarpVector->SetScaleFactor(theScale);
myScaleFactor = theScale;
- myDeformVectors->SetScaleFactor(myScaleFactor);
- Modified();
}
+//----------------------------------------------------------------------------
/*!
* Gets scale of deformed shape.
*/
VISU_ScalarMapOnDeformedShapePL
::GetScale()
{
- return myScaleFactor;
+ return myWarpVector->GetScaleFactor();
}
+//----------------------------------------------------------------------------
/*!
* Set scale factor of deformation.
*/
VISU_ScalarMapOnDeformedShapePL
::SetMapScale(vtkFloatingPointType theMapScale)
{
- TSupperClass::SetMapScale(theMapScale); // enk::added
- myDeformVectors->SetScaleFactor(myScaleFactor*theMapScale);
- Modified();
+ Superclass::SetMapScale(theMapScale);
+ myWarpVector->SetScaleFactor(myScaleFactor*theMapScale);
}
+//----------------------------------------------------------------------------
/*!
* Gets scalar mode.
*/
VISU_ScalarMapOnDeformedShapePL
::GetScalarMode()
{
- int aMode=myExtractorScalars->GetScalarMode();
- return aMode;
+ return myScalarsExtractor->GetScalarMode();
}
+//----------------------------------------------------------------------------
/*!
* Sets scalar mode.
*/
VISU_ScalarMapOnDeformedShapePL
::SetScalarMode(int theScalarMode)
{
- myExtractorScalars->SetScalarMode(theScalarMode);
- Modified();
+ VISU_ScalarMapPL::SetScalarMode(theScalarMode, GetScalars(), myScalarsExtractor);
}
+//----------------------------------------------------------------------------
+void
+VISU_ScalarMapOnDeformedShapePL
+::SetScaling(int theScaling)
+{
+ if(GetScaling() == theScaling)
+ return;
+
+ GetBarTable()->SetScale(theScaling);
+
+ if(theScaling == VTK_SCALE_LOG10)
+ myScalarsFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Log10));
+ else
+ myScalarsFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Ident));
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_ScalarMapOnDeformedShapePL
+::SetScalarRange(vtkFloatingPointType theRange[2])
+{
+ if(VISU::CheckIsSameRange(theRange, GetScalarRange()))
+ return;
+
+ myScalarsFieldTransform->SetScalarRange(theRange);
+ GetBarTable()->SetRange(theRange);
+}
+
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType*
+VISU_ScalarMapOnDeformedShapePL
+::GetScalarRange()
+{
+ return myScalarsFieldTransform->GetScalarRange();
+}
+
+
+//----------------------------------------------------------------------------
/*!
* Gets ranges of extracted scalars
* \param theRange[2] - output values
VISU_ScalarMapOnDeformedShapePL
::GetSourceRange(vtkFloatingPointType theRange[2])
{
- myExtractorScalars->Update();
- myExtractorScalars->GetUnstructuredGridOutput()->GetScalarRange(theRange);
+ myScalarsExtractor->Update();
+ myScalarsExtractor->GetUnstructuredGridOutput()->GetScalarRange(theRange);
}
#define VISU_ScalarMapOnDeformedShapePL_HeaderFile
#include "VISUPipeline.hxx"
-#include "VISU_PrsMergerPL.hxx"
+#include "VISU_ScalarMapPL.hxx"
class VISU_MergeFilter;
class vtkWarpVector;
class vtkCellDataToPointData;
class vtkPointDataToCellData;
-class VISU_PIPELINE_EXPORT VISU_ScalarMapOnDeformedShapePL : public VISU_PrsMergerPL
-{
-
- typedef VISU_PrsMergerPL TSupperClass;
-protected:
- VISU_ScalarMapOnDeformedShapePL();
-
- virtual ~VISU_ScalarMapOnDeformedShapePL();
-
- VISU_ScalarMapOnDeformedShapePL(const VISU_ScalarMapOnDeformedShapePL&);
+//----------------------------------------------------------------------------
+class VISU_PIPELINE_EXPORT VISU_ScalarMapOnDeformedShapePL : public VISU_ScalarMapPL
+{
public:
- vtkTypeMacro(VISU_ScalarMapOnDeformedShapePL,VISU_PrsMergerPL);
+ vtkTypeMacro(VISU_ScalarMapOnDeformedShapePL, VISU_ScalarMapPL);
+
+ static
+ VISU_ScalarMapOnDeformedShapePL*
+ New();
+
+ virtual
+ void
+ SetScale(vtkFloatingPointType theScale);
+
+ virtual
+ vtkFloatingPointType
+ GetScale();
- static VISU_ScalarMapOnDeformedShapePL* New();
+ virtual
+ int
+ GetScalarMode();
- virtual void ShallowCopy(VISU_PipeLine *thePipeLine);
+ virtual
+ void
+ SetScalarMode(int theScalarMode = 0);
+
+ virtual
+ void
+ SetScaling(int theScaling);
+
+ virtual
+ void
+ SetScalarRange(vtkFloatingPointType theRange[2]);
- virtual void SetScale(vtkFloatingPointType theScale);
- virtual vtkFloatingPointType GetScale();
+ virtual
+ vtkFloatingPointType*
+ GetScalarRange();
- virtual int GetScalarMode();
- virtual void SetScalarMode(int theScalarMode = 0);
+ virtual
+ void
+ GetSourceRange(vtkFloatingPointType theRange[2]);
- virtual void GetSourceRange(vtkFloatingPointType theRange[2]);
+ virtual
+ void
+ SetScalars(vtkDataSet *theScalars);
- virtual void SetScalars(vtkDataSet *theScalars);
- virtual vtkUnstructuredGrid* GetScalarsUnstructuredGrid();
+ virtual
+ vtkDataSet*
+ GetScalars();
public:
//! Redefined method for initialization of the pipeline.
void
Update();
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
//! Update scalars.
void
UpdateScalars();
- virtual void SetMapScale(vtkFloatingPointType theMapScale = 1.0);
+ virtual
+ void
+ SetMapScale(vtkFloatingPointType theMapScale = 1.0);
protected:
+ VISU_ScalarMapOnDeformedShapePL();
+
+ virtual
+ ~VISU_ScalarMapOnDeformedShapePL();
+
+ virtual
+ vtkDataSet*
+ InsertCustomPL();
+
+ virtual
+ void
+ DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
+
+private:
+ VISU_ScalarMapOnDeformedShapePL(const VISU_ScalarMapOnDeformedShapePL&);
+
vtkFloatingPointType myScaleFactor;
- vtkWarpVector *myDeformVectors;
- VISU_MergeFilter *myMergeFilter;
+ vtkWarpVector *myWarpVector;
+ VISU_MergeFilter *myScalarsMergeFilter;
vtkSmartPointer<vtkUnstructuredGrid> myScalars;
- VISU_Extractor* myExtractorScalars;
vtkCellDataToPointData* myCellDataToPointData;
+ VISU_FieldTransform* myScalarsFieldTransform;
+ VISU_Extractor* myScalarsExtractor;
};
#endif
//
//
//
-// File: VISU_PipeLine.cxx
+// File: VISU_ScalarMapPL.cxx
// Author: Alexey PETROV
// Module : VISU
#include "VISU_ScalarMapPL.hxx"
-#include "VISU_PipeLineUtils.hxx"
-#include "SALOME_ExtractGeometry.h"
+#include "VISU_DataSetMapperHolder.hxx"
+#include "VISU_FieldTransform.hxx"
+#include "VISU_AppendFilter.hxx"
+#include "VISU_MergeFilter.hxx"
+#include "VISU_ConvertorUtils.hxx"
-//============================================================================
+#include <vtkDataSet.h>
+#include <vtkPointSet.h>
+#include <vtkUnstructuredGrid.h>
+
+#include <vtkDataSetMapper.h>
+#include <vtkObjectFactory.h>
+
+
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_ScalarMapPL);
//----------------------------------------------------------------------------
VISU_ScalarMapPL
-::VISU_ScalarMapPL()
+::VISU_ScalarMapPL():
+ VISU_UnstructuredGridPL(this),
+ myAppendFilter(VISU_AppendFilter::New()),
+ myMergeFilter(VISU_MergeFilter::New())
{
- myMapperTable = VISU_LookupTable::New();
- myMapperTable->SetScale(VTK_SCALE_LINEAR);
- myMapperTable->SetHueRange(0.667,0.0);
-
- myBarTable = VISU_LookupTable::New();
- myBarTable->SetScale(VTK_SCALE_LINEAR);
- myBarTable->SetHueRange(0.667,0.0);
+ SetIsShrinkable(true);
- myExtractor = VISU_Extractor::New();
- myExtractor->SetInput(myExtractGeometry->GetOutput());
+ myAppendFilter->SetMergingInputs(true);
+ myAppendFilter->Delete();
- myFieldTransform = VISU_FieldTransform::New();
- myFieldTransform->SetInput(myExtractor->GetOutput());
-
- myIsShrinkable = true;
+ myMergeFilter->SetMergingInputs(true);
+ myMergeFilter->Delete();
}
+//----------------------------------------------------------------------------
VISU_ScalarMapPL
::~VISU_ScalarMapPL()
-{
- myFieldTransform->Delete();
- myMapperTable->Delete();
- myBarTable->Delete();
- myExtractor->Delete();
-}
+{}
//----------------------------------------------------------------------------
-void
+void
VISU_ScalarMapPL
-::ShallowCopy(VISU_PipeLine *thePipeLine)
+::OnCreateMapperHolder()
{
- if(VISU_ScalarMapPL *aPipeLine = dynamic_cast<VISU_ScalarMapPL*>(thePipeLine)){
- SetScalarRange(aPipeLine->GetScalarRange());
- SetScalarMode(aPipeLine->GetScalarMode());
- SetNbColors(aPipeLine->GetNbColors());
- SetScaling(aPipeLine->GetScaling());
- SetMapScale(aPipeLine->GetMapScale());
- }
- Superclass::ShallowCopy(thePipeLine);
+ VISU_UnstructuredGridPL::OnCreateMapperHolder();
}
//----------------------------------------------------------------------------
-int
-VISU_ScalarMapPL
-::GetScalarMode()
-{
- return myExtractor->GetScalarMode();
-}
-
void
VISU_ScalarMapPL
-::SetScalarMode(int theScalarMode)
+::Build()
{
- vtkDataSet *anInput = GetInput();
- if(anInput){
- if(VISU::IsDataOnPoints(anInput)){
- vtkPointData *inData = anInput->GetPointData();
- if(!inData->GetAttribute(vtkDataSetAttributes::VECTORS)) {
- if (theScalarMode==0){
- return;
- }
- }
- }
- else {
- vtkCellData *inData = anInput->GetCellData();
- if(!inData->GetAttribute(vtkDataSetAttributes::VECTORS)){
- if (theScalarMode==0){
- return;
- }
- }
- }
- }
- //
- myExtractor->SetScalarMode(theScalarMode);
- Modified();
-}
+ Superclass::Build();
+ SetSourceGeometry();
-//----------------------------------------------------------------------------
-int
-VISU_ScalarMapPL
-::GetScaling()
-{
- return myBarTable->GetScale();
-}
+ vtkPointSet* aDataSet = GetClippedInput();
+ myAppendFilter->SetSharedPointSet(aDataSet);
-void
-VISU_ScalarMapPL
-::SetScaling(int theScaling)
-{
- myBarTable->SetScale(theScaling);
- if(theScaling == VTK_SCALE_LOG10)
- myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Log10));
- else
- myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Ident));
- Modified();
-}
+ myMergeFilter->SetGeometry(myAppendFilter->GetOutput());
+ myMergeFilter->SetScalars(aDataSet);
+ myMergeFilter->SetVectors(aDataSet);
+ myMergeFilter->RemoveFields();
+ myMergeFilter->AddField("VISU_FIELD", aDataSet);
+ myMergeFilter->AddField("VISU_CELLS_MAPPER", aDataSet);
+ myMergeFilter->AddField("VISU_POINTS_MAPPER", aDataSet);
-//----------------------------------------------------------------------------
-vtkFloatingPointType*
-VISU_ScalarMapPL
-::GetScalarRange()
-{
- return myFieldTransform->GetScalarRange();
+ GetDataSetMapper()->SetInput(InsertCustomPL());
}
-void
-VISU_ScalarMapPL
-::SetScalarRange(vtkFloatingPointType theRange[2])
-{
- myFieldTransform->SetScalarRange(theRange);
- myBarTable->SetRange(theRange);
- Modified();
-}
+//----------------------------------------------------------------------------
void
VISU_ScalarMapPL
-::SetScalarMin(vtkFloatingPointType theValue)
+::Update()
{
- vtkFloatingPointType aScalarRange[2] = {theValue, GetScalarRange()[1]};
- SetScalarRange(aScalarRange);
+ Superclass::Update();
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aScalarsOutput.vtk";
+ // VISU::WriteToFile(GetFieldTransformFilter()->GetUnstructuredGridOutput(), aFileName);
+ //}
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-aGeomDataSet.vtk";
+ // VISU::WriteToFile(myAppendFilter->GetOutput(), aFileName);
+ //}
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myMergeFilter.vtk";
+ // VISU::WriteToFile(myMergeFilter->GetUnstructuredGridOutput(), aFileName);
+ //}
}
+
+//----------------------------------------------------------------------------
void
VISU_ScalarMapPL
-::SetScalarMax(vtkFloatingPointType theValue)
-{
- vtkFloatingPointType aScalarRange[2] = {GetScalarRange()[0], theValue};
- SetScalarRange(aScalarRange);
+::DoShallowCopy(VISU_PipeLine *thePipeLine,
+ 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();
+ }
+ }
}
//----------------------------------------------------------------------------
void
VISU_ScalarMapPL
-::SetNbColors(int theNbColors)
+::SetSourceGeometry()
{
- myMapperTable->SetNumberOfColors(theNbColors);
- myBarTable->SetNumberOfColors(theNbColors);
- Modified();
+ if(IsExternalGeometryUsed()){
+ ClearGeometry();
+ myAppendFilter->AddInput(GetClippedInput());
+ }
}
+
+//----------------------------------------------------------------------------
int
VISU_ScalarMapPL
-::GetNbColors()
+::AddGeometry(vtkDataSet* theGeometry)
{
- return myMapperTable->GetNumberOfColors();
+ myAppendFilter->AddInput(theGeometry);
+ return GetNumberOfGeometry();
}
//----------------------------------------------------------------------------
-VISU_ScalarMapPL::THook*
+vtkDataSet*
VISU_ScalarMapPL
-::DoHook()
+::GetGeometry(int theGeomNumber)
{
- myMapper->SetColorModeToMapScalars();
- myMapper->ScalarVisibilityOn();
- return myFieldTransform->GetUnstructuredGridOutput();
+ return vtkDataSet::SafeDownCast(myAppendFilter->GetInput(theGeomNumber));
}
-void
+//----------------------------------------------------------------------------
+int
VISU_ScalarMapPL
-::Init()
+::GetNumberOfGeometry()
{
- SetScalarMode(0);
- SetSourceRange();
+ return myAppendFilter->GetNumberOfInputConnections(0);
}
-void
+
+//----------------------------------------------------------------------------
+bool
VISU_ScalarMapPL
-::Build()
+::IsExternalGeometryUsed()
{
- myMapper->SetInput(DoHook());
+ return myAppendFilter->GetInput() != GetClippedInput();
}
+//----------------------------------------------------------------------------
void
VISU_ScalarMapPL
-::Update()
-{
- vtkFloatingPointType *aRange = myFieldTransform->GetScalarRange();
- vtkFloatingPointType aScalarRange[2] = {aRange[0], aRange[1]};
- if(myBarTable->GetScale() == VTK_SCALE_LOG10)
- VISU_LookupTable::ComputeLogRange(aRange,aScalarRange);
- myMapperTable->SetRange(aScalarRange);
-
- myMapperTable->Build();
- myBarTable->Build();
-
- myMapper->SetLookupTable(myMapperTable);
- myMapper->SetScalarRange(aScalarRange);
-
- VISU_PipeLine::Update();
+::ClearGeometry()
+{
+ myAppendFilter->RemoveAllInputs();
}
//----------------------------------------------------------------------------
-VISU_LookupTable *
+vtkDataSet*
VISU_ScalarMapPL
-::GetMapperTable()
-{
- return myMapperTable;
-}
-
-VISU_LookupTable*
-VISU_ScalarMapPL
-::GetBarTable()
+::InsertCustomPL()
{
- return myBarTable;
+ return GetMergedInput();
}
//----------------------------------------------------------------------------
-void
+vtkDataSet*
VISU_ScalarMapPL
-::SetMapScale(vtkFloatingPointType theMapScale)
-{
- myMapperTable->SetMapScale(theMapScale);
- myMapperTable->Build();
-}
-
-vtkFloatingPointType
-VISU_ScalarMapPL::GetMapScale()
+::GetMergedInput()
{
- return myMapperTable->GetMapScale();
+ if(myMergeFilter->GetInput())
+ myMergeFilter->Update();
+ return myMergeFilter->GetOutput();
}
//----------------------------------------------------------------------------
-void
-VISU_ScalarMapPL
-::GetSourceRange(vtkFloatingPointType theRange[2])
-{
- myExtractor->Update();
- myExtractor->GetOutput()->GetScalarRange(theRange);
-}
-
-void
-VISU_ScalarMapPL
-::SetSourceRange()
-{
- vtkFloatingPointType aRange[2];
- GetSourceRange(aRange);
- SetScalarRange(aRange);
-}
//
//
//
-// File: VISU_PipeLine.hxx
+// File: VISU_ScalarMapPL.hxx
// Author: Alexey PETROV
// Module : VISU
-#ifndef VISU_ScalrMapPL_HeaderFile
-#define VISU_ScalrMapPL_HeaderFile
+#ifndef VISU_ScalarMapPL_HeaderFile
+#define VISU_ScalarMapPL_HeaderFile
#include "VISUPipeline.hxx"
-#include "VISU_PipeLine.hxx"
-#include "VISU_ScalarBarActor.hxx"
+#include "VISU_ColoredPL.hxx"
+#include "VISU_UnstructuredGridPL.hxx"
-class vtkCell;
-class vtkDataSet;
+class VISU_DataSetMapperHolder;
+class VISU_AppendFilter;
+class VISU_MergeFilter;
-class VISU_Extractor;
-class VISU_FieldTransform;
-
-//============================================================================
-class VISU_PIPELINE_EXPORT VISU_ScalarMapPL : public VISU_PipeLine
+//----------------------------------------------------------------------------
+class VISU_PIPELINE_EXPORT VISU_ScalarMapPL : public VISU_ColoredPL,
+ public VISU_UnstructuredGridPL
{
-protected:
- VISU_ScalarMapPL();
-
- virtual
- ~VISU_ScalarMapPL();
-
public:
- //----------------------------------------------------------------------------
- vtkTypeMacro(VISU_ScalarMapPL,VISU_PipeLine);
+ vtkTypeMacro(VISU_ScalarMapPL, VISU_ColoredPL);
- static
+ static
VISU_ScalarMapPL*
New();
virtual
void
- ShallowCopy(VISU_PipeLine *thePipeLine);
-
- //----------------------------------------------------------------------------
- virtual
- int
- GetScalarMode();
+ Update();
virtual
void
- SetScalarMode(int theScalarMode = 0);
-
+ SetSourceGeometry();
+
virtual
int
- GetScaling();
- virtual
- void
- SetScaling(int theScaling = VTK_SCALE_LINEAR);
-
- virtual
- vtkFloatingPointType*
- GetScalarRange();
+ AddGeometry(vtkDataSet* theGeometry);
virtual
- void
- SetScalarRange(vtkFloatingPointType theRange[2]);
+ vtkDataSet*
+ GetGeometry(int theGeomNumber);
virtual
- void
- SetScalarMin(vtkFloatingPointType theValue);
+ int
+ GetNumberOfGeometry();
- virtual
- void
- SetScalarMax(vtkFloatingPointType theValue);
-
- virtual
- void
- SetNbColors(int theNbColors = 16);
+ bool
+ IsExternalGeometryUsed();
- virtual
- int
- GetNbColors();
-
- //----------------------------------------------------------------------------
-public:
virtual
void
- Init();
+ ClearGeometry();
- virtual
- void
- Build();
+ //----------------------------------------------------------------------------
+ virtual
+ vtkDataSet*
+ GetMergedInput();
- virtual
- void
- Update();
+protected:
+ //----------------------------------------------------------------------------
+ VISU_ScalarMapPL();
+ VISU_ScalarMapPL(const VISU_ScalarMapPL&);
virtual
- VISU_LookupTable*
- GetMapperTable();
-
- virtual
- VISU_LookupTable*
- GetBarTable();
+ ~VISU_ScalarMapPL();
- virtual
+ virtual
void
- SetMapScale(vtkFloatingPointType theMapScale = 1.0);
+ OnCreateMapperHolder();
virtual
- vtkFloatingPointType
- GetMapScale();
+ vtkDataSet*
+ InsertCustomPL();
virtual
void
- GetSourceRange(vtkFloatingPointType theRange[2]);
+ Build();
virtual
void
- SetSourceRange();
-
- //----------------------------------------------------------------------------
-protected:
- typedef vtkDataSet THook;
- virtual THook* DoHook();
+ DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
- VISU_LookupTable* myMapperTable;
- VISU_LookupTable* myBarTable;
- VISU_FieldTransform* myFieldTransform;
- VISU_Extractor* myExtractor;
+private:
+ vtkSmartPointer<VISU_AppendFilter> myAppendFilter;
+ vtkSmartPointer<VISU_MergeFilter> myMergeFilter;
};
#endif
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
-// File: VISU_PipeLine.cxx
+// File: VISU_StreamLinesPL.cxx
// Author: Alexey PETROV
// Module : VISU
#include "VISU_StreamLinesPL.hxx"
-#include "VISU_PipeLineUtils.hxx"
+#include "VISU_Extractor.hxx"
+#include "VISU_FieldTransform.hxx"
#include "VISU_UsedPointsFilter.hxx"
#include "VTKViewer_GeometryFilter.h"
+#include "VISU_PipeLineUtils.hxx"
+
#include <algorithm>
#include <vtkCell.h>
-#include <vtkPointSet.h>
#include <vtkDataSet.h>
#include <vtkStreamLine.h>
static vtkFloatingPointType aCoeffOfIntStep = 1.0E+1;
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_StreamLinesPL);
-VISU_StreamLinesPL::VISU_StreamLinesPL(){
+
+//----------------------------------------------------------------------------
+VISU_StreamLinesPL
+::VISU_StreamLinesPL()
+{
+ SetIsShrinkable(false);
+
myStream = vtkStreamLine::New();
myCenters = vtkCellCenters::New();
myGeomFilter = VTKViewer_GeometryFilter::New();
mySource = NULL;
}
-VISU_StreamLinesPL::~VISU_StreamLinesPL(){
- // commented: porting to vtk5.0
- // myPointsFilter->UnRegisterAllOutputs();
+
+//----------------------------------------------------------------------------
+VISU_StreamLinesPL
+::~VISU_StreamLinesPL()
+{
myPointsFilter->Delete();
+ myPointsFilter = NULL;
- // commented: porting to vtk5.0
- // myCenters->UnRegisterAllOutputs();
myCenters->Delete();
+ myCenters = NULL;
- // commented: porting to vtk5.0
- // myGeomFilter->UnRegisterAllOutputs();
myGeomFilter->Delete();
+ myGeomFilter = NULL;
- // commented: porting to vtk5.0
- // myStream->UnRegisterAllOutputs();
myStream->Delete();
+ myStream = NULL;
}
-void VISU_StreamLinesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
+
+//----------------------------------------------------------------------------
+void
+VISU_StreamLinesPL
+::DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput)
+{
+ Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
+
if(VISU_StreamLinesPL *aPipeLine = dynamic_cast<VISU_StreamLinesPL*>(thePipeLine)){
SetParams(aPipeLine->GetIntegrationStep(),
aPipeLine->GetPropagationTime(),
aPipeLine->GetUsedPoints(),
aPipeLine->GetDirection());
}
- Superclass::ShallowCopy(thePipeLine);
}
-vtkFloatingPointType
+//----------------------------------------------------------------------------
+size_t
VISU_StreamLinesPL
::GetNecasseryMemorySize(vtkIdType theNbOfPoints,
vtkFloatingPointType theStepLength,
vtkFloatingPointType anAssignedDataSize = aCellsSize*4.0*sizeof(vtkFloatingPointType);
vtkFloatingPointType anOutputDataSetSize = aMeshSize + anAssignedDataSize;
- vtkFloatingPointType aResult = aStreamArraySize*aNbCells + anOutputDataSetSize;
+ size_t aResult = size_t(aStreamArraySize*aNbCells + anOutputDataSetSize);
return aResult;
}
-int
+
+//----------------------------------------------------------------------------
+size_t
VISU_StreamLinesPL
-::FindPossibleParams(vtkPointSet* theDataSet,
+::FindPossibleParams(vtkDataSet* theDataSet,
vtkFloatingPointType& theStepLength,
vtkFloatingPointType& thePropogationTime,
vtkFloatingPointType& thePercents)
{
static vtkFloatingPointType aPercentsDecrease = 3.0, aStepLengthIncrease = 9.0;
vtkIdType aNbOfPoints = theDataSet->GetNumberOfPoints();
- vtkFloatingPointType aSize = GetNecasseryMemorySize(aNbOfPoints,theStepLength,thePropogationTime,thePercents);
- int isPoss = CheckAvailableMemory(aSize);
- if(!isPoss){
- vtkFloatingPointType aMaxStepLength = max(GetMaxStepLength(theDataSet),thePropogationTime);
+ size_t aSize = GetNecasseryMemorySize(aNbOfPoints,theStepLength,thePropogationTime,thePercents);
+ size_t anIsPossible = CheckAvailableMemory(aSize);
+ if(!anIsPossible){
+ vtkFloatingPointType aMaxStepLength = std::max(GetMaxStepLength(theDataSet),thePropogationTime);
vtkFloatingPointType aMinStepLength = GetMinStepLength(theDataSet);
vtkFloatingPointType aDeltaStepLength = (aMaxStepLength - aMinStepLength)/aStepLengthIncrease;
for(int i = 2, aStepChanged = 1, aPerecentsChanged = 1; aStepChanged || aPerecentsChanged; i++){
}
aSize = GetNecasseryMemorySize(aNbOfPoints,theStepLength,thePropogationTime,thePercents);
if(CheckAvailableMemory(aSize)){
- isPoss = i;
+ anIsPossible = i;
break;
}
}
}
- if(MYDEBUG) MESSAGE("FindPossibleParams - aSize = "<<aSize<<"; isPoss = "<<isPoss);
- return isPoss;
+ if(MYDEBUG) MESSAGE("FindPossibleParams - aSize = "<<aSize<<"; anIsPossible = "<<anIsPossible);
+ return anIsPossible;
}
-int
+//----------------------------------------------------------------------------
+size_t
VISU_StreamLinesPL
::SetParams(vtkFloatingPointType theIntStep,
vtkFloatingPointType thePropogationTime,
vtkFloatingPointType theStepLength,
- vtkPointSet* theSource,
+ vtkDataSet* theSource,
vtkFloatingPointType thePercents,
- int theDirection,
- int isOnlyTry)
+ int theDirection)
{
- vtkPointSet* aDataSet = theSource? theSource: myFieldTransform->GetUnstructuredGridOutput();
+ vtkDataSet* aDataSet = theSource? theSource: GetMergedInput();
aDataSet->Update();
+
vtkIdType aNbOfPoints = aDataSet->GetNumberOfPoints();
- vtkPointSet* aPointSet = myExtractor->GetOutput();
- if(thePercents*aNbOfPoints < 1) thePercents = 2.0/aNbOfPoints;
- theIntStep = CorrectIntegrationStep(theIntStep,aPointSet,thePercents);
- thePropogationTime = CorrectPropagationTime(thePropogationTime,aPointSet);
- theStepLength = CorrectStepLength(theStepLength,aPointSet);
- int isAccepted = FindPossibleParams(aPointSet,theStepLength,thePropogationTime,thePercents);
- if((!isOnlyTry && isAccepted) || (isOnlyTry && isAccepted == 1)){
+ vtkDataSet* aPointSet = GetExtractorFilter()->GetOutput();
+ if (thePercents * aNbOfPoints < 1)
+ thePercents = 2.0 / aNbOfPoints;
+
+ theIntStep = CorrectIntegrationStep(theIntStep,
+ aPointSet,
+ thePercents);
+
+ thePropogationTime = CorrectPropagationTime(thePropogationTime,
+ aPointSet);
+
+ theStepLength = CorrectStepLength(theStepLength,
+ aPointSet);
+
+ size_t anIsAccepted = FindPossibleParams(aPointSet,
+ theStepLength,
+ thePropogationTime,
+ thePercents);
+
+ if (anIsAccepted) {
mySource = theSource;
myPercents = thePercents;
- if(VISU::IsDataOnCells(GetInput2())){
+ if(VISU::IsDataOnCells(GetMergedInput())){
myCenters->SetInput(aDataSet);
myCenters->VertexCellsOn();
aDataSet = myCenters->GetOutput();
myStream->Modified();
Modified();
}
- return isAccepted;
+ return anIsAccepted;
}
-vtkPointSet*
+//----------------------------------------------------------------------------
+vtkDataSet*
VISU_StreamLinesPL
::GetSource()
{
return mySource;
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
::GetUsedPoints()
return myPercents;
}
+
+//----------------------------------------------------------------------------
vtkDataSet*
VISU_StreamLinesPL
::GetStreamerSource()
return myStream->GetSource();
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
::GetVelocityCoeff()
{
- return GetVelocityCoeff(myExtractor->GetOutput());
+ return GetVelocityCoeff(GetExtractorFilter()->GetOutput());
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
-::GetVelocityCoeff(vtkPointSet* theDataSet)
+::GetVelocityCoeff(vtkDataSet* theDataSet)
{
vtkFloatingPointType* aScalarRange = theDataSet->GetScalarRange();
vtkFloatingPointType aVelocity = (fabs(aScalarRange[1]) + fabs(aScalarRange[0]))/2.0;
}
-int
+//----------------------------------------------------------------------------
+size_t
VISU_StreamLinesPL
-::IsPossible(vtkPointSet* theDataSet,
+::IsPossible(vtkDataSet* theDataSet,
vtkFloatingPointType thePercents)
{
vtkFloatingPointType aStepLength = GetBaseStepLength(theDataSet);
vtkFloatingPointType aBasePropTime = GetBasePropagationTime(theDataSet);
VISU_UsedPointsFilter *aPointsFilter = VISU_UsedPointsFilter::New();
aPointsFilter->SetInput(theDataSet);
- vtkPointSet* aDataSet = aPointsFilter->GetOutput();
+ vtkDataSet* aDataSet = aPointsFilter->GetOutput();
aDataSet->Update();
- int aRes = FindPossibleParams(aDataSet,aStepLength,aBasePropTime,thePercents);
- aPointsFilter->UnRegisterAllOutputs();
+ size_t aRes = FindPossibleParams(aDataSet,
+ aStepLength,
+ aBasePropTime,
+ thePercents);
aPointsFilter->Delete();
return aRes;
}
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
::GetIntegrationStep()
return myStream->GetIntegrationStepLength();
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
::GetStepLength()
return myStream->GetStepLength();
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
::GetPropagationTime()
return myStream->GetMaximumPropagationTime();
}
+
+//----------------------------------------------------------------------------
int
VISU_StreamLinesPL
::GetDirection()
}
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
-::GetMinIntegrationStep(vtkPointSet* theDataSet,
+::GetMinIntegrationStep(vtkDataSet* theDataSet,
vtkFloatingPointType thePercents)
{
- if(!theDataSet) return -1.0;
- vtkFloatingPointType aVolume = 1.0;
- int degree = 0;
+ if(!theDataSet)
+ return -1.0;
+
theDataSet->Update();
+
+ int degree = 0;
+ vtkFloatingPointType aVolume = 1.0;
vtkFloatingPointType* aBounds = theDataSet->GetBounds();
for(int i = 0, j = 0; i < 3; ++i, j = 2*i){
vtkFloatingPointType tmp = aBounds[j+1] - aBounds[j];
degree += 1;
}
}
- if (degree < 1) return 0.0; // absolutely empty object
+
+ if (degree < 1)
+ return 0.0; // absolutely empty object
+
vtkFloatingPointType anStepLength = GetMaxIntegrationStep(theDataSet)/aCoeffOfIntStep;
vtkFloatingPointType aBasePropTime = GetBasePropagationTime(theDataSet)/GetVelocityCoeff(theDataSet);
thePercents = 1.0;
vtkIdType aNbOfPoints = theDataSet->GetNumberOfPoints();
- vtkFloatingPointType aSize = GetNecasseryMemorySize(aNbOfPoints,anStepLength,aBasePropTime,thePercents);
- vtkFloatingPointType aRealSize = GetAvailableMemory(aSize);
+ size_t aSize = GetNecasseryMemorySize(aNbOfPoints,anStepLength,aBasePropTime,thePercents);
+ size_t aRealSize = GetAvailableMemory(aSize);
vtkFloatingPointType anAverageVolume = aVolume / aRealSize;
vtkFloatingPointType aStep = pow(double(anAverageVolume), double(1.0/double(degree)));
return aStep;
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
::GetMinIntegrationStep()
{
- return GetMinIntegrationStep(myExtractor->GetOutput(),GetUsedPoints());
+ return GetMinIntegrationStep(GetExtractorFilter()->GetOutput(), GetUsedPoints());
}
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
-::GetMaxIntegrationStep(vtkPointSet* theDataSet)
+::GetMaxIntegrationStep(vtkDataSet* theDataSet)
{
- if(!theDataSet) return -1.0;
+ if(!theDataSet)
+ return -1.0;
+
theDataSet->Update();
+
vtkFloatingPointType aLength = theDataSet->GetLength();
vtkFloatingPointType* aBounds = theDataSet->GetBounds();
vtkFloatingPointType aMaxSizeY = (aBounds[3]-aBounds[2])/aLength;
vtkFloatingPointType aMaxSizeZ = (aBounds[5]-aBounds[4])/aLength;
vtkFloatingPointType aMinMax = (aBounds[1] - aBounds[0])/aLength;
- if (aMinMax < EPS || (aMaxSizeY < aMinMax && aMaxSizeY > EPS)) aMinMax = aMaxSizeY;
- if (aMinMax < EPS || (aMaxSizeZ < aMinMax && aMaxSizeZ > EPS)) aMinMax = aMaxSizeZ;
+ if (aMinMax < EPS || (aMaxSizeY < aMinMax && aMaxSizeY > EPS))
+ aMinMax = aMaxSizeY;
+ if (aMinMax < EPS || (aMaxSizeZ < aMinMax && aMaxSizeZ > EPS))
+ aMinMax = aMaxSizeZ;
return aMinMax*aLength/2.0;
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
::GetMaxIntegrationStep()
{
- return GetMaxIntegrationStep(myExtractor->GetOutput());
+ return GetMaxIntegrationStep(GetExtractorFilter()->GetOutput());
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
-::GetBaseIntegrationStep(vtkPointSet* theDataSet,
+::GetBaseIntegrationStep(vtkDataSet* theDataSet,
vtkFloatingPointType thePercents)
{
theDataSet->Update();
- vtkFloatingPointType aMinIntegrationStep = GetMinIntegrationStep(theDataSet,thePercents);
+
vtkFloatingPointType aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet);
vtkFloatingPointType anIntegrationStep = aMaxIntegrationStep / aCoeffOfIntStep;
- vtkFloatingPointType aMinMax = theDataSet->GetLength()/theDataSet->GetNumberOfPoints();
+ vtkFloatingPointType aMinMax = theDataSet->GetLength() / theDataSet->GetNumberOfPoints();
if(aMinMax > anIntegrationStep)
anIntegrationStep = (anIntegrationStep*aCoeffOfIntStep*0.9+aMinMax)/aCoeffOfIntStep;
+
+ vtkFloatingPointType aMinIntegrationStep = GetMinIntegrationStep(theDataSet, thePercents);
if(aMinIntegrationStep > anIntegrationStep)
anIntegrationStep = aMinIntegrationStep;
+
return anIntegrationStep;
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
::CorrectIntegrationStep(vtkFloatingPointType theStep,
- vtkPointSet* theDataSet,
+ vtkDataSet* theDataSet,
vtkFloatingPointType thePercents)
{
theDataSet->Update();
- vtkFloatingPointType aMinIntegrationStep = GetMinIntegrationStep(theDataSet,thePercents);
- vtkFloatingPointType aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet);
+
+ vtkFloatingPointType aMinIntegrationStep = GetMinIntegrationStep(theDataSet, thePercents);
if(aMinIntegrationStep > theStep)
theStep = aMinIntegrationStep;
+
+ vtkFloatingPointType aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet);
if(aMaxIntegrationStep < theStep)
theStep = aMaxIntegrationStep;
+
return theStep;
}
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
-::GetMinPropagationTime(vtkPointSet* theDataSet)
+::GetMinPropagationTime(vtkDataSet* theDataSet)
{
- if(!theDataSet) return -1.0;
+ if(!theDataSet)
+ return -1.0;
+
return GetMinStepLength(theDataSet);
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
::GetMinPropagationTime()
{
- return GetMinPropagationTime(myExtractor->GetOutput());
+ return GetMinPropagationTime(GetExtractorFilter()->GetOutput());
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
-::GetMaxPropagationTime(vtkPointSet* theDataSet)
+::GetMaxPropagationTime(vtkDataSet* theDataSet)
{
- if(!theDataSet) return -1.0;
+ if(!theDataSet)
+ return -1.0;
+
return GetBasePropagationTime(theDataSet)*aMinNbOfSteps;
}
-vtkFloatingPointType VISU_StreamLinesPL::GetMaxPropagationTime(){
- return GetMaxPropagationTime(myExtractor->GetOutput());
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType
+VISU_StreamLinesPL
+::GetMaxPropagationTime()
+{
+ return GetMaxPropagationTime(GetExtractorFilter()->GetOutput());
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
::CorrectPropagationTime(vtkFloatingPointType thePropagationTime,
- vtkPointSet* theDataSet)
+ vtkDataSet* theDataSet)
{
vtkFloatingPointType aMinPropagationTime = GetMinPropagationTime(theDataSet);
- vtkFloatingPointType aMaxPropagationTime = GetMaxPropagationTime(theDataSet);
if(aMinPropagationTime > thePropagationTime)
thePropagationTime = aMinPropagationTime;
+
+ vtkFloatingPointType aMaxPropagationTime = GetMaxPropagationTime(theDataSet);
if(aMaxPropagationTime < thePropagationTime)
thePropagationTime = aMaxPropagationTime;
+
return thePropagationTime;
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
-::GetBasePropagationTime(vtkPointSet* theDataSet)
+::GetBasePropagationTime(vtkDataSet* theDataSet)
{
- if(!theDataSet) return -1.0;
+ if(!theDataSet)
+ return -1.0;
+
theDataSet->Update();
- vtkFloatingPointType aPropagationTime = theDataSet->GetLength()/GetVelocityCoeff(theDataSet);
+ vtkFloatingPointType aPropagationTime = theDataSet->GetLength() / GetVelocityCoeff(theDataSet);
+
return aPropagationTime;
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
::GetBasePropagationTime()
{
- return GetBasePropagationTime(myExtractor->GetOutput());
+ return GetBasePropagationTime(GetExtractorFilter()->GetOutput());
}
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
-::GetMinStepLength(vtkPointSet* theDataSet)
+::GetMinStepLength(vtkDataSet* theDataSet)
{
static vtkFloatingPointType aNbOfStepsOfIntStep = 1.0E+1;
vtkFloatingPointType anIntStep = GetMinIntegrationStep(theDataSet);
- vtkFloatingPointType aStepLength = anIntStep*aNbOfStepsOfIntStep/GetVelocityCoeff(theDataSet);
+ vtkFloatingPointType aStepLength = anIntStep * aNbOfStepsOfIntStep / GetVelocityCoeff(theDataSet);
return aStepLength;
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
::GetMinStepLength()
{
- return GetMinStepLength(myExtractor->GetOutput());
+ return GetMinStepLength(GetExtractorFilter()->GetOutput());
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
-::GetMaxStepLength(vtkPointSet* theDataSet)
+::GetMaxStepLength(vtkDataSet* theDataSet)
{
vtkFloatingPointType aStepLength = GetBasePropagationTime(theDataSet);
return aStepLength;
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
::GetMaxStepLength()
{
- return GetMaxStepLength(myExtractor->GetOutput());
+ return GetMaxStepLength(GetExtractorFilter()->GetOutput());
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
::CorrectStepLength(vtkFloatingPointType theStep,
- vtkPointSet* theDataSet)
+ vtkDataSet* theDataSet)
{
vtkFloatingPointType aMinStep = GetMinStepLength(theDataSet);
- if(theStep < aMinStep) theStep = aMinStep;
+ if(theStep < aMinStep)
+ theStep = aMinStep;
+
vtkFloatingPointType aMaxStep = GetMaxStepLength(theDataSet);
- if(theStep > aMaxStep) theStep = aMaxStep;
+ if(theStep > aMaxStep)
+ theStep = aMaxStep;
+
return theStep;
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_StreamLinesPL
-::GetBaseStepLength(vtkPointSet* theDataSet)
+::GetBaseStepLength(vtkDataSet* theDataSet)
{
static vtkFloatingPointType anAvgNbOfSteps = 1.0E+2;
vtkFloatingPointType aPropagationTime = GetBasePropagationTime(theDataSet);
vtkFloatingPointType aStepLength = aPropagationTime/anAvgNbOfSteps;
aStepLength = CorrectStepLength(aStepLength,theDataSet);
+
return aStepLength;
}
+//----------------------------------------------------------------------------
void
VISU_StreamLinesPL
::Init()
{
Superclass::Init();
- vtkPointSet* aDataSet = myExtractor->GetOutput();
+
+ vtkDataSet* aDataSet = GetExtractorFilter()->GetOutput();
vtkFloatingPointType anIntStep = GetBaseIntegrationStep(aDataSet);
vtkFloatingPointType aPropagationTime = GetBasePropagationTime(aDataSet);
vtkFloatingPointType aStepLength = GetBaseStepLength(aDataSet);
- SetParams(anIntStep,aPropagationTime,aStepLength);
+ SetParams(anIntStep,
+ aPropagationTime,
+ aStepLength);
}
-VISU_ScalarMapPL::THook*
+
+//----------------------------------------------------------------------------
+void
VISU_StreamLinesPL
-::DoHook()
+::Build()
{
- GetInput2()->Update();
- VISU::CellDataToPoint(myStream,myCellDataToPointData,GetInput2(),myFieldTransform);
- vtkFloatingPointType *aBounds = GetInput2()->GetBounds();
- myGeomFilter->SetExtent(aBounds);
- myGeomFilter->ExtentClippingOn();
+ Superclass::Build();
+
+ VISU::CellDataToPoint(myStream,
+ myCellDataToPointData,
+ GetMergedInput());
+
myGeomFilter->SetInput(myStream->GetOutput());
+ myGeomFilter->ExtentClippingOn();
+}
+
+
+//----------------------------------------------------------------------------
+vtkDataSet*
+VISU_StreamLinesPL
+::InsertCustomPL()
+{
return myGeomFilter->GetOutput();
}
+
+//----------------------------------------------------------------------------
void
VISU_StreamLinesPL
::Update()
{
try{
Superclass::Update();
- } catch(...){}
+
+ vtkFloatingPointType aBounds[6];
+ GetMergedInput()->GetBounds(aBounds);
+ myGeomFilter->SetExtent(aBounds);
+ //{
+ // std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-myStream.vtk";
+ // VISU::WriteToFile(myStream->GetOutput(), aFileName);
+ //}
+ }catch(std::exception& exc){
+ MSG(true, "Follow exception was occured :\n"<<exc.what());
+ }catch(...){
+ MSG(MYDEBUG,"Unknown exception was occured\n");
+ }
}
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_StreamLinesPL
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ if(vtkDataSet* aDataSet = myStream->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(vtkDataSet* aDataSet = myGeomFilter->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(myCellDataToPointData->GetInput())
+ if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ return aSize;
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_StreamLinesPL
::SetMapScale(vtkFloatingPointType theMapScale)
{
Superclass::SetMapScale(theMapScale);
}
+
+
+//----------------------------------------------------------------------------
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
-// File: VISU_PipeLine.hxx
+// File: VISU_StreamLinesPL.hxx
// Author: Alexey PETROV
// Module : VISU
#include "VISU_DeformedShapePL.hxx"
#include <vtkStreamLine.h>
-using namespace std;
-
-class vtkPointSet;
+class vtkDataSet;
class vtkCellCenters;
class VTKViewer_GeometryFilter;
class VISU_UsedPointsFilter;
-class VISU_PIPELINE_EXPORT VISU_StreamLinesPL : public VISU_DeformedShapePL{
-protected:
- VISU_StreamLinesPL();
- VISU_StreamLinesPL(const VISU_StreamLinesPL&);
-
- virtual
- ~VISU_StreamLinesPL();
+//----------------------------------------------------------------------------
+class VISU_PIPELINE_EXPORT VISU_StreamLinesPL : public VISU_DeformedShapePL
+{
public:
- vtkTypeMacro(VISU_StreamLinesPL,VISU_DeformedShapePL);
+ vtkTypeMacro(VISU_StreamLinesPL, VISU_DeformedShapePL);
static
- VISU_StreamLinesPL*
+ VISU_StreamLinesPL*
New();
virtual
- void
- ShallowCopy(VISU_PipeLine *thePipeLine);
-
- virtual
- int
- SetParams(vtkFloatingPointType theIntStep,
+ size_t
+ SetParams(vtkFloatingPointType theIntStep,
vtkFloatingPointType thePropogationTime,
vtkFloatingPointType theStepLength,
- vtkPointSet* theSource = NULL,
+ vtkDataSet* theSource = NULL,
vtkFloatingPointType thePercents = 0.3,
- int theDirection = VTK_INTEGRATE_BOTH_DIRECTIONS,
- int isOnlyTry = false);
+ int theDirection = VTK_INTEGRATE_BOTH_DIRECTIONS);
virtual
- vtkPointSet*
+ vtkDataSet*
GetSource();
virtual
public:
virtual
- THook*
- DoHook();
+ vtkDataSet*
+ InsertCustomPL();
virtual
void
Init();
+ virtual
+ void
+ Build();
+
virtual
void
Update();
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
virtual
void
SetMapScale(vtkFloatingPointType theMapScale = 1.0);
public:
static
vtkFloatingPointType
- GetMaxIntegrationStep(vtkPointSet* theDataSet);
+ GetMaxIntegrationStep(vtkDataSet* theDataSet);
static
vtkFloatingPointType
- GetMinIntegrationStep(vtkPointSet* theDataSet,
+ GetMinIntegrationStep(vtkDataSet* theDataSet,
vtkFloatingPointType thePercents = 0.3);
static
vtkFloatingPointType
- GetBaseIntegrationStep(vtkPointSet* theDataSet,
+ GetBaseIntegrationStep(vtkDataSet* theDataSet,
vtkFloatingPointType thePercents = 0.3);
static
vtkFloatingPointType
- GetMinPropagationTime(vtkPointSet* theDataSet);
+ GetMinPropagationTime(vtkDataSet* theDataSet);
static
vtkFloatingPointType
- GetMaxPropagationTime(vtkPointSet* theDataSet);
+ GetMaxPropagationTime(vtkDataSet* theDataSet);
static
vtkFloatingPointType
- GetBasePropagationTime(vtkPointSet* theDataSet);
+ GetBasePropagationTime(vtkDataSet* theDataSet);
static
vtkFloatingPointType
- GetMinStepLength(vtkPointSet* theDataSet);
+ GetMinStepLength(vtkDataSet* theDataSet);
static
vtkFloatingPointType
- GetMaxStepLength(vtkPointSet* theDataSet);
+ GetMaxStepLength(vtkDataSet* theDataSet);
static
vtkFloatingPointType
- GetBaseStepLength(vtkPointSet* theDataSet);
+ GetBaseStepLength(vtkDataSet* theDataSet);
static
vtkFloatingPointType
- GetVelocityCoeff(vtkPointSet* theDataSet);
+ GetVelocityCoeff(vtkDataSet* theDataSet);
static
- int
- IsPossible(vtkPointSet* theDataSet,
+ size_t
+ IsPossible(vtkDataSet* theDataSet,
vtkFloatingPointType thePercents = 0.3);
protected:
+ VISU_StreamLinesPL();
+ VISU_StreamLinesPL(const VISU_StreamLinesPL&);
+
+ virtual
+ ~VISU_StreamLinesPL();
+
+ virtual
+ void
+ DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
+
static
- vtkFloatingPointType
+ size_t
GetNecasseryMemorySize(vtkIdType theNbOfPoints,
vtkFloatingPointType theStepLength,
vtkFloatingPointType thePropogationTime,
vtkFloatingPointType thePercents = 0.3);
static
- int
- FindPossibleParams(vtkPointSet* theDataSet,
+ size_t
+ FindPossibleParams(vtkDataSet* theDataSet,
vtkFloatingPointType& theStepLength,
vtkFloatingPointType& thePropogationTime,
vtkFloatingPointType& thePercents);
static
vtkFloatingPointType
CorrectIntegrationStep(vtkFloatingPointType theStep,
- vtkPointSet* theDataSet,
+ vtkDataSet* theDataSet,
vtkFloatingPointType thePercents = 0.3);
static
vtkFloatingPointType
CorrectPropagationTime(vtkFloatingPointType thePropagationTime,
- vtkPointSet* theDataSet);
+ vtkDataSet* theDataSet);
static
vtkFloatingPointType
CorrectStepLength(vtkFloatingPointType theStep,
- vtkPointSet* theDataSet);
+ vtkDataSet* theDataSet);
vtkStreamLine* myStream;
- vtkPointSet* mySource;
+ vtkDataSet* mySource;
vtkCellCenters* myCenters;
VTKViewer_GeometryFilter *myGeomFilter;
VISU_UsedPointsFilter *myPointsFilter;
--- /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_UnstructuredGridPL.cxx
+// Author: Alexey PETROV
+// Module : VISU
+
+
+#include "VISU_UnstructuredGridPL.hxx"
+#include "VISU_DataSetMapperHolder.hxx"
+
+
+//----------------------------------------------------------------------------
+VISU_UnstructuredGridPL
+::VISU_UnstructuredGridPL(VISU_PipeLine* thePipeLine):
+ myPipeLine(thePipeLine)
+{}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_UnstructuredGridPL
+::OnCreateMapperHolder()
+{
+ myDataSetMapperHolder = VISU_DataSetMapperHolder::New();
+ myDataSetMapperHolder->Delete();
+
+ myPipeLine->SetMapperHolder(myDataSetMapperHolder.GetPointer());
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_UnstructuredGridPL
+::SetUnstructuredGridIDMapper(const VISU::PUnstructuredGridIDMapper& theIDMapper)
+{
+ GetDataSetMapperHolder()->SetUnstructuredGridIDMapper(theIDMapper);
+}
+
+
+//----------------------------------------------------------------------------
+VISU_DataSetMapperHolder*
+VISU_UnstructuredGridPL
+::GetDataSetMapperHolder()
+{
+ myPipeLine->GetMapperHolder();
+
+ return myDataSetMapperHolder.GetPointer();
+}
+
+
+//----------------------------------------------------------------------------
+vtkDataSetMapper*
+VISU_UnstructuredGridPL
+::GetDataSetMapper()
+{
+ return GetDataSetMapperHolder()->GetDataSetMapper();
+}
+
+
+//----------------------------------------------------------------------------
--- /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_UnstructuredGripPL.hxx
+// Author: Alexey PETROV
+// Module : VISU
+
+#ifndef VISU_UnstructuredGridPL_HeaderFile
+#define VISU_UnstructuredGridPL_HeaderFile
+
+#include "VISU_PipeLine.hxx"
+
+class VISU_DataSetMapperHolder;
+class vtkDataSetMapper;
+
+//----------------------------------------------------------------------------
+class VISU_UnstructuredGridPL
+{
+public:
+ //----------------------------------------------------------------------------
+ void
+ SetUnstructuredGridIDMapper(const VISU::PUnstructuredGridIDMapper& theIDMapper);
+
+ VISU_DataSetMapperHolder*
+ GetDataSetMapperHolder();
+
+ vtkDataSetMapper*
+ GetDataSetMapper();
+
+protected:
+ //----------------------------------------------------------------------------
+ VISU_UnstructuredGridPL(VISU_PipeLine* thePipeLine);
+
+ virtual
+ void
+ OnCreateMapperHolder();
+
+private:
+ //----------------------------------------------------------------------------
+ VISU_UnstructuredGridPL(); // Not implemented
+ VISU_UnstructuredGridPL(const VISU_UnstructuredGridPL&); // Not implemented
+
+ VISU_PipeLine* myPipeLine;
+ vtkSmartPointer<VISU_DataSetMapperHolder> myDataSetMapperHolder;
+};
+
+#endif
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
// File: VISU_StreamLinesPL.cxx
#include "VISU_UsedPointsFilter.hxx"
+#include "VISU_ConvertorUtils.hxx"
+
#include <vtkObjectFactory.h>
-#include <vtkPointSet.h>
+#include <vtkUnstructuredGrid.h>
#include <vtkPointData.h>
#include <vtkCellData.h>
#include <vtkPoints.h>
#include <vtkIdList.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+
+
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_UsedPointsFilter);
-VISU_UsedPointsFilter::VISU_UsedPointsFilter(){
+
+//----------------------------------------------------------------------------
+VISU_UsedPointsFilter::VISU_UsedPointsFilter()
+{
PercentsOfUsedPoints = 1.0;
}
-VISU_UsedPointsFilter::~VISU_UsedPointsFilter(){}
+//----------------------------------------------------------------------------
+VISU_UsedPointsFilter::~VISU_UsedPointsFilter()
+{}
-void VISU_UsedPointsFilter::Execute(){
- vtkPointSet *anInput = this->GetInput(), *anOutput = this->GetOutput();
- anOutput->GetPointData()->CopyAllOff();
- anOutput->GetCellData()->CopyAllOff();
- anOutput->CopyStructure(anInput);
+
+//----------------------------------------------------------------------------
+int VISU_UsedPointsFilter::RequestData (vtkInformation *vtkNotUsed(request),
+ vtkInformationVector **inputVector,
+ vtkInformationVector *outputVector)
+{
+ // get the info objects
+ vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
+ vtkInformation *outInfo = outputVector->GetInformationObject(0);
+
+ // get the input and ouptut
+ vtkDataSet *input = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
+ vtkPointSet *output = vtkPointSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
+
+ //////////
+ output->GetPointData()->CopyAllOff();
+ output->GetCellData()->CopyAllOff();
+ output->CopyStructure(input);
vtkPoints* aPoints = vtkPoints::New();
vtkIdList *anIdList = vtkIdList::New();
- vtkIdType iEnd = anInput->GetNumberOfPoints();
- for(vtkIdType i = 0; i < iEnd; i++){
- anInput->GetPointCells(i,anIdList);
- if(anIdList->GetNumberOfIds() > 0)
- aPoints->InsertNextPoint(anInput->GetPoint(i));
+ vtkIdType iEnd = input->GetNumberOfPoints();
+ for (vtkIdType i = 0; i < iEnd; i++) {
+ input->GetPointCells(i, anIdList);
+ if (anIdList->GetNumberOfIds() > 0)
+ aPoints->InsertNextPoint(input->GetPoint(i));
}
vtkPoints* aNewPoints = vtkPoints::New();
iEnd = aPoints->GetNumberOfPoints();
- if (PercentsOfUsedPoints > 0){
+ if (PercentsOfUsedPoints > 0) {
vtkIdType anOffset = vtkIdType(1.0/PercentsOfUsedPoints);
- if(anOffset < 1) anOffset = 1;
- for(vtkIdType i = 0; i < iEnd; i += anOffset)
+ if (anOffset < 1) anOffset = 1;
+ for (vtkIdType i = 0; i < iEnd; i += anOffset)
aNewPoints->InsertNextPoint(aPoints->GetPoint(i));
}
- anOutput->SetPoints(aNewPoints);
+ output->SetPoints(aNewPoints);
aNewPoints->Delete();
aPoints->Delete();
+
+ return 1;
}
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
// File: VISU_UsedPointsFilter.hxx
#ifndef VISU_UsedPointsFilter_HeaderFile
#define VISU_UsedPointsFilter_HeaderFile
-#include <vtkPointSetToPointSetFilter.h>
+#include <vtkPointSetAlgorithm.h>
+
+
+//----------------------------------------------------------------------------
+class VISU_UsedPointsFilter : public vtkPointSetAlgorithm
+{
+public:
+ vtkTypeMacro(VISU_UsedPointsFilter, vtkPointSetAlgorithm);
+
+ static
+ VISU_UsedPointsFilter*
+ New();
+
+ vtkSetMacro(PercentsOfUsedPoints,float);
+ vtkGetMacro(PercentsOfUsedPoints,float);
-class VISU_UsedPointsFilter : public vtkPointSetToPointSetFilter{
protected:
VISU_UsedPointsFilter();
VISU_UsedPointsFilter(const VISU_UsedPointsFilter&);
- virtual void Execute();
- float PercentsOfUsedPoints;
+ virtual
+ ~VISU_UsedPointsFilter();
-public:
- vtkTypeMacro(VISU_UsedPointsFilter,vtkPointSetToPointSetFilter);
- static VISU_UsedPointsFilter* New();
- virtual ~VISU_UsedPointsFilter();
+ int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
- vtkSetMacro(PercentsOfUsedPoints,float);
- vtkGetMacro(PercentsOfUsedPoints,float);
+ float PercentsOfUsedPoints;
};
#endif
#include "VISU_VectorsPL.hxx"
+#include "VISU_FieldTransform.hxx"
#include "VISU_PipeLineUtils.hxx"
#include "VTKViewer_TransformFilter.h"
#include "VTKViewer_Transform.h"
#include <vtkGlyphSource2D.h>
#include <vtkPolyData.h>
+
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_VectorsPL);
+
+//----------------------------------------------------------------------------
VISU_VectorsPL
::VISU_VectorsPL()
{
+ SetIsShrinkable(false);
+
myBaseGlyph = vtkGlyph3D::New();
myTransformedGlyph = vtkGlyph3D::New();
myCenters = vtkCellCenters::New();
myTransformFilter = VTKViewer_TransformFilter::New();
- myIsShrinkable = false;
}
+
+//----------------------------------------------------------------------------
VISU_VectorsPL
::~VISU_VectorsPL()
{
myTransformFilter->Delete();
}
+
+//----------------------------------------------------------------------------
void
VISU_VectorsPL
-::ShallowCopy(VISU_PipeLine *thePipeLine)
+::DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput)
{
+ Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
+
if(VISU_VectorsPL *aPipeLine = dynamic_cast<VISU_VectorsPL*>(thePipeLine)){
SetGlyphType(aPipeLine->GetGlyphType());
SetGlyphPos(aPipeLine->GetGlyphPos());
}
- Superclass::ShallowCopy(thePipeLine);
}
+//----------------------------------------------------------------------------
void
VISU_VectorsPL
::SetTransform(VTKViewer_Transform* theTransform)
{
- myFieldTransform->SetSpaceTransform(theTransform);
+ GetFieldTransformFilter()->SetSpaceTransform(theTransform);
myTransformFilter->SetTransform(theTransform);
myTransformFilter->Modified();
}
+
+//----------------------------------------------------------------------------
VTKViewer_Transform*
VISU_VectorsPL
::GetTransform()
{
- return myFieldTransform->GetSpaceTransform();
+ return GetFieldTransformFilter()->GetSpaceTransform();
}
+//----------------------------------------------------------------------------
void
VISU_VectorsPL
::SetScale(vtkFloatingPointType theScale)
Modified();
}
+
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU_VectorsPL
::GetScale()
}
+//----------------------------------------------------------------------------
void
VISU_VectorsPL
-::Init()
+::SetGlyphType(VISU_VectorsPL::GlyphType theType)
{
- Superclass::Init();
+ myTypeGlyph = theType;
+ Modified();
+}
- myTypeGlyph = ARROW;
- myPosGlyph = TAIL;
+
+//----------------------------------------------------------------------------
+VISU_VectorsPL::GlyphType
+VISU_VectorsPL
+::GetGlyphType() const
+{
+ return myTypeGlyph;
}
-vtkDataSet*
+//----------------------------------------------------------------------------
+void
VISU_VectorsPL
-::GetOutput()
+::SetGlyphPos(VISU_VectorsPL::GlyphPos thePos)
{
- myBaseGlyph->Update();
- return myBaseGlyph->GetOutput();
+ myPosGlyph = thePos;
+ Modified();
+}
+
+
+//----------------------------------------------------------------------------
+VISU_VectorsPL::GlyphPos
+VISU_VectorsPL
+::GetGlyphPos() const
+{
+ return myPosGlyph;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_VectorsPL
+::Init()
+{
+ Superclass::Init();
+
+ myTypeGlyph = ARROW;
+ myPosGlyph = TAIL;
}
-VISU_ScalarMapPL::THook*
+//----------------------------------------------------------------------------
+void
VISU_VectorsPL
-::DoHook()
+::Build()
{
- VISU::ToCellCenters(myBaseGlyph,myCenters,GetInput2(),myFieldTransform);
+ Superclass::Build();
+
+ VISU::ToCellCenters(myBaseGlyph,
+ myCenters,
+ GetMergedInput());
myBaseGlyph->SetVectorModeToUseVector();
myBaseGlyph->SetScaleModeToScaleByVector();
myBaseGlyph->SetColorModeToColorByScalar();
- VISU::ToCellCenters(myTransformFilter,myCenters,GetInput2(),myFieldTransform);
+ VISU::ToCellCenters(myTransformFilter,
+ myCenters,
+ GetMergedInput());
myTransformedGlyph->SetInput(myTransformFilter->GetOutput());
myTransformedGlyph->SetVectorModeToUseVector();
myTransformedGlyph->SetScaleModeToScaleByVector();
myTransformedGlyph->SetColorModeToColorByScalar();
+}
+
+//----------------------------------------------------------------------------
+vtkDataSet*
+VISU_VectorsPL
+::InsertCustomPL()
+{
return myTransformedGlyph->GetOutput();
}
+//----------------------------------------------------------------------------
void
VISU_VectorsPL
::Update()
}
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_VectorsPL
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ if(vtkDataSet* aDataSet = myBaseGlyph->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(vtkDataSet* aDataSet = myTransformedGlyph->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(vtkDataSet* aDataSet = myCenters->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(myCellDataToPointData->GetInput())
+ if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ return aSize;
+}
+
+
+//----------------------------------------------------------------------------
+vtkDataSet*
+VISU_VectorsPL
+::GetOutput()
+{
+ myBaseGlyph->Update();
+ return myBaseGlyph->GetOutput();
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_VectorsPL
::SetMapScale(vtkFloatingPointType theMapScale)
Modified();
}
+
+
+//----------------------------------------------------------------------------
class vtkGlyph3D;
-class VISU_PIPELINE_EXPORT VISU_VectorsPL : public VISU_DeformedShapePL{
-protected:
- VISU_VectorsPL();
- VISU_VectorsPL(const VISU_VectorsPL&);
-
- virtual
- ~VISU_VectorsPL();
+//----------------------------------------------------------------------------
+class VISU_PIPELINE_EXPORT VISU_VectorsPL : public VISU_DeformedShapePL
+{
public:
- vtkTypeMacro(VISU_VectorsPL,VISU_DeformedShapePL);
+ vtkTypeMacro(VISU_VectorsPL, VISU_DeformedShapePL);
static
VISU_VectorsPL*
New();
- virtual
- void
- ShallowCopy(VISU_PipeLine *thePipeLine);
-
virtual
void
SetScale(vtkFloatingPointType theScale);
virtual
void
- SetGlyphType(GlyphType theType)
- {
- myTypeGlyph = theType;
- }
+ SetGlyphType(GlyphType theType);
virtual
GlyphType
- GetGlyphType()
- {
- return myTypeGlyph;
- }
+ GetGlyphType() const;
enum GlyphPos{ CENTER, TAIL,HEAD};
virtual
void
- SetGlyphPos(GlyphPos thePos)
- {
- myPosGlyph = thePos;
- }
+ SetGlyphPos(GlyphPos thePos);
virtual
GlyphPos
- GetGlyphPos()
- {
- return myPosGlyph;
- }
+ GetGlyphPos() const;
public:
virtual
void
Init();
+ virtual
+ void
+ Build();
+
virtual
void
Update();
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
vtkDataSet*
GetOutput();
SetMapScale(vtkFloatingPointType theMapScale = 1.0);
protected:
+ VISU_VectorsPL();
+ VISU_VectorsPL(const VISU_VectorsPL&);
+
+ virtual
+ ~VISU_VectorsPL();
+
+ virtual
+ vtkDataSet*
+ InsertCustomPL();
+
virtual
- THook*
- DoHook();
+ void
+ DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
GlyphType myTypeGlyph;
GlyphPos myPosGlyph;
VISU_msg_en.qm VISU_images.qm
dist_libVISU_la_SOURCES= \
- VisuGUI.cxx \
- VisuGUI_Factory.cxx \
- VisuGUI_Module.cxx \
- VisuGUI_Selection.cxx \
- VisuGUI_Tools.cxx \
- VisuGUI_ViewTools.cxx \
- VisuGUI_PopupTools.cxx \
- VisuGUI_NameDlg.cxx \
- VisuGUI_FileDlg.cxx \
- VisuGUI_CursorDlg.cxx \
- VisuGUI_TimeAnimation.cxx \
- VisuGUI_EditContainerDlg.cxx \
- VisuGUI_ClippingDlg.cxx \
- VisuGUI_DialogRunner.cxx \
- VisuGUI_OffsetDlg.cxx \
- VisuGUI_Plot3DDlg.cxx \
- VisuGUI_ScalarBarDlg.cxx \
- VisuGUI_GaussPointsDlg.cxx \
- VisuGUI_DeformedShapeDlg.cxx \
- VisuGUI_IsoSurfacesDlg.cxx \
- VisuGUI_CutLinesDlg.cxx \
- VisuGUI_CutPlanesDlg.cxx \
- VisuGUI_StreamLinesDlg.cxx \
- VisuGUI_VectorsDlg.cxx \
- VisuGUI_Displayer.cxx \
- VisuGUI_ScalarMapOnDeformedShapeDlg.cxx \
- VisuGUI_SetupPlot2dDlg.cxx \
- VisuGUI_BuildProgressDlg.cxx \
- VisuGUI_TransparencyDlg.cxx \
- VisuGUI_Timer.cxx
+ VisuGUI.cxx \
+ VisuGUI_Factory.cxx \
+ VisuGUI_Module.cxx \
+ VisuGUI_Selection.cxx \
+ VisuGUI_Tools.cxx \
+ VisuGUI_ViewTools.cxx \
+ VisuGUI_PopupTools.cxx \
+ VisuGUI_NameDlg.cxx \
+ VisuGUI_FileDlg.cxx \
+ VisuGUI_CursorDlg.cxx \
+ VisuGUI_TimeAnimation.cxx \
+ VisuGUI_EditContainerDlg.cxx \
+ VisuGUI_ClippingDlg.cxx \
+ VisuGUI_DialogRunner.cxx \
+ VisuGUI_OffsetDlg.cxx \
+ VisuGUI_Prs3dDlg.cxx \
+ VisuGUI_ScalarBarDlg.cxx \
+ VisuGUI_Plot3DDlg.cxx \
+ VisuGUI_GaussPointsDlg.cxx \
+ VisuGUI_DeformedShapeDlg.cxx \
+ VisuGUI_IsoSurfacesDlg.cxx \
+ VisuGUI_CutLinesDlg.cxx \
+ VisuGUI_CutPlanesDlg.cxx \
+ VisuGUI_StreamLinesDlg.cxx \
+ VisuGUI_VectorsDlg.cxx \
+ VisuGUI_Displayer.cxx \
+ VisuGUI_ScalarMapOnDeformedShapeDlg.cxx \
+ VisuGUI_SetupPlot2dDlg.cxx \
+ VisuGUI_BuildProgressDlg.cxx \
+ VisuGUI_TransparencyDlg.cxx \
+ VisuGUI_Timer.cxx \
+ VisuGUI_Slider.cxx \
+ VisuGUI_InputPane.cxx \
+ VisuGUI_CacheDlg.cxx \
+ VisuGUI_FieldFilter.cxx
+
+MOC_FILES= \
+ VisuGUI_moc.cxx \
+ VisuGUI_Module_moc.cxx \
+ VisuGUI_Selection_moc.cxx \
+ VisuGUI_NameDlg_moc.cxx \
+ VisuGUI_FileDlg_moc.cxx \
+ VisuGUI_CursorDlg_moc.cxx \
+ VisuGUI_TimeAnimation_moc.cxx \
+ VisuGUI_EditContainerDlg_moc.cxx \
+ VisuGUI_ClippingDlg_moc.cxx \
+ VisuGUI_DialogRunner_moc.cxx \
+ VisuGUI_OffsetDlg_moc.cxx \
+ VisuGUI_Prs3dDlg_moc.cxx \
+ VisuGUI_ScalarBarDlg_moc.cxx \
+ VisuGUI_Plot3DDlg_moc.cxx \
+ VisuGUI_GaussPointsDlg_moc.cxx \
+ VisuGUI_DeformedShapeDlg_moc.cxx \
+ VisuGUI_IsoSurfacesDlg_moc.cxx \
+ VisuGUI_CutLinesDlg_moc.cxx \
+ VisuGUI_CutPlanesDlg_moc.cxx \
+ VisuGUI_StreamLinesDlg_moc.cxx \
+ VisuGUI_VectorsDlg_moc.cxx \
+ VisuGUI_ScalarMapOnDeformedShapeDlg_moc.cxx \
+ VisuGUI_SetupPlot2dDlg_moc.cxx \
+ VisuGUI_BuildProgressDlg_moc.cxx \
+ VisuGUI_TransparencyDlg_moc.cxx \
+ VisuGUI_Slider_moc.cxx \
+ VisuGUI_InputPane_moc.cxx \
+ VisuGUI_CacheDlg_moc.cxx
-MOC_FILES= VisuGUI_moc.cxx \
- VisuGUI_Module_moc.cxx \
- VisuGUI_Selection_moc.cxx \
- VisuGUI_NameDlg_moc.cxx \
- VisuGUI_FileDlg_moc.cxx \
- VisuGUI_CursorDlg_moc.cxx \
- VisuGUI_TimeAnimation_moc.cxx \
- VisuGUI_EditContainerDlg_moc.cxx \
- VisuGUI_ClippingDlg_moc.cxx \
- VisuGUI_DialogRunner_moc.cxx \
- VisuGUI_OffsetDlg_moc.cxx \
- VisuGUI_Plot3DDlg_moc.cxx \
- VisuGUI_ScalarBarDlg_moc.cxx \
- VisuGUI_GaussPointsDlg_moc.cxx \
- VisuGUI_DeformedShapeDlg_moc.cxx \
- VisuGUI_IsoSurfacesDlg_moc.cxx \
- VisuGUI_CutLinesDlg_moc.cxx \
- VisuGUI_CutPlanesDlg_moc.cxx \
- VisuGUI_StreamLinesDlg_moc.cxx \
- VisuGUI_VectorsDlg_moc.cxx \
- VisuGUI_ScalarMapOnDeformedShapeDlg_moc.cxx \
- VisuGUI_SetupPlot2dDlg_moc.cxx \
- VisuGUI_BuildProgressDlg_moc.cxx \
- VisuGUI_TransparencyDlg_moc.cxx
nodist_libVISU_la_SOURCES=$(MOC_FILES)
# additionnal information to compil and link file
$(GUI_CXXFLAGS) \
$(CORBA_CXXFLAGS) $(CORBA_INCLUDES) \
-I$(srcdir)/../VVTK -I$(srcdir)/../OBJECT -I$(srcdir)/../VISU_I -I$(srcdir)/../GUITOOLS \
- -I$(top_builddir)/idl -I$(srcdir)/../CONVERTOR -I$(srcdir)/../PIPELINE -I$(top_builddir)/salome_adm/unix
+ -I$(top_builddir)/idl -I$(srcdir)/../CONVERTOR -I$(srcdir)/../PIPELINE \
+ -I$(top_builddir)/salome_adm/unix
libVISU_la_LDFLAGS= $(QWT_LIBS) -lSalomeNS $(KERNEL_LDFLAGS) $(GUI_LDFLAGS) -lSVTK -lSPlot2d \
- ../VVTK/libVVTK.la ../OBJECT/libVisuObject.la ../VISU_I/libVISUEngineImpl.la ../GUITOOLS/libVISUGUITOOLS.la \
+ ../VVTK/libVVTK.la ../OBJECT/libVisuObject.la ../VISU_I/libVISUEngineImpl.la \
+ ../GUITOOLS/libVISUGUITOOLS.la \
../../idl/libSalomeIDLVISU.la
+
+if MED_ENABLE_MULTIPR
+ libVISU_la_CPPFLAGS+= $(MULTIPR_CPPFLAGS)
+endif
msgid "ICON_OBJBROWSER_Visu"
msgstr "Visu_tree_visu.png"
+msgid "ICON_MULTIPR_VIEW_FULL"
+msgstr "Visu_tree_multipr_full.png"
+
+msgid "ICON_MULTIPR_VIEW_MEDIUM"
+msgstr "Visu_tree_multipr_medium.png"
+
+msgid "ICON_MULTIPR_VIEW_LOW"
+msgstr "Visu_tree_multipr_low.png"
+
+msgid "ICON_MULTIPR_VIEW_HIDE"
+msgstr "Visu_tree_multipr_hide.png"
+
+msgid "ICON_HOLO_RENDER"
+msgstr "Visu_holo_render.png"
+
msgid "ICON_SCALAR_MAP"
msgstr "Visu_scalars.png"
msgid "ICON_REMOVE"
msgstr "Visu_remove.png"
+
+msgid "ICON_SLIDER_MORE"
+msgstr "Visu_slider_more.png"
+
+msgid "ICON_SLIDER_AVI"
+msgstr "Visu_slider_avi.png"
+
+msgid "ICON_SLIDER_FIRST"
+msgstr "Visu_slider_first.png"
+
+msgid "ICON_SLIDER_PREVIOUS"
+msgstr "Visu_slider_previous.png"
+
+msgid "ICON_SLIDER_PLAY"
+msgstr "Visu_slider_play.png"
+
+msgid "ICON_SLIDER_PAUSE"
+msgstr "Visu_slider_pause.png"
+
+msgid "ICON_SLIDER_NEXT"
+msgstr "Visu_slider_next.png"
+
+msgid "ICON_SLIDER_LAST"
+msgstr "Visu_slider_last.png"
msgid "WRN_NO_AVAILABLE_DATA"
msgstr "No Available data in selection"
+msgid "WRN_EXTRA_MEMORY_REQUIRED"
+msgstr "Cache need more memory to build the presentation (%1 Mb).\nDo you want to enlarge the cache?"
+
+msgid "ERR_NO_MEMORY_TO_BUILD"
+msgstr "Please, free %1 Mb to make the cache enlarging possible\n(for example, try to delete some holders)"
+
msgid "ERR_CANT_FIND_VISU_COMPONENT"
msgstr "Failed to activate VISU engine!"
msgid "VISU_PREF_SECOND_TAB"
msgstr "Scalar range, Sweep, MED import, Shading"
-msgid "PRS_ON_GROUPS"
-msgstr "Build presentation on groups"
-
msgid "NO_GROUPS"
msgstr "No groups in the mesh"
msgid "VISU_SHRINK"
msgstr "Shrink"
+msgid "VISU_3DCACHE_PROPS"
+msgstr "3D Cache properties"
+
+msgid "VISU_MEMORY_MODE"
+msgstr "Memory mode"
+
+msgid "VISU_MINIMAL"
+msgstr "Minimal"
+
+msgid "VISU_LIMITED"
+msgstr "Limited"
+
+msgid "VISU_MEMORY_LIMIT"
+msgstr "Memory limit (Mb)"
+
#: VisuGUI.cxx
msgid "VisuGUI::MEN_IMPORT"
msgid "VisuGUI::MEN_PLOT3D_FROM_CUTPLANE"
msgstr "Plot3d"
+msgid "VisuGUI::MEN_CACHE_PROPERTIES"
+msgstr "Properties"
+
msgid "VisuGUI::ERR_ERROR_DURING_EXPORT"
msgstr "Error has been occured during exporting to file"
msgid "VisuGUI_DeformedShapeDlg::SCALAR_BAR_TAB"
msgstr "Scalar Bar"
+msgid "VisuGUI_DeformedShapeDlg::INPUT_TAB"
+msgstr "Input"
+
msgid "VisuGUI_DeformedShapeDlg::MAGNITUDE_COLORING"
msgstr "Magnitude coloring"
msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::SCALAR_BAR_TAB"
msgstr "Scalar Bar"
+msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::INPUT_TAB"
+msgstr "Input"
+
msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::SCALE_FACTOR"
msgstr "Scale Factor:"
msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::FIELD_ITEM"
-msgstr "Fields"
+msgstr "Scalar Field:"
msgid "VisuGUI_ScalarMapOnDeformedShapeDlg::TIMESTAMP_ITEM"
-msgstr "Time stamp"
+msgstr "Current Time Stamp:"
#: VisuGUI_EditContainerDlg.cxx
msgstr "Z :"
+#: VisuGUI_InputPane.cxx
+
+msgid "VisuGUI_InputPane::PRS_DATA_SOUIRCE"
+msgstr "Data Source"
+
+msgid "VisuGUI_InputPane::MED_FILE"
+msgstr "Source File :"
+
+msgid "VisuGUI_InputPane::MESH"
+msgstr "Mesh :"
+
+msgid "VisuGUI_InputPane::ENTITY"
+msgstr "Entity :"
+
+msgid "VisuGUI_InputPane::FIELD"
+msgstr "Field :"
+
+msgid "VisuGUI_InputPane::TIME_STAMP"
+msgstr "Time Stamp :"
+
+msgid "VisuGUI_InputPane::REINITIALIZE"
+msgstr "Auto Update"
+
+msgid "PRS_ON_GROUPS"
+msgstr "Use Only Groups"
+
+
#: VisuGUI_ScalarBarDlg.cxx
msgid "VisuGUI_ScalarBarDlg::&OK"
msgid "VisuGUI_Plot3DDlg::SCALAR_BAR_TAB_TITLE"
msgstr "Scalar Bar"
+msgid "VisuGUI_Plot3DDlg::INPUT_TAB_TITLE"
+msgstr "Input"
+
msgid "VisuGUI_Plot3DPane::ORIENTATION"
msgstr "Orientation"
msgid "VisuGUI_Module::VISU_RECORDER_PREF_PROGRESSIVE"
msgstr "Progressive"
+msgid "VisuGUI_Slider::TOOLBAR_TITLE"
+msgstr "Slider"
+
+msgid "VisuGUI_Slider::MORE"
+msgstr "More..."
+
+msgid "VisuGUI_Slider::CACHE_MEMORY"
+msgstr "Cache:"
+
+msgid "VisuGUI_Slider::FREE_MEMORY"
+msgstr "Free:"
+
+msgid "VisuGUI_Slider::SPEED"
+msgstr "Speed:"
+
+msgid "VisuGUI_Slider::AVI"
+msgstr "AVI"
+
msgid "VisuGUI_GaussPointsDlg::DLG_PREF_TITLE"
msgstr "Gauss Points Preferences"
msgid "VisuGUI_TransparencyDlg::BUT_CLOSE"
msgstr "Close"
+msgid "VisuGUI_CacheDlg::CACHE_TITLE"
+msgstr "Cache properties"
+
+msgid "VisuGUI_CacheDlg::MEMORY_MODE"
+msgstr "Memory mode"
+
+msgid "VisuGUI_CacheDlg::MINIMAL_MEMORY"
+msgstr "Minimal memory"
+
+msgid "VisuGUI_CacheDlg::LIMITED_MEMORY"
+msgstr "Limited memory"
+
+msgid "VisuGUI_CacheDlg::MEMORY STATE"
+msgstr "Memory state"
+
+msgid "VisuGUI_CacheDlg::USED_BY_CACHE"
+msgstr "Used by cache"
+
+msgid "VisuGUI_CacheDlg::FREE"
+msgstr "Free"
+
msgid "VVTK_ViewManager::VTK_VIEW_TITLE"
msgstr "Gauss scene:%1 - viewer:%2"
msgid "VisuGUI_GaussPointsDlg::SCALAR_BAR_TAB"
msgstr "Scalar Bar"
+msgid "VisuGUI_GaussPointsDlg::INPUT_TAB"
+msgstr "Input"
+
msgid "VisuGUI_GaussPointsDlg::PRS_TITLE"
msgstr "Presentation"
msgid "VISU_SCALAR_MAP_ON_DEFORMED_SHAPE"
msgstr "Scalar Map on Def. Shape"
+
+# MULTIPR
+msgid "VisuGUI::MEN_MULTIPR_VIEW_FULL_RES"
+msgstr "Display at full resolution"
+
+msgid "VisuGUI::MEN_MULTIPR_VIEW_MEDIUM_RES"
+msgstr "Display at medium resolution"
+
+msgid "VisuGUI::MEN_MULTIPR_VIEW_LOW_RES"
+msgstr "Display at low resolution"
+
+msgid "VisuGUI::MEN_MULTIPR_VIEW_HIDE"
+msgstr "Hide"
+
+msgid "VisuGUI::MEN_HOLO_RENDER"
+msgstr "Holo render"
#include "OB_Browser.h"
-#include "SALOME_ListIO.hxx"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SalomeApp_Application.h"
#include "VisuGUI_Displayer.h"
#include "VisuGUI_BuildProgressDlg.h"
#include "VisuGUI_TransparencyDlg.h"
+#include "VisuGUI_CacheDlg.h"
-#include "VISU_PrsMerger_i.hh"
+#include "VISU_ScalarMap_i.hh"
#include "VisuGUI_ScalarBarDlg.h"
#include "VISU_DeformedShape_i.hh"
using namespace VISU;
#ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
#endif
// Class: VisuGUI
//////////////////////////////////////////////////
-VisuGUI::VisuGUI():
+VisuGUI
+::VisuGUI():
SalomeApp_Module( "VISU" ),
myDisplayer( 0 )
{
}
-VisuGUI::~VisuGUI()
+VisuGUI
+::~VisuGUI()
{
}
void
-VisuGUI::
-OnImportFromFile()
+VisuGUI
+::OnImportFromFile()
{
if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
if ( CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this)) )
application()->putInfo( anInfo );
QApplication::setOverrideCursor(Qt::waitCursor);
+ // MULTIPR: CreateResult
VISU::Result_var aResult = GetVisuGen(this)->CreateResult( aFileInfo.filePath() );
if (CORBA::is_nil(aResult.in())) {
}
void
-VisuGUI::
-OnImportTableFromFile()
+VisuGUI
+::OnImportTableFromFile()
{
if(MYDEBUG) MESSAGE("VisuGUI::OnImportTableFromFile()");
if ( CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this)) )
}
void
-VisuGUI::
-OnExportTableToFile()
+VisuGUI
+::OnExportTableToFile()
{
if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()");
}
void
-VisuGUI::
-OnImportMedField()
+VisuGUI
+::OnImportMedField()
{
_PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
if (CheckLock(aCStudy,GetDesktop(this)))
return;
_PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
- _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry().latin1() );
+ _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry() );
if ( !theCreate && aSObject ) {
// Remove old Table
}
if ( aCutDlg->isGenerateTable() ) {
- GetVisuGen( theModule )->CreateTable( thePrs->GetEntry() );
+ GetVisuGen( theModule )->CreateTable( thePrs->GetEntry().c_str() );
if ( aCutDlg->isGenerateCurves() ) {
if ( aSObject ) {
_PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
}
void
-VisuGUI::
-OnCreateMesh()
+VisuGUI
+::OnCreateMesh()
{
+ cout << "MULTIPR: file=" << __FILE__<< " line=" << __LINE__ << " func=OnCreateMesh()" << endl;
+
_PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
if (CheckLock(aStudy,GetDesktop(this)))
return;
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
// Get selected SObject
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
if (anIO.IsNull() || !anIO->hasEntry())
return;
}
void
-VisuGUI::
-OnCreateManyMesh()
+VisuGUI
+::OnCreateManyMesh()
{
_PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
if (CheckLock(aStudy,GetDesktop(this)))
}
void
-VisuGUI::
-OnCreateScalarMap()
+VisuGUI
+::OnCreateScalarMap()
{
- CreatePrs3d<VISU::PrsMerger_i,VisuGUI_ScalarBarDlg,1>(this);
+ CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
}
void
-VisuGUI::
-OnCreateDeformedShape()
+VisuGUI
+::OnCreateDeformedShape()
{
CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
}
void
-VisuGUI::
-OnCreateScalarMapOnDeformedShape()
+VisuGUI
+::OnCreateScalarMapOnDeformedShape()
{
CreatePrs3d<VISU::ScalarMapOnDeformedShape_i,VisuGUI_ScalarMapOnDeformedShapeDlg,1>(this);
}
void
-VisuGUI::
-OnCreateVectors()
+VisuGUI
+::OnCreateVectors()
{
CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
}
void
-VisuGUI::
-OnCreateIsoSurfaces()
+VisuGUI
+::OnCreateIsoSurfaces()
{
CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
}
void
-VisuGUI::
-OnCreateCutPlanes()
+VisuGUI
+::OnCreateCutPlanes()
{
CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,0>(this);
}
void
-VisuGUI::
-OnCreateCutLines()
+VisuGUI
+::OnCreateCutLines()
{
CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,0>(this);
}
void
-VisuGUI::
-OnCreateStreamLines()
+VisuGUI
+::OnCreateStreamLines()
{
CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
}
void
-VisuGUI::
-OnCreatePlot3D()
+VisuGUI
+::OnCreatePlot3D()
{
CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,0>(this);
}
void
-VisuGUI::
-OnCreatePlot2dView()
+VisuGUI
+::OnCreatePlot2dView()
{
CheckLock(GetCStudy(GetAppStudy(this)),GetDesktop(this));
GetVisuGen( this )->CreateContainer();
}
void
-VisuGUI::
-OnDisplayPrs()
+VisuGUI
+::OnDisplayPrs()
{
if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs");
- LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
- if (!mgr) return;
+ LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ if (!aSelectionMgr)
+ return;
QApplication::setOverrideCursor(Qt::waitCursor);
- SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
-
SALOME_ListIO aSel, aList;
- mgr->selectedObjects(aSel);
+ aSelectionMgr->selectedObjects(aSel);
extractContainers(aSel, aList);
for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
Handle(SALOME_InteractiveObject) anIO = it.Value();
- CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry());
-
- if (!CORBA::is_nil(anObject)) {
- // is it Prs3d object ?
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
- if (aPrsObject) {
- if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object");
- //UpdateViewer( this, aPrsObject );
- if (vw) {
+ TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry());
+ VISU::Base_i* aBase = anObjectInfo.myBase;
+ if(!aBase)
+ continue;
+
+ VISU::VISUType aType = aBase->GetType();
+ switch (aType) {
+ case VISU::TCURVE:
+ case VISU::TCONTAINER:
+ case VISU::TTABLE:
+ displayer()->Display(anIO->getEntry());
+ break;
+ default: {
+ VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dFromBase(aBase);
+ if(aPrs3d){
+ if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(this)){
displayer()->Display(anIO->getEntry());
- vw->highlight(anIO, 1);
- }
- continue;
- }
- // is it Curve ?
- VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
- if (aCurve) {
- if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Curve object");
- //PlotCurve( this, aCurve, VISU::eDisplay );
- displayer()->Display(anIO->getEntry());
- continue;
- }
- // is it Container ?
- VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
- if (aContainer) {
- if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
- //PlotContainer( this, aContainer, VISU::eDisplay );
- displayer()->Display(anIO->getEntry());
- continue;
- }
- // is it Table ?
- VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
- if (aTable) {
- if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
- //PlotTable( this, aTable, VISU::eDisplay );
- displayer()->Display(anIO->getEntry());
- continue;
- }
+ aViewWindow->highlight(anIO, 1);
+ aViewWindow->getRenderer()->ResetCameraClippingRange();
+ aViewWindow->Repaint();
+ }
+ }}
}
}
- if (vw) {
- vw->getRenderer()->ResetCameraClippingRange();
- vw->Repaint();
- }
-
QApplication::restoreOverrideCursor();
}
void
-VisuGUI::
-OnDisplayOnlyPrs()
+VisuGUI
+::OnDisplayOnlyPrs()
{
OnEraseAll();
OnDisplayPrs();
}
void
-VisuGUI::
-OnErasePrs()
+VisuGUI
+::OnErasePrs()
{
if(MYDEBUG) MESSAGE("OnErasePrs");
-
QApplication::setOverrideCursor(Qt::waitCursor);
- //SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
- //if (vw)
- // vw->unHighlightAll();
-
SALOME_ListIO aList, aSel;
- LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
- mgr->selectedObjects(aSel);
+ LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ aSelectionMgr->selectedObjects(aSel);
extractContainers(aSel, aList);
for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
Handle(SALOME_InteractiveObject) anIO = it.Value();
- CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry());
- //ErasePrs(this, anObject, /*repaint_view_window = */false);
- ErasePrs(this, anObject, /*repaint_view_window = */true);
+ TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry());
+ VISU::Base_i* aBase = anObjectInfo.myBase;
+ ErasePrs(this, aBase, /*repaint_view_window = */true);
}
- //if (vw)
- // vw->Repaint();
-
QApplication::restoreOverrideCursor();
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnEraseAll()
+VisuGUI
+::OnEraseAll()
{
startOperation( myEraseAll );
if (SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this)) {
}
+namespace
+{
+ //----------------------------------------------------------------------------
+ VISU::Prs3d_i*
+ GetPrsToModify(const SalomeApp_Module* theModule,
+ Handle(SALOME_InteractiveObject)& theIO)
+ {
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule);
+ if(aSelectionInfo.empty())
+ return NULL;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ theIO = aSelectionItem.myIO;
+ return VISU::GetPrs3dToModify(theModule, aSelectionItem.myObjectInfo.myBase);
+ }
+}
+
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnEditScalarMap()
+VisuGUI
+::OnEditScalarMap()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
- EditPrs3d<VISU::PrsMerger_i, VisuGUI_ScalarBarDlg, 1>(this, anIO, aPrs3d);
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
+ EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg, 1>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnEditDeformedShape()
+VisuGUI
+::OnEditDeformedShape()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg, 1>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnEditScalarMapOnDeformedShape()
+VisuGUI
+::OnEditScalarMapOnDeformedShape()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::ScalarMapOnDeformedShape_i, VisuGUI_ScalarMapOnDeformedShapeDlg, 1>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnEditCutPlanes()
+VisuGUI
+::OnEditCutPlanes()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg, 0>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnEditCutLines()
+VisuGUI
+::OnEditCutLines()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg, 0>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnEditIsoSurfaces()
+VisuGUI
+::OnEditIsoSurfaces()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg, 1>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnEditVectors()
+VisuGUI
+::OnEditVectors()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg, 1>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnEditStreamLines()
+VisuGUI
+::OnEditStreamLines()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg, 1>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnEditPlot3D()
+VisuGUI
+::OnEditPlot3D()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg, 0>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnMakeSurfaceframe()
+VisuGUI
+::OnMakeSurfaceframe()
{
ChangeRepresentation(this, VISU::SURFACEFRAME);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnMakeInsideframe()
+VisuGUI
+::OnMakeInsideframe()
{
ChangeRepresentation(this, VISU::INSIDEFRAME);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnMakeWireframe()
+VisuGUI
+::OnMakeWireframe()
{
ChangeRepresentation(this, VISU::WIREFRAME);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnMakeSurface()
+VisuGUI
+::OnMakeSurface()
{
ChangeRepresentation(this, VISU::SHADED);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnMakePoints()
+VisuGUI
+::OnMakePoints()
{
ChangeRepresentation(this, VISU::POINT);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnMakeShrink()
+VisuGUI
+::OnMakeShrink()
{
ChangeRepresentation(this, VISU::SHRINK);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnSetShadingOn()
+VisuGUI
+::OnSetShadingOn()
{
SetShading(this, true);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnSetShadingOff()
+VisuGUI
+::OnSetShadingOff()
{
SetShading(this, false);
}
-void
-VisuGUI::
-OnChangeColor()
-{
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
- if (CORBA::is_nil(anObject)) return;
- PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
- if (!aServant.in()) return;
-
- VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
- if (!aPrs3d) return;
- SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
- if (!vw) return;
-
- VISU_Actor* anActor = GetActor(aPrs3d, vw);
- if (!anActor) return;
+namespace
+{
+ //----------------------------------------------------------------------------
+ bool
+ GetPrs3dSelectionInfo(const SalomeApp_Module* theModule,
+ VISU::Prs3d_i*& thePrs3d,
+ SVTK_ViewWindow*& theViewWindow,
+ VISU_Actor*& thenActor)
+ {
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule);
+ if(aSelectionInfo.empty())
+ return false;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ thePrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
+ if(!thePrs3d)
+ return false;
+
+ theViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
+ if(!theViewWindow)
+ return false;
+
+ thenActor = FindActor(theViewWindow, thePrs3d);
+ if(!thenActor)
+ return false;
+
+ return true;
+ }
+}
+//----------------------------------------------------------------------------
+void
+VisuGUI
+::OnChangeColor()
+{
+ VISU_Actor* anActor = NULL;
+ VISU::Prs3d_i* aPrs3d = NULL;
+ SVTK_ViewWindow* aViewWindow = NULL;
+ if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor))
+ return;
+
VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
+
SALOMEDS::Color anOldColor, aNewColor;
int aRepresent = anActor->GetRepresentation();
if (aMesh) {
}
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnChangeWireframeColor()
+VisuGUI
+::OnChangeWireframeColor()
{
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
- if (CORBA::is_nil(anObject)) return;
- PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
- if (!aServant.in()) return;
-
- VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
- if (!aPrs3d) return;
-
- SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
- if (!vw) return;
-
- VISU_Actor* anActor = GetActor(aPrs3d, vw);
- if (!anActor) return;
-
- if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
- SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
- QColor aColor (int(255*anOldColor.R),
- int(255*anOldColor.G),
- int(255*anOldColor.B));
- QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
- if (aColorNew.isValid()) {
- aNewColor.R = aColorNew.red()/255.;
- aNewColor.G = aColorNew.green()/255.;
- aNewColor.B = aColorNew.blue()/255.;
- aMesh->SetLinkColor(aNewColor);
- RecreateActor(this, aMesh);
- }
+ VISU_Actor* anActor = NULL;
+ VISU::Prs3d_i* aPrs3d = NULL;
+ SVTK_ViewWindow* aViewWindow = NULL;
+ if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor))
+ return;
+
+ VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
+ if(!aMesh)
+ return;
+
+ SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
+ QColor aColor (int(255*anOldColor.R),
+ int(255*anOldColor.G),
+ int(255*anOldColor.B));
+ QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
+ if (aColorNew.isValid()) {
+ aNewColor.R = aColorNew.red()/255.;
+ aNewColor.G = aColorNew.green()/255.;
+ aNewColor.B = aColorNew.blue()/255.;
+ aMesh->SetLinkColor(aNewColor);
+ RecreateActor(this, aMesh);
}
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnChangeOpacity()
+VisuGUI
+::OnChangeOpacity()
{
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
- if (CORBA::is_nil(anObject)) return;
- PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
- if (!aServant.in()) return;
-
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
- if (!aPrsObject) return;
-
- SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
- if (!vw) return;
-
- VISU_Actor* anActor = GetActor(aPrsObject, vw);
- if (!anActor) return;
-
- VisuGUI_TransparencyDlg* aTransparencyDlg = new VisuGUI_TransparencyDlg( this );
- aTransparencyDlg->show();
+ VISU_Actor* anActor = NULL;
+ VISU::Prs3d_i* aPrs3d = NULL;
+ SVTK_ViewWindow* aViewWindow = NULL;
+ if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor))
+ return;
+
+ VisuGUI_TransparencyDlg* aDialog = new VisuGUI_TransparencyDlg( this );
+ aDialog->show();
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnChangeLines()
+VisuGUI
+::OnChangeLines()
{
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
- if (CORBA::is_nil(anObject)) return;
- PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
- if (!aServant.in()) return;
-
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
- if (!aPrsObject) return;
-
- SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
- if (!vw) return;
-
- VISU_Actor* anActor = GetActor(aPrsObject, vw);
- if (!anActor) return;
-
+ VISU_Actor* anActor = NULL;
+ VISU::Prs3d_i* aPrs3d = NULL;
+ SVTK_ViewWindow* aViewWindow = NULL;
+ if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor))
+ return;
+
VisuGUI_CursorDlg* CursorDlg =
new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
delete CursorDlg;
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnShowTable()
+VisuGUI
+::OnShowTable()
{
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
- _PTR(SObject) SO;
- if ( !CORBA::is_nil( anObject ) ) {
- VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
- if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
- CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
- if( !CORBA::is_nil( aTable ) ) {
- VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
- if ( table ) {
- SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() );
- }
- }
- }
- } else {
- // possibly this is Table SObject
- SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
- }
-
- if( !IsSObjectTable( SO ) )
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+ _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
+ if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
+ aSObject = GetCStudy( GetAppStudy( this ) )->FindObjectID( aTable->GetObjectEntry() );
+
+ if( !IsSObjectTable( aSObject ) )
return;
VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
- SO,
+ aSObject,
false,
//SAL2670 Orientation of show tables
VisuGUI_TableDlg::ttAuto,
dlg->show();
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnCreateTable()
+VisuGUI
+::OnCreateTable()
{
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
- _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
- _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
- VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
- if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+
+ if((aBase && aBase->GetType() == VISU::TCUTLINES) || IsSObjectTable(aSObject)) {
GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
UpdateObjBrowser(this);
}
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnDeleteObjects()
+VisuGUI
+::OnDeleteObjects()
{
SalomeApp_Study* anAppStudy = GetAppStudy(this);
_PTR(Study) aCStudy = GetCStudy(anAppStudy);
int i = 0, nbSelected = aList.Extent();
if (nbSelected < 1) return;
- const char** entries = new const char*[nbSelected];
+ std::vector<std::string> anEntries(nbSelected);
Handle(SALOME_InteractiveObject) anIO;
for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
anIO = it.Value();
if (anIO->hasEntry())
- entries[i++] = anIO->getEntry();
+ anEntries[i++] = anIO->getEntry();
}
nbSelected = i;
if (nbSelected < 1) return;
aStudyBuilder->NewCommand();
for (i = 0; i < nbSelected; i++) {
- _PTR(SObject) aSObject = aCStudy->FindObjectID(entries[i]);
- if (aSObject) {
- _PTR(SObject) aRefObj;
- if (aSObject->ReferencedObject(aRefObj)) {
- // It can be a reference on curve, published under a container.
- // In this case the curve should be removed from the container.
- // See bug 10441.
- CORBA::Object_var aCorbaObj = VISU::GetSelectedObj(anAppStudy, aRefObj->GetID().c_str());
- if (!CORBA::is_nil(aCorbaObj)) {
- VISU::Base_var aVisuObj = VISU::Base::_narrow(aCorbaObj);
- if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TMESH)
- {
- DeleteSObject(this, aCStudy, aRefObj);
- UpdateObjBrowser(this, true, aRefObj);
+ VISU::TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(this), anEntries[i]);
+ if(_PTR(SObject) aSObject = anObjectInfo.mySObject){
+ _PTR(SObject) aRefSObject;
+ if (aSObject->ReferencedObject(aRefSObject)) {
+ // It can be a reference on curve, published under a container.
+ // In this case the curve should be removed from the container.
+ // See bug 10441.
+ VISU::TObjectInfo aRefObjectInfo = GetObjectByEntry(GetAppStudy(this), aRefSObject->GetID());
+ VISU::Base_i* aRefBase = aRefObjectInfo.myBase;
+ if(aRefBase && aRefBase->GetType() == VISU::TMESH){
+ DeleteSObject(this, aCStudy, aRefSObject);
+ UpdateObjBrowser(this, true, aRefSObject);
+ }else if(aRefBase && aRefBase->GetType() == VISU::TCURVE){
+ CORBA::Object_var anObject = ClientSObjectToObject(aRefSObject);
+ VISU::Curve_var aCurve = VISU::Curve::_narrow(anObject);
+ _PTR(SObject) aParentSO = aSObject->GetFather();
+ VISU::TObjectInfo aParentObjectInfo = GetObjectByEntry(GetAppStudy(this), aParentSO->GetID());
+ if(VISU::Base_i* aParentBase = aParentObjectInfo.myBase){
+ if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aParentBase)){
+ if(aContainer->GetNbCurves() > 0){
+ aContainer->RemoveCurve(aCurve);
+ UpdateObjBrowser(this, true, aParentSO);
+ }
+ }
}
- else if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
- VISU::Curve_ptr aCurve = VISU::Curve::_narrow(aVisuObj);
- _PTR(SObject) aParentSO = aSObject->GetFather();
- aCorbaObj = VISU::GetSelectedObj(anAppStudy, aParentSO->GetID().c_str());
- if (!CORBA::is_nil(aCorbaObj) && !CORBA::is_nil(aCurve)) {
- aVisuObj = VISU::Base::_narrow(aCorbaObj);
- if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
- // Container object
- CORBA::Object_ptr aCnt = VISU::Container::_narrow(aVisuObj);
- if (!CORBA::is_nil(aCnt)) {
- VISU::Container_i* aContainer =
- dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
- if (aContainer && aContainer->GetNbCurves() > 0) {
- aContainer->RemoveCurve(aCurve);
- UpdateObjBrowser(this, true, aParentSO);
- }
- }
- }
- }
- }
- }
- } else {
- DeleteSObject(this, aCStudy, aSObject);
- UpdateObjBrowser(this, true, aSObject);
+ }
+ }else{
+ DeleteSObject(this, aCStudy, aSObject);
+ UpdateObjBrowser(this, true, aSObject);
}
}
}
- delete [] entries;
-
// Finish transaction
aStudyBuilder->CommitCommand();
mgr->clearSelected();
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnPlotData()
+VisuGUI
+::OnPlotData()
{
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
- _PTR(SObject) SO;
- _PTR(GenericAttribute) anAttr;
- _PTR(AttributeName) aName;
- QString SOName;
- _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
-
- if ( !CORBA::is_nil( anObject ) ) {
- VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
- if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
- // Table (VISU object) is selected
- CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
- if( !CORBA::is_nil( aTbl ) ) {
- VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
- if ( table ) {
- _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
- if ( IsSObjectTable(SO) ) {
- // get name of SObject
- if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
- aName = anAttr;
- SOName = QString( aName->Value().c_str() );
- }
- VisuGUI_SetupPlot2dDlg* dlg = new VisuGUI_SetupPlot2dDlg( SO, GetDesktop( this ) );
- if ( dlg->exec() == QDialog::Accepted ) {
- if ( !IsStudyLocked( aStudy ) ) {
- // if study is not locked - create new container, create curves and insert them
- // into container, then plot container if current viewer is of VIEW_PLOT2D type
- int horIndex;
- QValueList<int> verIndices, zIndices;
- dlg->getCurvesSource( horIndex, verIndices, zIndices );
- if ( horIndex >= 0 && verIndices.count() > 0 ) {
- CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
- if( !CORBA::is_nil( aContainer ) ) {
- VISU::Container_i* pContainer =
- dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
- if ( pContainer ) {
- for ( int i = 0; i < verIndices.count(); i++ ) {
- CORBA::Object_var aNewCurve =
- GetVisuGen(this)->CreateCurveWithZ( table->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1 );
- if( !CORBA::is_nil( aNewCurve ) ) {
- VISU::Curve_i* pCrv =
- dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
- if ( pCrv ) {
- bool isAuto;
- int marker, line, lineWidth;
- QColor color;
- if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
- line, lineWidth, color) && !isAuto ) {
- SALOMEDS::Color c;
- c.R = color.red() /255.;
- c.G = color.green()/255.;
- c.B = color.blue() /255.;
- pCrv->SetColor( c );
- pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
- pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
- }
- pContainer->AddCurve( pCrv->_this() );
- }
- }
- }
- UpdateObjBrowser(this);
- PlotContainer( this, pContainer, VISU::eDisplay );
- }
- }
- }
- }
- else {
- // if study is locked just get curves info and plot them
- // if current viewer is of VIEW_PLOT2D type
- QPtrList<Plot2d_Curve> container;
- dlg->getCurves( container );
- if ( !container.isEmpty() ) {
- GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
- GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
- }
- }
- }
- delete dlg;
- }
- }
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){
+ if(aBase->GetType() == VISU::TTABLE) {
+ if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase)){
+ _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
+ _PTR(SObject) aSObject = aStudy->FindObjectID( aTable->GetObjectEntry() );
+ if(IsSObjectTable(aSObject)){
+ VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this));
+ if(aDlg->exec() == QDialog::Accepted){
+ if(!IsStudyLocked(aStudy)){
+ // if study is not locked - create new container, create curves and insert them
+ // into container, then plot container if current viewer is of VIEW_PLOT2D type
+ int horIndex;
+ QValueList<int> verIndices, zIndices;
+ aDlg->getCurvesSource( horIndex, verIndices, zIndices );
+ if( horIndex >= 0 && verIndices.count() > 0 ){
+ CORBA::Object_var aContainerObj = GetVisuGen(this)->CreateContainer();
+ if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainerObj).in())){
+ for( int i = 0; i < verIndices.count(); i++ ){
+ VISU::Curve_var aCurveObject =
+ GetVisuGen(this)->CreateCurveWithZ(aTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1 );
+ if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurveObject).in())){
+ bool isAuto;
+ int marker, line, lineWidth;
+ QColor color;
+ if ( aDlg->getCurveAttributes(verIndices[i], isAuto, marker,
+ line, lineWidth, color) && !isAuto )
+ {
+ SALOMEDS::Color c;
+ c.R = color.red() /255.;
+ c.G = color.green()/255.;
+ c.B = color.blue() /255.;
+ aCurve->SetColor( c );
+ aCurve->SetMarker( ( VISU::Curve::MarkerType )marker );
+ aCurve->SetLine( ( VISU::Curve::LineType )line, lineWidth );
+ }
+ aContainer->AddCurve(aCurveObject);
+ }
+ }
+ UpdateObjBrowser(this);
+ PlotContainer( this, aContainer, VISU::eDisplay );
+ }
+ }
+ } else {
+ // get name of SObject
+ QString aSObjectName;
+ _PTR(GenericAttribute) anAttr;
+ if(aSObject->FindAttribute( anAttr, "AttributeName" )){
+ _PTR(AttributeName) aName = anAttr;
+ aSObjectName = QString( aName->Value().c_str() );
+ }
+ // if study is locked just get curves info and plot them
+ // if current viewer is of VIEW_PLOT2D type
+ QPtrList<Plot2d_Curve> container;
+ aDlg->getCurves( container );
+ if ( !container.isEmpty() ) {
+ GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
+ GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( aSObjectName );
+ }
+ }
+ }
+ delete aDlg;
+ }
}
}
- }
- else if ( !anIO.IsNull() ) {
+ }else if(!aSelectionItem.myIO.IsNull()){
// check if Table SObject is selected
- SO = aStudy->FindObjectID( anIO->getEntry() );
- if ( IsSObjectTable(SO) ) {
- // get name of SObject
- if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
- aName = anAttr;
- SOName = QString( aName->Value().c_str() );
- }
- VisuGUI_SetupPlot2dDlg* dlg = new VisuGUI_SetupPlot2dDlg( SO, GetDesktop( this ) );
- if ( dlg->exec() == QDialog::Accepted ) {
- if ( !IsStudyLocked( aStudy ) ) {
+ _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
+ if(IsSObjectTable(aSObject)){
+ VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this));
+ if(aDlg->exec() == QDialog::Accepted){
+ _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
+ if(!IsStudyLocked(aStudy)){
// if study is not locked - create new table and container objects, create curves
// and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
int horIndex;
QValueList<int> verIndices, zIndices;
- dlg->getCurvesSource( horIndex, verIndices, zIndices );
+ aDlg->getCurvesSource( horIndex, verIndices, zIndices );
if ( horIndex >= 0 && verIndices.count() > 0 ) {
- CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() );
- CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
- if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
- VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
- VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
-
- if ( pContainer && pTable ) {
- for ( int i = 0; i < verIndices.count(); i++ ) {
- CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurveWithZ
- ( pTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1 );
- if( !CORBA::is_nil( aNewCurve ) ) {
- VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
- if ( pCrv ) {
- bool isAuto;
- int marker, line, lineWidth;
- QColor color;
- if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
- line, lineWidth, color) && !isAuto ) {
- SALOMEDS::Color c;
- c.R = color.red()/255.;
- c.G = color.green()/255.;
- c.B = color.blue()/255.;
- pCrv->SetColor( c );
- pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
- pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
- }
- pContainer->AddCurve( pCrv->_this() );
- }
- }
- }
- UpdateObjBrowser(this);
- PlotContainer( this, pContainer, VISU::eDisplay );
- }
- }
- }
+ VISU::Table_var aTableObject = GetVisuGen(this)->CreateTable(aSObject->GetID().c_str());
+ if(!CORBA::is_nil(aTableObject)){
+ VISU::Container_var aContainerObject = GetVisuGen(this)->CreateContainer();
+ VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainerObject).in());
+ for ( int i = 0; i < verIndices.count(); i++ ) {
+ VISU::Curve_var aCurveObject = GetVisuGen(this)->CreateCurveWithZ
+ ( aTableObject, horIndex+1, verIndices[i]+1, zIndices[i]+1 );
+ if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurveObject).in())){
+ bool isAuto;
+ int marker, line, lineWidth;
+ QColor color;
+ if ( aDlg->getCurveAttributes(verIndices[i], isAuto, marker,
+ line, lineWidth, color) && !isAuto )
+ {
+ SALOMEDS::Color c;
+ c.R = color.red()/255.;
+ c.G = color.green()/255.;
+ c.B = color.blue()/255.;
+ aCurve->SetColor( c );
+ aCurve->SetMarker( ( VISU::Curve::MarkerType )marker );
+ aCurve->SetLine( ( VISU::Curve::LineType )line, lineWidth );
+ }
+ aContainerObject->AddCurve(aCurveObject);
+ }
+ }
+ UpdateObjBrowser(this);
+ PlotContainer( this, aContainer, VISU::eDisplay );
+ }
+ }
} else {
+ // get name of SObject
+ QString aSObjectName;
+ _PTR(GenericAttribute) anAttr;
+ if(aSObject->FindAttribute(anAttr, "AttributeName")){
+ _PTR(AttributeName) aName = anAttr;
+ aSObjectName = QString( aName->Value().c_str() );
+ }
// if study is locked just get curves info and plot them
QPtrList<Plot2d_Curve> container;
- dlg->getCurves( container );
+ aDlg->getCurves( container );
if ( !container.isEmpty() ) {
GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
- GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
+ GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( aSObjectName );
}
}
}
- delete dlg;
+ delete aDlg;
}
}
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnCurveProperties()
+VisuGUI
+::OnCurveProperties()
{
- LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
- SALOME_ListIO aListIO;
- aSelectionMgr->selectedObjects(aListIO);
- if (aListIO.Extent() != 1) return;
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.size() != 1)
+ return;
- SalomeApp_Study* aAppStudy = GetAppStudy(this);
- const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
- CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() );
- if (CORBA::is_nil( anObject )) return;
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+ if(!aBase)
+ return;
- VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
- if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
+ if(aBase->GetType() == VISU::TCURVE) {
// Curve object
- CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
- if( !CORBA::is_nil( aCurve ) ) {
- VISU::Curve_i* aDSCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
- if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) {
+ if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase)){
+ if(!IsStudyLocked(GetCStudy(GetAppStudy(this)))){
Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
- aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() );
- aDlg.setMarker( (int)aDSCurve->GetMarker() );
- SALOMEDS::Color aColor = aDSCurve->GetColor();
+ aDlg.setLine( (int)aCurve->GetLine(), aCurve->GetLineWidth() );
+ aDlg.setMarker( (int)aCurve->GetMarker() );
+ SALOMEDS::Color aColor = aCurve->GetColor();
aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
if( aDlg.exec() == QDialog::Accepted ) {
- aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
- aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
+ aCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
+ aCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
SALOMEDS::Color newColor;
newColor.R = aDlg.getColor().red()/255.;
newColor.G = aDlg.getColor().green()/255.;
newColor.B = aDlg.getColor().blue()/255.;
- aDSCurve->SetColor( newColor );
- PlotCurve(this, aDSCurve, VISU::eDisplay);
+ aCurve->SetColor( newColor );
+ PlotCurve(this, aCurve, VISU::eDisplay);
}
}
}
}
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnClearContainer()
+VisuGUI
+::OnClearContainer()
{
_PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
if (CheckLock(aCStudy,GetDesktop(this)))
return;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
- if (anIO.IsNull() || CORBA::is_nil(anObject))
+
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+ if(!aBase)
return;
- VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
- if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
+ if(aBase->GetType() == VISU::TCONTAINER){
// Container object
- CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
- if (!CORBA::is_nil(aCnt)) {
- VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
- if (container && container->GetNbCurves() > 0) {
- container->Clear();
+ if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase)){
+ if(aContainer && aContainer->GetNbCurves() > 0){
+ aContainer->Clear();
UpdateObjBrowser(this);
}
}
}
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnEditContainer()
+VisuGUI
+::OnEditContainer()
{
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
- if (CORBA::is_nil(anObject)) return;
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+ if(!aBase)
+ return;
- PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
- if (!aServant.in()) return;
- VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
- if (!aContainer) return;
+ VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase);
+ if(!aContainer)
+ return;
VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this);
aDlg->initFromPrsObject(aContainer);
delete aDlg;
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnSaveViewParams()
+VisuGUI
+::OnSaveViewParams()
{
_PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
if (CheckLock(aCStudy,GetDesktop(this)))
UpdateObjBrowser(this);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnRestoreViewParams()
+VisuGUI
+::OnRestoreViewParams()
{
SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
if (aViewMgr->getType() != SVTK_Viewer::Type())
VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnRename()
+VisuGUI
+::OnRename()
{
_PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
if (CheckLock(aCStudy,GetDesktop(this)))
return;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
-
- _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
- if (!aSObj) return;
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
+ if(!aSObject)
+ return;
//TEST DU PARENT == VISU
_PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder();
- _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObj, "AttributeName");
+ _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObject, "AttributeName");
if (anAttr) {
_PTR(AttributeName) aName (anAttr);
QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
QApplication::setOverrideCursor(Qt::waitCursor);
// rename specific objects
- if (!CORBA::is_nil(anObject)) {
- VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
- if (!CORBA::is_nil(aVisuObj)) {
- switch (aVisuObj->GetType()) {
- case VISU::TCURVE: // Curve object
- {
- CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject);
- if (!CORBA::is_nil(aCurve)) {
- VISU::Curve_i* curve =
- dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
- if (curve)
- curve->SetName(Name.latin1());
- }
- break;
- }
- case VISU::TTABLE: // Table object
- {
- CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject);
- if (!CORBA::is_nil(aTable)) {
- VISU::Table_i* table =
- dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
- if (table)
- table->SetName(Name.latin1());
- }
- break;
- }
- case VISU::TCONTAINER: // Container object
- {
- CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject);
- if (!CORBA::is_nil(aContainer)) {
- VISU::Container_i* container =
- dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
- if (container)
- container->SetName(Name.latin1());
- }
- break;
- }
- default:
- {
- }
- }
- }
+ if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){
+ switch(aBase->GetType()){
+ case VISU::TCURVE: { // Curve object
+ if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase))
+ aCurve->SetName(Name.latin1(), true);
+ break;
+ }
+ case VISU::TTABLE: { // Table object
+ if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
+ aTable->SetName(Name.latin1(), true);
+ break;
+ }
+ case VISU::TCONTAINER: { // Container object
+ if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase))
+ aContainer->SetName(Name.latin1(), true);
+ break;
+ }
+ default: {
+ }}
}
+ }
+ if (!Name.isEmpty()) {
// rename the study object
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
aName->SetValue(Name.latin1()); // rename the SObject
anIO->setName(Name.latin1()); // rename the InteractiveObject
- ViewManagerList pvm_list;
- getApp()->viewManagers( SPlot2d_Viewer::Type(), pvm_list );
- for( SUIT_ViewManager* mgr = pvm_list.first(); mgr; mgr = pvm_list.next() )
- {
- Plot2d_ViewManager* pvm = dynamic_cast<Plot2d_ViewManager*>( mgr );
- if( pvm )
- {
- SPlot2d_Viewer* pv = dynamic_cast<SPlot2d_Viewer*>( pvm->getViewModel() );
- if( pv )
- pv->renameAll( anIO, Name.latin1() );
+ ViewManagerList aViewManagerList;
+ getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList);
+ SUIT_ViewManager* aViewManager = aViewManagerList.first();
+ for(; aViewManager; aViewManager = aViewManagerList.next()){
+ if(Plot2d_ViewManager* aManager = dynamic_cast<Plot2d_ViewManager*>(aViewManager)){
+ if(SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aManager->getViewModel()))
+ aViewer->renameAll( anIO, Name.latin1() );
}
}
UpdateObjBrowser(this, false);
-
- QApplication::restoreOverrideCursor();
}
+
+ QApplication::restoreOverrideCursor();
}
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnClippingPlanes()
+VisuGUI
+::OnClippingPlanes()
{
new VisuGUI_ClippingDlg (this, "", false);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnSweep()
+VisuGUI
+::OnSweep()
{
- // GetSelectedPrs3d
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
- if (CORBA::is_nil(anObject)) return;
- PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
- if (!aServant.in()) return;
-
- VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
- if (!aPrsObject) return;
-
- SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
- if (!vw) return;
+ VISU_Actor* anActor = NULL;
+ VISU::Prs3d_i* aPrs3d = NULL;
+ SVTK_ViewWindow* aViewWindow = NULL;
+ if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor))
+ return;
- VISU_Actor* aActor = GetActor(aPrsObject, vw);
- if (!aActor) return;
+ VISU::ScalarMap_i* aScalarMap = dynamic_cast<VISU::ScalarMap_i*>(aPrs3d);
+ if(!aScalarMap)
+ return;
- if (!aActor->GetVisibility()) {
- aActor->VisibilityOn();
- }
+ if(!anActor->GetVisibility())
+ anActor->VisibilityOn();
// Get sweep parameters
SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
}
else //if selected Linear mode of sweeping
aPercents = float(i)/aSteps;
- aPrsObject->SetMapScale(aPercents);
- aPrsObject->UpdateActor(aActor);
- vw->getRenderWindow()->Render();
+ aScalarMap->SetMapScale(aPercents);
+ aScalarMap->UpdateActor(anActor);
+ aViewWindow->getRenderWindow()->Render();
usleep(aTemp);
} catch (std::exception& exc) {
INFOS("Follow exception was occured :\n" << exc.what());
QApplication::restoreOverrideCursor();
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnTimeAnimation(int theMode)
+VisuGUI
+::OnTimeAnimation(int theMode)
{
if (!VISU::GetActiveViewWindow<SVTK_ViewWindow>(this))
return;
aAnimationDlg->show();
}
+//----------------------------------------------------------------------------
void
VisuGUI::
OnParallelTimeAnimation()
OnTimeAnimation(1);
}
-//************************************************************************
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnShowAnimation()
+VisuGUI
+::OnShowAnimation()
{
if (!VISU::GetActiveViewWindow<SVTK_ViewWindow>(this))
return;
aAnimationDlg->show();
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnCopyPresentation()
+VisuGUI
+::OnCopyPresentation()
{
_PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
if (CheckLock(aCStudy,GetDesktop(this)))
return;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
- if (CORBA::is_nil(anObject)) return;
- PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
- if (!aServant.in()) return;
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+ if(!aBase)
+ return;
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
- if (!aPrsObject) return;
+ VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dToModify(this, aBase);
+ if(!aPrs3d)
+ return;
- switch (aPrsObject->GetType()) {
- case VISU::TMESH:
- {
- VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
- VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
- aSameMesh->SameAs(aMeshPrs);
- }
- break;
- case VISU::TPRSMERGER:
- {
- VISU::PrsMerger_i* aScalarPrs = dynamic_cast<VISU::PrsMerger_i*>(aPrsObject);
- VISU::PrsMerger_i* aSameScalar = new VISU::PrsMerger_i(aScalarPrs->GetResult(),true);
- aSameScalar->SameAs(aScalarPrs);
- }
- break;
- case VISU::TDEFORMEDSHAPE:
- {
- VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
- VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true);
- aSameDeformed->SameAs(aDefPrs);
- }
- break;
- case VISU::TSCALARMAPONDEFORMEDSHAPE:
- {
- VISU::ScalarMapOnDeformedShape_i* aDefPrs =
- dynamic_cast<VISU::ScalarMapOnDeformedShape_i*>(aPrsObject);
- VISU::ScalarMapOnDeformedShape_i* aSameScalarMapOnDeformed =
- new VISU::ScalarMapOnDeformedShape_i(aDefPrs->GetResult(),true);
- aSameScalarMapOnDeformed->SameAs(aDefPrs);
- }
- break;
- case VISU::TCUTPLANES:
- {
- VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
- VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true);
- aSameCut->SameAs(aCutPrs);
- }
- break;
- case VISU::TCUTLINES:
- {
- VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
- VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true);
- aSameCut->SameAs(aCutPrs);
- }
- break;
- case VISU::TISOSURFACE:
- {
- VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
- VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult(),true);
- aSameIso->SameAs(aIsoPrs);
- }
- break;
- case VISU::TSTREAMLINES:
- {
- VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
- VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true);
- aSameLines->SameAs(aLinesPrs);
- }
- break;
- case VISU::TVECTORS:
- {
- VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
- VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true);
- aSameVectors->SameAs(aVectorsPrs);
+ if(aBase->GetType() != VISU::TMESH){
+ VISU::ColoredPrs3d_i* aColoredPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>(aBase);
+ switch (aBase->GetType()) {
+ case VISU::TSCALARMAP:
+ TSameAsFactory<VISU::TSCALARMAP>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TDEFORMEDSHAPE:
+ TSameAsFactory<VISU::TDEFORMEDSHAPE>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TSCALARMAPONDEFORMEDSHAPE:
+ TSameAsFactory<VISU::TSCALARMAPONDEFORMEDSHAPE>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TCUTPLANES:
+ TSameAsFactory<VISU::TCUTPLANES>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TCUTLINES:
+ TSameAsFactory<VISU::TCUTLINES>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TISOSURFACE:
+ TSameAsFactory<VISU::TISOSURFACE>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TSTREAMLINES:
+ TSameAsFactory<VISU::TSTREAMLINES>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TVECTORS:
+ TSameAsFactory<VISU::TVECTORS>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TPLOT3D:
+ TSameAsFactory<VISU::TPLOT3D>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
}
- break;
- case VISU::TPLOT3D:
- {
- VISU::Plot3D_i* aPlot3DPrs = dynamic_cast<VISU::Plot3D_i*>(aPrsObject);
- VISU::Plot3D_i* aSamePlot3D = new VISU::Plot3D_i(aPlot3DPrs->GetResult());
- aSamePlot3D->SameAs(aPlot3DPrs);
- }
- break;
+ UpdateObjBrowser(this);
}
- UpdateObjBrowser(this);
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnSelectionInfo()
+VisuGUI
+::OnSelectionInfo()
{
if (GetActiveViewWindow<SVTK_ViewWindow>(this))
(new VisuGUI_SelectionDlg(this))->show();
tr("BUT_OK") );
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnMergeScalarBars()
+VisuGUI
+::OnMergeScalarBars()
{
LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
SALOME_ListIO aListIO;
}
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnFreeScalarBars()
+VisuGUI
+::OnFreeScalarBars()
{
LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
SALOME_ListIO aListIO;
}
}
+//----------------------------------------------------------------------------
void
-VisuGUI::
-OnTranslatePrs()
+VisuGUI
+::OnTranslatePrs()
{
if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs");
VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this);
- _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
-
LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
SALOME_ListIO aListIO;
aSelectionMgr->selectedObjects(aListIO);
- SALOME_ListIteratorOfListIO It (aListIO);
- for (; It.More(); It.Next()) {
- Handle(SALOME_InteractiveObject)& anIO = It.Value();
+ SalomeApp_Study* aStudy = GetAppStudy(this);
+ SALOME_ListIteratorOfListIO anIter(aListIO);
+ for (; anIter.More(); anIter.Next()) {
+ Handle(SALOME_InteractiveObject) anIO = anIter.Value();
if (anIO->hasEntry()) {
- _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
- if (aSObject) {
- CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
- if (!CORBA::is_nil(aCORBAObject)) {
- PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
- if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())) {
- aDlg->addPresentation(aPrsObject);
- }
- }
- }
+ QString anEntry(anIO->getEntry());
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, anEntry);
+ if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase))
+ aDlg->addPresentation(aPrsObject);
}
}
if (aDlg->getPrsCount() > 0)
}
void
-VisuGUI::
-OnArrangeActors()
+VisuGUI
+::OnArrangeActors()
{
- SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
- if (vw) {
- ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), vw);
+ if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(this)){
+ ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), this, aViewWindow);
aDlg->exec();
delete aDlg;
}
void
-VisuGUI::
-initialize( CAM_Application* theApp )
+VisuGUI
+::initialize( CAM_Application* theApp )
{
SalomeApp_Module::initialize( theApp );
}
void
-VisuGUI::
-createActions()
+VisuGUI
+::createActions()
{
QPixmap aPixmap;
QWidget* aParent = application()->desktop();
createAction( VISU_PLOT3D_FROM_CUTPLANE, tr("MEN_PLOT3D_FROM_CUTPLANE"), QIconSet(aPixmap),
tr("MEN_PLOT3D_FROM_CUTPLANE"), "", 0, aParent, false,
this, SLOT(OnPlot3dFromCutPlane()));
+
+ createAction( VISU_CACHE_PROPERTIES, tr("MEN_CACHE_PROPERTIES"), QIconSet(),
+ tr("MEN_CACHE_PROPERTIES"), "", 0, aParent, false,
+ this, SLOT(OnCacheProperties()));
+
+#ifdef ENABLE_MULTIPR
+ // MULTIPR
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_MULTIPR_VIEW_FULL"));
+ createAction( VISU_MULTIPR_FULL_RES, tr("MEN_MULTIPR_VIEW_FULL_RES"), QIconSet(aPixmap),
+ tr("MEN_MULTIPR_VIEW_FULL_RES"), "", 0, aParent, false,
+ this, SLOT(OnMultiprViewFullRes()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_MULTIPR_VIEW_MEDIUM"));
+ createAction( VISU_MULTIPR_MED_RES, tr("MEN_MULTIPR_VIEW_MEDIUM_RES"), QIconSet(aPixmap),
+ tr("MEN_MULTIPR_VIEW_MEDIUM_RES"), "", 0, aParent, false,
+ this, SLOT(OnMultiprViewMediumRes()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_MULTIPR_VIEW_LOW"));
+ createAction( VISU_MULTIPR_LOW_RES, tr("MEN_MULTIPR_VIEW_LOW_RES"), QIconSet(aPixmap),
+ tr("MEN_MULTIPR_VIEW_LOW_RES"), "", 0, aParent, false,
+ this, SLOT(OnMultiprViewLowRes()));
+
+ aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_MULTIPR_VIEW_HIDE"));
+ createAction( VISU_MULTIPR_HIDE, tr("MEN_MULTIPR_VIEW_HIDE"), QIconSet(aPixmap),
+ tr("MEN_MULTIPR_VIEW_HIDE"), "", 0, aParent, false,
+ this, SLOT(OnMultiprViewHide()));
+#endif
}
void
-VisuGUI::
-createMenus()
+VisuGUI
+::createMenus()
{
// Add actions to menus
int aMenuId;
}
void
-VisuGUI::
-createToolBars()
+VisuGUI
+::createToolBars()
{
int aToolId = createTool( tr("TOOL_IMPORT") );
createTool( VISU_IMPORT_FROM_FILE, aToolId );
}
void
-VisuGUI::
-createPopupMenus()
+VisuGUI
+::createPopupMenus()
{
// Prepare popup menus
QtxPopupMgr* mgr = popupMgr();
mgr->insert( action( VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info
+#ifdef ENABLE_MULTIPR
+ // MULTIPR
+ mgr->insert( action( VISU_MULTIPR_FULL_RES ), -1, -1, -1 );
+ mgr->insert( action( VISU_MULTIPR_MED_RES ), -1, -1, -1 );
+ mgr->insert( action( VISU_MULTIPR_LOW_RES ), -1, -1, -1 );
+ mgr->insert( action( VISU_MULTIPR_HIDE ), -1, -1, -1 );
+#endif
+
+
// Rules
- QString aPrsAll ("'VISU::TPRSMERGER' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
- "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'");
+ QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
+ "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' "
+ "'VISU::TSCALARMAPONDEFORMEDSHAPE' 'VISU::TCOLOREDPRS3DHOLDER'");
// VISU root commands
QString aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'";
mgr->setRule( action( VISU_PLOT2D ), aRule, true );
// timestamp commands
- aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TTIMESTAMP'";
+ aRule = "client='ObjectBrowser' and selcount=1 and type in {'VISU::TTIMESTAMP' 'VISU::TFIELD'}";
mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
mgr->setRule( action( VISU_ISO_SURFACES ), aRule, true );
mgr->setRule( action( VISU_CUT_PLANES ), aRule, true );
mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D' and activeView='VTKViewer'", true );
//mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
- mgr->setRule( action( VISU_ARRANGE_ACTORS ), "client='VTKViewer' and selcount=0", true );
+ mgr->setRule( action( VISU_ARRANGE_ACTORS ), "$client in {'VTKViewer' 'VVTK'} and selcount=0", true );
// 3D presentations commands
QString aPrsType = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
- QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TPRSMERGER' 'VISU::TDEFORMEDSHAPE'}";
- QString aSurfFrameType = " and $type in {'VISU::TMESH' 'VISU::TPRSMERGER''VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}";
- QString aSurfType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TPRSMERGER' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
+ QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
+ QString aSurfFrameType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP''VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}";
+ QString aSurfType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
" 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}";
- QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TPRSMERGER' 'VISU::TISOSURFACE' "
- "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}";
- QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TPRSMERGER' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
+ QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE' 'VISU::TSCALARMAPONDEFORMEDSHAPE'}";
+ QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
"'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE' }";
aRule = "selcount=1";
mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
mgr->setRule( action( VISU_EDIT_SCALARMAP ),
- "selcount=1 and type='VISU::TPRSMERGER'", true );
+ "selcount=1 and type='VISU::TSCALARMAP'", true );
mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ),
"selcount=1 and type='VISU::TDEFORMEDSHAPE'", true );
mgr->setRule( action( VISU_EDIT_SCALARMAPONDEFORMEDSHAPE ),
//aRule = "client='ObjectBrowser' and type='MEDFIELD'";
//mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
+
+#ifdef ENABLE_MULTIPR
+ // MULTIPR
+ aRule = "client='ObjectBrowser' and $type in {'VISU::TPART'}";
+ mgr->setRule( action( VISU_MULTIPR_FULL_RES ), aRule + " and selcount>=1", true );
+ mgr->setRule( action( VISU_MULTIPR_MED_RES ), aRule + " and selcount>=1", true );
+ mgr->setRule( action( VISU_MULTIPR_LOW_RES ), aRule + " and selcount>=1", true );
+ mgr->setRule( action( VISU_MULTIPR_HIDE), aRule + " and selcount>=1", true );
+#endif
}
//***************************************************************************
LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
SALOME_ListIO aListIO;
aSelectionMgr->selectedObjects(aListIO);
+ mySelectedObjects = aListIO;
if (aListIO.Extent() < 1) return;
if (isExist && aType == VISU::TCURVE) {
isCurves = true;
} else {
- CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry());
- if (!CORBA::is_nil(anObject)) {
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
- if (aPrsObject) {
- if (aPrsObject->GetType() == VISU::TCUTPLANES) {
- VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
- if (aCutPrs) {
- isOneCutPlane = aCutPrs->GetNbPlanes() == 1;
- }
- }
- }
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry());
+ if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)){
+ if (aPrsObject->GetType() == VISU::TCUTPLANES) {
+ VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
+ if (aCutPrs) {
+ isOneCutPlane = aCutPrs->GetNbPlanes() == 1;
+ }
+ }
}
}
}
if (isOneCutPlane)
action( VISU_PLOT3D_FROM_CUTPLANE )->addTo(theMenu);
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
+ _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
+ VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(aSObject);
+ CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
+
+ if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){
+ if(aBase->GetType() == VISU::TCOLOREDPRS3DCACHE)
+ action( VISU_CACHE_PROPERTIES )->addTo(theMenu);
+ }
+
theMenu->insertSeparator();
// Check if some (nb > 0) removable objects selected
}
// Check single selection
- if (aListIO.Extent() != 1) return;
-
- Handle(SALOME_InteractiveObject) anIO;
- VISU::Storable::TRestoringMap aMap;
- CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
-
- _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry());
- if ( !SO )
+ if (aListIO.Extent() != 1)
return;
+
bool isExist;
VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
action( VISU_SHOW_ANIMATION )->addTo(theMenu);
} else if (isOBClient) {
- if (IsSObjectTable(SO)) {
+ if (IsSObjectTable(aSObject)) {
action( VISU_SHOW_TABLE )->addTo(theMenu);
action( VISU_CREATE_CURVES )->addTo(theMenu);
action( VISU_EXPORT_TABLE )->addTo(theMenu);
action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
}
} else {
- _PTR(SObject) aSFather = SO->GetFather();
+ _PTR(SObject) aSFather = aSObject->GetFather();
if (aSFather) {
_PTR(GenericAttribute) anAttr;
aSFather->FindAttribute(anAttr, "AttributeName");
//***************************************************************************
void
-VisuGUI::
-windows( QMap<int, int>& theMap ) const
+VisuGUI
+::windows( QMap<int, int>& theMap ) const
{
theMap.clear();
theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
void
-VisuGUI::
-viewManagers( QStringList& theList ) const
+VisuGUI
+::viewManagers( QStringList& theList ) const
{
theList.clear();
// append SVTK viewer only if there is no opened VVTK
QString
-VisuGUI::
-engineIOR() const
+VisuGUI
+::engineIOR() const
{
CORBA::String_var anIOR = GetVisuGen(this)->GetID();
return QString(anIOR.in());
bool
-VisuGUI::
-activateModule( SUIT_Study* theStudy )
+VisuGUI
+::activateModule( SUIT_Study* theStudy )
{
SalomeApp_Module::activateModule( theStudy );
studyActivated();
bool
-VisuGUI::
-deactivateModule( SUIT_Study* theStudy )
+VisuGUI
+::deactivateModule( SUIT_Study* theStudy )
{
setMenuShown( false );
setToolShown( false );
}
LightApp_Selection*
-VisuGUI::
-createSelection() const
+VisuGUI
+::createSelection() const
{
return new VisuGUI_Selection( (SalomeApp_Module*)this );
}
addPreference( tr( "VISU_DISP_ONLY" ), representGr,
LightApp_Preferences::Bool, "VISU", "display_only" );
+
+ // TAB: 3D Cache ; group: "Cache properties"
+ int cacheTab = addPreference( tr( "3D Cache" ) );
+
+ int cacheGr = addPreference( tr( "VISU_3DCACHE_PROPS" ), cacheTab );
+ setPreferenceProperty( cacheGr, "columns", 1 );
+
+ modes.clear();
+ modes.append( tr( "VISU_MINIMAL" ) );
+ modes.append( tr( "VISU_LIMITED" ) );
+ indices.clear();
+ indices.append( 0 );
+ indices.append( 1 );
+ setPreferenceProperty( mode, "strings", modes );
+ setPreferenceProperty( mode, "indexes", indices );
+
+ int memory_mode = addPreference( tr( "VISU_MEMORY_MODE" ), cacheGr,
+ LightApp_Preferences::Selector, "VISU", "cache_memory_mode" );
+ setPreferenceProperty( memory_mode, "strings", modes );
+ setPreferenceProperty( memory_mode, "indexes", indices );
+
+ int memory_limit = addPreference( tr( "VISU_MEMORY_LIMIT" ), cacheGr,
+ LightApp_Preferences::IntSpin, "VISU", "cache_memory_limit" );
+ setPreferenceProperty( memory_limit, "min", 1 );
+ setPreferenceProperty( memory_limit, "max", 5000 );
+ setPreferenceProperty( memory_limit, "step", 10 );
}
void VisuGUI::preferencesChanged( const QString& a, const QString& b)
return getApp()->getViewManager(theType,theIsCreate);
}
+TViewToPrs3d&
+VisuGUI
+::getScalarBarsMap()
+{
+ return myScalarBarsMap;
+}
+
+void
+VisuGUI
+::selectedObjects( SALOME_ListIO& theList ) const
+{
+ theList = mySelectedObjects;
+}
+
LightApp_Displayer* VisuGUI::displayer()
{
if( !myDisplayer )
aSObject = aCStudy->FindObjectID(anIO->getEntry());
if ( !aSObject )
continue;
- CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry());
- if (!CORBA::is_nil(anObject)) {
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
- if (aPrsObject->GetType() == VISU::TCUTPLANES) {
- aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
- if (aCutPrs)
- break;
- }
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry());
+ if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)){
+ if (aPrsObject->GetType() == VISU::TCUTPLANES) {
+ aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
+ if (aCutPrs)
+ break;
+ }
}
}
}
}
GetResourceMgr()->setValue("VISU", "scalar_bar_position_num", aPos);
- VISU::Plot3D_i* aPrs3d = CreatePrs3d<VISU::Plot3D_i>(this, aTimeStampSObj, aMeshName.latin1(), (Entity)anEntity.toInt(),
- aFieldName.latin1(), aTimeStampId.toInt());
+ VISU::Plot3D_i* aPrs3d =
+ CreatePrs3dFromFactory<VISU::Plot3D_i>(this,
+ aTimeStampSObj,
+ aMeshName.latin1(),
+ (Entity)anEntity.toInt(),
+ aFieldName.latin1(),
+ aTimeStampId.toInt(),
+ ColoredPrs3d_i::EPublishUnderTimeStamp);
if (aPrs3d) {
SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0);
aDlg->setPlane(aOrient, aRotX, aRotY, aPlanePos);
if (!(runAndWait(aDlg, 0) && (aDlg->storeToPrsObject(aPrs3d)))) {
- DeletePrs3d(this, aPrs3d, anIO);
+ DeletePrs3d(this, aPrs3d);
delete aDlg;
return;
}
application()->putInfo(QObject::tr("INF_DONE"));
}
}
+
+void VisuGUI::OnCacheProperties()
+{
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
+
+ CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
+ if( CORBA::is_nil( anObject ) )
+ return;
+
+ VISU::ColoredPrs3dCache_var aCache = VISU::GetInterface<VISU::ColoredPrs3dCache>(anObject);
+ if( CORBA::is_nil( aCache ) )
+ return;
+
+ VisuGUI_CacheDlg* aDlg = new VisuGUI_CacheDlg( aCache, this );
+ aDlg->exec();
+}
+
+#ifdef ENABLE_MULTIPR
+
+// MULTIPR
+void VisuGUI::OnMultiprViewFullRes()
+{
+ OnMultiprChangeRes('F');
+}
+
+// MULTIPR
+void VisuGUI::OnMultiprViewMediumRes()
+{
+ OnMultiprChangeRes('M');
+}
+
+// MULTIPR
+void VisuGUI::OnMultiprViewLowRes()
+{
+ OnMultiprChangeRes('L');
+}
+
+// MULTIPR
+void VisuGUI::OnMultiprViewHide()
+{
+ OnMultiprChangeRes('H');
+}
+
+// MULTIPR
+void VisuGUI::OnMultiprChangeRes(char resolution)
+{
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+ if (CheckLock(aCStudy,GetDesktop(this)))
+ return;
+
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ //cout << "selection: #=" << aSelectionInfo.size() << endl;
+
+ for (int i=0; i<aSelectionInfo.size(); i++)
+ {
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo[i];
+
+ _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
+ if (!aSObject)
+ continue;
+
+ VISU::Result_var aResult = FindResult( VISU::GetSObject( aSObject ).in() );
+ VISU::Result_i* result = dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult).in());
+
+ _PTR(GenericAttribute) anAttr;
+ if (aSObject->FindAttribute(anAttr, "AttributePixMap"))
+ {
+ _PTR(AttributePixMap) aPixMap(anAttr);
+ if ( aPixMap->HasPixMap() )
+ {
+ const char* oldIcon = aPixMap->GetPixMap().c_str();
+ if ( (strcmp(oldIcon, "ICON_MULTIPR_VIEW_FULL") == 0) ||
+ (strcmp(oldIcon, "ICON_MULTIPR_VIEW_MEDIUM") == 0) ||
+ (strcmp(oldIcon, "ICON_MULTIPR_VIEW_LOW") == 0) ||
+ (strcmp(oldIcon, "ICON_MULTIPR_VIEW_HIDE") == 0) )
+ {
+ bool hasMediumOrLow = (strstr(aSObject->GetComment().c_str(), "res=FML") != NULL);
+
+ if (resolution == 'F')
+ {
+ if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'F');
+ aPixMap->SetPixMap("ICON_MULTIPR_VIEW_FULL");
+ }
+ else if ((resolution == 'M') && hasMediumOrLow)
+ {
+ if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'M');
+ aPixMap->SetPixMap("ICON_MULTIPR_VIEW_MEDIUM");
+ }
+ else if ((resolution == 'L') && hasMediumOrLow)
+ {
+ if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'L');
+ aPixMap->SetPixMap("ICON_MULTIPR_VIEW_LOW");
+ }
+ else if (resolution == 'H')
+ {
+ if (result != NULL) result->SetResolutionMultipr(aSObject->GetName().c_str(), 'H');
+ aPixMap->SetPixMap("ICON_MULTIPR_VIEW_HIDE");
+ }
+ }
+ }
+ }
+ }
+
+ UpdateObjBrowser(this, false);
+}
+
+#endif // ENABLE_MULTIPR
#include "SalomeApp_Module.h"
+#include "SALOME_ListIO.hxx"
+
#include <map>
#include <set>
class SVTK_ViewWindow;
class Prs3d_i;
-namespace VISU{
-typedef std::pair<Prs3d_i*,int> TPrs3dToInd; // prs pointer and default index of scalar bar placement
-typedef std::set<TPrs3dToInd> TSetPrs3d;
-typedef std::map<SVTK_ViewWindow*,TSetPrs3d> TViewToPrs3d;
+namespace VISU
+{
+ typedef std::pair<Prs3d_i*,int> TPrs3dToInd; // prs pointer and default index of scalar bar placement
+ typedef std::set<TPrs3dToInd> TSetPrs3d;
+ typedef std::map<SVTK_ViewWindow*,TSetPrs3d> TViewToPrs3d;
}
class VisuGUI: public SalomeApp_Module
getViewManager(const QString& theType,
const bool theIsCreate);
- VISU::TViewToPrs3d myScalarBarsMap;
- VISU::TViewToPrs3d getScalarBarsMap() { return myScalarBarsMap; }
+ VISU::TViewToPrs3d&
+ getScalarBarsMap();
+
+ void selectedObjects( SALOME_ListIO& theList ) const;
public slots:
virtual bool deactivateModule( SUIT_Study* );
void OnArrangeActors();
void OnPlot3dFromCutPlane();
+ void OnCacheProperties();
+
+ // MULTIPR
+ void OnMultiprViewFullRes();
+ void OnMultiprViewMediumRes();
+ void OnMultiprViewLowRes();
+ void OnMultiprViewHide();
+ void OnMultiprChangeRes(char resolution);
+
protected:
virtual LightApp_Selection* createSelection() const;
void createPopupMenus();
private:
- LightApp_Displayer* myDisplayer;
+ LightApp_Displayer* myDisplayer;
+ SALOME_ListIO mySelectedObjects;
+ VISU::TViewToPrs3d myScalarBarsMap;
};
#endif
#define VISU_PLOT3D_FROM_CUTPLANE 4085
+#define VISU_CACHE_PROPERTIES 4090
+
+// MULTIPR
+#define VISU_MULTIPR_FULL_RES 4095
+#define VISU_MULTIPR_MED_RES 4096
+#define VISU_MULTIPR_LOW_RES 4097
+#define VISU_MULTIPR_HIDE 4098
+
#endif
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// 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 : VisuGUI_CacheDlg.cxx
+// Author : Oleg UVAROV
+// Module : VISU
+
+#include "VisuGUI_CacheDlg.h"
+
+#include "VisuGUI_Tools.h"
+
+#include "VISU_PipeLine.hxx"
+
+#include "SUIT_Desktop.h"
+#include "SUIT_MessageBox.h"
+#include "SUIT_Session.h"
+
+#include "SalomeApp_Module.h"
+
+#include "LightApp_Application.h"
+
+#include "QtxDblSpinBox.h"
+
+#include <qbuttongroup.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+
+VisuGUI_CacheDlg::VisuGUI_CacheDlg( VISU::ColoredPrs3dCache_var theCache,
+ SalomeApp_Module* theModule )
+ : QDialog( VISU::GetDesktop( theModule ), "VisuGUI_CacheDlg", true,
+ WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ),
+ myCache( theCache )
+{
+ setCaption( tr( "CACHE_TITLE" ) );
+
+ QVBoxLayout* aTopLayout = new QVBoxLayout( this );
+ aTopLayout->setSpacing( 6 );
+ aTopLayout->setMargin( 6 );
+ aTopLayout->setAutoAdd( true );
+
+ long aMb = 1024 * 1024;
+ bool isLimitedMemory = myCache->GetMemoryMode() == VISU::ColoredPrs3dCache::LIMITED;
+ double aLimitedMemory = myCache->GetLimitedMemory();
+ double aFreeMemory = (double)VISU_PipeLine::GetAvailableMemory( 2048 * aMb ) / (double)aMb;
+ double anUsedMemory = myCache->GetMemorySize();
+ double aLimitedMemoryMax = std::max(anUsedMemory + aFreeMemory, aLimitedMemory);
+
+ // Settings
+ QButtonGroup* aMemoryGroup = new QButtonGroup( 2, Qt::Vertical, tr( "MEMORY_MODE" ), this );
+ aMemoryGroup->setRadioButtonExclusive( true );
+
+ myLimitedMemoryButton = new QRadioButton( tr( "LIMITED_MEMORY" ), aMemoryGroup );
+ myLimitedMemoryButton->setChecked( isLimitedMemory );
+
+ myMimimalMemoryButton = new QRadioButton( tr( "MINIMAL_MEMORY" ), aMemoryGroup );
+ myMimimalMemoryButton->setChecked( !isLimitedMemory );
+
+ myLimitedMemory = new QtxDblSpinBox( 1.0, aLimitedMemoryMax, 10.0, aMemoryGroup );
+ myLimitedMemory->setSuffix( " Mb" );
+ myLimitedMemory->setValue( aLimitedMemory );
+ myLimitedMemory->setEnabled( isLimitedMemory );
+
+ connect( myLimitedMemoryButton, SIGNAL( toggled( bool ) ), myLimitedMemory, SLOT( setEnabled( bool ) ) );
+
+ // Current state
+ QGroupBox* aStateGroup = new QGroupBox( tr( "MEMORY STATE" ), this );
+ aStateGroup->setColumnLayout( 0, Qt::Vertical );
+ aStateGroup->layout()->setSpacing( 0 );
+ aStateGroup->layout()->setMargin( 0 );
+
+ QGridLayout* aStateLayout = new QGridLayout( aStateGroup->layout(), 2, 2 );
+ aStateLayout->setSpacing(6);
+ aStateLayout->setMargin(6);
+
+ QLabel* aUsedMemoryLabel = new QLabel( tr( "USED_BY_CACHE" ), aStateGroup );
+ myUsedMemory = new QLineEdit( aStateGroup );
+ myUsedMemory->setText( QString::number( anUsedMemory ) + " Mb" );
+ myUsedMemory->setReadOnly( true );
+ myUsedMemory->setEnabled( false );
+ myUsedMemory->setPaletteForegroundColor( Qt::black );
+
+ QLabel* aFreeMemoryLabel = new QLabel( tr( "FREE" ), aStateGroup );
+ myFreeMemory = new QLineEdit( aStateGroup );
+ myFreeMemory->setText( QString::number( aFreeMemory ) + " Mb" );
+ myFreeMemory->setReadOnly( true );
+ myFreeMemory->setEnabled( false );
+ myFreeMemory->setPaletteForegroundColor( Qt::black );
+
+ aStateLayout->addWidget( aUsedMemoryLabel, 0, 0 );
+ aStateLayout->addWidget( myUsedMemory, 0, 1 );
+ aStateLayout->addWidget( aFreeMemoryLabel, 1, 0 );
+ aStateLayout->addWidget( myFreeMemory, 1, 1 );
+
+ // Ok / Cancel
+ QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
+ GroupButtons->setColumnLayout(0, Qt::Vertical );
+ GroupButtons->layout()->setSpacing( 0 );
+ GroupButtons->layout()->setMargin( 0 );
+ QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+ GroupButtonsLayout->setAlignment( Qt::AlignTop );
+ GroupButtonsLayout->setSpacing( 6 );
+ GroupButtonsLayout->setMargin( 11 );
+
+ QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
+ buttonOk->setAutoDefault( TRUE );
+ buttonOk->setDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
+ GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
+
+ QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
+ buttonCancel->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
+
+ QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
+ buttonHelp->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
+
+ connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
+}
+
+VisuGUI_CacheDlg::~VisuGUI_CacheDlg()
+{
+}
+
+bool VisuGUI_CacheDlg::isLimitedMemory()
+{
+ return myLimitedMemoryButton->isChecked();
+}
+
+double VisuGUI_CacheDlg::getLimitedMemory()
+{
+ return myLimitedMemory->value();
+}
+
+void VisuGUI_CacheDlg::accept()
+{
+ if( isLimitedMemory() )
+ {
+ myCache->SetMemoryMode( VISU::ColoredPrs3dCache::LIMITED );
+ myCache->SetLimitedMemory( (float)getLimitedMemory() );
+ }
+ else
+ myCache->SetMemoryMode( VISU::ColoredPrs3dCache::MINIMAL );
+
+
+ QDialog::accept();
+}
+
+void VisuGUI_CacheDlg::onHelp()
+{
+ QString aHelpFileName;// = "types_of_gauss_points_presentations.htm";
+ LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+ if (app)
+ app->onHelpContextModule(app->activeModule() ?
+ app->moduleName(app->activeModule()->moduleName()) : QString(""), aHelpFileName);
+ else {
+ SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
+ QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
+ QObject::tr("BUT_OK"));
+ }
+}
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// 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 : VisuGUI_CacheDlg.h
+// Author : Oleg UVAROV
+// Module : VISU
+
+#ifndef VISUGUI_CACHEDLG_H
+#define VISUGUI_CACHEDLG_H
+
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(VISU_Gen)
+
+#include <qdialog.h>
+
+class QLineEdit;
+class QRadioButton;
+class QtxDblSpinBox;
+
+class SalomeApp_Module;
+
+class VisuGUI_CacheDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ VisuGUI_CacheDlg( VISU::ColoredPrs3dCache_var aCache,
+ SalomeApp_Module* theModule );
+ virtual ~VisuGUI_CacheDlg();
+
+public:
+ bool isLimitedMemory();
+ double getLimitedMemory();
+
+protected slots:
+ virtual void accept();
+
+ void onHelp();
+
+private:
+ VISU::ColoredPrs3dCache_var myCache;
+
+ QRadioButton* myMimimalMemoryButton;
+ QRadioButton* myLimitedMemoryButton;
+ QtxDblSpinBox* myLimitedMemory;
+
+ QLineEdit* myUsedMemory;
+ QLineEdit* myFreeMemory;
+};
+
+#endif
WFlags fl)
: QDialog(VISU::GetDesktop(theModule), name, modal, WStyle_Customize |
WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
- mySelectionMgr(VISU::GetSelectionMgr(theModule)),
- myVisuGUI(theModule)
+ mySelectionMgr(VISU::GetSelectionMgr(theModule)),
+ myVisuGUI(theModule),
+ myPrs3d(0),
+ myIsSelectPlane(false)
{
if (!name)
setName("VisuGUI_ClippingDlg");
SpinBoxDistance->setValue(0.5);
- myPrs3d = 0;
- myIsSelectPlane = false;
onSelectionChanged();
// signals and slots connections :
// Check contents of the resulting (clipped) presentation data
if (!isFailed) {
- VISU_PipeLine* aPL = myPrs3d->GetPL();
- VISU_PipeLine::TMapper* aM = aPL->GetMapper();
- vtkDataSet* aPrsData = aM->GetInput();
+ VISU_PipeLine* aPL = myPrs3d->GetPipeLine();
+ vtkMapper* aMapper = aPL->GetMapper();
+ vtkDataSet* aPrsData = aMapper->GetInput();
aPrsData->Update();
if (aPrsData->GetNumberOfCells() < 1) {
isFailed = true;
//=================================================================================
void VisuGUI_ClippingDlg::onSelectionChanged()
{
- if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myVisuGUI)) {
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = VISU::GetSelectedObj(myVisuGUI, &anIO);
- if (CORBA::is_nil(anObject)) return;
-
+ if(SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myVisuGUI)){
+
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(myVisuGUI);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+ if(!aBase)
+ return;
+
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
if (!anIO.IsNull())
myIO = anIO;
-
- PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
- if (!aServant.in()) return;
-
- VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
- SetPrs3d(aPrs3d);
+ SetPrs3d(dynamic_cast<VISU::Prs3d_i*>(aBase));
if (myPrs3d) {
std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false));
myPlanes.clear();
//=================================================================================
void VisuGUI_ClippingDlg::ClickOnNew()
{
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = VISU::GetSelectedObj(myVisuGUI, &anIO);
- if (CORBA::is_nil(anObject)) return;
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(myVisuGUI);
+ if(aSelectionInfo.empty())
+ return;
+
+ const VISU::TSelectionItem& aSelectionItem = aSelectionInfo[0];
+ if(!aSelectionItem.myObjectInfo.myBase)
+ return;
SetCurrentPlaneParam();
SpinBoxIJKIndex ->setEnabled(anIsControlsEnable);
CheckBoxIJKPlaneReverse->setEnabled(anIsControlsEnable);
//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
- if(myPrs3d)
- if(myPrs3d->GetPL()->GetIDMapper()->IsStructured()){
- VISU::TIdTypeVector aVec = myPrs3d->GetPL()->GetIDMapper()->GetStructure();
+ if(myPrs3d){
+ VISU_PipeLine* aPipeLine = myPrs3d->GetPipeLine();
+ VISU::PIDMapper anIDMapper = aPipeLine->GetIDMapper();
+ if(anIDMapper->IsStructured()){
+ VISU::TIdTypeVector aVec = anIDMapper->GetStructure();
switch(aVec.size()){
case 1:
ButtonGroupIJKAxis->find(0)->setEnabled(true);
break;
}
}
+ }
//ENK: 23.11.2006
}
if (myPlanes.empty() || myIsSelectPlane || !WidgetIJKTab->isEnabled())
return;
- VISU::Result_i* result = myPrs3d ? myPrs3d->GetResult() : 0;
+ VISU::Result_i* result = myPrs3d ? myPrs3d->GetCResult() : 0;
if (!result)
return;
int i, axId = ButtonGroupIJKAxis->id (ButtonGroupIJKAxis->selected());
VISU::Result_i::TAxis axis = (VISU::Result_i::TAxis) axId;
gp_Dir dir;
+ CORBA::String_var aMeshName = myPrs3d->GetMeshName();
const vector<vtkFloatingPointType> * values =
- result->GetAxisInfo(myPrs3d->GetMeshName(), axis, dir);
+ result->GetAxisInfo(aMeshName.in(), axis, dir);
if (!values)
return;
//=================================================================================
void VisuGUI_ClippingDlg::setIJKByNonStructured()
{
- if (!myPrs3d || myPlanes.empty() || !myPrs3d->GetResult())
+ if (!myPrs3d || myPlanes.empty() || !myPrs3d->GetCResult())
return;
// get plane normal
gp_Dir dir, gridDir;
double maxDot = 0;
const vector<vtkFloatingPointType> *curValues, *values = 0;
- VISU::Result_i* result = myPrs3d->GetResult();
+ VISU::Result_i* result = myPrs3d->GetCResult();
int aNbAxes = 3;
- if(myPrs3d->GetPL()->GetIDMapper()->IsStructured() &&
- !myPrs3d->GetPL()->GetIDMapper()->myType)
- aNbAxes = (myPrs3d->GetPL()->GetIDMapper()->GetStructure()).size();
+ VISU_PipeLine* aPipeLine = myPrs3d->GetPipeLine();
+ VISU::PIDMapper anIDMapper = aPipeLine->GetIDMapper();
+ if(anIDMapper->IsStructured() && !anIDMapper->myType)
+ aNbAxes = (anIDMapper->GetStructure()).size();
for (i = 0; i < aNbAxes; ++i) {
VISU::Result_i::TAxis axis = (VISU::Result_i::TAxis) i;
- curValues = result->GetAxisInfo(myPrs3d->GetMeshName(), axis, dir);
+ CORBA::String_var aMeshName = myPrs3d->GetMeshName();
+ curValues = result->GetAxisInfo(aMeshName.in(), axis, dir);
if (curValues) {
double dot = normal * dir;
//ENK: 23.11.2006 - PAL13176
//=================================================================================
bool VisuGUI_ClippingDlg::isStructured() const
{
- VISU::Result_i* result = myPrs3d ? myPrs3d->GetResult() : 0;
+ VISU::Result_i* result = myPrs3d ? myPrs3d->GetCResult() : 0;
if (result) {
gp_Dir dir;
- return result->GetAxisInfo(myPrs3d->GetMeshName(),
+ CORBA::String_var aMeshName = myPrs3d->GetMeshName();
+ return result->GetAxisInfo(aMeshName.in(),
VISU::Result_i::AXIS_X,
dir);
}
{
// set index range
int maxIndex = 0;
- VISU::Result_i* result = myPrs3d ? myPrs3d->GetResult() : 0;
+ VISU::Result_i* result = myPrs3d ? myPrs3d->GetCResult() : 0;
if (result) {
VISU::Result_i::TAxis axis = (VISU::Result_i::TAxis) axisId;
gp_Dir dir;
- const vector<vtkFloatingPointType> * indices = result->GetAxisInfo(myPrs3d->GetMeshName(),
+ CORBA::String_var aMeshName = myPrs3d->GetMeshName();
+ const vector<vtkFloatingPointType> * indices = result->GetAxisInfo(aMeshName.in(),
axis, dir);
if (indices)
maxIndex = indices->size() - 1;
#include "VisuGUI_CutLinesDlg.h"
+#include "VISU_ColoredPrs3dFactory.hh"
+
#include "VisuGUI.h"
#include "VisuGUI_Tools.h"
#include "VisuGUI_ViewTools.h"
+#include "VisuGUI_InputPane.h"
#include "VISU_Gen_i.hh"
#include "VISU_CutLines_i.hh"
+#include "VISU_ColoredPrs3dFactory.hh"
#include "VISU_PipeLine.hxx"
#include "VISU_PipeLineUtils.hxx"
#include <qhbox.h>
#include <qtabwidget.h>
#include <qhgroupbox.h>
+#include <qlineedit.h>
#include <vtkRenderer.h>
#include <vtkPolyData.h>
using namespace std;
VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule)
- : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutLinesDlg", false,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
- myPreviewActor(0),myPreviewActorGlyphs(0)
+ : VisuGUI_Prs3dDlg(theModule),
+ myPreviewActor(0),myPreviewActorGlyphs(0)
{
setCaption("Cut Lines Definition");
setSizeGripEnabled(true);
hasInit = false;
// Tab pane
- QTabWidget* aTabPane = new QTabWidget(this);
+ myTabBox = new QTabWidget(this);
// Plane of lines
QFrame* aPlanePane = new QFrame(this);
aPlaneLayout->addStretch();
- aTabPane->addTab( aPlanePane, tr("LBL_LINES_PLANE") );
+ myTabBox->addTab( aPlanePane, tr("LBL_LINES_PLANE") );
// Number of lines
QFrame* aLinesPane = new QFrame(this);
aLinesLayout->addWidget( aPosBox2 );
aLinesLayout->addStretch();
- aTabPane->addTab( aLinesPane, tr("LBL_LINES_CUT") );
+ myTabBox->addTab( aLinesPane, tr("LBL_LINES_CUT") );
myScalarPane = new VisuGUI_ScalarBarPane(this, false);
myScalarPane->setMargin( 5 );
- aTabPane->addTab(myScalarPane, "Scalar Bar");
+ myInputPane = new VisuGUI_InputPane(VISU::TCUTLINES, theModule, this);
+ myTabBox->addTab(myScalarPane, "Scalar Bar");
+ myTabBox->addTab(myInputPane, "Input");
- aMainLayout->addWidget(aTabPane);
+ aMainLayout->addWidget(myTabBox);
// Dialog buttons
QHBox* aBtnBox = new QHBox(this);
}
//------------------------------------------------------------------------------
-void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::CutLines_i* thePrs)
+void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bool theInit)
{
- myPrs = thePrs;
- myScalarPane->initFromPrsObject(thePrs);
-
- SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
- myPreviewCheck->setChecked( aResourceMgr->booleanValue("VISU", "show_preview", false) );
- myCreateTable->setChecked( aResourceMgr->booleanValue("VISU", "generate_data_table", true) );
- myCurvesCheck->setChecked( aResourceMgr->booleanValue("VISU", "generate_curves", true) );
- myCurvesCheck->setEnabled( aResourceMgr->booleanValue("VISU", "generate_curves", true) );
-
- myRotXSpn->setValue(thePrs->GetRotateX()*180./PI);
- myRotYSpn->setValue(thePrs->GetRotateY()*180./PI);
- myPosSpn->setValue(thePrs->GetDisplacement());
- setOrientation(thePrs->GetOrientationType());
-
- myNbSpn->setValue( (int)thePrs->GetNbLines() );
- myRotXSpn2->setValue(thePrs->GetRotateX2()*180./PI);
- myRotYSpn2->setValue(thePrs->GetRotateY2()*180./PI);
- myPosSpn2->setValue(thePrs->GetDisplacement2());
- setOrientation2(thePrs->GetOrientationType2());
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TCUTLINES>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
+
+ myScalarPane->initFromPrsObject(myPrsCopy);
+
+ myRotXSpn->setValue(myPrsCopy->GetRotateX()*180./PI);
+ myRotYSpn->setValue(myPrsCopy->GetRotateY()*180./PI);
+ myPosSpn->setValue(myPrsCopy->GetDisplacement());
+ setOrientation(myPrsCopy->GetOrientationType());
+
+ myNbSpn->setValue( (int)myPrsCopy->GetNbLines() );
+ myRotXSpn2->setValue(myPrsCopy->GetRotateX2()*180./PI);
+ myRotYSpn2->setValue(myPrsCopy->GetRotateY2()*180./PI);
+ myPosSpn2->setValue(myPrsCopy->GetDisplacement2());
+ setOrientation2(myPrsCopy->GetOrientationType2());
hasInit = true;
- myCutLines = new VISU::CutLines_i(thePrs->GetResult(),false);
- myCutLines->SameAs(thePrs);
- myAllCurvesInvertedCheck->setChecked(myCutLines->IsAllCurvesInverted());
- myUseAbsoluteLengthCheck->setChecked(myCutLines->IsUseAbsoluteLength());
+ myCutLines = VISU::TSameAsFactory<VISU::TCUTLINES>().Create(myPrsCopy, VISU::ColoredPrs3d_i::EDoNotPublish);
+ myCutLines->CopyCurvesInverted(myPrsCopy->GetCurvesInverted());
+ if (myCutLines->IsAllCurvesInverted()) myAllCurvesInvertedCheck->setChecked(true);
myBasePlanePos->setText( QString::number(myCutLines->GetBasePlanePosition()) );
- myCBSetDef->setChecked(thePrs->IsDefault());
+ myCBSetDef->setChecked(myPrsCopy->IsDefault());
DrawTable();
// Draw Preview
if (myPreviewCheck->isChecked()) {
createPlanes();
}
+
+ if( !theInit )
+ return;
+
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentPage( 0 );
}
//------------------------------------------------------------------------------
-int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::CutLines_i* thePrs)
+int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs)
{
- myScalarPane->storeToPrsObject(thePrs);
+ if(!myInputPane->check() || !myScalarPane->check())
+ return 0;
+
+ int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy );
- thePrs->SetOrientation(getOrientaion(),
- myRotXSpn->value()*PI/180.,
- myRotYSpn->value()*PI/180.);
- thePrs->SetDisplacement(myPosSpn->value());
- thePrs->SetNbLines((int)myNbSpn->value());
+ myPrsCopy->SetOrientation(getOrientaion(),
+ myRotXSpn->value()*PI/180.,
+ myRotYSpn->value()*PI/180.);
+ myPrsCopy->SetDisplacement(myPosSpn->value());
+ myPrsCopy->SetNbLines((int)myNbSpn->value());
- thePrs->SetOrientation2(getOrientaion(false),
- myRotXSpn2->value()*PI/180.,
- myRotYSpn2->value()*PI/180.);
- thePrs->SetDisplacement2(myPosSpn2->value());
+ myPrsCopy->SetOrientation2(getOrientaion(false),
+ myRotXSpn2->value()*PI/180.,
+ myRotYSpn2->value()*PI/180.);
+ myPrsCopy->SetDisplacement2(myPosSpn2->value());
if (!myCBSetDef->isChecked())
- thePrs->SetBasePlanePosition(myBasePlanePos->text().toDouble());
- else thePrs->SetDefault();
+ myPrsCopy->SetBasePlanePosition(myBasePlanePos->text().toDouble());
+ else myPrsCopy->SetDefault();
for (int i = 0; i < (int)myNbSpn->value(); ++i) {
if (!((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked())
- thePrs->SetLinePosition( i, myPosTable->text( i, 0 ).toDouble() );
- else thePrs->SetDefaultPosition(i);
+ myPrsCopy->SetLinePosition( i, myPosTable->text( i, 0 ).toDouble() );
+ else myPrsCopy->SetDefaultPosition(i);
}
if (myAllCurvesInvertedCheck->isChecked())
- thePrs->SetAllCurvesInverted(true);
- thePrs->SetUseAbsoluteLength(myUseAbsoluteLengthCheck->isChecked());
- return 1;
+ myPrsCopy->SetAllCurvesInverted(true);
+
+ VISU::TSameAsFactory<VISU::TCUTLINES>().Copy(thePrs, myPrsCopy);
+
+ return anIsOk;
}
//------------------------------------------------------------------------------
if (myPreviewActor != 0) return;
storeToPrsObject(myCutLines);
- myCutLines->GetPL()->Update();
- vtkAppendPolyData* aPolyData = myCutLines->GetCutLinesPL()->GetAppendPolyData();
+ myCutLines->GetPipeLine()->Update();
+ vtkAppendPolyData* aPolyData = myCutLines->GetSpecificPL()->GetAppendPolyData();
vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
aPlaneMapper->SetInput(aPolyData->GetOutput());
aPlaneMapper->ScalarVisibilityOff();
myRotXSpn2->value()*PI/180.,
myRotYSpn2->value()*PI/180.);
myCutLines->SetDisplacement2(myPosSpn2->value());*/
- //myCutLines->GetPL()->Update();
+ //myCutLines->GetPipeLine()->Update();
deletePlanes();
createPlanes();
//aView->Repaint();
if (aView) {
if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) {
//myCutLines->SetBasePlanePosition(aPos);
- // myCutLines->GetPL()->Update();
+ // myCutLines->GetPipeLine()->Update();
deletePlanes();
createPlanes();
//aView->Repaint();
SVTK_ViewWindow* aView = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
if (aView) {
if (myPreviewCheck->isChecked()) {
- // myCutLines->GetPL()->Update();
+ // myCutLines->GetPipeLine()->Update();
deletePlanes();
createPlanes();
//aView->Repaint();
void VisuGUI_CutLinesDlg::updateGlyphs(bool update){
if (myPreviewActorGlyphs == 0 ) return;
- const vtkFloatingPointType *aDirLn = myCutLines->GetCutLinesPL()->GetRealDirLn();
- const vtkFloatingPointType *aBasePnt = myCutLines->GetCutLinesPL()->GetBasePnt();
+ const vtkFloatingPointType *aDirLn = myCutLines->GetSpecificPL()->GetRealDirLn();
+ const vtkFloatingPointType *aBasePnt = myCutLines->GetSpecificPL()->GetBasePnt();
vtkFloatingPointType aSecondPnt[3];
vtkFloatingPointType aBoundCenter[3];
- vtkAppendPolyData* aPolyData = myCutLines->GetCutLinesPL()->GetAppendPolyData();
+ vtkAppendPolyData* aPolyData = myCutLines->GetSpecificPL()->GetAppendPolyData();
vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
aPlaneMapper->SetInput(aPolyData->GetOutput());
vtkFloatingPointType bounds[6];
aFloatArray->SetNumberOfComponents(3);
for(int i=0; i<3 ;i++)
- aFloatArray->InsertNextValue(aSecondPnt[i]);
+ aFloatArray->InsertNextValue(aSecondPnt[i]);
vtkDataSetAttributes* aDataSetAttributes;
aDataSetAttributes = profile->GetPointData();
if (myPreviewCheck->isChecked()) {
//Update Preview
//myCutLines->SetLinePosition( theRow, aTxt.toDouble());
- // myCutLines->GetPL()->Update();
+ // myCutLines->GetPipeLine()->Update();
deletePlanes();
createPlanes();
//aView->Repaint();
if (aView) {
if (myPreviewCheck->isChecked()) {
//Update Preview
- // myCutLines->GetPL()->Update();
+ // myCutLines->GetPipeLine()->Update();
deletePlanes();
createPlanes();
//aView->Repaint();
void VisuGUI_CutLinesDlg::accept()
{
+ //if ( !VisuGUI::CheckActiveStudyLock() ) {
+ // reject();
+ // return;
+ //}
+ // if (myScalarPane->check()) {
+ /*jfa tmp:((QWidget*)sender())->setDisabled(true);
+ storeToPrsObject(myPrsCopy);
+ if (myIsCreation) {
+ if (isGenerateTable()) {
+ visuGUI->GetVisuGen()->CreateTable(myPrsCopy->GetEntry());
+ if (isGenerateCurves()) {
+ SALOMEDSClient_Study* aStudy = study()->studyDS();
+ SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrsCopy->GetEntry());
+ if( aSObject ) {
+ SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
+ SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
+ for ( ;aIter->More(); aIter->Next()) {
+ SALOMEDSClient_SObject* aTblObj = aIter->Value();
+ if ( aTblObj ) {
+ SALOMEDSClient_GenericAttribute* anAttr;
+ if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
+ visuGUI->CreatePlot(aTblObj);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (GET_VTK_VIEWWINDOW(myMgr)) {
+ try {
+ visuGUI->CreateActor(myPrsCopy);
+ } catch (...) {
+ reject();
+ return;
+ }
+ GET_VTK_VIEWWINDOW(myMgr)->onFitAll();
+ }
+ } else {
+ visuGUI->RecreateActor(myPrsCopy);
+ if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) {
+ if (vf->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
+ vf->getRenderer()->ResetCameraClippingRange();
+ vf->Repaint();
+ }
+ }
+ // Remove old Table
+ SALOMEDSClient_Study* aStudy = study()->studyDS();
+ SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrsCopy->GetEntry());
+ if( aSObject ) {
+ SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
+ SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
+ for ( ;aIter->More(); aIter->Next()) {
+ SALOMEDSClient_SObject* aTblObj = aIter->Value();
+ if ( aTblObj ) {
+ SALOMEDSClient_GenericAttribute* anAttr;
+ if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
+ aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
+ break;
+ }
+ }
+ }
+ if (isGenerateTable()) {
+ visuGUI->GetVisuGen()->CreateTable(aSObject->GetID().c_str());
+ if (isGenerateCurves()) {
+ SALOMEDSClient_Study* aStudy = study()->studyDS();
+ SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
+ SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
+ for ( ;aIter->More(); aIter->Next()) {
+ SALOMEDSClient_SObject* aTblObj = aIter->Value();
+ if ( aTblObj ) {
+ SALOMEDSClient_GenericAttribute* anAttr;
+ if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
+ visuGUI->CreatePlot(aTblObj);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ VisuGUI::application()->objectBrowser()->updateTree();*/
myScalarPane->deletePreview();
deletePlanes();
QDialog::accept();
void VisuGUI_CutLinesDlg::reject()
{
/*jfa tmp:if (myIsCreation) {
- myPrs->RemoveFromStudy();
+ myPrsCopy->RemoveFromStudy();
VisuGUI::application()->objectBrowser()->updateTree();
}*/
myScalarPane->deletePreview();
if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
if (thePreview) {
//storeToPrsObject(myCutLines);
- // myCutLines->GetPL()->Update();
+ // myCutLines->GetPipeLine()->Update();
createPlanes();
//vf->onFitAll();
} else {
{
if (myAllCurvesInvertedCheck->isChecked()){
myCutLines->SetAllCurvesInverted(true);
- myPrs->SetAllCurvesInverted(true);
+ myPrsCopy->SetAllCurvesInverted(true);
}
else {
myCutLines->SetAllCurvesInverted(false);
- myPrs->SetAllCurvesInverted(false);
+ myPrsCopy->SetAllCurvesInverted(false);
}
updateGlyphs(true);
}
myCutLines->SetOrientation2(getOrientaion(false),
myRotXSpn2->value()*PI/180.,
myRotYSpn2->value()*PI/180.);*/
- // myCutLines->GetPL()->Update();
+ // myCutLines->GetPipeLine()->Update();
deletePlanes();
createPlanes();
//aView->Repaint();
if (aView) {
if (myPreviewCheck->isChecked()) {
//myCutLines->SetBasePlanePosition(theValue.toDouble());
- // myCutLines->GetPL()->Update();
+ // myCutLines->GetPipeLine()->Update();
deletePlanes();
createPlanes();
//aView->Repaint();
#include <qhbuttongroup.h>
#include <qvalidator.h>
+#include <qtabwidget.h>
+#include <qcheckbox.h>
+
+class QLineEdit;
class SUIT_ViewManager;
class SalomeApp_Module;
+class VisuGUI_InputPane;
-namespace VISU{
+namespace VISU
+{
class CutLines_i;
}
-class VisuGUI_CutLinesDlg: public QDialog
+class VisuGUI_CutLinesDlg: public VisuGUI_Prs3dDlg
{
Q_OBJECT
VisuGUI_CutLinesDlg (SalomeApp_Module* theModule);
~VisuGUI_CutLinesDlg();
- void initFromPrsObject (VISU::CutLines_i* thePrs);
- int storeToPrsObject (VISU::CutLines_i* thePrs);
+ virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true);
+ virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs);
bool isGenerateTable() { return myCreateTable->isChecked(); }
bool isGenerateCurves() { return myCreateTable->isChecked() && myCurvesCheck->isChecked(); }
QDoubleValidator *mydvalidator;
VISU::CutLines_i* myCutLines;
+ QTabWidget* myTabBox;
VisuGUI_ScalarBarPane* myScalarPane;
+ VisuGUI_InputPane* myInputPane;
VISU::CutPlanes::Orientation getOrientaion (bool IsBasePlane = true);
void setOrientation (const VISU::CutPlanes::Orientation orient);
QCheckBox* myAllCurvesInvertedCheck;
QCheckBox* myUseAbsoluteLengthCheck;
- VISU::CutLines_i* myPrs;
-
- //jfa tmp:SUIT_ViewManager *myMgr;
- //jfa tmp:SUIT_ViewWindow *myStudyWnd;
-
- static bool MYGenerateTable;
- static bool MYGenerateCurve;
+ SALOME::GenericObjPtr<VISU::CutLines_i> myPrsCopy;
};
#endif // VISUGUI_CUTLINESDLG_H
#include "VisuGUI_CutPlanesDlg.h"
+#include "VISU_ColoredPrs3dFactory.hh"
+
#include "VisuGUI.h"
#include "VisuGUI_Tools.h"
#include "VisuGUI_ViewTools.h"
+#include "VisuGUI_InputPane.h"
+#include "VISU_ColoredPrs3dFactory.hh"
#include "VISU_CutPlanes_i.hh"
#include "VISU_CutPlanesPL.hxx"
#include "SUIT_ResourceMgr.h"
#include <qlayout.h>
+#include <qbuttongroup.h>
#include <qcheckbox.h>
#include <qstyle.h>
#include <qstring.h>
myPosSpn->setValue(thePrs->GetDisplacement());
hasInit = true;
// init table
- myCutPlanes = new VISU::CutPlanes_i(thePrs->GetResult(),false);
+ myCutPlanes = VISU::TSameAsFactory<VISU::TCUTPLANES>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
myCutPlanes->SameAs(thePrs);
DrawTable();
if (myCutPlanes == NULL) return;
if (myPreviewActor != 0) return;
- vtkAppendPolyData* aPolyData = myCutPlanes->GetCutPlanesPL()->GetAppendPolyData();
+ vtkAppendPolyData* aPolyData = myCutPlanes->GetSpecificPL()->GetAppendPolyData();
if (!aPolyData->GetOutput()->GetNumberOfCells()) {
onPreviewCheck(false);
return;
// Update preview
if (myPreviewCheck->isChecked()) {
if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
- myCutPlanes->GetPL()->Update();
+ myCutPlanes->GetPipeLine()->Update();
deletePlanes();
createPlanes();
vf->Repaint();
//Update Preview
if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
myCutPlanes->SetPlanePosition( theRow, aTxt.toDouble());
- myCutPlanes->GetPL()->Update();
+ myCutPlanes->GetPipeLine()->Update();
deletePlanes();
createPlanes();
vf->Repaint();
if (myPreviewCheck->isChecked()) {
if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
//Update Preview
- myCutPlanes->GetPL()->Update();
+ myCutPlanes->GetPipeLine()->Update();
deletePlanes();
createPlanes();
vf->Repaint();
if (myPreviewCheck->isChecked()) {
if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.);
- myCutPlanes->GetPL()->Update();
+ myCutPlanes->GetPipeLine()->Update();
deletePlanes();
createPlanes();
vf->Repaint();
if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
if (thePreview) {
storeToPrsObject(myCutPlanes);
- myCutPlanes->GetPL()->Update();
+ myCutPlanes->GetPipeLine()->Update();
createPlanes();
vf->onFitAll();
} else {
Constructor
*/
VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg (SalomeApp_Module* theModule)
- : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutPlanesDlg", false,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+ : VisuGUI_Prs3dDlg(theModule)
{
setCaption("Cut Planes Definition");
setSizeGripEnabled(true);
TopLayout->setMargin(11);
// Tab pane
- QTabWidget* aTabBox = new QTabWidget(this);
+ myTabBox = new QTabWidget(this);
myCutPane = new VisuGUI_CutPlanesPane(this/*, myMgr*/);
- aTabBox->addTab(myCutPane, "Cut Planes");
+ myTabBox->addTab(myCutPane, "Cut Planes");
myScalarPane = new VisuGUI_ScalarBarPane(this, false);
myScalarPane->setMargin(5);
- aTabBox->addTab(myScalarPane, "Scalar Bar");
+ myInputPane = new VisuGUI_InputPane(VISU::TCUTPLANES, theModule, this);
+ myTabBox->addTab(myScalarPane, "Scalar Bar");
+ myTabBox->addTab(myInputPane, "Input");
- TopLayout->addWidget(aTabBox);
+ TopLayout->addWidget(myTabBox);
QGroupBox* GroupButtons = new QGroupBox(this, "GroupButtons");
GroupButtons->setGeometry(QRect(10, 10, 281, 48));
// this, SLOT(onWindowActivated(SUIT_ViewWindow*)));
}
-void VisuGUI_CutPlanesDlg::initFromPrsObject (VISU::CutPlanes_i* thePrs)
+VisuGUI_CutPlanesDlg::~VisuGUI_CutPlanesDlg()
+{}
+
+void VisuGUI_CutPlanesDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bool theInit)
{
- myPrs = thePrs;
- myScalarPane->initFromPrsObject(thePrs);
- myCutPane->initFromPrsObject(thePrs);
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TCUTPLANES>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
+
+ myScalarPane->initFromPrsObject( myPrsCopy );
+
+ if( !theInit )
+ return;
+
+ myScalarPane->initFromPrsObject(myPrsCopy);
+ myCutPane->initFromPrsObject(myPrsCopy);
+
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentPage( 0 );
}
-int VisuGUI_CutPlanesDlg::storeToPrsObject (VISU::CutPlanes_i* thePrs)
+int VisuGUI_CutPlanesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs)
{
- return (myScalarPane->storeToPrsObject(thePrs) &&
- myCutPane->storeToPrsObject(thePrs));
+ if(!myInputPane->check() || !myScalarPane->check())
+ return 0;
+
+ int anIsOk = myInputPane->storeToPrsObject(myPrsCopy);
+ anIsOk &= myScalarPane->storeToPrsObject(myPrsCopy);
+ anIsOk &= myCutPane->storeToPrsObject(myPrsCopy);
+
+ VISU::TSameAsFactory<VISU::TCUTPLANES>().Copy(thePrs, myPrsCopy);
+
+ return anIsOk;
}
void VisuGUI_CutPlanesDlg::accept()
#ifndef VISUGUI_CUTPLANESDLG_H
#define VISUGUI_CUTPLANESDLG_H
-#include "VisuGUI_ScalarBarDlg.h"
-#include "VISU_CutPlanes_i.hh"
+#include "VisuGUI_Prs3dDlg.h"
#include <SALOME_Actor.h>
+#include <qspinbox.h>
#include <qradiobutton.h>
#include <qtable.h>
+#include <qtabwidget.h>
+
+#include <QtxDblSpinBox.h>
#include "SALOMEconfig.h"
#include CORBA_CLIENT_HEADER(VISU_Gen)
-class QtxDblSpinBox;
+namespace VISU
+{
+ class CutPlanes_i;
+};
+
class SUIT_ViewWindow;
class SUIT_ViewManager;
class SalomeApp_Module;
-
+class VisuGUI_InputPane;
class VisuGUI_CutPlanesPane : public QFrame
{
};
-class VisuGUI_CutPlanesDlg : public QDialog
+class VisuGUI_CutPlanesDlg : public VisuGUI_Prs3dDlg
{
Q_OBJECT
public:
VisuGUI_CutPlanesDlg (SalomeApp_Module* theModule);
- ~VisuGUI_CutPlanesDlg() {};
+ ~VisuGUI_CutPlanesDlg();
- void initFromPrsObject (VISU::CutPlanes_i* thePrs);
- int storeToPrsObject (VISU::CutPlanes_i* thePrs);
+ virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true);
+ virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs);
private:
void keyPressEvent( QKeyEvent* e );
void onHelp();
private:
+ QTabWidget* myTabBox;
VisuGUI_CutPlanesPane* myCutPane;
VisuGUI_ScalarBarPane* myScalarPane;
+ VisuGUI_InputPane* myInputPane;
VISU::CutPlanes_i* myPrs;
+ SALOME::GenericObjPtr<VISU::CutPlanes_i> myPrsCopy;
};
#include "VisuGUI.h"
#include "VisuGUI_Tools.h"
+#include "VisuGUI_InputPane.h"
+#include "VISU_ColoredPrs3dFactory.hh"
#include "VISU_DeformedShape_i.hh"
#include "SalomeApp_Module.h"
* Constructor
*/
VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule)
- : QDialog(VISU::GetDesktop(theModule), "VisuGUI_DeformedShapeDlg", true,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+ : VisuGUI_Prs3dDlg(theModule)
{
setCaption(tr("DLG_TITLE"));
setSizeGripEnabled(TRUE);
TopLayout->setSpacing(6);
TopLayout->setMargin(11);
- QTabWidget* aTabBox = new QTabWidget (this);
+ myTabBox = new QTabWidget (this);
// Deformed shape pane
QVBox* aBox = new QVBox (this);
UseMagn->setChecked(true);
TopGroupLayout->addMultiCellWidget(UseMagn, 1, 1, 0, 1);
- aTabBox->addTab(aBox, tr("DEFORMED_SHAPE_TAB"));
+ myTabBox->addTab(aBox, tr("DEFORMED_SHAPE_TAB"));
// Scalar bar pane
myScalarPane = new VisuGUI_ScalarBarPane (this, false);
myScalarPane->setMargin(5);
+ myInputPane = new VisuGUI_InputPane(VISU::TDEFORMEDSHAPE, theModule, this);
- aTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB"));
+ myTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB"));
+ myTabBox->addTab(myInputPane, tr("INPUT_TAB"));
// Buttons
QGroupBox* GroupButtons = new QGroupBox (this, "GroupButtons");
GroupButtonsLayout->addWidget(buttonHelp, 0, 3);
// Add Tab box and Buttons to the top layout
- TopLayout->addWidget(aTabBox);
+ TopLayout->addWidget(myTabBox);
TopLayout->addWidget(GroupButtons);
// signals and slots connections
connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
}
-void VisuGUI_DeformedShapeDlg::initFromPrsObject (VISU::DeformedShape_i* thePrs)
+VisuGUI_DeformedShapeDlg::~VisuGUI_DeformedShapeDlg()
+{}
+
+void VisuGUI_DeformedShapeDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bool theInit)
{
- myScalarPane->initFromPrsObject(thePrs);
- setFactor(thePrs->GetScale());
- UseMagn->setChecked(thePrs->IsColored());
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TDEFORMEDSHAPE>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
+
+ myScalarPane->initFromPrsObject( myPrsCopy );
+
+ setFactor(myPrsCopy->GetScale());
+ UseMagn->setChecked(myPrsCopy->IsColored());
+
+ if( !theInit )
+ return;
+
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentPage( 0 );
}
-int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::DeformedShape_i* thePrs) {
- myScalarPane->storeToPrsObject(thePrs);
- thePrs->SetScale(getFactor());
- thePrs->ShowColored(isColored());
- return 1;
+int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
+{
+ if(!myInputPane->check() || !myScalarPane->check())
+ return 0;
+
+ int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy );
+
+ myPrsCopy->SetScale(getFactor());
+ myPrsCopy->ShowColored(isColored());
+
+ VISU::TSameAsFactory<VISU::TDEFORMEDSHAPE>().Copy(thePrs, myPrsCopy);
+
+ return anIsOk;
}
void VisuGUI_DeformedShapeDlg::accept() {
#ifndef VISUGUI_DEFORMEDSHAPEDLS_H
#define VISUGUI_DEFORMEDSHAPEDLS_H
-#include "VisuGUI_ScalarBarDlg.h"
+#include "VisuGUI_Prs3dDlg.h"
#include "QtxDblSpinBox.h"
#include <qcheckbox.h>
#include <qlabel.h>
#include <qpushbutton.h>
+#include <qtabwidget.h>
class SalomeApp_Module;
+class VisuGUI_InputPane;
-namespace VISU{
+namespace VISU
+{
class DeformedShape_i;
}
-class VisuGUI_DeformedShapeDlg : public QDialog
+class VisuGUI_DeformedShapeDlg : public VisuGUI_Prs3dDlg
{
Q_OBJECT
public:
VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule);
- ~VisuGUI_DeformedShapeDlg() {};
+ ~VisuGUI_DeformedShapeDlg();
double getFactor()
{ return ScalFact->value(); }
bool isColored()
{ return UseMagn->isChecked(); }
- void initFromPrsObject(VISU::DeformedShape_i* thePrs);
- int storeToPrsObject(VISU::DeformedShape_i* thePrs);
+ virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true);
+ virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs);
private:
void keyPressEvent( QKeyEvent* e );
private:
QtxDblSpinBox* ScalFact;
QCheckBox* UseMagn;
+ QTabWidget* myTabBox;
VisuGUI_ScalarBarPane* myScalarPane;
+ VisuGUI_InputPane* myInputPane;
+ SALOME::GenericObjPtr<VISU::DeformedShape_i> myPrsCopy;
};
#endif // VISUGUI_DEFORMEDSHAPEDLS_H
{
}
-SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& entry, SALOME_View* theViewFrame )
+SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& theEntry, SALOME_View* theView )
{
- SALOME_Prs* prs = 0;
+ SALOME_Prs* aPrs = 0;
- SALOME_View* aViewFrame = theViewFrame ? theViewFrame : GetActiveView();
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
+ SALOME_View* aView = theView ? theView : GetActiveView();
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
- if ( study && aViewFrame )
- {
- _PTR(SObject) obj = study->studyDS()->FindObjectID( entry.latin1() );
- CORBA::Object_var anObj = VISU::ClientSObjectToObject( obj );
- if( CORBA::is_nil( anObj ) )
+ if(aStudy && aView){
+ _PTR(SObject) aSObject = aStudy->studyDS()->FindObjectID( theEntry.latin1() );
+ CORBA::Object_var anObject = VISU::ClientSObjectToObject( aSObject );
+ if( CORBA::is_nil( anObject ) )
return 0;
- SVTK_Viewer* vtk_viewer = dynamic_cast<VVTK_Viewer*>( aViewFrame );
- if (!vtk_viewer)
- vtk_viewer = dynamic_cast<SVTK_Viewer*>( aViewFrame );
- if( vtk_viewer )
- {
- SVTK_ViewWindow* wnd =
- dynamic_cast<SVTK_ViewWindow*>( vtk_viewer->getViewManager()->getActiveView() );
- if( wnd )
- {
- VISU::Prs3d_i* thePrs = dynamic_cast<VISU::Prs3d_i*>( VISU::GetServant( anObj ).in() );
- if( thePrs )
- {
- buildPrs3d( wnd, thePrs );
- prs = LightApp_Displayer::buildPresentation( entry, aViewFrame );
+ VISU::Base_var aBase = VISU::Base::_narrow(anObject);
+ if (CORBA::is_nil(aBase))
+ return 0;
+
+ VISU::Base_i* aBaseServant = dynamic_cast<VISU::Base_i*>(VISU::GetServant(aBase).in());
+
+ VISU::VISUType aType = aBase->GetType();
+ VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aBase);
+ if(!CORBA::is_nil(aPrs3d) || aType == VISU::TCOLOREDPRS3DHOLDER){
+ SVTK_Viewer* aViewer = dynamic_cast<VVTK_Viewer*>( aView );
+ if (!aViewer)
+ aViewer = dynamic_cast<SVTK_Viewer*>( aView );
+ if( aViewer ){
+ SUIT_ViewManager* aViewManager = aViewer->getViewManager();
+ SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aWindow )){
+ VISU::Prs3d_i* aPrs3d = NULL;
+ if(aType == VISU::TCOLOREDPRS3DHOLDER){
+ VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(aBase);
+ VISU::ColoredPrs3d_var aColoredPrs3d = aHolder->GetDevice();
+ aPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aColoredPrs3d).in());
+ }else
+ aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aBaseServant);
+
+ if(aPrs3d){
+ buildPrs3d( aViewWindow, aPrs3d );
+ Handle(SALOME_InteractiveObject) anIO = aPrs3d->GetIO();
+ if(anIO->hasEntry()){
+ std::string anEntry = anIO->getEntry();
+ aPrs = LightApp_Displayer::buildPresentation( anEntry, aView );
+ }
+ }
}
}
}
- SPlot2d_Viewer* plot_viewer = dynamic_cast<SPlot2d_Viewer*>( aViewFrame );
- if( plot_viewer )
- {
- Plot2d_ViewWindow* wnd =
- dynamic_cast<Plot2d_ViewWindow*>( plot_viewer->getViewManager()->getActiveView() );
- if( !wnd )
+ if(SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aView)){
+ SUIT_ViewManager* aViewManager = aViewer->getViewManager();
+ SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
+ Plot2d_ViewWindow* aViewWindow = dynamic_cast<Plot2d_ViewWindow*>( aWindow );
+ if( !aViewWindow )
return 0;
+
+ SPlot2d_Prs* aPlot2dPrs = 0;
+ switch (aType) {
+ case VISU::TCURVE: {
+ VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBaseServant);
+ aPlot2dPrs = buildCurve( aViewWindow, aCurve );
+ break;
+ }
+ case VISU::TCONTAINER: {
+ VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBaseServant);
+ aPlot2dPrs = buildContainer( aViewWindow, aContainer );
+ break;
+ }
+ case VISU::TTABLE: {
+ VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBaseServant);
+ aPlot2dPrs = buildTable( aViewWindow, aTable );
+ break;
+ }}
- VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( anObj ).in() );
- SPlot2d_Prs* iprs = 0;
- if( aCurve )
- iprs = buildCurve( wnd, aCurve );
-
- VISU::Container_i* aCont = dynamic_cast<VISU::Container_i*>( VISU::GetServant( anObj ).in() );
- if( aCont )
- iprs = buildContainer( wnd, aCont );
-
- VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant( anObj ).in() );
- if( aTable )
- iprs = buildTable( wnd, aTable );
-
- if( iprs )
- prs = new SPlot2d_Prs( iprs );
+ if( aPlot2dPrs )
+ aPrs = new SPlot2d_Prs( aPlot2dPrs );
- if( prs )
- UpdatePrs( prs );
+ if( aPrs )
+ UpdatePrs( aPrs );
}
}
- return prs;
+ return aPrs;
}
-void VisuGUI_Displayer::buildPrs3d( SVTK_ViewWindow* wnd, VISU::Prs3d_i* thePrs ) const
+void VisuGUI_Displayer::buildPrs3d( SVTK_ViewWindow* theViewWindow, VISU::Prs3d_i* thePrs3d ) const
{
- VISU_Actor* newAct = VISU::FindActor(wnd, thePrs);
- if (!newAct) {
+ VISU_Actor* anActor = VISU::FindActor(theViewWindow, thePrs3d);
+ if (!anActor) {
try {
- newAct = thePrs->CreateActor();
+ anActor = thePrs3d->CreateActor();
} catch (std::runtime_error& exc) {
- thePrs->RemoveActors();
+ thePrs3d->RemoveActors();
INFOS(exc.what());
SUIT_MessageBox::warn1
QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()),
QObject::tr("BUT_OK"));
}
- }
- if (newAct) {
- wnd->AddActor(newAct);
- wnd->Repaint();
- }
+ if (anActor)
+ theViewWindow->AddActor(anActor);
+ } else
+ anActor->SetVisibility(true);
+
+ theViewWindow->Repaint();
}
bool VisuGUI_Displayer::addCurve( SPlot2d_Prs* prs, Plot2d_ViewWindow* wnd, VISU::Curve_i* c ) const
if( !study )
return prs;
- _PTR(SObject) TableSO = study->studyDS()->FindObjectID( t->GetEntry().latin1() );
+ _PTR(SObject) TableSO = study->studyDS()->FindObjectID( t->GetEntry() );
if( !TableSO )
return prs;
if( viewer_type==SVTK_Viewer::Type() || viewer_type==VVTK_Viewer::Type())
{
- VISU::Prs3d_i* thePrs = dynamic_cast<VISU::Prs3d_i*>( VISU::GetServant( anObj ).in() );
- return thePrs;
+ VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObj).in());
+ if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER)
+ return true;
+
+ return dynamic_cast<VISU::Prs3d_i*>(aBase);
}
else if( viewer_type==SPlot2d_Viewer::Type() )
{
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// 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 : VisuGUI_FieldFilter.cxx
+// Author : Oleg UVAROV
+// Module : VISU
+
+#include "VisuGUI_FieldFilter.h"
+
+#include "VisuGUI_Tools.h"
+
+#include "VISUConfig.hh"
+#include "VISU_ColoredPrs3dFactory.hh"
+
+#include <SUIT_Session.h>
+
+#include <SalomeApp_Study.h>
+#include <LightApp_DataOwner.h>
+
+using namespace VISU;
+
+VisuGUI_FieldFilter::VisuGUI_FieldFilter( VISU::VISUType theType ) :
+ myType( theType )
+{
+}
+
+VisuGUI_FieldFilter::~VisuGUI_FieldFilter()
+{
+}
+
+void VisuGUI_FieldFilter::setPrs3dEntry( const QString& theEntry )
+{
+ myPrs3dEntry = theEntry;
+}
+
+bool VisuGUI_FieldFilter::isOk( const SUIT_DataOwner* theDataOwner ) const
+{
+ const LightApp_DataOwner* anOwner =
+ dynamic_cast<const LightApp_DataOwner*>( theDataOwner );
+
+ SalomeApp_Study* anAppStudy = dynamic_cast<SalomeApp_Study*>
+ (SUIT_Session::session()->activeApplication()->activeStudy());
+
+ if( anOwner && anAppStudy )
+ {
+ if(myPrs3dEntry == anOwner->entry())
+ return true;
+
+ _PTR(Study) aStudy = anAppStudy->studyDS();
+ _PTR(SObject) aSObject = aStudy->FindObjectID( anOwner->entry() );
+ if (!aSObject)
+ return false;
+
+ _PTR(SObject) aRefSO;
+ if( aSObject->ReferencedObject( aRefSO ) )
+ aSObject = aRefSO;
+
+ if( !aSObject )
+ return false;
+
+ _PTR(GenericAttribute) anAttr;
+ if( !aSObject->FindAttribute( anAttr, "AttributeString" ) )
+ return false;
+
+ _PTR(AttributeString) aComment( anAttr );
+ string aComm = aComment->Value();
+ QString strIn( aComm.c_str() );
+
+ bool isExist;
+ VISU::Storable::TRestoringMap aMap;
+ VISU::Storable::StrToMap( strIn, aMap );
+ VISU::VISUType aType = ( VISU::VISUType )VISU::Storable::FindValue( aMap, "myType", &isExist ).toInt();
+
+ if( aType == VISU::TFIELD )
+ {
+ VISU::Result_var aResult = FindResult( VISU::GetSObject( aSObject ).in() );
+ QString aMeshName = VISU::getValue( aSObject, "myMeshName" );
+ int anEntity = VISU::getValue( aSObject, "myEntityId" ).toInt();
+ QString aFieldName = VISU::getValue( aSObject, "myName" );
+
+ VISU::ColoredPrs3dHolder::BasicInput anInput;
+ anInput.myResult = aResult;
+ anInput.myMeshName = CORBA::string_dup( aMeshName.latin1() );
+ anInput.myEntity = (VISU::Entity)anEntity;
+ anInput.myFieldName = CORBA::string_dup( aFieldName.latin1() );
+ anInput.myTimeStampNumber = 1;
+
+ size_t isOk = VISU::CheckIsPossible( myType, anInput, true );
+ return isOk > 0;
+ }
+ }
+ return false;
+}
--- /dev/null
+// Copyright (C) 2005 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 : VisuGUI_FieldFilter.hxx
+// Author : Oleg UVAROV
+// Module : VISU
+
+#ifndef VISUGUI_FIELDFILTER_H
+#define VISUGUI_FIELDFILTER_H
+
+#include "VISUConfig.hh"
+
+#include "SUIT_SelectionFilter.h"
+
+class SUIT_DataOwner;
+
+class VisuGUI_FieldFilter : public SUIT_SelectionFilter
+{
+public:
+ VisuGUI_FieldFilter( VISU::VISUType theType );
+ ~VisuGUI_FieldFilter();
+
+public:
+ virtual bool isOk( const SUIT_DataOwner* ) const;
+
+ void setPrs3dEntry( const QString& theEntry );
+
+private:
+ VISU::VISUType myType;
+ QString myPrs3dEntry;
+};
+
+#endif
#include "VISUConfig.hh"
#include "VisuGUI_Tools.h"
+#include "VisuGUI_InputPane.h"
+#include "VISU_ColoredPrs3dFactory.hh"
#include "VISU_GaussPoints_i.hh"
#include "VISU_GaussPointsPL.hxx"
#include "VISU_OpenGLPointSpriteMapper.hxx"
#include "SUIT_MessageBox.h"
#include "SVTK_FontWidget.h"
+#include "QtxDblSpinBox.h"
+
#include <qlayout.h>
#include <qtabwidget.h>
#include <qbuttongroup.h>
#include <qfiledialog.h>
#include <qvalidator.h>
#include <qcolordialog.h>
+#include <qgroupbox.h>
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qlineedit.h>
+#include <qspinbox.h>
+#include <qcombobox.h>
+#include <qtoolbutton.h>
+#include <qtabwidget.h>
#include <vtkPolyData.h>
#include <vtkDataSet.h>
myCBDisplayed->setEnabled( activeLocal );
myCBDisplayed->setChecked( thePrs->GetIsDispGlobalScalarBar() );
- bool bicolor = thePrs->GetGaussPointsPL()->GetBicolor();
+ bool bicolor = thePrs->GetSpecificPL()->GetBicolor();
BicolorButton->setChecked( bicolor );
RainbowButton->setChecked( !bicolor );
ColorLabel->setEnabled( !bicolor );
thePrs->SetNbColors(ColorSpin->value());
thePrs->SetLabels(LabelSpin->value());
- thePrs->GetGaussPointsPL()->SetBicolor(BicolorButton->isChecked());
+ thePrs->GetSpecificPL()->SetBicolor(BicolorButton->isChecked());
//if (isToSave()) storeToResources();
/*!
Gets orientation
*/
-int VisuGUI_GaussScalarBarPane::getOrientation()
+int VisuGUI_GaussScalarBarPane::getOrientation()
{
if (RBvert->isChecked() )
return 1;
return 0;
}
+/*!
+ Sets and gets parameters
+*/
+double VisuGUI_GaussScalarBarPane::getX() {
+ return XSpin->value();
+}
+
+double VisuGUI_GaussScalarBarPane::getY() {
+ return YSpin->value();
+}
+
+double VisuGUI_GaussScalarBarPane::getWidth() {
+ return WidthSpin->value();
+}
+
+double VisuGUI_GaussScalarBarPane::getHeight() {
+ return HeightSpin->value();
+}
+
+int VisuGUI_GaussScalarBarPane::getNbColors() {
+ return ColorSpin->value();
+}
+
+int VisuGUI_GaussScalarBarPane::getNbLabels() {
+ return LabelSpin->value();
+}
+
+bool VisuGUI_GaussScalarBarPane::isToSave() {
+ return CBSave ? CBSave->isChecked() : false;
+}
void VisuGUI_GaussScalarBarPane::onTextPref()
{
* Constructor
*/
VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool SetPref):
- QDialog(VISU::GetDesktop(theModule),
- "VisuGUI_GaussPointsDlg", true,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
- myPrs(NULL)
+ VisuGUI_Prs3dDlg(theModule)
{
setName("VisuGUI_ScalarBarDlg");
setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE"));
myGeometryButton = new QRadioButton( tr( "GEOMETRY" ), PrsGroup );
myDefShapeButton = new QRadioButton( tr( "DEFORMED_SHAPE" ), PrsGroup );
- QTabWidget* aTabBox = new QTabWidget (this);
+ myTabBox = new QTabWidget (this);
// Gauss points pane
QVBox* aBox = new QVBox (this);
myScalarPane = new VisuGUI_GaussScalarBarPane(this, SetPref);
myScalarPane->setMargin(5);
+ // Input pane
+ myInputPane = new VisuGUI_InputPane(VISU::TGAUSSPOINTS, theModule, this);
connect( myResultsButton, SIGNAL( clicked() ), mySizeBox, SLOT( onToggleResults() ) );
connect( myResultsButton, SIGNAL( toggled( bool ) ), myScalarPane, SLOT( setEnabled( bool ) ) );
connect( myDefShapeButton, SIGNAL( toggled( bool ) ), this, SLOT( onToggleDefShape( bool ) ) );
connect( myDefShapeButton, SIGNAL( toggled( bool ) ), myScalarPane, SLOT( setEnabled( bool ) ) );
- aTabBox->addTab(aBox, tr("GAUSS_POINTS_TAB"));
- aTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB"));
+ myTabBox->addTab(aBox, tr("GAUSS_POINTS_TAB"));
+ myTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB"));
+ myTabBox->addTab(myInputPane, tr("INPUT_TAB"));
// Common buttons ===========================================================
QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
TopLayout->addWidget( PrsGroup );
- TopLayout->addWidget( aTabBox );
+ TopLayout->addWidget( myTabBox );
TopLayout->addWidget( GroupButtons );
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
}
-void VisuGUI_GaussPointsDlg::initFromPrsObject( VISU::GaussPoints_i* thePrs )
+VisuGUI_GaussPointsDlg::~VisuGUI_GaussPointsDlg()
+{}
+
+void VisuGUI_GaussPointsDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit)
{
- bool isDeformed = thePrs->GetIsDeformed();
- myScaleSpinBox->setValue( thePrs->GetScaleFactor() );
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TGAUSSPOINTS>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
+
+ myScalarPane->initFromPrsObject( myPrsCopy );
+
+ bool isDeformed = myPrsCopy->GetIsDeformed();
+ myScaleSpinBox->setValue( myPrsCopy->GetScaleFactor() );
myDefShapeButton->setChecked( isDeformed );
- myDefShapeButton->setEnabled( thePrs->GetField()->myNbComp > 1 );
+ myDefShapeButton->setEnabled( myPrsCopy->GetField()->myNbComp > 1 );
onToggleDefShape( isDeformed );
- bool isResults = thePrs->GetIsColored();
+ bool isResults = myPrsCopy->GetIsColored();
myResultsButton->setChecked( isResults && !isDeformed );
myGeometryButton->setChecked( !isResults && !isDeformed );
- myPrimitiveBox->setPrimitiveType( thePrs->GetPrimitiveType() );
- myPrimitiveBox->setClampMaximum( thePrs->GetMaximumSupportedSize() );
- myPrimitiveBox->setClamp( thePrs->GetClamp() );
- myPrimitiveBox->setMainTexture( thePrs->GetMainTexture() );
- myPrimitiveBox->setAlphaTexture( thePrs->GetAlphaTexture() );
- myPrimitiveBox->setAlphaThreshold( thePrs->GetAlphaThreshold() );
- myPrimitiveBox->setResolution( thePrs->GetResolution() );
- myPrimitiveBox->setFaceLimit( thePrs->GetFaceLimit() );
+ myPrimitiveBox->setPrimitiveType( myPrsCopy->GetPrimitiveType() );
+ myPrimitiveBox->setClampMaximum( myPrsCopy->GetMaximumSupportedSize() );
+ myPrimitiveBox->setClamp( myPrsCopy->GetClamp() );
+ myPrimitiveBox->setMainTexture( myPrsCopy->GetMainTexture() );
+ myPrimitiveBox->setAlphaTexture( myPrsCopy->GetAlphaTexture() );
+ myPrimitiveBox->setAlphaThreshold( myPrsCopy->GetAlphaThreshold() );
+ myPrimitiveBox->setResolution( myPrsCopy->GetResolution() );
+ myPrimitiveBox->setFaceLimit( myPrsCopy->GetFaceLimit() );
mySizeBox->setType( isResults || isDeformed ? VVTK_SizeBox::Results : VVTK_SizeBox::Geometry );
- mySizeBox->setGeomSize( thePrs->GetGeomSize() );
- mySizeBox->setMinSize( thePrs->GetMinSize() );
- mySizeBox->setMaxSize( thePrs->GetMaxSize() );
- mySizeBox->setMagnification( thePrs->GetMagnification() );
- mySizeBox->setIncrement( thePrs->GetMagnificationIncrement() );
- mySizeBox->setColor( thePrs->GetColor() );
-
- myScalarPane->initFromPrsObject(thePrs);
+ mySizeBox->setGeomSize( myPrsCopy->GetGeomSize() );
+ mySizeBox->setMinSize( myPrsCopy->GetMinSize() );
+ mySizeBox->setMaxSize( myPrsCopy->GetMaxSize() );
+ mySizeBox->setMagnification( myPrsCopy->GetMagnification() );
+ mySizeBox->setIncrement( myPrsCopy->GetMagnificationIncrement() );
+ mySizeBox->setColor( myPrsCopy->GetColor() );
+
+ if( !theInit )
+ return;
- myPrs = thePrs;
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentPage( 0 );
}
-int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::GaussPoints_i* thePrs )
+int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs )
{
- thePrs->SetIsDeformed( myDefShapeButton->isChecked() );
- thePrs->SetScaleFactor( myScaleSpinBox->value() );
+ if(!myInputPane->check())
+ return 0;
- thePrs->SetPrimitiveType( myPrimitiveBox->getPrimitiveType() );
+ int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy );
- thePrs->SetClamp( myPrimitiveBox->getClamp() );
+ myPrsCopy->SetIsDeformed( myDefShapeButton->isChecked() );
+ myPrsCopy->SetScaleFactor( myScaleSpinBox->value() );
+
+ myPrsCopy->SetPrimitiveType( myPrimitiveBox->getPrimitiveType() );
+
+ myPrsCopy->SetClamp( myPrimitiveBox->getClamp() );
QString aMainTexture = myPrimitiveBox->getMainTexture();
QString anAlphaTexture = myPrimitiveBox->getAlphaTexture();
- aMainTexture = aMainTexture.isNull() ? thePrs->GetMainTexture() : aMainTexture;
- anAlphaTexture = anAlphaTexture.isNull() ? thePrs->GetAlphaTexture() : anAlphaTexture;
+ aMainTexture = aMainTexture.isNull() ? myPrsCopy->GetMainTexture() : aMainTexture;
+ anAlphaTexture = anAlphaTexture.isNull() ? myPrsCopy->GetAlphaTexture() : anAlphaTexture;
- thePrs->SetTextures( aMainTexture, anAlphaTexture );
+ myPrsCopy->SetTextures( aMainTexture, anAlphaTexture );
- thePrs->SetAlphaThreshold( myPrimitiveBox->getAlphaThreshold() );
+ myPrsCopy->SetAlphaThreshold( myPrimitiveBox->getAlphaThreshold() );
- thePrs->SetResolution( myPrimitiveBox->getResolution() );
- thePrs->SetFaceLimit( myPrimitiveBox->getFaceLimit() );
+ myPrsCopy->SetResolution( myPrimitiveBox->getResolution() );
+ myPrsCopy->SetFaceLimit( myPrimitiveBox->getFaceLimit() );
bool isColored = !myGeometryButton->isChecked();
if( isColored )
{
- thePrs->SetIsColored( true );
- thePrs->SetMinSize( mySizeBox->getMinSize() );
- thePrs->SetMaxSize( mySizeBox->getMaxSize() );
+ myPrsCopy->SetIsColored( true );
+ myPrsCopy->SetMinSize( mySizeBox->getMinSize() );
+ myPrsCopy->SetMaxSize( mySizeBox->getMaxSize() );
}
else
{
- thePrs->SetIsColored( false );
- thePrs->SetColor( mySizeBox->getColor() );
- thePrs->SetGeomSize( mySizeBox->getGeomSize() );
+ myPrsCopy->SetIsColored( false );
+ myPrsCopy->SetColor( mySizeBox->getColor() );
+ myPrsCopy->SetGeomSize( mySizeBox->getGeomSize() );
}
- thePrs->SetMagnification( mySizeBox->getMagnification() );
- thePrs->SetMagnificationIncrement( mySizeBox->getIncrement() );
+ myPrsCopy->SetMagnification( mySizeBox->getMagnification() );
+ myPrsCopy->SetMagnificationIncrement( mySizeBox->getIncrement() );
+
+ VISU::TSameAsFactory<VISU::TGAUSSPOINTS>().Copy(thePrs, myPrsCopy);
- return myScalarPane->storeToPrsObject(thePrs);
+ return anIsOk;
}
void VisuGUI_GaussPointsDlg::onToggleDefShape( bool on )
void VisuGUI_GaussPointsDlg::accept()
{
- if( myPrs && myPrimitiveBox->getPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere )
+ if( myPrsCopy && myPrimitiveBox->getPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere )
{
int aNumberOfFaces = myPrimitiveBox->getFaceNumber();
- int aNumberOfPoints = ( (vtkPolyData*)myPrs->GetGaussPointsPL()->GetInput() )->GetNumberOfCells();
+ int aNumberOfPoints = ( (vtkPolyData*)myPrsCopy->GetSpecificPL()->GetInput() )->GetNumberOfCells();
if( aNumberOfFaces * aNumberOfPoints > myPrimitiveBox->getFaceLimit() )
{
#ifndef VISUGUI_GAUSSPOINTSDLS_H
#define VISUGUI_GAUSSPOINTSDLS_H
-#include "VisuGUI_ScalarBarDlg.h"
+#include "VisuGUI_Prs3dDlg.h"
#include <qvbox.h>
-#include <qdialog.h>
-#include <qgroupbox.h>
-#include <qcheckbox.h>
-#include <qlabel.h>
-#include <qpushbutton.h>
-#include <qlineedit.h>
-#include <qbuttongroup.h>
-#include <qradiobutton.h>
-#include <qspinbox.h>
-#include <qcombobox.h>
-#include <qtoolbutton.h>
+
+class QtxDblSpinBox;
class SalomeApp_Module;
class VVTK_PrimitiveBox;
class VVTK_SizeBox;
class VisuGUI_TextPrefDlg;
+class VisuGUI_InputPane;
namespace VISU
{
int getOrientation();
void setPosAndSize( double x, double y, double w, double h, bool vert );
- double getX() {return XSpin->value();}
- double getY() {return YSpin->value();}
- double getWidth() {return WidthSpin->value();}
- double getHeight() {return HeightSpin->value();}
void setScalarBarData( int colors, int labels );
- int getNbColors() {return ColorSpin->value();}
- int getNbLabels() {return LabelSpin->value();}
- bool isToSave() {return CBSave ? CBSave->isChecked() : false;}
+ double getX();
+ double getY();
+ double getWidth();
+ double getHeight();
+ int getNbColors();
+ int getNbLabels();
+ bool isToSave();
void initFromPrsObject(VISU::GaussPoints_i* thePrs);
int storeToPrsObject(VISU::GaussPoints_i* thePrs);
* Uses for set up initial parameters of the Gauss Points
* presentation and edit them interactively.
*/
-class VisuGUI_GaussPointsDlg : public QDialog
+class VisuGUI_GaussPointsDlg : public VisuGUI_Prs3dDlg
{
Q_OBJECT
public:
VisuGUI_GaussPointsDlg (SalomeApp_Module* theModule, bool SetPref = FALSE);
- ~VisuGUI_GaussPointsDlg() {}
+ ~VisuGUI_GaussPointsDlg();
//! Initializing dialog from the Gauss Points presentation.
- void initFromPrsObject(VISU::GaussPoints_i* thePrs);
+ virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true);
//! Update Gauss Points presentation using parameters from the dialog.
- int storeToPrsObject(VISU::GaussPoints_i* thePrs);
+ virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs);
private:
void keyPressEvent( QKeyEvent* e );
void accept();
private:
- VISU::GaussPoints_i* myPrs;
+ QTabWidget* myTabBox;
VisuGUI_GaussScalarBarPane* myScalarPane;
+ VisuGUI_InputPane* myInputPane;
QRadioButton* myResultsButton;
QRadioButton* myGeometryButton;
QGroupBox* myDefShapeBox;
QtxDblSpinBox* myScaleSpinBox;
+
+ SALOME::GenericObjPtr<VISU::GaussPoints_i> myPrsCopy;
};
#endif // VISUGUI_GAUSSPOINTSDLS_H
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// 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 : VisuGUI_InputPane.cxx
+// Author : Oleg UVAROV
+// Module : VISU
+
+#include "VisuGUI_InputPane.h"
+
+#include "VisuGUI_Prs3dDlg.h"
+#include "VisuGUI_FieldFilter.h"
+#include "VisuGUI_Tools.h"
+
+#include "VISU_ColoredPrs3d_i.hh"
+#include "VISU_ScalarMap_i.hh"
+#include "VISU_Result_i.hh"
+#include "VISU_Convertor.hxx"
+
+#include "SUIT_ResourceMgr.h"
+
+#include "SalomeApp_Module.h"
+
+#include "LightApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+
+#include "SALOME_ListIO.hxx"
+
+#include "SALOMEDSClient_AttributeString.hxx"
+#include "SALOMEDSClient_AttributeName.hxx"
+
+#include "QtxListBox.h"
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qtoolbutton.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+
+
+//---------------------------------------------------------------
+class VisuGUI_ListBox: public QtxListBox
+{
+ public:
+ VisuGUI_ListBox( QWidget * parent = 0, const char * name = 0, WFlags f = 0 ):
+ QtxListBox(parent, name, f)
+ {};
+
+ virtual QSize sizeHint() const
+ {
+ return minimumSizeHint(); }
+ ;
+};
+
+
+//---------------------------------------------------------------
+VisuGUI_InputPane::VisuGUI_InputPane( VISU::VISUType theType,
+ SalomeApp_Module* theModule,
+ VisuGUI_Prs3dDlg* theDialog ) :
+ QGroupBox( theDialog ),
+ myModule( theModule ),
+ myDialog( theDialog ),
+ myPrs( NULL )
+{
+ setFrameStyle( QFrame::NoFrame );
+
+ connect( VISU::GetSelectionMgr( theModule ), SIGNAL( selectionChanged() ), SLOT( onSelectionChanged() ) );
+
+ QGridLayout* aMainLayout = new QGridLayout( this, 1, 1, 11, 6 );
+
+ // Definition of data source
+ myDataSourceGroupBox = new QGroupBox( this );
+ aMainLayout->addWidget( myDataSourceGroupBox, 0, 0 );
+ myDataSourceGroupBox->setTitle( tr( "PRS_DATA_SOUIRCE" ) );
+ {
+ QGroupBox* aGroupBox = myDataSourceGroupBox;
+ aGroupBox->setColumnLayout(0, Qt::Vertical );
+ aGroupBox->layout()->setSpacing( 6 );
+ aGroupBox->layout()->setMargin( 11 );
+
+ QGridLayout* aGroupBoxLayout = new QGridLayout( aGroupBox->layout() );
+ aGroupBoxLayout->setAlignment( Qt::AlignTop );
+ {
+ QLabel* aLabel = new QLabel( tr( "MED_FILE" ), aGroupBox );
+ aGroupBoxLayout->addWidget( aLabel, 0, 0 );
+
+ myMedFile = new QLineEdit( aGroupBox );
+ myMedFile->setReadOnly( true );
+ myMedFile->setEnabled( false );
+ myMedFile->setPaletteForegroundColor( Qt::black );
+ aGroupBoxLayout->addWidget( myMedFile, 0, 1 );
+ }
+ {
+ QLabel* aLabel = new QLabel( tr( "MESH" ), aGroupBox );
+ aGroupBoxLayout->addWidget( aLabel, 1, 0 );
+
+ myMeshName = new QLineEdit( aGroupBox );
+ myMeshName->setReadOnly( true );
+ myMeshName->setEnabled( false );
+ myMeshName->setPaletteForegroundColor( Qt::black );
+ aGroupBoxLayout->addWidget( myMeshName, 1, 1 );
+ }
+ {
+ QLabel* aLabel = new QLabel( tr( "ENTITY" ), aGroupBox );
+ aGroupBoxLayout->addWidget( aLabel, 2, 0 );
+
+ myEntityName = new QLineEdit( aGroupBox );
+ myEntityName->setReadOnly( true );
+ myEntityName->setEnabled( false );
+ myEntityName->setPaletteForegroundColor( Qt::black );
+ aGroupBoxLayout->addWidget( myEntityName, 2, 1 );
+ }
+ {
+ QLabel* aLabel = new QLabel( tr( "FIELD" ), aGroupBox );
+ aGroupBoxLayout->addWidget( aLabel, 3, 0 );
+
+ myFieldName = new QLineEdit( aGroupBox );
+ myFieldName->setReadOnly( true );
+ aGroupBoxLayout->addWidget( myFieldName, 3, 1 );
+ }
+ {
+ QLabel* aLabel = new QLabel( tr( "TIME_STAMP" ), aGroupBox );
+ aGroupBoxLayout->addWidget( aLabel, 4, 0 );
+
+ myTimeStamps = new QComboBox( aGroupBox );
+ aGroupBoxLayout->addWidget( myTimeStamps, 4, 1 );
+ }
+
+ myReInit = new QCheckBox( tr( "REINITIALIZE" ), aGroupBox );
+ myReInit->setChecked( true );
+ aGroupBoxLayout->addWidget( myReInit, 5, 1 );
+ }
+
+ // Definition of used groups
+ myUseGroupsGroupBox = new QGroupBox( this );
+ aMainLayout->addWidget( myUseGroupsGroupBox, 1, 0 );
+ myUseGroupsGroupBox->setTitle( tr( "PRS_ON_GROUPS" ) );
+ myUseGroupsGroupBox->setCheckable( TRUE );
+ {
+ QGroupBox* aGroupBox = myUseGroupsGroupBox;
+ aGroupBox->setColumnLayout(0, Qt::Vertical );
+ aGroupBox->layout()->setSpacing( 6 );
+ aGroupBox->layout()->setMargin( 11 );
+
+ QGridLayout* aGroupBoxLayout = new QGridLayout( aGroupBox->layout() );
+ aGroupBoxLayout->setAlignment( Qt::AlignTop );
+ {
+ myAllGroups = new VisuGUI_ListBox(aGroupBox, "myAllGroups");
+ myAllGroups->setSelectionMode(QListBox::Extended);
+ aGroupBoxLayout->addMultiCellWidget( myAllGroups, 0, 3, 0, 0 );
+ }
+ {
+ mySelectedGroups = new VisuGUI_ListBox(aGroupBox, "mySelectedGroups");
+ mySelectedGroups->setSelectionMode(QListBox::Extended);
+ mySelectedGroups->installEventFilter(this);
+ aGroupBoxLayout->addMultiCellWidget( mySelectedGroups, 0, 3, 2, 2 );
+ }
+ {
+ myAddButton = new QToolButton(aGroupBox);
+ myAddButton->setPixmap( VISU::GetResourceMgr()->loadPixmap("VISU", tr("ICON_ADD")) );
+ aGroupBoxLayout->addWidget( myAddButton, 1, 1 );
+ }
+ {
+ myRemoveButton = new QToolButton(aGroupBox);
+ myRemoveButton->setPixmap( VISU::GetResourceMgr()->loadPixmap("VISU", tr("ICON_REMOVE")) );
+ aGroupBoxLayout->addWidget( myRemoveButton, 2, 1 );
+ }
+ {
+ QSpacerItem* aSpacer = new QSpacerItem( 20, 51, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ aGroupBoxLayout->addItem( aSpacer, 0, 1 );
+ }
+ {
+ QSpacerItem* aSpacer = new QSpacerItem( 20, 61, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ aGroupBoxLayout->addItem( aSpacer, 3, 1 );
+ }
+ }
+
+ connect( myReInit, SIGNAL( toggled( bool ) ), SLOT( onReInitialize( bool ) ) );
+ connect( myUseGroupsGroupBox, SIGNAL( toggled( bool ) ), this, SLOT( onTypeChanged() ) );
+ connect( myAllGroups, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onListDoubleClicked( QListBoxItem* ) ) );
+ connect( mySelectedGroups, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onListDoubleClicked( QListBoxItem* ) ) );
+ connect( myAddButton, SIGNAL(clicked()), this, SLOT(onAdd()));
+ connect( myRemoveButton, SIGNAL(clicked()), this, SLOT(onRemove()));
+
+ onTypeChanged();
+ onSelectionChanged();
+
+ myFieldFilter = new VisuGUI_FieldFilter( theType );
+
+ hide();
+}
+
+
+//---------------------------------------------------------------
+VisuGUI_InputPane::~VisuGUI_InputPane()
+{
+ if( myFieldFilter )
+ {
+ VISU::GetSelectionMgr( myModule )->removeFilter( myFieldFilter );
+ delete myFieldFilter;
+ }
+}
+
+
+//---------------------------------------------------------------
+/*!
+ Event filter
+*/
+bool VisuGUI_InputPane::eventFilter (QObject* object, QEvent* event)
+{
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent* aKeyEvent = (QKeyEvent*)event;
+ if (object == mySelectedGroups && aKeyEvent->key() == Key_Delete)
+ onRemove();
+ }
+ return QObject::eventFilter(object, event);
+}
+
+
+//---------------------------------------------------------------
+/*!
+ Called when the checkbox is toggled
+*/
+void VisuGUI_InputPane::onTypeChanged( )
+{
+ bool toEnable = myUseGroupsGroupBox->isChecked();
+ if (!toEnable)
+ {
+ myAllGroups->clearSelection();
+ mySelectedGroups->clearSelection();
+ }
+ myAllGroups->setEnabled( toEnable );
+ mySelectedGroups->setEnabled( toEnable );
+ myAddButton->setEnabled( toEnable );
+ myRemoveButton->setEnabled( toEnable );
+}
+
+
+//---------------------------------------------------------------
+/*!
+ Called when add button is clicked, adds item to choosen groups
+*/
+void VisuGUI_InputPane::onAdd()
+{
+ QStringList aList;
+
+ for (int i = 0; i < myAllGroups->count(); i++)
+ if (myAllGroups->isSelected(i))
+ aList.append(myAllGroups->text(i));
+
+ for (int i = 0; i < mySelectedGroups->count(); i++)
+ aList.remove(mySelectedGroups->text(i));
+
+ mySelectedGroups->insertStringList(aList);
+}
+
+
+//---------------------------------------------------------------
+/*!
+ Called when remove button is clicked, remove selected items from choosen
+*/
+void VisuGUI_InputPane::onRemove()
+{
+ QPtrList<QListBoxItem> aList;
+ aList.setAutoDelete(false);
+ for (int i = 0; i < mySelectedGroups->count(); i++)
+ if (mySelectedGroups->isSelected(i))
+ aList.append(mySelectedGroups->item(i));
+
+ for (int i = 0; i < aList.count(); i++)
+ delete aList.at(i);
+}
+
+
+//---------------------------------------------------------------
+/*!
+ Called when an item of listbox is double-clicked
+*/
+void VisuGUI_InputPane::onListDoubleClicked( QListBoxItem* theItem )
+{
+ QListBox* aListBox = theItem->listBox();
+
+ if (aListBox == myAllGroups)
+ {
+ if (!mySelectedGroups->findItem( theItem->text(), Qt::ExactMatch ))
+ mySelectedGroups->insertItem(theItem->text());
+ }
+ else if (aListBox == mySelectedGroups)
+ delete theItem;
+}
+
+
+//---------------------------------------------------------------
+bool VisuGUI_InputPane::check()
+{
+ return myTimeStamps->count() != 0;
+}
+
+
+//---------------------------------------------------------------
+void VisuGUI_InputPane::clear()
+{
+ myMedFile->clear();
+ myMeshName->clear();
+ myEntityName->clear();
+ myFieldName->clear();
+ myTimeStamps->clear();
+}
+
+
+//---------------------------------------------------------------
+void VisuGUI_InputPane::onSelectionChanged()
+{
+ //clear();
+
+ SALOME_ListIO aListIO;
+ VISU::GetSelectionMgr( myModule )->selectedObjects(aListIO);
+
+ if (aListIO.Extent() != 1)
+ return;
+
+ const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
+
+ _PTR(Study) aCStudy = VISU::GetCStudy(VISU::GetAppStudy(myModule));
+ _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
+ if (!aSObject)
+ return;
+
+ VISU::Storable::TRestoringMap aMap;
+ _PTR(GenericAttribute) anAttr;
+ if (!aSObject->FindAttribute(anAttr, "AttributeString"))
+ return;
+
+ _PTR(AttributeString) aComment (anAttr);
+ string aComm = aComment->Value();
+ QString strIn (aComm.c_str());
+ VISU::Storable::StrToMap(strIn, aMap);
+ bool isExist;
+ VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
+ if (aType == VISU::TFIELD)
+ {
+ _PTR(SObject) aMedObject = aSObject->GetFather()->GetFather()->GetFather();
+ if( !aMedObject )
+ return;
+
+ myTimeStamps->clear();
+
+ QString anEntityName, aTimeStampName;
+
+ _PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder();
+ _PTR(ChildIterator) aIter = aCStudy->NewChildIterator(aSObject);
+ for( ; aIter->More(); aIter->Next() )
+ {
+ _PTR(SObject) aChildObj = aIter->Value();
+ if( !aChildObj )
+ return;
+
+ if( anEntityName.isNull() )
+ {
+ _PTR(SObject) aRefObj;
+ if( aChildObj->ReferencedObject( aRefObj ) )
+ anEntityName = aRefObj->GetName().c_str();
+ }
+
+ if( VISU::getValue(aChildObj, "myComment") == "TIMESTAMP" )
+ {
+ aTimeStampName = aChildObj->GetName().c_str();
+ myTimeStamps->insertItem( aTimeStampName );
+ }
+ }
+
+ myResult = VISU::FindResult( VISU::GetSObject( aSObject ).in() );
+
+ myEntity = VISU::getValue( aSObject, "myEntityId" ).toInt();
+
+ QString aMedFile = aMedObject->GetName().c_str();
+ QString aMeshName = VISU::getValue(aSObject, "myMeshName");
+ QString aFieldName = VISU::getValue(aSObject, "myName");
+
+ myMedFile->setText( aMedFile );
+ myMeshName->setText( aMeshName );
+ myEntityName->setText( anEntityName );
+ myFieldName->setText( aFieldName );
+ myTimeStamps->setCurrentItem( 0 );
+
+ if( myReInit->isChecked() && myPrs )
+ {
+ myPrs->SetResultObject( myResult );
+ myPrs->SetMeshName( aMeshName.latin1() );
+ myPrs->SetEntity( VISU::Entity( myEntity ) );
+ myPrs->SetFieldName( aFieldName.latin1() );
+ myPrs->SetTimeStampNumber( myPrs->GetTimeStampNumberByIndex( 0 ) );
+ myPrs->Apply( true );
+
+ myDialog->initFromPrsObject( myPrs, false );
+ }
+ }
+}
+
+
+//---------------------------------------------------------------
+void VisuGUI_InputPane::onReInitialize( bool on )
+{
+ if( on )
+ onSelectionChanged();
+}
+
+
+//---------------------------------------------------------------
+void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs )
+{
+ if( myPrs == thePrs )
+ return;
+
+ myPrs = thePrs;
+
+ clear();
+
+ CORBA::Long aTimeStampNumber = thePrs->GetTimeStampNumber();
+ VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = thePrs->GetTimeStampsRange();
+ CORBA::Long aLength = aTimeStampsRange->length();
+
+ for( int index = 0; index < aLength; index++ )
+ {
+ VISU::ColoredPrs3d::TimeStampInfo anInfo = aTimeStampsRange[ index ];
+ QString aTime = anInfo.myTime.in();
+ myTimeStamps->insertItem( aTime );
+ }
+
+ myResult = thePrs->GetResultObject();
+ VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(GetServant(myResult).in());
+ myMedFile->setText( aResult->GetName().c_str() );
+
+ myEntity = (int)thePrs->GetEntity();
+
+ QString anEntityName;
+ switch( myEntity )
+ {
+ case VISU::NODE_ENTITY:
+ anEntityName = "onNodes";
+ break;
+ case VISU::EDGE_ENTITY:
+ anEntityName = "onEdges";
+ break;
+ case VISU::FACE_ENTITY:
+ anEntityName = "onFaces";
+ break;
+ case VISU::CELL_ENTITY:
+ anEntityName = "onCells";
+ break;
+ default: break;
+ }
+ myEntityName->setText( anEntityName );
+
+ myMeshName->setText( thePrs->GetMeshName() );
+ myFieldName->setText( thePrs->GetFieldName() );
+ myTimeStamps->setCurrentItem( thePrs->GetTimeStampIndexByNumber( aTimeStampNumber ) );
+
+ myFieldFilter->setPrs3dEntry( thePrs->GetHolderEntry() );
+ bool anIsTimeStampFixed = myPrs->IsTimeStampFixed();
+ myDataSourceGroupBox->setEnabled(!anIsTimeStampFixed);
+ if(!anIsTimeStampFixed)
+ VISU::GetSelectionMgr( myModule )->installFilter( myFieldFilter );
+
+ // type of presentation and groups
+ VISU_Convertor* anInput = aResult->GetInput();
+ const VISU::TMeshMap& aMeshMap = anInput->GetMeshMap();
+ std::string aMeshName = thePrs->GetCMeshName();
+ VISU::TMeshMap::const_iterator aMeshIter = aMeshMap.find(aMeshName);
+ if(aMeshIter != aMeshMap.end()){
+ const VISU::PMesh& aMesh = aMeshIter->second;
+ const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
+ VISU::TGroupMap::const_iterator aGroupIter = aGroupMap.begin();
+ for(; aGroupIter != aGroupMap.end(); aGroupIter++){
+ const std::string& aGroupName = aGroupIter->first;
+ myAllGroups->insertItem(QString(aGroupName));
+ }
+ }
+
+ 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();
+ for(; anIter != aGroupNames.end(); anIter++){
+ const std::string aGroupName = *anIter;
+ mySelectedGroups->insertItem(QString(aGroupName));
+ }
+ }
+ myUseGroupsGroupBox->setChecked(mySelectedGroups->count() > 0);
+ myUseGroupsGroupBox->setEnabled(anIsTimeStampFixed);
+}
+
+
+//---------------------------------------------------------------
+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();
+ }
+
+ thePrs->SetResultObject( myResult );
+
+ thePrs->SetMeshName( myMeshName->text().latin1() );
+ thePrs->SetEntity( VISU::Entity( myEntity ) );
+ thePrs->SetFieldName( myFieldName->text().latin1() );
+ thePrs->SetTimeStampNumber( thePrs->GetTimeStampNumberByIndex( myTimeStamps->currentItem() ) );
+ return ( int )thePrs->Apply( false );
+}
+
+
+//---------------------------------------------------------------
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// 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 : VisuGUI_InputPane.h
+// Author : Oleg UVAROV
+// Module : VISU
+
+#ifndef VISUGUI_INPUTPANE_H
+#define VISUGUI_INPUTPANE_H
+
+#include "VISUConfig.hh"
+
+#include <qgroupbox.h>
+
+class QCheckBox;
+class QComboBox;
+class QLineEdit;
+class QListBoxItem;
+class QToolButton;
+
+class SalomeApp_Module;
+class LightApp_SelectionMgr;
+
+class VisuGUI_ListBox;
+class VisuGUI_Prs3dDlg;
+class VisuGUI_FieldFilter;
+
+namespace VISU
+{
+ class ColoredPrs3d_i;
+ class Result_i;
+}
+
+class VisuGUI_InputPane : public QGroupBox
+{
+ Q_OBJECT
+
+public:
+ VisuGUI_InputPane( VISU::VISUType theType,
+ SalomeApp_Module* theModule,
+ VisuGUI_Prs3dDlg* theDialog );
+ virtual ~VisuGUI_InputPane();
+
+public:
+ virtual bool check();
+ virtual void clear();
+
+ void initFromPrsObject( VISU::ColoredPrs3d_i* );
+ int storeToPrsObject( VISU::ColoredPrs3d_i* );
+
+ bool eventFilter (QObject* object, QEvent* event);
+
+public slots:
+ virtual void onSelectionChanged();
+ virtual void onReInitialize( bool );
+
+private slots:
+ void onTypeChanged();
+ void onListDoubleClicked( QListBoxItem* theItem );
+ void onAdd();
+ void onRemove();
+
+private:
+ SalomeApp_Module* myModule;
+ VisuGUI_Prs3dDlg* myDialog;
+ VISU::ColoredPrs3d_i* myPrs;
+
+ QGroupBox* myUseGroupsGroupBox;
+ VisuGUI_ListBox* myAllGroups;
+ VisuGUI_ListBox* mySelectedGroups;
+ QToolButton* myAddButton;
+ QToolButton* myRemoveButton;
+
+ QGroupBox* myDataSourceGroupBox;
+ QLineEdit* myMedFile;
+ QLineEdit* myMeshName;
+ QLineEdit* myEntityName;
+ QLineEdit* myFieldName;
+ QComboBox* myTimeStamps;
+ QCheckBox* myReInit;
+
+ VISU::Result_var myResult;
+ int myEntity;
+
+ VisuGUI_FieldFilter* myFieldFilter;
+};
+
+#endif
#include "VisuGUI.h"
#include "VisuGUI_Tools.h"
+#include "VisuGUI_InputPane.h"
+
+#include "VISU_ColoredPrs3dFactory.hh"
#include "LightApp_Application.h"
Constructor
*/
VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg (SalomeApp_Module* theModule)
- : QDialog(VISU::GetDesktop(theModule), "VisuGUI_IsoSurfacesDlg", true,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+ : VisuGUI_Prs3dDlg(theModule)
{
setCaption(tr("DEFINE_ISOSURFACES"));
setSizeGripEnabled( TRUE );
TopLayout->setSpacing( 6 );
TopLayout->setMargin(11);
- QTabWidget* aTabBox = new QTabWidget(this);
+ myTabBox = new QTabWidget(this);
myIsoPane = new VisuGUI_IsoSurfPane(this);
myIsoPane->setMargin( 5 );
- aTabBox->addTab(myIsoPane, "Iso Surface");
+ myTabBox->addTab(myIsoPane, "Iso Surface");
myScalarPane = new VisuGUI_ScalarBarPane(this, false);
myIsoPane->setScalarBarPane(myScalarPane);
myScalarPane->setMargin( 5 );
- aTabBox->addTab(myScalarPane, "Scalar Bar");
+ myInputPane = new VisuGUI_InputPane(VISU::TISOSURFACE, theModule, this);
+ myTabBox->addTab(myScalarPane, "Scalar Bar");
+ myTabBox->addTab(myInputPane, "Input");
- TopLayout->addWidget(aTabBox);
+ TopLayout->addWidget(myTabBox);
QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
}
+VisuGUI_IsoSurfacesDlg::~VisuGUI_IsoSurfacesDlg()
+{}
+
void VisuGUI_IsoSurfacesDlg::accept()
{
if (myIsoPane->check() && myScalarPane->check())
QDialog::reject();
}
+void VisuGUI_IsoSurfacesDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit)
+{
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TISOSURFACE>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
+
+ myScalarPane->initFromPrsObject(myPrsCopy);
+ myIsoPane->initFromPrsObject(myPrsCopy);
+
+ if( !theInit )
+ return;
+
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentPage( 0 );
+}
+
+int VisuGUI_IsoSurfacesDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
+{
+ if(!myInputPane->check() || !myScalarPane->check())
+ return 0;
+
+ int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= myIsoPane->storeToPrsObject( myPrsCopy );
+
+ VISU::TSameAsFactory<VISU::TISOSURFACE>().Copy(thePrs, myPrsCopy);
+
+ return anIsOk;
+}
+
void VisuGUI_IsoSurfacesDlg::onHelp()
{
QString aHelpFileName = "/files/iso_surfaces_presentation.htm";
#ifndef VISUGUI_ISOSURFACESDLG_H
#define VISUGUI_ISOSURFACESDLG_H
-#include "VisuGUI_ScalarBarDlg.h"
-#include "VISU_IsoSurfaces_i.hh"
+#include "VisuGUI_Prs3dDlg.h"
#include <qdialog.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qcheckbox.h>
#include <qlineedit.h>
+#include <qtabwidget.h>
+
+namespace VISU
+{
+ class IsoSurfaces_i;
+};
class SalomeApp_Module;
+class VisuGUI_InputPane;
class VisuGUI_IsoSurfPane : public QVBox
{
};
-class VisuGUI_IsoSurfacesDlg : public QDialog
+class VisuGUI_IsoSurfacesDlg : public VisuGUI_Prs3dDlg
{
Q_OBJECT;
public:
VisuGUI_IsoSurfacesDlg (SalomeApp_Module* theModule);
- ~VisuGUI_IsoSurfacesDlg() {};
+ ~VisuGUI_IsoSurfacesDlg();
- void initFromPrsObject(VISU::IsoSurfaces_i* thePrs)
- {myScalarPane->initFromPrsObject(thePrs); myIsoPane->initFromPrsObject(thePrs);}
-
- int storeToPrsObject(VISU::IsoSurfaces_i* thePrs)
- {return myScalarPane->storeToPrsObject(thePrs) && myIsoPane->storeToPrsObject(thePrs);}
+ virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true);
+ virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs);
private:
void keyPressEvent( QKeyEvent* e );
void onHelp();
private:
+ QTabWidget* myTabBox;
VisuGUI_IsoSurfPane* myIsoPane;
VisuGUI_ScalarBarPane* myScalarPane;
+ VisuGUI_InputPane* myInputPane;
+
+ SALOME::GenericObjPtr<VISU::IsoSurfaces_i> myPrsCopy;
};
#endif // VISUGUI_ISOSURFACESDLG_H
#include "VISU_GaussPtsAct.h"
#include "VisuGUI_GaussPointsDlg.h"
+#include "VisuGUI_Slider.h"
+
#include "VISU_Gen_i.hh"
#include "VISU_Result_i.hh"
#include "VISU_CutLines_i.hh"
mgr->insert( action( GAUSS_CREATE_PRS ), -1, 0, -1 );
mgr->setRule( action( GAUSS_CREATE_PRS ),
"client='ObjectBrowser' and selcount=1 "
- "and type='VISU::TTIMESTAMP' "
+ "and type in {'VISU::TTIMESTAMP' 'VISU::TFIELD'} "
"and $medEntity in {'EDGE_ENTITY' 'FACE_ENTITY' 'CELL_ENTITY'} "
"and $medSource in {'eImportFile' 'eCopyAndImportFile'} ",
true );
new LightApp_VTKSelector( aViewer, anApp->selectionMgr() );
anApp->addViewManager( aViewManager );
- aViewManager->createViewWindow();
+ VVTK_ViewWindow* aViewWindow = ( VVTK_ViewWindow* )aViewManager->createViewWindow();
+ if( aViewWindow )
+ {
+ new VisuGUI_Slider( this, aViewWindow, anApp->selectionMgr() );
+ }
return aViewer->getViewManager();
}
OnCreateGaussPoints()
{
double initialTime = vtkTimerLog::GetCPUTime();
- CreatePrs3d<VISU::GaussPoints_i, VVTK_Viewer, VisuGUI_GaussPointsDlg, 1>(this);
+ CreatePrs3d<VISU::GaussPoints_i, VisuGUI_GaussPointsDlg, 1>(this, VVTK_Viewer::Type());
INFOS( "VisuGUI_Module::OnCreateGaussPoints() : Gauss Points created in " <<
vtkTimerLog::GetCPUTime() - initialTime << " seconds" );
}
VisuGUI_Module::
OnEditGaussPoints()
{
- Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) {
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
+
+ if(VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dToModify(this, aSelectionItem.myObjectInfo.myBase)){
// Create VVTK_ViewWindow, if it does not exist
if (VVTK_ViewWindow* aViewWindow = GetViewWindow<VVTK_Viewer>(this)) {
EditPrs3d<VISU::GaussPoints_i, VisuGUI_GaussPointsDlg, 1>(this, anIO, aPrs3d, aViewWindow);
}
}
-// returns VISU_Actor with IO with given entry
-VISU_Actor* getActor( const QString& entry, SVTK_ViewWindow* vtkView )
-{
- if ( vtkView && !entry.isEmpty() ) {
- vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
- allActors->InitTraversal();
- while ( vtkActor* actor = allActors->GetNextActor() ) {
- if ( VISU_Actor* vActor = VISU_Actor::SafeDownCast( actor ) ) {
- if ( vActor->hasIO() ) { // actor corresponds to existing obj
- Handle(SALOME_InteractiveObject) io = vActor->getIO();
- if ( entry == io->getEntry() )
- return vActor;
- }
- }
- }
- }
- return 0;
-}
-
const int ViewerType = 0;
const int ViewIndex = 1;
const int ParamName = 2;
QMap<QString, VISU_Actor*> viewActorMap;
if ( vtkActors.contains( entry ) )
viewActorMap = vtkActors[ entry ];
- viewActorMap[ viewerTypeIndex ] = getActor( entry, vtkView );
+ viewActorMap[ viewerTypeIndex ] = FindActor( GetAppStudy(this), vtkView, entry );
vtkActors[ entry ] = viewActorMap;
}
}
void VisuGUI_OffsetDlg::updateOffset (VISU::Prs3d_i* thePrs, vtkFloatingPointType* theOffset)
{
- if (myPrsList.count() == 0) return;
+ if (myPrsList.count() == 0)
+ return;
- if (isToSave()) thePrs->SetOffset(theOffset[0],theOffset[1],theOffset[2]);
+ if (isToSave())
+ thePrs->SetOffset(theOffset[0],theOffset[1],theOffset[2]);
ViewManagerList aViewManagerList;
SalomeApp_Application* anApp = myModule->getApp();
if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
vw->onAdjustTrihedron();
- if (VISU_Actor* anActor = VISU::GetActor(thePrs, vw)) {
+ if (VISU_Actor* anActor = VISU::FindActor(vw, thePrs)) {
anActor->SetPosition(theOffset);
+ vw->highlight(thePrs->GetIO(), 1);
vw->getRenderer()->ResetCameraClippingRange();
vw->Repaint();
-
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = VISU::GetSelectedObj(myModule, &anIO);
- if (!CORBA::is_nil(anObject))
- vw->highlight(anIO, 1);
}
}
}
#include "VisuGUI.h"
#include "VisuGUI_Tools.h"
#include "VisuGUI_ViewTools.h"
+#include "VisuGUI_InputPane.h"
+#include "VISU_ColoredPrs3dFactory.hh"
#include "VISU_ViewManager_i.hh"
#include "VISU_Plot3DPL.hxx"
#include "SUIT_ResourceMgr.h"
#include "LightApp_Application.h"
+#include "QtxDblSpinBox.h"
+
#include <qlayout.h>
#include <qvalidator.h>
#include <qtabwidget.h>
+#include <qradiobutton.h>
+#include <qspinbox.h>
+#include <qcheckbox.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
//purpose :
//=======================================================================
VisuGUI_Plot3DPane::~VisuGUI_Plot3DPane()
-{
-}
+{}
//=======================================================================
//function : storePrsParams
if (!myPipeCopy)
myPipeCopy = VISU_Plot3DPL::New();
if (myPrs) {
- myPipeCopy->SetIDMapper(myPrs->GetPL()->GetIDMapper());
- myPipeCopy->ShallowCopy(myPrs->GetPL());
+ myPipeCopy->ShallowCopy(myPrs->GetPipeLine(), true);
storeToPrsObject(myPrs);
}
}
if (!myPipeCopy)
myPipeCopy = VISU_Plot3DPL::New();
if (myPrs)
- myPrs->GetPL()->ShallowCopy(myPipeCopy);
+ myPrs->GetPipeLine()->ShallowCopy(myPipeCopy, false);
}
//=======================================================================
if (myPrs && !RelativeChkB->isChecked()) {
vtkFloatingPointType minPos, maxPos;
storePrsParams();
- myPrs->GetPlot3DPL()->GetMinMaxPosition(minPos, maxPos);
+ myPrs->GetSpecificPL()->GetMinMaxPosition(minPos, maxPos);
restorePrsParams();
if (minPos > PositionSpn->value())
minPos = PositionSpn->value();
vtkFloatingPointType minPos = 0., maxPos = 1., pos = PositionSpn->value();
if (myPrs) {
storePrsParams();
- myPrs->GetPlot3DPL()->GetMinMaxPosition(minPos, maxPos);
+ myPrs->GetSpecificPL()->GetMinMaxPosition(minPos, maxPos);
restorePrsParams();
if (-1e-7 < (maxPos - minPos) && (maxPos - minPos) < 1e-7) {
pos = 0;
if (!planePreview) {
myPreviewActor = planePreview = new TPlane(myPrs->GetInput()->GetLength());
myViewWindow->AddActor(planePreview);
- fitall = !VISU::GetActor(myPrs, myViewWindow);
+ fitall = !VISU::FindActor(myViewWindow, myPrs);
}
// set plane parameters corresponding to control values
storePrsParams();
vtkFloatingPointType normal[3], origin[3];
- myPrs->GetPlot3DPL()->GetBasePlane(origin, normal, true);
+ myPrs->GetSpecificPL()->GetBasePlane(origin, normal, true);
planePreview->Set(origin, normal);
restorePrsParams();
}
// disable cutting plane controls if the mesh is planar
- if (thePrs->GetPL()->IsPlanarInput())
+ if (thePrs->GetPipeLine()->IsPlanarInput())
{
GBOrientation->setEnabled(false);
Rot1 ->setEnabled(false);
{
if(!myPreviewActor) return true;
- SVTK_ViewWindow* aView;
vtkRenderer* aRend = myPreviewActor->GetRenderer();
vtkRenderWindow* aWnd = aRend->GetRenderWindow();
if(aRend && aWnd){
//purpose :
//=======================================================================
VisuGUI_Plot3DDlg::VisuGUI_Plot3DDlg (SalomeApp_Module* theModule)
- : QDialog(VISU::GetDesktop(theModule), "VisuGUI_Plot3DDlg", false, WStyle_Customize |
- WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+ : VisuGUI_Prs3dDlg(theModule)
{
setCaption(tr("TITLE"));
setSizeGripEnabled(TRUE);
TopLayout->setSpacing(6);
TopLayout->setMargin(11);
- QTabWidget* aTabBox = new QTabWidget (this);
+ myTabBox = new QTabWidget (this);
myIsoPane = new VisuGUI_Plot3DPane (this);
myIsoPane->setMargin(5);
- aTabBox->addTab(myIsoPane, tr("PLOT3D_TAB_TITLE"));
+ myTabBox->addTab(myIsoPane, tr("PLOT3D_TAB_TITLE"));
myScalarPane = new VisuGUI_ScalarBarPane (this, false);
myScalarPane->setMargin(5);
- aTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB_TITLE"));
+ myInputPane = new VisuGUI_InputPane(VISU::TPLOT3D, theModule, this);
+ myTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB_TITLE"));
+ myTabBox->addTab(myInputPane, tr("INPUT_TAB_TITLE"));
- TopLayout->addWidget(aTabBox);
+ TopLayout->addWidget(myTabBox);
QGroupBox* GroupButtons = new QGroupBox (this, "GroupButtons");
GroupButtons->setGeometry(QRect(10, 10, 281, 48));
connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
}
+VisuGUI_Plot3DDlg::~VisuGUI_Plot3DDlg()
+{}
+
//=======================================================================
//function : accept
//purpose :
QDialog::reject();
}
+//=======================================================================
+//function : initFromPrsObject
+//purpose :
+//=======================================================================
+void VisuGUI_Plot3DDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit)
+{
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TPLOT3D>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
+
+ myScalarPane->initFromPrsObject(myPrsCopy);
+ myIsoPane->initFromPrsObject(myPrsCopy);
+
+ if( !theInit )
+ return;
+
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentPage( 0 );
+}
+
+//=======================================================================
+//function : storeToPrsObject
+//purpose :
+//=======================================================================
+int VisuGUI_Plot3DDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs)
+{
+ if(!myInputPane->check() || !myScalarPane->check())
+ return 0;
+
+ int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= myIsoPane->storeToPrsObject( myPrsCopy );
+
+ VISU::TSameAsFactory<VISU::TPLOT3D>().Copy(thePrs, myPrsCopy);
+
+ return anIsOk;
+}
+
//=======================================================================
//function : onHelp
//purpose :
#ifndef VISUGUI_PLOT3D_H
#define VISUGUI_PLOT3D_H
-#include "VisuGUI_ScalarBarDlg.h"
-
-#include "VISU_Plot3D_i.hh"
+#include "VisuGUI_Prs3dDlg.h"
#include <qhbuttongroup.h>
+#include <qtabwidget.h>
class SalomeApp_Module;
+class VisuGUI_InputPane;
-namespace VISU {
+namespace VISU
+{
class Plot3D_i;
};
};
-class VisuGUI_Plot3DDlg : public QDialog
+class VisuGUI_Plot3DDlg : public VisuGUI_Prs3dDlg
{
Q_OBJECT
public:
VisuGUI_Plot3DDlg (SalomeApp_Module* theModule);
- ~VisuGUI_Plot3DDlg() {};
+ ~VisuGUI_Plot3DDlg();
- void initFromPrsObject (VISU::Plot3D_i* thePrs)
- { myScalarPane->initFromPrsObject(thePrs); myIsoPane->initFromPrsObject(thePrs); }
-
- int storeToPrsObject (VISU::Plot3D_i* thePrs)
- { return myScalarPane->storeToPrsObject(thePrs) && myIsoPane->storeToPrsObject(thePrs); }
+ virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true);
+ virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs);
void setPlane(int theOrientation, double theXRotation, double theYRotation, double thePlanePos);
void onHelp();
private:
+ QTabWidget* myTabBox;
VisuGUI_Plot3DPane* myIsoPane;
VisuGUI_ScalarBarPane* myScalarPane;
+ VisuGUI_InputPane* myInputPane;
+
+ SALOME::GenericObjPtr<VISU::Plot3D_i> myPrsCopy;
};
#endif // VISUGUI_PLOT3D_H
QString VisuGUI_Selection::type( const int ind ) const
{
QString aResStr;
- VISU::Storable::TRestoringMap aMap;
SalomeApp_Study* aStudy = GetStudy();
if ( !aStudy )
return aResStr;
- CORBA::Object_var anObject = GetSelectedObj( aStudy, entry( ind ), &aMap );
- VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
- if ( !CORBA::is_nil( aVisuObj ) ){
- VISU::VISUType aType = aVisuObj->GetType();
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind ));
+ VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(anObjectInfo.mySObject);
+
+ VISU::Base_i* aBase = anObjectInfo.myBase;
+ if(aBase){
+ VISU::VISUType aType = aBase->GetType();
+ if(aType == VISU::TCOLOREDPRS3DHOLDER){
+ CORBA::Object_var anObject = ClientSObjectToObject(anObjectInfo.mySObject);
+ VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
+ aType = aHolder->GetPrsType();
+ }
switch (aType) {
ENUM2STRING( aResStr, VISU::TVISUGEN );
ENUM2STRING( aResStr, VISU::TRESULT );
ENUM2STRING( aResStr, VISU::TCURVE );
ENUM2STRING( aResStr, VISU::TCONTAINER );
ENUM2STRING( aResStr, VISU::TMESH );
- ENUM2STRING( aResStr, VISU::TPRSMERGER );
+ ENUM2STRING( aResStr, VISU::TSCALARMAP );
ENUM2STRING( aResStr, VISU::TISOSURFACE );
ENUM2STRING( aResStr, VISU::TDEFORMEDSHAPE );
ENUM2STRING( aResStr, VISU::TSCALARMAPONDEFORMEDSHAPE );
QString VisuGUI_Selection::nbComponents( const int ind ) const
{
QString aResStr;
- VISU::Storable::TRestoringMap aMap;
SalomeApp_Study* aStudy = GetStudy();
if ( !aStudy )
return aResStr;
- GetSelectedObj( aStudy, entry( ind ), &aMap );
+
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind ));
+ VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(anObjectInfo.mySObject);
+
bool isExist;
- const QString& aVal = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist);
+ QString aVal = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist);
if ( isExist )
aResStr = aVal;
return aResStr;
QString VisuGUI_Selection::medEntity( const int ind ) const
{
+ SalomeApp_Study* aStudy = GetStudy();
+ if ( !aStudy )
+ return QString();
+
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind ));
+ VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(anObjectInfo.mySObject);
+
bool isExist;
- VISU::Storable::TRestoringMap aMap;
- GetSelectedObj( GetStudy(), entry( ind ), &aMap );
- const QString& aVal = VISU::Storable::FindValue(aMap,"myEntityId",&isExist);
+ QString aVal = VISU::Storable::FindValue(aMap,"myEntityId",&isExist);
if ( isExist ) {
using namespace VISU;
TEntity anEntityId = TEntity(aVal.toInt());
QString VisuGUI_Selection::nbTimeStamps( const int ind ) const
{
QString aResStr;
- VISU::Storable::TRestoringMap aMap;
SalomeApp_Study* aStudy = GetStudy();
if ( !aStudy )
return aResStr;
- GetSelectedObj( aStudy, entry( ind ), &aMap );
+
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind ));
+ VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(anObjectInfo.mySObject);
+
bool isExist;
const QString& aVal = VISU::Storable::FindValue(aMap,"myNbTimeStamps",&isExist);
if ( isExist )
return aResStr;
}
-QString VisuGUI_Selection::representation( const int ind ) const
-{
- QString aResStr;
- if (SVTK_ViewWindow* aView = GetActiveViewWindow<SVTK_ViewWindow>(myModule)) {
- if (VISU_Actor* anVISUActor = FindActor(aView, entry(ind).latin1())) {
- int aRepresent = anVISUActor->GetRepresentation();
- switch (aRepresent) {
- ENUM2STRING( aResStr, VISU::POINT );
- ENUM2STRING( aResStr, VISU::WIREFRAME );
- ENUM2STRING( aResStr, VISU::SHADED );
- ENUM2STRING( aResStr, VISU::INSIDEFRAME );
- ENUM2STRING( aResStr, VISU::SURFACEFRAME );
- }
+//----------------------------------------------------------------------------
+template<class TPopupFunctor>
+struct TPopupDispatcher
+{
+ QString
+ operator()(const SalomeApp_Module* theModule,
+ const QString& theEntry)
+ {
+ if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){
+ QString aType = aViewManager->getType();
+ TPopupFunctor aFunctor;
+ if(aType == SVTK_Viewer::Type())
+ return aFunctor.template Get<SVTK_Viewer>(theModule, theEntry);
+ else if(aType == VVTK_Viewer::Type())
+ return aFunctor.template Get<VVTK_Viewer>(theModule, theEntry);
}
+ return QString();
+ }
+};
+
+
+//----------------------------------------------------------------------------
+template<class TViewer>
+bool
+GetPrs3dSelectionInfo(const SalomeApp_Module* theModule,
+ const QString& theEntry,
+ VISU::Prs3d_i*& thePrs3d,
+ SVTK_ViewWindow*& theViewWindow,
+ VISU_Actor*& thenActor)
+{
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(theModule), theEntry);
+ thePrs3d = GetPrs3dFromBase(anObjectInfo.myBase);
+ if(!thePrs3d)
+ return false;
+
+ typedef typename TViewer::TViewWindow TViewWindow;
+ theViewWindow = GetActiveViewWindow<TViewWindow>(theModule);
+ if(!theViewWindow)
+ return false;
+
+ thenActor = FindActor(theViewWindow, thePrs3d);
+ if(!thenActor)
+ return false;
+
+ return true;
+}
+
+
+//----------------------------------------------------------------------------
+struct TViewFunctor
+{
+ template<class TViewer>
+ QString
+ Get(const SalomeApp_Module* theModule,
+ const QString& theEntry)
+ {
+ VISU_Actor* anActor = NULL;
+ VISU::Prs3d_i* aPrs3d = NULL;
+ SVTK_ViewWindow* aViewWindow = NULL;
+ if(!GetPrs3dSelectionInfo<TViewer>(theModule, theEntry, aPrs3d, aViewWindow, anActor))
+ return QString();
+
+ return get(aPrs3d, aViewWindow, anActor);
+ }
+
+ QString
+ virtual
+ get(VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow,
+ VISU_Actor* theActor)
+ {
+ return QString();
}
+};
- return aResStr;
+
+//----------------------------------------------------------------------------
+struct TGetRepesentationFunctor: TViewFunctor
+{
+ QString
+ virtual
+ get(VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow,
+ VISU_Actor* theActor)
+ {
+ QString aResStr;
+ switch (theActor->GetRepresentation()) {
+ ENUM2STRING( aResStr, VISU::POINT );
+ ENUM2STRING( aResStr, VISU::WIREFRAME );
+ ENUM2STRING( aResStr, VISU::SHADED );
+ ENUM2STRING( aResStr, VISU::INSIDEFRAME );
+ ENUM2STRING( aResStr, VISU::SURFACEFRAME );
+ }
+ return aResStr;
+ }
+};
+
+QString VisuGUI_Selection::representation( const int ind ) const
+{
+ return TPopupDispatcher<TGetRepesentationFunctor>()(myModule, entry(ind));
}
+//----------------------------------------------------------------------------
SalomeApp_Study* VisuGUI_Selection::GetStudy() const
{
return dynamic_cast<SalomeApp_Study*>( aLightStudy );
}
+//----------------------------------------------------------------------------
int VisuGUI_Selection::nbChild( const int ind, const bool named ) const
{
int cnt = 0;
return cnt;
}
+//----------------------------------------------------------------------------
QString VisuGUI_Selection::nbChildren( const int ind ) const
{
QString aResStr;
return aResStr;
}
+//----------------------------------------------------------------------------
QString VisuGUI_Selection::nbNamedChildren( const int ind ) const
{
QString aResStr;
return aResStr;
}
-namespace
-{
- struct TIsVisibleFunctor
- {
- template<class TViewer>
- QString
- Get(VisuGUI* theModule,
- const QString& theEntry)
- {
- typedef typename TViewer::TViewWindow TViewWindow;
- if (TViewWindow* aViewWindow = GetActiveViewWindow<TViewWindow>(theModule))
- if (VISU_Actor* anActor = FindActor(aViewWindow,theEntry.latin1()))
- return anActor->GetVisibility() ? "true" : "false";
-
- return QString();
- }
- };
- template<class TPopupFunctor>
- struct TPopupDispatcher
+//----------------------------------------------------------------------------
+struct TIsVisibleFunctor: TViewFunctor
+{
+ QString
+ virtual
+ get(VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow,
+ VISU_Actor* theActor)
{
- QString
- operator()(VisuGUI* theModule,
- const QString& theEntry)
- {
- if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){
- QString aType = aViewManager->getType();
- TPopupFunctor aFunctor;
- if(aType == SVTK_Viewer::Type())
- return aFunctor.template Get<SVTK_Viewer>(theModule,theEntry);
- else if(aType == VVTK_Viewer::Type())
- return aFunctor.template Get<VVTK_Viewer>(theModule,theEntry);
- }
- return QString();
- }
- };
-}
+ return theActor->GetVisibility() ? "true" : "false";
+ }
+};
QString VisuGUI_Selection::isVisible( const int ind ) const
{
- return TPopupDispatcher<TIsVisibleFunctor>()((VisuGUI*)myModule,entry(ind));
+ return TPopupDispatcher<TIsVisibleFunctor>()(myModule, entry(ind));
}
-QString VisuGUI_Selection::isShrunk( const int ind ) const
-{
- QString aResStr;
- if ( SVTK_ViewWindow* aView = GetActiveViewWindow<SVTK_ViewWindow>(myModule) )
- if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
- if ( anVISUActor->IsShrunkable() )
- aResStr = anVISUActor->IsShrunk() ? "1" : "0";
+//----------------------------------------------------------------------------
+struct TIsShrunkFunctor: TViewFunctor
+{
+ QString
+ virtual
+ get(VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow,
+ VISU_Actor* theActor)
+ {
+ return theActor->IsShrunk() ? "1" : "0";
+ }
+};
- return aResStr;
+QString VisuGUI_Selection::isShrunk( const int ind ) const
+{
+ return TPopupDispatcher<TIsShrunkFunctor>()(myModule, entry(ind));
}
+
+//----------------------------------------------------------------------------
QString VisuGUI_Selection::hasActor( const int ind ) const
{
return representation( ind ).isEmpty() ? "0" : "1";
}
+
+//----------------------------------------------------------------------------
+struct TIsShadingFunctor: TViewFunctor
+{
+ QString
+ virtual
+ get(VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow,
+ VISU_Actor* theActor)
+ {
+ if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor))
+ return anActor->IsShading() ? "1" : "0";
+ return QString();
+ }
+};
+
QString VisuGUI_Selection::isShading( const int ind ) const
{
- QString aResStr;
-
- if ( SVTK_ViewWindow* aView = GetActiveViewWindow<SVTK_ViewWindow>(myModule) )
- if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
- if ( VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(anVISUActor) )
- aResStr = anActor->IsShading() ? "1" : "0";
-
- return aResStr;
+ return TPopupDispatcher<TIsShadingFunctor>()(myModule, entry(ind));
}
-QString VisuGUI_Selection::isScalarMapAct( const int ind ) const
-{
- QString aResStr;
- if ( SVTK_ViewWindow* aView = GetActiveViewWindow<SVTK_ViewWindow>(myModule) )
- if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
- {
- VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(anVISUActor);
- aResStr = anActor ? "1" : "0";
- }
+//----------------------------------------------------------------------------
+struct TIsScalarMapActFunctor: TViewFunctor
+{
+ QString
+ virtual
+ get(VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow,
+ VISU_Actor* theActor)
+ {
+ return dynamic_cast<VISU_ScalarMapAct*>(theActor)? "1" : "0";
+ }
+};
- return aResStr;
+QString VisuGUI_Selection::isScalarMapAct( const int ind ) const
+{
+ return TPopupDispatcher<TIsScalarMapActFunctor>()(myModule, entry(ind));
}
+
+//----------------------------------------------------------------------------
bool VisuGUI_Selection::isVisuComponent( const int ind ) const
{
SalomeApp_Study* study = GetStudy();
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// 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 : VisuGUI_Prs3dDlg.cxx
+// Author : Laurent CORNABE & Hubert ROLLAND
+// Module : VISU
+
+#include "VisuGUI_Prs3dDlg.h"
+
+#include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+#include "VisuGUI_ViewTools.h"
+#include "VisuGUI_InputPane.h"
+
+#include "SVTK_ViewWindow.h"
+#include "SVTK_FontWidget.h"
+
+#include "VISUConfig.hh"
+#include "VISU_Convertor.hxx"
+#include "VISU_ScalarMapPL.hxx"
+#include "VISU_ScalarBarActor.hxx"
+#include "VISU_ScalarMapAct.h"
+#include "VISU_ScalarMap_i.hh"
+#include "VISU_Result_i.hh"
+
+#include "LightApp_Application.h"
+
+#include "SUIT_Session.h"
+#include "SUIT_MessageBox.h"
+#include "SUIT_ResourceMgr.h"
+
+#include <qcheckbox.h>
+#include <qlineedit.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qcombobox.h>
+#include <qvbox.h>
+#include <qtoolbutton.h>
+#include <qlayout.h>
+#include <qvalidator.h>
+#include <qcolordialog.h>
+#include <qtabwidget.h>
+
+#include "QtxDblSpinBox.h"
+
+#include <vtkTextProperty.h>
+
+#include <limits.h>
+
+using namespace std;
+
+//-----------------------------------------------------------------------
+// Text Preferences Dialog
+//-----------------------------------------------------------------------
+
+/*!
+ Constructor
+*/
+VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
+ : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+{
+ setName("VisuGUI_TextPrefDlg");
+ setCaption(tr("TIT_TEXT_PREF"));
+ setSizeGripEnabled(TRUE);
+
+ QVBoxLayout* TopLayout = new QVBoxLayout(this);
+ TopLayout->setSpacing(6);
+ TopLayout->setMargin(11);
+
+ // "Title" grp
+ QGroupBox* aTitleGrp = new QGroupBox (2, Qt::Vertical, tr("LBL_TITLE"), this);
+
+ // edit line
+ myTitleEdt = new QLineEdit (aTitleGrp);
+
+ // font
+ QHBox* aHBox = new QHBox (aTitleGrp);
+ aHBox->setSpacing(5);
+ myTitleFont = new SVTK_FontWidget (aHBox);
+
+ TopLayout->addWidget(aTitleGrp);
+
+ // "Labels" grp
+ QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this);
+
+ // font
+ aHBox = new QHBox (aLabelsGrp);
+ aHBox->setSpacing(5);
+ myLabelFont = new SVTK_FontWidget (aHBox);
+
+ TopLayout->addWidget(aLabelsGrp);
+
+ // Common buttons ===========================================================
+ QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
+ GroupButtons->setColumnLayout(0, Qt::Vertical );
+ GroupButtons->layout()->setSpacing( 0 );
+ GroupButtons->layout()->setMargin( 0 );
+ QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+ GroupButtonsLayout->setAlignment( Qt::AlignTop );
+ GroupButtonsLayout->setSpacing( 6 );
+ GroupButtonsLayout->setMargin( 11 );
+
+ QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
+ buttonOk->setAutoDefault( TRUE );
+ buttonOk->setDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
+ GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
+
+ QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
+ buttonCancel->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
+
+ QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
+ buttonHelp->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
+
+ TopLayout->addWidget( GroupButtons );
+
+ connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
+ connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
+ connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
+}
+
+QString VisuGUI_TextPrefDlg::getTitleText()
+{
+ return myTitleEdt->text();
+}
+
+void VisuGUI_TextPrefDlg::setTitleText(QString theText)
+{
+ myTitleEdt->setText(theText);
+}
+
+void VisuGUI_TextPrefDlg::setTitleVisible(bool isVisible)
+{
+ if(isVisible)
+ myTitleEdt->show();
+ else
+ myTitleEdt->hide();
+}
+
+void VisuGUI_TextPrefDlg::onHelp()
+{
+ QString aHelpFileName = "/files/scalar_map_presentation.htm";
+ LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+ if (app) {
+ VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
+ app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
+ }
+ else {
+ SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
+ QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
+ QObject::tr("BUT_OK"));
+ }
+}
+
+void VisuGUI_TextPrefDlg::storeBeginValues()
+{
+ myTitle = myTitleEdt->text();
+ myTitleFont->GetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
+ myLabelFont->GetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
+}
+
+/*!
+ Called when <Cancel> button is clicked, restore begin values
+*/
+void VisuGUI_TextPrefDlg::reject()
+{
+ myTitleEdt->setText(myTitle);
+ myTitleFont->SetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
+ myLabelFont->SetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
+
+ QDialog::reject();
+}
+/*!
+ Called when <Ok> button is clicked, store begin values
+*/
+void VisuGUI_TextPrefDlg::accept()
+{
+ storeBeginValues();
+
+ QDialog::accept();
+}
+
+/*!
+ Provides help on F1 button click
+*/
+void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Key_F1 )
+ {
+ e->accept();
+ onHelp();
+ }
+}
+
+//-----------------------------------------------------------------------
+// Scalar Bar Pane
+//-----------------------------------------------------------------------
+
+/*!
+ Constructor
+*/
+VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
+ QVBox(parent), myPreviewActor(0)
+{
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+ QString propertyName;
+ propertyName = QString("scalar_bar_vertical_");
+ myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
+ myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
+ myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
+ myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
+
+ propertyName = QString("scalar_bar_horizontal_");
+ myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
+ myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
+ myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
+ myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
+
+ Imin = 0.0; Imax = 0.0; /*Fmin = 0.0; Fmax = 0.0;*/ Rmin = 0.0; Rmax = 0.0;
+ myRangeMode = -1;
+
+ setSpacing(6);
+ //setMargin(11);
+
+ // Range ============================================================
+ RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup");
+ RangeGroup->setColumnLayout(0, Qt::Vertical );
+ RangeGroup->layout()->setSpacing( 0 );
+ RangeGroup->layout()->setMargin( 0 );
+ QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
+ RangeGroupLayout->setAlignment( Qt::AlignTop );
+ RangeGroupLayout->setSpacing( 6 );
+ RangeGroupLayout->setMargin( 11 );
+
+ myModeLbl = new QLabel("Scalar Mode", RangeGroup);
+
+ myModeCombo = new QComboBox(RangeGroup);
+
+ CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), RangeGroup);
+ CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), RangeGroup, "RBFrange");
+ RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), RangeGroup, "RBIrange");
+ RBFrange->setChecked( true );
+
+ MinEdit = new QLineEdit( RangeGroup, "MinEdit" );
+ MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ MinEdit->setMinimumWidth( 70 );
+ MinEdit->setValidator( new QDoubleValidator(this) );
+ MinEdit->setText( "0.0" );
+ QLabel* MinLabel = new QLabel (tr("LBL_MIN"), RangeGroup, "MinLabel");
+ MinLabel->setBuddy(MinEdit);
+
+ MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" );
+ MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ MaxEdit->setMinimumWidth( 70 );
+ MaxEdit->setValidator( new QDoubleValidator(this) );
+ MaxEdit->setText( "0.0" );
+ QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), RangeGroup, "MaxLabel");
+ MaxLabel->setBuddy(MaxEdit);
+
+ RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
+ RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3);
+ RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3);
+ RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1);
+ RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3);
+ RangeGroupLayout->addWidget( MinLabel, 3, 0 );
+ RangeGroupLayout->addWidget( MinEdit, 3, 1 );
+ RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
+ RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
+
+ //TopLayout->addWidget( RangeGroup );
+
+ // Colors and Labels ========================================================
+ QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup");
+ ColLabGroup->setColumnLayout(0, Qt::Vertical );
+ ColLabGroup->layout()->setSpacing( 0 );
+ ColLabGroup->layout()->setMargin( 0 );
+ QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
+ ColLabGroupLayout->setAlignment( Qt::AlignTop );
+ ColLabGroupLayout->setSpacing( 6 );
+ ColLabGroupLayout->setMargin( 11 );
+
+ QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup, "ColorLabel");
+ ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
+ ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ ColorSpin->setMinimumWidth( 70 );
+ ColorSpin->setValue( 64 );
+
+ QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup, "LabelLabel");
+ LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
+ LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ LabelSpin->setMinimumWidth( 70 );
+ LabelSpin->setValue( 5 );
+
+ ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
+ ColLabGroupLayout->addWidget( ColorSpin, 0, 1);
+ ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
+ ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
+
+ //TopLayout->addWidget( ColLabGroup );
+
+ // Orientation ==========================================================
+ QButtonGroup* OrientGroup = new QButtonGroup (tr("ORIENTATION_GRP"), this, "OrientGroup");
+ OrientGroup->setColumnLayout(0, Qt::Vertical );
+ OrientGroup->layout()->setSpacing( 0 );
+ OrientGroup->layout()->setMargin( 0 );
+ QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
+ OrientGroupLayout->setAlignment( Qt::AlignTop );
+ OrientGroupLayout->setSpacing( 6 );
+ OrientGroupLayout->setMargin( 11 );
+
+ RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGroup, "RBvert");
+ RBvert->setChecked( true );
+ RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori");
+ OrientGroupLayout->addWidget( RBvert, 0, 0 );
+ OrientGroupLayout->addWidget( RBhori, 0, 1 );
+
+ // TopLayout->addWidget( OrientGroup );
+
+ // Origin ===============================================================
+ QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this, "OriginGroup");
+ OriginGroup->setColumnLayout(0, Qt::Vertical );
+ OriginGroup->layout()->setSpacing( 0 );
+ OriginGroup->layout()->setMargin( 0 );
+ QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
+ OriginGroupLayout->setAlignment( Qt::AlignTop );
+ OriginGroupLayout->setSpacing( 6 );
+ OriginGroupLayout->setMargin( 11 );
+
+ QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup, "XLabel");
+ XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
+ XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ XSpin->setMinimumWidth( 70 );
+ XSpin->setValue( 0.01 );
+
+ QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup, "YLabel");
+ YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
+ YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ YSpin->setMinimumWidth( 70 );
+ YSpin->setValue( 0.01 );
+
+ OriginGroupLayout->addWidget( XLabel, 0, 0);
+ OriginGroupLayout->addWidget( XSpin, 0, 1);
+ OriginGroupLayout->addWidget( YLabel, 0, 2);
+ OriginGroupLayout->addWidget( YSpin, 0, 3);
+
+ //TopLayout->addWidget( OriginGroup );
+
+ // Dimensions =========================================================
+ QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this, "DimGroup");
+ DimGroup->setColumnLayout(0, Qt::Vertical );
+ DimGroup->layout()->setSpacing( 0 );
+ DimGroup->layout()->setMargin( 0 );
+ QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
+ DimGroupLayout->setAlignment( Qt::AlignTop );
+ DimGroupLayout->setSpacing( 6 );
+ DimGroupLayout->setMargin( 11 );
+
+ QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup, "WidthLabel");
+ WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
+ WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ WidthSpin->setMinimumWidth( 70 );
+ WidthSpin->setValue( 0.1 );
+
+ QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup, "HeightLabel");
+ HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
+ HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ HeightSpin->setMinimumWidth( 70 );
+ HeightSpin->setValue( 0.8 );
+
+ DimGroupLayout->addWidget( WidthLabel, 0, 0);
+ DimGroupLayout->addWidget( WidthSpin, 0, 1);
+ DimGroupLayout->addWidget( HeightLabel, 0, 2);
+ DimGroupLayout->addWidget( HeightSpin, 0, 3);
+
+ //TopLayout->addWidget( DimGroup );
+
+ // Save check box ===========================================================
+ QHBox* aSaveBox = new QHBox(this);
+ if (!SetPref) {
+ CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), aSaveBox, "CBSave");
+ //TopLayout->addWidget(CBSave);
+ }
+ else {
+ CBSave = 0;
+ }
+ myTextBtn = new QPushButton("Text properties...", aSaveBox);
+ myTextDlg = new VisuGUI_TextPrefDlg(this);
+ myTextDlg->setTitleVisible(!SetPref);
+
+ QGroupBox* CheckGroup = new QGroupBox("", this, "CheckGroup");
+ CheckGroup->setColumnLayout(0, Qt::Vertical );
+ CheckGroup->layout()->setSpacing( 0 );
+ CheckGroup->layout()->setMargin( 0 );
+ QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup->layout() );
+
+ myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup);
+ myPreviewCheck->setChecked(false);
+ CheckGroupLayout->addWidget(myPreviewCheck , 0, 0 );
+
+ // signals and slots connections ===========================================
+ connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
+ connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) );
+ connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
+ connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
+ connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
+ connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
+ connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
+ connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
+ connect( LabelSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
+ connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
+ connect( HeightSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
+ connect( CBLog, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ));
+ changeRange( 0 );
+ changeDefaults( 0 );
+ myIsStoreTextProp = false;
+ myBusy = false;
+}
+
+/**
+ * Initializes dialog box values from resources
+ */
+void VisuGUI_ScalarBarPane::initFromResources() {
+ int sbCol=64,sbLab=5,orient=0;
+ float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8;
+ float sbVmin=0., sbVmax=0.;
+ bool sbRange=false;
+ QString aString;
+
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+ bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0);
+ int aPlace = 1;
+ if (anIsArrangeBar){
+ aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0);
+ }
+
+ int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0);
+ myModeCombo->setCurrentItem(aScalarMode);
+
+ orient = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", orient);
+ if(orient != 0){
+ orient=1;
+ sbX1=0.2;
+ sbY1=0.01;
+ sbW=0.6;
+ sbH=0.12;
+ }
+
+ QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
+
+ sbX1 = aResourceMgr->doubleValue("VISU", propertyName + "x", sbX1);
+ sbY1 = aResourceMgr->doubleValue("VISU", propertyName + "y", sbY1);
+
+ sbW = aResourceMgr->doubleValue("VISU", propertyName + "width", sbW);
+ sbH = aResourceMgr->doubleValue("VISU", propertyName + "height",sbH);
+
+ if(orient){
+ sbY1 += sbH*(aPlace-1);
+ } else {
+ sbX1 += sbW*(aPlace-1);
+ }
+ sbCol = aResourceMgr->integerValue("VISU" ,"scalar_bar_num_colors", sbCol);
+ sbLab = aResourceMgr->integerValue("VISU", "scalar_bar_num_labels", sbLab);
+
+ int rangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
+ if (rangeType == 1) sbRange = true;
+ sbVmin = aResourceMgr->doubleValue("VISU", "scalar_range_min", sbVmin);
+ sbVmax = aResourceMgr->doubleValue("VISU", "scalar_range_max", sbVmax);
+
+ bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false);
+ setLogarithmic(isLog);
+
+ if((sbX1 < 0.) || (sbY1 < 0.) ||
+ ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
+ if(orient == 0) {
+ sbX1=0.01;
+ sbY1=0.1;
+ sbW=0.1;
+ sbH=0.8;
+ } else {
+ sbX1=0.2;
+ sbY1=0.01;
+ sbW=0.6;
+ sbH=0.12;
+ }
+ }
+ if(sbCol < 2) sbCol=2;
+ if(sbCol > 64) sbCol=64;
+ if(sbLab < 2) sbLab=2;
+ if(sbLab > 65) sbLab=65;
+
+ if(sbVmin > sbVmax) {
+ sbVmin=0.;
+ sbVmax=0.;
+ }
+
+ setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange );
+ setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 0);
+ setScalarBarData( sbCol, sbLab );
+
+ // "Title"
+ bool isBold = false, isItalic = false, isShadow = false;
+ int aFontFamily = VTK_ARIAL;
+
+ if ( aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" ) )
+ {
+ QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
+
+ if ( f.family() == "Arial" )
+ aFontFamily = VTK_ARIAL;
+ else if ( f.family() == "Courier" )
+ aFontFamily = VTK_COURIER;
+ else if ( f.family() == "Times" )
+ aFontFamily = VTK_TIMES;
+
+ isBold = f.bold();
+ isItalic = f.italic();
+ isShadow = f.underline();
+ }
+
+ QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
+
+ myTextDlg->myTitleFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
+
+ // "Labels"
+ isBold = isItalic = isShadow = false;
+ aFontFamily = VTK_ARIAL;
+
+ if ( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" ) )
+ {
+ QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
+
+ if ( f.family() == "Arial" )
+ aFontFamily = VTK_ARIAL;
+ else if ( f.family() == "Courier" )
+ aFontFamily = VTK_COURIER;
+ else if ( f.family() == "Times" )
+ aFontFamily = VTK_TIMES;
+
+ isBold = f.bold();
+ isItalic = f.italic();
+ isShadow = f.underline();
+ }
+
+ aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
+
+ myTextDlg->myLabelFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
+}
+
+/**
+ * Stores dialog values to resources
+ */
+void VisuGUI_ScalarBarPane::storeToResources() {
+ int orient = (RBvert->isChecked())? 0 : 1;
+ float sbX1 = XSpin->value();
+ float sbY1 = YSpin->value();
+ float sbW = WidthSpin->value();
+ float sbH = HeightSpin->value();
+ int sbCol = ColorSpin->value();
+ int sbLab = LabelSpin->value();
+
+ if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
+ if(orient == 0) {
+ sbX1=0.01;
+ sbY1=0.1;
+ sbW=0.17;
+ sbH=0.8;
+ } else {
+ sbX1=0.2;
+ sbY1=0.01;
+ sbW=0.6;
+ sbH=0.12;
+ }
+ }
+
+ bool sbRange = RBIrange->isChecked();
+ float sbVmin = (float)(MinEdit->text().toDouble());
+ float sbVmax = (float)(MaxEdit->text().toDouble());
+
+ if(sbVmin > sbVmax) {
+ sbVmin=0.;
+ sbVmax=0.;
+ }
+
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+ aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient);
+
+ QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
+
+ aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
+ aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
+ aResourceMgr->setValue("VISU", propertyName + "width", sbW);
+ aResourceMgr->setValue("VISU", propertyName + "height", sbH);
+
+ aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
+ aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
+
+ if(sbRange)
+ {
+ aResourceMgr->setValue("VISU", "scalar_range_type", 1);
+ aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin);
+ aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax);
+ }
+ else
+ aResourceMgr->setValue("VISU", "scalar_range_type", 0);
+
+ aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
+
+ ////
+
+ if (myIsStoreTextProp) {
+ // "Title"
+ QColor aTitleColor (255, 255, 255);
+ int aTitleFontFamily = VTK_ARIAL;
+ bool isTitleBold = false;
+ bool isTitleItalic = false;
+ bool isTitleShadow = false;
+
+ myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
+ isTitleBold, isTitleItalic, isTitleShadow);
+
+ QFont aTitleFont;
+
+ aTitleFont.setBold(isTitleBold);
+ aTitleFont.setItalic(isTitleItalic);
+ aTitleFont.setUnderline(isTitleShadow);
+
+ QString titleFontFamily;
+ switch (aTitleFontFamily) {
+ case VTK_ARIAL:
+ titleFontFamily = "Arial";
+ break;
+ case VTK_COURIER:
+ titleFontFamily = "Courier";
+ break;
+ case VTK_TIMES:
+ titleFontFamily = "Times";
+ break;
+ }
+ aTitleFont.setFamily(titleFontFamily);
+
+ aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
+
+ aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
+
+ // "Label"
+ QColor aLabelColor (255, 255, 255);
+ int aLabelFontFamily = VTK_ARIAL;
+ bool isLabelBold = false;
+ bool isLabelItalic = false;
+ bool isLabelShadow = false;
+
+ myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
+ isLabelBold, isLabelItalic, isLabelShadow);
+
+
+ QFont aLabelFont;
+
+ aLabelFont.setBold(isLabelBold);
+ aLabelFont.setItalic(isLabelItalic);
+ aLabelFont.setUnderline(isLabelShadow);
+
+ QString labelFontFamily;
+ switch (aLabelFontFamily) {
+ case VTK_ARIAL:
+ labelFontFamily = "Arial";
+ break;
+ case VTK_COURIER:
+ labelFontFamily = "Courier";
+ break;
+ case VTK_TIMES:
+ labelFontFamily = "Times";
+ break;
+ }
+
+ aLabelFont.setFamily(labelFontFamily);
+
+ aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
+
+ aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
+ }
+}
+
+/**
+ * Initialise dialog box from presentation object
+ */
+void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs)
+{
+ initFromResources();
+ myScalarMap = dynamic_cast<VISU::ScalarMap_i*>(thePrs);
+ if( !myScalarMap )
+ return;
+
+ myTitle = myScalarMap->GetTitle();
+ setPosAndSize( myScalarMap->GetPosX(),
+ myScalarMap->GetPosY(),
+ myScalarMap->GetWidth(),
+ myScalarMap->GetHeight(),
+ myScalarMap->GetBarOrientation());
+ switch(myScalarMap->GetScaling()){
+ case VISU::LOGARITHMIC :
+ setLogarithmic(true);
+ break;
+ default:
+ setLogarithmic(false);
+ }
+ CORBA::Double aRange[2] = {myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax()};
+ Rmin = aRange[0]; Rmax = aRange[1];
+ setRange( myScalarMap->GetMin(), myScalarMap->GetMax(),
+ /*0.0, 0.0,*/ myScalarMap->IsRangeFixed() );
+ setScalarBarData( myScalarMap->GetNbColors(), myScalarMap->GetLabels() );
+
+ // Update myModeCombo
+ int aNbComp = myScalarMap->GetField()->myNbComp;
+ bool isScalarMode = (aNbComp > 1);
+ myModeCombo->clear();
+ myModeCombo->insertItem("<Modulus>");
+ const VISU::PField& aField = myScalarMap->GetField();
+ const VISU::TNames& aCompNames = aField->myCompNames;
+ const VISU::TNames& aUnitNames = aField->myUnitNames;
+ for(int i = 0; i < aNbComp; i++){
+ QString aComponent = QString(aCompNames[i].c_str()).simplifyWhiteSpace();
+ if(aComponent.isNull() || aComponent == "")
+ aComponent = "Component " + QString::number(i+1);
+ else
+ aComponent = "[" + QString::number(i+1) + "] " + aComponent;
+
+ QString anUnit = QString(aUnitNames[i].c_str()).simplifyWhiteSpace();
+ if(anUnit.isNull() || anUnit == "")
+ anUnit = "-";
+
+ aComponent = aComponent + ", " + anUnit;
+
+ myModeCombo->insertItem(aComponent);
+ }
+ //
+ myModeCombo->setCurrentItem(myScalarMap->GetScalarMode());
+ if (aNbComp==1){
+ myModeCombo->setCurrentItem(1);
+ }
+ //
+ myModeLbl->setEnabled(isScalarMode);
+ myModeCombo->setEnabled(isScalarMode);
+
+ // "Title"
+ myTextDlg->setTitleText(QString(myScalarMap->GetTitle()));
+
+ vtkFloatingPointType R, G, B;
+ myScalarMap->GetTitleColor(&R, &G, &B);
+
+ myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
+ myScalarMap->GetTitFontType(),
+ myScalarMap->IsBoldTitle(),
+ myScalarMap->IsItalicTitle(),
+ myScalarMap->IsShadowTitle());
+
+ // "Labels"
+ myScalarMap->GetLabelColor(&R, &G, &B);
+
+ myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
+ myScalarMap->GetLblFontType(),
+ myScalarMap->IsBoldLabel(),
+ myScalarMap->IsItalicLabel(),
+ myScalarMap->IsShadowLabel());
+
+ // Draw Preview
+ if (myPreviewCheck->isChecked()) {
+ createScalarBar();
+ updatePreview();
+ }
+
+}
+/*! Slot update preview of scalar bar, if preview is checked
+ */
+void VisuGUI_ScalarBarPane::updatePreview()
+{
+ if (myPreviewCheck->isChecked()) {
+ if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
+ deleteScalarBar();
+ createScalarBar();
+ vf->Repaint();
+ }
+ }
+}
+
+/*! Creating preview scalar bar
+ */
+void VisuGUI_ScalarBarPane::createScalarBar()
+{
+ if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
+ if (myPreviewActor != 0) return;
+ if (myScalarMap == NULL) return;
+
+ if (!check()) return;
+ myScalarMapPL = VISU_ScalarMapPL::New();
+ if(myScalarMap->GetSpecificPL())
+ myScalarMapPL->ShallowCopy(myScalarMap->GetSpecificPL(), true);
+
+ if ( myBusy ) return;
+
+ myBusy = true;
+
+ int sbCol,sbLab;
+ sbCol = getNbColors();
+ sbLab = getNbLabels();
+ if(sbCol < 2) sbCol=2;
+ if(sbCol > 64) sbCol=64;
+ if(sbLab < 2) sbLab=2;
+ if(sbLab > 65) sbLab=65;
+ myPreviewActor = VISU_ScalarMapAct::New();
+ VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar();
+ myPreviewActor->GetScalarBar()->VisibilityOn();
+ myPreviewActor->PickableOff();
+
+ myScalarMapPL->SetScalarMode(myModeCombo->currentItem());
+ if(isLogarithmic())
+ myScalarMapPL->SetScaling(VISU::LOGARITHMIC);
+ else
+ myScalarMapPL->SetScaling(VISU::LINEAR);
+ vtkFloatingPointType theRange[2];
+ theRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble();
+ theRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble();
+ myScalarMapPL->SetScalarRange(theRange);
+ myScalarMapPL->SetNbColors(sbCol);
+
+ myScalarMapPL->Update();
+
+ aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable());
+
+ if (myTextDlg->getTitleText().latin1() != "")
+ aScalarBarActor->SetTitle(myTextDlg->getTitleText().latin1());
+ else
+ aScalarBarActor->SetTitle(myTitle.c_str());
+ aScalarBarActor->SetOrientation(getOrientation());
+ aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
+ aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY());
+ aScalarBarActor->SetWidth(getWidth());
+ aScalarBarActor->SetHeight(getHeight());
+ aScalarBarActor->SetNumberOfLabels(sbLab);
+ aScalarBarActor->SetMaximumNumberOfColors(sbCol);
+
+ // title text property
+ QColor aTitleColor;
+ int aTitleFontFamily;
+ bool isTitleBold;
+ bool isTitleItalic;
+ bool isTitleShadow;
+ myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily,
+ isTitleBold,isTitleItalic,isTitleShadow);
+ vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty();
+ aTitleProp->SetFontFamily(aTitleFontFamily);
+ aTitleProp->SetColor(vtkFloatingPointType(aTitleColor.red())/255.,
+ vtkFloatingPointType(aTitleColor.green())/255.,
+ vtkFloatingPointType(aTitleColor.blue())/255.);
+ (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
+ (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
+ (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
+
+ // label text property
+ QColor aLabelColor;
+ int aLabelFontFamily;
+ bool isLabelBold;
+ bool isLabelItalic;
+ bool isLabelShadow;
+ myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
+ isLabelBold, isLabelItalic, isLabelShadow);
+ vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty();
+ aLabelProp->SetFontFamily(aLabelFontFamily);
+ aLabelProp->SetColor(vtkFloatingPointType(aLabelColor.red())/255.,
+ vtkFloatingPointType(aLabelColor.green())/255.,
+ vtkFloatingPointType(aLabelColor.blue())/255.);
+ (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
+ (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
+ (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
+
+ aScalarBarActor->Modified();
+
+ VISU::GetActiveViewWindow<SVTK_ViewWindow>()->AddActor(myPreviewActor);
+
+ myBusy = false;
+}
+/*! Deleting preview scalar bar
+ */
+void VisuGUI_ScalarBarPane::deleteScalarBar()
+{
+ if ( myBusy ) return;
+
+ if (myPreviewActor == 0) return;
+ vtkRenderer* aRend = myPreviewActor->GetRenderer();
+ vtkRenderWindow* aWnd = aRend->GetRenderWindow();
+ if(aRend && aWnd)
+ myPreviewActor->RemoveFromRender(aRend);
+ myPreviewActor->GetScalarBar()->VisibilityOff();
+ myPreviewActor->Delete();
+ myPreviewActor = 0;
+
+ if (myScalarMapPL){
+ myScalarMapPL->Delete();
+ myScalarMapPL = 0;
+ }
+}
+/*! public: Deleting preview scalar bar
+ */
+void VisuGUI_ScalarBarPane::deletePreview()
+{
+ deleteScalarBar();
+ if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
+ vf->Repaint();
+}
+/**
+ * Store values to presentation object
+ */
+int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) {
+ if( !myScalarMap )
+ return 0;
+
+ myScalarMap->SetScalarMode(myModeCombo->currentItem());
+ myScalarMap->SetPosition(XSpin->value(), YSpin->value());
+ myScalarMap->SetSize(WidthSpin->value(), HeightSpin->value());
+ myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
+ if(isLogarithmic())
+ myScalarMap->SetScaling(VISU::LOGARITHMIC);
+ else
+ myScalarMap->SetScaling(VISU::LINEAR);
+
+ if (RBFrange->isChecked()) {
+ myScalarMap->SetSourceRange();
+ } else {
+ myScalarMap->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
+ }
+ myScalarMap->SetNbColors(ColorSpin->value());
+ myScalarMap->SetLabels(LabelSpin->value());
+
+ if (isToSave()) storeToResources();
+
+ if (myIsStoreTextProp) {
+ // "Title"
+ myScalarMap->SetTitle(myTextDlg->getTitleText().latin1());
+
+ QColor aTitColor (255, 255, 255);
+ int aTitleFontFamily = VTK_ARIAL;
+ bool isTitleBold = false;
+ bool isTitleItalic = false;
+ bool isTitleShadow = false;
+
+ myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
+ isTitleBold, isTitleItalic, isTitleShadow);
+
+ myScalarMap->SetBoldTitle(isTitleBold);
+ myScalarMap->SetItalicTitle(isTitleItalic);
+ myScalarMap->SetShadowTitle(isTitleShadow);
+ myScalarMap->SetTitFontType(aTitleFontFamily);
+ myScalarMap->SetTitleColor(aTitColor.red()/255.,
+ aTitColor.green()/255.,
+ aTitColor.blue()/255.);
+
+ // "Label"
+ QColor aLblColor (255, 255, 255);
+ int aLabelFontFamily = VTK_ARIAL;
+ bool isLabelBold = false;
+ bool isLabelItalic = false;
+ bool isLabelShadow = false;
+
+ myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
+ isLabelBold, isLabelItalic, isLabelShadow);
+
+ myScalarMap->SetBoldLabel(isLabelBold);
+ myScalarMap->SetItalicLabel(isLabelItalic);
+ myScalarMap->SetShadowLabel(isLabelShadow);
+ myScalarMap->SetLblFontType(aLabelFontFamily);
+ myScalarMap->SetLabelColor(aLblColor.red()/255.,
+ aLblColor.green()/255.,
+ aLblColor.blue()/255.);
+ myIsStoreTextProp = false;
+ }
+
+ return 1;
+}
+
+/*!
+ Called when orientation is changed
+*/
+void VisuGUI_ScalarBarPane::changeDefaults( int )
+{
+ if ( RBvert->isChecked() ) {
+ XSpin->setValue( myVerX );
+ YSpin->setValue( myVerY );
+ WidthSpin->setValue( myVerW );
+ HeightSpin->setValue( myVerH );
+ }
+ else {
+ XSpin->setValue( myHorX );
+ YSpin->setValue( myHorY );
+ WidthSpin->setValue( myHorW );
+ HeightSpin->setValue( myHorH );
+ }
+ updatePreview();
+}
+
+/*!
+ Called when Range mode is changed
+*/
+void VisuGUI_ScalarBarPane::changeRange( int )
+{
+ int mode = -1;
+ if ( RBFrange->isChecked() )
+ mode = 0;
+ if ( RBIrange->isChecked() )
+ mode = 1;
+ if ( myRangeMode == mode )
+ return;
+ //MinSpin->setMaxValue( Fmin );
+ //MaxSpin->setMinValue( Fmax );
+ if ( RBFrange->isChecked() ) {
+ //MinLabel->setEnabled( false );
+ MinEdit->setEnabled( false );
+ //MaxLabel->setEnabled( false );
+ MaxEdit->setEnabled( false );
+ if ( mode != -1 ) {
+ Imin = MinEdit->text().toDouble();
+ Imax = MaxEdit->text().toDouble();
+ }
+ MinEdit->setText( QString::number( Rmin ) );
+ MaxEdit->setText( QString::number( Rmax ) );
+ }
+ else {
+ //MinLabel->setEnabled( true );
+ MinEdit->setEnabled( true );
+ //MaxLabel->setEnabled( true );
+ MaxEdit->setEnabled( true );
+ MinEdit->setText( QString::number( Imin ) );
+ MaxEdit->setText( QString::number( Imax ) );
+ }
+ myRangeMode = mode;
+ updatePreview();
+}
+
+/*!
+ Called when X,Y position is changed
+*/
+void VisuGUI_ScalarBarPane::XYChanged( double )
+{
+ QtxDblSpinBox* snd = (QtxDblSpinBox*)sender();
+ if ( snd == XSpin ) {
+ WidthSpin->setMaxValue( 1.0 - XSpin->value() );
+ }
+ if ( snd == YSpin ) {
+ HeightSpin->setMaxValue( 1.0 - YSpin->value() );
+ }
+ updatePreview();
+}
+
+/*!
+ Called when scalar mode is changed
+*/
+void VisuGUI_ScalarBarPane::changeScalarMode( int theMode )
+{
+ if ( myScalarMap ) {
+ if ( RBFrange->isChecked() ) {
+ int aMode = myScalarMap->GetScalarMode();
+ myScalarMap->SetScalarMode(theMode);
+ CORBA::Double aRange[2] = {myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax()};
+ MinEdit->setText( QString::number( aRange[0] ) );
+ MaxEdit->setText( QString::number( aRange[1] ) );
+ myScalarMap->SetScalarMode(aMode);
+ }
+ }
+ updatePreview();
+}
+
+/*!
+ Sets default values and range mode
+*/
+void VisuGUI_ScalarBarPane::setRange( double imin, double imax/*, double fmin, double fmax*/, bool sbRange )
+{
+ Imin = imin; Imax = imax;// Fmin = fmin; Fmax = fmax;
+ if ( RBIrange->isChecked() ) {
+ MinEdit->setText( QString::number( Imin ) );
+ MaxEdit->setText( QString::number( Imax ) );
+ }
+ else {
+ MinEdit->setText( QString::number( Rmin ) );
+ MaxEdit->setText( QString::number( Rmax ) );
+ }
+ myRangeMode = -1;
+ if( sbRange )
+ RBIrange->setChecked( true );
+ else
+ RBFrange->setChecked( true );
+ changeRange( 0 );
+}
+
+/*!
+ Sets default values and range mode
+*/
+void VisuGUI_ScalarBarPane::setDefaultRange(double imin, double imax){
+ Rmin = imin;
+ Rmax = imax;
+}
+
+/*!
+ Sets and gets parameters
+*/
+bool VisuGUI_ScalarBarPane::isIRange() {
+ return RBIrange->isChecked();
+}
+
+double VisuGUI_ScalarBarPane::getMin() {
+ return MinEdit->text().toDouble();
+}
+
+double VisuGUI_ScalarBarPane::getMax() {
+ return MaxEdit->text().toDouble();
+}
+
+double VisuGUI_ScalarBarPane::getX() {
+ return XSpin->value();
+}
+
+double VisuGUI_ScalarBarPane::getY() {
+ return YSpin->value();
+}
+
+double VisuGUI_ScalarBarPane::getWidth() {
+ return WidthSpin->value();
+}
+
+double VisuGUI_ScalarBarPane::getHeight() {
+ return HeightSpin->value();
+}
+
+int VisuGUI_ScalarBarPane::getNbColors() {
+ return ColorSpin->value();
+}
+
+int VisuGUI_ScalarBarPane::getNbLabels() {
+ return LabelSpin->value();
+}
+
+bool VisuGUI_ScalarBarPane::isLogarithmic() {
+ return CBLog->isChecked();
+}
+
+void VisuGUI_ScalarBarPane::setLogarithmic( bool on ) {
+ CBLog->setChecked( on );
+}
+
+bool VisuGUI_ScalarBarPane::isToSave() {
+ return CBSave ? CBSave->isChecked() : false;
+}
+
+/*!
+ Sets size and position
+*/
+void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
+{
+ if ( vert ) {
+ myVerX = x;
+ myVerY = y;
+ myVerW = w;
+ myVerH = h;
+ RBvert->setChecked( true );
+ }
+ else {
+ myHorX = x;
+ myHorY = y;
+ myHorW = w;
+ myHorH = h;
+ RBhori->setChecked( true );
+ }
+ changeDefaults( 0 );
+}
+
+/*!
+ Sets colors and labels number
+*/
+void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
+{
+ ColorSpin->setValue( colors );
+ LabelSpin->setValue( labels );
+}
+
+/*!
+ Gets orientation
+*/
+int VisuGUI_ScalarBarPane::getOrientation()
+{
+ if (RBvert->isChecked() )
+ return 1;
+ else
+ return 0;
+}
+
+/*!
+ Called when <OK> button is clicked, validates data and closes dialog
+*/
+bool VisuGUI_ScalarBarPane::check()
+{
+ double minVal = MinEdit->text().toDouble();
+ double maxVal = MaxEdit->text().toDouble();
+ if ( RBIrange->isChecked() ) {
+ if (minVal >= maxVal) {
+ SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
+ tr("MSG_MINMAX_VALUES"),
+ tr("BUT_OK"));
+ return false;
+ }
+ }
+ // check if logarithmic mode is on and check imposed range to not contain negative values
+ if ( CBLog->isChecked() ) {
+ if ( RBIrange->isChecked() ) {
+ if ( (minVal > 0) && (maxVal > 0) ) {
+ // nothing to do
+ }
+ else {
+ SUIT_MessageBox::warn1( this,
+ tr("WRN_VISU"),
+ tr("WRN_LOGARITHMIC_RANGE"),
+ tr("BUT_OK"));
+ return false;
+ }
+ }
+ else {
+ if ( Rmin > 0 && Rmax > 0 ) {
+ // nothing to do
+ }
+ else {
+ SUIT_MessageBox::warn1( this,
+ tr("WRN_VISU"),
+ tr("WRN_LOGARITHMIC_FIELD_RANGE"),
+ tr("BUT_OK"));
+ RBIrange->setChecked(1);
+ changeRange(1);
+ //MinEdit->setText( QString::number( Rmin ) );
+ //MaxEdit->setText( QString::number( Rmax ) );
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+void VisuGUI_ScalarBarPane::onTextPref()
+{
+ myTextDlg->storeBeginValues();
+ myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp;
+ updatePreview();
+}
+
+void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview)
+{
+ if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
+ if (thePreview) {
+ createScalarBar();
+ } else {
+ deleteScalarBar();
+ }
+ vf->Repaint();
+ }
+}
+
+VisuGUI_Prs3dDlg::VisuGUI_Prs3dDlg( SalomeApp_Module* theModule )
+ : QDialog( VISU::GetDesktop( theModule ), 0, false,
+ WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+}
+
+void VisuGUI_Prs3dDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, bool theInit )
+{
+}
+
+int VisuGUI_Prs3dDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs )
+{
+ return 1;
+}
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// 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 : VisuGUI_Prs3dDlg.h
+// Author : Laurent CORNABE & Hubert ROLLAND
+// Module : VISU
+
+#ifndef VISUGUI_PRS3DDLG_H
+#define VISUGUI_PRS3DDLG_H
+
+#include <qdialog.h>
+#include <qvbox.h>
+
+#include "SALOME_GenericObjPointer.hh"
+
+class QButtonGroup;
+class QGroupBox;
+class QLabel;
+class QCheckBox;
+class QPushButton;
+class QRadioButton;
+class QSpinBox;
+class QLineEdit;
+class QComboBox;
+class QToolButton;
+class QTabWidget;
+
+class QtxDblSpinBox;
+
+class SalomeApp_Module;
+class SVTK_FontWidget;
+class VISU_ScalarMapAct;
+class VISU_ScalarMapPL;
+
+namespace VISU
+{
+ class ColoredPrs3d_i;
+ class ScalarMap_i;
+}
+
+class VisuGUI_TextPrefDlg: public QDialog
+{
+ Q_OBJECT;
+
+ public:
+ VisuGUI_TextPrefDlg (QWidget* parent);
+ ~VisuGUI_TextPrefDlg() {};
+
+ QString getTitleText();
+ void setTitleText(QString theText);
+
+ void setTitleVisible(bool isVisible);
+
+ void storeBeginValues();
+
+ private:
+ void keyPressEvent( QKeyEvent* e );
+
+ public:
+ SVTK_FontWidget* myTitleFont;
+ SVTK_FontWidget* myLabelFont;
+
+ protected slots:
+ void accept();
+ void reject();
+ void onHelp();
+
+ private:
+ QLineEdit* myTitleEdt;
+ QString myTitle;
+ QColor myColors[2];
+ int myComboVals[2];
+ bool myCheckVals[6];
+};
+
+
+class VisuGUI_ScalarBarPane : public QVBox
+{
+ Q_OBJECT;
+
+ public:
+ VisuGUI_ScalarBarPane(QWidget* parent, bool SetPref);
+ ~VisuGUI_ScalarBarPane() {};
+
+ void setRange( double imin, double imax, /*double fmin, double fmax,*/ bool sbRange );
+ void setDefaultRange(double imin, double imax);
+ int getOrientation();
+ void setPosAndSize( double x, double y, double w, double h, bool vert );
+ void setScalarBarData( int colors, int labels );
+ bool isIRange();
+ double getMin();
+ double getMax();
+ double getX();
+ double getY();
+ double getWidth();
+ double getHeight();
+ int getNbColors();
+ int getNbLabels();
+ bool isLogarithmic();
+ void setLogarithmic( bool on );
+ bool isToSave();
+
+ void initFromResources();
+ void storeToResources();
+
+ void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs);
+ int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs);
+
+ bool check();
+ void deletePreview();
+
+ protected:
+ QButtonGroup* RangeGroup;
+ QRadioButton* RBFrange;
+ QRadioButton* RBIrange;
+ QLineEdit* MinEdit;
+ QLineEdit* MaxEdit;
+
+ QRadioButton* RBhori;
+ QRadioButton* RBvert;
+
+ QtxDblSpinBox* XSpin;
+ QtxDblSpinBox* YSpin;
+
+ QtxDblSpinBox* WidthSpin;
+ QtxDblSpinBox* HeightSpin;
+
+ QSpinBox* ColorSpin;
+ QSpinBox* LabelSpin;
+
+ QCheckBox* CBSave;
+ QCheckBox* CBLog;
+ QLabel* myModeLbl;
+ QComboBox* myModeCombo;
+ QPushButton* myTextBtn;
+ VisuGUI_TextPrefDlg* myTextDlg;
+
+ double Imin, Imax, /* Fmin, Fmax,*/ Rmin, Rmax;
+ double myHorX, myHorY, myHorW, myHorH;
+ double myVerX, myVerY, myVerW, myVerH;
+ int myRangeMode;
+ bool myIsStoreTextProp;
+
+ private slots:
+ void changeDefaults( int );
+ void changeRange( int );
+ void XYChanged( double );
+ void changeScalarMode( int );
+ void onTextPref();
+ void onPreviewCheck(bool thePreview);
+ void updatePreview();
+
+ private:
+ void createScalarBar();
+ void deleteScalarBar();
+
+ QCheckBox* myPreviewCheck;
+ VISU_ScalarMapAct* myPreviewActor;
+ VISU::ScalarMap_i* myScalarMap;
+ VISU_ScalarMapPL* myScalarMapPL;
+ std::string myTitle;
+
+ bool myBusy;
+};
+
+class VisuGUI_Prs3dDlg : public QDialog
+{
+ Q_OBJECT;
+
+ public:
+ VisuGUI_Prs3dDlg( SalomeApp_Module* theModule );
+ ~VisuGUI_Prs3dDlg() {}
+
+ virtual void initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, bool theInit = true );
+ virtual int storeToPrsObject( VISU::ColoredPrs3d_i* thePrs );
+};
+
+#endif
#ifndef VisuGUI_Prs3dTools_HeaderFile
#define VisuGUI_Prs3dTools_HeaderFile
-#include "VISU_Gen_i.hh"
+#include "VISUConfig.hh"
+#include "VisuGUI_Tools.h"
#include "VisuGUI_ViewTools.h"
-#include "VisuGUI_DialogRunner.h"
+#include "VISU_ColoredPrs3dFactory.hh"
+#include "VISU_PipeLine.hxx"
#include <SPlot2d_ViewWindow.h>
namespace VISU
{
- class CutLines_i;
-
- //---------------------------------------------------------------
- inline
- int
- runAndWait( QDialog* dlg, const bool modal )
- {
- VisuGUI_DialogRunner r( dlg );
- return r.run( modal );
- }
-
//---------------------------------------------------------------
template<class TPrs3d_i, class TViewer, class TDlg, int TIsDlgModal>
void
EditPrs3d(VisuGUI* theModule,
+ Handle(SALOME_InteractiveObject)& theIO,
VISU::Prs3d_i* thePrs3d,
SVTK_ViewWindow* theViewWindow)
{
if (TPrs3d_i* aPrs3d = dynamic_cast<TPrs3d_i*>(thePrs3d)) {
+ bool isModal = TIsDlgModal;
+ if( ColoredPrs3d_i* aColoredPrs3d = dynamic_cast<ColoredPrs3d_i*>(aPrs3d) )
+ if( !aColoredPrs3d->IsTimeStampFixed() )
+ isModal = 0;
+
TDlg* aDlg = new TDlg (theModule);
aDlg->initFromPrsObject(aPrs3d);
- if (runAndWait(aDlg,TIsDlgModal)) {
+ if (runAndWait(aDlg,isModal)) {
if (!(aDlg->storeToPrsObject(aPrs3d))) {
delete aDlg;
return;
QObject::tr("BUT_OK"));
}
if (theViewWindow) {
+ theViewWindow->highlight(theIO, 1);
theViewWindow->getRenderer()->ResetCameraClippingRange();
theViewWindow->Repaint();
}
QApplication::restoreOverrideCursor();
}
delete aDlg;
+ RestoreSelection(theModule, NULL/*thePrs3d*/);
}
}
+
+ //----------------------------------------------------------------------------
template<class TPrs3d_i, class TDlg, int TIsDlgModal>
- inline
void
EditPrs3d(VisuGUI* theModule,
Handle(SALOME_InteractiveObject)& theIO,
// Create SVTK_ViewWindow, if it does not exist
aViewWindow = GetViewWindow<SVTK_Viewer>(theModule);
if (aViewWindow) {
- EditPrs3d<TPrs3d_i,SVTK_Viewer,TDlg,TIsDlgModal>(theModule, thePrs3d, aViewWindow);
- aViewWindow->highlight(theIO, 1);
+ EditPrs3d<TPrs3d_i,SVTK_Viewer,TDlg,TIsDlgModal>(theModule, theIO, thePrs3d, aViewWindow);
}
}
+
//---------------------------------------------------------------
template<class TPrs3d_i>
- inline
TPrs3d_i*
- CreatePrs3d(VisuGUI* theModule,
- _PTR(SObject) theTimeStamp,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- int theTimeId)
+ CreatePrs3dFromFactory(VisuGUI* theModule,
+ _PTR(SObject) theTimeStamp,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ int theTimeId,
+ ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
{
VISU::Result_var aResult;
- if (CheckResult(theModule,theTimeStamp,aResult)){
+ if (CheckResult(theModule, theTimeStamp, aResult)){
QApplication::setOverrideCursor(Qt::waitCursor);
- TPrs3d_i* aPrs3d =
- GetVisuGen(theModule)->template CreatePrs3d<TPrs3d_i>
- (aResult,theMeshName,theEntity,theFieldName,theTimeId);
+ TPrs3d_i* aPrs3d = NULL;
+ if(thePublishInStudyMode == VISU::ColoredPrs3d_i::EPublishUnderTimeStamp)
+ aPrs3d = VISU::CreatePrs3d<TPrs3d_i>(aResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeId);
+ else
+ {
+ CORBA::Float anUsedMemory = 0.0;
+ CORBA::Float aRequiredMemory = 0.0;
+ VISU::ColoredPrs3dCache::EnlargeType anEnlargeType =
+ VISU::GetRequiredCacheMemory<TPrs3d_i>(aResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeId,
+ anUsedMemory,
+ aRequiredMemory);
+
+ if( anEnlargeType == VISU::ColoredPrs3dCache::IMPOSSIBLE )
+ {
+ size_t aMb = 1024 * 1024;
+ double aFreeMemory = double(VISU_PipeLine::GetAvailableMemory(2048*aMb)) / double(aMb);
+
+ CORBA::Float aNecessaryMemory = aRequiredMemory - aFreeMemory - anUsedMemory;
+ SUIT_MessageBox::warn1(GetDesktop(theModule),
+ QObject::tr("WRN_VISU"),
+ QObject::tr("ERR_NO_MEMORY_TO_BUILD").arg(aNecessaryMemory),
+ QObject::tr("&OK") );
+ QApplication::restoreOverrideCursor();
+ return NULL;
+ }
+ else
+ {
+ if( anEnlargeType == VISU::ColoredPrs3dCache::ENLARGE )
+ {
+ if(SUIT_MessageBox::info2(GetDesktop(theModule),
+ QObject::tr("WRN_VISU"),
+ QObject::tr("WRN_EXTRA_MEMORY_REQUIRED").arg(aRequiredMemory),
+ QObject::tr("&OK"), QObject::tr("&Cancel"),
+ 0, 1, 0) == 1)
+ {
+ QApplication::restoreOverrideCursor();
+ return NULL;
+ }
+ }
+ aPrs3d = VISU::CreateHolder2GetDeviceByType<TPrs3d_i>(aResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeId,
+ anEnlargeType,
+ aRequiredMemory);
+ }
+ }
+
QApplication::restoreOverrideCursor();
if(aPrs3d)
return aPrs3d;
//---------------------------------------------------------------
template<class TPrs3d_i, class TViewer, class TDlg, int IsDlgModal>
- inline
- bool
- CreatePrs3d(VisuGUI* theModule,
- _PTR(SObject) theTimeStamp,
- const Handle(SALOME_InteractiveObject)& theIO)
+ TPrs3d_i*
+ CreateAndEditPrs3d(VisuGUI* theModule,
+ _PTR(SObject) theTimeStamp,
+ ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
{
Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp);
bool isExist;
QString aType = Storable::FindValue(aMap,"myType",&isExist);
if (!isExist || aType.toInt() != TTIMESTAMP )
- return false;
+ return NULL;
QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
QApplication::setOverrideCursor(Qt::waitCursor);
TPrs3d_i* aPrs3d =
- CreatePrs3d<TPrs3d_i>(theModule,
- theTimeStamp,
- aMeshName.latin1(),
- (Entity)anEntity.toInt(),
- aFieldName.latin1(),
- aTimeStampId.toInt());
-
+ CreatePrs3dFromFactory<TPrs3d_i>(theModule,
+ theTimeStamp,
+ aMeshName.latin1(),
+ (Entity)anEntity.toInt(),
+ aFieldName.latin1(),
+ aTimeStampId.toInt(),
+ thePublishInStudyMode);
+
QApplication::restoreOverrideCursor();
if (aPrs3d) {
SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
QApplication::restoreOverrideCursor();
delete aDlg;
} else {
- DeletePrs3d(theModule,aPrs3d,theIO);
+ DeletePrs3d(theModule,aPrs3d);
QApplication::restoreOverrideCursor();
delete aDlg;
- return false;
+ return NULL;
}
}
}
AddScalarBarPosition(theModule, aViewWindow, aPrs3d, aPos);
}
- return true;
+ return aPrs3d;
}
- return false;
+ return NULL;
}
//---------------------------------------------------------------
template<class TPrs3d_i, class TViewer, class TDlg, int IsDlgModal>
- inline
void
- CreatePrs3d(VisuGUI* theModule)
+ CreatePrs3dInViewer(VisuGUI* theModule,
+ _PTR(SObject) theTimeStampSObj,
+ ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
{
- if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule)))
- return;
-
- _PTR(SObject) aTimeStampSObj;
- Handle(SALOME_InteractiveObject) anIO;
- if (!CheckTimeStamp(theModule,aTimeStampSObj,&anIO))
- return;
-
// Create new TViewWindow instance, if it does not exist.
typedef typename TViewer::TViewWindow TViewWindow;
if (!GetViewWindow<TViewer>(theModule))
return;
- if (!CreatePrs3d<TPrs3d_i,TViewer,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
- return;
+ TPrs3d_i* aPrs3d = CreateAndEditPrs3d<TPrs3d_i,TViewer,TDlg,IsDlgModal>
+ (theModule,theTimeStampSObj,thePublishInStudyMode);
+
+ RestoreSelection(theModule, aPrs3d);
theModule->application()->putInfo(QObject::tr("INF_DONE"));
}
+
+ //----------------------------------------------------------------------------
template<class TPrs3d_i, class TDlg, int IsDlgModal>
- inline
void
- CreatePrs3d(VisuGUI* theModule)
+ CreatePrs3d(VisuGUI* theModule,
+ const QString& theDesiredViewerType = QString())
{
- if (SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager())
- if (aViewManager->getType() == VVTK_Viewer::Type())
- return CreatePrs3d<TPrs3d_i,VVTK_Viewer,TDlg,IsDlgModal>(theModule);
+ if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule)))
+ return;
+
+ _PTR(SObject) aTimeStampSObj;
+ Handle(SALOME_InteractiveObject) anIO;
+ ColoredPrs3d_i::EPublishInStudyMode aPublishInStudyMode;
+ if (!CheckTimeStamp(theModule,aTimeStampSObj,anIO,aPublishInStudyMode))
+ return;
- CreatePrs3d<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>(theModule);
+ if(aPublishInStudyMode == VISU::ColoredPrs3d_i::EPublishIndependently){
+ CreatePrs3dInViewer<TPrs3d_i,VVTK_Viewer,TDlg,0>
+ (theModule,aTimeStampSObj,aPublishInStudyMode);
+ return;
+ }else{
+ if(theDesiredViewerType.isNull()){
+ if (SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager())
+ if (aViewManager->getType() == VVTK_Viewer::Type()){
+ CreatePrs3dInViewer<TPrs3d_i,VVTK_Viewer,TDlg,IsDlgModal>
+ (theModule,aTimeStampSObj,aPublishInStudyMode);
+ return;
+ }
+ CreatePrs3dInViewer<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>
+ (theModule,aTimeStampSObj,aPublishInStudyMode);
+ }else{
+ if(theDesiredViewerType == VVTK_Viewer::Type())
+ CreatePrs3dInViewer<TPrs3d_i,VVTK_Viewer,TDlg,IsDlgModal>
+ (theModule,aTimeStampSObj,aPublishInStudyMode);
+ else
+ CreatePrs3dInViewer<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>
+ (theModule,aTimeStampSObj,aPublishInStudyMode);
+ }
+ }
+ }
+
+
+ //----------------------------------------------------------------------------
+ template<typename TInterface>
+ typename TInterface::_var_type
+ GetInterface(CORBA::Object_ptr theObject)
+ {
+ if(!CORBA::is_nil(theObject))
+ return TInterface::_narrow(theObject);
+ return TInterface::_nil();
}
+
+
+ //----------------------------------------------------------------------------
+ template<typename TServant>
+ TServant*
+ GetServantInterface(CORBA::Object_ptr theObject)
+ {
+ if(!CORBA::is_nil(theObject)){
+ PortableServer::ServantBase_var aServant = GetServant(theObject);
+ return dynamic_cast<TServant*>(aServant.in());
+ }
+ return NULL;
+ }
+
+
+ //----------------------------------------------------------------------------
}
#endif
#include "VisuGUI.h"
#include "VisuGUI_Tools.h"
#include "VisuGUI_ViewTools.h"
+#include "VisuGUI_InputPane.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_FontWidget.h"
#include "VISUConfig.hh"
#include "VISU_Convertor.hxx"
+#include "VISU_ScalarMapPL.hxx"
+#include "VISU_ScalarMap_i.hh"
#include "VISU_ScalarMapAct.h"
+
#include "VISU_Result_i.hh"
+#include "VISU_ColoredPrs3dFactory.hh"
#include "LightApp_Application.h"
#include <qlayout.h>
#include <qvalidator.h>
#include <qcolordialog.h>
-
+#include <qtabwidget.h>
#include <vtkTextProperty.h>
-using namespace VISU;
using namespace std;
-
-VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
- QVBox(parent), myPreviewActor(0)
-{
- SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
- QString propertyName;
- propertyName = QString("scalar_bar_vertical_");
- myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
- myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
- myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
- myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
-
- propertyName = QString("scalar_bar_horizontal_");
- myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
- myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
- myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
- myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
-
- Imin = 0.0; Imax = 0.0; /*Fmin = 0.0; Fmax = 0.0;*/ Rmin = 0.0; Rmax = 0.0;
- myRangeMode = -1;
-
- setSpacing(6);
- //setMargin(11);
-
- // Presentation type ================================================
- myMainGroupBox = new QGroupBox(tr(""), this, "myMainGroupBox");
- myMainGroupBox->setColumnLayout(0, Qt::Vertical );
- myMainGroupBox->layout()->setSpacing( 0 );
- myMainGroupBox->layout()->setMargin( 0 );
- QGridLayout* aMainGroupBoxLayout = new QGridLayout( myMainGroupBox->layout() );
- myMainGroupBox->setAlignment( Qt::AlignTop );
- aMainGroupBoxLayout->setSpacing( 6 );
- aMainGroupBoxLayout->setMargin( 11 );
-
- myOnGroupsCB = new QCheckBox (tr("PRS_ON_GROUPS"), myMainGroupBox);
- myOnGroupsCB->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
- // Lists of groups and add/remove buttons
- QPixmap addImage ( aResourceMgr->loadPixmap("VISU", tr("ICON_ADD")));
- QPixmap removeImage ( aResourceMgr->loadPixmap("VISU", tr("ICON_REMOVE")));
-
- myAllGroups = new VisuGUI_ListBox(myMainGroupBox, "myAllGroups");
- myAllGroups->setSelectionMode(QListBox::Extended);
-
- myAddButton = new QToolButton(myMainGroupBox);
- myAddButton->setPixmap( addImage );
-
- myRemoveButton = new QToolButton(myMainGroupBox);
- myRemoveButton->setPixmap( removeImage );
-
- mySelectedGroups = new VisuGUI_ListBox(myMainGroupBox, "mySelectedGroups");
- mySelectedGroups->setSelectionMode(QListBox::Extended);
-
- // Layouting
- QVBoxLayout* buttonsLayout = new QVBoxLayout();
- buttonsLayout->addWidget(myAddButton);
- buttonsLayout->addSpacing(6);
- buttonsLayout->addWidget(myRemoveButton);
- buttonsLayout->addStretch();
-
- aMainGroupBoxLayout->addMultiCellWidget( myOnGroupsCB, 0, 0, 0, 2);
- aMainGroupBoxLayout->addWidget( myAllGroups, 1, 0 );
- aMainGroupBoxLayout->addLayout( buttonsLayout, 1, 1 );
- aMainGroupBoxLayout->addWidget( mySelectedGroups, 1, 2 );
- aMainGroupBoxLayout->setRowStretch(1, 10);
-
- mySelectedGroups->installEventFilter(this);
-
- // Range ============================================================
- RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup");
- RangeGroup->setColumnLayout(0, Qt::Vertical );
- RangeGroup->layout()->setSpacing( 0 );
- RangeGroup->layout()->setMargin( 0 );
- QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
- RangeGroupLayout->setAlignment( Qt::AlignTop );
- RangeGroupLayout->setSpacing( 6 );
- RangeGroupLayout->setMargin( 11 );
-
- myModeLbl = new QLabel("Scalar Mode", RangeGroup);
-
- myModeCombo = new QComboBox(RangeGroup);
-
- CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), RangeGroup);
- CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
- RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), RangeGroup, "RBFrange");
- RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), RangeGroup, "RBIrange");
- RBFrange->setChecked( true );
-
- MinEdit = new QLineEdit( RangeGroup, "MinEdit" );
- MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- MinEdit->setMinimumWidth( 70 );
- MinEdit->setValidator( new QDoubleValidator(this) );
- MinEdit->setText( "0.0" );
- QLabel* MinLabel = new QLabel (tr("LBL_MIN"), RangeGroup, "MinLabel");
- MinLabel->setBuddy(MinEdit);
-
- MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" );
- MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- MaxEdit->setMinimumWidth( 70 );
- MaxEdit->setValidator( new QDoubleValidator(this) );
- MaxEdit->setText( "0.0" );
- QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), RangeGroup, "MaxLabel");
- MaxLabel->setBuddy(MaxEdit);
-
- RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
- RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3);
- RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3);
- RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1);
- RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3);
- RangeGroupLayout->addWidget( MinLabel, 3, 0 );
- RangeGroupLayout->addWidget( MinEdit, 3, 1 );
- RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
- RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
-
- //TopLayout->addWidget( RangeGroup );
-
- // Colors and Labels ========================================================
- QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup");
- ColLabGroup->setColumnLayout(0, Qt::Vertical );
- ColLabGroup->layout()->setSpacing( 0 );
- ColLabGroup->layout()->setMargin( 0 );
- QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
- ColLabGroupLayout->setAlignment( Qt::AlignTop );
- ColLabGroupLayout->setSpacing( 6 );
- ColLabGroupLayout->setMargin( 11 );
-
- QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup, "ColorLabel");
- ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
- ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- ColorSpin->setMinimumWidth( 70 );
- ColorSpin->setValue( 64 );
-
- QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup, "LabelLabel");
- LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
- LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- LabelSpin->setMinimumWidth( 70 );
- LabelSpin->setValue( 5 );
-
- ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
- ColLabGroupLayout->addWidget( ColorSpin, 0, 1);
- ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
- ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
-
- //TopLayout->addWidget( ColLabGroup );
-
- // Orientation ==========================================================
- QButtonGroup* OrientGroup = new QButtonGroup (tr("ORIENTATION_GRP"), this, "OrientGroup");
- OrientGroup->setColumnLayout(0, Qt::Vertical );
- OrientGroup->layout()->setSpacing( 0 );
- OrientGroup->layout()->setMargin( 0 );
- QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
- OrientGroupLayout->setAlignment( Qt::AlignTop );
- OrientGroupLayout->setSpacing( 6 );
- OrientGroupLayout->setMargin( 11 );
-
- RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGroup, "RBvert");
- RBvert->setChecked( true );
- RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori");
- OrientGroupLayout->addWidget( RBvert, 0, 0 );
- OrientGroupLayout->addWidget( RBhori, 0, 1 );
-
- // TopLayout->addWidget( OrientGroup );
-
- // Origin ===============================================================
- QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this, "OriginGroup");
- OriginGroup->setColumnLayout(0, Qt::Vertical );
- OriginGroup->layout()->setSpacing( 0 );
- OriginGroup->layout()->setMargin( 0 );
- QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
- OriginGroupLayout->setAlignment( Qt::AlignTop );
- OriginGroupLayout->setSpacing( 6 );
- OriginGroupLayout->setMargin( 11 );
-
- QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup, "XLabel");
- XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
- XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- XSpin->setMinimumWidth( 70 );
- XSpin->setValue( 0.01 );
-
- QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup, "YLabel");
- YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
- YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- YSpin->setMinimumWidth( 70 );
- YSpin->setValue( 0.01 );
-
- OriginGroupLayout->addWidget( XLabel, 0, 0);
- OriginGroupLayout->addWidget( XSpin, 0, 1);
- OriginGroupLayout->addWidget( YLabel, 0, 2);
- OriginGroupLayout->addWidget( YSpin, 0, 3);
-
- //TopLayout->addWidget( OriginGroup );
-
- // Dimensions =========================================================
- QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this, "DimGroup");
- DimGroup->setColumnLayout(0, Qt::Vertical );
- DimGroup->layout()->setSpacing( 0 );
- DimGroup->layout()->setMargin( 0 );
- QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
- DimGroupLayout->setAlignment( Qt::AlignTop );
- DimGroupLayout->setSpacing( 6 );
- DimGroupLayout->setMargin( 11 );
-
- QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup, "WidthLabel");
- WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
- WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- WidthSpin->setMinimumWidth( 70 );
- WidthSpin->setValue( 0.1 );
-
- QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup, "HeightLabel");
- HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
- HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- HeightSpin->setMinimumWidth( 70 );
- HeightSpin->setValue( 0.8 );
-
- DimGroupLayout->addWidget( WidthLabel, 0, 0);
- DimGroupLayout->addWidget( WidthSpin, 0, 1);
- DimGroupLayout->addWidget( HeightLabel, 0, 2);
- DimGroupLayout->addWidget( HeightSpin, 0, 3);
-
- //TopLayout->addWidget( DimGroup );
-
- // Save check box ===========================================================
- QHBox* aSaveBox = new QHBox(this);
- if (!SetPref) {
- CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), aSaveBox, "CBSave");
- //TopLayout->addWidget(CBSave);
- }
- else {
- CBSave = 0;
- }
- myTextBtn = new QPushButton("Text properties...", aSaveBox);
- myTextDlg = new VisuGUI_TextPrefDlg(this);
- myTextDlg->setTitleVisible(!SetPref);
-
- QGroupBox* CheckGroup = new QGroupBox("", this, "CheckGroup");
- CheckGroup->setColumnLayout(0, Qt::Vertical );
- CheckGroup->layout()->setSpacing( 0 );
- CheckGroup->layout()->setMargin( 0 );
- QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup->layout() );
-
- myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup);
- myPreviewCheck->setChecked(false);
- CheckGroupLayout->addWidget(myPreviewCheck , 0, 0 );
-
- // signals and slots connections ===========================================
- connect( myOnGroupsCB, SIGNAL( toggled( bool ) ), this, SLOT( onTypeChanged() ) );
- connect( myAllGroups, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onListDoubleClicked( QListBoxItem* ) ) );
- connect( mySelectedGroups, SIGNAL( doubleClicked( QListBoxItem* ) ), this, SLOT( onListDoubleClicked( QListBoxItem* ) ) );
- connect( myAddButton, SIGNAL(clicked()), this, SLOT(onAdd()));
- connect( myRemoveButton, SIGNAL(clicked()), this, SLOT(onRemove()));
- connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
- connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) );
- connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
- connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
- connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
- connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
- connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
- connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
- connect( LabelSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
- connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
- connect( HeightSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
- connect( CBLog, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ));
- onTypeChanged();
- changeRange( 0 );
- changeDefaults( 0 );
- myIsStoreTextProp = false;
- myBusy = false;
-}
-
-/**
- * Initializes dialog box values from resources
- */
-void VisuGUI_ScalarBarPane::initFromResources() {
- int sbCol=64,sbLab=5,orient=0;
- float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8;
- float sbVmin=0., sbVmax=0.;
- bool sbRange=false;
- QString aString;
-
- SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
-
- bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0);
- int aPlace = 1;
- if (anIsArrangeBar){
- aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0);
- }
-
- int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0);
- myModeCombo->setCurrentItem(aScalarMode);
-
- orient = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", orient);
- if(orient != 0){
- orient=1;
- sbX1=0.2;
- sbY1=0.01;
- sbW=0.6;
- sbH=0.12;
- }
-
- QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
-
- sbX1 = aResourceMgr->doubleValue("VISU", propertyName + "x", sbX1);
- sbY1 = aResourceMgr->doubleValue("VISU", propertyName + "y", sbY1);
-
- sbW = aResourceMgr->doubleValue("VISU", propertyName + "width", sbW);
- sbH = aResourceMgr->doubleValue("VISU", propertyName + "height",sbH);
-
- if(orient){
- sbY1 += sbH*(aPlace-1);
- } else {
- sbX1 += sbW*(aPlace-1);
- }
- sbCol = aResourceMgr->integerValue("VISU" ,"scalar_bar_num_colors", sbCol);
- sbLab = aResourceMgr->integerValue("VISU", "scalar_bar_num_labels", sbLab);
-
- int rangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
- if (rangeType == 1) sbRange = true;
- sbVmin = aResourceMgr->doubleValue("VISU", "scalar_range_min", sbVmin);
- sbVmax = aResourceMgr->doubleValue("VISU", "scalar_range_max", sbVmax);
-
- bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false);
- setLogarithmic(isLog);
-
- if((sbX1 < 0.) || (sbY1 < 0.) ||
- ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
- if(orient == 0) {
- sbX1=0.01;
- sbY1=0.1;
- sbW=0.1;
- sbH=0.8;
- } else {
- sbX1=0.2;
- sbY1=0.01;
- sbW=0.6;
- sbH=0.12;
- }
- }
- if(sbCol < 2) sbCol=2;
- if(sbCol > 64) sbCol=64;
- if(sbLab < 2) sbLab=2;
- if(sbLab > 65) sbLab=65;
-
- if(sbVmin > sbVmax) {
- sbVmin=0.;
- sbVmax=0.;
- }
-
- setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange );
- setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 0);
- setScalarBarData( sbCol, sbLab );
-
- // "Title"
- bool isBold = false, isItalic = false, isShadow = false;
- int aFontFamily = VTK_ARIAL;
-
- if ( aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" ) )
- {
- QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
-
- if ( f.family() == "Arial" )
- aFontFamily = VTK_ARIAL;
- else if ( f.family() == "Courier" )
- aFontFamily = VTK_COURIER;
- else if ( f.family() == "Times" )
- aFontFamily = VTK_TIMES;
-
- isBold = f.bold();
- isItalic = f.italic();
- isShadow = f.underline();
- }
-
- QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
-
- myTextDlg->myTitleFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
-
- // "Labels"
- isBold = isItalic = isShadow = false;
- aFontFamily = VTK_ARIAL;
-
- if ( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" ) )
- {
- QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
-
- if ( f.family() == "Arial" )
- aFontFamily = VTK_ARIAL;
- else if ( f.family() == "Courier" )
- aFontFamily = VTK_COURIER;
- else if ( f.family() == "Times" )
- aFontFamily = VTK_TIMES;
-
- isBold = f.bold();
- isItalic = f.italic();
- isShadow = f.underline();
- }
-
- aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
-
- myTextDlg->myLabelFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
-}
-
-/**
- * Stores dialog values to resources
- */
-void VisuGUI_ScalarBarPane::storeToResources() {
- int orient = (RBvert->isChecked())? 0 : 1;
- float sbX1 = XSpin->value();
- float sbY1 = YSpin->value();
- float sbW = WidthSpin->value();
- float sbH = HeightSpin->value();
- int sbCol = ColorSpin->value();
- int sbLab = LabelSpin->value();
-
- if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
- if(orient == 0) {
- sbX1=0.01;
- sbY1=0.1;
- sbW=0.17;
- sbH=0.8;
- } else {
- sbX1=0.2;
- sbY1=0.01;
- sbW=0.6;
- sbH=0.12;
- }
- }
-
- bool sbRange = RBIrange->isChecked();
- float sbVmin = (float)(MinEdit->text().toDouble());
- float sbVmax = (float)(MaxEdit->text().toDouble());
-
- if(sbVmin > sbVmax) {
- sbVmin=0.;
- sbVmax=0.;
- }
-
- SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
-
- aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient);
-
- QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
-
- aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
- aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
- aResourceMgr->setValue("VISU", propertyName + "width", sbW);
- aResourceMgr->setValue("VISU", propertyName + "height", sbH);
-
- aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
- aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
-
- if(sbRange)
- {
- aResourceMgr->setValue("VISU", "scalar_range_type", 1);
- aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin);
- aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax);
- }
- else
- aResourceMgr->setValue("VISU", "scalar_range_type", 0);
-
- aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
-
- ////
-
- if (myIsStoreTextProp) {
- // "Title"
- QColor aTitleColor (255, 255, 255);
- int aTitleFontFamily = VTK_ARIAL;
- bool isTitleBold = false;
- bool isTitleItalic = false;
- bool isTitleShadow = false;
-
- myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
- isTitleBold, isTitleItalic, isTitleShadow);
-
- QFont aTitleFont;
-
- aTitleFont.setBold(isTitleBold);
- aTitleFont.setItalic(isTitleItalic);
- aTitleFont.setUnderline(isTitleShadow);
-
- QString titleFontFamily;
- switch (aTitleFontFamily) {
- case VTK_ARIAL:
- titleFontFamily = "Arial";
- break;
- case VTK_COURIER:
- titleFontFamily = "Courier";
- break;
- case VTK_TIMES:
- titleFontFamily = "Times";
- break;
- }
- aTitleFont.setFamily(titleFontFamily);
-
- aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
-
- aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
-
- // "Label"
- QColor aLabelColor (255, 255, 255);
- int aLabelFontFamily = VTK_ARIAL;
- bool isLabelBold = false;
- bool isLabelItalic = false;
- bool isLabelShadow = false;
-
- myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
- isLabelBold, isLabelItalic, isLabelShadow);
-
-
- QFont aLabelFont;
-
- aLabelFont.setBold(isLabelBold);
- aLabelFont.setItalic(isLabelItalic);
- aLabelFont.setUnderline(isLabelShadow);
-
- QString labelFontFamily;
- switch (aLabelFontFamily) {
- case VTK_ARIAL:
- labelFontFamily = "Arial";
- break;
- case VTK_COURIER:
- labelFontFamily = "Courier";
- break;
- case VTK_TIMES:
- labelFontFamily = "Times";
- break;
- }
-
- aLabelFont.setFamily(labelFontFamily);
-
- aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
-
- aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
- }
-}
-
-/**
- * Initialise dialog box from presentation object
- */
-void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::PrsMerger_i* thePrs) {
- initFromResources();
- myScalarMap = thePrs;
-
- // type of presentation and groups
- VISU::Result_i* theResult = myScalarMap->GetResult();
- VISU_Convertor* aInput = theResult->GetInput();
-
- const VISU::TMeshMap& aMeshMap = aInput->GetMeshMap();
-
- VISU::TMeshMap::const_iterator aMeshIter = aMeshMap.find(thePrs->GetMeshName());
- if(aMeshIter!=aMeshMap.end()){
- const PMesh& aMesh = aMeshIter->second;
- const TGroupMap& aGroupMap = aMesh->myGroupMap;
- TGroupMap::const_iterator aGroupIter = aGroupMap.begin();
- for(;aGroupIter!=aGroupMap.end();aGroupIter++)
- {
- const string& aGroupName = aGroupIter->first;
- if(thePrs->CheckGroup(&aGroupName[0]))
- myAllGroups->insertItem( QString(aGroupName) );
- }
- }
-
- if (myAllGroups->count() < 1)
- {
- myAllGroups->insertItem( tr("NO_GROUPS") );
- myMainGroupBox->setEnabled(false);
- }
- else
- {
- // Get names of the groups
- string_array_var aGroupNames = thePrs->getGroupNames();
- for(int i=0; i<aGroupNames->length(); i++)
- mySelectedGroups->insertItem( QString(aGroupNames[i]) );
-
- if (mySelectedGroups->count() > 0)
- myOnGroupsCB->setChecked(true);
- }
-
- //
- myTitle = thePrs->GetTitle();
- setPosAndSize( thePrs->GetPosX(),
- thePrs->GetPosY(),
- thePrs->GetWidth(),
- thePrs->GetHeight(),
- thePrs->GetBarOrientation());
- switch(thePrs->GetScaling()){
- case VISU::LOGARITHMIC :
- setLogarithmic(true);
- break;
- default:
- setLogarithmic(false);
- }
- vtkFloatingPointType aRange[2];
- thePrs->GetPrsMergerPL()->GetSourceRange(aRange);
- Rmin = aRange[0]; Rmax = aRange[1];
- setRange( thePrs->GetMin(), thePrs->GetMax(),
- /*0.0, 0.0,*/ thePrs->IsRangeFixed() );
- setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
-
- // Update myModeCombo
- int aNbComp = thePrs->GetField()->myNbComp;
- bool isScalarMode = (aNbComp > 1);
- myModeCombo->clear();
- myModeCombo->insertItem("<Modulus>");
- const VISU::PField& aField = thePrs->GetField();
- const VISU::TNames& aCompNames = aField->myCompNames;
- const VISU::TNames& aUnitNames = aField->myUnitNames;
- for(int i = 0; i < aNbComp; i++){
- QString aComponent = QString(aCompNames[i].c_str()).simplifyWhiteSpace();
- if(aComponent.isNull() || aComponent == "")
- aComponent = "Component " + QString::number(i+1);
- else
- aComponent = "[" + QString::number(i+1) + "] " + aComponent;
-
- QString anUnit = QString(aUnitNames[i].c_str()).simplifyWhiteSpace();
- if(anUnit.isNull() || anUnit == "")
- anUnit = "-";
-
- aComponent = aComponent + ", " + anUnit;
-
- myModeCombo->insertItem(aComponent);
- }
- //
- myModeCombo->setCurrentItem(thePrs->GetScalarMode());
- if (aNbComp==1){
- myModeCombo->setCurrentItem(1);
- }
- //
- myModeLbl->setEnabled(isScalarMode);
- myModeCombo->setEnabled(isScalarMode);
-
- // "Title"
- myTextDlg->setTitleText(QString(thePrs->GetTitle()));
-
- vtkFloatingPointType R, G, B;
- thePrs->GetTitleColor(&R, &G, &B);
-
- myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
- thePrs->GetTitFontType(),
- thePrs->IsBoldTitle(),
- thePrs->IsItalicTitle(),
- thePrs->IsShadowTitle());
-
- // "Labels"
- thePrs->GetLabelColor(&R, &G, &B);
-
- myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
- thePrs->GetLblFontType(),
- thePrs->IsBoldLabel(),
- thePrs->IsItalicLabel(),
- thePrs->IsShadowLabel());
-
- // Draw Preview
- if (myPreviewCheck->isChecked()) {
- createScalarBar();
- updatePreview();
- }
-
-}
-/*! Slot update preview of scalar bar, if preview is checked
- */
-void VisuGUI_ScalarBarPane::updatePreview()
-{
- if (myPreviewCheck->isChecked()) {
- if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
- deleteScalarBar();
- createScalarBar();
- vf->Repaint();
- }
- }
-}
-
-/*! Creating preview scalar bar
- */
-void VisuGUI_ScalarBarPane::createScalarBar()
-{
- if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
- if (myPreviewActor != 0) return;
- if (myScalarMap == NULL) return;
-
- if (!check()) return;
- myScalarMapPL = VISU_PrsMergerPL::New();
- if(myScalarMap->GetPrsMergerPL())
- myScalarMapPL->ShallowCopy(myScalarMap->GetPrsMergerPL());
-
- if ( myBusy ) return;
-
- myBusy = true;
-
- int sbCol,sbLab;
- sbCol = getNbColors();
- sbLab = getNbLabels();
- if(sbCol < 2) sbCol=2;
- if(sbCol > 64) sbCol=64;
- if(sbLab < 2) sbLab=2;
- if(sbLab > 65) sbLab=65;
- myPreviewActor = VISU_ScalarMapAct::New();
- VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar();
- myPreviewActor->GetScalarBar()->VisibilityOn();
- myPreviewActor->PickableOff();
-
- myScalarMapPL->SetScalarMode(myModeCombo->currentItem());
- if(isLogarithmic())
- myScalarMapPL->SetScaling(VISU::LOGARITHMIC);
- else
- myScalarMapPL->SetScaling(VISU::LINEAR);
- vtkFloatingPointType theRange[2];
- theRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble();
- theRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble();
- myScalarMapPL->SetScalarRange(theRange);
- myScalarMapPL->SetNbColors(sbCol);
-
- myScalarMapPL->Update();
-
- aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable());
-
- if (myTextDlg->getTitleText().latin1() != "")
- aScalarBarActor->SetTitle(myTextDlg->getTitleText().latin1());
- else
- aScalarBarActor->SetTitle(myTitle.c_str());
- aScalarBarActor->SetOrientation(getOrientation());
- aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
- aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY());
- aScalarBarActor->SetWidth(getWidth());
- aScalarBarActor->SetHeight(getHeight());
- aScalarBarActor->SetNumberOfLabels(sbLab);
- aScalarBarActor->SetMaximumNumberOfColors(sbCol);
-
- // title text property
- QColor aTitleColor;
- int aTitleFontFamily;
- bool isTitleBold;
- bool isTitleItalic;
- bool isTitleShadow;
- myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily,
- isTitleBold,isTitleItalic,isTitleShadow);
- vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty();
- aTitleProp->SetFontFamily(aTitleFontFamily);
- aTitleProp->SetColor(vtkFloatingPointType(aTitleColor.red())/255.,
- vtkFloatingPointType(aTitleColor.green())/255.,
- vtkFloatingPointType(aTitleColor.blue())/255.);
- (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
- (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
- (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
-
- // label text property
- QColor aLabelColor;
- int aLabelFontFamily;
- bool isLabelBold;
- bool isLabelItalic;
- bool isLabelShadow;
- myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
- isLabelBold, isLabelItalic, isLabelShadow);
- vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty();
- aLabelProp->SetFontFamily(aLabelFontFamily);
- aLabelProp->SetColor(vtkFloatingPointType(aLabelColor.red())/255.,
- vtkFloatingPointType(aLabelColor.green())/255.,
- vtkFloatingPointType(aLabelColor.blue())/255.);
- (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
- (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
- (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
-
- aScalarBarActor->Modified();
-
- VISU::GetActiveViewWindow<SVTK_ViewWindow>()->AddActor(myPreviewActor);
-
- myBusy = false;
-}
-/*! Deleting preview scalar bar
- */
-void VisuGUI_ScalarBarPane::deleteScalarBar()
-{
- if ( myBusy ) return;
-
- if (myPreviewActor == 0) return;
- vtkRenderer* aRend = myPreviewActor->GetRenderer();
- vtkRenderWindow* aWnd = aRend->GetRenderWindow();
- if(aRend && aWnd)
- myPreviewActor->RemoveFromRender(aRend);
- myPreviewActor->GetScalarBar()->VisibilityOff();
- myPreviewActor->Delete();
- myPreviewActor = 0;
-
- if (myScalarMapPL){
- myScalarMapPL->Delete();
- myScalarMapPL = 0;
- }
-}
-/*! public: Deleting preview scalar bar
- */
-void VisuGUI_ScalarBarPane::deletePreview()
-{
- deleteScalarBar();
- if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
- vf->Repaint();
-}
-
-/*!
- Event filter
-*/
-bool VisuGUI_ScalarBarPane::eventFilter (QObject* object, QEvent* event)
-{
- if (event->type() == QEvent::KeyPress) {
- QKeyEvent* aKeyEvent = (QKeyEvent*)event;
- if (object == mySelectedGroups && aKeyEvent->key() == Key_Delete)
- onRemove();
- }
- return QObject::eventFilter(object, event);
-}
-
-/**
- * Store values to presentation object
- */
-int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::PrsMerger_i* thePrs) {
- thePrs->RemoveAllGeom();
-
- if (myOnGroupsCB->isChecked())
- {
- QString aMeshName = thePrs->GetMeshName();
- for (int i = 0; i < mySelectedGroups->count(); i++)
- thePrs->AddMeshOnGroup( aMeshName , mySelectedGroups->text(i) );
- }
-
- thePrs->SetScalarMode(myModeCombo->currentItem());
- thePrs->SetPosition(XSpin->value(), YSpin->value());
- thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
- thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
- if(isLogarithmic())
- thePrs->SetScaling(VISU::LOGARITHMIC);
- else
- thePrs->SetScaling(VISU::LINEAR);
-
- if (RBFrange->isChecked()) {
- thePrs->SetSourceRange();
- } else {
- thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
- }
- thePrs->SetNbColors(ColorSpin->value());
- thePrs->SetLabels(LabelSpin->value());
-
- if (isToSave()) storeToResources();
-
- if (myIsStoreTextProp) {
- // "Title"
- thePrs->SetTitle(myTextDlg->getTitleText().latin1());
-
- QColor aTitColor (255, 255, 255);
- int aTitleFontFamily = VTK_ARIAL;
- bool isTitleBold = false;
- bool isTitleItalic = false;
- bool isTitleShadow = false;
-
- myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
- isTitleBold, isTitleItalic, isTitleShadow);
-
- thePrs->SetBoldTitle(isTitleBold);
- thePrs->SetItalicTitle(isTitleItalic);
- thePrs->SetShadowTitle(isTitleShadow);
- thePrs->SetTitFontType(aTitleFontFamily);
- thePrs->SetTitleColor(aTitColor.red()/255.,
- aTitColor.green()/255.,
- aTitColor.blue()/255.);
-
- // "Label"
- QColor aLblColor (255, 255, 255);
- int aLabelFontFamily = VTK_ARIAL;
- bool isLabelBold = false;
- bool isLabelItalic = false;
- bool isLabelShadow = false;
-
- myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
- isLabelBold, isLabelItalic, isLabelShadow);
-
- thePrs->SetBoldLabel(isLabelBold);
- thePrs->SetItalicLabel(isLabelItalic);
- thePrs->SetShadowLabel(isLabelShadow);
- thePrs->SetLblFontType(aLabelFontFamily);
- thePrs->SetLabelColor(aLblColor.red()/255.,
- aLblColor.green()/255.,
- aLblColor.blue()/255.);
- myIsStoreTextProp = false;
- }
-
- return 1;
-}
-
-/*!
- Called when the checkbox is toggled
-*/
-void VisuGUI_ScalarBarPane::onTypeChanged( )
-{
- bool toEnable = myOnGroupsCB->isChecked();
- if (!toEnable)
- {
- myAllGroups->clearSelection();
- mySelectedGroups->clearSelection();
- }
- myAllGroups->setEnabled( toEnable );
- mySelectedGroups->setEnabled( toEnable );
- myAddButton->setEnabled( toEnable );
- myRemoveButton->setEnabled( toEnable );
-}
-
-/*!
- Called when add button is clicked, adds item to choosen groups
-*/
-void VisuGUI_ScalarBarPane::onAdd()
-{
- QStringList aList;
-
- for (int i = 0; i < myAllGroups->count(); i++)
- if (myAllGroups->isSelected(i))
- aList.append(myAllGroups->text(i));
-
- for (int i = 0; i < mySelectedGroups->count(); i++)
- aList.remove(mySelectedGroups->text(i));
-
- mySelectedGroups->insertStringList(aList);
-}
-
-/*!
- Called when remove button is clicked, remove selected items from choosen
-*/
-void VisuGUI_ScalarBarPane::onRemove()
-{
- QPtrList<QListBoxItem> aList;
- aList.setAutoDelete(false);
- for (int i = 0; i < mySelectedGroups->count(); i++)
- if (mySelectedGroups->isSelected(i))
- aList.append(mySelectedGroups->item(i));
-
- for (int i = 0; i < aList.count(); i++)
- delete aList.at(i);
-}
-
-/*!
- Called when an item of listbox is double-clicked
-*/
-void VisuGUI_ScalarBarPane::onListDoubleClicked( QListBoxItem* theItem )
-{
- QListBox* aListBox = theItem->listBox();
-
- if (aListBox == myAllGroups)
- {
- if (!mySelectedGroups->findItem( theItem->text(), Qt::ExactMatch ))
- mySelectedGroups->insertItem(theItem->text());
- }
- else if (aListBox == mySelectedGroups)
- delete theItem;
-}
-
-/*!
- Called when orientation is changed
-*/
-void VisuGUI_ScalarBarPane::changeDefaults( int )
-{
- if ( RBvert->isChecked() ) {
- XSpin->setValue( myVerX );
- YSpin->setValue( myVerY );
- WidthSpin->setValue( myVerW );
- HeightSpin->setValue( myVerH );
- }
- else {
- XSpin->setValue( myHorX );
- YSpin->setValue( myHorY );
- WidthSpin->setValue( myHorW );
- HeightSpin->setValue( myHorH );
- }
- updatePreview();
-}
-
-/*!
- Called when Range mode is changed
-*/
-void VisuGUI_ScalarBarPane::changeRange( int )
-{
- int mode = -1;
- if ( RBFrange->isChecked() )
- mode = 0;
- if ( RBIrange->isChecked() )
- mode = 1;
- if ( myRangeMode == mode )
- return;
- //MinSpin->setMaxValue( Fmin );
- //MaxSpin->setMinValue( Fmax );
- if ( RBFrange->isChecked() ) {
- //MinLabel->setEnabled( false );
- MinEdit->setEnabled( false );
- //MaxLabel->setEnabled( false );
- MaxEdit->setEnabled( false );
- if ( mode != -1 ) {
- Imin = MinEdit->text().toDouble();
- Imax = MaxEdit->text().toDouble();
- }
- MinEdit->setText( QString::number( Rmin ) );
- MaxEdit->setText( QString::number( Rmax ) );
- }
- else {
- //MinLabel->setEnabled( true );
- MinEdit->setEnabled( true );
- //MaxLabel->setEnabled( true );
- MaxEdit->setEnabled( true );
- MinEdit->setText( QString::number( Imin ) );
- MaxEdit->setText( QString::number( Imax ) );
- }
- myRangeMode = mode;
- updatePreview();
-}
-
-/*!
- Called when X,Y position is changed
-*/
-void VisuGUI_ScalarBarPane::XYChanged( double )
-{
- QtxDblSpinBox* snd = (QtxDblSpinBox*)sender();
- if ( snd == XSpin ) {
- WidthSpin->setMaxValue( 1.0 - XSpin->value() );
- }
- if ( snd == YSpin ) {
- HeightSpin->setMaxValue( 1.0 - YSpin->value() );
- }
- updatePreview();
-}
-
-/*!
- Called when scalar mode is changed
-*/
-void VisuGUI_ScalarBarPane::changeScalarMode( int theMode )
-{
- if ( myScalarMap ) {
- if ( RBFrange->isChecked() ) {
- vtkFloatingPointType aRange[2];
- int aMode = myScalarMap->GetScalarMode();
- myScalarMap->SetScalarMode(theMode);
- myScalarMap->GetPrsMergerPL()->GetSourceRange(aRange);
- MinEdit->setText( QString::number( aRange[0] ) );
- MaxEdit->setText( QString::number( aRange[1] ) );
- myScalarMap->SetScalarMode(aMode);
- }
- }
- updatePreview();
-}
-
-/*!
- Sets default values and range mode
-*/
-void VisuGUI_ScalarBarPane::setRange( double imin, double imax/*, double fmin, double fmax*/, bool sbRange )
-{
- Imin = imin; Imax = imax;// Fmin = fmin; Fmax = fmax;
- if ( RBIrange->isChecked() ) {
- MinEdit->setText( QString::number( Imin ) );
- MaxEdit->setText( QString::number( Imax ) );
- }
- else {
- MinEdit->setText( QString::number( Rmin ) );
- MaxEdit->setText( QString::number( Rmax ) );
- }
- myRangeMode = -1;
- if( sbRange )
- RBIrange->setChecked( true );
- else
- RBFrange->setChecked( true );
- changeRange( 0 );
-}
-
-/*!
- Sets default values and range mode
-*/
-void VisuGUI_ScalarBarPane::setDefaultRange(double imin, double imax){
- Rmin = imin;
- Rmax = imax;
-}
-
-/*!
- Sets size and position
-*/
-void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
-{
- if ( vert ) {
- myVerX = x;
- myVerY = y;
- myVerW = w;
- myVerH = h;
- RBvert->setChecked( true );
- }
- else {
- myHorX = x;
- myHorY = y;
- myHorW = w;
- myHorH = h;
- RBhori->setChecked( true );
- }
- changeDefaults( 0 );
-}
-
-/*!
- Sets colors and labels number
-*/
-void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
-{
- ColorSpin->setValue( colors );
- LabelSpin->setValue( labels );
-}
-
-/*!
- Gets orientation
-*/
-int VisuGUI_ScalarBarPane::getOrientation()
-{
- if (RBvert->isChecked() )
- return 1;
- else
- return 0;
-}
-
-/*!
- Called when <OK> button is clicked, validates data and closes dialog
-*/
-bool VisuGUI_ScalarBarPane::check()
-{
- double minVal = MinEdit->text().toDouble();
- double maxVal = MaxEdit->text().toDouble();
- if ( RBIrange->isChecked() ) {
- if (minVal >= maxVal) {
- SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
- tr("MSG_MINMAX_VALUES"),
- tr("BUT_OK"));
- return false;
- }
- }
- // check if logarithmic mode is on and check imposed range to not contain negative values
- if ( CBLog->isChecked() ) {
- if ( RBIrange->isChecked() ) {
- if ( (minVal > 0) && (maxVal > 0) ) {
- // nothing to do
- }
- else {
- SUIT_MessageBox::warn1( this,
- tr("WRN_VISU"),
- tr("WRN_LOGARITHMIC_RANGE"),
- tr("BUT_OK"));
- return false;
- }
- }
- else {
- if ( Rmin > 0 && Rmax > 0 ) {
- // nothing to do
- }
- else {
- SUIT_MessageBox::warn1( this,
- tr("WRN_VISU"),
- tr("WRN_LOGARITHMIC_FIELD_RANGE"),
- tr("BUT_OK"));
- RBIrange->setChecked(1);
- changeRange(1);
- //MinEdit->setText( QString::number( Rmin ) );
- //MaxEdit->setText( QString::number( Rmax ) );
- return false;
- }
- }
- }
- return true;
-}
-
-void VisuGUI_ScalarBarPane::onTextPref()
-{
- myTextDlg->storeBeginValues();
- myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp;
- updatePreview();
-}
-
-void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview)
-{
- if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
- if (thePreview) {
- createScalarBar();
- } else {
- deleteScalarBar();
- }
- vf->Repaint();
- }
-}
-
-//#######################################################################################
-
/*!
Constructor
*/
VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool SetPref)
- : QDialog(VISU::GetDesktop(theModule), 0, true,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+ : VisuGUI_Prs3dDlg(theModule)
{
setName("VisuGUI_ScalarBarDlg");
setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE"));
TopLayout->setSpacing(6);
TopLayout->setMargin(11);
+ myTabBox = new QTabWidget(this);
myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
- TopLayout->addWidget(myScalarPane);
+ myScalarPane->setMargin( 5 );
+ myInputPane = new VisuGUI_InputPane(VISU::TSCALARMAP, theModule, this);
+ myTabBox->addTab(myScalarPane, "Scalar Bar");
+ myTabBox->addTab(myInputPane, "Input");
+
+ TopLayout->addWidget(myTabBox);
// Common buttons ===========================================================
QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
}
-/*!
- Set values in the dialog from the presentation
-*/
-void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::PrsMerger_i* thePrs)
-{
- myScalarPane->initFromPrsObject(thePrs);
-}
-
-/*!
- Set values to presentation from the dialog
-*/
-int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::PrsMerger_i* thePrs)
-{
- return myScalarPane->storeToPrsObject(thePrs);
-}
+VisuGUI_ScalarBarDlg::~VisuGUI_ScalarBarDlg()
+{}
/*!
Called when <OK> button is clicked, validates data and closes dialog
}
/*!
- Provides help on F1 button click
+ Initialize dialog from the presentation
*/
-void VisuGUI_ScalarBarDlg::keyPressEvent( QKeyEvent* e )
+void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit)
{
- QDialog::keyPressEvent( e );
- if ( e->isAccepted() )
- return;
-
- if ( e->key() == Key_F1 )
- {
- e->accept();
- onHelp();
- }
-}
-
-//#######################################################################################
-VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
- : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
-{
- setName("VisuGUI_TextPrefDlg");
- setCaption(tr("TIT_TEXT_PREF"));
- setSizeGripEnabled(TRUE);
-
- QVBoxLayout* TopLayout = new QVBoxLayout(this);
- TopLayout->setSpacing(6);
- TopLayout->setMargin(11);
-
- // "Title" grp
- QGroupBox* aTitleGrp = new QGroupBox (2, Qt::Vertical, tr("LBL_TITLE"), this);
-
- // edit line
- myTitleEdt = new QLineEdit (aTitleGrp);
-
- // font
- QHBox* aHBox = new QHBox (aTitleGrp);
- aHBox->setSpacing(5);
- myTitleFont = new SVTK_FontWidget (aHBox);
-
- TopLayout->addWidget(aTitleGrp);
-
- // "Labels" grp
- QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this);
-
- // font
- aHBox = new QHBox (aLabelsGrp);
- aHBox->setSpacing(5);
- myLabelFont = new SVTK_FontWidget (aHBox);
-
- TopLayout->addWidget(aLabelsGrp);
-
- // Common buttons ===========================================================
- QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
- GroupButtons->setColumnLayout(0, Qt::Vertical );
- GroupButtons->layout()->setSpacing( 0 );
- GroupButtons->layout()->setMargin( 0 );
- QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
- GroupButtonsLayout->setAlignment( Qt::AlignTop );
- GroupButtonsLayout->setSpacing( 6 );
- GroupButtonsLayout->setMargin( 11 );
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TSCALARMAP>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
- QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
- buttonOk->setAutoDefault( TRUE );
- buttonOk->setDefault( TRUE );
- GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
- GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
-
- QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
- buttonCancel->setAutoDefault( TRUE );
- GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
+ myScalarPane->initFromPrsObject( myPrsCopy );
- QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
- buttonHelp->setAutoDefault( TRUE );
- GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
-
- TopLayout->addWidget( GroupButtons );
-
- connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
- connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
- connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
-}
-
-void VisuGUI_TextPrefDlg::onHelp()
-{
- QString aHelpFileName = "/files/scalar_map_presentation.htm";
- LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
- if (app) {
- VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
- app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
- }
- else {
- QString platform;
-#ifdef WIN32
- platform = "winapplication";
-#else
- platform = "application";
-#endif
- SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
- QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
- arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
- QObject::tr("BUT_OK"));
- }
-}
+ if( !theInit )
+ return;
-void VisuGUI_TextPrefDlg::storeBeginValues()
-{
- myTitle = myTitleEdt->text();
- myTitleFont->GetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
- myLabelFont->GetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentPage( 0 );
}
/*!
- Called when <Cancel> button is clicked, restore begin values
-*/
-void VisuGUI_TextPrefDlg::reject()
-{
- myTitleEdt->setText(myTitle);
- myTitleFont->SetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
- myLabelFont->SetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
-
- QDialog::reject();
-}
-/*!
- Called when <Ok> button is clicked, store begin values
+ Store dialog to the presentation
*/
-void VisuGUI_TextPrefDlg::accept()
+int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
{
- storeBeginValues();
-
- QDialog::accept();
+ if(!myInputPane->check() || !myScalarPane->check())
+ return 0;
+
+ int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy );
+
+ VISU::TSameAsFactory<VISU::TSCALARMAP>().Copy(thePrs, myPrsCopy);
+
+ return anIsOk;
}
/*!
Provides help on F1 button click
*/
-void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e )
+void VisuGUI_ScalarBarDlg::keyPressEvent( QKeyEvent* e )
{
QDialog::keyPressEvent( e );
if ( e->isAccepted() )
onHelp();
}
}
-
-
#ifndef VISUGUI_SCALARBARDLG_H
#define VISUGUI_SCALARBARDLG_H
-#include <qdialog.h>
+#include "VisuGUI_Prs3dDlg.h"
+
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qvbox.h>
-#include <qtoolbutton.h>
#include "QtxDblSpinBox.h"
#include "QtxListBox.h"
-#include "VISU_PrsMerger_i.hh"
-
-class QButtonGroup;
-class QGroupBox;
-class QLabel;
-class QRadioButton;
-class QCheckBox;
-class QPushButton;
-class QSpinBox;
-class QLineEdit;
-class QComboBox;
-class QVBox;
-class QToolButton;
-
-class QListBoxItem;
-class SalomeApp_Module;
-class SVTK_FontWidget;
-class VISU_ScalarMapAct;
-
-class VisuGUI_TextPrefDlg: public QDialog
-{
- Q_OBJECT;
-
- public:
- VisuGUI_TextPrefDlg (QWidget* parent);
- ~VisuGUI_TextPrefDlg() {};
-
- QString getTitleText() { return myTitleEdt->text(); }
- void setTitleText(QString theText) { myTitleEdt->setText(theText); }
-
- void setTitleVisible (bool isVisible)
- { (isVisible)? myTitleEdt->show() : myTitleEdt->hide(); }
-
- void storeBeginValues();
-
- private:
- void keyPressEvent( QKeyEvent* e );
-
- public:
- SVTK_FontWidget* myTitleFont;
- SVTK_FontWidget* myLabelFont;
-
- protected slots:
- void accept();
- void reject();
- void onHelp();
-
- private:
- QLineEdit* myTitleEdt;
- QString myTitle;
- QColor myColors[2];
- int myComboVals[2];
- bool myCheckVals[6];
-};
+class VisuGUI_InputPane;
-
-class VisuGUI_ListBox: public QtxListBox
-{
- Q_OBJECT;
-
- public:
- VisuGUI_ListBox( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )
- : QtxListBox(parent, name, f) {};
- ~VisuGUI_ListBox() {};
-
- virtual QSize sizeHint() const { return minimumSizeHint(); };
-};
-
-
-class VisuGUI_ScalarBarPane : public QVBox
+namespace VISU
{
- Q_OBJECT;
-
- public:
- VisuGUI_ScalarBarPane(QWidget* parent, bool SetPref);
- ~VisuGUI_ScalarBarPane() {};
-
- void setRange( double imin, double imax, /*double fmin, double fmax,*/ bool sbRange );
- void setDefaultRange(double imin, double imax);
- bool isIRange() {return RBIrange->isChecked();}
- double getMin() {return MinEdit->text().toDouble();}
- double getMax() {return MaxEdit->text().toDouble();}
- int getOrientation();
- void setPosAndSize( double x, double y, double w, double h, bool vert );
- double getX() {return XSpin->value();}
- double getY() {return YSpin->value();}
- double getWidth() {return WidthSpin->value();}
- double getHeight() {return HeightSpin->value();}
- void setScalarBarData( int colors, int labels );
- int getNbColors() {return ColorSpin->value();}
- int getNbLabels() {return LabelSpin->value();}
- bool isLogarithmic() {return CBLog->isChecked();}
- void setLogarithmic( bool on ) {CBLog->setChecked( on );}
- bool isToSave() {return CBSave ? CBSave->isChecked() : false;}
-
- void initFromResources();
- void storeToResources();
-
- void initFromPrsObject(VISU::PrsMerger_i* thePrs);
- int storeToPrsObject(VISU::PrsMerger_i* thePrs);
-
- bool check();
- void deletePreview();
-
- bool eventFilter (QObject* object, QEvent* event);
-
- protected:
- QGroupBox* myMainGroupBox;
- QCheckBox* myOnGroupsCB;
- VisuGUI_ListBox* myAllGroups;
- VisuGUI_ListBox* mySelectedGroups;
- QToolButton* myAddButton;
- QToolButton* myRemoveButton;
-
- QButtonGroup* RangeGroup;
- QRadioButton* RBFrange;
- QRadioButton* RBIrange;
- QLineEdit* MinEdit;
- QLineEdit* MaxEdit;
-
- QRadioButton* RBhori;
- QRadioButton* RBvert;
-
- QtxDblSpinBox* XSpin;
- QtxDblSpinBox* YSpin;
-
- QtxDblSpinBox* WidthSpin;
- QtxDblSpinBox* HeightSpin;
-
- QSpinBox* ColorSpin;
- QSpinBox* LabelSpin;
-
- QCheckBox* CBSave;
- QCheckBox* CBLog;
- QLabel* myModeLbl;
- QComboBox* myModeCombo;
- QPushButton* myTextBtn;
- VisuGUI_TextPrefDlg* myTextDlg;
-
- double Imin, Imax, /* Fmin, Fmax,*/ Rmin, Rmax;
- double myHorX, myHorY, myHorW, myHorH;
- double myVerX, myVerY, myVerW, myVerH;
- int myRangeMode;
- bool myIsStoreTextProp;
-
- private slots:
- void onTypeChanged();
- void onListDoubleClicked( QListBoxItem* theItem );
- void onAdd();
- void onRemove();
-
- void changeDefaults( int );
- void changeRange( int );
- void XYChanged( double );
- void changeScalarMode( int );
- void onTextPref();
- void onPreviewCheck(bool thePreview);
- void updatePreview();
-
- private:
- void createScalarBar();
- void deleteScalarBar();
+ class ScalarMap_i;
+}
- QCheckBox* myPreviewCheck;
- VISU_ScalarMapAct* myPreviewActor;
- VISU::PrsMerger_i* myScalarMap;
- VISU_PrsMergerPL* myScalarMapPL;
- std::string myTitle;
-
- bool myBusy;
-};
-
-
-class VisuGUI_ScalarBarDlg : public QDialog
+class VisuGUI_ScalarBarDlg : public VisuGUI_Prs3dDlg
{
Q_OBJECT;
public:
VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool SetPref = FALSE);
- ~VisuGUI_ScalarBarDlg() {};
+ ~VisuGUI_ScalarBarDlg();
bool isToSave() {return myScalarPane->isToSave();}
void initFromResources() {myScalarPane->initFromResources();}
void storeToResources() {myScalarPane->storeToResources();}
- void initFromPrsObject(VISU::PrsMerger_i* thePrs);
- int storeToPrsObject(VISU::PrsMerger_i* thePrs);
+ virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true);
+ virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs);
private:
void keyPressEvent( QKeyEvent* e );
protected:
VisuGUI_ScalarBarPane* myScalarPane;
+ VisuGUI_InputPane* myInputPane;
+ QTabWidget* myTabBox;
+
+ SALOME::GenericObjPtr<VISU::ScalarMap_i> myPrsCopy;
};
#endif // VISUGUI_SCALARBARDLG_H
#include "VisuGUI_ScalarMapOnDeformedShapeDlg.h"
#include "VisuGUI_Tools.h"
+#include "VisuGUI_InputPane.h"
#include "VISU_Result_i.hh"
#include "VISU_ScalarMapOnDeformedShape_i.hh"
+#include "VISU_ColoredPrs3dFactory.hh"
#include "VISU_ScalarMapPL.hxx"
#include "VISU_ScalarMapOnDeformedShapePL.hxx"
* Constructor
*/
VisuGUI_ScalarMapOnDeformedShapeDlg::VisuGUI_ScalarMapOnDeformedShapeDlg (SalomeApp_Module* theModule)
- : QDialog(VISU::GetDesktop(theModule), "VisuGUI_ScalarMapOnDeformedShapeDlg", false,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
- myIsAnimation(false),
- myVisuGUI(theModule)
+ : VisuGUI_Prs3dDlg(theModule),
+ myIsAnimation(false),
+ myUpdateScalars(true),
+ myVisuGUI(theModule)
{
- myPrs = NULL;
setCaption(tr("DLG_TITLE"));
setSizeGripEnabled(TRUE);
TopLayout->setSpacing(6);
TopLayout->setMargin(11);
- QTabWidget* aTabBox = new QTabWidget (this);
+ myTabBox = new QTabWidget (this);
// Scalar Map on Deformed shape pane
QVBox* aBox = new QVBox (this);
TopGroupLayout->addWidget(myTimeStampsCombo,2,1);
//
- aTabBox->addTab(aBox, tr("SCALAR_MAP_ON_DEFORMED_SHAPE_TAB"));
+ myTabBox->addTab(aBox, tr("SCALAR_MAP_ON_DEFORMED_SHAPE_TAB"));
// Scalar bar pane
myScalarPane = new VisuGUI_ScalarBarPane (this, false);
myScalarPane->setMargin(5);
+ myInputPane = new VisuGUI_InputPane(VISU::TSCALARMAPONDEFORMEDSHAPE, theModule, this);
- aTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB"));
+ myTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB"));
+ myTabBox->addTab(myInputPane, tr("INPUT_TAB"));
// Buttons
QGroupBox* GroupButtons = new QGroupBox (this, "GroupButtons");
GroupButtonsLayout->addWidget(buttonHelp, 0, 3);
// Add Tab box and Buttons to the top layout
- TopLayout->addWidget(aTabBox);
+ TopLayout->addWidget(myTabBox);
TopLayout->addWidget(GroupButtons);
// signals and slots connections
connect(myTimeStampsCombo, SIGNAL(activated(int)), this, SLOT(onTimeStampChanged(int)));
}
-void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject
- (VISU::ScalarMapOnDeformedShape_i* thePrs, bool isAnim)
-{
- myIsAnimation = isAnim;
- myPrs = thePrs;
-
- setFactor(myPrs->GetScale());
- myTimeStampsCombo->setDisabled(isAnim);
+VisuGUI_ScalarMapOnDeformedShapeDlg::~VisuGUI_ScalarMapOnDeformedShapeDlg()
+{}
- QString aFieldName(myPrs->GetScalarFieldName().c_str());
- float aIterFloat = GetFloatValueOfTimeStamp(myPrs->GetMeshName().c_str(),
- myPrs->GetScalarFieldName().c_str(),
- myPrs->GetScalarIteration(),
- myPrs->GetScalarEntity());
+void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit)
+{
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TSCALARMAPONDEFORMEDSHAPE>().Create(thePrs,
+ VISU::ColoredPrs3d_i::EDoNotPublish);
+
+ setFactor(myPrsCopy->GetScale());
+ myTimeStampsCombo->setDisabled(myIsAnimation);
+ myCurrMeshName = myPrsCopy->GetCMeshName();
+
+
+ CORBA::String_var aMeshName = myPrsCopy->GetMeshName();
+ CORBA::String_var aFieldName(myPrsCopy->GetScalarCFieldName());
+ float aIterFloat = GetFloatValueOfTimeStamp(aMeshName.in(),
+ aFieldName.in(),
+ myPrsCopy->GetScalarLIteration(),
+ myPrsCopy->GetScalarEEntity());
QString aIteration(QString("%1").arg(aIterFloat));
if (myMeshFieldsTimes.size() == 0)
for (aIter->InitEx(true); aIter->More(); aIter->Next()) {
_PTR(SObject) aChildSObj = aIter->Value();
- CORBA::Object_var aChildObject = VISU::ClientSObjectToObject(aChildSObj);
-
_PTR(GenericAttribute) anAttr;
if (aChildSObj->FindAttribute(anAttr, "AttributeString")) {
_PTR(AttributeString) aComment (anAttr);
VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
if (isExist) {
if ((aType == VISU::TTIMESTAMP)) {
- _PTR(GenericAttribute) aNameAttr;
- if (aChildSObj->FindAttribute(aNameAttr, "AttributeName")) {
- _PTR(AttributeName) aName (aNameAttr);
- VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow(aChildObject);
+ _PTR(GenericAttribute) anAttr;
+ if (aChildSObj->FindAttribute(anAttr, "AttributeName")) {
+ _PTR(AttributeName) aNameAttr(anAttr);
QString aMeshName = VISU::getValue(aChildSObj, "myMeshName");
- if (QString(myPrs->GetMeshName().c_str()) != aMeshName) continue;
+ CORBA::String_var aName = myPrsCopy->GetMeshName();
+ if (aMeshName != aName.in())
+ continue;
myCurrMeshName = aMeshName;
QString aFieldName = VISU::getValue(aChildSObj, "myFieldName");
QString aTimeIter = VISU::getValue(aChildSObj, "myTimeStampId");
QString aEntity = VISU::getValue(aChildSObj, "myEntityId");
- VISU::TEntity anEntity;
+ VISU::Entity anEntity;
switch (aEntity.toInt()) {
- case 0: anEntity = VISU::NODE_ENTITY; break;
- case 1: anEntity = VISU::EDGE_ENTITY; break;
- case 2: anEntity = VISU::FACE_ENTITY; break;
- case 3: anEntity = VISU::CELL_ENTITY; break;
+ case 0: anEntity = VISU::NODE; break;
+ case 1: anEntity = VISU::EDGE; break;
+ case 2: anEntity = VISU::FACE; break;
+ case 3: anEntity = VISU::CELL; break;
}
TFT &aFieldsMap = myMeshFieldsTimes[aMeshName.latin1()];
TFE aKey (aFieldName.latin1(), anEntity);
aFieldsMap[aKey][aTimeIter.toInt()] =
- GetFloatValueOfTimeStamp(myPrs->GetMeshName().c_str(),
+ GetFloatValueOfTimeStamp(aMeshName.latin1(),
aFieldName.latin1(),
aTimeIter.toInt(),
anEntity);
AddAllFieldNames();
}
- myFieldsCombo->setCurrentText(aFieldName);
+ myFieldsCombo->setCurrentText(aFieldName.in());
AddAllTimes(myFieldsCombo->currentText());
myTimeStampsCombo->setCurrentText(aIteration);
SetScalarField( false );
- myScalarPane->initFromPrsObject(myPrs);
+ myScalarPane->initFromPrsObject(myPrsCopy);
+
+ if( !theInit )
+ return;
+
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentPage( 0 );
}
-int VisuGUI_ScalarMapOnDeformedShapeDlg::storeToPrsObject
- (VISU::ScalarMapOnDeformedShape_i* thePrs, bool theUpdateScalars, int theIter)
+int
+VisuGUI_ScalarMapOnDeformedShapeDlg
+::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
{
- thePrs->SetScale(getFactor());
-
- if (myIsAnimation)
- thePrs->SetScalarField(myPrs->GetScalarMeshName().c_str(),
- getCurrentScalarFieldName().latin1(),
- theIter,
- myPrs->GetScalarEntity());
- else
- thePrs->SetScalarField(myPrs->GetScalarMeshName().c_str(),
- getCurrentScalarFieldName().latin1(),
- // PAL12928 myTimeStampsCombo->currentItem() + 1,
- myTimeStampID[ myTimeStampsCombo->currentItem() ],
- myPrs->GetScalarEntity());
+ if(!myInputPane->check() || !myScalarPane->check())
+ return 0;
+
+ int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy );
+
+ myPrsCopy->SetScale(getFactor());
- if (theUpdateScalars) SetScalarField( false );
+ CORBA::String_var aMeshName = myPrsCopy->GetMeshName();
+ myPrsCopy->SetScalarField(aMeshName.in(),
+ getCurrentScalarFieldName().latin1(),
+ myTimeStampID[ myTimeStampsCombo->currentItem() ],
+ myPrsCopy->GetScalarEEntity());
- thePrs->ShowColored(true);
+ if(myUpdateScalars)
+ SetScalarField( false );
- myScalarPane->storeToPrsObject(thePrs);
+ myPrsCopy->ShowColored(true);
- myPrs = thePrs;
+ VISU::TSameAsFactory<VISU::TSCALARMAPONDEFORMEDSHAPE>().Copy(thePrs, myPrsCopy);
- return 1;
+ return anIsOk;
}
int VisuGUI_ScalarMapOnDeformedShapeDlg::getCurrentScalarFieldNamePos(){
return myTimeStampsCombo->count();
}
-VISU::TEntity VisuGUI_ScalarMapOnDeformedShapeDlg::getCurrentScalarEntity(){
- VISU::TEntity anEntity;
+VISU::Entity
+VisuGUI_ScalarMapOnDeformedShapeDlg
+::getCurrentScalarEntity()
+{
+ VISU::Entity anEntity;
TFT::const_iterator aIterField = myMeshFieldsTimes[myCurrMeshName].begin();
for(;aIterField != myMeshFieldsTimes[myCurrMeshName].end();aIterField++){
if (aIterField->first.first == myFieldsCombo->currentText()){
}
void VisuGUI_ScalarMapOnDeformedShapeDlg::SetScalarField( const bool save_scalar_pane ){
- // PAL12928 SetScalarField( myTimeStampsCombo->currentItem()+1, "", save_scalar_pane );
SetScalarField( myTimeStampID[ myTimeStampsCombo->currentItem() ], "", save_scalar_pane );
}
-void VisuGUI_ScalarMapOnDeformedShapeDlg::SetScalarField(int theIter,QString theFieldName, const bool save_scalar_pane ){
+void
+VisuGUI_ScalarMapOnDeformedShapeDlg
+::SetScalarField(int theIter,
+ QString theFieldName,
+ const bool save_scalar_pane )
+{
+ if( save_scalar_pane )
+ myScalarPane->storeToPrsObject(myPrsCopy);
QString aFieldName;
else
aFieldName = theFieldName;
- VISU::TEntity anEntity = getCurrentScalarEntity();
-
- myPrs->SetScalarField(myCurrMeshName.latin1(),
- aFieldName.latin1(),
- theIter,
- anEntity);
-
+ VISU::Entity anEntity = getCurrentScalarEntity();
+
+ myPrsCopy->SetScalarField(myCurrMeshName.latin1(),
+ aFieldName.latin1(),
+ theIter,
+ anEntity);
+
if( save_scalar_pane )
- {
- myScalarPane->storeToPrsObject(myPrs);
UpdateScalarField();
- }
}
void VisuGUI_ScalarMapOnDeformedShapeDlg::accept()
}
void VisuGUI_ScalarMapOnDeformedShapeDlg::UpdateScalarField(){
- myPrs->SetScale(getFactor());
- vtkFloatingPointType aRange[2];
- myPrs->GetScalarMapOnDeformedShapePL()->Build();
- myPrs->GetScalarMapOnDeformedShapePL()->Update();
- myPrs->GetScalarMapOnDeformedShapePL()->GetSourceRange(aRange);
- double aDoubleRange[2];
- aDoubleRange[0] = double(aRange[0]);
- aDoubleRange[1] = double(aRange[1]);
- myScalarPane->initFromPrsObject(myPrs);
- myScalarPane->setRange(aDoubleRange[0],aDoubleRange[1],myScalarPane->isIRange());
+ myScalarPane->initFromPrsObject(myPrsCopy);
}
-float VisuGUI_ScalarMapOnDeformedShapeDlg::GetFloatValueOfTimeStamp(const char* theMeshName,
- const char* theFieldName,
- const int theIter,
- const VISU::TEntity theEntity){
+float
+VisuGUI_ScalarMapOnDeformedShapeDlg
+::GetFloatValueOfTimeStamp(const char* theMeshName,
+ const char* theFieldName,
+ const int theIter,
+ const VISU::Entity theEntity)
+{
float ret=1;
- VISU::Result_i* theResult = myPrs->GetResult();
- VISU::PField aField = theResult->GetInput()->GetField(theMeshName,theEntity,theFieldName);
- if(!aField) return ret;
+ VISU::TEntity anEntity = VISU::TEntity(theEntity);
+ VISU::Result_i* theResult = myPrsCopy->GetCResult();
+ VISU::Result_i::TInput* anInput = theResult->GetInput();
+ VISU::PField aField = anInput->GetField(theMeshName,
+ anEntity,
+ theFieldName);
+ if(!aField)
+ return ret;
VISU::TValField& aValField = aField->myValField;
VISU::TValField::const_iterator aIter = aValField.find(theIter);
if(aIter != aValField.end()){
#ifndef VISUGUI_SCALARMAPONDEFORMEDSHAPEDLS_H
#define VISUGUI_SCALARMAPONDEFORMEDSHAPEDLS_H
-#include "VisuGUI_ScalarBarDlg.h"
+#include "VisuGUI_Prs3dDlg.h"
+
+#include "VISUConfig.hh"
#include "QtxDblSpinBox.h"
#include <qdialog.h>
#include <qgroupbox.h>
#include <qcheckbox.h>
+#include <qcombobox.h>
#include <qlabel.h>
#include <qpushbutton.h>
+#include <qtabwidget.h>
#include <set>
#include <vector>
class SalomeApp_Module;
-class QComboBox;
-class QString;
+class VisuGUI_InputPane;
-namespace VISU{
+namespace VISU
+{
class ScalarMapOnDeformedShape_i;
}
-class VisuGUI_ScalarMapOnDeformedShapeDlg : public QDialog
+class VisuGUI_ScalarMapOnDeformedShapeDlg : public VisuGUI_Prs3dDlg
{
Q_OBJECT
public:
VisuGUI_ScalarMapOnDeformedShapeDlg (SalomeApp_Module* theModule);
- ~VisuGUI_ScalarMapOnDeformedShapeDlg() {};
+ ~VisuGUI_ScalarMapOnDeformedShapeDlg();
double getFactor()
{ return ScalFact->value(); }
void setFactor(double theFactor)
{ ScalFact->setValue(theFactor); }
-
- void initFromPrsObject(VISU::ScalarMapOnDeformedShape_i* thePrs,bool isAnim=false);
- int storeToPrsObject(VISU::ScalarMapOnDeformedShape_i* thePrs,bool theUpdateScalars=true,int theIter=1);
+ virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true);
+ virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs);
int getCurrentScalarFieldNamePos();
QString getCurrentScalarFieldName();
int getCurrentScalarNbIterations();
- VISU::TEntity getCurrentScalarEntity();
+ VISU::Entity getCurrentScalarEntity();
void SetScalarField(int theIter,QString theFieldName=QString(""), const bool = true );
private:
private:
QtxDblSpinBox* ScalFact;
+ QTabWidget* myTabBox;
VisuGUI_ScalarBarPane* myScalarPane;
+ VisuGUI_InputPane* myInputPane;
QComboBox *myFieldsCombo;
QComboBox *myTimeStampsCombo;
typedef std::map<int,float> TTL; // Times map definition (iteration time, real value of time)
- typedef std::pair<QString,VISU::TEntity> TFE; // pair field name and entity
+ typedef std::pair<QString,VISU::Entity> TFE; // pair field name and entity
typedef std::map<TFE,TTL> TFT; // Field name and enity to Times
typedef std::map<QString,TFT> TMF; // Mesh to fields map
QString myCurrMeshName;
int myCurrScalarIter;
bool myIsAnimation;
+ bool myUpdateScalars;
std::vector<int> myTimeStampID;
_PTR(SObject) mySelectionObj;
- VISU::ScalarMapOnDeformedShape_i* myPrs;
+ SALOME::GenericObjPtr<VISU::ScalarMapOnDeformedShape_i> myPrsCopy;
SalomeApp_Module* myVisuGUI;
protected:
float GetFloatValueOfTimeStamp(const char* theMeshName,
const char* theFieldName,
const int theIteration,
- const VISU::TEntity theEntity);
+ const VISU::Entity theEntity);
};
#endif // VISUGUI_DEFORMEDSHAPEDLS_H
myFieldName->setText((aFieldName == "NULL") ? QString("No name") : aFieldName);
VISU_Actor* anVISUActor =
- VISU::FindActor(aViewWindow, aSObject->GetID().c_str());
+ VISU::FindActor(VISU::GetAppStudy(myModule), aViewWindow, aSObject->GetID().c_str());
if (anVISUActor) {
vtkFloatingPointType aCoord[6];
anVISUActor->GetBounds(aCoord);
myDZLbl->setText(QString::number( ABS(aCoord[5]-aCoord[4]) ));
TColStd_IndexedMapOfInteger aMapIndex;
- typedef map<int,vtkFloatingPointType*> PointsMap;
- PointsMap aPointsMap;
+ typedef std::vector<vtkFloatingPointType> TCoordArray;
+ typedef map<int, TCoordArray> TPointCoordsMap;
+ TPointCoordsMap aPointCoordsMap;
aSelector->GetIndex(anIO, aMapIndex);
- vtkDataSet* aDataSet = anVISUActor->GetInput();
+ vtkDataSet* aDataSet = anVISUActor->GetMapper()->GetInput();
vtkPointData* aPntData = aDataSet->GetPointData();
for (int ind = 1; ind <= aMapIndex.Extent(); ind++) {
myScalarValLbl->setText(getValue(aPntData, aVTKID));
myVectorValLbl->setText(getVector(aPntData, aVTKID));
//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
- const VISU::PIDMapper& aMapper = aPrs3d->GetPL()->GetIDMapper();
+ const VISU::PIDMapper& aMapper = aPrs3d->GetPipeLine()->GetIDMapper();
VISU::TIdTypeVector aVec = aMapper->GetIndexesOfNode(anID);
switch(aVec.size()){
case 3:
int aVTKID = anVISUActor->GetElemVTKID(anID);
if (aCell != NULL) {
int aNbOfPoints = aCell->GetNumberOfPoints();
- if ( aNbOfPoints <= 1 ) { // Cell is point
- clearFields();
- } else {
+ if ( aNbOfPoints > 0 ) {
myCellIDValLbl->setText( QString::number(anID) );
myCellScalarValLbl->setText(getValue(aCellData, aVTKID));
myCellVectorValLbl->setText(getVector(aCellData, aVTKID));
int aNodeVTKId = aPointList->GetId(i);
vtkFloatingPointType* aCoord = aDataSet->GetPoint(aNodeVTKId);
vtkIdType aNodeObjId = anVISUActor->GetNodeObjId(aNodeVTKId);
- aPointsMap.insert(PointsMap::value_type(aNodeObjId,aCoord));
+ TCoordArray aCoordArray(aCoord, aCoord + 3);
+ aPointCoordsMap[aNodeObjId] = aCoordArray;
}
}
}
}
}
- myListPoints->setNumRows(aPointsMap.size());
- PointsMap::const_iterator It = aPointsMap.begin();
+ myListPoints->setNumRows(aPointCoordsMap.size());
+ TPointCoordsMap::const_iterator anIter = aPointCoordsMap.begin();
- const VISU::PIDMapper& aMapper = aPrs3d->GetPL()->GetIDMapper();
- for (int i = 0; It != aPointsMap.end() && i < myListPoints->numRows(); It++, i++) {
+ const VISU::PIDMapper& aMapper = aPrs3d->GetPipeLine()->GetIDMapper();
+ for (int i = 0; anIter != aPointCoordsMap.end() && i < myListPoints->numRows(); anIter++, i++) {
myListPoints->verticalHeader()->setLabel(i, QString::number( i ));
- int id = It->first;
+ int id = anIter->first;
//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
VISU::TIdTypeVector aVec = aMapper->GetIndexesOfNode(id);
QString aI,aJ,aK;
//ENK: 23.11.2006
myListPoints->setText(i, 0, QString::number( id ));
- vtkFloatingPointType* aCoord = It->second;
- myListPoints->setText(i, 1, QString::number( aCoord[0] ));
- myListPoints->setText(i, 2, QString::number( aCoord[1] ));
- myListPoints->setText(i, 3, QString::number( aCoord[2] ));
+ const TCoordArray& aCoordArray = anIter->second;
+ myListPoints->setText(i, 1, QString::number( aCoordArray[0] ));
+ myListPoints->setText(i, 2, QString::number( aCoordArray[1] ));
+ myListPoints->setText(i, 3, QString::number( aCoordArray[2] ));
myListPoints->setText(i, 4, aI);//ENK: 23.11.2006 - PAL13176
myListPoints->setText(i, 5, aJ);//ENK: 23.11.2006 - PAL13176
myListPoints->setText(i, 6, aK);//ENK: 23.11.2006 - PAL13176
myListPoints->setText(i, 7, getValue(aPntData, id));
myListPoints->setText(i, 8, getVector(aPntData, id));
}
+ for(int aColumnId = 0; aColumnId < 9; aColumnId++)
+ myListPoints->adjustColumn(aColumnId);
}
} else {
clearFields();
myIValLbl->setText( "-" );//ENK: 23.11.2006 - PAL13176
myJValLbl->setText( "-" );//ENK: 23.11.2006 - PAL13176
myKValLbl->setText( "-" );//ENK: 23.11.2006 - PAL13176
- myIDValLbl->setText( "" );
myScalarValLbl->setText("");
myVectorValLbl->setText("");
break;
case 1:
- myCellIDValLbl->setText( "" );
myCellScalarValLbl->setText("");
myCellVectorValLbl->setText("");
myListPoints->setNumRows(0);
}
}
-typedef vtkIdType (vtkDataSet::* TDataSetMethod)();
+typedef vtkIdType (VISU_PipeLine::* TGetVTKIdMethod)(vtkIdType theID);
bool onIdEdit (const QString& theText,
- TDataSetMethod theMethod,
+ TGetVTKIdMethod theMethod,
bool theIsCell,
const SalomeApp_Module* theModule,
LightApp_SelectionMgr* theSelectionMgr,
}
if (aPrs3d) {
- int anId = theText.toInt();
- vtkDataSet* aDataSet = aPrs3d->GetPL()->GetMapper()->GetInput();
- int aMaxId = (aDataSet->*theMethod)();
- if (anId < 0) anId = 0;
- if (anId >= aMaxId) anId = aMaxId - 1;
+ int anObjId = theText.toInt();
+ VISU_PipeLine* aPipeLine = aPrs3d->GetPipeLine();
+ int aVTKId = (aPipeLine->*theMethod)(anObjId);
+ if(aVTKId < 0)
+ return false;
TColStd_MapOfInteger newIndices;
- newIndices.Add(anId);
+ newIndices.Add(anObjId);
aSelector->AddOrRemoveIndex(anIO, newIndices, false);
aViewWindow->highlight(anIO, true, true);
void VisuGUI_SelectionDlg::onPointIdEdit (const QString& theText)
{
if (myFl) return;
- TDataSetMethod aMethod = &vtkDataSet::GetNumberOfPoints;
- bool anIsSelected = onIdEdit(theText,aMethod,false,myModule,mySelectionMgr,
- myMeshName,tr("WRN_NO_AVAILABLE_DATA"),
+ TGetVTKIdMethod aMethod = &VISU_PipeLine::GetNodeVTKID;
+ bool anIsSelected = onIdEdit(theText,
+ aMethod,
+ false,
+ myModule,
+ mySelectionMgr,
+ myMeshName,
+ tr("WRN_NO_AVAILABLE_DATA"),
myFieldName);
if (anIsSelected)
// as selection manager doesn't send signal currentSelectionChanged()
void VisuGUI_SelectionDlg::onCellIdEdit (const QString& theText)
{
if (myFl) return;
- TDataSetMethod aMethod = &vtkDataSet::GetNumberOfCells;
- bool anIsSelected = onIdEdit(theText,aMethod,true,myModule,mySelectionMgr,
- myMeshName,tr("WRN_NO_AVAILABLE_DATA"),
+ TGetVTKIdMethod aMethod = &VISU_PipeLine::GetElemVTKID;
+ bool anIsSelected = onIdEdit(theText,
+ aMethod,
+ true,
+ myModule,
+ mySelectionMgr,
+ myMeshName,
+ tr("WRN_NO_AVAILABLE_DATA"),
myFieldName);
if (anIsSelected)
// as selection manager doesn't send signal currentSelectionChanged()
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// 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 : VisuGUI_Slider.cxx
+// Author : Oleg UVAROV
+// Module : VISU
+
+#include "VisuGUI_Slider.h"
+
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+
+#include "SalomeApp_Application.h"
+#include "SalomeApp_Study.h"
+
+#include "LightApp_SelectionMgr.h"
+
+#include "SALOME_ListIteratorOfListIO.hxx"
+
+#include "VISU_PipeLine.hxx"
+
+#include "VISU_Actor.h"
+
+#include "VVTK_MainWindow.h"
+#include "VVTK_ViewWindow.h"
+
+#include "VISU_Gen_i.hh"
+#include "VisuGUI_Module.h"
+#include "VisuGUI_Tools.h"
+#include "VisuGUI_Prs3dTools.h"
+
+#include "VTKViewer_Algorithm.h"
+#include "SVTK_Functor.h"
+
+#include <vtkActorCollection.h>
+#include <vtkRenderer.h>
+
+#include <qcombobox.h>
+#include <qfont.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qtoolbutton.h>
+#include <qtooltip.h>
+#include <qslider.h>
+#include <qspinbox.h>
+#include <qtimer.h>
+
+/*!
+ Constructor
+*/
+VisuGUI_Slider::VisuGUI_Slider( VisuGUI_Module* theModule,
+ VVTK_ViewWindow* theViewWindow,
+ LightApp_SelectionMgr* theSelectionMgr )
+ : QtxDockWindow( InDock, theViewWindow->getMainWindow1() ),
+ myModule( theModule ),
+ myMainWindow( theViewWindow->getMainWindow1() ),
+ mySelectionMgr( theSelectionMgr )
+{
+ setCaption(tr("TOOLBAR_TITLE"));
+
+ VISU::ViewManager_var aViewManager = VISU::GetVisuGen( myModule )->GetViewManager();
+ VISU::View_var aView = aViewManager->GetCurrentView();
+ if(!CORBA::is_nil(aView.in()))
+ myView3D = VISU::View3D::_narrow(aView);
+
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+ setHorizontallyStretchable( true );
+
+ QWidget* aWidget = new QWidget( this );
+ setWidget( aWidget );
+
+ QGridLayout* aLayout = new QGridLayout( aWidget, 2, 13, 11, 6 );
+
+ // Slider and time stamps
+ myFirstTimeStamp = new QLabel( aWidget );
+ myFirstTimeStamp->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
+ aLayout->addWidget( myFirstTimeStamp, 0, 0, Qt::AlignHCenter );
+
+ mySlider = new QSlider( aWidget );
+ mySlider->setMinValue( 0 );
+ mySlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ mySlider->setOrientation( QSlider::Horizontal );
+ mySlider->setTracking( false );
+ aLayout->addMultiCellWidget( mySlider, 0, 0, 1, 8 );
+
+ myLastTimeStamp = new QLabel( aWidget );
+ myLastTimeStamp->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
+ aLayout->addWidget( myLastTimeStamp, 0, 9, Qt::AlignHCenter );
+
+ myTimeStampsNumber = new QLabel( aWidget );
+ myTimeStampsNumber->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
+ aLayout->addWidget( myTimeStampsNumber, 0, 10, Qt::AlignHCenter );
+
+ QLabel* aCacheMemoryLabel = new QLabel( tr( "CACHE_MEMORY" ), aWidget );
+ aCacheMemoryLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
+ aLayout->addWidget( aCacheMemoryLabel, 0, 11 );
+
+ myCacheMemory = new QLabel( aWidget );
+ myCacheMemory->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
+ QFontMetrics fm( myCacheMemory->font() );
+ myCacheMemory->setFixedWidth( fm.width( "9.99E+99 Mb" ) );
+
+ aLayout->addWidget( myCacheMemory, 0, 12 );
+
+ // Buttons
+ myMoreButton = new QToolButton( aWidget );
+ myMoreButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ myMoreButton->setEnabled( false );
+ myMoreButton->setToggleButton( true );
+ myMoreButton->setIconSet( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_MORE" ) ) );
+ QToolTip::add( myMoreButton, tr( "MORE" ) );
+ aLayout->addWidget( myMoreButton, 1, 0 );
+
+ myAVIButton = new QToolButton( aWidget );
+ myAVIButton->setEnabled( false );
+ myAVIButton->setToggleButton( true );
+ myAVIButton->setIconSet( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_AVI" ) ) );
+ QToolTip::add( myAVIButton, tr( "AVI" ) );
+ aLayout->addWidget( myAVIButton, 1, 1 );
+
+ aLayout->addItem( new QSpacerItem( 24, 24, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 2 );
+
+ myFirstButton = new QToolButton( aWidget );
+ myFirstButton->setIconSet( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_FIRST" ) ) );
+ aLayout->addWidget( myFirstButton, 1, 3 );
+
+ myPreviousButton = new QToolButton( aWidget );
+ myPreviousButton->setIconSet( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PREVIOUS" ) ) );
+ aLayout->addWidget( myPreviousButton, 1, 4 );
+
+ myPlayButton = new QToolButton( aWidget );
+ myPlayButton->setIconSet( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PLAY" ) ) );
+ myPlayButton->setToggleButton( true );
+ aLayout->addWidget( myPlayButton, 1, 5 );
+
+ myNextButton = new QToolButton( aWidget );
+ myNextButton->setIconSet( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_NEXT" ) ) );
+ aLayout->addWidget( myNextButton, 1, 6 );
+
+ myLastButton = new QToolButton( aWidget );
+ myLastButton->setIconSet( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_LAST" ) ) );
+ aLayout->addWidget( myLastButton, 1, 7 );
+
+ aLayout->addItem( new QSpacerItem( 24, 24, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 8 );
+
+ myTimeStampStrings = new QComboBox( aWidget );
+ myTimeStampStrings->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
+ aLayout->addWidget( myTimeStampStrings, 1, 9 );
+
+ myTimeStampIndices = new QComboBox( aWidget );
+ myTimeStampIndices->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
+ aLayout->addWidget( myTimeStampIndices, 1, 10 );
+
+ // Speed
+ QLabel* aSpeedLabel = new QLabel( tr( "SPEED" ), aWidget );
+ aSpeedLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
+ aLayout->addWidget( aSpeedLabel, 1, 11 );
+
+ mySpeedBox = new QSpinBox( 1, 100, 1, aWidget );
+ mySpeedBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
+ mySpeedBox->setValue( 50 );
+ aLayout->addWidget( mySpeedBox, 1, 12 );
+
+ myTimer = new QTimer( this );
+
+ // Common
+ connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionChanged() ) );
+
+ connect( myTimeStampStrings, SIGNAL( activated( int ) ), SLOT( onTimeStampActivated( int ) ) );
+ connect( myTimeStampIndices, SIGNAL( activated( int ) ), SLOT( onTimeStampActivated( int ) ) );
+
+ connect( myMoreButton, SIGNAL( toggled( bool ) ), SLOT( onMore( bool ) ) );
+ connect( myFirstButton, SIGNAL( clicked() ), SLOT( onFirst() ) );
+ connect( myPreviousButton, SIGNAL( clicked() ), SLOT( onPrevious() ) );
+ connect( myPlayButton, SIGNAL( toggled( bool ) ), SLOT( onPlay( bool ) ) );
+ connect( myNextButton, SIGNAL( clicked() ), SLOT( onNext() ) );
+ connect( myLastButton, SIGNAL( clicked() ), SLOT( onLast() ) );
+
+ connect( mySlider, SIGNAL( valueChanged( int ) ), SLOT( onValueChanged( int ) ) );
+
+ connect( mySpeedBox, SIGNAL( valueChanged( int ) ), SLOT( onSpeedChanged( int ) ) );
+
+ connect( myTimer, SIGNAL( timeout() ), SLOT( onTimeout() ) );
+
+ enableControls( false );
+
+ myMainWindow->addDockWindow( this, Qt::DockBottom );
+}
+
+/*!
+ Destructor
+*/
+VisuGUI_Slider::~VisuGUI_Slider()
+{
+}
+
+bool VisuGUI_Slider::checkHolderList()
+{
+ THolderList aHolderList;
+ THolderList::const_iterator anIter = myHolderList.begin();
+ THolderList::const_iterator anIterEnd = myHolderList.end();
+ for(; anIter != anIterEnd; anIter++){
+ VISU::ColoredPrs3dHolder_var aHolder = *anIter;
+ if(!aHolder->_non_existent())
+ aHolderList.push_back(aHolder);
+ }
+ myHolderList.swap(aHolderList);
+ return myHolderList.empty();
+}
+
+void VisuGUI_Slider::enableControls( bool on )
+{
+ widget()->setEnabled( on );
+ if( on )
+ {
+ if( checkHolderList() )
+ return;
+
+ myTimeStampStrings->clear();
+ myTimeStampIndices->clear();
+
+ VISU::ColoredPrs3dHolder_var aHolder = myHolderList.front();
+
+ VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = aHolder->GetTimeStampsRange();
+ CORBA::Long aLength = aTimeStampsRange->length();
+
+ VISU::ColoredPrs3dHolder::BasicInput_var anInput = aHolder->GetBasicInput();
+ CORBA::Long aTimeStampNumber = anInput->myTimeStampNumber;
+
+ myFirstTimeStamp->setText( aTimeStampsRange[0].myTime.in() );
+ myLastTimeStamp->setText( aTimeStampsRange[aLength-1].myTime.in() );
+ myTimeStampsNumber->setText( QString("(") + QString::number( aLength ) + ")" );
+
+ CORBA::Long a_current_index = 0;
+ for( CORBA::Long an_index = 0; an_index < aLength; an_index++ )
+ {
+ VISU::ColoredPrs3d::TimeStampInfo anInfo = aTimeStampsRange[ an_index ];
+ CORBA::Long aNumber = anInfo.myNumber;
+ QString aTime = anInfo.myTime.in();
+
+ myTimeStampStrings->insertItem( aTime );
+ myTimeStampIndices->insertItem( QString::number( aNumber ) );
+
+ if( aNumber == aTimeStampNumber )
+ a_current_index = an_index;
+ }
+ // work around - to update controls' sizes
+ myTimeStampStrings->setFont(myTimeStampStrings->font());
+ myTimeStampStrings->updateGeometry();
+
+ myTimeStampIndices->setFont(myTimeStampStrings->font());
+ myTimeStampIndices->updateGeometry();
+
+ if( a_current_index > mySlider->maxValue() )
+ mySlider->setMaxValue( aLength-1 );
+
+ myTimeStampStrings->setCurrentItem( a_current_index );
+ myTimeStampIndices->setCurrentItem( a_current_index );
+ mySlider->setValue( a_current_index );
+
+ if( a_current_index <= mySlider->maxValue() )
+ mySlider->setMaxValue( aLength-1 );
+ }
+ else
+ {
+ myPlayButton->setOn( false );
+ }
+
+}
+
+void VisuGUI_Slider::updateMemoryState()
+{
+ if( checkHolderList() )
+ return;
+
+ VISU::ColoredPrs3dHolder_var aHolder = myHolderList.front();
+
+ VISU::ColoredPrs3dCache_var aCache = aHolder->GetCache();
+ CORBA::Float aCacheMemory = aCache->GetMemorySize();
+ myCacheMemory->setText( QString::number( double( aCacheMemory ), 'E', 2 ) + " Mb" );
+}
+
+void VisuGUI_Slider::onSelectionChanged()
+{
+ //cout << "VisuGUI_Slider::onSelectionChanged()" << endl;
+ myHolderList.clear();
+
+ _PTR(SObject) aSObject;
+
+ SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
+ (SUIT_Session::session()->activeApplication());
+
+ SALOME_ListIO aListIO;
+ mySelectionMgr->selectedObjects(aListIO);
+ SALOME_ListIteratorOfListIO anIter(aListIO);
+ for(; anIter.More(); anIter.Next() ){
+ Handle(SALOME_InteractiveObject) anIO = anIter.Value();
+ if (anIO->hasEntry()) {
+ SalomeApp_Study* theStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy());
+ _PTR(Study) aStudy = theStudy->studyDS();
+ aSObject = aStudy->FindObjectID(anIO->getEntry());
+
+ if (aSObject) {
+ CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
+ if (!CORBA::is_nil(anObject)) {
+ VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
+
+ if(!CORBA::is_nil(aHolder))
+ {
+ //cout << "ColoredPrs3dHolder" << endl;
+ myHolderList.push_back(aHolder);
+ }
+ }
+ }
+ }
+ }
+
+ enableControls( !checkHolderList() );
+ updateMemoryState();
+}
+
+void VisuGUI_Slider::onTimeStampActivated( int value )
+{
+ mySlider->setValue( value );
+ onValueChanged( value );
+}
+
+void VisuGUI_Slider::onMore( bool )
+{
+}
+
+void VisuGUI_Slider::onFirst()
+{
+ int value = mySlider->minValue();
+ mySlider->setValue( value );
+}
+
+void VisuGUI_Slider::onPrevious()
+{
+ int value = mySlider->value() - 1;
+ if( value >= mySlider->minValue() )
+ mySlider->setValue( value );
+}
+
+void VisuGUI_Slider::onPlay( bool on )
+{
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+ if( on )
+ {
+ myPlayButton->setIconSet( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PAUSE" ) ) );
+
+ int delay = int(5000.0 / double(mySpeedBox->value()));
+ myTimer->start( delay );
+ }
+ else
+ {
+ myTimer->stop();
+ myPlayButton->setIconSet( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PLAY" ) ) );
+ }
+}
+
+void VisuGUI_Slider::onNext()
+{
+ int value = mySlider->value() + 1;
+ if( value <= mySlider->maxValue() )
+ mySlider->setValue( value );
+}
+
+void VisuGUI_Slider::onLast()
+{
+ int value = mySlider->maxValue();
+ mySlider->setValue( value );
+}
+
+void VisuGUI_Slider::onValueChanged( int value )
+{
+ if( checkHolderList() ){
+ enableControls( false );
+ return;
+ }
+
+ myTimeStampStrings->setCurrentItem( value );
+ myTimeStampIndices->setCurrentItem( value );
+
+ VISU::ColoredPrs3dHolder_var aHolder = myHolderList.front();
+
+ VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = aHolder->GetTimeStampsRange();
+ CORBA::Long aLength = aTimeStampsRange->length();
+ if(value < 0 || aLength <= value)
+ return;
+
+ VISU::ColoredPrs3dHolder::BasicInput_var anInput = aHolder->GetBasicInput();
+ CORBA::Long aTimeStampNumber = anInput->myTimeStampNumber;
+ CORBA::Long aNumber = aTimeStampsRange[ value ].myNumber;
+ if(aNumber == aTimeStampNumber)
+ return;
+
+ THolderList::const_iterator anIter = myHolderList.begin();
+ THolderList::const_iterator anIterEnd = myHolderList.end();
+ for( ; anIter != anIterEnd; anIter++ )
+ {
+ VISU::ColoredPrs3dHolder_var aHolder = *anIter;
+ if( CORBA::is_nil( aHolder.in() ) )
+ continue;
+
+ VISU::ColoredPrs3d_var aPrs3d = aHolder->GetDevice();
+ VISU::ColoredPrs3dHolder::BasicInput_var anInput = aHolder->GetBasicInput();
+ anInput->myTimeStampNumber = aNumber;
+
+ aHolder->Apply( aPrs3d, anInput, myView3D );
+ }
+
+ updateMemoryState();
+}
+
+void VisuGUI_Slider::onSpeedChanged( int value )
+{
+ if(myPlayButton->isOn()){
+ int delay = int(5000.0 / double(mySpeedBox->value()));
+ myTimer->start( delay );
+ }
+}
+
+void VisuGUI_Slider::onTimeout()
+{
+ int value = mySlider->value();
+ if( value < mySlider->maxValue() )
+ onNext();
+ else
+ myPlayButton->setOn( false );
+}
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// 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 : VisuGUI_Slider.h
+// Author : Oleg UVAROV
+// Module : VISU
+
+#ifndef VisuGUI_Slider_HeaderFile
+#define VisuGUI_Slider_HeaderFile
+
+#include "QtxDockWindow.h"
+#include <vector>
+
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(VISU_Gen)
+
+namespace VISU
+{
+ class ColoredPrs3dHolder_i;
+}
+
+class QComboBox;
+class QLabel;
+class QLineEdit;
+class QToolButton;
+class QSlider;
+class QSpinBox;
+class QTimer;
+
+class VVTK_ViewWindow;
+class VVTK_MainWindow;
+class LightApp_SelectionMgr;
+
+class VisuGUI_Module;
+
+class VisuGUI_Slider : public QtxDockWindow
+{
+ Q_OBJECT
+
+public:
+ VisuGUI_Slider( VisuGUI_Module* theModule,
+ VVTK_ViewWindow* theViewWindow,
+ LightApp_SelectionMgr* theSelectionMgr );
+ virtual ~VisuGUI_Slider();
+
+public slots:
+ virtual void onSelectionChanged();
+
+ virtual void onTimeStampActivated( int );
+
+ virtual void onMore( bool );
+ virtual void onFirst();
+ virtual void onPrevious();
+ virtual void onPlay( bool );
+ virtual void onNext();
+ virtual void onLast();
+
+ virtual void onValueChanged( int );
+
+ virtual void onSpeedChanged( int );
+
+ virtual void onTimeout();
+
+protected:
+ virtual void enableControls( bool );
+ virtual void updateMemoryState();
+ virtual bool checkHolderList();
+
+private:
+ VisuGUI_Module* myModule;
+ VVTK_MainWindow* myMainWindow;
+ LightApp_SelectionMgr* mySelectionMgr;
+ VISU::View3D_var myView3D;
+
+ QSlider* mySlider;
+ QLabel* myFirstTimeStamp;
+ QLabel* myLastTimeStamp;
+ QLabel* myTimeStampsNumber;
+
+ QLabel* myCacheMemory;
+
+ QToolButton* myMoreButton;
+ QToolButton* myAVIButton;
+
+ QToolButton* myFirstButton;
+ QToolButton* myPreviousButton;
+ QToolButton* myPlayButton;
+ QToolButton* myNextButton;
+ QToolButton* myLastButton;
+
+ QComboBox* myTimeStampStrings;
+ QComboBox* myTimeStampIndices;
+
+ QSpinBox* mySpeedBox;
+
+ QTimer* myTimer;
+
+ typedef std::vector<VISU::ColoredPrs3dHolder_var> THolderList;
+ THolderList myHolderList;
+};
+
+#endif
#include "VisuGUI.h"
#include "VisuGUI_Tools.h"
+#include "VisuGUI_InputPane.h"
#include "VISU_Mesh_i.hh"
#include "VISU_Gen_i.hh"
#include "VISU_StreamLines_i.hh"
+#include "VISU_ColoredPrs3dFactory.hh"
#include "VISU_StreamLinesPL.hxx"
#include "VISU_Actor.h"
#include <SALOMEDSClient_SObject.hxx>
+#include "QtxDblSpinBox.h"
+
#include <limits.h>
#include <qlayout.h>
+#include <qcheckbox.h>
#include <qgroupbox.h>
#include <qcolordialog.h>
#include <qtabwidget.h>
+#include <qpushbutton.h>
using namespace std;
VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule)
- : QDialog(VISU::GetDesktop(theModule), "VisuGUI_StreamLinesDlg", false,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
- myVisuGUI(theModule)
+ : VisuGUI_Prs3dDlg(theModule),
+ myVisuGUI(theModule)
{
- myPrs = NULL;
setCaption(tr("DLG_TITLE"));
setSizeGripEnabled(TRUE);
aBoxLayout->setSpacing( 6 );
aBoxLayout->setMargin( 11 );
- QTabWidget* aTabBox = new QTabWidget(this);
+ myTabBox = new QTabWidget(this);
QFrame* aTopBox = new QFrame(this);
aTopBox->setMargin( 11 );
connect( SelColor, SIGNAL( clicked() ), this, SLOT( setVColor() ) );
TopLayout->addWidget( SelColor, 5, 1);
- aTabBox->addTab(aTopBox, "Stream Lines");
+ myTabBox->addTab(aTopBox, "Stream Lines");
myScalarPane = new VisuGUI_ScalarBarPane(this, false);
myScalarPane->setMargin( 5 );
- aTabBox->addTab(myScalarPane, "Scalar Bar");
+ myInputPane = new VisuGUI_InputPane(VISU::TSTREAMLINES, theModule, this);
+ myTabBox->addTab(myScalarPane, "Scalar Bar");
+ myTabBox->addTab(myInputPane, "Input");
- aBoxLayout->addWidget(aTabBox);
+ aBoxLayout->addWidget(myTabBox);
QGroupBox* aGroupButtons = new QGroupBox( this, "GroupButtons" );
aGroupButtons->setColumnLayout(0, Qt::Vertical );
enableSetColor();
}
+VisuGUI_StreamLinesDlg::~VisuGUI_StreamLinesDlg()
+{}
-void VisuGUI_StreamLinesDlg::initFromPrsObject (VISU::StreamLines_i* thePrs)
+void VisuGUI_StreamLinesDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bool theInit)
{
- myScalarPane->initFromPrsObject(thePrs);
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TSTREAMLINES>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
+
+ myScalarPane->initFromPrsObject( myPrsCopy );
- myPrs = thePrs;
static int aNbOfSteps = 30;
- VISU_StreamLinesPL* aStreamLinesPL = thePrs->GetStreamLinesPL();
+ VISU_StreamLinesPL* aStreamLinesPL = myPrsCopy->GetSpecificPL();
float aMin, aMax;
aMin = aStreamLinesPL->GetMinPropagationTime();
aMax = aStreamLinesPL->GetMaxPropagationTime();
myIntegStepLen->setValue(aStreamLinesPL->GetIntegrationStep());
myIntegStepLen->setLineStep((aMax-aMin)/aNbOfSteps);
- switch (thePrs->GetDirection()) {
+ switch (myPrsCopy->GetDirection()) {
case VISU::StreamLines::FORWARD:
myDirCombo->setCurrentItem(0);
break;
case VISU::StreamLines::BOTH:
myDirCombo->setCurrentItem(2);
}
- myUseScalar->setChecked(thePrs->IsColored());
- myPntPercent->setValue(thePrs->GetUsedPoints());
+ myUseScalar->setChecked(myPrsCopy->IsColored());
+ myPntPercent->setValue(myPrsCopy->GetUsedPoints());
mySrcCombo->setEnabled(false);
- QString aSrcEntry = thePrs->GetSourceEntry();
+ QString aSrcEntry = myPrsCopy->GetSourceEntry();
- SALOMEDS::Color anOldColor = thePrs->GetColor();
+ SALOMEDS::Color anOldColor = myPrsCopy->GetColor();
QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
setColor(aColor);
enableSetColor();
INITPRS(myPrsList, 4);
}
#undef INITPRS
+
+ if( !theInit )
+ return;
+
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentPage( 0 );
+
}
-int VisuGUI_StreamLinesDlg::storeToPrsObject (VISU::StreamLines_i* thePrs)
+int VisuGUI_StreamLinesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs)
{
- bool isAccepted = myScalarPane->storeToPrsObject(thePrs);
- if (isAccepted) {
- thePrs->ShowColored(myUseScalar->isChecked());
- if (!thePrs->IsColored()) {
+ if(!myInputPane->check() || !myScalarPane->check())
+ return 0;
+
+ int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy );
+
+ if (anIsOk) {
+ myPrsCopy->ShowColored(myUseScalar->isChecked());
+ if (!myPrsCopy->IsColored()) {
SALOMEDS::Color aColor;
aColor.R = myColor.red()/255.;
aColor.G = myColor.green()/255.;
aColor.B = myColor.blue()/255.;
- thePrs->SetColor(aColor);
+ myPrsCopy->SetColor(aColor);
}
VISU::StreamLines::Direction aDirection = VISU::StreamLines::BOTH;
aPrs = createMesh(aType, aName);
}
}
- isAccepted = thePrs->SetParams(myIntegStepLen->value(),
+ anIsOk &= myPrsCopy->SetParams(myIntegStepLen->value(),
myPropTime->value(),
myStepLen->value(),
aPrs,
// SUIT_MessageBox::warn1(VisuGUI::application()->desktop(), tr("WRN_VISU"),
// tr("ERR_CANT_BUILD_PRESENTATION"),
// tr("BUT_OK"));
- return isAccepted;
+
+ VISU::TSameAsFactory<VISU::TSTREAMLINES>().Copy(thePrs, myPrsCopy);
+
+ return anIsOk;
}
/*!
#ifndef VISUGUI_STREAMLINESDLG_H
#define VISUGUI_STREAMLINESDLG_H
-#include "VisuGUI_ScalarBarDlg.h"
+#include "VisuGUI_Prs3dDlg.h"
-#include <qdialog.h>
+#include <qlabel.h>
#include <qcombobox.h>
#include <qcheckbox.h>
#include <qstringlist.h>
+#include <qtabwidget.h>
+
+#include "VISUConfig.hh"
class SalomeApp_Module;
+class VisuGUI_InputPane;
class QtxDblSpinBox;
-namespace VISU{
+namespace VISU
+{
class StreamLines_i;
}
-class VisuGUI_StreamLinesDlg: public QDialog
+class VisuGUI_StreamLinesDlg: public VisuGUI_Prs3dDlg
{
Q_OBJECT
public:
VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule);
- ~VisuGUI_StreamLinesDlg() {};
+ ~VisuGUI_StreamLinesDlg();
+
+ virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true);
+ virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs);
- void initFromPrsObject(VISU::StreamLines_i* thePrs);
- int storeToPrsObject(VISU::StreamLines_i* thePrs);
void setColor( QColor color );
void enableMagnColor( bool enable );
QtxDblSpinBox* myPntPercent;
QComboBox* mySrcCombo;
+ QTabWidget* myTabBox;
VisuGUI_ScalarBarPane* myScalarPane;
+ VisuGUI_InputPane* myInputPane;
QValueList<VISU::Prs3d_var> myPrsList;
QValueList<VISU::Prs3d_var> myEntityList;
QStringList myPrsLst;
_PTR(SObject) mySelectionObj;
- VISU::StreamLines_i* myPrs;
+ SALOME::GenericObjPtr<VISU::StreamLines_i> myPrsCopy;
SalomeApp_Module* myVisuGUI;
private slots:
#include "VisuGUI.h"
#include "VisuGUI_Tools.h"
#include "VisuGUI_ViewTools.h"
+#include "VisuGUI_ScalarBarDlg.h"
#include "VisuGUI_DeformedShapeDlg.h"
#include "VisuGUI_CutPlanesDlg.h"
#include "VisuGUI_CutLinesDlg.h"
#include <qhgroupbox.h>
#include <qlcdnumber.h>
#include <qvgroupbox.h>
+#include <qtoolbutton.h>
#define MAXVAL 1e10
myFieldLst->setSelected(0, true);
}
-ArrangeDlg::ArrangeDlg(QWidget* theParent, SVTK_ViewWindow* theViewWindow)
+ArrangeDlg::ArrangeDlg(QWidget* theParent,
+ const SalomeApp_Module* theModule,
+ SVTK_ViewWindow* theViewWindow)
: QDialog(theParent, "ArrangeDlg", true, WStyle_Customize |
WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
- myAnimator(NULL), myViewWindow(theViewWindow)
+ myAnimator(NULL),
+ myViewWindow(theViewWindow)
{
myCurrent = 0;
init();
QStringList aPrsNames;
- vtkActor* anActor;
- vtkActorCollection *anActColl = myViewWindow->getRenderer()->GetActors();
- for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;) {
- VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor);
- if (anVISUActor)
- if (anVISUActor->GetVisibility() != 0) {
- VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();
- if (aPrs) {
- if (!myPrsMap.contains(aPrs)) {
- SALOMEDS::SObject_var aSObject = aPrs->GetSObject();
- if(!aSObject->_is_nil()){
- SALOMEDS::GenericAttribute_var anAttr;
+ vtkActorCollection *aCollection = myViewWindow->getRenderer()->GetActors();
+ aCollection->InitTraversal();
+ while(vtkActor* anActor = aCollection->GetNextActor()){
+ if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
+ if(anVISUActor->GetVisibility() != 0){
+ if (VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d()){
+ if(!myPrsMap.contains(aPrs)){
+ Handle(SALOME_InteractiveObject) anIO = aPrs->GetIO();
+ if(!anIO->hasEntry())
+ continue;
+ SalomeApp_Study* aStudy = VISU::GetAppStudy(theModule);
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, anIO->getEntry());
+ if(_PTR(SObject) aSObject = anObjectInfo.mySObject){
+ _PTR(GenericAttribute) anAttr;
if (aSObject->FindAttribute(anAttr, "AttributeName")) {
- SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
- string aNam = aName->Value();
- QString strIn(aNam.c_str());
+ _PTR(AttributeName) aName(anAttr);
+ QString strIn(aName->Value().c_str());
aPrsNames.append(strIn);
myPrsMap[aPrs] = myOffsets.count();
Offset aOffs;
for (it = myPrsMap.begin(); it != myPrsMap.end(); ++it) {
VISU::Prs3d_i* aPrs = it.key();
Offset& aOffs = myOffsets[it.data()];
- if (VISU_Actor* anActor = VISU::GetActor(aPrs, myViewWindow))
+ if (VISU_Actor* anActor = VISU::FindActor(myViewWindow, aPrs))
anActor->SetPosition(aOffs.myOffset);
if (mySaveChk)
if (mySaveChk->isChecked())
QMap<VISU::Prs3d_i*, int>::Iterator it;
for (it = myPrsMap.begin(), i = 0; it != myPrsMap.end(); ++it, i++) {
VISU::Prs3d_i* aPrs = it.key();
- if (VISU_Actor* aActor = VISU::GetActor(aPrs, myViewWindow)) {
+ if (VISU_Actor* aActor = VISU::FindActor(myViewWindow, aPrs)) {
int aAxis = getAxis();
vtkFloatingPointType aZeroOffset[3];
}
switch (aPrsType) {
- case VISU::TPRSMERGER: //Scalar Map
+ case VISU::TSCALARMAP: //Scalar Map
myTypeCombo->setCurrentItem(myTypeId2ComboId[TSCALARMAP_ITEM]);
break;
case VISU::TISOSURFACE: //Iso Surfaces
switch (aType) {
case TSCALARMAP_ITEM: //Scalar Map
- aData.myPrsType = VISU::TPRSMERGER;
+ aData.myPrsType = VISU::TSCALARMAP;
break;
case TISOSURFACE_ITEM: //Iso Surfaces
aData.myPrsType = VISU::TISOSURFACE;
switch (aType) {
case TSCALARMAP_ITEM: //Scalar Map
c.suspend();
- EditPrs<VISU::PrsMerger_i,VisuGUI_ScalarBarDlg>(myModule,aData,myAnimator);
+ EditPrs<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg>(myModule,aData,myAnimator);
break;
case TISOSURFACE_ITEM: //Iso Surfaces
c.suspend();
typedef VisuGUI_ScalarMapOnDeformedShapeDlg DLG;
typedef VISU::ScalarMapOnDeformedShape_i TYPE;
DLG* aDlg = new DLG (myModule);
- aDlg->initFromPrsObject(dynamic_cast<TYPE*>(aData.myPrs[0]),true);
+ aDlg->initFromPrsObject(dynamic_cast<TYPE*>(aData.myPrs[0]));
if (aDlg->exec())
{
int anbFrames=aDlg->getCurrentScalarNbIterations();
aIter = i+1;
if(i+1 > anbFrames)
aIter=anbFrames;
- aDlg->storeToPrsObject(aCurrPrs_i,false,aIter);
+ aDlg->storeToPrsObject(aCurrPrs_i);
}
}
delete aDlg;
#include <map>
class VisuGUI;
+class SalomeApp_Module;
class VISU_TimeAnimation;
-namespace VISU {
+namespace VISU
+{
class Prs3d_i;
}
enum { AutoMode, ManualMode };
enum { XAxis, YAxis, ZAxis };
- ArrangeDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator);
- ArrangeDlg(QWidget* theParent, SVTK_ViewWindow* theViewWindow);
+ ArrangeDlg(QWidget* theParent,
+ VISU_TimeAnimation* theAnimator);
+
+ ArrangeDlg(QWidget* theParent,
+ const SalomeApp_Module* theModule,
+ SVTK_ViewWindow* theViewWindow);
+
~ArrangeDlg() {};
int getMode() const { return myStackWgt->id(myStackWgt->visibleWidget()); }
#include "VisuGUI_Tools.h"
+#include "VisuGUI_ViewTools.h"
+#include "VisuGUI_Prs3dTools.h"
+#include "VisuGUI_DialogRunner.h"
#include "VisuGUI.h"
-#include "VisuGUI_ViewTools.h"
#include "VISU_Gen_i.hh"
#include "VISU_Prs3d_i.hh"
//=============================================================================
namespace VISU
{
+ //------------------------------------------------------------
SUIT_Desktop*
GetDesktop(const CAM_Module* theModule)
{
return theModule->application()->desktop();
}
+ //------------------------------------------------------------
LightApp_SelectionMgr*
GetSelectionMgr(const SalomeApp_Module* theModule)
{
return theModule->getApp()->selectionMgr();
}
+ //------------------------------------------------------------
SalomeApp_Study*
GetAppStudy(const CAM_Module* theModule)
{
dynamic_cast<SalomeApp_Study*>(theModule->application()->activeStudy());
}
+ //------------------------------------------------------------
_PTR(Study)
GetCStudy(const SalomeApp_Study* theStudy)
{
return theStudy->studyDS();
}
+ //------------------------------------------------------------
bool
IsStudyLocked( _PTR(Study) theStudy )
{
return true;
}
+ //------------------------------------------------------------
bool
CheckLock( _PTR(Study) theStudy,
QWidget* theWidget )
return false;
}
+ //------------------------------------------------------------
+ int
+ runAndWait( QDialog* dlg, const bool modal )
+ {
+ VisuGUI_DialogRunner r( dlg );
+ return r.run( modal );
+ }
+
+ //------------------------------------------------------------
LightApp_DataObject*
FindDataObject(SUIT_DataObject* theDataObject,
const QString& theEntry,
return NULL;
}
+ //------------------------------------------------------------
LightApp_DataObject*
FindDataObject(CAM_Module* theModule,
_PTR(SObject) theSObject)
return FindDataObject(aRootDataObject,anEntry.c_str(),aLevel);
}
+ //------------------------------------------------------------
void
UpdateObjBrowser(SalomeApp_Module* theModule,
bool theIsUpdateDataModel,
theModule->getApp()->updateActions();
}
+ //------------------------------------------------------------
bool
IsSObjectTable( _PTR(SObject) theSObject )
{
return false;
}
+ //------------------------------------------------------------
VISU_Gen_i*
GetVisuGen(const CAM_Module* theModule)
{
Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","VISU");
VISU_Gen_var aVISU = VISU_Gen::_narrow(aComponent);
if(!CORBA::is_nil(aVISU)){
- if( aGen = VISU_Gen_i::GetVisuGenImpl() )
- aGen->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(theModule))));
+ if((aGen = VISU_Gen_i::GetVisuGenImpl()))
+ aGen->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(theModule))));
}
}
if(!aGen)
return aGen;
}
+ //------------------------------------------------------------
SALOME_MED::MED_Gen_var
GetMEDEngine()
{
}
- VISU::Storable::TRestoringMap getMapOfValue (_PTR(SObject) theSObject)
+ //------------------------------------------------------------
+ VISU::Storable::TRestoringMap
+ getMapOfValue(_PTR(SObject) theSObject)
{
VISU::Storable::TRestoringMap aMap;
if (theSObject) {
return aMap;
}
- QString getValue (_PTR(SObject) theSObject, QString theKey)
+ //------------------------------------------------------------
+ QString
+ getValue(_PTR(SObject) theSObject, QString theKey)
{
QString aStr("");
VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
return aStr;
}
- //------------------------------------------------------------
- // Selection
- CORBA::Object_var
- GetSelectedObj(const SalomeApp_Study* theStudy,
- const QString& theEntry,
- VISU::Storable::TRestoringMap* theMap)
- {
- if (!theStudy || theEntry.isEmpty())
- return CORBA::Object::_nil();
-
- _PTR(Study) aStudy = GetCStudy(theStudy);
- _PTR(SObject) aSObject = aStudy->FindObjectID(theEntry.latin1());
- if (aSObject) {
- _PTR(GenericAttribute) anAttr;
- if (theMap && aSObject->FindAttribute(anAttr,"AttributeString")) {
- _PTR(AttributeString) aComment (anAttr);
- std::string aValue = aComment->Value();
- QString aString (aValue.c_str());
- VISU::Storable::StrToMap(aString, *theMap);
- }
- return VISU::ClientSObjectToObject(aSObject);
- }
- return CORBA::Object::_nil();
- }
- CORBA::Object_var
- GetSelectedObj(const SalomeApp_Module* theModule,
- Handle(SALOME_InteractiveObject)* theIO,
- VISU::Storable::TRestoringMap* theMap)
+ //----------------------------------------------------------------------------
+ // Selection
+ TSelectionInfo
+ GetSelectedObjects(const SalomeApp_Module* theModule)
{
+ TSelectionInfo aSelectionInfo;
+ const SalomeApp_Study* aStudy = GetAppStudy(theModule);
LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
SALOME_ListIO aListIO;
aSelectionMgr->selectedObjects(aListIO);
SALOME_ListIteratorOfListIO anIter(aListIO);
- if(anIter.More()){
+ while(anIter.More())
+ {
Handle(SALOME_InteractiveObject) anIO = anIter.Value();
- if(theIO)
- *theIO = anIO;
if(anIO->hasEntry())
- return GetSelectedObj( GetAppStudy(theModule), anIO->getEntry(), theMap );
+ {
+ TObjectInfo anObjectInfo = GetObjectByEntry(aStudy, anIO->getEntry());
+ if(anObjectInfo.mySObject){
+ TSelectionItem aSelectionItem;
+ aSelectionItem.myObjectInfo = anObjectInfo;
+ aSelectionItem.myIO = anIO;
+ aSelectionInfo.push_back(aSelectionItem);
+ }
+ }
+ anIter.Next(); // MULTIPR fixed
}
- return CORBA::Object::_nil();
+ return aSelectionInfo;
}
+ //----------------------------------------------------------------------------
+ TObjectInfo
+ GetObjectByEntry(const SalomeApp_Study* theStudy,
+ const std::string& theEntry)
+ {
+ TObjectInfo anObjectInfo;
+ if(!theStudy || theEntry == "")
+ return anObjectInfo;
+
+ _PTR(Study) aStudy = GetCStudy(theStudy);
+ if(_PTR(SObject) aSObject = aStudy->FindObjectID(theEntry)){
+ anObjectInfo.mySObject = aSObject;
+ CORBA::Object_var anObject = ClientSObjectToObject(aSObject);
+ if(VISU::Base_i* aBase = GetServantInterface<VISU::Base_i>(anObject))
+ anObjectInfo.myBase = aBase;
+ }
+
+ return anObjectInfo;
+ }
+
+
+ //----------------------------------------------------------------------------
VISU::Prs3d_i*
- GetPrsToModify(const SalomeApp_Module* theModule,
- Handle(SALOME_InteractiveObject)* theIO,
- VISU::Storable::TRestoringMap* theMap)
+ GetPrs3dToModify(const SalomeApp_Module* theModule,
+ Base_i* theBase)
{
- if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule)))
+ if (CheckLock(GetCStudy(GetAppStudy(theModule)), GetDesktop(theModule)))
return NULL;
- CORBA::Object_var anObject = GetSelectedObj(theModule, theIO);
- if (CORBA::is_nil(anObject))
- return NULL;
+ return GetPrs3dFromBase(theBase);
+ }
- PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
- if (!aServant.in())
- return NULL;
+ //----------------------------------------------------------------------------
+ VISU::Prs3d_i*
+ GetPrs3dFromBase(Base_i* theBase)
+ {
+ if(theBase && theBase->GetType() == VISU::TCOLOREDPRS3DHOLDER){
+ CORBA::Object_var anObject = theBase->_this();
+ VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
+ VISU::Prs3d_var aPrs3d = aHolder->GetDevice();
+ return VISU::GetServantInterface<VISU::Prs3d_i>(aPrs3d);
+ }
+ return dynamic_cast<VISU::Prs3d_i*>(theBase);
+ }
- return dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+ //----------------------------------------------------------------------------
+ Storable::TRestoringMap
+ GetStorableMap(_PTR(SObject) theSObject)
+ {
+ Storable::TRestoringMap aMap;
+ if(theSObject){
+ _PTR(GenericAttribute) anAttr;
+ if(theSObject->FindAttribute(anAttr,"AttributeString")){
+ _PTR(AttributeString) aComment (anAttr);
+ std::string aValue = aComment->Value();
+ VISU::Storable::StrToMap(aValue.c_str(), aMap);
+ }
+ }
+ return aMap;
+ }
+
+ //----------------------------------------------------------------------------
+ bool
+ GetPrs3dSelectionInfo(const SalomeApp_Module* theModule,
+ VISU::Prs3d_i*& thePrs3d,
+ SVTK_ViewWindow*& theViewWindow,
+ VISU_Actor*& thenActor)
+ {
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule);
+ if(aSelectionInfo.empty())
+ return false;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ thePrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
+ if(!thePrs3d)
+ return false;
+
+ theViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
+ if(!theViewWindow)
+ return false;
+
+ thenActor = FindActor(theViewWindow, thePrs3d);
+ if(!thenActor)
+ return false;
+
+ return true;
}
+ //----------------------------------------------------------------------------
void
Add(LightApp_SelectionMgr* theSelectionMgr,
const Handle(SALOME_InteractiveObject)& theIO)
theSelectionMgr->setSelectedObjects(aListIO);
}
+ //------------------------------------------------------------
void
Remove(LightApp_SelectionMgr* theSelectionMgr,
const Handle(SALOME_InteractiveObject)& theIO)
theSelectionMgr->setSelectedObjects(aNewListIO);
}
+ //------------------------------------------------------------
+ //! Restores selection after presentation creating and editing
+ void
+ RestoreSelection(VisuGUI* theModule, VISU::Prs3d_i* thePrs3d)
+ {
+ SALOME_ListIO aList;
+ theModule->selectedObjects(aList);
+
+ if( thePrs3d )
+ {
+ Handle(SALOME_InteractiveObject) anIO = thePrs3d->GetIO();
+ aList.Append(anIO);
+ }
+
+ LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
+ aSelectionMgr->setSelectedObjects(aList);
+ }
+
/*!
* \brief Check, if "Delete" popup-menu can be put on current selection
*
return true;
}
+ //------------------------------------------------------------
void
DeleteSObject(VisuGUI* theModule,
_PTR(Study) theStudy,
{
_PTR(ChildIterator) aChildIter = theStudy->NewChildIterator(theSObject);
for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
- _PTR(SObject) aChildSObject = aChildIter->Value();
- CORBA::Object_var aChildObj = VISU::ClientSObjectToObject(aChildSObject);
- ErasePrs(theModule, aChildObj, /*repaint_view_window = */false);
+ _PTR(SObject) aSObject = aChildIter->Value();
+ TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(theModule), aSObject->GetID());
+ ErasePrs(theModule, anObjectInfo.myBase, /*repaint_view_window = */false);
}
- CORBA::Object_var anObj = VISU::ClientSObjectToObject(theSObject);
- if (!CORBA::is_nil(anObj)) {
- ErasePrs(theModule, anObj, /*repaint_view_window = */true);
+ TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(theModule), theSObject->GetID());
+ if(anObjectInfo.myBase){
+ ErasePrs(theModule, anObjectInfo.myBase, /*repaint_view_window = */true);
- VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObj);
+ CORBA::Object_var anObject = ClientSObjectToObject(theSObject);
+ VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObject);
if (!CORBA::is_nil(aRemovableObject)) {
aRemovableObject->RemoveFromStudy();
}
} else {
// Remove aSObject together with all its sub-objects
-
VISU::RemoveFromStudy(theSObject,
false, // remove not only IOR attribute, but Object With Children
false); // not Destroy() sub-objects
}
}
+ //------------------------------------------------------------
void
DeletePrs3d(VisuGUI* theModule,
- VISU::Prs3d_i* thePrs,
- const Handle(SALOME_InteractiveObject)& theIO)
+ VISU::Prs3d_i* thePrs)
{
if (!thePrs)
return;
+
if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule)))
return;
- SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
- RemoveScalarBarPosition(theModule, vw, thePrs);
-
+ if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule))
+ RemoveScalarBarPosition(theModule, aViewWindow, thePrs);
+
+ if(VISU::ColoredPrs3d_i* aColoredPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>(thePrs)){
+ std::string anEntry = aColoredPrs3d->GetHolderEntry();
+ if(anEntry != ""){
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(theModule), anEntry);
+ if(VISU::Base_i* aBase = anObjectInfo.myBase){
+ if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER){
+ CORBA::Object_var anObject = aBase->_this();
+ VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObject);
+ aRemovableObject->RemoveFromStudy();
+ return;
+ }
+ }
+ }
+ }
+
thePrs->RemoveFromStudy();
+
}
+ //------------------------------------------------------------
// Presentation management
-
void
ChangeRepresentation (const SalomeApp_Module* theModule,
VISU::PresentationType theType)
{
- SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
- if (!vw)
+ TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
+ if(aSelectionInfo.empty())
return;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(theModule, &anIO);
- if (CORBA::is_nil(anObject)) return;
-
- VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
- if (CORBA::is_nil(aVisuObj)) return;
-
- PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
- if (!aServant.in()) return;
-
- VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
- if (aPrs3d) {
- if (VISU_Actor* anActor = GetActor(aPrs3d, vw)) {
- switch (theType) {
- case VISU::SHRINK:
- if (anActor->IsShrunk())
- anActor->UnShrink();
- else
- anActor->SetShrink();
- break;
- default:
- if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
- aMesh->SetPresentationType(theType);
- RecreateActor(theModule, aMesh);
- } else {
- anActor->SetRepresentation(theType);
- }
- }
- vw->Repaint();
+ TSelectionItem aSelectionItem = aSelectionInfo.front();
+ VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
+ if(!aPrs3d)
+ return;
+
+ SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
+ if(!aViewWindow)
+ return;
+
+ VISU_Actor* anActor = FindActor(aViewWindow, aPrs3d);
+ if(!anActor)
+ return;
+
+ switch (theType) {
+ case VISU::SHRINK:
+ if (anActor->IsShrunk())
+ anActor->UnShrink();
+ else
+ anActor->SetShrink();
+ break;
+ default:
+ if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
+ aMesh->SetPresentationType(theType);
+ RecreateActor(theModule, aMesh);
+ } else {
+ anActor->SetRepresentation(theType);
}
}
+ aViewWindow->Repaint();
}
+ //------------------------------------------------------------
void
SetShading ( const SalomeApp_Module* theModule,
bool theOn )
{
- SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
- if (!vw)
+ TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
+ if(aSelectionInfo.empty())
return;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(theModule, &anIO);
- if (CORBA::is_nil(anObject)) return;
+ TSelectionItem aSelectionItem = GetSelectedObjects(theModule).front();
+ VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
+ if(!aPrs3d)
+ return;
- VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
- if (CORBA::is_nil(aVisuObj)) return;
+ SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
+ if(!aViewWindow)
+ return;
- PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
- if (!aServant.in()) return;
+ VISU_Actor* anActor = FindActor(aViewWindow, aPrs3d);
+ if(!anActor)
+ return;
- VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
- if (aPrs3d) {
- if (VISU_Actor* anActor = GetActor(aPrs3d, vw)) {
- if ( VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor) )
- aScalarMapActor->SetShading( theOn );
- }
- vw->Repaint();
+ if(VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor)){
+ aScalarMapActor->SetShading(theOn);
+ aViewWindow->Repaint();
}
}
+ //------------------------------------------------------------
// SObject type
-
bool
CheckTimeStamp(const SalomeApp_Module* theModule,
_PTR(SObject)& theSObject,
- Handle(SALOME_InteractiveObject)* theIO)
+ Handle(SALOME_InteractiveObject)& theIO,
+ ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode)
{
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(theModule, &anIO);
- if (theIO)
- *theIO = anIO;
- if (!anIO.IsNull() && anIO->hasEntry()){
- _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
- theSObject = aStudy->FindObjectID(anIO->getEntry());
+ TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
+ if(!aSelectionInfo.empty()){
+ TSelectionItem aSelectionItem = aSelectionInfo.front();
+ theIO = aSelectionItem.myIO;
+ theSObject = aSelectionItem.myObjectInfo.mySObject;
QString aValue = getValue(theSObject,"myType");
- if (aValue.toInt() == int(VISU::TTIMESTAMP))
+ if (aValue.toInt() == int(VISU::TTIMESTAMP)){
+ thePublishInStudyMode = ColoredPrs3d_i::EPublishUnderTimeStamp;
return true;
+ }
+ if (aValue.toInt() == int(VISU::TFIELD)){
+ thePublishInStudyMode = ColoredPrs3d_i::EPublishIndependently;
+ if(theSObject->FindSubObject(2,theSObject))
+ return true;
+ }
}
SUIT_MessageBox::warn1(GetDesktop(theModule),
QObject::tr("WRN_VISU"),
return false;
}
+ //------------------------------------------------------------
VISU::Result_i*
CheckResult(const SalomeApp_Module* theModule,
_PTR(SObject) theSource,
return dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
}
+ //------------------------------------------------------------
// VTK View
-
VISU_Actor*
PublishMeshInView(const SalomeApp_Module* theModule,
VISU::Prs3d_i* thePrs,
return aActor;
}
+ //------------------------------------------------------------
void
RepaintViewWindows (const SalomeApp_Module* theModule,
const Handle(SALOME_InteractiveObject)& theIObject)
}
}
+ //------------------------------------------------------------
VISU_Actor*
- FindActor(SVTK_ViewWindow* theViewWindow,
- const char* theEntry)
+ FindActor(const SalomeApp_Study* theStudy,
+ SVTK_ViewWindow* theViewWindow,
+ const QString& theEntry)
{
- using namespace SVTK;
- if(vtkRenderer* aRenderer = theViewWindow->getRenderer()){
- if(vtkActorCollection* aCollection = aRenderer->GetActors()){
- if(VISU_Actor* anActor = Find<VISU_Actor>(aCollection,TIsSameEntry<VISU_Actor>(theEntry))){
- return anActor;
- }
- }
- }
- return NULL;
- }
-
- VISU_Actor*
- FindActor(SVTK_ViewWindow* theViewWindow,
- VISU::Prs3d_i* thePrs)
- {
- SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
- CORBA::String_var anEntry = aSObject->GetID();
- return FindActor(theViewWindow,anEntry.in());
+ TObjectInfo anObjectInfo = GetObjectByEntry(theStudy, theEntry);
+ VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(anObjectInfo.myBase);
+ return FindActor(theViewWindow, aPrs3d);
}
+ //------------------------------------------------------------
void
RecreateActor (const SalomeApp_Module* theModule,
VISU::Prs3d_i* thePrs)
QApplication::restoreOverrideCursor();
}
+ //------------------------------------------------------------
static
bool
ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow,
return somethingVisible;
}
+ //------------------------------------------------------------
void SetFitAll(SVTK_ViewWindow* theViewWindow)
{
static vtkFloatingPointType PRECISION = 0.000001;
return NULL;
}
+ //------------------------------------------------------------
// Internal function used by several public functions below
void
UpdateCurve(VISU::Curve_i* theCurve,
}
}
+ //------------------------------------------------------------
void
PlotTable(const SalomeApp_Module* theModule,
VISU::Table_i* table,
QList<Plot2d_Curve> clist;
aPlot->getCurves( clist );
_PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
- _PTR(SObject) TableSO = aStudy->FindObjectID( table->GetEntry().latin1() );
+ _PTR(SObject) TableSO = aStudy->FindObjectID( table->GetEntry() );
if ( TableSO ) {
_PTR(ChildIterator) Iter = aStudy->NewChildIterator( TableSO );
for ( ; Iter->More(); Iter->Next() ) {
for ( int i = 0; i < clist.count(); i++ ) {
tmpCurve = dynamic_cast<SPlot2d_Curve*>( clist.at( i ) );
if (tmpCurve && tmpCurve->hasIO() &&
- !strcmp(tmpCurve->getIO()->getEntry(), theCurve->GetEntry())) {
+ theCurve->GetEntry() != tmpCurve->getIO()->getEntry()) {
plotCurve = tmpCurve;
break;
}
}
}
+ //------------------------------------------------------------
void
PlotCurve(const SalomeApp_Module* theModule,
VISU::Curve_i* theCurve,
for (int i = 0; i < clist.count(); i++) {
tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
if (tmpCurve && tmpCurve->hasIO() &&
- !strcmp(tmpCurve->getIO()->getEntry(), theCurve->GetEntry())) {
+ theCurve->GetEntry() != tmpCurve->getIO()->getEntry()) {
plotCurve = tmpCurve;
} else if (theDisplaying == VISU::eDisplayOnly) {
aPlot->eraseCurve(clist.at(i));
aPlot->Repaint();
}
+ //------------------------------------------------------------
void
PlotRemoveCurve(const SalomeApp_Module* theModule,
VISU::Curve_i* pCrv)
}
}
+ //------------------------------------------------------------
void
PlotContainer(const SalomeApp_Module* theModule,
VISU::Container_i* container,
VISU::Curve_i* theCurve = container->GetCurve( k );
if ( theCurve && theCurve->IsValid() ) {
SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>
- (aView->getCurveByIO(new SALOME_InteractiveObject (theCurve->GetEntry(), "", "")));
+ (aView->getCurveByIO(new SALOME_InteractiveObject(theCurve->GetEntry().c_str(), "", "")));
UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
aPlot->fitAll();
}
+ //------------------------------------------------------------
void
CreatePlot(SalomeApp_Module* theModule,
_PTR(SObject) theTableSO)
void CreateMesh (const SalomeApp_Module* theModule,
const Handle(SALOME_InteractiveObject)& theIO,
SVTK_ViewWindow* theViewWindow)
- {
- _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
+ {
+ _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
//if (CheckLock(aStudy))
// return;
if (!CORBA::is_nil(aVisuObj)) {
VISU::VISUType aType = aVisuObj->GetType();
switch (aType) {
- case VISU::TPRSMERGER:
+ case VISU::TSCALARMAP:
case VISU::TISOSURFACE:
case VISU::TDEFORMEDSHAPE:
case VISU::TCUTPLANES:
return aList;
}
+ //------------------------------------------------------------
int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow)
{
int minIndx = 1;
return minIndx;
}
+ //------------------------------------------------------------
void AddScalarBarPosition (VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
VISU::Prs3d_i* thePrs3d, int pos)
{
- TViewToPrs3d& aMap = theModule->myScalarBarsMap;
+ TViewToPrs3d& aMap = theModule->getScalarBarsMap();
TPrs3dToInd aPair; aPair.first = thePrs3d; aPair.second = pos;
aMap[theViewWindow].insert(aPair);
}
+ //------------------------------------------------------------
void RemoveScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
VISU::Prs3d_i* thePrs3d)
{
- TViewToPrs3d& aMap = theModule->myScalarBarsMap;
+ TViewToPrs3d& aMap = theModule->getScalarBarsMap();
TSetPrs3d::iterator aIter = aMap[theViewWindow].begin();
for (; aIter != aMap[theViewWindow].end(); aIter++)
if ((*aIter).first == thePrs3d) {
return;
}
}
+ //------------------------------------------------------------
}
#include "SALOME_InteractiveObject.hxx"
#include "VISUConfig.hh"
+#include "VISU_ColoredPrs3d_i.hh"
#include "SALOMEDSClient_Study.hxx"
#include CORBA_SERVER_HEADER(MED_Gen)
class QWidget;
+class QDialog;
class SUIT_Desktop;
class SUIT_ViewWindow;
class SalomeApp_Study;
class VisuGUI;
-namespace VISU {
+#include <vector>
+#include <utility>
+
+namespace VISU
+{
+ class Base_i;
class Prs3d_i;
class Result_i;
class Table_i;
typedef std::vector<SVTK_ViewWindow*> TViewWindows;
+ //----------------------------------------------------------------------------
SUIT_Desktop* GetDesktop(const CAM_Module* theModule);
SalomeApp_Study* GetAppStudy(const CAM_Module* theModule);
_PTR(Study) GetCStudy(const SalomeApp_Study* theStudy);
bool CheckLock( _PTR(Study) theStudy,
QWidget* theWidget );
+ //----------------------------------------------------------------------------
+ int runAndWait( QDialog* dlg, const bool modal );
+
void UpdateObjBrowser(SalomeApp_Module* theModule,
bool theIsUpdateDataModel = true,
_PTR(SObject) theSObject = _PTR(SObject)());
+ //----------------------------------------------------------------------------
VISU_Gen_i* GetVisuGen(const CAM_Module* theModule);
SALOME_MED::MED_Gen_var GetMEDEngine();
// Selection
LightApp_SelectionMgr* GetSelectionMgr(const SalomeApp_Module* theModule);
- CORBA::Object_var GetSelectedObj(const SalomeApp_Study* theStudy,
- const QString& theEntry,
- VISU::Storable::TRestoringMap* theMap = NULL);
- CORBA::Object_var GetSelectedObj(const SalomeApp_Module* theModule,
- Handle(SALOME_InteractiveObject)* theIO = NULL,
- VISU::Storable::TRestoringMap* theMap = NULL);
- VISU::Prs3d_i* GetPrsToModify(const SalomeApp_Module* theModule,
- Handle(SALOME_InteractiveObject)* theIO = NULL,
- VISU::Storable::TRestoringMap* theMap = NULL);
+ //----------------------------------------------------------------------------
+ struct TObjectInfo
+ {
+ Base_i* myBase;
+ _PTR(SObject) mySObject;
+ TObjectInfo():
+ myBase(NULL)
+ {}
+ };
+
+ struct TSelectionItem
+ {
+ TObjectInfo myObjectInfo;
+ Handle(SALOME_InteractiveObject) myIO;
+ };
+
+ typedef std::vector<TSelectionItem> TSelectionInfo;
+
+ TSelectionInfo GetSelectedObjects(const SalomeApp_Module* theModule);
+
+ TObjectInfo GetObjectByEntry(const SalomeApp_Study* theStudy,
+ const std::string& theEntry);
+
+ VISU::Prs3d_i* GetPrs3dToModify(const SalomeApp_Module* theModule,
+ Base_i* theBase);
+
+ VISU::Prs3d_i* GetPrs3dFromBase(Base_i* theBase);
+
+ Storable::TRestoringMap GetStorableMap(_PTR(SObject) theSObject);
+
+ //----------------------------------------------------------------------------
void Add(LightApp_SelectionMgr* theSelectionMgr,
const Handle(SALOME_InteractiveObject)& theIO);
void Remove(LightApp_SelectionMgr* theSelectionMgr,
const Handle(SALOME_InteractiveObject)& theIO);
+ void RestoreSelection(VisuGUI* theModule, VISU::Prs3d_i* thePrs3d);
+
bool IsRemovableSelected(const SalomeApp_Module* theModule);
void DeleteSObject(VisuGUI* theModule,
_PTR(Study) theStudy,
_PTR(SObject) theSObject);
void DeletePrs3d(VisuGUI* theModule,
- VISU::Prs3d_i* thePrs,
- const Handle(SALOME_InteractiveObject)& theIO);
+ VISU::Prs3d_i* thePrs);
// Presentation management
void ChangeRepresentation (const SalomeApp_Module* theModule,
// SObject type
bool CheckTimeStamp(const SalomeApp_Module* theModule,
_PTR(SObject)& theSObject,
- Handle(SALOME_InteractiveObject)* theIO = NULL);
+ Handle(SALOME_InteractiveObject)& theIO,
+ ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode);
VISU::Result_i* CheckResult(const SalomeApp_Module* theModule,
_PTR(SObject) theSource,
VISU::Result_var& theResult);
void RepaintViewWindows(const SalomeApp_Module* theModule,
const Handle(SALOME_InteractiveObject)& theIObject);
- VISU_Actor* FindActor(SVTK_ViewWindow* theViewWindow,
- const char* theEntry);
+ VISU_Actor* FindActor(const SalomeApp_Study* theStudy,
+ SVTK_ViewWindow* theViewWindow,
+ const QString& theEntry);
VISU_Actor* FindActor(SVTK_ViewWindow* theViewWindow,
VISU::Prs3d_i* thePrs);
void RecreateActor(const SalomeApp_Module* theModule,
WFlags fl)
: QDialog( VISU::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
WStyle_Title | WStyle_SysMenu | WDestructiveClose ),
+ myModule(theModule),
mySelectionMgr( VISU::GetSelectionMgr( theModule ) ),
myViewWindow( VISU::GetActiveViewWindow<SVTK_ViewWindow>(theModule) )
{
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList);
- SALOME_ListIteratorOfListIO It (aList);
- for (;It.More(); It.Next()) {
- Handle(SALOME_InteractiveObject) IOS = It.Value();
- VISU_Actor* anActor = VISU::FindActor(myViewWindow, IOS->getEntry());
+ SALOME_ListIteratorOfListIO anIter(aList);
+ for (; anIter.More(); anIter.Next()) {
+ Handle(SALOME_InteractiveObject) anIO = anIter.Value();
+ VISU_Actor* anActor = VISU::FindActor(VISU::GetAppStudy(myModule), myViewWindow, anIO->getEntry());
if (anActor)
anActor->SetOpacity(opacity);
}
if (aList.Extent() == 1) {
Handle(SALOME_InteractiveObject) FirstIOS = aList.First();
if (!FirstIOS.IsNull()) {
- VISU_Actor* anActor = VISU::FindActor(myViewWindow, FirstIOS->getEntry());
+ VISU_Actor* anActor = VISU::FindActor(VISU::GetAppStudy(myModule), myViewWindow, FirstIOS->getEntry());
if (anActor)
opacity = int(anActor->GetOpacity() * 100. + 0.5);
}
for (; It.More(); It.Next()) {
Handle(SALOME_InteractiveObject) IO = It.Value();
if (!IO.IsNull()) {
- VISU_Actor* anActor = VISU::FindActor(myViewWindow, IO->getEntry());
+ VISU_Actor* anActor = VISU::FindActor(VISU::GetAppStudy(myModule), myViewWindow, IO->getEntry());
if (anActor) {
int op = int(anActor->GetOpacity() * 100. + 0.5);
if (setOp < 0)
class QPushButton;
class QSlider;
class LightApp_SelectionMgr;
+class SalomeApp_Module;
class SVTK_Selector;
class SVTK_ViewWindow;
class VisuGUI;
private :
LightApp_SelectionMgr* mySelectionMgr;
SVTK_ViewWindow* myViewWindow;
+ const SalomeApp_Module* myModule;
QPushButton* buttonOk;
QPushButton* buttonHelp;
#include "VisuGUI_VectorsDlg.h"
#include "VisuGUI.h"
-//#include "VisuGUI_Selection.h"
#include "VisuGUI_Tools.h"
+#include "VisuGUI_InputPane.h"
+#include "VISU_ColoredPrs3dFactory.hh"
#include "VISU_Vectors_i.hh"
#include "LightApp_Application.h"
#include "SalomeApp_Module.h"
Constructor
*/
VisuGUI_VectorsDlg::VisuGUI_VectorsDlg (SalomeApp_Module* theModule)
- : QDialog(VISU::GetDesktop(theModule), "VisuGUI_VectorsDlg", true,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+ : VisuGUI_Prs3dDlg(theModule)
{
setCaption(tr("DLG_TITLE"));
setSizeGripEnabled(TRUE);
TopLayout->setSpacing( 6 );
TopLayout->setMargin( 11 );
- QTabWidget* aTabBox = new QTabWidget(this);
+ myTabBox = new QTabWidget(this);
QVBox* aBox = new QVBox(this);
aBox->setMargin( 11 );
GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
// top layout
- aTabBox->addTab(aBox, "Vectors");
+ myTabBox->addTab(aBox, "Vectors");
myScalarPane = new VisuGUI_ScalarBarPane(this, false);
myScalarPane->setMargin( 5 );
- aTabBox->addTab(myScalarPane, "Scalar Bar");
+ myInputPane = new VisuGUI_InputPane(VISU::TVECTORS, theModule, this);
+ myTabBox->addTab(myScalarPane, "Scalar Bar");
+ myTabBox->addTab(myInputPane, "Input");
- TopLayout->addWidget( aTabBox );
+ TopLayout->addWidget( myTabBox );
TopLayout->addWidget( GroupButtons );
// signals and slots connections
enableSetColor();
}
+VisuGUI_VectorsDlg::~VisuGUI_VectorsDlg()
+{}
+void VisuGUI_VectorsDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit) {
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TVECTORS>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
-void VisuGUI_VectorsDlg::initFromPrsObject(VISU::Vectors_i* thePrs) {
- myScalarPane->initFromPrsObject(thePrs);
- setScaleFactor(thePrs->GetScale());
- setLineWidth((int)thePrs->GetLineWidth());
- setUseMagnColor(thePrs->IsColored());
- SALOMEDS::Color anOldColor = thePrs->GetColor();
+ myScalarPane->initFromPrsObject( myPrsCopy );
+
+ setScaleFactor(myPrsCopy->GetScale());
+ setLineWidth((int)myPrsCopy->GetLineWidth());
+ setUseMagnColor(myPrsCopy->IsColored());
+ SALOMEDS::Color anOldColor = myPrsCopy->GetColor();
QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
setColor(aColor);
- if (thePrs->GetGlyphType() != VISU::Vectors::NONE) {
+ if (myPrsCopy->GetGlyphType() != VISU::Vectors::NONE) {
setUseGlyphs(true);
- setGlyphType(thePrs->GetGlyphType());
- setGlyphPos(thePrs->GetGlyphPos());
+ setGlyphType(myPrsCopy->GetGlyphType());
+ setGlyphPos(myPrsCopy->GetGlyphPos());
} else
setUseGlyphs(false);
enableSetColor();
+
+ if( !theInit )
+ return;
+
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentPage( 0 );
}
-int VisuGUI_VectorsDlg::storeToPrsObject(VISU::Vectors_i* thePrs) {
- myScalarPane->storeToPrsObject(thePrs);
- thePrs->SetScale(getScaleFactor());
- thePrs->SetLineWidth(getLineWidth());
- thePrs->ShowColored(getUseMagnColor());
- if(!thePrs->IsColored()){
+int VisuGUI_VectorsDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
+{
+ if(!myInputPane->check() || !myScalarPane->check())
+ return 0;
+
+ int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= myScalarPane->storeToPrsObject( myPrsCopy );
+
+ myPrsCopy->SetScale(getScaleFactor());
+ myPrsCopy->SetLineWidth(getLineWidth());
+ myPrsCopy->ShowColored(getUseMagnColor());
+ if(!myPrsCopy->IsColored()){
SALOMEDS::Color aColor;
aColor.R = myColor.red()/255.;
aColor.G = myColor.green()/255.;
aColor.B = myColor.blue()/255.;
- thePrs->SetColor(aColor);
+ myPrsCopy->SetColor(aColor);
}
if (getUseGlyphs()) {
- thePrs->SetGlyphPos(getGlyphPos());
- thePrs->SetGlyphType(getGlyphType());
+ myPrsCopy->SetGlyphPos(getGlyphPos());
+ myPrsCopy->SetGlyphType(getGlyphType());
} else
- thePrs->SetGlyphType(VISU::Vectors::NONE);
- return 1;
+ myPrsCopy->SetGlyphType(VISU::Vectors::NONE);
+
+ VISU::TSameAsFactory<VISU::TVECTORS>().Copy(thePrs, myPrsCopy);
+
+ return anIsOk;
}
#ifndef VISUGUI_VECTORSDLG_H
#define VISUGUI_VECTORSDLG_H
-#include "VisuGUI_ScalarBarDlg.h"
+#include "VisuGUI_Prs3dDlg.h"
#include "QtxDblSpinBox.h"
#include <qdialog.h>
#include <qlabel.h>
#include <qspinbox.h>
#include <qpushbutton.h>
+#include <qtabwidget.h>
#include "SALOMEconfig.h"
#include CORBA_CLIENT_HEADER(VISU_Gen)
class SalomeApp_Module;
+class VisuGUI_InputPane;
-namespace VISU{
+namespace VISU
+{
class Vectors_i;
}
-class VisuGUI_VectorsDlg : public QDialog
+class VisuGUI_VectorsDlg : public VisuGUI_Prs3dDlg
{
Q_OBJECT
public:
VisuGUI_VectorsDlg (SalomeApp_Module* theModule);
- ~VisuGUI_VectorsDlg() {};
+ ~VisuGUI_VectorsDlg();
void setScaleFactor( double sf );
double getScaleFactor();
VISU::Vectors::GlyphPos getGlyphPos();
void enableMagnColor( bool enable );
- void initFromPrsObject(VISU::Vectors_i* thePrs);
- int storeToPrsObject(VISU::Vectors_i* thePrs);
+ virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true);
+ virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs);
private:
void keyPressEvent( QKeyEvent* e );
QPushButton* buttonHelp;
QColor myColor;
+ QTabWidget* myTabBox;
+
VisuGUI_ScalarBarPane* myScalarPane;
+ VisuGUI_InputPane* myInputPane;
+
+ SALOME::GenericObjPtr<VISU::Vectors_i> myPrsCopy;
private slots:
void enableGlyphType();
namespace VISU
{
+ //----------------------------------------------------------------------------
+ void
+ ErasePrs3d(VisuGUI* theModule,
+ VISU::Prs3d_i* thePrs,
+ bool theDoRepaint)
+ {
+ if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule)){
+ if(VISU_Actor* anActor = FindActor(aViewWindow, thePrs)){
+ anActor->VisibilityOff();
+ if(theDoRepaint)
+ aViewWindow->Repaint();
+ }
+ }
+ }
+
+ //----------------------------------------------------------------------------
void
ErasePrs(VisuGUI* theModule,
- CORBA::Object_ptr theObject,
- bool theDoRepaintVW)
+ Base_i* theBase,
+ bool theDoRepaint)
{
- if (CORBA::is_nil(theObject)) return;
- VISU::Base_var aBase = VISU::Base::_narrow(theObject);
- if (CORBA::is_nil(aBase)) return;
+ if(!theBase)
+ return;
- VISU::VISUType aType = aBase->GetType();
- switch (aType) {
+ switch (theBase->GetType()) {
case VISU::TCURVE: {
- if (VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aBase).in()))
+ if (VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(theBase))
PlotCurve(theModule, aCurve, VISU::eErase );
break;
}
case VISU::TCONTAINER: {
- if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aBase).in()))
+ if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(theBase))
PlotContainer(theModule, aContainer, VISU::eErase );
break;
}
case VISU::TTABLE: {
- if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aBase).in()))
+ if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(theBase))
PlotTable(theModule, aTable, VISU::eErase );
break;
}
default: {
- if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())) {
- SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
- RemoveScalarBarPosition(theModule, vw, aPrsObject);
- ErasePrs3d(theModule, aPrsObject, theDoRepaintVW);
+ if(VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dFromBase(theBase)){
+ if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule)){
+ RemoveScalarBarPosition(theModule, aViewWindow, aPrs3d);
+ ErasePrs3d(theModule, aPrs3d, theDoRepaint);
+ }
}
}} // switch (aType)
}
+
}
//---------------------------------------------------------------
- inline
void
ErasePrs3d(VisuGUI* theModule,
VISU::Prs3d_i* thePrs,
- const bool theDoRepaintVW = true)
- {
- if (SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule)) {
- if (VISU_Actor* anActor = FindActor(aViewWindow, thePrs)) {
- anActor->VisibilityOff();
- if (theDoRepaintVW)
- aViewWindow->Repaint();
- }
- }
- }
+ bool theDoRepaint = true);
void
ErasePrs(VisuGUI* theModule,
- CORBA::Object_ptr theObject,
+ Base_i* theBase,
bool theDoRepaintVW);
}
lib_LTLIBRARIES= libVISUEngineImpl.la
salomeinclude_HEADERS = \
+ VISU_I.hxx \
VISUConfig.hh \
VISU_Gen_i.hh \
VISU_Result_i.hh \
VISU_View_i.hh \
VISU_TimeAnimation.h \
VISU_ScalarMapOnDeformedShape_i.hh \
- VISU_PrsMerger_i.hh \
- VISU_I.hxx
+ VISU_ColoredPrs3dFactory.hh \
+ SALOME_GenericObjPointer.hh
libVISUEngineImpl_la_SOURCES = \
VISU_Result_i.cc \
VISU_CutLines_i.cc \
VISU_Vectors_i.cc \
VISU_StreamLines_i.cc \
+ VISU_ScalarMapOnDeformedShape_i.cc \
+ VISU_ColoredPrs3dCache_i.cc \
+ VISU_ColoredPrs3dHolder_i.cc \
+ VISU_ColoredPrs3dFactory.cc \
VISU_Mesh_i.cc \
- VISU_Table_i.cc \
- VISU_Gen_i.cc \
VISU_ViewManager_i.cc \
- VISU_View_i.cc \
VISU_TimeAnimation.cxx \
+ VISU_View_i.cc \
+ VISU_Table_i.cc \
+ VISU_Gen_i.cc \
VISU_CorbaMedConvertor.cxx \
VISU_DumpPython.cc \
- VISU_ScalarMapOnDeformedShape_i.cc \
- VISU_PrsMerger_i.cc
+ SALOME_GenericObjPointer.cc
MOC_FILES = VISU_TimeAnimation_moc.cxx
nodist_libVISUEngineImpl_la_SOURCES= $(MOC_FILES)
libVISUEngineImpl_la_LIBADD= -lboost_signals@BOOST_LIBSUFFIX@ -lboost_thread@BOOST_LIBSUFFIX@ \
-lSalomeHDFPersist \
- -lSalomeCommunication \
-lSalomeGenericObj \
-lSalomeContainer \
+ -lSalomeCommunication \
-lSalomeNS \
-lTOOLSDS \
-lOpUtil \
../VVTK/libVVTK.la \
../GUITOOLS/libVISUGUITOOLS.la
+if MED_ENABLE_MULTIPR
+ libVISUEngineImpl_la_CPPFLAGS+= $(MULTIPR_CPPFLAGS)
+ libVISUEngineImpl_la_LIBADD+= $(MULTIPR_LIBS)
+endif
+
# Executables targets
bin_PROGRAMS = VISU_I
dist_VISU_I_SOURCES=VISU_I.cxx
-lMEDWrapperBase \
-lMEDWrapper_V2_2 \
-lMEDWrapper_V2_1 \
- -lmed_V2_1
+ -lmed_V2_1 \
+ -lmedmem
+
+if MED_ENABLE_MULTIPR
+ VISU_I_CPPFLAGS+= $(MULTIPR_CPPFLAGS)
+ VISU_I_LDADD+= $(MULTIPR_LIBS) -lmedsplitter
+endif
--- /dev/null
+// 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 : SALOME_GenericObjPtr.cc
+// Author : Oleg UVAROV
+// Module : SALOME
+
+#include "SALOME_GenericObjPointer.hh"
--- /dev/null
+// 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 : SALOME_GenericObjPtr.hh
+// Author : Oleg UVAROV
+// Module : SALOME
+
+#ifndef SALOME_GenericObjPointer_HH
+#define SALOME_GenericObjPointer_HH
+
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SALOME_GenericObj)
+
+#include <iosfwd> // for std::basic_ostream
+
+namespace SALOME
+{
+ //----------------------------------------------------------------------------
+ template <class TGenericObj>
+ class GenericObjPtr
+ {
+ //! Pointer to the actual object.
+ TGenericObj* myPointer;
+
+ void
+ swap(GenericObjPtr& thePointer)
+ {
+ TGenericObj* aPointer = thePointer.myPointer;
+ thePointer.myPointer = this->myPointer;
+ this->myPointer = aPointer;
+ }
+
+ void
+ Register()
+ {
+ if(this->myPointer)
+ this->myPointer->Register();
+ }
+
+ void
+ Destroy()
+ {
+ if(this->myPointer){
+ this->myPointer->Destroy();
+ this->myPointer = NULL;
+ }
+ }
+
+ public:
+ //! Initialize smart pointer to NULL.
+ GenericObjPtr():
+ myPointer(NULL)
+ {}
+
+ //! Initialize smart pointer to given object (TSGenericObj must be complete).
+ template<class TSGenericObj>
+ explicit
+ GenericObjPtr(TSGenericObj* thePointer):
+ myPointer(thePointer)
+ {
+ this->Register();
+ }
+
+ /*!
+ Initialize smart pointer with a new reference to the same object
+ referenced by given smart pointer.
+ */
+ GenericObjPtr(const GenericObjPtr& thePointer):
+ myPointer(thePointer.myPointer)
+ {
+ this->Register();
+ }
+
+ //! Destroy smart pointer and remove the reference to its object.
+ ~GenericObjPtr()
+ {
+ this->Destroy();
+ }
+
+ /*!
+ Assign object to reference. This removes any reference to an old
+ object.
+ */
+ GenericObjPtr&
+ operator=(TGenericObj* thePointer)
+ {
+ GenericObjPtr(thePointer).swap(*this);
+ return *this;
+ }
+
+ /*!
+ Assign object to reference. This removes any reference to an old
+ object.
+ */
+ GenericObjPtr&
+ operator=(const GenericObjPtr& thePointer)
+ {
+ GenericObjPtr(thePointer).swap(*this);
+ return *this;
+ }
+
+ //! Get the contained pointer.
+ virtual
+ TGenericObj*
+ get() const
+ {
+ return this->myPointer;
+ }
+
+ //! Get the contained pointer.
+ operator TGenericObj* () const
+ {
+ return this->get();
+ }
+
+ /*!
+ Dereference the pointer and return a reference to the contained
+ object.
+ */
+ TGenericObj&
+ operator*() const
+ {
+ return *this->get();
+ }
+
+ //! Provides normal pointer target member access using operator ->.
+ TGenericObj* operator->() const
+ {
+ return this->get();
+ }
+
+ operator bool () const
+ {
+ return this->get() != 0;
+ }
+ };
+}
+
+template<class T, class U>
+inline
+bool
+operator==(SALOME::GenericObjPtr<T> const & a, SALOME::GenericObjPtr<U> const & b)
+{
+ return a.get() == b.get();
+}
+
+template<class T, class U>
+inline
+bool
+operator!=(SALOME::GenericObjPtr<T> const & a, SALOME::GenericObjPtr<U> const & b)
+{
+ return a.get() != b.get();
+}
+
+template<class Y>
+std::ostream&
+operator<< (std::ostream & os, SALOME::GenericObjPtr<Y> const & p)
+{
+ os << p.get();
+ return os;
+}
+
+
+#endif
//===========================================================================
static Storable::TCallbackMap VisuStoreMap;
- string Storable::ToString(){
+ std::string
+ Storable
+ ::ToString()
+ {
ostringstream strOut;
Storable::DataToStream( strOut, "myComment", GetComment() );
ToStream(strOut);
return strOut.str();
}
- void Storable::Registry(const char* theComment, TStorableEngine theEngine)
+ void
+ Storable
+ ::Registry(const std::string& theComment,
+ TStorableEngine theEngine)
{
if(!VisuStoreMap.insert(TCallbackMap::value_type(theComment,theEngine)).second){
if(MYDEBUG) MESSAGE("Storable::Registry >> dupliacte registring !!!");
}
}
- void Storable::StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap){
+ void
+ Storable
+ ::StrToMap(const QString& theStr,
+ VISU::Storable::TRestoringMap& theMap)
+ {
if(0 && MYDEBUG) MESSAGE("Storable::StrToMap : string="<<theStr);
QStringList strList = QStringList::split( ";", theStr, false );
for ( int i = 0; i < strList.count(); i++ ) {
}
}
- void Storable::DataToStream(ostringstream& theStr, const QString& theName, const QString& theVal) {
+ void
+ Storable
+ ::DataToStream(std::ostringstream& theStr,
+ const QString& theName,
+ const QString& theVal)
+ {
QString output = ( !theName.isNull() ? theName : QString("") )
+ QString( "=" )
+ ( !theVal.isNull() ? theVal : QString("") );
theStr<<output.latin1()<<";";
}
- void Storable::DataToStream(ostringstream& theStr, const QString& theName, const int theVal) {
+ void
+ Storable
+ ::DataToStream(std::ostringstream& theStr,
+ const QString& theName,
+ const int theVal)
+ {
QString output = ( !theName.isNull() ? theName : QString("") )
+ QString( "=" )
+ QString::number( theVal );
theStr<<output.latin1()<<";";
}
- void Storable::DataToStream(ostringstream& theStr, const QString& theName, const double theVal) {
+ void
+ Storable
+ ::DataToStream(std::ostringstream& theStr,
+ const QString& theName,
+ const double theVal)
+ {
QString output = ( !theName.isNull() ? theName : QString("") )
+ QString( "=" )
+ QString::number( theVal );
theStr<<output.latin1()<<";";
}
- Storable* Storable::Create(SALOMEDS::SObject_ptr theSObject,
- const string& thePrefix, const string& theLocalPersistentID)
+
+ Storable*
+ Storable
+ ::Create(SALOMEDS::SObject_ptr theSObject,
+ const std::string& thePrefix,
+ const std::string& theLocalPersistentID)
{
try{
QString strIn( theLocalPersistentID.c_str() );
return NULL;
}
- QString Storable::FindValue(const TRestoringMap& theMap, const string& theArg, bool* isFind)
+ QString
+ Storable
+ ::FindValue(const TRestoringMap& theMap,
+ const std::string& theArg,
+ bool* isFind)
{
TRestoringMap::const_iterator i = theMap.find(theArg);
if(i == theMap.end()) {
}
- QString Storable::FindValue(const TRestoringMap& theMap, const string& theArg, const QString& theDefaultValue)
+ QString
+ Storable
+ ::FindValue(const TRestoringMap& theMap,
+ const std::string& theArg,
+ const QString& theDefaultValue)
{
bool anIsFound = false;
QString aValue = FindValue(theMap,theArg,&anIsFound);
//===========================================================================
- PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject){
+ PortableServer::ServantBase_var
+ GetServant(CORBA::Object_ptr theObject)
+ {
if(CORBA::is_nil(theObject)) return NULL;
try{
PortableServer::POA_ptr aPOA = Base_i::GetPOA();
//===========================================================================
- CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject){
+ CORBA::Object_var
+ SObjectToObject(SALOMEDS::SObject_ptr theSObject)
+ {
SALOMEDS::GenericAttribute_var anAttr;
- CORBA::Object_var anObj;
+ CORBA::Object_var anObject;
+ if(CORBA::is_nil(theSObject))
+ return anObject;
try{
if(theSObject->FindAttribute(anAttr, "AttributeIOR")){
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
CORBA::String_var aValue = anIOR->Value();
CORBA::ORB_ptr anORB = Base_i::GetORB();
if(strcmp(aValue,"") != 0)
- anObj = anORB->string_to_object(aValue);
+ anObject = anORB->string_to_object(aValue);
}
}catch(...){
INFOS("SObjectToObject - Unknown exception was occured!!!");
}
- return anObj;
+ return anObject;
}
//===========================================================================
- CORBA::Object_var ClientSObjectToObject(_PTR(SObject) theSObject){
+ CORBA::Object_var
+ ClientSObjectToObject(_PTR(SObject) theSObject)
+ {
_PTR(GenericAttribute) anAttr;
- CORBA::Object_var anObj;
+ CORBA::Object_var anObject;
+ if(!theSObject)
+ return anObject;
try{
if(theSObject->FindAttribute(anAttr, "AttributeIOR")){
_PTR(AttributeIOR) anIOR = anAttr;
CORBA::String_var aValue = anIOR->Value().c_str();
CORBA::ORB_ptr anORB = Base_i::GetORB();
if(strcmp(aValue,"") != 0)
- anObj = anORB->string_to_object(aValue);
+ anObject = anORB->string_to_object(aValue);
}
}catch(...){
INFOS("ClientSObjectToObject - Unknown exception was occured!!!");
}
- return anObj;
+ return anObject;
}
//===========================================================================
- string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry,
- const char* theComment, int IsAllLevels)
+ std::string
+ FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument,
+ const std::string& theStartEntry,
+ const std::string& theComment,
+ int IsAllLevels)
{
SALOMEDS::ChildIterator_var anIter =
- theStudyDocument->NewChildIterator(theStudyDocument->FindObjectID(theStartEntry));
+ theStudyDocument->NewChildIterator(theStudyDocument->FindObjectID(theStartEntry.c_str()));
anIter->InitEx(IsAllLevels);
SALOMEDS::SObject_var aFieldSO;
for(;anIter->More();anIter->Next()) {
return "";
}
//===========================================================================
- string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
- const char* theFatherEntry, const char* theRefFatherEntry,
- const char* theIOR, const char* theName,
- const char* thePersistentRef, const char* theComment,
- CORBA::Boolean theCreateNew)
+ std::string
+ CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
+ const std::string& theFatherEntry,
+ const std::string& theIconName,
+ const std::string& theIOR,
+ const std::string& theName,
+ const std::string& thePersistentRef,
+ const std::string& theComment,
+ CORBA::Boolean theCreateNew)
{
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
- SALOMEDS::SObject_var aFather = theStudyDocument->FindObjectID(theFatherEntry);
- SALOMEDS::SObject_var newObj;
- if (theCreateNew) newObj = aStudyBuilder->NewObject(aFather);
- else newObj = aFather;
+ SALOMEDS::SObject_var aFather = theStudyDocument->FindObjectID(theFatherEntry.c_str());
+ SALOMEDS::SObject_var aNewSObject;
+ if (theCreateNew)
+ aNewSObject = aStudyBuilder->NewObject(aFather);
+ else
+ aNewSObject = aFather;
SALOMEDS::GenericAttribute_var anAttr;
- if(strcmp(theIOR,"") != 0){
- anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
- SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- anIOR->SetValue(theIOR);
+ if(theIOR != ""){
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeIOR");
+ SALOMEDS::AttributeIOR_var aCustomAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ aCustomAttr->SetValue(theIOR.c_str());
}
- if(strcmp(theName,"") != 0){
- anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
- SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
- aName->SetValue(theName);
+ if(theName != ""){
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeName");
+ SALOMEDS::AttributeName_var aCustomAttr = SALOMEDS::AttributeName::_narrow(anAttr);
+ aCustomAttr->SetValue(theName.c_str());
}
- if(strcmp(thePersistentRef,"") != 0){
- anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePersistentRef");
- SALOMEDS::AttributePersistentRef_var aPRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr);
- aPRef->SetValue(thePersistentRef);
+ if(thePersistentRef != ""){
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePersistentRef");
+ SALOMEDS::AttributePersistentRef_var aCustomAttr = SALOMEDS::AttributePersistentRef::_narrow(anAttr);
+ aCustomAttr->SetValue(thePersistentRef.c_str());
}
- if(strcmp(theComment,"") != 0){
- anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeString");
- SALOMEDS::AttributeString_var aCmnt = SALOMEDS::AttributeString::_narrow(anAttr);
- aCmnt->SetValue(theComment);
- if(MYDEBUG) INFOS("CreateAttributes - Comment = "<<theComment);
+ if(theComment != ""){
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeString");
+ SALOMEDS::AttributeString_var aCustomAttr = SALOMEDS::AttributeString::_narrow(anAttr);
+ aCustomAttr->SetValue(theComment.c_str());
}
- if(strcmp(theRefFatherEntry,"") != 0){
- SALOMEDS::SObject_var aRefFather = theStudyDocument->FindObjectID(theRefFatherEntry);
- SALOMEDS::SObject_var anObj = aStudyBuilder->NewObject(aRefFather);
- aStudyBuilder->Addreference(anObj,newObj);
+ if(theIconName != ""){
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePixMap");
+ SALOMEDS::AttributePixMap_var aCustomAttr = SALOMEDS::AttributePixMap::_narrow(anAttr);
+ aCustomAttr->SetPixMap(theIconName.c_str());
}
- CORBA::String_var anEntry = newObj->GetID();
- string aRet(anEntry);
+ CORBA::String_var anEntry = aNewSObject->GetID();
+ std::string aRet(anEntry);
if(MYDEBUG)
INFOS("CreateAttributes - StudyId = "<<theStudyDocument->StudyId()<<"; anEntry = "<<aRet<<"; IOR = '"<<theIOR<<"'");
return aRet;
}
- string CreateAttributes(_PTR(Study) theStudyDocument,
- const char* theFatherEntry, const char* theRefFatherEntry,
- const char* theIOR, const char* theName,
- const char* thePersistentRef, const char* theComment,
- CORBA::Boolean theCreateNew)
+
+ std::string
+ CreateAttributes(_PTR(Study) theStudyDocument,
+ const std::string& theFatherEntry,
+ const std::string& theIconName,
+ const std::string& theIOR,
+ const std::string& theName,
+ const std::string& thePersistentRef,
+ const std::string& theComment,
+ CORBA::Boolean theCreateNew)
{
_PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
_PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry);
- _PTR(SObject) newObj;
+ _PTR(SObject) aNewSObject;
if (theCreateNew)
- newObj = aStudyBuilder->NewObject(aFather);
+ aNewSObject = aStudyBuilder->NewObject(aFather);
else
- newObj = aFather;
+ aNewSObject = aFather;
_PTR(GenericAttribute) anAttr;
- if (strcmp(theIOR, "") != 0) {
- anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
- _PTR(AttributeIOR) anIOR (anAttr);
- anIOR->SetValue(theIOR);
+ if (theIOR != "") {
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeIOR");
+ _PTR(AttributeIOR) aCustomAttr (anAttr);
+ aCustomAttr->SetValue(theIOR);
}
- if (strcmp(theName, "") != 0) {
- anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
- _PTR(AttributeName) aName (anAttr);
- aName->SetValue(theName);
+ if (theName != "") {
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeName");
+ _PTR(AttributeName) aCustomAttr (anAttr);
+ aCustomAttr->SetValue(theName);
}
- if (strcmp(thePersistentRef, "") != 0) {
- anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePersistentRef");
- _PTR(AttributePersistentRef) aPRef (anAttr);
- aPRef->SetValue(thePersistentRef);
+ if (thePersistentRef != "") {
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePersistentRef");
+ _PTR(AttributePersistentRef) aCustomAttr (anAttr);
+ aCustomAttr->SetValue(thePersistentRef);
}
- if (strcmp(theComment, "") != 0) {
- anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeString");
- _PTR(AttributeString) aCmnt (anAttr);
- aCmnt->SetValue(theComment);
- if (MYDEBUG) INFOS("CreateAttributes - Comment = " << theComment);
+ if (theComment != "") {
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributeString");
+ _PTR(AttributeString) aCustomAttr (anAttr);
+ aCustomAttr->SetValue(theComment);
}
- if (strcmp(theRefFatherEntry, "") != 0) {
- _PTR(SObject) aRefFather = theStudyDocument->FindObjectID(theRefFatherEntry);
- _PTR(SObject) anObj = aStudyBuilder->NewObject(aRefFather);
- aStudyBuilder->Addreference(anObj, newObj);
+ if (theIconName != "") {
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSObject, "AttributePixMap");
+ _PTR(AttributePixMap) aCustomAttr (anAttr);
+ aCustomAttr->SetPixMap(theIconName);
}
- string aRet = newObj->GetID();
+ std::string aRet = aNewSObject->GetID();
if (MYDEBUG)
INFOS("CreateAttributes - StudyId = " << theStudyDocument->StudyId()
<< "; anEntry = " << aRet << "; IOR = '" << theIOR << "'");
return aRet;
}
- QString GenerateName(const string& theFmt, int theId){
+ QString
+ GenerateName(const string& theFmt, int theId)
+ {
static QString aName;
if(theId > 0)
aName.sprintf("%s:%d",theFmt.c_str(),theId);
}
- SALOMEDS::StudyManager_var GetStudyManager()
+ SALOMEDS::StudyManager_var
+ GetStudyManager()
{
static SALOMEDS::StudyManager_var aStudyManager;
if(CORBA::is_nil(aStudyManager)){
}
- SALOMEDS::Study_var GetDSStudy(_PTR(Study) theStudy)
+ SALOMEDS::Study_var
+ GetDSStudy(_PTR(Study) theStudy)
{
//std::string aStudyName = theStudy->Name();
//return GetStudyManager()->GetStudyByName(aStudyName.c_str());
return GetStudyManager()->GetStudyByID(aStudyID);
}
- SALOMEDS::SObject_var GetSObject( _PTR(SObject) obj )
+ SALOMEDS::SObject_var
+ GetSObject( _PTR(SObject) obj )
{
_PTR(Study) aStudy = obj->GetStudy();
SALOMEDS::Study_var aSalomeDSStudy = GetDSStudy( aStudy );
return aSalomeDSStudy->FindObjectID( id.c_str() );
}
- _PTR(SObject) GetClientSObject( SALOMEDS::SObject_var obj,
- _PTR(Study) study )
+ _PTR(SObject)
+ GetClientSObject( SALOMEDS::SObject_var obj,
+ _PTR(Study) study )
{
return study->FindObjectID( obj->GetID() );
}
- void RemoveFromStudy (SALOMEDS::SObject_ptr theSObject,
- bool theIsAttrOnly,
- bool theDestroySubObjects)
+ void
+ RemoveFromStudy (SALOMEDS::SObject_ptr theSObject,
+ bool theIsAttrOnly,
+ bool theDestroySubObjects)
{
if (theSObject->_is_nil()) return;
}
// asl, fix for PAL10455: Remove references to SObject
- SALOMEDS::Study::ListOfSObject* aRefs = aStudyDocument->FindDependances( theSObject );
+ SALOMEDS::Study::ListOfSObject_var aRefs = aStudyDocument->FindDependances( theSObject );
for( int i=0, n=aRefs->length(); i<n; i++ )
{
- SALOMEDS::SObject_var o = (*aRefs)[i];
+ SALOMEDS::SObject_var o = aRefs[i];
if( o->GetFatherComponent()->ComponentDataType()==theSObject->GetFatherComponent()->ComponentDataType() )
{
aStudyBuilder->RemoveReference( o );
aStudyBuilder->RemoveObjectWithChildren(theSObject);
}
- void RemoveFromStudy (_PTR(SObject) theSObject,
- bool theIsAttrOnly,
- bool theDestroySubObjects)
+ void
+ RemoveFromStudy (_PTR(SObject) theSObject,
+ bool theIsAttrOnly,
+ bool theDestroySubObjects)
{
if (!theSObject) return;
// STL headers
#include <map>
+#include <deque>
#include <string>
#include <sstream>
#include <iostream>
class VISU_Gen_i;
class VISU_I_EXPORT Base_i : public virtual POA_VISU::Base,
- public virtual PortableServer::RefCountServantBase
+ public virtual PortableServer::RefCountServantBase
{
public:
+ typedef VISU::Base TInterface;
+
Base_i();
virtual ~Base_i();
virtual char* GetID();
//===========================================================================
- class VISU_I_EXPORT Mutex{
+ class VISU_I_EXPORT Mutex
+ {
QMutex* myMutex;
int isQAppLocked;
public:
//===========================================================================
- class VISU_I_EXPORT Storable : public virtual Base_i {
+ class VISU_I_EXPORT Storable : public virtual Base_i
+ {
protected:
virtual void ToStream(std::ostringstream& theStr) = 0;
public:
- std::string ToString();
- virtual const char* GetComment() const = 0;
+ std::string
+ ToString();
+
+ virtual
+ const char*
+ GetComment() const = 0;
+
typedef std::map<std::string,QString> TRestoringMap;
+
typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject,
- const std::string& thePrefix, const TRestoringMap& theMap);
+ const std::string& thePrefix,
+ const TRestoringMap& theMap);
typedef std::map<std::string,TStorableEngine> TCallbackMap;
- static void Registry(const char* theComment, TStorableEngine theEngine);
- static Storable* Create(SALOMEDS::SObject_ptr, const std::string& thePrefix, const std::string& theString);
- static QString FindValue(const TRestoringMap& theMap, const std::string& theArg, bool* isFind = NULL);
- static QString FindValue(const TRestoringMap& theMap, const std::string& theArg, const QString& theDefaultValue);
- static void StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap);
- static SALOMEDS::SObject_ptr GetResultSO(SALOMEDS::SObject_ptr theSObject);
- static void DataToStream(std::ostringstream& theStr, const QString& theName, const QString& theVal);
- static void DataToStream(std::ostringstream& theStr, const QString& theName, const int theVal);
- static void DataToStream(std::ostringstream& theStr, const QString& theName, const double theVal);
- };
- //===========================================================================
- class VISU_I_EXPORT RemovableObject_i : public virtual POA_VISU::RemovableObject,
- public virtual Storable
- {
- public:
- virtual void RemoveFromStudy() = 0;
+ static
+ void
+ Registry(const std::string& theComment,
+ TStorableEngine theEngine);
+
+ static
+ Storable*
+ Create(SALOMEDS::SObject_ptr,
+ const std::string& thePrefix,
+ const std::string& theString);
+
+ static
+ QString
+ FindValue(const TRestoringMap& theMap,
+ const std::string& theArg,
+ bool* isFind = NULL);
+
+ static
+ QString
+ FindValue(const TRestoringMap& theMap,
+ const std::string& theArg,
+ const QString& theDefaultValue);
+
+ static
+ void
+ StrToMap(const QString& theStr,
+ VISU::Storable::TRestoringMap& theMap);
+
+ static
+ SALOMEDS::SObject_ptr
+ GetResultSO(SALOMEDS::SObject_ptr theSObject);
+
+ static
+ void
+ DataToStream(std::ostringstream& theStr,
+ const QString& theName,
+ const QString& theVal);
+
+ static
+ void
+ DataToStream(std::ostringstream& theStr,
+ const QString& theName,
+ const int theVal);
+
+ static
+ void
+ DataToStream(std::ostringstream& theStr,
+ const QString& theName,
+ const double theVal);
};
//===========================================================================
- VISU_I_EXPORT const CORBA::Boolean IsMultifile();
- VISU_I_EXPORT QString GenerateName(const std::string& theFmt, int theId);
-
- VISU_I_EXPORT PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject);
- VISU_I_EXPORT CORBA::Object_var ClientSObjectToObject(_PTR(SObject) theSObject);
- VISU_I_EXPORT CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr);
-
- VISU_I_EXPORT _PTR(SComponent) ClientFindOrCreateVisuComponent(_PTR(Study) theStudyDocument);
- VISU_I_EXPORT SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
-
- VISU_I_EXPORT std::string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
- const char* theFatherEntry, const char* theRefFatherEntry,
- const char* theIOR, const char* theName,
- const char* thePersistentRef, const char* theComment,
- CORBA::Boolean theCreateNew = true);
-
- VISU_I_EXPORT std::string CreateAttributes(_PTR(Study) theStudyDocument,
- const char* theFatherEntry, const char* theRefFatherEntry,
- const char* theIOR, const char* theName,
- const char* thePersistentRef, const char* theComment,
- CORBA::Boolean theCreateNew = true);
-
- VISU_I_EXPORT std::string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry,
- const char* theComment, int IsAllLevels = true);
-
- VISU_I_EXPORT SALOMEDS::SObject_var GetSObject(_PTR(SObject));
- VISU_I_EXPORT _PTR(SObject) GetClientSObject(SALOMEDS::SObject_var, _PTR(Study));
-
- VISU_I_EXPORT SALOMEDS::Study_var GetDSStudy(_PTR(Study));
-
- VISU_I_EXPORT void RemoveFromStudy(SALOMEDS::SObject_ptr theSObject,
- bool theIsAttrOnly = true,
- bool theDestroySubObjects = false);
- VISU_I_EXPORT void RemoveFromStudy(_PTR(SObject) theSObject,
- bool theIsAttrOnly = true,
- bool theDestroySubObjects = false);
+ VISU_I_EXPORT
+ const CORBA::Boolean
+ IsMultifile();
+
+ VISU_I_EXPORT
+ QString
+ GenerateName(const std::string& theFmt, int theId);
+
+ VISU_I_EXPORT
+ PortableServer::ServantBase_var
+ GetServant(CORBA::Object_ptr theObject);
+
+ VISU_I_EXPORT
+ CORBA::Object_var
+ ClientSObjectToObject(_PTR(SObject) theSObject);
+
+ VISU_I_EXPORT
+ CORBA::Object_var
+ SObjectToObject(SALOMEDS::SObject_ptr);
+
+ VISU_I_EXPORT
+ _PTR(SComponent)
+ ClientFindOrCreateVisuComponent(_PTR(Study) theStudyDocument);
+
+ VISU_I_EXPORT
+ SALOMEDS::SComponent_var
+ FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
+
+ VISU_I_EXPORT
+ std::string
+ CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
+ const std::string& theFatherEntry,
+ const std::string& theIconName,
+ const std::string& theIOR,
+ const std::string& theName,
+ const std::string& thePersistentRef,
+ const std::string& theComment,
+ CORBA::Boolean theCreateNew = true);
+
+ VISU_I_EXPORT
+ std::string
+ CreateAttributes(_PTR(Study) theStudyDocument,
+ const std::string& theFatherEntry,
+ const std::string& theIconName,
+ const std::string& theIOR,
+ const std::string& theName,
+ const std::string& thePersistentRef,
+ const std::string& theComment,
+ CORBA::Boolean theCreateNew = true);
+
+ VISU_I_EXPORT
+ std::string
+ FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument,
+ const std::string& theStartEntry,
+ const std::string& theComment,
+ int IsAllLevels = true);
+
+ VISU_I_EXPORT
+ SALOMEDS::SObject_var
+ GetSObject(_PTR(SObject));
+
+ VISU_I_EXPORT
+ _PTR(SObject)
+ GetClientSObject(SALOMEDS::SObject_var, _PTR(Study));
+
+ VISU_I_EXPORT
+ SALOMEDS::Study_var
+ GetDSStudy(_PTR(Study));
+
+ VISU_I_EXPORT
+ void
+ RemoveFromStudy(SALOMEDS::SObject_ptr theSObject,
+ bool theIsAttrOnly = true,
+ bool theDestroySubObjects = false);
+ VISU_I_EXPORT
+ void
+ RemoveFromStudy(_PTR(SObject) theSObject,
+ bool theIsAttrOnly = true,
+ bool theDestroySubObjects = false);
}
#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_ColoredPrs3dCache_i.cc
+// Author : Oleg UVAROV
+// Module : VISU
+
+#include "VISU_ColoredPrs3dCache_i.hh"
+
+#include "VISU_ColoredPrs3dHolder_i.hh"
+#include "VISU_ColoredPrs3dFactory.hh"
+
+#include "VISU_ViewManager_i.hh"
+#include "VISU_View_i.hh"
+#include "VISU_Actor.h"
+
+#include "VISU_PipeLine.hxx"
+
+#include "SALOME_Event.hxx"
+
+#include "VTKViewer_Algorithm.h"
+#include "SVTK_Functor.h"
+
+#include "VVTK_ViewWindow.h"
+#include "SUIT_ResourceMgr.h"
+
+#include <vtkRenderWindow.h>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+namespace
+{
+ //----------------------------------------------------------------------------
+ inline
+ bool
+ IsSameField(const VISU::ColoredPrs3dHolder::BasicInput& theReferenceInput,
+ const VISU::ColoredPrs3dHolder::BasicInput& thePrs3dInput)
+ {
+ return thePrs3dInput.myResult->_is_equivalent(theReferenceInput.myResult) &&
+ thePrs3dInput.myEntity == theReferenceInput.myEntity &&
+ !strcmp(thePrs3dInput.myFieldName.in(), theReferenceInput.myFieldName.in());
+ }
+
+
+ //----------------------------------------------------------------------------
+ inline
+ bool
+ IsSameTimeStamp(const VISU::ColoredPrs3dHolder::BasicInput& theReferenceInput,
+ const VISU::ColoredPrs3dHolder::BasicInput& thePrs3dInput)
+ {
+ return IsSameField(theReferenceInput, thePrs3dInput) &&
+ thePrs3dInput.myTimeStampNumber == theReferenceInput.myTimeStampNumber;
+ }
+
+
+ //----------------------------------------------------------------------------
+ VISU::ColoredPrs3d_i*
+ FindSameFieldPrs(const VISU::TColoredPrs3dHolderMap& theHolderMap,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ VISU::VISUType theType)
+ {
+ VISU::TColoredPrs3dHolderMap::const_iterator aHolderIter = theHolderMap.begin();
+ VISU::TColoredPrs3dHolderMap::const_iterator aHolderIterEnd = theHolderMap.end();
+ for(; aHolderIter != aHolderIterEnd; aHolderIter++){
+ const VISU::TLastVisitedPrsList& aPrsList = aHolderIter->second;
+ VISU::TLastVisitedPrsList::const_iterator aPrsIter = aPrsList.begin();
+ VISU::TLastVisitedPrsList::const_iterator aPrsIterEnd = aPrsList.end();
+ for(; aPrsIter != aPrsIterEnd; aPrsIter++){
+ VISU::TPrs3dPtr aPrs3d = *aPrsIter;
+ if(aPrs3d->GetType() != theType)
+ break;
+ VISU::ColoredPrs3dHolder::BasicInput_var anInput = aPrs3d->GetBasicInput();
+ if(IsSameField(theInput, anInput))
+ return aPrs3d.get();
+ }
+ }
+ return VISU::TPrs3dPtr();
+ }
+
+
+ //----------------------------------------------------------------------------
+ CORBA::Float
+ EstimateMemorySize(const VISU::TColoredPrs3dHolderMap& theHolderMap,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ VISU::VISUType theType,
+ const size_t theRawEstimatedMemorySize)
+ {
+ VISU::ColoredPrs3d_i* aPrs3d = FindSameFieldPrs(theHolderMap, theInput, theType);
+ if(aPrs3d)
+ return aPrs3d->GetMemorySize();
+ return CORBA::Float(theRawEstimatedMemorySize/(1024.0*1024.0)); // convert to Mb
+ }
+
+
+ //----------------------------------------------------------------------------
+ bool
+ SelectPrs3dToBeDeleted(CORBA::Float theRequiredMemory,
+ const std::string& theActiveHolderEntry,
+ const VISU::TColoredPrs3dHolderMap& theHolderMap,
+ VISU::TColoredPrs3dHolderMap& theColoredPrs3dHolderMap)
+ {
+ if( theRequiredMemory < 1.0 / VTK_LARGE_FLOAT )
+ return false;
+
+ VISU::TColoredPrs3dHolderMap::const_iterator aHolderIter = theHolderMap.begin();
+ VISU::TColoredPrs3dHolderMap::const_iterator aHolderIterEnd = theHolderMap.end();
+
+ // To calculate the maximum length of the cache history among all holders
+ int anIteration = 0;
+ for( ; aHolderIter != aHolderIterEnd; aHolderIter++ ){
+ if( aHolderIter->first == theActiveHolderEntry )
+ continue;
+ const VISU::TLastVisitedPrsList& aPrsList = aHolderIter->second;
+ anIteration = QMAX( aPrsList.size() - 1, anIteration );
+ }
+
+ // To estimate what amount of memory can be obtained
+ // by cleaning of non-active holder's presentation
+ CORBA::Float aGatheredMemory = 0.0;
+ for(; anIteration > 0; anIteration--){ // To take into account only non-devices
+ aHolderIter = theHolderMap.begin();
+ for(; aHolderIter != aHolderIterEnd; aHolderIter++ ){
+ const std::string& aHolderEntry = aHolderIter->first;
+ if( aHolderEntry == theActiveHolderEntry )
+ continue;
+ const VISU::TLastVisitedPrsList& aPrsList = aHolderIter->second;
+ if( anIteration < aPrsList.size() ){
+ VISU::TPrs3dPtr aPrs3d = aPrsList[anIteration];
+ aGatheredMemory += aPrs3d->GetMemorySize();
+ theColoredPrs3dHolderMap[aHolderEntry].push_back(aPrs3d);
+ if( aGatheredMemory > theRequiredMemory )
+ return true;
+ }
+ }
+ }
+
+ // To estimate what amount of memory can be obtained
+ // by cleaning of active holder's presentation
+ if( theActiveHolderEntry != "" ){
+ aHolderIter = theHolderMap.find( theActiveHolderEntry );
+ if(aHolderIter == theHolderMap.end())
+ return false;
+
+ const VISU::TLastVisitedPrsList& aPrsList = aHolderIter->second;
+
+ // To prefere "move" action instead of destroy / create presentation
+ if(aPrsList.back()->GetMemorySize() >= theRequiredMemory)
+ return false;
+
+ VISU::TLastVisitedPrsList::const_reverse_iterator aPrsIter = aPrsList.rbegin();
+ // Do not porcess first item to avoid of the device destruction
+ VISU::TLastVisitedPrsList::const_reverse_iterator aPrsIterEnd = aPrsList.rend()++;
+ for(; aPrsIter != aPrsIterEnd; aPrsIter++){
+ VISU::TPrs3dPtr aPrs3d = *aPrsIter;
+ aGatheredMemory += aPrs3d->GetMemorySize();
+ theColoredPrs3dHolderMap[theActiveHolderEntry].push_back(aPrs3d);
+ if( aGatheredMemory > theRequiredMemory )
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ //----------------------------------------------------------------------------
+ void
+ ErasePrs3d(VISU::TLastVisitedPrsList& thePrsList,
+ const VISU::TPrs3dPtr& thePrs3d)
+ {
+ VISU::TLastVisitedPrsList::iterator anIter = thePrsList.begin();
+ VISU::TLastVisitedPrsList::iterator aEndIter = thePrsList.end();
+ for(; anIter != aEndIter; anIter++){
+ VISU::TPrs3dPtr aPrs3d = *anIter;
+ if(aPrs3d == thePrs3d)
+ thePrsList.erase(anIter);
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dCache_i
+::ColoredPrs3dCache_i(SALOMEDS::Study_ptr theStudy,
+ bool thePublishInStudy):
+ RemovableObject_i()
+{
+ if(MYDEBUG) MESSAGE("ColoredPrs3dCache_i::ColoredPrs3dCache_i - this = "<<this);
+ SetStudyDocument(theStudy);
+
+ SetName(GetFolderName(), false);
+
+ if( thePublishInStudy )
+ {
+ CORBA::String_var anIOR = GetID();
+ SALOMEDS::SComponent_var aSComponent = VISU::FindOrCreateVisuComponent(theStudy);
+ CORBA::String_var aFatherEntry = aSComponent->GetID();
+ CreateAttributes(GetStudyDocument(), aFatherEntry.in(), "", anIOR.in(), GetName(), "", "", true);
+ }
+
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+ int aMemoryMode = aResourceMgr->integerValue( "VISU", "cache_memory_mode", 0 );
+ SetMemoryMode( aMemoryMode == 0 ? VISU::ColoredPrs3dCache::MINIMAL : VISU::ColoredPrs3dCache::LIMITED );
+
+ float aLimitedMemory = aResourceMgr->doubleValue( "VISU", "cache_memory_limit", 1024.0 );
+ SetLimitedMemory( aLimitedMemory );
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dCache_i
+::~ColoredPrs3dCache_i()
+{
+ if(MYDEBUG) MESSAGE("ColoredPrs3dCache_i::~ColoredPrs3dCache_i - this = "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+const string VISU::ColoredPrs3dCache_i::myComment = "COLOREDPRS3DCACHE";
+
+const char*
+VISU::ColoredPrs3dCache_i
+::GetComment() const
+{
+ return myComment.c_str();
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Float
+VISU::ColoredPrs3dCache_i
+::GetMemorySize()
+{
+ CORBA::Float aMemoryUsed = 0.0;
+ TColoredPrs3dHolderMap::const_iterator aHolderIter = myHolderMap.begin();
+ TColoredPrs3dHolderMap::const_iterator aHolderIterEnd = myHolderMap.end();
+ for(; aHolderIter != aHolderIterEnd; aHolderIter++){
+ const TLastVisitedPrsList& aPrsList = aHolderIter->second;
+ TLastVisitedPrsList::const_iterator aPrsIter = aPrsList.begin();
+ TLastVisitedPrsList::const_iterator aPrsIterEnd = aPrsList.end();
+ for(; aPrsIter != aPrsIterEnd; aPrsIter++){
+ if(TPrs3dPtr aPrs3d = *aPrsIter)
+ aMemoryUsed += aPrs3d->GetMemorySize();
+ }
+ }
+ return aMemoryUsed;
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Float
+VISU::ColoredPrs3dCache_i
+::GetDeviceMemorySize()
+{
+ CORBA::Float aMemoryUsed = 0.0;
+ TColoredPrs3dHolderMap::const_iterator aHolderIter = myHolderMap.begin();
+ TColoredPrs3dHolderMap::const_iterator aHolderIterEnd = myHolderMap.end();
+ for(; aHolderIter != aHolderIterEnd; aHolderIter++){
+ const TLastVisitedPrsList& aPrsList = aHolderIter->second;
+ if(TPrs3dPtr aPrs3d = aPrsList.front())
+ aMemoryUsed += aPrs3d->GetMemorySize();
+ }
+ return aMemoryUsed;
+}
+
+
+//----------------------------------------------------------------------------
+int
+VISU::ColoredPrs3dCache_i
+::IsPossible(VISU::VISUType theType,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ CORBA::Float& theRequiredMemory,
+ const std::string theHolderEntry)
+{
+ size_t aRawEstimatedMemorySize = VISU::CheckIsPossible(theType, theInput, true);
+ if(aRawEstimatedMemorySize > 0){
+ if(GetMemoryMode() == VISU::ColoredPrs3dCache::LIMITED){
+ CORBA::Float aMemoryUsed = GetMemorySize();
+ CORBA::Float aMemoryLimit = GetLimitedMemory();
+ CORBA::Float aMemoryNeeded = EstimateMemorySize(myHolderMap,
+ theInput,
+ theType,
+ aRawEstimatedMemorySize);
+
+ if( aMemoryUsed + aMemoryNeeded < aMemoryLimit )
+ return true;
+
+ theRequiredMemory = aMemoryNeeded - ( aMemoryLimit - aMemoryUsed );
+ TColoredPrs3dHolderMap aColoredPrs3dHolderMap;
+ return SelectPrs3dToBeDeleted(theRequiredMemory,
+ theHolderEntry,
+ myHolderMap,
+ aColoredPrs3dHolderMap);
+ }
+ }
+ return aRawEstimatedMemorySize > 0;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dCache::EnlargeType
+VISU::ColoredPrs3dCache_i
+::GetRequiredMemory(VISU::VISUType theType,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ CORBA::Float& theRequiredMemory)
+{
+ VISU::ColoredPrs3dCache::EnlargeType anEnlargeType = VISU::ColoredPrs3dCache::NO_ENLARGE;
+
+ size_t aRawEstimatedMemorySize = VISU::CheckIsPossible(theType, theInput, true);
+ if(aRawEstimatedMemorySize > 0){
+ if(GetMemoryMode() == VISU::ColoredPrs3dCache::LIMITED){
+ CORBA::Float aMemoryUsed = GetDeviceMemorySize();
+ CORBA::Float aMemoryLimit = GetLimitedMemory();
+ CORBA::Float aMemoryNeeded = EstimateMemorySize(myHolderMap,
+ theInput,
+ theType,
+ aRawEstimatedMemorySize);
+ if( aMemoryUsed + aMemoryNeeded < aMemoryLimit )
+ return anEnlargeType;
+
+ theRequiredMemory = int( aMemoryUsed + aMemoryNeeded ) + 1;
+
+ size_t aMb = 1024 * 1024;
+ double aFreeMemory = double(VISU_PipeLine::GetAvailableMemory(2048*aMb)) / double(aMb);
+ anEnlargeType = aMemoryNeeded < aFreeMemory ?
+ VISU::ColoredPrs3dCache::ENLARGE : VISU::ColoredPrs3dCache::IMPOSSIBLE;
+ }
+ }
+ return anEnlargeType;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dCache_i*
+VISU::ColoredPrs3dCache_i
+::GetInstance_i(SALOMEDS::Study_ptr theStudy)
+{
+ std::string aFolderName = VISU::ColoredPrs3dCache_i::GetFolderName();
+ SALOMEDS::SObject_var aSObject = theStudy->FindObject(aFolderName.c_str());
+ if(!CORBA::is_nil(aSObject)){
+ CORBA::Object_var anObject = aSObject->GetObject();
+ VISU::ColoredPrs3dCache_var aCache = VISU::ColoredPrs3dCache::_narrow(anObject);
+ if(!CORBA::is_nil(aCache))
+ return dynamic_cast<VISU::ColoredPrs3dCache_i*>(GetServant(aCache).in());
+ }
+
+ return new VISU::ColoredPrs3dCache_i(theStudy);
+}
+
+
+VISU::ColoredPrs3dCache_ptr
+VISU::ColoredPrs3dCache_i
+::GetInstance(SALOMEDS::Study_ptr theStudy)
+{
+ VISU::ColoredPrs3dCache_i* aServant = GetInstance_i(theStudy);
+ VISU::ColoredPrs3dCache_var anObject = aServant->_this();
+ return anObject._retn();
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dHolder_ptr
+VISU::ColoredPrs3dCache_i
+::CreateHolder(VISU::VISUType theType,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput)
+{
+ if(MYDEBUG) cout << "CreateHolder " << theType << endl;
+ CORBA::Float aRequiredMemory = 0.0;
+ if(IsPossible(theType, theInput, aRequiredMemory, "")){
+ if(VISU::ColoredPrs3d_i* aColoredPrs3d = CreateColoredPrs3d(theType, theInput)){
+ VISU::ColoredPrs3dHolder_i* aHolder = new VISU::ColoredPrs3dHolder_i(*this);
+ std::string aComment = std::string("myComment=") + aColoredPrs3d->GetComment();
+ std::string aName = aColoredPrs3d->GenerateName().latin1();
+ aHolder->PublishInStudy(aName, aColoredPrs3d->GetIconName(), aComment);
+ RegisterInHolder(aColoredPrs3d, aHolder->GetEntry());
+ if( aRequiredMemory > 1.0 / VTK_LARGE_FLOAT )
+ ClearMemory( aRequiredMemory, aHolder->GetEntry() );
+ return aHolder->_this();
+ }
+ }
+ return VISU::ColoredPrs3dHolder::_nil();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3dCache_i
+::SetMemoryMode(VISU::ColoredPrs3dCache::MemoryMode theMode)
+{
+ VISU::ColoredPrs3dCache::MemoryMode aCurrentMode = GetMemoryMode();
+
+ if( aCurrentMode == VISU::ColoredPrs3dCache::LIMITED &&
+ theMode == VISU::ColoredPrs3dCache::MINIMAL )
+ {
+ ClearCache();
+ }
+
+ myMemoryMode = theMode;
+}
+
+VISU::ColoredPrs3dCache::MemoryMode
+VISU::ColoredPrs3dCache_i
+::GetMemoryMode()
+{
+ return myMemoryMode;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3dCache_i
+::SetLimitedMemory(CORBA::Float theMemorySize)
+{
+ if( fabs( myLimitedMemory - theMemorySize ) < 1 / VTK_LARGE_FLOAT )
+ return;
+
+ size_t aMb = 1024 * 1024;
+ double aFreeMemory = double(VISU_PipeLine::GetAvailableMemory(2048*aMb)) / double(aMb);
+ CORBA::Float aMemoryUsed = GetDeviceMemorySize();
+ CORBA::Float aMemoryNeeded = theMemorySize - aMemoryUsed;
+ if( aMemoryNeeded > aFreeMemory )
+ return;
+
+ ClearCache(theMemorySize);
+ myLimitedMemory = theMemorySize;
+}
+
+CORBA::Float
+VISU::ColoredPrs3dCache_i
+::GetLimitedMemory()
+{
+ return myLimitedMemory;
+}
+
+
+void
+VISU::ColoredPrs3dCache_i
+::RemoveFromStudy()
+{
+ CORBA::String_var anIOR = GetID();
+ SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectIOR(anIOR.in());
+ VISU::RemoveFromStudy(aSObject, false, true);
+ Destroy();
+}
+
+std::string
+VISU::ColoredPrs3dCache_i
+::GetFolderName()
+{
+ return "3D Cache System";
+}
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d_i*
+VISU::ColoredPrs3dCache_i
+::CreateColoredPrs3d(VISU::VISUType theType,
+ VISU::ColoredPrs3dHolder::BasicInput theInput)
+{
+ VISU::ColoredPrs3d_i* aPrs3d = VISU::CreatePrs3d_i(theType, GetStudyDocument(), ColoredPrs3d_i::ERegisterInCache);
+ aPrs3d->SetResultObject( theInput.myResult );
+ aPrs3d->SetMeshName( theInput.myMeshName );
+ aPrs3d->SetEntity( theInput.myEntity );
+ aPrs3d->SetFieldName( theInput.myFieldName );
+ aPrs3d->SetTimeStampNumber( theInput.myTimeStampNumber );
+ if(aPrs3d->Apply( false ))
+ return aPrs3d;
+ return NULL;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d_i*
+VISU::ColoredPrs3dCache_i
+::RegisterInHolder(VISU::ColoredPrs3d_i* thePrs3d,
+ const std::string& theHolderEntry)
+{
+ if(MYDEBUG) cout << "RegisterInHolder " << theHolderEntry.c_str() << " " << thePrs3d << endl;
+ if(thePrs3d){
+ TPrs3dPtr aPrs3d(thePrs3d);
+ myHolderMap[theHolderEntry].push_front(aPrs3d);
+ thePrs3d->SetHolderEntry( theHolderEntry );
+ thePrs3d->Destroy();
+ }
+ return thePrs3d;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d_i*
+VISU::ColoredPrs3dCache_i
+::CreatePrs(VISU::VISUType theType,
+ VISU::ColoredPrs3dHolder::BasicInput theInput,
+ VISU::ColoredPrs3dHolder_i* theHolder)
+{
+ return RegisterInHolder(CreateColoredPrs3d(theType, theInput),
+ theHolder->GetEntry());
+}
+
+
+//----------------------------------------------------------------------------
+VISU::TLastVisitedPrsList&
+VISU::ColoredPrs3dCache_i
+::GetLastVisitedPrsList(VISU::ColoredPrs3dHolder_i* theHolder)
+{
+ return myHolderMap[theHolder->GetEntry()];
+}
+
+
+//----------------------------------------------------------------------------
+VISU::TPrs3dPtr
+VISU::ColoredPrs3dCache_i
+::GetLastVisitedPrs(VISU::ColoredPrs3dHolder_i* theHolder)
+{
+ const TLastVisitedPrsList& aList = GetLastVisitedPrsList(theHolder);
+ if(MYDEBUG) cout << "GetLastVisitedPrs " << theHolder->GetEntry().c_str() << " " << aList.size() << endl;
+ if( !aList.empty() )
+ return aList.front();
+ return VISU::TPrs3dPtr();
+}
+
+
+//----------------------------------------------------------------------------
+VISU::TPrs3dPtr
+VISU::ColoredPrs3dCache_i
+::FindPrsByInput(TLastVisitedPrsList& theLastVisitedPrsList,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput)
+{
+ TLastVisitedPrsList::iterator anIter = theLastVisitedPrsList.begin();
+ TLastVisitedPrsList::iterator aEndIter = theLastVisitedPrsList.end();
+ for(; anIter != aEndIter; anIter++){
+ TPrs3dPtr aPrs3d = *anIter;
+ VISU::ColoredPrs3dHolder::BasicInput_var anInput = aPrs3d->GetBasicInput();
+ if(IsSameTimeStamp(theInput, anInput)){
+ theLastVisitedPrsList.erase(anIter);
+ return aPrs3d;
+ }
+ }
+ return VISU::TPrs3dPtr();
+}
+
+struct TFindActorEvent: public SALOME_Event
+{
+ VISU::TPrs3dPtr myPrs3d;
+ SVTK_ViewWindow* myViewWindow;
+
+ typedef VISU_Actor* TResult;
+ TResult myResult;
+
+ TFindActorEvent(VISU::TPrs3dPtr thePrs3d, SVTK_ViewWindow* theViewWindow):
+ myPrs3d(thePrs3d),
+ myViewWindow(theViewWindow),
+ myResult(NULL)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ myResult = VISU::FindActor(myViewWindow, myPrs3d);
+ }
+};
+
+struct TAddActorEvent: public SALOME_Event
+{
+ VISU_Actor* myActor;
+ SVTK_ViewWindow* myViewWindow;
+public:
+ TAddActorEvent(VISU_Actor* theActor, SVTK_ViewWindow* theViewWindow):
+ myActor(theActor),
+ myViewWindow(theViewWindow)
+ {}
+ virtual void Execute(){
+ myViewWindow->AddActor(myActor);
+ }
+};
+
+struct TRenderEvent: public SALOME_Event
+{
+ SVTK_ViewWindow* myViewWindow;
+public:
+ TRenderEvent(SVTK_ViewWindow* theViewWindow):
+ myViewWindow(theViewWindow)
+ {}
+ virtual void Execute(){
+ myViewWindow->getRenderWindow()->Render();
+ }
+};
+
+//----------------------------------------------------------------------------
+bool
+VISU::ColoredPrs3dCache_i
+::UpdateLastVisitedPrs(VISU::ColoredPrs3dHolder_i* theHolder,
+ VISU::ColoredPrs3d_i* thePrs,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ VISU::View3D_ptr theView3D)
+{
+ if(MYDEBUG) cout << "VISU::ColoredPrs3dCache_i::UpdateLastVisitedPrs" << endl;
+ TPrs3dPtr aLastVisitedPrs3d = GetLastVisitedPrs(theHolder);
+ TLastVisitedPrsList& aLastVisitedPrsList = GetLastVisitedPrsList(theHolder);
+ TPrs3dPtr aPrs3d;
+ bool anIsCheckPossible = GetMemoryMode() == VISU::ColoredPrs3dCache::LIMITED;
+ std::string aHolderEntry = theHolder->GetEntry();
+ VISU::VISUType aPrsType = theHolder->GetPrsType();
+ CORBA::Float aRequiredMemory = 0.0;
+ if(aPrs3d = FindPrsByInput(aLastVisitedPrsList, theInput)){
+ aLastVisitedPrsList.push_front(aPrs3d);
+ if(MYDEBUG) cout << "FindPrsByInput " << aPrs3d << endl;
+ }else if(anIsCheckPossible && IsPossible(aPrsType, theInput, aRequiredMemory, aHolderEntry)){
+ if( aRequiredMemory > 1.0 / VTK_LARGE_FLOAT )
+ ClearMemory(aRequiredMemory, aHolderEntry);
+ aPrs3d = CreatePrs(aPrsType, theInput, theHolder);
+ if(MYDEBUG) cout << "Created " << aPrs3d << endl;
+ }else{
+ aPrs3d = aLastVisitedPrsList.back();
+ aPrs3d->SetResultObject(theInput.myResult);
+ aPrs3d->SetMeshName(theInput.myMeshName);
+ aPrs3d->SetEntity(theInput.myEntity);
+ aPrs3d->SetFieldName(theInput.myFieldName);
+ aPrs3d->SetTimeStampNumber(theInput.myTimeStampNumber);
+ aLastVisitedPrsList.pop_back();
+ aLastVisitedPrsList.push_front(aPrs3d);
+ if(MYDEBUG) cout << "Move only " << aPrs3d << endl;
+ }
+ //if(MYDEBUG) PrintCache();
+
+ aPrs3d->SameAs(thePrs);
+ aPrs3d->UpdateActors();
+ if(!CORBA::is_nil(theView3D)){
+ PortableServer::ServantBase_var aServant = GetServant(theView3D);
+ if(VISU::View3D_i* aView3d = dynamic_cast<VISU::View3D_i*>(aServant.in())){
+ if(SUIT_ViewWindow* aView = aView3d->GetViewWindow()){
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aView)){
+ // Find actor that corresponds to the holder
+ VISU_Actor* anActor = ProcessEvent(new TFindActorEvent(aLastVisitedPrs3d,aViewWindow));
+ //VISU_Actor* anActor = VISU::FindActor(aViewWindow, aLastVisitedPrs3d);
+
+ // If the holder was erased from view then do nothing
+ if(anActor && !anActor->GetVisibility())
+ return true;
+
+ if(!anActor)
+ {
+ anActor = aLastVisitedPrs3d->CreateActor();
+ ProcessVoidEvent(new TAddActorEvent(anActor,aViewWindow));
+ //aViewWindow->AddActor(anActor);
+ anActor->SetVisibility(true);
+ }
+
+ if(aPrs3d != aLastVisitedPrs3d)
+ {
+ // To erase non active presentation
+ aLastVisitedPrs3d->SetActiveState(false);
+ if(anActor)
+ anActor->SetVisibility(false);
+
+ // To find the new one that corresponds to fresh presentation
+ VISU_Actor* aNewActor = ProcessEvent(new TFindActorEvent(aPrs3d,aViewWindow));
+ //VISU_Actor* aNewActor = VISU::FindActor(aViewWindow, aPrs3d);
+ if(!aNewActor){
+ aNewActor = aPrs3d->CreateActor();
+ ProcessVoidEvent(new TAddActorEvent(aNewActor,aViewWindow));
+ //aViewWindow->AddActor(aNewActor);
+ }else
+ aNewActor->SetVisibility(true);
+ aNewActor->DeepCopy(anActor);
+
+ aPrs3d->SetActiveState(true);
+ }
+ ProcessVoidEvent(new TRenderEvent(aViewWindow));
+ //aViewWindow->getRenderWindow()->Render();
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3dCache_i
+::ClearCache(float theMemory)
+{
+ CORBA::Float aCurrentMemory = GetMemorySize();
+ ClearMemory( aCurrentMemory - theMemory, "" );
+}
+
+
+//----------------------------------------------------------------------------
+bool
+VISU::ColoredPrs3dCache_i
+::ClearMemory(CORBA::Float theRequiredMemory,
+ const std::string& theHolderEntry)
+{
+ CORBA::Float aInitialMemorySize = GetMemorySize();
+ TColoredPrs3dHolderMap aHolder2PrsToBeDeletedMap;
+ SelectPrs3dToBeDeleted(theRequiredMemory, theHolderEntry, myHolderMap, aHolder2PrsToBeDeletedMap);
+ TColoredPrs3dHolderMap::const_iterator aHolderIter = aHolder2PrsToBeDeletedMap.begin();
+ TColoredPrs3dHolderMap::const_iterator anEndHolderIter = aHolder2PrsToBeDeletedMap.end();
+ for(; aHolderIter != anEndHolderIter; aHolderIter++){
+ const std::string aHolderEntry = aHolderIter->first;
+ TColoredPrs3dHolderMap::iterator anHolderMapIter = myHolderMap.find(aHolderEntry);
+ if(anHolderMapIter != myHolderMap.end()){
+ TLastVisitedPrsList& aLastVisitedPrsList = anHolderMapIter->second;
+
+ const TLastVisitedPrsList& aPrsToBeDeletedList = aHolderIter->second;
+ TLastVisitedPrsList::const_iterator anIter = aPrsToBeDeletedList.begin();
+ TLastVisitedPrsList::const_iterator aEndIter = aPrsToBeDeletedList.end();
+ for(; anIter != aEndIter; anIter++){
+ TPrs3dPtr aPrs3d = *anIter;
+ ErasePrs3d(aLastVisitedPrsList, aPrs3d);
+ }
+ }
+ }
+ CORBA::Float aCurrentMemory = GetMemorySize();
+ return (aInitialMemorySize - aCurrentMemory >= theRequiredMemory);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3dCache_i
+::PrintCache()
+{
+ if(MYDEBUG)
+ {
+ cout << "--------------CACHE-----------------" << endl;
+ cout << "Cache memory - " << GetMemorySize() << " Mb" << endl;
+ TColoredPrs3dHolderMap::const_iterator aHolderIter = myHolderMap.begin();
+ TColoredPrs3dHolderMap::const_iterator aHolderIterEnd = myHolderMap.end();
+ for(; aHolderIter != aHolderIterEnd; aHolderIter++){
+ const TLastVisitedPrsList& aPrsList = aHolderIter->second;
+ TLastVisitedPrsList::const_iterator aPrsIter = aPrsList.begin();
+ TLastVisitedPrsList::const_iterator aPrsIterEnd = aPrsList.end();
+
+ cout << "--------------------------" << endl;
+ cout << "Holder - " << aHolderIter->first.c_str() << endl;
+ cout << "Size - " << aPrsList.size() << endl;
+ for(; aPrsIter != aPrsIterEnd; aPrsIter++)
+ if(TPrs3dPtr aPrs3d = *aPrsIter)
+ {
+ cout << aPrs3d << " (" << aPrs3d->GetMemorySize() << " Mb)";
+ if(aPrsIter == aPrsList.begin())
+ cout << " (device)";
+ cout << endl;
+ }
+ }
+ cout << "------------------------------------" << endl;
+ }
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3dCache_i
+::RemoveHolder(VISU::ColoredPrs3dHolder_i* theHolder)
+{
+ TColoredPrs3dHolderMap::iterator anIter = myHolderMap.find(theHolder->GetEntry());
+ if(anIter != myHolderMap.end())
+ myHolderMap.erase(anIter);
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3dCache_i
+::ToStream(std::ostringstream& theStr)
+{
+ Storable::DataToStream( theStr, "myMemoryMode", GetMemoryMode() );
+ Storable::DataToStream( theStr, "myLimitedMemory", GetLimitedMemory() );
+}
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::ColoredPrs3dCache_i
+::Restore(SALOMEDS::SObject_ptr theSObject,
+ const Storable::TRestoringMap& theMap,
+ const string& thePrefix)
+{
+ SetMemoryMode( (VISU::ColoredPrs3dCache::MemoryMode)VISU::Storable::FindValue( theMap, "myMemoryMode" ).toInt() );
+ SetLimitedMemory( VISU::Storable::FindValue( theMap, "myLimitedMemory" ).toInt() );
+
+ return this;
+}
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::ColoredPrs3dCache_i
+::Restore(SALOMEDS::SObject_ptr theSObject,
+ const string& thePrefix,
+ const Storable::TRestoringMap& theMap)
+{
+ SALOMEDS::Study_var aStudy = theSObject->GetStudy();
+ VISU::ColoredPrs3dCache_i* aCache = new VISU::ColoredPrs3dCache_i(aStudy, false);
+ return aCache->Restore(theSObject,theMap,thePrefix);
+}
--- /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_ColoredPrs3dCache_i.hh
+// Author : Oleg UVAROV
+// Module : VISU
+
+#ifndef VISU_ColoredPrs3dCache_i_HeaderFile
+#define VISU_ColoredPrs3dCache_i_HeaderFile
+
+#include "VISU_ColoredPrs3dFactory.hh"
+
+#include "SALOME_GenericObjPointer.hh"
+
+namespace VISU
+{
+ class Result_i;
+ class ColoredPrs3d_i;
+ class ColoredPrs3dHolder_i;
+
+ struct TPrs3dPtr: SALOME::GenericObjPtr<ColoredPrs3d_i>
+ {
+ typedef SALOME::GenericObjPtr<ColoredPrs3d_i> TSuperClass;
+
+ //! Initialize smart pointer to NULL.
+ TPrs3dPtr():
+ TSuperClass()
+ {}
+
+ //! Initialize smart pointer to given object (TSGenericObj must be complete).
+ TPrs3dPtr(ColoredPrs3d_i* thePointer):
+ TSuperClass(thePointer)
+ {}
+
+ /*!
+ Initialize smart pointer with a new reference to the same object
+ referenced by given smart pointer.
+ */
+ TPrs3dPtr(const TPrs3dPtr& thePointer):
+ TSuperClass(thePointer)
+ {}
+
+
+ /*!
+ Assign object to reference. This removes any reference to an old
+ object.
+ */
+ TPrs3dPtr&
+ operator=(const TPrs3dPtr& thePointer)
+ {
+ TSuperClass::operator=(thePointer);
+ return *this;
+ }
+
+ /*!
+ Assign object to reference. This removes any reference to an old
+ object.
+ */
+ TPrs3dPtr&
+ operator=(ColoredPrs3d_i* thePointer)
+ {
+ TSuperClass::operator=(thePointer);
+ return *this;
+ }
+
+ //! Get the contained pointer.
+ ColoredPrs3d_i*
+ get() const
+ {
+ ColoredPrs3d_i* aColoredPrs3d = TSuperClass::get();
+ // To implement postponed restoring of the presentation
+ if(aColoredPrs3d)
+ aColoredPrs3d->InitFromRestoringState();
+ return aColoredPrs3d;
+ }
+ };
+
+ typedef std::deque<TPrs3dPtr> TLastVisitedPrsList;
+
+ typedef std::string THolderEntry;
+ typedef std::map<THolderEntry,TLastVisitedPrsList> TColoredPrs3dHolderMap;
+
+ /*!
+ * This interface is responsible for memory management of 3d presentations.
+ * One cache corresponds to one study.
+ */
+ class ColoredPrs3dCache_i : public virtual POA_VISU::ColoredPrs3dCache,
+ public virtual SALOME::GenericObj_i,
+ public virtual RemovableObject_i
+ {
+ ColoredPrs3dCache_i();
+ ColoredPrs3dCache_i(const ColoredPrs3dCache_i&);
+ public:
+ //----------------------------------------------------------------------------
+ //! A constructor to create an instance of the class
+ explicit
+ ColoredPrs3dCache_i(SALOMEDS::Study_ptr theStudy,
+ bool thePublishInStudy = true);
+
+ virtual
+ ~ColoredPrs3dCache_i();
+
+ //----------------------------------------------------------------------------
+ /*! Creates ColoredPrs3dHolder */
+ virtual
+ VISU::ColoredPrs3dHolder_ptr
+ CreateHolder(VISU::VISUType theType,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput);
+
+ //----------------------------------------------------------------------------
+ /*! Gets a memory which is required to create a holder. */
+ virtual
+ VISU::ColoredPrs3dCache::EnlargeType
+ GetRequiredMemory(VISU::VISUType theType,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ CORBA::Float& theRequiredMemory);
+
+ //----------------------------------------------------------------------------
+ //! Sets a memory mode.
+ virtual
+ void
+ SetMemoryMode(VISU::ColoredPrs3dCache::MemoryMode theMode);
+
+ virtual
+ VISU::ColoredPrs3dCache::MemoryMode
+ GetMemoryMode();
+
+ //----------------------------------------------------------------------------
+ //! Sets a memory size for limited mode.
+ virtual
+ void
+ SetLimitedMemory(CORBA::Float theMemorySize);
+
+ virtual
+ CORBA::Float
+ GetLimitedMemory();
+
+ virtual
+ CORBA::Float
+ GetMemorySize();
+
+ virtual
+ CORBA::Float
+ GetDeviceMemorySize();
+
+ //----------------------------------------------------------------------------
+ virtual
+ VISU::VISUType
+ GetType()
+ {
+ return VISU::TCOLOREDPRS3DCACHE;
+ }
+
+ virtual
+ void
+ RemoveFromStudy();
+
+ static
+ std::string
+ GetFolderName();
+
+ virtual
+ const char*
+ GetComment() const;
+
+ virtual
+ void
+ ToStream(std::ostringstream&);
+
+ virtual
+ Storable*
+ Restore(SALOMEDS::SObject_ptr theSObject,
+ const Storable::TRestoringMap& theMap,
+ const std::string& thePrefix);
+
+ static
+ Storable*
+ Restore(SALOMEDS::SObject_ptr theSObject,
+ const std::string& thePrefix,
+ const Storable::TRestoringMap& theMap);
+
+ //----------------------------------------------------------------------------
+ //! Finds or creates instance of the ColoredPrs3dCache in the given SALOMEDS::Study
+ static
+ VISU::ColoredPrs3dCache_i*
+ GetInstance_i(SALOMEDS::Study_ptr theStudy);
+
+ static
+ VISU::ColoredPrs3dCache_ptr
+ GetInstance(SALOMEDS::Study_ptr theStudy);
+
+ //! Creates corresponding ColoredPrs3d instance and apply the BasicInput
+ VISU::ColoredPrs3d_i*
+ CreateColoredPrs3d(VISU::VISUType theType,
+ VISU::ColoredPrs3dHolder::BasicInput theInput);
+
+ //! Registers the given ColoredPrs3d instance for the ColoredPrs3dHolder
+ VISU::ColoredPrs3d_i*
+ RegisterInHolder(VISU::ColoredPrs3d_i* thePrs3d,
+ const std::string& theHolderEntry);
+
+ //! Creates and registers corresponding ColoredPrs3d instance for the ColoredPrs3dHolder
+ VISU::ColoredPrs3d_i*
+ CreatePrs(VISU::VISUType theType,
+ VISU::ColoredPrs3dHolder::BasicInput theInput,
+ VISU::ColoredPrs3dHolder_i* theHolder);
+
+ TLastVisitedPrsList&
+ GetLastVisitedPrsList(VISU::ColoredPrs3dHolder_i* theHolder);
+
+ TPrs3dPtr
+ GetLastVisitedPrs(VISU::ColoredPrs3dHolder_i* theHolder);
+
+ bool
+ UpdateLastVisitedPrs(VISU::ColoredPrs3dHolder_i* theHolder,
+ VISU::ColoredPrs3d_i* thePrs,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ VISU::View3D_ptr theView3D);
+
+ //! Unregister the holder instance from cache
+ void
+ RemoveHolder(VISU::ColoredPrs3dHolder_i* theHolder);
+
+ TColoredPrs3dHolderMap
+ GetHolderMap() { return myHolderMap; }
+
+ public:
+ static const std::string myComment;
+
+ protected:
+ //----------------------------------------------------------------------------
+ virtual int
+ IsPossible(VISU::VISUType theType,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ float& theMemoryToClear,
+ const std::string theHolderEntry);
+
+ TPrs3dPtr
+ FindPrsByInput(TLastVisitedPrsList& theLastVisitedPrsList,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput);
+
+ //----------------------------------------------------------------------------
+ void
+ ClearCache(float theMemory = 0);
+
+ bool
+ ClearMemory(CORBA::Float theRequiredMemory,
+ const std::string& theHolderEntry);
+
+ void
+ PrintCache();
+
+ private:
+ CORBA::Float myLimitedMemory;
+ VISU::ColoredPrs3dCache::MemoryMode myMemoryMode;
+
+ TColoredPrs3dHolderMap myHolderMap;
+ };
+
+
+ //----------------------------------------------------------------------------
+}
+
+#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_ColoredPrs3dCache_i.cc
+// Author : Oleg UVAROV
+// Module : VISU
+
+#include "VISU_ColoredPrs3dFactory.hh"
+#include "VISU_ColoredPrs3dCache_i.hh"
+
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+#define NO_CAS_CATCH
+#endif
+
+#include <Standard_Failure.hxx>
+
+#ifdef NO_CAS_CATCH
+#include <Standard_ErrorHandler.hxx>
+#else
+#include "CASCatch.hxx"
+#endif
+
+#ifdef _DEBUG_
+//static int MYDEBUG = 0;
+//#define _DEXCEPT_
+#else
+//static int MYDEBUG = 0;
+#endif
+
+
+namespace VISU
+{
+ //----------------------------------------------------------------------------
+ bool
+ CreatColoredPrs3d(ColoredPrs3d_i* theColoredPrs3d,
+ Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theIteration)
+ {
+#ifndef _DEXCEPT_
+#ifdef NO_CAS_CATCH
+ try{
+ OCC_CATCH_SIGNALS;
+#else
+ CASCatch_TRY{
+ try{
+#endif
+#endif
+ theColoredPrs3d->SetCResult(theResult);
+ theColoredPrs3d->SetMeshName(theMeshName.c_str());
+ theColoredPrs3d->SetEntity(theEntity);
+ theColoredPrs3d->SetFieldName(theFieldName.c_str());
+ theColoredPrs3d->SetTimeStampNumber(theIteration);
+ if(theColoredPrs3d->Apply(false))
+ return true;
+#ifndef _DEXCEPT_
+#ifdef NO_CAS_CATCH
+ }catch(Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ INFOS("Follow signal was occured :\n"<<aFail->GetMessageString());
+ }catch(std::exception& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was occured!");
+ }
+#else
+ }catch(std::exception& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was occured!");
+ }
+ }CASCatch_CATCH(Standard_Failure){
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ INFOS("Follow signal was occured :\n"<<aFail->GetMessageString());
+ }
+#endif
+#endif
+ return false;
+ }
+
+
+ //----------------------------------------------------------------------------
+ VISU::ColoredPrs3d_i*
+ CreatePrs3d_i(VISUType theType,
+ SALOMEDS::Study_ptr theStudy,
+ ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
+ {
+ switch(theType){
+ case TSCALARMAP:
+ return VISU::CreatePrs3dByEnum<TSCALARMAP>(theStudy, thePublishInStudyMode);
+ case TGAUSSPOINTS:
+ return VISU::CreatePrs3dByEnum<TGAUSSPOINTS>(theStudy, thePublishInStudyMode);
+ case TDEFORMEDSHAPE:
+ return VISU::CreatePrs3dByEnum<TDEFORMEDSHAPE>(theStudy, thePublishInStudyMode);
+ case TSCALARMAPONDEFORMEDSHAPE:
+ return VISU::CreatePrs3dByEnum<TSCALARMAPONDEFORMEDSHAPE>(theStudy, thePublishInStudyMode);
+ case TISOSURFACE:
+ return VISU::CreatePrs3dByEnum<TISOSURFACE>(theStudy, thePublishInStudyMode);
+ case TSTREAMLINES:
+ return VISU::CreatePrs3dByEnum<TSTREAMLINES>(theStudy, thePublishInStudyMode);
+ case TPLOT3D:
+ return VISU::CreatePrs3dByEnum<TPLOT3D>(theStudy, thePublishInStudyMode);
+ case TCUTPLANES:
+ return VISU::CreatePrs3dByEnum<TCUTPLANES>(theStudy, thePublishInStudyMode);
+ case TCUTLINES:
+ return VISU::CreatePrs3dByEnum<TCUTLINES>(theStudy, thePublishInStudyMode);
+ case TVECTORS:
+ return VISU::CreatePrs3dByEnum<TVECTORS>(theStudy, thePublishInStudyMode);
+ }
+ return NULL;
+ }
+
+
+ //----------------------------------------------------------------------------
+ VISU::ColoredPrs3dCache::EnlargeType
+ GetRequiredCacheMemory(VISU::VISUType theType,
+ VISU::Result_ptr theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theIteration,
+ CORBA::Float& theUsedMemory,
+ CORBA::Float& theRequiredMemory)
+ {
+ VISU::ColoredPrs3dCache::EnlargeType anEnlargeType = VISU::ColoredPrs3dCache::NO_ENLARGE;
+ if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
+ VISU::ColoredPrs3dHolder::BasicInput anInput;
+ anInput.myResult = VISU::Result::_duplicate(theResult);
+ anInput.myMeshName = theMeshName.c_str();
+ anInput.myEntity = theEntity;
+ anInput.myFieldName = theFieldName.c_str();
+ anInput.myTimeStampNumber = theIteration;
+
+ SALOMEDS::Study_var aStudy = aResult->GetStudyDocument();
+ VISU::ColoredPrs3dCache_var aCache = ColoredPrs3dCache_i::GetInstance(aStudy);
+
+ theUsedMemory = aCache->GetMemorySize();
+ anEnlargeType = aCache->GetRequiredMemory(theType, anInput, theRequiredMemory);
+ }
+ return anEnlargeType;
+ }
+
+
+ //----------------------------------------------------------------------------
+ VISU::ColoredPrs3d_i*
+ CreateHolder2GetDeviceByEnum(VISU::VISUType theType,
+ VISU::Result_ptr theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theIteration,
+ VISU::ColoredPrs3dCache::EnlargeType theEnlargeType,
+ CORBA::Float theRequiredMemory)
+ {
+ VISU::ColoredPrs3d_i* aColoredPrs3d = NULL;
+ if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
+ VISU::ColoredPrs3dHolder::BasicInput anInput;
+ anInput.myResult = VISU::Result::_duplicate(theResult);
+ anInput.myMeshName = theMeshName.c_str();
+ anInput.myEntity = theEntity;
+ anInput.myFieldName = theFieldName.c_str();
+ anInput.myTimeStampNumber = theIteration;
+
+ SALOMEDS::Study_var aStudy = aResult->GetStudyDocument();
+ VISU::ColoredPrs3dCache_var aCache = ColoredPrs3dCache_i::GetInstance(aStudy);
+
+ if( theEnlargeType == VISU::ColoredPrs3dCache::ENLARGE )
+ aCache->SetLimitedMemory( theRequiredMemory );
+
+ VISU::ColoredPrs3dHolder_var aHolder = aCache->CreateHolder(theType, anInput);
+
+ if( CORBA::is_nil(aHolder) )
+ return NULL;
+
+ VISU::ColoredPrs3d_var aPrs3d = aHolder->GetDevice();
+ aColoredPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>(GetServant(aPrs3d).in());
+ }
+ return aColoredPrs3d;
+ }
+
+
+ //----------------------------------------------------------------------------
+ size_t
+ CheckIsPossible(VISU::VISUType theType,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ bool theMemoryCheck)
+ {
+ size_t aMemory = 0;
+ switch(theType){
+ case TSCALARMAP:
+ aMemory = CheckIsPossible<TSCALARMAP>(theInput, theMemoryCheck);
+ break;
+ case TGAUSSPOINTS:
+ aMemory = CheckIsPossible<TGAUSSPOINTS>(theInput, theMemoryCheck);
+ break;
+ case TDEFORMEDSHAPE:
+ aMemory = CheckIsPossible<TDEFORMEDSHAPE>(theInput, theMemoryCheck);
+ break;
+ case TSCALARMAPONDEFORMEDSHAPE:
+ aMemory = CheckIsPossible<TSCALARMAPONDEFORMEDSHAPE>(theInput, theMemoryCheck);
+ break;
+ case TISOSURFACE:
+ aMemory = CheckIsPossible<TISOSURFACE>(theInput, theMemoryCheck);
+ break;
+ case TSTREAMLINES:
+ aMemory = CheckIsPossible<TSTREAMLINES>(theInput, theMemoryCheck);
+ break;
+ case TPLOT3D:
+ aMemory = CheckIsPossible<TPLOT3D>(theInput, theMemoryCheck);
+ break;
+ case TCUTPLANES:
+ aMemory = CheckIsPossible<TCUTPLANES>(theInput, theMemoryCheck);
+ break;
+ case TCUTLINES:
+ aMemory = CheckIsPossible<TCUTLINES>(theInput, theMemoryCheck);
+ break;
+ case TVECTORS:
+ aMemory = CheckIsPossible<TVECTORS>(theInput, theMemoryCheck);
+ break;
+ }
+ return aMemory;
+ }
+
+
+ //----------------------------------------------------------------------------
+}
--- /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_ColoredPrs3dCache_i.hh
+// Author : Oleg UVAROV
+// Module : VISU
+
+#ifndef VISU_ColoredPrs3dFactory_HeaderFile
+#define VISU_ColoredPrs3dFactory_HeaderFile
+
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(VISU_Gen)
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+#include "VISU_ScalarMapOnDeformedShape_i.hh"
+#include "VISU_Plot3D_i.hh"
+#include "VISU_GaussPoints_i.hh"
+#include "VISU_StreamLines_i.hh"
+#include "VISU_Vectors_i.hh"
+#include "VISU_CutLines_i.hh"
+#include "VISU_CutPlanes_i.hh"
+#include "VISU_DeformedShape_i.hh"
+#include "VISU_IsoSurfaces_i.hh"
+#include "VISU_ScalarMap_i.hh"
+#include "VISU_ColoredPrs3d_i.hh"
+#include "VISU_Result_i.hh"
+#include "VISU_TypeList.hxx"
+
+namespace VISU
+{
+ namespace TL
+ {
+ //----------------------------------------------------------------------------
+ typedef TList<ScalarMapOnDeformedShape_i,
+ TList<DeformedShape_i,
+ TList<StreamLines_i,
+ TList<GaussPoints_i,
+ TList<ScalarMap_i,
+ TList<IsoSurfaces_i,
+ TList<CutPlanes_i,
+ TList<CutLines_i,
+ TList<Vectors_i,
+ TList<Plot3D_i,
+ TNullType> > > > > > > > > >
+ TColoredPrs3dTypeList;
+
+
+ typedef TList<TInt2Type<TSCALARMAPONDEFORMEDSHAPE>,
+ TList<TInt2Type<TDEFORMEDSHAPE>,
+ TList<TInt2Type<TSTREAMLINES>,
+ TList<TInt2Type<TGAUSSPOINTS>,
+ TList<TInt2Type<TSCALARMAP>,
+ TList<TInt2Type<TISOSURFACE>,
+ TList<TInt2Type<TCUTPLANES>,
+ TList<TInt2Type<TCUTLINES>,
+ TList<TInt2Type<TVECTORS>,
+ TList<TInt2Type<TPLOT3D>,
+ TNullType> > > > > > > > > >
+ TColoredPrs3dEnumList;
+
+
+ //----------------------------------------------------------------------------
+ template <unsigned int type_enum>
+ struct TColoredEnum2Type
+ {
+ typedef typename TTypeAt<TColoredPrs3dTypeList, TIndexOf<TColoredPrs3dEnumList, TInt2Type<type_enum> >::value >::TResult TResult;
+ };
+
+ //----------------------------------------------------------------------------
+ template <class T>
+ struct TColoredType2Enum
+ {
+ typedef typename TTypeAt<TColoredPrs3dEnumList, TIndexOf<TColoredPrs3dTypeList, T>::value >::TResult TResult;
+ };
+
+ }
+
+ //----------------------------------------------------------------------------
+ template<typename TPrs3d_i>
+ ColoredPrs3d_i*
+ CreatePrs3dByType(SALOMEDS::Study_ptr theStudy,
+ ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
+ {
+ if(!theStudy->GetProperties()->IsLocked()){
+ typedef typename TPrs3d_i::TInterface TPrs3d;
+ if(TPrs3d_i* aPresent = new TPrs3d_i(thePublishInStudyMode)){
+ return aPresent;
+ }
+ }
+ return NULL;
+ }
+
+
+ //----------------------------------------------------------------------------
+ template<unsigned int type_enum>
+ ColoredPrs3d_i*
+ CreatePrs3dByEnum(SALOMEDS::Study_ptr theStudy,
+ ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
+ {
+ typedef typename TL::TColoredEnum2Type<type_enum>::TResult TColoredPrs3d;
+ return CreatePrs3dByType<TColoredPrs3d>(theStudy,
+ thePublishInStudyMode);
+ };
+
+
+ //----------------------------------------------------------------------------
+ ColoredPrs3d_i*
+ CreatePrs3d_i(VISUType theType,
+ SALOMEDS::Study_ptr theStudy,
+ ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode);
+
+
+ //----------------------------------------------------------------------------
+ bool
+ CreatColoredPrs3d(ColoredPrs3d_i* theColoredPrs3d,
+ Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theIteration);
+
+
+ //----------------------------------------------------------------------------
+ //Create 3D collored Presentation Of Different Types
+ template<typename TPrs3d_i> TPrs3d_i*
+ CreatePrs3d(Result_ptr theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
+ {
+ typedef typename TPrs3d_i::TInterface TPrs3d;
+ typename TPrs3d::_var_type aPrs3d;
+
+ if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
+ SALOMEDS::Study_var aStudy = aResult->GetStudyDocument();
+ if(aStudy->GetProperties()->IsLocked())
+ return NULL;
+
+ if(TPrs3d_i::IsPossible(aResult, theMeshName, theEntity, theFieldName, theTimeStampNumber, true)){
+ TPrs3d_i* aPresent = new TPrs3d_i(ColoredPrs3d_i::EPublishUnderTimeStamp);
+
+ if(CreatColoredPrs3d(aPresent, aResult, theMeshName, theEntity, theFieldName, theTimeStampNumber))
+ return aPresent;
+
+ aPresent->_remove_ref();
+ }
+ }
+ return NULL;
+ }
+
+
+ //----------------------------------------------------------------------------
+ template<typename TPrs3d_i>
+ typename TPrs3d_i::TInterface::_var_type
+ Prs3dOnField(Result_ptr theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
+ {
+ if(TPrs3d_i* aPrs3d = CreatePrs3d<TPrs3d_i>(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber))
+ return aPrs3d->_this();
+ typedef typename TPrs3d_i::TInterface TPrs3d;
+ return TPrs3d::_nil();
+ }
+
+
+ //----------------------------------------------------------------------------
+ //! Gets the memory required for cache
+ VISU::ColoredPrs3dCache::EnlargeType
+ GetRequiredCacheMemory(VISU::VISUType theType,
+ VISU::Result_ptr theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ CORBA::Float& theUsedMemory,
+ CORBA::Float& theRequiredMemory);
+
+
+ //----------------------------------------------------------------------------
+ //! Gets the memory required for cache
+ template<class TColoredPrs3d_i>
+ VISU::ColoredPrs3dCache::EnlargeType
+ GetRequiredCacheMemory(VISU::Result_ptr theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ CORBA::Float& theUsedMemory,
+ CORBA::Float& theRequiredMemory)
+ {
+ typedef typename TL::TColoredType2Enum<TColoredPrs3d_i>::TResult TEnum;
+ VISU::VISUType aColoredPrs3dType = VISU::VISUType(TEnum::value);
+ return GetRequiredCacheMemory(aColoredPrs3dType,
+ theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber,
+ theUsedMemory,
+ theRequiredMemory);
+ }
+
+
+ //----------------------------------------------------------------------------
+ //! Creates ColoredPrs3dHolder by enumeration value and gets its first device
+ ColoredPrs3d_i*
+ CreateHolder2GetDeviceByEnum(VISU::VISUType theType,
+ VISU::Result_ptr theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ VISU::ColoredPrs3dCache::EnlargeType theEnlargeType,
+ CORBA::Float theRequiredMemory);
+
+
+ //----------------------------------------------------------------------------
+ //! Creates ColoredPrs3dHolder by type and gets its first device
+ template<class TColoredPrs3d_i>
+ TColoredPrs3d_i*
+ CreateHolder2GetDeviceByType(VISU::Result_ptr theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ VISU::ColoredPrs3dCache::EnlargeType theEnlargeType,
+ CORBA::Float theRequiredMemory)
+ {
+ typedef typename TL::TColoredType2Enum<TColoredPrs3d_i>::TResult TEnum;
+ VISU::VISUType aColoredPrs3dType = VISU::VISUType(TEnum::value);
+ ColoredPrs3d_i* aColoredPrs3d = CreateHolder2GetDeviceByEnum(aColoredPrs3dType,
+ theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber,
+ theEnlargeType,
+ theRequiredMemory);
+ return dynamic_cast<TColoredPrs3d_i*>(aColoredPrs3d);
+ }
+
+
+ //----------------------------------------------------------------------------
+ template<unsigned int colored_prs3d_type_enum>
+ struct TSameAsFactory
+ {
+ typedef typename TL::TColoredEnum2Type<colored_prs3d_type_enum>::TResult TColoredPrs3d;
+
+ void
+ Copy(ColoredPrs3d_i* theColoredPrs3dTo, ColoredPrs3d_i* theColoredPrs3dFrom)
+ {
+ theColoredPrs3dTo->SetCResult(theColoredPrs3dFrom->GetCResult());
+ theColoredPrs3dTo->SetMeshName(theColoredPrs3dFrom->GetCMeshName().c_str());
+ theColoredPrs3dTo->SetEntity(theColoredPrs3dFrom->GetEntity());
+ theColoredPrs3dTo->SetFieldName(theColoredPrs3dFrom->GetCFieldName().c_str());
+ theColoredPrs3dTo->SetTimeStampNumber(theColoredPrs3dFrom->GetTimeStampNumber());
+ theColoredPrs3dTo->SameAs(theColoredPrs3dFrom);
+ }
+
+ TColoredPrs3d*
+ Create(ColoredPrs3d_i* theColoredPrs3d,
+ ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
+ {
+ TColoredPrs3d* aSameColoredPrs3d = new TColoredPrs3d(thePublishInStudyMode);
+ Copy(aSameColoredPrs3d, theColoredPrs3d);
+ return aSameColoredPrs3d;
+ }
+ };
+
+ //----------------------------------------------------------------------------
+ //! Check is possible to create ColoredPrs3dHolder with the given input
+ size_t
+ CheckIsPossible(VISU::VISUType theType,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ bool theMemoryCheck);
+
+ //----------------------------------------------------------------------------
+ //! Check is possible to create ColoredPrs3dHolder with the given input
+ template<unsigned int colored_prs3d_type_enum>
+ size_t
+ CheckIsPossible(const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ bool theMemoryCheck)
+ {
+ VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>( VISU::GetServant(theInput.myResult).in() );
+ std::string aMeshName = theInput.myMeshName.in();
+ VISU::Entity anEntity = theInput.myEntity;
+ std::string aFieldName = theInput.myFieldName.in();
+ CORBA::Long aTimeStampNumber = theInput.myTimeStampNumber;
+
+ typedef typename VISU::TL::TColoredEnum2Type<colored_prs3d_type_enum>::TResult TColoredPrs3d;
+ return TColoredPrs3d::IsPossible(aResult,
+ aMeshName,
+ anEntity,
+ aFieldName,
+ aTimeStampNumber,
+ theMemoryCheck);
+ }
+
+ //----------------------------------------------------------------------------
+}
+
+#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_ColoredPrs3dHolder_i.cc
+// Author : Oleg UVAROV
+// Module : VISU
+
+#include "VISU_ColoredPrs3dHolder_i.hh"
+
+#include "VISU_ColoredPrs3dCache_i.hh"
+#include "VISU_ColoredPrs3d_i.hh"
+
+#include "SALOME_Event.hxx"
+
+using namespace VISU;
+using namespace std;
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//---------------------------------------------------------------
+int VISU::ColoredPrs3dHolder_i::myNbHolders = 0;
+
+//---------------------------------------------------------------
+QString
+VISU::ColoredPrs3dHolder_i
+::GenerateName()
+{
+ return VISU::GenerateName("Holder",myNbHolders++);
+}
+
+//----------------------------------------------------------------------------
+const string VISU::ColoredPrs3dHolder_i::myComment = "COLOREDPRS3DHOLDER";
+
+const char*
+VISU::ColoredPrs3dHolder_i
+::GetComment() const
+{
+ return myComment.c_str();
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dHolder_i
+::ColoredPrs3dHolder_i(VISU::ColoredPrs3dCache_i& theCache) :
+ PrsObject_i(theCache.GetStudyDocument()),
+ myCache(theCache)
+{
+ if(MYDEBUG) MESSAGE("ColoredPrs3dHolder_i::ColoredPrs3dHolder_i - this = "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dHolder_i
+::~ColoredPrs3dHolder_i()
+{
+ if(MYDEBUG) MESSAGE("ColoredPrs3dHolder_i::~ColoredPrs3dHolder_i - this = "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3dHolder_i
+::PublishInStudy(const std::string& theName,
+ const std::string& theIconName,
+ const std::string& theComment)
+{
+ SetName(theName, false);
+ CORBA::String_var anIOR = GetID();
+ std::string aFatherEntry = myCache.GetEntry();
+ CreateAttributes(GetStudyDocument(),
+ aFatherEntry,
+ theIconName,
+ anIOR.in(),
+ GetName(),
+ "",
+ theComment,
+ true);
+}
+
+//----------------------------------------------------------------------------
+struct TApplyEvent: public SALOME_Event
+{
+ VISU::ColoredPrs3dCache_i& myCache;
+ VISU::ColoredPrs3dHolder_i* myHolder;
+ VISU::ColoredPrs3d_i* myPrs3d;
+ VISU::ColoredPrs3dHolder::BasicInput myInput;
+ VISU::View3D_ptr myView3D;
+
+ typedef CORBA::Boolean TResult;
+ TResult myResult;
+
+ TApplyEvent(VISU::ColoredPrs3dCache_i& theCache,
+ VISU::ColoredPrs3dHolder_i* theHolder,
+ VISU::ColoredPrs3d_i* thePrs3d,
+ VISU::ColoredPrs3dHolder::BasicInput theInput,
+ VISU::View3D_ptr theView3D):
+ myCache(theCache),
+ myHolder(theHolder),
+ myPrs3d(thePrs3d),
+ myInput(theInput),
+ myView3D(theView3D)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ myResult = myCache.UpdateLastVisitedPrs(myHolder, myPrs3d, myInput, myView3D);
+ }
+};
+
+//----------------------------------------------------------------------------
+CORBA::Boolean
+VISU::ColoredPrs3dHolder_i
+::Apply(VISU::ColoredPrs3d_ptr thePrs3d,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ VISU::View3D_ptr theView3D)
+{
+
+ VISU::ColoredPrs3d_i* aPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>( VISU::GetServant(thePrs3d).in() );
+ return ProcessEvent(new TApplyEvent(myCache, this, aPrs3d, theInput, theView3D));
+ //return myCache.UpdateLastVisitedPrs(this, aPrs3d, theInput, theView3D);
+}
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d_i*
+VISU::ColoredPrs3dHolder_i
+::GetPrs3dDevice()
+{
+ return myCache.GetLastVisitedPrs(this);
+}
+
+
+VISU::ColoredPrs3d_ptr
+VISU::ColoredPrs3dHolder_i
+::GetDevice()
+{
+ return GetPrs3dDevice()->_this();
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d::TimeStampsRange*
+VISU::ColoredPrs3dHolder_i
+::GetTimeStampsRange()
+{
+ if( VISU::ColoredPrs3d_ptr aDevice = GetDevice() )
+ return aDevice->GetTimeStampsRange();
+
+ return NULL;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dHolder::BasicInput*
+VISU::ColoredPrs3dHolder_i
+::GetBasicInput()
+{
+ if( VISU::ColoredPrs3d_ptr aDevice = GetDevice() )
+ {
+ VISU::ColoredPrs3d_i* aPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>( VISU::GetServant(aDevice).in() );
+ if( aPrs3d )
+ return aPrs3d->GetBasicInput();
+ }
+
+ return NULL;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3dCache_ptr
+VISU::ColoredPrs3dHolder_i
+::GetCache()
+{
+ return myCache._this();
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Float
+VISU::ColoredPrs3dHolder_i
+::GetMemorySize()
+{
+ return GetDevice()->GetMemorySize();
+}
+
+
+//----------------------------------------------------------------------------
+VISU::VISUType
+VISU::ColoredPrs3dHolder_i
+::GetPrsType()
+{
+ return GetPrs3dDevice()->GetType();
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3dHolder_i
+::RemoveFromStudy()
+{
+ myCache.RemoveHolder(this);
+ CORBA::String_var anIOR = GetID();
+ SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectIOR(anIOR.in());
+ VISU::RemoveFromStudy(aSObject, false);
+ Destroy();
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3dHolder_i
+::ToStream(std::ostringstream& theStr)
+{
+ Storable::DataToStream( theStr, "myPrsType", GetPrsType() );
+ GetPrs3dDevice()->ToStream(theStr);
+}
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::ColoredPrs3dHolder_i
+::Restore(SALOMEDS::SObject_ptr theSObject,
+ const string& thePrefix,
+ const Storable::TRestoringMap& theMap)
+{
+ using namespace VISU;
+ SALOMEDS::Study_var aStudy = theSObject->GetStudy();
+ VISUType aType = VISUType(Storable::FindValue(theMap,"myPrsType").toInt());
+ if(ColoredPrs3d_i* aColoredPrs3d = CreatePrs3d_i(aType, aStudy, ColoredPrs3d_i::EDoNotPublish)){
+ if(ColoredPrs3dCache_i* aCache = ColoredPrs3dCache_i::GetInstance_i(aStudy))
+ if(ColoredPrs3dHolder_i* aHolder = new ColoredPrs3dHolder_i(*aCache)){
+ // To postpone restoring of the device
+ aColoredPrs3d->SaveRestoringState(aStudy, theMap);
+ CORBA::String_var anEntry = theSObject->GetID();
+ aCache->RegisterInHolder(aColoredPrs3d, anEntry.in());
+ return aHolder;
+ }
+ }
+ return NULL;
+}
--- /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_ColoredPrs3dHolder_i.hxx
+// Author : Oleg UVAROV
+// Module : VISU
+
+#ifndef VISU_ColoredPrs3dHolder_i_HeaderFile
+#define VISU_ColoredPrs3dHolder_i_HeaderFile
+
+#include "VISU_PrsObject_i.hh"
+
+#include "SALOME_GenericObj_i.hh"
+
+namespace VISU
+{
+ class ColoredPrs3d_i;
+ class ColoredPrs3dCache_i;
+
+ /*!
+ * Interface of 3d presentation's holder, which represents colored 3d presentations,
+ * created on fields. It is publishing in the object browser in a separate folder
+ * and can be controled by viewer's slider.
+ */
+ class ColoredPrs3dHolder_i : public virtual POA_VISU::ColoredPrs3dHolder,
+ public virtual SALOME::GenericObj_i,
+ public virtual PrsObject_i
+ {
+ ColoredPrs3dHolder_i();
+ ColoredPrs3dHolder_i(const ColoredPrs3dHolder_i&);
+
+ friend class ColoredPrs3dCache_i;
+ public:
+ //----------------------------------------------------------------------------
+ //! A constructor to create an instance of the class
+ explicit
+ ColoredPrs3dHolder_i(VISU::ColoredPrs3dCache_i& theCache);
+
+ virtual
+ ~ColoredPrs3dHolder_i();
+
+ //----------------------------------------------------------------------------
+ //! Apply input parameters to last visited presentation in the cache.
+ virtual
+ CORBA::Boolean
+ Apply(VISU::ColoredPrs3d_ptr thePrs3d,
+ const VISU::ColoredPrs3dHolder::BasicInput& theInput,
+ VISU::View3D_ptr theView3D);
+
+ //----------------------------------------------------------------------------
+ //! Gets the last visited presentation in the cache.
+ VISU::ColoredPrs3d_i*
+ GetPrs3dDevice();
+
+ //! Gets the last visited presentation in the cache.
+ virtual
+ VISU::ColoredPrs3d_ptr
+ GetDevice();
+
+ //----------------------------------------------------------------------------
+ //! Gets TimeStampsRange information from the last visited presentation.
+ virtual
+ VISU::ColoredPrs3d::TimeStampsRange*
+ GetTimeStampsRange();
+
+ //----------------------------------------------------------------------------
+ //! Gets input parameters of the last visited presentation.
+ VISU::ColoredPrs3dHolder::BasicInput*
+ GetBasicInput();
+
+ //----------------------------------------------------------------------------
+ //! Gets a ColoredPrs3dCache, to which the holder belongs
+ VISU::ColoredPrs3dCache_ptr
+ GetCache();
+
+ //----------------------------------------------------------------------------
+ //! Gets memory size actually used by the holder (Mb).
+ virtual
+ CORBA::Float
+ GetMemorySize();
+
+ //----------------------------------------------------------------------------
+ virtual
+ VISU::VISUType
+ GetType()
+ {
+ return VISU::TCOLOREDPRS3DHOLDER;
+ }
+
+ virtual
+ VISU::VISUType
+ GetPrsType();
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ RemoveFromStudy();
+
+ virtual
+ const char*
+ GetComment() const;
+
+ virtual
+ void
+ ToStream(std::ostringstream&);
+
+ static
+ Storable*
+ Restore(SALOMEDS::SObject_ptr theSObject,
+ const std::string& thePrefix,
+ const Storable::TRestoringMap& theMap);
+
+ virtual
+ QString
+ GenerateName();
+
+ public:
+ static const std::string myComment;
+
+ //----------------------------------------------------------------------------
+ private:
+ void
+ PublishInStudy(const std::string& theName,
+ const std::string& theIconName,
+ const std::string& theComment);
+
+ VISU::ColoredPrs3dCache_i& myCache;
+ static int myNbHolders;
+ };
+}
+
+#endif
#include "VISU_ColoredPrs3d_i.hh"
-#include "VISU_ScalarMapPL.hxx"
+#include "VISU_ColoredPL.hxx"
#include "VISU_Result_i.hh"
#include "VISU_Convertor.hxx"
#include "SUIT_ResourceMgr.h"
#include "SALOME_Event.hxx"
+#include <strstream>
#include <vtkMapper.h>
-
-using namespace VISU;
-using namespace std;
+#include <vtkDataSet.h>
#ifdef _DEBUG_
static int MYDEBUG = 0;
#endif
-//============================================================================
-VISU::ColoredPrs3d_i::
-ColoredPrs3d_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theAddToStudy),
- myScalarMapPL(NULL),
- myIsFixedRange(false)
-{}
+//---------------------------------------------------------------
+namespace
+{
+ std::string
+ FindOrCreate3DPresentationsFolder(SALOMEDS::Study_ptr theStudy)
+ {
+ static char aFolderName[] = "3D Presentations";
+ CORBA::String_var anEntry;
+ SALOMEDS::SObject_var aSObject = theStudy->FindObject(aFolderName);
+ if(!CORBA::is_nil(aSObject) && aSObject->Depth() == 3){
+ anEntry = aSObject->GetID();
+ return anEntry.in();
+ }
+ SALOMEDS::SComponent_var aSComponent = VISU::FindOrCreateVisuComponent(theStudy);
+ CORBA::String_var aFatherEntry = aSComponent->GetID();
+ anEntry = VISU::CreateAttributes(theStudy,
+ aFatherEntry.in(),
+ "",
+ "",
+ aFolderName,
+ "",
+ "",
+ true).c_str();
+ return anEntry.in();
+ }
+}
+//---------------------------------------------------------------
VISU::ColoredPrs3d_i::
-ColoredPrs3d_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
- myScalarMapPL(NULL),
+ColoredPrs3d_i(EPublishInStudyMode thePublishInStudyMode) :
+ myPublishInStudyMode(thePublishInStudyMode),
+ myIsTimeStampFixed(thePublishInStudyMode == EPublishUnderTimeStamp),
+ myColoredPL(NULL),
myIsFixedRange(false)
{}
+//---------------------------------------------------------------
VISU::ColoredPrs3d_i
::~ColoredPrs3d_i()
{}
ProcessVoidEvent(new TRemoveFromStudy(this));
}
+//---------------------------------------------------------------
+bool
+VISU::ColoredPrs3d_i
+::SetInput(bool theReInit)
+{
+ try{
+ if(TSuperClass::SetInput(theReInit)){
+ if(CheckIsPossible()){
+ if(OnSetInput(theReInit)){
+ if(Create(GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber()))
+ return true;
+ }else
+ return true;
+ }
+ }
+ }catch(...){
+ }
+
+ return false;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::OnRestoreInput()
+{
+ TSuperClass::OnRestoreInput();
+ myEntity = myPreviousEntity;
+ myFieldName = myPreviousFieldName;
+ myTimeStampNumber = myPreviousTimeStampNumber;
+}
+
+
+//---------------------------------------------------------------
+bool
+VISU::ColoredPrs3d_i
+::OnSetInput(bool theReInit)
+{
+ myPreviousEntity = myEntity;
+ myPreviousFieldName = myFieldName;
+ myPreviousTimeStampNumber = myTimeStampNumber;
+
+ bool anIsCreatNew = !IsPipeLineExists();
+ if(anIsCreatNew)
+ CreatePipeLine(NULL); // to create proper pipeline
+
+ try{
+ DoSetInput(anIsCreatNew, theReInit);
+ }catch(std::exception& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ throw;
+ }catch(...){
+ INFOS("Unknown exception was occured!");
+ throw;
+ }
+
+ // To update title according to the new input
+ if(theReInit)
+ SetTitle(GetCFieldName().c_str());
+
+ return anIsCreatNew;
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetEntity(VISU::Entity theEntity)
+{
+ if(myEntity != theEntity){
+ myEntity = theEntity;
+ myParamsTime.Modified();
+ }
+}
+
+
+//---------------------------------------------------------------
+VISU::Entity
+VISU::ColoredPrs3d_i
+::GetEntity()
+{
+ return myEntity;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::TEntity
+VISU::ColoredPrs3d_i
+::GetTEntity() const
+{
+ return VISU::TEntity(int(myEntity));
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetFieldName(const char* theFieldName)
+{
+ if(myFieldName != theFieldName){
+ myFieldName = theFieldName;
+ myParamsTime.Modified();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+char*
+VISU::ColoredPrs3d_i
+::GetFieldName()
+{
+ return CORBA::string_dup(myFieldName.c_str());
+}
+
+
+//----------------------------------------------------------------------------
+std::string
+VISU::ColoredPrs3d_i
+::GetCFieldName() const
+{
+ return myFieldName;
+}
+
+
+//----------------------------------------------------------------------------
+const VISU::PField&
+VISU::ColoredPrs3d_i
+::GetField() const
+{
+ return myField;
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetField(VISU::PField theField)
+{
+ myField = theField;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetTimeStampNumber(CORBA::Long theTimeStampNumber)
+{
+ if(myTimeStampNumber != theTimeStampNumber){
+ myTimeStampNumber = theTimeStampNumber;
+ myParamsTime.Modified();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetTimeStampNumber()
+{
+ return myTimeStampNumber;
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetTimeStampNumberByIndex( CORBA::Long theIndex )
+{
+ VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = GetTimeStampsRange();
+ CORBA::Long aLength = aTimeStampsRange->length();
+
+ if( theIndex >= 0 && theIndex < aLength )
+ {
+ VISU::ColoredPrs3d::TimeStampInfo anInfo = aTimeStampsRange[ theIndex ];
+ return anInfo.myNumber;
+ }
+
+ return -1;
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetTimeStampIndexByNumber( CORBA::Long theNumber )
+{
+ VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = GetTimeStampsRange();
+ CORBA::Long aLength = aTimeStampsRange->length();
+
+ for( int index = 0; index < aLength; index++ )
+ {
+ VISU::ColoredPrs3d::TimeStampInfo anInfo = aTimeStampsRange[ index ];
+
+ if( anInfo.myNumber == theNumber )
+ return index;
+ }
+
+ return -1;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::PValForTime
+VISU::ColoredPrs3d_i
+::GetScalarValForTime() const
+{
+ VISU::TValField& aValField = GetField()->myValField;
+ PValForTime aValForTime;
+ VISU::TValField::iterator anIter = aValField.find(myTimeStampNumber);
+ if(anIter != aValField.end())
+ aValForTime = anIter->second;
+ return aValForTime;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d::TimeStampsRange*
+VISU::ColoredPrs3d_i
+::GetTimeStampsRange()
+{
+ VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = new VISU::ColoredPrs3d::TimeStampsRange();
+ VISU::TValField& aValField = GetField()->myValField;
+ if(IsTimeStampFixed()){
+ aTimeStampsRange->length(1);
+ PValForTime& aValForTime = aValField[GetTimeStampNumber()];
+ std::string aTime = VISU_Convertor::GenerateName(aValForTime->myTime);
+ VISU::ColoredPrs3d::TimeStampInfo anInfo;
+ anInfo.myNumber = GetTimeStampNumber();
+ anInfo.myTime = aTime.c_str();
+ aTimeStampsRange[0] = anInfo;
+ return aTimeStampsRange._retn();
+ }
+
+ // To exclude timstamps with repeated time
+ typedef std::map<std::string, long> TTimeStampsRange;
+ TTimeStampsRange aRange;
+ {
+ VISU::TValField::const_iterator anIter = aValField.begin();
+ for(; anIter != aValField.end(); anIter++){
+ vtkIdType aTimeStampNumber = anIter->first;
+ const PValForTime& aValForTime = anIter->second;
+ std::string aTime = VISU_Convertor::GenerateName(aValForTime->myTime);
+ aRange[aTime] = aTimeStampNumber;
+ }
+ }
+
+ // To sort timestamps according to their timestamp number
+ typedef std::map<long, std::string> TTimeStampsSortedRange;
+ TTimeStampsSortedRange aSortedRange;
+ {
+ TTimeStampsRange::const_iterator anIter = aRange.begin();
+ for(size_t aCounter = 0; anIter != aRange.end(); anIter++, aCounter++){
+ vtkIdType aTimeStampNumber = anIter->second;
+ const std::string& aTime = anIter->first;
+ aSortedRange[aTimeStampNumber] = aTime;
+ }
+ }
+
+ // To map the C++ data structures to the corresponding CORBA ones
+ {
+ aTimeStampsRange->length(aRange.size());
+ TTimeStampsSortedRange::const_iterator anIter = aSortedRange.begin();
+ for(size_t aCounter = 0; anIter != aSortedRange.end(); anIter++, aCounter++){
+ vtkIdType aTimeStampNumber = anIter->first;
+ const std::string& aTime = anIter->second;
+ VISU::ColoredPrs3d::TimeStampInfo anInfo;
+ anInfo.myNumber = aTimeStampNumber;
+ anInfo.myTime = aTime.c_str();
+ aTimeStampsRange[aCounter] = anInfo;
+ }
+ }
+ return aTimeStampsRange._retn();
+}
+
+CORBA::Float
+VISU::ColoredPrs3d_i
+::GetMemorySize()
+{
+ return TSuperClass::GetMemorySize();
+}
+
+VISU::ColoredPrs3dHolder::BasicInput*
+VISU::ColoredPrs3d_i
+::GetBasicInput()
+{
+ VISU::ColoredPrs3dHolder::BasicInput* aBasicInput = new VISU::ColoredPrs3dHolder::BasicInput();
+ aBasicInput->myResult = GetResultObject();
+ aBasicInput->myMeshName = GetMeshName();
+ aBasicInput->myEntity = GetEntity();
+ aBasicInput->myFieldName = GetFieldName();
+ aBasicInput->myTimeStampNumber = GetTimeStampNumber();
+
+ return aBasicInput;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetHolderEntry(const std::string& theEntry)
+{
+ myHolderEntry = theEntry;
+}
+
+
+//----------------------------------------------------------------------------
+std::string
+VISU::ColoredPrs3d_i
+::GetHolderEntry()
+{
+ return myHolderEntry;
+}
+
+
+//----------------------------------------------------------------------------
+std::string
+VISU::ColoredPrs3d_i
+::GetActorEntry()
+{
+ if(myHolderEntry != "")
+ return myHolderEntry;
+ return TSuperClass::GetActorEntry();
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Boolean
+VISU::ColoredPrs3d_i
+::IsTimeStampFixed()
+{
+ return myIsTimeStampFixed;
+}
+
+//----------------------------------------------------------------------------
+VISU::ColoredPrs3d_i::EPublishInStudyMode
+VISU::ColoredPrs3d_i
+::GetPublishInStudyMode()
+{
+ return myPublishInStudyMode;
+}
+
//---------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::SameAs(const Prs3d_i* theOrigin)
{
if(const ColoredPrs3d_i* aPrs3d = dynamic_cast<const ColoredPrs3d_i*>(theOrigin)){
- DoHook();
-
ColoredPrs3d_i* anOrigin = const_cast<ColoredPrs3d_i*>(aPrs3d);
- if(myMeshName == ""){
- myField = anOrigin->GetField();
- myMeshName = myField->myMeshName;
- myEntity = VISU::TEntity(anOrigin->GetEntity());//myField->myEntity;
- myIteration = anOrigin->GetIteration();
- myFieldName = anOrigin->GetFieldName();
- }
- Build(-1);
+
+ bool anIsCreatNew = OnSetInput(false);
+ if(anIsCreatNew)
+ Build(ESameAs);
TSuperClass::SameAs(theOrigin);
- SetScalarMode(anOrigin->GetScalarMode());
+ CORBA::Long aNbComp = GetField()->myNbComp;
+ CORBA::Long anOriginNbComp = anOrigin->GetField()->myNbComp;
+ if(anOriginNbComp < aNbComp)
+ SetScalarMode(0);
+ else
+ SetScalarMode(anOrigin->GetScalarMode());
+
SetNbColors(anOrigin->GetNbColors());
SetBarOrientation(anOrigin->GetBarOrientation());
SetPosition(anOrigin->GetPosX(), anOrigin->GetPosY());
SetSize(anOrigin->GetWidth(), anOrigin->GetHeight());
SetLabels(anOrigin->GetLabels());
- SetTitle(anOrigin->GetTitle());
-
+
+ SetTitle(anOrigin->GetTitle());
SetBoldTitle(anOrigin->IsBoldTitle());
SetItalicTitle(anOrigin->IsItalicTitle());
SetShadowTitle(anOrigin->IsShadowTitle());
SetLblFontType(anOrigin->GetLblFontType());
anOrigin->GetLabelColor(&r,&g,&b);
SetLabelColor(r,g,b);
+
+ UseFixedRange( anOrigin->IsRangeFixed() );
+ myIsTimeStampFixed = anOrigin->IsTimeStampFixed();
+
+ SetHolderEntry( anOrigin->GetHolderEntry() );
}
}
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::ColoredPrs3d_i
+::GetScalarMode()
+{
+ return myColoredPL->GetScalarMode();
+}
+
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SameAsParams(const ColoredPrs3d_i* theOrigin,
- const std::string& theMeshName, const std::string& theFieldName,
- VISU::Entity theEntity, int theIteration,
- bool theIsFixedRange)
+::SetScalarMode(CORBA::Long theScalarMode)
{
- myMeshName = theMeshName;
- myFieldName = theFieldName;
- myEntity = (VISU::TEntity)theEntity;
- myIteration = theIteration;
- int aScalarMode = (const_cast<ColoredPrs3d_i*>(theOrigin))->GetScalarMode();
+ CORBA::Long aNbComp = GetField()->myNbComp;
+ if(aNbComp == 1)
+ theScalarMode = 1;
+ else if(theScalarMode > aNbComp)
+ theScalarMode = 0;
- SameAs(theOrigin);
-
- myIsFixedRange = theIsFixedRange;
-
- Build(-1);
-
- SetScalarMode(aScalarMode); // mkr : IPAL14030
+ myColoredPL->SetScalarMode(theScalarMode);
+}
- Update();
+//----------------------------------------------------------------------------
+CORBA::Double
+VISU::ColoredPrs3d_i
+::GetMin()
+{
+ return myColoredPL->GetScalarRange()[0];
}
+//----------------------------------------------------------------------------
+CORBA::Double
+VISU::ColoredPrs3d_i
+::GetMax()
+{
+ return myColoredPL->GetScalarRange()[1];
+}
//----------------------------------------------------------------------------
-CORBA::Long
+void
VISU::ColoredPrs3d_i
-::GetScalarMode()
+::SetRange(CORBA::Double theMin, CORBA::Double theMax)
{
- return myScalarMapPL->GetScalarMode();
+ if(theMin > theMax)
+ return;
+ vtkFloatingPointType aScalarRange[2] = {theMin, theMax};
+ GetSpecificPL()->SetScalarRange(aScalarRange);
+ UseFixedRange(true);
}
+
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetScalarMode(CORBA::Long theScalarMode)
+::SetSourceRange()
{
- myScalarMapPL->SetScalarMode(theScalarMode);
+ if(IsTimeStampFixed())
+ GetSpecificPL()->SetSourceRange();
+ else{
+ TMinMax aTMinMax = GetField()->GetMinMax(GetScalarMode());
+ vtkFloatingPointType aScalarRange[2] = {aTMinMax.first, aTMinMax.second};
+ GetSpecificPL()->SetScalarRange(aScalarRange);
+ }
+ UseFixedRange(false);
}
+//----------------------------------------------------------------------------
CORBA::Double
VISU::ColoredPrs3d_i
-::GetMin()
+::GetSourceMin()
{
- return myScalarMapPL->GetScalarRange()[0];
+ if(IsTimeStampFixed()){
+ vtkFloatingPointType aRange[2];
+ GetSpecificPL()->GetSourceRange(aRange);
+ return aRange[0];
+ }else{
+ TMinMax aTMinMax = GetField()->GetMinMax(GetScalarMode());
+ return aTMinMax.first;
+ }
}
+//----------------------------------------------------------------------------
CORBA::Double
VISU::ColoredPrs3d_i
-::GetMax()
+::GetSourceMax()
{
- return myScalarMapPL->GetScalarRange()[1];
+ if(IsTimeStampFixed()){
+ vtkFloatingPointType aRange[2];
+ GetSpecificPL()->GetSourceRange(aRange);
+ return aRange[1];
+ }else{
+ TMinMax aTMinMax = GetField()->GetMinMax(GetScalarMode());
+ return aTMinMax.second;
+ }
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::SetNbColors(CORBA::Long theNbColors)
{
- struct TEvent: public SALOME_Event {
- VISU_ScalarMapPL* myMap;
- int myNbColors;
- TEvent( VISU_ScalarMapPL* theMap, int theNbColors)
- :myMap(theMap), myNbColors(theNbColors)
- {}
-
- virtual
- void
- Execute()
- {
- myMap->SetNbColors(myNbColors);
- }
- };
-
- ProcessVoidEvent(new TEvent(myScalarMapPL, theNbColors));
+ GetSpecificPL()->SetNbColors(theNbColors);
}
+//----------------------------------------------------------------------------
CORBA::Long
VISU::ColoredPrs3d_i
::GetNbColors()
{
- return myScalarMapPL->GetNbColors();
+ return GetSpecificPL()->GetNbColors();
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::SetBarOrientation(VISU::ScalarMap::Orientation theOrientation)
{
- myOrientation = theOrientation;
+ if(myOrientation != theOrientation){
+ myOrientation = theOrientation;
+ myParamsTime.Modified();
+ }
}
+//----------------------------------------------------------------------------
VISU::ScalarMap::Orientation
VISU::ColoredPrs3d_i
::GetBarOrientation()
return myOrientation;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::SetPosition(CORBA::Double X, CORBA::Double Y)
{
myPosition[0] = X;
myPosition[1] = Y;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
CORBA::Double
VISU::ColoredPrs3d_i
::GetPosX()
return myPosition[0];
}
+//----------------------------------------------------------------------------
CORBA::Double
VISU::ColoredPrs3d_i
::GetPosY()
return myPosition[1];
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::SetSize(CORBA::Double theWidth, CORBA::Double theHeight)
{
myWidth = theWidth;
myHeight = theHeight;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
CORBA::Double
VISU::ColoredPrs3d_i
::GetWidth()
return myWidth;
}
+//----------------------------------------------------------------------------
CORBA::Double
VISU::ColoredPrs3d_i
::GetHeight()
return myHeight;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::SetLabels(CORBA::Long theNbLabels)
{
- myNumberOfLabels = theNbLabels;
+ if(myNumberOfLabels != theNbLabels){
+ myNumberOfLabels = theNbLabels;
+ myParamsTime.Modified();
+ }
}
+//----------------------------------------------------------------------------
CORBA::Long
VISU::ColoredPrs3d_i
::GetLabels()
return myNumberOfLabels;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::SetTitle(const char* theTitle)
{
- // mkr : IPAL14030
- std::strstream aStream;
- const VISU::TValField& aValField = myField->myValField;
- const VISU::PValForTime aValForTime = aValField.find(myIteration)->second;
- aStream<<theTitle<<" "<<VISU_Convertor::GenerateName(aValForTime->myTime)<<std::ends;
- std::string aScalarBarTitle = aStream.str();
- if(myTitle != theTitle || myScalarBarTitle != aScalarBarTitle){
- myScalarBarTitle = aScalarBarTitle;
- myTitle = theTitle;
+ if(VISU::PValForTime aValForTime = GetScalarValForTime()){
+ std::strstream aStream;
+ const VISU::TTime& aTime = aValForTime->myTime;
+ aStream<<theTitle<<" "<<VISU_Convertor::GenerateName(aTime)<<std::ends;
+ std::string aScalarBarTitle = aStream.str();
+ if(myTitle != theTitle || myScalarBarTitle != aScalarBarTitle){
+ myScalarBarTitle = aScalarBarTitle;
+ myTitle = theTitle;
+ myParamsTime.Modified();
+ }
}
}
+//----------------------------------------------------------------------------
char*
VISU::ColoredPrs3d_i
::GetTitle()
return CORBA::string_dup(myTitle.c_str());
}
+//----------------------------------------------------------------------------
+std::string
+VISU::ColoredPrs3d_i
+::GetCTitle()
+{
+ return myTitle;
+}
+
+//----------------------------------------------------------------------------
bool
VISU::ColoredPrs3d_i
::IsBoldTitle()
return myIsBoldTitle;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetBoldTitle(bool isBold)
+::SetBoldTitle(bool theIsBoldTitle)
{
- myIsBoldTitle = isBold;
+ if(myIsBoldTitle != theIsBoldTitle){
+ myIsBoldTitle = theIsBoldTitle;
+ myParamsTime.Modified();
+ }
}
+//----------------------------------------------------------------------------
bool
VISU::ColoredPrs3d_i
::IsItalicTitle()
return myIsItalicTitle;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetItalicTitle(bool isItalic)
+::SetItalicTitle(bool theIsItalicTitle)
{
- myIsItalicTitle = isItalic;
+ if(myIsItalicTitle != theIsItalicTitle){
+ myIsItalicTitle = theIsItalicTitle;
+ myParamsTime.Modified();
+ }
}
+//----------------------------------------------------------------------------
bool
VISU::ColoredPrs3d_i
::IsShadowTitle()
return myIsShadowTitle;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetShadowTitle(bool isShadow)
+::SetShadowTitle(bool theIsShadowTitle)
{
- myIsShadowTitle = isShadow;
+ if(myIsShadowTitle != theIsShadowTitle){
+ myIsShadowTitle = theIsShadowTitle;
+ myParamsTime.Modified();
+ }
}
+//----------------------------------------------------------------------------
int
VISU::ColoredPrs3d_i
::GetTitFontType()
return myTitFontType;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetTitFontType(int theType)
+::SetTitFontType(int theTitFontType)
{
- myTitFontType = theType;
+ if(myTitFontType != theTitFontType){
+ myTitFontType = theTitFontType;
+ myParamsTime.Modified();
+ }
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::GetTitleColor(vtkFloatingPointType* theR,
*theB = myTitleColor[2];
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::SetTitleColor(vtkFloatingPointType theR,
myTitleColor[0] = theR;
myTitleColor[1] = theG;
myTitleColor[2] = theB;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
bool
VISU::ColoredPrs3d_i
::IsBoldLabel()
return myIsBoldLabel;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetBoldLabel(bool isBold)
+::SetBoldLabel(bool theIsBoldLabel)
{
- myIsBoldLabel = isBold;
+ if(myIsBoldLabel != theIsBoldLabel){
+ myIsBoldLabel = theIsBoldLabel;
+ myParamsTime.Modified();
+ }
}
+//----------------------------------------------------------------------------
bool
VISU::ColoredPrs3d_i
::IsItalicLabel()
return myIsItalicLabel;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetItalicLabel(bool isItalic)
+::SetItalicLabel(bool theIsItalicLabel)
{
- myIsItalicLabel = isItalic;
+ if(myIsItalicLabel != theIsItalicLabel){
+ myIsItalicLabel = theIsItalicLabel;
+ myParamsTime.Modified();
+ }
}
+//----------------------------------------------------------------------------
bool
VISU::ColoredPrs3d_i
::IsShadowLabel()
return myIsShadowLabel;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetShadowLabel(bool isShadow)
+::SetShadowLabel(bool theIsShadowLabel)
{
- myIsShadowLabel = isShadow;
+ if(myIsShadowLabel != theIsShadowLabel){
+ myIsShadowLabel = theIsShadowLabel;
+ myParamsTime.Modified();
+ }
}
+//----------------------------------------------------------------------------
int
VISU::ColoredPrs3d_i
::GetLblFontType()
return myLblFontType;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::SetLblFontType(int theType)
+::SetLblFontType(int theLblFontType)
{
- myLblFontType = theType;
+ if(myIsShadowLabel != theLblFontType){
+ myLblFontType = theLblFontType;
+ myParamsTime.Modified();
+ }
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::GetLabelColor(vtkFloatingPointType* theR,
*theB = myLabelColor[2];
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::SetLabelColor(vtkFloatingPointType theR,
myLabelColor[0] = theR;
myLabelColor[1] = theG;
myLabelColor[2] = theB;
+ myParamsTime.Modified();
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Boolean
+VISU::ColoredPrs3d_i
+::IsRangeFixed()
+{
+ return myIsFixedRange;
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::UseFixedRange(bool theUseFixedRange)
+{
+ myIsFixedRange = theUseFixedRange;
}
//----------------------------------------------------------------------------
*/
VISU::Storable*
VISU::ColoredPrs3d_i
-::Create(const char* theMeshName,
+::Create(const std::string& theMeshName,
VISU::Entity theEntity,
- const char* theFieldName,
- int theIteration)
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
{
- DoHook(); // to create proper pipeline
+ SetMeshName(theMeshName.c_str());
+ SetEntity(theEntity);
+ SetFieldName(theFieldName.c_str());
+ SetTimeStampNumber(theTimeStampNumber);
+ OnSetInput(false);
- myMeshName = theMeshName;
- myEntity = (VISU::TEntity)theEntity;
- myFieldName =theFieldName;
- myIteration = theIteration;
-
- Build(false); // to get corresponding input from result and initilize the pipeline
+ Build(ECreateNew); // to get corresponding input from result and initilize the pipeline
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
return this;
}
+//----------------------------------------------------------------------------
VISU::Storable*
VISU::ColoredPrs3d_i
-::Restore(const Storable::TRestoringMap& theMap)
+::Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
{
- DoHook();
-
- myMeshName = VISU::Storable::FindValue(theMap,"myMeshName").latin1();
- myEntity = (VISU::TEntity)VISU::Storable::FindValue(theMap,"myEntity").toInt();
- myFieldName = VISU::Storable::FindValue(theMap,"myFieldName").latin1();
- myIteration = VISU::Storable::FindValue(theMap,"myIteration").toInt();
+ if(!TSuperClass::Restore(theStudy, theMap))
+ return NULL;
- myAddToStudy = false; //SRN Added 21/06/2003 SAL2983: to avoid addition of the new ScalarMap to study.
+ SetEntity((VISU::Entity)VISU::Storable::FindValue(theMap,"myEntity").toInt());
+ SetFieldName(VISU::Storable::FindValue(theMap,"myFieldName").latin1());
+ SetTimeStampNumber(VISU::Storable::FindValue(theMap,"myIteration").toInt());
+ myIsTimeStampFixed = VISU::Storable::FindValue(theMap,"myIsTimeStampFixed").toInt();
+ OnSetInput(false);
- Build(true);
-
- TSuperClass::Restore(theMap);
+ Build(ERestore);
SetScalarMode(VISU::Storable::FindValue(theMap,"myScalarMode").toInt());
SetNbColors(VISU::Storable::FindValue(theMap,"myNumberOfColors").toInt());
return this;
}
+//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
::ToStream(std::ostringstream& theStr)
{
TSuperClass::ToStream(theStr);
+ Storable::DataToStream( theStr, "myEntity", GetEntity() );
+ Storable::DataToStream( theStr, "myFieldName", GetCFieldName() );
+ Storable::DataToStream( theStr, "myIteration", int(GetTimeStampNumber()) );
+ Storable::DataToStream( theStr, "myIsTimeStampFixed", int(myIsTimeStampFixed) );
+
Storable::DataToStream( theStr, "myScalarMode", int(GetScalarMode()) );
Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) );
Storable::DataToStream( theStr, "myOrientation", myOrientation );
- Storable::DataToStream( theStr, "myMeshName", myMeshName.c_str() );
- Storable::DataToStream( theStr, "myEntity", myEntity );
- Storable::DataToStream( theStr, "myFieldName", myFieldName.c_str() );
- Storable::DataToStream( theStr, "myIteration", myIteration );
-
Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
Storable::DataToStream( theStr, "myNumberOfLabels", myNumberOfLabels );
Storable::DataToStream( theStr, "myPosition[0]", myPosition[0] );
//----------------------------------------------------------------------------
void
VISU::ColoredPrs3d_i
-::DoHook()
+::CreatePipeLine(VISU_PipeLine* thePipeLine)
{
- if(MYDEBUG) MESSAGE("ColoredPrs3d_i::DoHook() - "<<myPipeLine);
- if(!myPipeLine){
- myPipeLine = VISU_ScalarMapPL::New();
- myPipeLine->GetMapper()->SetScalarVisibility(1);
- }
- myScalarMapPL = dynamic_cast<VISU_ScalarMapPL*>(myPipeLine);
+ if(MYDEBUG) MESSAGE("ColoredPrs3d_i::CreatePipeLine() - "<<thePipeLine);
+ myColoredPL = dynamic_cast<VISU_ColoredPL*>(thePipeLine);
+
+ SetPipeLine(myColoredPL);
}
//----------------------------------------------------------------------------
VISU::Storable*
VISU::ColoredPrs3d_i
-::Build(int theRestoring)
+::Build(EBuildMode theBuildMode)
{
if(MYDEBUG)
- MESSAGE("ColoredPrs3d_i::Build - "<<myFieldName<<"; theRestoring = "<<theRestoring);
- SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
- if(myAddToStudy)
+ MESSAGE("ColoredPrs3d_i::Build - "<<myFieldName<<"; theBuildMode = "<<theBuildMode);
+ SALOMEDS::StudyBuilder_var aStudyBuilder = GetStudyDocument()->NewBuilder();
+ bool anIsPublishInStudy = (myPublishInStudyMode == EPublishUnderTimeStamp || myPublishInStudyMode == EPublishIndependently);
+ if(anIsPublishInStudy)
aStudyBuilder->NewCommand(); // There is a transaction
#ifndef _DEXCEPT_
try{
#endif
- DoSetInput(myResult);
QString aComment;
- myName = "NoName";
- if(theRestoring <= 0){
- if(theRestoring == 0) myScalarMapPL->Init();
- if(!myIsFixedRange) myScalarMapPL->SetSourceRange();
- const VISU::TValField& aValField = myField->myValField;
- const VISU::PValForTime aValForTime = aValField.find(myIteration)->second;
- aComment.sprintf("%s %s",myFieldName.c_str(),VISU_Convertor::GenerateName(aValForTime->myTime).c_str());
- if (theRestoring == 0) SetTitle(myFieldName.c_str());
+ SetName("NoName", false);
+ if(theBuildMode == ECreateNew || theBuildMode == ESameAs){
+ if(!IsRangeFixed())
+ SetSourceRange();
+ if(theBuildMode == ECreateNew)
+ SetTitle(GetCFieldName().c_str());
}
- if(myAddToStudy){
- myName = GenerateName().latin1();
+ if(myPublishInStudyMode == EPublishUnderTimeStamp){
+ SetName(GenerateName().latin1(), false);
aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
- VISU::TTIMESTAMP,myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp);
- string aResultEntry = myResult->GetEntry();
- string aRefFatherEntry = myResult->GetRefFatherEntry();
- string anEntry = myResult->GetEntry(aComment.latin1());
- if(anEntry == "") throw std::runtime_error("There is no Entry for binding the presentation !!!");
+ VISU::TTIMESTAMP,
+ GetCMeshName().c_str(),
+ GetEntity(),
+ GetCFieldName().c_str(),
+ GetTimeStampNumber(),
+ GetField()->myNbComp);
+ std::string aResultEntry = GetCResult()->GetEntry();
+ std::string anEntry = GetCResult()->GetEntry(aComment.latin1());
+ if(anEntry == "")
+ throw std::runtime_error("There is no Entry for binding the presentation !!!");
aComment.sprintf("myComment=%s;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
- GetComment(),myMeshName.c_str(),myEntity,myFieldName.c_str(),myIteration,myField->myNbComp);
+ GetComment(),
+ GetCMeshName().c_str(),
+ GetEntity(),
+ GetCFieldName().c_str(),
+ GetTimeStampNumber(),
+ GetField()->myNbComp);
CORBA::String_var anIOR = GetID();
- CreateAttributes(myStudy,anEntry.c_str(),aRefFatherEntry.c_str(),anIOR,myName.c_str(),"",aComment.latin1(),true);
- mySObject = myStudy->FindObjectIOR(anIOR);
-
- // Set icon
- if (GetIconName() != 0)
- {
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributePixMap_var aPixmap;
-
- anAttr = aStudyBuilder->FindOrCreateAttribute( mySObject, "AttributePixMap" );
- aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
- aPixmap ->SetPixMap(GetIconName());
- }
+ CreateAttributes(GetStudyDocument(),
+ anEntry,
+ GetIconName(),
+ anIOR.in(),
+ GetName(),
+ "",
+ aComment.latin1(),
+ true);
+ }else if(myPublishInStudyMode == EPublishIndependently){
+ SetName(GenerateName().latin1(), false);
+ CORBA::String_var anIOR = GetID();
+ std::string aFatherEntry = ::FindOrCreate3DPresentationsFolder(GetStudyDocument());
+ aComment.sprintf("myComment=%s",
+ GetComment());
+ CreateAttributes(GetStudyDocument(),
+ aFatherEntry,
+ GetIconName(),
+ anIOR.in(),
+ GetName(),
+ "",
+ aComment.latin1(),
+ true);
}
#ifndef _DEXCEPT_
}catch(std::exception& exc){
throw;
}
#endif
- if(myAddToStudy)
+ if(anIsPublishInStudy)
aStudyBuilder->CommitCommand();
return this;
}
-
-
-//----------------------------------------------------------------------------
-const VISU::PField&
-VISU::ColoredPrs3d_i
-::GetField() const
-{
- return myField;
-}
-
-const std::string&
-VISU::ColoredPrs3d_i
-::GetMeshName() const
-{
- return myMeshName;
-}
-
-VISU::Entity
-VISU::ColoredPrs3d_i
-::GetEntity() const
-{
- return VISU::Entity(myEntity);
-}
-
-const std::string&
-VISU::ColoredPrs3d_i
-::GetFieldName() const
-{
- return myFieldName;
-}
-
-int
-VISU::ColoredPrs3d_i
-::GetIteration() const
-{
- return myIteration;
-}
-
-VISU_ScalarMapPL*
-VISU::ColoredPrs3d_i
-::GetScalarMapPL()
-{
- return myScalarMapPL;
-}
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
-// File : VISU_PrsObject_i.hxx
+// File : VISU_ColoredPrs3d_i.hh
// Author : Alexey PETROV
// Module : VISU
#include "VISU_Prs3d_i.hh"
-class VISU_ScalarMapPL;
+class VISU_ColoredPL;
namespace VISU
{
- //============================================================================
+ //----------------------------------------------------------------------------
class VISU_I_EXPORT ColoredPrs3d_i : public virtual POA_VISU::ColoredPrs3d,
- public virtual Prs3d_i
+ public virtual Prs3d_i
{
ColoredPrs3d_i(const ColoredPrs3d_i&);
public:
//----------------------------------------------------------------------------
typedef Prs3d_i TSuperClass;
+ typedef VISU::ColoredPrs3d TInterface;
+
+ /*!
+ The enumeration allow to define what mode should be used for the presentation building.
+ */
+ enum EPublishInStudyMode {EPublishUnderTimeStamp, EPublishIndependently, ERegisterInCache, EDoNotPublish};
explicit
- ColoredPrs3d_i(Result_i* theResult,
- bool theAddToStudy);
- explicit
- ColoredPrs3d_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject);
+ ColoredPrs3d_i(EPublishInStudyMode thePublishInStudyMode);
virtual
~ColoredPrs3d_i();
void
RemoveFromStudy();
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ SetEntity(Entity theEntity);
+
+ virtual
+ Entity
+ GetEntity();
+
+ TEntity
+ GetTEntity() const;
+
+ virtual
+ void
+ SetFieldName(const char* theFieldName);
+
+ virtual
+ char*
+ GetFieldName();
+
+ std::string
+ GetCFieldName() const;
+
+ virtual
+ const VISU::PField&
+ GetField() const;
+
+ virtual
+ void
+ SetTimeStampNumber(CORBA::Long theTimeStampNumber);
+
+ virtual
+ CORBA::Long
+ GetTimeStampNumber();
+
+ virtual
+ CORBA::Long
+ GetTimeStampNumberByIndex( CORBA::Long theIndex );
+
+ virtual
+ CORBA::Long
+ GetTimeStampIndexByNumber( CORBA::Long theNumber );
+
+ virtual
+ VISU::PValForTime
+ GetScalarValForTime() const;
+
+ virtual
+ VISU::ColoredPrs3d::TimeStampsRange*
+ GetTimeStampsRange();
+
+ virtual
+ CORBA::Boolean
+ IsTimeStampFixed();
+
+ virtual
+ EPublishInStudyMode
+ GetPublishInStudyMode();
+
//----------------------------------------------------------------------------
virtual
CORBA::Long
CORBA::Double
GetMax();
+ virtual
+ void
+ SetRange(CORBA::Double theMin, CORBA::Double theMax);
+
+ virtual
+ CORBA::Double
+ GetSourceMin();
+
+ virtual
+ CORBA::Double
+ GetSourceMax();
+
+ virtual
+ void
+ SetSourceRange();
+
+ virtual
+ CORBA::Boolean
+ IsRangeFixed();
+
virtual
void
SetNbColors(CORBA::Long theNbColors);
char*
GetTitle();
+ std::string
+ GetCTitle();
+
//----------------------------------------------------------------------------
- protected:
- VISU::ScalarMap::Orientation myOrientation;
- std::string myTitle;
- std::string myScalarBarTitle;
- int myNumberOfLabels;
- vtkFloatingPointType myPosition[2], myWidth, myHeight;
+ //! Gets memory size actually used by the presentation (Mb).
+ virtual
+ CORBA::Float
+ GetMemorySize();
+
+ //----------------------------------------------------------------------------
+ //! Returns presentation input
+ VISU::ColoredPrs3dHolder::BasicInput*
+ GetBasicInput();
+
+ virtual
+ void
+ SetHolderEntry(const std::string& theEntry);
+
+ virtual
+ std::string
+ GetHolderEntry();
- public:
//----------------------------------------------------------------------------
+ virtual
+ const char*
+ GetIconName() = 0;
+
+ //----------------------------------------------------------------------------
+ public:
+ /*!
+ Initlizes the in first time presentation
+ */
virtual
Storable*
- Create(const char* theMeshName,
+ Create(const std::string& theMeshName,
VISU::Entity theEntity,
- const char* theFieldName,
- int theIteration);
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber);
+ /*!
+ Retores state of the presentation
+ */
virtual
Storable*
- Restore(const Storable::TRestoringMap& theMap);
+ Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap);
+ /*!
+ Writes persistent params of the presentation into the given stream
+ */
virtual
void
ToStream(std::ostringstream& theStr);
+ /*!
+ Update state of the presentation according to the input.
+ */
virtual
void
SameAs(const Prs3d_i* theOrigin);
- /*!
- * \brief Works like SameAs() method, but keep myIteration value unchanged.
- *
- * Is used in VISU_TimeAnimation class implementation.
- */
- void
- SameAsParams(const ColoredPrs3d_i* theOrigin,
- const std::string& theMeshName, const std::string& theFieldName,
- VISU::Entity theEntity, int theIteration,
- bool theIsFixedRange);
-
- virtual const VISU::PField&
- GetField() const;
-
- const std::string&
- GetMeshName() const;
-
- VISU::Entity
- GetEntity() const;
-
- const std::string&
- GetFieldName() const;
-
- int
- GetIteration() const;
-
- VISU_ScalarMapPL*
- GetScalarMapPL();
-
virtual
bool
IsBoldTitle();
vtkFloatingPointType theG,
vtkFloatingPointType theB);
+ VISU_ColoredPL*
+ GetSpecificPL() const
+ {
+ return myColoredPL;
+ }
+
+ //----------------------------------------------------------------------------
+ protected:
+ /*!
+ Applyes basic input parameters to the presentation.
+ Returns true if all are right.
+ */
+ virtual
+ bool
+ SetInput(bool theReInit);
+
+ //! Restore input parameters if Apply function fails (redefines Prs3d::OnRestoreInput)
+ virtual
+ void
+ OnRestoreInput();
+
+ /*!
+ Checks whether it is possible to create presentation
+ with the given basic parameters or not.
+ */
+ virtual
+ bool
+ CheckIsPossible() = 0;
+
+ /*!
+ Creates proper instance of VTK pipeline.
+ */
+ virtual
+ void
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
+
+ /*!
+ First checks whether corresponding VTK pipeline exists and create it if not.
+ Then calls VISU_ColoredPrs3d_i::DoSetInput.
+ Returns true if during the call corresponding VTK pipeline was created,
+ false otherwise.
+ */
+ virtual
+ bool
+ OnSetInput(bool theReInit);
+
+ /*!
+ Sets input data set according to basic input parameters -
+ Result, MeshName, Entity, FieldName and TimeStampNumber.
+ */
+ virtual
+ void
+ DoSetInput(bool theIsInitilizePipe, bool theReInit) = 0;
+
+ /*!
+ The enumeration allow to define what mode should be used for the presentation building.
+ */
+ enum EBuildMode {ECreateNew, ESameAs, ERestore};
+
+ /*!
+ The enumeration allow to define what mode should be used for the presentation building.
+ */
+ Storable*
+ Build(EBuildMode theBuildMode);
+
+ virtual
+ void
+ SetField(VISU::PField theField);
+
+ void
+ UseFixedRange(bool theUseFixedRange);
+
std::string
GetScalarBarTitle();
- //----------------------------------------------------------------------------
- protected:
- PField myField;
- TEntity myEntity;
+ //! Used in derived classes to initilize the IO for actors
+ virtual
+ std::string
+ GetActorEntry();
+
+ private:
+ // Decalare basic input parameters
+ VISU::Entity myEntity;
+ VISU::Entity myPreviousEntity;
+
std::string myFieldName;
- int myIteration;
+ std::string myPreviousFieldName;
+
+ CORBA::Long myTimeStampNumber;
+ CORBA::Long myPreviousTimeStampNumber;
+
+ bool myIsTimeStampFixed;
+
+ PField myField;
+ EPublishInStudyMode myPublishInStudyMode;
+
+ std::string myHolderEntry;
+
+ std::string myTitle;
+ std::string myScalarBarTitle;
+
+ int myNumberOfLabels;
+ VISU::ScalarMap::Orientation myOrientation;
+ vtkFloatingPointType myPosition[2], myWidth, myHeight;
//Font management
bool myIsBoldTitle;
int myLblFontType;
vtkFloatingPointType myLabelColor[3];
- VISU_ScalarMapPL* myScalarMapPL;
+ VISU_ColoredPL* myColoredPL;
bool myIsFixedRange;
-
- virtual
- void
- DoSetInput(Result_i* theResult) = 0;
-
- Storable*
- Build(int theRestoring);
-
- virtual
- void
- DoHook();
-
- virtual
- const char*
- GetIconName() = 0;
};
+ //----------------------------------------------------------------------------
+ template<class TColoredPrs3d>
+ Storable*
+ Restore(SALOMEDS::SObject_ptr theSObject,
+ const std::string& thePrefix,
+ const Storable::TRestoringMap& theMap)
+ {
+ TColoredPrs3d* aColoredPrs3d = new TColoredPrs3d(ColoredPrs3d_i::EDoNotPublish);
+ SALOMEDS::Study_var aStudy = theSObject->GetStudy();
+ return aColoredPrs3d->Restore(aStudy, theMap);
+ }
+ //----------------------------------------------------------------------------
}
#endif
// Copyright (C) 2003 CEA/DEN, EDF R&D
#include "VISU_CorbaMedConvertor.hxx"
+#include "VISU_ConvertorUtils.hxx"
#include <vtkCellType.h>
#include "ReceiverFactory.hxx"
#include "MED_SliceArray.hxx"
-using namespace std;
-using namespace VISU;
-
#define USER_INTERLACE MED_FULL_INTERLACE
#ifdef _DEBUG_
namespace
{
- using namespace SALOME_MED;
-
const int MED_NBR_GEOMETRIE_MAILLE = 17;
- medGeometryElement
+ SALOME_MED::medGeometryElement
CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = {
- MED_POINT1,
- MED_SEG2,
- MED_SEG3,
- MED_TRIA3,
- MED_QUAD4,
- MED_TRIA6,
- MED_QUAD8,
- MED_TETRA4,
- MED_PYRA5,
- MED_PENTA6,
- MED_HEXA8,
- MED_TETRA10,
- MED_PYRA13,
- MED_PENTA15,
- MED_HEXA20,
- MED_POLYGON,
- MED_POLYHEDRA
+ SALOME_MED::MED_POINT1,
+ SALOME_MED::MED_SEG2,
+ SALOME_MED::MED_SEG3,
+ SALOME_MED::MED_TRIA3,
+ SALOME_MED::MED_QUAD4,
+ SALOME_MED::MED_TRIA6,
+ SALOME_MED::MED_QUAD8,
+ SALOME_MED::MED_TETRA4,
+ SALOME_MED::MED_PYRA5,
+ SALOME_MED::MED_PENTA6,
+ SALOME_MED::MED_HEXA8,
+ SALOME_MED::MED_TETRA10,
+ SALOME_MED::MED_PYRA13,
+ SALOME_MED::MED_PENTA15,
+ SALOME_MED::MED_HEXA20,
+ SALOME_MED::MED_POLYGON,
+ SALOME_MED::MED_POLYHEDRA
};
const int MED_NBR_GEOMETRIE_FACE = 5;
- medGeometryElement
+ SALOME_MED::medGeometryElement
FACEGEOM[MED_NBR_GEOMETRIE_FACE] = {
- MED_TRIA3,
- MED_QUAD4,
- MED_TRIA6,
- MED_QUAD8,
- MED_POLYGON
+ SALOME_MED::MED_TRIA3,
+ SALOME_MED::MED_QUAD4,
+ SALOME_MED::MED_TRIA6,
+ SALOME_MED::MED_QUAD8,
+ SALOME_MED::MED_POLYGON
};
const int MED_NBR_GEOMETRIE_ARETE = 2;
- medGeometryElement
+ SALOME_MED::medGeometryElement
EDGEGEOM[MED_NBR_GEOMETRIE_ARETE] = {
- MED_SEG2,
- MED_SEG3
+ SALOME_MED::MED_SEG2,
+ SALOME_MED::MED_SEG3
};
const int MED_NBR_GEOMETRIE_NODE = 1;
- medGeometryElement
+ SALOME_MED::medGeometryElement
NODEGEOM[MED_NBR_GEOMETRIE_NODE] = {
- MED_POINT1,
+ SALOME_MED::MED_POINT1,
};
//---------------------------------------------------------------
int
- GetEntity2Geom(const VISU::TEntity& theEntity, medGeometryElement*& theVector)
+ GetEntity2Geom(const VISU::TEntity& theEntity,
+ SALOME_MED::medGeometryElement*& theVector)
{
switch(theEntity){
- case CELL_ENTITY: theVector = CELLGEOM; return MED_NBR_GEOMETRIE_MAILLE; break;
- case FACE_ENTITY: theVector = FACEGEOM; return MED_NBR_GEOMETRIE_FACE; break;
- case EDGE_ENTITY: theVector = EDGEGEOM; return MED_NBR_GEOMETRIE_ARETE; break;
- case NODE_ENTITY: theVector = NODEGEOM; return MED_NBR_GEOMETRIE_NODE; break;
+ case VISU::CELL_ENTITY:
+ theVector = CELLGEOM;
+ return MED_NBR_GEOMETRIE_MAILLE;
+ case VISU::FACE_ENTITY:
+ theVector = FACEGEOM;
+ return MED_NBR_GEOMETRIE_FACE;
+ case VISU::EDGE_ENTITY:
+ theVector = EDGEGEOM;
+ return MED_NBR_GEOMETRIE_ARETE;
+ case VISU::NODE_ENTITY:
+ theVector = NODEGEOM;
+ return MED_NBR_GEOMETRIE_NODE;
}
return -1;
}
MEDGeom2NbNodes(int theMEDGeomType)
{
switch(theMEDGeomType){
- case MED_NONE: return 0;
- case MED_POINT1: return 1;
- case MED_SEG2: return 2;
- case MED_SEG3: return 3;
- case MED_TRIA3: return 3;
- case MED_TRIA6: return 6;
- case MED_QUAD4: return 4;
- case MED_QUAD8: return 8;
- case MED_TETRA4: return 4;
- case MED_TETRA10: return 10;
- case MED_HEXA8: return 8;
- case MED_HEXA20: return 20;
- case MED_PENTA6: return 6;
- case MED_PENTA15: return 15;
- case MED_PYRA5: return 5;
- case MED_PYRA13: return 13;
+ case SALOME_MED::MED_NONE:
+ return 0;
+ case SALOME_MED::MED_POINT1:
+ return 1;
+ case SALOME_MED::MED_SEG2:
+ return 2;
+ case SALOME_MED::MED_SEG3:
+ return 3;
+ case SALOME_MED::MED_TRIA3:
+ return 3;
+ case SALOME_MED::MED_TRIA6:
+ return 6;
+ case SALOME_MED::MED_QUAD4:
+ return 4;
+ case SALOME_MED::MED_QUAD8:
+ return 8;
+ case SALOME_MED::MED_TETRA4:
+ return 4;
+ case SALOME_MED::MED_TETRA10:
+ return 10;
+ case SALOME_MED::MED_HEXA8:
+ return 8;
+ case SALOME_MED::MED_HEXA20:
+ return 20;
+ case SALOME_MED::MED_PENTA6:
+ return 6;
+ case SALOME_MED::MED_PENTA15:
+ return 15;
+ case SALOME_MED::MED_PYRA5:
+ return 5;
+ case SALOME_MED::MED_PYRA13:
+ return 13;
}
return -1;
}
//---------------------------------------------------------------
VISU::EGeometry
- MEDGeom2VISU(medGeometryElement theGeom)
+ MEDGeom2VISU(SALOME_MED::medGeometryElement theGeom)
{
switch(theGeom){
- case MED_POINT1: return VISU::ePOINT1;
- case MED_SEG2: return VISU::eSEG2;
- case MED_SEG3: return VISU::eSEG3;
- case MED_TRIA3: return VISU::eTRIA3;
- case MED_TRIA6: return VISU::eTRIA6;
- case MED_QUAD4: return VISU::eQUAD4;
- case MED_QUAD8: return VISU::eQUAD8;
- case MED_TETRA4: return VISU::eTETRA4;
- case MED_TETRA10: return VISU::eTETRA10;
- case MED_HEXA8: return VISU::eHEXA8;
- case MED_HEXA20: return VISU::eHEXA20;
- case MED_PENTA6: return VISU::ePENTA6;
- case MED_PENTA15: return VISU::ePENTA15;
- case MED_PYRA5: return VISU::ePYRA5;
- case MED_PYRA13: return VISU::ePYRA13;
- case MED_POLYGON: return VISU::ePOLYGONE;
- case MED_POLYHEDRA: return VISU::ePOLYEDRE;
+ case SALOME_MED::MED_POINT1:
+ return VISU::ePOINT1;
+ case SALOME_MED::MED_SEG2:
+ return VISU::eSEG2;
+ case SALOME_MED::MED_SEG3:
+ return VISU::eSEG3;
+ case SALOME_MED::MED_TRIA3:
+ return VISU::eTRIA3;
+ case SALOME_MED::MED_TRIA6:
+ return VISU::eTRIA6;
+ case SALOME_MED::MED_QUAD4:
+ return VISU::eQUAD4;
+ case SALOME_MED::MED_QUAD8:
+ return VISU::eQUAD8;
+ case SALOME_MED::MED_TETRA4:
+ return VISU::eTETRA4;
+ case SALOME_MED::MED_TETRA10:
+ return VISU::eTETRA10;
+ case SALOME_MED::MED_HEXA8:
+ return VISU::eHEXA8;
+ case SALOME_MED::MED_HEXA20:
+ return VISU::eHEXA20;
+ case SALOME_MED::MED_PENTA6:
+ return VISU::ePENTA6;
+ case SALOME_MED::MED_PENTA15:
+ return VISU::ePENTA15;
+ case SALOME_MED::MED_PYRA5:
+ return VISU::ePYRA5;
+ case SALOME_MED::MED_PYRA13:
+ return VISU::ePYRA13;
+ case SALOME_MED::MED_POLYGON:
+ return VISU::ePOLYGONE;
+ case SALOME_MED::MED_POLYHEDRA:
+ return VISU::ePOLYEDRE;
}
return VISU::eNONE;
}
//---------------------------------------------------------------
- medGeometryElement
+ SALOME_MED::medGeometryElement
VISUGeomToMED(int theGeom)
{
switch(theGeom){
- case VISU::ePOINT1: return MED_POINT1;
- case VISU::eSEG2: return MED_SEG2;
- case VISU::eTRIA3: return MED_TRIA3;
- case VISU::eQUAD4: return MED_QUAD4;
- case VISU::eTETRA4: return MED_TETRA4;
- case VISU::eHEXA8: return MED_HEXA8;
- case VISU::ePENTA6: return MED_PENTA6;
- case VISU::ePYRA5: return MED_PYRA5;
-
- case VISU::eSEG3: return MED_SEG3;
- case VISU::eTRIA6: return MED_TRIA6;
- case VISU::eQUAD8: return MED_QUAD8;
- case VISU::eTETRA10: return MED_TETRA10;
- case VISU::eHEXA20: return MED_HEXA20;
- case VISU::ePENTA15: return MED_PENTA15;
- case VISU::ePYRA13: return MED_PYRA13;
- case VISU::ePOLYGONE: return MED_POLYGON;
- case VISU::ePOLYEDRE: return MED_POLYHEDRA;
+ case VISU::ePOINT1:
+ return SALOME_MED::MED_POINT1;
+ case VISU::eSEG2:
+ return SALOME_MED::MED_SEG2;
+ case VISU::eTRIA3:
+ return SALOME_MED::MED_TRIA3;
+ case VISU::eQUAD4:
+ return SALOME_MED::MED_QUAD4;
+ case VISU::eTETRA4:
+ return SALOME_MED::MED_TETRA4;
+ case VISU::eHEXA8:
+ return SALOME_MED::MED_HEXA8;
+ case VISU::ePENTA6:
+ return SALOME_MED::MED_PENTA6;
+ case VISU::ePYRA5:
+ return SALOME_MED::MED_PYRA5;
+
+ case VISU::eSEG3:
+ return SALOME_MED::MED_SEG3;
+ case VISU::eTRIA6:
+ return SALOME_MED::MED_TRIA6;
+ case VISU::eQUAD8:
+ return SALOME_MED::MED_QUAD8;
+ case VISU::eTETRA10:
+ return SALOME_MED::MED_TETRA10;
+ case VISU::eHEXA20:
+ return SALOME_MED::MED_HEXA20;
+ case VISU::ePENTA15:
+ return SALOME_MED::MED_PENTA15;
+ case VISU::ePYRA13:
+ return SALOME_MED::MED_PYRA13;
+ case VISU::ePOLYGONE:
+ return SALOME_MED::MED_POLYGON;
+ case VISU::ePOLYEDRE:
+ return SALOME_MED::MED_POLYHEDRA;
}
- return medGeometryElement(-1);
+ return SALOME_MED::medGeometryElement(-1);
}
//---------------------------------------------------------------
- medGeometryElement
+ SALOME_MED::medGeometryElement
VTKGeomToMED(int theVTKGeomType)
{
switch(theVTKGeomType){
- case VTK_VERTEX: return MED_POINT1;
- case VTK_LINE: return MED_SEG2;
- case VTK_TRIANGLE: return MED_TRIA3;
- case VTK_QUAD: return MED_QUAD4;
- case VTK_TETRA: return MED_TETRA4;
- case VTK_HEXAHEDRON: return MED_HEXA8;
- case VTK_WEDGE: return MED_PENTA6;
- case VTK_PYRAMID: return MED_PYRA5;
- case VTK_POLYGON: return MED_POLYGON;
+ case VTK_VERTEX:
+ return SALOME_MED::MED_POINT1;
+ case VTK_LINE:
+ return SALOME_MED::MED_SEG2;
+ case VTK_TRIANGLE:
+ return SALOME_MED::MED_TRIA3;
+ case VTK_QUAD:
+ return SALOME_MED::MED_QUAD4;
+ case VTK_TETRA:
+ return SALOME_MED::MED_TETRA4;
+ case VTK_HEXAHEDRON:
+ return SALOME_MED::MED_HEXA8;
+ case VTK_WEDGE:
+ return SALOME_MED::MED_PENTA6;
+ case VTK_PYRAMID:
+ return SALOME_MED::MED_PYRA5;
+ case VTK_POLYGON:
+ return SALOME_MED::MED_POLYGON;
}
- return medGeometryElement(-1);
+ return SALOME_MED::medGeometryElement(-1);
}
//---------------------------------------------------------------
VISU::TEntity
- MEDEntityToVTK(medEntityMesh theMEDEntity)
+ MEDEntityToVTK(SALOME_MED::medEntityMesh theMEDEntity)
{
switch(theMEDEntity){
- case MED_NODE: return NODE_ENTITY;
- case MED_EDGE: return EDGE_ENTITY;
- case MED_FACE: return FACE_ENTITY;
- case MED_CELL: return CELL_ENTITY;
+ case SALOME_MED::MED_NODE:
+ return VISU::NODE_ENTITY;
+ case SALOME_MED::MED_EDGE:
+ return VISU::EDGE_ENTITY;
+ case SALOME_MED::MED_FACE:
+ return VISU::FACE_ENTITY;
+ case SALOME_MED::MED_CELL:
+ return VISU::CELL_ENTITY;
}
return VISU::TEntity(-1);
}
//---------------------------------------------------------------
- medEntityMesh
+ SALOME_MED::medEntityMesh
VTKEntityToMED(VISU::TEntity theVTKEntity)
{
switch(theVTKEntity){
- case NODE_ENTITY: return MED_NODE;
- case EDGE_ENTITY: return MED_EDGE;
- case FACE_ENTITY: return MED_FACE;
- case CELL_ENTITY: return MED_CELL;
+ case VISU::NODE_ENTITY:
+ return SALOME_MED::MED_NODE;
+ case VISU::EDGE_ENTITY:
+ return SALOME_MED::MED_EDGE;
+ case VISU::FACE_ENTITY:
+ return SALOME_MED::MED_FACE;
+ case VISU::CELL_ENTITY:
+ return SALOME_MED::MED_CELL;
}
- return medEntityMesh(-1);
+ return SALOME_MED::medEntityMesh(-1);
}
{
theNbCells = theCellsSize = 0;
if(MYDEBUG) MESSAGE("GetCellsSize - theVEntity = "<<theVEntity);
- const medEntityMesh& aMEntity = VTKEntityToMED(theVEntity);
+ const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(theVEntity);
SALOME_MED::MESH::connectivityInfos_var connInfo=theMEDMesh->getConnectGlobal(aMEntity);
int iGeomEnd = connInfo->meshTypes.length();
for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
SALOME_MED::MESH_ptr theMEDMesh,
const VISU::TEntity& theEntity)
{
- TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[theEntity];
- if(theEntity == NODE_ENTITY){
+ if(theEntity == VISU::NODE_ENTITY){
aMeshOnEntity->myNbCells = theMesh->myNbPoints;
aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;
}else{
//---------------------------------------------------------------
- PCMeshOnEntity
+ VISU::PCMeshOnEntity
InitMeshOnEntity(const VISU::PCMesh& theMesh,
const VISU::TEntity& theEntity,
const VISU::PCMeshOnEntity& theMeshOnEntity)
{
- PCMeshOnEntity aMeshOnEntity;
- TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
- TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(theEntity);
+ VISU::PCMeshOnEntity aMeshOnEntity;
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(theEntity);
if(anIter == aMeshOnEntityMap.end()){
- aMeshOnEntity.reset(new TCMeshOnEntity());
+ aMeshOnEntity.reset(new VISU::TCMeshOnEntity());
*aMeshOnEntity = *theMeshOnEntity;
aMeshOnEntity->myEntity = theEntity;
aMeshOnEntityMap[theEntity] = aMeshOnEntity;
}
- PCSubProfile
+ VISU::PCSubProfile
CrSubProfile(const VISU::PCMesh theMesh,
const VISU::PCField theField,
const VISU::TCMeshOnEntity& theMeshOnEntity,
SALOME_MED::medGeometryElement theMGeom,
- // SALOME_MED::long_array_var theGeom2Profile)
- int nbElts)
+ int theNbElems)
{
if (MYDEBUG) MESSAGE("CrSubProfile");
VISU::EGeometry aEGeom = MEDGeom2VISU(theMGeom);
vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom);
- PCSubProfile aSubProfile(new TCSubProfile());
+ VISU::PCSubProfile aSubProfile(new VISU::TCSubProfile());
aSubProfile->myGeom = aEGeom;
aSubProfile->myMGeom = theMGeom;
- aSubProfile->myStatus = eAddAll;
+ aSubProfile->myStatus = VISU::eAddAll;
if(MYDEBUG) MESSAGE("theMGeom = "<<theMGeom);
- TCellsFirstIndex::const_iterator aTimeStampIter = (theMeshOnEntity.myCellsFirstIndex).find(theMGeom);
+ const VISU::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity.myCellsFirstIndex;
+ VISU::TCellsFirstIndex::const_iterator aTimeStampIter = aCellsFirstIndex.find(theMGeom);
if(aTimeStampIter == (theMeshOnEntity.myCellsFirstIndex).end() &&
theMGeom != SALOME_MED::MED_POINT1)
- aSubProfile->myStatus = eRemoveAll;
- else if( aTimeStampIter == (theMeshOnEntity.myCellsFirstIndex).end() &&
- theMGeom == SALOME_MED::MED_POINT1)
- {
- if(nbElts>0){
- aSubProfile->myName = "";
- aSubProfile->myStatus = eAddPart;
-
- aSubProfile->myNbCells = nbElts;
- aSubProfile->myCellsSize = aSubProfile->myNbCells;
- }
+ aSubProfile->myStatus = VISU::eRemoveAll;
+ else if(aTimeStampIter == aCellsFirstIndex.end() && theMGeom == SALOME_MED::MED_POINT1){
+ if(theNbElems > 0){
+ aSubProfile->myName = "";
+ aSubProfile->myStatus = VISU::eAddPart;
+
+ aSubProfile->myNbCells = theNbElems;
+ aSubProfile->myCellsSize = aSubProfile->myNbCells;
}
- else
- {
- if(nbElts>0){
+ }else{
+ if(theNbElems > 0){
aSubProfile->myName = "";
- aSubProfile->myStatus = eAddPart;
+ aSubProfile->myStatus = VISU::eAddPart;
- aSubProfile->myNbCells = nbElts;
+ aSubProfile->myNbCells = theNbElems;
aSubProfile->myCellsSize = aSubProfile->myNbCells*aVNbNodes;
}
}
return aSubProfile;
}
- TProfileKey
+ VISU::TProfileKey
GetProfileKey(const VISU::PCMesh theMesh,
const VISU::PCField theField,
const VISU::PCValForTime theValForTime,
{
if (MYDEBUG) MESSAGE("GetProfileKey");
- TProfileKey aProfileKey;
+ VISU::TProfileKey aProfileKey;
- const TCellsFirstIndex& aFirstIndex = theMeshOnEntity.myCellsFirstIndex;
- TCellsFirstIndex::const_iterator anIter = aFirstIndex.begin();
- int aNbElts = 0;
- if(anIter==aFirstIndex.end() &&
- (theValForTime->myField->getSupport()->getEntity() == SALOME_MED::MED_NODE))
- {
- SALOME_MED::medGeometryElement aMGeom = SALOME_MED::MED_POINT1;
-
- try{
- aNbElts = theValForTime->myField->getSupport()->getNumberOfElements(SALOME_MED::MED_NONE);
- if(MYDEBUG)MESSAGE("aMGeom="<<aMGeom<<" aNbElts="<<aNbElts);
- } catch(...){
- MESSAGE("Error in theValForTime->myField->getSupport()->getNumberOfElements(aMGeom);");
- }
-
- PCSubProfile aSubProfile = CrSubProfile(theMesh,
- theField,
- theMeshOnEntity,
- aMGeom,
- aNbElts);
- aProfileKey.insert(aSubProfile);
+ const VISU::TCellsFirstIndex& aFirstIndex = theMeshOnEntity.myCellsFirstIndex;
+ VISU::TCellsFirstIndex::const_iterator anIter = aFirstIndex.begin();
+ SALOME_MED::SUPPORT_var aSupport = theValForTime->myField->getSupport();
+ int aNbElems = 0;
+ if(anIter == aFirstIndex.end() && aSupport->getEntity() == SALOME_MED::MED_NODE){
+ SALOME_MED::medGeometryElement aMGeom = SALOME_MED::MED_POINT1;
+ try{
+ aNbElems = aSupport->getNumberOfElements(SALOME_MED::MED_NONE);
+ if(MYDEBUG)MESSAGE("aMGeom="<<aMGeom<<" aNbElems="<<aNbElems);
+ }catch(...){
+ MESSAGE("Error in theValForTime->myField->getSupport()->getNumberOfElements(aMGeom);");
}
+
+ VISU::PCSubProfile aSubProfile = CrSubProfile(theMesh,
+ theField,
+ theMeshOnEntity,
+ aMGeom,
+ aNbElems);
+ aProfileKey.insert(aSubProfile);
+ }
for(; anIter != aFirstIndex.end(); anIter++){
SALOME_MED::medGeometryElement aMGeom = anIter->first;
try{
- aNbElts = theValForTime->myField->getSupport()->getNumberOfElements(aMGeom);
- if(MYDEBUG)MESSAGE("aMGeom="<<aMGeom<<" aNbElts="<<aNbElts);
+ aNbElems = aSupport->getNumberOfElements(aMGeom);
+ if(MYDEBUG)MESSAGE("aMGeom="<<aMGeom<<" aNbElems="<<aNbElems);
} catch(...){
MESSAGE("Error in theValForTime->myField->getSupport()->getNumberOfElements(aMGeom);");
continue;
}
- PCSubProfile aSubProfile = CrSubProfile(theMesh,
- theField,
- theMeshOnEntity,
- aMGeom,
- aNbElts);
+ VISU::PCSubProfile aSubProfile = CrSubProfile(theMesh,
+ theField,
+ theMeshOnEntity,
+ aMGeom,
+ aNbElems);
aProfileKey.insert(aSubProfile);
}
{
if (MYDEBUG) MESSAGE("InitProfile");
- TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
+ VISU::TProfileMap& aProfileMap = theMeshOnEntity.myProfileMap;
- TProfileKey aProfileKey = GetProfileKey(theMesh,
- theField,
- theValForTime,
- theMeshOnEntity);
-
- TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
+ VISU::TProfileKey aProfileKey = GetProfileKey(theMesh,
+ theField,
+ theValForTime,
+ theMeshOnEntity);
+
+ VISU::TProfileMap::const_iterator anIter = aProfileMap.find(aProfileKey);
if(anIter != aProfileMap.end()){
theValForTime->myProfile = anIter->second;
if(MYDEBUG) MESSAGE("aProfileMap.find(aProfileKey) aProfile->myGeom=");
}else{
- PCProfile aProfile(new TCProfile());
- TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+ VISU::PCProfile aProfile(new VISU::TCProfile());
+ VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
- TProfileKey::const_iterator anIter = aProfileKey.begin();
+ VISU::TProfileKey::const_iterator anIter = aProfileKey.begin();
for(; anIter != aProfileKey.end(); anIter++){
- PCSubProfile aSubProfile(*anIter);
+ VISU::PCSubProfile aSubProfile(*anIter);
- if(aProfile->myIsAll && aSubProfile->myStatus != eAddAll)
+ if(aProfile->myIsAll && aSubProfile->myStatus != VISU::eAddAll)
aProfile->myIsAll = false;
VISU::EGeometry aEGeom = aSubProfile->myGeom;
VISU::PCValForTime theValForTime,
VISU::PCMeshOnEntity theMeshOnEntity)
{
- PCProfile aProfile = theValForTime->myProfile;
+ VISU::PCProfile aProfile = theValForTime->myProfile;
if (MYDEBUG) MESSAGE("LoadProfile aProfile->myIsDone="<<aProfile->myIsDone);
if(aProfile->myIsDone)
return;
- const TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
- TGeom2SubProfile::const_iterator aGeom2SubProfileIter = aGeom2SubProfile.begin();
- if(aGeom2SubProfileIter==aGeom2SubProfile.end()){
+ const VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+ VISU::TGeom2SubProfile::const_iterator aGeom2SubProfileIter = aGeom2SubProfile.begin();
+ if(aGeom2SubProfileIter == aGeom2SubProfile.end()){
MESSAGE("Warning! No geom 2 sub profile");
}
- for(;aGeom2SubProfileIter!=aGeom2SubProfile.end();aGeom2SubProfileIter++){
- VISU::EGeometry aEGeom = aGeom2SubProfileIter->first;
- medGeometryElement aMGeom = VISUGeomToMED(aEGeom);
- PCSubProfile aSubProfile = aGeom2SubProfileIter->second;
+ SALOME_MED::SUPPORT_var aSupport = theValForTime->myField->getSupport();
+ for(; aGeom2SubProfileIter != aGeom2SubProfile.end(); aGeom2SubProfileIter++){
+ VISU::EGeometry aEGeom = aGeom2SubProfileIter->first;
+ SALOME_MED::medGeometryElement aMGeom = VISUGeomToMED(aEGeom);
+ VISU::PCSubProfile aSubProfile = aGeom2SubProfileIter->second;
SALOME_MED::long_array_var aGeom2ProfileIds;
std::vector<int> aGeom2Profile;
- if(!theValForTime->myField->getSupport()->isOnAllElements()){
+ if(!aSupport->isOnAllElements()){
try{
if(aMGeom == SALOME_MED::MED_POINT1)
- aGeom2ProfileIds = theValForTime->myField->getSupport()->getNumberFromFile(SALOME_MED::MED_NONE);
+ aGeom2ProfileIds = aSupport->getNumberFromFile(SALOME_MED::MED_NONE);
else
- aGeom2ProfileIds = theValForTime->myField->getSupport()->getNumberFromFile(aMGeom);
+ aGeom2ProfileIds = aSupport->getNumberFromFile(aMGeom);
int aLen = aGeom2ProfileIds->length();
if(MYDEBUG) MESSAGE(" - aMGeom="<<aMGeom<<"; aNbCells="<<aLen);
- for(int i=0;i<aLen;i++){
+ for(int i = 0; i < aLen; i++){
int anId = aGeom2ProfileIds[i];
aGeom2Profile.push_back(anId);
if(MYDEBUG) cout << "------------------------------->" << anId << endl;
continue;
}
} else {
- SALOME_MED::medEntityMesh aMEntity = theValForTime->myField->getSupport()->getEntity();
- int aNbElts = theMesh->myMesh->getNumberOfElements(aMEntity,aMGeom);
- for(int i=0;i<aNbElts;i++) aGeom2Profile.push_back(i+1);
+ SALOME_MED::medEntityMesh aMEntity = aSupport->getEntity();
+ int aNbElems = theMesh->myMesh->getNumberOfElements(aMEntity,aMGeom);
+ for(int i = 0; i < aNbElems; i++)
+ aGeom2Profile.push_back(i+1);
}
if(aGeom2Profile.size()>0){
- TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
+ VISU::TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID;
int aSize = aGeom2Profile.size();
aSubMeshID.resize(aSize);
-
-
for(int anId = 0; anId < aSize; anId++){
- aSubMeshID[anId] = aGeom2Profile[anId]-1; // ENKENKENKENKENEKENKENKN
+ aSubMeshID[anId] = aGeom2Profile[anId] - 1;
}
}
-
}
-
aProfile->myIsDone = true;
if (MYDEBUG) MESSAGE("LoadProfile done");
}
//---------------------------------------------------------------
VISU_Convertor*
-VISU_MEDFieldConvertor::Build()
+VISU_MEDFieldConvertor
+::Build()
{
if(myField->_is_nil())
throw std::runtime_error("VISU_MEDFieldConvertor::Build >> myField->_is_nil() !!!");
throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDSupport->_is_nil() !!!");
SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
- TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh();
if(aMEDMesh->_is_nil())
throw std::runtime_error("VISU_MEDFieldConvertor::Build >> aMEDMesh->_is_nil() !!!");
CORBA::String_var aMeshName = aMEDMesh->getName();
CORBA::String_var aFieldName = myField->getName();
- PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
- aMesh->myNamedPointCoords(new TNamedPointCoords());
+ VISU::PCMesh aMesh = myMeshMap[aMeshName.in()](new VISU::TCMesh());
+ aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());
aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
aMesh->myDim = aMEDMesh->getSpaceDimension();
aMesh->myName = aMeshName.in();
aMesh->myMesh = aMEDMesh;
- TNamedPointCoords& aCoords = aMesh->myNamedPointCoords;
- aCoords.Init(aMesh->myNbPoints,aMesh->myDim);
-
if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
- TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
- PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TCMeshOnEntity());
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new VISU::TCMeshOnEntity());
aMeshOnEntity->myEntity = aVEntity;
aMeshOnEntity->myMeshName = aMeshName.in();
aMeshOnEntity->mySupport = aMEDSupport;
- if(aVEntity == NODE_ENTITY)
- ::InitMeshOnEntity(aMesh,CELL_ENTITY,aMeshOnEntity);
+ if(aVEntity == VISU::NODE_ENTITY)
+ ::InitMeshOnEntity(aMesh, VISU::CELL_ENTITY, aMeshOnEntity);
else
- ::InitMeshOnEntity(aMesh,NODE_ENTITY,aMeshOnEntity);
+ ::InitMeshOnEntity(aMesh, VISU::NODE_ENTITY, aMeshOnEntity);
- ::GetCellsSize(aMesh,aMEDMesh,aVEntity);
+ ::GetCellsSize(aMesh, aMEDMesh, aVEntity);
- TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
- PCField aField = aFieldMap[aFieldName.in()](new TCField());
+ VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+ VISU::PCField aField = aFieldMap[aFieldName.in()](new VISU::TCField());
aField->myId = myField->getOrderNumber();
aField->myName = aFieldName.in();
aField->myEntity = aVEntity;
aField->myMeshName = aMeshName.in();
- aField->InitArrays(myField->getNumberOfComponents());
aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
+ vtkIdType aDataType = VTK_DOUBLE;
+ SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(myField);
+ if(aFieldDouble->_is_nil())
+ aDataType = VTK_LONG;
+ aField->Init(myField->getNumberOfComponents(), aDataType);
+
if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
- TValField& aValField = aField->myValField;
+ VISU::TValField& aValField = aField->myValField;
int anId = myField->getIterationNumber();
- PCValForTime aValForTime = aValField[anId](new TCValForTime());
+ VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());
aValForTime->myId = anId;
CORBA::Double aDT = myField->getTime();
- aValForTime->myTime = TTime(aDT,"");
+ aValForTime->myTime = VISU::TTime(aDT,"");
aValForTime->myField = myField;
if(MYDEBUG)
//---------------------------------------------------------------
VISU_Convertor*
-VISU_MEDConvertor::Build()
+VISU_MEDConvertor
+::Build()
{
if(mySObject->_is_nil())
throw std::runtime_error("VISU_MEDConvertor::Build >> mySObject->_is_nil() !!!");
}
-namespace{
-
+namespace
+{
using namespace boost;
//---------------------------------------------------------------
//---------------------------------------------------------------
VISU_Convertor*
-VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
+VISU_MEDConvertor
+::Build(SALOME_MED::MED_ptr theMED)
{
if(CORBA::is_nil(theMED))
return NULL;
if(!anIsSuccess)
continue;
- PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
+ VISU::PCMesh aMesh = myMeshMap[aMeshName.in()](new VISU::TCMesh());
SALOME_MED::MESH_var aMEDMesh = boost::get<0>(aMeshByNameRet);
- aMesh->myNamedPointCoords(new TNamedPointCoords());
+ aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());
aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
aMesh->myDim = aMEDMesh->getSpaceDimension();
aMesh->myName = aMeshName.in();
aMesh->myMesh = aMEDMesh;
- TNamedPointCoords& aCoords = aMesh->myNamedPointCoords;
- aCoords.Init(aMesh->myNbPoints,aMesh->myDim);
-
if(MYDEBUG)
MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
if(!anIsSuccess)
continue;
- TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
SALOMEDS::SObject_var aSupportsSObj = boost::get<0>(aSObjectByNameRet);
SALOMEDS::ChildIterator_var aSupportIterator = aStudy->NewChildIterator(aSupportsSObj);
"' aVEntity = "<<aVEntity);
int aNbCells, aCellsSize;
//Check, if there is any data on the support?
- if(aVEntity == NODE_ENTITY){
+ if(aVEntity == VISU::NODE_ENTITY){
aMesh->myNbPoints = aMeshOnSupport->getNumberOfNodes();
aNbCells = aMesh->myNbPoints;
aCellsSize = 2*aMesh->myNbPoints;
::GetCellsSize(aNbCells,aCellsSize,aMeshOnSupport,aVEntity);
if(aNbCells > 0){
- TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
- if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()){
- PCMeshOnEntity aMeshOnEntity(new TCMeshOnEntity());
+ if(aMeshOnEntityMap.find(aVEntity) == aMeshOnEntityMap.end()){
+ VISU::PCMeshOnEntity aMeshOnEntity(new VISU::TCMeshOnEntity());
aMeshOnEntity->myMeshName = aMeshName.in();
aMeshOnEntity->myEntity = aVEntity;
aMeshOnEntity->myNbCells = aNbCells;
SALOME_MED::FAMILY_var aMEDFamily = SALOME_MED::FAMILY::_narrow(aMedSupport);
if(!aMEDFamily->_is_nil()) {
- TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
+ VISU::TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
continue;
- PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
+ VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
int aNbCells = aMeshOnEntity->myNbCells, aCellsSize = aMeshOnEntity->myCellsSize;
CORBA::Boolean anIsOnAllElements = aMEDSupport->isOnAllElements();
"; aNbCells = "<<aNbCells);
if(aNbCells > 0){
- TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
- TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.find(aSupportName.in());
+ VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+ VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.find(aSupportName.in());
if(aFamilyMapIter == aFamilyMap.end()){
- PCFamily aFamily(new TCFamily());
+ VISU::PCFamily aFamily(new VISU::TCFamily());
aFamily->myEntity = aVEntity;
aFamily->myNbCells = aNbCells;
aFamily->myCellsSize = aCellsSize;
"; anIsOnAllElements = "<<anIsOnAllElements<<
"; aVEntity = "<<aVEntity);
- PCGroup aGroup(new TCGroup());
+ VISU::PCGroup aGroup(new VISU::TCGroup());
aGroup->myGroup = aMEDGroup;
VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
SALOME_MED::FAMILY_var aMEDFamily = aFamilies[iFamaily];
CORBA::String_var aFamilyName = aMEDFamily->getName();
TFindFamilyOnEntity aFindFamilyOnEntity =
- FindFamilyOnEntity(aMeshName.in(),aVEntity,aFamilyName.in());
- PCFamily aFamily = boost::get<2>(aFindFamilyOnEntity);
+ FindFamilyOnEntity(aMeshName.in(), aVEntity, aFamilyName.in());
+ VISU::PCFamily aFamily = boost::get<2>(aFindFamilyOnEntity);
if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aGroup - aFamilyName = '"<<aFamilyName.in()<<"' = "<<bool(aFamily));
if(aFamily){
aFamilySet.insert(aFamily);
}
if(!aFamilySet.empty()){
- TGroupMap& aGroupMap = aMesh->myGroupMap;
+ VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
aGroupMap[aSupportName.in()] = aGroup;
}
CORBA::String_var aMeshName = aMEDMesh->getName();
CORBA::String_var aFieldName = aMEDField->getName();
- TMeshMap::iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
+ VISU::TMeshMap::iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
if(aMeshMapIter == myMeshMap.end())
continue;
- PCMesh aMesh = aMeshMapIter->second;
- TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
- TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity);
+ VISU::PCMesh aMesh = aMeshMapIter->second;
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap::iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity);
if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
continue;
- PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
- TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
- TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
- PCField aField;
+ VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
+ VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+ VISU::TFieldMap::iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
+ VISU::PCField aField;
if(aFieldMapIter == aFieldMap.end()){
- aField = aFieldMap[aFieldName.in()](new TCField());
+ aField = aFieldMap[aFieldName.in()](new VISU::TCField());
aField->myId = iField;
aField->myName = aFieldName.in();
aField->myEntity = anEntity;
aField->myMeshName = aMeshName.in();
- aField->InitArrays(aMEDField->getNumberOfComponents());
aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
+
+ vtkIdType aDataType = VTK_DOUBLE;
+ SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
+ if(aFieldDouble->_is_nil())
+ aDataType = VTK_LONG;
+ aField->Init(aMEDField->getNumberOfComponents(), aDataType);
+
if(MYDEBUG)
MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
}else
aField = aFieldMapIter->second;
- TValField& aValField = aField->myValField;
+ VISU::TValField& aValField = aField->myValField;
int anId = aMEDField->getIterationNumber();
- PCValForTime aValForTime = aValField[anId](new TCValForTime());
+ VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());
aValForTime->myId = anId;
CORBA::Double aDT = aMEDField->getTime();
- aValForTime->myTime = TTime(aDT,"");
+ aValForTime->myTime = VISU::TTime(aDT,"");
aValForTime->myField = aMEDField;
if(MYDEBUG)
MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<
//---------------------------------------------------------------
VISU_Convertor*
-VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
+VISU_MEDConvertor
+::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
{
if(theTimeStampIterator->_is_nil()) return NULL;
for(; theTimeStampIterator->More(); theTimeStampIterator->Next()){
continue;
SALOME_MED::medEntityMesh aMEntity = aMEDSupport->getEntity();
- TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity);
SALOME_MED::MESH_var aMEDMesh = aMEDSupport->getMesh();
if(aMEDMesh->_is_nil()) continue;
CORBA::String_var aMeshName = aMEDMesh->getName();
CORBA::String_var aFieldName = aMEDField->getName();
- PCMesh aMesh;
- TMeshMap::const_iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
+ VISU::PCMesh aMesh;
+ VISU::TMeshMap::const_iterator aMeshMapIter = myMeshMap.find(aMeshName.in());
if(aMeshMapIter == myMeshMap.end()){
- aMesh.reset(new TCMesh());
- aMesh->myNamedPointCoords(new TNamedPointCoords());
+ aMesh.reset(new VISU::TCMesh());
+ aMesh->myNamedPointCoords(new VISU::TNamedPointCoords());
aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
aMesh->myDim = aMEDMesh->getSpaceDimension();
aMesh->myName = aMeshName.in();
aMesh->myMesh = aMEDMesh;
- TNamedPointCoords& aCoords = aMesh->myNamedPointCoords;
- aCoords.Init(aMesh->myNbPoints,aMesh->myDim);
-
myMeshMap[aMeshName.in()] = aMesh;
if(MYDEBUG)
}else
aMesh = aMeshMapIter->second;
- PCMeshOnEntity aMeshOnEntity;
- TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
- TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
+ VISU::PCMeshOnEntity aMeshOnEntity;
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(aVEntity);
if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()){
- aMeshOnEntity.reset(new TCMeshOnEntity());
+ aMeshOnEntity.reset(new VISU::TCMeshOnEntity());
aMeshOnEntity->myEntity = aVEntity;
aMeshOnEntity->myMeshName = aMeshName.in();
aMeshOnEntity->mySupport = aMEDSupport;
}else
aMeshOnEntity = aMeshOnEntityMapIter->second;
- if(aVEntity == NODE_ENTITY)
- ::InitMeshOnEntity(aMesh,CELL_ENTITY,aMeshOnEntity);
+ if(aVEntity == VISU::NODE_ENTITY)
+ ::InitMeshOnEntity(aMesh,VISU::CELL_ENTITY,aMeshOnEntity);
else
- ::InitMeshOnEntity(aMesh,NODE_ENTITY,aMeshOnEntity);
+ ::InitMeshOnEntity(aMesh,VISU::NODE_ENTITY,aMeshOnEntity);
::GetCellsSize(aMesh,aMEDMesh,aVEntity);
- PCField aField;
- TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
- TFieldMap::const_iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
+ VISU::PCField aField;
+ VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+ VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.find(aFieldName.in());
if(aFieldMapIter == aFieldMap.end()){
- aField.reset(new TCField());
+ aField.reset(new VISU::TCField());
aField->myId = mySObject->Tag();
aField->myName = aFieldName.in();
aField->myEntity = aVEntity;
aField->myMeshName = aMeshName.in();
- aField->InitArrays(aMEDField->getNumberOfComponents());
aField->myDataSize = aMeshOnEntity->myNbCells * aField->myNbComp;
+ vtkIdType aDataType = VTK_DOUBLE;
+ SALOME_MED::FIELDDOUBLE_ptr aFieldDouble = SALOME_MED::FIELDDOUBLE::_narrow(aMEDField);
+ if(aFieldDouble->_is_nil())
+ aDataType = VTK_LONG;
+ aField->Init(aMEDField->getNumberOfComponents(), aDataType);
+
aFieldMap[aFieldName.in()] = aField;
if(MYDEBUG)
}else
aField = aFieldMapIter->second;
- TValField& aValField = aField->myValField;
+ VISU::TValField& aValField = aField->myValField;
int anId = aMEDField->getIterationNumber();
- PCValForTime aValForTime = aValField[anId](new TCValForTime());
+ VISU::PCValForTime aValForTime = aValField[anId](new VISU::TCValForTime());
aValForTime->myId = anId;
CORBA::Double aDT = aMEDField->getTime();
- aValForTime->myTime = TTime(aDT,"");
+ aValForTime->myTime = VISU::TTime(aDT,"");
aValForTime->myField = aMEDField;
if(MYDEBUG)
MESSAGE("VISU_MEDConvertor::Build "<<
VISU::PMeshOnEntityImpl theMeshOnEntity)
{
int anIsUpdated = LoadPoints(theMesh);
- const TEntity& aVEntity = theMeshOnEntity->myEntity;
- if(aVEntity != NODE_ENTITY)
+ const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
+ if(aVEntity != VISU::NODE_ENTITY)
anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);
return anIsUpdated;
VISU::PFamilyImpl theFamily)
{
int anIsUpdated = LoadPoints(theMesh);
- const TEntity& anEntity = theMeshOnEntity->myEntity;
- if(anEntity == NODE_ENTITY){
+ const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
+ if(anEntity == VISU::NODE_ENTITY){
anIsUpdated |= LoadPointsOnFamily(theMesh,theFamily);
}else{
anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);
{
//Main part of code
int anIsUpdated = LoadPoints(theMesh);
- TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
+ VISU::TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
for(; aFamilyIter != theFamilySet.end(); aFamilyIter++){
- PCFamily aFamily = *aFamilyIter;
+ VISU::PCFamily aFamily = *aFamilyIter;
const VISU::TEntity& aVEntity = aFamily->myEntity;
- PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
+ VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
if(aVEntity == VISU::NODE_ENTITY){
anIsUpdated |= LoadPointsOnFamily(theMesh,aFamily);
}else{
{
//Main part of code
int anIsUpdated = LoadPoints(theMesh);
- const TEntity& aVEntity = theMeshOnEntity->myEntity;
- if(aVEntity != NODE_ENTITY)
+ const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
+ if(aVEntity != VISU::NODE_ENTITY)
anIsUpdated |= LoadCellsOnEntity(theMesh,theMeshOnEntity);
anIsUpdated |= LoadField(theMesh,theMeshOnEntity,theField,theValForTime);
::LoadPoints(VISU::PCMesh theMesh)
{
//Check on existing family
- PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
+ VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
//Check on loading already done
if(theMesh->myIsDone)
return 0;
SALOME_MED::MESH_var& aMedMesh = theMesh->myMesh;
- int aDim = theMesh->myDim;
- TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
- int aNbElem = aCoords.GetNbPoints();
+ vtkIdType aDim = theMesh->GetDim();
+ vtkIdType aNbElem = theMesh->GetNbPoints();
if(MYDEBUG) MESSAGE("LoadPoints - aNbElem = "<<aNbElem);
throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!");
SALOME_MED::double_array_var aCCoord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
- for(int iElem = 0, anId = 0; iElem < aNbElem; iElem++){
- VISU::TCoordSlice aCoordSlice = aCoords.GetCoordSlice(iElem);
- for(int iDim = 0; iDim < aDim; iDim++)
- aCoordSlice[iDim] = aCCoord[anId++];
- }
+ VISU::TCMEDCoordHolder* aCoordHolder = new VISU::TCMEDCoordHolder();
+ aCoordHolder->Init(aNbElem, aDim, aCCoord);
+
+ VISU::TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
+ aCoords.Init(VISU::PCoordHolder(aCoordHolder));
if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");
- TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
- PSubMeshImpl aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new TCSubMesh());
+ VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
+ VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new VISU::TCSubMesh());
aSubMesh->myNbCells = theMesh->myNbPoints;
aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
- TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
aCell2Connect.resize(aNbElem);
if(MYDEBUG) MESSAGE("LoadPoints - aNbElem="<<aNbElem);
for(int iElem = 0; iElem < aNbElem; iElem++)
- aCell2Connect[iElem] = TConnect(1,iElem);
+ aCell2Connect[iElem] = VISU::TConnect(1,iElem);
theMesh->myIsDone = true;
::LoadPointsOnFamily(VISU::PCMesh theMesh,
VISU::PCFamily theFamily)
{
- PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
+ VISU::PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
if(theFamily->myIsDone)
return 0;
- TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
- int aNbElem = aCoords.GetNbPoints();
-
+ vtkIdType aNbElem = theMesh->GetNbPoints();
SALOME_MED::FAMILY_var aMedFamily = theFamily->myFamily;
CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
- TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
+ VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
if(!anIsOnAllElements){
SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
}
theFamily->myIsDone = true;
-
+
return 1;
}
-
//---------------------------------------------------------------
-namespace {
-
- using namespace MED;
+namespace
+{
+ typedef MED::TCSlice<int> TA;
+ //---------------------------------------------------------------
+ typedef std::set<int> TConnSet;
+ typedef std::vector<int> TIntArray;
+ typedef MED::TCSlice<int> TConnSlice;
- typedef vector< int > TCIntArray;
- typedef TCSlice< TCIntArray > TConnSlice;
//---------------------------------------------------------------
- class MEDPolygonConnectivity { //! retriver of polygon connectivity
- TCIntArray myConn, myConnIndex;
+ class MEDPolygonConnectivity //! retriver of polygon connectivity
+ {
+ TIntArray myConn;
+ TIntArray myConnIndex;
public:
- MEDPolygonConnectivity(SALOME_MED::MESH_var theMesh,
- SALOME_MED::medEntityMesh theEntity) {
- SALOME::SenderInt_var connSender, connIndexSender;
- connSender = theMesh->getSenderForPolygonsConnectivity (MED_NODAL, theEntity);
- connIndexSender = theMesh->getSenderForPolygonsConnectivityIndex (MED_NODAL, theEntity);
- long connSize, connIndexSize;
- int* conn = ReceiverFactory::getValue(connSender,connSize);
- int* index = ReceiverFactory::getValue(connIndexSender,connIndexSize);
- myConn.assign( conn, & conn[connSize] );
- myConnIndex.assign( index, &index[connIndexSize] );
- // should we delete arrays got via ReceiverFactory? nobody knows
+
+ MEDPolygonConnectivity(SALOME_MED::MESH_var theMesh,
+ SALOME_MED::medEntityMesh theEntity)
+ {
+ {
+ SALOME::SenderInt_var aSender =
+ theMesh->getSenderForPolygonsConnectivity(SALOME_MED::MED_NODAL, theEntity);
+ long int aSize;
+ int* aValuePtr = ReceiverFactory::getValue(aSender.in(), aSize);
+ myConn.assign(aValuePtr, aValuePtr + aSize);
+ }
+ {
+ SALOME::SenderInt_var aSender =
+ theMesh->getSenderForPolygonsConnectivityIndex(SALOME_MED::MED_NODAL, theEntity);
+ long int aSize;
+ int* aValuePtr = ReceiverFactory::getValue(aSender, aSize);
+ myConnIndex.assign(aValuePtr, aValuePtr + aSize);
+ }
}
- TConnSlice GetConn(int theId) const {
- int offset = myConnIndex[ theId ] - 1;
- int size = myConnIndex[ theId + 1 ] - myConnIndex[ theId ];
- return TConnSlice(myConn,std::slice(offset,size,1));
+
+ TConnSlice
+ GetConn(int theId) const
+ {
+ int anOffSet = myConnIndex[theId] - 1;
+ int aSize = myConnIndex[theId + 1] - myConnIndex[ theId ];
+ return TConnSlice(&myConn[0], myConn.size(), std::slice(anOffSet, aSize, 1));
}
- int GetNbElem() const {
+
+ int
+ GetNbElem() const
+ {
return myConnIndex.size() - 1;
}
- int GetCellSize() const {
+
+ int
+ GetCellSize() const
+ {
return myConn.size() + GetNbElem();
}
};
+
+
//---------------------------------------------------------------
- class MEDPolyhedraConnectivity {//! retriver of polyhedron connectivity
- TCIntArray myConn, myConnIndex, myFaceIndex;
+ class MEDPolyhedraConnectivity //! retriver of polyhedron connectivity
+ {
+ TIntArray myConn;
+ TIntArray myConnIndex;
+ TIntArray myFaceIndex;
public:
- MEDPolyhedraConnectivity(SALOME_MED::MESH_var theMesh) {
- SALOME::SenderInt_var connSender, connIndexSender, faceIndexSender;
- connSender = theMesh->getSenderForPolyhedronConnectivity (MED_NODAL);
- connIndexSender = theMesh->getSenderForPolyhedronIndex (MED_NODAL);
- faceIndexSender = theMesh->getSenderForPolyhedronFacesIndex ();
- long connSize, connIndexSize, facesSize;
- int* conn = ReceiverFactory::getValue(connSender,connSize);
- int* index = ReceiverFactory::getValue(connIndexSender,connIndexSize);
- int* faces = ReceiverFactory::getValue(faceIndexSender,facesSize);
- myConn.assign( conn, & conn[connSize] );
- myConnIndex.assign( index, &index[connIndexSize] );
- myFaceIndex.assign( faces, &faces[facesSize] );
- // should we delete arrays got via ReceiverFactory? nobody knows
+
+ MEDPolyhedraConnectivity(SALOME_MED::MESH_var theMesh)
+ {
+ {
+ SALOME::SenderInt_var aSender =
+ theMesh->getSenderForPolyhedronConnectivity(SALOME_MED::MED_NODAL);
+ long int aSize;
+ int* aValuePtr = ReceiverFactory::getValue(aSender, aSize);
+ myConn.assign(aValuePtr, aValuePtr + aSize);
+ }
+ {
+ SALOME::SenderInt_var aSender =
+ theMesh->getSenderForPolyhedronIndex(SALOME_MED::MED_NODAL);
+ long int aSize;
+ int* aValuePtr = ReceiverFactory::getValue(aSender, aSize);
+ myConnIndex.assign(aValuePtr, aValuePtr + aSize);
+ }
+ {
+ SALOME::SenderInt_var aSender =
+ theMesh->getSenderForPolyhedronFacesIndex();
+ long int aSize;
+ int* aValuePtr = ReceiverFactory::getValue(aSender, aSize);
+ myFaceIndex.assign(aValuePtr, aValuePtr + aSize);
+ }
}
- int GetUniqueConn(int id, std::set<int>& connSet) const {
- connSet.clear();
- int f1 = myConnIndex[ id ]-1, f2 = myConnIndex[ id+1 ]-2;
- int i1 = myFaceIndex[ f1 ]-1, i2 = myFaceIndex[ f2+1 ]-1;
- for ( int i = i1; i < i2; ++i )
- connSet.insert( myConn[ i ]);
- return connSet.size();
+
+ int
+ GetUniqueConn(int theId,
+ TConnSet& theConnSet) const
+ {
+ theConnSet.clear();
+ int aStartFaceId = myConnIndex[theId] - 1;
+ int anEndFaceId = myConnIndex[theId + 1] - 2;
+ int aStartConnId = myFaceIndex[aStartFaceId] - 1;
+ int anEndConnId = myFaceIndex[anEndFaceId + 1] - 1;
+ for(int aConnId = aStartConnId; aConnId < anEndConnId; aConnId++)
+ theConnSet.insert(myConn[aConnId]);
+ return theConnSet.size();
}
- int GetNbElem() const {
+
+ int
+ GetNbElem() const
+ {
return myConnIndex.size() - 1;
}
- int GetCellSize() const {
- return myConn.size();//???? + GetNbElem();
+
+ int
+ GetCellSize() const
+ {
+ TConnSet aConnSet;
+ int aCellSize = 0;
+ for(int anElemId = 0; anElemId < GetNbElem(); anElemId++)
+ aCellSize += GetUniqueConn(anElemId, aConnSet);
+ return aCellSize;
}
};
}
SALOME_MED::MESH_var aMedMesh = aMedSupport->getMesh();
//Main part of code
- const TEntity& aVEntity = theMeshOnEntity->myEntity;
+ const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity;
const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(aVEntity);
- SALOME_MED::MESH::connectivityInfos_var connInfo;
- try {
- connInfo= aMedMesh->getConnectGlobal(aMEntity);
- }
- catch (const std::exception & ex) {
- return 0;
- }
- int iGeomEnd = connInfo->meshTypes.length();
- const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
- TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
- int aNbPoints = aCoords.GetNbPoints();
+ VISU::TCellsFirstIndex& aFirstIndex = theMeshOnEntity->myCellsFirstIndex;
+
+ SALOME_MED::MESH::connectivityInfos_var anInfo = aMedMesh->getConnectGlobal(aMEntity);
+ int iGeomEnd = anInfo->meshTypes.length();
+
+ VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
+ vtkIdType aNbPoints = theMesh->GetNbPoints();
for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++) {
- SALOME_MED::medGeometryElement aMGeom = connInfo->meshTypes[iGeom];
+ SALOME_MED::medGeometryElement aMGeom = anInfo->meshTypes[iGeom];
VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
- int aNbElem = connInfo->numberOfElements[ iGeom ];
switch (aMGeom) {
case SALOME_MED::MED_POLYGON:
{
- MEDPolygonConnectivity conn(aMedMesh, aMEntity);
- aNbElem = conn.GetNbElem();
- if (aNbElem) {
- PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new TCSubMesh());
+ MEDPolygonConnectivity aConn(aMedMesh, aMEntity);
+ int aNbElem = aConn.GetNbElem();
+ if (aNbElem > 0) {
+ VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());
aSubMesh->myNbCells = aNbElem;
- aSubMesh->myCellsSize = conn.GetCellSize();
+ aSubMesh->myCellsSize = aConn.GetCellSize();
- TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
aCell2Connect.resize(aNbElem);
for(int iElem = 0; iElem < aNbElem; iElem++) {
- TConnSlice aConnSlice = conn.GetConn(iElem);
- TConnect& anArray = aCell2Connect[iElem];
+ TConnSlice aConnSlice = aConn.GetConn(iElem);
+ VISU::TConnect& anArray = aCell2Connect[iElem];
anArray.resize(aConnSlice.size());
for(int iConn = 0; iConn < aConnSlice.size(); iConn++)
anArray[iConn] = aConnSlice[iConn] - 1;
break;
case SALOME_MED::MED_POLYHEDRA:
{
- MEDPolyhedraConnectivity conn( aMedMesh );
- aNbElem = conn.GetNbElem();
- if (aNbElem) {
- PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new TCSubMesh());
- aSubMesh->myNbCells = aNbElem;
- aSubMesh->myCellsSize = conn.GetCellSize();
+ MEDPolyhedraConnectivity aConn( aMedMesh );
+ int aNbElem = aConn.GetNbElem();
+ if (aNbElem > 0) {
+ VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());
+ aSubMesh->myNbCells = aNbElem;
+ aSubMesh->myCellsSize = aConn.GetCellSize();
- TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
aCell2Connect.resize(aNbElem);
- std::set< int > aConnectSet;
- for(int iElem = 0; iElem < aNbElem; iElem++) {
- if ( conn.GetUniqueConn( iElem, aConnectSet )) {
+ TConnSet aConnectSet;
+ for(int iElem = 0; iElem < aNbElem; iElem++){
+ if(aConn.GetUniqueConn(iElem, aConnectSet)){
int aNbConn = aConnectSet.size();
- TConnect& anArray = aCell2Connect[iElem];
+ VISU::TConnect& anArray = aCell2Connect[iElem];
anArray.resize(aNbConn);
std::set<int>::iterator anIter = aConnectSet.begin();
for(int i = 0; anIter != aConnectSet.end(); anIter++, i++)
{
int aMNbNodes = MEDGeom2NbNodes(aMGeom);
int aVNbNodes = VISUGeom2NbNodes(aEGeom);
+ int aNbElem = anInfo->numberOfElements[iGeom];
if (aNbElem > 0) {
- using namespace SALOME_MED;
- SALOME_MED::long_array_var conn =
- aMedMesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,aMEntity,aMGeom);
- PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new TCSubMesh());
+ SALOME_MED::long_array_var aConn =
+ aMedMesh->getConnectivity(SALOME_MED::MED_FULL_INTERLACE,
+ SALOME_MED::MED_NODAL,
+ aMEntity,
+ aMGeom);
+ VISU::PSubMeshImpl aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TCSubMesh());
aSubMesh->myNbCells = aNbElem;
aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
- TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
std::vector<int> aConnect(aMNbNodes);
- int aNbConnForElem = conn->length()/aNbElem;
+ int aNbConnForElem = aConn->length() / aNbElem;
if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aMGeom = "<<aMGeom<<
"; aNbElem = "<<aNbElem<<
for(int iElem = 0; iElem < aNbElem; iElem++) {
VISU::TConnect anArray(aVNbNodes);
for(int k = 0, kj = iElem*aNbConnForElem; k < aMNbNodes; k++)
- aConnect[k] = conn[kj+k] - 1;
+ aConnect[k] = aConn[kj+k] - 1;
switch(aMGeom){
#if !(defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)) && defined(VISU_ENABLE_QUADRATIC)
} // loop on elements
}
}} // switch( aMGeom )
- //Workaround for MED Component data structure
- int aSize = aNbElem; //aCell2Connect.size();
- if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aCounter = "<<aCounter<<"; aSize = "<<aSize<<"; aMGeom = "<<aMGeom);
- theMeshOnEntity->myCellsFirstIndex[aMGeom] = TIndexAndSize(aCounter,aSize);
- aCounter += aSize;
+ VISU::TGeom2SubMesh::iterator anIter = aGeom2SubMesh.find(aEGeom);
+ if(anIter != aGeom2SubMesh.end()){
+ const VISU::PSubMeshImpl& aSubMesh = anIter->second;
+ const VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
+ int aSize = aCell2Connect.size();
+ if(MYDEBUG) MESSAGE("LoadCellsOnEntity - aCounter = "<<aCounter<<"; aSize = "<<aSize<<"; aMGeom = "<<aMGeom);
+ aFirstIndex[aMGeom] = VISU::TIndexAndSize(aCounter, aSize);
+ aCounter += aSize;
+ }
} //loop on types
// Dump result connectivity
int aNbElem = aCellNumForType->length();
int aCounter = theMeshOnEntity->myCellsFirstIndex[aMGeom].first;
int aSize = theMeshOnEntity->myCellsFirstIndex[aMGeom].second;
- TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aEGeom];
+ VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aEGeom];
if(MYDEBUG)
MESSAGE("LoadCellsOnFamily "<<
VISU::EGeometry aEGeom = anIter->first;
const VISU::TSubMeshImpl& aSubMesh = anIter->second;
const VISU::TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect;
- TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aEGeom];
+ VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aEGeom];
int iNumElemEnd = aCell2Connect.size();
for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
aSubMeshID.push_back(iNumElem);
}
-template<class TArray>
-int
-ImportField(TArray& theArray,
+template<class TValueType,
+ class TContainerType>
+void
+ImportField(TContainerType& theContainer,
VISU::PCMesh theMesh,
VISU::PCField theField,
VISU::PCValForTime theValForTime,
VISU::PCMeshOnEntity theMeshOnEntity)
{
- if(MYDEBUG) MESSAGE("ImportField");
-
- int aNbComp = theField->myNbComp;
-
- if(MYDEBUG) MESSAGE("- aNbComp = "<<aNbComp);
-
- CORBA::String_var aSupportName = theMeshOnEntity->mySupport->getName();
-
- if(theMeshOnEntity->mySupport->isOnAllElements() &&
- strcmp(aSupportName.in(),"SupportOnAll_MED_") > 0){
-
- if(theField->myEntity == NODE_ENTITY){
- VISU::EGeometry aEGeom = VISU::ePOINT1;
- int aNbGauss = theValForTime->GetNbGauss(aEGeom);
- const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
- int aNbElem = aCoords.GetNbPoints();
-
- if(MYDEBUG) MESSAGE("ImportField - aNbElem = "<<aNbElem);
-
- TMeshValue& aMeshValue = theValForTime->GetMeshValue(VISU::ePOINT1);
- aMeshValue.Init(aNbElem,aNbGauss,aNbComp);
- for(int iElem = 0, anId = 0; iElem < aNbElem; iElem++){
- TValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem);
- for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
- TValueSlice& aValueSlice = aValueSliceArr[iGauss];
- for(int iComp = 0; iComp < aNbComp; iComp++){
- aValueSlice[iComp] = theArray[anId++];
- }
- }
- }
- } else {
- SALOME_MED::medGeometryElement* aGeomElems;
- const TEntity& aVEntity = theField->myEntity;
- int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
- for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
- SALOME_MED::medGeometryElement aMGeom = aGeomElems[iGeom];
- VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
- int aNbGauss = theValForTime->GetNbGauss(aEGeom);
- const TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity->myCellsFirstIndex;
- TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aMGeom);
- if(aCellsFirstIndexIter != aCellsFirstIndex.end()){
- const TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second;
- if(MYDEBUG)
- MESSAGE("ImportField - aMGeom = "<<aMGeom<<
- "; aIndexAndSize = {"<<aIndexAndSize.first<<
- ","<<aIndexAndSize.second<<"}");
-
- int aNbElem = aIndexAndSize.second;
- int aStart = aIndexAndSize.first*aNbComp;
- TMeshValue& aMeshValue = theValForTime->GetMeshValue(aEGeom);
- aMeshValue.Init(aNbElem,aNbGauss,aNbComp);
- for(int iElem = 0, anId = 0; iElem < aNbElem; iElem++, anId += aNbComp){
- TValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem);
- for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
- TValueSlice& aValueSlice = aValueSliceArr[iGauss];
- for(int iComp = 0; iComp < aNbComp; iComp++)
- aValueSlice[iComp] = theArray[aStart+anId+iComp];
- }
- }
- }
- }
- }
- return 1;
- }
-
- if(MYDEBUG) MESSAGE("Loading profile");
- theField->myDataSize = 0;
-
- InitProfile(theMesh,theField,theValForTime,theMeshOnEntity);
-
- LoadProfile(theMesh,theField,theValForTime,theMeshOnEntity);
-
- PCProfile aProfile = theValForTime->myProfile;
- TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
-
- TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
- for(; anIter != aGeom2SubProfile.end(); anIter++){
- VISU::EGeometry aEGeom = anIter->first;
- PCSubProfile aSubProfile(anIter->second);
-
- int aNbElem = aSubProfile->myNbCells;
- theField->myDataSize += aNbElem*aNbComp;
-
- if(aSubProfile->myStatus != eRemoveAll){
- int aNbGauss = theValForTime->GetNbGauss(aEGeom);
-
- if(MYDEBUG) MESSAGE("- aEGeom = "<<aEGeom<<
- "; aNbElem = "<<aNbElem<<
- "; aNbGauss = "<<aNbGauss);
-
- TMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
- aVMeshValue.Init(aNbElem,aNbGauss,aNbComp);
-
- for(int iElem = 0, anId = 0; iElem < aNbElem; iElem++){
- TValueSliceArr aVValueSliceArr = aVMeshValue.GetGaussValueSliceArr(iElem);
- for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
- TValueSlice& aVValueSlice = aVValueSliceArr[iGauss];
- for(int iComp = 0; iComp < aNbComp; iComp++){
- aVValueSlice[iComp] = theArray[anId++];
- }
- }
+ typedef VISU::TTCMEDMeshValue<TValueType, TContainerType> TVMeshValue;
+ vtkIdType aNbComp = theField->myNbComp;
+ if(theField->myEntity == VISU::NODE_ENTITY){
+ VISU::EGeometry aEGeom = VISU::ePOINT1;
+ vtkIdType aNbGauss = theValForTime->GetNbGauss(aEGeom);
+ vtkIdType aNbElem = theMesh->GetNbPoints();
+
+ if(MYDEBUG) MESSAGE("ImportField - aNbElem = "<<aNbElem);
+
+ VISU::PMeshValue& aVMeshValue = theValForTime->GetMeshValue(VISU::ePOINT1);
+ TVMeshValue* aMeshValue = new TVMeshValue();
+ aMeshValue->Init(aNbElem, aNbGauss, aNbComp, theContainer, 0);
+ aVMeshValue.reset(aMeshValue);
+ }else{
+ SALOME_MED::medGeometryElement* aGeomElems;
+ const VISU::TEntity& aVEntity = theField->myEntity;
+ int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
+ for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
+ SALOME_MED::medGeometryElement aMGeom = aGeomElems[iGeom];
+ VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
+ vtkIdType aNbGauss = theValForTime->GetNbGauss(aEGeom);
+ const VISU::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity->myCellsFirstIndex;
+ VISU::TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aMGeom);
+ if(aCellsFirstIndexIter != aCellsFirstIndex.end()){
+ const VISU::TIndexAndSize& aIndexAndSize = aCellsFirstIndexIter->second;
+ if(MYDEBUG)
+ MESSAGE("ImportField - aMGeom = "<<aMGeom<<
+ "; aIndexAndSize = {"<<aIndexAndSize.first<<
+ ","<<aIndexAndSize.second<<"}");
+
+ vtkIdType aNbElem = aIndexAndSize.second;
+ vtkIdType aStart = aIndexAndSize.first * aNbComp;
+ VISU::PMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
+ TVMeshValue* aMeshValue = new TVMeshValue();
+ aMeshValue->Init(aNbElem, aNbGauss, aNbComp, theContainer, aStart);
+ aVMeshValue.reset(aMeshValue);
}
}
}
- return 1;
}
int
{
MESSAGE("VISU_MEDConvertor::LoadField");
//Check on loading already done
- PIDMapperFilter anIDMapperFilter = theValForTime->myIDMapperFilter;
- if(anIDMapperFilter->myIsVTKDone)
+ VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = theValForTime->myUnstructuredGridIDMapper;
+ if(anUnstructuredGridIDMapper->myIsVTKDone)
return 0;
- PCProfile aProfile(new TCProfile());
+ VISU::PCProfile aProfile(new VISU::TCProfile());
aProfile->myIsAll = true;
theValForTime->myProfile = aProfile;
if(!aFieldDouble->_is_nil()){
SALOME_MED::double_array_var anArray = aFieldDouble->getValue(SALOME_MED::MED_FULL_INTERLACE);
if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDDOUBLE = "<<anArray->length());
- ::ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity);
+ ImportField<CORBA::Double>(anArray,
+ theMesh,
+ theField,
+ theValForTime,
+ theMeshOnEntity);
}
+
SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(aMEDField);
if(!aFieldInt->_is_nil()){
SALOME_MED::long_array_var anArray = aFieldInt->getValue(SALOME_MED::MED_FULL_INTERLACE);
if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDINT = "<<anArray->length());
- ::ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity);
+ ImportField<CORBA::Long>(anArray,
+ theMesh,
+ theField,
+ theValForTime,
+ theMeshOnEntity);
}
- anIDMapperFilter->myIsVTKDone = true;
+ anUnstructuredGridIDMapper->myIsVTKDone = true;
MESSAGE("VISU_MEDConvertor::LoadField done");
return 1;
#include "VISUConfig.hh"
#include "VISU_Convertor_impl.hxx"
+#include "VISU_Structures_impl.hxx"
+#include "VISU_PointCoords.hxx"
+#include "VISU_MeshValue.hxx"
#include <string>
namespace VISU
{
- typedef std::pair<int,int> TIndexAndSize; //
- typedef std::map<SALOME_MED::medGeometryElement,TIndexAndSize> TCellsFirstIndex; // key: SALOME_MED::medGeometryElement
+ //---------------------------------------------------------------
+ typedef std::pair<int, int> TIndexAndSize; //
+ typedef std::map<SALOME_MED::medGeometryElement, TIndexAndSize> TCellsFirstIndex; // key: SALOME_MED::medGeometryElement
+
+ //---------------------------------------------------------------
+ struct TCMEDCoordHolder: TCoordHolder<SALOME_MED::double_array_var>
+ {
+ virtual
+ const TCoord*
+ GetPointer() const
+ {
+ return &myCoord[0];
+ }
+
+ virtual
+ TCoord*
+ GetPointer()
+ {
+ return &myCoord[0];
+ }
+ };
+
+
+ //---------------------------------------------------------------
+ template<class TValueType, class TContainerType>
+ struct TTCMEDMeshValue: TTMeshValueHolder<TValueType, TContainerType>
+ {
+ typedef TTMeshValueHolder<TValueType, TContainerType> TSuperClass;
+ vtkIdType myStartIndex;
+
+ //! To initilize the class instance
+ void
+ Init(vtkIdType theNbElem,
+ vtkIdType theNbGauss,
+ vtkIdType theNbComp,
+ const TContainerType& theContainer,
+ vtkIdType theStartIndex)
+ {
+ TSuperClass::Init(theNbElem, theNbGauss, theNbComp, theContainer);
+ myStartIndex = theStartIndex;
+ }
+
+ virtual
+ const TValueType*
+ GetPointer() const
+ {
+ return &(this->myContainer[myStartIndex]);
+ }
+
+ virtual
+ TValueType*
+ GetPointer()
+ {
+ return &(this->myContainer[myStartIndex]);
+ }
+ };
+
+
//---------------------------------------------------------------
struct TCMesh: virtual TMeshImpl
{
SALOME_MED::MESH_var myMesh;
};
- typedef SharedPtr<TCMesh> PCMesh;
+ typedef MED::SharedPtr<TCMesh> PCMesh;
//---------------------------------------------------------------
struct TCSubProfile: virtual TSubProfileImpl
//---------------------------------------------------------------
struct TCProfile: virtual TProfileImpl
{};
- typedef SharedPtr<TCProfile> PCProfile;
+ typedef MED::SharedPtr<TCProfile> PCProfile;
//---------------------------------------------------------------
struct TCGauss: virtual TGaussImpl
//---------------------------------------------------------------
struct TCSubMesh: virtual TSubMeshImpl
- {
- };
- typedef SharedPtr<TCSubMesh> PCSubMesh;
+ {};
+ typedef MED::SharedPtr<TCSubMesh> PCSubMesh;
//---------------------------------------------------------------
SALOME_MED::SUPPORT_var mySupport;
TCellsFirstIndex myCellsFirstIndex;
};
- typedef SharedPtr<TCMeshOnEntity> PCMeshOnEntity;
+ typedef MED::SharedPtr<TCMeshOnEntity> PCMeshOnEntity;
//---------------------------------------------------------------
{
SALOME_MED::FAMILY_var myFamily;
};
- typedef SharedPtr<TCFamily> PCFamily;
+ typedef MED::SharedPtr<TCFamily> PCFamily;
//---------------------------------------------------------------
{
SALOME_MED::GROUP_var myGroup;
};
- typedef SharedPtr<TCGroup> PCGroup;
+ typedef MED::SharedPtr<TCGroup> PCGroup;
//---------------------------------------------------------------
struct TCField: virtual TFieldImpl
{};
- typedef SharedPtr<TCField> PCField;
+ typedef MED::SharedPtr<TCField> PCField;
//---------------------------------------------------------------
{
SALOME_MED::FIELD_var myField;
};
- typedef SharedPtr<TCValForTime> PCValForTime;
+ typedef MED::SharedPtr<TCValForTime> PCValForTime;
}
-class VISU_MEDConvertor: public VISU_Convertor_impl{
+//---------------------------------------------------------------
+class VISU_MEDConvertor: public VISU_Convertor_impl
+{
protected:
SALOMEDS::SObject_var mySObject;
VISU_MEDConvertor() {};
};
+
+//---------------------------------------------------------------
class VISU_MEDFieldConvertor: public VISU_MEDConvertor
{
protected:
#include <vtkAppendPolyData.h>
-using namespace VISU;
-using namespace std;
-
static vtkFloatingPointType EPS_machine = 1.0E-7;
#ifdef _DEBUG_
static int MYDEBUG = 0;
#endif
-int VISU::CutLines_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration, int isMemoryCheck)
+
+//---------------------------------------------------------------
+size_t
+VISU::CutLines_i
+::IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck)
{
- return TSuperClass::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck);
+ return TSuperClass::IsPossible(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber,
+ theIsMemoryCheck);
}
+//---------------------------------------------------------------
int VISU::CutLines_i::myNbPresent = 0;
-QString VISU::CutLines_i::GenerateName() { return VISU::GenerateName("CutLines",myNbPresent++);}
+//---------------------------------------------------------------
+QString
+VISU::CutLines_i::GenerateName()
+{
+ return VISU::GenerateName("CutLines",myNbPresent++);
+}
+
+//---------------------------------------------------------------
const string VISU::CutLines_i::myComment = "CUTLINES";
-const char* VISU::CutLines_i::GetComment() const { return myComment.c_str();}
+//---------------------------------------------------------------
+const char*
+VISU::CutLines_i
+::GetComment() const
+{
+ return myComment.c_str();
+}
+
+//----------------------------------------------------------------------------
+const char*
+VISU::CutLines_i
+::GetIconName()
+{
+ if (!IsGroupsUsed())
+ return "ICON_TREE_CUT_LINES";
+ else
+ return "ICON_TREE_CUT_LINES_GROUPS";
+}
+//---------------------------------------------------------------
VISU::CutLines_i::
-CutLines_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theAddToStudy),
- ColoredPrs3d_i(theResult,theAddToStudy),
- ScalarMap_i(theResult,theAddToStudy),
- TSuperClass(theResult,theAddToStudy),
- myCutLinesPL(NULL),
- myUseAbsLength(false)
+CutLines_i(EPublishInStudyMode thePublishInStudyMode) :
+ ColoredPrs3d_i(thePublishInStudyMode),
+ ScalarMap_i(thePublishInStudyMode),
+ myCutLinesPL(NULL)
{}
-VISU::CutLines_i::
-CutLines_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
- ColoredPrs3d_i(theResult,theSObject),
- ScalarMap_i(theResult,theSObject),
- TSuperClass(theResult,theSObject),
- myCutLinesPL(NULL),
- myUseAbsLength(false)
+//---------------------------------------------------------------
+void
+VISU::CutLines_i
+::SameAs(const Prs3d_i* theOrigin)
{
+ TSuperClass::SameAs(theOrigin);
+
+ if(const CutLines_i* aPrs3d = dynamic_cast<const CutLines_i*>(theOrigin)){
+ CutLines_i* anOrigin = const_cast<CutLines_i*>(aPrs3d);
+ myUseAbsLength = anOrigin->IsUseAbsoluteLength();
+ CopyCurvesInverted(anOrigin->GetCurvesInverted());
+ }
}
+//---------------------------------------------------------------
/*! Copy map to /a myMapCurvesInverted.
* \param theCurves - map
*/
-void VISU::CutLines_i::CopyCurvesInverted(const TCurvesInv& theCurves){
+void
+VISU::CutLines_i
+::CopyCurvesInverted(const TCurvesInv& theCurves)
+{
myMapCurvesInverted = theCurves;
}
-VISU::Storable* VISU::CutLines_i::Create(const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration)
-{
- TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
- SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
- SetAllCurvesInverted( aResourceMgr->booleanValue("VISU", "invert_all_curves", false) );
- SetUseAbsoluteLength( aResourceMgr->booleanValue("VISU", "use_absolute_length", false) );
- return this;
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::CutLines_i
+::Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
+{
+ return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
}
-VISU::Storable* VISU::CutLines_i::Restore(const Storable::TRestoringMap& theMap)
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::CutLines_i
+::Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
{
- TSuperClass::Restore(theMap);
+ if(!TSuperClass::Restore(theStudy, theMap))
+ return NULL;
SetNbLines(VISU::Storable::FindValue(theMap,"myNbLines").toInt());
SetDisplacement(VISU::Storable::FindValue(theMap,"myDisplacement[0]").toDouble());
}
-void VISU::CutLines_i::ToStream(std::ostringstream& theStr){
+//---------------------------------------------------------------
+void
+VISU::CutLines_i
+::ToStream(std::ostringstream& theStr)
+{
TSuperClass::ToStream(theStr);
int aNbLines = GetNbLines();
Storable::DataToStream( theStr, "myMapCurvesInverted", aStrCurvesInverted.latin1());
}
-VISU::CutLines_i::~CutLines_i(){
+
+//---------------------------------------------------------------
+VISU::CutLines_i
+::~CutLines_i()
+{
if(MYDEBUG) MESSAGE("CutLines_i::~CutLines_i()");
}
-void VISU::CutLines_i::SetOrientation(VISU::CutPlanes::Orientation theOrient,
- CORBA::Double theXAngle, CORBA::Double theYAngle)
+//---------------------------------------------------------------
+void
+VISU::CutLines_i
+::SetOrientation(VISU::CutPlanes::Orientation theOrient,
+ CORBA::Double theXAngle,
+ CORBA::Double theYAngle)
{
-
- struct TEvent: public SALOME_Event {
+ struct TEvent: public SALOME_Event
+ {
VISU_CutLinesPL* myCutLinesPL;
CORBA::Double myXAngle, myYAngle;
VISU::CutPlanes::Orientation myOrient;
- TEvent( VISU_CutLinesPL* theCutLines, VISU::CutPlanes::Orientation theOrient,
- CORBA::Double theXAngle, CORBA::Double theYAngle)
- :myCutLinesPL(theCutLines), myOrient(theOrient), myXAngle(theXAngle), myYAngle(theYAngle)
+ TEvent(VISU_CutLinesPL* theCutLines,
+ VISU::CutPlanes::Orientation theOrient,
+ CORBA::Double theXAngle,
+ CORBA::Double theYAngle):
+ myCutLinesPL(theCutLines),
+ myOrient(theOrient),
+ myXAngle(theXAngle),
+ myYAngle(theYAngle)
{}
virtual
Execute()
{
myCutLinesPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(myOrient),
- myXAngle, myYAngle);
+ myXAngle,
+ myYAngle);
}
};
}
-void VISU::CutLines_i::SetOrientation2(VISU::CutPlanes::Orientation theOrient,
- CORBA::Double theXAngle, CORBA::Double theYAngle)
+//---------------------------------------------------------------
+void
+VISU::CutLines_i
+::SetOrientation2(VISU::CutPlanes::Orientation theOrient,
+ CORBA::Double theXAngle,
+ CORBA::Double theYAngle)
{
- struct TEvent: public SALOME_Event {
+ struct TEvent: public SALOME_Event
+ {
VISU_CutLinesPL* myCutLinesPL;
CORBA::Double myXAngle, myYAngle;
VISU::CutPlanes::Orientation myOrient;
- TEvent( VISU_CutLinesPL* theCutLines, VISU::CutPlanes::Orientation theOrient,
- CORBA::Double theXAngle, CORBA::Double theYAngle)
- :myCutLinesPL(theCutLines), myOrient(theOrient), myXAngle(theXAngle), myYAngle(theYAngle)
+ TEvent(VISU_CutLinesPL* theCutLines,
+ VISU::CutPlanes::Orientation theOrient,
+ CORBA::Double theXAngle,
+ CORBA::Double theYAngle):
+ myCutLinesPL(theCutLines),
+ myOrient(theOrient),
+ myXAngle(theXAngle),
+ myYAngle(theYAngle)
{}
virtual
Execute()
{
myCutLinesPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(myOrient),
- myXAngle, myYAngle, 1);
+ myXAngle,
+ myYAngle,
+ 1);
}
};
ProcessVoidEvent(new TEvent(myCutLinesPL, theOrient, theXAngle, theYAngle));
-
}
-VISU::CutPlanes::Orientation VISU::CutLines_i::GetOrientationType() {
+//---------------------------------------------------------------
+VISU::CutPlanes::Orientation
+VISU::CutLines_i
+::GetOrientationType()
+{
return VISU::CutPlanes::Orientation(myCutLinesPL->GetPlaneOrientation());
}
-VISU::CutPlanes::Orientation VISU::CutLines_i::GetOrientationType2() {
+
+//---------------------------------------------------------------
+VISU::CutPlanes::Orientation
+VISU::CutLines_i
+::GetOrientationType2()
+{
return VISU::CutPlanes::Orientation(myCutLinesPL->GetPlaneOrientation(1));
}
-CORBA::Double VISU::CutLines_i::GetRotateX(){
+//---------------------------------------------------------------
+CORBA::Double
+VISU::CutLines_i
+::GetRotateX()
+{
return myCutLinesPL->GetRotateX();
}
-CORBA::Double VISU::CutLines_i::GetRotateY(){
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::CutLines_i
+::GetRotateY()
+{
return myCutLinesPL->GetRotateY();
}
-CORBA::Double VISU::CutLines_i::GetRotateX2(){
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::CutLines_i
+::GetRotateX2()
+{
return myCutLinesPL->GetRotateX(1);
}
-CORBA::Double VISU::CutLines_i::GetRotateY2(){
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::CutLines_i
+::GetRotateY2()
+{
return myCutLinesPL->GetRotateY(1);
}
-void VISU::CutLines_i::SetDisplacement(CORBA::Double theDisp) {
+//---------------------------------------------------------------
+void
+VISU::CutLines_i
+::SetDisplacement(CORBA::Double theDisp)
+{
myCutLinesPL->SetDisplacement(theDisp);
}
-void VISU::CutLines_i::SetDisplacement2(CORBA::Double theDisp) {
+
+//---------------------------------------------------------------
+void
+VISU::CutLines_i
+::SetDisplacement2(CORBA::Double theDisp)
+{
myCutLinesPL->SetDisplacement(theDisp,1);
}
-CORBA::Double VISU::CutLines_i::GetDisplacement() {
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::CutLines_i
+::GetDisplacement()
+{
return myCutLinesPL->GetDisplacement();
}
-CORBA::Double VISU::CutLines_i::GetDisplacement2() {
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::CutLines_i
+::GetDisplacement2()
+{
return myCutLinesPL->GetDisplacement(1);
}
-void VISU::CutLines_i::SetBasePlanePosition(CORBA::Double thePlanePosition){
+//---------------------------------------------------------------
+void
+VISU::CutLines_i
+::SetBasePlanePosition(CORBA::Double thePlanePosition)
+{
myCutLinesPL->SetPosition(thePlanePosition);
}
-CORBA::Double VISU::CutLines_i::GetBasePlanePosition(){
+//---------------------------------------------------------------
+CORBA::Double
+VISU::CutLines_i
+::GetBasePlanePosition()
+{
return myCutLinesPL->GetPosition();
}
-void VISU::CutLines_i::SetLinePosition(CORBA::Long thePlaneNumber, CORBA::Double thePlanePosition){
+//---------------------------------------------------------------
+void
+VISU::CutLines_i
+::SetLinePosition(CORBA::Long thePlaneNumber,
+ CORBA::Double thePlanePosition)
+{
myCutLinesPL->SetPartPosition(thePlaneNumber,thePlanePosition);
}
-CORBA::Double VISU::CutLines_i::GetLinePosition(CORBA::Long thePlaneNumber){
+//---------------------------------------------------------------
+CORBA::Double
+VISU::CutLines_i
+::GetLinePosition(CORBA::Long thePlaneNumber)
+{
return myCutLinesPL->GetPartPosition(thePlaneNumber,1);
}
-void VISU::CutLines_i::SetDefault(){
+//---------------------------------------------------------------
+void
+VISU::CutLines_i
+::SetDefault()
+{
myCutLinesPL->SetDefault();
}
-CORBA::Boolean VISU::CutLines_i::IsDefault(){
+//---------------------------------------------------------------
+CORBA::Boolean
+VISU::CutLines_i
+::IsDefault()
+{
return myCutLinesPL->IsDefault();
}
-void VISU::CutLines_i::SetDefaultPosition(CORBA::Long thePlaneNumber){
+//---------------------------------------------------------------
+void
+VISU::CutLines_i
+::SetDefaultPosition(CORBA::Long thePlaneNumber)
+{
myCutLinesPL->SetPartDefault(thePlaneNumber);
}
-CORBA::Boolean VISU::CutLines_i::IsDefaultPosition(CORBA::Long thePlaneNumber){
+//---------------------------------------------------------------
+CORBA::Boolean
+VISU::CutLines_i
+::IsDefaultPosition(CORBA::Long thePlaneNumber)
+{
return myCutLinesPL->IsPartDefault(thePlaneNumber);
}
+//---------------------------------------------------------------
/*! Invert all curves of corresponding table
* see void VISU::CutLines_i::SetCurveInverted(CORBA::Long theCurveNumber,CORBA::Boolean theInvert)
* \param theInvert - Invert all curves, if value is TRUE, else not.
*/
-void VISU::CutLines_i::SetAllCurvesInverted(CORBA::Boolean theInvert){
- for (int i=0; i<GetNbLines(); i++) SetCurveInverted(i,theInvert);
+void
+VISU::CutLines_i
+::SetAllCurvesInverted(CORBA::Boolean theInvert)
+{
+ for(int i=0; i<GetNbLines(); i++)
+ SetCurveInverted(i, theInvert);
}
+//---------------------------------------------------------------
/*! Checks the orientation of all curves
* \retval TRUE - if all curves are inverted, else FALSE
*/
-CORBA::Boolean VISU::CutLines_i::IsAllCurvesInverted(){
+CORBA::Boolean
+VISU::CutLines_i
+::IsAllCurvesInverted()
+{
for (int i=0; i<GetNbLines(); i++)
if (!IsCurveInverted(i)) return false;
return true;
}
+//---------------------------------------------------------------
/*! Sets orientation of curve
* \param theCurveNumber - integer value, number of cut line.
* \param theInvert - boolean value, TRUE or false.
*/
-void VISU::CutLines_i::SetCurveInverted(CORBA::Long theCurveNumber,CORBA::Boolean theInvert){
+void
+VISU::CutLines_i
+::SetCurveInverted(CORBA::Long theCurveNumber,CORBA::Boolean theInvert)
+{
myMapCurvesInverted[theCurveNumber] = theInvert;
}
+//---------------------------------------------------------------
+/*! Checks orientation of curve.
+ * \param theCurveNumber - integer value, number of cut line.
+ * \retval TRUE - if line in the table is inverted, else FALSE.
+ */
+CORBA::Boolean
+VISU::CutLines_i
+::IsCurveInverted(CORBA::Long theCurveNumber)
+{
+ return myMapCurvesInverted[theCurveNumber];
+}
+
+//---------------------------------------------------------------
/*! It control the way the length of cutlines is shown: using aboslute or relative values
* \param theAbsLength - boolean value, TRUE or false.
*/
-void VISU::CutLines_i::SetUseAbsoluteLength(CORBA::Boolean theAbsLength){
+void
+VISU::CutLines_i
+::SetUseAbsoluteLength(CORBA::Boolean theAbsLength)
+{
myUseAbsLength = theAbsLength;
}
-/*! Checks orientation of curve.
- * \param theCurveNumber - integer value, number of cut line.
- * \retval TRUE - if line in the table is inverted, else FALSE.
- */
-CORBA::Boolean VISU::CutLines_i::IsCurveInverted(CORBA::Long theCurveNumber){
- return myMapCurvesInverted[theCurveNumber];
+//---------------------------------------------------------------
+CORBA::Boolean
+VISU::CutLines_i
+::IsUseAbsoluteLength()
+{
+ return myUseAbsLength;
}
-void VISU::CutLines_i::SetNbLines(CORBA::Long theNb) {
+//---------------------------------------------------------------
+void
+VISU::CutLines_i
+::SetNbLines(CORBA::Long theNb)
+{
myCutLinesPL->SetNbParts(theNb);
}
-CORBA::Long VISU::CutLines_i::GetNbLines() {
+
+//---------------------------------------------------------------
+CORBA::Long
+VISU::CutLines_i
+::GetNbLines()
+{
return myCutLinesPL->GetNbParts();
}
-void VISU::CutLines_i::DoHook(){
- if(!myPipeLine) myPipeLine = VISU_CutLinesPL::New();
- myCutLinesPL = dynamic_cast<VISU_CutLinesPL*>(myPipeLine);
+//---------------------------------------------------------------
+void
+VISU::CutLines_i
+::CreatePipeLine(VISU_PipeLine* thePipeLine)
+{
+ if(!thePipeLine){
+ myCutLinesPL = VISU_CutLinesPL::New();
+ }else
+ myCutLinesPL = dynamic_cast<VISU_CutLinesPL*>(thePipeLine);
- TSuperClass::DoHook();
+ TSuperClass::CreatePipeLine(myCutLinesPL);
}
-const char*
+
+//----------------------------------------------------------------------------
+bool
VISU::CutLines_i
-::GetIconName()
+::CheckIsPossible()
{
- if (!GetNumberOfGeom())
- return "ICON_TREE_CUT_LINES";
- else
- return "ICON_TREE_CUT_LINES_GROUPS";
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
}
+
+//---------------------------------------------------------------
VISU_Actor*
VISU::CutLines_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+::CreateActor()
{
- if(VISU_Actor* anActor = TSuperClass::CreateActor(theIO)){
+ if(VISU_Actor* anActor = TSuperClass::CreateActor()){
anActor->SetVTKMapping(true);
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
int aDispMode = aResourceMgr->integerValue("VISU" , "cut_lines_represent", 2);
return NULL;
}
-void VISU::CutLines_i::BuildTableOfReal(SALOMEDS::SObject_ptr theSObject){
+//---------------------------------------------------------------
+void
+VISU::CutLines_i
+::BuildTableOfReal(SALOMEDS::SObject_var theSObject)
+{
try{
if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal");
Update();
SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = GetStudyDocument()->NewBuilder();
anAttr = aStudyBuilder->FindOrCreateAttribute(theSObject, "AttributeTableOfReal");
SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
typedef map<long,long> TLineIdCont;
QString aTitle;
- aTitle.sprintf("%s",myTitle.c_str());
+ aTitle.sprintf("%s",GetCTitle().c_str());
aTitle = aTitle.simplifyWhiteSpace();
aTableOfReal->SetTitle(aTitle.latin1());
}
aXYMap[aDist] = aScalars->GetTuple1(i);
}
- if(aFilter){
- // commented: porting to vtk 5.0
- //aFilter->UnRegisterAllOutputs();
+ if(aFilter)
aFilter->Delete();
- }
}
if(aXYMapCont.size() == 0)
throw std::runtime_error("CutPlanes_i::BuildTableOfReal aXYMapCont.size() == 0 !!!");
{
aTableOfReal->SetRowTitle(1,"X");
aTableOfReal->SetRowUnit(1,"-");
- QString aUnitName = myField->myUnitNames[0].c_str();
+ QString aUnitName = GetField()->myUnitNames[0].c_str();
int aScalarMode = myCutLinesPL->GetScalarMode();
if(aScalarMode != 0)
- aUnitName = myField->myUnitNames[aScalarMode-1].c_str();
+ aUnitName = GetField()->myUnitNames[aScalarMode-1].c_str();
aUnitName = aUnitName.simplifyWhiteSpace();
if(aUnitName.isEmpty()) aUnitName = "-";
TXYMapCont::const_iterator aXYMapContIter = aXYMapCont.begin();
INFOS("Unknown exception was occured !!!");
}
}
-
-void VISU::CutLines_i::SameAs(const Prs3d_i* theOrigin){
- TSuperClass::SameAs(theOrigin);
- if(const CutLines_i* aPrs3d = dynamic_cast<const CutLines_i*>(theOrigin)){
- CutLines_i* anOrigin = const_cast<CutLines_i*>(aPrs3d);
- myUseAbsLength = anOrigin->IsUseAbsoluteLength();
- CopyCurvesInverted(anOrigin->GetCurvesInverted());
- }
-}
-
#ifndef VISU_CutLines_i_HeaderFile
#define VISU_CutLines_i_HeaderFile
-#include "VISU_PrsMerger_i.hh"
+#include "VISU_ScalarMap_i.hh"
class VISU_CutLinesPL;
-namespace VISU{
- class VISU_I_EXPORT CutLines_i : public virtual POA_VISU::CutLines,
- public virtual PrsMerger_i
+namespace VISU
+{
+ //----------------------------------------------------------------------------
+ class CutLines_i : public virtual POA_VISU::CutLines,
+ public virtual ScalarMap_i
{
static int myNbPresent;
CutLines_i(const CutLines_i&);
public:
- typedef PrsMerger_i TSuperClass;
+ //----------------------------------------------------------------------------
+ typedef ScalarMap_i TSuperClass;
+ typedef VISU::CutLines TInterface;
explicit
- CutLines_i(Result_i* theResult,
- bool theAddToStudy);
- explicit
- CutLines_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject);
- virtual ~CutLines_i();
+ CutLines_i(EPublishInStudyMode thePublishInStudyModep);
+
+ virtual
+ ~CutLines_i();
- virtual VISU::VISUType GetType() { return VISU::TCUTLINES;};
+ virtual
+ VISU::VISUType
+ GetType()
+ {
+ return VISU::TCUTLINES;
+ }
+
+ virtual
+ void
+ SetOrientation(VISU::CutPlanes::Orientation theOrient,
+ CORBA::Double theXAngle,
+ CORBA::Double theYAngle);
+
+ virtual
+ void
+ SetOrientation2(VISU::CutPlanes::Orientation theOrient,
+ CORBA::Double theXAngle,
+ CORBA::Double theYAngle);
- virtual void SetOrientation(VISU::CutPlanes::Orientation theOrient,
- CORBA::Double theXAngle, CORBA::Double theYAngle);
- virtual void SetOrientation2(VISU::CutPlanes::Orientation theOrient,
- CORBA::Double theXAngle, CORBA::Double theYAngle);
+ virtual
+ VISU::CutPlanes::Orientation
+ GetOrientationType();
- virtual VISU::CutPlanes::Orientation GetOrientationType();
- virtual VISU::CutPlanes::Orientation GetOrientationType2();
+ virtual
+ VISU::CutPlanes::Orientation
+ GetOrientationType2();
- virtual CORBA::Double GetRotateX();
- virtual CORBA::Double GetRotateY();
+ virtual
+ CORBA::Double
+ GetRotateX();
- virtual CORBA::Double GetRotateX2();
- virtual CORBA::Double GetRotateY2();
+ virtual
+ CORBA::Double
+ GetRotateY();
- virtual void SetDisplacement(CORBA::Double theDisp);
- virtual CORBA::Double GetDisplacement();
+ virtual
+ CORBA::Double
+ GetRotateX2();
- virtual void SetDisplacement2(CORBA::Double theDisp);
- virtual CORBA::Double GetDisplacement2();
+ virtual
+ CORBA::Double
+ GetRotateY2();
- virtual void SetBasePlanePosition(CORBA::Double thePlanePosition);
- virtual CORBA::Double GetBasePlanePosition();
+ virtual
+ void
+ SetDisplacement(CORBA::Double theDisp);
- virtual void SetLinePosition(CORBA::Long thePlaneNumber, CORBA::Double thePlanePosition);
- virtual CORBA::Double GetLinePosition(CORBA::Long thePlaneNumber);
+ virtual
+ CORBA::Double
+ GetDisplacement();
- virtual void SetDefault();
- virtual CORBA::Boolean IsDefault();
+ virtual
+ void
+ SetDisplacement2(CORBA::Double theDisp);
- virtual void SetDefaultPosition(CORBA::Long thePlaneNumber);
- virtual CORBA::Boolean IsDefaultPosition(CORBA::Long thePlaneNumber);
+ virtual
+ CORBA::Double
+ GetDisplacement2();
- virtual void SetAllCurvesInverted(CORBA::Boolean theInvert);
- virtual CORBA::Boolean IsAllCurvesInverted();
- virtual void SetCurveInverted(CORBA::Long theCurveNumber,CORBA::Boolean theInvert);
- virtual CORBA::Boolean IsCurveInverted(CORBA::Long theCurveNumber);
+ virtual
+ void
+ SetBasePlanePosition(CORBA::Double thePlanePosition);
- virtual void SetUseAbsoluteLength(CORBA::Boolean theAbsLength);
- virtual CORBA::Boolean IsUseAbsoluteLength() {return myUseAbsLength;}
+ virtual
+ CORBA::Double
+ GetBasePlanePosition();
+
+ virtual
+ void
+ SetLinePosition(CORBA::Long thePlaneNumber,
+ CORBA::Double thePlanePosition);
+
+ virtual
+ CORBA::Double
+ GetLinePosition(CORBA::Long thePlaneNumber);
+
+ virtual
+ void
+ SetDefault();
+
+ virtual
+ CORBA::Boolean
+ IsDefault();
+
+ virtual
+ void
+ SetDefaultPosition(CORBA::Long thePlaneNumber);
+
+ virtual
+ CORBA::Boolean
+ IsDefaultPosition(CORBA::Long thePlaneNumber);
+
+ virtual
+ void
+ SetAllCurvesInverted(CORBA::Boolean theInvert);
+
+ virtual
+ CORBA::Boolean
+ IsAllCurvesInverted();
+
+ virtual
+ void
+ SetCurveInverted(CORBA::Long theCurveNumber,
+ CORBA::Boolean theInvert);
+
+ virtual
+ CORBA::Boolean
+ IsCurveInverted(CORBA::Long theCurveNumber);
+
+ virtual
+ void
+ SetUseAbsoluteLength(CORBA::Boolean theAbsLength);
+
+ virtual
+ CORBA::Boolean
+ IsUseAbsoluteLength();
+
+ virtual
+ void
+ SetNbLines(CORBA::Long theNb);
+
+ virtual
+ CORBA::Long
+ GetNbLines();
- virtual void SetNbLines(CORBA::Long theNb);
- virtual CORBA::Long GetNbLines();
- typedef VISU::CutLines TInterface;
- VISU_CutLinesPL* GetCutLinesPL(){ return myCutLinesPL;}
-
typedef std::map<int,bool> TCurvesInv;
- TCurvesInv GetCurvesInverted() {return myMapCurvesInverted;}
- void CopyCurvesInverted(const TCurvesInv& theCurves);
+ TCurvesInv
+ GetCurvesInverted()
+ {
+ return myMapCurvesInverted;
+ }
+
+ void
+ CopyCurvesInverted(const TCurvesInv& theCurves);
+ VISU_CutLinesPL*
+ GetSpecificPL() const
+ {
+ return myCutLinesPL;
+ }
+
protected:
- virtual void DoHook();
+ //! Extends VISU_ColoredPrs3d_i::CreatePipeLine
+ virtual
+ void
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
- virtual const char* GetIconName();
+ //! Extends VISU_ColoredPrs3d_i::CheckIsPossible
+ virtual
+ bool
+ CheckIsPossible();
+
+ virtual
+ const char*
+ GetIconName();
VISU_CutLinesPL *myCutLinesPL;
TCurvesInv myMapCurvesInverted;
CORBA::Boolean myUseAbsLength;
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);
+ //! Extends VISU_ColoredPrs3d_i::IsPossible
+ static
+ size_t
+ IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck);
- virtual void ToStream(std::ostringstream& theStr);
+ //! Extends VISU_ColoredPrs3d_i::Create
+ virtual
+ Storable*
+ Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber);
+
+ //! Extends VISU_ColoredPrs3d_i::ToStream
+ virtual
+ void
+ ToStream(std::ostringstream& theStr);
- virtual Storable* Restore(const Storable::TRestoringMap& theMap);
- virtual void SameAs( const Prs3d_i* Origin );
+ //! Extends VISU_ColoredPrs3d_i::Restore
+ virtual
+ Storable*
+ Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap);
+ virtual
+ void
+ SameAs(const Prs3d_i* theOrigin);
+
+ //! Extends VISU_ColoredPrs3d_i::CreateActor
virtual
VISU_Actor*
- CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
+ CreateActor();
- void BuildTableOfReal(SALOMEDS::SObject_ptr theSObject);
+ void BuildTableOfReal(SALOMEDS::SObject_var theSObject);
static const std::string myComment;
- virtual const char* GetComment() const;
- virtual QString GenerateName();
+
+ virtual
+ const char*
+ GetComment() const;
+
+ virtual
+ QString
+ GenerateName();
};
}
#include "SUIT_ResourceMgr.h"
#include "SALOME_Event.hxx"
-using namespace VISU;
-using namespace std;
-
#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
#endif
-int VISU::CutPlanes_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration, int isMemoryCheck)
+
+//----------------------------------------------------------------------------
+size_t
+VISU::CutPlanes_i
+::IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck)
{
- return TSuperClass::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck);
+ return TSuperClass::IsPossible(theResult,theMeshName,theEntity,theFieldName,theTimeStampNumber,theIsMemoryCheck);
}
+//----------------------------------------------------------------------------
int VISU::CutPlanes_i::myNbPresent = 0;
-QString VISU::CutPlanes_i::GenerateName() { return VISU::GenerateName("CutPlanes",myNbPresent++);}
+//----------------------------------------------------------------------------
+QString
+VISU::CutPlanes_i
+::GenerateName()
+{
+ return VISU::GenerateName("CutPlanes",myNbPresent++);
+}
+//----------------------------------------------------------------------------
const string VISU::CutPlanes_i::myComment = "CUTPLANES";
-const char* VISU::CutPlanes_i::GetComment() const { return myComment.c_str();}
-
-VISU::CutPlanes_i::
-CutPlanes_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theAddToStudy),
- ColoredPrs3d_i(theResult,theAddToStudy),
- ScalarMap_i(theResult,theAddToStudy),
- TSuperClass(theResult,theAddToStudy),
- myCutPlanesPL(NULL)
-{}
+//----------------------------------------------------------------------------
+const char*
+VISU::CutPlanes_i
+::GetComment() const
+{
+ return myComment.c_str();
+}
-VISU::CutPlanes_i::
-CutPlanes_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
- ColoredPrs3d_i(theResult,theSObject),
- ScalarMap_i(theResult,theSObject),
- TSuperClass(theResult,theSObject),
- myCutPlanesPL(NULL)
+//----------------------------------------------------------------------------
+const char*
+VISU::CutPlanes_i
+::GetIconName()
{
+ if (!IsGroupsUsed())
+ return "ICON_TREE_CUT_PLANES";
+ else
+ return "ICON_TREE_CUT_PLANES_GROUPS";
}
-VISU::Storable* VISU::CutPlanes_i::Create(const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration)
+//----------------------------------------------------------------------------
+VISU::CutPlanes_i
+::CutPlanes_i(EPublishInStudyMode thePublishInStudyMode):
+ ColoredPrs3d_i(thePublishInStudyMode),
+ ScalarMap_i(thePublishInStudyMode),
+ myCutPlanesPL(NULL)
+{}
+
+
+//----------------------------------------------------------------------------
+VISU::Storable*
+VISU::CutPlanes_i
+::Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
{
- return TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
+ return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
}
-VISU::Storable* VISU::CutPlanes_i::Restore(const Storable::TRestoringMap& theMap)
+//----------------------------------------------------------------------------
+VISU::Storable*
+VISU::CutPlanes_i
+::Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
{
- TSuperClass::Restore(theMap);
+ if(!TSuperClass::Restore(theStudy, theMap))
+ return NULL;
SetNbPlanes(VISU::Storable::FindValue(theMap,"myNbPlanes").toInt());
SetDisplacement(VISU::Storable::FindValue(theMap,"myDisplacement").toDouble());
}
+//----------------------------------------------------------------------------
void VISU::CutPlanes_i::ToStream(std::ostringstream& theStr){
TSuperClass::ToStream(theStr);
}
-VISU::CutPlanes_i::~CutPlanes_i(){
+//----------------------------------------------------------------------------
+VISU::CutPlanes_i
+::~CutPlanes_i()
+{
if(MYDEBUG) MESSAGE("CutPlanes_i::~CutPlanes_i()");
}
-void VISU::CutPlanes_i::SetOrientation(VISU::CutPlanes::Orientation theOrient,
- CORBA::Double theXAngle, CORBA::Double theYAngle)
+//----------------------------------------------------------------------------
+void
+VISU::CutPlanes_i
+::SetOrientation(VISU::CutPlanes::Orientation theOrient,
+ CORBA::Double theXAngle,
+ CORBA::Double theYAngle)
{
- struct TEvent: public SALOME_Event {
- VISU_CutPlanesPL* myCutPlanes;
- CORBA::Double myXAngle, myYAngle;
- VISU::CutPlanes::Orientation myOrient;
- TEvent( VISU_CutPlanesPL* theCutPlanes, VISU::CutPlanes::Orientation theOrient,
- CORBA::Double theXAngle, CORBA::Double theYAngle)
- :myCutPlanes(theCutPlanes), myOrient(theOrient), myXAngle(theXAngle), myYAngle(theYAngle)
- {}
-
- virtual
- void
- Execute()
- {
- myCutPlanes->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(myOrient),
- myXAngle, myYAngle);
- }
- };
-
- ProcessVoidEvent(new TEvent(myCutPlanesPL, theOrient, theXAngle, theYAngle));
-}
-
-VISU::CutPlanes::Orientation VISU::CutPlanes_i::GetOrientationType() {
+ myCutPlanesPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(theOrient),
+ theXAngle,
+ theYAngle);
+}
+
+//----------------------------------------------------------------------------
+VISU::CutPlanes::Orientation
+VISU::CutPlanes_i
+::GetOrientationType()
+{
return VISU::CutPlanes::Orientation(myCutPlanesPL->GetPlaneOrientation());
}
-CORBA::Double VISU::CutPlanes_i::GetRotateX(){
+
+//----------------------------------------------------------------------------
+CORBA::Double
+VISU::CutPlanes_i
+::GetRotateX()
+{
return myCutPlanesPL->GetRotateX();
}
-CORBA::Double VISU::CutPlanes_i::GetRotateY(){
+
+//----------------------------------------------------------------------------
+CORBA::Double
+VISU::CutPlanes_i
+::GetRotateY()
+{
return myCutPlanesPL->GetRotateY();
}
-void VISU::CutPlanes_i::SetDisplacement(CORBA::Double theDisp) {
+//----------------------------------------------------------------------------
+void
+VISU::CutPlanes_i
+::SetDisplacement(CORBA::Double theDisp)
+{
myCutPlanesPL->SetDisplacement(theDisp);
}
-CORBA::Double VISU::CutPlanes_i::GetDisplacement() {
+
+//----------------------------------------------------------------------------
+CORBA::Double
+VISU::CutPlanes_i
+::GetDisplacement()
+{
return myCutPlanesPL->GetDisplacement();
}
-void VISU::CutPlanes_i::SetPlanePosition(CORBA::Long thePlaneNumber, CORBA::Double thePlanePosition){
- myCutPlanesPL->SetPartPosition(thePlaneNumber,thePlanePosition);
+//----------------------------------------------------------------------------
+void
+VISU::CutPlanes_i
+::SetPlanePosition(CORBA::Long thePlaneNumber,
+ CORBA::Double thePlanePosition)
+{
+ myCutPlanesPL->SetPartPosition(thePlaneNumber, thePlanePosition);
}
-CORBA::Double VISU::CutPlanes_i::GetPlanePosition(CORBA::Long thePlaneNumber){
+
+//----------------------------------------------------------------------------
+CORBA::Double
+VISU::CutPlanes_i
+::GetPlanePosition(CORBA::Long thePlaneNumber)
+{
return myCutPlanesPL->GetPartPosition(thePlaneNumber);
}
-void VISU::CutPlanes_i::SetDefault(CORBA::Long thePlaneNumber){
+//----------------------------------------------------------------------------
+void
+VISU::CutPlanes_i
+::SetDefault(CORBA::Long thePlaneNumber)
+{
myCutPlanesPL->SetPartDefault(thePlaneNumber);
}
-CORBA::Boolean VISU::CutPlanes_i::IsDefault(CORBA::Long thePlaneNumber){
+
+//----------------------------------------------------------------------------
+CORBA::Boolean
+VISU::CutPlanes_i
+::IsDefault(CORBA::Long thePlaneNumber)
+{
return myCutPlanesPL->IsPartDefault(thePlaneNumber);
}
-void VISU::CutPlanes_i::SetNbPlanes(CORBA::Long theNb) {
-
- struct TEvent: public SALOME_Event {
- VISU_CutPlanesPL* myCutPlanes;
- CORBA::Long myNbPlanes;
- TEvent( VISU_CutPlanesPL* theCutPlanes, int theNbPlanes)
- :myCutPlanes(theCutPlanes), myNbPlanes(theNbPlanes)
- {}
-
- virtual
- void
- Execute()
- {
- myCutPlanes->SetNbParts(myNbPlanes);
- }
- };
-
- ProcessVoidEvent(new TEvent(myCutPlanesPL, theNb));
+//----------------------------------------------------------------------------
+void
+VISU::CutPlanes_i
+::SetNbPlanes(CORBA::Long theNb)
+{
+ myCutPlanesPL->SetNbParts(theNb);
}
-CORBA::Long VISU::CutPlanes_i::GetNbPlanes() {
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::CutPlanes_i
+::GetNbPlanes()
+{
return myCutPlanesPL->GetNbParts();
}
-void VISU::CutPlanes_i::DoHook(){
- if(!myPipeLine) myPipeLine = VISU_CutPlanesPL::New();
- myCutPlanesPL = dynamic_cast<VISU_CutPlanesPL*>(myPipeLine);
+//----------------------------------------------------------------------------
+void
+VISU::CutPlanes_i
+::CreatePipeLine(VISU_PipeLine* thePipeLine)
+{
+ if(!thePipeLine){
+ myCutPlanesPL = VISU_CutPlanesPL::New();
+ }else
+ myCutPlanesPL = dynamic_cast<VISU_CutPlanesPL*>(thePipeLine);
- TSuperClass::DoHook();
+ TSuperClass::CreatePipeLine(myCutPlanesPL);
}
-const char*
+
+//---------------------------------------------------------------
+bool
VISU::CutPlanes_i
-::GetIconName()
+::CheckIsPossible()
{
- if (!GetNumberOfGeom())
- return "ICON_TREE_CUT_PLANES";
- else
- return "ICON_TREE_CUT_PLANES_GROUPS";
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
}
+//----------------------------------------------------------------------------
VISU_Actor*
VISU::CutPlanes_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+::CreateActor()
{
- if(VISU_Actor* anActor = TSuperClass::CreateActor(theIO)){
+ if(VISU_Actor* anActor = TSuperClass::CreateActor()){
anActor->SetVTKMapping(true);
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
int aDispMode = aResourceMgr->integerValue("VISU" , "cut_planes_represent", 1);
#ifndef VISU_CutPlanes_i_HeaderFile
#define VISU_CutPlanes_i_HeaderFile
-#include "VISU_PrsMerger_i.hh"
+#include "VISU_ScalarMap_i.hh"
class VISU_CutPlanesPL;
-namespace VISU{
+namespace VISU
+{
+ //----------------------------------------------------------------------------
class VISU_I_EXPORT CutPlanes_i : public virtual POA_VISU::CutPlanes,
- public virtual PrsMerger_i
+ public virtual ScalarMap_i
{
static int myNbPresent;
CutPlanes_i(const CutPlanes_i&);
public:
- typedef PrsMerger_i TSuperClass;
+ //----------------------------------------------------------------------------
+ typedef ScalarMap_i TSuperClass;
+ typedef VISU::CutPlanes TInterface;
explicit
- CutPlanes_i(Result_i* theResult,
- bool theAddToStudy);
- explicit
- CutPlanes_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject);
- virtual ~CutPlanes_i();
+ CutPlanes_i(EPublishInStudyMode thePublishInStudyModep);
- virtual VISU::VISUType GetType() { return VISU::TCUTPLANES;};
+ virtual
+ ~CutPlanes_i();
- virtual void SetOrientation(VISU::CutPlanes::Orientation theOrient,
- CORBA::Double theXAngle, CORBA::Double theYAngle);
+ virtual
+ VISU::VISUType
+ GetType()
+ {
+ return VISU::TCUTPLANES;
+ }
- virtual VISU::CutPlanes::Orientation GetOrientationType();
- virtual CORBA::Double GetRotateX();
- virtual CORBA::Double GetRotateY();
+ virtual
+ void
+ SetOrientation(VISU::CutPlanes::Orientation theOrient,
+ CORBA::Double theXAngle,
+ CORBA::Double theYAngle);
- virtual void SetDisplacement(CORBA::Double theDisp);
- virtual CORBA::Double GetDisplacement();
+ virtual
+ VISU::CutPlanes::Orientation
+ GetOrientationType();
- virtual void SetPlanePosition(CORBA::Long thePlaneNumber, CORBA::Double thePlanePosition);
- virtual CORBA::Double GetPlanePosition(CORBA::Long thePlaneNumber);
+ virtual
+ CORBA::Double
+ GetRotateX();
- virtual void SetDefault(CORBA::Long thePlaneNumber);
- virtual CORBA::Boolean IsDefault(CORBA::Long thePlaneNumber);
+ virtual
+ CORBA::Double
+ GetRotateY();
- virtual void SetNbPlanes(CORBA::Long theNb);
- virtual CORBA::Long GetNbPlanes();
+ virtual
+ void
+ SetDisplacement(CORBA::Double theDisp);
- typedef VISU::CutPlanes TInterface;
- VISU_CutPlanesPL* GetCutPlanesPL(){ return myCutPlanesPL;}
+ virtual
+ CORBA::Double
+ GetDisplacement();
+ virtual
+ void
+ SetPlanePosition(CORBA::Long thePlaneNumber,
+ CORBA::Double thePlanePosition);
+ virtual
+ CORBA::Double
+ GetPlanePosition(CORBA::Long thePlaneNumber);
+
+ virtual
+ void
+ SetDefault(CORBA::Long thePlaneNumber);
+
+ virtual
+ CORBA::Boolean
+ IsDefault(CORBA::Long thePlaneNumber);
+
+ virtual
+ void
+ SetNbPlanes(CORBA::Long theNb);
+
+ virtual
+ CORBA::Long
+ GetNbPlanes();
+
+ VISU_CutPlanesPL*
+ GetSpecificPL() const
+ {
+ return myCutPlanesPL;
+ }
+
protected:
- virtual void DoHook();
+ //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine
+ virtual
+ void
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
- virtual const char* GetIconName();
+ //! Redefines VISU_ColoredPrs3d_i::CheckIsPossible
+ virtual
+ bool
+ CheckIsPossible();
VISU_CutPlanesPL *myCutPlanesPL;
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);
-
+ //! Redefines VISU_ColoredPrs3d_i::IsPossible
+ static
+ size_t
+ IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck);
+
+ //! Redefines VISU_ColoredPrs3d_i::Create
+ virtual
+ Storable*
+ Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber);
+
+ //! Redefines VISU_ColoredPrs3d_i::ToStream
+ virtual
+ void
+ ToStream(std::ostringstream& theStr);
+
+ //! Redefines VISU_ColoredPrs3d_i::Restore
+ virtual
+ Storable*
+ Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap);
+
+ //! Redefines VISU_ColoredPrs3d_i::CreateActor
virtual
VISU_Actor*
- CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
+ CreateActor();
static const std::string myComment;
- virtual const char* GetComment() const;
- virtual QString GenerateName();
+
+ //! Redefines VISU_ColoredPrs3d_i::GetComment
+ virtual
+ const char*
+ GetComment() const;
+
+ //! Redefines VISU_ColoredPrs3d_i::GenerateName
+ virtual
+ QString
+ GenerateName();
+
+ virtual
+ const char*
+ GetIconName();
};
}
#include <vtkDataSetMapper.h>
#include <vtkProperty.h>
-using namespace VISU;
-using namespace std;
-
#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
#endif
-int VISU::DeformedShape_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration, int isMemoryCheck)
+
+//---------------------------------------------------------------
+size_t
+VISU::DeformedShape_i
+::IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck)
{
try{
- if(!TSuperClass::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck)) return 0;
- const VISU::PField aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName);
- return aField->myNbComp > 1;
+ size_t aResult = TSuperClass::IsPossible(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber,
+ theIsMemoryCheck);
+ if(aResult){
+ VISU::Result_i::TInput* anInput = theResult->GetInput();
+ VISU::PField aField = anInput->GetField(theMeshName,
+ (VISU::TEntity)theEntity,
+ theFieldName);
+ if(aField->myNbComp > 1)
+ return aResult;
+ }
}catch(std::exception& exc){
INFOS("Follow exception was occured :\n"<<exc.what());
}catch(...){
return 0;
}
+
+//---------------------------------------------------------------
int VISU::DeformedShape_i::myNbPresent = 0;
-QString VISU::DeformedShape_i::GenerateName() { return VISU::GenerateName("Def.Shape",myNbPresent++);}
+//---------------------------------------------------------------
+QString
+VISU::DeformedShape_i
+::GenerateName()
+{
+ return VISU::GenerateName("Def.Shape",myNbPresent++);
+}
+
+//---------------------------------------------------------------
const string VISU::DeformedShape_i::myComment = "DEFORMEDSHAPE";
-const char* VISU::DeformedShape_i::GetComment() const { return myComment.c_str();}
+
+//---------------------------------------------------------------
+const char*
+VISU::DeformedShape_i
+::GetComment() const
+{
+ return myComment.c_str();
+}
-VISU::DeformedShape_i::
-DeformedShape_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theAddToStudy),
- ColoredPrs3d_i(theResult,theAddToStudy),
- ScalarMap_i(theResult,theAddToStudy),
- TSuperClass(theResult,theAddToStudy),
- myDeformedShapePL(NULL)
+//---------------------------------------------------------------
+const char*
+VISU::DeformedShape_i
+::GetIconName()
{
- if(MYDEBUG) MESSAGE("DeformedShape_i::DeformedShape_i");
-}
+ if (!IsGroupsUsed())
+ return "ICON_TREE_DEFORMED_SHAPE";
+ else
+ return "ICON_TREE_DEFORMED_SHAPE_GROUPS";
+}
-VISU::DeformedShape_i::
-DeformedShape_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
- ColoredPrs3d_i(theResult,theSObject),
- ScalarMap_i(theResult,theSObject),
- TSuperClass(theResult,theSObject),
+//---------------------------------------------------------------
+VISU::DeformedShape_i
+::DeformedShape_i(EPublishInStudyMode thePublishInStudyMode):
+ ColoredPrs3d_i(thePublishInStudyMode),
+ ScalarMap_i(thePublishInStudyMode),
myDeformedShapePL(NULL)
{
if(MYDEBUG) MESSAGE("DeformedShape_i::DeformedShape_i");
}
-void VISU::DeformedShape_i::SameAs(const Prs3d_i* theOrigin)
+//---------------------------------------------------------------
+void
+VISU::DeformedShape_i
+::SameAs(const Prs3d_i* theOrigin)
{
TSuperClass::SameAs(theOrigin);
}
}
-void VISU::DeformedShape_i::Update()
-{
- TSuperClass::Update();
-}
-
-VISU::Storable* VISU::DeformedShape_i::Create(const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration)
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::DeformedShape_i
+::Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
{
myIsColored = false;
myColor.R = myColor.G = myColor.B = 0.5;
- return TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
+ return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
}
-VISU::Storable* VISU::DeformedShape_i::Restore(const Storable::TRestoringMap& theMap)
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::DeformedShape_i
+::Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
{
- TSuperClass::Restore(theMap);
+ if(!TSuperClass::Restore(theStudy, theMap))
+ return NULL;
SetScale(VISU::Storable::FindValue(theMap,"myFactor").toDouble());
myIsColored = VISU::Storable::FindValue(theMap,"myIsColored").toInt();
}
-void VISU::DeformedShape_i::ToStream(std::ostringstream& theStr){
+//---------------------------------------------------------------
+void
+VISU::DeformedShape_i
+::ToStream(std::ostringstream& theStr)
+{
TSuperClass::ToStream(theStr);
Storable::DataToStream( theStr, "myFactor", GetScale() );
}
-VISU::DeformedShape_i::~DeformedShape_i(){
+//---------------------------------------------------------------
+VISU::DeformedShape_i
+::~DeformedShape_i()
+{
if(MYDEBUG) MESSAGE("DeformedShape_i::~DeformedShape_i()");
}
-void VISU::DeformedShape_i::SetScale(CORBA::Double theScale) {
+//---------------------------------------------------------------
+void
+VISU::DeformedShape_i
+::SetScale(CORBA::Double theScale)
+{
myDeformedShapePL->SetScale(theScale);
}
-CORBA::Double VISU::DeformedShape_i::GetScale(){
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::DeformedShape_i
+::GetScale()
+{
return myDeformedShapePL->GetScale();
}
-void VISU::DeformedShape_i::DoHook(){
- if(!myPipeLine) myPipeLine = VISU_DeformedShapePL::New();
- myDeformedShapePL = dynamic_cast<VISU_DeformedShapePL*>(myPipeLine);
- myPipeLine->GetMapper()->SetScalarVisibility(IsColored());
+//---------------------------------------------------------------
+CORBA::Boolean
+VISU::DeformedShape_i
+::IsColored()
+{
+ return myIsColored;
+}
- TSuperClass::DoHook();
+
+//---------------------------------------------------------------
+void
+VISU::DeformedShape_i
+::ShowColored(CORBA::Boolean theColored)
+{
+ myIsColored = theColored;
+ myParamsTime.Modified();
+}
+
+//---------------------------------------------------------------
+SALOMEDS::Color
+VISU::DeformedShape_i
+::GetColor()
+{
+ return myColor;
}
-const char*
+//---------------------------------------------------------------
+void
VISU::DeformedShape_i
-::GetIconName()
+::SetColor(const SALOMEDS::Color& theColor)
{
- if (!GetNumberOfGeom())
- return "ICON_TREE_DEFORMED_SHAPE";
- else
- return "ICON_TREE_DEFORMED_SHAPE_GROUPS";
-}
+ myColor = theColor;
+ myParamsTime.Modified();
+}
-void VISU::DeformedShape_i::SetMapScale(double theMapScale){
+//---------------------------------------------------------------
+void
+VISU::DeformedShape_i
+::CreatePipeLine(VISU_PipeLine* thePipeLine)
+{
+ if(!thePipeLine){
+ myDeformedShapePL = VISU_DeformedShapePL::New();
+ }else
+ myDeformedShapePL = dynamic_cast<VISU_DeformedShapePL*>(thePipeLine);
+
+ myDeformedShapePL->GetMapper()->SetScalarVisibility(IsColored());
+
+ TSuperClass::CreatePipeLine(myDeformedShapePL);
+}
+
+
+//---------------------------------------------------------------
+bool
+VISU::DeformedShape_i
+::CheckIsPossible()
+{
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::DeformedShape_i
+::SetMapScale(double theMapScale)
+{
myDeformedShapePL->SetMapScale(theMapScale);
}
+//---------------------------------------------------------------
VISU_Actor*
VISU::DeformedShape_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO, bool toSupressShrinking)
+::CreateActor(bool toSupressShrinking)
{
- VISU_Actor* anActor = TSuperClass::CreateActor(theIO, true);
+ VISU_Actor* anActor = TSuperClass::CreateActor(true);
anActor->SetVTKMapping(false);
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
int aDispMode = aResourceMgr->integerValue("VISU", "deformed_shape_represent", 1);
return anActor;
}
+
+//---------------------------------------------------------------
VISU_Actor*
VISU::DeformedShape_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+::CreateActor()
{
- return CreateActor(theIO, false);
+ return CreateActor(false);
}
-void VISU::DeformedShape_i::UpdateActor(VISU_Actor* theActor) {
+
+//---------------------------------------------------------------
+void
+VISU::DeformedShape_i
+::UpdateActor(VISU_Actor* theActor)
+{
if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
if(IsColored()){
anActor->SetBarVisibility(true);
- myPipeLine->GetMapper()->SetScalarVisibility(1);
+ GetPipeLine()->GetMapper()->SetScalarVisibility(1);
}else{
anActor->SetBarVisibility(false);
- myPipeLine->GetMapper()->SetScalarVisibility(0);
+ GetPipeLine()->GetMapper()->SetScalarVisibility(0);
anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B);
}
TSuperClass::UpdateActor(theActor);
#ifndef VISU_DeformedShape_i_HeaderFile
#define VISU_DeformedShape_i_HeaderFile
-#include "VISU_PrsMerger_i.hh"
+#include "VISU_ScalarMap_i.hh"
class VISU_DeformedShapePL;
-namespace VISU{
- class VISU_I_EXPORT DeformedShape_i : public virtual POA_VISU::DeformedShape,
- public virtual PrsMerger_i
+namespace VISU
+{
+ //----------------------------------------------------------------------------
+ class DeformedShape_i : public virtual POA_VISU::DeformedShape,
+ public virtual ScalarMap_i
{
static int myNbPresent;
DeformedShape_i(const DeformedShape_i&);
public:
- typedef PrsMerger_i TSuperClass;
+ //----------------------------------------------------------------------------
+ typedef ScalarMap_i TSuperClass;
+ typedef VISU::DeformedShape TInterface;
explicit
- DeformedShape_i(Result_i* theResult,
- bool theAddToStudy);
- explicit
- DeformedShape_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject);
- virtual void SameAs(const Prs3d_i* theOrigin);
- virtual ~DeformedShape_i();
+ DeformedShape_i(EPublishInStudyMode thePublishInStudyModep);
- virtual VISU::VISUType GetType() { return VISU::TDEFORMEDSHAPE;};
+ virtual
+ void
+ SameAs(const Prs3d_i* theOrigin);
- virtual void SetScale(CORBA::Double theScale);
- virtual CORBA::Double GetScale();
+ virtual
+ ~DeformedShape_i();
- virtual CORBA::Boolean IsColored() { return myIsColored; }
- virtual void ShowColored(CORBA::Boolean theColored) { myIsColored = theColored; }
+ virtual
+ VISU::VISUType
+ GetType()
+ {
+ return VISU::TDEFORMEDSHAPE;
+ }
- virtual SALOMEDS::Color GetColor() { return myColor;}
- virtual void SetColor(const SALOMEDS::Color& theColor) { myColor = theColor;}
+ virtual
+ void
+ SetScale(CORBA::Double theScale);
- typedef VISU::DeformedShape TInterface;
- VISU_DeformedShapePL* GetDeformedShapePL(){ return myDeformedShapePL;}
+ virtual
+ CORBA::Double
+ GetScale();
- virtual void Update();
+ virtual
+ CORBA::Boolean
+ IsColored();
- protected:
- virtual void DoHook();
+ virtual
+ void
+ ShowColored(CORBA::Boolean theColored);
+
+ virtual
+ SALOMEDS::Color
+ GetColor();
+
+ virtual
+ void
+ SetColor(const SALOMEDS::Color& theColor);
+
+ VISU_DeformedShapePL*
+ GetSpecificPL() const
+ {
+ return myDeformedShapePL;
+ }
- virtual const char* GetIconName();
+ protected:
+ //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine
+ virtual
+ void
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
+
+ //! Redefines VISU_ColoredPrs3d_i::CheckIsPossible
+ virtual
+ bool
+ CheckIsPossible();
VISU_DeformedShapePL *myDeformedShapePL;
SALOMEDS::Color myColor;
bool myIsColored;
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);
+ static
+ size_t
+ IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck);
+
+ virtual
+ Storable*
+ Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber);
static const std::string myComment;
- virtual const char* GetComment() const;
- virtual QString GenerateName();
- virtual void ToStream(std::ostringstream& theStr);
+ virtual
+ const char*
+ GetComment() const;
+
+ virtual
+ QString
+ GenerateName();
+
+ virtual
+ const char*
+ GetIconName();
- virtual Storable* Restore(const Storable::TRestoringMap& theMap);
+ virtual
+ void
+ ToStream(std::ostringstream& theStr);
- virtual void SetMapScale(double theMapScale = 1.0);
+ virtual
+ Storable*
+ Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap);
+
+ virtual
+ void
+ SetMapScale(double theMapScale = 1.0);
virtual
VISU_Actor*
- CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
+ CreateActor();
virtual
VISU_Actor*
- CreateActor(const Handle(SALOME_InteractiveObject)& theIO, bool toSupressShrinking);
+ CreateActor(bool toSupressShrinking);
- virtual void UpdateActor(VISU_Actor* theActor) ;
+ virtual
+ void
+ UpdateActor(VISU_Actor* theActor) ;
};
}
#include "VISU_Prs3d_i.hh"
#include "VISU_Mesh_i.hh"
-#include "VISU_PrsMerger_i.hh"
#include "VISU_ScalarMap_i.hh"
#include "VISU_IsoSurfaces_i.hh"
#include "VISU_DeformedShape_i.hh"
#include "VISU_Table_i.hh"
#include "VISU_GaussPoints_i.hh"
#include "VISU_ScalarMapOnDeformedShape_i.hh"
+#include "VISU_ColoredPrs3dCache_i.hh"
+#include "VISU_ColoredPrs3dHolder_i.hh"
#include "utilities.h"
{
static std::string PREFIX(" ");
+ static std::string aResultName;
+
typedef std::map<std::string,std::string> TName2EntryMap;
typedef std::map<std::string,std::string> TEntry2NameMap;
}
theStr<<thePrefix<<theName<<" = aVisu."<<theConstructorName<<"("<<theArgumentName<<
- ",'"<<theServant->GetMeshName()<<"'"<<
+ ",'"<<theServant->GetCMeshName()<<"'"<<
","<<aParam<<
- ",'"<<theServant->GetFieldName()<<"'"<<
- ","<<theServant->GetIteration()<<
+ ",'"<<theServant->GetCFieldName()<<"'"<<
+ ","<<theServant->GetTimeStampNumber()<<
")"<<endl;
theStr<<thePrefix<<"if "<<theName<<":"<<endl;
return thePrefix;
}
-
+ //===========================================================================
std::string
ScalarMapToPython(SALOMEDS::SObject_ptr theSObject,
VISU::ScalarMap_i* theServant,
}
theStr<<thePrefix<<theName<<".SetBarOrientation("<<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;
}
- //===========================================================================
- std::string
- PrsMergerToPython(SALOMEDS::SObject_ptr theSObject,
- VISU::PrsMerger_i* theServant,
- std::ostream& theStr,
- std::string& theName,
- const std::string& theConstructorName,
- const std::string& theArgumentName,
- std::string thePrefix)
- {
- thePrefix = ScalarMapToPython(theSObject,theServant,theStr,theName,theConstructorName,theArgumentName,thePrefix);
- string_array_var aGroupNames = theServant->getGroupNames();
- for(int i=0; i<aGroupNames->length(); i++)
- {
- theStr<<thePrefix<<theName<<".AddMeshOnGroup('"
- <<theServant->GetMeshName()<<"','"
- <<aGroupNames[i]<<"')"<<endl;
- }
- return thePrefix;
- }
-
//===========================================================================
std::string
DeformedShapeToPython(SALOMEDS::SObject_ptr theSObject,
const std::string& theArgumentName,
std::string thePrefix)
{
- thePrefix = PrsMergerToPython(theSObject,theServant,theStr,theName,theConstructorName,theArgumentName,thePrefix);
+ thePrefix = ScalarMapToPython(theSObject,theServant,theStr,theName,theConstructorName,theArgumentName,thePrefix);
theStr<<thePrefix<<theName<<".SetScale("<<theServant->GetScale()<<")"<<endl;
theStr<<thePrefix<<theName<<".ShowColored("<<theServant->IsColored()<<")"<<endl;
SALOMEDS::Color aColor = theServant->GetColor();
switch(aType){
case VISU::TRESULT:
if(Result_i* aServant = dynamic_cast<Result_i*>(GetServant(anObj).in())){
+ aResultName = aName;
std::string aFileName = aServant->GetFileName();
Result_i::ECreationId anId = aServant->GetCreationId();
if(anId == Result_i::eImportFile || anId == Result_i::eCopyAndImportFile){
if(aSubMeshName == "")
theStr<<thePrefix<<aName<<" = aVisu.MeshOnEntity("<<theArgumentName<<
- ",'"<<aServant->GetMeshName()<<"'"<<
+ ",'"<<aServant->GetCMeshName()<<"'"<<
","<<aParam<<
")"<<endl;
else
theStr<<thePrefix<<aName<<" = aVisu.FamilyMeshOnEntity("<<theArgumentName<<
- ",'"<<aServant->GetMeshName()<<"'"<<
+ ",'"<<aServant->GetCMeshName()<<"'"<<
","<<aParam<<
",'"<<aSubMeshName<<"'"<<
")"<<endl;
}else
theStr<<thePrefix<<aName<<" = aVisu.GroupMesh("<<theArgumentName<<
- ",'"<<aServant->GetMeshName()<<"'"<<
+ ",'"<<aServant->GetCMeshName()<<"'"<<
",'"<<aSubMeshName<<"'"<<
")"<<endl;
}
break;
case VISU::TSCALARMAP:
- case VISU::TPRSMERGER:
- if(PrsMerger_i* aServant = dynamic_cast<PrsMerger_i*>(GetServant(anObj).in())){
- thePrefix = PrsMergerToPython(theSObject,aServant,theStr,aName,"ScalarMapOnField",theArgumentName,thePrefix);
+ if(ScalarMap_i* aServant = dynamic_cast<ScalarMap_i*>(GetServant(anObj).in())){
+ thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"ScalarMapOnField",theArgumentName,thePrefix);
theStr<<thePrefix<<"pass"<<endl<<endl;
}
return;
return;
case VISU::TSCALARMAPONDEFORMEDSHAPE:
if(ScalarMapOnDeformedShape_i* aServant = dynamic_cast<ScalarMapOnDeformedShape_i*>(GetServant(anObj).in())){
- thePrefix = PrsMergerToPython(theSObject,aServant,theStr,aName,"ScalarMapOnDeformedShapeOnField",theArgumentName,thePrefix);
+ thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"ScalarMapOnDeformedShapeOnField",theArgumentName,thePrefix);
- theStr<<thePrefix<<aName<<".SetSourceRange("<<aServant->GetSourceRangeMin()<<","<<aServant->GetSourceRangeMax()<<")"<<endl;
+ theStr<<thePrefix<<aName<<".SetRange("<<aServant->GetMin()<<","<<aServant->GetMax()<<")"<<endl;
theStr<<thePrefix<<aName<<".SetScale("<<aServant->GetScale()<<")"<<endl;
std::string aParam;
break;
}
+ CORBA::String_var aMeshName = aServant->GetScalarCMeshName();
+ CORBA::String_var aFieldName = aServant->GetScalarCFieldName();
+ CORBA::Long aTimeStampNumber = aServant->GetScalarLIteration();
+
theStr<<thePrefix<<aName<<".SetScalarField("<<
- "'"<<aServant->GetScalarMeshName()<<"',"<<
- "'"<<aServant->GetScalarFieldName()<<"',"<<
- aServant->GetScalarIteration()<<","<<
+ "'"<<aMeshName<<"',"<<
+ "'"<<aFieldName<<"',"<<
+ aTimeStampNumber<<","<<
aParam<<
")"<<endl;
return;
case VISU::TISOSURFACE:
if(IsoSurfaces_i* aServant = dynamic_cast<IsoSurfaces_i*>(GetServant(anObj).in())){
- thePrefix = PrsMergerToPython(theSObject,aServant,theStr,aName,"IsoSurfacesOnField",theArgumentName,thePrefix);
+ thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"IsoSurfacesOnField",theArgumentName,thePrefix);
theStr<<thePrefix<<aName<<".SetNbSurfaces("<<aServant->GetNbSurfaces()<<")"<<endl;
theStr<<thePrefix<<"pass"<<endl<<endl;
}
return;
case VISU::TCUTPLANES:
if(CutPlanes_i* aServant = dynamic_cast<CutPlanes_i*>(GetServant(anObj).in())){
- thePrefix = PrsMergerToPython(theSObject,aServant,theStr,aName,"CutPlanesOnField",theArgumentName,thePrefix);
+ thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"CutPlanesOnField",theArgumentName,thePrefix);
std::string aParam;
switch(aServant->GetOrientationType()){
return;
case VISU::TCUTLINES:
if(CutLines_i* aServant = dynamic_cast<CutLines_i*>(GetServant(anObj).in())){
- thePrefix = PrsMergerToPython(theSObject,aServant,theStr,aName,"CutLinesOnField",theArgumentName,thePrefix);
+ thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"CutLinesOnField",theArgumentName,thePrefix);
std::string aParam;
switch(aServant->GetOrientationType()){
return;
case VISU::TPLOT3D:
if (Plot3D_i* aServant = dynamic_cast<Plot3D_i*>(GetServant(anObj).in())) {
- thePrefix = PrsMergerToPython(theSObject, aServant, theStr, aName,"Plot3DOnField", theArgumentName, thePrefix);
+ thePrefix = ScalarMapToPython(theSObject, aServant, theStr, aName,"Plot3DOnField", theArgumentName, thePrefix);
std::string aParam;
switch(aServant->GetOrientationType()){
}
}
return;
+ case VISU::TCOLOREDPRS3DCACHE:
+ if(ColoredPrs3dCache_i* aServant = dynamic_cast<ColoredPrs3dCache_i*>(GetServant(anObj).in())){
+ theStr<<thePrefix<<"aCache = aVisu.GetColoredPrs3dCache(aVisu.GetCurrentStudy())"<<endl<<endl;
+ TColoredPrs3dHolderMap aHolderMap = aServant->GetHolderMap();
+ TColoredPrs3dHolderMap::const_iterator aHolderIter = aHolderMap.begin();
+ TColoredPrs3dHolderMap::const_iterator aHolderIterEnd = aHolderMap.end();
+ for(; aHolderIter != aHolderIterEnd; aHolderIter++){
+ const TLastVisitedPrsList& aPrsList = aHolderIter->second;
+ if(TPrs3dPtr aPrs3d = aPrsList.front())
+ {
+ ColoredPrs3dHolder::BasicInput_var anInput = aPrs3d->GetBasicInput();
+
+ std::string anEntity;
+ switch(anInput->myEntity){
+ case VISU::NODE : anEntity = "VISU.NODE"; break;
+ case VISU::EDGE : anEntity = "VISU.EDGE"; break;
+ case VISU::FACE : anEntity = "VISU.FACE"; break;
+ case VISU::CELL : anEntity = "VISU.CELL"; break;
+ }
+
+ theStr<<thePrefix<<"anInput = VISU.ColoredPrs3dHolder.BasicInput("<<aResultName<<",'"<<
+ anInput->myMeshName<<"',"<<anEntity<<",'"<<
+ anInput->myFieldName<<"',"<<anInput->myTimeStampNumber<<")"<<endl;
+
+ std::string aType = aPrs3d->GetComment();
+ theStr<<thePrefix<<"aHolder = aCache.CreateHolder(VISU.T"<<aType<<",anInput)"<<endl<<endl;
+ }
+ }
+ }
+ return;
}
}
} else { /*if(!CORBA::is_nil(anObj))*/
#include "VISU_OpenGLPointSpriteMapper.hxx"
#include "VISU_ScalarBarCtrl.hxx"
+#include "VISU_LookupTable.hxx"
+#include "VISU_Convertor.hxx"
#include "SUIT_ResourceMgr.h"
+#include "VISU_PipeLineUtils.hxx"
+
#include <vtkImageData.h>
#include <vtkXMLImageDataReader.h>
#include <vtkScalarBarActor.h>
#include <vtkTextProperty.h>
#include <vtkProperty.h>
-using namespace VISU;
-using namespace std;
+#ifdef ENABLE_MULTIPR
+#include "MULTIPR_API.hxx"
+#endif
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int MYDEBUG = 0;
#endif
+static int INCMEMORY = 10;
+
//----------------------------------------------------------------------------
-int
+size_t
VISU::GaussPoints_i
::IsPossible(Result_i* theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- int theIteration,
- int isMemoryCheck)
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck)
{
+ size_t aResult = 0;
+ if(theEntity == VISU::NODE)
+ return aResult;
try{
- if(theEntity != VISU::NODE)
- return VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck);
- else
- return false;
+ bool anIsEstimated = true;
+ VISU::Result_i::TInput* anInput = theResult->GetInput();
+ size_t aSize = anInput->GetTimeStampOnGaussPtsSize(theMeshName,
+ (VISU::TEntity)theEntity,
+ theFieldName,
+ theTimeStampNumber,
+ anIsEstimated);
+ aResult = 1;
+ if(theIsMemoryCheck){
+ if(anIsEstimated)
+ aSize *= INCMEMORY;
+ aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
+ if(MYDEBUG)
+ MESSAGE("GaussPoints_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<aResult);
+ }
}catch(std::exception& exc){
INFOS("Follow exception was occured :\n"<<exc.what());
}catch(...){
INFOS("Unknown exception was occured!");
}
- return 0;
+ return aResult;
}
//----------------------------------------------------------------------------
}
-//----------------------------------------------------------------------------
-VISU::GaussPoints_i::
-GaussPoints_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theAddToStudy),
- ColoredPrs3d_i(theResult,theAddToStudy),
- myGaussPointsPL(NULL),
- myIsColored(true),
- myColor(Qt::blue),
- myIsActiveLocalScalarBar(true),
- myIsDispGlobalScalarBar(true),
- mySpacing(0.01),
- myFaceLimit(50000)
+//---------------------------------------------------------------
+const char*
+VISU::GaussPoints_i
+::GetIconName()
{
- if(MYDEBUG) MESSAGE("GaussPoints_i::GaussPoints_i - this = "<<this);
-}
+ return "ICON_TREE_GAUSS_POINTS";
+}
//----------------------------------------------------------------------------
-VISU::GaussPoints_i::
-GaussPoints_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
- ColoredPrs3d_i(theResult,theSObject),
+VISU::GaussPoints_i
+::GaussPoints_i(EPublishInStudyMode thePublishInStudyMode) :
+ ColoredPrs3d_i(thePublishInStudyMode),
myGaussPointsPL(NULL),
- myIsColored(true),
myColor(Qt::blue),
myIsActiveLocalScalarBar(true),
myIsDispGlobalScalarBar(true),
+ mySpacing(0.01),
myFaceLimit(50000)
{
if(MYDEBUG) MESSAGE("GaussPoints_i::GaussPoints_i - this = "<<this);
//----------------------------------------------------------------------------
VISU::Storable*
VISU::GaussPoints_i
-::Create(const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- int theIteration)
+::Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
{
- TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
+ TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
}
+//---------------------------------------------------------------
+void
+VISU::GaussPoints_i
+::SameAs(const Prs3d_i* theOrigin)
+{
+ TSuperClass::SameAs(theOrigin);
+
+ if(const GaussPoints_i* aPrs3d = dynamic_cast<const GaussPoints_i*>(theOrigin)){
+ GaussPoints_i* anOrigin = const_cast<GaussPoints_i*>(aPrs3d);
+ // To restore the range after shallow copy of the pipeline mapper
+ // in the parent class
+ SetSourceRange();
+
+ SetIsActiveLocalScalarBar(anOrigin->GetIsActiveLocalScalarBar());
+ SetIsDispGlobalScalarBar(anOrigin->GetIsDispGlobalScalarBar());
+
+ SetSpacing(anOrigin->GetSpacing());
+
+ SetFaceLimit(anOrigin->GetFaceLimit());
+
+ SetColor(anOrigin->GetColor());
+
+ SetTextures(anOrigin->GetMainTexture(), anOrigin->GetAlphaTexture());
+ }
+}
+
+//----------------------------------------------------------------------------
+CORBA::Float
+VISU::GaussPoints_i
+::GetMemorySize()
+{
+ return TSuperClass::GetMemorySize();
+}
+
//----------------------------------------------------------------------------
VISU::Storable*
VISU::GaussPoints_i
-::Restore(const Storable::TRestoringMap& theMap)
+::Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
{
- TSuperClass::Restore(theMap);
+ if(!TSuperClass::Restore(theStudy, theMap))
+ return NULL;
SetIsActiveLocalScalarBar(Storable::FindValue(theMap,"myIsActiveLocalScalarBar").toInt());
SetIsDispGlobalScalarBar(Storable::FindValue(theMap,"myIsDispGlobalScalarBar").toInt());
//----------------------------------------------------------------------------
-VISU_GaussPointsPL*
+int
VISU::GaussPoints_i
-::GetGaussPointsPL()
-{
- return myGaussPointsPL;
+::GetFaceLimit()
+{
+ return myFaceLimit;
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::GaussPoints_i
+::SetFaceLimit( int theFaceLimit )
+{
+ if( myFaceLimit != theFaceLimit ){
+ myFaceLimit = theFaceLimit;
+ myParamsTime.Modified();
+ }
}
+//----------------------------------------------------------------------------
void
VISU::GaussPoints_i
::SetIsDeformed( bool theIsDeformed )
return myGaussPointsPL->GetIsDeformed();
}
+//----------------------------------------------------------------------------
void
VISU::GaussPoints_i
::SetScaleFactor( vtkFloatingPointType theScaleFactor )
return myGaussPointsPL->GetScale();
}
+//----------------------------------------------------------------------------
+QColor
+VISU::GaussPoints_i
+::GetColor()
+{
+ return myColor;
+}
+
+void
+VISU::GaussPoints_i
+::SetColor( const QColor& theColor )
+{
+ myColor = theColor;
+ myParamsTime.Modified();
+}
+
+//----------------------------------------------------------------------------
void
VISU::GaussPoints_i
::SetIsColored( bool theIsColored )
{
- myIsColored = theIsColored;
myGaussPointsPL->SetIsColored( theIsColored );
}
+bool
+VISU::GaussPoints_i
+::GetIsColored()
+{
+ return myGaussPointsPL->GetIsColored();
+}
+
+//----------------------------------------------------------------------------
bool
VISU::GaussPoints_i
::SetMainTexture( const QString& theMainTexture )
return myMainTexture;
}
+//----------------------------------------------------------------------------
bool
VISU::GaussPoints_i
::SetAlphaTexture( const QString& theAlphaTexture )
return myAlphaTexture;
}
+//----------------------------------------------------------------------------
void
VISU::GaussPoints_i
::SetAlphaThreshold( vtkFloatingPointType theAlphaThreshold )
return myGaussPointsPL->GetAlphaThreshold();
}
+//----------------------------------------------------------------------------
void
VISU::GaussPoints_i
::SetResolution( int theResolution )
return myGaussPointsPL->GetResolution();
}
+//----------------------------------------------------------------------------
void
VISU::GaussPoints_i
::SetPrimitiveType(int thePrimitiveType)
return myGaussPointsPL->GetPrimitiveType();
}
+//----------------------------------------------------------------------------
vtkFloatingPointType
VISU::GaussPoints_i
::GetMaximumSupportedSize()
return myGaussPointsPL->GetMaximumSupportedSize();
}
+//----------------------------------------------------------------------------
void
VISU::GaussPoints_i
::SetClamp(vtkFloatingPointType theClamp)
return myGaussPointsPL->GetClamp();
}
+//----------------------------------------------------------------------------
void
VISU::GaussPoints_i
::SetGeomSize( vtkFloatingPointType theGeomSize )
return myGaussPointsPL->GetSize();
}
+//----------------------------------------------------------------------------
void
VISU::GaussPoints_i
::SetMinSize( vtkFloatingPointType theMinSize )
return myGaussPointsPL->GetMinSize();
}
+//----------------------------------------------------------------------------
void
VISU::GaussPoints_i
::SetMaxSize( vtkFloatingPointType theMaxSize )
return myGaussPointsPL->GetMaxSize();
}
+//----------------------------------------------------------------------------
void
VISU::GaussPoints_i
::SetMagnification( vtkFloatingPointType theMagnification )
return myGaussPointsPL->GetMagnification();
}
+//----------------------------------------------------------------------------
void
VISU::GaussPoints_i
::SetMagnificationIncrement( vtkFloatingPointType theIncrement )
//----------------------------------------------------------------------------
void
VISU::GaussPoints_i
-::DoSetInput(Result_i* theResult)
+::DoSetInput(bool theIsInitilizePipe, bool theReInit)
{
- VISU::Result_i::TInput* anInput = theResult->GetInput();
+ static string aStrPrev = "";
+ static VISU::Result_i::TInput* anInputPrev = NULL;
+
+ // MULTIPR
+ VISU::Result_i::TInput* anInput = NULL;
+#ifdef ENABLE_MULTIPR
+ if (GetCResult()->IsDistributedMEDMultipr())
+ {
+ vector<string> aListMEDFiles = GetCResult()->GetCurrentRepresentationMultipr();
+
+ string aStrCurrent = "";
+ for (unsigned i = 0 ; i < aListMEDFiles.size() ; i++)
+ {
+ aStrCurrent +=aListMEDFiles[i];
+ }
+ aStrCurrent += GetCMeshName();
+ aStrCurrent += GetCFieldName();
+ if (aStrPrev != aStrCurrent)
+ {
+ if (anInputPrev != NULL) delete anInputPrev;
+
+ char aTmpFilename[256];
+ sprintf(aTmpFilename, "__tmp.med");
+
+ int res = multipr::merge(aListMEDFiles, GetCMeshName().c_str(), GetCFieldName().c_str(), aTmpFilename);
+ if (res == 0) throw std::runtime_error("empty mesh");
+
+ anInput = CreateConvertor(aTmpFilename);
+ anInput->Build();
+ anInputPrev = anInput;
+
+ aStrPrev = aStrCurrent;
+ }
+ else
+ {
+ anInput = anInputPrev;
+ }
+ }
+ else
+#endif
+ {
+ anInput = GetCResult()->GetInput();
+ }
+
if(!anInput)
- throw std::runtime_error("Mesh_i::Build - theResult->GetInput() == NULL !!!");
+ throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!");
- myField = anInput->GetField(myMeshName,myEntity,myFieldName);
- if(!myField)
+ SetField(anInput->GetField(GetCMeshName(),GetTEntity(),GetCFieldName()));
+ if(!GetField())
throw std::runtime_error("There is no Field with the parameters !!!");
VISU::PGaussPtsIDMapper aGaussPtsIDMapper =
- anInput->GetTimeStampOnGaussPts(myMeshName,myEntity,myFieldName,myIteration);
+ anInput->GetTimeStampOnGaussPts(GetCMeshName(),GetTEntity(),GetCFieldName(),GetTimeStampNumber());
if(!aGaussPtsIDMapper)
throw std::runtime_error("There is no TimeStamp with the parameters !!!");
- myGaussPointsPL->SetGaussPtsIDMapper(aGaussPtsIDMapper);
- myGaussPointsPL->Init();
- myGaussPointsPL->Build();
+ GetSpecificPL()->SetGaussPtsIDMapper(aGaussPtsIDMapper);
+ if(theIsInitilizePipe){
+ GetSpecificPL()->Init();
+ }
+ GetCResult()->MinMaxConnect(this);
- theResult->MinMaxConnect(this);
+ // To update scalar range according to the new input
+ if(!IsTimeStampFixed() || theReInit)
+ SetSourceRange();
}
//----------------------------------------------------------------------------
-void
+bool
VISU::GaussPoints_i
-::DoHook()
+::CheckIsPossible()
{
- if(!myPipeLine)
- myPipeLine = VISU_GaussPointsPL::New();
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
+}
- myGaussPointsPL = dynamic_cast<VISU_GaussPointsPL*>(myPipeLine);
- TSuperClass::DoHook();
+//----------------------------------------------------------------------------
+void
+VISU::GaussPoints_i
+::CreatePipeLine(VISU_PipeLine* thePipeLine)
+{
+ if(!thePipeLine){
+ myGaussPointsPL = VISU_GaussPointsPL::New();
+ }else
+ myGaussPointsPL = dynamic_cast<VISU_GaussPointsPL*>(thePipeLine);
+
+ TSuperClass::CreatePipeLine(myGaussPointsPL);
}
//----------------------------------------------------------------------------
VISU_PipeLine*
VISU::GaussPoints_i
-::GetPipeLine()
+::GetActorPipeLine()
{
// We create a new PipeLine instance in order to provide
// different representations for different actors (basic and segmented)
VISU_GaussPointsPL* aPipeLine = VISU_GaussPointsPL::New();
- aPipeLine->SetGaussPtsIDMapper(myGaussPointsPL->GetGaussPtsIDMapper());
- aPipeLine->ShallowCopy(myPipeLine);
- aPipeLine->Update();
+ aPipeLine->ShallowCopy(GetPipeLine(), true);
return aPipeLine;
}
//----------------------------------------------------------------------------
bool
VISU::GaussPoints_i
-::OnCreateActor(VISU_GaussPtsAct* theActor,
- const Handle(SALOME_InteractiveObject)& theIO)
+::OnCreateActor(VISU_GaussPtsAct* theActor)
{
try{
- TSuperClass::CreateActor(theActor,theIO);
- theActor->GetPipeLine()->Delete();
+ TSuperClass::CreateActor(theActor);
UpdateActor(theActor);
return true;
}catch(...){
VISU_GaussPtsAct1*
VISU::GaussPoints_i
-::OnCreateActor1(const Handle(SALOME_InteractiveObject)& theIO)
+::OnCreateActor1()
{
VISU_GaussPtsAct1* anActor = VISU_GaussPtsAct1::New();
- if(OnCreateActor(anActor,theIO))
+ if(OnCreateActor(anActor))
return anActor;
return NULL;
}
VISU_GaussPtsAct2*
VISU::GaussPoints_i
-::OnCreateActor2(const Handle(SALOME_InteractiveObject)& theIO)
+::OnCreateActor2()
{
VISU_GaussPtsAct2* anActor = VISU_GaussPtsAct2::New();
- if(OnCreateActor(anActor,theIO))
+ if(OnCreateActor(anActor))
return anActor;
return NULL;
}
VISU_Actor*
VISU::GaussPoints_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+::CreateActor()
{
- return OnCreateActor1(theIO);
+ return OnCreateActor1();
}
//----------------------------------------------------------------------------
vtkLookupTable* theLookupTable)
{
theScalarBar->SetTitle(GetScalarBarTitle().c_str());
- theScalarBar->SetOrientation(myOrientation);
- theScalarBar->SetNumberOfLabels(myNumberOfLabels);
+ theScalarBar->SetOrientation(GetBarOrientation());
+ theScalarBar->SetNumberOfLabels(GetLabels());
- vtkLookupTable* aLookupTable = myScalarMapPL->GetBarTable();
+ vtkLookupTable* aLookupTable = GetSpecificPL()->GetBarTable();
theLookupTable->SetNumberOfColors(aLookupTable->GetNumberOfColors());
theScalarBar->SetMaximumNumberOfColors(aLookupTable->GetNumberOfColors());
+ vtkFloatingPointType anRGB[3];
+
vtkTextProperty* aTitleProp = theScalarBar->GetTitleTextProperty();
- aTitleProp->SetFontFamily(myTitFontType);
- aTitleProp->SetColor(myTitleColor[0],myTitleColor[1],myTitleColor[2]);
- (myIsBoldTitle)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
- (myIsItalicTitle)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
- (myIsShadowTitle)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
+ aTitleProp->SetFontFamily(GetTitFontType());
+
+ GetTitleColor(&anRGB[0],&anRGB[1],&anRGB[2]);
+ aTitleProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+
+ IsBoldTitle()? aTitleProp->BoldOn() : aTitleProp->BoldOff();
+ IsItalicTitle()? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
+ IsShadowTitle()? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
vtkTextProperty* aLabelProp = theScalarBar->GetLabelTextProperty();
- aLabelProp->SetFontFamily(myLblFontType);
- aLabelProp->SetColor(myLabelColor[0],myLabelColor[1],myLabelColor[2]);
- (myIsBoldLabel)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
- (myIsItalicLabel)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
- (myIsShadowLabel)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
+ aLabelProp->SetFontFamily(GetLblFontType());
+
+ GetLabelColor(&anRGB[0],&anRGB[1],&anRGB[2]);
+ aLabelProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+
+ IsBoldLabel()? aLabelProp->BoldOn() : aLabelProp->BoldOff();
+ IsItalicLabel()? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
+ IsShadowLabel()? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
theScalarBar->Modified();
}
VISU_ScalarBarCtrl *aScalarBarCtrl = anActor->GetScalarBarCtrl();
if(GetIsColored()){
anActor->SetBarVisibility(true);
- myPipeLine->GetMapper()->SetScalarVisibility(1);
+ GetPipeLine()->GetMapper()->SetScalarVisibility(1);
vtkFloatingPointType aRange[2];
- myScalarMapPL->GetSourceRange(aRange);
+ GetSpecificPL()->GetSourceRange(aRange);
aScalarBarCtrl->SetRangeLocal(aRange);
TMinMax aTMinMax(-VTK_LARGE_FLOAT,VTK_LARGE_FLOAT);
bool anIsMinMaxDone = IsGlobalRangeDefined();
if(anIsMinMaxDone)
- aTMinMax = myField->GetMinMax(GetScalarMode());
+ aTMinMax = GetField()->GetMinMax(GetScalarMode());
aScalarBarCtrl->SetGlobalRangeIsDefined(anIsMinMaxDone);
aScalarBarCtrl->SetRangeGlobal(aTMinMax.first, aTMinMax.second);
aRangeGlobal[0] = aTMinMax.first;
aRangeGlobal[1] = aTMinMax.second;
- GetGaussPointsPL()->GetMapper()->SetScalarRange(aRangeGlobal);
+ GetSpecificPL()->GetMapper()->SetScalarRange(aRangeGlobal);
}
aScalarBarCtrl->SetMode(aScalarBarMode);
// Position
- aScalarBarCtrl->SetWidth(myWidth);
- aScalarBarCtrl->SetHeight(myHeight);
- aScalarBarCtrl->SetPosition(myPosition);
+ aScalarBarCtrl->SetWidth(GetWidth());
+ aScalarBarCtrl->SetHeight(GetHeight());
+
+ vtkFloatingPointType aPosition[] = {GetPosX(), GetPosY()};
+ aScalarBarCtrl->SetPosition(aPosition);
aScalarBarCtrl->SetSpacing(mySpacing);
// Bicolor
- bool anIsBicolor = GetGaussPointsPL()->GetBicolor();
+ bool anIsBicolor = GetSpecificPL()->GetBicolor();
aScalarBarCtrl->SetBicolor(anIsBicolor);
UpdateScalarBar(aScalarBarCtrl->GetLocalBar(),
}else{
anActor->SetBarVisibility(false);
- myPipeLine->GetMapper()->SetScalarVisibility(0);
+ GetPipeLine()->GetMapper()->SetScalarVisibility(0);
anActor->GetProperty()->SetColor(myColor.red() / 255.0,
myColor.green() / 255.0,
myColor.blue() / 255.0);
}
- if( GetGaussPointsPL()->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
+ if( GetSpecificPL()->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
theActor->SetRepresentation( VTK_POINTS );
else
theActor->SetRepresentation( VTK_SURFACE );
{
if(MYDEBUG) MESSAGE("GaussPoints_i::UpdateFromActor - this = "<<this);
myGaussPointsPL->ChangeMagnification(theActor->GetChangeMagnification());
+ myParamsTime.Modified();
UpdateActors();
}
//----------------------------------------------------------------------------
void
VISU::GaussPoints_i
-::SetIsActiveLocalScalarBar(const bool theFlag)
+::SetIsActiveLocalScalarBar(const bool theIsActiveLocalScalarBar)
{
- myIsActiveLocalScalarBar = theFlag;
+ if(myIsActiveLocalScalarBar != theIsActiveLocalScalarBar){
+ myIsActiveLocalScalarBar = theIsActiveLocalScalarBar;
+ myParamsTime.Modified();
+ }
}
bool
void
VISU::GaussPoints_i
-::SetIsDispGlobalScalarBar(const bool theFlag)
+::SetIsDispGlobalScalarBar(const bool theIsDispGlobalScalarBar)
{
- myIsDispGlobalScalarBar=theFlag;
+ if(myIsDispGlobalScalarBar != theIsDispGlobalScalarBar){
+ myIsDispGlobalScalarBar = theIsDispGlobalScalarBar;
+ myParamsTime.Modified();
+ }
}
bool
VISU::GaussPoints_i
::IsGlobalRangeDefined() const
{
- return myResult->IsMinMaxDone();
+ return GetCResult()->IsMinMaxDone();
}
+//----------------------------------------------------------------------------
+void
+VISU::GaussPoints_i
+::SetSourceRange()
+{
+ if(IsTimeStampFixed() || GetIsActiveLocalScalarBar())
+ GetSpecificPL()->SetSourceRange();
+ else{
+ TMinMax aTMinMax = GetField()->GetMinMax(GetScalarMode());
+ vtkFloatingPointType aScalarRange[2] = {aTMinMax.first, aTMinMax.second};
+ GetSpecificPL()->SetScalarRange(aScalarRange);
+ }
+}
+
+CORBA::Double
+VISU::GaussPoints_i
+::GetSourceMin()
+{
+ if(IsTimeStampFixed() || GetIsActiveLocalScalarBar()){
+ vtkFloatingPointType aRange[2];
+ GetSpecificPL()->GetSourceRange(aRange);
+ return aRange[0];
+ }else{
+ TMinMax aTMinMax = GetField()->GetMinMax(GetScalarMode());
+ return aTMinMax.first;
+ }
+}
+
+CORBA::Double
+VISU::GaussPoints_i
+::GetSourceMax()
+{
+ if(IsTimeStampFixed() || GetIsActiveLocalScalarBar()){
+ vtkFloatingPointType aRange[2];
+ GetSpecificPL()->GetSourceRange(aRange);
+ return aRange[1];
+ }else{
+ TMinMax aTMinMax = GetField()->GetMinMax(GetScalarMode());
+ return aTMinMax.second;
+ }
+}
+
+
+//----------------------------------------------------------------------------
bool
VISU::GaussPoints_i
::GetIsDispGlobalScalarBar() const
return myIsDispGlobalScalarBar;
}
+
void
VISU::GaussPoints_i
::SetBiColor(bool theIsBiColor)
{
- GetGaussPointsPL()->SetBicolor(theIsBiColor);
+ GetSpecificPL()->SetBicolor(theIsBiColor);
}
bool
VISU::GaussPoints_i
::GetBiColor()
{
- return GetGaussPointsPL()->GetBicolor();
+ return GetSpecificPL()->GetBicolor();
}
void
VISU::GaussPoints_i
::SetSpacing(const vtkFloatingPointType theSpacing)
{
- mySpacing = theSpacing;
+ if(!VISU::CheckIsSameValue(mySpacing, theSpacing)){
+ mySpacing = theSpacing;
+ myParamsTime.Modified();
+ }
}
vtkFloatingPointType
public:
//----------------------------------------------------------------------------
typedef ColoredPrs3d_i TSuperClass;
+ typedef VISU::GaussPoints TInterface;
explicit
- GaussPoints_i(Result_i* theResult,
- bool theAddToStudy);
- explicit
- GaussPoints_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject);
+ GaussPoints_i(EPublishInStudyMode thePublishInStudyModep);
virtual
~GaussPoints_i();
return VISU::TGAUSSPOINTS;
}
- typedef VISU::GaussPoints TInterface;
-
- //! Get the Gauss Points Pipeline.
- VISU_GaussPointsPL*
- GetGaussPointsPL();
+ //----------------------------------------------------------------------------
+ //! Gets memory size actually used by the presentation (Mb).
+ virtual
+ CORBA::Float
+ GetMemorySize();
+ //----------------------------------------------------------------------------
int
- GetFaceLimit() { return myFaceLimit; }
+ GetFaceLimit();
void
- SetFaceLimit( int theFaceLimit ) { myFaceLimit = theFaceLimit; }
+ SetFaceLimit( int theFaceLimit );
bool
GetIsDeformed();
//! Get color for Geometry mode of the presentation.
QColor
- GetColor() { return myColor; }
+ GetColor();
//! Set color for Geometry mode of the presentation.
void
- SetColor( const QColor& theColor ) { myColor = theColor; }
+ SetColor( const QColor& theColor );
//! Get flag indicating which mode of the presentation is active.
/*! When Results mode is active, returns true. Geometry - false. */
bool
- GetIsColored() { return myIsColored; }
+ GetIsColored();
//! Get flag indicating which mode of the presentation is active.
void
bool
IsGlobalRangeDefined() const;
+ virtual
+ CORBA::Double
+ GetSourceMin();
+
+ virtual
+ CORBA::Double
+ GetSourceMax();
+
+ virtual
+ void
+ SetSourceRange();
+
//! To update the min / max automatically
virtual
void
UpdateMinMax();
+ VISU_GaussPointsPL*
+ GetSpecificPL() const
+ {
+ return myGaussPointsPL;
+ }
+
protected:
+ //! Redefines VISU_ColoredPrs3d_i::DoSetInput
virtual
void
- DoSetInput(Result_i* theResult);
+ DoSetInput(bool theIsInitilizePipe, bool theReInit);
+ //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine
virtual
void
- DoHook();
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
+
+ //! Redefines VISU_ColoredPrs3d_i::CheckIsPossible
+ virtual
+ bool
+ CheckIsPossible();
virtual
const char*
- GetIconName() {return "ICON_TREE_GAUSS_POINTS";}
+ GetIconName();
virtual
VISU_PipeLine*
- GetPipeLine();
+ GetActorPipeLine();
bool
- OnCreateActor(VISU_GaussPtsAct* theActor,
- const Handle(SALOME_InteractiveObject)& theIO = NULL);
+ OnCreateActor(VISU_GaussPtsAct* theActor);
VISU_GaussPtsAct1*
- OnCreateActor1(const Handle(SALOME_InteractiveObject)& theIO = NULL);
+ OnCreateActor1();
VISU_GaussPtsAct2*
- OnCreateActor2(const Handle(SALOME_InteractiveObject)& theIO = NULL);
+ OnCreateActor2();
void
UpdateScalarBar(vtkScalarBarActor *theScalarBar,
vtkLookupTable* theLookupTable);
-
+ protected:
VISU_GaussPointsPL *myGaussPointsPL;
-
- bool myIsColored;
+
bool myIsDispGlobalScalarBar;
bool myIsActiveLocalScalarBar;
QColor myColor;
public:
static
- int
+ size_t
IsPossible(Result_i* theResult,
- const char* theMeshName,
+ const std::string& theMeshName,
VISU::Entity theEntity,
- const char* theFieldName,
- int theIteration,
- int isMemoryCheck = true);
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck);
virtual
Storable*
- Create(const char* theMeshName,
+ Create(const std::string& theMeshName,
VISU::Entity theEntity,
- const char* theFieldName,
- int theIteration);
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber);
+
+ virtual
+ void
+ SameAs(const Prs3d_i* theOrigin);
static const std::string myComment;
virtual
Storable*
- Restore(const Storable::TRestoringMap& theMap);
+ Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap);
//----------------------------------------------------------------------------
virtual
VISU_Actor*
- CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
+ CreateActor();
virtual
VISU_GaussPtsAct2*
}
#endif
-
#include "VISU_Prs3d_i.hh"
#include "VISU_Mesh_i.hh"
-#include "VISU_ScalarMap_i.hh"
-#include "VISU_IsoSurfaces_i.hh"
-#include "VISU_DeformedShape_i.hh"
-#include "VISU_CutPlanes_i.hh"
-#include "VISU_CutLines_i.hh"
-#include "VISU_Vectors_i.hh"
-#include "VISU_StreamLines_i.hh"
-#include "VISU_GaussPoints_i.hh"
-#include "VISU_Plot3D_i.hh"
#include "VISU_Table_i.hh"
#include "VISU_TimeAnimation.h"
-#include "VISU_ScalarMapOnDeformedShape_i.hh"
-#include "VISU_PrsMerger_i.hh"
+
+#include "VISU_ColoredPrs3dFactory.hh"
+#include "VISU_ColoredPrs3dCache_i.hh"
+#include "VISU_ColoredPrs3dHolder_i.hh"
#include "VISU_Actor.h"
#include <TCollection_AsciiString.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
-// STL Includes
-#include <strstream>
-
#include "Utils_ExceptHandlers.hxx"
+UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
-#define NO_CAS_CATCH
-#endif
-
-#include <Standard_Failure.hxx>
-
-#ifdef NO_CAS_CATCH
-#include <Standard_ErrorHandler.hxx>
-#else
-#include "CASCatch.hxx"
-#endif
+// STL Includes
+#include <strstream>
using namespace std;
#ifdef _DEBUG_
static int MYDEBUG = 0;
-//#define _DEXCEPT_
#else
static int MYDEBUG = 0;
#endif
-UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
-
-extern "C" VISU_I_EXPORT VISU::VISU_Gen_ptr GetImpl(CORBA::ORB_ptr theORB,
- PortableServer::POA_ptr thePOA,
- SALOME_NamingService* theNamingService,
- QMutex* theMutex)
+extern "C"
+VISU::VISU_Gen_ptr
+GetImpl(CORBA::ORB_ptr theORB,
+ PortableServer::POA_ptr thePOA,
+ SALOME_NamingService* theNamingService,
+ QMutex* theMutex)
{
- if(MYDEBUG) MESSAGE("extern \"C\" GetImpl");
+ if(MYDEBUG) MESSAGE("extern 'C' GetImpl");
VISU::VISU_Gen_i *aVISU_Gen = new VISU::VISU_Gen_i(theORB,thePOA,theNamingService,theMutex);
//return VISU::VISU_Gen::_duplicate(aVISU_Gen->_this());
return aVISU_Gen->_this();
namespace VISU
{
+ //----------------------------------------------------------------------------
static string VisuTmpDir;
static CORBA::Boolean myIsMultiFile;
const CORBA::Boolean IsMultifile() { return myIsMultiFile;}
- //===========================================================================
- _PTR(SComponent) ClientFindOrCreateVisuComponent (_PTR(Study) theStudyDocument)
+ //----------------------------------------------------------------------------
+ _PTR(SComponent)
+ ClientFindOrCreateVisuComponent (_PTR(Study) theStudyDocument)
{
_PTR(SComponent) aSComponent = theStudyDocument->FindComponent("VISU");
if (!aSComponent) {
return aSComponent;
}
- SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument){
+
+ //----------------------------------------------------------------------------
+ SALOMEDS::SComponent_var
+ FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument)
+ {
SALOMEDS::SComponent_var aSComponent = theStudyDocument->FindComponent("VISU");
if (aSComponent->_is_nil()) {
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
return aSComponent;
}
- void RegistryStorable() {
+
+ //----------------------------------------------------------------------------
+ void
+ RegistryStorable()
+ {
Storable::Registry(Result_i::myComment.c_str(),&(Result_i::Restore));
- Storable::Registry(Mesh_i::myComment.c_str(),&(Restore<Mesh_i>));
- Storable::Registry(ScalarMap_i::myComment.c_str(),&(Restore<PrsMerger_i>));
+ Storable::Registry(Mesh_i::myComment.c_str(),&(Mesh_i::Restore));
+ Storable::Registry(ScalarMap_i::myComment.c_str(),&(Restore<ScalarMap_i>));
Storable::Registry(GaussPoints_i::myComment.c_str(),&(Restore<GaussPoints_i>));
Storable::Registry(DeformedShape_i::myComment.c_str(),&(Restore<DeformedShape_i>));
Storable::Registry(CutPlanes_i::myComment.c_str(),&(Restore<CutPlanes_i>));
Storable::Registry(Curve_i::myComment.c_str(),&(Curve_i::Restore));
Storable::Registry(Container_i::myComment.c_str(),&(Container_i::Restore));
Storable::Registry(ScalarMapOnDeformedShape_i::myComment.c_str(),&(Restore<ScalarMapOnDeformedShape_i>));
- Storable::Registry(PrsMerger_i::myComment.c_str(),&(Restore<PrsMerger_i>));
+ Storable::Registry(ColoredPrs3dHolder_i::myComment.c_str(),&(ColoredPrs3dHolder_i::Restore));
+ Storable::Registry(ColoredPrs3dCache_i::myComment.c_str(),&(ColoredPrs3dCache_i::Restore));
}
- //===========================================================================
- VISU_Gen_i::VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA,
- SALOME_NamingService* theNamingService, QMutex* theMutex) :
+ //----------------------------------------------------------------------------
+ VISU_Gen_i
+ ::VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA,
+ SALOME_NamingService* theNamingService, QMutex* theMutex) :
Engines_Component_i()
{
if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : "<<theMutex);
if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : there is no opened study in StudyManager !!!");
}
- bool
- CreatColoredPrs3d(ColoredPrs3d_i* theColoredPrs3d,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+
+ //----------------------------------------------------------------------------
+ Prs3d_ptr
+ VISU_Gen_i
+ ::CreatePrs3d(VISUType theType,
+ SALOMEDS::Study_ptr theStudy)
{
-#ifndef _DEXCEPT_
-# ifdef NO_CAS_CATCH
- try{
- OCC_CATCH_SIGNALS;
-# else
- CASCatch_TRY{
- try{
-# endif
-#endif
- if(theColoredPrs3d->Create(theMeshName,theEntity,theFieldName,int(theIteration)))
- return true;
-#ifndef _DEXCEPT_
-# ifdef NO_CAS_CATCH
- }catch(Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- INFOS("Follow signal was occured :\n"<<aFail->GetMessageString());
- }catch(std::exception& exc){
- INFOS("Follow exception was occured :\n"<<exc.what());
- }catch(...){
- INFOS("Unknown exception was occured!");
- }
-# else
- }catch(std::exception& exc){
- INFOS("Follow exception was occured :\n"<<exc.what());
- }catch(...){
- INFOS("Unknown exception was occured!");
- }
- }CASCatch_CATCH(Standard_Failure){
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- INFOS("Follow signal was occured :\n"<<aFail->GetMessageString());
- }
-# endif
-#endif
- return false;
- }
+ if(ColoredPrs3d_i* aPrs3d = CreatePrs3d_i(theType, theStudy, ColoredPrs3d_i::EPublishIndependently))
+ return aPrs3d->_this();
+ return Prs3d::_nil();
+ }
+
- VISU_Gen_i::~VISU_Gen_i(){
+ //----------------------------------------------------------------------------
+ VISU_Gen_i
+ ::~VISU_Gen_i()
+ {
if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i");
}
- void CorrectSObjectType(SALOMEDS::SObject_ptr theSObject, SALOMEDS::StudyBuilder_ptr theBuilder)
+
+ //----------------------------------------------------------------------------
+ void
+ CorrectSObjectType(SALOMEDS::SObject_ptr theSObject,
+ SALOMEDS::StudyBuilder_ptr theBuilder)
{
SALOMEDS::GenericAttribute_var anAttr;
bool isAttrStringFound = false;
SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
aStringAttr->SetValue(aValue.c_str());
isAttrStringFound = true;
-
}
if ( isAttrStringFound || theSObject->FindAttribute(anAttr, "AttributeString") ) {
else if ( !aComment.compare(QString("CONTAINER")) ) aVISUType = VISU::TCONTAINER;
else if ( !aComment.compare(QString("MESH")) ) aVISUType = VISU::TMESH;
else if ( !aComment.compare(QString("SCALARMAP")) ) aVISUType = VISU::TSCALARMAP;
- else if ( !aComment.compare(QString("PRSMERGER")) ) aVISUType = VISU::TPRSMERGER;
+ else if ( !aComment.compare(QString("PRSMERGER")) ) aVISUType = VISU::TSCALARMAP;
else if ( !aComment.compare(QString("ISOSURFACE")) ) aVISUType = VISU::TISOSURFACE;
else if ( !aComment.compare(QString("DEFORMEDSHAPE")) ) aVISUType = VISU::TDEFORMEDSHAPE;
else if ( !aComment.compare(QString("SCALARMAPONDEFORMEDSHAPE")) ) aVISUType = VISU::TSCALARMAPONDEFORMEDSHAPE;
else if ( !aComment.compare(QString("GAUSSVIEW")) ) aVISUType = VISU::TGAUSSVIEW;
else if ( !aComment.compare(QString("ENTITY")) ) aVISUType = VISU::TENTITY;
else if ( !aComment.compare(QString("FAMILY")) ) aVISUType = VISU::TFAMILY;
+ else if ( !aComment.compare(QString("PART")) ) aVISUType = VISU::TPART; // MULTIPR
else if ( !aComment.compare(QString("GROUP")) ) aVISUType = VISU::TGROUP;
else if ( !aComment.compare(QString("FIELD")) ) aVISUType = VISU::TFIELD;
else if ( !aComment.compare(QString("TIMESTAMP")) ) aVISUType = VISU::TTIMESTAMP;
}
}
- //===========================================================================
- CORBA::Boolean VISU_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
- const SALOMEDS::TMPFile & theStream,
- const char* theURL,
- bool isMultiFile)
+
+ //----------------------------------------------------------------------------
+ CORBA::Boolean
+ VISU_Gen_i
+ ::Load(SALOMEDS::SComponent_ptr theComponent,
+ const SALOMEDS::TMPFile & theStream,
+ const char* theURL,
+ bool isMultiFile)
{
Mutex mt(myMutex);
SALOMEDS::Study_var aStudy = theComponent->GetStudy();
return true;
}
- CORBA::Boolean VISU_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
- const SALOMEDS::TMPFile & theStream,
- const char* theURL,
- bool isMultiFile)
+
+ //----------------------------------------------------------------------------
+ CORBA::Boolean
+ VISU_Gen_i
+ ::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
+ const SALOMEDS::TMPFile & theStream,
+ const char* theURL,
+ bool isMultiFile)
{
return Load(theComponent, theStream, theURL, isMultiFile);
}
- char* VISU_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
- const char* aLocalPersistentID,
- CORBA::Boolean isMultiFile,
- CORBA::Boolean isASCII)
+
+ //----------------------------------------------------------------------------
+ char*
+ VISU_Gen_i
+ ::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
+ const char* aLocalPersistentID,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean isASCII)
{
CORBA::String_var aString("");
if(strcmp(aLocalPersistentID,"") != 0) {
return aString._retn();
}
- //===========================================================================
- SALOMEDS::TMPFile* VISU_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
- const char* theURL,
- bool theIsMultiFile)
+
+ //----------------------------------------------------------------------------
+ SALOMEDS::TMPFile*
+ VISU_Gen_i
+ ::Save(SALOMEDS::SComponent_ptr theComponent,
+ const char* theURL,
+ bool theIsMultiFile)
{
Mutex mt(myMutex);
string aTmpDir = theURL;
return aStreamFile._retn();
}
- SALOMEDS::TMPFile* VISU_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
- const char* theURL,
- bool isMultiFile)
+
+ //----------------------------------------------------------------------------
+ SALOMEDS::TMPFile*
+ VISU_Gen_i
+ ::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
+ const char* theURL,
+ bool isMultiFile)
{
Mutex mt(myMutex);
string aDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
return aStreamFile._retn();
}
- char* VISU_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
- const char* IORString,
- CORBA::Boolean isMultiFile,
- CORBA::Boolean isASCII)
+
+ //----------------------------------------------------------------------------
+ char*
+ VISU_Gen_i
+ ::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
+ const char* IORString,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean isASCII)
{
CORBA::String_var aString(IORString);
if(strcmp(IORString,"") != 0){
return aString._retn();
}
- char* VISU_Gen_i::GetID(){
+
+ //----------------------------------------------------------------------------
+ char*
+ VISU_Gen_i
+ ::GetID()
+ {
return Base_i::GetID();
}
- void VISU_Gen_i::SetCurrentStudy (SALOMEDS::Study_ptr theStudy)
+
+ //----------------------------------------------------------------------------
+ void
+ VISU_Gen_i
+ ::SetCurrentStudy(SALOMEDS::Study_ptr theStudy)
{
class TEvent: public SALOME_Event {
std::string myStudyName;
}
}
- SALOMEDS::Study_ptr VISU_Gen_i::GetCurrentStudy(){
+
+ //----------------------------------------------------------------------------
+ SALOMEDS::Study_ptr
+ VISU_Gen_i
+ ::GetCurrentStudy()
+ {
return SALOMEDS::Study::_duplicate(myStudyDocument);
}
- ViewManager_ptr VISU_Gen_i::GetViewManager(){
+
+ //----------------------------------------------------------------------------
+ ViewManager_ptr
+ VISU_Gen_i
+ ::GetViewManager()
+ {
Mutex mt(myMutex);
ViewManager_i * aViewManager = new ViewManager_i(myStudyDocument);
return ViewManager::_duplicate(aViewManager->_this());
}
- SALOMEDS::SObject_ptr VISU_Gen_i::ImportTables(const char* theFileName){
+
+ //----------------------------------------------------------------------------
+ SALOMEDS::SObject_ptr
+ VISU_Gen_i
+ ::ImportTables(const char* theFileName)
+ {
if(myStudyDocument->GetProperties()->IsLocked())
return SALOMEDS::SObject::_nil();
Mutex mt(myMutex);
return aRes._retn();
}
- CORBA::Boolean VISU_Gen_i::ExportTableToFile(SALOMEDS::SObject_ptr theTable,
- const char* theFileName)
+
+ //----------------------------------------------------------------------------
+ CORBA::Boolean
+ VISU_Gen_i
+ ::ExportTableToFile(SALOMEDS::SObject_ptr theTable,
+ const char* theFileName)
{
return VISU::ExportTableToFile(theTable, theFileName);
}
- Result_ptr VISU_Gen_i::ImportFile(const char* theFileName){
+
+ //----------------------------------------------------------------------------
+ Result_ptr
+ VISU_Gen_i
+ ::ImportFile(const char* theFileName)
+ {
if(myStudyDocument->GetProperties()->IsLocked())
return Result::_nil();
Mutex mt(myMutex);
}
}
- Result_ptr VISU_Gen_i::CreateResult(const char* theFileName){
+
+ //----------------------------------------------------------------------------
+ Result_ptr
+ VISU_Gen_i
+ ::CreateResult(const char* theFileName)
+ {
if(myStudyDocument->GetProperties()->IsLocked())
return Result::_nil();
Mutex mt(myMutex);
}
}
- Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){
+
+ //----------------------------------------------------------------------------
+ Result_ptr
+ VISU_Gen_i
+ ::CopyAndImportFile(const char* theFileName)
+ {
if(myStudyDocument->GetProperties()->IsLocked())
return Result::_nil();
Mutex mt(myMutex);
return aResult._retn();
}
- Result_ptr VISU_Gen_i::ImportMed (SALOMEDS::SObject_ptr theMedSObject)
+
+ //----------------------------------------------------------------------------
+ Result_ptr
+ VISU_Gen_i
+ ::ImportMed(SALOMEDS::SObject_ptr theMedSObject)
{
if (myStudyDocument->GetProperties()->IsLocked())
return Result::_nil();
}
}
- Result_ptr VISU_Gen_i::ImportMedField (SALOME_MED::FIELD_ptr theField)
+
+ //----------------------------------------------------------------------------
+ Result_ptr
+ VISU_Gen_i
+ ::ImportMedField (SALOME_MED::FIELD_ptr theField)
{
if (myStudyDocument->GetProperties()->IsLocked())
return Result::_nil();
}
}
- void VISU_Gen_i::RenameMeshInStudy(Result_ptr theResult,
- string theMeshName,
- int theEntity, // -1 for group indication
- string theSubMeshName, // Family or Group name
- string theNewName)
+ void
+ VISU_Gen_i
+ ::RenameMeshInStudy(Result_ptr theResult,
+ const std::string& theMeshName,
+ int theEntity, // -1 for group indication
+ const std::string& theSubMeshName, // Family or Group name
+ const std::string& theNewName)
{
if (myStudyDocument->GetProperties()->IsLocked()) return;
Mutex mt(myMutex);
aStudyBuilder->CommitCommand();
}
- void VISU_Gen_i::RenameEntityInStudy(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theNewName)
+
+ //----------------------------------------------------------------------------
+ void
+ VISU_Gen_i
+ ::RenameEntityInStudy(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theNewName)
{
RenameMeshInStudy(theResult, theMeshName, (int)theEntity, "", theNewName);
}
- void VISU_Gen_i::RenameFamilyInStudy(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFamilyName,
- const char* theNewName)
+
+ //----------------------------------------------------------------------------
+ void
+ VISU_Gen_i
+ ::RenameFamilyInStudy(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFamilyName,
+ const char* theNewName)
{
RenameMeshInStudy(theResult, theMeshName, (int)theEntity, theFamilyName, theNewName);
}
- void VISU_Gen_i::RenameGroupInStudy(Result_ptr theResult,
- const char* theMeshName,
- const char* theGroupName,
- const char* theNewName)
+
+ //----------------------------------------------------------------------------
+ void
+ VISU_Gen_i
+ ::RenameGroupInStudy(Result_ptr theResult,
+ const char* theMeshName,
+ const char* theGroupName,
+ const char* theNewName)
{
RenameMeshInStudy(theResult, theMeshName, -1, theGroupName, theNewName);
}
- Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity)
+
+ //----------------------------------------------------------------------------
+ Mesh_ptr
+ VISU_Gen_i
+ ::MeshOnEntity(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity)
{
if(myStudyDocument->GetProperties()->IsLocked())
return Mesh::_nil();
- Mutex mt(myMutex);
- if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
- Mesh_i* aPresent = new Mesh_i(pResult);
- if(aPresent->Create(theMeshName,theEntity) != NULL)
+
+ if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
+ Mesh_i* aPresent = new Mesh_i();
+ if(aPresent->Create(aResult, theMeshName, theEntity))
return aPresent->_this();
else{
aPresent->_remove_ref();
return VISU::Mesh::_nil();
}
- Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFamilyName)
+
+ //----------------------------------------------------------------------------
+ Mesh_ptr
+ VISU_Gen_i
+ ::FamilyMeshOnEntity(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFamilyName)
{
if(myStudyDocument->GetProperties()->IsLocked())
return Mesh::_nil();
- Mutex mt(myMutex);
- if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
- Mesh_i* aPresent = new Mesh_i(pResult);
- if(aPresent->Create(theMeshName,theEntity,theFamilyName) != NULL)
+
+ if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
+ Mesh_i* aPresent = new Mesh_i();
+ if(aPresent->Create(aResult, theMeshName, theEntity, theFamilyName))
return aPresent->_this();
else{
aPresent->_remove_ref();
return VISU::Mesh::_nil();
}
- Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult,
- const char* theMeshName,
- const char* theGroupName)
+
+ //----------------------------------------------------------------------------
+ Mesh_ptr
+ VISU_Gen_i
+ ::GroupMesh(Result_ptr theResult,
+ const char* theMeshName,
+ const char* theGroupName)
{
if(myStudyDocument->GetProperties()->IsLocked())
return Mesh::_nil();
- Mutex mt(myMutex);
- if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
- Mesh_i* aPresent = new Mesh_i(pResult);
- if(aPresent->Create(theMeshName,theGroupName) != NULL)
+
+ if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
+ Mesh_i* aPresent = new Mesh_i();
+ if(aPresent->Create(aResult, theMeshName, theGroupName))
return aPresent->_this();
else{
aPresent->_remove_ref();
return VISU::Mesh::_nil();
}
- ScalarMap_ptr VISU_Gen_i::ScalarMapOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+
+ //----------------------------------------------------------------------------
+ ScalarMap_ptr
+ VISU_Gen_i
+ ::ScalarMapOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
- //return Prs3dOnField<VISU::ScalarMap_i>(theResult,theMeshName,theEntity,theFieldName,theIteration,true)._retn();
- return Prs3dOnField<VISU::PrsMerger_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
+ return Prs3dOnField<VISU::ScalarMap_i>(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theIteration)._retn();
}
- GaussPoints_ptr VISU_Gen_i::GaussPointsOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+
+ //----------------------------------------------------------------------------
+ GaussPoints_ptr
+ VISU_Gen_i
+ ::GaussPointsOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
- return Prs3dOnField<VISU::GaussPoints_i>(theResult,theMeshName,theEntity,theFieldName,theIteration,true)._retn();
+ return Prs3dOnField<VISU::GaussPoints_i>(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theIteration)._retn();
}
- DeformedShape_ptr VISU_Gen_i::DeformedShapeOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ DeformedShape_ptr
+ VISU_Gen_i
+ ::DeformedShapeOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
- return Prs3dOnField<VISU::DeformedShape_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
+ return Prs3dOnField<VISU::DeformedShape_i>(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theIteration)._retn();
}
- ScalarMapOnDeformedShape_ptr VISU_Gen_i::ScalarMapOnDeformedShapeOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ ScalarMapOnDeformedShape_ptr
+ VISU_Gen_i
+ ::ScalarMapOnDeformedShapeOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
- return Prs3dOnField<VISU::ScalarMapOnDeformedShape_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
+ return Prs3dOnField<VISU::ScalarMapOnDeformedShape_i>(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theIteration)._retn();
}
- Vectors_ptr VISU_Gen_i::VectorsOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ Vectors_ptr
+ VISU_Gen_i
+ ::VectorsOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
- return Prs3dOnField<VISU::Vectors_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
+ return Prs3dOnField<VISU::Vectors_i>(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theIteration)._retn();
}
- IsoSurfaces_ptr VISU_Gen_i::IsoSurfacesOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ IsoSurfaces_ptr
+ VISU_Gen_i
+ ::IsoSurfacesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
- return Prs3dOnField<VISU::IsoSurfaces_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
+ return Prs3dOnField<VISU::IsoSurfaces_i>(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theIteration)._retn();
}
- StreamLines_ptr VISU_Gen_i::StreamLinesOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ StreamLines_ptr
+ VISU_Gen_i
+ ::StreamLinesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
- return Prs3dOnField<VISU::StreamLines_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
+ return Prs3dOnField<VISU::StreamLines_i>(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theIteration)._retn();
}
- Plot3D_ptr VISU_Gen_i::Plot3DOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration)
+ Plot3D_ptr
+ VISU_Gen_i
+ ::Plot3DOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
+ CORBA::Long theIteration)
{
- return Prs3dOnField<VISU::Plot3D_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
+ return Prs3dOnField<VISU::Plot3D_i>(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theIteration)._retn();
}
CutPlanes_ptr VISU_Gen_i::CutPlanesOnField(Result_ptr theResult,
const char* theMeshName,
VISU::Entity theEntity,
const char* theFieldName,
- CORBA::Double theIteration)
+ CORBA::Long theIteration)
{
- return Prs3dOnField<VISU::CutPlanes_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
+ return Prs3dOnField<VISU::CutPlanes_i>(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theIteration)._retn();
}
CutLines_ptr VISU_Gen_i::CutLinesOnField(Result_ptr theResult,
const char* theMeshName,
VISU::Entity theEntity,
const char* theFieldName,
- CORBA::Double theIteration)
+ CORBA::Long theIteration)
{
- return Prs3dOnField<VISU::CutLines_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
+ return Prs3dOnField<VISU::CutLines_i>(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theIteration)._retn();
}
struct CreateTableEvent: public SALOME_Event
// Assign an ID = 1 the the type VISU::Result
theObjectID = 1;
-
SALOMEDS::SComponent_var aSComponent = theObject->GetStudy()->FindComponent("VISU");
return aStreamFile._retn();
}
anIOR->SetValue(anIORValue);
return aResultSO._retn();
}
+
+ VISU::ColoredPrs3dCache_ptr
+ VISU_Gen_i::
+ GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy)
+ {
+ return ColoredPrs3dCache_i::GetInstance(theStudy);
+ }
}
#include "SALOME_Component_i.hxx"
#include "SALOME_NamingService.hxx"
+#include "VISU_ColoredPrs3d_i.hh"
#include <string>
namespace VISU
{
- class Result_i;
- class ColoredPrs3d_i;
-
- bool
- VISU_I_EXPORT CreatColoredPrs3d(ColoredPrs3d_i* theColoredPrs3d,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration);
-
+ //----------------------------------------------------------------------------
class VISU_Gen_i : public virtual POA_VISU::VISU_Gen,
public virtual ::Engines_Component_i,
public virtual Base_i
PortableServer::POA_ptr thePOA,
SALOME_NamingService* theNamingService,
QMutex* theMutex);
- virtual ~VISU_Gen_i();
+
+ virtual
+ ~VISU_Gen_i();
virtual
char*
const char* theFileName );
//Create Result
- virtual
+ virtual
Result_ptr
ImportFile(const char* theFileName);
//Rename Presentation Of Submeshes
void
- RenameMeshInStudy(Result_ptr theResult,
- std::string theMeshName,
- int theEntity, // -1 for group indication
- std::string theSubMeshName, // Family or Group name
- std::string theNewName);
+ RenameMeshInStudy(Result_ptr theResult,
+ const std::string& theMeshName,
+ int theEntity, // -1 for group indication
+ const std::string& theSubMeshName, // Family or Group name
+ const std::string& theNewName);
virtual
void
RenameEntityInStudy(Result_ptr theResult,
virtual
void
RenameGroupInStudy(Result_ptr theResult,
- const char* theMeshName,
+ const char* theMeshName,
const char* theGroupName,
const char* theNewName);
const char* theMeshName,
const char* theGroupName);
- //Create 3D collored Presentation Of Different Types
- template<typename TPrs3d_i> TPrs3d_i*
- CreatePrs3d(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration,
- bool theAddToStudy = true)
- {
- if(myStudyDocument->GetProperties()->IsLocked())
- return NULL;
-
- typedef typename TPrs3d_i::TInterface TPrs3d;
- typename TPrs3d::_var_type aPrs3d;
- Mutex mt(myMutex);
- if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
- if(TPrs3d_i::IsPossible(aResult,theMeshName,theEntity,theFieldName,int(theIteration))){
- TPrs3d_i* aPresent = new TPrs3d_i(aResult,theAddToStudy);
- if(CreatColoredPrs3d(aPresent,theMeshName,theEntity,theFieldName,theIteration))
- return aPresent;
- aPresent->_remove_ref();
- }
- }
- return NULL;
- }
-
- template<typename TPrs3d_i> typename TPrs3d_i::TInterface::_var_type
- Prs3dOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
- CORBA::Double theIteration,
- bool theAddToStudy = true)
- {
- typedef typename TPrs3d_i::TInterface TPrs3d;
- typename TPrs3d::_var_type aPrs3d;
- if(TPrs3d_i* aPrs3d = CreatePrs3d<TPrs3d_i>(theResult,theMeshName,theEntity,theFieldName,theIteration,theAddToStudy))
- return aPrs3d->_this();
- return TPrs3d::_nil();
- }
+ Prs3d_ptr
+ CreatePrs3d(VISUType theType,
+ SALOMEDS::Study_ptr theStudy);
virtual
ScalarMap_ptr
const char* theMeshName,
VISU::Entity theEntity,
const char* theFieldName,
- CORBA::Double theIteration);
+ CORBA::Long theIteration);
virtual
GaussPoints_ptr
const char* theMeshName,
VISU::Entity theEntity,
const char* theFieldName,
- CORBA::Double theIteration);
+ CORBA::Long theIteration);
virtual
DeformedShape_ptr
const char* theMeshName,
VISU::Entity theEntity,
const char* theFieldName,
- CORBA::Double theIteration);
+ CORBA::Long theIteration);
virtual
ScalarMapOnDeformedShape_ptr
const char* theMeshName,
VISU::Entity theEntity,
const char* theFieldName,
- CORBA::Double theIteration);
+ CORBA::Long theIteration);
virtual
Vectors_ptr
VectorsOnField(Result_ptr theResult,
const char* theMeshName,
VISU::Entity theEntity,
const char* theFieldName,
- CORBA::Double theIteration);
+ CORBA::Long theIteration);
virtual
IsoSurfaces_ptr
const char* theMeshName,
VISU::Entity theEntity,
const char* theFieldName,
- CORBA::Double theIteration);
+ CORBA::Long theIteration);
virtual
CutPlanes_ptr
const char* theMeshName,
VISU::Entity theEntity,
const char* theFieldName,
- CORBA::Double theIteration);
+ CORBA::Long theIteration);
virtual
CutLines_ptr
const char* theMeshName,
VISU::Entity theEntity,
const char* theFieldName,
- CORBA::Double theIteration);
+ CORBA::Long theIteration);
virtual
StreamLines_ptr
const char* theMeshName,
VISU::Entity theEntity,
const char* theFieldName,
- CORBA::Double theIteration);
+ CORBA::Long theIteration);
virtual
Plot3D_ptr
const char* theMeshName,
VISU::Entity theEntity,
const char* theFieldName,
- CORBA::Double theIteration);
+ CORBA::Long theIteration);
//Create Digital Presentation
virtual
PasteInto(const SALOMEDS::TMPFile& theStream,
CORBA::Long theObjectID,
SALOMEDS::SObject_ptr theObject);
+
+ virtual
+ VISU::ColoredPrs3dCache_ptr
+ GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy);
};
}
#include "VISU_Vectors_i.hh"
#include "VISU_StreamLines_i.hh"
#include "VISU_GaussPoints_i.hh"
+#include "VISU_ScalarMapOnDeformedShape_i.hh"
#include "VISU_ViewManager_i.hh"
#include "VISU_View_i.hh"
#include "VISU_TimeAnimation.h"
#include "SUIT_ResourceMgr.h"
#include "SALOME_Event.hxx"
-using namespace VISU;
-using namespace std;
-
#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
#endif
-int VISU::IsoSurfaces_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration, int isMemoryCheck)
+//---------------------------------------------------------------
+size_t
+VISU::IsoSurfaces_i
+::IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck)
{
- return TSuperClass::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck);
+ return TSuperClass::IsPossible(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber,
+ theIsMemoryCheck);
}
+//---------------------------------------------------------------
int VISU::IsoSurfaces_i::myNbPresent = 0;
-QString VISU::IsoSurfaces_i::GenerateName() { return VISU::GenerateName("IsoSurfaces",myNbPresent++);}
-
-const string VISU::IsoSurfaces_i::myComment = "ISOSURFACES";
-const char* VISU::IsoSurfaces_i::GetComment() const { return myComment.c_str();}
+//---------------------------------------------------------------
+QString VISU::IsoSurfaces_i::GenerateName()
+{
+ return VISU::GenerateName("IsoSurfaces",myNbPresent++);
+}
-VISU::IsoSurfaces_i::
-IsoSurfaces_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theAddToStudy),
- ColoredPrs3d_i(theResult,theAddToStudy),
- ScalarMap_i(theResult,theAddToStudy),
- TSuperClass(theResult,theAddToStudy),
- myIsoSurfacesPL(NULL)
-{}
+//---------------------------------------------------------------
+const string VISU::IsoSurfaces_i::myComment = "ISOSURFACES";
+//---------------------------------------------------------------
+const char*
+VISU::IsoSurfaces_i
+::GetComment() const
+{
+ return myComment.c_str();
+}
-VISU::IsoSurfaces_i::
-IsoSurfaces_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
- ColoredPrs3d_i(theResult,theSObject),
- ScalarMap_i(theResult,theSObject),
- TSuperClass(theResult,theSObject),
- myIsoSurfacesPL(NULL)
+//---------------------------------------------------------------
+const char*
+VISU::IsoSurfaces_i
+::GetIconName()
{
+ if (!IsGroupsUsed())
+ return "ICON_TREE_ISO_SURFACES";
+ else
+ return "ICON_TREE_ISO_SURFACES_GROUPS";
}
+//---------------------------------------------------------------
+VISU::IsoSurfaces_i
+::IsoSurfaces_i(EPublishInStudyMode thePublishInStudyMode) :
+ ColoredPrs3d_i(thePublishInStudyMode),
+ ScalarMap_i(thePublishInStudyMode),
+ myIsoSurfacesPL(NULL)
+{}
+
-VISU::Storable* VISU::IsoSurfaces_i::Create(const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration)
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::IsoSurfaces_i
+::Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
{
- return TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
+ return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
}
-VISU::Storable* VISU::IsoSurfaces_i::Restore(const Storable::TRestoringMap& theMap)
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::IsoSurfaces_i
+::Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
{
- TSuperClass::Restore(theMap);
+ if(!TSuperClass::Restore(theStudy, theMap))
+ return NULL;
SetNbSurfaces(VISU::Storable::FindValue(theMap,"myNbSurface").toInt());
float aMin = VISU::Storable::FindValue(theMap,"myRange[0]").toDouble();
return this;
}
-void VISU::IsoSurfaces_i::ToStream(std::ostringstream& theStr){
+
+//---------------------------------------------------------------
+void
+VISU::IsoSurfaces_i
+::ToStream(std::ostringstream& theStr)
+{
TSuperClass::ToStream(theStr);
Storable::DataToStream( theStr, "myNbSurface", int(GetNbSurfaces()) );
}
-VISU::IsoSurfaces_i::~IsoSurfaces_i(){
+//---------------------------------------------------------------
+VISU::IsoSurfaces_i
+::~IsoSurfaces_i()
+{
if(MYDEBUG) MESSAGE("IsoSurfaces_i::~IsoSurfaces_i()");
}
-void VISU::IsoSurfaces_i::SetNbSurfaces(CORBA::Long theNb){
+//---------------------------------------------------------------
+void
+VISU::IsoSurfaces_i
+::SetNbSurfaces(CORBA::Long theNb)
+{
- struct TEvent: public SALOME_Event {
+ struct TEvent: public SALOME_Event
+ {
VISU_IsoSurfacesPL* myIsoSurfacesPL;
CORBA::Long myNb;
- TEvent( VISU_IsoSurfacesPL* theIsoSurfacesPL, int theNb)
- :myIsoSurfacesPL(theIsoSurfacesPL), myNb(theNb)
+
+ TEvent(VISU_IsoSurfacesPL* theIsoSurfacesPL,
+ CORBA::Long theNb):
+ myIsoSurfacesPL(theIsoSurfacesPL),
+ myNb(theNb)
{}
virtual
ProcessVoidEvent(new TEvent(myIsoSurfacesPL, theNb));
}
-CORBA::Long VISU::IsoSurfaces_i::GetNbSurfaces(){
+//---------------------------------------------------------------
+CORBA::Long
+VISU::IsoSurfaces_i
+::GetNbSurfaces()
+{
return myIsoSurfacesPL->GetNbParts();
}
-void VISU::IsoSurfaces_i::SetSubRange(CORBA::Double theMin, CORBA::Double theMax)
+//---------------------------------------------------------------
+void
+VISU::IsoSurfaces_i
+::SetSubRange(CORBA::Double theMin, CORBA::Double theMax)
{
vtkFloatingPointType aRange[2] = {theMin, theMax};
myIsoSurfacesPL->SetRange(aRange);
}
-CORBA::Double VISU::IsoSurfaces_i::GetSubMin(){
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::IsoSurfaces_i
+::GetSubMin()
+{
return myIsoSurfacesPL->GetMin();
}
-CORBA::Double VISU::IsoSurfaces_i::GetSubMax(){
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::IsoSurfaces_i
+::GetSubMax()
+{
return myIsoSurfacesPL->GetMax();
}
-void VISU::IsoSurfaces_i::DoHook(){
- if(MYDEBUG) MESSAGE("IsoSurfaces_i::DoHook()- "<<myPipeLine);
- if(!myPipeLine) myPipeLine = VISU_IsoSurfacesPL::New();
- myIsoSurfacesPL = dynamic_cast<VISU_IsoSurfacesPL*>(myPipeLine);
+//---------------------------------------------------------------
+void
+VISU::IsoSurfaces_i
+::CreatePipeLine(VISU_PipeLine* thePipeLine)
+{
+ if(!thePipeLine){
+ myIsoSurfacesPL = VISU_IsoSurfacesPL::New();
+ }else
+ myIsoSurfacesPL = dynamic_cast<VISU_IsoSurfacesPL*>(thePipeLine);
+
+ TSuperClass::CreatePipeLine(myIsoSurfacesPL);
+}
+
- TSuperClass::DoHook();
+//----------------------------------------------------------------------------
+void
+VISU::IsoSurfaces_i
+::DoSetInput(bool theIsInitilizePipe, bool theReInit)
+{
+ TSuperClass::DoSetInput(theIsInitilizePipe, theReInit);
+ if(theIsInitilizePipe || (!IsTimeStampFixed() && !IsRangeFixed()) || theReInit)
+ SetSubRange(GetSourceMin(), GetSourceMax());
}
-const char*
+//---------------------------------------------------------------
+bool
VISU::IsoSurfaces_i
-::GetIconName()
+::CheckIsPossible()
{
- if (!GetNumberOfGeom())
- return "ICON_TREE_ISO_SURFACES";
- else
- return "ICON_TREE_ISO_SURFACES_GROUPS";
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
}
+//---------------------------------------------------------------
VISU_Actor*
VISU::IsoSurfaces_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+::CreateActor()
{
- if(VISU_Actor* anActor = TSuperClass::CreateActor(theIO)){
+ if(VISU_Actor* anActor = TSuperClass::CreateActor()){
anActor->SetVTKMapping(true);
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
int aDispMode = aResourceMgr->integerValue("VISU" , "iso_surfaces_represent", 2);
return NULL;
}
-void VISU::IsoSurfaces_i::SetMapScale(double theMapScale){
+
+//---------------------------------------------------------------
+void
+VISU::IsoSurfaces_i
+::SetMapScale(double theMapScale)
+{
myIsoSurfacesPL->SetMapScale(theMapScale);
}
#ifndef VISU_IsoSurfaces_i_HeaderFile
#define VISU_IsoSurfaces_i_HeaderFile
-#include "VISU_PrsMerger_i.hh"
+#include "VISU_ScalarMap_i.hh"
class VISU_IsoSurfacesPL;
-namespace VISU{
- class VISU_I_EXPORT IsoSurfaces_i : public virtual POA_VISU::IsoSurfaces,
- public virtual PrsMerger_i
+namespace VISU
+{
+ //----------------------------------------------------------------------------
+ class IsoSurfaces_i : public virtual POA_VISU::IsoSurfaces,
+ public virtual ScalarMap_i
{
static int myNbPresent;
IsoSurfaces_i(const IsoSurfaces_i&);
public:
- typedef PrsMerger_i TSuperClass;
+ //----------------------------------------------------------------------------
+ typedef ScalarMap_i TSuperClass;
+ typedef VISU::IsoSurfaces TInterface;
explicit
- IsoSurfaces_i(Result_i* theResult,
- bool theAddToStudy);
- explicit
- IsoSurfaces_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject);
- virtual ~IsoSurfaces_i();
+ IsoSurfaces_i(EPublishInStudyMode thePublishInStudyModep);
- virtual VISU::VISUType GetType() { return VISU::TISOSURFACE;};
+ virtual
+ ~IsoSurfaces_i();
- virtual void SetNbSurfaces(CORBA::Long theNb);
- virtual CORBA::Long GetNbSurfaces();
+ virtual
+ VISU::VISUType
+ GetType()
+ {
+ return VISU::TISOSURFACE;
+ }
- virtual void SetSubRange(CORBA::Double theMin, CORBA::Double theMax);
- virtual CORBA::Double GetSubMin();
- virtual CORBA::Double GetSubMax();
+ virtual
+ void
+ SetNbSurfaces(CORBA::Long theNb);
- typedef VISU::IsoSurfaces TInterface;
- VISU_IsoSurfacesPL* GetIsoSurfacesPL(){ return myIsoSurfacesPL;}
+ virtual
+ CORBA::Long
+ GetNbSurfaces();
+ virtual
+ void
+ SetSubRange(CORBA::Double theMin, CORBA::Double theMax);
+
+ virtual
+ CORBA::Double
+ GetSubMin();
+
+ virtual
+ CORBA::Double
+ GetSubMax();
+
+ VISU_IsoSurfacesPL*
+ GetSpecificPL() const
+ {
+ return myIsoSurfacesPL;
+ }
+
protected:
- virtual void DoHook();
- virtual const char* GetIconName();
+ //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine
+ virtual
+ void
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
+
+ //! Redefines VISU_ScalarMap_i::DoSetInput
+ virtual
+ void
+ DoSetInput(bool theIsInitilizePipe, bool theReInit);
+
+ //! Redefines VISU_ScalarMap_i::CheckIsPossible
+ virtual
+ bool
+ CheckIsPossible();
VISU_IsoSurfacesPL* myIsoSurfacesPL;
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);
+ static
+ size_t
+ IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck);
+
+ virtual
+ Storable*
+ Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber);
static const std::string myComment;
- virtual const char* GetComment() const;
- virtual QString GenerateName();
- virtual void ToStream(std::ostringstream& theStr);
+ virtual
+ const char*
+ GetComment() const;
+
+ virtual
+ QString
+ GenerateName();
- virtual Storable* Restore(const Storable::TRestoringMap& theMap);
+ virtual
+ const char*
+ GetIconName();
+
+ virtual
+ void
+ ToStream(std::ostringstream& theStr);
+
+ virtual
+ Storable*
+ Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap);
virtual
VISU_Actor*
- CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
-
- virtual void SetMapScale(double theMapScale = 1.0);
+ CreateActor();
+
+ virtual
+ void
+ SetMapScale(double theMapScale = 1.0);
};
}
#include "VISU_Mesh_i.hh"
#include "VISU_Result_i.hh"
-#include "VISU_ViewManager_i.hh"
#include "VISU_MeshAct.h"
#include "VISU_MeshPL.hxx"
+#include "VISU_PipeLineUtils.hxx"
#include "VISU_Convertor.hxx"
#include "SALOME_Event.hxx"
#include "SUIT_ResourceMgr.h"
-using namespace VISU;
-using namespace std;
-
#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
static int INCMEMORY = 4;
-int VISU::Mesh_i::myNbPresent = 0;
-
-QString VISU::Mesh_i::GenerateName() { return VISU::GenerateName("Mesh",myNbPresent++);}
-
-const string VISU::Mesh_i::myComment = "MESH";
-
-const char* VISU::Mesh_i::GetComment() const { return myComment.c_str();}
-
-VISU::Mesh_i::
-Mesh_i(Result_i* theResult) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,false),
- myMeshPL(VISU_MeshPL::New())
+//----------------------------------------------------------------------------
+namespace
{
- myPipeLine = myMeshPL;
+ bool
+ IsSameColor(const SALOMEDS::Color& theLeft,
+ const SALOMEDS::Color& theRight)
+ {
+ return
+ VISU::CheckIsSameValue(theLeft.R, theRight.R) &&
+ VISU::CheckIsSameValue(theLeft.G, theRight.G) &&
+ VISU::CheckIsSameValue(theLeft.B, theRight.B);
+ }
}
+//----------------------------------------------------------------------------
+int VISU::Mesh_i::myNbPresent = 0;
-VISU::Mesh_i::
-Mesh_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
- myMeshPL(VISU_MeshPL::New())
-{
- myPipeLine = myMeshPL;
+//----------------------------------------------------------------------------
+QString
+VISU::Mesh_i
+::GenerateName()
+{
+ return VISU::GenerateName("Mesh", myNbPresent++);
}
+//----------------------------------------------------------------------------
+const string VISU::Mesh_i::myComment = "MESH";
-//---------------------------------------------------------------
-void VISU::Mesh_i::RemoveFromStudy()
-{
- struct TRemoveFromStudy: public SALOME_Event
- {
- VISU::Mesh_i* myRemovable;
- TRemoveFromStudy(VISU::Mesh_i* theRemovable):
- myRemovable(theRemovable)
- {}
-
- virtual
- void
- Execute()
- {
- VISU::RemoveFromStudy(myRemovable->GetSObject());
- myRemovable->TSuperClass::RemoveFromStudy();
- }
- };
-
- // Unset icon
- SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
- aStudyBuilder->RemoveAttribute(GetSObject(), "AttributePixMap");
-
- ProcessVoidEvent(new TRemoveFromStudy(this));
+//----------------------------------------------------------------------------
+const char*
+VISU::Mesh_i
+::GetComment() const
+{
+ return myComment.c_str();
}
-
-void VISU::Mesh_i::SameAs (const Prs3d_i* theOrigin)
+//----------------------------------------------------------------------------
+VISU::Mesh_i
+::Mesh_i():
+ myMeshPL(VISU_MeshPL::New())
{
- return; // "SameAs" command for mesh is not valid in current architecture
+ SetPipeLine(myMeshPL);
}
-
-int VISU::Mesh_i::IsPossible (Result_i* theResult, const char* theMeshName,
- Entity theEntity, const char* theFamilyName)
+//----------------------------------------------------------------------------
+size_t
+VISU::Mesh_i
+::IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ Entity theEntity,
+ const std::string& theFamilyName)
{
try{
MESSAGE("Mesh_i::IsPossible - theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<"; theFamilyName = '"<<theFamilyName<<"'");
- float aSize = INCMEMORY*
+ size_t aSize = INCMEMORY*
theResult->GetInput()->GetMeshOnEntitySize(theMeshName,(VISU::TEntity)theEntity);
- bool aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
+ size_t aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
MESSAGE("Mesh_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<aResult);
return aResult;
}catch(std::exception& exc){
return 0;
}
-VISU::Storable* VISU::Mesh_i::Create (const char* theMeshName,
- Entity theEntity,
- const char* theFamilyName)
+
+//----------------------------------------------------------------------------
+VISU::Storable*
+VISU::Mesh_i
+::Create(VISU::Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFamilyName)
{
- myMeshName = theMeshName;
- //jfa IPAL9284:myEntity = VISU::TEntity(theEntity);
+ SetCResult(theResult);
+ SetMeshName(theMeshName.c_str());
myEntity = int(theEntity);//jfa IPAL9284
mySubMeshName = theFamilyName;
return Build(false);
}
-int VISU::Mesh_i::IsPossible (Result_i* theResult, const char* theMeshName, const char* theGroupName)
+//----------------------------------------------------------------------------
+size_t
+VISU::Mesh_i
+::IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ const std::string& theGroupName)
{
try{
MESSAGE("Mesh_i::IsPossible - theMeshName = '"<<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
- float aSize = INCMEMORY*
+ size_t aSize = INCMEMORY*
theResult->GetInput()->GetMeshOnGroupSize(theMeshName,theGroupName);
- bool aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
+ size_t aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
INFOS("Mesh_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<aResult);
return aResult;
}catch(std::exception& exc){
}
-VISU::Storable* VISU::Mesh_i::Create (const char* theMeshName,
- const char* theGroupName)
+//----------------------------------------------------------------------------
+VISU::Storable*
+VISU::Mesh_i
+::Create(VISU::Result_i* theResult,
+ const std::string& theMeshName,
+ const std::string& theGroupName)
{
- myMeshName = theMeshName;
- //jfa IPAL9284:myEntity = VISU::TEntity(-1);
+ SetCResult(theResult);
+ SetMeshName(theMeshName.c_str());
myEntity = -1;//jfa IPAL9284
mySubMeshName = theGroupName;
return Build(false);
}
-VISU::Storable* VISU::Mesh_i::Restore(const Storable::TRestoringMap& theMap)
+//----------------------------------------------------------------------------
+//----------------------------------------------------------------------------
+VISU::Mesh_i
+::~Mesh_i()
{
- Prs3d_i::Restore(theMap);
-
- myMeshName = VISU::Storable::FindValue(theMap,"myMeshName").latin1();
- //jfa IPAL9284:myEntity = (VISU::TEntity)VISU::Storable::FindValue(theMap,"myEntity").toInt();
- myEntity = VISU::Storable::FindValue(theMap,"myEntity").toInt();//jfa IPAL9284
- mySubMeshName = VISU::Storable::FindValue(theMap,"mySubMeshName").latin1();
-
- myPresentType = VISU::PresentationType(VISU::Storable::FindValue(theMap,"myPresentType").toInt());
-
- myCellColor.R = VISU::Storable::FindValue(theMap,"myCellColor.R").toDouble();
- myCellColor.G = VISU::Storable::FindValue(theMap,"myCellColor.G").toDouble();
- myCellColor.B = VISU::Storable::FindValue(theMap,"myCellColor.B").toDouble();
-
- myNodeColor.R = VISU::Storable::FindValue(theMap,"myNodeColor.R").toDouble();
- myNodeColor.G = VISU::Storable::FindValue(theMap,"myNodeColor.G").toDouble();
- myNodeColor.B = VISU::Storable::FindValue(theMap,"myNodeColor.B").toDouble();
-
- myLinkColor.R = VISU::Storable::FindValue(theMap,"myLinkColor.R").toDouble();
- myLinkColor.G = VISU::Storable::FindValue(theMap,"myLinkColor.G").toDouble();
- myLinkColor.B = VISU::Storable::FindValue(theMap,"myLinkColor.B").toDouble();
-
- return Build(true);
-}
-
-
-void VISU::Mesh_i::ToStream(std::ostringstream& theStr){
- Prs3d_i::ToStream(theStr);
-
- Storable::DataToStream( theStr, "myMeshName", myMeshName.c_str() );
- Storable::DataToStream( theStr, "myEntity", myEntity );
- Storable::DataToStream( theStr, "mySubMeshName", mySubMeshName.c_str() );
-
- Storable::DataToStream( theStr, "myPresentType", int(myPresentType) );
-
- Storable::DataToStream( theStr, "myCellColor.R", myCellColor.R );
- Storable::DataToStream( theStr, "myCellColor.G", myCellColor.G );
- Storable::DataToStream( theStr, "myCellColor.B", myCellColor.B );
-
- Storable::DataToStream( theStr, "myNodeColor.R", myNodeColor.R );
- Storable::DataToStream( theStr, "myNodeColor.G", myNodeColor.G );
- Storable::DataToStream( theStr, "myNodeColor.B", myNodeColor.B );
-
- Storable::DataToStream( theStr, "myLinkColor.R", myLinkColor.R );
- Storable::DataToStream( theStr, "myLinkColor.G", myLinkColor.G );
- Storable::DataToStream( theStr, "myLinkColor.B", myLinkColor.B );
-}
-
-
-VISU::Mesh_i::~Mesh_i(){
if(MYDEBUG) MESSAGE("Mesh_i::~Mesh_i()");
}
-VISU::Storable* VISU::Mesh_i::Build (int theRestoring)
+//----------------------------------------------------------------------------
+VISU::Storable*
+VISU::Mesh_i
+::Build(int theRestoring)
{
- SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = GetStudyDocument()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction
try {
- if (myResult->GetInput() == NULL)
- throw std::runtime_error("Mesh_i::Build - myResult->GetInput() == NULL !!!");
+ if (GetCResult()->GetInput() == NULL)
+ throw std::runtime_error("Mesh_i::Build - GetCResult()->GetInput() == NULL !!!");
if (!theRestoring) {
myPresentType = VISU::PresentationType(VISU::GetResourceMgr()->integerValue("VISU" , "mesh_represent", 2));
if(myEntity == VISU::NODE_ENTITY)
myPresentType = VISU::POINT;
- myName = GenerateName().latin1();
+ SetName(GenerateName().latin1(), false);
myCellColor.R = 0.0; myCellColor.G = myCellColor.B = 1.0;
myNodeColor.R = myNodeColor.G = 1.0; myNodeColor.B = 1.0;
myLinkColor.R = myLinkColor.G = myLinkColor.B = 83/255.;
if(MYDEBUG) MESSAGE("Mesh_i::Build - myType = "<<myType);
QString aComment,aTmp;
- VISU::PIDMapper anIDMapper;
+ VISU::PUnstructuredGridIDMapper anIDMapper;
+ VISU::Result_i::TInput* anInput = GetCResult()->GetInput();
switch(myType){
case VISU::TENTITY :
- anIDMapper = myResult->GetInput()->GetMeshOnEntity(myMeshName,(VISU::TEntity)myEntity);//jfa IPAL9284
+ anIDMapper = anInput->GetMeshOnEntity(GetCMeshName(),
+ (VISU::TEntity)myEntity);//jfa IPAL9284
aComment = "";
aComment.append(aTmp.sprintf("myComment=ENTITY;myType=%d;",VISU::TENTITY));
- aComment.append("myMeshName=");aComment.append(myMeshName);aComment.append(";");
+ aComment.append("myMeshName=");
+ aComment.append(GetCMeshName().c_str());
+ aComment.append(";");
aComment.append(aTmp.sprintf("myId=%d",myEntity));
break;
case VISU::TFAMILY :
- anIDMapper = myResult->GetInput()->GetFamilyOnEntity(myMeshName,(VISU::TEntity)myEntity,mySubMeshName);
+ anIDMapper = anInput->GetFamilyOnEntity(GetCMeshName(),
+ (VISU::TEntity)myEntity,
+ mySubMeshName);
aComment = "";
aComment.append(aTmp.sprintf("myComment=FAMILY;myType=%d;",VISU::TFAMILY));
- aComment.append("myMeshName=");aComment.append(myMeshName);aComment.append(";");
+ aComment.append("myMeshName=");
+ aComment.append(GetCMeshName().c_str());
+ aComment.append(";");
aComment.append(aTmp.sprintf("myEntityId=%d;",myEntity));
- aComment.append("myName=");aComment.append(mySubMeshName);
+ aComment.append("myName=");
+ aComment.append(mySubMeshName);
break;
case VISU::TGROUP :
- anIDMapper = myResult->GetInput()->GetMeshOnGroup(myMeshName,mySubMeshName);
+ anIDMapper = anInput->GetMeshOnGroup(GetCMeshName(),
+ mySubMeshName);
aComment = "";
aComment.append(aTmp.sprintf("myComment=GROUP;myType=%d;",VISU::TGROUP));
- aComment.append("myMeshName=");aComment.append(myMeshName);aComment.append(";");
- aComment.append("myName=");aComment.append(mySubMeshName);
+ aComment.append("myMeshName=");
+ aComment.append(GetCMeshName().c_str());
+ aComment.append(";");
+ aComment.append("myName=");
+ aComment.append(mySubMeshName);
break;
}
if(!anIDMapper)
throw std::runtime_error("Mesh_i::Build - !anIDMapper !!!");
- myMeshPL->SetIDMapper(anIDMapper);
- myMeshPL->Build();
+ myMeshPL->SetUnstructuredGridIDMapper(anIDMapper);
if(!theRestoring) { //Setting IOR on the label
myMeshPL->Init();
- string aResultEntry = myResult->GetEntry();
- string anEntry = myResult->GetEntry(aComment.latin1());
+ string aResultEntry = GetCResult()->GetEntry();
+ string anEntry = GetCResult()->GetEntry(aComment.latin1());
if(anEntry == "")
throw std::runtime_error("Mesh_i::Build - anEntry was not found !!!");
- mySObject = myStudy->FindObjectID(anEntry.c_str());
- SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
- SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(mySObject,"AttributeIOR");
+ SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anEntry.c_str());
+ SALOMEDS::StudyBuilder_var aStudyBuilder = GetStudyDocument()->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeIOR");
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
CORBA::String_var aString = GetID();
anIOR->SetValue(aString);
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributePixMap_var aPixmap;
- anAttr = aStudyBuilder->FindOrCreateAttribute( mySObject, "AttributePixMap" );
+ anAttr = aStudyBuilder->FindOrCreateAttribute(GetSObject(), "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
aPixmap->SetPixMap("ICON_TREE_MESH");
}
-VISU_Actor* VISU::Mesh_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+//---------------------------------------------------------------
+void
+VISU::Mesh_i
+::SameAs(const VISU::Prs3d_i* theOrigin)
+{
+ return; // "SameAs" command for mesh is not valid in current architecture
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::Mesh_i
+::RemoveFromStudy()
+{
+ struct TRemoveFromStudy: public SALOME_Event
+ {
+ VISU::Mesh_i* myRemovable;
+ TRemoveFromStudy(VISU::Mesh_i* theRemovable):
+ myRemovable(theRemovable)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ VISU::RemoveFromStudy(myRemovable->GetSObject());
+ myRemovable->TSuperClass::RemoveFromStudy();
+ }
+ };
+
+ // Unset icon
+ SALOMEDS::StudyBuilder_var aStudyBuilder = GetStudyDocument()->NewBuilder();
+ aStudyBuilder->RemoveAttribute(GetSObject(), "AttributePixMap");
+
+ ProcessVoidEvent(new TRemoveFromStudy(this));
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::Mesh_i
+::SetCellColor(const SALOMEDS::Color& theColor)
+{
+ if(IsSameColor(myCellColor, theColor))
+ return;
+
+ myCellColor = theColor;
+ myParamsTime.Modified();
+}
+
+
+//----------------------------------------------------------------------------
+SALOMEDS::Color
+VISU::Mesh_i
+::GetCellColor()
+{
+ return myCellColor;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::Mesh_i
+::SetNodeColor(const SALOMEDS::Color& theColor)
+{
+ if(IsSameColor(myNodeColor, theColor))
+ return;
+
+ myNodeColor = theColor;
+ myParamsTime.Modified();
+}
+
+
+//----------------------------------------------------------------------------
+SALOMEDS::Color
+VISU::Mesh_i
+::GetNodeColor()
+{
+ return myNodeColor;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::Mesh_i
+::SetLinkColor(const SALOMEDS::Color& theColor)
+{
+ if(IsSameColor(myLinkColor, theColor))
+ return;
+
+ myLinkColor = theColor;
+ myParamsTime.Modified();
+}
+
+
+//----------------------------------------------------------------------------
+SALOMEDS::Color
+VISU::Mesh_i
+::GetLinkColor()
+{
+ return myLinkColor;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::Mesh_i
+::SetPresentationType(VISU::PresentationType theType)
+{
+ if(myPresentType == theType)
+ return;
+
+ myPresentType = theType;
+ myParamsTime.Modified();
+}
+
+
+//----------------------------------------------------------------------------
+VISU::PresentationType
+VISU::Mesh_i
+::GetPresentationType()
+{
+ return myPresentType;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::Entity
+VISU::Mesh_i
+::GetEntity() const
+{
+ return VISU::Entity(myEntity);
+}
+
+
+//----------------------------------------------------------------------------
+const std::string&
+VISU::Mesh_i
+::GetSubMeshName() const
+{
+ return mySubMeshName;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::Storable*
+VISU::Mesh_i
+::Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
+{
+ if(!TSuperClass::Restore(theStudy, theMap))
+ return NULL;
+
+ myEntity = VISU::Storable::FindValue(theMap,"myEntity").toInt();//jfa IPAL9284
+ mySubMeshName = VISU::Storable::FindValue(theMap,"mySubMeshName").latin1();
+
+ myPresentType = VISU::PresentationType(VISU::Storable::FindValue(theMap,"myPresentType").toInt());
+
+ myCellColor.R = VISU::Storable::FindValue(theMap,"myCellColor.R").toDouble();
+ myCellColor.G = VISU::Storable::FindValue(theMap,"myCellColor.G").toDouble();
+ myCellColor.B = VISU::Storable::FindValue(theMap,"myCellColor.B").toDouble();
+
+ myNodeColor.R = VISU::Storable::FindValue(theMap,"myNodeColor.R").toDouble();
+ myNodeColor.G = VISU::Storable::FindValue(theMap,"myNodeColor.G").toDouble();
+ myNodeColor.B = VISU::Storable::FindValue(theMap,"myNodeColor.B").toDouble();
+
+ myLinkColor.R = VISU::Storable::FindValue(theMap,"myLinkColor.R").toDouble();
+ myLinkColor.G = VISU::Storable::FindValue(theMap,"myLinkColor.G").toDouble();
+ myLinkColor.B = VISU::Storable::FindValue(theMap,"myLinkColor.B").toDouble();
+
+ return Build(true);
+}
+
+
+//----------------------------------------------------------------------------
+VISU::Storable*
+VISU::Mesh_i
+::Restore(SALOMEDS::SObject_ptr theSObject,
+ const string& thePrefix,
+ const Storable::TRestoringMap& theMap)
+{
+ Mesh_i* aMesh = new Mesh_i();
+ SALOMEDS::Study_var aStudy = theSObject->GetStudy();
+ return aMesh->Restore(aStudy, theMap);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::Mesh_i
+::ToStream(std::ostringstream& theStr)
+{
+ TSuperClass::ToStream(theStr);
+
+ Storable::DataToStream( theStr, "myEntity", myEntity );
+ Storable::DataToStream( theStr, "mySubMeshName", mySubMeshName.c_str() );
+
+ Storable::DataToStream( theStr, "myPresentType", int(myPresentType) );
+
+ Storable::DataToStream( theStr, "myCellColor.R", myCellColor.R );
+ Storable::DataToStream( theStr, "myCellColor.G", myCellColor.G );
+ Storable::DataToStream( theStr, "myCellColor.B", myCellColor.B );
+
+ Storable::DataToStream( theStr, "myNodeColor.R", myNodeColor.R );
+ Storable::DataToStream( theStr, "myNodeColor.G", myNodeColor.G );
+ Storable::DataToStream( theStr, "myNodeColor.B", myNodeColor.B );
+
+ Storable::DataToStream( theStr, "myLinkColor.R", myLinkColor.R );
+ Storable::DataToStream( theStr, "myLinkColor.G", myLinkColor.G );
+ Storable::DataToStream( theStr, "myLinkColor.B", myLinkColor.B );
+}
+
+
+//----------------------------------------------------------------------------
+VISU_Actor*
+VISU::Mesh_i
+::CreateActor()
{
VISU_MeshAct* anActor = VISU_MeshAct::New();
try{
- VISU::Prs3d_i::CreateActor(anActor,theIO);
+ VISU::Prs3d_i::CreateActor(anActor);
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
bool toShrink = aResourceMgr->booleanValue("VISU", "mesh_shrink", false);
if (toShrink) anActor->SetShrink();
}
-void VISU::Mesh_i::UpdateActor(VISU_Actor* theActor) {
+//----------------------------------------------------------------------------
+void
+VISU::Mesh_i
+::UpdateActor(VISU_Actor* theActor)
+{
if(VISU_MeshAct* anActor = dynamic_cast<VISU_MeshAct*>(theActor)){
if(MYDEBUG) MESSAGE("Mesh_i::UpdateActor");
VISU::Prs3d_i::UpdateActor(anActor);
anActor->GetNodeProperty()->SetColor(myNodeColor.R, myNodeColor.G, myNodeColor.B);
}
}
+
+//----------------------------------------------------------------------------
public:
typedef Prs3d_i TSuperClass;
+ typedef VISU::Mesh TInterface;
- explicit
- Mesh_i(Result_i* theResult);
+ Mesh_i();
- explicit
- Mesh_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject);
+ virtual
+ ~Mesh_i();
- virtual void SameAs(const Prs3d_i* theOrigin);
- virtual ~Mesh_i();
- virtual void RemoveFromStudy();
+ virtual
+ void
+ SameAs(const Prs3d_i* theOrigin);
- virtual VISU::VISUType GetType() { return VISU::TMESH;};
+ virtual
+ void
+ RemoveFromStudy();
- virtual void SetCellColor(const SALOMEDS::Color& theColor) { myCellColor = theColor;}
- virtual SALOMEDS::Color GetCellColor() { return myCellColor;}
+ virtual
+ VISU::VISUType
+ GetType()
+ {
+ return VISU::TMESH;
+ }
- virtual void SetNodeColor(const SALOMEDS::Color& theColor) { myNodeColor = theColor;}
- virtual SALOMEDS::Color GetNodeColor() { return myNodeColor;}
+ virtual
+ void
+ SetCellColor(const SALOMEDS::Color& theColor);
- virtual void SetLinkColor(const SALOMEDS::Color& theColor) { myLinkColor = theColor;}
- virtual SALOMEDS::Color GetLinkColor() { return myLinkColor;}
+ virtual
+ SALOMEDS::Color
+ GetCellColor();
- virtual void SetPresentationType(VISU::PresentationType theType) { myPresentType = theType;}
- virtual PresentationType GetPresentationType() { return myPresentType;}
+ virtual
+ void
+ SetNodeColor(const SALOMEDS::Color& theColor);
- typedef VISU::Mesh TInterface;
- VISU_MeshPL* GetMeshPL(){ return myMeshPL;}
+ virtual
+ SALOMEDS::Color
+ GetNodeColor();
+
+ virtual
+ void
+ SetLinkColor(const SALOMEDS::Color& theColor);
+
+ virtual
+ SALOMEDS::Color
+ GetLinkColor();
+
+ virtual
+ void
+ SetPresentationType(VISU::PresentationType theType);
+
+ virtual
+ VISU::PresentationType
+ GetPresentationType();
+
+ VISU_MeshPL* GetSpecificPL() const
+ {
+ return myMeshPL;
+ }
protected:
- Storable* Build(int theRestoring);
+ Storable*
+ Build(int theRestoring);
VISU_MeshPL* myMeshPL;
- // std::string myMeshName; move it to Prs3d_i
int myEntity;//jfa IPAL9284: TEntity myEntity;
std::string mySubMeshName;
VISU::VISUType myType;
VISU::PresentationType myPresentType;
- struct SALOMEDS::Color myCellColor, myNodeColor, myLinkColor;
+ SALOMEDS::Color myCellColor;
+ SALOMEDS::Color myNodeColor;
+ SALOMEDS::Color myLinkColor;
public:
- static int IsPossible(Result_i* theResult, const char* theMeshName,
- Entity theEntity, const char* theFamilyName = "");
- virtual Storable* Create(const char* theMeshName, Entity theEntity, const char* theFamilyName = "");
-
- static int IsPossible(Result_i* theResult, const char* theMeshName, const char* theGroupName);
- virtual Storable* Create(const char* theMeshName, const char* theGroupName);
-
- const std::string& GetMeshName() const { return myMeshName;}
- VISU::Entity GetEntity() const { return VISU::Entity(myEntity);}
- const string& GetSubMeshName() const { return mySubMeshName;}
+ static
+ size_t
+ IsPossible(VISU::Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFamilyName = "");
+ virtual
+ Storable*
+ Create(VISU::Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFamilyName = "");
+
+ static
+ size_t
+ IsPossible(VISU::Result_i* theResult,
+ const std::string& theMeshName,
+ const std::string& theGroupName);
+ virtual
+ Storable*
+ Create(VISU::Result_i* theResult,
+ const std::string& theMeshName,
+ const std::string& theGroupName);
+
+ VISU::Entity
+ GetEntity() const;
+
+ const std::string&
+ GetSubMeshName() const;
+
+ virtual
+ void
+ ToStream(std::ostringstream& theStr);
+
+ virtual
+ const char*
+ GetComment() const;
- virtual void ToStream(std::ostringstream& theStr);
-
- virtual const char* GetComment() const;
static const std::string myComment;
- virtual QString GenerateName();
-
- virtual Storable* Restore(const Storable::TRestoringMap& theMap);
-
- virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
- virtual void UpdateActor(VISU_Actor* theActor);
+ virtual
+ QString
+ GenerateName();
+
+ virtual
+ Storable*
+ Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap);
+
+ static
+ Storable*
+ Restore(SALOMEDS::SObject_ptr theSObject,
+ const std::string& thePrefix,
+ const Storable::TRestoringMap& theMap);
+
+ virtual
+ VISU_Actor*
+ CreateActor();
+
+ virtual
+ void
+ UpdateActor(VISU_Actor* theActor);
};
}
//
#include "VISU_Plot3D_i.hh"
-
#include "VISU_Result_i.hh"
-
#include "VISU_Plot3DPL.hxx"
-
#include "VISU_Actor.h"
-
#include "SUIT_ResourceMgr.h"
-using namespace VISU;
-using namespace std;
-
#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
#endif
-int VISU::Plot3D_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration, int isMemoryCheck)
+
+//---------------------------------------------------------------
+size_t
+VISU::Plot3D_i
+::IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck)
{
- return TSuperClass::IsPossible
- (theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck);
+ return TSuperClass::IsPossible(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber,
+ theIsMemoryCheck);
}
+//---------------------------------------------------------------
int VISU::Plot3D_i::myNbPresent = 0;
-QString VISU::Plot3D_i::GenerateName() { return VISU::GenerateName("Plot3D",myNbPresent++); }
+//---------------------------------------------------------------
+QString
+VISU::Plot3D_i
+::GenerateName()
+{
+ return VISU::GenerateName("Plot3D",myNbPresent++);
+}
+
+//---------------------------------------------------------------
const string VISU::Plot3D_i::myComment = "PLOT3D";
-const char* VISU::Plot3D_i::GetComment() const { return myComment.c_str(); }
+//---------------------------------------------------------------
+const char*
VISU::Plot3D_i
-::Plot3D_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theAddToStudy),
- ColoredPrs3d_i(theResult,theAddToStudy),
- ScalarMap_i(theResult,theAddToStudy),
- TSuperClass(theResult,theAddToStudy),
- myPlot3DPL(NULL)
-{}
+::GetComment() const
+{
+ return myComment.c_str();
+}
+
+//---------------------------------------------------------------
+const char*
+VISU::Plot3D_i
+::GetIconName()
+{
+ if (!IsGroupsUsed())
+ return "ICON_TREE_PLOT_3D";
+ else
+ return "ICON_TREE_PLOT_3D_GROUPS";
+}
+//---------------------------------------------------------------
VISU::Plot3D_i
-::Plot3D_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
- ColoredPrs3d_i(theResult,theSObject),
- ScalarMap_i(theResult,theSObject),
- TSuperClass(theResult,theSObject),
+::Plot3D_i(EPublishInStudyMode thePublishInStudyMode) :
+ ColoredPrs3d_i(thePublishInStudyMode),
+ ScalarMap_i(thePublishInStudyMode),
myPlot3DPL(NULL)
{}
-VISU::Storable* VISU::Plot3D_i::Create (const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration)
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::Plot3D_i
+::Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
{
- return TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
+ return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
}
-VISU::Storable* VISU::Plot3D_i::Restore (const Storable::TRestoringMap& theMap)
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::Plot3D_i
+::Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
{
- TSuperClass::Restore(theMap);
+ if(!TSuperClass::Restore(theStudy, theMap))
+ return NULL;
SetOrientation(VISU::Plot3D::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane").toInt()),
Storable::FindValue(theMap,"aRot[0]").toDouble(),
return this;
}
-void VISU::Plot3D_i::ToStream (std::ostringstream& theStr)
+
+//---------------------------------------------------------------
+void
+VISU::Plot3D_i
+::ToStream(std::ostringstream& theStr)
{
TSuperClass::ToStream(theStr);
Storable::DataToStream(theStr, "myNbOfContours", int(GetNbOfContours()));
}
-VISU::Plot3D_i::~Plot3D_i(){
+
+//---------------------------------------------------------------
+VISU::Plot3D_i
+::~Plot3D_i()
+{
if(MYDEBUG) MESSAGE("Plot3D_i::~Plot3D_i()");
}
-void VISU::Plot3D_i::SetOrientation (VISU::Plot3D::Orientation theOrient,
- CORBA::Double theXAngle, CORBA::Double theYAngle)
+
+//---------------------------------------------------------------
+void
+VISU::Plot3D_i
+::SetOrientation(VISU::Plot3D::Orientation theOrient,
+ CORBA::Double theXAngle,
+ CORBA::Double theYAngle)
{
myPlot3DPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(theOrient),
- theXAngle,theYAngle);
+ theXAngle,
+ theYAngle);
}
-VISU::Plot3D::Orientation VISU::Plot3D_i::GetOrientationType()
+
+//---------------------------------------------------------------
+VISU::Plot3D::Orientation
+VISU::Plot3D_i
+::GetOrientationType()
{
return VISU::Plot3D::Orientation(myPlot3DPL->GetPlaneOrientation());
}
-CORBA::Double VISU::Plot3D_i::GetRotateX()
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::Plot3D_i
+::GetRotateX()
{
return myPlot3DPL->GetRotateX();
}
-CORBA::Double VISU::Plot3D_i::GetRotateY()
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::Plot3D_i
+::GetRotateY()
{
return myPlot3DPL->GetRotateY();
}
-void VISU::Plot3D_i::SetPlanePosition (CORBA::Double thePlanePosition,
- CORBA::Boolean theIsRelative)
+
+//---------------------------------------------------------------
+void
+VISU::Plot3D_i
+::SetPlanePosition(CORBA::Double thePlanePosition,
+ CORBA::Boolean theIsRelative)
{
myPlot3DPL->SetPlanePosition(thePlanePosition, theIsRelative);
}
-CORBA::Double VISU::Plot3D_i::GetPlanePosition()
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::Plot3D_i
+::GetPlanePosition()
{
return myPlot3DPL->GetPlanePosition();
}
-CORBA::Boolean VISU::Plot3D_i::IsPositionRelative()
+
+//---------------------------------------------------------------
+CORBA::Boolean
+VISU::Plot3D_i
+::IsPositionRelative()
{
return myPlot3DPL->IsPositionRelative();
}
-void VISU::Plot3D_i::SetScaleFactor (CORBA::Double theScaleFactor)
+
+//---------------------------------------------------------------
+void
+VISU::Plot3D_i
+::SetScaleFactor(CORBA::Double theScaleFactor)
{
myPlot3DPL->SetScaleFactor(theScaleFactor);
}
-CORBA::Double VISU::Plot3D_i::GetScaleFactor()
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::Plot3D_i
+::GetScaleFactor()
{
return myPlot3DPL->GetScaleFactor();
}
-void VISU::Plot3D_i::SetNbOfContours (CORBA::Long theNb)
+
+//---------------------------------------------------------------
+void
+VISU::Plot3D_i
+::SetNbOfContours(CORBA::Long theNb)
{
myPlot3DPL->SetNumberOfContours(theNb);
}
-CORBA::Long VISU::Plot3D_i::GetNbOfContours()
+
+//---------------------------------------------------------------
+CORBA::Long
+VISU::Plot3D_i
+::GetNbOfContours()
{
return myPlot3DPL->GetNumberOfContours();
}
-void VISU::Plot3D_i::SetContourPrs (CORBA::Boolean theIsContourPrs )
+
+//---------------------------------------------------------------
+void
+VISU::Plot3D_i
+::SetContourPrs(CORBA::Boolean theIsContourPrs)
{
myPlot3DPL->SetContourPrs( theIsContourPrs );
}
-CORBA::Boolean VISU::Plot3D_i::GetIsContourPrs()
+
+//---------------------------------------------------------------
+CORBA::Boolean
+VISU::Plot3D_i
+::GetIsContourPrs()
{
return myPlot3DPL->GetIsContourPrs();
}
-void VISU::Plot3D_i::DoHook()
+
+//---------------------------------------------------------------
+void
+VISU::Plot3D_i
+::CreatePipeLine(VISU_PipeLine* thePipeLine)
{
- if (!myPipeLine) myPipeLine = VISU_Plot3DPL::New();
- myPlot3DPL = dynamic_cast<VISU_Plot3DPL*>(myPipeLine);
+ if(!thePipeLine){
+ myPlot3DPL = VISU_Plot3DPL::New();
+ }else
+ myPlot3DPL = dynamic_cast<VISU_Plot3DPL*>(thePipeLine);
- TSuperClass::DoHook();
+ TSuperClass::CreatePipeLine(myPlot3DPL);
}
-const char*
+
+//---------------------------------------------------------------
+bool
VISU::Plot3D_i
-::GetIconName()
+::CheckIsPossible()
{
- if (!GetNumberOfGeom())
- return "ICON_TREE_PLOT_3D";
- else
- return "ICON_TREE_PLOT_3D_GROUPS";
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
}
+//---------------------------------------------------------------
VISU_Actor*
VISU::Plot3D_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+::CreateActor()
{
- if(VISU_Actor* anActor = TSuperClass::CreateActor(theIO)){
+ if(VISU_Actor* anActor = TSuperClass::CreateActor()){
anActor->SetVTKMapping(true);
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
int aDispMode = aResourceMgr->integerValue("VISU", "plot3d_represent", 2);
return NULL;
}
-void VISU::Plot3D_i::SetMapScale(double theMapScale)
+
+//---------------------------------------------------------------
+void
+VISU::Plot3D_i
+::SetMapScale(double theMapScale)
{
myPlot3DPL->SetMapScale(theMapScale);
}
#ifndef VISU_Plot3D_i_HeaderFile
#define VISU_Plot3D_i_HeaderFile
-#include "VISU_PrsMerger_i.hh"
+#include "VISU_ScalarMap_i.hh"
class VISU_Plot3DPL;
-namespace VISU {
+namespace VISU
+{
+ //----------------------------------------------------------------------------
class VISU_I_EXPORT Plot3D_i : public virtual POA_VISU::Plot3D,
- public virtual PrsMerger_i
+ public virtual ScalarMap_i
{
static int myNbPresent;
Plot3D_i(const Plot3D_i&);
public:
- typedef PrsMerger_i TSuperClass;
+ //----------------------------------------------------------------------------
+ typedef ScalarMap_i TSuperClass;
+ typedef VISU::Plot3D TInterface;
explicit
- Plot3D_i (Result_i* theResult, bool theAddToStudy = true);
- explicit
- Plot3D_i (Result_i* theResult, SALOMEDS::SObject_ptr theSObject);
-
- virtual ~Plot3D_i();
-
- virtual VISU::VISUType GetType() { return VISU::TPLOT3D; };
-
- virtual void SetOrientation (VISU::Plot3D::Orientation theOrient,
- CORBA::Double theXAngle, CORBA::Double theYAngle);
-
- virtual VISU::Plot3D::Orientation GetOrientationType();
+ Plot3D_i(EPublishInStudyMode thePublishInStudyModep);
- virtual CORBA::Double GetRotateX();
- virtual CORBA::Double GetRotateY();
-
- virtual void SetPlanePosition (CORBA::Double thePlanePosition,
- CORBA::Boolean theIsRelative);
- virtual CORBA::Double GetPlanePosition();
- virtual CORBA::Boolean IsPositionRelative();
-
- virtual void SetScaleFactor (CORBA::Double theScaleFactor);
- virtual CORBA::Double GetScaleFactor();
-
- virtual void SetContourPrs (CORBA::Boolean theIsContourPrs );
- CORBA::Boolean GetIsContourPrs();
-
- virtual void SetNbOfContours (CORBA::Long theNb);
- virtual CORBA::Long GetNbOfContours();
+ virtual
+ ~Plot3D_i();
- typedef VISU::Plot3D TInterface;
- VISU_Plot3DPL* GetPlot3DPL() { return myPlot3DPL; }
+ virtual
+ VISU::VISUType
+ GetType()
+ {
+ return VISU::TPLOT3D;
+ }
+
+ virtual
+ void
+ SetOrientation (VISU::Plot3D::Orientation theOrient,
+ CORBA::Double theXAngle,
+ CORBA::Double theYAngle);
- void SetMapScale(double theMapScale);
+ virtual
+ VISU::Plot3D::Orientation
+ GetOrientationType();
+ virtual
+ CORBA::Double
+ GetRotateX();
+
+ virtual
+ CORBA::Double
+ GetRotateY();
+
+ virtual
+ void
+ SetPlanePosition(CORBA::Double thePlanePosition,
+ CORBA::Boolean theIsRelative);
+
+ virtual
+ CORBA::Double
+ GetPlanePosition();
+
+ virtual
+ CORBA::Boolean
+ IsPositionRelative();
+
+ virtual
+ void
+ SetScaleFactor(CORBA::Double theScaleFactor);
+
+ virtual
+ CORBA::Double
+ GetScaleFactor();
+
+ virtual
+ void
+ SetContourPrs(CORBA::Boolean theIsContourPrs);
+
+ CORBA::Boolean
+ GetIsContourPrs();
+
+ virtual
+ void
+ SetNbOfContours(CORBA::Long theNb);
+
+ virtual
+ CORBA::Long
+ GetNbOfContours();
+
+ VISU_Plot3DPL*
+ GetSpecificPL() const
+ {
+ return myPlot3DPL;
+ }
+
protected:
- virtual void DoHook();
+ //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine
+ virtual
+ void
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
- virtual const char* GetIconName();
+ //! Redefines VISU_ColoredPrs3d_i::CheckIsPossible
+ virtual
+ bool
+ CheckIsPossible();
VISU_Plot3DPL *myPlot3DPL;
public:
- static int IsPossible (Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration, int isMemoryCheck = true);
+ static
+ size_t
+ IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck);
- virtual Storable* Create (const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration);
+ virtual
+ Storable*
+ Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber);
- virtual void ToStream (std::ostringstream& theStr);
+ virtual
+ void
+ ToStream (std::ostringstream& theStr);
- virtual Storable* Restore (const Storable::TRestoringMap& theMap);
+ virtual
+ Storable*
+ Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap);
virtual
VISU_Actor*
- CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
+ CreateActor();
static const std::string myComment;
- virtual const char* GetComment() const;
- virtual QString GenerateName();
+
+ virtual
+ const char*
+ GetComment() const;
+
+ virtual
+ QString
+ GenerateName();
+
+ virtual
+ const char*
+ GetIconName();
+
+ void
+ SetMapScale(double theMapScale);
};
}
#include "SALOME_Event.hxx"
#include <vtkActorCollection.h>
+#include <vtkUnstructuredGrid.h>
#include <vtkDataSet.h>
#include <vtkMapper.h>
#include <boost/bind.hpp>
-using namespace VISU;
-using namespace std;
-
#ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
#endif
//----------------------------------------------------------------------------
VISU::Prs3d_i
-::Prs3d_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- mySObject(SALOMEDS::SObject::_duplicate(theSObject)),
+::Prs3d_i() :
+ PrsObject_i(SALOMEDS::Study::_nil()),
myActorCollection(vtkActorCollection::New()),
- myResult(theResult),
- myAddToStudy(true),
- myPipeLine(NULL)
+ myIsActiveSatate(true),
+ myIsRestored(true)
{
if(MYDEBUG) MESSAGE("Prs3d_i::Prs3d_i - this = "<<this);
myOffset[0] = myOffset[1] = myOffset[2] = 0;
myActorCollection->Delete();
- myResult->Register();
}
+
+//----------------------------------------------------------------------------
+void
VISU::Prs3d_i
-::Prs3d_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- myActorCollection(vtkActorCollection::New()),
- mySObject(SALOMEDS::SObject::_nil()),
- myAddToStudy(theAddToStudy),
- myResult(theResult),
- myPipeLine(NULL)
+::SameAs(const Prs3d_i* theOrigin)
{
- if(MYDEBUG) MESSAGE("Prs3d_i::Prs3d_i - this = "<<this);
- myOffset[0] = myOffset[1] = myOffset[2] = 0;
- myActorCollection->Delete();
- myResult->Register();
+ if(Prs3d_i* anOrigin = const_cast<Prs3d_i*>(theOrigin)){
+ GetPipeLine()->SameAs(anOrigin->GetPipeLine());
+ anOrigin->GetOffset(myOffset);
+ }
}
-void
+
+//----------------------------------------------------------------------------
+namespace VISU
+{
+ struct TInvokeSignalEvent: public SALOME_Event
+ {
+ typedef boost::signal0<void> TSignal;
+ const TSignal& mySignal;
+
+ TInvokeSignalEvent(const TSignal& theSignal):
+ mySignal(theSignal)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ mySignal();
+ }
+ };
+}
+
+//----------------------------------------------------------------------------
VISU::Prs3d_i
-::SameAs(const Prs3d_i* theOrigin)
+::~Prs3d_i()
{
- if (Prs3d_i* aOrigin = const_cast<Prs3d_i*>(theOrigin)) {
- myPipeLine->SameAs(aOrigin->GetPL());
- aOrigin->GetOffset(myOffset);
+ if(MYDEBUG) MESSAGE("Prs3d_i::~Prs3d_i - this = "<<this);
+ ProcessVoidEvent(new TInvokeSignalEvent(myRemoveActorsFromRendererSignal));
+}
+
+
+//----------------------------------------------------------------------------
+bool
+VISU::Prs3d_i
+::SetInput(bool theReInit)
+{
+ if(GetCResult()){
+ if(myMeshName != ""){
+ myPreviousResult = myResult;
+ myPreviousMeshName = myMeshName;
+ return true;
+ }
}
+ return false;
}
-struct TRemoveActorsFromRendererEvent: public SALOME_Event
+
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::OnRestoreInput()
{
- typedef boost::signal0<void> TRemoveActorsFromRendererSignalType;
- const TRemoveActorsFromRendererSignalType& myRemoveActorsFromRendererSignalVar;
+ SetCResult(myPreviousResult);
+ myMeshName = myPreviousMeshName;
+}
- TRemoveActorsFromRendererEvent
- (const TRemoveActorsFromRendererSignalType& theRemoveActorsFromRendererSignalVar):
- myRemoveActorsFromRendererSignalVar(theRemoveActorsFromRendererSignalVar)
- {}
- virtual
- void
- Execute()
- {
- myRemoveActorsFromRendererSignalVar();
+//----------------------------------------------------------------------------
+CORBA::Boolean
+VISU::Prs3d_i
+::Apply(bool theReInit)
+{
+ try{
+ if(SetInput(theReInit)){
+ if(myActorCollection->GetNumberOfItems())
+ UpdateActors();
+ return true;
+ }
+ }catch(std::exception& exc){
+ INFOS("Follow exception was occured :\n"<<exc.what());
+ }catch(...){
+ INFOS("Unknown exception was occured!");
}
-};
+ OnRestoreInput();
+ return false;
+}
+
+//----------------------------------------------------------------------------
+void
VISU::Prs3d_i
-::~Prs3d_i()
+::SetCResult(VISU::Result_i* theResult)
+{
+ VISU::Result_i* aResult = GetCResult();
+ if(aResult != theResult){
+ if(aResult)
+ aResult->Destroy();
+ if(theResult){
+ theResult->Register();
+ SetStudyDocument(theResult->GetStudyDocument());
+ }
+ myResult = theResult;
+ myParamsTime.Modified();
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::SetResultEntry(const std::string& theResultEntry)
{
- if(MYDEBUG) MESSAGE("Prs3d_i::~Prs3d_i - this = "<<this);
- ProcessVoidEvent(new TRemoveActorsFromRendererEvent(myRemoveActorsFromRendererSignal));
- myPipeLine->Delete();
- myResult->Destroy();
+ SetCResult(VISU::GetResult(GetStudyDocument(), theResultEntry));
}
+//----------------------------------------------------------------------------
+std::string
+VISU::Prs3d_i
+::GetResultEntry()
+{
+ if(VISU::Result_i* aResult = GetCResult())
+ return aResult->GetEntry();
+ return "";
+}
//----------------------------------------------------------------------------
-VISU::Storable*
+VISU::Result_i*
VISU::Prs3d_i
-::Restore(const Storable::TRestoringMap& theMap)
+::GetCResult() const
+{
+ return myResult;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::SetResultObject(VISU::Result_ptr theResult)
+{
+ SetCResult(dynamic_cast<VISU::Result_i*>(GetServant(theResult).in()));
+}
+
+
+//----------------------------------------------------------------------------
+VISU::Result_ptr
+VISU::Prs3d_i
+::GetResultObject()
{
- myName = VISU::Storable::FindValue(theMap,"myName").latin1();
+ return GetCResult()->_this();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::SetMeshName(const char* theMeshName)
+{
+ if(myMeshName != theMeshName){
+ myMeshName = theMeshName;
+ myParamsTime.Modified();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+char*
+VISU::Prs3d_i
+::GetMeshName()
+{
+ return CORBA::string_dup(myMeshName.c_str());
+}
+
+
+//----------------------------------------------------------------------------
+std::string
+VISU::Prs3d_i
+::GetCMeshName() const
+{
+ return myMeshName;
+}
+
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU::Prs3d_i
+::GetMTime()
+{
+ unsigned long int aTime = myParamsTime.GetMTime();
+ if(IsPipeLineExists())
+ aTime = std::max(aTime,GetPipeLine()->GetMTime());
+ return aTime;
+}
+
+//----------------------------------------------------------------------------
+bool
+VISU::Prs3d_i
+::GetActiveState()
+{
+ return myIsActiveSatate;
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::SetActiveState(bool theState)
+{
+ myIsActiveSatate = theState;
+}
+
+//----------------------------------------------------------------------------
+VISU::Storable*
+VISU::Prs3d_i
+::Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
+{
+ SetStudyDocument(theStudy);
+ SetResultEntry(VISU::Storable::FindValue(theMap,"myResultEntry").latin1());
+ if(!GetCResult())
+ return NULL;
+
+ SetMeshName(VISU::Storable::FindValue(theMap,"myMeshName").latin1());
+ SetName(VISU::Storable::FindValue(theMap,"myName").latin1(), false);
myOffset[0] = VISU::Storable::FindValue(theMap,"myOffset[0]").toFloat();
myOffset[1] = VISU::Storable::FindValue(theMap,"myOffset[1]").toFloat();
myOffset[2] = VISU::Storable::FindValue(theMap,"myOffset[2]").toFloat();
+ myParamsTime.Modified();
return this;
}
+//----------------------------------------------------------------------------
void
VISU::Prs3d_i
-::ToStream(std::ostringstream& theStr)
+::SaveRestoringState(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
{
- Storable::DataToStream( theStr, "myName", myName.c_str() );
- Storable::DataToStream( theStr, "myOffset[0]", myOffset[0] );
- Storable::DataToStream( theStr, "myOffset[1]", myOffset[1] );
- Storable::DataToStream( theStr, "myOffset[2]", myOffset[2] );
+ myRestoringStudy = SALOMEDS::Study::_duplicate(theStudy);
+ myRestoringMap = theMap;
+ myIsRestored = false;
}
-
//----------------------------------------------------------------------------
-SALOMEDS::SObject_var
+void
VISU::Prs3d_i
-::GetSObject()
+::InitFromRestoringState()
{
- if(CORBA::is_nil(mySObject.in())){
- const SALOMEDS::Study_var& aStudy = myResult->GetStudyDocument();
- CORBA::String_var anIOR = GetID();
- mySObject = aStudy->FindObjectIOR(anIOR);
+ if(!myIsRestored){
+ Restore(myRestoringStudy, myRestoringMap);
+ myIsRestored = true;
}
- return mySObject;
}
-Result_i*
+//----------------------------------------------------------------------------
+void
VISU::Prs3d_i
-::GetResult() const
+::ToStream(std::ostringstream& theStr)
{
- return myResult;
+ Storable::DataToStream( theStr, "myResultEntry", GetResultEntry() );
+ Storable::DataToStream( theStr, "myMeshName", GetCMeshName() );
+ Storable::DataToStream( theStr, "myName", GetName().c_str() );
+ Storable::DataToStream( theStr, "myOffset[0]", myOffset[0] );
+ Storable::DataToStream( theStr, "myOffset[1]", myOffset[1] );
+ Storable::DataToStream( theStr, "myOffset[2]", myOffset[2] );
}
-const std::string&
+
+//----------------------------------------------------------------------------
+SALOMEDS::SObject_var
VISU::Prs3d_i
-::GetMeshName() const
+::GetSObject()
{
- return myMeshName;
+ const SALOMEDS::Study_var& aStudy = GetStudyDocument();
+ if(!CORBA::is_nil(aStudy.in())){
+ CORBA::String_var anIOR = GetID();
+ return aStudy->FindObjectIOR(anIOR);
+ }
+ return SALOMEDS::SObject::_nil();
}
VISU::Prs3d_i
::Update()
{
+ if(GetMTime() < myUpdateTime.GetMTime())
+ return;
+
if(MYDEBUG) MESSAGE("Prs3d_i::Update - this = "<<this);
+
try{
- myPipeLine->Update();
+ GetPipeLine()->Update();
+ myUpdateTime.Modified();
+ }catch(std::exception&){
+ throw;
}catch(...){
throw std::runtime_error("Prs3d_i::Update >> unexpected exception was caught!!!");
}
VISU::Prs3d_i
::CheckDataSet()
{
- vtkMapper *aMapper = myPipeLine->GetMapper();
+ vtkMapper *aMapper = GetPipeLine()->GetMapper();
vtkDataSet *aDataSet = aMapper->GetInput();
if (!aDataSet)
throw std::runtime_error("There is no input data !!!");
+
aDataSet->Update();
static float eps = VTK_LARGE_FLOAT * 0.1 ;
if (!aDataSet->GetNumberOfCells())
throw std::runtime_error("There are no visible elements");
+
if (aDataSet->GetLength() > eps)
throw std::runtime_error("Diagonal of the actor is too large !!!");
}
+
+//----------------------------------------------------------------------------
void
VISU::Prs3d_i
::RemoveFromStudy()
{
- struct TRemoveFromStudy: public SALOME_Event
+ struct TEvent: public TInvokeSignalEvent
{
VISU::Prs3d_i* myRemovable;
- typedef boost::signal0<void> TRemoveFromStudySignal;
- const TRemoveFromStudySignal& myRemoveFromStudySignal;
-
- TRemoveFromStudy(VISU::Prs3d_i* theRemovable,
- const TRemoveFromStudySignal& theRemoveFromStudySignal):
- myRemovable(theRemovable),
- myRemoveFromStudySignal(theRemoveFromStudySignal)
- {}
+
+ TEvent(const TSignal& theSignal,
+ VISU::Prs3d_i* theRemovable):
+ TInvokeSignalEvent(theSignal),
+ myRemovable(theRemovable)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ TInvokeSignalEvent::Execute();
+ myRemovable->Destroy();
+ }
+};
- virtual
- void
- Execute()
- {
- myRemoveFromStudySignal();
- myRemovable->Destroy();
- }
- };
- ProcessVoidEvent(new TRemoveFromStudy(this,myRemoveActorsFromRendererSignal));
+ ProcessVoidEvent(new TEvent(myRemoveActorsFromRendererSignal, this));
}
//----------------------------------------------------------------------------
VISU_PipeLine*
VISU::Prs3d_i
-::GetPipeLine()
+::GetPipeLine() const
{
- return GetPL();
+ if(!myPipeLine.GetPointer())
+ throw std::runtime_error("VISU::Prs3d_i::myPipeLine == NULL !!!");
+
+ return myPipeLine.GetPointer();
}
-VISU_PipeLine*
+//----------------------------------------------------------------------------
+void
VISU::Prs3d_i
-::GetPL()
+::SetPipeLine(VISU_PipeLine* thePipeLine)
{
- return myPipeLine;
+ myPipeLine = thePipeLine;
+ if(thePipeLine)
+ thePipeLine->Delete();
}
-vtkUnstructuredGrid*
-VISU::Prs3d_i::
-GetInput()
+//----------------------------------------------------------------------------
+bool
+VISU::Prs3d_i
+::IsPipeLineExists()
+{
+ return myPipeLine.GetPointer() != NULL;
+}
+
+//----------------------------------------------------------------------------
+VISU_PipeLine*
+VISU::Prs3d_i
+::GetActorPipeLine()
+{
+ return GetPipeLine();
+}
+
+//----------------------------------------------------------------------------
+vtkDataSet*
+VISU::Prs3d_i
+::GetInput()
+{
+ return GetPipeLine()->GetInput();
+}
+
+//----------------------------------------------------------------------------
+Handle(SALOME_InteractiveObject)
+VISU::Prs3d_i
+::GetIO()
{
- return myPipeLine->GetInput();
+ if( myIO.IsNull() )
+ myIO = new SALOME_InteractiveObject(GetActorEntry().c_str(), "VISU", GetName().c_str());
+
+ return myIO;
+}
+
+//----------------------------------------------------------------------------
+std::string
+VISU::Prs3d_i
+::GetActorEntry()
+{
+ return GetEntry();
}
//----------------------------------------------------------------------------
void
VISU::Prs3d_i
-::CreateActor(VISU_Actor* theActor, const Handle(SALOME_InteractiveObject)& theIO)
+::CreateActor(VISU_Actor* theActor)
{
try{
- Handle(SALOME_InteractiveObject) anIO = theIO;
- if(anIO.IsNull() && (!mySObject->_is_nil())){
- anIO = new SALOME_InteractiveObject(mySObject->GetID(),"VISU",GetName());
+ Handle(SALOME_InteractiveObject) anIO = GetIO();
+ if(!anIO.IsNull() && anIO->hasEntry()){
theActor->setIO(anIO);
}
theActor->SetPrs3d(this);
theActor->SetShrinkFactor();
theActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]);
- theActor->SetPipeLine(GetPipeLine());
+ theActor->SetPipeLine(GetActorPipeLine());
+ if(theActor->GetPipeLine() != GetPipeLine()){
+ // To decrease actor'ss pipeline reference counter
+ theActor->GetPipeLine()->Delete();
+ }
theActor->SetFactory(this);
myUpdateActorsSignal.connect(boost::bind(&VISU_Actor::UpdateFromFactory,theActor));
myActorCollection->AddItem(theActor);
theActor->Delete();
-
}catch(std::bad_alloc& ex){
throw std::runtime_error("CreateActor >> No enough memory");
throw ex;
}
}
+//----------------------------------------------------------------------------
void
VISU::Prs3d_i
::RemoveActor(VISU_Actor* theActor)
{
- if(MYDEBUG) MESSAGE("Prs3d_i::RemoveActor - this = "<<this<<"; theActor = "<<theActor);
+ if(MYDEBUG) MESSAGE("Prs3d_i::RemoveActor - this = "<<this<<"; theActor = "<<theActor<<"; "<<theActor->GetReferenceCount());
myActorCollection->RemoveItem(theActor);
}
+//----------------------------------------------------------------------------
void
VISU::Prs3d_i
::RemoveActors()
{
if(MYDEBUG) MESSAGE("Prs3d_i::RemoveActors - this = "<<this);
- ProcessVoidEvent(new TRemoveActorsFromRendererEvent(myRemoveActorsFromRendererSignal));
+ ProcessVoidEvent(new TInvokeSignalEvent(myRemoveActorsFromRendererSignal));
myActorCollection->RemoveAllItems();
}
+//----------------------------------------------------------------------------
void
VISU::Prs3d_i
::UpdateActor(VISU_Actor* theActor)
{
if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor - this = "<<this<<"; theActor = "<<theActor);
- theActor->ShallowCopyPL(myPipeLine);
theActor->SetPosition(myOffset[0],myOffset[1],myOffset[2]);
- theActor->Modified();
+ theActor->ShallowCopyPL(GetPipeLine());
}
void
VISU::Prs3d_i
::UpdateActors()
{
- struct TUpdateActorsEvent: public SALOME_Event
- {
- typedef boost::signal0<void> TUpdateActorsSignalType;
- const TUpdateActorsSignalType& myUpdateActorsSignalVar;
-
- TUpdateActorsEvent(const TUpdateActorsSignalType& theUpdateActorsSignalVar):
- myUpdateActorsSignalVar(theUpdateActorsSignalVar)
- {}
-
- virtual
- void
- Execute()
- {
- myUpdateActorsSignalVar();
- }
- };
-
if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActors - this = "<<this);
Update();
CheckDataSet();
- ProcessVoidEvent(new TUpdateActorsEvent(myUpdateActorsSignal));
+ ProcessVoidEvent(new TInvokeSignalEvent(myUpdateActorsSignal));
}
VISU::Prs3d_i
::RemoveAllClippingPlanes()
{
- myPipeLine->RemoveAllClippingPlanes();
+ GetPipeLine()->RemoveAllClippingPlanes();
}
+//----------------------------------------------------------------------------
bool
VISU::Prs3d_i
::AddClippingPlane(vtkPlane* thePlane)
{
- return myPipeLine->AddClippingPlane(thePlane);
+ return GetPipeLine()->AddClippingPlane(thePlane);
}
+//----------------------------------------------------------------------------
vtkIdType
VISU::Prs3d_i
::GetNumberOfClippingPlanes() const
{
- return myPipeLine->GetNumberOfClippingPlanes();
+ return GetPipeLine()->GetNumberOfClippingPlanes();
}
-vtkPlane*
+//----------------------------------------------------------------------------
+vtkPlane*
VISU::Prs3d_i::
GetClippingPlane(vtkIdType theID) const
{
- return myPipeLine->GetClippingPlane(theID);
+ return GetPipeLine()->GetClippingPlane(theID);
}
+//----------------------------------------------------------------------------
void
VISU::Prs3d_i
-::SetPlaneParam (vtkFloatingPointType theDir[3],
- vtkFloatingPointType theDist,
- vtkPlane* thePlane)
+::SetPlaneParam(vtkFloatingPointType theDir[3],
+ vtkFloatingPointType theDist,
+ vtkPlane* thePlane)
{
- myPipeLine->SetPlaneParam(theDir, theDist, thePlane);
+ GetPipeLine()->SetPlaneParam(theDir, theDist, thePlane);
}
VISU::Prs3d_i
::GetBounds(vtkFloatingPointType aBounds[6])
{
- myPipeLine->GetMapper()->GetBounds(aBounds);
+ GetPipeLine()->GetMapper()->GetBounds(aBounds);
}
-void
+//----------------------------------------------------------------------------
+void
VISU::Prs3d_i
::SetOffset(const CORBA::Float* theOffsets)
{
myOffset[0] = theOffsets[0];
myOffset[1] = theOffsets[1];
myOffset[2] = theOffsets[2];
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
void
VISU::Prs3d_i
::SetOffset(CORBA::Float theDx,
myOffset[0] = theDx;
myOffset[1] = theDy;
myOffset[2] = theDz;
+ myParamsTime.Modified();
}
+//----------------------------------------------------------------------------
void
VISU::Prs3d_i
::GetOffset(CORBA::Float* theOffsets)
theOffsets[2] = myOffset[2];
}
-void
+//----------------------------------------------------------------------------
+void
VISU::Prs3d_i
::GetOffset(CORBA::Float& theDx,
CORBA::Float& theDy,
//----------------------------------------------------------------------------
-VISU::Result_i*
-VISU::GetResult(SALOMEDS::SObject_ptr theSObject)
-{
- VISU::Result_var aResult = FindResult(theSObject);
- if(!aResult->_is_nil())
- return dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());
- return NULL;
+CORBA::Float
+VISU::Prs3d_i
+::GetMemorySize()
+{
+ // To calculate memory used by VISU PipeLine
+ CORBA::Float aSize = GetPipeLine()->GetMemorySize();
+ //cout<<"Prs3d_i::GetMemorySize - "<<this<<"; GetPipeLine = "<<aSize / (1024.0 * 1024.0)<<endl;
+
+ // To calculate memory used by VISU Actos
+ int anEnd = myActorCollection->GetNumberOfItems();
+ for(int anId = 0; anId < anEnd; anId++)
+ if(vtkObject* anObject = myActorCollection->GetItemAsObject(anId))
+ if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anObject)){
+ aSize += anActor->GetMemorySize();
+ //cout<<"Prs3d_i::GetMemorySize - "<<this<<"; anActor = "<<aSize / (1024.0 * 1024.0)<<endl;
+ }
+
+ // Convert to mega bytes
+ return aSize / (1024.0 * 1024.0);
}
-
#include "VISU_ConvertorDef.hxx"
#include "SALOME_GenericObj_i.hh"
+#include "SALOME_GenericObjPointer.hh"
#include "SALOME_InteractiveObject.hxx"
#include "VTKViewer.h"
#include <vtkSmartPointer.h>
+#include <vtkTimeStamp.h>
class VISU_PipeLine;
class VISU_Actor;
class vtkPlane;
class vtkActorCollection;
-class vtkUnstructuredGrid;
+class vtkDataSet;
namespace VISU
{
Prs3d_i(const Prs3d_i&);
public:
- //----------------------------------------------------------------------------
- //! A constructor to create a fresh instance of the class
- explicit
- Prs3d_i(Result_i* theResult,
- bool theAddToStudy);
+ //----------------------------------------------------------------------------
+ typedef PrsObject_i TSuperClass;
+ typedef VISU::Prs3d TInterface;
- //! A constructor to restore an instance of the class
- explicit
- Prs3d_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject);
+ //----------------------------------------------------------------------------
+ //! A constructor to create a fresh instance of the class
+ Prs3d_i();
//! To create a deep copy from another instance of the class
virtual
virtual
~Prs3d_i();
+ //----------------------------------------------------------------------------
+ virtual
+ CORBA::Boolean
+ Apply(bool theReInit);
+
+ //----------------------------------------------------------------------------
+ void
+ SetCResult(Result_i* theResult);
+
+ Result_i*
+ GetCResult() const;
+
+ virtual
+ void
+ SetResultObject(VISU::Result_ptr theResult);
+
+ virtual
+ VISU::Result_ptr
+ GetResultObject();
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ SetMeshName(const char* theMeshName);
+
+ virtual
+ char*
+ GetMeshName();
+
+ std::string
+ GetCMeshName() const;
+
//----------------------------------------------------------------------------
//! To generate an unique type name for the class (used into persistent functionality)
virtual
QString
GenerateName() = 0;
+ //! To save paramters of the instance to std::ostringstream
+ virtual
+ void
+ ToStream(std::ostringstream& theStr);
+
//! To restore paramters of the instance from Storable::TRestoringMap
virtual
Storable*
- Restore(const Storable::TRestoringMap& theMap);
+ Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap);
- //! To save paramters of the instance to std::ostringstream
- virtual
+ //! To keep restoring params till the explicit Restore() call
void
- ToStream(std::ostringstream& theStr);
+ SaveRestoringState(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap);
- //----------------------------------------------------------------------------
- //! Get corresponding Result_i
- Result_i*
- GetResult() const;
+ //! To restore the presentation according to the saved state
+ void
+ InitFromRestoringState();
+ //----------------------------------------------------------------------------
//! Get corresponding SALOMEDS::SObject
virtual
SALOMEDS::SObject_var
GetSObject();
- const std::string&
- GetMeshName() const;
-
//----------------------------------------------------------------------------
//! To update is internal state
virtual
//----------------------------------------------------------------------------
//! Get corresponding VISU_PipeLine
VISU_PipeLine*
- GetPL();
+ GetPipeLine() const;
+
+ bool
+ IsPipeLineExists();
//! Get input of the VISU_PipeLine
- vtkUnstructuredGrid*
+ vtkDataSet*
GetInput();
//----------------------------------------------------------------------------
//! To define a way to create VTK representation of the instance
virtual
VISU_Actor*
- CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL) = 0;
+ CreateActor() = 0;
//! To unregister the pointed actor
virtual
void
GetBounds(vtkFloatingPointType aBounds[6]);
+ //! Move the 3D presentation according to the given offset parameters
void
SetOffset(const CORBA::Float* theOffsets);
+ //! Move the 3D presentation according to the given offset parameters
virtual
void
SetOffset(CORBA::Float theDx,
CORBA::Float theDy,
CORBA::Float theDz);
+ //! Gets offset parameters for the 3D presentation
void
GetOffset(CORBA::Float* theOffsets);
+ //! Gets offset parameters for the 3D presentation
virtual
void
GetOffset(CORBA::Float& theDx,
CORBA::Float& theDz);
//----------------------------------------------------------------------------
+ //! Gets memory size actually used by the presentation (Mb).
+ virtual
+ CORBA::Float
+ GetMemorySize();
+
+ //----------------------------------------------------------------------------
+ //! Gets know whether the factory instance can be used for actor management or not
+ virtual
+ bool
+ GetActiveState();
+
+ //----------------------------------------------------------------------------
+ //! Return modified time of the presentation
+ virtual
+ unsigned long int
+ GetMTime();
+
+ //----------------------------------------------------------------------------
+ //! Create and return the interactive object
+ virtual
+ Handle(SALOME_InteractiveObject)
+ GetIO();
+
protected:
+ /*!
+ Used in Apply method to get know whether it is possible to create presentation
+ with the input parameters or not. The derived classes can use this method
+ to customize Apply behaviour.
+ */
+ virtual
+ bool
+ SetInput(bool theReInit);
+
+ //! Restore input parameters if Apply function fails
+ virtual
+ void
+ OnRestoreInput();
+
+ //! Used in derived classes to initilize the myPipeLine member
void
- CreateActor(VISU_Actor* theActor,
- const Handle(SALOME_InteractiveObject)& theIO = NULL);
+ SetPipeLine(VISU_PipeLine* thePipeLine);
+ //! Used in derived classes to initilize the myPipeLine member
+ void
+ CreateActor(VISU_Actor* theActor);
+
+ //! Gets or creates VISU_PipeLine instance for actor initilization
virtual
VISU_PipeLine*
- GetPipeLine();
+ GetActorPipeLine();
//! To check dataset validity, throws std::exception if not valid
virtual
void
CheckDataSet();
- bool myAddToStudy;
- CORBA::Float myOffset[3];
- Result_i *myResult;
- VISU_PipeLine *myPipeLine;
- SALOMEDS::SObject_var mySObject;
+ protected:
+ vtkTimeStamp myUpdateTime;
+ vtkTimeStamp myParamsTime;
+
+ //! Used in derived classes to initilize the IO for actors
+ virtual
+ std::string
+ GetActorEntry();
+
+ private:
+ bool myIsRestored;
+ SALOMEDS::Study_var myRestoringStudy;
+ Storable::TRestoringMap myRestoringMap;
+
+ void
+ SetResultEntry(const std::string& theResultEntry);
+
+ std::string
+ GetResultEntry();
+
+ typedef SALOME::GenericObjPtr<VISU::Result_i> TResultPtr;
+ TResultPtr myResult;
+ TResultPtr myPreviousResult;
+
std::string myMeshName;
+ std::string myPreviousMeshName;
+
+ CORBA::Float myOffset[3];
boost::signal0<void> myUpdateActorsSignal;
boost::signal0<void> myRemoveActorsFromRendererSignal;
vtkSmartPointer<vtkActorCollection> myActorCollection;
- };
+ vtkSmartPointer<VISU_PipeLine> myPipeLine;
- //----------------------------------------------------------------------------
- Result_i*
- GetResult(SALOMEDS::SObject_ptr theSObject);
+ Handle(SALOME_InteractiveObject) myIO;
+
+ private:
+ friend class ColoredPrs3dCache_i;
+
+ //! Sets activity flag for the factory instance
+ void
+ SetActiveState(bool theState);
+
+ bool myIsActiveSatate;
+ };
- //----------------------------------------------------------------------------
- template<class TPrs3d>
- Storable*
- Restore(SALOMEDS::SObject_ptr theSObject,
- const std::string& thePrefix,
- const Storable::TRestoringMap& theMap)
- {
- VISU::Result_i* pResult = GetResult(theSObject);
- if(pResult != NULL){
- TPrs3d* pPrs3d = new TPrs3d(pResult,theSObject);
- return pPrs3d->Restore(theMap);
- }
- return NULL;
- }
//----------------------------------------------------------------------------
}
+++ /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
// Module : VISU
#include "VISU_PrsObject_i.hh"
-using namespace VISU;
-using namespace std;
#ifdef _DEBUG_
-static int MYDEBUG = 1;
-static int MYDEBUGWITHFILES = 0;
+static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#endif
-void VISU::PrsObject_i::SetName( const char* theName )
+//---------------------------------------------------------------
+VISU::RemovableObject_i
+::RemovableObject_i()
+{
+ if(MYDEBUG) MESSAGE("RemovableObject_i::RemovableObject_i - this = "<<this);
+}
+
+
+//---------------------------------------------------------------
+VISU::RemovableObject_i
+::~RemovableObject_i()
+{
+ if(MYDEBUG) MESSAGE("RemovableObject_i::~RemovableObject_i - this = "<<this);
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::RemovableObject_i
+::SetName(const std::string& theName,
+ bool theIsUpdateStudyAttr)
{
myName = theName;
- SALOMEDS::SObject_var mySO = myStudy->FindObjectID( GetEntry() );
- if(!mySO->_is_nil()){
- SALOMEDS::StudyBuilder_var aBuilder = myStudy->NewBuilder();
- SALOMEDS::GenericAttribute_var anAttr = aBuilder->FindOrCreateAttribute( mySO, "AttributeName" );
- SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow( anAttr );
- aNameAttr->SetValue( theName );
+ if(theIsUpdateStudyAttr){
+ SALOMEDS::SObject_var aSObject = myStudy->FindObjectID(GetEntry().c_str());
+ if(!aSObject->_is_nil()){
+ SALOMEDS::StudyBuilder_var aBuilder = myStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr = aBuilder->FindOrCreateAttribute( aSObject, "AttributeName" );
+ SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow( anAttr );
+ aNameAttr->SetValue( theName.c_str() );
+ }
}
}
-QString VISU::PrsObject_i::GetEntry() {
+
+
+//---------------------------------------------------------------
+const std::string&
+VISU::RemovableObject_i
+::GetName() const
+{
+ return myName;
+}
+
+
+//---------------------------------------------------------------
+const SALOMEDS::Study_var&
+VISU::RemovableObject_i
+::GetStudyDocument() const
+{
+ return myStudy;
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::RemovableObject_i
+::SetStudyDocument(SALOMEDS::Study_ptr theStudy)
+{
+ myStudy = SALOMEDS::Study::_duplicate(theStudy);
+}
+
+
+//---------------------------------------------------------------
+std::string
+VISU::RemovableObject_i
+::GetEntry()
+{
CORBA::String_var anIOR = GetID();
SALOMEDS::SObject_var aSObject = myStudy->FindObjectIOR(anIOR.in());
- CORBA::String_var anEntry;
+ CORBA::String_var anEntry("");
if(!CORBA::is_nil(aSObject.in()))
anEntry = aSObject->GetID();
else
MESSAGE("PrsObject_i::GetEntry - Cannot find SObject in the Study with StudyId = "<<myStudy->StudyId()<<" !!!");
return anEntry.in();
}
+
+
+//---------------------------------------------------------------
+VISU::PrsObject_i
+::PrsObject_i(SALOMEDS::Study_ptr theStudy)
+{
+ SetStudyDocument(theStudy);
+}
+
+
#include "VISUConfig.hh"
-namespace VISU{
- class VISU_I_EXPORT PrsObject_i : public virtual POA_VISU::PrsObject,
- public virtual RemovableObject_i
+namespace VISU
+{
+ //----------------------------------------------------------------------------
+ class VISU_I_EXPORT RemovableObject_i : public virtual POA_VISU::RemovableObject,
+ public virtual Storable
{
- PrsObject_i(const PrsObject_i&);
-
public:
- PrsObject_i(SALOMEDS::Study_ptr theStudy) : myStudy(SALOMEDS::Study::_duplicate(theStudy)) {};
- virtual ~PrsObject_i() {}
+ typedef Storable TSuperClass;
+
+ virtual
+ ~RemovableObject_i();
+
+ const SALOMEDS::Study_var&
+ GetStudyDocument() const;
+
+ virtual
+ std::string
+ GetEntry();
+
+ virtual
+ const std::string&
+ GetName() const;
+
+ virtual
+ void
+ SetName(const std::string& theName,
+ bool theIsUpdateStudyAttr);
protected:
+ RemovableObject_i();
+
+ void
+ SetStudyDocument(SALOMEDS::Study_ptr theStudy);
+
+ private:
std::string myName;
SALOMEDS::Study_var myStudy;
+ RemovableObject_i(const RemovableObject_i&);
+ };
+
+
+ //----------------------------------------------------------------------------
+ class VISU_I_EXPORT PrsObject_i : public virtual POA_VISU::PrsObject,
+ public virtual RemovableObject_i
+ {
+ PrsObject_i(const PrsObject_i&);
+
public:
- virtual const char* GetName() const { return myName.c_str();}
- virtual void SetName( const char* theName );
- const SALOMEDS::Study_var& GetStudyDocument() const { return myStudy;}
- QString GetEntry();
+ typedef RemovableObject_i TSuperClass;
+
+ PrsObject_i(SALOMEDS::Study_ptr theStudy = SALOMEDS::Study::_nil());
};
}
// OCCT Includes
#include <Bnd_Box.hxx>
+#ifdef ENABLE_MULTIPR
+// MULTIPR
+#include "MULTIPR_Obj.hxx"
+#endif
+
using namespace VISU;
using namespace std;
}
+ //---------------------------------------------------------------
+ Result_i*
+ GetResult(SALOMEDS::Study_ptr theStudy,
+ const std::string& theResultEntry)
+ {
+ if(CORBA::is_nil(theStudy))
+ return NULL;
+
+ SALOMEDS::SObject_var aSObject = theStudy->FindObjectID(theResultEntry.c_str());
+ CORBA::Object_var anObject = SObjectToObject(aSObject);
+ return dynamic_cast<VISU::Result_i*>(GetServant(anObject).in());
+ }
+
+
//---------------------------------------------------------------
typedef boost::recursive_mutex TMutex;
typedef TMutex::scoped_lock TLock;
//---------------------------------------------------------------
QString
- GenerateName (const char* theName)
+ GenerateName (const std::string& theName)
{
TLock aLock(myMutex);
const string& theIOR,
const string& theName,
const string& theComment,
- CORBA::Boolean theCreateNew)
+ CORBA::Boolean theCreateNew,
+ const string& theIcon = "")
{
TLock aLock(myMutex);
_PTR(AttributeString) aCmnt (anAttr);
aCmnt->SetValue(theComment);
}
+ // MULTIPR
+ if (theIcon != "") {
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributePixMap");
+ _PTR(AttributePixMap) aPixmap (anAttr);
+ aPixmap->SetPixMap(theIcon.c_str());
+ }
return aNewObj->GetID();
}
"",
true);
}
-
+
+#ifdef ENABLE_MULTIPR
+ // MULTIPR
+ aMesh->myPartsEntry =
+ CreateAttributes(theStudy,
+ aMesh->myEntry,
+ "",
+ "",
+ "",
+ true);
+#endif
+
//Import entities
TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
//---------------------------------------------------------------
- void
- BuildFields(Result_i* theResult,
- VISU_Convertor* theInput,
- CORBA::Boolean* theIsDone,
- CORBA::Boolean theIsBuild,
- CORBA::Boolean theIsAtOnce,
- _PTR(Study) theStudy)
+ void BuildFields(
+ Result_i* theResult,
+ VISU_Convertor* theInput,
+ CORBA::Boolean* theIsDone,
+ CORBA::Boolean theIsBuild,
+ CORBA::Boolean theIsAtOnce,
+ _PTR(Study) theStudy)
{
if(!theIsBuild || *theIsDone)
return;
QString aComment,aTmp;
const TMeshMap& aMeshMap = theInput->GetMeshMap();
TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
- for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
+
+ for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++)
+ {
const string& aMeshName = aMeshMapIter->first;
const PMesh& aMesh = aMeshMapIter->second;
-
+
const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
if(aMeshOnEntityMap.empty())
continue;
-
+
//Import fields
bool anIsFieldsEntryUpdated = false;
TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
- for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
+
+ for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++)
+ {
const TEntity& anEntity = aMeshOnEntityMapIter->first;
const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
const TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
- for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
- if(!anIsFieldsEntryUpdated){
+
+ for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++)
+ {
+ if(!anIsFieldsEntryUpdated)
+ {
aComment = "";
aComment.append("myComment=FIELDS;");
aComment.append("myMeshName=");aComment.append(aMeshName);
-
- UpdateAttributes(theStudy,
+
+ UpdateAttributes(
+ theStudy,
aMesh->myFieldsEntry,
"",
"Fields",
anIsFieldsEntryUpdated = true;
}
+
const string& aFieldName = aFieldMapIter->first;
const PField& aField = aFieldMapIter->second;
const TValField& aValField = aField->myValField;
aComment.append("myName=");aComment.append(aFieldName);aComment.append(";");
aComment.append(aTmp.sprintf("myNbTimeStamps=%d;",aValField.size()));
aComment.append(aTmp.sprintf("myNumComponent=%d",aField->myNbComp));
- aField->myEntry =
- CreateAttributes(theStudy,
- aMesh->myFieldsEntry,
- "",
- aFieldNameWithUnit.latin1(),
- aComment.latin1(),
- true);
- CreateReference(theStudy,
+
+ aField->myEntry = CreateAttributes(
+ theStudy,
+ aMesh->myFieldsEntry,
+ "",
+ aFieldNameWithUnit.latin1(),
+ aComment.latin1(),
+ true);
+
+ CreateReference(
+ theStudy,
aField->myEntry,
aMeshOnEntity->myEntry);
+
TValField::const_iterator aValFieldIter = aValField.begin();
- for(; aValFieldIter != aValField.end(); aValFieldIter++){
+
+ for(; aValFieldIter != aValField.end(); aValFieldIter++)
+ {
int aTimeStamp = aValFieldIter->first;
const PValForTime& aValForTime = aValFieldIter->second;
aComment = "";
aComment.append(aTmp.sprintf("myEntityId=%d;",anEntity));
aComment.append("myFieldName=");aComment.append(aFieldName);aComment.append(";");
aComment.append(aTmp.sprintf("myTimeStampId=%d;myNumComponent=%d",aTimeStamp,aField->myNbComp));
-
+
string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime);
- aValForTime->myEntry =
- CreateAttributes(theStudy,
- aField->myEntry,
- "",
- aTimeStampId,
- aComment.latin1(),
- true);
+
+ aValForTime->myEntry = CreateAttributes(
+ theStudy,
+ aField->myEntry,
+ "",
+ aTimeStampId,
+ aComment.latin1(),
+ true);
}
}
}
if(!anIsFieldsEntryUpdated && !theIsAtOnce)
- RemoveSObject(theStudy,
- aMesh->myFieldsEntry);
+ RemoveSObject(theStudy, aMesh->myFieldsEntry);
}
-
+
ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
}
+#ifdef ENABLE_MULTIPR
+ // MULTIPR
+ void BuildParts (Result_i* theResult,
+ VISU_Convertor* theInput,
+ CORBA::Boolean* theIsDone,
+ CORBA::Boolean theIsBuild,
+ CORBA::Boolean theIsAtOnce,
+ _PTR(Study) theStudy)
+ {
+ if(!theIsBuild || *theIsDone)
+ return;
+
+ // if MED file is not a distributed MED file (created with MULTIPR),
+ // then it is not necessary to build parts
+ if (theResult->GetFileInfoMultipr().filePath().isEmpty())
+ return;
+
+ try
+ {
+ multipr::Obj multiprObj;
+ multiprObj.create(theResult->GetFileInfoMultipr().filePath().latin1());
+ if (multiprObj.isValidDistributedMEDFile())
+ {
+ theResult->SetIsDistributedMEDMultipr(true);
+
+ const TMeshMap& aMeshMap = theInput->GetMeshMap();
+ TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+ const string& aMeshName = aMeshMapIter->first;
+ const PMesh& aMesh = aMeshMapIter->second;
+
+ vector<string> listParts = multiprObj.getParts();
+
+ QString aComment = "Sub-parts: #";
+ aComment += QString::number(listParts.size());
+
+ UpdateAttributes(
+ theStudy,
+ aMesh->myPartsEntry,
+ "",
+ "Parts",
+ aComment.latin1());
+
+ string lastEntry;
+
+ for (unsigned i = 0 ; i < listParts.size() ; i++)
+ {
+ const char* strItem = listParts[i].c_str();
+ const char* strPartInfo = multiprObj.getPartInfo(strItem).c_str();
+
+ char lMeshName[256];
+ int lId;
+ char lPartName[256];
+ char lPath[256];
+ char lMEDFileName[256];
+
+ // parse infos
+ int ret = sscanf(strPartInfo, "%s %d %s %s %s",
+ lMeshName,
+ &lId,
+ lPartName,
+ lPath,
+ lMEDFileName);
+
+ if ((strstr(lPartName,"_MED") != NULL) || (strstr(lPartName,"_LOW") != NULL))
+ {
+ QString aComment = "";
+ aComment.append("myComment=PART;");
+ aComment.append("res=ML;");
+ aComment.append("file=");
+ aComment.append(lMEDFileName);
+
+ CreateAttributes(
+ theStudy,
+ lastEntry, // father
+ "",
+ lPartName,
+ aComment.latin1(),
+ true);
+ }
+ else
+ {
+ QString aComment = "";
+ QString icon = "";
+
+ if (i != listParts.size()-1)
+ {
+ const char* strItemNext = listParts[i+1].c_str();
+ const char* strPartInfoNext = multiprObj.getPartInfo(strItemNext).c_str();
+ if ((strstr(strPartInfoNext,"_MED") != NULL) || (strstr(strPartInfoNext,"_LOW") != NULL))
+ {
+ // next part is MED or LOW resolution
+ icon = "ICON_MULTIPR_VIEW_LOW";
+ theResult->SetResolutionMultipr(lPartName, 'L');
+
+ aComment.append("myComment=PART;");
+ aComment.append("res=FML;");
+ aComment.append("file=");
+ aComment.append(lMEDFileName);
+ }
+ else
+ {
+ // no resolution associated with this part
+ icon = "ICON_MULTIPR_VIEW_FULL";
+ theResult->SetResolutionMultipr(lPartName, 'F');
+
+ aComment.append("myComment=PART;");
+ aComment.append("res=F;");
+ aComment.append("file=");
+ aComment.append(lMEDFileName);
+ }
+ }
+ else
+ {
+ // last part
+ icon = "ICON_MULTIPR_VIEW_FULL";
+ theResult->SetResolutionMultipr(lPartName, 'F');
+
+ aComment.append("myComment=PART;");
+ aComment.append("res=FML;");
+ aComment.append("file=");
+ aComment.append(lMEDFileName);
+ }
+
+ lastEntry = CreateAttributes(
+ theStudy,
+ aMesh->myPartsEntry, // father
+ "",
+ lPartName,
+ aComment.latin1(),
+ true,
+ icon.latin1());
+ }
+
+ theResult->AddPartMultipr(lPartName, lMEDFileName);
+ }
+ }
+ else
+ {
+ // invalid distributed MED file
+ return;
+ }
+ }
+ catch (...)
+ {
+ throw std::runtime_error("error while reading distributed MED file");
+ }
+
+ ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
+ }
+#endif
+
+
//---------------------------------------------------------------
void
BuildMinMax(Result_i* theResult,
theIsBuildMinMax,
theUpdateMinMaxSignal);
}
-
+
//---------------------------------------------------------------
struct TBuildArgs
Result_i::TUpdateMinMaxSignal* myUpdateMinMaxSignal;
CORBA::Boolean* myIsGroupsDone;
CORBA::Boolean myIsBuildGroups;
+#ifdef ENABLE_MULTIPR
+ CORBA::Boolean* myIsPartsDone;
+ CORBA::Boolean myIsBuildParts;
+#endif
_PTR(Study) myStudy;
TBuildArgs(Result_i* theResult,
Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal,
CORBA::Boolean* theIsGroupsDone,
CORBA::Boolean theIsBuildGroups,
+#ifdef ENABLE_MULTIPR
+ CORBA::Boolean* theIsPartsDone,
+ CORBA::Boolean theIsBuildParts,
+#endif
_PTR(Study) theStudy):
myResult(theResult),
myInput(theInput),
myUpdateMinMaxSignal(theUpdateMinMaxSignal),
myIsGroupsDone(theIsGroupsDone),
myIsBuildGroups(theIsBuildGroups),
+#ifdef ENABLE_MULTIPR
+ myIsPartsDone(theIsPartsDone),
+ myIsBuildParts(theIsBuildParts),
+#endif
myStudy(theStudy)
{}
-
};
//---------------------------------------------------------------
theBuildArgs.myIsBuildGroups,
theBuildArgs.myIsBuildFields,
theBuildArgs.myStudy);
+
{
boost::thread aThread(boost::bind(&BuildGroups,
theBuildArgs.myResult,
theBuildArgs.myUpdateMinMaxSignal,
theBuildArgs.myStudy));
}
+
+ /*
+ // MULTIPR
+ BuildParts(theBuildArgs.myResult,
+ theBuildArgs.myInput,
+ theBuildArgs.myIsPartsDone,
+ theBuildArgs.myIsBuildParts,
+ false,
+ theBuildArgs.myStudy);
+ */
}
-
}
myIsBuildFields(theIsBuildFields),
myIsBuildMinMax(theIsBuildMinMax),
myIsBuildGroups(theIsBuildGroups),
+#ifdef ENABLE_MULTIPR
+ myIsBuildParts(true),
+#endif
myIsEntitiesDone(false),
myIsFieldsDone(false),
myIsGroupsDone(false),
myIsMinMaxDone(false),
+#ifdef ENABLE_MULTIPR
+ myIsPartsDone(false),
+#endif
myIsAllDone(false),
myInput(NULL)
{
myStudy = ProcessEvent(new TGetStudy(myStudyDocument->StudyId()));
+#ifdef ENABLE_MULTIPR
+ myIsDistributedMEDMultipr = false;
+#endif
}
//---------------------------------------------------------------
-int
+size_t
VISU::Result_i
::IsPossible()
{
try{
- float aSize = myInput->GetSize();
- bool aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
+ size_t aSize = myInput->GetSize();
+ size_t aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
MESSAGE("Result_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<float(aResult));
return aResult;
}catch(std::exception& exc){
&myIsMinMaxDone,
myIsBuildMinMax,
&myUpdateMinMaxSignal);
-
- }else{
- TBuildArgs aBuildArgs(this,
- myInput,
- &myIsEntitiesDone,
- aResultEntry,
- &myIsFieldsDone,
- myIsBuildFields,
- &myIsMinMaxDone,
- myIsBuildMinMax,
- &myUpdateMinMaxSignal,
- &myIsGroupsDone,
- myIsBuildGroups,
- myStudy);
- boost::thread aThread(boost::bind(&BuildDataTree,
- aBuildArgs));
+
+#ifdef ENABLE_MULTIPR
+ // MULTIPR
+ BuildParts(this,
+ myInput,
+ &myIsPartsDone,
+ myIsBuildParts,
+ theIsAtOnce,
+ myStudy);
+#endif
+ }
+ else {
+#ifdef ENABLE_MULTIPR
+ if (strlen(GetFileInfoMultipr().filePath().latin1()) == 0)
+#endif
+ {
+ // sequential MED file
+ TBuildArgs aBuildArgs(this,
+ myInput,
+ &myIsEntitiesDone,
+ aResultEntry,
+ &myIsFieldsDone,
+ myIsBuildFields,
+ &myIsMinMaxDone,
+ myIsBuildMinMax,
+ &myUpdateMinMaxSignal,
+ &myIsGroupsDone,
+ myIsBuildGroups,
+#ifdef ENABLE_MULTIPR
+ &myIsPartsDone,
+ myIsBuildParts,
+#endif
+ myStudy);
+ boost::thread aThread(boost::bind(&BuildDataTree, aBuildArgs));
+ }
+#ifdef ENABLE_MULTIPR
+ else
+ {
+ // distributed MED file
+ BuildEntities(this,
+ myInput,
+ &myIsEntitiesDone,
+ aResultEntry,
+ theIsAtOnce,
+ myIsBuildGroups,
+ myIsBuildFields,
+ myStudy);
+
+ BuildGroups(this,
+ myInput,
+ &myIsGroupsDone,
+ myIsBuildGroups,
+ theIsAtOnce,
+ myStudy);
+
+ BuildFields(this,
+ myInput,
+ &myIsFieldsDone,
+ myIsBuildFields,
+ theIsAtOnce,
+ myStudy);
+
+ BuildMinMax(this,
+ myInput,
+ &myIsMinMaxDone,
+ myIsBuildMinMax,
+ &myUpdateMinMaxSignal);
+
+ // MULTIPR
+ BuildParts(this,
+ myInput,
+ &myIsPartsDone,
+ myIsBuildParts,
+ theIsAtOnce,
+ myStudy);
+ }
+#endif
}
return this;
VISU::Storable*
VISU::Result_i::
Create(const char* theFileName)
-{
- try{
+{
+ try {
myFileInfo.setFile(theFileName);
+
+#ifdef ENABLE_MULTIPR
+ // MULTIPR
+ if (myFileInfo.filePath().endsWith("_grains_maitre.med"))
+ {
+ // retrieve source MED file (sequential MED file)
+ QString originalMEDFileName = "";
+ FILE* aFile = fopen(theFileName, "rt");
+ char aBuf[1024];
+ while (!feof(aFile))
+ {
+ fgets(aBuf, 1024, aFile);
+ char* strTag = NULL;
+ if ((aBuf[0] == '#') && ((strTag = strstr(aBuf, "[SOURCE]=")) != NULL))
+ {
+ char strSequentialMEDFilename[256];
+ int ret = sscanf(strTag, "[SOURCE]=%s", strSequentialMEDFilename);
+ if (ret == 1)
+ {
+ originalMEDFileName = strSequentialMEDFilename;
+ break;
+ }
+ }
+ }
+ fclose(aFile);
+ if (originalMEDFileName == "")
+ throw std::runtime_error("distributed MED file; bad format");
+
+ //cout << "MULTIPR: original med file=" << originalMEDFileName << endl;
+ myFileInfoMultipr.setFile(myFileInfo.filePath());
+ myFileInfo.setFile(originalMEDFileName);
+ }
+ else
+ {
+ myFileInfoMultipr.setFile("");
+ }
+#endif
+
myInitFileName = myFileInfo.filePath().latin1();
myName = ::GenerateName(myFileInfo.fileName()).latin1();
if(mySourceId == eRestoredFile){
if(MYDEBUG) MESSAGE("Result_i::Create - aCommand = "<<aCommand);
myFileInfo.setFile(QString(aTmpDir.c_str()) + myFileInfo.fileName());
}
+
myInput = CreateConvertor(myFileInfo.absFilePath().latin1());
+
if(myInput){
if(myIsBuildImmediately)
Build(SALOMEDS::SObject::_nil());
//---------------------------------------------------------------
VISU::Storable*
-VISU::Result_i::
-Create(SALOMEDS::SObject_ptr theMedSObject)
+VISU::Result_i
+::Create(SALOMEDS::SObject_ptr theMedSObject)
{
if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOMEDS::SObject_ptr");
try{
//---------------------------------------------------------------
VISU::Storable*
-VISU::Result_i::
-Create(SALOME_MED::FIELD_ptr theField)
+VISU::Result_i
+::Create(SALOME_MED::FIELD_ptr theField)
{
if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOME_MED::FIELD_ptr");
try{
//---------------------------------------------------------------
VISU::Storable*
-VISU::Result_i::
-Restore(SALOMEDS::SObject_ptr theSObject,
- const Storable::TRestoringMap& theMap,
- const string& thePrefix)
+VISU::Result_i
+::Restore(SALOMEDS::SObject_ptr theSObject,
+ const Storable::TRestoringMap& theMap,
+ const string& thePrefix)
{
if(MYDEBUG) MESSAGE("Result_i::Restore - " << thePrefix);
try {
return "";
}
-string
+std::string
VISU::Result_i
::GetEntry()
{
CORBA::String_var anEntry = mySObject->GetID();
- return string(anEntry);
+ return anEntry.in();
}
const SALOMEDS::SObject_var&
} else
theMesh = aIter->second;
- if(!theMesh->IsStructured() || theMesh->myType){
+ VISU::PUnstructuredGridIDMapper anIDMapper = myInput->GetMeshOnEntity(theMeshName,
+ CELL_ENTITY);
+ vtkUnstructuredGrid* aMesh = anIDMapper->GetUnstructuredGridOutput();
- VISU::PIDMapper anIDMapper = myInput->GetMeshOnEntity(theMeshName,
- CELL_ENTITY);
-
- VISU::TVTKOutput* aMesh = anIDMapper->GetVTKOutput();
-
- if ( !aMesh || aMesh->GetNumberOfCells() == 0 ) {
- MESSAGE( "No cells in the mesh: " << theMeshName );
- return components;
- }
-
+ if ( !aMesh || aMesh->GetNumberOfCells() == 0 ) {
+ MESSAGE( "No cells in the mesh: " << theMeshName );
+ return components;
+ }
+
+ if(!theMesh->IsStructured() || theMesh->myType){
// define axis directions and min cell size in each direction
const int nbAxes = 3;
int iAx;
}
else {
//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
- TVectorID aIndexes = theMesh->GetStructure();
+ TIdTypeVector aIndexes = theMesh->GetStructure();
- VISU::PIDMapper anIDMapper = myInput->GetMeshOnEntity(theMeshName,
- CELL_ENTITY);
- VISU::TVTKOutput* aMesh = anIDMapper->GetVTKOutput();
-
gInfo = & myMeshName2GridInfoMap[ theMeshName ];
switch(aIndexes.size()){
case 3:
return components;
}
+
+
+#ifdef ENABLE_MULTIPR
+//=======================================================================
+// MULTIPR
+//=======================================================================
+
+// MULTIPR
+void VISU::Result_i::AddPartMultipr(const char* thePartName, const char* theMEDFilename)
+{
+ myMapPartNameToMEDFilename.insert(make_pair(thePartName, theMEDFilename));
+}
+
+// MULTIPR
+void VISU::Result_i::SetResolutionMultipr(const char* theName, char theNewResolution)
+{
+ map<string, char>::iterator anIterator = mySelectedResolutionMultipr.find(theName);
+
+ if (anIterator == mySelectedResolutionMultipr.end())
+ {
+ // current name does not exist: create
+ mySelectedResolutionMultipr.insert(make_pair(theName, theNewResolution));
+ }
+ else
+ {
+ // modify
+ (*anIterator).second = theNewResolution;
+ }
+}
+
+// MULTIPR
+string VISU::Result_i::FindPartMultipr(const char* theName)
+{
+ map<string, string>::iterator anIterator = myMapPartNameToMEDFilename.find(theName);
+
+ if (anIterator == myMapPartNameToMEDFilename.end())
+ {
+ return NULL;
+ }
+ return (*anIterator).second;
+}
+
+// MULTIPR
+void VISU::Result_i::SetIsDistributedMEDMultipr(bool theIsDistributedMED)
+{
+ myIsDistributedMEDMultipr = theIsDistributedMED;
+}
+
+// MULTIPR
+bool VISU::Result_i::IsDistributedMEDMultipr() const
+{
+ return myIsDistributedMEDMultipr;
+}
+
+// MULTIPR
+vector<string> VISU::Result_i::GetCurrentRepresentationMultipr()
+{
+ // name of selected parts
+ vector<string> res;
+
+ // for each part of the mesh
+ for (map<string, char>::iterator it = mySelectedResolutionMultipr.begin() ;
+ it != mySelectedResolutionMultipr.end() ;
+ it++)
+ {
+ const char* partName = ((*it).first).c_str();
+ char resolution = (*it).second;
+
+ //cout << "name=" << partName << " res=" << resolution << endl;
+
+ if (resolution == 'F')
+ {
+ res.push_back( FindPartMultipr(partName) );
+ }
+ else if (resolution == 'M')
+ {
+ char subPartName[256];
+ sprintf(subPartName, "%s_MED", partName);
+ res.push_back( FindPartMultipr(subPartName) );
+ }
+ else if (resolution == 'L')
+ {
+ char subPartName[256];
+ sprintf(subPartName, "%s_LOW", partName);
+ res.push_back( FindPartMultipr(subPartName) );
+ }
+ }
+
+ return res;
+}
+#endif // ENABLE_MULTIPR
#ifndef __VISU_RESULT_I_H__
#define __VISU_RESULT_I_H__
-#include "VISUConfig.hh"
+#include "VISU_PrsObject_i.hh"
#include "VISU_BoostSignals.h"
#include "SALOME_GenericObj_i.hh"
#include <gp_Dir.hxx>
#include <vector>
+#include <map>
class VISU_Convertor;
ECreationId myCreationId;
TInput *myInput;
- std::string myName, myInitFileName;
+ std::string myName, myInitFileName;
QFileInfo myFileInfo;
+#ifdef ENABLE_MULTIPR
+ // MULTIPR
+ QFileInfo myFileInfoMultipr;
+ std::map<std::string, std::string> myMapPartNameToMEDFilename;
+ std::map<std::string, char> mySelectedResolutionMultipr;
+ bool myIsDistributedMEDMultipr;
+#endif
+
protected:
virtual Storable* Build(SALOMEDS::SObject_ptr theSObject,
CORBA::Boolean theIsAtOnce = true) ;
CORBA::Boolean myIsFieldsDone;
CORBA::Boolean myIsGroupsDone;
CORBA::Boolean myIsMinMaxDone;
+#ifdef ENABLE_MULTIPR
+ CORBA::Boolean myIsPartsDone; // MULTIPR
+#endif
CORBA::Boolean myIsBuildFields;
CORBA::Boolean myIsBuildGroups;
CORBA::Boolean myIsBuildMinMax;
+#ifdef ENABLE_MULTIPR
+ CORBA::Boolean myIsBuildParts; // MULTIPR
+#endif
TUpdateMinMaxSignal myUpdateMinMaxSignal;
CORBA::Boolean myIsAllDone;
public:
- virtual int IsPossible();
+ virtual size_t IsPossible();
virtual Storable* Create(const char* theFileName);
virtual Storable* Create(SALOMEDS::SObject_ptr theMedSObject);
const std::string& GetName() const { return myName;}
const QFileInfo& GetFileInfo() const { return myFileInfo;}
+#ifdef ENABLE_MULTIPR
+ const QFileInfo& GetFileInfoMultipr() const { return myFileInfoMultipr;}
+#endif
const std::string& GetFileName() const { return myInitFileName;}
const ECreationId& GetCreationId() const { return myCreationId;}
+
+#ifdef ENABLE_MULTIPR
+ // MULTIPR
+ void AddPartMultipr(const char* thePartName, const char* theMEDFilename);
+ void SetResolutionMultipr(const char* theName, char theNewResolution); // 'F'=FULL 'M'=MEDIUM 'L'=LOW 'H'=HIDE
+ std::string FindPartMultipr(const char* theName);
+ std::vector<std::string> GetCurrentRepresentationMultipr();
+ void SetIsDistributedMEDMultipr(bool theIsDistributedMED);
+ bool IsDistributedMEDMultipr() const;
+#endif
private:
SALOMEDS::SObject_var mySObject;
std::map< std::string, TGridInfo > myMeshName2GridInfoMap;
};
- Result_var FindResult(SALOMEDS::SObject_ptr theSObject);
+ //! To find Result object as published on father of the given SObject
+ Result_var
+ FindResult(SALOMEDS::SObject_ptr theSObject);
+
+ //! To get VISU::Result object published on the given SALOMEDS::SObject
+ Result_i*
+ GetResult(SALOMEDS::Study_ptr theStudy,
+ const std::string& theResultEntry);
}
#endif
// Author : Eugeny Nikolaev
// Module : VISU
-#include "VISU_ScalarMapOnDeformedShapePL.hxx"
-#include "VISU_Result_i.hh"
#include "VISU_ScalarMapOnDeformedShape_i.hh"
-#include "VISU_Convertor.hxx"
#include "VISU_ScalarMapAct.h"
+#include "VISU_ScalarMapOnDeformedShapePL.hxx"
+#include "VISU_Convertor.hxx"
+#include "VISU_Result_i.hh"
#include "SUIT_ResourceMgr.h"
#include <vtkProperty.h>
#include <vtkMapper.h>
-using namespace VISU;
-using namespace std;
-
#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
static int INCMEMORY = 4+12;
-int VISU::ScalarMapOnDeformedShape_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration, int isMemoryCheck)
+
+//---------------------------------------------------------------
+size_t
+VISU::ScalarMapOnDeformedShape_i
+::IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck)
{
- bool aResult = false;
+ size_t aResult = 0;
try{
- aResult = TSuperClass::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,false);
- if(isMemoryCheck && aResult){
- const VISU::PField aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName);
+ aResult = TSuperClass::IsPossible(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber,
+ false);
+ if(theIsMemoryCheck && aResult){
+ VISU::Result_i::TInput* anInput = theResult->GetInput();
+ const VISU::PField aField = anInput->GetField(theMeshName,
+ (VISU::TEntity)theEntity,
+ theFieldName);
if(aField->myNbComp <= 1)
- return false;
- float aSize = INCMEMORY*
- theResult->GetInput()->GetTimeStampSize(theMeshName,(VISU::TEntity)theEntity,theFieldName,theIteration);
+ return 0;
+
+ bool anIsEstimated = true;
+ size_t aSize = anInput->GetTimeStampOnMeshSize(theMeshName,
+ (VISU::TEntity)theEntity,
+ theFieldName,
+ theTimeStampNumber,
+ anIsEstimated);
+ if(anIsEstimated)
+ aSize *= INCMEMORY;
aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
MESSAGE("ScalarMapOnDeformedShape_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<aResult);
}
return aResult;
}
+//---------------------------------------------------------------
int VISU::ScalarMapOnDeformedShape_i::myNbPresent = 0;
-QString VISU::ScalarMapOnDeformedShape_i::GenerateName() { return VISU::GenerateName("ScalarDef.Shape",myNbPresent++);}
-const string VISU::ScalarMapOnDeformedShape_i::myComment = "SCALARMAPONDEFORMEDSHAPE";
-const char* VISU::ScalarMapOnDeformedShape_i::GetComment() const { return myComment.c_str();}
-
-VISU::ScalarMapOnDeformedShape_i::
-ScalarMapOnDeformedShape_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theAddToStudy),
- ColoredPrs3d_i(theResult,theAddToStudy),
- ScalarMap_i(theResult,theAddToStudy),
- TSuperClass(theResult,theAddToStudy),
- myScalarMapOnDeformedShapePL(NULL),
- myScalarIteration(1)
+//---------------------------------------------------------------
+QString
+VISU::ScalarMapOnDeformedShape_i
+::GenerateName()
{
+ return VISU::GenerateName("ScalarDef.Shape",myNbPresent++);
}
-VISU::ScalarMapOnDeformedShape_i::
-ScalarMapOnDeformedShape_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
- ColoredPrs3d_i(theResult,theSObject),
- ScalarMap_i(theResult,theSObject),
- TSuperClass(theResult,theSObject),
- myScalarMapOnDeformedShapePL(NULL),
- myScalarIteration(1)
+//---------------------------------------------------------------
+const string VISU::ScalarMapOnDeformedShape_i::myComment = "SCALARMAPONDEFORMEDSHAPE";
+
+//---------------------------------------------------------------
+const char*
+VISU::ScalarMapOnDeformedShape_i
+::GetComment() const
+{
+ return myComment.c_str();
+}
+
+//----------------------------------------------------------------------------
+const char*
+VISU::ScalarMapOnDeformedShape_i
+::GetIconName()
{
+ if (!IsGroupsUsed())
+ return "ICON_TREE_SCALAR_MAP_ON_DEFORMED_SHAPE";
+ else
+ return "ICON_TREE_SCALAR_MAP_ON_DEFORMED_SHAPE_GROUPS";
}
-VISU::Storable* VISU::ScalarMapOnDeformedShape_i::Create(const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration)
+//---------------------------------------------------------------
+VISU::ScalarMapOnDeformedShape_i
+::ScalarMapOnDeformedShape_i(EPublishInStudyMode thePublishInStudyMode) :
+ ColoredPrs3d_i(thePublishInStudyMode),
+ ScalarMap_i(thePublishInStudyMode),
+ myScalarMapOnDeformedShapePL(NULL),
+ myScalarTimeStampNumber(1)
+{}
+
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::ScalarMapOnDeformedShape_i
+::Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
{
- if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::Create:"<<__LINE__<<endl;
myIsColored = true;
myColor.R = myColor.G = myColor.B = 0.5;
- VISU::Storable* aRes = TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
- SetScalarFieldName(theFieldName);
- SetScalarIteration(theIteration);
- SetScalarMeshName(theMeshName);
- int anEntity = theEntity;
- SetScalarEntity(VISU::TEntity(anEntity));
- SetScalarField(myScalarMeshName.c_str(),myScalarFieldName.c_str(),myScalarIteration,myScalarEntity);
- return aRes;
+
+ SetScalarField(theMeshName.c_str(),
+ theFieldName.c_str(),
+ theTimeStampNumber,
+ theEntity);
+
+ return TSuperClass::Create(theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber);
}
-VISU::Storable* VISU::ScalarMapOnDeformedShape_i::Restore(const Storable::TRestoringMap& theMap)
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::ScalarMapOnDeformedShape_i
+::Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
{
- if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::Restore:"<<__LINE__<<endl;
- TSuperClass::Restore(theMap);
+ QString aMeshName = VISU::Storable::FindValue(theMap,"myScalarMeshName");
+ VISU::Entity anEntity = VISU::Entity(VISU::Storable::FindValue(theMap,"myScalarFieldName").toInt());
+
+ QString aFieldName = VISU::Storable::FindValue(theMap,"myScalarFieldName");
+ int aTimeStampNumber = VISU::Storable::FindValue(theMap,"myScalarFieldName").toInt();
+
+ SetScalarField(aMeshName,
+ aFieldName,
+ aTimeStampNumber,
+ anEntity);
- SetScalarFieldName(VISU::Storable::FindValue(theMap,"myScalarFieldName"));
- SetScalarMeshName(VISU::Storable::FindValue(theMap,"myScalarMeshName"));
- SetScalarIteration(VISU::Storable::FindValue(theMap,"myScalarIteration").toInt());
- SetScalarEntity(VISU::TEntity(VISU::Storable::FindValue(theMap,"myScalarEntity").toInt()));
- SetScalarField(GetScalarMeshName().c_str(),
- GetScalarFieldName().c_str(),
- GetScalarIteration(),
- GetScalarEntity());
+ if(!TSuperClass::Restore(theStudy, theMap))
+ return NULL;
SetScale(VISU::Storable::FindValue(theMap,"myFactor").toDouble());
myIsColored = VISU::Storable::FindValue(theMap,"myIsColored").toInt();
return this;
}
-void VISU::ScalarMapOnDeformedShape_i::ToStream(std::ostringstream& theStr)
+
+//---------------------------------------------------------------
+void
+VISU::ScalarMapOnDeformedShape_i
+::ToStream(std::ostringstream& theStr)
{
- if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::ToStream:"<<__LINE__<<endl;
TSuperClass::ToStream(theStr);
Storable::DataToStream( theStr, "myScalarFieldName", myScalarFieldName.c_str());
Storable::DataToStream( theStr, "myScalarMeshName", myScalarMeshName.c_str());
- Storable::DataToStream( theStr, "myScalarIteration", myScalarIteration);
+ Storable::DataToStream( theStr, "myScalarIteration", int(myScalarTimeStampNumber));
Storable::DataToStream( theStr, "myScalarEntity", int(myScalarEntity));
Storable::DataToStream( theStr, "myFactor", GetScale() );
Storable::DataToStream( theStr, "myColor.R", myColor.R );
Storable::DataToStream( theStr, "myColor.G", myColor.G );
Storable::DataToStream( theStr, "myColor.B", myColor.B );
-
}
-VISU::ScalarMapOnDeformedShape_i::~ScalarMapOnDeformedShape_i(){
+
+//---------------------------------------------------------------
+VISU::ScalarMapOnDeformedShape_i
+::~ScalarMapOnDeformedShape_i()
+{
if(MYDEBUG) MESSAGE("ScalarMapOnDeformedShape_i::~ScalarMapOnDeformedShape_i()");
}
+
+//---------------------------------------------------------------
void
VISU::ScalarMapOnDeformedShape_i
::SameAs(const Prs3d_i* theOrigin)
{
- if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::SameAs:"<<__LINE__<<endl;
- int theScalarIter = this->GetScalarIteration();
- string theScalarMeshName = this->GetScalarMeshName();
- string theScalarFieldName = this->GetScalarFieldName();
- if(MYDEBUG) cout << "SameAs:"<<endl
- << "\t"<<theScalarIter<<":"<<theScalarMeshName.c_str()<<":"<<theScalarFieldName.c_str()<<endl;
-
TSuperClass::SameAs(theOrigin);
-
+
if(const ScalarMapOnDeformedShape_i* aPrs3d = dynamic_cast<const ScalarMapOnDeformedShape_i*>(theOrigin)){
ScalarMapOnDeformedShape_i* anOrigin = const_cast<ScalarMapOnDeformedShape_i*>(aPrs3d);
-
- this->SetScalarField(anOrigin->GetScalarMeshName().c_str(),
- anOrigin->GetScalarFieldName().c_str(),
- theScalarIter,
- anOrigin->GetScalarEntity());
+ CORBA::String_var aMeshName = anOrigin->GetScalarCMeshName();
+ CORBA::String_var aFieldName = anOrigin->GetScalarCFieldName();
+
+ SetScalarField(aMeshName,
+ aFieldName,
+ anOrigin->GetScalarLIteration(),
+ anOrigin->GetScalarEEntity());
Update();
}
}
-void VISU::ScalarMapOnDeformedShape_i::SetScale(CORBA::Double theScale) {
+
+//---------------------------------------------------------------
+void
+VISU::ScalarMapOnDeformedShape_i
+::SetScale(CORBA::Double theScale)
+{
myScalarMapOnDeformedShapePL->SetScale(theScale);
}
-CORBA::Double VISU::ScalarMapOnDeformedShape_i::GetScale(){
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::ScalarMapOnDeformedShape_i
+::GetScale()
+{
return myScalarMapOnDeformedShapePL->GetScale();
}
-void
+
+//---------------------------------------------------------------
+CORBA::Boolean
VISU::ScalarMapOnDeformedShape_i
-::SetRange(CORBA::Double theMin, CORBA::Double theMax)
+::IsColored()
{
- if(theMin > theMax)
- return;
- vtkFloatingPointType aScalarRange[2] = {theMin, theMax};
- myScalarMapOnDeformedShapePL->SetScalarRange(aScalarRange);
- myIsFixedRange = true;
+ return myIsColored;
}
-void VISU::ScalarMapOnDeformedShape_i::SetSourceRange(CORBA::Double theMinRange,CORBA::Double theMaxRange){
- SetRange(theMinRange,theMaxRange);
-}
+//---------------------------------------------------------------
void
VISU::ScalarMapOnDeformedShape_i
-::SetSourceRange()
+::ShowColored(CORBA::Boolean theColored)
{
- myScalarMapOnDeformedShapePL->SetSourceRange();
- myIsFixedRange = false;
+ myIsColored = theColored;
+ myParamsTime.Modified();
}
-CORBA::Double VISU::ScalarMapOnDeformedShape_i::GetSourceRangeMin(){
- vtkFloatingPointType aRange[2];
- myScalarMapOnDeformedShapePL->GetSourceRange(aRange);
- return aRange[0];
+//---------------------------------------------------------------
+SALOMEDS::Color
+VISU::ScalarMapOnDeformedShape_i
+::GetColor()
+{
+ return myColor;
}
-CORBA::Double VISU::ScalarMapOnDeformedShape_i::GetSourceRangeMax(){
- vtkFloatingPointType aRange[2];
- myScalarMapOnDeformedShapePL->GetSourceRange(aRange);
- return aRange[1];
+
+//---------------------------------------------------------------
+void
+VISU::ScalarMapOnDeformedShape_i
+::SetColor(const SALOMEDS::Color& theColor)
+{
+ myColor = theColor;
+ myParamsTime.Modified();
}
-void VISU::ScalarMapOnDeformedShape_i::DoHook()
+
+//---------------------------------------------------------------
+void
+VISU::ScalarMapOnDeformedShape_i
+::CreatePipeLine(VISU_PipeLine* thePipeLine)
{
- if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::DoHook:"<<__LINE__<<endl;
- if(!myPipeLine)
- myPipeLine = VISU_ScalarMapOnDeformedShapePL::New();
-
- myScalarMapOnDeformedShapePL = dynamic_cast<VISU_ScalarMapOnDeformedShapePL*>(myPipeLine);
- myPipeLine->GetMapper()->SetScalarVisibility(IsColored());
+ if(!thePipeLine){
+ myScalarMapOnDeformedShapePL = VISU_ScalarMapOnDeformedShapePL::New();
+ }else
+ myScalarMapOnDeformedShapePL = dynamic_cast<VISU_ScalarMapOnDeformedShapePL*>(thePipeLine);
- TSuperClass::DoHook();
+ myScalarMapOnDeformedShapePL->GetMapper()->SetScalarVisibility(IsColored());
+
+ TSuperClass::CreatePipeLine(myScalarMapOnDeformedShapePL);
}
-const char*
+
+//---------------------------------------------------------------
+bool
VISU::ScalarMapOnDeformedShape_i
-::GetIconName()
+::CheckIsPossible()
{
- if (!GetNumberOfGeom())
- return "ICON_TREE_SCALAR_MAP_ON_DEFORMED_SHAPE";
- else
- return "ICON_TREE_SCALAR_MAP_ON_DEFORMED_SHAPE_GROUPS";
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
}
-VISU_Actor* VISU::ScalarMapOnDeformedShape_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+
+//---------------------------------------------------------------
+VISU_Actor*
+VISU::ScalarMapOnDeformedShape_i
+::CreateActor()
{
- if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::CreateActor:"<<__LINE__<<endl;
- VISU_Actor* anActor = TSuperClass::CreateActor(theIO, true);
+ VISU_Actor* anActor = TSuperClass::CreateActor(true);
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
int aDispMode = aResourceMgr->integerValue("VISU", "scalar_def_represent", 2);
bool toShrink = aResourceMgr->booleanValue("VISU", "scalar_def_shrink", false);
}
-void VISU::ScalarMapOnDeformedShape_i::UpdateActor(VISU_Actor* theActor) {
- if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::UpdateActor:"<<__LINE__<<endl;
+//---------------------------------------------------------------
+void
+VISU::ScalarMapOnDeformedShape_i
+::UpdateActor(VISU_Actor* theActor)
+{
if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
if(IsColored()){
anActor->SetBarVisibility(true);
- myPipeLine->GetMapper()->SetScalarVisibility(1);
+ GetPipeLine()->GetMapper()->SetScalarVisibility(1);
}else{
anActor->SetBarVisibility(false);
- myPipeLine->GetMapper()->SetScalarVisibility(0);
+ GetPipeLine()->GetMapper()->SetScalarVisibility(0);
anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B);
}
TSuperClass::UpdateActor(theActor);
}
}
-void VISU::ScalarMapOnDeformedShape_i::SetScalarField(const char* theMeshName,
- const char* theFieldName,
- int theIteration,
- VISU::TEntity theEntity)
+
+//---------------------------------------------------------------
+void
+VISU::ScalarMapOnDeformedShape_i
+::SetField(VISU::PField theField)
{
- if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::SetScalarField:"<<__LINE__<<endl;
- if(MYDEBUG) cout << "\ttheFieldName="<<theFieldName<<endl;
- if(MYDEBUG) cout << "\ttheIteration="<<theIteration<<endl;
- myScalarField = myResult->GetInput()->GetField(theMeshName,theEntity,theFieldName);
- TVTKOutput* aOut = myResult->GetInput()->GetTimeStampOnMesh(theMeshName,
- theEntity,
- theFieldName,
- theIteration)->GetVTKOutput();
- if (myScalarMapOnDeformedShapePL){
- myScalarMapOnDeformedShapePL->SetScalars(aOut);
- }
- this->SetScalarMeshName(theMeshName);
- this->SetScalarFieldName(theFieldName);
- this->SetScalarIteration(theIteration);
- this->SetScalarEntity(theEntity);
+ TSuperClass::SetField(theField);
+
+ if(!myScalarField)
+ myScalarField = theField;
}
-void VISU::ScalarMapOnDeformedShape_i::SetScalarField(const char* theMeshName,
- const char* theFieldName,
- CORBA::Long theIteration,
- VISU::Entity theEntity)
+
+//---------------------------------------------------------------
+void
+VISU::ScalarMapOnDeformedShape_i
+::SetScalarField(const char* theMeshName,
+ const char* theFieldName,
+ CORBA::Long theTimeStampNumber,
+ VISU::Entity theEntity)
{
- this->SetScalarField(theMeshName,theFieldName,(int)theIteration,VISU::TEntity(theEntity));
-}
+ bool anIsModified = false;
-void VISU::ScalarMapOnDeformedShape_i::SetScalarMeshName(const char* theName){
- myScalarMeshName = theName;
-}
-std::string VISU::ScalarMapOnDeformedShape_i::GetScalarMeshName(){
- return myScalarMeshName;
-}
-char* VISU::ScalarMapOnDeformedShape_i::GetScalarCMeshName(){
- return &this->GetScalarMeshName()[0];
-}
+ if(!anIsModified)
+ anIsModified |= myScalarMeshName != theMeshName;
-void VISU::ScalarMapOnDeformedShape_i::SetScalarFieldName(const char* theName){
- myScalarFieldName = theName;
-}
+ if(!anIsModified)
+ anIsModified |= myScalarEntity != theEntity;
-std::string VISU::ScalarMapOnDeformedShape_i::GetScalarFieldName(){
- return myScalarFieldName;
-}
+ if(!anIsModified)
+ anIsModified |= myScalarFieldName != theFieldName;
-char* VISU::ScalarMapOnDeformedShape_i::GetScalarCFieldName(){
- return &this->GetScalarFieldName()[0];
-}
+ if(!anIsModified)
+ anIsModified |= myScalarTimeStampNumber != theTimeStampNumber;
+
+ if(!anIsModified)
+ return;
-void VISU::ScalarMapOnDeformedShape_i::SetScalarIteration(const int theValue){
- myScalarIteration = theValue;
-}
+ VISU::TEntity aEntity = VISU::TEntity(theEntity);
+ VISU::Result_i::TInput* anInput = GetCResult()->GetInput();
+ myScalarField = anInput->GetField(theMeshName, aEntity, theFieldName);
+ VISU::PUnstructuredGridIDMapper anIDMapper =
+ anInput->GetTimeStampOnMesh(theMeshName,
+ aEntity,
+ theFieldName,
+ theTimeStampNumber);
-int VISU::ScalarMapOnDeformedShape_i::GetScalarIteration(){
- return myScalarIteration;
-}
+ vtkUnstructuredGrid* anOutput = anIDMapper->GetUnstructuredGridOutput();
+ if(myScalarMapOnDeformedShapePL && anOutput)
+ myScalarMapOnDeformedShapePL->SetScalars(anOutput);
-CORBA::Long VISU::ScalarMapOnDeformedShape_i::GetScalarLIteration(){
- return CORBA::Long(this->GetScalarIteration());
-}
+ myScalarMeshName = theMeshName;
+ myScalarEntity = theEntity;
+ myScalarFieldName = theFieldName;
+ myScalarTimeStampNumber = theTimeStampNumber;
-void VISU::ScalarMapOnDeformedShape_i::SetScalarEntity(const VISU::TEntity theValue){
- myScalarEntity = theValue;
-}
+ SetTitle(theFieldName);
+ if(!IsRangeFixed() && IsPipeLineExists())
+ GetSpecificPL()->SetSourceRange();
-VISU::TEntity VISU::ScalarMapOnDeformedShape_i::GetScalarEntity(){
- return myScalarEntity;
+ myParamsTime.Modified();
}
-void VISU::ScalarMapOnDeformedShape_i::SetScalarEEntity(const VISU::Entity theValue){
- myScalarEntity = VISU::TEntity(theValue);
-}
-VISU::Entity VISU::ScalarMapOnDeformedShape_i::GetScalarEEntity(){
- return VISU::Entity(myScalarEntity);
+//---------------------------------------------------------------
+char*
+VISU::ScalarMapOnDeformedShape_i
+::GetScalarCMeshName()
+{
+ return CORBA::string_dup(myScalarMeshName.c_str());
}
-const VISU::PField&
+
+//---------------------------------------------------------------
+VISU::Entity
VISU::ScalarMapOnDeformedShape_i
-::GetField() const
-{
- return myScalarField;
+::GetScalarEEntity()
+{
+ return myScalarEntity;
}
-void
+
+//---------------------------------------------------------------
+char*
VISU::ScalarMapOnDeformedShape_i
-::SetMapScale(double theMapScale)
+::GetScalarCFieldName()
{
- myScalarMapOnDeformedShapePL->SetMapScale(theMapScale);
+ return CORBA::string_dup(myScalarFieldName.c_str());
}
-CORBA::Double
+
+//---------------------------------------------------------------
+CORBA::Long
VISU::ScalarMapOnDeformedShape_i
-::GetMin()
+::GetScalarLIteration()
{
- return myScalarMapOnDeformedShapePL->GetScalarRange()[0];
+ return myScalarTimeStampNumber;
}
-CORBA::Double
+
+//----------------------------------------------------------------------------
+VISU::PValForTime
VISU::ScalarMapOnDeformedShape_i
-::GetMax()
-{
- return myScalarMapOnDeformedShapePL->GetScalarRange()[1];
+::GetScalarValForTime() const
+{
+ VISU::TValField& aValField = myScalarField->myValField;
+ PValForTime aValForTime;
+ VISU::TValField::iterator anIter = aValField.find(myScalarTimeStampNumber);
+ if(anIter != aValField.end())
+ aValForTime = anIter->second;
+ return aValForTime;
}
+
+
+//---------------------------------------------------------------
#ifndef VISU_ScalarMapOnDeformedShape_i_HeaderFile
#define VISU_ScalarMapOnDeformedShape_i_HeaderFile
-#include "VISU_PrsMerger_i.hh"
+#include "VISU_ScalarMap_i.hh"
class VISU_ScalarMapOnDeformedShapePL;
-namespace VISU{
-
+namespace VISU
+{
+ //----------------------------------------------------------------------------
//! Class of Scalar Map on Deformed Shape presentation.
class VISU_I_EXPORT ScalarMapOnDeformedShape_i : public virtual POA_VISU::ScalarMapOnDeformedShape,
- public virtual PrsMerger_i
+ public virtual ScalarMap_i
{
static int myNbPresent;
ScalarMapOnDeformedShape_i(const ScalarMapOnDeformedShape_i&);
public:
-
- typedef PrsMerger_i TSuperClass;
-
- explicit
- ScalarMapOnDeformedShape_i(Result_i* theResult,
- bool theAddToStudy);
+ //----------------------------------------------------------------------------
+ typedef ScalarMap_i TSuperClass;
+ typedef VISU::ScalarMapOnDeformedShape TInterface;
+
explicit
- ScalarMapOnDeformedShape_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject);
+ ScalarMapOnDeformedShape_i(EPublishInStudyMode thePublishInStudyModep);
- virtual ~ScalarMapOnDeformedShape_i();
+ virtual
+ ~ScalarMapOnDeformedShape_i();
- virtual VISU::VISUType GetType()
+ virtual
+ VISU::VISUType
+ GetType()
{
return VISU::TSCALARMAPONDEFORMEDSHAPE;
- };
-
- typedef VISU::ScalarMapOnDeformedShape TInterface;
+ }
- virtual void SetScale(CORBA::Double theScale);
- virtual CORBA::Double GetScale();
-
- virtual
+ virtual
void
- SetRange(CORBA::Double theMin, CORBA::Double theMax);
+ SetScale(CORBA::Double theScale);
- virtual CORBA::Boolean IsColored() { return myIsColored; }
- virtual void ShowColored(CORBA::Boolean theColored) { myIsColored = theColored; }
+ virtual
+ CORBA::Double
+ GetScale();
- virtual SALOMEDS::Color GetColor() { return myColor;}
- virtual void SetColor(const SALOMEDS::Color& theColor) { myColor = theColor;}
+ virtual
+ CORBA::Boolean
+ IsColored();
- virtual void SetSourceRange(CORBA::Double theMinRange,CORBA::Double theMaxRange);
-
virtual
- CORBA::Double
- GetMin();
+ void
+ ShowColored(CORBA::Boolean theColored);
virtual
- CORBA::Double
- GetMax();
+ SALOMEDS::Color
+ GetColor();
virtual
void
- SetSourceRange();
-
- virtual CORBA::Double GetSourceRangeMin();
- virtual CORBA::Double GetSourceRangeMax();
+ SetColor(const SALOMEDS::Color& theColor);
virtual
void
SameAs(const Prs3d_i* theOrigin);
- virtual const VISU::PField&
- GetField() const;
-
- VISU_ScalarMapOnDeformedShapePL* GetScalarMapOnDeformedShapePL(){ return myScalarMapOnDeformedShapePL;}
+ VISU_ScalarMapOnDeformedShapePL*
+ GetSpecificPL()
+ {
+ return myScalarMapOnDeformedShapePL;
+ }
protected:
-
+ //! Redefines VISU_ColoredPrs3d_i::SetField
virtual
void
- DoHook();
+ SetField(VISU::PField theField);
- virtual
- const char*
- GetIconName();
+ //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine
+ virtual
+ void
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
- VISU_ScalarMapOnDeformedShapePL *myScalarMapOnDeformedShapePL;
- SALOMEDS::Color myColor;
- bool myIsColored;
- std::string myScalarMeshName;
- std::string myScalarFieldName;
- VISU::TEntity myScalarEntity;
- int myScalarIteration;
- PField myScalarField;
+ //! Redefines VISU_ColoredPrs3d_i::CheckIsPossible
+ virtual
+ bool
+ CheckIsPossible();
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);
+ //! Redefines VISU_ColoredPrs3d_i::IsPossible
+ static
+ size_t
+ IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck);
+
+ //! Redefines VISU_ColoredPrs3d_i::IsPossible
+ virtual
+ Storable*
+ Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber);
- virtual void ToStream(std::ostringstream& theStr);
+ //! Redefines VISU_ColoredPrs3d_i::ToStream
+ virtual
+ void
+ ToStream(std::ostringstream& theStr);
- virtual Storable* Restore(const Storable::TRestoringMap& theMap);
+ //! Redefines VISU_ColoredPrs3d_i::Restore
+ virtual
+ Storable*
+ Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap);
- static Storable* Restore(SALOMEDS::SObject_ptr theSObject,
- const std::string& thePrefix, const Storable::TRestoringMap& theMap);
+ static const std::string myComment;
+
+ virtual
+ const char*
+ GetComment() const;
+
+ virtual
+ QString
+ GenerateName();
+
+ virtual
+ const char*
+ GetIconName();
virtual
+ VISU_Actor*
+ CreateActor();
+
+ virtual
+ void
+ UpdateActor(VISU_Actor* theActor) ;
+
+ virtual
void
- SetMapScale(double theMapScale = 1.0);
+ SetScalarField(const char* theMeshName,
+ const char* theFieldName,
+ CORBA::Long theTimeStampNumber,
+ VISU::Entity theEntity);
+ virtual
+ char*
+ GetScalarCMeshName();
- static const std::string myComment;
- virtual const char* GetComment() const;
- virtual QString GenerateName();
+ virtual
+ VISU::Entity
+ GetScalarEEntity();
- virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
+ virtual
+ char*
+ GetScalarCFieldName();
- virtual void UpdateActor(VISU_Actor* theActor) ;
+ virtual
+ CORBA::Long
+ GetScalarLIteration();
- virtual void SetScalarField(const char* theMeshName,
- const char* theFieldName,
- int theIteration,
- VISU::TEntity theEntity);
-
- virtual void SetScalarField(const char* theMeshName,
- const char* theFieldName,
- CORBA::Long theIteration,
- VISU::Entity theEntity);
-
- virtual void SetScalarFieldName(const char* theName);
- virtual std::string GetScalarFieldName();
- virtual char* GetScalarCFieldName();
- virtual void SetScalarIteration(const int theValue);
- virtual int GetScalarIteration();
- virtual CORBA::Long GetScalarLIteration();
- virtual void SetScalarMeshName(const char* theName);
- virtual std::string GetScalarMeshName();
- virtual char* GetScalarCMeshName();
- virtual void SetScalarEntity(const VISU::TEntity theValue);
- virtual VISU::TEntity GetScalarEntity();
- virtual void SetScalarEEntity(const VISU::Entity theValue);
- virtual VISU::Entity GetScalarEEntity();
+ virtual
+ VISU::PValForTime
+ GetScalarValForTime() const;
+
+ private:
+ VISU_ScalarMapOnDeformedShapePL *myScalarMapOnDeformedShapePL;
+
+ bool myIsColored;
+ SALOMEDS::Color myColor;
+
+ PField myScalarField;
+ std::string myScalarMeshName;
+ std::string myScalarFieldName;
+ VISU::Entity myScalarEntity;
+ CORBA::Long myScalarTimeStampNumber;
};
}
#endif
#include "VISU_ScalarMap_i.hh"
#include "VISU_Result_i.hh"
-#include "VISU_ViewManager_i.hh"
#include "VISU_ScalarMapAct.h"
#include "VISU_ScalarMapPL.hxx"
+#include "VISU_LookupTable.hxx"
+#include "VISU_ScalarBarActor.hxx"
#include "VISU_Convertor.hxx"
#include "SUIT_ResourceMgr.h"
-#include <vtkDataSetMapper.h>
-#include <vtkTextProperty.h>
-
+#include "SUIT_Session.h"
#include "SALOME_Event.hxx"
+#include "SalomeApp_Study.h"
+#include "SalomeApp_Application.h"
-using namespace VISU;
-using namespace std;
+#include <vtkDataSetMapper.h>
+#include <vtkTextProperty.h>
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int INCMEMORY = 4;
-//============================================================================
-int
+//----------------------------------------------------------------------------
+size_t
VISU::ScalarMap_i
::IsPossible(Result_i* theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName, int theIteration, int isMemoryCheck)
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck)
{
+ size_t aResult = 0;
try{
- float aSize = INCMEMORY*
- theResult->GetInput()->GetTimeStampSize(theMeshName,(VISU::TEntity)theEntity,theFieldName,theIteration);
- bool aResult = true;
- if(isMemoryCheck){
- aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
- MESSAGE("ScalarMap_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<aResult);
+ if(theResult){
+ bool anIsEstimated = true;
+ VISU::Result_i::TInput* anInput = theResult->GetInput();
+ size_t aSize = anInput->GetTimeStampOnMeshSize(theMeshName,
+ (VISU::TEntity)theEntity,
+ theFieldName,
+ theTimeStampNumber,
+ anIsEstimated);
+ aResult = 1;
+ if(theIsMemoryCheck){
+ if(anIsEstimated)
+ aSize *= INCMEMORY;
+ aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
+ if(MYDEBUG)
+ MESSAGE("ScalarMap_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;
+ return aResult;
}
//----------------------------------------------------------------------------
-int
-VISU::ScalarMap_i
-::myNbPresent = 0;
+int VISU::ScalarMap_i::myNbPresent = 0;
+//----------------------------------------------------------------------------
QString
VISU::ScalarMap_i
::GenerateName()
return VISU::GenerateName("ScalarMap",myNbPresent++);
}
-const string
-VISU::ScalarMap_i
-::myComment = "SCALARMAP";
+//----------------------------------------------------------------------------
+const string VISU::ScalarMap_i::myComment = "SCALARMAP";
+//----------------------------------------------------------------------------
const char*
VISU::ScalarMap_i
-::GetComment() const {
+::GetComment() const
+{
return myComment.c_str();
}
+//----------------------------------------------------------------------------
+const char*
+VISU::ScalarMap_i
+::GetIconName()
+{
+ if (!IsGroupsUsed())
+ return "ICON_TREE_SCALAR_MAP";
+ else
+ return "ICON_TREE_SCALAR_MAP_GROUPS";
+}
//----------------------------------------------------------------------------
-VISU::ScalarMap_i::
-ScalarMap_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theAddToStudy),
- ColoredPrs3d_i(theResult,theAddToStudy)
-{}
+void
+VISU::ScalarMap_i
+::UpdateIcon()
+{
+ SALOMEDS::SObject_var aSObject = GetSObject();
+ if(CORBA::is_nil(aSObject))
+ return;
+ SALOMEDS::Study_var aStudyDocument = GetStudyDocument();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDocument->NewBuilder();
+
+ // Check if the icon needs to be updated, update if necessary
+ SALOMEDS::GenericAttribute_var anAttr =
+ aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributePixMap");
+ SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
+
+ CORBA::String_var aPixMapName = aPixmap->GetPixMap();
+ if(strcmp(GetIconName(), aPixMapName.in()) != 0)
+ 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()){
+ if(SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSApp)){
+ if(SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy())){
+ if(_PTR(Study) aCStudy = aStudy->studyDS()){
+ if(aStudyDocument->StudyId() == aCStudy->StudyId()){
+ anApp->updateObjectBrowser();
+ break;
+ }
+ }
+ }
+ }
+ ++anIter;
+ }
+}
+
+//----------------------------------------------------------------------------
VISU::ScalarMap_i::
-ScalarMap_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
- ColoredPrs3d_i(theResult,theSObject)
+ScalarMap_i(EPublishInStudyMode thePublishInStudyMode) :
+ ColoredPrs3d_i(thePublishInStudyMode)
{}
+//----------------------------------------------------------------------------
VISU::ScalarMap_i
::~ScalarMap_i()
{}
ScalarMap_i* anOrigin = const_cast<ScalarMap_i*>(aPrs3d);
SetRange(anOrigin->GetMin(), anOrigin->GetMax());
- myIsFixedRange = anOrigin->IsRangeFixed();
+ UseFixedRange(anOrigin->IsRangeFixed());
SetScaling(anOrigin->GetScaling());
+ myGroupNames = anOrigin->GetGroupNames();
+
Update();
}
}
*/
VISU::Storable*
VISU::ScalarMap_i
-::Create(const char* theMeshName,
+::Create(const std::string& theMeshName,
VISU::Entity theEntity,
- const char* theFieldName,
- int theIteration)
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
{
- TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
+ TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
// Scalar Range
int aRangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
- myIsFixedRange = (aRangeType == 1) ? true : false;
-
- if(myIsFixedRange){
+ if(aRangeType == 1){
float aMin = aResourceMgr->doubleValue("VISU", "scalar_range_min", 0);
float aMax = aResourceMgr->doubleValue("VISU", "scalar_range_max", 0);
SetRange(aMin,aMax);
}
+ UseFixedRange((aRangeType == 1) ? true : false);
bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false);
if( isLog )
return this;
}
+//----------------------------------------------------------------------------
+CORBA::Float
+VISU::ScalarMap_i
+::GetMemorySize()
+{
+ return TSuperClass::GetMemorySize();
+}
+
+//----------------------------------------------------------------------------
VISU::Storable*
VISU::ScalarMap_i
-::Restore(const Storable::TRestoringMap& theMap)
+::Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
{
- TSuperClass::Restore(theMap);
+ if(!TSuperClass::Restore(theStudy, theMap))
+ return NULL;
SetScaling(VISU::Scaling(VISU::Storable::FindValue(theMap,"myScaling").toInt()));
float aMax = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble();
SetRange(aMin,aMax);
- myIsFixedRange = VISU::Storable::FindValue(theMap,"myIsFixedRange").toInt();
+ UseFixedRange(VISU::Storable::FindValue(theMap,"myIsFixedRange").toInt());
+
+ QString aGeomNames = VISU::Storable::FindValue(theMap, "myGeomNameList");
+ 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;
}
+//----------------------------------------------------------------------------
void
VISU::ScalarMap_i
::ToStream(std::ostringstream& theStr)
Storable::DataToStream( theStr, "myScalarRange[0]", GetMin() );
Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() );
- Storable::DataToStream( theStr, "myIsFixedRange", myIsFixedRange );
+ Storable::DataToStream( theStr, "myIsFixedRange", IsRangeFixed() );
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());
}
TSuperClass::SetBarOrientation(theOrientation);
}
+//----------------------------------------------------------------------------
VISU::ScalarMap::Orientation
VISU::ScalarMap_i
::GetBarOrientation()
return TSuperClass::GetBarOrientation();
}
+//----------------------------------------------------------------------------
VISU::Scaling
VISU::ScalarMap_i
::GetScaling()
{
- return VISU::Scaling(myScalarMapPL->GetScaling());
+ return VISU::Scaling(GetSpecificPL()->GetScaling());
}
+//----------------------------------------------------------------------------
void
VISU::ScalarMap_i
::SetScaling(VISU::Scaling theScaling)
{
- myScalarMapPL->SetScaling(theScaling);
+ GetSpecificPL()->SetScaling(theScaling);
}
+//----------------------------------------------------------------------------
void
VISU::ScalarMap_i
::SetRange(CORBA::Double theMin, CORBA::Double theMax)
{
- if(theMin > theMax)
- return;
+ TSuperClass::SetRange(theMin, theMax);
+}
- struct TEvent: public SALOME_Event {
- VISU_ScalarMapPL* myMap;
- vtkFloatingPointType myRange[2];
- TEvent( VISU_ScalarMapPL* theMap, const vtkFloatingPointType& theMin , const vtkFloatingPointType& theMax)
- :myMap(theMap)
- {
- myRange[0] = theMin;
- myRange[1] = theMax;
- }
+//----------------------------------------------------------------------------
+void
+VISU::ScalarMap_i
+::SetSourceRange()
+{
+ TSuperClass::SetSourceRange();
+}
+
+//----------------------------------------------------------------------------
+const VISU::ScalarMap_i::TGroupNames&
+VISU::ScalarMap_i
+::GetGroupNames()
+{
+ return myGroupNames;
+}
+
+//----------------------------------------------------------------------------
+bool
+VISU::ScalarMap_i
+::IsGroupsUsed()
+{
+ return !myGroupNames.empty();
+}
- virtual
- void
- Execute()
- {
- myMap->SetScalarRange(myRange);
+//----------------------------------------------------------------------------
+void
+VISU::ScalarMap_i
+::SetSourceGeometry()
+{
+ int aNbGroups = myGroupNames.size();
+ if(aNbGroups != 0){
+ GetSpecificPL()->SetSourceGeometry();
+ myGroupNames.clear();
+ UpdateIcon();
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::ScalarMap_i
+::AddMeshOnGroup(const char* theGroupName)
+{
+ VISU::Result_i::TInput* 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();
}
- };
+ }
+}
+
- ProcessVoidEvent(new TEvent(myScalarMapPL, theMin, theMax));
- myIsFixedRange = true;
+//----------------------------------------------------------------------------
+void
+VISU::ScalarMap_i
+::RemoveAllGeom()
+{
+ int aNbGroups = myGroupNames.size();
+ GetSpecificPL()->ClearGeometry();
+ myGroupNames.clear();
+ if(aNbGroups != 0)
+ UpdateIcon();
}
//----------------------------------------------------------------------------
void
VISU::ScalarMap_i
-::DoSetInput(Result_i* theResult)
+::DoSetInput(bool theIsInitilizePipe, bool theReInit)
{
- VISU::Result_i::TInput* anInput = theResult->GetInput();
+ VISU::Result_i::TInput* anInput = GetCResult()->GetInput();
if(!anInput)
- throw std::runtime_error("Mesh_i::Build - theResult->GetInput() == NULL !!!");
+ throw std::runtime_error("Mesh_i::Build - GetCResult()->GetInput() == NULL !!!");
- myField = anInput->GetField(myMeshName,myEntity,myFieldName);
- if(!myField)
+ SetField(anInput->GetField(GetCMeshName(),GetTEntity(),GetCFieldName()));
+ if(!GetField())
throw std::runtime_error("There is no Field with the parameters !!!");
-
- VISU::PIDMapper anIDMapper =
- anInput->GetTimeStampOnMesh(myMeshName,myEntity,myFieldName,myIteration);
+
+ VISU::PUnstructuredGridIDMapper anIDMapper =
+ anInput->GetTimeStampOnMesh(GetCMeshName(),GetTEntity(),GetCFieldName(),GetTimeStampNumber());
if(!anIDMapper)
throw std::runtime_error("There is no TimeStamp with the parameters !!!");
- myScalarMapPL->SetIDMapper(anIDMapper);
- // mkr : 23.11.2006 - PAL13908 - save animation range if range is fixed -->
- if ( myIsFixedRange )
- myScalarMapPL->SetScalarMode(0);
- else
- myScalarMapPL->Init();
- // mkr : 23.11.2006 <--
- myScalarMapPL->Build();
+ GetSpecificPL()->SetUnstructuredGridIDMapper(anIDMapper);
+ if(theIsInitilizePipe){
+ GetSpecificPL()->Init();
+ }
+
+ // To update scalar range according to the new input
+ if(!IsTimeStampFixed() && !IsRangeFixed() || theReInit)
+ SetSourceRange();
}
-void
+
+//----------------------------------------------------------------------------
+bool
VISU::ScalarMap_i
-::Update()
+::CheckIsPossible()
{
- TSuperClass::Update();
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
}
//----------------------------------------------------------------------------
void
VISU::ScalarMap_i
-::SetMapScale(double theMapScale)
+::CreatePipeLine(VISU_PipeLine* thePipeLine)
{
- myScalarMapPL->SetMapScale(theMapScale);
-}
-
-bool
-VISU::ScalarMap_i
-::IsRangeFixed()
-{
- return myIsFixedRange;
+ if(MYDEBUG) MESSAGE("ScalarMap_i::CreatePipeLine() - "<<thePipeLine);
+ if(!thePipeLine){
+ myScalarMapPL = VISU_ScalarMapPL::New();
+ myScalarMapPL->GetMapper()->SetScalarVisibility(1);
+ }else
+ myScalarMapPL = dynamic_cast<VISU_ScalarMapPL*>(thePipeLine);
+
+ TSuperClass::CreatePipeLine(myScalarMapPL);
}
+//----------------------------------------------------------------------------
void
VISU::ScalarMap_i
-::SetSourceRange()
+::SetMapScale(double theMapScale)
{
- myScalarMapPL->SetSourceRange();
- myIsFixedRange = false;
+ GetSpecificPL()->SetMapScale(theMapScale);
}
//----------------------------------------------------------------------------
VISU_Actor*
VISU::ScalarMap_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO, bool toSupressShrinking)
+::CreateActor(bool toSupressShrinking)
{
VISU_ScalarMapAct* anActor = VISU_ScalarMapAct::New();
try{
- TSuperClass::CreateActor(anActor,theIO);
+ TSuperClass::CreateActor(anActor);
anActor->SetBarVisibility(true);
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
int aDispMode = aResourceMgr->integerValue("VISU", "scalar_map_represent", 2);
return anActor;
}
+//----------------------------------------------------------------------------
VISU_Actor*
VISU::ScalarMap_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+::CreateActor()
{
- return CreateActor(theIO, false);
+ return CreateActor(false);
}
+//----------------------------------------------------------------------------
void
VISU::ScalarMap_i
::UpdateActor(VISU_Actor* theActor)
{
if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
VISU_ScalarBarActor *aScalarBar = anActor->GetScalarBar();
- aScalarBar->SetLookupTable(myScalarMapPL->GetBarTable());
- aScalarBar->SetTitle(GetScalarBarTitle().c_str()); // mkr : IPAL14030
- aScalarBar->SetOrientation(myOrientation);
+ aScalarBar->SetLookupTable(GetSpecificPL()->GetBarTable());
+ aScalarBar->SetTitle(GetScalarBarTitle().c_str());
+ aScalarBar->SetOrientation(GetBarOrientation());
aScalarBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
- aScalarBar->GetPositionCoordinate()->SetValue(myPosition[0],myPosition[1]);
- aScalarBar->SetWidth(myWidth);
- aScalarBar->SetHeight(myHeight);
- aScalarBar->SetNumberOfLabels(myNumberOfLabels);
+ aScalarBar->GetPositionCoordinate()->SetValue(GetPosX(),GetPosY());
+ aScalarBar->SetWidth(GetWidth());
+ aScalarBar->SetHeight(GetHeight());
+ aScalarBar->SetNumberOfLabels(GetLabels());
+
+ vtkFloatingPointType anRGB[3];
vtkTextProperty* aTitleProp = aScalarBar->GetTitleTextProperty();
- aTitleProp->SetFontFamily(myTitFontType);
- aTitleProp->SetColor(myTitleColor[0],myTitleColor[1],myTitleColor[2]);
- (myIsBoldTitle)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
- (myIsItalicTitle)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
- (myIsShadowTitle)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
+ aTitleProp->SetFontFamily(GetTitFontType());
+
+ GetTitleColor(&anRGB[0],&anRGB[1],&anRGB[2]);
+ aTitleProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+
+ IsBoldTitle()? aTitleProp->BoldOn() : aTitleProp->BoldOff();
+ IsItalicTitle()? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
+ IsShadowTitle()? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
vtkTextProperty* aLabelProp = aScalarBar->GetLabelTextProperty();
- aLabelProp->SetFontFamily(myLblFontType);
- aLabelProp->SetColor(myLabelColor[0],myLabelColor[1],myLabelColor[2]);
- (myIsBoldLabel)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
- (myIsItalicLabel)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
- (myIsShadowLabel)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
+ aLabelProp->SetFontFamily(GetLblFontType());
+
+ GetLabelColor(&anRGB[0],&anRGB[1],&anRGB[2]);
+ aLabelProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+
+ IsBoldLabel()? aLabelProp->BoldOn() : aLabelProp->BoldOff();
+ IsItalicLabel()? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
+ IsShadowLabel()? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
aScalarBar->Modified();
}
#include "VISU_ColoredPrs3d_i.hh"
+#include <string>
+#include <set>
+
+class VISU_ScalarMapPL;
namespace VISU
{
public:
//----------------------------------------------------------------------------
typedef ColoredPrs3d_i TSuperClass;
+ typedef VISU::ScalarMap TInterface;
explicit
- ScalarMap_i(Result_i* theResult,
- bool theAddToStudy);
- explicit
- ScalarMap_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject);
+ ScalarMap_i(EPublishInStudyMode thePublishInStudyModep);
+
virtual
~ScalarMap_i();
return VISU::TSCALARMAP;
}
+ //----------------------------------------------------------------------------
+ //! Gets memory size actually used by the presentation (Mb).
+ virtual
+ CORBA::Float
+ GetMemorySize();
+
+ //----------------------------------------------------------------------------
virtual
VISU::Scaling
GetScaling();
void
SetRange(CORBA::Double theMin, CORBA::Double theMax);
+ virtual
+ void
+ SetSourceRange();
+
// To provide backward compatibility
virtual
void
VISU::ScalarMap::Orientation
GetBarOrientation();
- typedef VISU::ScalarMap TInterface;
+ //----------------------------------------------------------------------------
+ //! 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();
+ //----------------------------------------------------------------------------
+ VISU_ScalarMapPL*
+ GetSpecificPL() const
+ {
+ return myScalarMapPL;
+ }
+
protected:
+ //! Redefines VISU_ColoredPrs3d_i::DoSetInput
virtual
void
- DoSetInput(Result_i* theResult);
+ DoSetInput(bool theIsInitilizePipe, bool theReInit);
+
+ //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine
+ virtual
+ void
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
+
+ //! Redefines VISU_ColoredPrs3d_i::CheckIsPossible
+ virtual
+ bool
+ CheckIsPossible();
public:
+ /*!
+ Checks staticaly, whether it is possible to create presentation
+ with the given basic parameters or not.
+ */
static
- int
+ size_t
IsPossible(Result_i* theResult,
- const char* theMeshName,
+ const std::string& theMeshName,
VISU::Entity theEntity,
- const char* theFieldName,
- int theIteration,
- int isMemoryCheck = true);
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck);
+
+ //! Redefines VISU_ColoredPrs3d_i::Create
virtual
Storable*
- Create(const char* theMeshName,
+ Create(const std::string& theMeshName,
VISU::Entity theEntity,
- const char* theFieldName,
- int theIteration);
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber);
virtual
void
QString
GenerateName();
- virtual
- Storable*
- Restore(const Storable::TRestoringMap& theMap);
+ virtual
+ const char*
+ GetIconName();
+
+ void
+ UpdateIcon();
- static
+ virtual
Storable*
- Restore(SALOMEDS::SObject_ptr theSObject,
- const std::string& thePrefix,
+ Restore(SALOMEDS::Study_ptr theStudy,
const Storable::TRestoringMap& theMap);
- virtual
- void
- Update() ;
-
virtual
void
SetMapScale(double theMapScale = 1.0);
- virtual
- bool
- IsRangeFixed();
-
- virtual
- void
- SetSourceRange();
-
virtual
void
SameAs(const Prs3d_i* theOrigin);
virtual
VISU_Actor*
- CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
+ CreateActor();
virtual
VISU_Actor*
- CreateActor(const Handle(SALOME_InteractiveObject)& theIO, bool toSupressShrinking);
+ CreateActor(bool toSupressShrinking);
virtual
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;
};
}
#include <vtkAppendFilter.h>
#include <vtkUnstructuredGrid.h>
-using namespace VISU;
-using namespace std;
-
#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
#endif
-int VISU::StreamLines_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration, int isMemoryCheck)
+
+//---------------------------------------------------------------
+size_t
+VISU::StreamLines_i
+::IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck)
{
try{
- if(!TSuperClass::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,false))
+ if(!VISU::ScalarMap_i::IsPossible(theResult, theMeshName, theEntity, theFieldName, theTimeStampNumber, false))
return 0;
- VISU::PIDMapper anIDMapper =
- theResult->GetInput()->GetTimeStampOnMesh(theMeshName,VISU::TEntity(theEntity),theFieldName,theIteration);
- VISU::TVTKOutput* aDataSet = anIDMapper->GetVTKOutput();
- bool aResult = VISU_StreamLinesPL::IsPossible(aDataSet);
+ VISU::Result_i::TInput* anInput = theResult->GetInput();
+ VISU::PUnstructuredGridIDMapper anIDMapper =
+ anInput->GetTimeStampOnMesh(theMeshName,
+ VISU::TEntity(theEntity),
+ theFieldName,
+ theTimeStampNumber);
+
+ vtkUnstructuredGrid* aDataSet = anIDMapper->GetUnstructuredGridOutput();
+ size_t aResult = VISU_StreamLinesPL::IsPossible(aDataSet);
MESSAGE("StreamLines_i::IsPossible - aResult = "<<aResult);
return aResult;
}catch(std::exception& exc){
return 0;
}
-
+//---------------------------------------------------------------
int VISU::StreamLines_i::myNbPresent = 0;
-QString VISU::StreamLines_i::GenerateName() { return VISU::GenerateName("StreamLines",myNbPresent++);}
+//---------------------------------------------------------------
+QString
+VISU::StreamLines_i
+::GenerateName()
+{
+ return VISU::GenerateName("StreamLines",myNbPresent++);
+}
+//---------------------------------------------------------------
const string VISU::StreamLines_i::myComment = "STREAMLINES";
-const char* VISU::StreamLines_i::GetComment() const { return myComment.c_str();}
-
-
-VISU::StreamLines_i::
-StreamLines_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theAddToStudy),
- ColoredPrs3d_i(theResult,theAddToStudy),
- ScalarMap_i(theResult,theAddToStudy),
- PrsMerger_i(theResult,theAddToStudy),
- DeformedShape_i(theResult,theAddToStudy),
- myStreamLinesPL(NULL),
- myAppendFilter(vtkAppendFilter::New())
-{
+
+//---------------------------------------------------------------
+const char*
+VISU::StreamLines_i
+::GetComment() const
+{
+ return myComment.c_str();
}
+//---------------------------------------------------------------
+const char*
+VISU::StreamLines_i
+::GetIconName()
+{
+ if (!IsGroupsUsed())
+ return "ICON_TREE_STREAM_LINES";
+ else
+ return "ICON_TREE_STREAM_LINES_GROUPS";
+}
-VISU::StreamLines_i::
-StreamLines_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
- ColoredPrs3d_i(theResult,theSObject),
- ScalarMap_i(theResult,theSObject),
- PrsMerger_i(theResult,theSObject),
- DeformedShape_i(theResult,theSObject),
+//---------------------------------------------------------------
+VISU::StreamLines_i
+::StreamLines_i(EPublishInStudyMode thePublishInStudyMode) :
+ ColoredPrs3d_i(thePublishInStudyMode),
+ ScalarMap_i(thePublishInStudyMode),
+ DeformedShape_i(thePublishInStudyMode),
myStreamLinesPL(NULL),
myAppendFilter(vtkAppendFilter::New())
-{
-}
+{}
-void VISU::StreamLines_i::SameAs(const Prs3d_i* theOrigin)
+//---------------------------------------------------------------
+void
+VISU::StreamLines_i
+::SameAs(const Prs3d_i* theOrigin)
{
TSuperClass::SameAs(theOrigin);
}
-VISU::Storable* VISU::StreamLines_i::Create(const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration)
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::StreamLines_i
+::Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
{
- return DeformedShape_i::Create(theMeshName,theEntity,theFieldName,theIteration);
+ return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
}
-VISU::Storable* VISU::StreamLines_i::Restore(const Storable::TRestoringMap& theMap)
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::StreamLines_i
+::Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
{
- TSuperClass::Restore(theMap);
+ if(!TSuperClass::Restore(theStudy, theMap))
+ return NULL;
double anIntegrationStep = VISU::Storable::FindValue(theMap,"myIntegrationStep").toDouble();
double aPropagationTime = VISU::Storable::FindValue(theMap,"myPropagationTime").toDouble();
}
-void VISU::StreamLines_i::ToStream(std::ostringstream& theStr){
- DeformedShape_i::ToStream(theStr);
+//---------------------------------------------------------------
+void
+VISU::StreamLines_i
+::ToStream(std::ostringstream& theStr)
+{
+ TSuperClass::ToStream(theStr);
Storable::DataToStream( theStr, "myIntegrationStep", GetIntegrationStep());
Storable::DataToStream( theStr, "myPropagationTime", GetPropagationTime());
}
-VISU::StreamLines_i::~StreamLines_i(){
+//---------------------------------------------------------------
+VISU::StreamLines_i
+::~StreamLines_i()
+{
if(MYDEBUG) MESSAGE("StreamLines_i::~StreamLines_i()");
- // commented: porting to vtk 5.0
- //myAppendFilter->UnRegisterAllOutputs();
myAppendFilter->Delete();
}
-CORBA::Boolean
-VISU::StreamLines_i::SetParams(CORBA::Double theIntStep,
- CORBA::Double thePropogationTime,
- CORBA::Double theStepLength,
- VISU::Prs3d_ptr thePrs3d,
- CORBA::Double thePercents,
- VISU::StreamLines::Direction theDirection)
-{
- VISU::Prs3d_i* aPrs3di = NULL;
+//---------------------------------------------------------------
+CORBA::Boolean
+VISU::StreamLines_i
+::SetParams(CORBA::Double theIntStep,
+ CORBA::Double thePropogationTime,
+ CORBA::Double theStepLength,
+ VISU::Prs3d_ptr thePrs3d,
+ CORBA::Double thePercents,
+ VISU::StreamLines::Direction theDirection)
+{
+ VISU::Prs3d_i* aPrs3d = NULL;
vtkPointSet* aSource = NULL;
- if(!thePrs3d->_is_nil())
- if((aPrs3di = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(thePrs3d).in()))){
- for(int i = myAppendFilter->GetNumberOfInputConnections(0)-1; i >= 0; i--)
- myAppendFilter->RemoveInput(myAppendFilter->GetInput(i));
- myAppendFilter->AddInput(aPrs3di->GetPL()->GetMapper()->GetInput());
+ if (!thePrs3d->_is_nil())
+ if ((aPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(thePrs3d).in()))) {
+ myAppendFilter->RemoveAllInputs();
+ myAppendFilter->AddInput(aPrs3d->GetPipeLine()->GetMapper()->GetInput());
aSource = myAppendFilter->GetOutput();
}
- int isAccepted = myStreamLinesPL->SetParams(theIntStep,
- thePropogationTime,
- theStepLength,
- aSource,
- thePercents,
- theDirection,
- 1);
- if(isAccepted == 1)
- SetSource(aPrs3di);
- return isAccepted == 1;
+ size_t anIsAccepted = myStreamLinesPL->SetParams(theIntStep,
+ thePropogationTime,
+ theStepLength,
+ aSource,
+ thePercents,
+ theDirection);
+ if (anIsAccepted)
+ SetSource(aPrs3d);
+ return anIsAccepted;
}
-void VISU::StreamLines_i::SetSource(VISU::Prs3d_ptr thePrs3d){
+//---------------------------------------------------------------
+void
+VISU::StreamLines_i
+::SetSource(VISU::Prs3d_ptr thePrs3d)
+{
if(!thePrs3d->_is_nil()){
VISU::Prs3d_i* aPrs3di = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(thePrs3d).in());
SetSource(aPrs3di);
}
}
-void VISU::StreamLines_i::SetSource(VISU::Prs3d_i* thePrs3d){
+
+//---------------------------------------------------------------
+void
+VISU::StreamLines_i
+::SetSource(VISU::Prs3d_i* thePrs3d)
+{
mySourceEntry = "";
if(thePrs3d){
SALOMEDS::SObject_var aSObject = thePrs3d->GetSObject();
CORBA::String_var aString = aSObject->GetID();
mySourceEntry = aString.in();
+ myParamsTime.Modified();
}
}
-void VISU::StreamLines_i::SetSource(){
- if(!myStreamLinesPL->GetSource() && mySourceEntry == "") return;
- if(myStreamLinesPL->GetSource() == myAppendFilter->GetOutput()) return;
+
+//---------------------------------------------------------------
+void
+VISU::StreamLines_i
+::SetSource()
+{
+ if(!myStreamLinesPL->GetSource() && mySourceEntry == "")
+ return;
+ if(myStreamLinesPL->GetSource() == myAppendFilter->GetOutput())
+ return;
VISU::Prs3d_var aPrs3d = GetSource();
SetParams(GetIntegrationStep(),
GetPropagationTime(),
}
-CORBA::Double VISU::StreamLines_i::GetIntegrationStep() {
+//---------------------------------------------------------------
+CORBA::Double
+VISU::StreamLines_i
+::GetIntegrationStep()
+{
return myStreamLinesPL->GetIntegrationStep();
}
-CORBA::Double VISU::StreamLines_i::GetPropagationTime() {
+//---------------------------------------------------------------
+CORBA::Double
+VISU::StreamLines_i
+::GetPropagationTime()
+{
return myStreamLinesPL->GetPropagationTime();
}
-CORBA::Double VISU::StreamLines_i::GetStepLength() {
+//---------------------------------------------------------------
+CORBA::Double
+VISU::StreamLines_i
+::GetStepLength()
+{
return myStreamLinesPL->GetStepLength();
}
-VISU::StreamLines::Direction VISU::StreamLines_i::GetDirection() {
+//---------------------------------------------------------------
+VISU::StreamLines::Direction
+VISU::StreamLines_i
+::GetDirection()
+{
return VISU::StreamLines::Direction(myStreamLinesPL->GetDirection());
}
-VISU::Prs3d_ptr VISU::StreamLines_i::GetSource(){
+//---------------------------------------------------------------
+VISU::Prs3d_ptr
+VISU::StreamLines_i
+::GetSource()
+{
VISU::Prs3d_var aPrs3d;
if(MYDEBUG) MESSAGE("StreamLines_i::GetSource() mySourceEntry = '"<<mySourceEntry<<"'");
if(mySourceEntry != ""){
- SALOMEDS::SObject_var aSObject = myStudy->FindObjectID(mySourceEntry.c_str());
+ SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(mySourceEntry.c_str());
CORBA::Object_var anObj = SObjectToObject(aSObject);
if(!CORBA::is_nil(anObj)) aPrs3d = VISU::Prs3d::_narrow(anObj);
}
return aPrs3d._retn();
}
-CORBA::Double VISU::StreamLines_i::GetUsedPoints() {
+//---------------------------------------------------------------
+CORBA::Double
+VISU::StreamLines_i
+::GetUsedPoints()
+{
return myStreamLinesPL->GetUsedPoints();
}
-void VISU::StreamLines_i::DoHook(){
- if(!myPipeLine) myPipeLine = VISU_StreamLinesPL::New();
- myStreamLinesPL = dynamic_cast<VISU_StreamLinesPL*>(myPipeLine);
+//---------------------------------------------------------------
+void
+VISU::StreamLines_i
+::CreatePipeLine(VISU_PipeLine* thePipeLine)
+{
+ if(!thePipeLine){
+ myStreamLinesPL = VISU_StreamLinesPL::New();
+ }else
+ myStreamLinesPL = dynamic_cast<VISU_StreamLinesPL*>(thePipeLine);
- DeformedShape_i::DoHook();
+ TSuperClass::CreatePipeLine(myStreamLinesPL);
}
-const char*
+
+//----------------------------------------------------------------------------
+bool
VISU::StreamLines_i
-::GetIconName()
+::CheckIsPossible()
{
- if (!GetNumberOfGeom())
- return "ICON_TREE_STREAM_LINES";
- else
- return "ICON_TREE_STREAM_LINES_GROUPS";
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
}
-void VISU::StreamLines_i::Update() {
+//---------------------------------------------------------------
+void
+VISU::StreamLines_i
+::Update()
+{
SetSource();
- VISU::DeformedShape_i::Update();
+ TSuperClass::Update();
}
+//---------------------------------------------------------------
VISU_Actor*
VISU::StreamLines_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+::CreateActor()
{
- if(VISU_Actor* anActor = VISU::DeformedShape_i::CreateActor(theIO, true)){
+ if(VISU_Actor* anActor = TSuperClass::CreateActor(true)){
anActor->SetVTKMapping(true);
SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
int aDispMode = aResourceMgr->integerValue("VISU", "stream_lines_represent", 1);
}
-void VISU::StreamLines_i::UpdateActor(VISU_Actor* theActor) {
- VISU::DeformedShape_i::UpdateActor(theActor);
+//---------------------------------------------------------------
+void
+VISU::StreamLines_i
+::UpdateActor(VISU_Actor* theActor)
+{
+ TSuperClass::UpdateActor(theActor);
}
class VISU_StreamLinesPL;
class vtkAppendFilter;
-namespace VISU{
+namespace VISU
+{
+ //----------------------------------------------------------------------------
class VISU_I_EXPORT StreamLines_i : public virtual POA_VISU::StreamLines,
- public virtual DeformedShape_i
+ public virtual DeformedShape_i
{
static int myNbPresent;
StreamLines_i(const StreamLines_i&);
public:
+ //----------------------------------------------------------------------------
typedef DeformedShape_i TSuperClass;
+ typedef VISU::StreamLines TInterface;
explicit
- StreamLines_i(Result_i* theResult,
- bool theAddToStudy);
- explicit
- StreamLines_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject);
- virtual void SameAs(const Prs3d_i* theOriginal);
- virtual ~StreamLines_i();
-
- virtual VISU::VISUType GetType() { return VISU::TSTREAMLINES;}
-
- virtual CORBA::Boolean SetParams(CORBA::Double theIntStep,
- CORBA::Double thePropogationTime,
- CORBA::Double theStepLength,
- VISU::Prs3d_ptr thePrs3d,
- CORBA::Double thePercents,
- VISU::StreamLines::Direction theDirection);
- virtual CORBA::Double GetIntegrationStep();
- virtual CORBA::Double GetPropagationTime();
- virtual CORBA::Double GetStepLength();
- virtual CORBA::Double GetUsedPoints();
- virtual VISU::Prs3d_ptr GetSource();
- virtual VISU::StreamLines::Direction GetDirection();
+ StreamLines_i(EPublishInStudyMode thePublishInStudyModep);
+
+ virtual
+ void
+ SameAs(const Prs3d_i* theOriginal);
+
+ virtual
+ ~StreamLines_i();
+
+ virtual
+ VISU::VISUType GetType()
+ {
+ return VISU::TSTREAMLINES;
+ }
+
+ virtual
+ CORBA::Boolean
+ SetParams(CORBA::Double theIntStep,
+ CORBA::Double thePropogationTime,
+ CORBA::Double theStepLength,
+ VISU::Prs3d_ptr thePrs3d,
+ CORBA::Double thePercents,
+ VISU::StreamLines::Direction theDirection);
+
+ virtual
+ CORBA::Double
+ GetIntegrationStep();
+
+ virtual
+ CORBA::Double
+ GetPropagationTime();
+
+ virtual
+ CORBA::Double
+ GetStepLength();
+
+ virtual
+ CORBA::Double
+ GetUsedPoints();
+
+ virtual
+ VISU::Prs3d_ptr
+ GetSource();
+
+ virtual
+ VISU::StreamLines::Direction
+ GetDirection();
+
+ VISU_StreamLinesPL*
+ GetSpecificPL() const
+ {
+ return myStreamLinesPL;
+ }
+
+ protected:
+ //! Extends VISU_ColoredPrs3d_i::CreatePipeLine
+ virtual
+ void
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
- typedef VISU::StreamLines TInterface;
- VISU_StreamLinesPL* GetStreamLinesPL(){ return myStreamLinesPL;}
+ //! Extends VISU_ColoredPrs3d_i::CheckIsPossible
+ virtual
+ bool
+ CheckIsPossible();
- protected:
- virtual void DoHook();
+ virtual
+ void
+ SetSource(VISU::Prs3d_ptr thePrs3d);
- virtual const char* GetIconName();
-
- virtual void SetSource(VISU::Prs3d_ptr thePrs3d);
- virtual void SetSource(VISU::Prs3d_i* thePrs3d);
- virtual void SetSource();
+ virtual
+ void
+ SetSource(VISU::Prs3d_i* thePrs3d);
+
+ virtual
+ void
+ SetSource();
VISU_StreamLinesPL* myStreamLinesPL;
vtkAppendFilter* myAppendFilter;
std::string mySourceEntry;
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);
+ //! Extends VISU_ColoredPrs3d_i::IsPossible
+ static
+ size_t
+ IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck);
+
+ //! Extends VISU_ColoredPrs3d_i::Create
+ virtual
+ Storable*
+ Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber);
+
+ //! Extends VISU_ColoredPrs3d_i::ToStream
+ virtual
+ void
+ ToStream(std::ostringstream& theStr);
static const std::string myComment;
- virtual const char* GetComment() const;
- virtual QString GenerateName();
- virtual Storable* Restore(const Storable::TRestoringMap& theMap);
+ virtual
+ const char*
+ GetComment() const;
+
+ virtual
+ QString
+ GenerateName();
- virtual void Update();
+ virtual
+ const char*
+ GetIconName();
+ //! Extends VISU_ColoredPrs3d_i::Restore
virtual
- VISU_Actor*
- CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
+ Storable*
+ Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap);
- virtual void UpdateActor(VISU_Actor* theActor);
+ //! Extends VISU_ColoredPrs3d_i::Update
+ virtual
+ void
+ Update();
- virtual QString GetSourceEntry() { return QString(mySourceEntry.c_str()); }
+ //! Extends VISU_ColoredPrs3d_i::CreateActor
+ virtual
+ VISU_Actor*
+ CreateActor();
+
+ //! Extends VISU_ColoredPrs3d_i::UpdateActor
+ virtual
+ void
+ UpdateActor(VISU_Actor* theActor);
+
+ virtual
+ QString
+ GetSourceEntry()
+ {
+ return QString(mySourceEntry.c_str());
+ }
};
}
{
MESSAGE("Table_i::~Table_i");
}
+
+//----------------------------------------------------------------------------
+void
+VISU::Table_i
+::SetTitle( const char* theTitle )
+{
+ SetName( theTitle, true );
+}
+
+//----------------------------------------------------------------------------
+char*
+VISU::Table_i
+::GetTitle()
+{
+ return CORBA::string_dup( GetName().c_str() );
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Table_i
+::SetOrientation( VISU::Table::Orientation theOrientation )
+{
+ myOrientation = theOrientation;
+}
+
+//----------------------------------------------------------------------------
+VISU::Table::Orientation
+VISU::Table_i
+::GetOrientation()
+{
+ return myOrientation;
+}
+
+//----------------------------------------------------------------------------
+SALOMEDS::SObject_var
+VISU::Table_i
+::GetSObject() const
+{
+ return mySObj;
+}
+
+//----------------------------------------------------------------------------
+char*
+VISU::Table_i
+::GetObjectEntry()
+{
+ return CORBA::string_dup( mySObj->GetID() );
+}
+
+//----------------------------------------------------------------------------
/*!
Gets number of rows in table
*/
CORBA::Long VISU::Table_i::GetNbRows()
{
SALOMEDS::SObject_var SO = mySObj;
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
if ( !SO->_is_nil() ) {
SALOMEDS::GenericAttribute_var anAttr;
if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
CORBA::Long VISU::Table_i::GetNbColumns()
{
SALOMEDS::SObject_var SO = mySObj;
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
if ( !SO->_is_nil() ) {
SALOMEDS::GenericAttribute_var anAttr;
if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
VISU::Storable* VISU::Table_i::Create()
{
// generate name ...
- myName = GetTableTitle();
+ SetName(GetTableTitle(), false);
// mpv (PAL 5357): if name attribute already exist at this label, use it as name of table
- if ( myName == "" )
+ if ( GetName() == "" )
if ( !mySObj->_is_nil() ) {
CutLines_i* pCutLines = NULL;
CORBA::Object_var anObj = SObjectToObject(mySObj);
pCutLines = dynamic_cast<CutLines_i*>(GetServant(aCutLines).in());
}
if (!pCutLines)
- if (mySObj->GetName()) myName = mySObj->GetName();
+ if (mySObj->GetName()) SetName(mySObj->GetName(), false);
}
- if ( myName == "" )
- myName = GenerateName();
+ if ( GetName() == "" )
+ SetName(GenerateName(), false);
// ... and build the object
return Build( false );
}
if(!aCutLines->_is_nil())
pCutLines = dynamic_cast<CutLines_i*>(GetServant(aCutLines).in());
}
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
SALOMEDS::GenericAttribute_var anAttr;
// look for component
if ( !theRestoring ) {
- SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( myStudy );
+ SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() );
// create SObject and set attributes
QString aComment;
if(pCutLines)
}
}
- string anEntry = CreateAttributes( myStudy,
+ string anEntry = CreateAttributes( GetStudyDocument(),
SO->GetID(),//SComponent->GetID(),
- "",
+ "ICON_TREE_TABLE",
GetID(),
GetName(),
"",
aComment.latin1(),
pCutLines );
// create SObject referenced to real table object
- mySObj = SALOMEDS::SObject::_duplicate(myStudy->FindObjectID( anEntry.c_str() ));
+ mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID( anEntry.c_str() ));
if(pCutLines) {
pCutLines->BuildTableOfReal(mySObj);
}
//Builder->Addreference( refSO, SO );
}
- // Set icon
- SALOMEDS::AttributePixMap_var aPixmap;
-
- anAttr = Builder->FindOrCreateAttribute( mySObj, "AttributePixMap" );
- aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
- aPixmap->SetPixMap("ICON_TREE_TABLE");
-
return this;
}
return NULL;
VISU::Storable* VISU::Table_i::Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO)
{
if(MYDEBUG) MESSAGE(GetComment());
- myName = (const char*)(VISU::Storable::FindValue(theMap,"myName"));
- myTitle = (const char*)(VISU::Storable::FindValue(theMap,"myTitle"));
+ SetName(VISU::Storable::FindValue(theMap,"myName").latin1(), false);
+ myTitle = VISU::Storable::FindValue(theMap,"myTitle").latin1();
myOrientation = ( VISU::Table::Orientation )( VISU::Storable::FindValue(theMap,"myOrientation").toInt() );
mySObj = SALOMEDS::SObject::_duplicate(SO);
return Build( true );
*/
void VISU::Table_i::ToStream( std::ostringstream& theStr )
{
- Storable::DataToStream( theStr, "myName", myName.c_str() );
+ Storable::DataToStream( theStr, "myName", GetName().c_str() );
Storable::DataToStream( theStr, "myTitle", myTitle.c_str() );
Storable::DataToStream( theStr, "myOrientation", myOrientation );
}
const char* VISU::Table_i::GetTableTitle()
{
SALOMEDS::SObject_var SO = mySObj;
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeTableOfInteger_var anInt;
SALOMEDS::AttributeTableOfReal_var aReal;
{
MESSAGE("Curve_i::~Curve_i");
}
+
+//----------------------------------------------------------------------------
+void
+VISU::Curve_i
+::SetTitle( const char* theTitle )
+{
+ SetName( theTitle, true );
+}
+
+//----------------------------------------------------------------------------
+char*
+VISU::Curve_i
+::GetTitle()
+{
+ return CORBA::string_dup( GetName().c_str() );
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Curve_i
+::SetColor( const SALOMEDS::Color& theColor )
+{
+ myColor = theColor;
+ myAuto = false;
+}
+
+//----------------------------------------------------------------------------
+SALOMEDS::Color
+VISU::Curve_i
+::GetColor()
+{
+ return myColor;
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Curve_i
+::SetMarker( VISU::Curve::MarkerType theType )
+{
+ myMarker = theType;
+ myAuto = false;
+}
+
+//----------------------------------------------------------------------------
+VISU::Curve::MarkerType
+VISU::Curve_i
+::GetMarker()
+{
+ return myMarker;
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Curve_i
+::SetLine( VISU::Curve::LineType theType, CORBA::Long theWidth )
+{
+ myLine = theType;
+ myLineWidth = theWidth;
+ myAuto = false;
+}
+
+//----------------------------------------------------------------------------
+VISU::Curve::LineType
+VISU::Curve_i
+::GetLine()
+{
+ return myLine;
+}
+
+//----------------------------------------------------------------------------
+CORBA::Long
+VISU::Curve_i
+::GetLineWidth()
+{
+ return myLineWidth;
+}
+
+//----------------------------------------------------------------------------
/*!
Creates curve object
*/
VISU::Storable* VISU::Curve_i::Create()
{
// generate name ...
- myName = GetVerTitle();
- if ( myName == "" )
- myName = GenerateName();
+ SetName(GetVerTitle(), false);
+ if ( GetName() == "" )
+ SetName(GenerateName(), false);
// ... and build the object
return Build( false );
}
if ( myHRow > 0 && myHRow <= nbRows && myVRow > 0 && myVRow <= nbRows ) {
if ( !theRestoring ) {
// look for component
- SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( myStudy );
+ SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() );
// create SObject and set attributes
QString aComment;
aComment.sprintf("myComment=%s;myType=%d",GetComment(),VISU::TCURVE);
- string anEntry = CreateAttributes( myStudy,
+ string anEntry = CreateAttributes( GetStudyDocument(),
myTable->GetObjectEntry(),
"",
GetID(),
aComment.latin1(),
true );
// create SObject referenced to real table object
- mySObj = SALOMEDS::SObject::_duplicate(myStudy->FindObjectID(anEntry.c_str()));
-
- // Set icon
- SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
-
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributePixMap_var aPixmap;
-
- anAttr = aStudyBuilder->FindOrCreateAttribute( mySObj, "AttributePixMap" );
- aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
- aPixmap ->SetPixMap("ICON_TREE_CURVE");
+ mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID(anEntry.c_str()));
}
return this;
}
CORBA::Boolean VISU::Curve_i::IsValid()
{
// getting table SObject by it's entry
- SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
+ SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry());
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeTableOfInteger_var anInt;
SALOMEDS::AttributeTableOfReal_var aReal;
{
string title;
// getting table SObject by it's entry
- SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
+ SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry());
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeTableOfInteger_var anInt;
SALOMEDS::AttributeTableOfReal_var aReal;
{
string title;
// getting table SObject by it's entry
- SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
+ SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry());
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeTableOfInteger_var anInt;
SALOMEDS::AttributeTableOfReal_var aReal;
{
string units;
// getting table SObject by it's entry
- SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
+ SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry());
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeTableOfInteger_var anInt;
SALOMEDS::AttributeTableOfReal_var aReal;
{
string units;
// getting table SObject by it's entry
- SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
+ SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry());
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeTableOfInteger_var anInt;
SALOMEDS::AttributeTableOfReal_var aReal;
{
theHorList = 0; theVerList = 0;
// getting table SObject by it's entry
- SALOMEDS::SObject_var SO = myStudy->FindObjectID(myTable->GetObjectEntry());
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
+ SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry());
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeTableOfInteger_var anInt;
SALOMEDS::AttributeTableOfReal_var aReal;
SALOMEDS::Color color = GetColor();
crv->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
crv->setAutoAssign( IsAuto() );
- crv->setIO(new SALOME_InteractiveObject(mySObj->GetID(),"VISU",GetName()));
+ CORBA::String_var aString = mySObj->GetID();
+ crv->setIO(new SALOME_InteractiveObject(aString.in(), "VISU", GetName().c_str()));
if ( myTable )
- crv->setTableIO(new SALOME_InteractiveObject(myTable->GetObjectEntry(),"VISU",myTable->GetName()));
+ crv->setTableIO(new SALOME_InteractiveObject(myTable->GetObjectEntry(), "VISU", myTable->GetName().c_str()));
return crv;
}
/*!
{
if(MYDEBUG) MESSAGE(GetComment());
mySObj = SALOMEDS::SObject::_duplicate(theSO);
- myName = VISU::Storable::FindValue(theMap,"myName").latin1();
+ SetName(VISU::Storable::FindValue(theMap,"myName").latin1(), false);
myHRow = VISU::Storable::FindValue(theMap,"myHRow").toInt();
myVRow = VISU::Storable::FindValue(theMap,"myVRow").toInt();
bool ok = false;
*/
void VISU::Curve_i::ToStream( std::ostringstream& theStr )
{
- Storable::DataToStream( theStr, "myName", myName.c_str() );
+ Storable::DataToStream( theStr, "myName", GetName().c_str() );
Storable::DataToStream( theStr, "myHRow", myHRow );
Storable::DataToStream( theStr, "myVRow", myVRow );
Storable::DataToStream( theStr, "myZRow", myZRow );
*/
void VISU::Container_i::AddCurve( Curve_ptr theCurve )
{
- if ( myStudy->_is_nil() )
+ if ( GetStudyDocument()->_is_nil() )
return;
- SALOMEDS::SObject_var mySO = myStudy->FindObjectID( GetEntry() );
+ SALOMEDS::SObject_var mySO = GetStudyDocument()->FindObjectID( GetEntry().c_str() );
if ( mySO->_is_nil() )
return;
PortableServer::POA_ptr aPOA = GetPOA();
Curve_i* pCurve = dynamic_cast<Curve_i*>( aPOA->reference_to_servant( theCurve ) );
if( pCurve ) {
QString entry = pCurve->GetEntry();
- SALOMEDS::SObject_var SO = myStudy->FindObjectID( entry.latin1() );
+ SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID( entry.latin1() );
if ( !SO->_is_nil() && myCurves.find( entry ) == myCurves.end() ) {
myCurves.append( entry );
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
SALOMEDS::SObject_var newSO = Builder->NewObject( mySO );
Builder->Addreference( newSO, SO );
}
*/
void VISU::Container_i::RemoveCurve( Curve_ptr theCurve )
{
- if ( myStudy->_is_nil() )
+ if ( GetStudyDocument()->_is_nil() )
return;
- SALOMEDS::SObject_var mySO = myStudy->FindObjectID( GetEntry() );
+ SALOMEDS::SObject_var mySO = GetStudyDocument()->FindObjectID( GetEntry().c_str() );
if ( mySO->_is_nil() )
return;
PortableServer::POA_ptr aPOA = GetPOA();
if ( myCurves.find( entry ) != myCurves.end() ) {
// found !!!
myCurves.remove( entry );
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
- SALOMEDS::ChildIterator_var CI = myStudy->NewChildIterator( mySO );
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
+ SALOMEDS::ChildIterator_var CI = GetStudyDocument()->NewChildIterator( mySO );
for ( ; CI->More(); CI->Next() ) {
SALOMEDS::SObject_var childSO = CI->Value();
SALOMEDS::SObject_var refSO;
*/
void VISU::Container_i::Clear()
{
- if ( myStudy->_is_nil() )
+ if ( GetStudyDocument()->_is_nil() )
return;
- SALOMEDS::SObject_var mySO = myStudy->FindObjectID( GetEntry() );
+ SALOMEDS::SObject_var mySO = GetStudyDocument()->FindObjectID( GetEntry().c_str() );
if ( mySO->_is_nil() )
return;
QStringList toDelete;
- SALOMEDS::ChildIterator_var CI = myStudy->NewChildIterator( mySO );
+ SALOMEDS::ChildIterator_var CI = GetStudyDocument()->NewChildIterator( mySO );
for ( ; CI->More(); CI->Next() ) {
toDelete.append( CI->Value()->GetID() );
}
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
for ( int i = 0; i < toDelete.count(); i++ ) {
- SALOMEDS::SObject_var SO = myStudy->FindObjectID( toDelete[i].latin1() );
+ SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID( toDelete[i].latin1() );
Builder->RemoveObject( SO );
}
myCurves.clear();
VISU::Storable* VISU::Container_i::Create()
{
// generate name ...
- myName = GenerateName();
+ SetName(GenerateName(), false);
// ... and build the object
return Build( false );
}
{
if ( !theRestoring ) {
// looking for component
- SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( myStudy );
+ SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( GetStudyDocument() );
// create SObject and set attributes
QString aComment;
aComment.sprintf("myComment=%s;myType=%d",GetComment(),VISU::TCONTAINER);
- string anEntry = CreateAttributes( myStudy,
+ string anEntry = CreateAttributes( GetStudyDocument(),
SComponent->GetID(),
"",
GetID(),
"",
aComment.latin1(),
true );
- mySObj = SALOMEDS::SObject::_duplicate(myStudy->FindObjectID(anEntry.c_str()));
-
- // Set icon
- SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
-
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributePixMap_var aPixmap;
-
- anAttr = aStudyBuilder->FindOrCreateAttribute( mySObj, "AttributePixMap" );
- aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
- aPixmap ->SetPixMap("ICON_TREE_CONTAINER");
+ mySObj = SALOMEDS::SObject::_duplicate(GetStudyDocument()->FindObjectID(anEntry.c_str()));
}
return this;
}
*/
void VISU::Container_i::Update()
{
- if ( myStudy->_is_nil() )
+ if ( GetStudyDocument()->_is_nil() )
return;
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
- SALOMEDS::SObject_var mySO = myStudy->FindObjectID( GetEntry() );
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
+ SALOMEDS::SObject_var mySO = GetStudyDocument()->FindObjectID( GetEntry().c_str() );
SALOMEDS::GenericAttribute_var anAttr;
if ( !mySO->_is_nil() ) {
QStringList toDelete;
int i;
for ( i = 0; i < myCurves.count(); i++ ) {
- SALOMEDS::SObject_var SO = myStudy->FindObjectID( myCurves[i].latin1() );
+ SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID( myCurves[i].latin1() );
if ( !SO->_is_nil() && Builder->FindAttribute( SO, anAttr, "AttributeIOR" ) ) {
// if real Curve Object still exists
- SALOMEDS::ChildIterator_var CI = myStudy->NewChildIterator( mySO );
+ SALOMEDS::ChildIterator_var CI = GetStudyDocument()->NewChildIterator( mySO );
bool bFound = false;
for ( ; CI->More(); CI->Next() ) {
SALOMEDS::SObject_var childSO = CI->Value();
myCurves.remove( toDelete[i] );
}
toDelete.clear();
- SALOMEDS::ChildIterator_var CI = myStudy->NewChildIterator( mySO );
+ SALOMEDS::ChildIterator_var CI = GetStudyDocument()->NewChildIterator( mySO );
for ( ; CI->More(); CI->Next() ) {
SALOMEDS::SObject_var childSO = CI->Value();
SALOMEDS::SObject_var refSO;
}
}
for ( i = 0; i < toDelete.count(); i++ ) {
- SALOMEDS::ChildIterator_var CI = myStudy->NewChildIterator( mySO );
+ SALOMEDS::ChildIterator_var CI = GetStudyDocument()->NewChildIterator( mySO );
for ( ; CI->More(); CI->Next() ) {
SALOMEDS::SObject_var childSO = CI->Value();
if ( toDelete[i] == CI->Value()->GetID() ) {
VISU::Curve_i* VISU::Container_i::GetCurve( CORBA::Long theIndex )
{
if ( theIndex > 0 && theIndex <= myCurves.count() ) {
- SALOMEDS::StudyBuilder_var Builder = myStudy->NewBuilder();
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::SObject_var SO = myStudy->FindObjectID( myCurves[ theIndex-1 ].latin1() );
+ SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID( myCurves[ theIndex-1 ].latin1() );
CORBA::Object_var anObject = VISU::SObjectToObject( SO );
if( !CORBA::is_nil( anObject ) ) {
// if real Curve Object exists
{
if(MYDEBUG) MESSAGE(GetComment());
mySObj = SALOMEDS::SObject::_duplicate(SO);
- myName = VISU::Storable::FindValue( theMap, "myName" ).latin1();
+ SetName(VISU::Storable::FindValue( theMap, "myName" ).latin1(), false);
QString val = VISU::Storable::FindValue( theMap, "myCurves" );
myCurves = QStringList::split( QString( "*" ), val, false );
return Build( true );
*/
void VISU::Container_i::ToStream( std::ostringstream& theStr )
{
- Storable::DataToStream( theStr, "myName", myName.c_str() );
+ Storable::DataToStream( theStr, "myName", GetName().c_str() );
Storable::DataToStream( theStr, "myCurves", myCurves.join( QString( "*" ) ) );
// theStr<<" myName "<<myName;
// theStr<<" myCurves "<<myCurves.join( QString( "*" ) ).latin1()<<"* ";
virtual ~Table_i();
virtual VISU::VISUType GetType() { return VISU::TTABLE;};
- virtual void SetTitle( const char* theName ) { SetName( theName ); }
- virtual char* GetTitle() { return CORBA::string_dup( GetName() ); }
+ virtual void SetTitle( const char* theTitle );
+ virtual char* GetTitle();
- virtual void SetOrientation( VISU::Table::Orientation theOrientation ) { myOrientation = theOrientation; }
- virtual VISU::Table::Orientation GetOrientation() { return myOrientation; }
+ virtual void SetOrientation( VISU::Table::Orientation theOrientation );
+ virtual VISU::Table::Orientation GetOrientation();
virtual CORBA::Long GetNbRows();
virtual CORBA::Long GetNbColumns();
public:
virtual Storable* Create();
- SALOMEDS::SObject_var GetSObject() const { return mySObj;}
+ SALOMEDS::SObject_var GetSObject() const;
+
+ virtual Storable* Restore( const Storable::TRestoringMap& theMap,
+ SALOMEDS::SObject_ptr SO);
- virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO);
static Storable* Restore(SALOMEDS::SObject_ptr theSObject,
const std::string& thePrefix,
const Storable::TRestoringMap& theMap);
+
virtual void ToStream( std::ostringstream& theStr );
static const std::string myComment;
virtual const char* GetComment() const;
virtual const char* GenerateName();
virtual const char* GetTableTitle();
- virtual char* GetObjectEntry() { return CORBA::string_dup( mySObj->GetID() ); }
+ virtual char* GetObjectEntry();
};
SALOMEDS::SObject_var ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy);
bool ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName);
virtual ~Curve_i();
virtual VISU::VISUType GetType() { return VISU::TCURVE;};
- virtual void SetTitle( const char* theName ) { SetName( theName ); }
- virtual char* GetTitle() { return CORBA::string_dup( GetName() ); }
+ virtual void SetTitle( const char* theTitle );
+ virtual char* GetTitle();
- virtual void SetColor( const SALOMEDS::Color& theColor ) { myColor = theColor; myAuto = false; }
- virtual SALOMEDS::Color GetColor() { return myColor; }
+ virtual void SetColor( const SALOMEDS::Color& theColor );
+ virtual SALOMEDS::Color GetColor();
- virtual void SetMarker( VISU::Curve::MarkerType theType ) { myMarker = theType; myAuto = false; }
- virtual VISU::Curve::MarkerType GetMarker() { return myMarker; }
+ virtual void SetMarker( VISU::Curve::MarkerType theType );
+ virtual VISU::Curve::MarkerType GetMarker();
- virtual void SetLine( VISU::Curve::LineType theType, CORBA::Long theWidth )
- { myLine = theType; myLineWidth = theWidth; myAuto = false; }
- virtual VISU::Curve::LineType GetLine() { return myLine; }
- virtual CORBA::Long GetLineWidth() { return myLineWidth; }
+ virtual void SetLine( VISU::Curve::LineType theType, CORBA::Long theWidth );
+ virtual VISU::Curve::LineType GetLine();
+ virtual CORBA::Long GetLineWidth();
virtual void RemoveFromStudy();
#include "VISU_Result_i.hh"
#include "VISU_Prs3d_i.hh"
#include "VISU_Mesh_i.hh"
-#include "VISU_PrsMerger_i.hh"
#include "VISU_IsoSurfaces_i.hh"
#include "VISU_DeformedShape_i.hh"
#include "VISU_ScalarMapOnDeformedShape_i.hh"
FieldData aNewData;
aNewData.myField = theField;
aNewData.myNbFrames = 0;
- aNewData.myPrsType = VISU::TPRSMERGER;
+ aNewData.myPrsType = VISU::TSCALARMAP;
aNewData.myOffset[0] = aNewData.myOffset[1] = aNewData.myOffset[2] = 0;
VISU::Storable::TRestoringMap aMap = getMapOfValue(aNewData.myField);
if(VISU::Storable::FindValue(aMap,"myComment") != QString("FIELD"))
int aTimeStampId = VISU::Storable::FindValue(aTimeMap,"myTimeStampId").toInt();
bool anIsCreated = false;
- TPrs3d* aPresent = new TPrs3d(theResult, false);
+ TPrs3d* aPresent = new TPrs3d(VISU::ColoredPrs3d_i::EDoNotPublish);
+ aPresent->SetCResult(theResult);
+ aPresent->SetMeshName(aMeshName.latin1());
+ aPresent->SetEntity(anEntity);
+ aPresent->SetFieldName(aFieldName.latin1());
+ aPresent->SetTimeStampNumber(aTimeStampId);
#ifdef NO_CAS_CATCH
try{
OCC_CATCH_SIGNALS;
CASCatch_TRY{
try{
#endif
- if(aPresent->Create(aMeshName.latin1(),anEntity,aFieldName.latin1(),aTimeStampId)){
+ if(aPresent->Apply(false)){
anIsCreated = true;
theData.myPrs[aFrameId++] = aPresent;
aMin = std::min(aPresent->GetMin(), aMin);
int aRangeType = VISU::GetResourceMgr()->integerValue("VISU" , "scalar_range_type", 0);
if( aRangeType != 1 ){
for(long aFrameId = 0; aFrameId < theData.myNbFrames; aFrameId++) {
- if (VISU::PrsMerger_i* aPrs = dynamic_cast<VISU::PrsMerger_i*>(theData.myPrs[aFrameId])){
+ if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(theData.myPrs[aFrameId])){
aPrs->SetRange(aMin, aMax);
aPrs->SetOffset(theData.myOffset);
}
using namespace VISU;
switch (aData.myPrsType) {
case VISU::TSCALARMAP:
- case VISU::TPRSMERGER: // ScalarMap
- GeneratePresentations<PrsMerger_i>(myStudy,
+ GeneratePresentations<ScalarMap_i>(myStudy,
aData,
aResult,
isRangeDefined(),
std::string aPrsCmt;
switch (thePrsType) {
case VISU::TSCALARMAP:
- case VISU::TPRSMERGER:
- aPrsCmt = VISU::PrsMerger_i::myComment;
+ aPrsCmt = VISU::ScalarMap_i::myComment;
break;
case VISU::TISOSURFACE:
aPrsCmt = VISU::IsoSurfaces_i::myComment;
string aStr = aName->Value();
QString strName (aStr.c_str());
- if (strName == VISU::PrsMerger_i::myComment.c_str() ||
- strName == VISU::ScalarMap_i::myComment.c_str())
- aData.myPrsType = VISU::TPRSMERGER;
+ if (strName == VISU::ScalarMap_i::myComment.c_str())
+ aData.myPrsType = VISU::TSCALARMAP;
else if (strName == VISU::IsoSurfaces_i::myComment.c_str())
aData.myPrsType = VISU::TISOSURFACE;
else if (strName == VISU::CutPlanes_i::myComment.c_str())
VISU::Storable::TRestoringMap aPrsMap;
VISU::Storable::StrToMap(strPrsIn,aPrsMap);
- aData.myPrs[0]->Restore(aPrsMap);
+ aData.myPrs[0]->Restore(VISU::GetDSStudy(myStudy), aPrsMap);
}
aData.myPrs[0]->GetOffset(aData.myOffset);
for (int i = 1; i < aData.myNbFrames; i++) {
anIsFixedRange = aPrs->IsRangeFixed();
}
//jfa 03.08.2005:aData.myPrs[i]->SameAs(aData.myPrs[0]);
- aData.myPrs[i]->SameAsParams(aData.myPrs[0],
- aData.myPrs[i]->GetMeshName(),aData.myPrs[i]->GetFieldName(),
- aData.myPrs[i]->GetEntity(), aData.myPrs[i]->GetIteration(),
- anIsFixedRange);//jfa 03.08.2005
+ aData.myPrs[i]->SameAs(aData.myPrs[0]);//jfa 03.08.2005
}
}
string aStr = aAnimSObject->GetID();
if ( aData.myPrs.empty() )
throw SALOME_Exception(LOCALIZED("Error : presentations for the given field is not yet created!"));
- if ( aPrs_i->GetResult() != aData.myPrs[0]->GetResult() )
+ if ( aPrs_i->GetCResult() != aData.myPrs[0]->GetCResult() )
throw SALOME_Exception(LOCALIZED("Error : the MED file is not the same!"));
for (int i = 0; i < aData.myNbFrames; i++) {
if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(aData.myPrs[i]))
anIsFixedRange = aPrs->IsRangeFixed();
}
- aData.myPrs[i]->SameAsParams(aPrs_i,
- aData.myPrs[i]->GetMeshName(),aData.myPrs[i]->GetFieldName(),
- aData.myPrs[i]->GetEntity(), aData.myPrs[i]->GetIteration(),
- anIsFixedRange);
+ aData.myPrs[i]->SameAs(aPrs_i);
}
}
else if ( myAnimationMode == 1 ) { // successive animation mode
throw SALOME_Exception(LOCALIZED("Error : presentations for the given field is not yet created!"));
for (int i = 0; i < aData.myNbFrames; i++) {
- aData.myPrs[i]->SameAsParams(aPrs_i,
- aData.myPrs[i]->GetMeshName(),aData.myPrs[i]->GetFieldName(),
- aData.myPrs[i]->GetEntity(), aData.myPrs[i]->GetIteration(),
- true);
+ aData.myPrs[i]->SameAs(aPrs_i);
}
}
}
#include <vtkProperty.h>
-using namespace VISU;
-using namespace std;
-
#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
static int INCMEMORY = 4+12;
-int VISU::Vectors_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration, int isMemoryCheck)
+
+//---------------------------------------------------------------
+size_t
+VISU::Vectors_i
+::IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck)
{
- bool aResult = false;
try{
- aResult = DeformedShape_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,false);
- if(isMemoryCheck && aResult){
- float aSize = INCMEMORY*
- theResult->GetInput()->GetTimeStampSize(theMeshName,(VISU::TEntity)theEntity,theFieldName,theIteration);
+ size_t aResult = TSuperClass::IsPossible(theResult,
+ theMeshName,
+ theEntity,
+ theFieldName,
+ theTimeStampNumber,
+ false);
+ if(theIsMemoryCheck && aResult){
+ bool anIsEstimated = true;
+ VISU::Result_i::TInput* anInput = theResult->GetInput();
+ size_t aSize = anInput->GetTimeStampOnMeshSize(theMeshName,
+ (VISU::TEntity)theEntity,
+ theFieldName,
+ theTimeStampNumber,
+ anIsEstimated);
+ if(anIsEstimated)
+ aSize *= INCMEMORY;
aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
- MESSAGE("Vectors_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<aResult);
+ if(MYDEBUG)
+ MESSAGE("Vectors_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 aResult;
+ return 0;
}
-
+//---------------------------------------------------------------
int VISU::Vectors_i::myNbPresent = 0;
-QString VISU::Vectors_i::GenerateName() { return VISU::GenerateName("Vectors",myNbPresent++);}
+//---------------------------------------------------------------
+QString
+VISU::Vectors_i
+::GenerateName()
+{
+ return VISU::GenerateName("Vectors",myNbPresent++);
+}
+//---------------------------------------------------------------
const string VISU::Vectors_i::myComment = "VECTORS";
-const char* VISU::Vectors_i::GetComment() const { return myComment.c_str();}
-
-
-VISU::Vectors_i::
-Vectors_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theAddToStudy),
- ColoredPrs3d_i(theResult,theAddToStudy),
- ScalarMap_i(theResult,theAddToStudy),
- PrsMerger_i(theResult,theAddToStudy),
- DeformedShape_i(theResult,theAddToStudy),
- myVectorsPL(NULL)
+
+//---------------------------------------------------------------
+const char*
+VISU::Vectors_i
+::GetComment() const
{
+ return myComment.c_str();
}
-VISU::Vectors_i::
-Vectors_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
- ColoredPrs3d_i(theResult,theSObject),
- ScalarMap_i(theResult,theSObject),
- PrsMerger_i(theResult,theSObject),
- DeformedShape_i(theResult,theSObject),
- myVectorsPL(NULL)
+//---------------------------------------------------------------
+const char*
+VISU::Vectors_i
+::GetIconName()
{
+ if (!IsGroupsUsed())
+ return "ICON_TREE_VECTORS";
+ else
+ return "ICON_TREE_VECTORS_GROUPS";
}
+//---------------------------------------------------------------
+VISU::Vectors_i
+::Vectors_i(EPublishInStudyMode thePublishInStudyMode) :
+ ColoredPrs3d_i(thePublishInStudyMode),
+ ScalarMap_i(thePublishInStudyMode),
+ DeformedShape_i(thePublishInStudyMode),
+ myLineWidth(1.0),
+ myVectorsPL(NULL)
+{}
+
-void VISU::Vectors_i::SameAs(const VISU::Prs3d_i* theOrigin)
+//---------------------------------------------------------------
+void
+VISU::Vectors_i
+::SameAs(const VISU::Prs3d_i* theOrigin)
{
TSuperClass::SameAs(theOrigin);
}
-VISU::Storable* VISU::Vectors_i::Create(const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration)
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::Vectors_i
+::Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
{
- myLineWidth = 1.0;
- return DeformedShape_i::Create(theMeshName,theEntity,theFieldName,theIteration);
+ return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
}
-VISU::Storable* VISU::Vectors_i::Restore(const Storable::TRestoringMap& theMap)
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::Vectors_i
+::Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
{
- TSuperClass::Restore(theMap);
+ if(!TSuperClass::Restore(theStudy, theMap))
+ return NULL;
SetGlyphType(VISU::Vectors::GlyphType(VISU::Storable::FindValue(theMap,"myTypeGlyph").toInt()));
SetGlyphPos(VISU::Vectors::GlyphPos(VISU::Storable::FindValue(theMap,"myPosGlyph").toInt()));
}
-void VISU::Vectors_i::ToStream(std::ostringstream& theStr){
- DeformedShape_i::ToStream(theStr);
+//---------------------------------------------------------------
+void
+VISU::Vectors_i
+::ToStream(std::ostringstream& theStr)
+{
+ TSuperClass::ToStream(theStr);
Storable::DataToStream( theStr, "myTypeGlyph", int(GetGlyphType()));
Storable::DataToStream( theStr, "myPosGlyph", int(GetGlyphPos()));
}
-VISU::Vectors_i::~Vectors_i(){
+//---------------------------------------------------------------
+VISU::Vectors_i
+::~Vectors_i()
+{
if(MYDEBUG) MESSAGE("Vectors_i::~Vectors_i()");
}
-void VISU::Vectors_i::SetLineWidth(CORBA::Double theWidth) {
+//---------------------------------------------------------------
+void
+VISU::Vectors_i
+::SetLineWidth(CORBA::Double theWidth)
+{
myLineWidth = theWidth;
+ myParamsTime.Modified();
}
-CORBA::Double VISU::Vectors_i::GetLineWidth() {
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::Vectors_i
+::GetLineWidth()
+{
return myLineWidth;
}
-void VISU::Vectors_i::SetGlyphType(VISU::Vectors::GlyphType theType) {
+//---------------------------------------------------------------
+void
+VISU::Vectors_i
+::SetGlyphType(VISU::Vectors::GlyphType theType)
+{
myVectorsPL->SetGlyphType(VISU_VectorsPL::GlyphType(theType));
}
-VISU::Vectors::GlyphType VISU::Vectors_i::GetGlyphType() {
+
+//---------------------------------------------------------------
+VISU::Vectors::GlyphType
+VISU::Vectors_i
+::GetGlyphType()
+{
return VISU::Vectors::GlyphType(myVectorsPL->GetGlyphType());
}
-void VISU::Vectors_i::SetGlyphPos(VISU::Vectors::GlyphPos thePos) {
+//---------------------------------------------------------------
+void
+VISU::Vectors_i
+::SetGlyphPos(VISU::Vectors::GlyphPos thePos)
+{
myVectorsPL->SetGlyphPos(VISU_VectorsPL::GlyphPos(thePos));
}
-VISU::Vectors::GlyphPos VISU::Vectors_i::GetGlyphPos() {
+
+//---------------------------------------------------------------
+VISU::Vectors::GlyphPos
+VISU::Vectors_i::GetGlyphPos()
+{
return VISU::Vectors::GlyphPos(myVectorsPL->GetGlyphPos());
}
-void VISU::Vectors_i::DoHook(){
- if(!myPipeLine) myPipeLine = VISU_VectorsPL::New();
- myVectorsPL = dynamic_cast<VISU_VectorsPL*>(myPipeLine);
+//---------------------------------------------------------------
+void
+VISU::Vectors_i
+::CreatePipeLine(VISU_PipeLine* thePipeLine)
+{
+ if(!thePipeLine){
+ myVectorsPL = VISU_VectorsPL::New();
+ }else
+ myVectorsPL = dynamic_cast<VISU_VectorsPL*>(thePipeLine);
- DeformedShape_i::DoHook();
+ TSuperClass::CreatePipeLine(myVectorsPL);
}
-const char*
+//---------------------------------------------------------------
+VISU_PipeLine*
VISU::Vectors_i
-::GetIconName()
+::GetActorPipeLine()
{
- if (!GetNumberOfGeom())
- return "ICON_TREE_VECTORS";
- else
- return "ICON_TREE_VECTORS_GROUPS";
-}
-
-
-VISU_PipeLine* VISU::Vectors_i::GetPipeLine(){
VISU_PipeLine* aPipeLine = VISU_VectorsPL::New();
- aPipeLine->SetIDMapper(myPipeLine->GetIDMapper());
- aPipeLine->ShallowCopy(myPipeLine);
- aPipeLine->Update();
+ aPipeLine->ShallowCopy(GetPipeLine(), true);
return aPipeLine;
}
-VISU_Actor* VISU::Vectors_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+//---------------------------------------------------------------
+bool
+VISU::Vectors_i
+::CheckIsPossible()
+{
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
+}
+
+//---------------------------------------------------------------
+VISU_Actor*
+VISU::Vectors_i
+::CreateActor()
{
VISU_VectorsAct* anActor = VISU_VectorsAct::New();
try{
- VISU::Prs3d_i::CreateActor(anActor,theIO);
+ VISU::Prs3d_i::CreateActor(anActor);
anActor->SetVTKMapping(true);
anActor->SetBarVisibility(true);
anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B);
}
-void VISU::Vectors_i::UpdateActor(VISU_Actor* theActor) {
+//---------------------------------------------------------------
+void
+VISU::Vectors_i
+::UpdateActor(VISU_Actor* theActor)
+{
if(VISU_VectorsAct* anActor = dynamic_cast<VISU_VectorsAct*>(theActor)){
- VISU::DeformedShape_i::UpdateActor(anActor);
+ TSuperClass::UpdateActor(anActor);
anActor->GetProperty()->SetLineWidth(GetLineWidth());
if(VISU_VectorsPL* aVectorsPL = dynamic_cast<VISU_VectorsPL*>(anActor->GetPipeLine())){
- aVectorsPL->ShallowCopy(myPipeLine);
+ aVectorsPL->ShallowCopy(GetPipeLine(), true);
aVectorsPL->Update();
aVectorsPL->SetMapScale(myVectorsPL->GetMapScale());
}
class VISU_VectorsPL;
-namespace VISU{
+namespace VISU
+{
+ //----------------------------------------------------------------------------
class VISU_I_EXPORT Vectors_i : public virtual POA_VISU::Vectors,
- public virtual DeformedShape_i
+ public virtual DeformedShape_i
{
static int myNbPresent;
Vectors_i(const Vectors_i&);
public:
+ //----------------------------------------------------------------------------
typedef DeformedShape_i TSuperClass;
+ typedef VISU::Vectors TInterface;
explicit
- Vectors_i(Result_i* theResult,
- bool theAddToStudy);
- explicit
- Vectors_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject);
- virtual void SameAs(const Prs3d_i* theOrigin);
- virtual ~Vectors_i();
+ Vectors_i(EPublishInStudyMode thePublishInStudyModep);
- virtual VISU::VISUType GetType() { return VISU::TVECTORS;};
+ virtual
+ void
+ SameAs(const Prs3d_i* theOrigin);
- virtual void SetLineWidth(CORBA::Double theWidth);
- virtual CORBA::Double GetLineWidth();
+ virtual
+ ~Vectors_i();
- virtual void SetGlyphType(VISU::Vectors::GlyphType theType);
- virtual VISU::Vectors::GlyphType GetGlyphType();
+ virtual
+ VISU::VISUType
+ GetType()
+ {
+ return VISU::TVECTORS;
+ }
- virtual void SetGlyphPos(VISU::Vectors::GlyphPos thePos);
- virtual VISU::Vectors::GlyphPos GetGlyphPos();
+ virtual
+ void
+ SetLineWidth(CORBA::Double theWidth);
- typedef VISU::Vectors TInterface;
- VISU_VectorsPL* GetVectorsPL(){ return myVectorsPL;}
+ virtual
+ CORBA::Double
+ GetLineWidth();
- protected:
- virtual void DoHook();
+ virtual
+ void
+ SetGlyphType(VISU::Vectors::GlyphType theType);
- virtual const char* GetIconName();
+ virtual
+ VISU::Vectors::GlyphType
+ GetGlyphType();
+
+ virtual
+ void
+ SetGlyphPos(VISU::Vectors::GlyphPos thePos);
+
+ virtual
+ VISU::Vectors::GlyphPos
+ GetGlyphPos();
+
+ VISU_VectorsPL*
+ GetSpecificPL() const
+ {
+ return myVectorsPL;
+ }
- virtual VISU_PipeLine* GetPipeLine();
+ protected:
+ //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine
+ virtual
+ void
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
+
+ //! Redefines VISU_ColoredPrs3d_i::CheckIsPossible
+ virtual
+ bool
+ CheckIsPossible();
+
+ virtual
+ VISU_PipeLine*
+ GetActorPipeLine();
VISU_VectorsPL *myVectorsPL;
float myLineWidth;
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);
+ //! Redefines VISU_ColoredPrs3d_i::IsPossible
+ static
+ size_t
+ IsPossible(Result_i* theResult,
+ const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber,
+ bool theIsMemoryCheck);
+
+ //! Redefines VISU_ColoredPrs3d_i::Create
+ virtual
+ Storable*
+ Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber);
- virtual void ToStream(std::ostringstream& theStr);
+ //! Redefines VISU_ColoredPrs3d_i::ToStream
+ virtual
+ void
+ ToStream(std::ostringstream& theStr);
- virtual Storable* Restore(const Storable::TRestoringMap& theMap);
+ //! Redefines VISU_ColoredPrs3d_i::Restore
+ virtual
+ Storable*
+ Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap);
static const std::string myComment;
- virtual const char* GetComment() const;
- virtual QString GenerateName();
+
+ //! Redefines VISU_ColoredPrs3d_i::GetComment
+ virtual
+ const char*
+ GetComment() const;
+
+ //! Redefines VISU_ColoredPrs3d_i::GenerateName
+ virtual
+ QString
+ GenerateName();
+ virtual
+ const char*
+ GetIconName();
+
+ //! Redefines VISU_ColoredPrs3d_i::CreateActor
virtual
VISU_Actor*
- CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
+ CreateActor();
- virtual void UpdateActor(VISU_Actor* theActor) ;
+ //! Redefines VISU_ColoredPrs3d_i::UpdateActor
+ virtual
+ void
+ UpdateActor(VISU_Actor* theActor) ;
};
}
#include "SALOME_ListIO.hxx"
#include "SALOME_ListIteratorOfListIO.hxx"
+#include "VTKViewer_Algorithm.h"
+#include "SVTK_Functor.h"
+
#include <vtkCamera.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
using namespace std;
#ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
#endif
for (int i = 0; i < clist.count(); i++) {
SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
if (aSPlot2dC->hasIO() &&
- !strcmp(aSPlot2dC->getIO()->getEntry(), theCurve->GetEntry())) {
+ theCurve->GetEntry() != aSPlot2dC->getIO()->getEntry()) {
if(MYDEBUG) MESSAGE("UpdatePlot2d - erasing : curve - " << aSPlot2dC);
theView->eraseCurve(aSPlot2dC);
}
for (int i = 0; i < clist.count(); i++) {
SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
if (aSPlot2dC->hasIO() &&
- !strcmp(aSPlot2dC->getIO()->getEntry(), theCurve->GetEntry())) {
+ theCurve->GetEntry() != aSPlot2dC->getIO()->getEntry()) {
if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - " << aSPlot2dC);
aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() );
aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() );
for (int i = 0; i < clist.count(); i++) {
SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
if (aSPlot2dC->hasIO() &&
- !strcmp(aSPlot2dC->getIO()->getEntry(), theCurve->GetEntry())) {
+ theCurve->GetEntry() != aSPlot2dC->getIO()->getEntry()) {
if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - " << aSPlot2dC);
aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() );
aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() );
}
}
- VISU_Actor* GetActor (VISU::Prs3d_i* thePrs3d, SVTK_ViewWindow* theVTKFrame)
+
+ //----------------------------------------------------------------------------
+ struct TIsSamePrs3d
{
- vtkActorCollection *anActColl = theVTKFrame->getRenderer()->GetActors();
- anActColl->InitTraversal();
- while (vtkActor *anActor = anActColl->GetNextActor())
- if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
- if (thePrs3d == anVISUActor->GetPrs3d())
- return anVISUActor;
- return NULL;
+ VISU::Prs3d_i* myPrs3d;
+
+ TIsSamePrs3d(VISU::Prs3d_i* thePrs3d):
+ myPrs3d(thePrs3d)
+ {}
+
+ bool
+ operator()(VISU_Actor* theActor)
+ {
+ return theActor->GetPrs3d() == myPrs3d;
+ }
+ };
+
+
+ //----------------------------------------------------------------------------
+ VISU_Actor*
+ FindActor(SVTK_ViewWindow* theViewWindow, VISU::Prs3d_i* thePrs3d)
+ {
+ if(!thePrs3d)
+ return NULL;
+
+ vtkRenderer* aRenderer = theViewWindow->getRenderer();
+ vtkActorCollection* anActors = aRenderer->GetActors();
+ return SVTK::Find<VISU_Actor>(anActors, VISU::TIsSamePrs3d(thePrs3d));
}
+
+ //----------------------------------------------------------------------------
struct TDeleteActorsEvent: public SALOME_Event
{
VISU::Curve_i* myPrs;
for (int i = 0; i < clist.count(); i++) {
if (SPlot2d_Curve* cu = dynamic_cast<SPlot2d_Curve*>(clist.at(i))) {
if (cu->hasIO() &&
- strcmp(cu->getIO()->getEntry(), myPrs->GetEntry()) == 0) {
+ myPrs->GetEntry() == cu->getIO()->getEntry()) {
vf->eraseCurve(cu);
}
}
VISU_Actor* UpdateViewer (SUIT_ViewWindow* theViewWindow, int theDisplaing, Prs3d_i* thePrs = NULL);
void UpdatePlot2d (Plot2d_ViewFrame *theView, int theDisplaying, Curve_i* theCurve);
- VISU_I_EXPORT VISU_Actor* GetActor (VISU::Prs3d_i* thePrs, SVTK_ViewWindow* theViewWindow);
+ VISU_Actor* VISU_I_EXPORT FindActor(SVTK_ViewWindow* theViewWindow, VISU::Prs3d_i* thePrs3d);
void DeleteActors (VISU::Prs3d_i* thePrs);
void DeleteActors (VISU::Curve_i* thePrs);
}
}
if (!aCStudy) return;
- _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry().latin1());
+ _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry());
if (TableSO) {
_PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO);
for (; Iter->More(); Iter->Next()) {
{
class TEvent: public SALOME_Event
{
- SUIT_ViewWindow* myVW;
+ SUIT_ViewWindow* myViewWindow;
public:
TEvent(SUIT_ViewWindow* theViewWindow):
- myVW(theViewWindow)
+ myViewWindow(theViewWindow)
{}
virtual void Execute()
{
- SVTK_ViewWindow* vf = dynamic_cast<SVTK_ViewWindow*>(myVW);
- vtkRenderer* Renderer = vf->getRenderer();
- vtkActorCollection* theActors = Renderer->GetActors();
- theActors->InitTraversal();
- while (vtkActor *anAct = theActors->GetNextActor()) {
+ SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(myViewWindow);
+ vtkRenderer* aRenderer = aViewWindow->getRenderer();
+ vtkActorCollection* anActors = aRenderer->GetActors();
+ anActors->InitTraversal();
+ while (vtkActor *anAct = anActors->GetNextActor()) {
if (VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anAct)) {
- VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d();
- if (anActor->GetVisibility() && aPrs3d) {
- aPrs3d->Update();
- aPrs3d->UpdateActor(anActor);
- }
+ if (anActor->GetVisibility())
+ anActor->UpdateFromFactory();
}
}
- RepaintView(myVW);
+ RepaintView(myViewWindow);
}
};
- SUIT_ViewWindow* aVW = GetViewWindow();
- if (aVW)
- ProcessVoidEvent(new TEvent(aVW));
+ if (SUIT_ViewWindow* aViewWindow = GetViewWindow())
+ ProcessVoidEvent(new TEvent(aViewWindow));
}
- bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const char* theName)
+ bool View3D_i::SaveViewParams (SUIT_ViewManager* theViewManager, const std::string& theName)
{
MESSAGE("View3D_i::SaveViewParams()");
- if (!theViewManager || !theName)
+ if (!theViewManager || theName == "")
return false;
_PTR(Study) aCStudy;
if (!aCStudy)
return false;
- if (strcmp(theName, "") != 0) {
- std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName, "VISU");
+ if (theName != "") {
+ std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(theName.c_str(), "VISU");
_PTR(GenericAttribute) anAttr;
int iEnd = aList.size();
for (int i = 0; i < iEnd; i++) {
}
_PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
string aSComponentEntry = aSComponent->GetID();
- string anEntry = CreateAttributes(aCStudy, aSComponentEntry.c_str(), "", "", theName, "",
+ string anEntry = CreateAttributes(aCStudy,
+ aSComponentEntry.c_str(),
+ "",
+ "",
+ theName,
+ "",
ToString(theViewManager->getActiveView()).c_str());
return true;
}
class TSaveViewParamsEvent: public SALOME_Event
{
SUIT_ViewManager* myViewMgr;
- const char* myName;
+ std::string myName;
public:
TSaveViewParamsEvent (SUIT_ViewManager* theViewManager,
- const char* theName):
+ const std::string& theName):
myViewMgr(theViewManager),
myName(theName)
{}
TResult myResult;
};
- CORBA::Boolean View3D_i::SaveViewParams (const char* theName)
+ CORBA::Boolean View3D_i::SaveViewParams (const char* theViewParamsName)
{
- return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theName));
+ return ProcessEvent(new TSaveViewParamsEvent (myViewManager, theViewParamsName));
}
- bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const char* theName)
+ bool View3D_i::RestoreViewParams (SUIT_ViewManager* theViewManager, const std::string& theName)
{
_PTR(Study) aCStudy;
if (SUIT_Study* aSStudy = theViewManager->study()) {
class TRestoreViewParamsEvent: public SALOME_Event
{
SUIT_ViewManager* myViewMgr;
- const char* myName;
+ std::string myName;
public:
TRestoreViewParamsEvent (SUIT_ViewManager* theViewManager,
- const char* theName):
+ const std::string& theName):
myViewMgr(theViewManager),
myName(theName)
{}
TResult myResult;
};
- CORBA::Boolean View3D_i::RestoreViewParams (const char* theName)
+ CORBA::Boolean View3D_i::RestoreViewParams (const char* theViewParamsName)
{
- return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theName));
+ return ProcessEvent(new TRestoreViewParamsEvent (myViewManager, theViewParamsName));
}
void View3D_i::Restore (SUIT_ViewWindow* theViewWindow,
if (!aPrs) {
myError = "Corrupted presentation";
} else {
- VISU_Actor* anActor = VISU::GetActor(aPrs, vw);
+ VISU_Actor* anActor = VISU::FindActor(vw, aPrs);
if (!anActor) {
myError = "No actor found. Display the presentation at first.";
} else {
{
VISU::VISUType aType = myPrs->GetType();
if (aType != VISU::TSCALARMAP &&
- aType != VISU::TPRSMERGER &&
aType != VISU::TDEFORMEDSHAPE &&
aType != VISU::TSCALARMAPONDEFORMEDSHAPE) {
myResult = "Insideframe representation is not available for this type of presentations.";
static void ToStream (SUIT_ViewWindow* theViewWindow, std::ostringstream& theStr);
static bool SaveViewParams (SUIT_ViewManager* theViewManager,
- const char* theName);
- virtual CORBA::Boolean SaveViewParams (const char* theName);
+ const std::string& theName);
+ virtual CORBA::Boolean SaveViewParams (const char* theViewParamsName);
static bool RestoreViewParams (SUIT_ViewManager* theViewManager,
- const char* theName);
- virtual CORBA::Boolean RestoreViewParams (const char* theName);
+ const std::string& theName);
+ virtual CORBA::Boolean RestoreViewParams (const char* theViewParamsName);
static QString GenerateViewParamsName();
#include "VISU_Convertor.hxx"
#include "VISU_ScalarMapPL.hxx"
+#include "VISU_ScalarBarActor.hxx"
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
: myScalarMap(NULL)
{
if(VISU_Convertor* aConvertor = theConvertor->GetImpl()){
- VISU::PIDMapper anIDMapper =
+ VISU::PUnstructuredGridIDMapper anIDMapper =
aConvertor->GetTimeStampOnMesh(theMeshName,VISU::TEntity(theEntity),theFieldName,theIteration);
- VISU::TVTKOutput* aDataSet = anIDMapper->GetVTKOutput();
- if(aDataSet){
+ if(anIDMapper){
myScalarMap = VISU_ScalarMapPL::New();
- myScalarMap->SetInput(aDataSet);
- myScalarMap->Build();
- myScalarMap->Init();
- myScalarMap->SetSourceRange();
+ myScalarMap->SetUnstructuredGridIDMapper(anIDMapper);
}
}
}
VISU_ScalarBarActor * aScalarBar = VISU_ScalarBarActor::New();
aScalarBar->SetLookupTable(aScalarMap->GetBarTable());
- aScalarMap->Build();
-
myRen->AddActor(anActor);
myRen->AddActor2D(aScalarBar);
myRen->ResetCameraClippingRange();
import SALOME_Session_idl
import SALOMEDS
import SALOME_MED
+import SALOME_ModuleCatalog
from omniORB import CORBA
from string import *
from time import sleep
aSComponent = aStudyBuilder.NewComponent(aComponentDataType);
aName = aStudyBuilder.FindOrCreateAttribute(aSComponent,"AttributeName")
- aModuleCatalog = myNamingService.Resolve("/Kernel/ModulCatalog");
+ aModuleCatalogObj = myNamingService.Resolve("/Kernel/ModulCatalog");
+ aModuleCatalog = aModuleCatalogObj._narrow(SALOME_ModuleCatalog.ModuleCatalog)
aComponent = aModuleCatalog.GetComponent(aComponentDataType);
if aComponent != None:
aComponentUserName = aComponent._get_componentusername()
--- /dev/null
+import os
+import time
+import VISU
+import SALOMEDS
+from batchmode_visu import *
+
+#---------------------------------------------------------------
+def WalkTroughTimeStamps(theVISUType,
+ theInput,
+ theViewManager):
+ aView = theViewManager.Create3DView();
+ aView.SetTitle("To test presentation of %s type" % theVISUType)
+
+ aCache = myVisu.GetColoredPrs3dCache(myVisu.GetCurrentStudy())
+ aHolder = aCache.CreateHolder(theVISUType, theInput)
+
+ if not aHolder:
+ print "It is impossible to create such kind of holder (%s) with the given parameters" % theVISUType
+ print "\ttheMeshName = '%s'" % theInput.myMeshName
+ print "\ttheEntity = %s" % theInput.myEntity
+ print "\ttheFieldName = '%s'" % theInput.myFieldName
+ print "\ttheTimeStampNumber = %s" % theInput.myTimeStampNumber
+ return
+
+ aPrs3d = aHolder.GetDevice()
+
+ if not aHolder.Apply(aPrs3d, theInput, aView):
+ print "It is impossible to create such kind of presentation (%s) with the given parameters" % theVISUType
+ print "\ttheMeshName = '%s'" % theInput.myMeshName
+ print "\ttheEntity = %s" % theInput.myEntity
+ print "\ttheFieldName = '%s'" % theInput.myFieldName
+ print "\ttheTimeStampNumber = %s" % theInput.myTimeStampNumber
+ return
+
+ aView.FitAll()
+
+ aDelay = 0.0
+ aRange = aHolder.GetTimeStampsRange()
+ for anInfo in aRange:
+ print "%d (%s); " % (anInfo.myNumber, anInfo.myTime)
+ theInput.myTimeStampNumber = anInfo.myNumber
+ aHolder.Apply(aPrs3d, theInput, aView)
+ time.sleep(aDelay)
+ pass
+ pass
+
+#---------------------------------------------------------------
+PRS3D_TYPE_LIST = []
+PRS3D_TYPE_LIST.append(VISU.TGAUSSPOINTS)
+PRS3D_TYPE_LIST.append(VISU.TSCALARMAP)
+PRS3D_TYPE_LIST.append(VISU.TISOSURFACE)
+PRS3D_TYPE_LIST.append(VISU.TCUTPLANES)
+PRS3D_TYPE_LIST.append(VISU.TCUTLINES)
+PRS3D_TYPE_LIST.append(VISU.TPLOT3D)
+PRS3D_TYPE_LIST.append(VISU.TDEFORMEDSHAPE)
+PRS3D_TYPE_LIST.append(VISU.TVECTORS)
+PRS3D_TYPE_LIST.append(VISU.TSTREAMLINES)
+PRS3D_TYPE_LIST.append(VISU.TSCALARMAPONDEFORMEDSHAPE)
+
+
+#---------------------------------------------------------------
+aMedFile = "TimeStamps.med"
+aMedFile = "ResOK_0000.med"
+aMedFile = os.getenv('DATA_DIR') + '/MedFiles/' + aMedFile
+aResult = myVisu.ImportFile(aMedFile)
+
+aMeshName ="dom"
+anEntity = VISU.NODE
+aFieldName = "vitesse";
+aTimeStampNumber = 1
+
+anInput = VISU.ColoredPrs3dHolder.BasicInput(aResult,aMeshName,anEntity,aFieldName,aTimeStampNumber);
+
+aViewManager = myVisu.GetViewManager();
+
+WalkTroughTimeStamps(VISU.TSCALARMAP, anInput, aViewManager)
+
+for aVISUType in PRS3D_TYPE_LIST:
+ WalkTroughTimeStamps(aVISUType, anInput, aViewManager)
+ pass
+
+anInput.myEntity = VISU.CELL;
+anInput.myFieldName = "pression";
+WalkTroughTimeStamps(VISU.TGAUSSPOINTS, anInput, aViewManager)
+
+#execfile('/data/apo/a.py')
\ No newline at end of file
--- /dev/null
+import os
+import time
+import VISU
+import SALOMEDS
+from batchmode_visu import *
+
+#---------------------------------------------------------------
+def GetPrsType2OldFactoryMethod(theVISUType):
+ if theVISUType == VISU.TGAUSSPOINTS:
+ return myVisu.GaussPointsOnField
+ if theVISUType == VISU.TSCALARMAP:
+ return myVisu.ScalarMapOnField
+ if theVISUType == VISU.TISOSURFACE:
+ return myVisu.IsoSurfacesOnField
+ if theVISUType == VISU.TCUTPLANES:
+ return myVisu.CutPlanesOnField
+ if theVISUType == VISU.TCUTLINES:
+ return myVisu.CutLinesOnField
+ if theVISUType == VISU.TPLOT3D:
+ return myVisu.Plot3DOnField
+ if theVISUType == VISU.TDEFORMEDSHAPE:
+ return myVisu.DeformedShapeOnField
+ if theVISUType == VISU.TVECTORS:
+ return myVisu.VectorsOnField
+ if theVISUType == VISU.TSTREAMLINES:
+ return myVisu.StreamLinesOnField
+ if theVISUType == VISU.TSCALARMAPONDEFORMEDSHAPE:
+ return myVisu.ScalarMapOnDeformedShapeOnField
+ return None
+
+
+#---------------------------------------------------------------
+def WalkTroughTimeStamps(theVISUType,
+ theResult, theMeshName,theEntity, theFieldName, theTimeStampNumber,
+ theViewManager):
+ anOldFactoryMethod = GetPrsType2OldFactoryMethod(theVISUType)
+ aPrs3d = anOldFactoryMethod(theResult, theMeshName, theEntity, theFieldName, theTimeStampNumber)
+
+ aPrs3d = myVisu.CreatePrs3d(theVISUType, myVisu.GetCurrentStudy())
+ aPrs3d.SetResultObject(theResult)
+ aPrs3d.SetMeshName(theMeshName)
+ aPrs3d.SetEntity(theEntity)
+ aPrs3d.SetFieldName(theFieldName)
+ aPrs3d.SetTimeStampNumber(theTimeStampNumber)
+ if not aPrs3d.Apply(0):
+ print "It is impossible to create such kind of presentation (%s) with the given parameters" % theVISUType
+ print "\ttheMeshName = '%s'" % theMeshName
+ print "\ttheEntity = %s" % theEntity
+ print "\ttheFieldName = '%s'" % theFieldName
+ print "\ttheTimeStampNumber = %s" % theTimeStampNumber
+ return
+
+ aView = theViewManager.Create3DView();
+ aView.SetTitle("To test presentation of %s type" % theVISUType)
+ aView.Display(aPrs3d);
+ aView.FitAll()
+
+ aDelay = 0.0
+ aRange = aPrs3d.GetTimeStampsRange()
+ for anInfo in aRange:
+ print "%d (%s); " % (anInfo.myNumber, anInfo.myTime)
+ aPrs3d.SetTimeStampNumber(anInfo.myNumber)
+ aPrs3d.Apply(0)
+ aView.Update();
+ time.sleep(aDelay)
+ pass
+ pass
+
+
+#---------------------------------------------------------------
+PRS3D_TYPE_LIST = []
+PRS3D_TYPE_LIST.append(VISU.TGAUSSPOINTS)
+PRS3D_TYPE_LIST.append(VISU.TSCALARMAP)
+PRS3D_TYPE_LIST.append(VISU.TISOSURFACE)
+PRS3D_TYPE_LIST.append(VISU.TCUTPLANES)
+PRS3D_TYPE_LIST.append(VISU.TCUTLINES)
+PRS3D_TYPE_LIST.append(VISU.TPLOT3D)
+PRS3D_TYPE_LIST.append(VISU.TDEFORMEDSHAPE)
+PRS3D_TYPE_LIST.append(VISU.TVECTORS)
+PRS3D_TYPE_LIST.append(VISU.TSTREAMLINES)
+PRS3D_TYPE_LIST.append(VISU.TSCALARMAPONDEFORMEDSHAPE)
+
+
+#---------------------------------------------------------------
+aMedFile = "TimeStamps.med"
+aMedFile = "ResOK_0000.med"
+aMedFile = os.getenv('DATA_DIR') + '/MedFiles/' + aMedFile
+aResult = myVisu.ImportFile(aMedFile)
+
+aMeshName ="dom"
+anEntity = VISU.NODE
+aFieldName = "vitesse";
+aTimeStampNumber = 1
+
+aViewManager = myVisu.GetViewManager();
+
+WalkTroughTimeStamps(VISU.TSCALARMAPONDEFORMEDSHAPE, aResult, aMeshName, anEntity, aFieldName, aTimeStampNumber, aViewManager)
+
+for aVISUType in PRS3D_TYPE_LIST:
+ WalkTroughTimeStamps(aVISUType, aResult, aMeshName, anEntity, aFieldName, aTimeStampNumber, aViewManager)
+ pass
+
+anEntity = VISU.CELL
+aFieldName = "pression";
+
+WalkTroughTimeStamps(VISU.TGAUSSPOINTS, aResult, aMeshName, anEntity, aFieldName, aTimeStampNumber, aViewManager)
#include "VVTK_ViewWindow.h"
-VVTK_Viewer::
-VVTK_Viewer()
+#include "VTKViewer_Algorithm.h"
+#include "SVTK_Functor.h"
+#include "VISU_Actor.h"
+#include "SVTK_View.h"
+#include "SVTK_Prs.h"
+
+#include <vtkActorCollection.h>
+#include <vtkRenderer.h>
+
+//---------------------------------------------------------------
+VVTK_Viewer
+::VVTK_Viewer()
{
}
-VVTK_Viewer::
-~VVTK_Viewer()
+//---------------------------------------------------------------
+VVTK_Viewer
+::~VVTK_Viewer()
{
}
-//==========================================================
+//---------------------------------------------------------------
SUIT_ViewWindow*
-VVTK_Viewer::
-createView( SUIT_Desktop* theDesktop )
+VVTK_Viewer
+::createView( SUIT_Desktop* theDesktop )
{
TViewWindow* aViewWindow = new TViewWindow (theDesktop);
aViewWindow->Initialize(this);
return aViewWindow;
}
+
+//---------------------------------------------------------------
+void
+VVTK_Viewer
+::Display(const SALOME_VTKPrs* thePrs)
+{
+ // try do downcast object
+ if(const SVTK_Prs* aPrs = dynamic_cast<const SVTK_Prs*>(thePrs)){
+ if(aPrs->IsNull())
+ return;
+ if(vtkActorCollection* aCollection = aPrs->GetObjects()){
+ aCollection->InitTraversal();
+ while(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(aCollection->GetNextActor())){
+ if(!anActor->GetFactory()->GetActiveState())
+ continue;
+ QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
+ for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i))){
+ if(SVTK_View* aView = aViewWindow->getView()){
+ aView->Display(anActor, false);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------
+namespace VVTK
+{
+ struct TIsOneActorVisibleAction
+ {
+ bool& myResult;
+ TIsOneActorVisibleAction(bool& theResult):
+ myResult(theResult)
+ {
+ myResult = false;
+ }
+ void
+ operator()(SALOME_Actor* theActor)
+ {
+ if(!myResult)
+ myResult = theActor->GetVisibility();
+ }
+ };
+}
+
+//---------------------------------------------------------------
+bool
+VVTK_Viewer
+::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
+{
+ QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
+ for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i))){
+ bool aResult;
+ VVTK::TIsOneActorVisibleAction anAction(aResult);
+ SVTK::ForEachIf<SALOME_Actor>(aViewWindow->getRenderer()->GetActors(),
+ SVTK::TIsSameIObject<SALOME_Actor>(theIO),
+ anAction);
+ return anAction.myResult;
+ }
+
+ return false;
+}
public:
typedef VVTK_ViewWindow TViewWindow;
- static QString Type() { return "VVTK"; }
+
+ static
+ QString
+ Type()
+ {
+ return "VVTK";
+ }
VVTK_Viewer();
- virtual ~VVTK_Viewer();
+
+ virtual
+ ~VVTK_Viewer();
//! See #SUIT_ViewModel::createView
- virtual SUIT_ViewWindow* createView(SUIT_Desktop*);
+ virtual
+ SUIT_ViewWindow*
+ createView(SUIT_Desktop*);
//! See SUIT_ViewModel::getType
- virtual QString getType() const { return Type(); }
+ virtual
+ QString
+ getType() const
+ {
+ return Type();
+ }
+
+ //! See #SALOME_View::Display( const SALOME_Prs* )
+ virtual
+ void
+ Display(const SALOME_VTKPrs* thePrs);
+
+ //! See #SALOME_View::isVisible( const Handle(SALOME_InteractiveObject)& )
+ virtual
+ bool
+ isVisible(const Handle(SALOME_InteractiveObject)& theIO);
};
#endif
bool theIsHighlight,
bool theIsUpdate )
{
+ if(GetSelector()->AddIObject(theIO))
+ GetSelector()->EndPickCallback();
myView1->highlight( theIO, theIsHighlight, theIsUpdate );
myView2->highlight( theIO, theIsHighlight, theIsUpdate );
}