HDF5_LIBS=@HDF5_LIBS@
HDF5_MT_LIBS=@HDF5_MT_LIBS@
+# MED2
+
+MED2_INCLUDES=@MED2_INCLUDES@
+MED2_LIBS=@MED2_LIBS@
+MED2_MT_LIBS=@MED2_MT_LIBS@
+
# OpenCasCade
OCC_INCLUDES=@CAS_CPPFLAGS@
cd $(top_srcdir) ; aclocal -I adm_local/unix/config_files -I @KERNEL_ROOT_DIR@/salome_adm/unix/config_files \
-I @GUI_ROOT_DIR@/adm_local/unix/config_files \
-I @MED_ROOT_DIR@/adm_local/unix/config_files
+
exit
fi
+########################################################################
+# Test if the MED2HOME is set correctly
+
+if test ! -d "${MED2HOME}"; then
+ echo "failed : MED2HOME variable is not correct !"
+ exit
+fi
+
########################################################################
# find_in - utility function
#
CHECK_HDF5
+echo
+echo ---------------------------------------------
+echo testing MED2
+echo ---------------------------------------------
+echo
+
+CHECK_MED2
+
echo
echo ---------------------------------------------
echo BOOST Library
echo
echo Configure
-variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok omniORB_ok occ_ok qwt_ok doxygen_ok graphviz_ok Kernel_ok Med_ok"
+variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok occ_ok qwt_ok doxygen_ok graphviz_ok Kernel_ok Med_ok"
for var in $variables
do
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.*/
*/
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
<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 -->
@COMMENCE@
EXPORT_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_AppendPolyData.hxx \
VISU_ExtractUnstructuredGrid.hxx
# Libraries targets
LIB = libVisuConvertor.la
LIB_SRC = \
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_AppendPolyData.cxx \
+ VISU_MergeFilter.cxx
# Executables targets
BIN = VISUConvertor
static int MYDEBUG = 0;
#endif
-//#define _DEXCEPT_
+//#define _DEBUG_ID_MAPPING_
+#define _DEXCEPT_
typedef vtkUnstructuredGrid TOutput;
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 <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[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
- aName.sprintf("%s_%d",aNewName,theTimeId);
+ aName.sprintf("%s_%d", aNewName, theTimeId);
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 "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
- {};
-
-
- //---------------------------------------------------------------
- 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.
- };
-
-
- //---------------------------------------------------------------
- //! 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
- };
-
-
- //---------------------------------------------------------------
- typedef std::set<PFamily> 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
- 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
{
-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
#include "VISU_ConvertorUtils.hxx"
+#include <vtkCellType.h>
#include <vtkUnstructuredGridWriter.h>
+#include <vtkPolyDataWriter.h>
#include <vtkTimerLog.h>
#ifdef _DEBUG_
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();
+ }
+
+
+ //---------------------------------------------------------------
TTimerLog
::TTimerLog(int theIsDebug,
const std::string& theName):
BEGMSG(myIsDebug > 1,"{\n");
}
+ //---------------------------------------------------------------
TTimerLog
::~TTimerLog()
{
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 "VISU_ConvertorDef.hxx"
+#include "MED_Utilities.hxx"
-#include <vtkCellType.h>
+#include <vtkSystemIncludes.h>
-#include "MED_Utilities.hxx"
+#include <string>
class vtkUnstructuredGrid;
+class vtkPolyData;
class vtkTimerLog;
+#ifndef VISU_ENABLE_QUADRATIC
+ #define VISU_ENABLE_QUADRATIC
+ #define VISU_USE_VTK_QUADRATIC
+#endif
+
namespace MED
{
class PrefixPrinter;
}
-namespace VISU{
+namespace VISU
+{
+ //---------------------------------------------------------------
+ //! 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
void
- WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName);
+ WriteToFile(vtkUnstructuredGrid* theDataSet,
+ const std::string& theFileName);
+ //---------------------------------------------------------------
+ //! The utility function allows to write vtkPolyData to a file with defined name
+ void
+ WriteToFile(vtkPolyData* theDataSet,
+ const std::string& theFileName);
+
+ //---------------------------------------------------------------
+ //! The utility class that allows to perform perfomance mesurement
class TTimerLog
{
int myIsDebug;
vtkTimerLog* myTimerLog;
MED::PrefixPrinter myPrefixPrinter;
public:
+
TTimerLog(int theIsDebug,
const std::string& theName);
~TTimerLog();
// Module : VISU
#include "VISU_Convertor_impl.hxx"
-#include "VISU_ConvertorUtils.hxx"
-#include "VTKViewer_AppendFilter.h"
-#include "VISU_MergeFilter.hxx"
-#include "VTKViewer_CellLocationsArray.h"
-
-#include <vtkPoints.h>
-#include <vtkUnstructuredGrid.h>
-
-#include <vtkIdList.h>
-#include <vtkCellType.h>
-#include <vtkCellArray.h>
-#include <vtkFloatArray.h>
-#include <vtkUnsignedCharArray.h>
-#include <vtkPointData.h>
-#include <vtkCellData.h>
-#include <vtkCellLinks.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()->GetUnstructuredGridOutput();
- }
-
-
- //---------------------------------------------------------------
- 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():
- myPoints(vtkPoints::New()),
- myNbPoints(0)
- {
- myPoints->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);
- }
- return myFilter->GetUnstructuredGridOutput();
- }
-
- 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);
- }
-
-
- //---------------------------------------------------------------
- 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
- {
- if(myElemObj2VTKID.empty())
- return theID;
- else{
- TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
- if(anIter != myElemObj2VTKID.end())
- return anIter->second;
- }
- return -1;
- }
-
- vtkIdType
- TMeshOnEntityImpl
- ::GetElemObjID(vtkIdType theID) const
- {
- vtkIdType anInputID, aStartId, anInputDataSetID;
- const TVTKAppendFilter& anAppendFilter = GetFilter();
- anAppendFilter->GetCellInputID(theID,anInputID,aStartId,anInputDataSetID);
- const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputDataSetID];
- return aSubMesh->GetElemObjID(anInputID);
- }
-
- 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;
- }
+#include "VISU_Structures_impl.hxx"
+#include "VISU_PointCoords.hxx"
+#include "VISU_MeshValue.hxx"
- 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 TIDMapperFilter())
- {}
-
- 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;
- }
- }
+#include "VISU_AppendPolyData.hxx"
+#include "VTKViewer_AppendFilter.h"
+#include "VTKViewer_CellLocationsArray.h"
- 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;
+#include "VISU_ConvertorUtils.hxx"
-#else
+#include <vtkUnstructuredGrid.h>
+#include <vtkPolyData.h>
- case VISU::eSEG3:
-#if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)
- return VTK_QUADRATIC_EDGE;
-#else
- return VTK_POLY_LINE;
-#endif
+#include <vtkPoints.h>
+#include <vtkPointData.h>
+#include <vtkCellData.h>
- case VISU::eTRIA6:
-#if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)
- return VTK_QUADRATIC_TRIANGLE;
-#else
- return VTK_POLYGON;
-#endif
+#include <vtkIdList.h>
+#include <vtkCellType.h>
+#include <vtkCellArray.h>
+#include <vtkCellLinks.h>
+#include <vtkUnsignedCharArray.h>
- case VISU::eQUAD8:
-#if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)
- return VTK_QUADRATIC_QUAD;
-#else
- return VTK_POLYGON;
-#endif
+#include <qstring.h>
+#include <qfileinfo.h>
- case VISU::eTETRA10:
-#if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)
- return VTK_QUADRATIC_TETRA;
-#else
- return VTK_CONVEX_POINT_SET;
-#endif
+#include <memory>
- 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 = 1;
+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;
-
-
- //---------------------------------------------------------------
- vtkPoints*
- GetPoints(const PMeshImpl& theMesh)
- {
- TVTKPoints& aPoints = theMesh->myPoints;
- const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
-
- if(!theMesh->myIsVTKDone){
- 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;
- }
- }
-
- vtkIdType aNbPoints = aCoords.GetNbPoints();
- aPoints->SetNumberOfPoints(aNbPoints);
-
- INITMSG(MYDEBUG,"GetPoints - 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));
- }
-
- theMesh->myIsVTKDone = true;
-
- if(MYVTKDEBUG) aPoints->DebugOn();
- }
-
- return aPoints.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;
//---------------------------------------------------------------
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);
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())
}
- //---------------------------------------------------------------
- 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<float> 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;
//---------------------------------------------------------------
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->SetPoints(GetPoints(theMesh));
+ aSource->SetPoints(theMesh->GetPoints());
INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
GetCells(aSource,theSubProfile,theProfile,theMeshOnEntity);
BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
//---------------------------------------------------------------
void
- 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->myIsVTKDone)
return;
+ VISU::TTimerLog aTimerLog(MYDEBUG,"GetMeshOnProfile");
+ INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<<theMeshOnEntity->myEntity<<endl);
+
theProfile->myMeshOnEntity = theMeshOnEntity.get();
- const TVTKAppendFilter& anAppendFilter = theProfile->GetFilter();
- anAppendFilter->SetPoints(GetPoints(theMesh));
+ const VISU::PAppendFilter& anAppendFilter = theProfile->GetFilter();
+ anAppendFilter->SetPoints(theMesh->GetPoints());
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]);
- }
- }
- }
- aFloatArray->Delete();
- aDataArray->Delete();
- }
-
-
//---------------------------------------------------------------
void
- GetSource(const TVTKSource& theSource,
- const PGaussSubMeshImpl& theGaussSubMesh,
- const PMeshOnEntityImpl& theMeshOnEntity)
+ GetSource(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->SetVerts(aConnectivity);
+ aSource->SetPoints(aCoords.GetPoints());
- aCellLocationsArray->Delete();
- aCellTypesArray->Delete();
aConnectivity->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();
+ GetSource(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();
+ 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(; anIter != aGeom2GaussSubMesh.end(); anIter++){
- PGaussSubMeshImpl aGaussSubMesh = anIter->second;
- if(aGaussSubMesh->myStatus == eRemoveAll)
+ VISU::PGaussSubMeshImpl aGaussSubMesh = anIter->second;
+ if(aGaussSubMesh->myStatus == VISU::eRemoveAll)
continue;
GetGaussSubMesh(theMesh,
theGaussMesh,
aGaussSubMesh);
- const TVTKSource& aSource = aGaussSubMesh->GetSource();
+ const VISU::PPolyData& aSource = aGaussSubMesh->GetSource();
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->SetPoints(GetPoints(aMesh));
+ anAppendFilter->SetPoints(aMesh->GetPoints());
- const TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
- TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
+ const VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
+ VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
- TID2ID& anElemObj2VTKID = aMeshOnEntity->myElemObj2VTKID;
- TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr;
+ 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;
- const TVTKSource& aSource = aSubMesh->GetSource();
- aSource->SetPoints(GetPoints(aMesh));
+ VISU::PSubMeshImpl aSubMesh = anIter->second;
+ const VISU::PUnstructuredGrid& aSource = aSubMesh->GetSource();
+ aSource->SetPoints(aMesh->GetPoints());
GetCellsOnSubMesh(aSource,aMeshOnEntity,aSubMesh,aVGeom);
anAppendFilter->AddInput(aSource.GetPointer());
if(MYDEBUGWITHFILES){
std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
- std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
+ std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-Conv.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->SetPoints(GetPoints(aMesh));
+ aSource->SetPoints(aMesh->GetPoints());
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")+"-";
+ std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-Conv.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->SetPoints(GetPoints(aMesh));
+ anAppendFilter->SetPoints(aMesh->GetPoints());
- 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")+"-";
+ std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
aFileName += aMeshName + "-" + aGroupName + "-Conv.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::PIDMapperFilter& theIDMapperFilter,
+ const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper,
const VISU::PProfileImpl& theProfile,
const VISU::TEntity& theEntity)
{
- LoadMeshOnEntity(theMesh,theMeshOnEntity);
- GetMeshOnEntity(theMeshOnEntity->myMeshName,theMeshOnEntity->myEntity);
- GetMeshOnProfile(theMesh,theMeshOnEntity,theProfile);
-
- theIDMapperFilter->myIDMapper = theProfile;
- TVTKOutput* anOutput = theIDMapperFilter->GetVTKOutput();
- const TVTKSource& aSource = theIDMapperFilter->mySource.GetSource();
- ::GetTimeStampOnProfile(aSource,theField,theValForTime,theEntity);
-
+ 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;
}
//---------------------------------------------------------------
-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
- PIDMapperFilter anIDMapperFilter = aValForTime->myIDMapperFilter;
+ VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
#ifndef _DEXCEPT_
try{
#endif
- if(!anIDMapperFilter->myIsVTKDone){
- LoadValForTimeOnMesh(aMesh,aMeshOnEntity,aField,aValForTime);
+ if(!anUnstructuredGridIDMapper->myIsVTKDone){
+ VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnMesh");
+ LoadValForTimeOnMesh(aMesh, aMeshOnEntity, aField, aValForTime);
- TVTKOutput* anOutput;
+ vtkUnstructuredGrid* anOutput = NULL;
try{
anOutput = GetTimeStampOnProfile(aMesh,
aVTKMeshOnEntity,
aField,
aValForTime,
- anIDMapperFilter,
+ anUnstructuredGridIDMapper,
aValForTime->myProfile,
aMeshOnEntity->myEntity);
}catch(std::exception& exc){
aMeshOnEntity,
aField,
aValForTime,
- anIDMapperFilter,
+ anUnstructuredGridIDMapper,
aValForTime->myProfile,
aVTKMeshOnEntity->myEntity);
}
- 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) + "-Conv.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);
}
#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)) +
+ 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) + "-Conv.vtk";
- VISU::WriteToFile(anOutput,aFileName);
+ 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,
+::FindMeshOnEntity(const std::string& theMeshName,
const VISU::TEntity& theEntity)
{
- 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,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
+ EXCEPTION(std::runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
- PMeshOnEntityImpl 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];
aVTKMeshOnEntity = aMeshOnEntityMap[VISU::FACE_ENTITY];
else if(aMeshOnEntityMap.find(VISU::NODE_ENTITY) != aMeshOnEntityMap.end())
aVTKMeshOnEntity = aMeshOnEntityMap[VISU::EDGE_ENTITY];
- }else
- aVTKMeshOnEntity = aMeshOnEntity;
+ }
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;
-
#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
- vtkIdType
- VISUGeom2NbNodes(EGeometry theGeom);
-
- //! Maps VISU geometrical type to VTK one
- vtkIdType
- VISUGeom2VTK(EGeometry theGeom);
-
- //---------------------------------------------------------------
- using MED::TCSlice;
- using MED::TSlice;
-
- typedef vtkUnstructuredGrid TDataSet;
+#include "VISU_ConvertorDef_impl.hxx"
- typedef vtkSmartPointer<TDataSet> TVTKSource;
- typedef vtkSmartPointer<vtkPoints> TVTKPoints;
- typedef vtkSmartPointer<VISU_MergeFilter> TVTKMergeFilter;
-
- typedef vtkSmartPointer<VTKViewer_AppendFilter> TVTKAppendFilter;
-
- typedef vtkFloatingPointType TCoord;
-
- //---------------------------------------------------------------
- //! Define an utility base class which is repsonsible for preventing repetion
- struct 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 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 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 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();
- };
-
-
- //---------------------------------------------------------------
- //! Define a container for VTK representation
- /*!
- This container allow to assign data to mesh and represent them into single VTK representation
- */
- class 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<TAppendFilter> PAppendFilter;
-
-
- //---------------------------------------------------------------
- typedef TVector<TCoord> TCoordArray;
- typedef TSlice<TCoordArray> TCoordSlice;
- typedef TCSlice<TCoordArray> TCCoordSlice;
-
- //! This class is responsible for representation of mesh nodes
- class 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 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 TMeshImpl: virtual TMesh,
- virtual TIsVTKDone
- {
- PNamedPointCoords myNamedPointCoords; //!< Keeps intermediate representation of the nodes
-
- TVTKPoints myPoints; //!< 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 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 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 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;
-
-
- //---------------------------------------------------------------
- struct TGaussImpl;
- typedef SharedPtr<TGaussImpl> PGaussImpl;
-
- //! 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
-
- //! 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 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 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 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 TSubMeshImpl: virtual TSource
- {
-
- //! 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 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 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 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 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 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 TValForTimeImpl: virtual TValForTime
- {
- PGaussPtsIDFilter myGaussPtsIDFilter; //!< Keep VTK representation for mesh and data on Gauss Points
- PIDMapperFilter 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);
//! 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::PIDMapperFilter& theIDMapperFilter,
+ const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter,
const VISU::PProfileImpl& theProfile,
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 <string>
class vtkUnstructuredGrid;
+class vtkPolyData;
+class vtkDataSet;
class vtkCell;
namespace VISU
{
- using MED::SharedPtr;
-
//---------------------------------------------------------------
//! Defines a basic class for intemediate data structures
struct TBaseStructure
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 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 SharedPtr<TIDMapper> PIDMapper;
+ 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;
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
static int MYVALUEDEBUG = 0;
static int MY_FAMILY_DEBUG = 0;
static int MY_GROUP_DEBUG = 0;
MEDEntityToVTK(MED::EEntiteMaillage theMEDEntity)
{
switch(theMEDEntity){
- case MED::eNOEUD: return NODE_ENTITY;
- case MED::eARETE: return EDGE_ENTITY;
- case MED::eFACE: return FACE_ENTITY;
- case MED::eMAILLE: return CELL_ENTITY;
+ case MED::eNOEUD: return VISU::NODE_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 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::NODE_ENTITY: return MED::eNOEUD;
+ 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 == NODE_ENTITY)
+ 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();
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<<
//---------------------------------------------------------------
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::iterator aFamInter = theFamilyInfoSet.begin();
- for(;aFamInter != theFamilyInfoSet.end();aFamInter++){
- TInt anId = (*aFamInter)->GetId();
+ MED::TFamilyInfoSet::const_iterator aFamInter = theFamilyInfoSet.begin();
+ 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;
aFamily = aFamilyMapIter->second;
}
+ //---------------------------------------------------------------
+ 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
::GetElemObjID(vtkIdType theID) const
{
if(myIsElemNum)
- return myElemNum[theID];
+ return (*myElemNum)[theID];
else
return theID;
}
+ unsigned long int
+ TMEDSubProfile
+ ::GetMemorySize()
+ {
+ size_t aSize = TSubProfileImpl::GetMemorySize();
+ if(myIsElemNum)
+ aSize += myElemNum->size() * sizeof(MED::TInt);
+ return aSize;
+ }
+
//---------------------------------------------------------------
void
TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
if(myIsElemNum)
- aCellID = myElemNum[aCellID];
+ aCellID = (*myElemNum)[aCellID];
else
aCellID += theStartID;
- 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");
MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
TInt aNbMeshes = aMed->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 = aMed->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");
MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
TInt aNbMeshes = aMed->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 = aMed->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::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(aMed);
MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(aMed);
TInt aNbMeshes = aMed->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 = aMed->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 = aMed->GetEntityInfo(aMeshInfo);
for(TInt iField = 1; iField <= aNbFields; iField++){
- TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPFieldInfo()");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPFieldInfo()");
MED::PFieldInfo aFieldInfo = aMed->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 = aMed->GetPTimeStampInfo(aFieldInfo,
- aMEntity,
- aGeom2Size,
- iTimeStamp);
-
- MED::PTimeStampVal aTimeStampVal = aMed->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::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
- if(aGaussIter == aGeom2Gauss.end())
- aNbGauss = 1;
+ MED::PTimeStampInfo aTimeStampInfo =
+ aMed->GetPTimeStampInfo(aFieldInfo,
+ aMEntity,
+ aGeom2Size,
+ iTimeStamp);
- 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 =
+ aMed->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");
MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
TInt aNbMeshes = aMed->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 = aMed->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");
::LoadMeshOnEntity(VISU::PMeshImpl theMesh,
VISU::PMeshOnEntityImpl theMeshOnEntity)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnEntity");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnEntity");
INITMSG(MYDEBUG,"LoadMeshOnEntity"<<endl);
MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
- const TEntity& anEntity = theMeshOnEntity->myEntity;
+ const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
- if(anEntity == NODE_ENTITY){
+ if(anEntity == VISU::NODE_ENTITY){
isPointsUpdated += LoadPoints(aMed,theMesh);
}else{
isPointsUpdated += LoadPoints(aMed,theMesh);
VISU::PMeshOnEntityImpl theMeshOnEntity,
VISU::PFamilyImpl theFamily)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadFamilyOnEntity");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadFamilyOnEntity");
INITMSG(MYDEBUG,"LoadFamilyOnEntity"<<endl);
MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
- const TEntity& anEntity = theMeshOnEntity->myEntity;
+ const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
- if(anEntity == NODE_ENTITY){
+ if(anEntity == VISU::NODE_ENTITY){
isPointsUpdated += LoadPointsOnFamily(aMed,theMesh,theFamily);
}else{
isPointsUpdated += LoadPoints(aMed,theMesh);
::LoadMeshOnGroup(VISU::PMeshImpl theMesh,
const VISU::TFamilySet& theFamilySet)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnGroup");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnGroup");
INITMSG(MYDEBUG,"LoadMeshOnGroup"<<endl);
MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
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];
+ VISU::PMEDFamily aFamily = *aFamilyIter;
+ const VISU::TEntity& anEntity = aFamily->myEntity;
+ const VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
isPointsUpdated += LoadPoints(aMed,theMesh);
- if(anEntity == NODE_ENTITY){
+ if(anEntity == VISU::NODE_ENTITY){
isPointsUpdated += LoadPointsOnFamily(aMed,theMesh,aFamily);
}else{
isCellsOnEntityUpdated += LoadCellsOnFamily(aMed,theMesh,aMeshOnEntity,aFamily);
VISU::PFieldImpl theField,
VISU::PValForTimeImpl theValForTime)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnMesh");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnMesh");
INITMSG(MYDEBUG,"LoadValForTimeOnMesh"<<endl);
MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
- const TEntity& anEntity = theMeshOnEntity->myEntity;
+ const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
isPointsUpdated += LoadPoints(aMed,theMesh);
- if(anEntity != NODE_ENTITY)
+ if(anEntity != VISU::NODE_ENTITY)
isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity);
int isFieldUpdated = LoadValForTimeOnMesh(aMed,theMesh,theMeshOnEntity,theField,theValForTime);
VISU::PFieldImpl theField,
VISU::PValForTimeImpl theValForTime)
{
- TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnGaussPts");
+ VISU::TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnGaussPts");
INITMSG(MYDEBUG,"LoadValForTimeOnGaussPts"<<endl);
MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1());
- const TEntity& anEntity = theMeshOnEntity->myEntity;
+ const VISU::TEntity& anEntity = theMeshOnEntity->myEntity;
int isPointsUpdated = 0, isCellsOnEntityUpdated = 0;
- if(anEntity != NODE_ENTITY)
+ if(anEntity != VISU::NODE_ENTITY)
isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity);
int isFieldUpdated = LoadValForTimeOnGaussPts(aMed,theMesh,theMeshOnEntity,theField,theValForTime);
::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 = NODE_ENTITY;
+ aMeshOnEntity->myEntity = VISU::NODE_ENTITY;
INITMSG(MYDEBUG,"LoadPoints - theMesh->myIsDone = "<<theMesh->myIsDone<<"'\n");
//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);
-
- 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];
- }
+ VISU::PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
+ aNamedPointCoords->Init(aNodeInfo, theMed->GetVersion());
- 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);
+ VISU::PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
+ aNamedPointCoords->Init(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];
- }
- }
-
- 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 = 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_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;
+
+ //! 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;
}
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);
};
};
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_API.cxx
+ *
+ * \brief see MULTIPR_API.hxx
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include "MULTIPR_API.hxx"
+#include "MULTIPR_Globals.hxx"
+#include "MULTIPR_Mesh.hxx"
+#include "MULTIPR_MeshDis.hxx"
+#include "MULTIPR_Utils.hxx"
+#include "MULTIPR_Exceptions.hxx"
+
+extern "C"
+{
+ #include "med.h"
+}
+
+#include "MEDSPLITTER_API.hxx"
+
+#include <iostream>
+#include <fstream>
+#include <string>
+
+using namespace std;
+
+
+//*****************************************************************************
+// Implementation
+//*****************************************************************************
+
+const char* multipr::getVersion()
+{
+ return "1.0.5";
+}
+
+
+void multipr::partitionneDomaine(const char* pMEDfilename, const char* pMeshName)
+{
+ if (pMEDfilename == NULL) throw NullArgumentException("pMEDfilename should not be NULL", __FILE__, __LINE__);
+ if (pMeshName == NULL) throw NullArgumentException("pMeshName should not be NULL", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Read the sequential mesh
+ //---------------------------------------------------------------------
+ cout << "Read sequential MED file: " << pMEDfilename << ": please wait... " << endl;
+
+ multipr::Mesh mesh;
+ mesh.readSequentialMED(pMEDfilename, pMeshName);
+ cout << mesh << endl;
+
+ //---------------------------------------------------------------------
+ // Build distributed mesh from groups
+ //---------------------------------------------------------------------
+ cout << "Build distributed mesh: please wait... " << endl;
+
+ multipr::MeshDis* meshDis = NULL;
+
+ try
+ {
+ meshDis = mesh.splitGroupsOfElements();
+
+ //-------------------------------------------------------------
+ // Write distributed mesh
+ //-------------------------------------------------------------
+ cout << "Write distributed mesh: please wait... " << endl;
+ string strPrefix = removeExtension(pMEDfilename, ".med");
+ meshDis->writeDistributedMED(strPrefix.c_str());
+
+ delete meshDis;
+ }
+ catch (RuntimeException& e)
+ {
+ delete meshDis;
+ throw e;
+ }
+}
+
+
+void multipr::partitionneGrain(
+ const char* pMEDfilename,
+ const char* pGroupName,
+ int pNbParts,
+ int pPartitionner)
+{
+ if (pMEDfilename == NULL) throw NullArgumentException("pMEDfilename should not be NULL", __FILE__, __LINE__);
+ if (pGroupName == NULL) throw NullArgumentException("pGroupName should not be NULL", __FILE__, __LINE__);
+ if (pNbParts < 2) throw IllegalArgumentException("pNbParts should be >= 2", __FILE__, __LINE__);
+ if ((pPartitionner != MULTIPR_METIS) && (pPartitionner != MULTIPR_SCOTCH)) throw NullArgumentException("pPartitionner should be METIS (0) or SCOTCH (1)", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Read the distributed mesh
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Read distributed MED file: " << pMEDfilename << ": please wait... " << endl);
+
+ int ret = MEDformatConforme(pMEDfilename);
+ if (ret == 0) throw IOException("waiting for a distributed MED file (not a sequential one)", __FILE__, __LINE__);
+
+ multipr::MeshDis meshDis;
+ meshDis.readDistributedMED(pMEDfilename);
+ cout << meshDis << endl;
+
+ //---------------------------------------------------------------------
+ // Split the given part (pGroupName)
+ //---------------------------------------------------------------------
+ if (pPartitionner == MULTIPR_METIS)
+ {
+ cout << "Use METIS" << endl;
+ }
+ else if (pPartitionner == MULTIPR_SCOTCH)
+ {
+ cout << "Use SCOTCH" << endl;
+ }
+
+ meshDis.splitPart(pGroupName, pNbParts, pPartitionner);
+ cout << meshDis << endl;
+
+ //---------------------------------------------------------------------
+ // Write new distributed mesh
+ //---------------------------------------------------------------------
+ string strPrefix = multipr::removeExtension(pMEDfilename, ".med");
+ meshDis.writeDistributedMED(strPrefix.c_str());
+}
+
+
+void multipr::decimePartition(
+ const char* pMEDfilename,
+ const char* pPartName,
+ const char* pFieldName,
+ int pFieldIt,
+ const char* pFilterName,
+ double pTMed,
+ double pTLow,
+ double pRadius,
+ int pBoxing)
+{
+ //---------------------------------------------------------------------
+ // Check arguments
+ //---------------------------------------------------------------------
+ if (pMEDfilename == NULL) throw NullArgumentException("pMEDfilename should not be NULL", __FILE__, __LINE__);
+ if (pPartName == NULL) throw NullArgumentException("pPartName should not be NULL", __FILE__, __LINE__);
+ if (pFieldName == NULL) throw NullArgumentException("pFieldName should not be NULL", __FILE__, __LINE__);
+ if (pFieldIt < 1) throw IllegalArgumentException("pFieldIt: invalid field iteration; should be >= 1", __FILE__, __LINE__);
+ if (pTMed < 0.0) throw IllegalArgumentException("med res.: threshold must be > 0", __FILE__, __LINE__);
+ if (pTMed >= pTLow) throw IllegalArgumentException("threshold for med res. must be < threshold for low res.", __FILE__, __LINE__);
+ if (pRadius <= 0.0) throw IllegalArgumentException("radius should be > 0", __FILE__, __LINE__);
+ if ((pBoxing < 1) || (pBoxing > 200)) throw IllegalArgumentException("boxing should be in [1..200]", __FILE__, __LINE__);
+
+ cout << "--decim file=" << pMEDfilename << " part=" << pPartName << " filter=" << pFilterName << " tmed=" << pTMed << " tlow=" << pTLow << " radius=" << pRadius << endl;
+
+ //---------------------------------------------------------------------
+ // Read the distributed mesh
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Read distributed MED file: " << pMEDfilename << ": please wait... " << endl);
+
+ int ret = MEDformatConforme(pMEDfilename);
+ if (ret == 0) throw IOException("waiting for a distributed MED file (not a sequential one)", __FILE__, __LINE__);
+
+ multipr::MeshDis meshDis;
+ meshDis.readDistributedMED(pMEDfilename);
+ cout << meshDis << endl;
+
+ //---------------------------------------------------------------------
+ // Create 3 resolutions of the given part
+ //---------------------------------------------------------------------
+ meshDis.decimatePart(
+ pPartName,
+ pFieldName,
+ pFieldIt,
+ pFilterName,
+ pTMed,
+ pTLow,
+ pRadius,
+ pBoxing);
+ cout << meshDis << endl;
+
+ //---------------------------------------------------------------------
+ // Write new distributed mesh
+ //---------------------------------------------------------------------
+ string strPrefix = removeExtension(pMEDfilename, ".med"); // get prefix from the original MED filename
+ meshDis.writeDistributedMED(strPrefix.c_str());
+}
+
+
+int multipr::merge(
+ std::vector<std::string> pMEDFilenameSrc,
+ const char* pMeshName,
+ const char* pFieldName,
+ const char* pMEDFilenameDst)
+{
+ if (pMEDFilenameSrc.size() < 2) throw IllegalArgumentException("list must contain two files at least", __FILE__, __LINE__);
+ if (pMeshName == NULL) throw NullArgumentException("pMeshName1 should not be NULL", __FILE__, __LINE__);
+ if (pMEDFilenameDst == NULL) throw NullArgumentException("pMEDFilenameDst should not be NULL", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Read sources
+ //---------------------------------------------------------------------
+ std::vector<multipr::Mesh*> meshes;
+ for (unsigned i = 0 ; i < pMEDFilenameSrc.size() ; i++)
+ {
+ multipr::Mesh* mesh = new multipr::Mesh();
+ mesh->readSequentialMED(pMEDFilenameSrc[i].c_str(), pMeshName);
+ //mesh->setPrintAll(true);
+ //cout << (*mesh) << endl;
+ if (mesh->getNumberOfElements() != 0)
+ {
+ meshes.push_back(mesh);
+ }
+ else
+ {
+ delete mesh;
+ }
+ }
+
+ // if no mesh (all meshes are empty) => return
+ if (meshes.size() == 0) return 0;
+
+ // if only one non-empty mesh
+ if (meshes.size() == 1)
+ {
+ multipr::Mesh* mesh = meshes[0];
+ mesh->writeMED(pMEDFilenameDst);
+ delete mesh;
+ return 1;
+ }
+
+ //---------------------------------------------------------------------
+ // Merge sources and write resulting mesh to disk
+ //---------------------------------------------------------------------
+ multipr::Mesh* meshFirst = meshes.back();
+ meshes.pop_back();
+ multipr::Mesh* meshMerged = meshFirst->mergePartial(meshes, pFieldName, -1);
+ //meshMerged->setPrintAll(true);
+ //cout << (*meshMerged) << endl;
+
+ meshMerged->writeMED(pMEDFilenameDst);
+
+ delete meshMerged;
+ delete meshFirst;
+ for (unsigned i = 0 ; i < meshes.size(); i++)
+ {
+ delete meshes[i];
+ }
+ return 1;
+}
+
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_API.hxx
+ *
+ * \brief Main header of the high level MULTIPR API.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_API_HXX
+#define MULTIPR_API_HXX
+
+#include <vector>
+#include <string>
+
+namespace multipr
+{
+
+
+enum Partitionner
+{
+ MULTIPR_METIS = 0,
+ MULTIPR_SCOTCH = 1
+
+}; // enum Partitionner
+
+
+/**
+ * \fn const char* getVersion()
+ * \brief returns the current version of the MULTIPR API.
+ * \return the current version of the MULTIPR API.
+ */
+const char* getVersion();
+
+
+/**
+ * \fn void partitionneDomaine(const char* medFilename, const char* meshName)
+ * \brief creates a distributed MED file (v2.3) by extracting all the groups from the mesh of a sequential MED file.
+ * Assumes:
+ * - the file is in MED format and can be read using MED file v2.3.
+ * - the file is sequential (not a distributed MED).
+ * - the file only contains TETRA10 elements (dimension of space and mesh is 3).
+ * - the file have no profil.
+ * \param medFilename filename of any valid sequential MED file with TETRA10 elements only.
+ * \param meshName name of the mesh to be distributed.
+ * \throw RuntimeException if any error occurs.
+ */
+void partitionneDomaine(
+ const char* medFilename,
+ const char* meshName);
+
+
+/**
+ * \fn void partitionneGrain(const char* medFilename, const char* groupName, int nbParts, int partitionner)
+ * \brief creates a distributed MED file (V2.3) by splitting a group of a MED file previously created by partitionneDomaine.
+ * Assumes:
+ * - the file is a distributed MED file, previously created by partitionneDomaine()
+ * (=> each part only contain 1 mesh, TETRA10 elements only)
+ * - nbPart > 1
+ * \param medFilename filename of any valid distributed MED file previously created by partitionneDomaine().
+ * \param partName name of the part to be splitted.
+ * \param nbParts number of parts; must be > 1.
+ * \param partitionner use value MULTIPR_METIS for Metis or MULTIPR_SCOTCH for Scotch.
+ * \throw RuntimeException if any error occurs.
+ */
+ void partitionneGrain(
+ const char* medFilename,
+ const char* partName,
+ int nbParts,
+ int partitionner=MULTIPR_METIS);
+
+
+/**
+ * \fn void decimePartition(const char* medFilename, const char* partName, const char* fieldName, int fieldIt, const char* filterName, double tmed, double tlow, double radius);
+ * \brief creates 3 resolutions of the given part of a distributed MED file (V2.3).
+ * Assumes:
+ * - the file is a distributed MED file, previously created by partitionneDomaine() or partitionneGrain()
+ * (=> each part only contain 1 mesh, TETRA10 elements only)
+ * \param medFilename filename of any valid distributed MED file previously created by partitionneDomaine or partitionneGrain.
+ * \param partName name of the part to be decimated.
+ * \param fieldName name of the field used for decimation.
+ * \param fieldIt iteration (time step) of the field.
+ * \param filterName name of the filter to be used.
+ * \param tmed threshold used for medium resolution.
+ * \param tlow threshold used for low resolution; tmed must be less than tlow
+ * \param radius radius used to determine the neighbourhood.
+ * \param boxing number of cells along each axis; must be >= 1; e.g. if 100 then acceleration grid will have 100*100*100 = 10**6 cells.
+ * \throw RuntimeException if any error occurs.
+ */
+void decimePartition(
+ const char* medFilename,
+ const char* partName,
+ const char* fieldName,
+ int fieldIt,
+ const char* filterName,
+ double tmed,
+ double tlow,
+ double radius,
+ int boxing);
+
+
+/**
+ * \fn void merge(...);
+ * \brief merge a list of sequential MED file if possible.
+ * \param medFilenameSrc list of source file (sequential MED files).
+ * \param meshName name of the mesh (all mesh must have the same name).
+ * \param fieldName name of the field to merge (if NULL, merge all fields).
+ * \param medFilenameDst destination file.
+ * \return 1 if a mesh has been generated, 0 otherwise (e.g. if all the sources are empty meshes).
+ * \throw RuntimeException if any error occurs.
+ */
+int merge(
+ std::vector<std::string> medFilenameSrc,
+ const char* meshName,
+ const char* fieldName,
+ const char* medFilenameDst);
+
+
+} // namespace MULTIPR
+
+
+#endif // MULTIPR_API_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_DecimationAccel.cxx
+ *
+ * \brief see MULTIPR_DecimationAccel.hxx
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include "MULTIPR_DecimationAccel.hxx"
+#include "MULTIPR_PointOfField.hxx"
+#include "MULTIPR_Exceptions.hxx"
+
+#include <iostream>
+
+using namespace std;
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class DecimationAccel implementation
+//*****************************************************************************
+
+
+ostream& operator<<(ostream& pOs, DecimationAccel& pA)
+{
+ pOs << "DecimationAccel:" << endl;
+ return pOs;
+}
+
+
+//*****************************************************************************
+// Class DecimationAccelGrid
+//*****************************************************************************
+
+DecimationAccelGrid::DecimationAccelGrid()
+{
+ mGrid = NULL;
+
+ reset();
+}
+
+
+DecimationAccelGrid::~DecimationAccelGrid()
+{
+ reset();
+}
+
+
+void DecimationAccelGrid::reset()
+{
+ mNum = 0;
+
+ mMin[0] = numeric_limits<med_float>::quiet_NaN();
+ mMin[1] = numeric_limits<med_float>::quiet_NaN();
+ mMin[2] = numeric_limits<med_float>::quiet_NaN();
+
+ mMax[0] = numeric_limits<med_float>::quiet_NaN();
+ mMax[1] = numeric_limits<med_float>::quiet_NaN();
+ mMax[2] = numeric_limits<med_float>::quiet_NaN();
+
+ mInvLen[0] = numeric_limits<med_float>::quiet_NaN();
+ mInvLen[1] = numeric_limits<med_float>::quiet_NaN();
+ mInvLen[2] = numeric_limits<med_float>::quiet_NaN();
+
+ mSize[0] = 0;
+ mSize[1] = 0;
+ mSize[2] = 0;
+
+ if (mGrid != NULL)
+ {
+ delete[] mGrid;
+ mGrid = NULL;
+ }
+
+ mFlagPrintAll = false;
+}
+
+
+void DecimationAccelGrid::create(const std::vector<PointOfField>& pPts)
+{
+ // check if grid have been initialized
+ if (mSize[0] == 0) throw IllegalStateException("call setSize() before", __FILE__, __LINE__);
+
+ // compute bbox of the grid
+ computeBBox(pPts);
+
+ // allocate the grid
+ int size = mSize[0] * mSize[1] * mSize[2];
+ mGrid = new vector<PointOfField>[size];
+
+ // fill the grid
+ mNum = pPts.size();
+ for (int i = 0 ; i < mNum ; i++)
+ {
+ vector<PointOfField>& cell = getCell(pPts[i]);
+ cell.push_back(pPts[i]);
+ }
+}
+
+
+void DecimationAccelGrid::configure(const char* pArgv)
+{
+ // check arguments
+ if (pArgv == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+
+ int sizeX = 0;
+ int sizeY = 0;
+ int sizeZ = 0;
+
+ int ret = sscanf(pArgv, "%d %d %d", &sizeX, &sizeY, &sizeZ);
+
+ if (ret != 3) throw IllegalArgumentException("expected 3 parameters", __FILE__, __LINE__);
+ if (sizeX <= 0) throw IllegalArgumentException("number of cells along X-axis must be > 0", __FILE__, __LINE__);
+ if (sizeY <= 0) throw IllegalArgumentException("number of cells along Y-axis must be > 0", __FILE__, __LINE__);
+ if (sizeZ <= 0) throw IllegalArgumentException("number of cells along Z-axis must be > 0", __FILE__, __LINE__);
+
+ reset();
+
+ mSize[0] = sizeX;
+ mSize[1] = sizeY;
+ mSize[2] = sizeZ;
+}
+
+
+void DecimationAccelGrid::getCellCoord(
+ med_float pX, med_float pY, med_float pZ,
+ int* pIx, int* pIy, int* pIz) const
+{
+ med_float cx = (pX - mMin[0]) * mInvLen[0];
+ med_float cy = (pY - mMin[1]) * mInvLen[1];
+ med_float cz = (pZ - mMin[2]) * mInvLen[2];
+
+ // clamp all indices to avoid overflow
+ *pIx = med_int(cx);
+ if (*pIx >= mSize[0]) *pIx = mSize[0] - 1;
+ else if (*pIx < 0) *pIx = 0;
+
+ *pIy = med_int(cy);
+ if (*pIy >= mSize[1]) *pIy = mSize[1] - 1;
+ else if (*pIy < 0) *pIy = 0;
+
+ *pIz = med_int(cz);
+ if (*pIz >= mSize[2]) *pIz = mSize[2] - 1;
+ else if (*pIz < 0) *pIz = 0;
+}
+
+
+int DecimationAccelGrid::getCellIndex(int pI, int pJ, int pK) const
+{
+ int index = pK * (mSize[0] * mSize[1]) + pJ * mSize[0] + pI;
+
+ return index;
+}
+
+
+vector<PointOfField>& DecimationAccelGrid::getCell(const PointOfField& pPt)
+{
+ int ix, iy, iz;
+
+ getCellCoord(
+ pPt.mXYZ[0], pPt.mXYZ[1], pPt.mXYZ[2],
+ &ix, &iy, &iz);
+
+ int index = getCellIndex(ix, iy, iz);
+
+ return mGrid[index];
+}
+
+
+vector<PointOfField> DecimationAccelGrid::findNeighbours(
+ med_float pCenterX,
+ med_float pCenterY,
+ med_float pCenterZ,
+ med_float pRadius) const
+{
+ //---------------------------------------------------------------------
+ // Determine the axis aligned bounding box of the sphere ((x, y, z), r)
+ //---------------------------------------------------------------------
+ med_float sphereBBoxMin[3];
+ med_float sphereBBoxMax[3];
+
+ sphereBBoxMin[0] = pCenterX - pRadius;
+ sphereBBoxMin[1] = pCenterY - pRadius;
+ sphereBBoxMin[2] = pCenterZ - pRadius;
+
+ sphereBBoxMax[0] = pCenterX + pRadius;
+ sphereBBoxMax[1] = pCenterY + pRadius;
+ sphereBBoxMax[2] = pCenterZ + pRadius;
+
+ //---------------------------------------------------------------------
+ // Determine the cells of the grid intersected by the sphere ((x, y, z), r)
+ // => range of cells are [iMinCell[0], iMaxCell[0]] x [iMinCell[1], iMaxCell[1]] x [iMinCell[2], iMaxCell[2]]
+ //---------------------------------------------------------------------
+ int iMinCell[3];
+ int iMaxCell[3];
+
+ getCellCoord(sphereBBoxMin[0], sphereBBoxMin[1], sphereBBoxMin[2],
+ &iMinCell[0], &iMinCell[1], &iMinCell[2]);
+
+ getCellCoord(sphereBBoxMax[0], sphereBBoxMax[1], sphereBBoxMax[2],
+ &iMaxCell[0], &iMaxCell[1], &iMaxCell[2]);
+
+ //---------------------------------------------------------------------
+ // Collect points of the field which are in the sphere
+ //---------------------------------------------------------------------
+ vector<PointOfField> res;
+
+/*
+// debug
+cout << "Center = " << pCenterX << " " << pCenterY << " " << pCenterZ << endl;
+cout << "Radius = " << pRadius << endl;
+cout << "Visited cells : [" << iMinCell[0] << " ; " << iMaxCell[0] << "] x ["<< iMinCell[1] << " ; " << iMaxCell[1] << "] x [" << iMinCell[2] << " ; " << iMaxCell[2] << "]" << endl;
+*/
+
+ // for all the cells in the grid intersected by the sphere ((x, y, z), r)
+ for (int i = iMinCell[0] ; i <= iMaxCell[0] ; i++)
+ {
+ for (int j = iMinCell[1] ; j <= iMaxCell[1] ; j++)
+ {
+ for (int k = iMinCell[2] ; k <= iMaxCell[2] ; k++)
+ {
+ int idCell = getCellIndex(i, j, k);
+
+//printf("DEBUG: visited cell(%d %d %d) -> %d\n", i, j, k, idCell);
+
+ vector<PointOfField>& cell = mGrid[idCell];
+
+ // for all the points in the current cell
+ for (vector<PointOfField>::const_iterator itPoint = cell.begin() ; itPoint != cell.end() ; itPoint++)
+ {
+ const PointOfField& currentPt = *itPoint;
+
+ // test if currentPt is in the sphere ((x, y, z), r)
+ med_float vecX = currentPt.mXYZ[0] - pCenterX;
+ med_float vecY = currentPt.mXYZ[1] - pCenterY;
+ med_float vecZ = currentPt.mXYZ[2] - pCenterZ;
+
+ med_float norm = med_float( sqrt( vecX*vecX + vecY*vecY + vecZ*vecZ ) );
+ if (norm < pRadius)
+ {
+ // only add the point if it is different from (x, y, z)
+ if ((currentPt.mXYZ[0] != pCenterX) ||
+ (currentPt.mXYZ[1] != pCenterY) ||
+ (currentPt.mXYZ[2] != pCenterZ))
+ {
+ res.push_back(currentPt);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return res;
+}
+
+
+void DecimationAccelGrid::computeBBox(const std::vector<PointOfField>& pPts)
+{
+ for (int itDim = 0 ; itDim < 3 ; itDim++)
+ {
+ mMin[itDim] = numeric_limits<med_float>::max();
+ mMax[itDim] = -mMin[itDim];
+ }
+
+ for (unsigned i = 0 ; i < pPts.size() ; i++)
+ {
+ for (int itDim = 0 ; itDim < 3 ; itDim++)
+ {
+ med_float coord = pPts[i].mXYZ[itDim];
+ if (coord < mMin[itDim]) mMin[itDim] = coord;
+ if (coord > mMax[itDim]) mMax[itDim] = coord;
+ }
+ }
+
+ mInvLen[0] = med_float(mSize[0]) / (mMax[0] - mMin[0]);
+ mInvLen[1] = med_float(mSize[1]) / (mMax[1] - mMin[1]);
+ mInvLen[2] = med_float(mSize[2]) / (mMax[2] - mMin[2]);
+}
+
+
+ostream& operator<<(ostream& pOs, DecimationAccelGrid& pG)
+{
+ pOs << "DecimationAccelGrid:" << endl;
+ pOs << " Num=" << pG.mNum << endl;
+ pOs << " Size=" << pG.mSize[0] << " x " << pG.mSize[1] << " x " << pG.mSize[2] << endl;
+ pOs << " BBox=[" << pG.mMin[0] << " ; " << pG.mMax[0] << "] x [" << pG.mMin[1] << " ; " << pG.mMax[1] << "] x [" << pG.mMin[2] << " ; " << pG.mMax[2] << "]" << endl;
+ pOs << " Inv len.=" << pG.mInvLen[0] << " ; " << pG.mInvLen[1] << " ; " << pG.mInvLen[2] << endl;
+
+ if (pG.mFlagPrintAll)
+ {
+ int checkNumCells = 0;
+ int numCells = pG.mSize[0] * pG.mSize[1] * pG.mSize[2];
+ for (int i = 0 ; i < numCells ; i++)
+ {
+ vector<PointOfField>& cell = pG.mGrid[i];
+ cout << " Cell " << i << ": #=" << cell.size() << ": " << endl;
+ for (unsigned j = 0 ; j < cell.size() ; j++)
+ {
+ cout << " " << cell[j] << endl;
+ }
+ checkNumCells += cell.size();
+ }
+
+ if (pG.mNum != checkNumCells) throw IllegalStateException("", __FILE__, __LINE__);
+ }
+
+ return pOs;
+}
+
+
+} // namespace multipr
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_DecimationAccel.hxx
+ *
+ * \brief Interface DecimationAccel: acceleration structure used for decimation.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_DECIMATION_ACCEL_HXX
+#define MULTIPR_DECIMATION_ACCEL_HXX
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+extern "C"
+{
+ #include "med.h"
+}
+
+#include <iostream>
+#include <vector>
+
+
+namespace multipr
+{
+
+//*****************************************************************************
+// Predeclaration
+//*****************************************************************************
+
+class PointOfField;
+
+
+//*****************************************************************************
+// Interface DecimationAccel
+//*****************************************************************************
+
+class DecimationAccel
+{
+public:
+
+ /**
+ * Builds an empty DecimationAccel (default constructor).
+ */
+ DecimationAccel() { /* do nothing */ }
+
+ /**
+ * Destructor. Removes everything.
+ */
+ virtual ~DecimationAccel() { /* do nothing */ }
+
+ //---------------------------------------------------------------------
+ // Algorithms
+ //---------------------------------------------------------------------
+
+ /**
+ * Interface. Configures this acceleration structure. String is used for genericity.
+ * \param pArgv all the configuration parameters in a string.
+ */
+ virtual void configure(const char* pArgv) = 0;
+
+ /**
+ * Interface. Creates a new acceleration structure and fills it with the given list of points.
+ * \param pPts list of points to be inserted in the acceleration structure.
+ */
+ virtual void create(const std::vector<PointOfField>& pPts) = 0;
+
+ /**
+ * Interface. Finds all the points in a sphere defined by its center (x,y,z) and its radius.
+ * \param pCenterX x-coordinates of the center of the sphere.
+ * \param pCenterY y-coordinates of the center of the sphere.
+ * \param pCenterZ z-coordinates of the center of the sphere.
+ * \param pRadius radius of the sphere.
+ * \return all the points in a sphere defined by its center (x,y,z) and its radius.
+ */
+ virtual std::vector<PointOfField> findNeighbours(
+ med_float pCenterX,
+ med_float pCenterY,
+ med_float pCenterZ,
+ med_float pRadius) const = 0;
+
+ //---------------------------------------------------------------------
+ // I/O
+ //---------------------------------------------------------------------
+
+ /**
+ * Sets the flag which control the stream operator <<.
+ * \param pFlag new flag value.
+ */
+ void setPrintAll(bool pFlag) { mFlagPrintAll = pFlag; }
+
+ /**
+ * Dumps any GaussLoc to the given output stream.
+ * \param pOs any output stream.
+ * \param pA any DecimationAccel.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, DecimationAccel& pA);
+
+protected:
+
+ bool mFlagPrintAll; /** Flag to control the behaviour of the stream operator <<. */
+
+private:
+
+ // do not allow copy constructor
+ DecimationAccel(const DecimationAccel&);
+
+ // do not allow copy
+ DecimationAccel& operator=(const DecimationAccel&);
+
+ // do not allow operator ==
+ bool operator==(const DecimationAccel&);
+
+}; // class DecimationAccel
+
+
+//*****************************************************************************
+// Interface DecimationFilter and factory to build filters.
+//*****************************************************************************
+
+class DecimationAccelGrid : public DecimationAccel
+{
+public:
+
+ /**
+ * Builds an empty DecimationAccelGrid (default constructor).
+ */
+ DecimationAccelGrid();
+
+ /**
+ * Destructor. Removes everything.
+ */
+ virtual ~DecimationAccelGrid();
+
+ /**
+ * Resets this object in its state by default (empty). Cleans memory.
+ */
+ void reset();
+
+ //---------------------------------------------------------------------
+ // Algorithms
+ //---------------------------------------------------------------------
+
+ /**
+ * Configures this acceleration structure. String is used for genericity.
+ * \param pArgv assumes "size_x size_y size_z": number of cells along each axis.
+ */
+ virtual void configure(const char* pArgv);
+
+ /**
+ * Creates a new acceleration structure and fills it with the given list of points.
+ * setSize() must have been called before.
+ * \param pPts list of points to be inserted in the acceleration structure.
+ * \throw IllegalStateException if setSize() has not been called before.
+ */
+ virtual void create(const std::vector<PointOfField>& pPts);
+
+ /**
+ * Finds all the points in a sphere defined by its center (x,y,z) and its radius.
+ * \param pCenterX x-coordinates of the center of the sphere.
+ * \param pCenterY y-coordinates of the center of the sphere.
+ * \param pCenterZ z-coordinates of the center of the sphere.
+ * \param pRadius radius of the sphere.
+ * \return all the points in a sphere defined by its center (x,y,z) and its radius.
+ */
+ virtual std::vector<PointOfField> findNeighbours(
+ med_float pCenterX,
+ med_float pCenterY,
+ med_float pCenterZ,
+ med_float pRadius) const;
+
+ /**
+ * Returns the coordinates of the cell which contain the point (x,y,z).
+ * Clamping is performed on (pIx, pIy, pIz) to avoid out of bounds.
+ * \param pX (in) X-coordinates of the point.
+ * \param pY (in) Y-coordinates of the point.
+ * \param pZ (in) Z-coordinates of the point.
+ * \param pIx (out) X-index of the cell which contain the point (x,y,z).
+ * \param pIy (out) Y-index.
+ * \param pIz (out) Z-index.
+ */
+ void getCellCoord(
+ med_float pX, med_float pY, med_float pZ,
+ int* pIx, int* pIy, int* pIz) const;
+
+ /**
+ * Returns the index of the cell whose coordinates are (i, j, k).
+ * \param pI
+ * \param pJ
+ * \param pK
+ * \return the index of the cell (i, j, k).
+ */
+ int getCellIndex(int pI, int pJ, int pK) const;
+
+ /**
+ * Returns the list of points contained in the cell of pPt.
+ * \param pPt any point which coordinates are in the bbox of this acceleration structure.
+ * \return the list of points contained in the cell of pPt.
+ */
+ std::vector<PointOfField>& getCell(const PointOfField& pPt);
+
+ //---------------------------------------------------------------------
+ // I/O
+ //---------------------------------------------------------------------
+
+ /**
+ * Dumps any GaussLoc to the given output stream.
+ * \param pOs any output stream.
+ * \param pG any DecimationAccelGrid.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, DecimationAccelGrid& pG);
+
+private:
+
+ /**
+ * Computes the axis-aligned bounding box of a set of points.
+ * Sets the fields mMin/mMax.
+ * \param pPts list of points.
+ */
+ void computeBBox(const std::vector<PointOfField>& pPts);
+
+private:
+
+ int mNum; /**< Number of points in the grid. */
+ med_float mMin[3]; /**< Bounding box, min corner. */
+ med_float mMax[3]; /**< Bounding box, max corner. */
+ med_float mInvLen[3]; /**< 1/length of cells, along each dimension; used to accelerate getCellCoord(). */
+ med_int mSize[3]; /**< Number of cells along each dimension. */
+ std::vector<PointOfField>* mGrid; /**< Flatten grid structure; each cell is a vector of PointOfField. */
+
+private:
+
+ // do not allow copy constructor
+ DecimationAccelGrid(const DecimationAccelGrid&);
+
+ // do not allow copy
+ DecimationAccelGrid& operator=(const DecimationAccelGrid&);
+
+ // do not allow operator ==
+ bool operator==(const DecimationAccelGrid&);
+
+}; // class DecimationAccelGrid
+
+
+} // namespace MULTIPR
+
+
+#endif // MULTIPR_DECIMATION_ACCEL_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_DecimationFilter.cxx
+ *
+ * \brief see MULTIPR_DecimationFilter.hxx
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include "MULTIPR_DecimationFilter.hxx"
+#include "MULTIPR_Field.hxx"
+#include "MULTIPR_Mesh.hxx"
+#include "MULTIPR_PointOfField.hxx"
+#include "MULTIPR_DecimationAccel.hxx"
+#include "MULTIPR_Exceptions.hxx"
+
+#include <iostream>
+
+using namespace std;
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class DecimationFilter implementation
+//*****************************************************************************
+
+// Factory used to build all filters from their name.
+DecimationFilter* DecimationFilter::create(const char* pFilterName)
+{
+ if (pFilterName == NULL) throw NullArgumentException("filter name should not be NULL", __FILE__, __LINE__);
+
+ if (strcmp(pFilterName, "Filtre_GradientMoyen") == 0)
+ {
+ return new DecimationFilterGradAvg();
+ }
+ else
+ {
+ throw IllegalArgumentException("unknown filter", __FILE__, __LINE__);
+ }
+}
+
+
+//*****************************************************************************
+// Class DecimationFilterGradAvg
+//*****************************************************************************
+
+DecimationFilterGradAvg::DecimationFilterGradAvg()
+{
+ // do nothing
+}
+
+
+DecimationFilterGradAvg::~DecimationFilterGradAvg()
+{
+ // do nothing
+}
+
+
+Mesh* DecimationFilterGradAvg::apply(Mesh* pMesh, const char* pArgv, const char* pNameNewMesh)
+{
+ //---------------------------------------------------------------------
+ // Retrieve and check parameters
+ //---------------------------------------------------------------------
+ if (pMesh == NULL) throw NullArgumentException("pMesh should not be NULL", __FILE__, __LINE__);
+ if (pArgv == NULL) throw NullArgumentException("pArgv should not be NULL", __FILE__, __LINE__);
+ if (pNameNewMesh == NULL) throw NullArgumentException("pNameNewMesh should not be NULL", __FILE__, __LINE__);
+
+ char fieldName[MED_TAILLE_NOM + 1];
+ int fieldIt;
+ double threshold;
+ double radius;
+ int boxing; // number of cells along axis (if 100 then grid will have 100*100*100 = 10**6 cells)
+
+ int ret = sscanf(pArgv, "%s %d %lf %lf %d",
+ fieldName,
+ &fieldIt,
+ &threshold,
+ &radius,
+ &boxing);
+
+ if (ret != 5) throw IllegalArgumentException("wrong number of arguments for filter GradAvg; expected 5 parameters", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Retrieve field = for each point: get its coordinate and the value of the field
+ //---------------------------------------------------------------------
+ Field* field = pMesh->getFieldByName(fieldName);
+
+ if (field == NULL) throw IllegalArgumentException("field not found", __FILE__, __LINE__);
+ if ((fieldIt < 1) || (fieldIt > field->getNumberOfTimeSteps())) throw IllegalArgumentException("invalid field iteration", __FILE__, __LINE__);
+
+ vector<PointOfField> points;
+ pMesh->getAllPointsOfField(field, fieldIt, points);
+
+ //---------------------------------------------------------------------
+ // Creates acceleration structure used to compute gradient
+ //---------------------------------------------------------------------
+ DecimationAccel* accel = new DecimationAccelGrid();
+ char strCfg[256]; // a string is used for genericity
+ sprintf(strCfg, "%d %d %d", boxing, boxing, boxing);
+ accel->configure(strCfg);
+ accel->create(points);
+
+ //---------------------------------------------------------------------
+ // Collects elements of the mesh to be kept
+ //---------------------------------------------------------------------
+ set<int> elementsToKeep;
+
+ int numElements = pMesh->getNumberOfElements();
+ int numGaussPointsByElt = points.size() / numElements; // for a TETRA10, should be 5 for a field of elements and 10 for a field of nodes
+
+ // for each element
+ for (int itElt = 0 ; itElt < numElements ; itElt++)
+ {
+ bool keepElement = false;
+
+ // for each Gauss point of the current element
+ for (int itPtGauss = 0 ; itPtGauss < numGaussPointsByElt ; itPtGauss++)
+ {
+ const PointOfField& currentPt = points[itElt * numGaussPointsByElt + itPtGauss];
+
+ vector<PointOfField> neighbours = accel->findNeighbours(
+ currentPt.mXYZ[0],
+ currentPt.mXYZ[1],
+ currentPt.mXYZ[2],
+ radius);
+
+ // if no neighbours => keep element
+ if (neighbours.size() == 0)
+ {
+ keepElement = true;
+ break;
+ }
+
+ // otherwise compute gradient...
+ med_float normGrad = computeNormGrad(currentPt, neighbours);
+
+ // debug
+ //cout << (itElt * numGaussPointsByElt + j) << ": " << normGrad << endl;
+
+ if ((normGrad >= threshold) || isnan(normGrad))
+ {
+ keepElement = true;
+ break;
+ }
+ }
+
+ if (keepElement)
+ {
+ // add index of the element to keep (index must start at 1)
+ elementsToKeep.insert(itElt + 1);
+ }
+ }
+
+ //---------------------------------------------------------------------
+ // Cleans
+ //---------------------------------------------------------------------
+ delete accel;
+
+ //---------------------------------------------------------------------
+ // Create the final mesh by extracting elements to keep from the current mesh
+ //---------------------------------------------------------------------
+ Mesh* newMesh = pMesh->createFromSetOfElements(elementsToKeep, pNameNewMesh);
+
+ return newMesh;
+}
+
+
+void DecimationFilterGradAvg::getGradientInfo(
+ Mesh* pMesh,
+ const char* pFieldName,
+ int pFieldIt,
+ double pRadius,
+ int pBoxing,
+ double* pOutGradMin,
+ double* pOutGradAvg,
+ double* pOutGradMax)
+{
+ if (pMesh == NULL) throw NullArgumentException("pMesh should not be NULL", __FILE__, __LINE__);
+ if (pFieldName == NULL) throw NullArgumentException("pFieldName should not be NULL", __FILE__, __LINE__);
+
+ Field* field = pMesh->getFieldByName(pFieldName);
+
+ if (field == NULL) throw IllegalArgumentException("field not found", __FILE__, __LINE__);
+ if ((pFieldIt < 1) || (pFieldIt > field->getNumberOfTimeSteps())) throw IllegalArgumentException("invalid field iteration", __FILE__, __LINE__);
+
+ vector<PointOfField> points;
+ pMesh->getAllPointsOfField(field, pFieldIt, points);
+
+ //---------------------------------------------------------------------
+ // Creates acceleration structure used to compute gradient
+ //---------------------------------------------------------------------
+ DecimationAccel* accel = new DecimationAccelGrid();
+ char strCfg[256]; // a string is used for genericity
+ sprintf(strCfg, "%d %d %d", pBoxing, pBoxing, pBoxing);
+ accel->configure(strCfg);
+ accel->create(points);
+
+ //---------------------------------------------------------------------
+ // Collects elements of the mesh to be kept
+ //---------------------------------------------------------------------
+
+ int numElements = pMesh->getNumberOfElements();
+ int numGaussPointsByElt = points.size() / numElements; // for a TETRA10, should be 5 for a field of elements and 10 for a field of nodes
+
+ *pOutGradMax = -1e300;
+ *pOutGradMin = 1e300;
+ *pOutGradAvg = 0.0;
+ int count = 0;
+
+ //cout << "numElements=" << numElements << endl;
+ //cout << "num gauss pt by elt=" << numGaussPointsByElt << endl;
+
+ // for each element
+ for (int itElt = 0 ; itElt < numElements ; itElt++)
+ {
+ // for each Gauss point of the current element
+ for (int itPtGauss = 0 ; itPtGauss < numGaussPointsByElt ; itPtGauss++)
+ {
+ const PointOfField& currentPt = points[itElt * numGaussPointsByElt + itPtGauss];
+
+ vector<PointOfField> neighbours = accel->findNeighbours(
+ currentPt.mXYZ[0],
+ currentPt.mXYZ[1],
+ currentPt.mXYZ[2],
+ pRadius);
+
+ // if no neighbours => keep element
+ if (neighbours.size() == 0)
+ {
+ continue;
+ }
+
+ // otherwise compute gradient...
+ med_float normGrad = computeNormGrad(currentPt, neighbours);
+
+ // debug
+ //cout << (itElt * numGaussPointsByElt + j) << ": " << normGrad << endl;
+
+ if (!isnan(normGrad))
+ {
+ if (normGrad > *pOutGradMax) *pOutGradMax = normGrad;
+ if (normGrad < *pOutGradMin) *pOutGradMin = normGrad;
+ *pOutGradAvg += normGrad;
+ count++;
+ }
+ }
+ }
+
+ if (count != 0) *pOutGradAvg /= double(count);
+
+ //---------------------------------------------------------------------
+ // Cleans
+ //---------------------------------------------------------------------
+ delete accel;
+}
+
+
+med_float DecimationFilterGradAvg::computeNormGrad(const PointOfField& pPt, const std::vector<PointOfField>& pNeighbours) const
+{
+ med_float gradX = 0.0;
+ med_float gradY = 0.0;
+ med_float gradZ = 0.0;
+
+ // for each neighbour
+ for (unsigned i = 0 ; i < pNeighbours.size() ; i++)
+ {
+ const PointOfField& neighbourPt = pNeighbours[i];
+
+ med_float vecX = neighbourPt.mXYZ[0] - pPt.mXYZ[0];
+ med_float vecY = neighbourPt.mXYZ[1] - pPt.mXYZ[1];
+ med_float vecZ = neighbourPt.mXYZ[2] - pPt.mXYZ[2];
+
+ med_float norm = med_float( sqrt( vecX*vecX + vecY*vecY + vecZ*vecZ ) );
+ med_float val = neighbourPt.mVal - pPt.mVal;
+
+ val /= norm;
+
+ gradX += vecX * val;
+ gradY += vecY * val;
+ gradZ += vecZ * val;
+ }
+
+ med_float invSize = 1.0 / med_float(pNeighbours.size());
+
+ gradX *= invSize;
+ gradY *= invSize;
+ gradZ *= invSize;
+
+ med_float norm = med_float( sqrt( gradX*gradX + gradY*gradY + gradZ*gradZ ) );
+
+ return norm;
+
+}
+
+
+} // namespace multipr
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_DecimationFilter.hxx
+ *
+ * \brief Interface DecimationFilter: filter used for decimation.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_DECIMATION_FILTER_HXX
+#define MULTIPR_DECIMATION_FILTER_HXX
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+extern "C"
+{
+ #include "med.h"
+}
+
+#include <iostream>
+#include <vector>
+
+
+namespace multipr
+{
+
+//*****************************************************************************
+// Predeclaration
+//*****************************************************************************
+
+class Mesh;
+class PointOfField;
+
+
+//*****************************************************************************
+// Interface DecimationFilter and factory to build filters.
+// Should be derivated to implement new filter.
+//*****************************************************************************
+
+class DecimationFilter
+{
+public:
+ /**
+ * Decimation filter factory. Must be used to build any new filter from its name.
+ * \param pFilterName name of the filter to be instanciated.
+ * \return a new instance of the given filter.
+ */
+ static DecimationFilter* create(const char* pFilterName);
+
+public:
+
+ /**
+ * Builds an empty DecimationFilter (default constructor).
+ */
+ DecimationFilter() { /* do nothing */ }
+
+ /**
+ * Destructor. Removes everything.
+ */
+ virtual ~DecimationFilter() { /* do nothing */ }
+
+ /**
+ * Interface. Creates a new Mesh by decimating the given Mesh with this DecimationFilter.
+ * \param pMesh any mesh to be decimated; must not be NULL.
+ * \param pArgv all the arguments of the filter as a string; must not be NULL.
+ * \param pNameNewMesh name of the decimated mesh; must not be NULL.
+ * \return the decimated mesh.
+ */
+ virtual Mesh* apply(Mesh* pMesh, const char* pArgv, const char* pNameNewMesh) = 0;
+
+private:
+
+ // do not allow copy constructor
+ DecimationFilter(const DecimationFilter&);
+
+ // do not allow copy
+ DecimationFilter& operator=(const DecimationFilter&);
+
+ // do not allow operator ==
+ bool operator==(const DecimationFilter&);
+
+}; // class DecimationFilter
+
+
+//*****************************************************************************
+// Filter : Average Gradient
+//*****************************************************************************
+
+class DecimationFilterGradAvg : public DecimationFilter
+{
+public:
+
+ /**
+ * Builds an empty DecimationFilterGradAvg (default constructor).
+ */
+ DecimationFilterGradAvg();
+
+ /**
+ * Destructor. Removes everything.
+ */
+ virtual ~DecimationFilterGradAvg();
+
+ /**
+ * Creates a new Mesh by decimating the given Mesh with this DecimationFilter.
+ *
+ * For each element
+ * Keep this element if all its points (related to a field) have a |gradient| > threshold.
+ *
+ * For each point, gradient is computed by considering all the neighbours in a sphere of radius r.
+ *
+ * \param pMesh any mesh to be decimated; must not be NULL.
+ * \param pArgv all the arguments of the filter as a string; must not be NULL.
+ * for GradAvg, expected "fieldName fieldIt threshold radius boxing" (5 parameters).
+ * \param pNameNewMesh name of the decimated mesh; must not be NULL.
+ * \return the decimated mesh.
+ */
+ virtual Mesh* apply(Mesh* pMesh, const char* pArgv, const char* pNameNewMesh);
+
+ /**
+ * Returns information about gradient.
+ */
+ void getGradientInfo(
+ Mesh* pMesh,
+ const char* pFieldName,
+ int pFieldIt,
+ double pRadius,
+ int pBoxing,
+ double* pOutGradMin,
+ double* pOutGradAvg,
+ double* pOutGradMax);
+
+private:
+
+ /**
+ * Returns the norm of the gradient of the field at the given point.
+ * Sub-method used by apply().
+ * \param pPt any point in the field.
+ * \param pNeigbours neighbourhood of pPt.
+ * \return the norm of the gradient of the field in pPt.
+ */
+ med_float computeNormGrad(const PointOfField& pPt, const std::vector<PointOfField>& pNeighbours) const;
+
+private:
+
+ // do not allow copy constructor
+ DecimationFilterGradAvg(const DecimationFilterGradAvg&);
+
+ // do not allow copy
+ DecimationFilterGradAvg& operator=(const DecimationFilterGradAvg&);
+
+ // do not allow operator ==
+ bool operator==(const DecimationFilterGradAvg&);
+
+}; // class DecimationFilterGradAvg
+
+
+} // namespace MULTIPR
+
+
+#endif // MULTIPR_DECIMATION_FILTER_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Elements.cxx
+ *
+ * \brief see MULTIPR_Elements.hxx
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include "MULTIPR_Elements.hxx"
+#include "MULTIPR_Nodes.hxx"
+#include "MULTIPR_Exceptions.hxx"
+
+#include <iostream>
+#include <set>
+#include <map>
+
+using namespace std;
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class Elements implementation
+//*****************************************************************************
+
+Elements::Elements()
+{
+ mId = NULL;
+ mFamIdent = NULL;
+ mNames = NULL;
+ mCon = NULL;
+
+ reset();
+}
+
+
+Elements::~Elements()
+{
+ reset();
+}
+
+
+void Elements::reset()
+{
+ mNum = 0;
+ mEntity = MED_MAILLE;
+ mGeom = MED_NONE;
+ mNumNodesByElt = 0;
+ mDim = 0;
+
+ if (mId != NULL) { delete[] mId; mId = NULL; }
+ if (mFamIdent != NULL) { delete[] mFamIdent; mFamIdent = NULL; }
+ if (mNames != NULL) { delete[] mNames; mNames = NULL; }
+ if (mCon != NULL) { delete[] mCon; mCon = NULL; }
+
+ mSetOfNodes.clear();
+
+ mFlagPrintAll = false;
+}
+
+
+med_int Elements::getFamilyIdentifier(med_int pIndex) const
+{
+ if ((pIndex < 0) || (pIndex >= mNum)) throw IndexOutOfBoundsException("", __FILE__, __LINE__);
+
+ return mFamIdent[pIndex];
+}
+
+
+const med_int* Elements::getConnectivity(int pIndex) const
+{
+ if ((pIndex < 0) || (pIndex >= mNum)) throw IndexOutOfBoundsException("", __FILE__, __LINE__);
+
+ return mCon + mNumNodesByElt * pIndex;
+}
+
+
+void Elements::getCoordinates(med_int pIndexElt, const Nodes* pNodes, med_float* pCoo, int pFirst) const
+{
+ if ((pIndexElt < 0) || (pIndexElt >= mNum)) throw IndexOutOfBoundsException("", __FILE__, __LINE__);
+ if (pNodes == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if (pCoo == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+
+ // get the list of nodes of the element
+ const med_int* con = getConnectivity(pIndexElt);
+
+ med_float* destCoo = pCoo;
+ int size = sizeof(med_float) * mDim;
+
+ // for each node of the element
+ int n = (mNumNodesByElt < pFirst) ? mNumNodesByElt : pFirst;
+ for (int i = 0 ; i < n ; i++)
+ {
+ // get index of node (MED index start at 1)
+ med_int indexNode = con[i] - 1;
+
+ // get coordinates of this node
+ const med_float* srcCoo = pNodes->getCoordinates(indexNode);
+
+ // copy coordinates to destCoo
+ memcpy(destCoo, srcCoo, size);
+
+ // prepare next point
+ destCoo += mDim;
+ }
+}
+
+
+Elements* Elements::extractSubSet(const set<med_int>& pSetIndices) const
+{
+ Elements* subset = new Elements();
+
+ //---------------------------------------------------------------------
+ // Copy parameters
+ //---------------------------------------------------------------------
+ subset->mNum = pSetIndices.size();
+ subset->mEntity = mEntity;
+ subset->mGeom = mGeom; // e.g. 310 for a TETRA10
+ subset->mNumNodesByElt = mNumNodesByElt; // e.g. 10 for a TETRA10
+ subset->mDim = mDim; // e.g. 3 for a TETRA10
+
+ //---------------------------------------------------------------------
+ // Allocate arrays
+ //---------------------------------------------------------------------
+ subset->mFamIdent = new med_int[subset->mNum];
+ subset->mCon = new med_int[mNumNodesByElt * subset->mNum];
+
+ //---------------------------------------------------------------------
+ // Copy subset of familys id and connectivity.
+ //---------------------------------------------------------------------
+ med_int* destCon = subset->mCon;
+ set<med_int>::iterator itSet = pSetIndices.begin();
+ for (int itElt = 0 ; itElt < subset->mNum; itElt++)
+ {
+ med_int srcIndex = (*itSet) - 1; // MED index start at 1
+ subset->mFamIdent[itElt] = mFamIdent[srcIndex];
+
+ med_int* srcCon = mCon + srcIndex * mNumNodesByElt;
+ memcpy(destCon, srcCon, sizeof(med_int) * mNumNodesByElt);
+
+ destCon += mNumNodesByElt;
+ itSet++;
+ }
+
+ //---------------------------------------------------------------------
+ // Copy subset of identifiers if necessary
+ //---------------------------------------------------------------------
+ if (isIdentifiers())
+ {
+ itSet = pSetIndices.begin();
+ subset->mId = new med_int[subset->mNum];
+ for (int itElt = 0 ; itElt < subset->mNum; itElt++)
+ {
+ med_int srcIndex = (*itSet) - 1; // MED index start at 1
+ subset->mId[itElt] = mId[srcIndex];
+
+ itSet++;
+ }
+ }
+
+ //---------------------------------------------------------------------
+ // Copy subset of names if necessary
+ //---------------------------------------------------------------------
+ if (isNames())
+ {
+ itSet = pSetIndices.begin();
+ subset->mNames = new char[MED_TAILLE_PNOM * subset->mNum + 1];
+ char* destPtr = subset->mNames;
+ for (int itElt = 0 ; itElt < subset->mNum; itElt++)
+ {
+ med_int srcIndex = (*itSet) - 1; // MED index start at 1
+ char* srcPtr = mNames + srcIndex * MED_TAILLE_PNOM;
+ memcpy(destPtr, srcPtr, MED_TAILLE_PNOM);
+
+ destPtr += MED_TAILLE_PNOM;
+ itSet++;
+ }
+ subset->mNames[MED_TAILLE_PNOM * subset->mNum] = '\0';
+ }
+
+ return subset;
+}
+
+
+const set<med_int>& Elements::getSetOfNodes()
+{
+ // lazy get: test if mSetOfNodes has already been built
+ if (mSetOfNodes.size() == 0)
+ {
+ buildSetOfNodes();
+ }
+
+ return mSetOfNodes;
+}
+
+
+set<med_int> Elements::getSetOfFamilies() const
+{
+ // set of families is empty at the beginning
+ set<med_int> setOfFamilies;
+
+ // for each element, add its family to the set
+ for (int itElt = 0 ; itElt < mNum ; itElt++)
+ {
+ setOfFamilies.insert(mFamIdent[itElt]);
+ }
+
+ return setOfFamilies;
+}
+
+
+void Elements::remap()
+{
+ // build set of nodes if necessary
+ if (mSetOfNodes.size() == 0)
+ {
+ buildSetOfNodes();
+ }
+
+ // build the map for indices convertion
+ map<med_int, med_int> mapOldIndexToNewIndex;
+ med_int newIndex = 1; // MED index start at 1
+ for (set<med_int>::iterator itSet = mSetOfNodes.begin(); itSet != mSetOfNodes.end() ; itSet++)
+ {
+ med_int oldIndex = (*itSet);
+ mapOldIndexToNewIndex.insert(make_pair(oldIndex, newIndex));
+ newIndex++;
+ }
+
+ // for each node referenced by this set of elements
+ for (int itNode = 0, size = mNum * mNumNodesByElt ; itNode < size ; itNode++)
+ {
+ // convert old index to new index (remap)
+ mCon[itNode] = mapOldIndexToNewIndex[mCon[itNode]];
+ }
+
+ buildSetOfNodes();
+}
+
+
+Elements* Elements::mergePartial(Elements* pElements, int pOffset)
+{
+ Elements* elements = new Elements();
+
+ //---------------------------------------------------------------------
+ // Copy parameters
+ //---------------------------------------------------------------------
+ elements->mNum = mNum + pElements->mNum;
+
+ if (mEntity != pElements->mEntity) throw IllegalStateException("entity should be the same", __FILE__, __LINE__);
+ elements->mEntity = mEntity;
+
+ elements->mGeom = mGeom; // e.g. 310 for a TETRA10
+ elements->mNumNodesByElt = mNumNodesByElt; // e.g. 10 for a TETRA10
+
+ if (mDim != pElements->mDim) throw IllegalStateException("dimension should be the same", __FILE__, __LINE__);
+ elements->mDim = mDim; // e.g. 3 for a TETRA10
+
+ elements->mId = NULL;
+ elements->mNames = NULL;
+
+ //---------------------------------------------------------------------
+ // Allocate arrays
+ //---------------------------------------------------------------------
+ elements->mFamIdent = new med_int[elements->mNum];
+ elements->mCon = new med_int[mNumNodesByElt * elements->mNum];
+
+ //---------------------------------------------------------------------
+ // Copy familys id and connectivity.
+ //---------------------------------------------------------------------
+ memcpy(elements->mFamIdent, mFamIdent, mNum * sizeof(med_int));
+ memcpy(elements->mFamIdent + mNum, pElements->mFamIdent, pElements->mNum * sizeof(med_int));
+
+ memcpy(elements->mCon, mCon, mNum * mNumNodesByElt * sizeof(med_int));
+
+ med_int* dst = elements->mCon + mNum * mNumNodesByElt;
+ for (int i = 0, n = pElements->mNum * mNumNodesByElt ; i < n ; i++)
+ {
+ dst[i] = pElements->mCon[i] + pOffset;
+ }
+
+ //cout << "WARNING: do no build set of nodes" << endl;
+ //elements->buildSetOfNodes();
+
+ return elements;
+}
+
+
+Elements* Elements::mergePartial(vector<Elements*> pElements, vector<int> pOffsets)
+{
+ if (pElements.size() == 0) throw IllegalArgumentException("pElements should contain at least 1 element", __FILE__, __LINE__);
+
+ Elements* elements = new Elements();
+
+ //---------------------------------------------------------------------
+ // Copy parameters
+ //---------------------------------------------------------------------
+ elements->mNum = mNum;
+ for (unsigned i = 0 ; i < pElements.size() ; i++)
+ {
+ elements->mNum += pElements[i]->mNum;
+
+ if (mEntity != pElements[i]->mEntity) throw IllegalStateException("entity should be the same", __FILE__, __LINE__);
+ if (mDim != pElements[i]->mDim) throw IllegalStateException("dimension should be the same", __FILE__, __LINE__);
+ }
+
+ elements->mEntity = mEntity;
+ elements->mGeom = mGeom; // e.g. 310 for a TETRA10
+ elements->mNumNodesByElt = mNumNodesByElt; // e.g. 10 for a TETRA10
+ elements->mDim = mDim; // e.g. 3 for a TETRA10
+
+ elements->mId = NULL;
+ elements->mNames = NULL;
+
+ //---------------------------------------------------------------------
+ // Allocate arrays
+ //---------------------------------------------------------------------
+ elements->mFamIdent = new med_int[elements->mNum];
+ elements->mCon = new med_int[mNumNodesByElt * elements->mNum];
+
+ //---------------------------------------------------------------------
+ // Copy familys id and connectivity.
+ //---------------------------------------------------------------------
+ memcpy(elements->mFamIdent, mFamIdent, mNum * sizeof(med_int));
+ memcpy(elements->mCon, mCon, mNum * mNumNodesByElt * sizeof(med_int));
+
+ int offsetFamIdent = mNum;
+ int offsetCon = mNum;
+ for (unsigned j = 0 ; j < pElements.size() ; j++)
+ {
+ memcpy(elements->mFamIdent + offsetFamIdent, pElements[j]->mFamIdent, pElements[j]->mNum * sizeof(med_int)); offsetFamIdent += pElements[j]->mNum;
+
+ med_int* dst = elements->mCon + offsetCon * mNumNodesByElt;
+ for (int i = 0, n = pElements[j]->mNum * mNumNodesByElt ; i < n ; i++)
+ {
+ dst[i] = pElements[j]->mCon[i] + pOffsets[j];
+ }
+ offsetCon += pElements[j]->mNum;
+ }
+
+ //cout << "WARNING: do no build set of nodes" << endl;
+ //elements->buildSetOfNodes();
+
+ return elements;
+}
+
+
+void Elements::buildSetOfNodes()
+{
+ if (mSetOfNodes.size() != 0)
+ {
+ mSetOfNodes.clear();
+ }
+
+ // for each node referenced by this set of elements
+ for (int itNode = 0, size = mNum * mNumNodesByElt ; itNode < size ; itNode++)
+ {
+ // add the node to the set
+ mSetOfNodes.insert(mCon[itNode]);
+ }
+}
+
+
+void Elements::readMED(
+ med_idt pMEDfile,
+ char* pMeshName,
+ med_int pMeshDim,
+ med_entite_maillage pEntity,
+ med_geometrie_element pGeom)
+{
+ if (pMEDfile == 0) throw IOException("", __FILE__, __LINE__);
+ if (pMeshName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if ((pMeshDim < 1) || (pMeshDim > 3)) throw IllegalArgumentException("", __FILE__, __LINE__);
+
+ reset();
+
+ mEntity = pEntity;
+ mGeom = pGeom;
+ mNumNodesByElt = mGeom % 100;
+ mDim = mGeom / 100;
+
+ mNum = MEDnEntMaa(
+ pMEDfile,
+ pMeshName,
+ MED_CONN, // type of information requested = CONNECTIVITY
+ pEntity,
+ pGeom,
+ MED_NOD); // nodal connectivity
+
+ if (mNum < 0) throw IOException("i/o error while reading information about elements in MED file", __FILE__, __LINE__);
+
+ if (mNum == 0)
+ {
+ // empty mesh
+ return;
+ }
+
+ mCon = new med_int[mNumNodesByElt * mNum];
+ mNames = new char[MED_TAILLE_PNOM * mNum + 1];
+ mId = new med_int[mNum];
+ mFamIdent = new med_int[mNum];
+ med_booleen isNames;
+ med_booleen isIdentifiers;
+
+ med_err ret = MEDelementsLire(
+ pMEDfile,
+ pMeshName,
+ pMeshDim,
+ mCon,
+ MED_FULL_INTERLACE,
+ mNames,
+ &isNames,
+ mId,
+ &isIdentifiers,
+ mFamIdent,
+ mNum,
+ mEntity,
+ mGeom,
+ MED_NOD); // NODAL CONNECTIVITY
+
+ if (ret != 0) throw IOException("i/o error while reading elements in MED file", __FILE__, __LINE__);
+
+ if (!isNames)
+ {
+ delete[] mNames;
+ mNames = NULL;
+ }
+
+ if (!isIdentifiers)
+ {
+ delete[] mId;
+ mId = NULL;
+ }
+}
+
+
+void Elements::writeMED(med_idt pMEDfile, char* pMeshName, med_int pMeshDim)
+{
+ if (pMEDfile == 0) throw IOException("", __FILE__, __LINE__);
+ if (pMeshName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if (strlen(pMeshName) > MED_TAILLE_NOM) throw IllegalArgumentException("", __FILE__, __LINE__);
+ if ((pMeshDim < 1) || (pMeshDim > 3)) throw IllegalArgumentException("", __FILE__, __LINE__);
+
+ // special case: if no elements => do nothing
+ if (mNum == 0) return;
+
+ med_err ret = MEDelementsEcr(
+ pMEDfile,
+ pMeshName,
+ pMeshDim,
+ mCon,
+ MED_FULL_INTERLACE,
+ mNames,
+ isNames()?MED_VRAI:MED_FAUX,
+ mId,
+ isIdentifiers()?MED_VRAI:MED_FAUX,
+ mFamIdent,
+ mNum,
+ mEntity,
+ mGeom,
+ MED_NOD); // NODAL CONNECTIVITY
+
+ if (ret != 0) throw IOException("i/o error while writing elements in MED file", __FILE__, __LINE__);
+}
+
+
+ostream& operator<<(ostream& pOs, Elements& pE)
+{
+ char strEntity[16];
+ switch (pE.mEntity)
+ {
+ case MED_MAILLE: strcpy(strEntity, "MED_MAILLE"); break;
+ case MED_FACE: strcpy(strEntity, "MED_FACE"); break;
+ case MED_ARETE: strcpy(strEntity, "MED_ARETE"); break;
+ case MED_NOEUD: strcpy(strEntity, "MED_NOEUD"); break;
+ default: strcpy(strEntity, "UNKNOWN"); break;
+ }
+
+ pOs << "Elements: " << endl;
+ pOs << " #number =" << pE.mNum << endl;
+ pOs << " Entity =" << strEntity << endl;
+ pOs << " Geom =" << pE.mGeom << endl;
+ pOs << " Has names?" << (pE.isNames()?"yes":"no") << endl;
+ pOs << " Has id ?" << (pE.isIdentifiers()?"yes":"no") << endl;
+
+ {
+ set<med_int> setOfFam = pE.getSetOfFamilies();
+ if (setOfFam.size() == 0)
+ {
+ pOs << " Families: #fam=0" << endl;
+ }
+ else
+ {
+ set<med_int>::iterator itFam = setOfFam.end();
+ itFam--;
+ pOs << " Families: #fam=" << setOfFam.size() << " id_min=" << (*(setOfFam.begin())) << " id_max=" << (*itFam) << endl;
+
+ if (pE.mFlagPrintAll)
+ {
+ for (int i = 0 ; i < pE.mNum; i++)
+ {
+ pOs << " Elt " << (i + 1) << ": " << pE.mFamIdent[i] << endl;
+ }
+ }
+ }
+ }
+
+ {
+ set<med_int> setOfNodes = pE.getSetOfNodes();
+ if (setOfNodes.size() == 0)
+ {
+ pOs << " Connectivity: #nodes=0" << endl;
+ }
+ else
+ {
+ set<med_int>::iterator itNode = setOfNodes.end();
+ itNode--;
+ pOs << " Connectivity: #nodes=" << setOfNodes.size() << " id_min=" << (*(setOfNodes.begin())) << " id_max=" << (*itNode) << endl;
+
+ if (pE.mFlagPrintAll)
+ {
+ for (int i = 0 ; i < pE.mNum ; i++)
+ {
+ pOs << " Elt " << (i + 1) << ": ";
+ for (int j = 0 ; j < pE.mNumNodesByElt ; j++)
+ {
+ pOs << pE.mCon[i * pE.mNumNodesByElt + j] << " ";
+ }
+ pOs << endl;
+ }
+ }
+ }
+ }
+
+ if (pE.mFlagPrintAll)
+ {
+
+ if (pE.isIdentifiers())
+ {
+ pOs << " Num (identifier): " << endl;
+ for (int i = 0 ; i < pE.mNum; i++)
+ {
+ pOs << " Elt " << (i + 1) << ": " << pE.mId[i] << " " << endl;
+ }
+ }
+
+ if (pE.isNames())
+ {
+ pE.mNames[MED_TAILLE_PNOM * pE.mNum] = '\0';
+ pOs << " Names: |" << pE.mNames << "|" << endl;
+ }
+
+ }
+
+ return pOs;
+}
+
+
+} // namespace multipr
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Elements.hxx
+ *
+ * \brief Class Elements = table of elements in a mesh.
+ * All elements share the same type (e.g. MED_MAILLE) and the same geometric description (e.g. TETRA10).
+ * Each element has a family and a table of connectivity.
+ * Optional: each element has a name and an id.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_ELEMENTS_HXX
+#define MULTIPR_ELEMENTS_HXX
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+extern "C"
+{
+ #include "med.h"
+}
+
+#include <set>
+#include <vector>
+
+
+namespace multipr
+{
+
+//*****************************************************************************
+// Predeclaration
+//*****************************************************************************
+
+class Nodes;
+
+
+//*****************************************************************************
+// Class Elements
+//*****************************************************************************
+
+class Elements
+{
+public:
+
+ /**
+ * Builds an empty set of elements (default constructor).
+ */
+ Elements();
+
+ /**
+ * Destructor. Removes everything.
+ */
+ ~Elements();
+
+ /**
+ * Resets this object in its state by default (empty). Cleans memory.
+ */
+ void reset();
+
+ //---------------------------------------------------------------------
+ // Basic accessors/mutators
+ //---------------------------------------------------------------------
+
+ /**
+ * Returns true iff this object contains no elements (table of elements is empty).
+ * \return true iff this object contains no elements.
+ */
+ bool isEmpty() const { return (mNum == 0); }
+
+ /**
+ * Returns true iff elements have a name.
+ * \return true iff elements have a name.
+ */
+ bool isNames() const { return (mNames != NULL); }
+
+ /**
+ * Returns true iff elements have an identifier (= a number).
+ * \return true iff elements have an identifier (= a number).
+ */
+ bool isIdentifiers() const { return (mId != NULL); }
+
+ /**
+ * Returns the number of elements.
+ * \return the number of elements.
+ */
+ int getNumberOfElements() const { return mNum; }
+
+ /**
+ * Returns the type of primitives (e.g. MED_TETRA10).
+ * \return the type of primitives
+ */
+ med_geometrie_element getTypeOfPrimitives() const { return mGeom; }
+
+ /**
+ * Returns the number of nodes that composed an element.
+ * \return the number of nodes that composed an element.
+ */
+ int getNumberOfNodesByElement() const { return mNumNodesByElt; }
+
+ /**
+ * Returns the family associated with an element.
+ * \param pIndex index of any element in [0..NUMBER_OF_ELEMENTS-1].
+ * \return the family associated with an element.
+ * \throw IndexOutOfBoundsException if pIndex is invalid.
+ */
+ med_int getFamilyIdentifier(med_int pIndex) const;
+
+ /**
+ * Returns the connectivity of one element.
+ * \param pIndex must be in [0..NUMBER_OF_ELEMENTS-1].
+ * \return a pointer towards the table of connectivity of the element.
+ * \throw IndexOutOfBoundsException if pIndex is invalid.
+ */
+ const med_int* getConnectivity(int pIndex) const;
+
+ /**
+ * Returns the coordinates of all the nodes of one element.
+ * \param pIndexElt must be in [0..NUMBER_OF_ELEMENTS-1].
+ * \param pNodes table of nodes, used to retrieve coordinates.
+ * \param pCoo (out) table of coordinates of nodes (e.g. 30 = 3 * 10 med_float for a TETRA10).
+ * \param pFirst only get the pFirst coordinates.
+ * \throw IndexOutOfBoundsException if pIndex is invalid.
+ */
+ void getCoordinates(med_int pIndexElt, const Nodes* pNodes, med_float* pCoo, int pFirst = 100) const;
+
+ //---------------------------------------------------------------------
+ // Algorithms
+ //---------------------------------------------------------------------
+
+ /**
+ * Constructor. Creates a subset of this set of elements from a set of indices.
+ * \param pSetIndices set of indices (start at 1).
+ * \return a restriction of this set of elements.
+ */
+ Elements* extractSubSet(const std::set<med_int>& pSetIndices) const;
+
+ /**
+ * Returns the set of indices (starting at 1) of all nodes used by this set of elements.
+ * \return the set of indices of all nodes used by this set of elements.
+ */
+ const std::set<med_int>& getSetOfNodes();
+
+ /**
+ * Returns the set of families referenced by this set of elements.
+ * Each family is described by its identifier.
+ * \return Returns the set of families referenced by this set of elements.
+ */
+ std::set<med_int> getSetOfFamilies() const;
+
+ /**
+ * Remaps this set of elements such that indices of nodes are continous 1 2 3 4 5 ... *
+ * This method is intended to be used after extractSubSet().
+ */
+ void remap();
+
+ /**
+ * Builds a new set of elements by merging two set of elements (this and pElements) if possible.
+ * Merge is partial because Id and Names are not take into account.
+ * \param pElements any set of nodes to be merged with this.
+ * \param pOffset
+ * \return a new set of nodes.
+ * \throw IllegalStateException if the two sets of elements are incompatible.
+ */
+ Elements* mergePartial(Elements* pElements, int pOffset);
+ Elements* mergePartial(std::vector<Elements*> pElements, std::vector<int> pOffsets);
+
+ //---------------------------------------------------------------------
+ // I/O
+ //---------------------------------------------------------------------
+
+ /**
+ * Reads a set of elements from a MED file.
+ * You must give: name of mesh, dimension of the mesh, type of entity and type of elements.
+ * \param pMEDfile any valid MED file opened for reading.
+ * \param pMeshName name of the mesh.
+ * \param pMeshDim dimension of the mesh.
+ * \param pEntity entity to be read (e.g. MED_MAILLE).
+ * \param pGeom type of primitves to be read (e.g. MED_TETRA10).
+ * \throw IOException if any i/o error occurs.
+ */
+ void readMED(
+ med_idt pMEDfile,
+ char* pMeshName,
+ med_int pMeshDim,
+ med_entite_maillage pEntity,
+ med_geometrie_element pGeom);
+
+ /**
+ * Writes this set of elements to a MED file.
+ * WARNING: mesh must have been created and added to the MED file before.
+ * \param pMEDfile any valid MED file opened for writing.
+ * \param pMeshName name of the mesh.
+ * \param pMeshDim dimension of the mesh.
+ * \throw IOException if any i/o error occurs.
+ */
+ void writeMED(med_idt pMEDfile, char* pMeshName, med_int pMeshDim);
+
+ /**
+ * Sets the flag which control the stream operator <<.
+ * \param pFlag new flag value.
+ */
+ void setPrintAll(bool pFlag) { mFlagPrintAll = pFlag; }
+
+ /**
+ * Dumps any Elements to the given output stream.
+ * \param pOs any output stream.
+ * \param pE any Elements.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, Elements& pE);
+
+private:
+
+ /**
+ * Builds the set of nodes used by this set of elements.
+ * If the set already exist, then it is cleared and a new set is computed.
+ */
+ void buildSetOfNodes();
+
+private:
+
+ med_int mNum; /**< Number of elements. */
+ med_entite_maillage mEntity; /**< Type of entity, e.g. MED_MAILLE. */
+ med_geometrie_element mGeom; /**< Type of primitive, e.g. MED_TETRA10. */
+ int mDim; /**< Dimension of elements = mGeom / 100. */
+ int mNumNodesByElt; /**< Number of nodes by element = mGeom % 100. */
+ med_int* mId; /**< Optional; for each element, its identifier; NULL if undefined. */
+ med_int* mFamIdent; /**< For each element, its family (identifier). */
+ char* mNames; /**< Optional; for each element, its name; NULL if undefined. */
+ med_int* mCon; /**< For each element, list of nodes (index in 1..*) = table of connectivity. */
+ std::set<med_int> mSetOfNodes; /**< Set of all nodes used by this set of elements. */
+
+ bool mFlagPrintAll; /** Flag to control the behaviour of the stream operator <<. */
+
+private:
+
+ // do not allow copy constructor
+ Elements(const Elements&);
+
+ // do not allow copy
+ Elements& operator=(const Elements&);
+
+ // do not allow operator ==
+ bool operator==(const Elements&);
+
+}; // class Elements
+
+
+} // namespace MULTIPR
+
+
+#endif // MULTIPR_NODES_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Exceptions.hxx
+ *
+ * \brief All the exceptions used by MULTIPR.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_EXCEPTIONS_HXX
+#define MULTIPR_EXCEPTIONS_HXX
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include <string>
+#include <iostream>
+
+
+namespace multipr
+{
+
+//*****************************************************************************
+// Class RuntimeException
+// Super class for all exceptions used by the module MULTIPR
+//*****************************************************************************
+
+class RuntimeException
+{
+public:
+
+ /**
+ * Constructor. Build a new RuntimeException.
+ * \param pMsg message to be associated with this exception.
+ * \param pFile name of the file where the probem occur (you can use the macro __FILE__); "unknown" by default.
+ * \param pLine number of the line where the probem occur (you can use the macro __LINE__); 0 by default.
+ */
+ RuntimeException(
+ const std::string& pMsg,
+ const std::string& pFile = "unknown",
+ int pLine = 0)
+ {
+ mMsg = pMsg;
+ mFile = pFile;
+ mLine = pLine;
+ mType = "RuntimeException";
+ }
+
+ /**
+ * Dumps info about this exception to the given output stream.
+ */
+ void dump(std::ostream& pOs) const
+ {
+ pOs << "MULTIPR: " << mType << " (" << mFile << ", line " << mLine << "): " << mMsg << std::endl;
+ }
+
+protected:
+
+ std::string mMsg; /**< Message associated with this exception. */
+ std::string mFile; /**< Name of the source file where the problem occurs (macro __FILE__ can be used to retrieve this field). */
+ int mLine; /**< Number of the line where the problem occurs (macro __LINE__ can be used to retrieve this field). */
+ std::string mType; /**< Type of this exception. */
+};
+
+
+//*****************************************************************************
+// Class NullArgumentException
+// Should be used when an unexpected NULL pointer occurs
+//*****************************************************************************
+
+class NullArgumentException : public RuntimeException
+{
+public:
+ NullArgumentException(
+ const std::string& pMsg,
+ const std::string& pFile="unknown",
+ int pLine=0) : RuntimeException(pMsg, pFile, pLine)
+ {
+ mType = "NullArgumentException";
+ }
+};
+
+
+//*****************************************************************************
+// Class IllegalArgumentException
+// Should be used when an invalid parameter is detected (check precondition)
+//*****************************************************************************
+
+class IllegalArgumentException : public RuntimeException
+{
+public:
+ IllegalArgumentException(
+ const std::string& pMsg,
+ const std::string& pFile="unknown",
+ int pLine=0) : RuntimeException(pMsg, pFile, pLine)
+ {
+ mType = "IllegalArgumentException";
+ }
+};
+
+
+//*****************************************************************************
+// Class IllegalStateException
+// Should be used when the internal state of an object is invalid
+//*****************************************************************************
+
+class IllegalStateException : public RuntimeException
+{
+public:
+ IllegalStateException(
+ const std::string& pMsg,
+ const std::string& pFile="unknown",
+ int pLine=0) : RuntimeException(pMsg, pFile, pLine)
+ {
+ mType = "IllegalStateException";
+ }
+};
+
+
+//*****************************************************************************
+// Class IndexOutOfBoundsException
+// Should be used when an index is out of bounds
+//*****************************************************************************
+
+class IndexOutOfBoundsException : public RuntimeException
+{
+public:
+ IndexOutOfBoundsException(
+ const std::string& pMsg,
+ const std::string& pFile="unknown",
+ int pLine=0) : RuntimeException(pMsg, pFile, pLine)
+ {
+ mType = "IndexOutOfBoundsException";
+ }
+};
+
+
+//*****************************************************************************
+// Class IOException
+// Should be used when any i/o error occurs
+//*****************************************************************************
+
+class IOException : public RuntimeException
+{
+public:
+ IOException(
+ const std::string& pMsg,
+ const std::string& pFile="unknown",
+ int pLine=0) : RuntimeException(pMsg, pFile, pLine)
+ {
+ mType = "IOException";
+ }
+};
+
+
+//*****************************************************************************
+// Class FileNotFoundException
+// Should be used to indicate that a file has not been found
+//*****************************************************************************
+
+class FileNotFoundException : public IOException
+{
+public:
+ FileNotFoundException(
+ const std::string& pMsg,
+ const std::string& pFile="unknown",
+ int pLine=0) : IOException(pMsg, pFile, pLine)
+ {
+ mType = "FileNotFoundException";
+ }
+};
+
+
+//*****************************************************************************
+// Class UnsupportedOperationException
+// Should be used when a function/method is not yet implemented or
+// if an operation is not supported in a given context
+//*****************************************************************************
+
+class UnsupportedOperationException : public RuntimeException
+{
+public:
+ UnsupportedOperationException(
+ const std::string& pMsg,
+ const std::string& pFile="unknown",
+ int pLine=0) : RuntimeException(pMsg, pFile, pLine)
+ {
+ mType = "UnsupportedOperationException";
+ }
+};
+
+
+} // namespace MULTIPR
+
+
+#endif // MULTIPR_EXCEPTIONS_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Family.cxx
+ *
+ * \brief see MULTIPR_Family.hxx
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include "MULTIPR_Family.hxx"
+#include "MULTIPR_Exceptions.hxx"
+
+#include <iostream>
+
+using namespace std;
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class Attributs implementation
+//*****************************************************************************
+
+Attributs::Attributs()
+{
+ mId = NULL;
+ mVal = NULL;
+ mDesc = NULL;
+
+ reset();
+}
+
+
+Attributs::~Attributs()
+{
+ reset();
+}
+
+
+Attributs& Attributs::operator=(const Attributs& pAttr)
+{
+ if (this != &pAttr) // check for self-assignement
+ {
+ reset();
+
+ mNum = pAttr.mNum;
+
+ if (mNum < 0) throw IllegalStateException("", __FILE__, __LINE__);
+
+ if (pAttr.mId != NULL)
+ {
+ mId = new med_int[mNum];
+ memcpy(mId, pAttr.mId, sizeof(med_int) * mNum);
+ }
+
+ if (pAttr.mVal != NULL)
+ {
+ mVal = new med_int[mNum];
+ memcpy(mVal, pAttr.mVal, sizeof(med_int) * mNum);
+ }
+
+ if (pAttr.mDesc != NULL)
+ {
+ mDesc = new char[MED_TAILLE_DESC * mNum + 1];
+ memcpy(mDesc, pAttr.mDesc, MED_TAILLE_DESC * mNum + 1);
+ }
+ }
+
+ return *this;
+}
+
+
+void Attributs::reset()
+{
+ mNum = 0;
+
+ if (mId != NULL) { delete[] mId; mId = NULL; }
+ if (mVal != NULL) { delete[] mVal; mVal = NULL; }
+ if (mDesc != NULL) { delete[] mDesc; mDesc = NULL; }
+}
+
+
+ostream& operator<<(ostream& pOs, Attributs& pA)
+{
+ if (pA.mNum == 0)
+ {
+ pOs << "NONE" << endl;
+ }
+ else
+ {
+ pOs << endl << " #attr=" << pA.mNum << endl;
+
+ if (pA.mId != NULL)
+ {
+ pOs << " Id =[";
+ for (int i = 0 ; i < pA.mNum ; i++)
+ {
+ pOs << pA.mId[i] << " ";
+ }
+ pOs << "]" << endl;
+ }
+ else
+ {
+ pOs << " Id =NULL" << endl;
+ }
+
+ if (pA.mVal != NULL)
+ {
+ pOs << " Val =[";
+ for (int i = 0 ; i < pA.mNum ; i++)
+ {
+ pOs << pA.mVal[i] << " ";
+ }
+ pOs << "]" << endl;
+ }
+ else
+ {
+ pOs << " Val =NULL";
+ }
+
+ if (pA.mDesc != NULL)
+ {
+ pOs << " Desc=|" << pA.mDesc << "|" << endl;
+ }
+ else
+ {
+ pOs << " Desc=NULL" << endl;
+ }
+ }
+
+ return pOs;
+}
+
+
+//*****************************************************************************
+// Class Family implementation
+//*****************************************************************************
+
+Family::Family()
+{
+ reset();
+}
+
+
+Family::Family(const Family& pFamily)
+{
+ strcpy(mName, pFamily.mName);
+ mId = pFamily.mId;
+ mStrNameGroups = pFamily.mStrNameGroups;
+ mNameGroups = pFamily.mNameGroups;
+ mAttributs = pFamily.mAttributs;
+}
+
+
+Family::~Family()
+{
+ reset();
+}
+
+
+void Family::reset()
+{
+ mName[0] = '\0';
+ mId = 0;
+ mStrNameGroups = "";
+
+ mElt.clear();
+ mNameGroups.clear();
+ mAttributs.reset();
+
+ mIsFamilyOfNodes = true;
+
+ mFlagPrintAll = false;
+}
+
+
+void Family::insertElt(med_int pIndexElt)
+{
+ if (pIndexElt < 1) throw new IllegalArgumentException("", __FILE__, __LINE__);
+
+ mElt.insert(pIndexElt);
+}
+
+
+void Family::buildGroups(vector<Group*>& pGroups, map<string, Group*>& pGroupNameToGroup) const
+{
+ // pGroups / pGroupNameToGroup can be empty or not
+
+ // for each group in this family
+ for (unsigned itGroup = 0 ; itGroup < mNameGroups.size() ; itGroup++)
+ {
+ const string& keyName = mNameGroups[itGroup];
+
+ // check if the group already exist
+ map<string, Group*>::iterator it = pGroupNameToGroup.find(keyName);
+
+ Group* group = NULL;
+ if (it != pGroupNameToGroup.end())
+ {
+ // the group already exists
+ group = (*it).second;
+ }
+ else
+ {
+ // a new group have been identified: create a new entry
+ group = new Group();
+ group->setName(keyName);
+ group->setIsGroupOfNodes(isFamilyOfNodes());
+
+ pGroups.push_back(group);
+ pGroupNameToGroup.insert(make_pair(keyName, group));
+ }
+
+ // add all elements of the this family to the group
+ for (set<med_int>::iterator itElt = mElt.begin() ; itElt != mElt.end() ; itElt++)
+ {
+ group->insertElt(*itElt);
+ }
+
+ }
+}
+
+
+Family* Family::extractGroup(const char* pGroupName)
+{
+ Family* family = new Family();
+
+ strcpy(family->mName, mName);
+ family->mId = mId;
+ family->mAttributs = mAttributs;
+
+ if (pGroupName == NULL)
+ {
+ family->mStrNameGroups = mStrNameGroups;
+ family->mNameGroups = mNameGroups;
+ }
+ else
+ {
+ if (strlen(pGroupName) > MED_TAILLE_LNOM) throw IllegalArgumentException("", __FILE__, __LINE__);
+ if (strlen(pGroupName) == 0) throw IllegalArgumentException("", __FILE__, __LINE__);
+
+ if (strstr(mStrNameGroups.c_str(), pGroupName) == 0)
+ {
+ // pGroupName found in the list of groups => just keep pGroupName
+ family->mStrNameGroups = mStrNameGroups;
+ family->mNameGroups = mNameGroups;
+ }
+ else
+ {
+ // pGroupName not found in the current list of groups
+ // probably not a group of the same nature => keep all the groups
+ family->mStrNameGroups = pGroupName;
+ family->mNameGroups.push_back(pGroupName);
+ }
+ }
+
+ return family;
+}
+
+
+void Family::readMED(med_idt pMEDfile, char* pMeshName, med_int pIndex)
+{
+ if (pMEDfile == 0) throw IOException("", __FILE__, __LINE__);
+ if (pMeshName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if (strlen(pMeshName) > MED_TAILLE_NOM) throw IllegalArgumentException("", __FILE__, __LINE__);
+ if (pIndex < 1) throw IllegalArgumentException("", __FILE__, __LINE__);
+
+ reset();
+
+ med_int numGroups = MEDnGroupe(pMEDfile, pMeshName, pIndex);
+
+ if (numGroups < 0) throw IOException("i/o error while reading number of groups in MED file", __FILE__, __LINE__);
+
+ med_int numAttr = MEDnAttribut(pMEDfile, pMeshName, pIndex);
+
+ med_int* attrId = new med_int[numAttr];
+ med_int* attrVal = new med_int[numAttr];
+ char* attrDesc = new char[MED_TAILLE_DESC * numAttr + 1];
+ attrDesc[0] = '\0';
+
+ char* nameGroups = new char[MED_TAILLE_LNOM * numGroups + 1];
+ nameGroups[0] = '\0';
+
+ med_err ret = MEDfamInfo(
+ pMEDfile,
+ pMeshName,
+ pIndex,
+ mName,
+ &mId,
+ attrId,
+ attrVal,
+ attrDesc,
+ &numAttr,
+ nameGroups,
+ &numGroups);
+
+ if (ret != 0) throw IOException("i/o error while reading family information in MED file", __FILE__, __LINE__);
+
+ attrDesc[MED_TAILLE_DESC * numAttr] = '\0';
+
+ mAttributs.mNum = numAttr;
+ mAttributs.mId = attrId;
+ mAttributs.mVal = attrVal;
+ mAttributs.mDesc = attrDesc;
+
+ mStrNameGroups = nameGroups;
+
+ // split nameGroups
+ for (int itGroup = 0 ; itGroup < numGroups ; itGroup++)
+ {
+ char str[MED_TAILLE_LNOM + 1];
+ strncpy(str, nameGroups + itGroup * MED_TAILLE_LNOM, MED_TAILLE_LNOM);
+ str[MED_TAILLE_LNOM] = '\0';
+ mNameGroups.push_back(str);
+ }
+
+ delete[] nameGroups;
+
+ // MEDfamLire is not necessary as we used MEDnoeudsLire/MEDelementsLire instead
+}
+
+
+void Family::writeMED(med_idt pMEDfile, char* pMeshName)
+{
+ if (pMEDfile == 0) throw IOException("", __FILE__, __LINE__);
+ if (pMeshName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if (strlen(pMeshName) > MED_TAILLE_NOM) throw IllegalArgumentException("", __FILE__, __LINE__);
+ if (strlen(mName) > MED_TAILLE_NOM) throw IllegalArgumentException("", __FILE__, __LINE__);
+ if (mAttributs.mVal == NULL) throw IllegalStateException("", __FILE__, __LINE__);
+ if (mAttributs.mDesc == NULL) throw IllegalStateException("", __FILE__, __LINE__);
+ if (mAttributs.mId == NULL) throw IllegalStateException("", __FILE__, __LINE__);
+
+ //cout << "Write family: " << mName << " " << mId << endl;
+
+ med_err ret = MEDfamCr(
+ pMEDfile,
+ pMeshName,
+ mName,
+ mId,
+ mAttributs.mId,
+ mAttributs.mVal,
+ mAttributs.mDesc,
+ mAttributs.mNum,
+ const_cast<char*>(mStrNameGroups.c_str()),
+ mNameGroups.size());
+
+ if (ret != 0) throw IOException("i/o error while creating family in MED file", __FILE__, __LINE__);
+
+ // MEDfamEcr is not necessary as we used MEDnoeudsEcr/MEDelementsEcr instead
+
+}
+
+
+ostream& operator<<(ostream& pOs, Family& pF)
+{
+ pOs << "Family: " << endl;
+ pOs << " Name =|" << pF.mName << "| size=" << strlen(pF.mName) << endl;
+ pOs << " Id =" << pF.mId << endl;
+ pOs << " Family of =" << (pF.isFamilyOfNodes()?"NODES":"ELEMENTS") << endl;
+
+ pOs << " Groups: #groups=" << pF.mNameGroups.size() << endl;
+ for (unsigned itGroup = 0 ; itGroup < pF.mNameGroups.size() ; itGroup++)
+ {
+ pOs << " Group " << (itGroup + 1) << ": |" << pF.mNameGroups[itGroup] << "| size=" << pF.mNameGroups[itGroup].length() << endl;
+ }
+ pOs << " Attributs: " << pF.mAttributs;
+
+ if (pF.mElt.size() != 0)
+ {
+ set<med_int>::iterator itSet = pF.mElt.end();
+ itSet--;
+ pOs << " Elements: #elt=" << pF.mElt.size() << " min_id=" << (*(pF.mElt.begin())) << " max_id=" << (*itSet) << endl;
+ if (pF.mFlagPrintAll)
+ {
+ pOs << " ";
+ for (set<med_int>::iterator itSet = pF.mElt.begin() ; itSet != pF.mElt.end() ; itSet++)
+ {
+ pOs << (*itSet) << " ";
+ }
+ pOs << endl;
+ }
+ }
+ else
+ {
+ pOs << " Elements: #elt=0" << endl;
+ }
+
+ return pOs;
+}
+
+
+//*****************************************************************************
+// Class Group implementation
+//*****************************************************************************
+
+Group::Group()
+{
+ reset();
+}
+
+
+Group::~Group()
+{
+ reset();
+}
+
+
+void Group::reset()
+{
+ mName = "";
+ mElt.clear();
+ mIsGroupOfNodes = true;
+
+ mFlagPrintAll = false;
+}
+
+
+void Group::setName(const string& pName)
+{
+ if (pName.length() > MED_TAILLE_LNOM) throw IllegalArgumentException("", __FILE__, __LINE__);
+
+ mName = pName;
+}
+
+
+void Group::insertElt(med_int pIndexElt)
+{
+ if (pIndexElt < 1) throw IllegalArgumentException("", __FILE__, __LINE__);
+
+ mElt.insert(pIndexElt);
+}
+
+ostream& operator<<(ostream& pOs, Group& pG)
+{
+ pOs << "Group: " << endl;
+ pOs << " Name =|" << pG.mName << "| size=" << pG.mName.length() << endl;
+ pOs << " Group of =" << (pG.isGroupOfNodes()?"NODES":"ELEMENTS") << endl;
+
+ if (pG.mElt.size() != 0)
+ {
+ set<med_int>::iterator itSet = pG.mElt.end();
+ itSet--;
+ pOs << " Elements: #elt=" << pG.mElt.size() << " min_id=" << (*(pG.mElt.begin())) << " max_id=" << (*itSet) << endl;
+ if (pG.mFlagPrintAll)
+ {
+ pOs << " ";
+ for (set<med_int>::iterator itSet = pG.mElt.begin() ; itSet != pG.mElt.end() ; itSet++)
+ {
+ pOs << (*itSet) << " ";
+ }
+ pOs << endl;
+ }
+ }
+ else
+ {
+ pOs << " Elements: #elt=0" << endl;
+ }
+
+ return pOs;
+}
+
+
+} // namespace multipr
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Family.hxx
+ *
+ * \brief Class Family, Group and Attributs used to wrap MED file structures.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_FAMILY_HXX
+#define MULTIPR_FAMILY_HXX
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+extern "C"
+{
+ #include "med.h"
+}
+
+
+#include <iostream>
+#include <vector>
+#include <set>
+#include <map>
+
+
+namespace multipr
+{
+
+//*****************************************************************************
+// Predeclaration
+//*****************************************************************************
+
+class Group;
+
+
+//*****************************************************************************
+// Class Attributs
+//*****************************************************************************
+
+class Attributs
+{
+public:
+
+ /**
+ * Builds an empty Attributs (default constructor).
+ */
+ Attributs();
+
+ /**
+ * Destructor. Removes everything.
+ */
+ ~Attributs();
+
+ /**
+ * Assignment operator (deep copy).
+ * \param pAttr any Atttibuts to be copied.
+ * \return a reference towards the copy.
+ */
+ Attributs& operator=(const Attributs& pAttr);
+
+ /**
+ * Resets this object in its state by default (empty). Cleans memory.
+ */
+ void reset();
+
+ //---------------------------------------------------------------------
+ // I/O
+ //---------------------------------------------------------------------
+
+ /**
+ * Dumps any Attributs to the given output stream.
+ * \param pOs any output stream.
+ * \param pA any Attributs.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, Attributs& pA);
+
+public:
+
+ med_int mNum; /**< Number of attributes. */
+ med_int* mId; /**< Table of identifiers: for each attribute, its identifier. */
+ med_int* mVal; /**< Table of values; for each attribute, its value. */
+ char* mDesc; /**< Table of description; for each attribute, its description. */
+
+private:
+
+ // do not allow copy constructor
+ Attributs(const Attributs&);
+
+ // do not allow operator ==
+ bool operator==(const Attributs&);
+
+}; // class Attribut
+
+
+//*****************************************************************************
+// Class Family
+//*****************************************************************************
+
+class Family
+{
+public:
+
+ /**
+ * Builds an empty Family (default constructor).
+ */
+ Family();
+
+ /**
+ * Copy constructor.
+ */
+ Family(const Family& pFamily);
+
+ /**
+ * Destructor. Removes everything.
+ */
+ ~Family();
+
+ /**
+ * Resets this object in its state by default (empty). Cleans memory.
+ */
+ void reset();
+
+ //---------------------------------------------------------------------
+ // Basic accessors/mutators
+ //---------------------------------------------------------------------
+
+ /**
+ * Returns the identifier (= number) of this Family.
+ * \return the identifier of this Family.
+ */
+ med_int getId() const { return mId; }
+
+ /**
+ * Returns the name of this Family.
+ * \return the name of this Family.
+ */
+ const char* getName() const { return mName; }
+
+ /**
+ * Returns true if this Family if a family of nodes, false if is a family of elements (=cells)).
+ * \return true iff this Family if a family of nodes.
+ */
+ bool isFamilyOfNodes() const { return mIsFamilyOfNodes; }
+
+ /**
+ * Sets whether this Family is a family of nodes or family of elements (= cells).
+ * \param pIsFamilyOfNodes flag.
+ */
+ void setIsFamilyOfNodes(bool pIsFamilyOfNodes) { mIsFamilyOfNodes = pIsFamilyOfNodes; }
+
+ /**
+ * Inserts a new element (by its index) into this Family.
+ * \param pIndexElt index of the element to be added; must be >= 1.
+ * \throw IllegalArgumentException if pIndexElt <= 0.
+ */
+ void insertElt(med_int pIndexElt);
+
+ /**
+ * Returns the number of elements in this Family.
+ * \return the number of elements in this Family.
+ */
+ int getSize() const { return mElt.size(); }
+
+ //---------------------------------------------------------------------
+ // Algorithms
+ //---------------------------------------------------------------------
+
+ /**
+ * Adds all the groups of this Family into the set of groups described by (pGroups, pGroupNameToGroup).
+ * \param pGroups current list of groups.
+ * \param pGroupNameToGroup table (map) to retrieve a Group* from its name.
+ */
+ void buildGroups(
+ std::vector<Group*>& pGroups,
+ std::map<std::string, Group*>& pGroupNameToGroup) const;
+
+ /**
+ * Constructor. Returns a copy of this family restricted to the given group if pGroupName != NULL.
+ * Examples:
+ * 1. If current family have 3 groups "A", "B" and "C" and pGroupName="B", then the new family will only reference the group "B"
+ * 2. If current family have 3 groups "A", "B" and "C" and pGroupName="D", then the new family will reference groups "A", "B" and "C".
+ * WARNING: elements are not copied
+ * \param pGroupName name of the group to keep.
+ * \return a copy of this family.
+ */
+ Family* extractGroup(const char* pGroupName);
+
+ //---------------------------------------------------------------------
+ // I/O
+ //---------------------------------------------------------------------
+
+ /**
+ * Reads a Family from a MED file.
+ * \param pMEDfile any valid MED file opened for reading.
+ * \param pMeshName name of the mesh.
+ * \param pIndex index of the family to be read (must be >= 1).
+ * \throw IOException if any i/o error occurs.
+ */
+ void readMED(med_idt pMEDfile, char* pMeshName, med_int pIndex);
+
+ /**
+ * Writes this Family to a MED file.
+ * WARNING: mesh must have been created and added to the MED file before.
+ * \param pMEDfile any valid MED file opened for writing.
+ * \param pPeshName name of the mesh.
+ * \throw IOException if any i/o error occurs.
+ */
+ void writeMED(med_idt pMEDfile, char* pMeshName);
+
+ /**
+ * Sets the flag which control the stream operator <<.
+ * \param pFlag new flag value.
+ */
+ void setPrintAll(bool pFlag) { mFlagPrintAll = pFlag; }
+
+ /**
+ * Dumps any Family to the given output stream.
+ * \param pOs any output stream.
+ * \param pF any Family.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, Family& pF);
+
+private:
+
+ char mName[MED_TAILLE_NOM + 1]; /** Name of the Family */
+ med_int mId; /**< Id: > 0 if family of nodes; < 0 if family of elements. */
+ std::set<med_int> mElt; /**< Set of all the elements (by their index in 1..*). */
+ std::string mStrNameGroups; /**< A string with name of all groups which contain the Family. */
+ std::vector<std::string> mNameGroups; /**< List of groups (by name) which contain the Family. */
+ Attributs mAttributs; /**< All the attributed related to the Family. */
+ bool mIsFamilyOfNodes; /**< Is it a family of nodes or a family of elements? */
+
+ bool mFlagPrintAll; /** Flag to control the behaviour of the stream operator <<. */
+
+private:
+
+ // do not allow copy constructor
+ //Family(const Family&);
+
+ // do not allow copy
+ Family& operator=(const Family&);
+
+ // do not allow operator ==
+ bool operator==(const Family&);
+
+}; // class Family
+
+
+//*****************************************************************************
+// Class Group
+//*****************************************************************************
+
+class Group
+{
+public:
+
+ /**
+ * Builds an empty group (default constructor).
+ */
+ Group();
+
+ /**
+ * Destructor. Removes everything.
+ */
+ ~Group();
+
+ /**
+ * Resets this object in its state by default (empty). Cleans memory.
+ */
+ void reset();
+
+ //---------------------------------------------------------------------
+ // Basic accessors/mutators
+ //---------------------------------------------------------------------
+
+ /**
+ * Returns true if it is a group of nodes, false if it is a group of elements.
+ * \return true if it is a group of nodes, false if it is a group of elements.
+ */
+ bool isGroupOfNodes() const { return mIsGroupOfNodes; }
+
+ /**
+ * Sets whether it is a group of nodes or a group of elements.
+ * \param pIsGroupOfNodes true for a group of nodes, false for a group of elements.
+ */
+ void setIsGroupOfNodes(bool pIsGroupOfNodes) { mIsGroupOfNodes = pIsGroupOfNodes; }
+
+ /**
+ * Returns the name of this Group.
+ * \return the name of this Group.
+ */
+ const std::string& getName() const { return mName; }
+
+ /**
+ * Sets the name of this Group.
+ * \param pName new name of this Group (length of name must not exceed MED_TAILLE_LNOM).
+ */
+ void setName(const std::string& pName);
+
+ /**
+ * Adds the index of a new element to this Group.
+ * \param pIndexElt must be >= 1.
+ */
+ void insertElt(med_int pIndexElt);
+
+ /**
+ * Returns the set of all the elements referenced in this Group.
+ * \return the set of all the elements referenced in this Group.
+ */
+ const std::set<med_int>& getSetOfElt() const { return mElt; }
+
+ /**
+ * Returns the number of elements referenced in this Group.
+ * \return the number of elements referenced in this Group.
+ */
+ int getSize() const { return mElt.size(); }
+
+ //---------------------------------------------------------------------
+ // I/O
+ //---------------------------------------------------------------------
+
+ /**
+ * Sets the flag which control the stream operator <<.
+ * \param pFlag new flag value.
+ */
+ void setPrintAll(bool pFlag) { mFlagPrintAll = pFlag; }
+
+ /**
+ * Dumps any Group to the given output stream.
+ * \param pOs any output stream.
+ * \param pG any Group.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, Group& pG);
+
+private:
+
+ std::string mName; /**< Name of the group. */
+ std::set<med_int> mElt; /**< All elements of this group; each element is referenced by its index >= 1; each element is unique. */
+ bool mIsGroupOfNodes; /**< Is it a group of nodes or a group of elements? */
+
+ bool mFlagPrintAll; /** Flag to control the behaviour of the stream operator <<. */
+
+private:
+
+ // do not allow copy constructor
+ Group(const Group&);
+
+ // do not allow copy
+ Group& operator=(const Group&);
+
+ // do not allow operator ==
+ bool operator==(const Group&);
+
+}; // class Group
+
+
+} // namespace MULTIPR
+
+
+#endif // MULTIPR_FAMILY_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Field.cxx
+ *
+ * \brief see MULTIPR_Field.hxx
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include "MULTIPR_Field.hxx"
+#include "MULTIPR_Exceptions.hxx"
+
+#include <iostream>
+
+using namespace std;
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class Field implementation
+//*****************************************************************************
+
+Field::Field()
+{
+ reset();
+}
+
+
+Field::~Field()
+{
+ reset();
+}
+
+
+void Field::reset()
+{
+ mName[0] = '\0';
+ mEntity = MED_NOEUD;
+ mGeom = MED_NONE;
+ mType = MED_FLOAT64;
+ mSizeOfType = 8;
+ mNumComponents = 0;
+ mStrComponent = "";
+ mStrUnit = "";
+
+ mNGauss.clear();
+ mDT.clear();
+ mNumDT.clear();
+ mDTUnit.clear();
+ mNumO.clear();
+ mGaussLoc.clear();
+ mProfil.clear();
+ mSizeOfData.clear();
+ mNVal.clear();
+
+ for (unsigned it = 0 ; it < mVal.size() ; it++)
+ {
+ delete[] mVal[it];
+ }
+ mVal.clear();
+
+ mFlagPrintAll = false;
+}
+
+
+bool Field::isEmpty() const
+{
+ return (mNGauss.size() == 0);
+}
+
+
+int Field::getNumberOfGaussPointsByElement(int pTimeStepIt) const
+{
+ if ((pTimeStepIt < 1) || (pTimeStepIt > int(mNGauss.size()))) throw IndexOutOfBoundsException("", __FILE__, __LINE__);
+
+ return mNGauss[pTimeStepIt - 1];
+}
+
+
+const string& Field::getNameGaussLoc(int pTimeStepIt) const
+{
+ if ((pTimeStepIt < 1) || (pTimeStepIt > int(mNGauss.size()))) throw IndexOutOfBoundsException("", __FILE__, __LINE__);
+
+ return mGaussLoc[pTimeStepIt - 1];
+}
+
+
+const unsigned char* Field::getValue(int pTimeStepIt, int pIndex) const
+{
+ if ((pTimeStepIt < 1) || (pTimeStepIt > int(mNGauss.size()))) throw IndexOutOfBoundsException("", __FILE__, __LINE__);
+ if ((pIndex < 1) || (pIndex > mNVal[pTimeStepIt - 1] / mNGauss[pTimeStepIt - 1])) throw IndexOutOfBoundsException("", __FILE__, __LINE__);
+
+ // size of one data = size of type * number of components * number of Gauss points
+ int sizeOfOneData = mSizeOfType * mNumComponents * mNGauss[pTimeStepIt - 1];
+
+ unsigned char* ret = mVal[pTimeStepIt - 1] + (pIndex - 1) * sizeOfOneData;
+
+ return ret;
+}
+
+
+Field* Field::extractSubSet(const set<med_int>& pSetIndices) const
+{
+ Field* subset = new Field();
+
+ memcpy(subset->mName, mName, MED_TAILLE_NOM + 1);
+ subset->mEntity = mEntity;
+ subset->mGeom = mGeom;
+ subset->mType = mType;
+ subset->mSizeOfType = mSizeOfType;
+ subset->mNumComponents = mNumComponents;
+ subset->mStrComponent = mStrComponent;
+ subset->mStrUnit = mStrUnit;
+
+ subset->mNGauss = mNGauss;
+ subset->mDT = mDT;
+ subset->mNumDT = mNumDT;
+ subset->mDTUnit = mDTUnit;
+ subset->mNumO = mNumO;
+ subset->mGaussLoc = mGaussLoc;
+ subset->mProfil = mProfil;
+
+ // for each time step
+ for (unsigned itTimeStep = 0 ; itTimeStep < mNGauss.size() ; itTimeStep++)
+ {
+ if (mProfil[itTimeStep].size() != 0) throw UnsupportedOperationException("", __FILE__, __LINE__);
+ // WARNING : do not manage profil for the moment
+ // if there is a profil,
+ // 1. we should set mProfil to NO_PROFIL for this time_step
+ // 2. we should extract data according to the profil
+
+ int nval = pSetIndices.size() * subset->mNGauss[itTimeStep];
+ subset->mNVal.push_back(nval);
+
+ int sizeOfData = nval * mSizeOfType * mNumComponents;
+ subset->mSizeOfData.push_back(sizeOfData);
+
+ unsigned char* data = new unsigned char[sizeOfData];
+ unsigned char* dest = data;
+ int sizeOfOneData = mSizeOfType * mNumComponents * subset->mNGauss[itTimeStep];
+
+ // for each element to extract
+ for (set<med_int>::iterator itSet = pSetIndices.begin() ; itSet != pSetIndices.end() ; itSet++)
+ {
+ int indexElt = (*itSet);
+
+ // MED index start at 1.
+ if (indexElt < 1) throw new IllegalArgumentException("", __FILE__, __LINE__);
+
+ unsigned char* src = mVal[itTimeStep] + (indexElt - 1) * sizeOfOneData;
+ memcpy(dest, src, sizeOfOneData);
+
+ dest += sizeOfOneData;
+ }
+ subset->mVal.push_back(data);
+ }
+
+ return subset;
+}
+
+
+Field* Field::merge(Field* pField)
+{
+ Field* field = new Field();
+
+ if (strcmp(mName, pField->mName) != 0) throw IllegalStateException("incompatible field", __FILE__, __LINE__);
+ memcpy(field->mName, mName, MED_TAILLE_NOM + 1);
+
+ if (mEntity != pField->mEntity) throw IllegalStateException("incompatible entity", __FILE__, __LINE__);
+ field->mEntity = mEntity;
+
+ if (mGeom != pField->mGeom) throw IllegalStateException("incompatible geom", __FILE__, __LINE__);
+ field->mGeom = mGeom;
+
+ if (mType != pField->mType) throw IllegalStateException("incompatible type", __FILE__, __LINE__);
+ field->mType = mType;
+
+ field->mSizeOfType = mSizeOfType;
+
+ if (mNumComponents != pField->mNumComponents) throw IllegalStateException("incompatible #components", __FILE__, __LINE__);
+ field->mNumComponents = mNumComponents;
+
+ field->mStrComponent = mStrComponent;
+ field->mStrUnit = mStrUnit;
+
+ if (mNGauss.size() != pField->mNGauss.size()) throw IllegalStateException("incompatible #time stamps", __FILE__, __LINE__);
+ field->mNGauss = mNGauss;
+
+ field->mDT = mDT;
+ field->mNumDT = mNumDT;
+ field->mDTUnit = mDTUnit;
+ field->mNumO = mNumO;
+ field->mGaussLoc = mGaussLoc;
+ field->mProfil = mProfil;
+
+ // for each time step
+ for (unsigned itTimeStep = 0 ; itTimeStep < mNGauss.size() ; itTimeStep++)
+ {
+ int sizeOfData = mSizeOfData[itTimeStep] + pField->mSizeOfData[itTimeStep];
+ field->mSizeOfData.push_back(sizeOfData);
+
+ int nVal = mNVal[itTimeStep] + pField->mNVal[itTimeStep];
+ field->mNVal.push_back(nVal);
+
+ unsigned char* data = new unsigned char[sizeOfData];
+ memcpy(data, mVal[itTimeStep], mSizeOfData[itTimeStep]);
+ memcpy(data + mSizeOfData[itTimeStep], pField->mVal[itTimeStep], pField->mSizeOfData[itTimeStep]);
+ field->mVal.push_back(data);
+ }
+
+ return field;
+}
+
+
+Field* Field::merge(vector<Field*> pFields, int pFieldIt)
+{
+ if (pFields.size() == 0) throw IllegalArgumentException("pElements should contain at least 1 element", __FILE__, __LINE__);
+
+ Field* field = new Field();
+
+ // check if fields are compatible
+ for (unsigned i = 0 ; i < pFields.size() ; i++)
+ {
+ if (strcmp(mName, pFields[i]->mName) != 0) throw IllegalStateException("incompatible field", __FILE__, __LINE__);
+ if (mEntity != pFields[i]->mEntity) throw IllegalStateException("incompatible entity", __FILE__, __LINE__);
+ if (mGeom != pFields[i]->mGeom) throw IllegalStateException("incompatible geom", __FILE__, __LINE__);
+ if (mType != pFields[i]->mType) throw IllegalStateException("incompatible type", __FILE__, __LINE__);
+ if (mNumComponents != pFields[i]->mNumComponents) throw IllegalStateException("incompatible #components", __FILE__, __LINE__);
+ if (mNGauss.size() != pFields[i]->mNGauss.size()) throw IllegalStateException("incompatible #time stamps", __FILE__, __LINE__);
+ }
+
+ memcpy(field->mName, mName, MED_TAILLE_NOM + 1);
+ field->mEntity = mEntity;
+ field->mGeom = mGeom;
+ field->mType = mType;
+ field->mSizeOfType = mSizeOfType;
+ field->mNumComponents = mNumComponents;
+ field->mStrComponent = mStrComponent;
+ field->mStrUnit = mStrUnit;
+
+ if (pFieldIt == -1) // merge all time step
+ {
+ field->mNGauss = mNGauss;
+ field->mDT = mDT;
+ field->mNumDT = mNumDT;
+ field->mDTUnit = mDTUnit;
+ field->mNumO = mNumO;
+ field->mGaussLoc = mGaussLoc;
+ field->mProfil = mProfil;
+
+ // for each time step
+ for (unsigned itTimeStep = 0 ; itTimeStep < mNGauss.size() ; itTimeStep++)
+ {
+ int sizeOfData = mSizeOfData[itTimeStep];
+ int nVal = mNVal[itTimeStep];
+
+ for (unsigned i = 0 ; i < pFields.size() ; i++)
+ {
+ sizeOfData += pFields[i]->mSizeOfData[itTimeStep];
+ nVal += pFields[i]->mNVal[itTimeStep];
+ }
+
+ field->mSizeOfData.push_back(sizeOfData);
+ field->mNVal.push_back(nVal);
+
+ unsigned char* data = new unsigned char[sizeOfData];
+ memcpy(data, mVal[itTimeStep], mSizeOfData[itTimeStep]);
+
+ int offsetData = mSizeOfData[itTimeStep];
+ for (unsigned i = 0 ; i < pFields.size() ; i++)
+ {
+ memcpy(data + offsetData, pFields[i]->mVal[itTimeStep], pFields[i]->mSizeOfData[itTimeStep]);
+ offsetData += pFields[i]->mSizeOfData[itTimeStep];
+ }
+
+ field->mVal.push_back(data);
+ }
+ }
+ else // only merge the given time step
+ {
+ field->mNGauss.push_back(mNGauss[pFieldIt]);
+ field->mDT.push_back(mDT[pFieldIt]);
+ field->mNumDT.push_back(mNumDT[pFieldIt]);
+ field->mDTUnit.push_back(mDTUnit[pFieldIt]);
+ field->mNumO.push_back(mNumO[pFieldIt]);
+
+ if (mGaussLoc.size() != 0) field->mGaussLoc.push_back(mGaussLoc[pFieldIt]);
+ if (mProfil.size() != 0) field->mProfil.push_back(mProfil[pFieldIt]);
+
+ // to finish
+ throw UnsupportedOperationException("not yet implemented", __FILE__, __LINE__);
+ }
+
+ return field;
+}
+
+
+void Field::getSetOfGaussLoc(set<string>& pSetOfGaussLoc) const
+{
+ for (unsigned itGaussLoc = 0 ; itGaussLoc < mGaussLoc.size() ; itGaussLoc++)
+ {
+ const string& gaussLocName = mGaussLoc[itGaussLoc];
+
+ if (gaussLocName.length() != 0)
+ {
+ pSetOfGaussLoc.insert(gaussLocName);
+ }
+ }
+}
+
+
+void Field::readMED(med_idt pMEDfile, med_int pIndex, char* pMeshName)
+{
+ if (pMEDfile == 0) throw IOException("", __FILE__, __LINE__);
+ if (pMeshName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if (strlen(pMeshName) > MED_TAILLE_NOM) throw IllegalArgumentException("", __FILE__, __LINE__);
+ if (pIndex < 1) throw IllegalArgumentException("", __FILE__, __LINE__);
+
+ reset();
+
+ mNumComponents = MEDnChamp(pMEDfile, pIndex);
+
+ if (mNumComponents < 0) throw IOException("", __FILE__, __LINE__);
+
+ char* strComponent = new char[mNumComponents * MED_TAILLE_PNOM + 1];
+ char* strUnit = new char[mNumComponents * MED_TAILLE_PNOM + 1];
+
+ strComponent[0] = '\0';
+ strUnit[0] = '\0';
+
+ med_err ret = MEDchampInfo(
+ pMEDfile,
+ pIndex,
+ mName,
+ &(mType),
+ strComponent,
+ strUnit,
+ mNumComponents);
+
+ if (ret != 0) throw IOException("", __FILE__, __LINE__);
+
+ mStrComponent = strComponent;
+ mStrUnit = strUnit;
+
+ delete[] strUnit;
+ delete[] strComponent;
+
+ switch (mType)
+ {
+ case MED_FLOAT64: mSizeOfType = 8; break;
+ case MED_INT64: mSizeOfType = 8; break;
+ case MED_INT32: mSizeOfType = 4; break;
+ case MED_INT: mSizeOfType = 4; break;
+ default: throw IllegalStateException("should not be there", __FILE__, __LINE__);
+ }
+
+ //---------------------------------------------------------------------
+ // Read fields over nodes
+ //---------------------------------------------------------------------
+ bool fieldOnNodes = false;
+ {
+ med_int numTimeStepNodes = MEDnPasdetemps(
+ pMEDfile,
+ mName,
+ MED_NOEUD,
+ (med_geometrie_element) 0);
+
+ if (numTimeStepNodes < 0) throw IOException("", __FILE__, __LINE__);
+
+ if (numTimeStepNodes != 0)
+ {
+ fieldOnNodes = true;
+ mEntity = MED_NOEUD;
+ mGeom = (med_geometrie_element) 0;
+ readMEDtimeSteps(pMEDfile, numTimeStepNodes, pMeshName);
+ }
+ }
+
+ //---------------------------------------------------------------------
+ // Read fields over elements
+ //---------------------------------------------------------------------
+ {
+ med_int numTimeStepElt = MEDnPasdetemps(
+ pMEDfile,
+ mName,
+ MED_MAILLE,
+ MED_TETRA10);
+
+ if (numTimeStepElt < 0) throw IOException("", __FILE__, __LINE__);
+
+ if (numTimeStepElt != 0)
+ {
+ if (fieldOnNodes) throw IllegalStateException("", __FILE__, __LINE__);
+
+ mEntity = MED_MAILLE;
+ mGeom = MED_TETRA10;
+ readMEDtimeSteps(pMEDfile, numTimeStepElt, pMeshName);
+ }
+ }
+}
+
+
+void Field::readMEDtimeSteps(med_idt pMEDfile, med_int pNumberOfTimeSteps, char* pMeshName)
+{
+ if (pMEDfile == 0) throw IOException("", __FILE__, __LINE__);
+ if (pMeshName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if (strlen(pMeshName) > MED_TAILLE_NOM) throw IllegalArgumentException("", __FILE__, __LINE__);
+ if (pNumberOfTimeSteps < 0) throw IllegalArgumentException("", __FILE__, __LINE__);
+
+ char strEntity[8];
+ switch (mEntity)
+ {
+ case MED_ARETE:
+ case MED_FACE:
+ case MED_MAILLE: strcpy(strEntity, "CELLS"); break;
+ case MED_NOEUD: strcpy(strEntity, "NODES"); break;
+ default: strcpy(strEntity, "UNKNOWN"); break;
+ }
+
+ // iterates over time step
+ for (int itTimeStep = 1 ; itTimeStep <= pNumberOfTimeSteps ; itTimeStep++)
+ {
+ med_int ngauss;
+ med_int numdt;
+ med_int numo;
+ char dtunit[MED_TAILLE_PNOM + 1];
+ med_float dt;
+ char maa[MED_TAILLE_NOM + 1];
+ med_booleen local;
+ med_int nmaa;
+
+ med_err ret = MEDpasdetempsInfo(
+ pMEDfile,
+ mName,
+ mEntity,
+ mGeom,
+ itTimeStep,
+ &ngauss,
+ &numdt,
+ &numo,
+ dtunit,
+ &dt,
+ maa,
+ &local,
+ &nmaa);
+
+ if (ret != 0) throw IOException("i/o error while reading #timesteps in MED file", __FILE__, __LINE__);
+
+ // mesh must be local
+ if (local != MED_VRAI) throw IllegalStateException("only local fields are currently supported", __FILE__, __LINE__);
+
+ // #mesh must be 1
+ if (nmaa != 1) throw IllegalStateException("field shoud be associated with 1 mesh only", __FILE__, __LINE__);
+
+ // mesh must be pMeshName
+ // if field does not apply on the current mesh, skip
+ if (strcmp(maa, pMeshName) != 0)
+ {
+ continue;
+ }
+
+ mNGauss.push_back(ngauss);
+ mDT.push_back(dt);
+ mNumDT.push_back(numdt);
+ mDTUnit.push_back(dtunit);
+ mNumO.push_back(numo);
+
+ med_int nval = MEDnVal(
+ pMEDfile,
+ mName,
+ mEntity,
+ mGeom,
+ numdt,
+ numo,
+ pMeshName,
+ MED_GLOBAL);
+
+ if (nval < 0) throw IOException("i/o error while reading field in MED file", __FILE__, __LINE__);
+
+ mNVal.push_back(nval);
+
+ char gaussLocName[MED_TAILLE_NOM + 1];
+ char profilName[MED_TAILLE_NOM + 1];
+ int sizeOfData = mSizeOfType * mNumComponents * nval;
+ mSizeOfData.push_back(sizeOfData);
+ unsigned char* fieldData = new unsigned char[sizeOfData];
+
+ ret = MEDchampLire(
+ pMEDfile,
+ pMeshName,
+ mName,
+ fieldData,
+ MED_FULL_INTERLACE,
+ MED_ALL,
+ gaussLocName,
+ profilName,
+ MED_COMPACT, // should be: MED_GLOBAL, MED_NO_PFLMOD, MED_COMPACT
+ mEntity,
+ mGeom,
+ numdt,
+ numo);
+
+ if (ret != 0) throw IOException("i/o error while reading field in MED file", __FILE__, __LINE__);
+
+ mGaussLoc.push_back(gaussLocName);
+ mProfil.push_back(profilName);
+ mVal.push_back(fieldData);
+ }
+}
+
+
+void Field::writeMED(med_idt pMEDfile, char* pMeshName)
+{
+ if (pMEDfile == 0) throw IOException("", __FILE__, __LINE__);
+ if (pMeshName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if (strlen(pMeshName) > MED_TAILLE_NOM) throw IllegalArgumentException("", __FILE__, __LINE__);
+ if (mNumComponents < 1) throw IllegalStateException("", __FILE__, __LINE__);
+
+ med_err ret = MEDchampCr(
+ pMEDfile,
+ mName, // name of the field
+ mType, // type of data (MED_FLOAT64, MED_INT32, etc.)
+ const_cast<char*>(mStrComponent.c_str()), // name of components
+ const_cast<char*>(mStrUnit.c_str()), // name of units
+ mNumComponents); // number of components
+
+ if (ret != 0) throw IOException("i/o error while creating field in MED file", __FILE__, __LINE__);
+
+ // for each time step
+ for (unsigned i = 0 ; i < mNGauss.size() ; i++)
+ {
+ // skip if no values
+ if (mNVal[i] == 0) continue;
+
+ ret = MEDchampEcr(
+ pMEDfile,
+ pMeshName, // name of the mesh (first call to MEDchampEcr => name of reference)
+ mName, // name of the field
+ mVal[i], // data (= values)
+ MED_FULL_INTERLACE, // data organization
+ mNVal[i], // number of values
+ const_cast<char*>(mGaussLoc[i].c_str()), // name of Gauss reference
+ MED_ALL, // components to be selected
+ const_cast<char*>(mProfil[i].c_str()), // name of profil
+ MED_GLOBAL, // how to read data: MED_NO_PFLMOD,MED_COMPACT,MED_GLOBAL
+ mEntity, // type of entity (MED_NOEUD, MED_MAILLE, etc.)
+ mGeom, // type of geometry (TETRA10, etc.)
+ mNumDT[i], // time step iteration
+ const_cast<char*>(mDTUnit[i].c_str()), // unit of time step
+ mDT[i], // time key
+ mNumO[i]); // order number
+
+ if (ret != 0) throw IOException("i/o error while writing field in MED file", __FILE__, __LINE__);
+ }
+}
+
+
+ostream& operator<<(ostream& pOs, Field& pF)
+{
+ char strEntity[16];
+ switch (pF.mEntity)
+ {
+ case MED_MAILLE: strcpy(strEntity, "MED_MAILLE"); break;
+ case MED_FACE: strcpy(strEntity, "MED_FACE"); break;
+ case MED_ARETE: strcpy(strEntity, "MED_ARETE"); break;
+ case MED_NOEUD: strcpy(strEntity, "MED_NOEUD"); break;
+ default: strcpy(strEntity, "UNKNOWN"); break;
+ }
+
+ char strType[16];
+ switch (pF.mType)
+ {
+ case MED_FLOAT64: strcpy(strType, "MED_FLOAT64"); break;
+ case MED_INT32: strcpy(strType, "MED_INT32"); break;
+ case MED_INT64: strcpy(strType, "MED_INT64"); break;
+ case MED_INT: strcpy(strType, "MED_INT"); break;
+ default: strcpy(strType, "UNKNOWN"); break;
+ }
+
+ pOs << "Field: " << endl;
+ pOs << " Name =|" << pF.mName << "|" << endl;
+ pOs << " Entity =" << strEntity << endl;
+ pOs << " Geom =" << pF.mGeom << endl;
+ pOs << " Type =" << strType << " (size=" << pF.mSizeOfType << ")" << endl;
+ pOs << " #Components=" << pF.mNumComponents << endl;
+ pOs << " Name component=|" << pF.mStrComponent << "|" << endl;
+ pOs << " Unit component=|" << pF.mStrUnit << "|" << endl;
+ pOs << " #Time steps=" << pF.mNGauss.size() << endl;
+
+ for (unsigned itTimeStep = 0 ; itTimeStep < pF.mNGauss.size() ; itTimeStep++)
+ {
+ pOs << " Time=" << pF.mDT[itTimeStep];
+ pOs << " it=" << pF.mNumDT[itTimeStep];
+ pOs << " order=" << pF.mNumO[itTimeStep];
+ pOs << " #gauss=" << pF.mNGauss[itTimeStep];
+ pOs << " #val=" << pF.mNVal[itTimeStep];
+ pOs << " sizeof_val=" << pF.mSizeOfData[itTimeStep];
+ pOs << " gauss_loc=|" << ((pF.mGaussLoc[itTimeStep].size() == 0)?"NONE":pF.mGaussLoc[itTimeStep]) << "| size=" << pF.mGaussLoc[itTimeStep].size();
+ pOs << " profil=|" << ((pF.mProfil[itTimeStep].size() == 0)?"NONE":pF.mProfil[itTimeStep]) << "| size=" << pF.mProfil[itTimeStep].size() << endl;
+
+ if (pF.mFlagPrintAll)
+ {
+ cout << " Values: ";
+ switch (pF.mType)
+ {
+ case MED_FLOAT64:
+ {
+ med_float* src = reinterpret_cast<med_float*>(pF.mVal[itTimeStep]);
+ for (int itVal = 0 ; itVal < pF.mNVal[itTimeStep] * pF.mNumComponents ; itVal++)
+ {
+ cout << src[itVal] << " ";
+ }
+ }
+ break;
+ case MED_INT:
+ case MED_INT32:
+ {
+ med_int* src = reinterpret_cast<med_int*>(pF.mVal[itTimeStep]);
+ for (int itVal = 0 ; itVal < pF.mNVal[itTimeStep] * pF.mNumComponents ; itVal++)
+ {
+ cout << src[itVal] << " ";
+ }
+ }
+ break;
+ case MED_INT64:
+ // not yet implemented
+ throw UnsupportedOperationException("not yet implemented", __FILE__, __LINE__);
+ default:
+ // should not be there
+ throw IllegalStateException("should not be there", __FILE__, __LINE__);
+ }
+ cout << endl;
+ }
+
+ }
+
+ return pOs;
+}
+
+
+} // namespace multipr
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Field.hxx
+ *
+ * \brief Class Field used to wrap MED file fields.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_FIELD_HXX
+#define MULTIPR_FIELD_HXX
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+extern "C"
+{
+ #include "med.h"
+}
+
+#include <string>
+#include <vector>
+#include <set>
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class Field
+//*****************************************************************************
+
+class Field
+{
+public:
+
+ /**
+ * Builds an empty field (default constructor).
+ */
+ Field();
+
+ /**
+ * Destructor. Removes everything.
+ */
+ ~Field();
+
+ /**
+ * Resets this object in its state by default (empty). Cleans memory.
+ */
+ void reset();
+
+ //---------------------------------------------------------------------
+ // Basic accessors/mutators
+ //---------------------------------------------------------------------
+
+ /**
+ * Returns true iff this field is empty (no data).
+ * \return true if this field is empty, false otherwise.
+ */
+ bool isEmpty() const;
+
+ /**
+ * Returns true iff this field apply on nodes (otherwise, information are related to elements).
+ * \return true iff this field apply on nodes.
+ */
+ bool isFieldOnNodes() const { return (mEntity == MED_NOEUD); }
+
+ /**
+ * Returns the name of this Field.
+ * \return the name of this Field.
+ */
+ const char* getName() const { return mName; }
+
+ /**
+ * Returns the number of time steps in this Field.
+ * \return the number of time steps in this Field.
+ */
+ int getNumberOfTimeSteps() const { return mNGauss.size(); }
+
+ /**
+ * Returns the numeric type of information contained in this Field (e.g. MED_FLOAT64).
+ * \return the numeric type of this Field.
+ */
+ med_type_champ getType() const { return mType; }
+
+ /**
+ * Returns the number of components of this Field.
+ * \return the number of components of this Field.
+ */
+ int getNumberOfComponents() const { return mNumComponents; }
+
+ /**
+ * Returns the number of Gauss points for each element at the given time step.
+ * \param pTimeStepIt iteration of the field; must be in [1..MAX_ITERATION].
+ * \return number of Gauss points in the elements of this Field at the given iteration.
+ * \throw IndexOutOfBoundsException if pTimeStepIt not in [1..MAX_ITERATION].
+ */
+ int getNumberOfGaussPointsByElement(int pTimeStepIt) const;
+
+ /**
+ * Returns the name of the Gauss localization related to the given iteration.
+ * \param pTimeStepIt iteration of the field; must be in [1..MAX_ITERATION].
+ * \return the name of the Gauss localization related to the given iteration.
+ * \throw IndexOutOfBoundsException if pTimeStepIt not in [1..MAX_ITERATION].
+ */
+ const std::string& getNameGaussLoc(int pTimeStepIt) const;
+
+ /**
+ * Returns a pointer towards the first value of this Field for the given element at the given time step.
+ * \param pTimeStepIt iteration of the field; must be in [1..MAX_ITERATION].
+ * \param pIndex index of the element; must be >= 1.
+ * \return the value of this Field for the given element at the given time step.
+ * \throw IndexOutOfBoundsException if pTimeStepIt or pIndex are invalid.
+ */
+ const unsigned char* getValue(int pTimeStepIt, int pIndex) const;
+
+ //---------------------------------------------------------------------
+ // Algorithms
+ //---------------------------------------------------------------------
+
+ /**
+ * Creates a subset of this Field restricted to a set of elements (NODES or CELLS).
+ * This method performs a projection of this Field on the given set of elements.
+ * \param pSetIndices WARNING: indices start at 1.
+ * \return a new Field restricted to the given set of elements.
+ */
+ Field* extractSubSet(const std::set<med_int>& pSetIndices) const;
+
+ /**
+ * Adds the set of GaussLoc used by this Field into the given set.
+ * \param pSetOfGauss any set of Gauss localisation.
+ */
+ void getSetOfGaussLoc(std::set<std::string>& pSetOfGaussLoc) const;
+
+ /**
+ * Builds a new field by merging data of this and pField if they are compatible.
+ * \param pField the field to be merged with this.
+ * \throw IllegalStateException if the two fields are incompatible.
+ */
+ Field* merge(Field* pField);
+ Field* merge(std::vector<Field*> pFields, int pFieldIt = -1);
+
+ //---------------------------------------------------------------------
+ // I/O
+ //---------------------------------------------------------------------
+
+ /**
+ * Reads a field from a MED file.
+ * If the field is not related to the given mesh, the result is an empty field.
+ * \param pMEDfile any valid MED file opened for reading.
+ * \param pIndex index of the field to be read; must be >= 1.
+ * \param pMeshName name of the mesh (a field is always related to a mesh).
+ * \throw IOException if any i/o error occurs.
+ */
+ void readMED(med_idt pMEDfile, med_int pIndex, char* pMeshName);
+
+ /**
+ * Writes this field to a MED file. The field is linked to the given mesh.
+ * WARNING: all related Gauss info must have been added to the MED file before.
+ * \param pMEDfile any valid MED file opened for writing.
+ * \param pMeshName name of the mesh.
+ * \throw IOException if any i/o error occurs.
+ */
+ void writeMED(med_idt pMEDfile, char* pMeshName);
+
+ /**
+ * Sets the flag which control the stream operator <<.
+ * \param pFlag new flag value.
+ */
+ void setPrintAll(bool pFlag) { mFlagPrintAll = pFlag; }
+
+ /**
+ * Dumps any Field to the given output stream.
+ * \param pOs any output stream.
+ * \param pF any Field.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, Field& pF);
+
+private:
+
+ /**
+ * Reads all the information related to its field and a given time step (by its index).
+ * \param pMEDfile MED file handle.
+ * \param pNumberOfTimeSteps number of timesteps (iteration) to be read.
+ * \param pMeshName name of the mesh.
+ * \throw IOException if any i/o error occurs.
+ */
+ void readMEDtimeSteps(med_idt pMEDfile, med_int pNumberOfTimeSteps, char* pMeshName);
+
+private:
+
+ char mName[MED_TAILLE_NOM + 1];
+ med_entite_maillage mEntity; // type of entity, e.g. MED_MAILLE
+ med_geometrie_element mGeom; // type of primitives, e.g. MED_TETRA10 (MED_NONE for a field on nodes)
+ med_type_champ mType; // type of field, e.g. MED_FLOAT64, MED_INT32
+ int mSizeOfType; // 8 for MED_FLOAT64, 4 for MED_INT32, etc.
+ med_int mNumComponents;
+ std::string mStrComponent;
+ std::string mStrUnit;
+
+ // Information related to time steps.
+ // Each vector should contain the same number of elements.
+ // Number of time step = mNGauss.size() = mDT.size() = ...
+
+ std::vector<med_int> mNGauss; /**< For each time step, number of Gauss points in the field. */
+ std::vector<med_float> mDT; /**< For each time step, value of time step. */
+ std::vector<med_int> mNumDT; /**< For each time step, iteration number. */
+ std::vector<std::string> mDTUnit; /**< For each time step, units. */
+ std::vector<med_int> mNumO; /**< For each time step, order number. */
+ std::vector<std::string> mGaussLoc; /**< For each time step, name of Gauss localization to be used (empty if none). */
+ std::vector<std::string> mProfil; /**< For each time step, name of the profil to be used (empty if none). */
+ std::vector<int> mSizeOfData; /**< For each time step, sizeof data (mVal) in bytes. */
+ std::vector<med_int> mNVal; /**< For each time step, number of values. */
+ std::vector<unsigned char*> mVal; /**< For each time step, raw data; can be MED_FLOAT64, MED_INT32, etc. see mType. */
+
+ bool mFlagPrintAll; /**< Flag to control the behaviour of the stream operator <<. */
+
+private:
+
+ // do not allow copy constructor
+ Field(const Field&);
+
+ // do not allow copy
+ Field& operator=(const Field&);
+
+ // do not allow operator ==
+ bool operator==(const Field&);
+
+}; // class Field
+
+
+} // namespace MULTIPR
+
+
+#endif // MULTIPR_FIELD_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_GaussLoc.cxx
+ *
+ * \brief see MULTIPR_GaussLoc.hxx
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include "MULTIPR_GaussLoc.hxx"
+#include "MULTIPR_Utils.hxx"
+#include "MULTIPR_Exceptions.hxx"
+
+#include <iostream>
+
+using namespace std;
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class GaussLoc implementation
+//*****************************************************************************
+
+GaussLoc::GaussLoc()
+{
+ mRefCoo = NULL;
+ mGaussCoo = NULL;
+ mWeight = NULL;
+
+ reset();
+}
+
+
+GaussLoc::GaussLoc(const GaussLoc& pGaussLoc)
+{
+ mRefCoo = NULL;
+ mGaussCoo = NULL;
+ mWeight = NULL;
+
+ strcpy(mName, pGaussLoc.mName);
+
+ mGeom = pGaussLoc.mGeom;
+ mDim = pGaussLoc.mDim;
+ mNumNodes = pGaussLoc.mNumNodes;
+ mNumGauss = pGaussLoc.mNumGauss;
+
+ if (mDim != (mGeom / 100)) throw IllegalStateException("", __FILE__, __LINE__);
+ if (mNumNodes != (mGeom % 100)) throw IllegalStateException("", __FILE__, __LINE__);
+
+ if (pGaussLoc.mRefCoo != NULL)
+ {
+ mRefCoo = new med_float[mDim * mNumNodes];
+ memcpy(mRefCoo, pGaussLoc.mRefCoo, sizeof(med_float) * mDim * mNumNodes);
+ }
+
+ if (pGaussLoc.mGaussCoo != NULL)
+ {
+ mGaussCoo = new med_float[mDim * mNumGauss];
+ memcpy(mGaussCoo, pGaussLoc.mGaussCoo, sizeof(med_float) * mDim * mNumGauss);
+ }
+
+ if (pGaussLoc.mWeight != NULL)
+ {
+ mWeight = new med_float[mNumGauss];
+ memcpy(mWeight, pGaussLoc.mWeight, sizeof(med_float) * mNumGauss);
+ }
+}
+
+
+GaussLoc::~GaussLoc()
+{
+ reset();
+}
+
+
+void GaussLoc::reset()
+{
+ mName[0] = '\0';
+ mGeom = MED_NONE;
+ mDim = 0;
+ mNumNodes = 0;
+ mNumGauss = 0;
+
+ if (mRefCoo != NULL) { delete[] mRefCoo; mRefCoo = NULL; }
+ if (mGaussCoo != NULL) { delete[] mGaussCoo; mGaussCoo = NULL; }
+ if (mWeight != NULL) { delete[] mWeight; mWeight = NULL; }
+}
+
+
+void GaussLoc::getCoordGaussPoints(
+ const med_float* pCooElt,
+ med_float* pCooGaussPoints) const
+{
+ // debug
+ //printArray2D(pCooElt, mNumNodes, mDim, "Node");
+
+ // WARNING: assumes TETRA10 !!!
+ // This method is not completely generic and should be extended to support all cases.
+ if (mGeom != MED_TETRA10) throw UnsupportedOperationException("only support TETRA10 for the moment", __FILE__, __LINE__);
+
+ const med_float* pt1 = pCooElt;
+ const med_float* pt2 = pt1 + mDim;
+ const med_float* pt3 = pt2 + mDim;
+ const med_float* pt4 = pt3 + mDim;
+
+ const med_float* coeff = mGaussCoo;
+ med_float* dest = pCooGaussPoints;
+
+ // for each Gauss point
+ for (int i = 0 ; i < mNumGauss ; i++)
+ {
+ dest[0] = pt2[0] + (pt4[0] - pt2[0]) * coeff[0] + (pt1[0] - pt2[0]) * coeff[1] + (pt3[0] - pt2[0]) * coeff[2];
+ dest[1] = pt2[1] + (pt4[1] - pt2[1]) * coeff[0] + (pt1[1] - pt2[1]) * coeff[1] + (pt3[1] - pt2[1]) * coeff[2];
+ dest[2] = pt2[2] + (pt4[2] - pt2[2]) * coeff[0] + (pt1[2] - pt2[2]) * coeff[1] + (pt3[2] - pt2[2]) * coeff[2];
+
+ // prepare next point
+ coeff += mDim;
+ dest += mDim;
+ }
+}
+
+
+void GaussLoc::readMED(med_idt pMEDfile, med_int pIndex)
+{
+ if (pMEDfile == 0) throw IOException("pMEDfile should not be NULL", __FILE__, __LINE__);
+ if (pIndex < 1) throw IllegalArgumentException("pIndex should be >= 1", __FILE__, __LINE__);
+
+ reset();
+
+ med_err ret = MEDgaussInfo(
+ pMEDfile,
+ pIndex,
+ mName,
+ &mGeom,
+ &mNumGauss);
+
+ if (ret != 0) throw IOException("i/o error while reading Gauss localization information in MED file", __FILE__, __LINE__);
+
+ mDim = mGeom / 100;
+ mNumNodes = mGeom % 100;
+
+ mRefCoo = new med_float[mDim * mNumNodes];
+ mGaussCoo = new med_float[mDim * mNumGauss];
+ mWeight = new med_float[mNumGauss];
+
+ ret = MEDgaussLire(
+ pMEDfile,
+ mRefCoo,
+ mGaussCoo,
+ mWeight,
+ MED_FULL_INTERLACE,
+ mName);
+
+ if (ret != 0) throw IOException("i/o error while reading Gauss localization in MED file", __FILE__, __LINE__);
+}
+
+
+void GaussLoc::writeMED(med_idt pMEDfile)
+{
+ if (pMEDfile == 0) throw IOException("", __FILE__, __LINE__);
+ if (mNumGauss < 0) throw IllegalStateException("", __FILE__, __LINE__);
+ if (mRefCoo == NULL) throw IllegalStateException("", __FILE__, __LINE__);
+ if (mGaussCoo == NULL) throw IllegalStateException("", __FILE__, __LINE__);
+ if (mWeight == NULL) throw IllegalStateException("", __FILE__, __LINE__);
+ if (strlen(mName) > MED_TAILLE_NOM) throw IllegalStateException("", __FILE__, __LINE__);
+
+ med_err ret = MEDgaussEcr(
+ pMEDfile,
+ mGeom,
+ mRefCoo,
+ MED_FULL_INTERLACE,
+ mNumGauss,
+ mGaussCoo,
+ mWeight,
+ mName);
+
+ if (ret != 0) throw IOException("i/o error while writing Gauss localization", __FILE__, __LINE__);
+}
+
+
+ostream& operator<<(ostream& pOs, GaussLoc& pG)
+{
+ pOs << "Gauss ref:" << endl;
+ pOs << " Name =|" << pG.mName << "|" << endl;
+ pOs << " Geom =" << pG.mGeom << endl;
+ pOs << " #Pt Gauss=" << pG.mNumGauss << endl;
+
+ pOs << " Ref nodes coords.: (#nodes=" << pG.mNumNodes << " dim=" << pG.mDim << ")" << endl;
+ for (int itNode = 0 ; itNode < pG.mNumNodes ; itNode++)
+ {
+ pOs << " Node " << (itNode + 1) << ": ";
+ for (int itDim = 0; itDim < pG.mDim ; itDim++)
+ {
+ pOs << pG.mRefCoo[itNode * pG.mDim + itDim] << " ";
+ }
+ pOs << endl;
+ }
+
+ pOs << " Gauss coords. and weight:" << endl;
+ for (int itGauss = 0 ; itGauss < pG.mNumGauss ; itGauss++)
+ {
+ pOs << " Pt " << (itGauss+1) << ": ";
+ for (int itDim = 0; itDim < pG.mDim ; itDim++)
+ {
+ pOs << pG.mGaussCoo[itGauss * pG.mDim + itDim] << " ";
+ }
+ pOs << "weight=" << pG.mWeight[itGauss];
+ pOs << endl;
+ }
+
+ // debug
+ //med_float res[15];
+ //pG.getCoordGaussPoints(pG.mRefCoo, res);
+ //printArray2D(res, pG.mNumGauss, pG.mDim, "Gauss pt");
+
+ return pOs;
+}
+
+
+} // namespace multipr
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_GaussLoc.hxx
+ *
+ * \brief Class GaussLoc. Allow to locate all the Gauss points in an element of reference (e.g. a TETRA10).
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_GAUSSLOC_HXX
+#define MULTIPR_GAUSSLOC_HXX
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+extern "C"
+{
+ #include "med.h"
+}
+
+#include <iostream>
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class GaussLoc
+//*****************************************************************************
+
+class GaussLoc
+{
+public:
+
+ /**
+ * Builds an empty Gauss reference (default constructor).
+ */
+ GaussLoc();
+
+ /**
+ * Copy constructor (deep copy).
+ * \param pGaussLoc the GaussLoc to copy.
+ */
+ GaussLoc(const GaussLoc& pGaussLoc);
+
+ /**
+ * Destructor. Removes everything.
+ */
+ ~GaussLoc();
+
+ /**
+ * Resets this object in its state by default (empty). Cleans memory.
+ */
+ void reset();
+
+ //---------------------------------------------------------------------
+ // Basic accessors/mutators
+ //--------------------------------------------------------------------
+
+ /**
+ * Returns the name of this GaussLoc.
+ * \return the name of this GaussLoc.
+ */
+ std::string getName() const { return mName; }
+
+ /**
+ * Returns dimension of Gauss points which is also the dimension of reference nodes.
+ * \return dimension of Gauss points.
+ */
+ int getDim() const { return mDim; }
+
+ /**
+ * Returns number of Gauss points.
+ * \return number of Gauss points.
+ */
+ int getNumGaussPoints() const { return mNumGauss; }
+
+ //---------------------------------------------------------------------
+ // Algorithms
+ //--------------------------------------------------------------------
+
+ /**
+ * Returns the coordinates of all the Gauss points for a given element.
+ * \param pCooElt (in) coordinates of nodes of an element.
+ * \param pCoo (out) coordinates of all the Gauss points (interlaced); memory must have been allocated.
+ */
+ void getCoordGaussPoints(const med_float* pCooElt, med_float* pCooGaussPoints) const;
+
+ //---------------------------------------------------------------------
+ // I/O
+ //---------------------------------------------------------------------
+
+ /**
+ * Reads a GaussLoc object from a MED file.
+ * \param pMEDfile any valid MED file opened for reading.
+ * \param pIndex index of the gauss localization to be read; must be >= 1.
+ * \throw IOException if any i/o error occurs.
+ */
+ void readMED(med_idt pMEDfile, med_int pIndex);
+
+ /**
+ * Writes this GaussLoc object to the given MED file.
+ * \param pMEDfile any valid MED file opened for writing.
+ * \throw IOException if any i/o error occurs.
+ */
+ void writeMED(med_idt pMEDfile);
+
+ /**
+ * Dumps any GaussLoc to the given output stream.
+ * \param pOs any output stream.
+ * \param pF any Field.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, GaussLoc& pG);
+
+private:
+
+ char mName[MED_TAILLE_NOM + 1]; /**< Name of the Gauss info. */
+ med_geometrie_element mGeom; /**< Type of elements, e.g. TETRA10 (code is 310). */
+ int mDim; /**< Dimension of nodes, e.g. 3 for a TETRA10. */
+ int mNumNodes; /**< Number of nodes in the reference element, e.g. 10 for a TETRA10. */
+ med_int mNumGauss; /**< Number of Gauss points. */
+ med_float* mRefCoo; /**< Table of coordinates of nodes.
+ Example: for a TETRA10: 10 nodes, 3 components => 30 med_float. */
+ med_float* mGaussCoo; /**< Table of coordinates of Gauss points. */
+ med_float* mWeight; /**< Table of weights of Gauss points. */
+
+private:
+
+ // do not allow copy
+ GaussLoc& operator=(const GaussLoc&);
+
+ // do not allow operator ==
+ bool operator==(const GaussLoc&);
+
+}; // class GaussLoc
+
+
+} // namespace MULTIPR
+
+
+#endif // MULTIPR_GAUSSLOC_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Globals.hxx
+ *
+ * \brief Some useful macros.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+
+#ifndef MULTIPR_GLOBALS_HXX
+#define MULTIPR_GLOBALS_HXX
+
+//*****************************************************************************
+// Some useful macros
+//*****************************************************************************
+
+#define ENABLE_LOG 0
+#define MULTIPR_LOG(STR) if (ENABLE_LOG) cout << STR;
+
+
+#endif // MULTIPR_GLOBALS_HXX
+
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Mesh.cxx
+ *
+ * \brief see MULTIPR_Mesh.hxx
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include "MULTIPR_Mesh.hxx"
+#include "MULTIPR_Nodes.hxx"
+#include "MULTIPR_Elements.hxx"
+#include "MULTIPR_Family.hxx"
+#include "MULTIPR_Profil.hxx"
+#include "MULTIPR_GaussLoc.hxx"
+#include "MULTIPR_Field.hxx"
+#include "MULTIPR_MeshDis.hxx"
+#include "MULTIPR_PointOfField.hxx"
+#include "MULTIPR_DecimationFilter.hxx"
+#include "MULTIPR_Utils.hxx"
+#include "MULTIPR_Exceptions.hxx"
+#include "MULTIPR_Globals.hxx"
+#include "MULTIPR_API.hxx"
+
+using namespace std;
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class Mesh implementation
+//*****************************************************************************
+
+Mesh::Mesh()
+{
+ mNodes = NULL;
+ mElements = NULL;
+
+ reset();
+}
+
+
+Mesh::~Mesh()
+{
+ reset();
+}
+
+
+void Mesh::reset()
+{
+ mMEDfilename[0] = '\0';
+ mMEDfile = 0;
+
+ mMeshName[0] = '\0';
+ mMeshUName[0] = '\0';
+ mMeshDesc[0] = '\0';
+ mMeshDim = -1;
+ mMeshType = MED_NON_STRUCTURE;
+
+ for (int itDim = 0 ; itDim < 3 ; itDim++)
+ {
+ mMeshBBoxMin[itDim] = numeric_limits<med_float>::quiet_NaN();
+ mMeshBBoxMax[itDim] = numeric_limits<med_float>::quiet_NaN();
+ }
+
+ if (mNodes != NULL) { delete mNodes; mNodes = NULL; }
+ if (mElements != NULL) { delete mElements; mElements = NULL; }
+
+ for (unsigned itFam = 0 ; itFam < mFamilies.size() ; itFam++)
+ {
+ delete mFamilies[itFam];
+ }
+ mFamilies.clear();
+ mFamIdToFam.clear();
+
+ for (unsigned itGroup = 0 ; itGroup < mGroups.size() ; itGroup++)
+ {
+ delete mGroups[itGroup];
+ }
+ mGroups.clear();
+ mGroupNameToGroup.clear();
+
+ for (unsigned itGaussLoc = 0 ; itGaussLoc < mGaussLoc.size() ; itGaussLoc++)
+ {
+ delete mGaussLoc[itGaussLoc];
+ }
+ mGaussLoc.clear();
+ mGaussLocNameToGaussLoc.clear();
+
+ for (unsigned itField = 0 ; itField < mFields.size() ; itField++)
+ {
+ delete mFields[itField];
+ }
+ mFields.clear();
+
+ for (unsigned itProfil = 0 ; itProfil < mProfils.size() ; itProfil++)
+ {
+ delete mProfils[itProfil];
+ }
+ mProfils.clear();
+
+ mFlagPrintAll = false;
+}
+
+
+vector<string> Mesh::getNameScalarFields() const
+{
+ vector<string> res;
+
+ for (unsigned itField = 0 ; itField < mFields.size() ; itField++)
+ {
+ Field* currentField = mFields[itField];
+
+ // only get scalar fields, not vectorial fields
+ // (because, currently, decimation can only be performed on scalar fields)
+ if (currentField->getNumberOfComponents() == 1)
+ {
+ res.push_back(currentField->getName());
+ }
+ }
+
+ return res;
+}
+
+
+int Mesh::getTimeStamps(const char* pFieldName) const
+{
+ for (unsigned itField = 0 ; itField < mFields.size() ; itField++)
+ {
+ Field* currentField = mFields[itField];
+ if (strcmp(currentField->getName(), pFieldName) == 0)
+ {
+ return currentField->getNumberOfTimeSteps();
+ }
+ }
+
+ return 0;
+}
+
+
+Field* Mesh::getFieldByName(const char* pFieldName) const
+{
+ if (pFieldName == NULL) throw NullArgumentException("pFieldName should not be NULL", __FILE__, __LINE__);
+
+ Field* retField = NULL;
+
+ // for each field
+ for (unsigned itField = 0 ; itField < mFields.size() ; itField++)
+ {
+ Field* currentField = mFields[itField];
+ if (strcmp(pFieldName, currentField->getName()) == 0)
+ {
+ // field found!
+ retField = currentField;
+ break;
+ }
+ }
+
+ return retField;
+}
+
+
+GaussLoc* Mesh::getGaussLocByName(const char* pGaussLocName) const
+{
+ if (pGaussLocName == NULL) throw NullArgumentException("pGaussLocName should not be NULL", __FILE__, __LINE__);
+
+ map<string, GaussLoc*>::const_iterator itGaussLoc = mGaussLocNameToGaussLoc.find(pGaussLocName);
+ GaussLoc* retGaussLoc = NULL;
+
+ if (itGaussLoc != mGaussLocNameToGaussLoc.end())
+ {
+ retGaussLoc = (*itGaussLoc).second;
+ }
+
+ return retGaussLoc;
+}
+
+
+int Mesh::getNumberOfElements() const
+{
+ if (mElements == NULL) throw IllegalStateException("", __FILE__, __LINE__);
+
+ return mElements->getNumberOfElements();
+}
+
+
+Mesh* Mesh::createFromSetOfElements(const std::set<med_int>& pSetOfElements, const char* pNewMeshName)
+{
+ if (pNewMeshName == NULL) throw NullArgumentException("pNewMeshName", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Create a new mesh
+ //---------------------------------------------------------------------
+ Mesh* mesh = new Mesh();
+
+ //---------------------------------------------------------------------
+ // Build name of the new mesh
+ //---------------------------------------------------------------------
+ strcpy(mesh->mMeshName, pNewMeshName);
+
+ MULTIPR_LOG("Mesh name=|" << mesh->mMeshName << "|" << endl);
+
+ //---------------------------------------------------------------------
+ // Fill general infos
+ //---------------------------------------------------------------------
+ strcpy(mesh->mMeshUName, mMeshUName);
+ strcpy(mesh->mMeshDesc, mMeshDesc);
+
+ mesh->mMeshDim = mMeshDim;
+ mesh->mMeshType = mMeshType;
+
+ MULTIPR_LOG("Mesh u. name=|" << mesh->mMeshUName << "|" << endl);
+ MULTIPR_LOG("Mesh desc=|" << mesh->mMeshDesc << "|" << endl);
+ MULTIPR_LOG("Mesh dim=" << mesh->mMeshDim << endl);
+ MULTIPR_LOG("Mesh Type=" << mesh->mMeshType << endl);
+
+ //---------------------------------------------------------------------
+ // Build nodes and elements
+ //---------------------------------------------------------------------
+ // get all elements involved
+ mesh->mElements = mElements->extractSubSet(pSetOfElements);
+ MULTIPR_LOG((*(mesh->mElements)) << endl);
+
+ // get all nodes involved
+ const set<med_int> setOfNodes = mesh->mElements->getSetOfNodes();
+ mesh->mNodes = mNodes->extractSubSet(setOfNodes);
+ MULTIPR_LOG((*(mesh->mNodes)) << endl);
+
+ //---------------------------------------------------------------------
+ // Remap nodes
+ //---------------------------------------------------------------------
+ mesh->mElements->remap();
+ MULTIPR_LOG((*(mesh->mElements)) << endl);
+
+ //---------------------------------------------------------------------
+ // Build families
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Build fam.:" << endl);
+ // get families of nodes
+ {
+ set<med_int> famOfNodes = mesh->mNodes->getSetOfFamilies();
+ for (set<med_int>::iterator itFam = famOfNodes.begin() ; itFam != famOfNodes.end() ; itFam++)
+ {
+ Family* famSrc = mFamIdToFam[*itFam];
+ cout << (*famSrc) << endl;
+ Family* famDest = famSrc->extractGroup(NULL);
+ mesh->mFamilies.push_back(famDest);
+ }
+ }
+
+ // get families of elements
+ {
+ set<med_int> famOfElt = mesh->mElements->getSetOfFamilies();
+ for (set<med_int>::iterator itFam = famOfElt.begin() ; itFam != famOfElt.end() ; itFam++)
+ {
+ Family* famSrc = mFamIdToFam[*itFam];
+ Family* famDest = famSrc->extractGroup(NULL);
+ mesh->mFamilies.push_back(famDest);
+ }
+ }
+
+ MULTIPR_LOG("Finalize:");
+
+ // fill families with elements and build groups
+ mesh->finalizeFamiliesAndGroups();
+
+ MULTIPR_LOG("OK\n");
+
+ //---------------------------------------------------------------------
+ // Create new fields and collect Gauss
+ //---------------------------------------------------------------------
+ // for each field
+ set<string> newSetOfGauss;
+ for (unsigned itField = 0 ; itField < mFields.size() ; itField++)
+ {
+ Field* currentField = mFields[itField];
+
+ Field* newField;
+ if (currentField->isFieldOnNodes())
+ {
+ newField = currentField->extractSubSet(setOfNodes);
+ }
+ else
+ {
+ newField = currentField->extractSubSet(pSetOfElements);
+ }
+
+ if (!newField->isEmpty())
+ {
+ mesh->mFields.push_back(newField);
+ newField->getSetOfGaussLoc(newSetOfGauss);
+ }
+ }
+ MULTIPR_LOG("Collect fields: ok: #gauss=" << newSetOfGauss.size() << endl);
+
+ //---------------------------------------------------------------------
+ // Build Gauss infos
+ //---------------------------------------------------------------------
+ for (set<string>::iterator itSet = newSetOfGauss.begin() ; itSet != newSetOfGauss.end(); itSet++)
+ {
+ const string& keyName = (*itSet);
+
+ GaussLoc* gaussLoc = getGaussLocByName(keyName.c_str());
+ if (gaussLoc != NULL)
+ {
+ GaussLoc* copyGaussLoc = new GaussLoc(*gaussLoc);
+ mesh->mGaussLoc.push_back(copyGaussLoc);
+ mesh->mGaussLocNameToGaussLoc.insert(make_pair(copyGaussLoc->getName(), copyGaussLoc));
+ }
+ }
+
+ //---------------------------------------------------------------------
+ // Compute bbox
+ //---------------------------------------------------------------------
+ mesh->mNodes->getBBox(mesh->mMeshBBoxMin, mesh->mMeshBBoxMax);
+
+ return mesh;
+}
+
+
+Mesh* Mesh::createFromGroup(const Group* pGroup, const char* pNewMeshName)
+{
+ if (pGroup == NULL) throw NullArgumentException("pGroup should not be NULL", __FILE__, __LINE__);
+ if (pNewMeshName == NULL) throw NullArgumentException("pNewMeshName should not be NULL", __FILE__, __LINE__);
+ if (strlen(pNewMeshName) > MED_TAILLE_NOM) throw IllegalArgumentException("pNewMeshName length too long", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Create a new mesh
+ //---------------------------------------------------------------------
+ Mesh* mesh = new Mesh();
+
+ //---------------------------------------------------------------------
+ // Build name of the new mesh
+ //---------------------------------------------------------------------
+ strcpy(mesh->mMeshName, pNewMeshName);
+
+ MULTIPR_LOG("Mesh name=|" << mesh->mMeshName << "|" << endl);
+
+ //---------------------------------------------------------------------
+ // Fill general infos
+ //---------------------------------------------------------------------
+ strcpy(mesh->mMeshUName, mMeshUName);
+ strcpy(mesh->mMeshDesc, mMeshDesc);
+
+ mesh->mMeshDim = mMeshDim;
+ mesh->mMeshType = mMeshType;
+
+ MULTIPR_LOG("Mesh u. name=|" << mesh->mMeshUName << "|" << endl);
+ MULTIPR_LOG("Mesh desc=|" << mesh->mMeshDesc << "|" << endl);
+ MULTIPR_LOG("Mesh dim=" << mesh->mMeshDim << endl);
+ MULTIPR_LOG("Mesh Type=" << mesh->mMeshType << endl);
+
+ //---------------------------------------------------------------------
+ // Build nodes and elements
+ //---------------------------------------------------------------------
+ // get all elements involved
+ const set<med_int> setOfElt = pGroup->getSetOfElt();
+ mesh->mElements = mElements->extractSubSet(setOfElt);
+ MULTIPR_LOG((*(mesh->mElements)) << endl);
+
+ // get all nodes involved
+ const set<med_int> setOfNodes = mesh->mElements->getSetOfNodes();
+ mesh->mNodes = mNodes->extractSubSet(setOfNodes);
+ MULTIPR_LOG((*(mesh->mNodes)) << endl);
+
+ //---------------------------------------------------------------------
+ // Remap nodes
+ //---------------------------------------------------------------------
+ mesh->mElements->remap();
+ MULTIPR_LOG((*(mesh->mElements)) << endl);
+
+ //---------------------------------------------------------------------
+ // Build families
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Build fam.:" << endl);
+ // get families of nodes
+ {
+ set<med_int> famOfNodes = mesh->mNodes->getSetOfFamilies();
+ for (set<med_int>::iterator itFam = famOfNodes.begin() ; itFam != famOfNodes.end() ; itFam++)
+ {
+ Family* famSrc = mFamIdToFam[*itFam];
+ Family* famDest = famSrc->extractGroup(pGroup->getName().c_str());
+ mesh->mFamilies.push_back(famDest);
+ }
+ }
+
+ // get families of elements
+ {
+ set<med_int> famOfElt = mesh->mElements->getSetOfFamilies();
+ for (set<med_int>::iterator itFam = famOfElt.begin() ; itFam != famOfElt.end() ; itFam++)
+ {
+ Family* famSrc = mFamIdToFam[*itFam];
+ Family* famDest = famSrc->extractGroup(pGroup->getName().c_str());
+ mesh->mFamilies.push_back(famDest);
+ }
+ }
+
+ MULTIPR_LOG("Finalize:");
+
+ // fill families with elements and build groups
+ mesh->finalizeFamiliesAndGroups();
+
+ MULTIPR_LOG("OK\n");
+
+ //---------------------------------------------------------------------
+ // Create new fields and collect Gauss
+ //---------------------------------------------------------------------
+ // for each field
+ set<string> newSetOfGauss;
+ for (unsigned itField = 0 ; itField < mFields.size() ; itField++)
+ {
+ Field* currentField = mFields[itField];
+
+ Field* newField;
+ if (currentField->isFieldOnNodes())
+ {
+ newField = currentField->extractSubSet(setOfNodes);
+ }
+ else
+ {
+ newField = currentField->extractSubSet(setOfElt);
+ }
+
+ if (!newField->isEmpty())
+ {
+ mesh->mFields.push_back(newField);
+ newField->getSetOfGaussLoc(newSetOfGauss);
+ }
+ }
+ MULTIPR_LOG("Collect fields: ok: #gauss=" << newSetOfGauss.size() << endl);
+
+ //---------------------------------------------------------------------
+ // Build Gauss infos
+ //---------------------------------------------------------------------
+ for (set<string>::iterator itSet = newSetOfGauss.begin() ; itSet != newSetOfGauss.end(); itSet++)
+ {
+ const string& keyName = (*itSet);
+
+ GaussLoc* gaussLoc = getGaussLocByName(keyName.c_str());
+ if (gaussLoc != NULL)
+ {
+ GaussLoc* copyGaussLoc = new GaussLoc(*gaussLoc);
+ mesh->mGaussLoc.push_back(copyGaussLoc);
+ mesh->mGaussLocNameToGaussLoc.insert(make_pair(copyGaussLoc->getName(), copyGaussLoc));
+ }
+ }
+
+ //---------------------------------------------------------------------
+ // Compute bbox
+ //---------------------------------------------------------------------
+ mesh->mNodes->getBBox(mesh->mMeshBBoxMin, mesh->mMeshBBoxMax);
+
+ return mesh;
+}
+
+
+Mesh* Mesh::mergePartial(const Mesh* pMesh)
+{
+ if (pMesh == NULL) throw NullArgumentException("pMesh should not be NULL", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Create a new mesh
+ //---------------------------------------------------------------------
+ Mesh* mesh = new Mesh();
+
+ //---------------------------------------------------------------------
+ // Build name of the new mesh
+ //---------------------------------------------------------------------
+ strcpy(mesh->mMeshName, mMeshName);
+
+ //---------------------------------------------------------------------
+ // Merge general infos
+ //---------------------------------------------------------------------
+ strcpy(mesh->mMeshUName, mMeshUName);
+ strcpy(mesh->mMeshDesc, mMeshDesc);
+
+ if (mMeshDim != pMesh->mMeshDim) throw IllegalStateException("the two mesh should have same dimension", __FILE__, __LINE__);
+ if (mMeshType != pMesh->mMeshType) throw IllegalStateException("the two mesh should have same type", __FILE__, __LINE__);
+
+ mesh->mMeshDim = mMeshDim;
+ mesh->mMeshType = mMeshType;
+
+ //---------------------------------------------------------------------
+ // Merge nodes and elements
+ //---------------------------------------------------------------------
+ mesh->mNodes = mNodes->mergePartial(pMesh->mNodes);
+ mesh->mElements = mElements->mergePartial(pMesh->mElements, mNodes->getNumberOfNodes());
+
+ //---------------------------------------------------------------------
+ // Merge families
+ //---------------------------------------------------------------------
+ for (unsigned i = 0 ; i < mFamilies.size() ; i++)
+ {
+ Family* family = new Family(*(mFamilies[i]));
+ mesh->mFamilies.push_back(family);
+ mesh->mFamIdToFam.insert(make_pair(family->getId(), family));
+ }
+
+ for (unsigned i = 0 ; i < pMesh->mFamilies.size() ; i++)
+ {
+ // test if there is a fimaly with the same id
+ map<med_int, Family*>::iterator itFam = mesh->mFamIdToFam.find(pMesh->mFamilies[i]->getId());
+
+ if (itFam == mesh->mFamIdToFam.end())
+ {
+ // id not found: create a new family
+ Family* family = new Family(*(pMesh->mFamilies[i]));
+ mesh->mFamilies.push_back(family);
+ mesh->mFamIdToFam.insert(make_pair(family->getId(), family));
+ }
+ }
+
+ // fill families with elements and build groups
+ //mesh->finalizeFamiliesAndGroups();
+
+ //---------------------------------------------------------------------
+ // Merge fields
+ //---------------------------------------------------------------------
+ // for each field
+ set<string> newSetOfGauss;
+ for (unsigned itField = 0 ; itField < mFields.size() ; itField++)
+ {
+ Field* field = mFields[itField]->merge(pMesh->mFields[itField]);
+ mesh->mFields.push_back(field);
+ field->getSetOfGaussLoc(newSetOfGauss);
+ }
+
+ //---------------------------------------------------------------------
+ // Merge Gauss infos
+ //---------------------------------------------------------------------
+ // WARNING: assume Gauss infos are the same for the two meshes.
+ if (mGaussLoc.size() != pMesh->mGaussLoc.size()) throw IllegalStateException("gauss localization should be the same", __FILE__, __LINE__);
+ for (unsigned i = 0 ; i < mGaussLoc.size() ; i++)
+ {
+ GaussLoc* copyGaussLoc = new GaussLoc(*(mGaussLoc[i]));
+ mesh->mGaussLoc.push_back(copyGaussLoc);
+ mesh->mGaussLocNameToGaussLoc.insert(make_pair(copyGaussLoc->getName(), copyGaussLoc));
+ }
+
+ //---------------------------------------------------------------------
+ // Compute bbox
+ //---------------------------------------------------------------------
+ //mesh->mNodes->getBBox(mesh->mMeshBBoxMin, mesh->mMeshBBoxMax);
+
+ return mesh;
+}
+
+
+Mesh* Mesh::mergePartial(vector<Mesh*> pMeshes, const char* pFieldName, int pFieldIt)
+{
+ if (pMeshes.size() == 0) throw IllegalArgumentException("list must contain one mesh", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Create a new mesh
+ //---------------------------------------------------------------------
+ Mesh* mesh = new Mesh();
+
+ //---------------------------------------------------------------------
+ // Build name of the new mesh
+ //---------------------------------------------------------------------
+ strcpy(mesh->mMeshName, mMeshName);
+
+ //---------------------------------------------------------------------
+ // Merge general infos
+ //---------------------------------------------------------------------
+ strcpy(mesh->mMeshUName, mMeshUName);
+ strcpy(mesh->mMeshDesc, mMeshDesc);
+
+ mesh->mMeshDim = mMeshDim;
+ mesh->mMeshType = mMeshType;
+
+ //---------------------------------------------------------------------
+ // Merge nodes and elements
+ //---------------------------------------------------------------------
+ vector<Nodes*> nodes;
+ vector<Elements*> elements;
+ vector<int> offsets;
+
+ int offset = mNodes->getNumberOfNodes();
+ offsets.push_back(offset);
+
+
+ for (unsigned i = 0 ; i < pMeshes.size() ; i++)
+ {
+ if (mMeshDim != pMeshes[i]->mMeshDim) throw IllegalStateException("meshes should have same dimension", __FILE__, __LINE__);
+ if (mMeshType != pMeshes[i]->mMeshType) throw IllegalStateException("meshes should have same type", __FILE__, __LINE__);
+
+ nodes.push_back(pMeshes[i]->mNodes);
+ //cout << *(pMeshes[i]->mNodes) << endl;
+ elements.push_back(pMeshes[i]->mElements);
+ offset += pMeshes[i]->mNodes->getNumberOfNodes();
+ offsets.push_back(offset);
+ }
+
+ mesh->mNodes = mNodes->mergePartial(nodes);
+ //cout << *(mesh->mNodes) << endl;
+ mesh->mElements = mElements->mergePartial(elements, offsets);
+
+ //---------------------------------------------------------------------
+ // Merge families
+ //---------------------------------------------------------------------
+ for (unsigned i = 0 ; i < mFamilies.size() ; i++)
+ {
+ Family* family = new Family(*(mFamilies[i]));
+ mesh->mFamilies.push_back(family);
+ mesh->mFamIdToFam.insert(make_pair(family->getId(), family));
+ }
+
+ for (unsigned j = 0 ; j < pMeshes.size() ; j++)
+ {
+ for (unsigned i = 0 ; i < pMeshes[j]->mFamilies.size() ; i++)
+ {
+ // test if there is a fimaly with the same id
+ map<med_int, Family*>::iterator itFam = mesh->mFamIdToFam.find(pMeshes[j]->mFamilies[i]->getId());
+
+ if (itFam == mesh->mFamIdToFam.end())
+ {
+ // id not found: create a new family
+ Family* family = new Family(*(pMeshes[j]->mFamilies[i]));
+ mesh->mFamilies.push_back(family);
+ mesh->mFamIdToFam.insert(make_pair(family->getId(), family));
+ }
+ }
+ }
+
+ // fill families with elements and build groups
+ //mesh->finalizeFamiliesAndGroups();
+
+ //---------------------------------------------------------------------
+ // Merge fields
+ //---------------------------------------------------------------------
+ // for each field
+ for (unsigned itField = 0 ; itField < mFields.size() ; itField++)
+ {
+ if (pFieldName == NULL) // merge all field
+ {
+ vector<Field*> fields;
+ for (unsigned i = 0 ; i < pMeshes.size() ; i++)
+ {
+ fields.push_back(pMeshes[i]->mFields[itField]);
+ }
+
+ Field* field = mFields[itField]->merge(fields);
+ mesh->mFields.push_back(field);
+ }
+ else if (strcmp(mFields[itField]->getName(), pFieldName) == 0) // only merge the given field
+ {
+ vector<Field*> fields;
+ for (unsigned i = 0 ; i < pMeshes.size() ; i++)
+ {
+ fields.push_back(pMeshes[i]->mFields[itField]);
+ }
+
+ Field* field = mFields[itField]->merge(fields, pFieldIt);
+ mesh->mFields.push_back(field);
+ }
+ }
+
+ //---------------------------------------------------------------------
+ // Merge Gauss infos
+ //---------------------------------------------------------------------
+ // WARNING: assume Gauss infos are the same for the two meshes.
+ for (unsigned i = 0 ; i < mGaussLoc.size() ; i++)
+ {
+ GaussLoc* copyGaussLoc = new GaussLoc(*(mGaussLoc[i]));
+ mesh->mGaussLoc.push_back(copyGaussLoc);
+ mesh->mGaussLocNameToGaussLoc.insert(make_pair(copyGaussLoc->getName(), copyGaussLoc));
+ }
+
+ //---------------------------------------------------------------------
+ // Compute bbox
+ //---------------------------------------------------------------------
+ //mesh->mNodes->getBBox(mesh->mMeshBBoxMin, mesh->mMeshBBoxMax);
+
+ return mesh;
+}
+
+
+MeshDis* Mesh::splitGroupsOfElements()
+{
+ MeshDis* meshDis = new MeshDis();
+ meshDis->setSequentialMEDFilename(mMEDfilename);
+
+ // get prefix from the original MED filename
+ string strPrefix = removeExtension(mMEDfilename, ".med");
+
+ int numGroup = 1;
+
+ // for each group
+ for (unsigned itGroup = 0 ; itGroup < mGroups.size() ; itGroup++)
+ {
+ Group* currentGroup = mGroups[itGroup];
+
+ // skip this group if it is a group of nodes
+ if (currentGroup->isGroupOfNodes())
+ {
+ continue;
+ }
+
+ char strPartName[256];
+ sprintf(strPartName, "%s_%d", mMeshName, numGroup);
+
+ char strMEDfilename[256];
+ sprintf(strMEDfilename, "%s_grain%d.med", strPrefix.c_str(), numGroup);
+
+ Mesh* mesh = createFromGroup(currentGroup, mMeshName);
+
+ // skip the group which contain all the others groups, even it contains only 1 group
+ if ((mesh->mElements->getNumberOfElements() == mElements->getNumberOfElements()) && (mGroups.size() > 1))
+ {
+ delete mesh;
+ continue;
+ }
+
+ meshDis->addMesh(
+ MeshDisPart::MULTIPR_WRITE_MESH,
+ mMeshName,
+ numGroup,
+ strPartName,
+ "localhost",
+ strMEDfilename,
+ mesh);
+
+ numGroup++;
+ }
+
+ return meshDis;
+}
+
+
+Mesh* Mesh::decimate(
+ const char* pFilterName,
+ const char* pArgv,
+ const char* pNameNewMesh)
+{
+ //---------------------------------------------------------------------
+ // Check parameters
+ //---------------------------------------------------------------------
+ if (pFilterName == NULL) throw NullArgumentException("pFilterName should not be NULL", __FILE__, __LINE__);
+ if (pArgv == NULL) throw NullArgumentException("pArgv should not be NULL", __FILE__, __LINE__);
+ if (pNameNewMesh == NULL) throw NullArgumentException("pNameNewMesh should not be NULL", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Instanciate filter used for decimation
+ //---------------------------------------------------------------------
+ DecimationFilter* filter = DecimationFilter::create(pFilterName);
+
+ //---------------------------------------------------------------------
+ // Create new mesh by decimating current one
+ //---------------------------------------------------------------------
+ Mesh* decimatedMesh = filter->apply(this, pArgv, pNameNewMesh);
+
+ //---------------------------------------------------------------------
+ // Cleans
+ //---------------------------------------------------------------------
+ delete filter;
+
+ return decimatedMesh;
+}
+
+
+
+void Mesh::getAllPointsOfField(Field* pField, int pTimeStepIt, std::vector<PointOfField>& pPoints)
+{
+ //---------------------------------------------------------------------
+ // Check arguments
+ //---------------------------------------------------------------------
+
+ if (pField == NULL) throw NullArgumentException("field should not be NULL", __FILE__, __LINE__);
+ if (pTimeStepIt < 1) throw IllegalArgumentException("invalid field iteration; should be >= 1", __FILE__, __LINE__);
+
+ if (mMeshDim != 3) throw UnsupportedOperationException("not yet implemented", __FILE__, __LINE__);
+ if (pField->getType() != MED_FLOAT64) throw UnsupportedOperationException("not yet implemented", __FILE__, __LINE__);
+ if (pField->getNumberOfComponents() != 1) throw UnsupportedOperationException("field have more than 1 component (vectorial field, expected scalar field)", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Collect points
+ //---------------------------------------------------------------------
+
+ if (pField->isFieldOnNodes())
+ {
+ //-------------------------------------------------------------
+ // Case 1: field of nodes
+ //-------------------------------------------------------------
+ if (mNodes == NULL) throw IllegalStateException("no nodes in the current mesh", __FILE__, __LINE__);
+
+ // for each node
+ for (int itNode = 0, size = mNodes->getNumberOfNodes() ; itNode < size ; itNode++)
+ {
+ // collect coordinates and value of the point
+ const med_float* coo = mNodes->getCoordinates(itNode);
+
+ const med_float* val =
+ reinterpret_cast<const med_float*>(pField->getValue(pTimeStepIt, itNode + 1));
+
+ // add new point
+ pPoints.push_back(PointOfField(coo[0], coo[1], coo[2], val[0]));
+ }
+ }
+ else
+ {
+ //-------------------------------------------------------------
+ // Case 2: field of elements
+ //-------------------------------------------------------------
+
+ if (mElements == NULL) throw IllegalStateException("no elements in the current mesh", __FILE__, __LINE__);
+ if (mElements->getTypeOfPrimitives() != MED_TETRA10) throw UnsupportedOperationException("only support TETRA10 mesh", __FILE__, __LINE__);
+
+ const string& nameGaussLoc = pField->getNameGaussLoc(pTimeStepIt);
+ GaussLoc* gaussLoc = getGaussLocByName(nameGaussLoc.c_str());
+ if (gaussLoc == NULL) throw IllegalStateException("no Gauss localization for these elements", __FILE__, __LINE__);
+
+ int numGauss = pField->getNumberOfGaussPointsByElement(pTimeStepIt);
+
+ int size = gaussLoc->getDim() * gaussLoc->getNumGaussPoints();
+ med_float* cooGaussPts = new med_float[size];
+
+ int dim = mElements->getTypeOfPrimitives() / 100;
+ int numNodes = mElements->getTypeOfPrimitives() % 100;
+ size = dim * numNodes;
+ med_float* cooNodes = new med_float[size];
+
+ // for each elements
+ for (int itElt = 0, size = mElements->getNumberOfElements() ; itElt < size ; itElt++)
+ {
+ // get coordinates of nodes of the current elements
+ // OPTIMIZATION: ASSUME TETRA10: ONLY GETS THE 4 FIRST NODES OF EACH ELEMENT
+ mElements->getCoordinates(itElt, mNodes, cooNodes, 4);
+
+ // compute coordinates of gauss points
+ gaussLoc->getCoordGaussPoints(cooNodes, cooGaussPts);
+
+ //printArray2D(cooGaussPts, 5, 3, "Gauss pt"); // debug
+
+ const med_float* val =
+ reinterpret_cast<const med_float*>(pField->getValue(pTimeStepIt, itElt + 1));
+
+ // for each point of Gauss of the element
+ med_float* srcCoo = cooGaussPts;
+ for (int itPtGauss = 0 ; itPtGauss < numGauss ; itPtGauss++)
+ {
+ pPoints.push_back(PointOfField(srcCoo[0], srcCoo[1], srcCoo[2], val[itPtGauss]));
+ srcCoo += 3;
+ }
+ }
+
+ delete[] cooNodes;
+ delete[] cooGaussPts;
+ }
+}
+
+
+float Mesh::evalDefaultRadius(int pN) const
+{
+ if (mFields.size() == 0) return 1.0f;
+
+ //---------------------------------------------------------------------
+ // Compute default radius
+ //---------------------------------------------------------------------
+
+ med_float volumeBBox =
+ (mMeshBBoxMax[0] - mMeshBBoxMin[0]) *
+ (mMeshBBoxMax[1] - mMeshBBoxMin[1]) *
+ (mMeshBBoxMax[2] - mMeshBBoxMin[2]);
+
+ if (isnan(volumeBBox))
+ {
+ return 1.0f;
+ }
+
+ const med_float k = 0.8; // considered 80% of the volume
+
+ // get nunmber of gauss points in the field
+ try
+ {
+ Field* anyField = mFields[mFields.size()-1];
+ int numTimeSteps = anyField->getNumberOfTimeSteps();
+
+ int numGaussPoints = getNumberOfElements() * anyField->getNumberOfGaussPointsByElement(numTimeSteps-1);
+
+ med_float radius = med_float(pow( (3.0/4.0) * pN * k * volumeBBox / (3.1415 * numGaussPoints), 1.0/3.0));
+
+ return float(radius);
+ }
+ catch (...)
+ {
+ return 1.0f;
+ }
+}
+
+
+med_geometrie_element CELL_TYPES[MED_NBR_GEOMETRIE_MAILLE] =
+{
+ MED_POINT1,
+ MED_SEG2,
+ MED_SEG3,
+ MED_TRIA3,
+ MED_TRIA6,
+ MED_QUAD4,
+ MED_QUAD8,
+ MED_TETRA4,
+ MED_TETRA10,
+ MED_HEXA8,
+ MED_HEXA20,
+ MED_PENTA6,
+ MED_PENTA15
+};
+
+
+char CELL_NAMES[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] =
+{
+ "MED_POINT1",
+ "MED_SEG2",
+ "MED_SEG3",
+ "MED_TRIA3",
+ "MED_TRIA6",
+ "MED_QUAD4",
+ "MED_QUAD8",
+ "MED_TETRA4",
+ "MED_TETRA10",
+ "MED_HEXA8",
+ "MED_HEXA20",
+ "MED_PENTA6",
+ "MED_PENTA15",
+ "MED_PYRA5",
+ "MED_PYRA13"
+};
+
+
+void Mesh::readSequentialMED(const char* pMEDfilename, const char* pMeshName)
+{
+ reset();
+
+ //---------------------------------------------------------------------
+ // Check arguments
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Check arguments: ");
+ if (pMEDfilename == NULL) throw NullArgumentException("pMEDfilename should not be NULL", __FILE__, __LINE__);
+ if (pMeshName == NULL) throw NullArgumentException("pMeshName should not be NULL", __FILE__, __LINE__);
+ MULTIPR_LOG("OK\n");
+
+ strncpy(mMEDfilename, pMEDfilename, 256);
+ strncpy(mMeshName, pMeshName, MED_TAILLE_NOM);
+
+ //---------------------------------------------------------------------
+ // Open MED file (READ_ONLY)
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Open MED file: ");
+ mMEDfile = MEDouvrir(mMEDfilename, MED_LECTURE); // open MED file for reading
+ if (mMEDfile <= 0) throw FileNotFoundException("MED file not found", __FILE__, __LINE__);
+ MULTIPR_LOG("OK\n");
+
+ //---------------------------------------------------------------------
+ // Check valid HDF format
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Format HDF: ");
+ if (MEDformatConforme(mMEDfilename) != 0) throw IOException("invalid file", __FILE__, __LINE__);
+ MULTIPR_LOG("OK\n");
+
+ //---------------------------------------------------------------------
+ // Get MED version
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("MED version: ");
+ med_int verMajor, verMinor, verRelease;
+ med_err ret = MEDversionLire(mMEDfile, &verMajor, &verMinor, &verRelease);
+ if (ret != 0) throw IOException("error while reading MED version", __FILE__, __LINE__);
+ MULTIPR_LOG(verMajor << "." << verMinor << "." << verRelease << ": OK\n");
+
+ //---------------------------------------------------------------------
+ // Check that there is no profil
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("#profils must be 0: ");
+ med_int nbProfils = MEDnProfil(mMEDfile);
+ if (nbProfils != 0) throw UnsupportedOperationException("not yet implemented", __FILE__, __LINE__);
+ MULTIPR_LOG("OK\n");
+
+ //---------------------------------------------------------------------
+ // Read all Gauss localizations
+ //---------------------------------------------------------------------
+ readGaussLoc();
+
+ //---------------------------------------------------------------------
+ // Read scalars (should be 0)
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Scalars: ");
+ med_int nbScalars = MEDnScalaire(mMEDfile);
+ if (nbScalars != 0) throw UnsupportedOperationException("not yet implemented", __FILE__, __LINE__);
+ MULTIPR_LOG(nbScalars << ": OK\n");
+
+ //---------------------------------------------------------------------
+ // Find the mesh
+ //---------------------------------------------------------------------
+ // read number of meshes
+ MULTIPR_LOG("Num meshes: ");
+ med_int nbMeshes = MEDnMaa(mMEDfile);
+ if (nbMeshes <= 0) throw IOException("i/o error while reading number of meshes in MED file", __FILE__, __LINE__);
+ MULTIPR_LOG(nbMeshes << ": OK\n");
+
+ med_int meshIndex = -1;
+ // iteration over mesh to find the mesh we want
+ // for each mesh in the file (warning: first mesh is number 1)
+ for (int itMesh = 1 ; itMesh <= nbMeshes ; itMesh++)
+ {
+ char meshName[MED_TAILLE_NOM + 1];
+
+ ret = MEDmaaInfo(
+ mMEDfile,
+ itMesh,
+ meshName,
+ &mMeshDim,
+ &mMeshType,
+ mMeshDesc);
+
+ if (ret != 0) throw IOException("i/o error while reading mesh information in MED file", __FILE__, __LINE__);
+ MULTIPR_LOG("Mesh: |" << meshName << "|");
+
+ // test if the current mesh is the mesh we want
+ if (strcmp(pMeshName, meshName) == 0)
+ {
+ // *** mesh found ***
+ MULTIPR_LOG(" OK (found)\n");
+ meshIndex = itMesh;
+ break;
+ }
+ else
+ {
+ // not the mesh we want: skip this mesh
+ MULTIPR_LOG(" skipped\n");
+ }
+ }
+
+ if (meshIndex == -1)
+ {
+ throw IllegalStateException("mesh not found in the given MED file", __FILE__, __LINE__);
+ }
+
+ //---------------------------------------------------------------------
+ // Check mesh validity
+ //---------------------------------------------------------------------
+ // dimension of the mesh must be 3 (= 3D mesh)
+ MULTIPR_LOG("Mesh is 3D: ");
+ if (mMeshDim != 3) throw UnsupportedOperationException("dimension of the mesh should be 3; other dimension not yet implemented", __FILE__, __LINE__);
+ MULTIPR_LOG("OK\n");
+
+ // mesh must not be a grid
+ MULTIPR_LOG("Mesh is not a grid: ");
+ if (mMeshType != MED_NON_STRUCTURE)
+ throw UnsupportedOperationException("grid not supported", __FILE__, __LINE__);
+ MULTIPR_LOG("OK\n");
+
+ // mesh must only contain TETRA10 elements
+ MULTIPR_LOG("Only TETRA10: ");
+ med_connectivite connectivite = MED_NOD; // NODAL CONNECTIVITY ONLY
+ bool onlyTETRA10 = true;
+ int numTetra10 = -1;
+ for (int itCell = 0 ; itCell < MED_NBR_GEOMETRIE_MAILLE ; itCell++)
+ {
+ med_int meshNumCells = MEDnEntMaa(
+ mMEDfile,
+ mMeshName,
+ MED_CONN,
+ MED_MAILLE,
+ CELL_TYPES[itCell],
+ connectivite);
+
+ if ((meshNumCells > 0) && (strcmp(CELL_NAMES[itCell], "MED_TETRA10") != 0))
+ {
+ onlyTETRA10 = false;
+ break;
+ }
+ if (strcmp(CELL_NAMES[itCell], "MED_TETRA10") == 0)
+ {
+ numTetra10 = meshNumCells;
+ }
+ }
+
+ if (!onlyTETRA10) throw UnsupportedOperationException("mesh should only contain TETRA10 elements", __FILE__, __LINE__);
+ MULTIPR_LOG(numTetra10 << ": OK\n");
+
+ // everything is OK...
+
+ //---------------------------------------------------------------------
+ // Check num joint = 0
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Num joints: ");
+ med_int numJoints = MEDnJoint(mMEDfile, mMeshName);
+ MULTIPR_LOG(numJoints << ": OK\n");
+
+ //---------------------------------------------------------------------
+ // Check num equivalence = 0
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Num equivalences: ");
+ med_int numEquiv = MEDnEquiv(mMEDfile, mMeshName);
+ MULTIPR_LOG(numEquiv << ": OK\n");
+
+ //---------------------------------------------------------------------
+ // Read nodes
+ //---------------------------------------------------------------------
+ mNodes = new Nodes();
+ mNodes->readMED(mMEDfile, mMeshName, mMeshDim);
+ mNodes->getBBox(mMeshBBoxMin, mMeshBBoxMax);
+
+ //---------------------------------------------------------------------
+ // Read elements
+ //---------------------------------------------------------------------
+ mElements = new Elements();
+ mElements->readMED(mMEDfile, mMeshName, mMeshDim, MED_MAILLE, MED_TETRA10);
+
+ if (mNodes->getNumberOfNodes() != 0)
+ {
+
+ //---------------------------------------------------------------------
+ // Read families
+ //---------------------------------------------------------------------
+ readFamilies();
+ finalizeFamiliesAndGroups();
+
+ //---------------------------------------------------------------------
+ // Read fields
+ //---------------------------------------------------------------------
+ readFields();
+ }
+
+ //---------------------------------------------------------------------
+ // Close the MED file
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Close MED file: ");
+ ret = MEDfermer(mMEDfile);
+ if (ret != 0) throw IOException("i/o error while closing MED file", __FILE__, __LINE__);
+ MULTIPR_LOG("OK\n");
+}
+
+
+void Mesh::writeMED(const char* pMEDfilename)
+{
+ MULTIPR_LOG("Write MED: " << pMEDfilename << endl);
+
+ if (pMEDfilename == NULL) throw NullArgumentException("pMEDfilename should not be NULL", __FILE__, __LINE__);
+ if (strlen(pMEDfilename) == 0) throw IllegalArgumentException("pMEDfilename size is 0", __FILE__, __LINE__);
+
+ remove(pMEDfilename);
+
+ //---------------------------------------------------------------------
+ // Create the new MED file (WRITE_ONLY)
+ //---------------------------------------------------------------------
+ med_idt newMEDfile = MEDouvrir(const_cast<char*>(pMEDfilename), MED_CREATION);
+ if (newMEDfile == -1) throw IOException("", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Write scalars
+ //---------------------------------------------------------------------
+ // no scalars to write
+
+ //---------------------------------------------------------------------
+ // Create mesh: must be created first
+ //---------------------------------------------------------------------
+ med_err ret = MEDmaaCr(
+ newMEDfile,
+ mMeshName,
+ mMeshDim,
+ MED_NON_STRUCTURE,
+ mMeshDesc);
+
+ if (ret != 0) throw IOException("", __FILE__, __LINE__);
+ MULTIPR_LOG(" Create mesh: |" << mMeshName << "|: OK" << endl);
+
+ //---------------------------------------------------------------------
+ // Write nodes and elements (mesh must exist)
+ //---------------------------------------------------------------------
+ if (mNodes == NULL) throw IllegalStateException("mNodes should not be NULL", __FILE__, __LINE__);
+ mNodes->writeMED(newMEDfile, mMeshName);
+ MULTIPR_LOG(" Write nodes: ok" << endl);
+
+ if (mElements == NULL) throw IllegalStateException("mElements should not be NULL", __FILE__, __LINE__);
+ mElements->writeMED(newMEDfile, mMeshName, mMeshDim);
+ MULTIPR_LOG(" write elt: ok" << endl);
+
+ //---------------------------------------------------------------------
+ // Write families (mesh must exist)
+ //---------------------------------------------------------------------
+ for (unsigned itFam = 0 ; itFam < mFamilies.size() ; itFam++)
+ {
+ Family* fam = mFamilies[itFam];
+ fam->writeMED(newMEDfile, mMeshName);
+ }
+ MULTIPR_LOG(" Write families: ok" << endl);
+
+ //---------------------------------------------------------------------
+ // Write profil
+ //---------------------------------------------------------------------
+ // no profil
+
+ //---------------------------------------------------------------------
+ // Write Gauss localization (must be written before fields)
+ //---------------------------------------------------------------------
+ for (unsigned itGaussLoc = 0 ; itGaussLoc < mGaussLoc.size() ; itGaussLoc++)
+ {
+
+ GaussLoc* gaussLoc = mGaussLoc[itGaussLoc];
+ gaussLoc->writeMED(newMEDfile);
+ }
+ MULTIPR_LOG(" Write Gauss: ok" << endl);
+
+ //---------------------------------------------------------------------
+ // Write fields
+ //---------------------------------------------------------------------
+ for (unsigned itField = 0 ; itField < mFields.size() ; itField++)
+ {
+ Field* field = mFields[itField];
+ field->writeMED(newMEDfile, mMeshName);
+ }
+ MULTIPR_LOG(" Write fields: ok" << endl);
+
+ //---------------------------------------------------------------------
+ // Close the new MED file
+ //---------------------------------------------------------------------
+ ret = MEDfermer(newMEDfile);
+ if (ret != 0) throw IOException("", __FILE__, __LINE__);
+}
+
+
+void Mesh::readGaussLoc()
+{
+ MULTIPR_LOG("Gauss ref: ");
+ med_int numGauss = MEDnGauss(mMEDfile);
+ if (numGauss < 0) throw IOException("", __FILE__, __LINE__);
+ MULTIPR_LOG(numGauss << ": OK\n");
+
+ for (int itGauss = 1 ; itGauss <= numGauss ; itGauss++)
+ {
+ GaussLoc* gaussLoc = new GaussLoc();
+ gaussLoc->readMED(mMEDfile, itGauss);
+
+ MULTIPR_LOG((*gaussLoc) << endl);
+
+ mGaussLoc.push_back(gaussLoc);
+ mGaussLocNameToGaussLoc.insert(make_pair(gaussLoc->getName(), gaussLoc));
+ }
+}
+
+
+void Mesh::readFamilies()
+{
+ med_int numFamilies = MEDnFam(mMEDfile, mMeshName);
+ if (numFamilies <= 0) throw IOException("", __FILE__, __LINE__);
+
+ for (int itFam = 1 ; itFam <= numFamilies ; itFam++)
+ {
+ Family* fam = new Family();
+ fam->readMED(mMEDfile, mMeshName, itFam);
+ mFamilies.push_back(fam);
+ }
+}
+
+
+void Mesh::finalizeFamiliesAndGroups()
+{
+ //---------------------------------------------------------------------
+ // Build mapping between family id and pointers towards families
+ //---------------------------------------------------------------------
+ for (unsigned itFam = 0 ; itFam < mFamilies.size() ; itFam++)
+ {
+ Family* fam = mFamilies[itFam];
+ mFamIdToFam.insert(make_pair(fam->getId(), fam));
+ }
+
+ //---------------------------------------------------------------------
+ // Fill families of nodes
+ //---------------------------------------------------------------------
+ for (int itNode = 1 ; itNode <= mNodes->getNumberOfNodes() ; itNode++)
+ {
+ // get family of the ith nodes
+ int famIdent = mNodes->getFamIdent(itNode - 1); // MED nodes start at 1
+ map<med_int, Family*>::iterator itFam = mFamIdToFam.find(famIdent);
+
+ if (itFam == mFamIdToFam.end()) throw IllegalStateException("", __FILE__, __LINE__);
+
+ Family* fam = (*itFam).second;
+
+ // insert the current node to its family
+ fam->insertElt(itNode);
+ fam->setIsFamilyOfNodes(true);
+ }
+
+ //---------------------------------------------------------------------
+ // Fill families of elements
+ //---------------------------------------------------------------------
+ for (int itElt = 1 ; itElt <= mElements->getNumberOfElements() ; itElt++)
+ {
+ // get family of the ith element (MED index start at 1)
+ int famIdent = mElements->getFamilyIdentifier(itElt - 1);
+ map<med_int, Family*>::iterator itFam = mFamIdToFam.find(famIdent);
+
+ if (itFam == mFamIdToFam.end()) throw IllegalStateException("", __FILE__, __LINE__);
+
+ Family* fam = (*itFam).second;
+
+ // insert the current node its family
+ fam->insertElt(itElt);
+ fam->setIsFamilyOfNodes(false);
+ }
+
+ //---------------------------------------------------------------------
+ // Build groups
+ //---------------------------------------------------------------------
+ // for each family
+ for (unsigned itFam = 0 ; itFam < mFamilies.size() ; itFam++)
+ {
+ mFamilies[itFam]->buildGroups(mGroups, mGroupNameToGroup);
+ }
+}
+
+
+void Mesh::readFields()
+{
+ //---------------------------------------------------------------------
+ // Read number of fields
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Read fields: ");
+ med_int numFields = MEDnChamp(mMEDfile, 0);
+ if (numFields <= 0) throw IOException("", __FILE__, __LINE__);
+ MULTIPR_LOG(numFields << ": OK\n");
+
+ //---------------------------------------------------------------------
+ // Iterate over fields
+ //---------------------------------------------------------------------
+ // for each field, read number of components and others infos
+ for (int itField = 1 ; itField <= numFields ; itField++)
+ {
+ Field* field = new Field();
+ field->readMED(mMEDfile, itField, mMeshName);
+
+ // if the nth field does not apply on our mesh => slip it
+ if (field->isEmpty())
+ {
+ delete field;
+ }
+ else
+ {
+ mFields.push_back(field);
+ }
+ }
+}
+
+
+ostream& operator<<(ostream& pOs, Mesh& pM)
+{
+ pOs << "Mesh: " << endl;
+ pOs << " MED file =|" << pM.mMEDfilename << "|" << endl;
+ pOs << " Name =|" << pM.mMeshName << "|" << endl;
+ pOs << " Unv name =|" << pM.mMeshUName << "|" << endl;
+ pOs << " Desc =|" << pM.mMeshDesc << "|" << endl;
+ pOs << " Dim =" << pM.mMeshDim << endl;
+ pOs << " Type =" << ((pM.mMeshType == MED_STRUCTURE)?"STRUCTURE":"NON_STRUCTURE") << endl;
+ pOs << " BBox =[" << pM.mMeshBBoxMin[0] << " ; " << pM.mMeshBBoxMax[0] << "] x [" << pM.mMeshBBoxMin[1] << " ; " << pM.mMeshBBoxMax[1] << "] x [" << pM.mMeshBBoxMin[2] << " ; " << pM.mMeshBBoxMax[2] << "]" << endl;
+
+ if (pM.mFlagPrintAll)
+ {
+ cout << (*(pM.mNodes)) << endl;
+ cout << (*(pM.mElements)) << endl;
+
+ pOs << " Families : #=" << pM.mFamilies.size() << endl;
+ for (unsigned i = 0 ; i < pM.mFamilies.size() ; i++)
+ {
+ cout << (*(pM.mFamilies[i])) << endl;
+ }
+
+ pOs << " Groups : #=" << pM.mGroups.size() << endl;
+ for (unsigned i = 0 ; i < pM.mGroups.size() ; i++)
+ {
+ cout << (*(pM.mGroups[i])) << endl;
+ }
+
+ pOs << " Gauss loc: #=" << pM.mGaussLoc.size() << endl;
+ for (unsigned i = 0 ; i < pM.mGaussLoc.size() ; i++)
+ {
+ cout << (*(pM.mGaussLoc[i])) << endl;
+ }
+
+ pOs << " Fields : #=" << pM.mFields.size() << endl;
+ for (unsigned i = 0 ; i < pM.mFields.size() ; i++)
+ {
+ cout << (*(pM.mFields[i])) << endl;
+ }
+ }
+ else
+ {
+ if (pM.mNodes != NULL)
+ {
+ pOs << " Nodes : #=" << pM.mNodes->getNumberOfNodes() << endl;
+ }
+
+ if (pM.mElements != NULL)
+ {
+ const set<med_int>& setOfNodes = pM.mElements->getSetOfNodes();
+ if (setOfNodes.size() == 0)
+ {
+ pOs << " Elt : #=" << pM.mElements->getNumberOfElements() << endl;
+ }
+ else
+ {
+ set<med_int>::iterator itNode = setOfNodes.end();
+ itNode--;
+ pOs << " Elt : #=" << pM.mElements->getNumberOfElements() << " node_id_min=" << (*(setOfNodes.begin())) << " node_id_max=" << (*itNode) << endl;
+ }
+ }
+
+ pOs << " Families : #=" << pM.mFamilies.size() << endl;
+ pOs << " Groups : #=" << pM.mGroups.size() << endl;
+ pOs << " Gauss loc: #=" << pM.mGaussLoc.size() << endl;
+ pOs << " Fields : #=" << pM.mFields.size() << endl;
+ }
+
+ return pOs;
+}
+
+
+} // namespace multipr
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Mesh.hxx
+ *
+ * \brief Class Mesh used by the MULTIPR API; used to wrap MED file meshes.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_MESH_HXX
+#define MULTIPR_MESH_HXX
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+extern "C"
+{
+ #include "med.h"
+}
+
+#include <iostream>
+#include <fstream>
+#include <set>
+#include <map>
+#include <vector>
+#include <string>
+
+
+namespace multipr
+{
+
+//*****************************************************************************
+// Pre-declaration
+//*****************************************************************************
+
+class GaussLoc;
+class Profil;
+class Nodes;
+class Elements;
+class Family;
+class Field;
+class Group;
+class MeshDis;
+class PointOfField;
+
+
+//*****************************************************************************
+// Class Mesh
+//*****************************************************************************
+
+/**
+ * Assumes:
+ * - 3D mesh in a 3D space
+ * - Unstructured mesh (not a grid)
+ * - Nodal connectivity
+ * - Cartesian coordinates system
+ * Always use FULL_INTERLACE arrays
+ */
+class Mesh
+{
+public:
+
+ /**
+ * Builds an empty Mesh (default constructor).
+ */
+ Mesh();
+
+ /**
+ * Destructor. Removes everything.
+ */
+ ~Mesh();
+
+ /**
+ * Resets this object in its state by default (empty). Cleans memory.
+ */
+ void reset();
+
+ //---------------------------------------------------------------------
+ // Basic accessors/mutators
+ //---------------------------------------------------------------------
+
+ /**
+ * Returns the name of this Mesh.
+ * \return the name of this Mesh.
+ */
+ const char* getName() const { return mMeshName; }
+
+ /**
+ * Returns the name of all the scalar fields.
+ * \return the name of all the scalar fields.
+ */
+ std::vector<std::string> getNameScalarFields() const;
+
+ /**
+ * Returns the number of iteration for a given field.
+ * \return the number of iteration for a given field.
+ */
+ int getTimeStamps(const char* pFieldName) const;
+
+ /**
+ * Returns a Field from its name; NULL if it does not exist.
+ * \param pFieldName name of the field to be retrieved.
+ * \return the Field pFieldName of it exists, NULL otherwise.
+ * \throw NullArgumentException if pFieldName is NULL.
+ */
+ Field* getFieldByName(const char* pFieldName) const;
+
+ /**
+ * Returns a GaussLoc from its name; NULL if it does not exist.
+ * \param pGaussLocName name of the GaussLoc to be retrieved.
+ * \return the GaussLoc pGaussLocName if it exists, NULL otherwise.
+ * \throw NullArgumentException if pGaussLocName is NULL.
+ */
+ GaussLoc* getGaussLocByName(const char* pGaussLocName) const;
+
+ /**
+ * Returns the number of elements.
+ * \return the number of elements.
+ */
+ int getNumberOfElements() const;
+
+ //---------------------------------------------------------------------
+ // Algorithms
+ //---------------------------------------------------------------------
+
+ /**
+ * Creates a Mesh from a subset of its elements (cells).
+ * \param pSetOfElements subset of elements to keep.
+ * \param pNewMeshName name of the new Mesh.
+ * \return a new Mesh which is a restriction of this Mesh to the given set of elements.
+ * \throw NullArgumentException if pNewMeshName is NULL.
+ */
+ Mesh* createFromSetOfElements(const std::set<med_int>& pSetOfElements, const char* pNewMeshName);
+
+ /**
+ * Creates a Mesh from one of its group.
+ * \param pGroup any group of this Mesh.
+ * \param pNewMeshName name of the new Mesh.
+ * \return a new Mesh which is a restriction of this Mesh to pGroup.
+ * \throw NullArgumentException if pGroup or pNewMeshName is NULL.
+ */
+ Mesh* createFromGroup(const Group* pGroup, const char* pNewMeshName);
+
+ /**
+ * Creates a Mesh by merging this one with the given one.
+ * Warning: not all the data are merged (e.g. bounding box if not computed and family/groups are partially filled).
+ * This method is intended to be used to build mesh for visualization (VISU integration).
+ * Merge is partial to improve speed.
+ * \param pMesh any Mesh
+ * \return a new Mesh which is a the union of this and pMesh.
+ * \throw NullArgumentException if pGroup or pNewMeshName is NULL.
+ */
+ Mesh* mergePartial(const Mesh* pMesh);
+ Mesh* mergePartial(std::vector<Mesh*> pMeshes, const char* pFieldName, int pFieldIt);
+
+ /**
+ * Creates a distributed mesh (MeshDis) by creating a new mesh for each group of elements in this Mesh.
+ * \return a distributed mesh from groups of this Mesh.
+ */
+ MeshDis* splitGroupsOfElements();
+
+ /**
+ * Creates a new mesh by decimating this one.
+ * \param pFilterName name of the filter to be used for decimation (e.g. Filtre_GradientMoyen); should not be NULL.
+ * \param pArgv all the arguments for filtering as a single string.
+ * \param pNameNewMesh name of the new mesh.
+ * \return the decimated mesh.
+ * \throw NullArgumentException if one of the arguments is NULL.
+ * \throw RuntimeException if any error occurs while decimating data.
+ */
+ Mesh* decimate(
+ const char* pFilterName,
+ const char* pArgv,
+ const char* pNameNewMesh);
+
+ /**
+ * Gets all the points in a field. Each point has coordinates and a value.
+ * \param pField any field of this Mesh.
+ * \param pTimeStepIt time step iteration.
+ * \param pPoints (out) list of points.
+ * \throw NullArgumentException if pField is NULL.
+ * \throw IllegalArgumentException if pTimeStepIt is invalid.
+ */
+ void getAllPointsOfField(Field* pField, int pTimeStepIt, std::vector<PointOfField>& pPoints);
+
+ /**
+ * Returns a default value for neighborhood radius.
+ * Return value is such that, for any point in the field, average number of neighbours is pN.
+ * \param pN average number of neighbours.
+ * \return a default value for neighborhood radius; 1.0 if some error occurs.
+ */
+ float evalDefaultRadius(int pN) const;
+
+ //---------------------------------------------------------------------
+ // I/O
+ //---------------------------------------------------------------------
+
+ /**
+ * Reads a Mesh from a sequential MED file. Resets the object before.
+ * \param pMEDfilename
+ * \param pMeshName
+ * \throw IOException if any i/o error occurs.
+ */
+ void readSequentialMED(const char* pMEDfilename, const char* pMeshName);
+
+ /**
+ * Writes this Mesh and all related things into a MED file.
+ * \param pMEDfilename
+ * \throw IOException if any i/o error occurs.
+ */
+ void writeMED(const char* pMEDfilename);
+
+ /**
+ * Sets the flag which control the stream operator <<.
+ * \param pFlag new flag value.
+ */
+ void setPrintAll(bool pFlag) { mFlagPrintAll = pFlag; }
+
+ /**
+ * Dumps any Mesh to the given output stream.
+ * \param pOs any output stream.
+ * \param pM any Mesh.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, Mesh& pM);
+
+private:
+
+ /**
+ * Reads all Gauss localizations in the current MED file.
+ * \throw IOException if an i/o error occurs.
+ */
+ void readGaussLoc();
+
+ /**
+ * Reads families in the currentMED file and build groups.
+ * \throw IOException if an i/o error occurs.
+ */
+ void readFamilies();
+
+ /**
+ * Finalizes the constructions of families and groups.
+ * Fill structures with elements.
+ */
+ void finalizeFamiliesAndGroups();
+
+ /**
+ * Reads fields related to this mesh in the current MED file.
+ * \throw IOException if an i/o error occurs.
+ */
+ void readFields();
+
+private:
+
+ /**
+ * Name of the associated MED file.
+ */
+ char mMEDfilename[256];
+
+ /**
+ * MED file handle.
+ */
+ med_idt mMEDfile;
+
+ /**
+ * Name of this mesh.
+ */
+ char mMeshName[MED_TAILLE_NOM + 1];
+
+ /**
+ * Universal name of this mesh.
+ */
+ char mMeshUName[MED_TAILLE_DESC + 1];
+
+ /**
+ * Description.
+ */
+ char mMeshDesc[MED_TAILLE_DESC + 1];
+
+ /**
+ * Dimension.
+ */
+ med_int mMeshDim;
+
+ /**
+ * Type of mesh (MED_NON_STRUCTURE or MED_STRUCTURE (=grid))
+ */
+ med_maillage mMeshType;
+
+ /**
+ * Axis aligned bounding box of this mesh.
+ */
+ med_float mMeshBBoxMin[3];
+ med_float mMeshBBoxMax[3];
+
+ /**
+ * All the nodes used by this mesh.
+ */
+ Nodes* mNodes;
+
+ /**
+ * All the TETRA10 elements used by this mesh.
+ */
+ Elements* mElements;
+
+ /**
+ * Table of families used by this mesh.
+ */
+ std::vector<Family*> mFamilies;
+
+ /**
+ * Map to retrieve a Family from its id.
+ */
+ std::map<med_int, Family*> mFamIdToFam;
+
+ /**
+ * Table of groups used by this mesh.
+ */
+ std::vector<Group*> mGroups;
+
+ /**
+ * Map to retrieve a Group from its name.
+ */
+ std::map<std::string, Group*> mGroupNameToGroup;
+
+ /**
+ * Table of GaussLoc.
+ */
+ std::vector<GaussLoc*> mGaussLoc;
+
+ /**
+ * Map to retrieve a Gauss info from its name.
+ */
+ std::map<std::string, GaussLoc*> mGaussLocNameToGaussLoc;
+
+ /**
+ * Table of fields related to this mesh.
+ * Number of fiels = mFields.size().
+ */
+ std::vector<Field*> mFields;
+
+ /**
+ * Table of profils.
+ */
+ std::vector<Profil*> mProfils;
+
+ /**
+ * Flag to control the behaviour of the stream operator <<.
+ */
+ bool mFlagPrintAll;
+
+private:
+
+ // do not allow copy constructor
+ Mesh(const Mesh&);
+
+ // do not allow copy
+ Mesh& operator=(const Mesh&);
+
+ // do not allow operator ==
+ bool operator==(const Mesh&);
+
+}; // class Mesh
+
+
+} // namespace MULTIPR
+
+
+#endif // MULTIPR_MESH_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_MeshDis.cxx
+ *
+ * \brief see MULTIPR_MeshDis.hxx
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include "MULTIPR_MeshDis.hxx"
+#include "MULTIPR_Mesh.hxx"
+#include "MULTIPR_DecimationFilter.hxx"
+#include "MULTIPR_Utils.hxx"
+#include "MULTIPR_Globals.hxx"
+#include "MULTIPR_API.hxx"
+#include "MULTIPR_Exceptions.hxx"
+#include "MULTIPR_ProgressCallback.hxx"
+
+#include "MEDSPLITTER_API.hxx"
+
+#include <iostream>
+#include <fstream>
+
+using namespace std;
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Global variables (exported)
+//*****************************************************************************
+
+// callback used to report progress about a long task (e.g. save to disk)
+MULTIPR_ProgressCallback* gProgressCallback = NULL;
+
+// callback used to report empty meshes
+MULTIPR_EmptyMeshCallback* gEmptyMeshCallback = NULL;
+
+
+//*****************************************************************************
+// Class MeshDisEntry implementation
+//*****************************************************************************
+
+MeshDisPart::MeshDisPart()
+{
+ mMesh = NULL;
+ mCollection = NULL;
+ mOldCollection = NULL;
+
+ reset();
+}
+
+
+MeshDisPart::~MeshDisPart()
+{
+ reset();
+}
+
+
+void MeshDisPart::reset()
+{
+ mToDoOnNextWrite = MULTIPR_UNDEFINED;
+
+ mMeshName[0] = '\0';
+ mId = 0;
+ mPartName[0] = '\0';
+ mPath[0] = '\0';
+ mMEDFileName[0] = '\0';
+
+ if (mMesh != NULL)
+ {
+ delete mMesh;
+ mMesh = NULL;
+ }
+
+ mSplit = 0;
+
+ if (mCollection != NULL)
+ {
+ delete mCollection;
+ mCollection = NULL;
+ }
+
+ if (mOldCollection != NULL)
+ {
+ delete mOldCollection;
+ mOldCollection = NULL;
+ }
+}
+
+
+const char* MeshDisPart::getMEDFileNameSuffix() const
+{
+ // Examples:
+ // "agregat100grains_12pas_grain97.med" -> "grain97"
+ // "agregat100grains_12pas_grain100_part2.med" -> "grain100_part2"
+ // "aagregat100grains_12pas_grain98_gradmoy-low-25.0-0.3.med" -> "grain98_gradmoy-low-25-0.3"
+
+ string prefix = removeExtension(mMEDFileName, ".med");
+ prefix.erase(0, prefix.rfind("grain"));
+ return prefix.c_str();
+}
+
+
+void MeshDisPart::create(
+ OnNextWrite pToDoOnNextWrite,
+ const char* pMeshName,
+ int pId,
+ const char* pPartName,
+ const char* pPath,
+ const char* pMEDFileName,
+ Mesh* pMesh)
+{
+ if (pToDoOnNextWrite == MULTIPR_UNDEFINED) throw IllegalArgumentException("", __FILE__, __LINE__);
+ if (pMeshName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if (pId < 1) throw IllegalArgumentException("", __FILE__, __LINE__);
+ if (pPartName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if (pPath == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if (pMEDFileName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+
+ reset();
+
+ mToDoOnNextWrite = pToDoOnNextWrite;
+ strcpy(mMeshName, pMeshName);
+ mId = pId;
+ strcpy(mPartName, pPartName);
+ strcpy(mPath, pPath);
+ strcpy(mMEDFileName, pMEDFileName);
+ mMesh = pMesh;
+
+}
+
+
+void MeshDisPart::readMED()
+{
+ if (mMesh != NULL) throw IllegalStateException("", __FILE__, __LINE__);
+ if (mCollection != NULL) throw IllegalStateException("", __FILE__, __LINE__);
+ if (mOldCollection != NULL) throw IllegalStateException("", __FILE__, __LINE__);
+
+ mMesh = new Mesh();
+ mMesh->readSequentialMED(mMEDFileName, mMeshName);
+}
+
+
+ostream& operator<<(ostream& pOs, MeshDisPart& pM)
+{
+ switch (pM.mToDoOnNextWrite)
+ {
+ case MeshDisPart::MULTIPR_UNDEFINED:
+ pOs << "undefined";
+ break;
+
+ case MeshDisPart::MULTIPR_KEEP_AS_IT:
+ pOs << pM.mMeshName << " " << pM.mId << " " << pM.mPartName << " " << pM.mPath << " " << pM.mMEDFileName;
+ break;
+
+ case MeshDisPart::MULTIPR_WRITE_MESH:
+ pOs << pM.mMeshName << " " << pM.mId << " " << pM.mPartName << " " << pM.mPath << " " << pM.mMEDFileName;
+ break;
+
+ case MeshDisPart::MULTIPR_WRITE_PARTS:
+ pOs << pM.mMeshName << " " << pM.mId << " " << pM.mPartName << " " << pM.mPath << " " << pM.mMEDFileName << " SPLIT " << pM.mSplit;
+ break;
+
+ default: throw IllegalStateException("", __FILE__, __LINE__);
+ }
+
+ return pOs;
+}
+
+
+//*****************************************************************************
+// Class MeshDis implementation
+//*****************************************************************************
+
+MeshDis::MeshDis()
+{
+ reset();
+}
+
+
+MeshDis::~MeshDis()
+{
+ reset();
+}
+
+
+void MeshDis::reset()
+{
+ mSequentialMEDFilename[0] = '\0';
+ mDistributedMEDFilename[0] = '\0';
+
+ for (unsigned itPart = 0 ; itPart != mParts.size() ; itPart++)
+ {
+ MeshDisPart* part = mParts[itPart];
+ delete part;
+ }
+ mParts.clear();
+
+ //mProgressCallback = NULL;
+}
+
+
+void MeshDis::setSequentialMEDFilename(const char* pFilename)
+{
+ strcpy(mSequentialMEDFilename, pFilename);
+}
+
+
+void MeshDis::addMesh(
+ MeshDisPart::OnNextWrite pToDoOnNextWrite,
+ const char* pMeshName,
+ int pId,
+ const char* pPartName,
+ const char* pPath,
+ const char* pMEDFileName,
+ Mesh* pMesh)
+{
+ MeshDisPart* part = new MeshDisPart();
+
+ part->create(
+ pToDoOnNextWrite,
+ pMeshName,
+ pId,
+ pPartName,
+ pPath,
+ pMEDFileName,
+ pMesh);
+
+ mParts.push_back(part);
+}
+
+
+void MeshDis::insertMesh(
+ MeshDisPart::OnNextWrite pToDoOnNextWrite,
+ const char* pMeshName,
+ int pId,
+ const char* pPartName,
+ const char* pPath,
+ const char* pMEDFileName,
+ Mesh* pMesh,
+ int pPosition)
+{
+ MeshDisPart* part = new MeshDisPart();
+
+ part->create(
+ pToDoOnNextWrite,
+ pMeshName,
+ pId,
+ pPartName,
+ pPath,
+ pMEDFileName,
+ pMesh);
+
+ mParts.insert(mParts.begin() + pPosition, part);
+
+ // rename id of following parts
+ for (unsigned i = pPosition + 1 ; i < mParts.size() ; i++)
+ {
+ mParts[i]->mId++;
+ }
+}
+
+
+void MeshDis::removeParts(const char* pPrefixPartName)
+{
+ if (pPrefixPartName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+
+ char strPrefix[256];
+ sprintf(strPrefix, "%s_", pPrefixPartName);
+
+ for (vector<MeshDisPart*>::iterator itPart = mParts.begin() ; itPart != mParts.end() ; itPart++)
+ {
+ MeshDisPart* currentPart = (*itPart);
+
+ // remove part which have the same name and all sub_parts
+ // e.g. if pPrefixPartName="PART_4" => remove "PART_4" and "PART_4_*", but not "PART41"
+ if ((strcmp(currentPart->getPartName(), pPrefixPartName) == 0) ||
+ startsWith(currentPart->getPartName(), strPrefix))
+ {
+ mParts.erase(itPart);
+
+ // decrement id of following parts
+ for (vector<MeshDisPart*>::iterator itPart2 = itPart ; itPart2 != mParts.end() ; itPart2++)
+ {
+ (*itPart2)->mId--;
+ }
+
+ itPart--;
+ if (currentPart->mMEDFileName != NULL)
+ {
+ remove(currentPart->mMEDFileName);
+ }
+
+ delete currentPart;
+ }
+ }
+}
+
+
+MeshDisPart* MeshDis::findPart(const char* pPartName)
+{
+ if (pPartName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+
+ MeshDisPart* part = NULL;
+
+ for (unsigned itPart = 0 ; itPart < mParts.size() ; itPart++)
+ {
+ MeshDisPart* currentPart = mParts[itPart];
+
+ if (strcmp(currentPart->getPartName(), pPartName) == 0)
+ {
+ part = currentPart;
+ break;
+ }
+ }
+
+ return part;
+
+}
+
+
+vector<string> MeshDis::getMeshes() const
+{
+ vector<string> res;
+
+ if (mParts.size() > 0)
+ {
+ MeshDisPart* part = mParts[0];
+ const char* meshName = part->getMeshName();
+ res.push_back(meshName);
+ }
+
+ return res;
+}
+
+
+vector<string> MeshDis::getFields() const
+{
+ vector<string> res;
+
+ if (mParts.size() == 0)
+ {
+ return res;
+ }
+
+ // all the parts of the distributed MED file should have the same fields
+ // => just return the name of fields of the first part
+ switch (mParts[0]->mToDoOnNextWrite)
+ {
+ case MeshDisPart::MULTIPR_KEEP_AS_IT:
+ case MeshDisPart::MULTIPR_WRITE_PARTS:
+ {
+ vector<pair<string, int> > tmp = multipr::getListScalarFields(mParts[0]->getMEDFileName());
+
+ for (unsigned i = 0 ; i < tmp.size() ; i++)
+ {
+ res.push_back(tmp[i].first);
+ }
+ return res;
+ }
+
+ case MeshDisPart::MULTIPR_WRITE_MESH:
+ return mParts[0]->mMesh->getNameScalarFields();
+
+ default:
+ throw IllegalStateException("", __FILE__, __LINE__);
+ }
+}
+
+
+int MeshDis::getTimeStamps(const char* pFieldName) const
+{
+ if (mParts.size() == 0)
+ {
+ // no parts in this distributed MED file => no fields => #iteration = 0
+ return 0;
+ }
+
+ // all the parts of the distributed MED file should have the same fields
+ // => just return the number of iteration found in the field of the first part
+ switch (mParts[0]->mToDoOnNextWrite)
+ {
+ case MeshDisPart::MULTIPR_KEEP_AS_IT:
+ case MeshDisPart::MULTIPR_WRITE_PARTS:
+ {
+ vector<pair<string, int> > tmp = multipr::getListScalarFields(mParts[0]->getMEDFileName());
+
+ for (unsigned i = 0 ; i < tmp.size() ; i++)
+ {
+ if (strcmp(tmp[i].first.c_str(), pFieldName) == 0)
+ {
+ return tmp[i].second;
+ }
+ }
+
+ // pFieldName not found in the list of fields
+ return 0;
+ }
+
+ case MeshDisPart::MULTIPR_WRITE_MESH:
+ return mParts[0]->mMesh->getTimeStamps(pFieldName);
+
+ default:
+ throw IllegalStateException("", __FILE__, __LINE__);
+ }
+}
+
+
+string MeshDis::getPartInfo(const char* pPartName)
+{
+ MeshDisPart* part = findPart(pPartName);
+
+ if (part != NULL)
+ {
+ char num[16];
+ sprintf(num, "%d", part->mId);
+
+ string res =
+ string(part->mMeshName) +
+ string(" ") +
+ string(num) +
+ string(" ") +
+ string(part->mPartName) +
+ string(" ") +
+ string(part->mPath) +
+ string(" ") +
+ string(part->mMEDFileName);
+
+ return res;
+ }
+ else
+ {
+ // part not found => return empty string
+ return "";
+ }
+}
+
+
+void MeshDis::splitPart(const char* pPartName, int pNbParts, int pPartitionner)
+{
+ //cout << "MULTIPR: MeshDis::splitPart()" << endl;
+ if (pPartName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if (pNbParts < 2) throw IllegalArgumentException("", __FILE__, __LINE__);
+ if ((pPartitionner != MULTIPR_METIS) && (pPartitionner != MULTIPR_SCOTCH)) throw IllegalArgumentException("should be 0=METIS or 1=SCOTCH", __FILE__, __LINE__);
+
+ //cout << "MULTIPR: file=" << __FILE__ << " line=" << __LINE__ << " args OK" << endl;
+
+ //---------------------------------------------------------------------
+ // Find the MED file corresponding to the given part
+ //---------------------------------------------------------------------
+ MeshDisPart* part = findPart(pPartName);
+
+ if (part == NULL)
+ {
+ throw IllegalArgumentException("part not found in this distributed MED file", __FILE__, __LINE__);
+ }
+
+ //cout << "MULTIPR: file=" << __FILE__ << " line=" << __LINE__ << " find part OK" << endl;
+
+ //---------------------------------------------------------------------
+ // Load the sequential MED file
+ //---------------------------------------------------------------------
+ MEDSPLITTER::MESHCollection* collection;
+ collection = new MEDSPLITTER::MESHCollection(part->getMEDFileName(), part->getMeshName());
+
+ //cout << "MULTIPR: file=" << __FILE__ << " line=" << __LINE__ << " MEDSPLITTER collection OK" << endl;
+ //---------------------------------------------------------------------
+ // Partition the group
+ //---------------------------------------------------------------------
+ MEDSPLITTER::Topology* topology;
+ if (pPartitionner == MULTIPR_METIS)
+ {
+ try
+ {
+ topology = collection->createPartition(pNbParts, MEDSPLITTER::Graph::METIS);
+ }
+ catch (...)
+ {
+ throw RuntimeException("MEDSPLITTER error: createPartition(), using METIS", __FILE__, __LINE__);
+ }
+ }
+ else if (pPartitionner == MULTIPR_SCOTCH)
+ {
+ try
+ {
+ //cout << "MULTIPR: file=" << __FILE__ << " line=" << __LINE__ << " try to create partition using SCOTCH: #parts=" << pNbParts << endl;
+ topology = collection->createPartition(pNbParts, MEDSPLITTER::Graph::SCOTCH);
+ //cout << "MULTIPR: file=" << __FILE__ << " line=" << __LINE__ << " assigned SCOTCH" << endl;
+ }
+ catch (...)
+ {
+ throw RuntimeException("MEDSPLITTER error: createPartition(), using SCOTCH", __FILE__, __LINE__);
+ }
+ }
+ else
+ {
+ throw IllegalStateException("unknown partitionner", __FILE__, __LINE__);
+ }
+
+ try
+ {
+ MEDSPLITTER::MESHCollection* newCollection = new MEDSPLITTER::MESHCollection(*collection, topology);
+
+ part->mToDoOnNextWrite = MeshDisPart::MULTIPR_WRITE_PARTS;
+ part->mSplit = pNbParts;
+ part->mOldCollection = collection;
+ part->mCollection = newCollection;
+ }
+ catch (...)
+ {
+ //cout << "MEDSPLITTER error: new MESHCollection()" << endl;
+ throw RuntimeException("MEDSPLITTER error: new MESHCollection()", __FILE__, __LINE__);
+ }
+}
+
+
+void MeshDis::decimatePart(
+ const char* pPartName,
+ const char* pFieldName,
+ med_int pFieldIt,
+ const char* pFilterName,
+ med_float pTMed,
+ med_float pTLow,
+ med_float pRadius,
+ int pBoxing)
+{
+ //---------------------------------------------------------------------
+ // Check arguments
+ //---------------------------------------------------------------------
+ if (pPartName == NULL) throw NullArgumentException("partname should not be NULL", __FILE__, __LINE__);
+ if (pFieldName == NULL) throw NullArgumentException("fieldname should not be NULL", __FILE__, __LINE__);
+ if (pFieldIt < med_int(1)) throw IllegalArgumentException("invalid field iteration; should be >= 1", __FILE__, __LINE__);
+ if (pTMed < 0.0) throw IllegalArgumentException("med res.: threshold must be > 0", __FILE__, __LINE__);
+ if (pTMed >= pTLow) throw IllegalArgumentException("threshold for med res. must be < threshold for low res.", __FILE__, __LINE__);
+ if (pRadius <= med_float(0.0)) throw IllegalArgumentException("radius should be > 0", __FILE__, __LINE__);
+ if ((pBoxing < 1) || (pBoxing > 200)) throw IllegalArgumentException("boxing should be in [1..200]", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Find the MED file corresponding to the given part
+ //---------------------------------------------------------------------
+ MeshDisPart* part = findPart(pPartName);
+ if (part == NULL)
+ {
+ throw IllegalArgumentException("part not found in the given distributed MED file", __FILE__, __LINE__);
+ }
+
+ //---------------------------------------------------------------------
+ // Load the associated sequential MED file
+ //---------------------------------------------------------------------
+ if (part->mMesh == NULL)
+ {
+ part->readMED();
+ }
+
+ Mesh* meshFull = part->mMesh;
+ cout << (*meshFull) << endl;
+
+ const char* originalFilename = part->getMEDFileName();
+ string strPrefix = removeExtension(originalFilename, ".med");
+
+ // debug
+ //cout << (*this) << endl;
+
+ //---------------------------------------------------------------------
+ // Decimates the given mesh
+ //---------------------------------------------------------------------
+ // arguments for decimation are passed as a string for genericity
+ char argv[256];
+ char newPartName[MED_TAILLE_NOM + 1];
+ char newMEDFileName[256];
+
+ // *** create a new mesh = MEDIUM resolution ***
+ sprintf(argv, "%s %d %lf %lf %d", pFieldName, pFieldIt, pTMed, pRadius, pBoxing);
+ sprintf(newPartName, "%s_MED", pPartName);
+ sprintf(newMEDFileName, "%s_gradmoy-med-%s-%s.med",
+ strPrefix.c_str(),
+ realToString(pTMed).c_str(),
+ realToString(pRadius).c_str());
+
+ {
+ Mesh* meshMedium = meshFull->decimate(pFilterName, argv, part->getMeshName());
+ cout << (*meshMedium) << endl;
+
+ insertMesh(
+ MeshDisPart::MULTIPR_WRITE_MESH,
+ part->getMeshName(),
+ part->mId + 1,
+ newPartName,
+ "localhost",
+ newMEDFileName,
+ meshMedium,
+ part->mId + 0);
+
+ if ((meshMedium->getNumberOfElements() == 0) && (gEmptyMeshCallback != NULL))
+ {
+ gEmptyMeshCallback->reportEmptyMesh(newPartName);
+ }
+ }
+
+ // *** create a new mesh = LOW resolution ***
+ sprintf(argv, "%s %d %lf %lf %d", pFieldName, pFieldIt, pTLow, pRadius, pBoxing);
+ sprintf(newPartName, "%s_LOW", pPartName);
+ sprintf(newMEDFileName, "%s_gradmoy-low-%s-%s.med",
+ strPrefix.c_str(),
+ realToString(pTLow).c_str(),
+ realToString(pRadius).c_str());
+
+ {
+ Mesh* meshLow = meshFull->decimate(pFilterName, argv, part->getMeshName());
+ cout << (*meshLow) << endl;
+
+ insertMesh(
+ MeshDisPart::MULTIPR_WRITE_MESH,
+ part->getMeshName(),
+ part->mId + 2,
+ newPartName,
+ "localhost",
+ newMEDFileName,
+ meshLow,
+ part->mId + 1);
+
+ if ((meshLow->getNumberOfElements() == 0) && (gEmptyMeshCallback != NULL))
+ {
+ gEmptyMeshCallback->reportEmptyMesh(newPartName);
+ }
+ }
+
+ // debug
+ //cout << (*this) << endl;
+}
+
+
+string MeshDis::evalDecimationParams(
+ const char* pPartName,
+ const char* pFieldName,
+ int pFieldIt,
+ const char* pFilterName,
+ const char* pFilterParams)
+{
+ MeshDisPart* part = findPart(pPartName);
+ if (part == NULL)
+ {
+ return "";
+ }
+
+ try
+ {
+ if (part->mMesh == NULL)
+ {
+ part->readMED();
+ }
+
+ multipr::DecimationFilter* filter = multipr::DecimationFilter::create(pFilterName);
+ if (filter == NULL)
+ {
+ return "";
+ }
+
+ multipr::DecimationFilterGradAvg* filterGrad = dynamic_cast<multipr::DecimationFilterGradAvg*>(filter);
+
+ if (filterGrad != NULL)
+ {
+ int mode;
+
+ int ret = sscanf(pFilterParams, "%d", &mode);
+
+ // mode 2 = GET RADIUS
+ if ((ret == 1) && (mode == 2))
+ {
+ double radius = part->mMesh->evalDefaultRadius(8);
+ char res[256];
+ sprintf(res, "%f", radius);
+ return res;
+ }
+
+ float radius;
+ int boxing;
+
+ ret = sscanf(pFilterParams, "%d %f %d", &mode, &radius, &boxing);
+
+ // mode 1 = GET GRADIENT MIN, MAX and AVG
+ if ((ret == 3) && (mode == 1))
+ {
+ double gradMin = 0.1, gradAvg = 0.15, gradMax = 0.2;
+
+ filterGrad->getGradientInfo(
+ part->mMesh,
+ pFieldName,
+ pFieldIt,
+ radius,
+ boxing,
+ &gradMin,
+ &gradAvg,
+ &gradMax);
+
+ char res[2048];
+ sprintf(res, "%f %f %f", gradMin, gradAvg, gradMax);
+ return res;
+ }
+ }
+
+ delete filter;
+ }
+ catch(...)
+ {
+ }
+
+ return "";
+}
+
+
+int MeshDis::computeNumParts()
+{
+ int numParts = 0;
+
+ for (unsigned itPart = 0 ; itPart < mParts.size() ; itPart++)
+ {
+ switch (mParts[itPart]->mToDoOnNextWrite)
+ {
+ case MeshDisPart::MULTIPR_KEEP_AS_IT:
+ case MeshDisPart::MULTIPR_WRITE_MESH:
+ numParts++;
+ break;
+
+ case MeshDisPart::MULTIPR_WRITE_PARTS:
+ numParts += mParts[itPart]->mSplit;
+ break;
+
+ default: throw IllegalStateException("", __FILE__, __LINE__);
+ }
+ }
+
+ return numParts;
+}
+
+
+void MeshDis::readDistributedMED(const char* pMEDfilename)
+{
+ if (pMEDfilename == NULL) throw NullArgumentException("filename should not be NULL", __FILE__, __LINE__);
+
+ const int MAX_SIZEOF_LINE = 1024;
+
+ reset();
+ strcpy(mDistributedMEDFilename, pMEDfilename);
+
+ //---------------------------------------------------------------------
+ // Open master file (ASCII file)
+ //---------------------------------------------------------------------
+ ifstream fileMaster(mDistributedMEDFilename);
+ if (fileMaster.fail()) throw IOException("i/o error while opening MED master file", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Read header
+ //---------------------------------------------------------------------
+ char charbuffer[MAX_SIZEOF_LINE];
+ fileMaster.getline(charbuffer, MAX_SIZEOF_LINE);
+ if (fileMaster.fail()) throw IOException("i/o error while reading MED master file", __FILE__, __LINE__);
+
+ // check format
+ if ((charbuffer[0] != '#') ||
+ (charbuffer[1] != ' ') ||
+ (charbuffer[2] != 'M') ||
+ (charbuffer[3] != 'E') ||
+ (charbuffer[4] != 'D'))
+ throw IOException("not a valid distributed MED file", __FILE__, __LINE__);
+
+ while ((charbuffer[0] == '#') || (strlen(charbuffer) == 0))
+ {
+ char* strTag = NULL;
+ if ((charbuffer[0] == '#') && ((strTag = strstr(charbuffer, "[SOURCE]=")) != NULL))
+ {
+ char strSequentialMEDFilename[256];
+ int ret = sscanf(strTag, "[SOURCE]=%s", strSequentialMEDFilename);
+ if (ret == 1)
+ {
+ setSequentialMEDFilename(strSequentialMEDFilename);
+ }
+ }
+ fileMaster.getline(charbuffer, MAX_SIZEOF_LINE);
+ if (fileMaster.fail()) throw IOException("i/o error while reading MED master file", __FILE__, __LINE__);
+ }
+
+ // read number of parts
+ int nbParts = atoi(charbuffer);
+
+ //---------------------------------------------------------------------
+ // Read infos about sub-parts
+ //---------------------------------------------------------------------
+ char lMeshName[MED_TAILLE_NOM + 1];
+ int lId;
+ char lPartName[MED_TAILLE_NOM + 1];
+ char lPath[256];
+ char lMEDFileName[256];
+
+ for (int i = 0 ; i < nbParts ; i++)
+ {
+ fileMaster.getline(charbuffer, MAX_SIZEOF_LINE);
+ if (fileMaster.fail()) throw IOException("i/o error while reading MED master file", __FILE__, __LINE__);
+
+ while ((charbuffer[0] == '#') || (strlen(charbuffer) == 0))
+ {
+ fileMaster.getline(charbuffer, MAX_SIZEOF_LINE);
+ if (fileMaster.fail()) throw IOException("i/o error while reading MED master file", __FILE__, __LINE__);
+ }
+
+ lMeshName[0] = '\0';
+ lId = 0;
+ lPartName[0] = '\0';
+ lPath[0] = '\0';
+ lMEDFileName[0] = '\0';
+
+ int ret = sscanf(charbuffer, "%s %d %s %s %s",
+ lMeshName,
+ &lId,
+ lPartName,
+ lPath,
+ lMEDFileName);
+
+ if (ret != 5) throw IOException("i/o error while reading MED master file; bad format", __FILE__, __LINE__);
+
+ //cout << "DBG: read: " << lMeshName << " " << lId << " " << lPartName << endl;
+ addMesh(
+ MeshDisPart::MULTIPR_KEEP_AS_IT,
+ lMeshName,
+ lId,
+ lPartName,
+ lPath,
+ lMEDFileName,
+ NULL);
+ }
+
+ //---------------------------------------------------------------------
+ // Close master file
+ //---------------------------------------------------------------------
+ fileMaster.close();
+ if (fileMaster.fail()) throw IOException("i/o error while closing MED master file", __FILE__, __LINE__);
+}
+
+
+/**
+ * Retrieves the output of MEDSPLITTER and convert it for MULTIPR.
+ */
+int convertMedsplitterToMultipr(ofstream& pFileMaster, const char* pTmpFilename, int pId, MeshDisPart* pPart, string pDestPath)
+{
+ MULTIPR_LOG("convert" << endl);
+
+ const int MAX_SIZEOF_LINE = 1024;
+ char charbuffer[MAX_SIZEOF_LINE];
+
+ // Open medsplitter master file (ASCII file)
+ ifstream fileMasterMedsplitter(pTmpFilename);
+ if (fileMasterMedsplitter.fail()) throw IOException("i/o error while opening MEDSPLITTER master file", __FILE__, __LINE__);
+
+ fileMasterMedsplitter.getline(charbuffer, MAX_SIZEOF_LINE);
+ if (fileMasterMedsplitter.fail()) throw IOException("i/o error while reading MEDSPLITTER master file", __FILE__, __LINE__);
+
+ while ((charbuffer[0] == '#') || (strlen(charbuffer) == 0))
+ {
+ fileMasterMedsplitter.getline(charbuffer, MAX_SIZEOF_LINE);
+ if (fileMasterMedsplitter.fail()) throw IOException("i/o error while reading MEDSPLITTER master file", __FILE__, __LINE__);
+ }
+
+ // read number of parts
+ int nbParts = atoi(charbuffer);
+ //cout << "nb parts=" << nbParts << endl;
+
+ char lMeshName[MED_TAILLE_NOM + 1];
+ int lId;
+ char lPartName[MED_TAILLE_NOM + 1];
+ char lPath[256];
+ char lMEDFileName[256];
+
+ for (int i = 0 ; i < nbParts ; i++)
+ {
+ fileMasterMedsplitter.getline(charbuffer, MAX_SIZEOF_LINE);
+ if (fileMasterMedsplitter.fail()) throw IOException("", __FILE__, __LINE__);
+
+ // parses the current line
+ lMeshName[0] = '\0';
+ lId = 0;
+ lPartName[0] = '\0';
+ lPath[0] = '\0';
+ lMEDFileName[0] = '\0';
+
+ int ret = sscanf(charbuffer, "%s %d %s %s %s",
+ lMeshName,
+ &lId,
+ lPartName,
+ lPath,
+ lMEDFileName);
+
+ if (ret != 5) throw IOException("i/o error while reading MEDSPLITTER master file; bad format", __FILE__, __LINE__);
+
+ string strDestFilename = pDestPath + multipr::getFilenameWithoutPath(lMEDFileName);
+ if (strcmp(lMEDFileName, strDestFilename.c_str()) != 0)
+ {
+ multipr::copyFile(lMEDFileName, pDestPath.c_str());
+ strcpy(lMEDFileName, strDestFilename.c_str());
+ }
+
+ pFileMaster << lMeshName << " " << (pId + i) << " " << pPart->getPartName() << "_" << (i + 1) << " " << lPath << " " << lMEDFileName << endl;
+ }
+
+ fileMasterMedsplitter.close();
+ if (fileMasterMedsplitter.fail()) throw IOException("i/o error while closing MEDSPLITTER master file", __FILE__, __LINE__);
+
+ // remove master file generated by MEDSPLITTER
+ remove(pTmpFilename);
+
+ return nbParts;
+}
+
+
+void MeshDis::writeDistributedMED(const char* pMEDfilenamePrefix)
+{
+ if (pMEDfilenamePrefix == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Build master filename
+ //---------------------------------------------------------------------
+ string strPrefix = string(pMEDfilenamePrefix);
+ const char* strExtension = ".med";
+ string strMasterFilename;
+
+ // add suffix "_grains_maitre" iff it is not yet in the filename
+ if (strstr(pMEDfilenamePrefix, "_grains_maitre") == 0)
+ {
+ strMasterFilename= strPrefix + "_grains_maitre" + strExtension;
+ }
+ else
+ {
+ strMasterFilename = strPrefix + strExtension;
+ }
+
+ string strDestPath = multipr::getPath(strMasterFilename.c_str());
+
+ MULTIPR_LOG("Create master: " << strMasterFilename << endl);
+ strcpy(mDistributedMEDFilename, strMasterFilename.c_str());
+
+ //---------------------------------------------------------------------
+ // Create an ASCII master file for the resulting distributed mesh and write header
+ //---------------------------------------------------------------------
+ remove(strMasterFilename.c_str());
+ ofstream fileMaster(strMasterFilename.c_str());
+
+ if (fileMaster == 0) throw IOException("i/o error while creating MED master file", __FILE__, __LINE__);
+
+ fileMaster << "# MED file v2.3 - Master file created by MULTIPR v" << getVersion() << endl;
+ fileMaster << "#" << " " << endl;
+ fileMaster << "# [SOURCE]=" << mSequentialMEDFilename << endl;
+ fileMaster << "#" << " " << endl;
+
+ fileMaster << computeNumParts() << endl;
+ if (fileMaster.fail()) throw IOException("i/o error while writing MED master file", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Create a new MED file (v2.3)
+ //---------------------------------------------------------------------
+ int id = 1;
+
+ if (gProgressCallback != NULL) gProgressCallback->start("Save mesh", mParts.size());
+
+ try
+ {
+
+ // for each sub-meshes
+ for (unsigned itPart = 0 ; itPart < mParts.size() ; itPart++)
+ {
+ switch (mParts[itPart]->mToDoOnNextWrite)
+ {
+ case MeshDisPart::MULTIPR_KEEP_AS_IT:
+ {
+ mParts[itPart]->mId = id;
+ id++;
+
+ // copy file in another directory?
+ string strSrcPath = multipr::getPath(mParts[itPart]->getMEDFileName());
+ if (strSrcPath != strDestPath)
+ {
+ cout << "Write: KEEP_AS_IT: copy file" << endl;
+ string strDestFilename = strDestPath + multipr::getFilenameWithoutPath(mParts[itPart]->getMEDFileName());
+ multipr::copyFile(mParts[itPart]->getMEDFileName(), strDestPath.c_str());
+ strcpy(mParts[itPart]->mMEDFileName, strDestFilename.c_str());
+ }
+
+ fileMaster << (*mParts[itPart]) << endl;
+ cout << (*mParts[itPart]) << endl;
+ break;
+ }
+
+ case MeshDisPart::MULTIPR_WRITE_MESH:
+ {
+ if (strlen(mParts[itPart]->getMEDFileName()) == 0) throw IOException("MED filename is empty", __FILE__, __LINE__);
+ if (mParts[itPart]->mMesh == NULL) throw IllegalStateException("invalid mesh (shoult not be NULL)", __FILE__, __LINE__);
+
+ string strDestFilename = strDestPath + multipr::getFilenameWithoutPath(mParts[itPart]->getMEDFileName());
+ strcpy(mParts[itPart]->mMEDFileName, strDestFilename.c_str());
+
+ mParts[itPart]->mMesh->writeMED(mParts[itPart]->getMEDFileName());
+ mParts[itPart]->mId = id;
+ id++;
+ fileMaster << (*mParts[itPart]) << endl;
+ cout << (*mParts[itPart]) << endl;
+ break;
+ }
+
+ case MeshDisPart::MULTIPR_WRITE_PARTS:
+ {
+ // split this part using medsplitter
+ if (mParts[itPart]->mOldCollection == NULL) throw IllegalStateException("", __FILE__, __LINE__);
+ string strPrefix = removeExtension(mParts[itPart]->getMEDFileName(), ".med");
+ char tmpFilename[256];
+ sprintf(tmpFilename, "%s_part", strPrefix.c_str());
+ mParts[itPart]->mCollection->write(tmpFilename);
+ mParts[itPart]->mCollection->castAllFields(*(mParts[itPart]->mOldCollection));
+ int ret = convertMedsplitterToMultipr(fileMaster, tmpFilename, id, mParts[itPart], strDestPath);
+ id += ret;
+ remove(mParts[itPart]->getMEDFileName());
+ break;
+ }
+
+ default: throw IllegalStateException("should not be there", __FILE__, __LINE__);
+ }
+
+ if (gProgressCallback != NULL) gProgressCallback->moveOn();
+ }
+
+ }
+ catch (RuntimeException& e)
+ {
+ if (gProgressCallback != NULL) gProgressCallback->done();
+ throw e;
+ }
+
+ if (gProgressCallback != NULL) gProgressCallback->done();
+
+ //---------------------------------------------------------------------
+ // Close master file
+ //---------------------------------------------------------------------
+ fileMaster.close();
+ if (fileMaster.fail()) throw IOException("i/o error while closing MED master file", __FILE__, __LINE__);
+}
+
+
+ostream& operator<<(ostream& pOs, MeshDis& pM)
+{
+ pOs << "Mesh Dis.:" << endl;
+ pOs << " Sequential filename (source) =|" << pM.mSequentialMEDFilename << "|" << endl;
+ pOs << " Distributed filename (master)=|" << pM.mDistributedMEDFilename << "|" << endl;
+ pOs << " #Sub-meshes =" << pM.mParts.size() << endl;
+
+ for (unsigned itPart = 0 ; itPart < pM.mParts.size() ; itPart++)
+ {
+ cout << " " << (itPart + 1) << ": " << (*(pM.mParts[itPart])) << endl;
+ }
+
+ return pOs;
+}
+
+
+} // namespace multipr
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_MeshDis.hxx
+ *
+ * \brief Class MeshDis: distributed mesh.
+ * = MASTER file (ASCII) -> list of sequential MED file.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_MESHDIS_HXX
+#define MULTIPR_MESHDIS_HXX
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+extern "C"
+{
+ #include "med.h"
+}
+
+#include <iostream>
+#include <vector>
+
+// include MEDSPLITTER used to split mesh using METIS or SCOTCH
+#include "MEDMEM_define.hxx"
+#include "MEDMEM_Mesh.hxx"
+#include "MEDMEM_Family.hxx"
+#include "MEDSPLITTER_Graph.hxx"
+#include "MEDSPLITTER_MESHCollection.hxx"
+#include "MEDSPLITTER_Topology.hxx"
+
+
+namespace multipr
+{
+
+//*****************************************************************************
+// Pre-declaration
+//*****************************************************************************
+
+class Mesh;
+
+
+//*****************************************************************************
+// Class MeshDisPart = a sub-part of a distributed mesh.
+//
+// It can be :
+// - a sequential MED file representing a Group (scenario 1)
+// - a sequential MED file representing a part of a Group (scenario 2 -> MEDSPLITTER)
+// - a lower resolution of a part (decimation)
+//*****************************************************************************
+
+class MeshDisPart
+{
+
+public:
+
+ /**
+ * Action to be done for this part on next writing on disk.
+ */
+ enum OnNextWrite
+ {
+ MULTIPR_UNDEFINED,
+ MULTIPR_KEEP_AS_IT,
+ MULTIPR_WRITE_MESH,
+ MULTIPR_WRITE_PARTS
+ };
+
+public:
+
+ /**
+ * Builds an empty part of a distributed mesh (default constructor).
+ */
+ MeshDisPart();
+
+ /**
+ * Destructor. Removes everything.
+ */
+ ~MeshDisPart();
+
+ /**
+ * Resets this object in its state by default (empty). Cleans memory.
+ */
+ void reset();
+
+ /**
+ * Creates a MeshDisPart.
+ * \param pToDoOnNextWrite
+ * \param pMeshName
+ * \param pId
+ * \param pPartName
+ * \param pPath
+ * \param pMEDFileName file name excluding the path.
+ * \param pMesh can be NULL.
+ */
+ void create(
+ OnNextWrite pToDoOnNextWrite,
+ const char* pMeshName,
+ int pId,
+ const char* pPartName,
+ const char* pPath,
+ const char* pMEDFileName,
+ Mesh* pMesh);
+
+ //---------------------------------------------------------------------
+ // Basic accessors/mutators
+ //---------------------------------------------------------------------
+
+ /**
+ * Returns the name of this part.
+ * \return the name of this part.
+ */
+ const char* getPartName() const { return mPartName; }
+
+ /**
+ * Returns the name of the mesh of this part.
+ * \return the name of the mesh of this part.
+ */
+ const char* getMeshName() const { return mMeshName; }
+
+ /**
+ * Returns the MED filename which contain this part.
+ * \return the MED filename which contain this part.
+ */
+ const char* getMEDFileName() const { return mMEDFileName; }
+
+ /**
+ * Returns the suffix of the related MED filename (without .med extension).
+ * For examples:
+ * 1. "agregat100grains_12pas_grain97.med" -> "grain97"
+ * 2. "agregat100grains_12pas_grain100_part2.med" -> "grain100_part2"
+ * 3. "aagregat100grains_12pas_grain98_gradmoy-low-25.0-0.3.med" -> "grain98_gradmoy-low-25-0.3"
+ */
+ const char* getMEDFileNameSuffix() const;
+
+ /**
+ * Returns the action to be performed on this part on next write.
+ * \return the action to be performed on this part on next write.
+ */
+ OnNextWrite getOnNextWrite() const { return mToDoOnNextWrite; }
+
+ //---------------------------------------------------------------------
+ // I/O
+ //---------------------------------------------------------------------
+
+ /**
+ * Reads the sequentiel MED file corresponding to this part.
+ * \throw IOException if an i/o error occurs.
+ */
+ void readMED();
+
+ /**
+ * Dumps any MeshDisPart to the given output stream.
+ * \param pOs any output stream.
+ * \param pM any MeshDisPart.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, MeshDisPart& pM);
+
+private:
+
+ // MeshDisPart can be used:
+ // 1 (KEEP_AS_IT) : To store data read from one line of an ASCII master file (distributed MED file)
+ // 2 (WRITE_MESH) : As a temporary structure to store all infos about a mesh corresponding to a group (before writing on disk).
+ // 3 (WRITE_PARTS) : As a temporary structure to store all infos about splitting using MEDSPLITTER.
+
+ OnNextWrite mToDoOnNextWrite; /**< See enum OnNextWrite. */
+
+ //---------------------------------------------------------------------
+ // Case 1, 2, and 3
+ //---------------------------------------------------------------------
+ char mMeshName[MED_TAILLE_NOM + 1]; /**< Name of the mesh. */
+ int mId; /**< Id of this part in [1..n]. */
+ char mPartName[MED_TAILLE_NOM + 1]; /**< Name of this part. */
+ char mPath[256]; /**< Path of the MED file. */
+ char mMEDFileName[256]; /**< Name of the MED file which contain this part. */
+
+ //---------------------------------------------------------------------
+ // Case 2: mesh of the related sequential MED file (can be NULL if not loaded)
+ //---------------------------------------------------------------------
+ Mesh* mMesh; /**< Mesh associated with this part; can be NULL. */
+
+ //---------------------------------------------------------------------
+ // Case 3 only: temporary result of MEDSPLITTER
+ //---------------------------------------------------------------------
+ int mSplit; /**< For MEDSPLITTER: number of parts. Temporary. */
+ MEDSPLITTER::MESHCollection* mCollection; /**< New data after splitting. */
+ MEDSPLITTER::MESHCollection* mOldCollection; /**< Data before splitting (we need them when we want to write new data on disk. */
+
+private:
+
+ // do not allow copy constructor
+ MeshDisPart(const MeshDisPart&);
+
+ // do not allow copy
+ MeshDisPart& operator=(const MeshDisPart&);
+
+ // do not allow operator ==
+ bool operator==(const MeshDisPart&);
+
+ //---------------------------------------------------------------------
+ // Friends
+ //---------------------------------------------------------------------
+ friend class MeshDis;
+
+}; // class MeshDisPart
+
+
+//*****************************************************************************
+// Class MeshDis
+//*****************************************************************************
+
+class MeshDis
+{
+public:
+
+ /**
+ * Builds an empty mesh (default constructor).
+ */
+ MeshDis();
+
+ /**
+ * Destructor. Removes everything.
+ */
+ ~MeshDis();
+
+ /**
+ * Resets this object in its state by default (empty). Clean memory.
+ */
+ void reset();
+
+ //---------------------------------------------------------------------
+ // Basic accessors/mutators
+ //---------------------------------------------------------------------
+
+ /**
+ * Sets the name of the associated sequential MED file (=original MED file).
+ * \param pFilename name of the associated sequential MED file.
+ */
+ void setSequentialMEDFilename(const char* pFilename);
+
+ /**
+ * Returns the name of this sequential MED file (=original MED file).
+ * \return the name of this sequential MED file (=original MED file).
+ */
+ const char* getSequentialMEDFilename() const { return mSequentialMEDFilename; }
+
+ /**
+ * Returns the name of this distributed MED file (=name of the master file).
+ * \return the name of this distributed MED file (=name of the master file).
+ */
+ const char* getDistributedMEDFilename() const { return mDistributedMEDFilename; }
+
+ /**
+ * Adds a new part to this distributed mesh.
+ * Used by the split process (extract groups).
+ * \param pToDoOnNextWrite
+ * \param pMeshName
+ * \param pId
+ * \param pPartName
+ * \param pPath
+ * \param pMEDFileName
+ * \param pMesh can be NULL.
+ */
+ void addMesh(
+ MeshDisPart::OnNextWrite pToDoOnNextWrite,
+ const char* pMeshName,
+ int pId,
+ const char* pPartName,
+ const char* pPath,
+ const char* pMEDFileName,
+ Mesh* pMesh);
+
+ /**
+ * Inserts a new part to this distributed mesh.
+ * Used by the decimation process.
+ * \param pToDoOnNextWrite
+ * \param pMeshName
+ * \param pId
+ * \param pPartName
+ * \param pPath
+ * \param pMEDFileName
+ * \param pMesh can be NULL.
+ * \param pPosition insert after this position. Start at 1.
+ */
+ void insertMesh(
+ MeshDisPart::OnNextWrite pToDoOnNextWrite,
+ const char* pMeshName,
+ int pId,
+ const char* pPartName,
+ const char* pPath,
+ const char* pMEDFileName,
+ Mesh* pMesh,
+ int pPosition);
+
+ /**
+ * Removes all the part beginning by pPrefixPartName from this distributed mesh.
+ * Example: if pPrefixPartName="PART_4" => remove "PART_4" and all sub-parts "PART_4_*", but not "PART41".
+ * \param pPrefixPartName name of the part.
+ */
+ void removeParts(const char* pPrefixPartName);
+
+ /**
+ * Returns the current number of parts in this distributed mesh.
+ * \return the current number of parts in this distributed mesh.
+ */
+ int getNumParts() const { return mParts.size(); }
+
+ /**
+ * Returns the nth part of this distributed mesh.
+ * \param pIndex index of the part (in 0..getNumParts()-1).
+ * \return the nth part of this distributed mesh.
+ */
+ MeshDisPart* getPart(int pIndex) const { return mParts[pIndex]; }
+
+ /**
+ * Returns the list of meshes contained in this distributed MED file.
+ * \return the list of meshes contained in this distributed MED file.
+ */
+ std::vector<std::string> getMeshes() const;
+
+ /**
+ * Returns the list of fields contained in this distributed MED file.
+ * \return the list of fields contained in this distributed MED file.
+ */
+ std::vector<std::string> getFields() const;
+
+ /**
+ * Returns the number of iteration for a given field.
+ * \param pFieldName field name.
+ * \return the number of iteration for a given field.
+ */
+ int getTimeStamps(const char* pFieldName) const;
+
+ /**
+ * Returns all information about a part.
+ * \param pPartName name of the part.
+ * \return all information about a part.
+ */
+ std::string getPartInfo(const char* pPartName);
+
+ //---------------------------------------------------------------------
+ // Algorithms
+ //---------------------------------------------------------------------
+
+ /**
+ * Finds a part of this distributed mesh by its name.
+ * Returns NULL if the part does not exist.
+ * \param pPartName part to be found; must not be NULL.
+ * \return a pointer towards the part if it exists, NULL otherwise.
+ * \throw NullArgumentException if pPartName is NULL.
+ */
+ MeshDisPart* findPart(const char* pPartName);
+
+ /**
+ * Updates this distributed mesh by splitting one of its part.
+ * This splitting method leans on medsplitter, by V. Bergeaud (CEA).
+ * \param pPartName name of the part to be splitted.
+ * \param pNbParts number of sub-parts.
+ * \param pPartitionner MULTIPR_METIS or MULTIPR_SCOTCH.
+ * \throw RuntimeException if any error occurs.
+ */
+ void splitPart(const char* pPartName, int pNbParts, int pPartitionner);
+
+ /**
+ * Creates 3 resolution (CURRENT = FULL, MEDIUM and LOW) of a part of this distributed mesh.
+ * Names of new meshes are <original_name>_MED and <original_name>_LOW.
+ * \param pPartName
+ * \param pFielName
+ * \param pFieldIt
+ * \param pFilterName
+ * \param pTMed threshold used to generate MEDIUM resolution.
+ * \param pTLow threshold used to generate LOW resolution (must be >= pTMed).
+ * \param pRadius
+ * \param pBoxing number of cells along each axis; e.g. if 100 then grid will have 100*100*100 = 10**6 cells; 100 by default.
+ * \throw RuntimeException if any error occurs.
+ */
+ void decimatePart(
+ const char* pPartName,
+ const char* pFieldName,
+ med_int pFieldIt,
+ const char* pFilterName,
+ med_float pTMed,
+ med_float pTLow,
+ med_float pRadius,
+ int pBoxing = 100);
+
+ /**
+ * Returns useful information to configure decimation parameters.
+ * Depends on part, field and filter: generic operation.
+ * \param pPartName name of the part.
+ * \param pFieldName name of the field used for decimation.
+ * \param pFieldIt iteration (time step) of the field.
+ * \param pFilterName name of the filter to be used.
+ * \param pFilterParams params to be used with the filter (depends on filter; this string will be parsed).
+ * \return
+ */
+ std::string evalDecimationParams(
+ const char* pPartName,
+ const char* pFieldName,
+ int pFieldIt,
+ const char* pFilterName,
+ const char* pFilterParams);
+
+ //---------------------------------------------------------------------
+ // I/O
+ //---------------------------------------------------------------------
+
+ /**
+ * Reads the master file of a distributed MED file.
+ * \param pMEDfilename
+ * \throw NullArgumentException if pMEDfilename is NULL.
+ * \throw IOException if any i/o error occurs.
+ */
+ void readDistributedMED(const char* pMEDfilename);
+
+ /**
+ * Writes this distributed MED file (including master file and sub MED files if necessary).
+ * \param pMEDfilenamePrefix
+ * \throw NullArgumentException if pMEDfilename is NULL.
+ * \throw IOException if any i/o error occurs.
+ */
+ void writeDistributedMED(const char* pMEDfilenamePrefix);
+
+ /**
+ * Dumps any MeshDis to the given output stream.
+ * \param pOs any output stream.
+ * \param pM any MeshDis.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, MeshDis& pM);
+
+private:
+
+ /**
+ * Recomputes the number of parts in this distributed mesh.
+ * This method is used by writeDistributedMED().
+ * \return the number of parts in this distributed mesh.
+ */
+ int computeNumParts();
+
+private:
+
+ char mSequentialMEDFilename[256]; /**< Name of the original MED file used to build distribyuted MED. */
+ char mDistributedMEDFilename[256]; /**< Name of this distributed MED file (= name of the master file). */
+ std::vector<MeshDisPart*> mParts; /**< Table of sub-parts; a distributed mesh is composed of N sub-part, where N = mParts.size(). */
+ //MULTIPR_ProgressCallback* mProgressCallback;
+
+private:
+
+ // do not allow copy constructor
+ MeshDis(const MeshDis&);
+
+ // do not allow copy
+ MeshDis& operator=(const MeshDis&);
+
+ // do not allow operator ==
+ bool operator==(const MeshDis&);
+
+}; // class MeshDis
+
+
+} // namespace MULTIPR
+
+
+#endif // MULTIPR_MESHDIS_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Nodes.cxx
+ *
+ * \brief see MULTIPR_Nodes.hxx
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include "MULTIPR_Nodes.hxx"
+#include "MULTIPR_Exceptions.hxx"
+
+#include <iostream>
+
+using namespace std;
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class Nodes implementation
+//*****************************************************************************
+
+Nodes::Nodes()
+{
+ mId = NULL;
+ mFamIdent = NULL;
+ mNames = NULL;
+ mCoo = NULL;
+ mNamesCoo = NULL;
+ mNamesUnitCoo = NULL;
+
+ reset();
+}
+
+
+Nodes::~Nodes()
+{
+ reset();
+}
+
+
+void Nodes::reset()
+{
+ mNum = 0;
+ mDim = 0;
+ mCoordSystem = MED_CART;
+
+ if (mId != NULL) { delete[] mId; mId = NULL; }
+ if (mFamIdent != NULL) { delete[] mFamIdent; mFamIdent = NULL; }
+ if (mNames != NULL) { delete[] mNames; mNames = NULL; }
+ if (mCoo != NULL) { delete[] mCoo; mCoo = NULL; }
+ if (mNamesCoo != NULL) { delete[] mNamesCoo; mNamesCoo = NULL; }
+ if (mNamesUnitCoo != NULL) { delete[] mNamesUnitCoo; mNamesUnitCoo = NULL; }
+
+ mFlagPrintAll = false;
+}
+
+
+const med_float* Nodes::getCoordinates(med_int pIndexNode) const
+{
+ if ((pIndexNode < 0) || (pIndexNode >= mNum)) throw IndexOutOfBoundsException("", __FILE__, __LINE__);
+
+ return mCoo + pIndexNode * mDim;
+}
+
+
+med_int Nodes::getFamIdent(med_int pIndexNode) const
+{
+ if ((pIndexNode < 0) || (pIndexNode >= mNum)) throw IndexOutOfBoundsException("", __FILE__, __LINE__);
+
+ return mFamIdent[pIndexNode];
+}
+
+
+void Nodes::getBBox(med_float pMin[3], med_float pMax[3]) const
+{
+ //---------------------------------------------------------------------
+ // Special case: no nodes => bbox = [0 ; 0] x [0 ; 0] x [0 ; 0]
+ //---------------------------------------------------------------------
+ if (mNum == 0)
+ {
+ for (int itDim = 0 ; itDim < mDim ; itDim++)
+ {
+ pMin[itDim] = med_float(0.0);
+ pMax[itDim] = med_float(0.0);
+ }
+
+ return;
+ }
+
+ //---------------------------------------------------------------------
+ // Compute axis-aligned bounding box
+ //---------------------------------------------------------------------
+ for (int itDim = 0 ; itDim < mDim ; itDim++)
+ {
+ pMin[itDim] = numeric_limits<med_float>::max();
+ pMax[itDim] = -pMin[itDim];
+ }
+ for (int itNode = 0 ; itNode < mNum ; itNode++)
+ {
+ for (int itDim = 0 ; itDim < mDim ; itDim++)
+ {
+ med_float coord = mCoo[itNode * mDim + itDim];
+ if (coord < pMin[itDim]) pMin[itDim] = coord;
+ if (coord > pMax[itDim]) pMax[itDim] = coord;
+ }
+ }
+}
+
+
+set<med_int> Nodes::getSetOfFamilies() const
+{
+ set<med_int> setOfFamilies;
+
+ // for each node, ad its family to the set
+ for (int itNode = 0 ; itNode < mNum ; itNode++)
+ {
+ setOfFamilies.insert(mFamIdent[itNode]);
+ }
+
+ return setOfFamilies;
+}
+
+
+Nodes* Nodes::extractSubSet(const set<med_int>& pSetIndices) const
+{
+ Nodes* subset = new Nodes();
+
+ subset->mNum = pSetIndices.size();
+ subset->mDim = mDim;
+ subset->mCoordSystem = mCoordSystem;
+
+ //---------------------------------------------------------------------
+ // Allocate arrays
+ //---------------------------------------------------------------------
+ subset->mFamIdent = new med_int[subset->mNum];
+ subset->mCoo = new med_float[subset->mDim * subset->mNum];
+ subset->mNamesCoo = new char[subset->mDim * MED_TAILLE_PNOM + 1];
+ subset->mNamesUnitCoo = new char[subset->mDim * MED_TAILLE_PNOM + 1];
+
+ memcpy(subset->mNamesCoo, mNamesCoo, subset->mDim * MED_TAILLE_PNOM + 1);
+ memcpy(subset->mNamesUnitCoo, mNamesUnitCoo, subset->mDim * MED_TAILLE_PNOM + 1);
+
+ //---------------------------------------------------------------------
+ // Copy subset of familys id and coords.
+ //---------------------------------------------------------------------
+ set<med_int>::iterator itSet = pSetIndices.begin();
+ for (int i = 0 ; i < subset->mNum; i++)
+ {
+
+ med_int srcIndex = (*itSet) - 1; // MED index start at 1
+ subset->mFamIdent[i] = mFamIdent[srcIndex];
+
+ med_float* srcCoo = mCoo + srcIndex * mDim;
+ med_float* destCoo = subset->mCoo + i * subset->mDim;
+ for (int itDim = 0 ; itDim < mDim ; itDim++)
+ {
+ destCoo[itDim] = srcCoo[itDim];
+ }
+
+ itSet++;
+ }
+
+ //---------------------------------------------------------------------
+ // Copy subset of identifiers if necessary
+ //---------------------------------------------------------------------
+ if (isIdentifiers())
+ {
+ itSet = pSetIndices.begin();
+ subset->mId = new med_int[subset->mNum];
+ for (int i = 0 ; i < subset->mNum; i++)
+ {
+ med_int srcIndex = (*itSet) - 1; // MED index start at 1
+ subset->mId[i] = mId[srcIndex];
+
+ itSet++;
+ }
+ }
+
+ //---------------------------------------------------------------------
+ // Copy subset of names if necessary
+ //---------------------------------------------------------------------
+ if (isNames())
+ {
+ subset->mNames = new char[MED_TAILLE_PNOM * subset->mNum + 1];
+ char* destPtr = subset->mNames;
+ itSet = pSetIndices.begin();
+ for (int i = 0 ; i < subset->mNum; i++)
+ {
+ med_int srcIndex = (*itSet) - 1; // MED index start at 1
+ char* srcPtr = mNames + srcIndex * MED_TAILLE_PNOM;
+ memcpy(destPtr, srcPtr, MED_TAILLE_PNOM);
+ destPtr += MED_TAILLE_PNOM;
+
+ itSet++;
+ }
+ subset->mNames[MED_TAILLE_PNOM * subset->mNum] = '\0';
+ }
+
+ return subset;
+}
+
+
+Nodes* Nodes::mergePartial(Nodes* pNodes)
+{
+ Nodes* nodes = new Nodes();
+
+ nodes->mNum = mNum + pNodes->mNum;
+
+ if (mDim != pNodes->mDim) throw IllegalStateException("dimension should be the same", __FILE__, __LINE__);
+ nodes->mDim = mDim;
+
+ if (mCoordSystem != pNodes->mCoordSystem) throw IllegalStateException("coord. sytstem should be the same", __FILE__, __LINE__);
+ nodes->mCoordSystem = mCoordSystem;
+
+ nodes->mId = NULL; // optional: ignored
+ nodes->mNames = NULL; // optional: ignored
+
+ //---------------------------------------------------------------------
+ // Allocate arrays
+ //---------------------------------------------------------------------
+ nodes->mFamIdent = new med_int[nodes->mNum];
+ nodes->mCoo = new med_float[nodes->mDim * nodes->mNum];
+ nodes->mNamesCoo = new char[nodes->mDim * MED_TAILLE_PNOM + 1];
+ nodes->mNamesUnitCoo = new char[nodes->mDim * MED_TAILLE_PNOM + 1];
+
+ memcpy(nodes->mNamesCoo, mNamesCoo, nodes->mDim * MED_TAILLE_PNOM + 1);
+ memcpy(nodes->mNamesUnitCoo, mNamesUnitCoo, nodes->mDim * MED_TAILLE_PNOM + 1);
+
+ //---------------------------------------------------------------------
+ // Copy familys id and coords.
+ //---------------------------------------------------------------------
+ memcpy(nodes->mFamIdent, mFamIdent, mNum * sizeof(med_int));
+ memcpy(nodes->mFamIdent + mNum, pNodes->mFamIdent, pNodes->mNum * sizeof(med_int));
+
+ memcpy(nodes->mCoo, mCoo, mNum * mDim * sizeof(med_float));
+ memcpy(nodes->mCoo + (mNum * mDim), pNodes->mCoo, pNodes->mNum * pNodes->mDim * sizeof(med_float));
+
+ return nodes;
+}
+
+
+Nodes* Nodes::mergePartial(vector<Nodes*> pNodes)
+{
+ if (pNodes.size() == 0) throw IllegalArgumentException("pNodes should contain at least 1 element", __FILE__, __LINE__);
+
+ Nodes* nodes = new Nodes();
+
+ // count total number of nodes and check if all set of nodes are compatible
+ nodes->mNum = mNum;
+ for (unsigned i = 0 ; i < pNodes.size() ; i++)
+ {
+ nodes->mNum += pNodes[i]->mNum;
+
+ if (mDim != pNodes[i]->mDim) throw IllegalStateException("dimension should be the same", __FILE__, __LINE__);
+ if (mCoordSystem != pNodes[i]->mCoordSystem) throw IllegalStateException("coord. sytstem should be the same", __FILE__, __LINE__);
+ }
+
+ nodes->mDim = mDim;
+ nodes->mCoordSystem = mCoordSystem;
+
+ nodes->mId = NULL; // optional: ignored
+ nodes->mNames = NULL; // optional: ignored
+
+ //---------------------------------------------------------------------
+ // Allocate arrays
+ //---------------------------------------------------------------------
+ nodes->mFamIdent = new med_int[nodes->mNum];
+ nodes->mCoo = new med_float[nodes->mDim * nodes->mNum];
+ nodes->mNamesCoo = new char[nodes->mDim * MED_TAILLE_PNOM + 1];
+ nodes->mNamesUnitCoo = new char[nodes->mDim * MED_TAILLE_PNOM + 1];
+
+ memcpy(nodes->mNamesCoo, mNamesCoo, nodes->mDim * MED_TAILLE_PNOM + 1);
+ memcpy(nodes->mNamesUnitCoo, mNamesUnitCoo, nodes->mDim * MED_TAILLE_PNOM + 1);
+
+ //---------------------------------------------------------------------
+ // Copy familys id and coords.
+ //---------------------------------------------------------------------
+ memcpy(nodes->mFamIdent, mFamIdent, mNum * sizeof(med_int));
+ memcpy(nodes->mCoo, mCoo, mNum * mDim * sizeof(med_float));
+
+ int offsetFamIdent = mNum;
+ int offsetCoo = mNum;
+ for (unsigned i = 0 ; i < pNodes.size() ; i++)
+ {
+ memcpy(nodes->mFamIdent + offsetFamIdent, pNodes[i]->mFamIdent, pNodes[i]->mNum * sizeof(med_int));
+ memcpy(nodes->mCoo + (offsetCoo * mDim), pNodes[i]->mCoo, pNodes[i]->mNum * mDim * sizeof(med_float));
+
+ offsetFamIdent += pNodes[i]->mNum;
+ offsetCoo += pNodes[i]->mNum;
+ }
+
+ return nodes;
+}
+
+
+void Nodes::readMED(med_idt pMEDfile, char* pMeshName, med_int pDim)
+{
+ if (pMEDfile == 0) throw IOException("", __FILE__, __LINE__);
+ if (pMeshName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if (pDim != 3) throw IllegalArgumentException("", __FILE__, __LINE__);
+
+ reset();
+
+ mDim = pDim;
+ mNum = MEDnEntMaa(
+ pMEDfile,
+ pMeshName,
+ MED_COOR,
+ MED_NOEUD,
+ med_geometrie_element(0),
+ med_connectivite(0));
+
+ if (mNum < 0) throw IOException("", __FILE__, __LINE__);
+
+ if (mNum == 0)
+ {
+ // empty mesh
+ return;
+ }
+
+ mId = new med_int[mNum];
+ mFamIdent = new med_int[mNum];
+ mNames = new char[MED_TAILLE_PNOM * mNum + 1];
+ mCoo = new med_float[mDim * mNum];
+ mNamesCoo = new char[mDim * MED_TAILLE_PNOM + 1];
+ mNamesUnitCoo = new char[mDim * MED_TAILLE_PNOM + 1];
+
+ mNames[0] = '\0';
+ mNamesCoo[0] = '\0';
+ mNamesUnitCoo[0] = '\0';
+
+ med_booleen isIdentifiers;
+ med_booleen isNames;
+
+ med_err ret = MEDnoeudsLire(
+ pMEDfile,
+ pMeshName,
+ mDim,
+ mCoo,
+ MED_FULL_INTERLACE,
+ &mCoordSystem,
+ mNamesCoo,
+ mNamesUnitCoo,
+ mNames,
+ &isNames,
+ mId,
+ &isIdentifiers,
+ mFamIdent,
+ mNum);
+
+ if (ret != 0) throw IOException("", __FILE__, __LINE__);
+
+ // check if coordinates system is CARTESIAN
+ if (mCoordSystem != MED_CART) throw IllegalStateException("", __FILE__, __LINE__);
+
+ if (!isNames)
+ {
+ delete[] mNames;
+ mNames = NULL;
+ }
+
+ if (!isIdentifiers)
+ {
+ delete[] mId;
+ mId = NULL;
+ }
+}
+
+
+void Nodes::writeMED(med_idt pMEDfile, char* pMeshName) const
+{
+ if (pMEDfile == 0) throw IOException("", __FILE__, __LINE__);
+ if (pMeshName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if (strlen(pMeshName) > MED_TAILLE_NOM) throw IllegalArgumentException("", __FILE__, __LINE__);
+ if ((mDim < 1) || (mDim > 3)) throw IllegalStateException("", __FILE__, __LINE__);
+ if (mFamIdent == NULL) throw IllegalStateException("", __FILE__, __LINE__);
+ if (mCoo == NULL) throw IllegalStateException("", __FILE__, __LINE__);
+ if (mNamesCoo == NULL) throw IllegalStateException("", __FILE__, __LINE__);
+ if (mNamesUnitCoo == NULL) throw IllegalStateException("", __FILE__, __LINE__);
+
+ // special case: if no nodes => do nothing
+ if (mNum == 0) return;
+
+ med_err ret = MEDnoeudsEcr(
+ pMEDfile,
+ pMeshName,
+ mDim,
+ mCoo,
+ MED_FULL_INTERLACE,
+ mCoordSystem,
+ mNamesCoo,
+ mNamesUnitCoo,
+ mNames,
+ isNames()?MED_VRAI:MED_FAUX,
+ mId,
+ isIdentifiers()?MED_VRAI:MED_FAUX,
+ mFamIdent,
+ mNum);
+
+ if (ret != 0) throw IOException("i/o error while writing nodes", __FILE__, __LINE__);
+
+}
+
+
+ostream& operator<<(ostream& pOs, Nodes& pN)
+{
+ char strCoordSystem[16];
+ switch (pN.mCoordSystem)
+ {
+ case MED_CART: strcpy(strCoordSystem, "CARTESIAN"); break;
+ case MED_CYL: strcpy(strCoordSystem, "CYLINDRIC"); break;
+ case MED_SPHER: strcpy(strCoordSystem, "SPHERIC"); break;
+ default: strcpy(strCoordSystem, "UNKNOWN"); break;
+ }
+
+ pOs << "Nodes: " << endl;
+ pOs << " #number =" << pN.mNum << endl;
+ pOs << " Dimension =" << pN.mDim << endl;
+ pOs << " Coord. system=" << strCoordSystem << endl;
+ pOs << " Has names ?" << (pN.isNames()?"yes":"no") << endl;
+ pOs << " Has id ?" << (pN.isIdentifiers()?"yes":"no") << endl;
+ if (pN.mNamesCoo != NULL) pOs << " Axis names =" << "|" << pN.mNamesCoo << "|" << endl;
+ if (pN.mNamesUnitCoo != NULL) pOs << " Unit axis =" << "|" << pN.mNamesUnitCoo << "|" << endl;
+
+ {
+ set<med_int> setOfFam = pN.getSetOfFamilies();
+ if (setOfFam.size() == 0)
+ {
+ pOs << " Families: #fam=0" << endl;
+ }
+ else
+ {
+ set<med_int>::iterator itFam = setOfFam.end();
+ itFam--;
+ pOs << " Families: #fam=" << setOfFam.size() << " id_min=" << (*(setOfFam.begin())) << " id_max=" << (*itFam) << endl;
+ }
+
+ if (pN.mFlagPrintAll)
+ {
+ for (int itNode = 0 ; itNode < pN.mNum; itNode++)
+ {
+ pOs << " Node " << (itNode+1) << ": " << pN.mFamIdent[itNode] << endl;
+ }
+ }
+ }
+
+ med_float bboxMin[3], bboxMax[3];
+ pN.getBBox(bboxMin, bboxMax);
+ pOs << " BBox: [" << bboxMin[0] << " ; " << bboxMax[0] << "] x [" << bboxMin[1] << " ; " << bboxMax[1] << "] x [" << bboxMin[2] << " ; " << bboxMax[2] << "]" << endl;
+
+ if (pN.mFlagPrintAll)
+ {
+ pOs << " Coordinates: " << endl;
+ for (int itNode = 0 ; itNode < pN.mNum ; itNode++)
+ {
+ pOs << " Node " << (itNode+1) << ": ";
+ for (int itDim = 0 ; itDim < pN.mDim ; itDim++)
+ {
+ pOs << pN.mCoo[itNode * pN.mDim + itDim] << " ";
+ }
+ pOs << endl;
+ }
+
+ if (pN.isIdentifiers())
+ {
+ pOs << " Num: " << endl;
+ for (int itNode = 0 ; itNode < pN.mNum; itNode++)
+ {
+ pOs << " Node " << (itNode+1) << ": " << pN.mId[itNode] << endl;
+ }
+ }
+
+ if (pN.isNames())
+ {
+ pN.mNames[MED_TAILLE_PNOM * pN.mNum] = '\0';
+ pOs << " Names: |" << pN.mNames << "|" << endl;
+ }
+
+ }
+
+ return pOs;
+}
+
+
+} // namespace multipr
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Nodes.hxx
+ *
+ * \brief Class Nodes = table of nodes.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_NODES_HXX
+#define MULTIPR_NODES_HXX
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+extern "C"
+{
+ #include "med.h"
+}
+
+#include <iostream>
+#include <set>
+#include <vector>
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class Nodes
+//*****************************************************************************
+
+class Nodes
+{
+public:
+
+ /**
+ * Builds an empty set of nodes (default constructor).
+ */
+ Nodes();
+
+ /**
+ * Destructor. Removes everything.
+ */
+ ~Nodes();
+
+ /**
+ * Resets this object in its state by default (empty). Cleans memory.
+ */
+ void reset();
+
+ //---------------------------------------------------------------------
+ // Basic accessors/mutators
+ //---------------------------------------------------------------------
+
+ /**
+ * Returns true if nodes have a name.
+ * \return true if nodes have a name.
+ */
+ bool isNames() const { return (mNames != NULL); }
+
+ /**
+ * Returns true if elements have an identifier (= a number).
+ * \return true if elements have an identifier (= a number).
+ */
+ bool isIdentifiers() const { return (mId != NULL); }
+
+ /**
+ * Returns the coordinates of one node according to its index.
+ * \param pIndexNode index of node in [0..NUMBER_OF_NODES-1].
+ * \return the coordinates of one node.
+ * \throw IndexOutOfBoundsException if pIndexNode is invalid.
+ */
+ const med_float* getCoordinates(med_int pIndexNode) const;
+
+ /**
+ * Returns the family of one node.
+ * \param pIndexNode index of node in [0..NUMBER_OF_NODES-1].
+ * \return the family of the given node.
+ * \throw IndexOutOfBoundsException if pIndexNode is invalid.
+ */
+ med_int getFamIdent(med_int pIndexNode) const;
+
+ /**
+ * Returns the number of nodes.
+ * \return the number of nodes.
+ */
+ int getNumberOfNodes() const { return mNum; }
+
+ //---------------------------------------------------------------------
+ // Algorithms
+ //---------------------------------------------------------------------
+
+ /**
+ * Returns the axis-aligned bounding box (CARTESIAN coordinates system) of this set of nodes.
+ * \param pMin (out) coordinates of the min-corner of the bbox.
+ * \param pMin (out) coordinates of the max-corner of the bbox.
+ */
+ void getBBox(med_float pMin[3], med_float pMax[3]) const;
+
+ /**
+ * Returns the set of families referenced by this set of nodes.
+ * Each family is described by its identifier.
+ * \return the set of families referenced by this set of nodes.
+ */
+ std::set<med_int> getSetOfFamilies() const;
+
+ /**
+ * Constructor. Creates a subset of this set of nodes from a set of indices.
+ * \param pSetOfIndices set of indices; each index must be >= 1.
+ * \return a subset of this set of nodes from a set of indices.
+ */
+ Nodes* extractSubSet(const std::set<med_int>& pSetIndices) const;
+
+ /**
+ * Builds a new set of nodes by merging two set of nodes (this and pNodes) if possible.
+ * Merge is partial because Id and Names are not take into account.
+ * \param pNodes any set of nodes to be merged with this.
+ * \return a new set of nodes.
+ * \throw IllegalStateException if the two sets of nodes are incompatible.
+ */
+ Nodes* mergePartial(Nodes* pNodes);
+ Nodes* mergePartial(std::vector<Nodes*> pNodes);
+
+ //---------------------------------------------------------------------
+ // I/O
+ //---------------------------------------------------------------------
+
+ /**
+ * Reads all nodes of a mesh from a MED file.
+ * \param pMEDfile any valid MED file opened for reading.
+ * \param pMeshName name of the mesh to be read.
+ * \param pDim dimension of the mesh.
+ * \throw IOException if any i/o error occurs.
+ */
+ void readMED(med_idt pMEDfile, char* pMeshName, med_int pDim);
+
+ /**
+ * Writes this set of nodes to a MED file. Nodes are associated with the given mesh.
+ * WARNING: mesh must have been created and added to the MED file before.
+ * \param pMEDfile any valid MED file opened for writing.
+ * \param pMeshName any mesh of the MED file.
+ * \throw IOException if any i/o error occurs.
+ */
+ void writeMED(med_idt pMEDfile, char* pMeshName) const;
+
+ /**
+ * Sets the flag which control the stream operator <<.
+ * \param pFlag new flag value.
+ */
+ void setPrintAll(bool pFlag) { mFlagPrintAll = pFlag; }
+
+ /**
+ * Dumps any Nodes to the given output stream.
+ * \param pOs any output stream.
+ * \param pN any Nodes.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, Nodes& pN);
+
+private:
+
+ med_int mNum; /**< Number of nodes in this set. */
+ med_int mDim; /**< Dimension of nodes. */
+ med_repere mCoordSystem; /**< Type of coordinates system; should be MED_CART for cartesian. */
+
+ med_int* mId; /**< Optional; for each node, its identifier; NULL if undefined. */
+ med_int* mFamIdent; /**< For each node, its identifier of its family. */
+ char* mNames; /**< Optional; for each node, its name; NULL if undefined. */
+ med_float* mCoo; /**< For each node, coordinates of node; array is interlaced: x1 y1 z1 x2 y2 z2 ...*/
+ char* mNamesCoo; /**< Names of axis of the coordinates system. */
+ char* mNamesUnitCoo; /**< Unit of axis of the coordinates system. */
+
+ bool mFlagPrintAll; /** Flag to control the behaviour of the stream operator <<. */
+
+private:
+
+ // do not allow copy constructor
+ Nodes(const Nodes&);
+
+ // do not allow copy
+ Nodes& operator=(const Nodes&);
+
+ // do not allow operator ==
+ bool operator==(const Nodes&);
+
+}; // class Nodes
+
+
+} // namespace MULTIPR
+
+
+#endif // MULTIPR_NODES_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Obj.cxx
+ *
+ * \brief see MULTIPR_Obj.hxx
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include "MULTIPR_Obj.hxx"
+#include "MULTIPR_Exceptions.hxx"
+#include "MULTIPR_Mesh.hxx"
+#include "MULTIPR_MeshDis.hxx"
+#include "MULTIPR_Utils.hxx"
+#include "MED_Factory.hxx"
+
+#include <stdio.h>
+#include <iostream>
+
+using namespace std;
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class Obj implementation
+//*****************************************************************************
+
+Obj::Obj()
+{
+ mMeshDis = NULL;
+
+ reset();
+}
+
+
+Obj::~Obj()
+{
+ reset();
+}
+
+
+void Obj::reset()
+{
+ mMEDfilename = "";
+ mMeshName = "";
+ mState = MULTIPR_OBJ_STATE_RESET;
+
+ if (mMeshDis != NULL) { delete mMeshDis; mMeshDis = NULL; }
+}
+
+
+void Obj::create(const char* pMEDfilename)
+{
+ if (pMEDfilename == NULL) throw multipr::NullArgumentException("file name must not be NULL", __FILE__, __LINE__);
+
+ // reset everything before associating a new MED file to this object
+ reset();
+
+ mMEDfilename = pMEDfilename;
+ mState = MULTIPR_OBJ_STATE_ERROR;
+
+ // check if file exists
+ FILE* f = fopen(pMEDfilename, "rb");
+ if (f == 0)
+ {
+ // file does not exist
+ mState = MULTIPR_OBJ_STATE_ERROR;
+ throw FileNotFoundException("file not found", __FILE__, __LINE__);
+ }
+ fclose(f);
+
+ // test whether it is a sequential MED file or a distributed MED file
+ MED::EVersion aVersion = MED::GetVersionId(pMEDfilename, true);
+ if (aVersion != MED::eVUnknown)
+ {
+ mState = MULTIPR_OBJ_STATE_SEQ_INIT;
+ cout << "Sequential MED file " << pMEDfilename << " has been successfuly opened" << endl;
+ }
+ else
+ {
+ // CASE 2: distributed MED file?
+ try
+ {
+ mMeshDis = new multipr::MeshDis();
+ mMeshDis->readDistributedMED(pMEDfilename);
+
+ mState = MULTIPR_OBJ_STATE_DIS;
+ cout << "Distributed MED file " << pMEDfilename << " has been successfuly opened" << endl;
+ }
+ catch (...)
+ {
+ // neither a sequential MED file, nor a distributed MED file => error
+ mState = MULTIPR_OBJ_STATE_ERROR;
+ throw IOException("file is nor a sequential MED file, neither a distributed MED file", __FILE__, __LINE__);
+ }
+ }
+}
+
+
+std::string Obj::getSequentialMEDFilename() const
+{
+ // partitionneGrain() is only available for distributed MED file (not sequential MED file)
+ if ((mState != MULTIPR_OBJ_STATE_DIS_MEM) &&
+ (mState != MULTIPR_OBJ_STATE_DIS)) throw IllegalStateException("unexpected operation", __FILE__, __LINE__);
+
+ return mMeshDis->getSequentialMEDFilename();
+}
+
+
+void Obj::setMesh(const char* pMeshName)
+{
+ // setMesh() is only available for sequential MED file (not distributed MED file)
+ if ((mState != MULTIPR_OBJ_STATE_SEQ_INIT) &&
+ (mState != MULTIPR_OBJ_STATE_SEQ)) throw IllegalStateException("expected a sequential MED file", __FILE__, __LINE__);
+
+ mMeshName = pMeshName;
+
+ // change state to MULTIPR_OBJ_STATE_SEQ (in case of state=MULTIPR_OBJ_STATE_SEQ_INIT)
+ mState = MULTIPR_OBJ_STATE_SEQ;
+}
+
+
+vector<string> Obj::getMeshes() const
+{
+ // test whether it is a sequential MED file or a distributed MED file
+ if ((mState == MULTIPR_OBJ_STATE_SEQ_INIT) ||
+ (mState == MULTIPR_OBJ_STATE_SEQ))
+ {
+ // CASE 1: sequential MED file
+ return multipr::getListMeshes(mMEDfilename.c_str());
+ }
+ else
+ {
+ // CASE 2: distributed MED file
+ if (mMeshDis == NULL)
+ {
+ throw IllegalStateException("distributed MED file should not be NULL", __FILE__, __LINE__);
+ }
+
+ return mMeshDis->getMeshes();
+ }
+}
+
+
+vector<string> Obj::getFields() const
+{
+ // test whether it is a sequential MED file or a distributed MED file
+ if ((mState == MULTIPR_OBJ_STATE_SEQ_INIT) ||
+ (mState == MULTIPR_OBJ_STATE_SEQ))
+ {
+ // CASE 1: sequential MED file
+ vector<pair<string, int> > tmp = multipr::getListScalarFields(mMEDfilename.c_str());
+
+ vector<string> res;
+ for (unsigned i = 0 ; i < tmp.size() ; i++)
+ {
+ res.push_back(tmp[i].first);
+ }
+
+ return res;
+ }
+ else
+ {
+ // CASE 2: distributed MED file
+ if (mMeshDis == NULL) throw IllegalStateException("distributed MED file should not be NULL", __FILE__, __LINE__);
+
+ return mMeshDis->getFields();
+ }
+}
+
+
+int Obj::getTimeStamps(const char* pFieldName) const
+{
+ // test whether it is a sequential MED file or a distributed MED file
+ if ((mState == MULTIPR_OBJ_STATE_SEQ_INIT) ||
+ (mState == MULTIPR_OBJ_STATE_SEQ))
+ {
+ // CASE 1: sequential MED file
+ vector<pair<string, int> > tmp = multipr::getListScalarFields(mMEDfilename.c_str());
+
+ for (unsigned i = 0 ; i < tmp.size() ; i++)
+ {
+ if (strcmp(tmp[i].first.c_str(), pFieldName) == 0)
+ {
+ return tmp[i].second;
+ }
+ }
+
+ // pFieldName not found in the list of fields
+ return 0;
+ }
+ else
+ {
+ // CASE 2: distributed MED file
+ if (mMeshDis == NULL) throw IllegalStateException("distributed MED file should not be NULL", __FILE__, __LINE__);
+
+ return mMeshDis->getTimeStamps(pFieldName);
+ }
+}
+
+
+vector<string> Obj::getParts() const
+{
+ // getParts() is only available for distributed MED file (not sequential MED file)
+ if ((mState != MULTIPR_OBJ_STATE_DIS) &&
+ (mState != MULTIPR_OBJ_STATE_DIS_MEM)) throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
+
+ return getListParts();
+}
+
+
+string Obj::getPartInfo(const char* pPartName) const
+{
+ // getParts() is only available for distributed MED file (not sequential MED file)
+ if ((mState != MULTIPR_OBJ_STATE_DIS) &&
+ (mState != MULTIPR_OBJ_STATE_DIS_MEM)) throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
+
+ if (mMeshDis == NULL) throw IllegalStateException("distributed MED file should not be NULL", __FILE__, __LINE__);
+
+ return mMeshDis->getPartInfo(pPartName);
+
+}
+
+
+void Obj::removeParts(const char* pPrefixPartName)
+{
+ // removePart() is only available for distributed MED file (not sequential MED file)
+ if ((mState != MULTIPR_OBJ_STATE_DIS) &&
+ (mState != MULTIPR_OBJ_STATE_DIS_MEM)) throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
+
+ if (mMeshDis == NULL) throw IllegalStateException("distributed MED file should not be NULL", __FILE__, __LINE__);
+
+ mMeshDis->removeParts(pPrefixPartName);
+ mState = MULTIPR_OBJ_STATE_DIS_MEM;
+}
+
+
+vector<string> Obj::partitionneDomaine()
+{
+ if (mState == MULTIPR_OBJ_STATE_SEQ_INIT) throw IllegalStateException("use setMesh() before", __FILE__, __LINE__);
+
+ // partitionneDomaine() is only available for sequential MED file (not distributed MED file)
+ if (mState != MULTIPR_OBJ_STATE_SEQ) throw IllegalStateException("unexpected operation", __FILE__, __LINE__);
+
+ //-------------------------------------------------------------
+ // Read the sequential mesh
+ //-------------------------------------------------------------
+ cout << "Read sequential MED file: " << mMEDfilename << ": please wait... " << endl;
+
+ Mesh mesh;
+ mesh.readSequentialMED(mMEDfilename.c_str(), mMeshName.c_str());
+ cout << mesh << endl;
+
+ //-------------------------------------------------------------
+ // Build distributed mesh from groups
+ //-------------------------------------------------------------
+ cout << "Build distributed mesh: please wait... " << endl;
+ try
+ {
+ mMeshDis = mesh.splitGroupsOfElements();
+ }
+ catch (RuntimeException& e)
+ {
+ delete mMeshDis;
+ mMeshDis = NULL;
+ throw e;
+ }
+
+ mState = MULTIPR_OBJ_STATE_DIS_MEM;
+
+ return getListParts();
+}
+
+
+vector<string> Obj::partitionneGrain(
+ const char* pPartName,
+ int pNbParts,
+ int pPartitionner)
+{
+ if (mMeshDis == NULL) throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
+ if (pPartName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+ if (pNbParts < 2) throw IllegalArgumentException("", __FILE__, __LINE__);
+ if ((pPartitionner != 0) && (pPartitionner != 1)) throw IllegalArgumentException("partitionner should be 0=METIS or 1=SCOTCH", __FILE__, __LINE__);
+
+ // partitionneGrain() is only available for distributed MED file (not sequential MED file)
+ if ((mState != MULTIPR_OBJ_STATE_DIS_MEM) &&
+ (mState != MULTIPR_OBJ_STATE_DIS)) throw IllegalStateException("unexpected operation", __FILE__, __LINE__);
+
+ // if distributed MED file is currently in memory, then write to disk before performing partitionneGrain()
+ // (because MEDSPLIITER starts from a file)
+ if (mState == MULTIPR_OBJ_STATE_DIS_MEM)
+ {
+ //-----------------------------------------------------
+ // Write distributed mesh
+ //-----------------------------------------------------
+ cout << "Write distributed mesh: please wait... " << endl;
+ string strPrefix = removeExtension(mMEDfilename.c_str(), ".med");
+ mMeshDis->writeDistributedMED(strPrefix.c_str());
+
+ mMEDfilename = mMeshDis->getDistributedMEDFilename();
+
+ delete mMeshDis;
+
+ //---------------------------------------------------------------------
+ // Read the distributed mesh
+ //---------------------------------------------------------------------
+ int ret = MEDformatConforme(mMEDfilename.c_str());
+ if (ret == 0) throw IOException("waiting for a distributed MED file (not a sequential one)", __FILE__, __LINE__);
+
+ mMeshDis = new MeshDis();
+ mMeshDis->readDistributedMED(mMEDfilename.c_str());
+
+ mState = MULTIPR_OBJ_STATE_DIS;
+ }
+
+ //---------------------------------------------------------------------
+ // Split the given part (pGroupName)
+ //---------------------------------------------------------------------
+ mMeshDis->splitPart(pPartName, pNbParts, pPartitionner);
+ cout << mMeshDis << endl;
+
+ //---------------------------------------------------------------------
+ // Write new distributed mesh
+ //---------------------------------------------------------------------
+ string strPrefix = multipr::removeExtension(mMEDfilename.c_str(), ".med");
+ mMeshDis->writeDistributedMED(strPrefix.c_str());
+
+ //---------------------------------------------------------------------
+ // Read the distributed mesh
+ //---------------------------------------------------------------------
+ delete mMeshDis;
+ mMeshDis = new MeshDis();
+ //cout << "read dis MED file: filename=" << mMEDfilename << endl;
+ mMeshDis->readDistributedMED(mMEDfilename.c_str());
+
+ return getListParts();
+}
+
+
+vector<string> Obj::decimePartition(
+ const char* pPartName,
+ const char* pFieldName,
+ int pFieldIt,
+ const char* pFilterName,
+ double pTmed,
+ double pTlow,
+ double pRadius,
+ int pBoxing)
+{
+
+ // decimePartition() is only available for distributed MED file (not sequential MED file)
+ if ((mState != MULTIPR_OBJ_STATE_DIS_MEM) &&
+ (mState != MULTIPR_OBJ_STATE_DIS)) throw IllegalStateException("unexpected operation", __FILE__, __LINE__);
+
+ if (mMeshDis == NULL) throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Decimate
+ //---------------------------------------------------------------------
+ mMeshDis->decimatePart(
+ pPartName,
+ pFieldName,
+ pFieldIt,
+ pFilterName,
+ pTmed,
+ pTlow,
+ pRadius,
+ pBoxing);
+
+ mState = MULTIPR_OBJ_STATE_DIS_MEM;
+
+ return getListParts();
+}
+
+
+string Obj::evalDecimationParams(
+ const char* pPartName,
+ const char* pFieldName,
+ int pFieldIt,
+ const char* pFilterName,
+ const char* pFilterParams)
+{
+ // decimePartition() is only available for distributed MED file (not sequential MED file)
+ if ((mState != MULTIPR_OBJ_STATE_DIS_MEM) &&
+ (mState != MULTIPR_OBJ_STATE_DIS)) throw IllegalStateException("unexpected operation", __FILE__, __LINE__);
+
+ if (mMeshDis == NULL) throw IllegalStateException("expected a distributed MED file", __FILE__, __LINE__);
+
+ string res = mMeshDis->evalDecimationParams(
+ pPartName,
+ pFieldName,
+ pFieldIt,
+ pFilterName,
+ pFilterParams);
+
+ return res;
+}
+
+
+vector<string> Obj::getListParts() const
+{
+ if (mMeshDis == NULL) throw IllegalStateException("not a distributed mesh", __FILE__, __LINE__);
+
+ vector<string> names;
+
+ int numParts = mMeshDis->getNumParts();
+ for (int i = 0 ; i < numParts ; i++)
+ {
+ names.push_back( mMeshDis->getPart(i)->getPartName() );
+ }
+
+ return names;
+}
+
+
+void Obj::save(const char* pPath)
+{
+ static string prevPath = "";
+
+ // only save file if it is a distributed MED file currently in memory or path has changed
+ if ((mState == MULTIPR_OBJ_STATE_DIS_MEM) || (strcmp(pPath, prevPath.c_str()) != 0))
+ {
+ prevPath = pPath;
+
+ //-------------------------------------------------------------
+ // Write new distributed mesh
+ //-------------------------------------------------------------
+ string filename;
+ if (strlen(pPath) == 0)
+ {
+ filename = multipr::removeExtension(mMEDfilename.c_str(), ".med");
+ }
+ else
+ {
+ filename = string(pPath) + string("/") + multipr::getFilenameWithoutPath(mMEDfilename.c_str());
+ }
+ string strPrefix = multipr::removeExtension(filename.c_str(), ".med");
+ mMeshDis->writeDistributedMED(strPrefix.c_str());
+ mMEDfilename = mMeshDis->getDistributedMEDFilename();
+
+ cout << "Write MED master file: " << mMEDfilename << ": OK" << endl;
+
+ //-------------------------------------------------------------
+ // Read the distributed mesh
+ //-------------------------------------------------------------
+ delete mMeshDis;
+ mMeshDis = new MeshDis();
+ mMeshDis->readDistributedMED(mMEDfilename.c_str());
+
+ mState = MULTIPR_OBJ_STATE_DIS;
+ }
+}
+
+
+ostream& operator<<(ostream& pOs, Obj& pO)
+{
+ pOs << "Obj:" << endl;
+ pOs << " Name:" << pO.mMEDfilename << endl;
+
+ return pOs;
+}
+
+
+} // namespace multipr
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_GaussLoc.hxx
+ *
+ * \brief Class MULTIPR_Obj.
+ * This class is used as an interface to implement MULTIPR services in the salome MODULE
+ * as described in the spec/design doc.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_OBJ_HXX
+#define MULTIPR_OBJ_HXX
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+
+namespace multipr
+{
+
+class MeshDis;
+
+
+//*****************************************************************************
+// Class Obj
+//*****************************************************************************
+
+enum ObjState
+{
+ MULTIPR_OBJ_STATE_ERROR,
+ MULTIPR_OBJ_STATE_RESET,
+ MULTIPR_OBJ_STATE_SEQ_INIT,
+ MULTIPR_OBJ_STATE_SEQ,
+ MULTIPR_OBJ_STATE_DIS,
+ MULTIPR_OBJ_STATE_DIS_MEM
+}; // enum ObjState
+
+
+class Obj
+{
+public:
+
+ /**
+ * Builds an empty Gauss reference (default constructor).
+ */
+ Obj();
+
+ /**
+ * Destructor. Removes everything.
+ */
+ ~Obj();
+
+ /**
+ * Resets this object in its state by default (empty). Cleans memory.
+ */
+ void reset();
+
+ /**
+ * Associate a MED file (sequential or distributed) with this object.
+ * This method also:
+ * - reset everything before starting
+ * - determine if the given file is a sequential (SEQ) or a distributed (DIS) MED file
+ * - read the ASCII master file if it is a distributed MED file
+ * - set state
+ */
+ void create(const char* pMEDfilename);
+
+ //---------------------------------------------------------------------
+ // Basic accessors/mutators
+ //--------------------------------------------------------------------
+
+ /**
+ * Returns true iff this obj represents a valid sequential MED file.
+ * \return true iff this obj represents a valid sequential MED file.
+ */
+ bool isValidSequentialMEDFile() const { return (mState == MULTIPR_OBJ_STATE_SEQ) || (mState == MULTIPR_OBJ_STATE_SEQ_INIT); }
+
+ /**
+ * Returns true iff this obj represents a valid distributed MED file.
+ * \return true iff this obj represents a valid distributed MED file.
+ */
+ bool isValidDistributedMEDFile() const { return (mState == MULTIPR_OBJ_STATE_DIS) || (mState == MULTIPR_OBJ_STATE_DIS_MEM); }
+
+ /**
+ * Returns the name of the associated MED file.
+ * \return the name of the associated MED file.
+ */
+ std::string getMEDFilename() const { return mMEDfilename; }
+
+ /**
+ * Returns the name of the associated sequential MED file.
+ * \return the name of the associated sequential MED file.
+ */
+ std::string getSequentialMEDFilename() const;
+
+ /**
+ * Defines the mesh to be processed.
+ * \param pMeshName name of the mesh to be partitionned.
+ */
+ void setMesh(const char* pMeshName);
+
+ /**
+ * Returns the list of meshes contained in the sequential MED file.
+ * Assumes this object encapsulates a sequential MED file.
+ * \return the list of meshes contained in the sequential MED file.
+ */
+ std::vector<std::string> getMeshes() const;
+
+ /**
+ * Returns the list of fields contained in the sequential MED file.
+ * Assumes this object encapsulates a sequential MED file.
+ * \return the list of fields contained in the sequential MED file.
+ */
+ std::vector<std::string> getFields() const;
+
+ /**
+ * Returns the number of timestamps for a given field.
+ * Assumes this object encapsulates a sequential MED file.
+ * \param pFieldName name of any field.
+ * \return the number of timestamps for a given field; 0 if field not found.
+ */
+ int getTimeStamps(const char* pFieldName) const;
+
+ /**
+ * Returns the name of all partitions.
+ * Assumes this object encapsulates a distributed MED file.
+ * \return the name of all partitions.
+ */
+ std::vector<std::string> getParts() const;
+
+ /**
+ * Returns all information about a part.
+ * \param pPartName name of the part.
+ * \return all information about a part.
+ */
+ std::string getPartInfo(const char* pPartName) const;
+
+ /**
+ * Removes all the part beginning by pPrefixPartName from the distributed MED file.
+ * Example: if pPrefixPartName="PART_4" => remove "PART_4" and all sub-parts "PART_4_*", but not "PART41".
+ * Assume this object encapsulates a distributed MED file.
+ * \param pPrefixPartName name of the part.
+ */
+ void removeParts(const char* pPrefixPartName);
+
+
+ //---------------------------------------------------------------------
+ // Algorithms
+ //--------------------------------------------------------------------
+
+ /**
+ * Creates a distributed MED file (v2.3) by extracting all the groups from the current mesh of the current MED sequential MED file.
+ * Assumes:
+ * - the file is in MED format and can be read using MED file v2.3.
+ * - the file is sequential (not a distributed MED).
+ * - the file only contains TETRA10 elements (dimension of space and mesh is 3).
+ * - the file have no profil.
+ * \return the name of each part.
+ * \throw RuntimeException if any error occurs.
+ */
+ std::vector<std::string> partitionneDomaine();
+
+ /**
+ * Creates a distributed MED file (V2.3) by splitting a group of a MED file previously created by partitionneDomaine.
+ * Assumes:
+ * - the file is a distributed MED file, previously created by partitionneDomaine()
+ * (=> each part only contain 1 mesh, TETRA10 elements only)
+ * - nbPart > 1
+ * \param pPartName name of the part to be splitted.
+ * \param pNbParts number of parts; must be > 1.
+ * \param pPartitionner use value 0=MULTIPR_METIS for Metis or 1=MULTIPR_SCOTCH for Scotch.
+ * \return the name of each part.
+ * \throw RuntimeException if any error occurs.
+ */
+ std::vector<std::string> partitionneGrain(
+ const char* pPartName,
+ int pNbParts,
+ int pPartitionner=0);
+
+ /**
+ * Creates 3 resolutions of the given part of a distributed MED file (V2.3).
+ * Assumes:
+ * - the file is a distributed MED file, previously created by partitionneDomaine() or partitionneGrain()
+ * (=> each part only contain 1 mesh, TETRA10 elements only)
+ * \param pPartName name of the part to be decimated.
+ * \param pFieldName name of the field used for decimation.
+ * \param pFieldIt iteration (time step) of the field.
+ * \param pFilterName name of the filter to be used.
+ * \param pTmed threshold used for medium resolution.
+ * \param pTlow threshold used for low resolution; tmed must be less than tlow
+ * \param pTadius radius used to determine the neighbourhood.
+ * \param pBoxing number of cells along each axis; must be >= 1; e.g. if 100 then acceleration grid will have 100*100*100 = 10**6 cells.
+ * \return the name of each part.
+ * \throw RuntimeException if any error occurs.
+ */
+ std::vector<std::string> decimePartition(
+ const char* pPartName,
+ const char* pFieldName,
+ int pFieldIt,
+ const char* pFilterName,
+ double pTmed,
+ double pTlow,
+ double pRadius,
+ int pBoxing);
+
+ /**
+ * Returns useful information to configure decimation parameters.
+ * Depends on part, field and filter: generic operation.
+ * \param pPartName name of the part.
+ * \param pFieldName name of the field used for decimation.
+ * \param pFieldIt iteration (time step) of the field.
+ * \param pFilterName name of the filter to be used.
+ * \param pFilterParams params to be used with the filter (depends on filter; this string will be parsed).
+ */
+ std::string evalDecimationParams(
+ const char* pPartName,
+ const char* pFieldName,
+ int pFieldIt,
+ const char* pFilterName,
+ const char* pFilterParams);
+
+
+ //---------------------------------------------------------------------
+ // I/O
+ //---------------------------------------------------------------------
+
+ /**
+ * Saves the associated MED file if necessary.
+ * \param pPath path where to save the file.
+ * \throw IOException if any i/o error occurs.
+ */
+ void save(const char* pPath);
+
+ /**
+ * Dumps any Obj to the given output stream.
+ * \param pOs any output stream.
+ * \param pO any Obj.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, Obj& pO);
+
+private:
+
+ /**
+ * Returns the list of parts contained in the current distributed mesh.
+ * \return the list of parts contained in the current distributed mesh.
+ * \throw IllegalStateException if the distributed mesh does not still exist.
+ */
+ std::vector<std::string> getListParts() const;
+
+private:
+
+ std::string mMEDfilename; /**< Name of the MED file: sequential or distributed. */
+ std::string mMeshName; /**< Mesh to be partitionned. */
+ ObjState mState; /**< State of this object. */
+ MeshDis* mMeshDis; /**< Distributed mesh. */
+
+
+private:
+
+ // do not allow copy constructor
+ Obj(const Obj&);
+
+ // do not allow copy
+ Obj& operator=(const Obj&);
+
+ // do not allow operator ==
+ bool operator==(const Obj&);
+
+}; // class Obj
+
+
+} // namespace MULTIPR
+
+
+#endif // MULTIPR_OBJ_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_PointOfField.hxx
+ *
+ * \brief Class PointOfField used for decimation. PointOfField = a point in a field = coordinates + value.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_POINTOFFIELD_HXX
+#define MULTIPR_POINTOFFIELD_HXX
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+extern "C"
+{
+ #include "med.h"
+}
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class PointOfField
+//*****************************************************************************
+
+class PointOfField
+{
+public:
+
+ /**
+ * Builds an empty set of elements (default constructor).
+ */
+ PointOfField() { reset(); }
+
+ /**
+ * Constructor.
+ * \param pX x-coordinate of the point.
+ * \param pY y-coordinate of the point.
+ * \param pZ z-coordinate of the point.
+ * \param pVal value of the field at the given point.
+ */
+ PointOfField(med_float pX, med_float pY, med_float pZ, med_float pVal)
+ {
+ mXYZ[0] = pX;
+ mXYZ[1] = pY;
+ mXYZ[2] = pZ;
+ mVal = pVal;
+ }
+
+ /**
+ * Destructor. Removes everything.
+ */
+ ~PointOfField() { reset(); }
+
+ /**
+ * Resets this object in its state by default (empty).
+ */
+ void reset()
+ {
+ mXYZ[0] = std::numeric_limits<med_float>::quiet_NaN();
+ mXYZ[1] = std::numeric_limits<med_float>::quiet_NaN();
+ mXYZ[2] = std::numeric_limits<med_float>::quiet_NaN();
+ mVal = std::numeric_limits<med_float>::quiet_NaN();
+ }
+
+ /**
+ * Dumps any PointOfField to the given output stream.
+ * \param pOs any output stream.
+ * \param pP any PointOfField.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, PointOfField& pP)
+ {
+ pOs << "[ " << pP.mXYZ[0] << " ; " << pP.mXYZ[1] << " ; " << pP.mXYZ[2] << "]: " << pP.mVal;
+ return pOs;
+ }
+
+public:
+
+ med_float mXYZ[3]; /**< 3D-position. */
+ med_float mVal; /**< Value of the field at this point. */
+
+}; // class PointOfField
+
+
+} // namespace multipr
+
+
+#endif // MULTIPR_FIELDPOINT_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Profil.cxx
+ *
+ * \brief see MULTIPR_Profil.hxx
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include "MULTIPR_Profil.hxx"
+#include "MULTIPR_Exceptions.hxx"
+
+#include <iostream>
+
+using namespace std;
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class Profil implementation
+//*****************************************************************************
+
+Profil::Profil()
+{
+ reset();
+}
+
+
+Profil::~Profil()
+{
+ reset();
+}
+
+
+void Profil::reset()
+{
+ mName[0] = '\0';
+ mTable.clear();
+}
+
+
+void Profil::create(const char* pName)
+{
+ if (pName == NULL) throw NullArgumentException("", __FILE__, __LINE__);
+
+ reset();
+ strcpy(mName, pName);
+}
+
+
+
+const char* Profil::getName() const
+{
+ return mName;
+}
+
+
+med_int Profil::get(med_int pIndex) const
+{
+ if ((pIndex < 0) || (pIndex >= med_int(mTable.size()))) throw IndexOutOfBoundsException("", __FILE__, __LINE__);
+
+ return mTable[pIndex];
+}
+
+
+void Profil::add(med_int pElt)
+{
+ mTable.push_back(pElt);
+}
+
+
+void Profil::readMED(med_idt pMEDfile, med_int pIndexProfil)
+{
+ if (pMEDfile == 0) throw IOException("", __FILE__, __LINE__);
+ if (pIndexProfil < 1) throw IllegalArgumentException("", __FILE__, __LINE__);
+
+ reset();
+
+ med_int numData;
+ med_err ret = MEDprofilInfo(
+ pMEDfile,
+ pIndexProfil,
+ mName,
+ &numData);
+
+ if (ret != 0) throw IOException("", __FILE__, __LINE__);
+
+ med_int* dataTmp = new med_int[numData];
+
+ ret = MEDprofilLire(
+ pMEDfile,
+ dataTmp,
+ mName);
+
+ if (ret != 0) throw IOException("", __FILE__, __LINE__);
+
+ for (int itData = 0 ; itData < numData ; itData++)
+ {
+ mTable.push_back(dataTmp[itData]);
+ }
+
+ delete[] dataTmp;
+}
+
+
+void Profil::writeMED(med_idt pMEDfile)
+{
+ if (pMEDfile == 0) throw IOException("", __FILE__, __LINE__);
+ if (strlen(mName) > MED_TAILLE_NOM) throw IllegalStateException("", __FILE__, __LINE__);
+ if (mTable.size() == 0) throw IllegalStateException("", __FILE__, __LINE__);
+
+ med_int* dataTmp = new med_int[mTable.size()];
+ for (unsigned itData = 0 ; itData < mTable.size() ; itData++)
+ {
+ dataTmp[itData] = mTable[itData];
+ }
+
+ med_err ret = MEDprofilEcr(
+ pMEDfile,
+ dataTmp,
+ mTable.size(),
+ mName);
+
+ if (ret != 0) throw IOException("", __FILE__, __LINE__);
+
+ delete[] dataTmp;
+}
+
+
+ostream& operator<<(ostream& pOs, Profil& pP)
+{
+ pOs << "Profil:" << endl;
+ pOs << " Name=|" << pP.mName << "|" << endl;
+ pOs << " Size=" << pP.mTable.size() << endl;
+
+ pOs << " Entities=[";
+ for (unsigned itElt = 0; itElt < pP.mTable.size() ; itElt++)
+ {
+ pOs << pP.mTable[itElt] << " ";
+ }
+ pOs << "]";
+
+ return pOs;
+}
+
+
+} // namespace multipr
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Profil.hxx
+ *
+ * \brief Class Profil used to managed MED profil.
+ * Profil is just a list of indices related to elements (NODES, CELLS).
+ * !!! currently not used !!!
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_PROFIL_HXX
+#define MULTIPR_PROFIL_HXX
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+extern "C"
+{
+ #include "med.h"
+}
+
+#include <vector>
+
+
+namespace multipr
+{
+
+
+//*****************************************************************************
+// Class Profil
+//*****************************************************************************
+
+class Profil
+{
+public:
+
+ /**
+ * Builds an empty profil (default constructor).
+ */
+ Profil();
+
+ /**
+ * Destructor. Removes everything.
+ */
+ ~Profil();
+
+ /**
+ * Resets this object in its state by default (empty). Cleans memory.
+ */
+ void reset();
+
+ /**
+ * Creates a profil from its name (reset before).
+ * \param pName name of the profil to be created.
+ * \throw NullArgumentException if pName is NULL.
+ */
+ void create(const char* pName);
+
+ //---------------------------------------------------------------------
+ // Basic accessors/mutators
+ //---------------------------------------------------------------------
+
+ /**
+ * Returns the name of this profil.
+ * \return the name of this profil.
+ */
+ const char* getName() const;
+
+ /**
+ * Returns the nth elements of this profil.
+ * \param pIndex index of the element to get; must be in [0..NUMBER_OF_ELEMENTS-1].
+ * \return the nth elements of this profil.
+ * \throw IndexOutOfBoundsException if index is invalid.
+ */
+ med_int get(med_int pIndex) const;
+
+ /**
+ * Adds a new element to this profil.
+ * \param pElt element to be added; must be >= 1.
+ */
+ void add(med_int pElt);
+
+ //---------------------------------------------------------------------
+ // I/O
+ //---------------------------------------------------------------------
+
+ /**
+ * Reads a Profil from a MED file.
+ * \param pMEDfile any valid MED file opened for reading.
+ * \param pIndexProfil index of the profil to be read; must be >= 1.
+ * \throw IOException if any i/o error occurs.
+ */
+ void readMED(med_idt pMEDfile, med_int pIndexProfil);
+
+ /**
+ * Writes this profil to a MED file.
+ * \param pMEDfile any valid MED file opened for writing.
+ * \throw IOException if any i/o error occurs.
+ */
+ void writeMED(med_idt pMEDfile);
+
+ /**
+ * Dumps any Profil to the given output stream.
+ * \param pOs any output stream.
+ * \param pP any Profil.
+ * \return the output stream pOs.
+ */
+ friend std::ostream& operator<<(std::ostream& pOs, Profil& pP);
+
+private:
+
+ char mName[MED_TAILLE_NOM + 1]; /**< Name of the profil. */
+ std::vector<med_int> mTable; /**< Table of elements. */
+
+private:
+
+ // do not allow copy constructor
+ Profil(const Profil&);
+
+ // do not allow copy
+ Profil& operator=(const Profil&);
+
+ // do not allow operator ==
+ bool operator==(const Profil&);
+
+}; // class Profil
+
+
+} // namespace MULTIPR
+
+
+#endif // MULTIPR_PROFIL_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_ProgressCallback.hxx
+ *
+ * \brief Class MULTIPR_ProgressCallback
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_PROGRESS_CALLBACK_HXX
+#define MULTIPR_PROGRESS_CALLBACK_HXX
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+
+//*****************************************************************************
+// Class MULTIPR_ProgressCallback
+// Used to provide feedback on the progress of a slow operation.
+//*****************************************************************************
+
+class MULTIPR_ProgressCallback
+{
+public:
+
+ /**
+ * Builds a new MULTIPR_ProgressCallback (default constructor).
+ */
+ MULTIPR_ProgressCallback() { init(100); }
+
+ /**
+ * Destructor. Removes everything.
+ */
+ virtual ~MULTIPR_ProgressCallback() { /* do nothing */ }
+
+ /**
+ * Starts to provide feedback on the progress of a slow operation.
+ * \param pTaskTitle name of the task to be monitored.
+ * \param pNumSteps number of steps in the task.
+ */
+ virtual void start(const char* pTaskTitle, int pNumSteps) = 0;
+
+ /**
+ * Moves on the current amount of progress made.
+ */
+ void moveOn() { mCurrentStep++; float percent = float(mCurrentStep)/float(mTotalSteps)*100.0f; progress(percent); }
+
+ /**
+ * Termines to provide feedback.
+ */
+ virtual void done() = 0;
+
+protected:
+
+ /**
+ * Resets this progress callback.
+ * \param pNumSteps number of steps in the task to be monitored.
+ */
+ void init(int pNumSteps) { mCurrentStep = 0; mTotalSteps = pNumSteps; }
+
+ /**
+ * Callback. Called on each progress.
+ * \param pPercent percent accomplished.
+ */
+ virtual void progress(float pPercent) = 0;
+
+private:
+
+ int mCurrentStep;
+ int mTotalSteps;
+
+}; // class MULTIPR_ProgressCallback
+
+
+//*****************************************************************************
+// Class MULTIPR_EmptyMeshCallback
+// Used to provide feedback when an empty mesh is produced.
+//*****************************************************************************
+
+class MULTIPR_EmptyMeshCallback
+{
+public:
+
+ /**
+ * Builds a new MULTIPR_EmptyMeshCallback (default constructor).
+ */
+ MULTIPR_EmptyMeshCallback() { /* do nothing */ }
+
+ /**
+ * Destructor. Removes everything.
+ */
+ virtual ~MULTIPR_EmptyMeshCallback() { /* do nothing */ }
+
+ /**
+ * Callback. Called each time an empty mesh is produced.
+ * \param pInfo information related to the empty mesh.
+ */
+ virtual void reportEmptyMesh(std::string pInfo) = 0;
+
+}; // class MULTIPR_EmptyMeshCallback
+
+
+#endif // MULTIPR_PROGRESS_CALLBACK_HXX
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Utils.cxx
+ *
+ * \brief see MULTIPR_Utils.hxx
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+//*****************************************************************************
+// Includes section
+//*****************************************************************************
+
+#include "MULTIPR_Utils.hxx"
+#include "MULTIPR_Exceptions.hxx"
+
+#include <iostream>
+
+using namespace std;
+
+
+//*****************************************************************************
+// Implementation
+//*****************************************************************************
+
+void multipr::trim(char* pStr, char pChar)
+{
+ int len = strlen(pStr) - 1;
+ int p = len;
+ while (pStr[p] == pChar)
+ {
+ p--;
+ }
+ if (p != len)
+ {
+ pStr[p + 1] = '\0';
+ }
+}
+
+
+bool multipr::startsWith(const char* pStr, const char* pStrPrefix)
+{
+ int i = 0;
+ while ((pStr[i] != '\0') && (pStrPrefix[i] != '\0') && (pStr[i] == pStrPrefix[i]))
+ {
+ i++;
+ }
+ return (pStrPrefix[i] == '\0');
+}
+
+
+string multipr::removeExtension(const char* pFilename, const char* pExtension)
+{
+ string strPrefix(pFilename);
+ strPrefix.erase(strPrefix.rfind(pExtension), strlen(pExtension));
+
+ return strPrefix;
+}
+
+
+string multipr::getFilenameWithoutPath(const char* pFilename)
+{
+ char* res = strrchr(pFilename, '/');
+ if (res == NULL)
+ {
+ return pFilename;
+ }
+ else
+ {
+ char* name = res + 1;
+ return name;
+ }
+}
+
+
+string multipr::getPath(const char* pFilename)
+{
+ // find (reverse) the first occurrence of '/' in the given string
+ char* res = strrchr(pFilename, '/');
+
+ // if there is no '/'...
+ if (res == NULL)
+ {
+ return "";
+ }
+ else
+ {
+ int size = res - pFilename + 1;
+ char path[256];
+ memcpy(path, pFilename, size);
+ path[size] = '\0';
+ return path;
+ }
+}
+
+
+void multipr::copyFile(const char* pFilename, const char* pDestDir)
+{
+ const char* srcDir = multipr::getPath(pFilename).c_str();
+ if (strcmp(srcDir, pDestDir) == 0) return;
+
+ const char* filenameWithoutPath = multipr::getFilenameWithoutPath(pFilename).c_str();
+ char pDstFilename[256];
+ sprintf(pDstFilename, "%s%s", pDestDir, filenameWithoutPath);
+
+ // open binary source file
+ FILE* src = fopen(pFilename, "rb");
+ if (src == NULL) return;
+
+ // open (create) binary destination file
+ FILE* dst = fopen(pDstFilename, "wb");
+ if (dst == NULL) return;
+
+ const int size = 65536; // size of buffer is 64Kb
+ char* buf = new char[size];
+ int ret;
+ ret = fread(buf, 1, size, src);
+ while (ret != 0)
+ {
+ fwrite(buf, 1, ret, dst); // write to destination
+ ret = fread(buf, 1, size, src); // read from source
+ }
+
+ delete[] buf;
+ fclose(src);
+ fclose(dst);
+}
+
+
+void multipr::printArray2D(
+ const med_float* pData,
+ const int pNumElt,
+ const int pDimElt,
+ const char* pPrefix)
+{
+ for (int itElt = 0 ; itElt < pNumElt ; itElt++)
+ {
+ cout << pPrefix << " " << (itElt + 1) << ": ";
+ for (int itDim = 0 ; itDim < pDimElt ; itDim++)
+ {
+ cout << pData[itElt * pDimElt + itDim] << " ";
+ }
+ cout << endl;
+ }
+}
+
+
+string multipr::realToString(med_float mV)
+{
+ char str[32];
+ sprintf(str, "%lf", mV);
+ trim(str, '0');
+ int len = strlen(str);
+ if (str[len - 1] == '.')
+ {
+ str[len] = '0';
+ str[len + 1] = '\0';
+ }
+ return string(str);
+}
+
+
+vector<string> multipr::getListMeshes(const char* pMEDfilename)
+{
+ if (pMEDfilename == NULL) throw multipr::NullArgumentException("", __FILE__, __LINE__);
+
+ vector<string> res;
+ med_err ret;
+
+ //---------------------------------------------------------------------
+ // Open MED file (READ_ONLY)
+ //---------------------------------------------------------------------
+ med_idt file = MEDouvrir(const_cast<char*>(pMEDfilename), MED_LECTURE); // open MED file for reading
+ if (file <= 0) throw multipr::IOException("MED file not found or not a sequential MED file", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Read name of meshes
+ //---------------------------------------------------------------------
+ med_int nbMeshes = MEDnMaa(file);
+ if (nbMeshes <= 0) throw multipr::IOException("i/o error while reading number of meshes in MED file", __FILE__, __LINE__);
+
+ // for each mesh in the file (warning: first mesh is number 1)
+ for (int itMesh = 1 ; itMesh <= nbMeshes ; itMesh++)
+ {
+ char meshName[MED_TAILLE_NOM + 1];
+
+ int meshDim;
+ med_maillage meshType;
+ char meshDesc[MED_TAILLE_DESC + 1];
+
+ ret = MEDmaaInfo(
+ file,
+ itMesh,
+ meshName,
+ &meshDim,
+ &meshType,
+ meshDesc);
+
+ if (ret != 0) throw multipr::IOException("i/o error while reading mesh information in MED file", __FILE__, __LINE__);
+
+ res.push_back(meshName);
+ }
+
+ //---------------------------------------------------------------------
+ // Close the MED file
+ //---------------------------------------------------------------------
+ ret = MEDfermer(file);
+ if (ret != 0) throw multipr::IOException("i/o error while closing MED file", __FILE__, __LINE__);
+
+ return res;
+}
+
+
+vector<pair<string,int> > multipr::getListScalarFields(const char* pMEDfilename)
+{
+ if (pMEDfilename == NULL) throw multipr::NullArgumentException("", __FILE__, __LINE__);
+
+ vector<pair<string, int> > res;
+ med_err ret;
+
+ //---------------------------------------------------------------------
+ // Open MED file (READ_ONLY)
+ //---------------------------------------------------------------------
+ med_idt file = MEDouvrir(const_cast<char*>(pMEDfilename), MED_LECTURE); // open MED file for reading
+ if (file <= 0) throw multipr::IOException("MED file not found or not a sequential MED file", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // Read number of fields
+ //---------------------------------------------------------------------
+ med_int numFields = MEDnChamp(file, 0);
+ if (numFields <= 0) throw IOException("", __FILE__, __LINE__);
+
+ //---------------------------------------------------------------------
+ // For each field, read its name
+ //---------------------------------------------------------------------
+ for (int itField = 1 ; itField <= numFields ; itField++)
+ {
+ char name[MED_TAILLE_NOM + 1];
+ med_type_champ type;
+
+ med_int numComponents = MEDnChamp(file, itField);
+
+ if (numComponents < 0) throw IOException("", __FILE__, __LINE__);
+
+ // collect scalar field only (not vectorial fields)
+ if (numComponents != 1)
+ continue;
+
+ // temporary buffers
+ char* strComponent = new char[numComponents * MED_TAILLE_PNOM + 1];
+ char* strUnit = new char[numComponents * MED_TAILLE_PNOM + 1];
+
+ strComponent[0] = '\0';
+ strUnit[0] = '\0';
+
+ med_err ret = MEDchampInfo(
+ file,
+ itField,
+ name,
+ &(type),
+ strComponent,
+ strUnit,
+ numComponents);
+
+ if (ret != 0) throw IOException("", __FILE__, __LINE__);
+
+ delete[] strUnit;
+ delete[] strComponent;
+
+ med_int numTimeStamps = MEDnPasdetemps(
+ file,
+ name,
+ MED_NOEUD,
+ (med_geometrie_element) 0);
+
+ if (numTimeStamps < 0) throw IOException("", __FILE__, __LINE__);
+
+ if (numTimeStamps == 0)
+ {
+ numTimeStamps = MEDnPasdetemps(
+ file,
+ name,
+ MED_MAILLE,
+ MED_TETRA10);
+
+ if (numTimeStamps < 0) throw IOException("", __FILE__, __LINE__);
+
+ }
+
+ // add the pair(name, #time stamps) to the result
+ res.push_back( make_pair(name, numTimeStamps) );
+ }
+
+ //---------------------------------------------------------------------
+ // Close the MED file
+ //---------------------------------------------------------------------
+ ret = MEDfermer(file);
+ if (ret != 0) throw multipr::IOException("i/o error while closing MED file", __FILE__, __LINE__);
+
+ // return the list of fields
+ return res;
+}
+
+
+// EOF
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file MULTIPR_Utils.hxx
+ *
+ * \brief Some useful miscellaneous tools.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#ifndef MULTIPR_UTILS_HXX
+#define MULTIPR_UTILS_HXX
+
+extern "C"
+{
+ #include "med.h"
+}
+
+#include <string>
+#include <vector>
+
+
+namespace multipr
+{
+
+
+/**
+ * Removes all the pChar at the end of the string.
+ * \param pStr any valid C string ending with the char '\0'.
+ * \param pChar any char; SPACE by default.
+ * \return the same string where the ending spaces have been removed.
+ */
+void trim(char* pStr, char pChar=' ');
+
+
+/**
+ * Returns true iff the given string starts by prefix.
+ * \param pStr any valid C string ending with the char '\0'.
+ * \param pStrPrefix any valid C string ending with the char '\0'.
+ * \return true iff the given string starts by prefix.
+ */
+bool startsWith(const char* pStr, const char* pStrPrefix);
+
+
+/**
+ * Removes the extension (suffix) of a filename.
+ * Example: removeExtension("agregat100grains_12pas.med", ".med") -> "agregat100grains_12pas"
+ * \param pPilename any valid C string ending with the char '\0'.
+ * \param pExtension any valid C string ending with the char '\0'.
+ * \return the filename without extension.
+ */
+std::string removeExtension(const char* pFilename, const char* pExtension);
+
+
+/**
+ * Returns the name of the file, excluding the path.
+ * Example: getFilenameWithoutPath("/home/data/agregat100grains_12pas.med") -> "agregat100grains_12pas.med"
+ * \param pPilename any valid C string ending with the char '\0'.
+ * \return the name of the file, excluding the path.
+ */
+std::string getFilenameWithoutPath(const char* pFilename);
+
+
+/**
+ * Returns the path of the filename (which may be relative or absolute).
+ * Example: getPath("/home/data/agregat100grains_12pas.med") -> "/home/data/"
+ * \param pPilename any valid C string ending with the char '\0'.
+ * \return the path of the filename (which may be relative or absolute).
+ */
+std::string getPath(const char* pFilename);
+
+
+/**
+ * Copies the given file into a directory.
+ * \param pFilename name of any file to be copied.
+ * \param pDestDir destination directory.
+ */
+void copyFile(const char* pFilename, const char* pDestDir);
+
+
+/**
+ * Prints all the elements of a 2D array.
+ * \param pData all the data (should contain pNumberOfElements * pDimOfElements values)
+ * \param pNumElt number of elements to display.
+ * \param pDimElt Dimension of elements.
+ * \param pPrefix string to display before each element.
+ */
+void printArray2D(
+ const med_float* pData,
+ const int pNumElt,
+ const int pDimElt,
+ const char* pPrefix);
+
+
+/**
+ * Converts any float value to a string (remove unecessary 0).
+ * \param mV any float value.
+ */
+std::string realToString(med_float mV);
+
+
+/**
+ * Returns the name of all meshes contained in a sequential MED file.
+ * \param pMEDfilename name of any valid sequential MED file; must not be NULL.
+ * \return a list of mesh names.
+ * \throw NullArgumentException if pMEDfilename is NULL.
+ * \throw IOException if any other error occurs while reading MED file.
+ */
+ std::vector<std::string> getListMeshes(const char* pMEDfilename);
+
+
+ /**
+ * For each scalar field in a sequential MED file, returns its name and the related number of time stamps.
+ * Do not returns info about vectorial fields (because, currently, decimation can only be performed on scalar fields).
+ * \param pMEDfilename name of any valid sequential MED file; must not be NULL.
+ * \return a list of (name, #time stamps).
+ * \throw NullArgumentException if pMEDfilename is NULL.
+ * \throw IOException if any other error occurs while reading MED file.
+ */
+ std::vector< std::pair<std::string, int> > getListScalarFields(const char* pMEDfilename);
+
+} // namespace MULTIPR
+
+
+#endif // MULTIPR_UTILS_HXX
+
+// EOF
--- /dev/null
+# Copyright (C) 2005 CEA/DEN, EDF 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
+#
+
+# Source path
+
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl
+
+MACHINE=PCLINUX
+
+@COMMENCE@
+
+# Libraries targets
+
+LIB = libMULTIPR_API.la
+
+LIB_SRC = \
+MULTIPR_API.cxx \
+MULTIPR_Mesh.cxx \
+MULTIPR_Profil.cxx \
+MULTIPR_GaussLoc.cxx \
+MULTIPR_Field.cxx \
+MULTIPR_Nodes.cxx \
+MULTIPR_Elements.cxx \
+MULTIPR_Family.cxx \
+MULTIPR_MeshDis.cxx \
+MULTIPR_DecimationFilter.cxx \
+MULTIPR_DecimationAccel.cxx \
+MULTIPR_Utils.cxx \
+MULTIPR_Obj.cxx
+
+#LIB_SERVER_IDL = MULTIPR.idl
+
+LIB_CLIENT_IDL = SALOME_Component.idl SALOME_Exception.idl SALOMEDS.idl SALOME_GenericObj.idl Logger.idl
+
+EXPORT_HEADERS = \
+MULTIPR_API.hxx \
+MULTIPR_DecimationAccel.hxx \
+MULTIPR_DecimationFilter.hxx \
+MULTIPR_Elements.hxx \
+MULTIPR_Exceptions.hxx \
+MULTIPR_Family.hxx \
+MULTIPR_Field.hxx \
+MULTIPR_GaussLoc.hxx \
+MULTIPR_Globals.hxx \
+MULTIPR_MeshDis.hxx \
+MULTIPR_Mesh.hxx \
+MULTIPR_Nodes.hxx \
+MULTIPR_PointOfField.hxx \
+MULTIPR_Profil.hxx \
+MULTIPR_Utils.hxx \
+MULTIPR_Obj.hxx \
+MULTIPR_ProgressCallback.hxx
+
+BIN = multipr
+BIN_SRC =
+
+# additionnal information to compile and link file
+
+CPPFLAGS += $(KERNEL_CXXFLAGS) $(MED_CXXFLAGS) $(MED2_INCLUDES) -Wall -pthread
+
+CPPFLAGSFORBIN=$(CPPFLAGS)
+
+LDFLAGS += $(KERNEL_LDFLAGS) $(MED_LDFLAGS) $(MED2_LIBS) -lSalomeContainer -lOpUtil -lm -lmed -lmedsplitter -lmedmem -lMEDWrapper -lSALOMELocalTrace
+
+LDFLAGSFORBIN=$(LDFLAGS) -lmed_V2_1 -lMEDWrapper_V2_2 -lMEDWrapper_V2_1 -lMEDWrapperBase
+# Executables targets
+
+@CONCLUDE@
+
--- /dev/null
+// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Partitioning/decimation module for the SALOME v3.2 platform
+
+/**
+ * \file multipr.cxx
+ *
+ * \brief Standalone command line application of the MULTIPR component.
+ * The application aims to reduce large data set to allow interactive visualization.
+ * Its two main function are the following:
+ * 1. Splits any TETRA10 mesh contained in a MED file.
+ * a. Builds a distributed MED file by extracting all the groups from a sequential MED file.
+ * b. Splits a part of distributed MED file.
+ * 2. Decimates fields to produce multi-resolution data set.
+ *
+ * Return 0 if application succeed, 1 otherwise (failure).
+ *
+ * See http://www.salome-platform.org to learn more about Salome or MED.
+ *
+ * \author Olivier LE ROUX - CS, Virtual Reality Dpt
+ *
+ * \date 01/2007
+ */
+
+#include "MULTIPR_API.hxx"
+#include "MULTIPR_Obj.hxx"
+#include "MULTIPR_Mesh.hxx"
+#include "MULTIPR_Exceptions.hxx"
+#include "MULTIPR_Utils.hxx"
+
+#include <iostream>
+#include <vector>
+#include <string>
+
+using namespace std;
+
+
+// This command line application can use 2 differents API to do the same work.
+// If MULTIPR_USE_OBJ_API is defined then this command line application used the MULTIPR_Obj API;
+// otherwise, it uses the MULTIPR_API
+//#define MULTIPR_USE_OBJ_API
+
+
+const int MULTIPR_APP_OK = 0;
+const int MULTIPR_APP_FAILED = 1;
+
+
+/**
+ * Enumerates all the usages of this application.
+ */
+enum Usage
+{
+ MULTIPR_USAGE_UNKNOWN,
+ MULTIPR_USAGE_DISPLAY_HELP,
+ MULTIPR_USAGE_AUTOTEST,
+ MULTIPR_USAGE_PARTITION1,
+ MULTIPR_USAGE_PARTITION2,
+ MULTIPR_USAGE_DECIMATION,
+ MULTIPR_USAGE_MERGE,
+ MULTIPR_USAGE_INFO
+};
+
+
+/**
+ * Enumerates all the possible errors.
+ */
+enum Error
+{
+ MULTIPR_APP_NO_ERROR,
+ MULTIPR_APP_UNKNOWN_USAGE,
+ MULTIPR_APP_WRONG_NUMBER_OF_ARGUMENTS,
+ MULTIPR_APP_ILLEGAL_ARGUMENT,
+ MULTIPR_APP_FILE_NOT_FOUND,
+ MULTIPR_APP_IO_ERROR,
+ MULTIPR_APP_UNDEFINED_ERROR
+};
+
+
+// global variables used to configure the application
+int g_usage = 0;
+int g_errorCode = MULTIPR_APP_NO_ERROR;
+char* g_medFilename = NULL;
+char* g_meshName = NULL;
+char* g_partName = NULL;
+int g_nbParts = 0;
+int g_splitter = multipr::MULTIPR_METIS;
+char* g_filterName = NULL;
+char* g_fieldName = NULL;
+int g_fieldTimeStepIt = 0;
+float g_decimThresholdMed = 0.0f;
+float g_decimThresholdLow = 0.0f;
+float g_decimRadius = 0.0f;
+int g_boxing = 100;
+
+// merge
+std::vector<std::string> g_medFilenameSrc;
+char* g_medFilenameDst = NULL;
+
+
+/**
+ * \fn const char* getUsage(int usage)
+ * \brief returns a string describing the usage of this application.
+ */
+const char* getUsage(int usage)
+{
+ switch(usage)
+ {
+ case MULTIPR_USAGE_DISPLAY_HELP:
+ return "--help: display help";
+
+ case MULTIPR_USAGE_AUTOTEST:
+ return "--auto: perform all unit tests";
+
+ case MULTIPR_USAGE_PARTITION1:
+ return "--part1: extract all groups from a sequential MED file";
+
+ case MULTIPR_USAGE_PARTITION2:
+ return "--part2: split a part of a distributed MED file";
+
+ case MULTIPR_USAGE_DECIMATION:
+ return "--decim: generated level of details from a part of a distributed MED file";
+
+ case MULTIPR_USAGE_MERGE:
+ return "--merge: merge two sequential MED file if possible";
+
+ case MULTIPR_USAGE_INFO:
+ return "--info: prints all infos about a mesh in a sequential MED file";
+
+ default:
+ return "unknown";
+ }
+}
+
+
+/**
+ * \fn void printDescription()
+ * \brief prints a short description of this application.
+ */
+void printDescription()
+{
+ cout << "Keywords:" << endl;
+ cout << " Post-processing numerical simulation, Salome platform, " << endl;
+ cout << " Large data set visualization, 3D meshes and fields" << endl;
+ cout << "Description:" << endl;
+ cout << " multipr is a partitionning/decimation tool of MED files." << endl;
+ cout << " See http://www.salome-platform.org for information about MED or Salome." << endl;
+ cout << " Note: current version only accept TETRA10 meshes." << endl;
+}
+
+
+/**
+ * \fn void printUsage()
+ * \brief prints "how to use" manual of this tools.2NbPart
+ */
+void printUsage()
+{
+ cout << "Usages:" << endl;
+ cout << " --auto Autotest: performs some unit tests on the MULTIPR API" << endl;
+ cout << " * Usage: --auto path (path where to find test file \"agregat100grains_12pas.med\")" << endl;
+ cout << " --part1 Extracts all groups from a sequential MED file (V2.2 or higher)" << endl;
+ cout << " * Usage: --part1 file.med meshName" << endl;
+ cout << " --part2 Split a group of a distributed MED file (V2.3) produced with --part1" << endl;
+ cout << " * Usage: --part2 file.med partName nbParts [splitter (0=METIS 1=SCOTCH)]" << endl;
+ cout << " --decim Generates 3 level of details (full, medium and low) from a part" << endl;
+ cout << " of a distributed MED file (V2.3)" << endl;
+ cout << " * Usage: --decim file.med partName fieldName fieldIt filterName [...]" << endl;
+ cout << " * Only one filter is currently available: Filtre_GradientMoyen" << endl;
+ cout << " * Usage: --decim file.med partName fieldName fieldIt Filtre_GradientMoyen m l radius" << endl;
+ cout << " where m=threshold for medium res. and l=threshold for low res.; assume m < l" << endl;
+ cout << " --info Dumps all infos related to a mesh in a sequential MED file" << endl;
+ cout << " * Usage: --info file.med [meshName]" << endl;
+ cout << " --help Displays this help page" << endl;
+ cout << endl;
+}
+
+
+/**
+ * \fn void printGlobals()
+ * \brief print current state of all global variables.
+ */
+void printGlobals()
+{
+ cout << endl;
+ cout << "********************************************************************************" << endl;
+ cout << "CONFIGURATION" << endl;
+ cout << "--------------------------------------------------------------------------------" << endl;
+ cout << "Mode : " << getUsage(g_usage) << endl;
+ cout << "Med filename : " << ((g_medFilename != NULL) ? g_medFilename : "UNDEFINED") << endl;
+ cout << "Mesh name : " << ((g_meshName != NULL) ? g_meshName : "UNDEFINED") << endl;
+ cout << "Part name : " << ((g_partName != NULL) ? g_partName : "UNDEFINED") << endl;
+ cout << "Nb parts : " << g_nbParts << endl;
+ cout << "Decimation:" << endl;
+ cout << " Field name : " << ((g_fieldName != NULL) ? g_fieldName : "UNDEFINED") << endl;
+ cout << " Time step iteration : " << g_fieldTimeStepIt << endl;
+ cout << " Filter name : " << ((g_filterName != NULL) ? g_filterName : "UNDEFINED") << endl;
+ cout << " Threshold for med. res. : " << g_decimThresholdMed << endl;
+ cout << " Threshold for low res. : " << g_decimThresholdLow << endl;
+ cout << " Radius : " << g_decimRadius << endl;
+ cout << " Boxing : " << g_boxing << endl;
+ cout << "********************************************************************************" << endl;
+ cout << endl;
+}
+
+
+/**
+ * \fn const char* getErrorMsg()
+ * \brief returns the error message corresponding to current error code.
+ * \return the current error message.
+ */
+const char* getErrorMsg()
+{
+ switch (g_errorCode)
+ {
+ case MULTIPR_APP_NO_ERROR:
+ return "no error";
+
+ case MULTIPR_APP_UNKNOWN_USAGE:
+ return "unknown usage";
+
+ case MULTIPR_APP_WRONG_NUMBER_OF_ARGUMENTS:
+ return "wrong number of arguments";
+
+ case MULTIPR_APP_ILLEGAL_ARGUMENT:
+ return "illegal argument";
+
+ case MULTIPR_APP_FILE_NOT_FOUND:
+ return "file not found";
+
+ case MULTIPR_APP_IO_ERROR:
+ return "i/o error";
+
+ default:
+ return "error (undefined)";
+ }
+}
+
+
+/**
+ * \fn void parseCommandLine(int argc, char** argv)
+ * \brief parses the command line and configure this application.
+ * \param argc number of arguments.
+ * \param argv array of arguments.
+ */
+void parseCommandLine(int argc, char** argv)
+{
+ if (argc == 1)
+ {
+ g_usage = MULTIPR_USAGE_UNKNOWN;
+ return;
+ }
+
+ if (strcmp(argv[1],"--help") == 0)
+ {
+ g_usage = MULTIPR_USAGE_DISPLAY_HELP;
+ }
+ else if (strcmp(argv[1],"--auto") == 0)
+ {
+ if (argc != 3)
+ {
+ g_usage = MULTIPR_USAGE_UNKNOWN;
+ g_errorCode = MULTIPR_APP_WRONG_NUMBER_OF_ARGUMENTS;
+ }
+ else
+ {
+ g_usage = MULTIPR_USAGE_AUTOTEST;
+ g_medFilename = argv[2];
+ }
+ }
+ else if (strcmp(argv[1],"--part1") == 0)
+ {
+ if (argc != 4)
+ {
+ g_usage = MULTIPR_USAGE_UNKNOWN;
+ g_errorCode = MULTIPR_APP_WRONG_NUMBER_OF_ARGUMENTS;
+ }
+ else
+ {
+ g_usage = MULTIPR_USAGE_PARTITION1;
+ g_medFilename = argv[2];
+ g_meshName = argv[3];
+ }
+ }
+ else if (strcmp(argv[1],"--part2") == 0)
+ {
+ if ((argc != 5) && (argc != 6))
+ {
+ g_usage = MULTIPR_USAGE_UNKNOWN;
+ g_errorCode = MULTIPR_APP_WRONG_NUMBER_OF_ARGUMENTS;
+ }
+ else
+ {
+ g_usage = MULTIPR_USAGE_PARTITION2;
+ g_medFilename = argv[2];
+ g_partName = argv[3];
+ g_nbParts = atoi(argv[4]);
+
+ if (argc == 6)
+ {
+ g_splitter = atoi(argv[5]);
+ }
+ }
+ }
+ else if (strcmp(argv[1],"--decim") == 0)
+ {
+ if ((argc != 10) && (argc != 11))
+ {
+ g_usage = MULTIPR_USAGE_UNKNOWN;
+ g_errorCode = MULTIPR_APP_WRONG_NUMBER_OF_ARGUMENTS;
+ }
+ else
+ {
+ g_usage = MULTIPR_USAGE_DECIMATION;
+ g_medFilename = argv[2];
+ g_partName = argv[3];
+ g_fieldName = argv[4];
+ g_fieldTimeStepIt = atoi(argv[5]);
+ g_filterName = argv[6];
+ g_decimThresholdMed = atof(argv[7]);
+ g_decimThresholdLow = atof(argv[8]);
+ g_decimRadius = atof(argv[9]);
+
+ if (argc == 11)
+ {
+ g_boxing = atoi(argv[10]);
+ }
+ }
+ }
+ else if (strcmp(argv[1],"--merge") == 0)
+ {
+ if (argc < 7)
+ {
+ g_usage = MULTIPR_USAGE_UNKNOWN;
+ g_errorCode = MULTIPR_APP_WRONG_NUMBER_OF_ARGUMENTS;
+ }
+ else
+ {
+ g_usage = MULTIPR_USAGE_MERGE;
+ for (int i = 2 ; i < argc-3 ; i++)
+ {
+ g_medFilenameSrc.push_back(argv[i]);
+ }
+ g_meshName = argv[argc-3];
+ g_fieldName = argv[argc-2];
+ if (strcmp(g_fieldName, "NULL") == 0) g_fieldName = NULL;
+ g_medFilenameDst = argv[argc-1];
+ }
+ }
+ else if (strcmp(argv[1],"--info") == 0)
+ {
+ if ((argc != 3) && (argc != 4))
+ {
+ g_usage = MULTIPR_USAGE_UNKNOWN;
+ g_errorCode = MULTIPR_APP_WRONG_NUMBER_OF_ARGUMENTS;
+ }
+ else
+ {
+ g_usage = MULTIPR_USAGE_INFO;
+ g_medFilename = argv[2];
+
+ if (argc == 4)
+ {
+ g_meshName = argv[3];
+ }
+ }
+ }
+ else
+ {
+ g_usage = MULTIPR_USAGE_UNKNOWN;
+ g_errorCode = MULTIPR_APP_UNKNOWN_USAGE;
+ }
+}
+
+
+/**
+ * \fn int runAutotest()
+ * \brief performs some unit tests on the MULTIPR API.
+ * \return MULTIPR_APP_OK if successful, MULTIPR_APP_FAILED if failure.
+ */
+int runAutotest()
+{
+ cout << "Start autotest..." << endl;
+
+ multipr::Obj multiprObj;
+ multiprObj.create("/data/apo/agregat100grains_12pas.med");
+
+ cout << "Start autotest..." << endl;
+
+ int ret = MULTIPR_APP_OK;
+ try
+ {
+ string strMEDfilename = g_medFilename;
+ strMEDfilename += "/agregat100grains_12pas.med";
+
+ cout << "Test file: " << strMEDfilename << endl << endl;
+
+ //---------------------------------------------------------------------
+ // Test partionneDomaine() = extract groups from a sequential MED file
+ //---------------------------------------------------------------------
+ multipr::partitionneDomaine(strMEDfilename.c_str(), "MAIL");
+
+ //---------------------------------------------------------------------
+ // Test partitionneGrain() = split a group from a distributed MED file
+ // using MEDSPLITTER (METIS)
+ //---------------------------------------------------------------------
+ string strDistributedMEDfilename = g_medFilename;
+ strDistributedMEDfilename += "/agregat100grains_12pas_grains_maitre.med";
+
+ multipr::partitionneGrain(
+ strDistributedMEDfilename.c_str(),
+ "MAIL_1",
+ 4,
+ multipr::MULTIPR_SCOTCH);
+
+ multipr::partitionneGrain(
+ strDistributedMEDfilename.c_str(),
+ "MAIL_97",
+ 3,
+ multipr::MULTIPR_METIS);
+
+ //---------------------------------------------------------------------
+ // Test decimePartition() = generate 2 lower resolution of a mesh
+ // using decimation based on gradient
+ //---------------------------------------------------------------------
+ multipr::decimePartition(
+ strDistributedMEDfilename.c_str(),
+ "MAIL_98",
+ "SIG_____SIEF_ELGA_______________",
+ 12,
+ "Filtre_GradientMoyen",
+ 10.0,
+ 25.0,
+ 0.3,
+ 100);
+
+ multipr::decimePartition(
+ strDistributedMEDfilename.c_str(),
+ "MAIL_92",
+ "SIG_____SIEF_ELGA_______________",
+ 11,
+ "Filtre_GradientMoyen",
+ 10.0,
+ 25.0,
+ 0.5,
+ 10);
+
+ multipr::decimePartition(
+ strDistributedMEDfilename.c_str(),
+ "MAIL_97_2",
+ "SIG_____SIEF_ELGA_______________",
+ 10,
+ "Filtre_GradientMoyen",
+ 10.0,
+ 25.0,
+ 0.4,
+ 20);
+
+ //---------------------------------------------------------------------
+ // Test passed: OK!
+ //---------------------------------------------------------------------
+ cout << endl;
+ cout << "Test passed: everything seems to be OK" << endl;
+ cout << "OK" << endl << endl;
+
+ }
+ catch (multipr::RuntimeException& e)
+ {
+ e.dump(cout);
+ cout << endl;
+ cout << "Test failed" << endl;
+ cout << "Failure" << endl << endl;
+ ret = MULTIPR_APP_FAILED;
+ }
+
+ return ret;
+}
+
+
+/**
+ * \fn void runPartition1()
+ * \brief builds a distributed MED file (v2.3) by extracting groups from a sequential MED file.
+ * \return MULTIPR_APP_OK if successful, MULTIPR_APP_FAILED if failure.
+ */
+int runPartition1()
+{
+ int ret = MULTIPR_APP_OK;
+ try
+ {
+ multipr::partitionneDomaine(g_medFilename, g_meshName);
+ }
+ catch (multipr::RuntimeException& e)
+ {
+ e.dump(cout);
+ ret = MULTIPR_APP_FAILED;
+ }
+
+ return ret;
+}
+
+
+/**
+ * \fn void runPartition2()
+ * \brief builds a distributed MED file (v2.3) by splitting a part of a distributed MED file generated by runPartition1().
+ * \return MULTIPR_APP_OK if successful, MULTIPR_APP_FAILED if failure.
+ */
+int runPartition2()
+{
+ int ret = MULTIPR_APP_OK;
+ try
+ {
+ multipr::partitionneGrain(
+ g_medFilename,
+ g_partName,
+ g_nbParts,
+ g_splitter);
+ }
+ catch (multipr::RuntimeException& e)
+ {
+ e.dump(cout);
+ ret = MULTIPR_APP_FAILED;
+ }
+
+ return ret;
+}
+
+
+/**
+ * \fn int runDecimation()
+ * \brief creates 3 resolutions of a part of a distributed MED file.
+ * \return MULTIPR_APP_OK if successful, MULTIPR_APP_FAILED if failure.
+ */
+int runDecimation()
+{
+ int ret = MULTIPR_APP_OK;
+ try
+ {
+ multipr::decimePartition(
+ g_medFilename,
+ g_partName,
+ g_fieldName,
+ g_fieldTimeStepIt,
+ g_filterName,
+ g_decimThresholdMed,
+ g_decimThresholdLow,
+ g_decimRadius,
+ g_boxing);
+ }
+ catch (multipr::RuntimeException& e)
+ {
+ e.dump(cout);
+ ret = MULTIPR_APP_FAILED;
+ }
+
+ return ret;
+}
+
+
+/**
+ * \fn int runMerge()
+ * \brief merges two sequential MED file if possible.
+ * \return MULTIPR_APP_OK if successful, MULTIPR_APP_FAILED if failure.
+ */
+int runMerge()
+{
+ int ret = MULTIPR_APP_OK;
+ try
+ {
+ multipr::merge(
+ g_medFilenameSrc,
+ g_meshName,
+ g_fieldName,
+ g_medFilenameDst);
+ }
+ catch (multipr::RuntimeException& e)
+ {
+ e.dump(cout);
+ ret = MULTIPR_APP_FAILED;
+ }
+
+ return ret;
+}
+
+
+/**
+ * \fn int runDumpMED()
+ * \brief dumps info about a sequential MED file.
+ * \return MULTIPR_APP_OK if successful, MULTIPR_APP_FAILED if failure.
+ */
+int runDumpMED()
+{
+#ifdef MULTIPR_USE_OBJ_API
+ int ret = MULTIPR_APP_OK;
+ try
+ {
+ // if mesh is unknown, then list all the meshes in the given MED file
+ if (g_meshName == NULL)
+ {
+ multipr::Obj obj;
+ obj.create(g_medFilename);
+
+ {
+ // display list of meshes contained in the MED file
+ vector<string> res = obj.getMeshes();
+ cout << "List of meshes in this MED file:" << endl;
+ for (unsigned i = 0 ; i < res.size() ; i++)
+ {
+ cout << "Mesh " << (i + 1) << ": \"" << res[i] << "\"" << endl;
+ }
+ }
+
+ cout << endl;
+
+ {
+ // display list of fields contained in the MED file
+ vector<string> names = obj.getFields();
+ cout << "List of scalar fields in this MED file:" << endl;
+ for (unsigned i = 0 ; i < names.size() ; i++)
+ {
+ cout << "Field " << (i + 1) << ": \"" << names[i] << "\" #Time stamps=" << obj.getTimeStamps(names[i].c_str()) << endl;
+ }
+ }
+ }
+ else
+ {
+ // display all infos about one mesh in a MED file
+ multipr::Mesh mesh;
+ mesh.readSequentialMED(g_medFilename, g_meshName);
+ mesh.setPrintAll(true);
+ cout << mesh << endl;
+ }
+ cout << "OK" << endl;
+ }
+ catch (multipr::RuntimeException& e)
+ {
+ e.dump(cout);
+ ret = MULTIPR_APP_FAILED;
+ }
+
+ return ret;
+#else
+ int ret = MULTIPR_APP_OK;
+ try
+ {
+ // if mesh is unknown, then list all the meshes in the given MED file
+ if (g_meshName == NULL)
+ {
+ {
+ // display list of meshes contained in the MED file
+ vector<string> res = multipr::getListMeshes(g_medFilename);
+ cout << "List of meshes in this MED file:" << endl;
+ for (unsigned i = 0 ; i < res.size() ; i++)
+ {
+ cout << "Mesh " << (i + 1) << ": \"" << res[i] << "\"" << endl;
+ }
+ }
+
+ cout << endl;
+
+ {
+ // display list of fields contained in the MED file
+ vector<pair<string,int> > res = multipr::getListScalarFields(g_medFilename);
+ cout << "List of scalar fields in this MED file:" << endl;
+ for (unsigned i = 0 ; i < res.size() ; i++)
+ {
+ cout << "Field " << (i + 1) << ": \"" << res[i].first << "\" #Time stamps=" << res[i].second << endl;
+ }
+ }
+ }
+ else
+ {
+ // display all infos about one mesh in a MED file
+ multipr::Mesh mesh;
+ mesh.readSequentialMED(g_medFilename, g_meshName);
+ mesh.setPrintAll(true);
+ cout << mesh << endl;
+ }
+ cout << "OK" << endl;
+ }
+ catch (multipr::RuntimeException& e)
+ {
+ e.dump(cout);
+ ret = MULTIPR_APP_FAILED;
+ }
+
+ return ret;
+#endif
+}
+
+
+/**
+ * \fn int run()
+ * \brief applies partitioning/decimation according to global parameters.
+ * \return MULTIPR_APP_OK if successful, MULTIPR_APP_FAILED if failure.
+ */
+int run()
+{
+ printGlobals();
+
+ int ret = MULTIPR_APP_OK;
+ switch (g_usage)
+ {
+ case MULTIPR_USAGE_AUTOTEST: ret = runAutotest(); break;
+ case MULTIPR_USAGE_PARTITION1: ret = runPartition1(); break;
+ case MULTIPR_USAGE_PARTITION2: ret = runPartition2(); break;
+ case MULTIPR_USAGE_DECIMATION: ret = runDecimation(); break;
+ case MULTIPR_USAGE_MERGE: ret = runMerge(); break;
+ case MULTIPR_USAGE_INFO: ret = runDumpMED(); break;
+ default:
+ cout << "ERROR: unknown usage" << endl;
+ ret = MULTIPR_APP_FAILED;
+ break;
+ }
+
+ return ret;
+}
+
+
+/**
+ * \fn int main(int argc, char** argv)
+ * \brief entry point of the application.
+ * \param argc number of arguments.
+ * \param argv list of arguments.
+ * \return 0 if OK, 1 if failed.
+ */
+int main(int argc, char** argv)
+{
+ string strTitle = string("multipr v") + string(multipr::getVersion()) + string(" - by EDF/CS - 04/2007");
+ string strUnderline = "";
+
+ for (int i = 0, len = strTitle.length() ; i < len ; i++) strUnderline += '=';
+
+ cout << strTitle << endl;
+ cout << strUnderline << endl;
+
+ #ifdef MULTIPR_USE_OBJ_API
+ cout << "Version MULTIPR_Obj" << endl;
+ #else
+ cout << "Version MULTIPR_API" << endl;
+ #endif
+
+ parseCommandLine(argc, argv);
+
+ int ret = MULTIPR_APP_OK; // assume no error at the beginning
+
+ if (g_usage == MULTIPR_USAGE_UNKNOWN)
+ {
+ if (argc != 1)
+ {
+ // if usage is unknown and there are some arguments, print an error message
+ cout << "ERROR: " << getErrorMsg() << endl;
+ cout << endl;
+ ret = MULTIPR_APP_FAILED;
+ }
+ else
+ {
+ // if no argument, print a description of this application
+ printDescription();
+ }
+
+ printUsage();
+ }
+ else if (g_usage == MULTIPR_USAGE_DISPLAY_HELP)
+ {
+ printDescription();
+ printUsage();
+ }
+ else
+ {
+ // the application seems to be configured properly: it can be executed
+ ret = run();
+ }
+
+ return ret;
+}
+
+// EOF
@COMMENCE@
-SUBDIRS = CONVERTOR PIPELINE OBJECT VVTK GUITOOLS VISU_I VISUGUI VISU_SWIG ENGINE
+SUBDIRS = MULTIPR CONVERTOR PIPELINE OBJECT VVTK GUITOOLS VISU_I VISUGUI VISU_SWIG ENGINE
@MODULE@
VISU_GaussPtsActorFactory.h \
VISU_Event.h \
VISU_Actor.h \
+ VISU_DataSetActor.h \
VISU_MeshAct.h \
VISU_ScalarMapAct.h \
VISU_GaussPtsAct.h \
LIB = libVisuObject.la
LIB_SRC = \
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
#include "VISU_BoostSignals.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
#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();
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"
namespace SVTK
}
}
-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 <vtkRenderer.h>
#include <vtkProperty.h>
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_ScalarMapAct);
+//----------------------------------------------------------------------------
VISU_ScalarMapAct
::VISU_ScalarMapAct()
{
myProperty->DeepCopy(aProperty);
}
+//----------------------------------------------------------------------------
VISU_ScalarMapAct
::~VISU_ScalarMapAct()
{
myScalarBar->Delete();
}
+//----------------------------------------------------------------------------
+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 (aProperty->GetAmbient() == 0 && aProperty->GetDiffuse() == 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
AddToRender(vtkRenderer* theRenderer);
bool
IsShading();
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
protected:
VISU_ScalarMapAct();
bool myBarVisibility;
::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
@COMMENCE@
EXPORT_HEADERS = \
+ VISU_MapperHolder.hxx \
+ VISU_DataSetMapperHolder.hxx \
+ VISU_PolyDataMapperHolder.hxx \
+ VISU_PointSpriteMapperHolder.hxx \
VISU_PipeLine.hxx \
+ VISU_ColoredPL.hxx \
+ VISU_UnstructuredGridPL.hxx \
+ VISU_ScalarMapPL.hxx \
+ VISU_DeformedShapePL.hxx \
+ VISU_GaussPointsPL.hxx \
VISU_PipeLineUtils.hxx \
VISU_MeshPL.hxx \
- VISU_ScalarMapPL.hxx \
VISU_CutPlanesPL.hxx \
VISU_CutLinesPL.hxx \
VISU_IsoSurfacesPL.hxx \
- VISU_DeformedShapePL.hxx \
VISU_VectorsPL.hxx \
VISU_StreamLinesPL.hxx \
+ VISU_Plot3DPL.hxx \
+ VISU_ScalarMapOnDeformedShapePL.hxx \
VISU_LookupTable.hxx \
VISU_ScalarBarActor.hxx \
VISU_Extractor.hxx \
VISU_FieldTransform.hxx \
VISU_UsedPointsFilter.hxx \
- VISU_GaussPointsPL.hxx \
- VISU_Plot3DPL.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_WidgetCtrl.hxx
# Libraries targets
-
LIB = libVisuPipeLine.la
LIB_SRC = \
+ VISU_MapperHolder.cxx \
+ VISU_DataSetMapperHolder.cxx \
+ VISU_PolyDataMapperHolder.cxx \
+ VISU_PointSpriteMapperHolder.cxx \
+ VISU_Extractor.cxx \
VISU_PipeLine.cxx \
- VISU_PipeLineUtils.cxx \
- VISU_MeshPL.cxx \
+ VISU_ColoredPL.cxx \
+ VISU_UnstructuredGridPL.cxx \
VISU_ScalarMapPL.cxx \
+ VISU_DeformedShapePL.cxx \
+ VISU_GaussPointsPL.cxx \
+ VISU_MeshPL.cxx \
VISU_CutPlanesPL.cxx \
VISU_CutLinesPL.cxx \
VISU_IsoSurfacesPL.cxx \
- VISU_DeformedShapePL.cxx \
VISU_VectorsPL.cxx \
VISU_StreamLinesPL.cxx \
+ VISU_Plot3DPL.cxx \
+ VISU_ScalarMapOnDeformedShapePL.cxx \
VISU_LookupTable.cxx \
VISU_ScalarBarActor.cxx \
- VISU_Extractor.cxx \
VISU_FieldTransform.cxx \
VISU_UsedPointsFilter.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_PipeLineUtils.cxx
# Executables targets
#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;
}
//
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){
+
+ if(myIsDoneShallowCopy)
GetOutput()->ShallowCopy(GetInput());
- Modified();
- return;
- }
-
- Execute2();
+ else
+ Execute2();
}
+
+//----------------------------------------------------------------------------
void
SALOME_ExtractGeometry
::Execute2()
#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);
private:
bool myStoreMapping;
bool myIsDoneShallowCopy;
+
typedef std::vector<vtkIdType> TVectorId;
TVectorId myElemVTK2ObjIds;
TVectorId myNodeVTK2ObjIds;
// Author: Alexey PETROV
// Module : VISU
-#include "VISU_Convertor.hxx"
#include "VISU_MeshPL.hxx"
#include "VISU_ScalarMapPL.hxx"
#include "VISU_IsoSurfacesPL.hxx"
#include "VISU_StreamLinesPL.hxx"
#include "VISU_GaussPointsPL.hxx"
#include "VISU_Plot3DPL.hxx"
+#include "VISU_ScalarBarActor.hxx"
+
+#include "VISU_Convertor.hxx"
typedef VISU_GaussPointsPL TPresent;
static int isOnlyMesh = false;
-int main(int argc, char** argv){
+//#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);
+
+
+//----------------------------------------------------------------------------
+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);
+ return aPresent;
+}
+
+
+//----------------------------------------------------------------------------
+int
+main(int argc, char** argv)
+{
try{
if(argc > 1){
vtkRenderWindow *renWin = vtkRenderWindow::New();
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());
if(aValFieldIter == aValField.end()) return 0;
int aTimeStamp = aValFieldIter->first;
- TPresent* aPresent = TPresent::New();
- VISU::PIDMapper anIDMapper;
+ VISU_ColoredPL* aPresent = NULL;
if(anEntity != VISU::NODE_ENTITY){
- VISU::PGaussPtsIDMapper aGaussPtsIDMapper = aConvertor->GetTimeStampOnGaussPts(aMeshName,anEntity,aFieldName,aTimeStamp);
- aPresent->SetGaussPtsIDMapper(aGaussPtsIDMapper);
+ aPresent = CreateColoredPL<TPresent>(aConvertor,
+ aMeshName,
+ anEntity,
+ aFieldName,
+ aTimeStamp);
}else{
continue;
- VISU::PIDMapper anIDMapper = aConvertor->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
- aPresent->SetIDMapper(anIDMapper);
+ aPresent = CreateColoredPL<TPresent>(aConvertor,
+ aMeshName,
+ anEntity,
+ aFieldName,
+ aTimeStamp);
}
- 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;
-
- vtkSmartPointer<vtkImageData> aTextureValue = VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture );
- aPresent->SetImageData( aTextureValue.GetPointer() );
-
- aPresent->Update();
-
vtkActor* anActor = vtkActor::New();
anActor->SetMapper(aPresent->GetMapper());
#include <vtkAppendPolyData.h>
-using namespace std;
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_CutLinesPL);
+
+//----------------------------------------------------------------------------
VISU_CutLinesPL
::VISU_CutLinesPL()
{
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];
+ GetClippedInput()->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];
+ GetClippedInput()->GetBounds(aBaseBounds);
+
+ vtkFloatingPointType aDir[2][3];
+ GetDir(aDir[0],
+ myAng[0],
+ myBasePlane[0]);
+
+ vtkUnstructuredGrid* aGrid = GetFieldTransformFilter()->GetUnstructuredGridOutput();
+ CutWithPlanes(anAppendPolyData,
+ aGrid,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 = aGrid;
+
+ 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]);
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_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_CutLinesPL : public VISU_CutPlanesPL{
-protected:
- VISU_CutLinesPL();
- VISU_CutLinesPL(const VISU_CutLinesPL&);
+
+//----------------------------------------------------------------------------
+class 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 <vtkCutter.h>
#include <vtkPlane.h>
-using namespace std;
-
static vtkFloatingPointType EPS = 1.0E-3;
+
+//----------------------------------------------------------------------------
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));
}
- VISU_ScalarMapPL::ShallowCopy(thePipeLine);
}
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::Init()
{
- VISU_ScalarMapPL::Init();
+ Superclass::Init();
SetNbParts(10);
myBasePlane[0] = YZ;
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]);
+ GetClippedInput()->GetBounds(aBounds);
+
+ vtkDataSet* aDataSet = GetFieldTransformFilter()->GetUnstructuredGridOutput();
+ CutWithPlanes(myAppendPolyData,
+ aDataSet,
+ myNbParts,
+ aDir,
+ aBounds,
+ myPartPosition,
+ myPartCondition,
+ myDisplacement[0]);
+
+ Superclass::Update();
+}
+
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_CutPlanesPL
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
- VISU_ScalarMapPL::Update();
+ if(vtkDataSet* aDataSet = myAppendPolyData->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ int anEnd = myAppendPolyData->GetNumberOfInputs();
+ 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->RemoveInput(theAppendPolyData->GetInput(i));
}
+
+//----------------------------------------------------------------------------
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
+::SetDisplacement(vtkFloatingPointType theDisp,
+ int theNum)
+{
+ myDisplacement[theNum] = theDisp;
+ Modified();
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_CutPlanesPL
::SetNbParts(int theNb)
{
myNbParts = theNb;
myPartPosition.resize(myNbParts);
- myPartCondition.resize(myNbParts,1);
+ 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){
+ GetClippedInput()->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();
}
+
+
+//----------------------------------------------------------------------------
class vtkAppendPolyData;
-class VISU_CutPlanesPL : public VISU_ScalarMapPL{
-protected:
- VISU_CutPlanesPL();
- VISU_CutPlanesPL(const VISU_CutPlanesPL&);
+
+//----------------------------------------------------------------------------
+class VISU_CutPlanesPL : public VISU_ScalarMapPL
+{
public:
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
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);
#include <vtkWarpVector.h>
+
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_DeformedShapePL);
+
+//----------------------------------------------------------------------------
VISU_DeformedShapePL
-::VISU_DeformedShapePL()
+::VISU_DeformedShapePL():
+ myScaleFactor(0.0)
{
myWarpVector = vtkWarpVector::New();
myCellDataToPointData = vtkCellDataToPointData::New();
}
+
+//----------------------------------------------------------------------------
VISU_DeformedShapePL
::~VISU_DeformedShapePL()
{
- myWarpVector->UnRegisterAllOutputs();
myWarpVector->Delete();
- 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());
}
- VISU_ScalarMapPL::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));
}
+//----------------------------------------------------------------------------
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()
{
- VISU_ScalarMapPL::Init();
+ Superclass::Init();
+
vtkFloatingPointType aScalarRange[2];
GetSourceRange(aScalarRange);
- vtkDataSet* aDataSet = GetInput2();
+ vtkDataSet* aDataSet = GetClippedInput();
vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet );
static double EPS = 1.0 / VTK_LARGE_FLOAT;
SetScale(0.0);
}
-VISU_ScalarMapPL::THook*
+
+//----------------------------------------------------------------------------
+vtkDataSet*
VISU_DeformedShapePL
-::DoHook()
+::InsertCustomPL()
{
- VISU::CellDataToPoint(myWarpVector,myCellDataToPointData,GetInput2(),myFieldTransform);
+ VISU::CellDataToPoint(myWarpVector,
+ myCellDataToPointData,
+ GetClippedInput(),
+ GetFieldTransformFilter());
return myWarpVector->GetOutput();
}
-void
+
+//----------------------------------------------------------------------------
+unsigned long int
VISU_DeformedShapePL
-::Update()
+::GetMemorySize()
{
- VISU_ScalarMapPL::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)
{
- VISU_ScalarMapPL::SetMapScale(theMapScale);
+ Superclass::SetMapScale(theMapScale);
myWarpVector->SetScaleFactor(myScaleFactor*theMapScale);
- Modified();
}
+
+
+//----------------------------------------------------------------------------
class VISU_DeformedShapePL : public VISU_ScalarMapPL
{
-protected:
- VISU_DeformedShapePL();
- VISU_DeformedShapePL(const VISU_DeformedShapePL&);
-
- virtual
- ~VISU_DeformedShapePL();
-
public:
vtkTypeMacro(VISU_DeformedShapePL,VISU_ScalarMapPL);
VISU_DeformedShapePL*
New();
- virtual
- void
- ShallowCopy(VISU_PipeLine *thePipeLine);
-
virtual
void
SetScale(vtkFloatingPointType theScale);
void
Init();
+ //! Gets memory size used by the instance (bytes).
virtual
- void
- Update();
+ unsigned long int
+ GetMemorySize();
virtual
void
GetScaleFactor(vtkDataSet* theDataSet);
protected:
+ VISU_DeformedShapePL();
+ VISU_DeformedShapePL(const VISU_DeformedShapePL&);
+
+ virtual
+ ~VISU_DeformedShapePL();
+
virtual
- THook*
- DoHook();
+ 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>
-using namespace std;
-
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_Extractor);
-VISU_Extractor::VISU_Extractor()
+//----------------------------------------------------------------------------
+VISU_Extractor
+::VISU_Extractor()
{
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> void
-execute(int theNbElems,
- int theScalarMode,
- TypeData* theInputData,
- TypeData* theOutputData)
+//----------------------------------------------------------------------------
+int
+VISU_Extractor
+::GetScalarMode()
+{
+ 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++;
+ }
+}
+
+
+//----------------------------------------------------------------------------
+template<typename TDataSetAttributesType> void
+ExecuteScalars(vtkIdType theNbOfTuples,
+ vtkIdType theScalarMode,
+ TDataSetAttributesType* theInputData,
+ TDataSetAttributesType* theOutputData)
{
- if(theNbElems < 1 )
+ if(theNbOfTuples < 1)
return;
+
vtkDataArray* aFieldArray = theInputData->GetArray("VISU_FIELD");
- 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]);
- }
+ 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{
+ switch(anInputDataType){
+ vtkTemplateMacro5(Component2Scalars,
+ aFieldArray,
+ (VTK_TT *)(anInputPtr),
+ (VTK_TT *)(anOutputPtr),
+ theNbOfTuples,
+ theScalarMode - 1);
+ default:
+ break;
}
- theOutputData->SetScalars(aScalars);
- aScalars->Delete();
}
+
+ theOutputData->SetScalars(anOutputScalars);
+ anOutputScalars->Delete();
}
-void VISU_Extractor::Execute(){
+
+//----------------------------------------------------------------------------
+void
+VISU_Extractor
+::Execute()
+{
vtkDataSet *input = this->GetInput(), *output = this->GetOutput();
output->CopyStructure(input);
output->GetPointData()->CopyAllOff();
output->GetCellData()->CopyAllOff();
if(input->GetPointData()->GetNumberOfArrays()){
output->GetPointData()->CopyVectorsOn();
- int aNbElems = input->GetNumberOfPoints();
+ vtkIdType aNbOfTuples = input->GetNumberOfPoints();
vtkPointData *inData = input->GetPointData(), *outData = output->GetPointData();
if(inData->GetAttribute(vtkDataSetAttributes::VECTORS))
- execute(aNbElems,myScalarMode,inData,outData);
+ ExecuteScalars(aNbOfTuples, myScalarMode, inData, outData);
else
output->GetPointData()->CopyScalarsOn();
outData->PassData(inData);
outData->AddArray(inData->GetArray("VISU_FIELD"));
}else{
output->GetCellData()->CopyVectorsOn();
- int aNbElems = input->GetNumberOfCells();
+ vtkIdType aNbOfTuples = input->GetNumberOfCells();
vtkCellData *inData = input->GetCellData(), *outData = output->GetCellData();
if(inData->GetAttribute(vtkDataSetAttributes::VECTORS))
- execute(aNbElems,myScalarMode,inData,outData);
+ ExecuteScalars(aNbOfTuples, myScalarMode, inData, outData);
else
output->GetCellData()->CopyScalarsOn();
outData->PassData(inData);
#ifndef VISU_Extractor_HeaderFile
#define VISU_Extractor_HeaderFile
-#include <vtkPointSetToPointSetFilter.h>
+#include <vtkDataSetToDataSetFilter.h>
-class VTK_EXPORT VISU_Extractor : public vtkPointSetToPointSetFilter{
+
+//----------------------------------------------------------------------------
+class VTK_EXPORT VISU_Extractor : public vtkDataSetToDataSetFilter
+{
public:
- vtkTypeMacro(VISU_Extractor,vtkPointSetToPointSetFilter);
- static VISU_Extractor *New();
+ vtkTypeMacro(VISU_Extractor, vtkDataSetToDataSetFilter);
+
+ 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();
- virtual void Execute();
+ virtual
+ void
+ Execute();
int myScalarMode;
};
#include "VTKViewer_Transform.h"
#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()
{
}
+//----------------------------------------------------------------------------
void
VISU_FieldTransform
::Update()
{
- vtkSource::Update();
+ Superclass::Update();
}
+//----------------------------------------------------------------------------
unsigned long
VISU_FieldTransform
::GetMTime()
{
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])
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 TValueType>
+void
+NonLinearTransformVectors(vtkDataArray *theInputVectors,
+ TValueType* theInputPtr,
+ TValueType* theOutputPtr,
+ vtkIdType theNbOfTuples,
+ vtkFloatingPointType theScale[3],
+ VISU_FieldTransform::TTransformFun theFunction,
+ vtkFloatingPointType theModifiedScalarMin,
+ vtkFloatingPointType theModifiedScalarDelta,
+ vtkFloatingPointType theSourceScalarMax)
+{
+ 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 TypeData> void
-ExecVectors(VISU_FieldTransform::TTransformFun theFunction,
- VTKViewer_Transform* theTransform,
- vtkFloatingPointType theScalarRange[2],
- int theNbOfTuples,
- TypeData* theInputData,
- TypeData* theOutputData)
+//----------------------------------------------------------------------------
+template<typename TDataSetAttributesType>
+void
+ExecuteVectors(VISU_FieldTransform::TTransformFun theFunction,
+ VTKViewer_Transform* theTransform,
+ vtkFloatingPointType theScalarRange[2],
+ vtkIdType theNbOfTuples,
+ TDataSetAttributesType* theInputData,
+ TDataSetAttributesType* theOutputData)
{
- vtkDataArray *anInVectors = theInputData->GetVectors();
- if ( !anInVectors || theNbOfTuples < 1 )
+ 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();
}
+
+//----------------------------------------------------------------------------
+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();
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_FieldTransform
::Execute()
output->GetPointData()->CopyAllOff();
output->GetCellData()->CopyAllOff();
- ExecScalars(myFunction,myScalarRange,input->GetNumberOfPoints(),input->GetPointData(),output->GetPointData());
- ExecVectors(myFunction,myTransform,myScalarRange,input->GetNumberOfPoints(),input->GetPointData(),output->GetPointData());
-
- ExecScalars(myFunction,myScalarRange,input->GetNumberOfCells(),input->GetCellData(),output->GetCellData());
- ExecVectors(myFunction,myTransform,myScalarRange,input->GetNumberOfCells(),input->GetCellData(),output->GetCellData());
+ 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();
output->GetCellData()->PassData(input->GetCellData());
}
}
+
+
+//----------------------------------------------------------------------------
vtkTypeMacro(VISU_FieldTransform,vtkDataSetToDataSetFilter);
static VISU_FieldTransform *New();
- virtual void Update();
- virtual unsigned long GetMTime();
+ virtual
+ void
+ Update();
+
+ 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);
+
+ 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);
+ vtkFloatingPointType*
+ GetScalarRange()
+ {
+ return myScalarRange;
+ }
+
+ void
+ SetScalarRange(vtkFloatingPointType theScalarRange[2]);
+
+ void
+ SetScalarMin(vtkFloatingPointType theValue);
+
+ void
+ SetScalarMax(vtkFloatingPointType theValue);
protected:
VISU_FieldTransform();
- virtual ~VISU_FieldTransform();
+
+ virtual
+ ~VISU_FieldTransform();
+
VISU_FieldTransform(const VISU_FieldTransform&) {};
void operator=(const VISU_FieldTransform&) {};
- void Execute();
+
+ virtual
+ void
+ Execute();
VTKViewer_Transform *myTransform;
TTransformFun myFunction;
#include "VISU_GaussPointsPL.hxx"
-#include "VISU_DeformedShapePL.hxx"
-#include "VISU_PipeLineUtils.hxx"
-#include "SALOME_ExtractGeometry.h"
-#include "VISU_DeformedShapePL.hxx"
+#include "VISU_PointSpriteMapperHolder.hxx"
#include "VISU_OpenGLPointSpriteMapper.hxx"
#include "VTKViewer_PassThroughFilter.h"
+#include "VISU_DeformedShapePL.hxx"
+#include "VISU_LookupTable.hxx"
+
+#include "VISU_PipeLineUtils.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();
-
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(VTKViewer_PassThroughFilter::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
-CopyGlyph( vtkGlyph3D* source, vtkGlyph3D* dest )
+VISU_GaussPointsPL
+::SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theIDMapper)
+{
+ GetPointSpriteMapperHolder()->SetGaussPtsIDMapper(theIDMapper);
+}
+
+
+//----------------------------------------------------------------------------
+const VISU::PGaussPtsIDMapper&
+VISU_GaussPointsPL
+::GetGaussPtsIDMapper()
{
- dest->SetRange( source->GetRange() );
- dest->SetScaling( source->GetScaling() );
- dest->SetClamping( source->GetClamping() );
- dest->SetScaleMode( source->GetScaleMode() );
- dest->SetColorMode( source->GetColorMode() );
- dest->SetScaleFactor( source->GetScaleFactor() );
+ 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* theSource, vtkGlyph3D* theDestination )
+{
+ 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
-{
- return myGaussPtsIDMapper->GetObjID(theID);
-}
-
-vtkFloatingPointType*
-VISU_GaussPointsPL
-::GetNodeCoord(int theObjID)
-{
- vtkIdType anID = GetNodeVTKID(theObjID);
- vtkDataSet* aDataSet = myGeomFilter->GetInput();
- return aDataSet->GetPoint(anID);
-}
-
-void
-VISU_GaussPointsPL
-::SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper)
-{
- myGaussPtsIDMapper = theGaussPtsIDMapper;
- SetIDMapper(myGaussPtsIDMapper);
-}
-
-const VISU::PGaussPtsIDMapper&
-VISU_GaussPointsPL
-::GetGaussPtsIDMapper() const
+::GetObjID(vtkIdType theID)
{
- return myGaussPtsIDMapper;
+ return GetGaussPtsIDMapper()->GetObjID(theID);
}
-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());
-
- myPSMapper->SetPrimitiveType( thePrimitiveType );
+ myPassFilter[2]->SetInput(myPassFilter[1]->GetOutput());
- 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 );
}
#ifndef VISU_GaussPointsPL_HeaderFile
#define VISU_GaussPointsPL_HeaderFile
-#include "VISU_ScalarMapPL.hxx"
-#include "VISU_Convertor.hxx"
+#include "VISU_ColoredPL.hxx"
#include <vector>
class VTKViewer_PassThroughFilter;
class VISU_OpenGLPointSpriteMapper;
+class VISU_PointSpriteMapperHolder;
class vtkGeometryFilter;
class vtkGlyph3D;
class vtkImageData;
class vtkPointSet;
-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_GaussPointsPL : public VISU_ScalarMapPL
+class 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<VTKViewer_PassThroughFilter*> 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()
{
- myContourFilter->UnRegisterAllOutputs();
myContourFilter->Delete();
+ myContourFilter = NULL;
- 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);
}
- VISU_ScalarMapPL::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])
{
- VISU_ScalarMapPL::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()
{
- VISU_ScalarMapPL::Init();
+ Superclass::Init();
SetNbParts(10);
+
vtkFloatingPointType aScalarRange[2];
GetSourceRange(aScalarRange);
SetRange(aScalarRange);
}
-VISU_ScalarMapPL::THook*
+//----------------------------------------------------------------------------
+
+vtkDataSet*
VISU_IsoSurfacesPL
-::DoHook()
+::InsertCustomPL()
{
- VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,GetInput2(),myFieldTransform);
+ VISU::CellDataToPoint(myContourFilter,
+ myCellDataToPointData,
+ GetClippedInput(),
+ GetFieldTransformFilter());
return myContourFilter->GetOutput();
}
+//----------------------------------------------------------------------------
void
VISU_IsoSurfacesPL
::Update()
{
- VISU_ScalarMapPL::Update();
+ Superclass::Update();
+}
+
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_IsoSurfacesPL
+::GetMemorySize()
+{
+ 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)
{
- VISU_ScalarMapPL::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);
}
+
+
+//----------------------------------------------------------------------------
class vtkContourFilter;
class vtkCellDataToPointData;
+
+//----------------------------------------------------------------------------
class VISU_IsoSurfacesPL : public VISU_ScalarMapPL
{
-protected:
- VISU_IsoSurfacesPL();
- VISU_IsoSurfacesPL(const VISU_IsoSurfacesPL&);
-
- virtual
- ~VISU_IsoSurfacesPL();
-
public:
- vtkTypeMacro(VISU_IsoSurfacesPL,VISU_ScalarMapPL);
+ 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
void
Update();
+ //! 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;
//
//
//
-// 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(GetInput());
}
+
+
+//----------------------------------------------------------------------------
// 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
#define VISU_MeshPL_HeaderFile
#include "VISU_PipeLine.hxx"
+#include "VISU_UnstructuredGridPL.hxx"
-class VISU_MeshPL : public VISU_PipeLine{
+
+//----------------------------------------------------------------------------
+class 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>
#include <cmath>
#include <string>
+//#define _DEBUG_RENDERING_PERFORMANCE_
+
#ifndef GLX_GLXEXT_LEGACY
#define GLX_GLXEXT_LEGACY
#endif
};
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(false)
{
if(MYDEBUG) MESSAGE("VISU_PipeLine::VISU_PipeLine - "<<this);
- SetDebug(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();
+ return GetMapperHolder()->GetMapper();
+}
- myExtractGeometry->SetInput(theInput);
- myInput = theInput;
- 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
+::Init()
+{}
+
+
+//----------------------------------------------------------------------------
+void
VISU_PipeLine
-::CheckAvailableMemory(const vtkFloatingPointType& theSize)
+::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(size_t theSize)
{
- return myExtractGeometry->GetImplicitFunction();
+ if(theSize < ULONG_MAX){
+ try{
+ if(char *aCheck = new char[theSize]){
+ delete [] aCheck;
+ return theSize;
+ }
+ }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 size_t EPSILON = 2 * 1024;
+ size_t aMax = std::max(theSize, theMinSize);
+ size_t aMin = std::min(theSize, theMinSize);
+ //cout<<"GetAvailableMemory - "<<aMax<<"; "<<aMin;
+ while(CheckAvailableMemory(aMax) == 0 && CheckAvailableMemory(aMin) > 0 && (aMax - aMin) > EPSILON){
+ size_t aRoot = (aMax + aMin) / 2;
+ if(CheckAvailableMemory(aRoot))
+ aMin = aRoot;
+ else
+ aMax = aRoot;
+ }
+ //cout<<"; "<<aMax<<endl;
+ return aMax;
+}
+
+
+//----------------------------------------------------------------------------
#ifndef VISU_PipeLine_HeaderFile
#define VISU_PipeLine_HeaderFile
-#include <vector>
+#include "VISU_IDMapper.hxx"
+
#include <vtkObject.h>
#include <vtkSmartPointer.h>
-#include "VISU_IDMapper.hxx"
-
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 SALOME_ExtractGeometry;
+class VISU_MapperHolder;
-typedef VISU::TVTKOutput TInput;
+//----------------------------------------------------------------------------
+class VISU_PipeLine : public vtkObject
+{
+ friend class VISU_MapperHolder;
-class 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(size_t theSize);
+
+ static
+ size_t
+ GetAvailableMemory(size_t theSize,
+ size_t theMinSize = 1024*1024);
protected:
+ //----------------------------------------------------------------------------
VISU_PipeLine();
VISU_PipeLine(const 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 "VISU_FieldTransform.hxx"
-#include "VISU_LookupTable.hxx"
-#include "VISU_Extractor.hxx"
#include <vtkProperty.h>
#include <vtkObjectFactory.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 TEndFilter>
void
- CellDataToPoint(TItem* theTItem,
+ CellDataToPoint(TEndFilter* theEndFilter,
vtkCellDataToPointData *theFilter,
vtkDataSet* theDataSet,
VISU_FieldTransform *theFieldTransform)
if(theDataSet->GetCellData()->GetNumberOfArrays()){
theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
theFilter->PassCellDataOn();
- theTItem->SetInput(theFilter->GetUnstructuredGridOutput());
+ theEndFilter->SetInput(theFilter->GetUnstructuredGridOutput());
}else
- theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput());
+ theEndFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
}
- template<class TItem>
+
+ //----------------------------------------------------------------------------
+ template<class TEndFilter>
void
- ToCellCenters(TItem* theTItem,
+ ToCellCenters(TEndFilter* theEndFilter,
vtkCellCenters *theFilter,
vtkDataSet* theDataSet,
VISU_FieldTransform *theFieldTransform)
if(theDataSet->GetCellData()->GetNumberOfArrays()){
theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
theFilter->VertexCellsOn();
- theTItem->SetInput(theFilter->GetOutput());
+ theEndFilter->SetInput(theFilter->GetOutput());
}else
- theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput());
+ theEndFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
}
+
+
+ //----------------------------------------------------------------------------
+ //! 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() );
}
- VISU_ScalarMapPL::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()
{
- VISU_ScalarMapPL::Init();
+ Superclass::Init();
- myOrientation = GetOrientation(GetInput2());
- SetScaleFactor(GetScaleFactor(GetInput2()));
+ myOrientation = GetOrientation(GetClippedInput());
+ SetScaleFactor(GetScaleFactor(GetClippedInput()));
}
-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();
+ GetFieldTransformFilter()->GetUnstructuredGridOutput();
if ( !IsPlanarInput() )
{
myWarpScalar->SetInput(myContourFilter->GetOutput());
}
- VISU_CutPlanesPL::ClearAppendPolyData(myAppendPolyData);
+ VISU_CutPlanesPL::ClearAppendPolyData(myAppendPolyData.GetPointer());
myAppendPolyData->AddInput(myWarpScalar->GetPolyDataOutput());
if ( aCutPlane )
myWarpScalar->SetNormal(aPlaneNormal);
- VISU_ScalarMapPL::Update();
+ Superclass::Update();
}
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_Plot3DPL
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ if(vtkDataSet* aDataSet = myGeometryFilter->GetInput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(myCellDataToPointData->GetInput())
+ if(vtkDataSet* aDataSet = myCellDataToPointData->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(vtkDataSet* aDataSet = myContourFilter->GetInput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(vtkDataSet* aDataSet = myWarpScalar->GetInput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ int anEnd = myAppendPolyData->GetNumberOfInputs();
+ for(int anId = 0; anId < anEnd; anId++){
+ if(vtkDataSet* aDataSet = myAppendPolyData->GetInput(anId))
+ aSize += aDataSet->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);
+ GetClippedInput()->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)
{
- VISU_ScalarMapPL::SetMapScale(theMapScale);
+ Superclass::SetMapScale(theMapScale);
if ( myIsContour ) {
vtkFloatingPointType aRange[2];
class vtkGeometryFilter;
class vtkCellDataToPointData;
-class VISU_Plot3DPL : public VISU_ScalarMapPL{
-protected:
- VISU_Plot3DPL();
- VISU_Plot3DPL(const VISU_Plot3DPL&);
+//----------------------------------------------------------------------------
+class VISU_Plot3DPL : public VISU_ScalarMapPL
+{
public:
vtkTypeMacro(VISU_Plot3DPL,VISU_ScalarMapPL);
static VISU_Plot3DPL* New();
virtual ~VISU_Plot3DPL();
- virtual
- void
- ShallowCopy(VISU_PipeLine *thePipeLine);
-
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
// Module : VISU
#include "VISU_ScalarMapOnDeformedShapePL.hxx"
+#include "VISU_Extractor.hxx"
+#include "VISU_LookupTable.hxx"
#include "VISU_DeformedShapePL.hxx"
-#include "VISU_PipeLineUtils.hxx"
#include "VTKViewer_TransformFilter.h"
#include "VTKViewer_Transform.h"
+#include "VISU_PipeLineUtils.hxx"
+
#include <vtkWarpVector.h>
#include <vtkMergeFilter.h>
#include <vtkUnstructuredGrid.h>
#include <vtkCellDataToPointData.h>
#include <vtkPointDataToCellData.h>
-#include <VISU_Convertor.hxx>
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_ScalarMapOnDeformedShapePL)
+//----------------------------------------------------------------------------
/*!
* Constructor. Creating new instances of vtkWarpVector,vtkMergeFilter,vtkUnstructuredGrid
* Where:
myCellDataToPointData = vtkCellDataToPointData::New();
}
+//----------------------------------------------------------------------------
/*!
* Destructor.
* Delete all fields.
myCellDataToPointData->Delete();
}
+//----------------------------------------------------------------------------
/*!
* Initial method
*/
VISU_ScalarMapOnDeformedShapePL
::Init()
{
- if (GetScalars() == NULL) SetScalars(GetInput2());
+ if(GetScalars() == NULL)
+ SetScalars(GetClippedInput());
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]);
+ SetScale(VISU_DeformedShapePL::GetScaleFactor(GetClippedInput()) / aScalarRange[1]);
else
SetScale(0.0);
- myMapper->SetColorModeToMapScalars();
- myMapper->ScalarVisibilityOn();
-
- // Sets input for field transformation filter
- myFieldTransform->SetInput(myExtractor->GetOutput());
-
+ GetMapper()->SetColorModeToMapScalars();
+ GetMapper()->ScalarVisibilityOn();
}
+//----------------------------------------------------------------------------
/*!
* 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);
+ VISU::CellDataToPoint(myDeformVectors,
+ myCellDataToPointData,
+ GetClippedInput(),
+ GetFieldTransformFilter());
// Sets geometry for merge filter
myMergeFilter->SetGeometry(myDeformVectors->GetOutput());
myMergeFilter->SetScalars(myExtractorScalars->GetOutput());
+
// Sets data to mapper
- myMapper->SetInput(myMergeFilter->GetOutput());
+ GetDataSetMapper()->SetInput(myMergeFilter->GetOutput());
}
+//----------------------------------------------------------------------------
/*!
* Update method
*/
GetSourceRange(aRange);
vtkFloatingPointType aScalarRange[2] = {aRange[0], aRange[1]};
- if(myBarTable->GetScale() == VTK_SCALE_LOG10)
+ if(GetBarTable()->GetScale() == VTK_SCALE_LOG10)
VISU_LookupTable::ComputeLogRange(aRange,aScalarRange);
- myMapperTable->SetRange(aScalarRange);
+ GetMapperTable()->SetRange(aScalarRange);
- myMapperTable->Build();
- myBarTable->Build();
+ GetMapperTable()->Build();
+ GetBarTable()->Build();
- myMapper->SetLookupTable(myMapperTable);
- myMapper->SetScalarRange(aScalarRange);
+ GetMapper()->SetLookupTable(GetMapperTable());
+ GetMapper()->SetScalarRange(aScalarRange);
VISU_PipeLine::Update();
}
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_ScalarMapOnDeformedShapePL
+::GetMemorySize()
+{
+ unsigned long int aSize = Superclass::GetMemorySize();
+
+ if(vtkDataSet* aDataSet = myDeformVectors->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(vtkDataSet* aDataSet = myExtractorScalars->GetOutput())
+ aSize += aDataSet->GetActualMemorySize() * 1024;
+
+ if(vtkDataSet* aDataSet = myMergeFilter->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.
myExtractorScalars->Update();
}
+//----------------------------------------------------------------------------
/*!
* 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->GetScalars());
vtkFloatingPointType aRange[2];
aPipeLine->GetSourceRange(aRange);
SetScalarRange(aRange);
}
- Superclass::ShallowCopy(thePipeLine);
}
+//----------------------------------------------------------------------------
/*!
* Set scalars.
* Sets vtkDataSet with scalars values to VISU_Extractor filter for scalars extraction.
Modified();
}
+//----------------------------------------------------------------------------
/*!
* Get pointer to input scalars.
*/
return myScalars.GetPointer();
}
+//----------------------------------------------------------------------------
/*!
* Sets scale for deformed shape
*/
VISU_ScalarMapOnDeformedShapePL
::SetScale(vtkFloatingPointType theScale)
{
- if(myScaleFactor == theScale) return;
- myScaleFactor = theScale;
+ if(VISU::CheckIsSameValue(myScaleFactor, theScale))
+ return;
+
myDeformVectors->SetScaleFactor(myScaleFactor);
- Modified();
+ myScaleFactor = theScale;
}
+//----------------------------------------------------------------------------
/*!
* Gets scale of deformed shape.
*/
VISU_ScalarMapOnDeformedShapePL
::GetScale()
{
- vtkFloatingPointType aScale=myDeformVectors->GetScaleFactor();
- return aScale;
+ return myDeformVectors->GetScaleFactor();
}
+//----------------------------------------------------------------------------
/*!
* Set scale factor of deformation.
*/
VISU_ScalarMapOnDeformedShapePL
::SetMapScale(vtkFloatingPointType theMapScale)
{
- myDeformVectors->SetScaleFactor(myScaleFactor*theMapScale);
- Modified();
+ myDeformVectors->SetScaleFactor(myScaleFactor * theMapScale);
}
+//----------------------------------------------------------------------------
/*!
* Gets scalar mode.
*/
VISU_ScalarMapOnDeformedShapePL
::GetScalarMode()
{
- int aMode=myExtractorScalars->GetScalarMode();
- return aMode;
+ return myExtractorScalars->GetScalarMode();
}
+//----------------------------------------------------------------------------
/*!
* Sets scalar mode.
*/
Modified();
}
+//----------------------------------------------------------------------------
/*!
* Gets ranges of extracted scalars
* \param theRange[2] - output values
class vtkCellDataToPointData;
class vtkPointDataToCellData;
+
+//----------------------------------------------------------------------------
class VISU_ScalarMapOnDeformedShapePL : public VISU_ScalarMapPL
{
-protected:
- VISU_ScalarMapOnDeformedShapePL();
-
- virtual ~VISU_ScalarMapOnDeformedShapePL();
-
- VISU_ScalarMapOnDeformedShapePL(const VISU_ScalarMapOnDeformedShapePL&);
public:
- vtkTypeMacro(VISU_ScalarMapOnDeformedShapePL,VISU_ScalarMapPL);
+ vtkTypeMacro(VISU_ScalarMapOnDeformedShapePL, VISU_ScalarMapPL);
+
+ static
+ VISU_ScalarMapOnDeformedShapePL*
+ New();
+
+ virtual
+ void
+ SetScale(vtkFloatingPointType theScale);
- static VISU_ScalarMapOnDeformedShapePL* New();
+ virtual
+ vtkFloatingPointType
+ GetScale();
- virtual void ShallowCopy(VISU_PipeLine *thePipeLine);
+ virtual
+ int
+ GetScalarMode();
- virtual void SetScale(vtkFloatingPointType theScale);
- virtual vtkFloatingPointType GetScale();
+ virtual
+ void
+ SetScalarMode(int theScalarMode = 0);
- 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* GetScalars();
+ virtual
+ vtkUnstructuredGrid*
+ 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();
+
+ VISU_ScalarMapOnDeformedShapePL(const VISU_ScalarMapOnDeformedShapePL&);
+
+ virtual
+ void
+ DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
+
vtkFloatingPointType myScaleFactor;
vtkWarpVector *myDeformVectors;
vtkMergeFilter *myMergeFilter;
//
//
//
-// 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"
-
-//============================================================================
-vtkStandardNewMacro(VISU_ScalarMapPL);
+#include <vtkDataSetMapper.h>
+#include <vtkObjectFactory.h>
//----------------------------------------------------------------------------
-VISU_ScalarMapPL
-::VISU_ScalarMapPL()
-{
- 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);
-
- myExtractor = VISU_Extractor::New();
- myExtractor->SetInput(myExtractGeometry->GetOutput());
-
- myFieldTransform = VISU_FieldTransform::New();
- myFieldTransform->SetInput(myExtractor->GetOutput());
-
- myIsShrinkable = true;
-}
-
-
-VISU_ScalarMapPL
-::~VISU_ScalarMapPL()
-{
- myFieldTransform->Delete();
- myMapperTable->Delete();
- myBarTable->Delete();
- myExtractor->Delete();
-}
-
-
-//----------------------------------------------------------------------------
-void
-VISU_ScalarMapPL
-::ShallowCopy(VISU_PipeLine *thePipeLine)
-{
- 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);
-}
-
-
-//----------------------------------------------------------------------------
-int
-VISU_ScalarMapPL
-::GetScalarMode()
-{
- return myExtractor->GetScalarMode();
-}
-
-void
-VISU_ScalarMapPL
-::SetScalarMode(int theScalarMode)
-{
- vtkDataSet *input = GetInput();
- if (input){
- if(input->GetPointData()->GetNumberOfArrays()){
- vtkPointData *inData = input->GetPointData();
- if(!inData->GetAttribute(vtkDataSetAttributes::VECTORS)) {
- if (theScalarMode==0){
- return;
- }
- }
- }
- else {
- vtkCellData *inData = input->GetCellData();
- if(!inData->GetAttribute(vtkDataSetAttributes::VECTORS)){
- if (theScalarMode==0){
- return;
- }
- }
- }
- }
- //
- myExtractor->SetScalarMode(theScalarMode);
- Modified();
-}
+vtkStandardNewMacro(VISU_ScalarMapPL);
//----------------------------------------------------------------------------
-int
VISU_ScalarMapPL
-::GetScaling()
-{
- return myBarTable->GetScale();
-}
-
-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();
-}
+::VISU_ScalarMapPL():
+ VISU_UnstructuredGridPL(this)
+{}
//----------------------------------------------------------------------------
-vtkFloatingPointType*
-VISU_ScalarMapPL
-::GetScalarRange()
-{
- return myFieldTransform->GetScalarRange();
-}
-
-void
-VISU_ScalarMapPL
-::SetScalarRange(vtkFloatingPointType theRange[2])
-{
- myFieldTransform->SetScalarRange(theRange);
- myBarTable->SetRange(theRange);
- Modified();
-}
-
-void
-VISU_ScalarMapPL
-::SetScalarMin(vtkFloatingPointType theValue)
-{
- vtkFloatingPointType aScalarRange[2] = {theValue, GetScalarRange()[1]};
- SetScalarRange(aScalarRange);
-}
-
-void
VISU_ScalarMapPL
-::SetScalarMax(vtkFloatingPointType theValue)
-{
- vtkFloatingPointType aScalarRange[2] = {GetScalarRange()[0], theValue};
- SetScalarRange(aScalarRange);
-}
+::~VISU_ScalarMapPL()
+{}
//----------------------------------------------------------------------------
-void
-VISU_ScalarMapPL
-::SetNbColors(int theNbColors)
-{
- myMapperTable->SetNumberOfColors(theNbColors);
- myBarTable->SetNumberOfColors(theNbColors);
- Modified();
-}
-
-int
+void
VISU_ScalarMapPL
-::GetNbColors()
+::OnCreateMapperHolder()
{
- return myMapperTable->GetNumberOfColors();
+ VISU_UnstructuredGridPL::OnCreateMapperHolder();
}
//----------------------------------------------------------------------------
-VISU_ScalarMapPL::THook*
-VISU_ScalarMapPL
-::DoHook()
-{
- myMapper->SetColorModeToMapScalars();
- myMapper->ScalarVisibilityOn();
- return myFieldTransform->GetUnstructuredGridOutput();
-}
-
-
-void
-VISU_ScalarMapPL
-::Init()
-{
- SetScalarMode(0);
- SetSourceRange();
-}
-
void
VISU_ScalarMapPL
::Build()
{
- myMapper->SetInput(DoHook());
-}
-
-
-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();
-}
-
-
-//----------------------------------------------------------------------------
-VISU_LookupTable *
-VISU_ScalarMapPL
-::GetMapperTable()
-{
- return myMapperTable;
-}
-
-VISU_LookupTable*
-VISU_ScalarMapPL
-::GetBarTable()
-{
- return myBarTable;
-}
+ Superclass::Build();
-
-//----------------------------------------------------------------------------
-void
-VISU_ScalarMapPL
-::SetMapScale(vtkFloatingPointType theMapScale)
-{
- myMapperTable->SetMapScale(theMapScale);
- myMapperTable->Build();
-}
-
-vtkFloatingPointType
-VISU_ScalarMapPL::GetMapScale()
-{
- return myMapperTable->GetMapScale();
+ GetDataSetMapper()->SetInput(InsertCustomPL());
}
//----------------------------------------------------------------------------
-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 "VISU_PipeLine.hxx"
-#include "VISU_ScalarBarActor.hxx"
+#include "VISU_ColoredPL.hxx"
+#include "VISU_UnstructuredGridPL.hxx"
-class vtkCell;
-class vtkDataSet;
+class VISU_DataSetMapperHolder;
-class VISU_Extractor;
-class VISU_FieldTransform;
-
-//============================================================================
-class VISU_ScalarMapPL : public VISU_PipeLine
+//----------------------------------------------------------------------------
+class VISU_ScalarMapPL : public VISU_ColoredPL,
+ public VISU_UnstructuredGridPL
{
-protected:
- VISU_ScalarMapPL();
- VISU_ScalarMapPL(const 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);
-
+protected:
//----------------------------------------------------------------------------
- virtual
- int
- GetScalarMode();
-
- virtual
- void
- SetScalarMode(int theScalarMode = 0);
-
- virtual
- int
- GetScaling();
- virtual
- void
- SetScaling(int theScaling = VTK_SCALE_LINEAR);
-
- virtual
- vtkFloatingPointType*
- GetScalarRange();
-
- virtual
- void
- SetScalarRange(vtkFloatingPointType theRange[2]);
-
- virtual
- void
- SetScalarMin(vtkFloatingPointType theValue);
-
- virtual
- void
- SetScalarMax(vtkFloatingPointType theValue);
+ VISU_ScalarMapPL();
+ VISU_ScalarMapPL(const VISU_ScalarMapPL&);
virtual
- void
- SetNbColors(int theNbColors = 16);
+ ~VISU_ScalarMapPL();
- virtual
- int
- GetNbColors();
-
- //----------------------------------------------------------------------------
-public:
virtual
void
- Init();
+ OnCreateMapperHolder();
virtual
void
Build();
-
- virtual
- void
- Update();
-
- 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:
- typedef vtkDataSet THook;
- virtual THook* DoHook();
-
- VISU_LookupTable* myMapperTable;
- VISU_LookupTable* myBarTable;
- VISU_FieldTransform* myFieldTransform;
- VISU_Extractor* myExtractor;
};
#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_UsedPointsFilter.hxx"
#include "VTKViewer_GeometryFilter.h"
+#include "VISU_PipeLineUtils.hxx"
+
#include <algo.h>
#include <vtkCell.h>
-#include <vtkPointSet.h>
+#include <vtkDataSet.h>
#include <vtkStreamLine.h>
#ifdef _DEBUG_
static vtkFloatingPointType aCoeffOfIntStep = 1.0E+1;
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_StreamLinesPL);
-VISU_StreamLinesPL::VISU_StreamLinesPL(){
+
+//----------------------------------------------------------------------------
+VISU_StreamLinesPL
+::VISU_StreamLinesPL()
+{
myStream = vtkStreamLine::New();
myCenters = vtkCellCenters::New();
myGeomFilter = VTKViewer_GeometryFilter::New();
mySource = NULL;
}
-VISU_StreamLinesPL::~VISU_StreamLinesPL(){
- myPointsFilter->UnRegisterAllOutputs();
+
+//----------------------------------------------------------------------------
+VISU_StreamLinesPL
+::~VISU_StreamLinesPL()
+{
myPointsFilter->Delete();
+ myPointsFilter = NULL;
myCenters->UnRegisterAllOutputs();
- myCenters->Delete();
+ myCenters = NULL;
myGeomFilter->UnRegisterAllOutputs();
- myGeomFilter->Delete();
+ myGeomFilter = NULL;
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());
}
- VISU_DeformedShapePL::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){
+ size_t aSize = GetNecasseryMemorySize(aNbOfPoints,theStepLength,thePropogationTime,thePercents);
+ size_t anIsPossible = CheckAvailableMemory(aSize);
+ if(!anIsPossible){
vtkFloatingPointType aMaxStepLength = max(GetMaxStepLength(theDataSet),thePropogationTime);
vtkFloatingPointType aMinStepLength = GetMinStepLength(theDataSet);
vtkFloatingPointType aDeltaStepLength = (aMaxStepLength - aMinStepLength)/aStepLengthIncrease;
}
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)
{
- vtkPointSet* aDataSet = theSource? theSource: myFieldTransform->GetUnstructuredGridOutput();
+ vtkDataSet* aDataSet = theSource? theSource:
+ GetFieldTransformFilter()->GetUnstructuredGridOutput();
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);
+ 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 isAccepted = FindPossibleParams(aPointSet,
+ theStepLength,
+ thePropogationTime,
+ thePercents);
+
if((!isOnlyTry && isAccepted) || (isOnlyTry && isAccepted == 1)){
mySource = theSource;
myPercents = thePercents;
- if(GetInput2()->GetCellData()->GetNumberOfArrays()){
+ if(GetClippedInput()->GetCellData()->GetNumberOfArrays()){
myCenters->SetInput(aDataSet);
myCenters->VertexCellsOn();
aDataSet = myCenters->GetOutput();
}
-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();
return (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()
{
VISU_ScalarMapPL::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*
+
+//----------------------------------------------------------------------------
+vtkDataSet*
VISU_StreamLinesPL
-::DoHook()
+::InsertCustomPL()
{
- GetInput2()->Update();
- VISU::CellDataToPoint(myStream,myCellDataToPointData,GetInput2(),myFieldTransform);
- vtkFloatingPointType *aBounds = GetInput2()->GetBounds();
+ GetClippedInput()->Update();
+
+ VISU::CellDataToPoint(myStream,
+ myCellDataToPointData,
+ GetClippedInput(),
+ GetFieldTransformFilter());
+
+ vtkFloatingPointType *aBounds = GetClippedInput()->GetBounds();
myGeomFilter->SetExtent(aBounds);
myGeomFilter->ExtentClippingOn();
myGeomFilter->SetInput(myStream->GetOutput());
+
return myGeomFilter->GetOutput();
}
+
+//----------------------------------------------------------------------------
void
VISU_StreamLinesPL
::Update()
VISU_ScalarMapPL::Update();
}
+
+//----------------------------------------------------------------------------
+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)
{
VISU_ScalarMapPL::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_StreamLinesPL : public VISU_DeformedShapePL
{
-protected:
- VISU_StreamLinesPL();
- VISU_StreamLinesPL(const VISU_StreamLinesPL&);
-
- virtual
- ~VISU_StreamLinesPL();
-
public:
- vtkTypeMacro(VISU_StreamLinesPL,VISU_DeformedShapePL);
+ vtkTypeMacro(VISU_StreamLinesPL, VISU_DeformedShapePL);
static
VISU_StreamLinesPL*
New();
virtual
- void
- ShallowCopy(VISU_PipeLine *thePipeLine);
-
- virtual
- int
+ 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);
virtual
- vtkPointSet*
+ vtkDataSet*
GetSource();
virtual
public:
virtual
- THook*
- DoHook();
+ vtkDataSet*
+ InsertCustomPL();
virtual
void
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;
#include "VISU_UsedPointsFilter.hxx"
#include <vtkObjectFactory.h>
-#include <vtkPointSet.h>
+#include <vtkUnstructuredGrid.h>
#include <vtkPointData.h>
#include <vtkCellData.h>
#include <vtkPoints.h>
#include <vtkIdList.h>
+
+//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_UsedPointsFilter);
-VISU_UsedPointsFilter::VISU_UsedPointsFilter(){
+
+//----------------------------------------------------------------------------
+VISU_UsedPointsFilter
+::VISU_UsedPointsFilter()
+{
PercentsOfUsedPoints = 1.0;
}
-VISU_UsedPointsFilter::~VISU_UsedPointsFilter(){}
-void VISU_UsedPointsFilter::Execute(){
- vtkPointSet *anInput = this->GetInput(), *anOutput = this->GetOutput();
+//----------------------------------------------------------------------------
+VISU_UsedPointsFilter
+::~VISU_UsedPointsFilter()
+{}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_UsedPointsFilter
+::Execute()
+{
+ vtkDataSet *anInput = this->GetInput();
+ vtkPointSet *anOutput = this->GetOutput();
anOutput->GetPointData()->CopyAllOff();
anOutput->GetCellData()->CopyAllOff();
anOutput->CopyStructure(anInput);
aNewPoints->Delete();
aPoints->Delete();
}
+
+
+//----------------------------------------------------------------------------
#ifndef VISU_UsedPointsFilter_HeaderFile
#define VISU_UsedPointsFilter_HeaderFile
-#include <vtkPointSetToPointSetFilter.h>
+#include <vtkDataSetToUnstructuredGridFilter.h>
+
+
+//----------------------------------------------------------------------------
+class VISU_UsedPointsFilter : public vtkDataSetToUnstructuredGridFilter
+{
+public:
+ vtkTypeMacro(VISU_UsedPointsFilter, vtkDataSetToUnstructuredGridFilter);
+
+ 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();
+ virtual
+ void
+ Execute();
- vtkSetMacro(PercentsOfUsedPoints,float);
- vtkGetMacro(PercentsOfUsedPoints,float);
+ float PercentsOfUsedPoints;
};
#endif
#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
+::SetGlyphType(VISU_VectorsPL::GlyphType theType)
+{
+ myTypeGlyph = theType;
+ Modified();
+}
+
+
+//----------------------------------------------------------------------------
+VISU_VectorsPL::GlyphType
+VISU_VectorsPL
+::GetGlyphType() const
+{
+ return myTypeGlyph;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_VectorsPL
+::SetGlyphPos(VISU_VectorsPL::GlyphPos thePos)
+{
+ myPosGlyph = thePos;
+ Modified();
+}
+
+
+//----------------------------------------------------------------------------
+VISU_VectorsPL::GlyphPos
+VISU_VectorsPL
+::GetGlyphPos() const
+{
+ return myPosGlyph;
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_VectorsPL
::Init()
}
+//----------------------------------------------------------------------------
vtkDataSet*
VISU_VectorsPL
::GetOutput()
}
-VISU_ScalarMapPL::THook*
+//----------------------------------------------------------------------------
+vtkDataSet*
VISU_VectorsPL
-::DoHook()
+::InsertCustomPL()
{
- VISU::ToCellCenters(myBaseGlyph,myCenters,GetInput2(),myFieldTransform);
+ VISU::ToCellCenters(myBaseGlyph,
+ myCenters,
+ GetClippedInput(),
+ GetFieldTransformFilter());
+
myBaseGlyph->SetVectorModeToUseVector();
myBaseGlyph->SetScaleModeToScaleByVector();
myBaseGlyph->SetColorModeToColorByScalar();
- VISU::ToCellCenters(myTransformFilter,myCenters,GetInput2(),myFieldTransform);
+ VISU::ToCellCenters(myTransformFilter,
+ myCenters,
+ GetClippedInput(),
+ GetFieldTransformFilter());
+
myTransformedGlyph->SetInput(myTransformFilter->GetOutput());
myTransformedGlyph->SetVectorModeToUseVector();
myTransformedGlyph->SetScaleModeToScaleByVector();
}
+//----------------------------------------------------------------------------
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;
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_VectorsPL
::SetMapScale(vtkFloatingPointType theMapScale)
Modified();
}
+
+
+//----------------------------------------------------------------------------
class vtkGlyph3D;
+
+//----------------------------------------------------------------------------
class VISU_VectorsPL : public VISU_DeformedShapePL
{
-protected:
- VISU_VectorsPL();
- VISU_VectorsPL(const VISU_VectorsPL&);
-
- virtual
- ~VISU_VectorsPL();
-
public:
vtkTypeMacro(VISU_VectorsPL,VISU_DeformedShapePL);
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
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
- THook*
- DoHook();
+ ~VISU_VectorsPL();
+
+ virtual
+ vtkDataSet*
+ InsertCustomPL();
+
+ virtual
+ void
+ DoShallowCopy(VISU_PipeLine *thePipeLine,
+ bool theIsCopyInput);
GlyphType myTypeGlyph;
GlyphPos myPosGlyph;
VisuGUI_ClippingDlg.cxx \
VisuGUI_DialogRunner.cxx \
VisuGUI_OffsetDlg.cxx \
- VisuGUI_Plot3DDlg.cxx \
+ VisuGUI_Prs3dDlg.cxx \
VisuGUI_ScalarBarDlg.cxx \
+ VisuGUI_Plot3DDlg.cxx \
VisuGUI_GaussPointsDlg.cxx \
VisuGUI_DeformedShapeDlg.cxx \
VisuGUI_IsoSurfacesDlg.cxx \
VisuGUI_SetupPlot2dDlg.cxx \
VisuGUI_BuildProgressDlg.cxx \
VisuGUI_TransparencyDlg.cxx \
- VisuGUI_Timer.cxx
+ VisuGUI_Timer.cxx \
+ VisuGUI_Slider.cxx \
+ VisuGUI_InputPane.cxx \
+ VisuGUI_CacheDlg.cxx \
+ VisuGUI_FieldFilter.cxx
LIB_MOC = VisuGUI.h \
VisuGUI_Module.h \
VisuGUI_ClippingDlg.h \
VisuGUI_DialogRunner.h \
VisuGUI_OffsetDlg.h \
- VisuGUI_Plot3DDlg.h \
+ VisuGUI_Prs3dDlg.h \
VisuGUI_ScalarBarDlg.h \
+ VisuGUI_Plot3DDlg.h \
VisuGUI_GaussPointsDlg.h \
VisuGUI_DeformedShapeDlg.h \
VisuGUI_IsoSurfacesDlg.h \
VisuGUI_ScalarMapOnDeformedShapeDlg.h \
VisuGUI_SetupPlot2dDlg.h \
VisuGUI_BuildProgressDlg.h \
- VisuGUI_TransparencyDlg.h
+ VisuGUI_TransparencyDlg.h \
+ VisuGUI_Slider.h \
+ VisuGUI_InputPane.h \
+ VisuGUI_CacheDlg.h
LIB_CLIENT_IDL = SALOME_Exception.idl \
VISU_Gen.idl \
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_LOAD_TEXTURE"
msgstr "Visu_load_texture.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_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:"
msgstr "Z :"
+#: VisuGUI_InputPane.cxx
+
+msgid "VisuGUI_InputPane::MED_FILE"
+msgstr "Med 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 "Reinitialize"
+
+
+
#: 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::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"
msgstr "Plot3D"
msgid "VISU_SCALAR_MAP_ON_DEFORMED_SHAPE"
-msgstr "Scalar Map on Def. Shape"
\ No newline at end of file
+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_ScalarMap_i.hh"
#include "VisuGUI_ScalarBarDlg.h"
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::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))
+ 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);
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), entries[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);
}
}
}
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();
for (int i = 0; i <= aSteps; i++) {
try {
float 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()
+VisuGUI
+::OnTimeAnimation()
{
if (!VISU::GetActiveViewWindow<SVTK_ViewWindow>(this))
return;
else delete aAnimationDlg;
}
-//************************************************************************
+//----------------------------------------------------------------------------
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::TSCALARMAP:
- {
- VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
- VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_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);
+ 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::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);
- }
- 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()));
+
+ // 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()));
}
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
+ // 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 );
+
+
// Rules
QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
- "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D' 'VISU::TSCALARMAPONDEFORMEDSHAPE'");
+ "'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 + "}";
//aRule = "client='ObjectBrowser' and type='MEDFIELD'";
//mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
+
+ // 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 );
}
//***************************************************************************
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_USE_SHADING" ), representGr,
LightApp_Preferences::Bool, "VISU", "represent_shading" );
+
+
+ // 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 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();
+}
+
+
+// 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);
+}
+
+
#include "SalomeApp_Module.h"
+#include "SALOME_ListIO.hxx"
+
#include <map>
#include <set>
VISU::TViewToPrs3d getScalarBarsMap();
VISU::TViewToPrs3d myScalarBarsMap;
+
+ 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;
private:
LightApp_Displayer* myDisplayer;
+ SALOME_ListIO mySelectedObjects;
};
#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
// 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;
-
- myPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+ myPrs3d = dynamic_cast<VISU::Prs3d_i*>(aBase);
if (myPrs3d) {
std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false));
myPlanes.clear();
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();
for (i = 0; i < 3; ++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;
if (Abs(dot) > Abs(maxDot)) {
//=================================================================================
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>
bool VisuGUI_CutLinesDlg::MYGenerateCurve = true;
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);
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TCUTLINES>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
+
+ myScalarPane->initFromPrsObject(myPrsCopy);
- myRotXSpn->setValue(thePrs->GetRotateX()*180./PI);
- myRotYSpn->setValue(thePrs->GetRotateY()*180./PI);
- myPosSpn->setValue(thePrs->GetDisplacement());
- setOrientation(thePrs->GetOrientationType());
+ myRotXSpn->setValue(myPrsCopy->GetRotateX()*180./PI);
+ myRotYSpn->setValue(myPrsCopy->GetRotateY()*180./PI);
+ myPosSpn->setValue(myPrsCopy->GetDisplacement());
+ setOrientation(myPrsCopy->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());
+ 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);
- myCutLines->CopyCurvesInverted(thePrs->GetCurvesInverted());
+ 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;
+
+ if( myPrsCopy->IsTimeStampFixed() )
+ myTabBox->removePage( myInputPane );
+ else
+ {
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->showPage( myInputPane );
+ }
+ myTabBox->setCurrentPage( 0 );
}
//------------------------------------------------------------------------------
-int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::CutLines_i* thePrs)
+int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs)
{
- myScalarPane->storeToPrsObject(thePrs);
+ myScalarPane->storeToPrsObject(myPrsCopy);
+
+ if( !myPrsCopy->IsTimeStampFixed() )
+ {
+ if( !myInputPane->check() )
+ return 0;
+ myInputPane->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);
+ myPrsCopy->SetAllCurvesInverted(true);
+
+ VISU::TSameAsFactory<VISU::TCUTLINES>().Copy(thePrs, myPrsCopy);
+
return 1;
}
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();
MYGenerateCurve = myCurvesCheck->isChecked();
// if (myScalarPane->check()) {
/*jfa tmp:((QWidget*)sender())->setDisabled(true);
- storeToPrsObject(myPrs);
+ storeToPrsObject(myPrsCopy);
if (myIsCreation) {
if (isGenerateTable()) {
- visuGUI->GetVisuGen()->CreateTable(myPrs->GetEntry());
+ visuGUI->GetVisuGen()->CreateTable(myPrsCopy->GetEntry());
if (isGenerateCurves()) {
SALOMEDSClient_Study* aStudy = study()->studyDS();
- SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrs->GetEntry());
+ SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrsCopy->GetEntry());
if( aSObject ) {
SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
}
if (GET_VTK_VIEWWINDOW(myMgr)) {
try {
- visuGUI->CreateActor(myPrs);
+ visuGUI->CreateActor(myPrsCopy);
} catch (...) {
reject();
return;
GET_VTK_VIEWWINDOW(myMgr)->onFitAll();
}
} else {
- visuGUI->RecreateActor(myPrs);
+ visuGUI->RecreateActor(myPrsCopy);
if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) {
if (vf->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
vf->getRenderer()->ResetCameraClippingRange();
}
// Remove old Table
SALOMEDSClient_Study* aStudy = study()->studyDS();
- SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrs->GetEntry());
+ SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrsCopy->GetEntry());
if( aSObject ) {
SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject );
SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder();
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* myPreviewCheck;
QCheckBox* myAllCurvesInvertedCheck;
- VISU::CutLines_i* myPrs;
+ SALOME::GenericObjPtr<VISU::CutLines_i> myPrsCopy;
//jfa tmp:SUIT_ViewManager *myMgr;
//jfa tmp:SUIT_ViewWindow *myStudyWnd;
#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);
+
+ if( myPrsCopy->IsTimeStampFixed() )
+ myTabBox->removePage( myInputPane );
+ else
+ {
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->showPage( myInputPane );
+ }
+ 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));
+ int ok = 1;
+ if( !myPrsCopy->IsTimeStampFixed() )
+ {
+ if( !myInputPane->check() )
+ return 0;
+
+ ok = myInputPane->storeToPrsObject(myPrsCopy);
+ }
+
+ ok = ok && myScalarPane->storeToPrsObject(myPrsCopy) && myCutPane->storeToPrsObject(myPrsCopy);
+
+ VISU::TSameAsFactory<VISU::TCUTPLANES>().Copy(thePrs, myPrsCopy);
+
+ return ok;
}
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;
+
+ if( myPrsCopy->IsTimeStampFixed() )
+ myTabBox->removePage( myInputPane );
+ else
+ {
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->showPage( myInputPane );
+ }
+ myTabBox->setCurrentPage( 0 );
}
-int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::DeformedShape_i* thePrs) {
- myScalarPane->storeToPrsObject(thePrs);
- thePrs->SetScale(getFactor());
- thePrs->ShowColored(isColored());
+int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) {
+ myScalarPane->storeToPrsObject(myPrsCopy);
+
+ if( !myPrsCopy->IsTimeStampFixed() )
+ {
+ if( !myInputPane->check() )
+ return 0;
+ myInputPane->storeToPrsObject( myPrsCopy );
+ }
+
+ myPrsCopy->SetScale(getFactor());
+ myPrsCopy->ShowColored(isColored());
+
+ VISU::TSameAsFactory<VISU::TDEFORMEDSHAPE>().Copy(thePrs, myPrsCopy);
+
return 1;
}
#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() )
{
#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;
+ if( myPrsCopy->IsTimeStampFixed() )
+ myTabBox->removePage( myInputPane );
+ else
+ {
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->showPage( myInputPane );
+ }
+ 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() );
+ myPrsCopy->SetIsDeformed( myDefShapeButton->isChecked() );
+ myPrsCopy->SetScaleFactor( myScaleSpinBox->value() );
- thePrs->SetPrimitiveType( myPrimitiveBox->getPrimitiveType() );
+ myPrsCopy->SetPrimitiveType( myPrimitiveBox->getPrimitiveType() );
- thePrs->SetClamp( myPrimitiveBox->getClamp() );
+ 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() );
+ }
+
+ myPrsCopy->SetMagnification( mySizeBox->getMagnification() );
+ myPrsCopy->SetMagnificationIncrement( mySizeBox->getIncrement() );
+
+ int ok = 1;
+ if( !myPrsCopy->IsTimeStampFixed() )
+ {
+ if( !myInputPane->check() )
+ return 0;
+
+ ok = myInputPane->storeToPrsObject( myPrsCopy );
}
+ ok = ok && myScalarPane->storeToPrsObject( myPrsCopy );
- thePrs->SetMagnification( mySizeBox->getMagnification() );
- thePrs->SetMagnificationIncrement( mySizeBox->getIncrement() );
+ VISU::TSameAsFactory<VISU::TGAUSSPOINTS>().Copy(thePrs, myPrsCopy);
- return myScalarPane->storeToPrsObject(thePrs);
+ return ok;
}
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
#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;
+
+ if( myPrsCopy->IsTimeStampFixed() )
+ myTabBox->removePage( myInputPane );
+ else
+ {
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->showPage( myInputPane );
+ }
+ myTabBox->setCurrentPage( 0 );
+}
+
+int VisuGUI_IsoSurfacesDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
+{
+ int ok = 1;
+ if( !myPrsCopy->IsTimeStampFixed() )
+ {
+ if( !myInputPane->check() )
+ return 0;
+
+ ok = myInputPane->storeToPrsObject( myPrsCopy );
+ }
+
+ ok = ok && myScalarPane->storeToPrsObject( myPrsCopy ) && myIsoPane->storeToPrsObject(myPrsCopy);
+
+ VISU::TSameAsFactory<VISU::TISOSURFACE>().Copy(thePrs, myPrsCopy);
+
+ return ok;
+}
+
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;
+
+ if( myPrsCopy->IsTimeStampFixed() )
+ myTabBox->removePage( myInputPane );
+ else
+ {
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->showPage( myInputPane );
+ }
+ myTabBox->setCurrentPage( 0 );
+}
+
+//=======================================================================
+//function : storeToPrsObject
+//purpose :
+//=======================================================================
+int VisuGUI_Plot3DDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs)
+{
+ int ok = 1;
+ if( !myPrsCopy->IsTimeStampFixed() )
+ {
+ if( !myInputPane->check() )
+ return 0;
+
+ ok = myInputPane->storeToPrsObject( myPrsCopy );
+ }
+ ok = ok && myScalarPane->storeToPrsObject(myPrsCopy) && myIsoPane->storeToPrsObject(myPrsCopy);
+
+ VISU::TSameAsFactory<VISU::TPLOT3D>().Copy(thePrs, myPrsCopy);
+
+ return ok;
+}
+
//=======================================================================
//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 );
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();
#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 <vtkRenderer.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 "VISU_ScalarMap_i.hh"
#include "VISU_ScalarMapAct.h"
+#include "VISU_Result_i.hh"
+#include "VISU_ColoredPrs3dFactory.hh"
+
#include "LightApp_Application.h"
#include "SUIT_Session.h"
#include <qlayout.h>
#include <qvalidator.h>
#include <qcolordialog.h>
-
+#include <qtabwidget.h>
#include <vtkTextProperty.h>
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);
-
- // 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::ScalarMap_i* thePrs) {
- initFromResources();
- myScalarMap = thePrs;
- 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->GetScalarMapPL()->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_ScalarMapPL::New();
- if(myScalarMap->GetScalarMapPL())
- myScalarMapPL->ShallowCopy(myScalarMap->GetScalarMapPL());
-
- 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::ScalarMap_i* thePrs) {
- 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 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->GetScalarMapPL()->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() ) );
}
+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 )
-{
- 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)
+void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit)
{
- 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);
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TSCALARMAP>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
- // font
- QHBox* aHBox = new QHBox (aTitleGrp);
- aHBox->setSpacing(5);
- myTitleFont = new SVTK_FontWidget (aHBox);
+ myScalarPane->initFromPrsObject( myPrsCopy );
- 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()));
-}
+ if( !theInit )
+ return;
-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"));
+ if( myPrsCopy->IsTimeStampFixed() )
+ myTabBox->removePage( myInputPane );
+ else
+ {
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->showPage( myInputPane );
}
-}
-
-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]);
+ myTabBox->setCurrentPage( 0 );
}
/*!
- Called when <Cancel> button is clicked, restore begin values
+ Store dialog to the presentation
*/
-void VisuGUI_TextPrefDlg::reject()
+int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
{
- 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]);
+ int ok = 1;
+ if( !myPrsCopy->IsTimeStampFixed() )
+ {
+ if( !myInputPane->check() )
+ return 0;
- QDialog::reject();
-}
-/*!
- Called when <Ok> button is clicked, store begin values
-*/
-void VisuGUI_TextPrefDlg::accept()
-{
- storeBeginValues();
+ ok = myInputPane->storeToPrsObject( myPrsCopy );
+ }
+
+ ok = ok && myScalarPane->storeToPrsObject( myPrsCopy );
- QDialog::accept();
+ VISU::TSameAsFactory<VISU::TSCALARMAP>().Copy(thePrs, myPrsCopy);
+
+ return ok;
}
/*!
Provides help on F1 button click
*/
-void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e )
+void VisuGUI_ScalarBarDlg::keyPressEvent( QKeyEvent* e )
{
QDialog::keyPressEvent( e );
if ( e->isAccepted() )
#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 "VISU_ScalarMap_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 QtxDblSpinBox;
-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_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::ScalarMap_i* thePrs);
- int storeToPrsObject(VISU::ScalarMap_i* thePrs);
-
- bool check();
- void deletePreview();
+ class ScalarMap_i;
+}
- 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_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::ScalarMap_i* thePrs) {myScalarPane->initFromPrsObject(thePrs);}
- int storeToPrsObject(VISU::ScalarMap_i* thePrs) {return myScalarPane->storeToPrsObject(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),
+ myIteration(1),
+ 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();
+
+ QString aFieldName(myPrsCopy->GetScalarFieldName().c_str());
+ CORBA::String_var aMeshName = myPrsCopy->GetMeshName();
+ float aIterFloat = GetFloatValueOfTimeStamp(aMeshName.in(),
+ myPrsCopy->GetScalarFieldName().c_str(),
+ myPrsCopy->GetScalarIteration(),
+ myPrsCopy->GetScalarEntity());
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, "AttributeComment")) {
_PTR(AttributeComment) 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");
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);
myTimeStampsCombo->setCurrentText(aIteration);
SetScalarField( false );
- myScalarPane->initFromPrsObject(myPrs);
+ myScalarPane->initFromPrsObject(myPrsCopy);
+
+ if( !theInit )
+ return;
+
+ if( myPrsCopy->IsTimeStampFixed() )
+ myTabBox->removePage( myInputPane );
+ else
+ {
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->showPage( myInputPane );
+ }
+ 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());
+ myPrsCopy->SetScale(getFactor());
if (myIsAnimation)
- thePrs->SetScalarField(myPrs->GetScalarMeshName().c_str(),
- getCurrentScalarFieldName().latin1(),
- theIter,
- myPrs->GetScalarEntity());
+ myPrsCopy->SetCScalarField(myPrsCopy->GetScalarMeshName().c_str(),
+ getCurrentScalarFieldName().latin1(),
+ myIteration,
+ myPrsCopy->GetScalarEntity());
else
- thePrs->SetScalarField(myPrs->GetScalarMeshName().c_str(),
- getCurrentScalarFieldName().latin1(),
- myTimeStampsCombo->currentItem() + 1,
- myPrs->GetScalarEntity());
+ myPrsCopy->SetCScalarField(myPrsCopy->GetScalarMeshName().c_str(),
+ getCurrentScalarFieldName().latin1(),
+ myTimeStampsCombo->currentItem() + 1,
+ myPrsCopy->GetScalarEntity());
- if (theUpdateScalars) SetScalarField( false );
+ if (myUpdateScalars) SetScalarField( false );
- thePrs->ShowColored(true);
+ myPrsCopy->ShowColored(true);
- myScalarPane->storeToPrsObject(thePrs);
+ myScalarPane->storeToPrsObject(myPrsCopy);
+
+ if( !myPrsCopy->IsTimeStampFixed() )
+ {
+ if( !myInputPane->check() )
+ return 0;
+ myInputPane->storeToPrsObject( myPrsCopy );
+ }
- myPrs = thePrs;
+ VISU::TSameAsFactory<VISU::TSCALARMAPONDEFORMEDSHAPE>().Copy(thePrs, myPrsCopy);
return 1;
}
VISU::TEntity anEntity = getCurrentScalarEntity();
- myPrs->SetScalarField(myCurrMeshName.latin1(),
- aFieldName.latin1(),
- theIter,
- anEntity);
+ myPrsCopy->SetCScalarField(myCurrMeshName.latin1(),
+ aFieldName.latin1(),
+ theIter,
+ anEntity);
if( save_scalar_pane )
{
- myScalarPane->storeToPrsObject(myPrs);
+ myScalarPane->storeToPrsObject(myPrsCopy);
UpdateScalarField();
}
}
}
void VisuGUI_ScalarMapOnDeformedShapeDlg::UpdateScalarField(){
- myPrs->SetScale(getFactor());
+ myPrsCopy->SetScale(getFactor());
vtkFloatingPointType aRange[2];
- myPrs->GetScalarMapOnDeformedShapePL()->Build();
- myPrs->GetScalarMapOnDeformedShapePL()->Update();
- myPrs->GetScalarMapOnDeformedShapePL()->GetSourceRange(aRange);
+ myPrsCopy->GetSpecificPL()->Build();
+ myPrsCopy->GetSpecificPL()->Update();
+ myPrsCopy->GetSpecificPL()->GetSourceRange(aRange);
double aDoubleRange[2];
aDoubleRange[0] = double(aRange[0]);
aDoubleRange[1] = double(aRange[1]);
- myScalarPane->initFromPrsObject(myPrs);
+ myScalarPane->initFromPrsObject(myPrsCopy);
myScalarPane->setRange(aDoubleRange[0],aDoubleRange[1],myScalarPane->isIRange());
}
const int theIter,
const VISU::TEntity theEntity){
float ret=1;
- VISU::Result_i* theResult = myPrs->GetResult();
+ VISU::Result_i* theResult = myPrsCopy->GetCResult();
VISU::PField aField = theResult->GetInput()->GetField(theMeshName,theEntity,theFieldName);
if(!aField) return ret;
VISU::TValField& aValField = aField->myValField;
#ifndef VISUGUI_SCALARMAPONDEFORMEDSHAPEDLS_H
#define VISUGUI_SCALARMAPONDEFORMEDSHAPEDLS_H
-#include "VisuGUI_ScalarBarDlg.h"
+#include "VisuGUI_Prs3dDlg.h"
+
+#include "VISUConfig.hh"
+#include "VISU_Convertor.hxx"
#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>
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 setAnimation( bool on ) { myIsAnimation = on; }
+ void setUpdateScalars( bool on ) { myUpdateScalars = on; }
+ void setIteration( int value ) { myIteration = value; }
- 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();
private:
QtxDblSpinBox* ScalFact;
+ QTabWidget* myTabBox;
VisuGUI_ScalarBarPane* myScalarPane;
+ VisuGUI_InputPane* myInputPane;
QComboBox *myFieldsCombo;
QComboBox *myTimeStampsCombo;
QString myCurrMeshName;
int myCurrScalarIter;
bool myIsAnimation;
+ bool myUpdateScalars;
+ int myIteration;
_PTR(SObject) mySelectionObj;
- VISU::ScalarMapOnDeformedShape_i* myPrs;
+ SALOME::GenericObjPtr<VISU::ScalarMapOnDeformedShape_i> myPrsCopy;
SalomeApp_Module* myVisuGUI;
protected:
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);
if (aPrs3d) {
int anId = theText.toInt();
- vtkDataSet* aDataSet = aPrs3d->GetPL()->GetMapper()->GetInput();
+ vtkDataSet* aDataSet = aPrs3d->GetPipeLine()->GetMapper()->GetInput();
int aMaxId = (aDataSet->*theMethod)();
if (anId < 0) anId = 0;
if (anId >= aMaxId) anId = aMaxId - 1;
#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;
+
+ if( myPrsCopy->IsTimeStampFixed() )
+ myTabBox->removePage( myInputPane );
+ else
+ {
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->showPage( myInputPane );
+ }
+ myTabBox->setCurrentPage( 0 );
+
}
-int VisuGUI_StreamLinesDlg::storeToPrsObject (VISU::StreamLines_i* thePrs)
+int VisuGUI_StreamLinesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs)
{
- bool isAccepted = myScalarPane->storeToPrsObject(thePrs);
+ bool isAccepted = myScalarPane->storeToPrsObject(myPrsCopy);
+
+ if( isAccepted && !myPrsCopy->IsTimeStampFixed() )
+ {
+ if( !myInputPane->check() )
+ return 0;
+ isAccepted = myInputPane->storeToPrsObject( myPrsCopy );
+ }
+
if (isAccepted) {
- thePrs->ShowColored(myUseScalar->isChecked());
- if (!thePrs->IsColored()) {
+ 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(),
+ isAccepted = 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"));
+
+ VISU::TSameAsFactory<VISU::TSTREAMLINES>().Copy(thePrs, myPrsCopy);
+
return isAccepted;
}
#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];
typedef VisuGUI_ScalarMapOnDeformedShapeDlg DLG;
typedef VISU::ScalarMapOnDeformedShape_i TYPE;
DLG* aDlg = new DLG (myModule);
- aDlg->initFromPrsObject(dynamic_cast<TYPE*>(aData.myPrs[0]),true);
+ aDlg->setAnimation( 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->setUpdateScalars(false);
+ aDlg->setIteration(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)
{
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,"AttributeComment")) {
- _PTR(AttributeComment) 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()){
- Handle(SALOME_InteractiveObject) anIO = anIter.Value();
- if(theIO)
- *theIO = anIO;
- if(anIO->hasEntry())
- return GetSelectedObj( GetAppStudy(theModule), anIO->getEntry(), theMap );
+ while(anIter.More())
+ {
+ Handle(SALOME_InteractiveObject) anIO = anIter.Value();
+ if(anIO->hasEntry())
+ {
+ TObjectInfo anObjectInfo = GetObjectByEntry(aStudy, anIO->getEntry());
+ 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;
+ _PTR(GenericAttribute) anAttr;
+ if(theSObject->FindAttribute(anAttr,"AttributeComment")){
+ _PTR(AttributeComment) 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)
- {
- 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)
+ FindActor(const SalomeApp_Study* theStudy,
+ SVTK_ViewWindow* theViewWindow,
+ const QString& theEntry)
{
- 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->Repaint();
}
+ //------------------------------------------------------------
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;
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)
{
aMap[theViewWindow].insert(aPair);
}
+ //------------------------------------------------------------
void RemoveScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
VISU::Prs3d_i* 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;
+
+ if( myPrsCopy->IsTimeStampFixed() )
+ myTabBox->removePage( myInputPane );
+ else
+ {
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->showPage( myInputPane );
+ }
+ 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) {
+ myScalarPane->storeToPrsObject(myPrsCopy);
+ if( !myPrsCopy->IsTimeStampFixed() )
+ {
+ if( !myInputPane->check() )
+ return 0;
+ myInputPane->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);
+ myPrsCopy->SetGlyphType(VISU::Vectors::NONE);
+
+ VISU::TSameAsFactory<VISU::TVECTORS>().Copy(thePrs, myPrsCopy);
+
return 1;
}
#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);
}
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
+ SALOME_GenericObjPointer.cc
LIB_MOC = \
VISU_TimeAnimation.h
VISU_Gen.idl \
SALOME_Component.idl \
SALOME_Exception.idl \
- SALOME_GenericObj.idl
+ SALOME_GenericObj.idl
LIB_CLIENT_IDL = \
SALOMEDS.idl \
VISU_ViewManager_i.hh \
VISU_View_i.hh \
VISU_TimeAnimation.h \
- VISU_ScalarMapOnDeformedShape_i.hh
+ VISU_ScalarMapOnDeformedShape_i.hh \
+ VISU_ColoredPrs3dFactory.hh \
+ SALOME_GenericObjPointer.hh
# additionnal information to compil and link file
CPPFLAGS += \
$(BOOST_LIBS) \
$(KERNEL_LDFLAGS) \
$(GUI_LDFLAGS) \
- $(MED_LDFLAGS)
+ $(MED_LDFLAGS)
LIBS+= -lboost_signals${BOOST_LIBSUFFIX} \
-lSalomeHDFPersist \
-lVisuPipeLine \
-lVisuObject \
-lVVTK \
- -lVISUGUITOOLS
+ -lVISUGUITOOLS \
+ -lMULTIPR_API
LDFLAGSFORBIN=$(LDFLAGS) $(LIBS) \
$(KERNEL_LDFLAGS) \
-lMEDWrapperBase \
-lMEDWrapper_V2_2 \
-lMEDWrapper_V2_1 \
- -lmed_V2_1
+ -lmed_V2_1 \
+ -lmedmem \
+ -lmedsplitter \
+ -lMULTIPR_API
# additional file to be cleaned
MOSTLYCLEAN =
//===========================================================================
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& theRefFatherEntry,
+ 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 aFather = theStudyDocument->FindObjectID(theFatherEntry.c_str());
SALOMEDS::SObject_var newObj;
if (theCreateNew) newObj = aStudyBuilder->NewObject(aFather);
else newObj = aFather;
SALOMEDS::GenericAttribute_var anAttr;
- if(strcmp(theIOR,"") != 0){
+ if(theIOR != ""){
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- anIOR->SetValue(theIOR);
+ anIOR->SetValue(theIOR.c_str());
}
- if(strcmp(theName,"") != 0){
+ if(theName != ""){
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
- aName->SetValue(theName);
+ aName->SetValue(theName.c_str());
}
- if(strcmp(thePersistentRef,"") != 0){
+ if(thePersistentRef != ""){
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePersistentRef");
SALOMEDS::AttributePersistentRef_var aPRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr);
- aPRef->SetValue(thePersistentRef);
+ aPRef->SetValue(thePersistentRef.c_str());
}
- if(strcmp(theComment,"") != 0){
+ if(theComment != ""){
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeComment");
SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
- aCmnt->SetValue(theComment);
+ aCmnt->SetValue(theComment.c_str());
if(MYDEBUG) INFOS("CreateAttributes - Comment = "<<theComment);
}
- if(strcmp(theRefFatherEntry,"") != 0){
- SALOMEDS::SObject_var aRefFather = theStudyDocument->FindObjectID(theRefFatherEntry);
+ if(theRefFatherEntry != ""){
+ SALOMEDS::SObject_var aRefFather = theStudyDocument->FindObjectID(theRefFatherEntry.c_str());
SALOMEDS::SObject_var anObj = aStudyBuilder->NewObject(aRefFather);
aStudyBuilder->Addreference(anObj,newObj);
}
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& theRefFatherEntry,
+ 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);
newObj = aFather;
_PTR(GenericAttribute) anAttr;
- if (strcmp(theIOR, "") != 0) {
+ if (theIOR != "") {
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
_PTR(AttributeIOR) anIOR (anAttr);
anIOR->SetValue(theIOR);
}
- if (strcmp(theName, "") != 0) {
+ if (theName != "") {
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
_PTR(AttributeName) aName (anAttr);
aName->SetValue(theName);
}
- if (strcmp(thePersistentRef, "") != 0) {
+ if (thePersistentRef != "") {
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePersistentRef");
_PTR(AttributePersistentRef) aPRef (anAttr);
aPRef->SetValue(thePersistentRef);
}
- if (strcmp(theComment, "") != 0) {
+ if (theComment != "") {
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeComment");
_PTR(AttributeComment) aCmnt (anAttr);
aCmnt->SetValue(theComment);
if (MYDEBUG) INFOS("CreateAttributes - Comment = " << theComment);
}
- if (strcmp(theRefFatherEntry, "") != 0) {
+ if (theRefFatherEntry != "") {
_PTR(SObject) aRefFather = theStudyDocument->FindObjectID(theRefFatherEntry);
_PTR(SObject) anObj = aStudyBuilder->NewObject(aRefFather);
aStudyBuilder->Addreference(anObj, newObj);
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>
public virtual PortableServer::RefCountServantBase
{
public:
+ typedef VISU::Base TInterface;
+
Base_i();
virtual ~Base_i();
virtual char* GetID();
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 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);
};
//===========================================================================
_PTR(SComponent) ClientFindOrCreateVisuComponent(_PTR(Study) theStudyDocument);
SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
- 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);
-
- 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);
-
- std::string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry,
- const char* theComment, int IsAllLevels = true);
-
- SALOMEDS::SObject_var GetSObject(_PTR(SObject));
- _PTR(SObject) GetClientSObject(SALOMEDS::SObject_var, _PTR(Study));
-
- SALOMEDS::Study_var GetDSStudy(_PTR(Study));
-
- void RemoveFromStudy(SALOMEDS::SObject_ptr theSObject,
- bool theIsAttrOnly = true,
- bool theDestroySubObjects = false);
- void RemoveFromStudy(_PTR(SObject) theSObject,
- bool theIsAttrOnly = true,
- bool theDestroySubObjects = false);
+ std::string
+ CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
+ const std::string& theFatherEntry,
+ const std::string& theRefFatherEntry,
+ const std::string& theIOR,
+ const std::string& theName,
+ const std::string& thePersistentRef,
+ const std::string& theComment,
+ CORBA::Boolean theCreateNew = true);
+
+ std::string
+ CreateAttributes(_PTR(Study) theStudyDocument,
+ const std::string& theFatherEntry,
+ const std::string& theRefFatherEntry,
+ const std::string& theIOR,
+ const std::string& theName,
+ const std::string& thePersistentRef,
+ const std::string& theComment,
+ CORBA::Boolean theCreateNew = true);
+
+ std::string
+ FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument,
+ const std::string& theStartEntry,
+ const std::string& theComment,
+ int IsAllLevels = true);
+
+ SALOMEDS::SObject_var
+ GetSObject(_PTR(SObject));
+
+ _PTR(SObject)
+ GetClientSObject(SALOMEDS::SObject_var, _PTR(Study));
+
+ SALOMEDS::Study_var
+ GetDSStudy(_PTR(Study));
+
+ void
+ RemoveFromStudy(SALOMEDS::SObject_ptr theSObject,
+ bool theIsAttrOnly = true,
+ bool theDestroySubObjects = false);
+ void
+ RemoveFromStudy(_PTR(SObject) theSObject,
+ bool theIsAttrOnly = true,
+ bool theDestroySubObjects = false);
}
#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;
//============================================================================
VISU::ColoredPrs3d_i::
-ColoredPrs3d_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theAddToStudy),
- myScalarMapPL(NULL),
- myIsFixedRange(false)
-{}
-
-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
+ 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;
+}
+
+
+//----------------------------------------------------------------------------
+const VISU::PValForTime&
+VISU::ColoredPrs3d_i
+::GetValForTime() const
+{
+ VISU::TValField& aValField = GetField()->myValField;
+ PValForTime& aValForTime = aValField[myTimeStampNumber];
+ 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);
- 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());
+ if(anIsCreatNew)
+ SetTitle(anOrigin->GetTitle());
SetBoldTitle(anOrigin->IsBoldTitle());
SetItalicTitle(anOrigin->IsItalicTitle());
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)
+::SetScalarMode(CORBA::Long theScalarMode)
{
- int anIteration = GetIteration();
- SameAs(theOrigin);
- myIteration = anIteration;
+ CORBA::Long aNbComp = GetField()->myNbComp;
+ if(aNbComp == 1)
+ theScalarMode = 1;
+ else if(theScalarMode > aNbComp)
+ theScalarMode = 0;
- Build(-1);
- Update();
+ myColoredPL->SetScalarMode(theScalarMode);
+}
+
+//----------------------------------------------------------------------------
+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)
{
- myScalarMapPL->SetNbColors(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* theName)
+::SetTitle(const char* theTitle)
{
- myTitle = theName;
+ std::strstream aStream;
+ const VISU::PValForTime& aValForTime = GetValForTime();
+ aStream<<theTitle<<" "<<VISU_Convertor::GenerateName(aValForTime->myTime)<<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;
}
+//----------------------------------------------------------------------------
+std::string
+VISU::ColoredPrs3d_i
+::GetScalarBarTitle()
+{
+ return myScalarBarTitle;
+}
//----------------------------------------------------------------------------
/**
*/
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();
+ if(!TSuperClass::Restore(theStudy, theMap))
+ return NULL;
- 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();
+ 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);
- myAddToStudy = false; //SRN Added 21/06/2003 SAL2983: to avoid addition of the new ScalarMap to study.
-
- 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);
+ if(MYDEBUG) MESSAGE("ColoredPrs3d_i::CreatePipeLine() - "<<thePipeLine);
+ myColoredPL = dynamic_cast<VISU_ColoredPL*>(thePipeLine);
+
+ SetPipeLine(myColoredPL);
+}
+
+//----------------------------------------------------------------------------
+std::string
+VISU::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();
}
- myScalarMapPL = dynamic_cast<VISU_ScalarMapPL*>(myPipeLine);
+ 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::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) myTitle = aComment.simplifyWhiteSpace().latin1();
+ 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 aRefFatherEntry = GetCResult()->GetRefFatherEntry();
+ 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(GetStudyDocument(),
+ anEntry,
+ aRefFatherEntry,
+ anIOR.in(),
+ GetName(),
+ "",
+ aComment.latin1(),
+ true);
+ }else if(myPublishInStudyMode == EPublishIndependently){
+ SetName(GenerateName().latin1(), false);
CORBA::String_var anIOR = GetID();
- CreateAttributes(myStudy,anEntry.c_str(),aRefFatherEntry.c_str(),anIOR,myName.c_str(),"",aComment.latin1(),true);
- mySObject = myStudy->FindObjectIOR(anIOR);
+ std::string aFatherEntry = VISU::FindOrCreate3DPresentationsFolder(GetStudyDocument());
+ aComment.sprintf("myComment=%s",
+ GetComment());
+ CreateAttributes(GetStudyDocument(),
+ aFatherEntry,
+ "",
+ 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;
-}
#include "VISU_Prs3d_i.hh"
-class VISU_ScalarMapPL;
+class VISU_ColoredPL;
namespace VISU
{
+ std::string
+ FindOrCreate3DPresentationsFolder(SALOMEDS::Study_ptr theStudy);
+
//============================================================================
class ColoredPrs3d_i : public virtual POA_VISU::ColoredPrs3d,
public virtual Prs3d_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
+ const VISU::PValForTime&
+ GetValForTime() 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);
virtual
void
- SetTitle(const char* theName);
+ SetTitle(const char* theTitle);
virtual
char*
GetTitle();
+ std::string
+ GetCTitle();
+
//----------------------------------------------------------------------------
- protected:
- VISU::ScalarMap::Orientation myOrientation;
- std::string myTitle;
- int myNumberOfLabels;
- vtkFloatingPointType myPosition[2], myWidth, myHeight;
+ //! Gets memory size actually used by the presentation (Mb).
+ virtual
+ CORBA::Float
+ GetMemorySize();
- public:
//----------------------------------------------------------------------------
+ //! Returns presentation input
+ VISU::ColoredPrs3dHolder::BasicInput*
+ GetBasicInput();
+
+ virtual
+ void
+ SetHolderEntry(const std::string& theEntry);
+
+ virtual
+ std::string
+ GetHolderEntry();
+
+ //----------------------------------------------------------------------------
+ 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);
-
- 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:
- PField myField;
- TEntity myEntity;
+ /*!
+ 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);
+
+ void
+ SetField(VISU::PField theField);
+
+ void
+ UseFixedRange(bool theUseFixedRange);
+
+ std::string
+ GetScalarBarTitle();
+
+ //! 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();
};
+ //----------------------------------------------------------------------------
+ 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>
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;
aMeshOnEntity->mySupport = aMEDSupport;
if(aVEntity == NODE_ENTITY)
- ::InitMeshOnEntity(aMesh,CELL_ENTITY,aMeshOnEntity);
+ ::InitMeshOnEntity(aMesh, CELL_ENTITY, aMeshOnEntity);
else
- ::InitMeshOnEntity(aMesh,NODE_ENTITY,aMeshOnEntity);
+ ::InitMeshOnEntity(aMesh, NODE_ENTITY, aMeshOnEntity);
- ::GetCellsSize(aMesh,aMEDMesh,aVEntity);
+ ::GetCellsSize(aMesh, aMEDMesh, aVEntity);
TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
PCField aField = aFieldMap[aFieldName.in()](new TCField());
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_INT;
+ aField->Init(myField->getNumberOfComponents(), aDataType);
+
if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
TValField& aValField = aField->myValField;
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);
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_INT;
+ aField->Init(aMEDField->getNumberOfComponents(), aDataType);
+
if(MYDEBUG)
MESSAGE("VISU_MEDConvertor::Build - aMeshOnEntity->myNbCells = "<<aMeshOnEntity->myNbCells);
}else
aMesh->myName = aMeshName.in();
aMesh->myMesh = aMEDMesh;
- TNamedPointCoords& aCoords = aMesh->myNamedPointCoords;
- aCoords.Init(aMesh->myNbPoints,aMesh->myDim);
-
myMeshMap[aMeshName.in()] = aMesh;
if(MYDEBUG)
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_INT;
+ aField->Init(aMEDField->getNumberOfComponents(), aDataType);
+
aFieldMap[aFieldName.in()] = aField;
if(MYDEBUG)
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++];
- }
+ TCMEDCoordHolder* aCoordHolder = new TCMEDCoordHolder();
+ aCoordHolder->Init(aNbElem, aDim, aCCoord);
+
+ TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
+ aCoords.Init(PCoordHolder(aCoordHolder));
if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type 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];
const TEntity& aVEntity = theMeshOnEntity->myEntity;
int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(aVEntity);
- const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
- int aNbPoints = aCoords.GetNbPoints();
+ vtkIdType aNbPoints = theMesh->GetNbPoints();
for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++){
SALOME_MED::medGeometryElement aMGeom = aGeomElems[iGeom];
}
-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)
{
- int aNbComp = theField->myNbComp;
+ typedef TTCMEDMeshValue<TValueType, TContainerType> TVMeshValue;
+ vtkIdType aNbComp = theField->myNbComp;
if(theField->myEntity == NODE_ENTITY){
VISU::EGeometry aEGeom = VISU::ePOINT1;
- int aNbGauss = theValForTime->GetNbGauss(aEGeom);
- const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
- int aNbElem = aCoords.GetNbPoints();
+ vtkIdType aNbGauss = theValForTime->GetNbGauss(aEGeom);
+ vtkIdType aNbElem = theMesh->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++];
- }
- }
- }
+ 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 TEntity& aVEntity = theField->myEntity;
for(int iGeom = 0; iGeom < iGeomEnd; iGeom++){
SALOME_MED::medGeometryElement aMGeom = aGeomElems[iGeom];
VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom);
- int aNbGauss = theValForTime->GetNbGauss(aEGeom);
+ vtkIdType aNbGauss = theValForTime->GetNbGauss(aEGeom);
const TCMeshOnEntity::TCellsFirstIndex& aCellsFirstIndex = theMeshOnEntity->myCellsFirstIndex;
TCMeshOnEntity::TCellsFirstIndex::const_iterator aCellsFirstIndexIter = aCellsFirstIndex.find(aMGeom);
if(aCellsFirstIndexIter != aCellsFirstIndex.end()){
"; 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];
- }
- }
+ vtkIdType aNbElem = aIndexAndSize.second;
+ vtkIdType aStart = aIndexAndSize.first * aNbComp;
+ PMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
+ TVMeshValue* aMeshValue = new TVMeshValue();
+ aMeshValue->Init(aNbElem, aNbGauss, aNbComp, theContainer, aStart);
+ aVMeshValue.reset(aMeshValue);
}
}
}
- return 1;
}
int
VISU::PCValForTime theValForTime)
{
//Check on loading already done
- PIDMapperFilter anIDMapperFilter = theValForTime->myIDMapperFilter;
- if(anIDMapperFilter->myIsVTKDone)
+ PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = theValForTime->myUnstructuredGridIDMapper;
+ if(anUnstructuredGridIDMapper->myIsVTKDone)
return 0;
PCProfile aProfile(new TCProfile());
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;
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
{
+ //---------------------------------------------------------------
+ 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 TCProfile: virtual TProfileImpl
{};
- typedef SharedPtr<TCProfile> PCProfile;
+ typedef MED::SharedPtr<TCProfile> PCProfile;
//---------------------------------------------------------------
struct TCSubMesh: virtual TSubMeshImpl
{};
- typedef SharedPtr<TCSubMesh> PCSubMesh;
+ typedef MED::SharedPtr<TCSubMesh> PCSubMesh;
//---------------------------------------------------------------
typedef std::map<int,TIndexAndSize> TCellsFirstIndex;
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 VISU::ScalarMap_i::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++);}
-const string VISU::CutLines_i::myComment = "CUTLINES";
-const char* VISU::CutLines_i::GetComment() const { return myComment.c_str();}
+//---------------------------------------------------------------
+QString
+VISU::CutLines_i::GenerateName()
+{
+ return VISU::GenerateName("CutLines",myNbPresent++);
+}
+//---------------------------------------------------------------
+const string VISU::CutLines_i::myComment = "CUTLINES";
-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),
- myCutLinesPL(NULL)
-{}
+//---------------------------------------------------------------
+const char*
+VISU::CutLines_i
+::GetComment() const
+{
+ return myComment.c_str();
+}
+//---------------------------------------------------------------
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),
+CutLines_i(EPublishInStudyMode thePublishInStudyMode) :
+ ColoredPrs3d_i(thePublishInStudyMode),
+ ScalarMap_i(thePublishInStudyMode),
myCutLinesPL(NULL)
-{
-}
+{}
+//---------------------------------------------------------------
/*! 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)
+
+//---------------------------------------------------------------
+VISU::Storable*
+VISU::CutLines_i
+::Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
{
- return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration);
+ 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){
- ScalarMap_i::ToStream(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)
{
myCutLinesPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(theOrient),
- theXAngle,theYAngle);
+ theXAngle,
+ theYAngle);
}
-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)
{
myCutLinesPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(theOrient),
- theXAngle,theYAngle,1);
+ theXAngle,
+ theYAngle,
+ 1);
}
-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);
}
* 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){
+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;
* \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;
}
* \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){
+CORBA::Boolean
+VISU::CutLines_i
+::IsCurveInverted(CORBA::Long theCurveNumber)
+{
return myMapCurvesInverted[theCurveNumber];
}
-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::CreatePipeLine(myCutLinesPL);
+}
+
- ScalarMap_i::DoHook();
+//----------------------------------------------------------------------------
+bool
+VISU::CutLines_i
+::CheckIsPossible()
+{
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
}
+
+//---------------------------------------------------------------
VISU_Actor*
VISU::CutLines_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+::CreateActor()
{
- if(VISU_Actor* anActor = ScalarMap_i::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());
{
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();
class VISU_CutLinesPL;
-namespace VISU{
+namespace VISU
+{
class CutLines_i : public virtual POA_VISU::CutLines,
public virtual ScalarMap_i
{
typedef ScalarMap_i TSuperClass;
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
+ 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::VISUType GetType() { return VISU::TCUTLINES;};
+ virtual
+ VISU::CutPlanes::Orientation
+ GetOrientationType2();
- 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
+ CORBA::Double
+ GetRotateX();
- virtual VISU::CutPlanes::Orientation GetOrientationType();
- virtual VISU::CutPlanes::Orientation GetOrientationType2();
+ virtual
+ CORBA::Double
+ GetRotateY();
- virtual CORBA::Double GetRotateX();
- virtual CORBA::Double GetRotateY();
+ virtual
+ CORBA::Double
+ GetRotateX2();
- virtual CORBA::Double GetRotateX2();
- virtual CORBA::Double GetRotateY2();
+ virtual
+ CORBA::Double
+ GetRotateY2();
- virtual void SetDisplacement(CORBA::Double theDisp);
- virtual CORBA::Double GetDisplacement();
+ virtual
+ void
+ SetDisplacement(CORBA::Double theDisp);
- virtual void SetDisplacement2(CORBA::Double theDisp);
- virtual CORBA::Double GetDisplacement2();
+ virtual
+ CORBA::Double
+ GetDisplacement();
- virtual void SetBasePlanePosition(CORBA::Double thePlanePosition);
- virtual CORBA::Double GetBasePlanePosition();
+ virtual
+ void
+ SetDisplacement2(CORBA::Double theDisp);
- virtual void SetLinePosition(CORBA::Long thePlaneNumber, CORBA::Double thePlanePosition);
- virtual CORBA::Double GetLinePosition(CORBA::Long thePlaneNumber);
+ virtual
+ CORBA::Double
+ GetDisplacement2();
- virtual void SetDefault();
- virtual CORBA::Boolean IsDefault();
+ virtual
+ void
+ SetBasePlanePosition(CORBA::Double thePlanePosition);
- virtual void SetDefaultPosition(CORBA::Long thePlaneNumber);
- virtual CORBA::Boolean IsDefaultPosition(CORBA::Long thePlaneNumber);
+ virtual
+ CORBA::Double
+ GetBasePlanePosition();
- 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
+ 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
+ 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);
+
+ typedef VISU::CutLines TInterface;
+ VISU_CutLinesPL*
+ GetSpecificPL() const
+ {
+ return myCutLinesPL;
+ }
+
protected:
- virtual void DoHook();
+ //! Extends VISU_ColoredPrs3d_i::CreatePipeLine
+ virtual
+ void
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
+
+ //! Extends VISU_ColoredPrs3d_i::CheckIsPossible
+ virtual
+ bool
+ CheckIsPossible();
VISU_CutLinesPL *myCutLinesPL;
TCurvesInv myMapCurvesInverted;
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);
+
+ //! Extends 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);
+ //! Extends VISU_ColoredPrs3d_i::ToStream
+ virtual
+ void
+ ToStream(std::ostringstream& theStr);
- virtual Storable* Restore(const Storable::TRestoringMap& theMap);
+ //! Extends VISU_ColoredPrs3d_i::Restore
+ virtual
+ Storable*
+ Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap);
+ //! 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"
-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 VISU::ScalarMap_i::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),
- 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),
+//----------------------------------------------------------------------------
+VISU::CutPlanes_i
+::CutPlanes_i(EPublishInStudyMode thePublishInStudyMode):
+ ColoredPrs3d_i(thePublishInStudyMode),
+ ScalarMap_i(thePublishInStudyMode),
myCutPlanesPL(NULL)
-{
-}
+{}
-VISU::Storable* VISU::CutPlanes_i::Create(const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration)
+//----------------------------------------------------------------------------
+VISU::Storable*
+VISU::CutPlanes_i
+::Create(const std::string& theMeshName,
+ VISU::Entity theEntity,
+ const std::string& theFieldName,
+ CORBA::Long theTimeStampNumber)
{
- return ScalarMap_i::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){
ScalarMap_i::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)
{
myCutPlanesPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(theOrient),
- theXAngle,theYAngle);
+ theXAngle,
+ theYAngle);
}
-VISU::CutPlanes::Orientation VISU::CutPlanes_i::GetOrientationType() {
+//----------------------------------------------------------------------------
+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){
+//----------------------------------------------------------------------------
+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) {
+//----------------------------------------------------------------------------
+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);
- ScalarMap_i::DoHook();
+ TSuperClass::CreatePipeLine(myCutPlanesPL);
+}
+
+
+//---------------------------------------------------------------
+bool
+VISU::CutPlanes_i
+::CheckIsPossible()
+{
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
}
+//----------------------------------------------------------------------------
VISU_Actor*
VISU::CutPlanes_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+::CreateActor()
{
- if(VISU_Actor* anActor = ScalarMap_i::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);
class VISU_CutPlanesPL;
-namespace VISU{
+namespace VISU
+{
class CutPlanes_i : public virtual POA_VISU::CutPlanes,
public virtual ScalarMap_i
{
typedef ScalarMap_i TSuperClass;
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
+ ~CutPlanes_i();
+
+ virtual
+ VISU::VISUType
+ GetType()
+ {
+ return VISU::TCUTPLANES;
+ }
- virtual VISU::VISUType GetType() { return VISU::TCUTPLANES;};
+ virtual
+ void
+ SetOrientation(VISU::CutPlanes::Orientation theOrient,
+ CORBA::Double theXAngle,
+ CORBA::Double theYAngle);
+
+ virtual
+ VISU::CutPlanes::Orientation
+ GetOrientationType();
- virtual void SetOrientation(VISU::CutPlanes::Orientation theOrient,
- CORBA::Double theXAngle, CORBA::Double theYAngle);
+ virtual
+ CORBA::Double
+ GetRotateX();
- virtual VISU::CutPlanes::Orientation GetOrientationType();
- virtual CORBA::Double GetRotateX();
- virtual CORBA::Double GetRotateY();
+ virtual
+ CORBA::Double
+ GetRotateY();
+
+ virtual
+ void
+ SetDisplacement(CORBA::Double theDisp);
+
+ virtual
+ CORBA::Double
+ GetDisplacement();
+
+ virtual
+ void
+ SetPlanePosition(CORBA::Long thePlaneNumber,
+ CORBA::Double thePlanePosition);
+ virtual
+ CORBA::Double
+ GetPlanePosition(CORBA::Long thePlaneNumber);
- virtual void SetDisplacement(CORBA::Double theDisp);
- virtual CORBA::Double GetDisplacement();
+ virtual
+ void
+ SetDefault(CORBA::Long thePlaneNumber);
- virtual void SetPlanePosition(CORBA::Long thePlaneNumber, CORBA::Double thePlanePosition);
- virtual CORBA::Double GetPlanePosition(CORBA::Long thePlaneNumber);
+ virtual
+ CORBA::Boolean
+ IsDefault(CORBA::Long thePlaneNumber);
- virtual void SetDefault(CORBA::Long thePlaneNumber);
- virtual CORBA::Boolean IsDefault(CORBA::Long thePlaneNumber);
+ virtual
+ void
+ SetNbPlanes(CORBA::Long theNb);
- virtual void SetNbPlanes(CORBA::Long theNb);
- virtual CORBA::Long GetNbPlanes();
+ virtual
+ CORBA::Long
+ GetNbPlanes();
typedef VISU::CutPlanes TInterface;
- VISU_CutPlanesPL* GetCutPlanesPL(){ return myCutPlanesPL;}
+ VISU_CutPlanesPL*
+ GetSpecificPL() const
+ {
+ return myCutPlanesPL;
+ }
+
protected:
- virtual void DoHook();
+ //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine
+ virtual
+ void
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
+
+ //! 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();
};
}
#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(!VISU::ScalarMap_i::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++);}
-const string VISU::DeformedShape_i::myComment = "DEFORMEDSHAPE";
-const char* VISU::DeformedShape_i::GetComment() const { return myComment.c_str();}
+//---------------------------------------------------------------
+QString
+VISU::DeformedShape_i
+::GenerateName()
+{
+ return VISU::GenerateName("Def.Shape",myNbPresent++);
+}
+//---------------------------------------------------------------
+const string VISU::DeformedShape_i::myComment = "DEFORMEDSHAPE";
-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),
- myDeformedShapePL(NULL)
-{
- if(MYDEBUG) MESSAGE("DeformedShape_i::DeformedShape_i");
+//---------------------------------------------------------------
+const char*
+VISU::DeformedShape_i
+::GetComment() const
+{
+ return myComment.c_str();
}
-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),
+//---------------------------------------------------------------
+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);
}
-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 ScalarMap_i::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){
- ScalarMap_i::ToStream(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;
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::DeformedShape_i
+::ShowColored(CORBA::Boolean theColored)
+{
+ myIsColored = theColored;
+ myParamsTime.Modified();
+}
- ScalarMap_i::DoHook();
+//---------------------------------------------------------------
+SALOMEDS::Color
+VISU::DeformedShape_i
+::GetColor()
+{
+ return myColor;
}
-void VISU::DeformedShape_i::SetMapScale(double theMapScale){
+//---------------------------------------------------------------
+void
+VISU::DeformedShape_i
+::SetColor(const SALOMEDS::Color& theColor)
+{
+ myColor = theColor;
+ myParamsTime.Modified();
+}
+
+
+//---------------------------------------------------------------
+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 = VISU::ScalarMap_i::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);
}
- VISU::ScalarMap_i::UpdateActor(theActor);
+ TSuperClass::UpdateActor(theActor);
}
}
class VISU_DeformedShapePL;
-namespace VISU{
+namespace VISU
+{
class DeformedShape_i : public virtual POA_VISU::DeformedShape,
public virtual ScalarMap_i
{
typedef ScalarMap_i TSuperClass;
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
+ void
+ SameAs(const Prs3d_i* theOrigin);
- virtual VISU::VISUType GetType() { return VISU::TDEFORMEDSHAPE;};
+ virtual
+ ~DeformedShape_i();
+
+ virtual
+ VISU::VISUType
+ GetType()
+ {
+ return VISU::TDEFORMEDSHAPE;
+ }
- virtual void SetScale(CORBA::Double theScale);
- virtual CORBA::Double GetScale();
+ virtual
+ void
+ 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
+ ShowColored(CORBA::Boolean theColored);
+
+ virtual
+ SALOMEDS::Color
+ GetColor();
+
+ virtual
+ void
+ SetColor(const SALOMEDS::Color& theColor);
typedef VISU::DeformedShape TInterface;
- VISU_DeformedShapePL* GetDeformedShapePL(){ return myDeformedShapePL;}
+ VISU_DeformedShapePL*
+ GetSpecificPL() const
+ {
+ return myDeformedShapePL;
+ }
+
protected:
- virtual void DoHook();
+ //! 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 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) ;
};
}
}
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;
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;
if(ScalarMapOnDeformedShape_i* aServant = dynamic_cast<ScalarMapOnDeformedShape_i*>(GetServant(anObj).in())){
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;
#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;
+#include "MULTIPR_API.hxx"
#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),
+VISU::GaussPoints_i
+::GaussPoints_i(EPublishInStudyMode thePublishInStudyMode) :
+ ColoredPrs3d_i(thePublishInStudyMode),
myGaussPointsPL(NULL),
- myIsColored(true),
myColor(Qt::blue),
myIsActiveLocalScalarBar(true),
myIsDispGlobalScalarBar(true),
}
-//----------------------------------------------------------------------------
-VISU::GaussPoints_i::
-GaussPoints_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
- ColoredPrs3d_i(theResult,theSObject),
- myGaussPointsPL(NULL),
- myIsColored(true),
- myColor(Qt::blue),
- myIsActiveLocalScalarBar(true),
- myIsDispGlobalScalarBar(true),
- 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;
+ 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
+ {
+ 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();
}
//----------------------------------------------------------------------------
::UpdateScalarBar(vtkScalarBarActor *theScalarBar,
vtkLookupTable* theLookupTable)
{
- theScalarBar->SetTitle(myTitle.c_str());
- theScalarBar->SetOrientation(myOrientation);
- theScalarBar->SetNumberOfLabels(myNumberOfLabels);
+ theScalarBar->SetTitle(GetScalarBarTitle().c_str());
+ 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
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_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::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(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(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(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)
+
+ //----------------------------------------------------------------------------
+ void
+ CorrectSObjectType(SALOMEDS::SObject_ptr theSObject)
{
SALOMEDS::GenericAttribute_var anAttr;
if ( theSObject->FindAttribute(anAttr, "AttributeComment") ) {
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::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();
}
Table_ptr VISU_Gen_i::CreateTable(const char* theTableEntry){
// 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
- 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"
-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 VISU::ScalarMap_i::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++);
+}
+//---------------------------------------------------------------
+const string VISU::IsoSurfaces_i::myComment = "ISOSURFACES";
-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),
- myIsoSurfacesPL(NULL)
-{}
+//---------------------------------------------------------------
+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),
+//---------------------------------------------------------------
+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 ScalarMap_i::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){
- ScalarMap_i::ToStream(theStr);
+
+//---------------------------------------------------------------
+void
+VISU::IsoSurfaces_i
+::ToStream(std::ostringstream& theStr)
+{
+ TSuperClass::ToStream(theStr);
Storable::DataToStream( theStr, "myNbSurface", int(GetNbSurfaces()) );
Storable::DataToStream( theStr, "myRange[0]", GetSubMin() );
}
-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)
+{
myIsoSurfacesPL->SetNbParts(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);
+}
+
- ScalarMap_i::DoHook();
+//----------------------------------------------------------------------------
+void
+VISU::IsoSurfaces_i
+::DoSetInput(bool theIsInitilizePipe, bool theReInit)
+{
+ TSuperClass::DoSetInput(theIsInitilizePipe, theReInit);
+ if(theIsInitilizePipe || (!IsTimeStampFixed() && !IsRangeFixed()) || theReInit)
+ SetSubRange(GetSourceMin(), GetSourceMax());
}
+//---------------------------------------------------------------
+bool
+VISU::IsoSurfaces_i
+::CheckIsPossible()
+{
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
+}
+
+//---------------------------------------------------------------
VISU_Actor*
VISU::IsoSurfaces_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+::CreateActor()
{
- if(VISU_Actor* anActor = ScalarMap_i::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);
}
class VISU_IsoSurfacesPL;
-namespace VISU{
+namespace VISU
+{
class IsoSurfaces_i : public virtual POA_VISU::IsoSurfaces,
public virtual ScalarMap_i
{
typedef ScalarMap_i TSuperClass;
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
+ ~IsoSurfaces_i();
- virtual VISU::VISUType GetType() { return VISU::TISOSURFACE;};
+ virtual
+ VISU::VISUType
+ GetType()
+ {
+ return VISU::TISOSURFACE;
+ }
- virtual void SetNbSurfaces(CORBA::Long theNb);
- virtual CORBA::Long GetNbSurfaces();
+ virtual
+ void
+ SetNbSurfaces(CORBA::Long theNb);
- virtual void SetSubRange(CORBA::Double theMin, CORBA::Double theMax);
- virtual CORBA::Double GetSubMin();
- virtual CORBA::Double GetSubMax();
+ virtual
+ CORBA::Long
+ GetNbSurfaces();
+
+ virtual
+ void
+ SetSubRange(CORBA::Double theMin, CORBA::Double theMax);
+
+ virtual
+ CORBA::Double
+ GetSubMin();
+
+ virtual
+ CORBA::Double
+ GetSubMax();
typedef VISU::IsoSurfaces TInterface;
- VISU_IsoSurfacesPL* GetIsoSurfacesPL(){ return myIsoSurfacesPL;}
+ VISU_IsoSurfacesPL*
+ GetSpecificPL() const
+ {
+ return myIsoSurfacesPL;
+ }
+
protected:
- virtual void DoHook();
+ //! 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 Storable* Restore(const Storable::TRestoringMap& theMap);
+ virtual
+ QString
+ GenerateName();
+
+ 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 "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++);}
+//----------------------------------------------------------------------------
+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())
-{
- myPipeLine = myMeshPL;
+//----------------------------------------------------------------------------
+const char*
+VISU::Mesh_i
+::GetComment() const
+{
+ return myComment.c_str();
}
-
-VISU::Mesh_i::
-Mesh_i(Result_i* theResult,
- SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theSObject),
+//----------------------------------------------------------------------------
+VISU::Mesh_i
+::Mesh_i():
myMeshPL(VISU_MeshPL::New())
{
- myPipeLine = myMeshPL;
+ SetPipeLine(myMeshPL);
}
-//---------------------------------------------------------------
-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();
- }
- };
-
- ProcessVoidEvent(new TRemoveFromStudy(this));
-}
-
-
-void VISU::Mesh_i::SameAs (const Prs3d_i* theOrigin)
-{
- return; // "SameAs" command for mesh is not valid in current architecture
-}
-
-
-
-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);
}
-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();
+ }
+ };
+
+ ProcessVoidEvent(new TRemoveFromStudy(this));
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::Mesh_i
+::SetCellColor(const SALOMEDS::Color& theColor)
+{
+ myCellColor = theColor;
+}
+
+
+//----------------------------------------------------------------------------
+SALOMEDS::Color
+VISU::Mesh_i
+::GetCellColor()
+{
+ return myCellColor;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::Mesh_i
+::SetNodeColor(const SALOMEDS::Color& theColor)
+{
+ myNodeColor = theColor;
+}
+
+
+//----------------------------------------------------------------------------
+SALOMEDS::Color
+VISU::Mesh_i
+::GetNodeColor()
+{
+ return myNodeColor;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::Mesh_i
+::SetLinkColor(const SALOMEDS::Color& theColor)
+{
+ myLinkColor = theColor;
+}
+
+
+//----------------------------------------------------------------------------
+SALOMEDS::Color
+VISU::Mesh_i
+::GetLinkColor()
+{
+ return myLinkColor;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::Mesh_i
+::SetPresentationType(VISU::PresentationType theType)
+{
+ myPresentType = theType;
+}
+
+
+//----------------------------------------------------------------------------
+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 virtual Prs3d_i
{
static int myNbPresent;
- Mesh_i();
Mesh_i(const Mesh_i&);
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 VISU::ScalarMap_i::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),
- myPlot3DPL(NULL)
-{}
+::GetComment() const
+{
+ return myComment.c_str();
+}
+
+//---------------------------------------------------------------
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),
+::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 ScalarMap_i::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)
{
- ScalarMap_i::ToStream(theStr);
+ TSuperClass::ToStream(theStr);
Storable::DataToStream(theStr, "myBasePlane", int(GetOrientationType()));
Storable::DataToStream(theStr, "aRot[0]", GetRotateX());
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);
- ScalarMap_i::DoHook();
+ TSuperClass::CreatePipeLine(myPlot3DPL);
}
+
+//---------------------------------------------------------------
+bool
+VISU::Plot3D_i
+::CheckIsPossible()
+{
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
+}
+
+//---------------------------------------------------------------
VISU_Actor*
VISU::Plot3D_i
-::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+::CreateActor()
{
- if(VISU_Actor* anActor = ScalarMap_i::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);
}
class VISU_Plot3DPL;
-namespace VISU {
+namespace VISU
+{
class Plot3D_i : public virtual POA_VISU::Plot3D,
public virtual ScalarMap_i
{
typedef ScalarMap_i TSuperClass;
explicit
- Plot3D_i (Result_i* theResult, bool theAddToStudy = true);
- explicit
- Plot3D_i (Result_i* theResult, SALOMEDS::SObject_ptr theSObject);
+ Plot3D_i(EPublishInStudyMode thePublishInStudyModep);
- virtual ~Plot3D_i();
+ virtual
+ ~Plot3D_i();
- virtual VISU::VISUType GetType() { return VISU::TPLOT3D; };
+ virtual
+ VISU::VISUType
+ GetType()
+ {
+ return VISU::TPLOT3D;
+ }
+
+ virtual
+ void
+ SetOrientation (VISU::Plot3D::Orientation theOrient,
+ CORBA::Double theXAngle,
+ CORBA::Double theYAngle);
- virtual void SetOrientation (VISU::Plot3D::Orientation theOrient,
- CORBA::Double theXAngle, CORBA::Double theYAngle);
+ virtual
+ VISU::Plot3D::Orientation
+ GetOrientationType();
- virtual VISU::Plot3D::Orientation GetOrientationType();
+ virtual
+ CORBA::Double
+ GetRotateX();
- virtual CORBA::Double GetRotateX();
- virtual CORBA::Double GetRotateY();
+ virtual
+ CORBA::Double
+ GetRotateY();
- virtual void SetPlanePosition (CORBA::Double thePlanePosition,
- CORBA::Boolean theIsRelative);
- virtual CORBA::Double GetPlanePosition();
- virtual CORBA::Boolean IsPositionRelative();
+ virtual
+ void
+ SetPlanePosition(CORBA::Double thePlanePosition,
+ CORBA::Boolean theIsRelative);
- virtual void SetScaleFactor (CORBA::Double theScaleFactor);
- virtual CORBA::Double GetScaleFactor();
+ virtual
+ CORBA::Double
+ GetPlanePosition();
- virtual void SetContourPrs (CORBA::Boolean theIsContourPrs );
- CORBA::Boolean GetIsContourPrs();
+ virtual
+ CORBA::Boolean
+ IsPositionRelative();
- virtual void SetNbOfContours (CORBA::Long theNb);
- virtual CORBA::Long GetNbOfContours();
+ virtual
+ void
+ SetScaleFactor(CORBA::Double theScaleFactor);
- typedef VISU::Plot3D TInterface;
- VISU_Plot3DPL* GetPlot3DPL() { return myPlot3DPL; }
+ virtual
+ CORBA::Double
+ GetScaleFactor();
+
+ virtual
+ void
+ SetContourPrs(CORBA::Boolean theIsContourPrs);
+
+ CORBA::Boolean
+ GetIsContourPrs();
+
+ virtual
+ void
+ SetNbOfContours(CORBA::Long theNb);
- void SetMapScale(double theMapScale);
+ virtual
+ CORBA::Long
+ GetNbOfContours();
+ typedef VISU::Plot3D TInterface;
+
+ VISU_Plot3DPL*
+ GetSpecificPL() const
+ {
+ return myPlot3DPL;
+ }
+
protected:
- virtual void DoHook();
+ //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine
+ virtual
+ void
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
+
+ //! 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();
+
+ 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();
}
-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)
-{
- if(MYDEBUG) MESSAGE("Prs3d_i::Prs3d_i - this = "<<this);
- myOffset[0] = myOffset[1] = myOffset[2] = 0;
- myActorCollection->Delete();
- myResult->Register();
-}
+//----------------------------------------------------------------------------
void
VISU::Prs3d_i
::SameAs(const Prs3d_i* theOrigin)
{
- if (Prs3d_i* aOrigin = const_cast<Prs3d_i*>(theOrigin)) {
- myPipeLine->SameAs(aOrigin->GetPL());
- aOrigin->GetOffset(myOffset);
+ if(Prs3d_i* anOrigin = const_cast<Prs3d_i*>(theOrigin)){
+ GetPipeLine()->SameAs(anOrigin->GetPipeLine());
+ anOrigin->GetOffset(myOffset);
}
}
+
+//----------------------------------------------------------------------------
VISU::Prs3d_i
::~Prs3d_i()
{
if(MYDEBUG) MESSAGE("Prs3d_i::~Prs3d_i - this = "<<this);
myRemoveActorsFromRendererSignal();
- myPipeLine->Delete();
- myResult->Destroy();
}
+//----------------------------------------------------------------------------
+bool
+VISU::Prs3d_i
+::SetInput(bool theReInit)
+{
+ if(GetCResult()){
+ if(myMeshName != ""){
+ myPreviousResult = myResult;
+ myPreviousMeshName = myMeshName;
+ return true;
+ }
+ }
+ return false;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::OnRestoreInput()
+{
+ SetCResult(myPreviousResult);
+ myMeshName = myPreviousMeshName;
+}
+
+
+//----------------------------------------------------------------------------
+CORBA::Boolean
+VISU::Prs3d_i
+::Apply(bool theReInit)
+{
+ try{
+ if(SetInput(theReInit)){
+ 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
+::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)
+{
+ SetCResult(VISU::GetResult(GetStudyDocument(), theResultEntry));
+}
+
+//----------------------------------------------------------------------------
+std::string
+VISU::Prs3d_i
+::GetResultEntry()
+{
+ if(VISU::Result_i* aResult = GetCResult())
+ return aResult->GetEntry();
+ return "";
+}
+
+//----------------------------------------------------------------------------
+VISU::Result_i*
+VISU::Prs3d_i
+::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()
+{
+ 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(const Storable::TRestoringMap& theMap)
+::Restore(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
{
- myName = VISU::Storable::FindValue(theMap,"myName").latin1();
+ 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
+::SaveRestoringState(SALOMEDS::Study_ptr theStudy,
+ const Storable::TRestoringMap& theMap)
+{
+ myRestoringStudy = SALOMEDS::Study::_duplicate(theStudy);
+ myRestoringMap = theMap;
+ myIsRestored = false;
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::InitFromRestoringState()
+{
+ if(!myIsRestored){
+ Restore(myRestoringStudy, myRestoringMap);
+ myIsRestored = true;
+ }
+}
+
+//----------------------------------------------------------------------------
void
VISU::Prs3d_i
::ToStream(std::ostringstream& theStr)
{
- Storable::DataToStream( theStr, "myName", myName.c_str() );
+ 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] );
VISU::Prs3d_i
::GetSObject()
{
- if(CORBA::is_nil(mySObject.in())){
- const SALOMEDS::Study_var& aStudy = myResult->GetStudyDocument();
+ const SALOMEDS::Study_var& aStudy = GetStudyDocument();
+ if(!CORBA::is_nil(aStudy.in())){
CORBA::String_var anIOR = GetID();
- mySObject = aStudy->FindObjectIOR(anIOR);
+ return aStudy->FindObjectIOR(anIOR);
}
- return mySObject;
-}
-
-Result_i*
-VISU::Prs3d_i
-::GetResult() const
-{
- return myResult;
-}
-
-const std::string&
-VISU::Prs3d_i
-::GetMeshName() const
-{
- return myMeshName;
+ 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 !!!");
}
+
+//----------------------------------------------------------------------------
+struct TRemoveFromStudy: public SALOME_Event
+{
+ VISU::Prs3d_i* myRemovable;
+ typedef boost::signal0<void> TRemoveFromStudySignal;
+ const TRemoveFromStudySignal& myRemoveFromStudySignal;
+
+ TRemoveFromStudy(VISU::Prs3d_i* theRemovable,
+ const TRemoveFromStudySignal& theRemoveFromStudySignal):
+ myRemovable(theRemovable),
+ myRemoveFromStudySignal(theRemoveFromStudySignal)
+ {}
+
+ virtual
+ void
+ Execute()
+ {
+ myRemoveFromStudySignal();
+ myRemovable->Destroy();
+ }
+};
+
+//----------------------------------------------------------------------------
void
VISU::Prs3d_i
::RemoveFromStudy()
{
- struct TRemoveFromStudy: public SALOME_Event
- {
- VISU::Prs3d_i* myRemovable;
- typedef boost::signal0<void> TRemoveFromStudySignal;
- const TRemoveFromStudySignal& myRemoveFromStudySignal;
-
- TRemoveFromStudy(VISU::Prs3d_i* theRemovable,
- const TRemoveFromStudySignal& theRemoveFromStudySignal):
- myRemovable(theRemovable),
- myRemoveFromStudySignal(theRemoveFromStudySignal)
- {}
-
- virtual
- void
- Execute()
- {
- myRemoveFromStudySignal();
- myRemovable->Destroy();
- }
- };
-
ProcessVoidEvent(new TRemoveFromStudy(this,myRemoveActorsFromRendererSignal));
}
//----------------------------------------------------------------------------
VISU_PipeLine*
VISU::Prs3d_i
-::GetPipeLine()
+::GetPipeLine() const
+{
+ if(!myPipeLine.GetPointer())
+ throw std::runtime_error("VISU::Prs3d_i::myPipeLine == NULL !!!");
+
+ return myPipeLine.GetPointer();
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::SetPipeLine(VISU_PipeLine* thePipeLine)
{
- return GetPL();
+ myPipeLine = thePipeLine;
+ if(thePipeLine)
+ thePipeLine->Delete();
}
+//----------------------------------------------------------------------------
+bool
+VISU::Prs3d_i
+::IsPipeLineExists()
+{
+ return myPipeLine.GetPointer() != NULL;
+}
+
+//----------------------------------------------------------------------------
VISU_PipeLine*
VISU::Prs3d_i
-::GetPL()
+::GetActorPipeLine()
{
- return myPipeLine;
+ return GetPipeLine();
}
-vtkUnstructuredGrid*
-VISU::Prs3d_i::
-GetInput()
+//----------------------------------------------------------------------------
+vtkDataSet*
+VISU::Prs3d_i
+::GetInput()
{
- return myPipeLine->GetInput();
+ return GetPipeLine()->GetInput();
+}
+
+//----------------------------------------------------------------------------
+Handle(SALOME_InteractiveObject)
+VISU::Prs3d_i
+::GetIO()
+{
+ 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()
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
::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*
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
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
VISU::Prs3d_i
::GetOffset(CORBA::Float& theDx,
//----------------------------------------------------------------------------
-VISU::Result_i*
-VISU::GetResult(SALOMEDS::SObject_ptr theSObject)
+CORBA::Float
+VISU::Prs3d_i
+::GetMemorySize()
{
- VISU::Result_var aResult = FindResult(theSObject);
- if(!aResult->_is_nil())
- return dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());
- return NULL;
+ // 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
{
public virtual PrsObject_i
{
- Prs3d_i();
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;
- }
//----------------------------------------------------------------------------
}
// 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 PrsObject_i : public virtual POA_VISU::PrsObject,
- public virtual RemovableObject_i
+namespace VISU
+{
+ //----------------------------------------------------------------------------
+ class 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 PrsObject_i : public virtual POA_VISU::PrsObject,
+ public virtual RemovableObject_i
+ {
+ PrsObject_i(const PrsObject_i&);
+ SALOMEDS::Study_var myStudy;
+
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>
+// MULTIPR
+#include "MULTIPR_Obj.hxx"
+
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(AttributeComment) 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);
}
+
+ // MULTIPR
+ aMesh->myPartsEntry =
+ CreateAttributes(theStudy,
+ aMesh->myEntry,
+ "",
+ "",
+ "",
+ true);
//Import entities
TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
//---------------------------------------------------------------
- void
- BuildFields(Result_i* theResult,
- VISU_Convertor* theInput,
- CORBA::Boolean* theIsDone,
- CORBA::Boolean theIsBuild,
- CORBA::Boolean theIsAtOnce,
- _PTR(Study) theStudy)
- {
- if(!theIsBuild || *theIsDone)
- return;
+void BuildFields(
+ Result_i* theResult,
+ VISU_Convertor* theInput,
+ CORBA::Boolean* theIsDone,
+ CORBA::Boolean theIsBuild,
+ CORBA::Boolean theIsAtOnce,
+ _PTR(Study) theStudy)
+{
+ if(!theIsBuild || *theIsDone)
+ return;
- TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildFields");
- TResultManager aResultManager(theResult);
- TTransactionManager aTransactionManager(theStudy);
+ TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildFields");
+ TResultManager aResultManager(theResult);
+ TTransactionManager aTransactionManager(theStudy);
- {
- TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildFields");
- theInput->BuildFields();
- }
+ {
+ TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildFields");
+ theInput->BuildFields();
+ }
- QString aComment,aTmp;
- const TMeshMap& aMeshMap = theInput->GetMeshMap();
- TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
- 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++){
- 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){
- aComment = "";
- aComment.append("myComment=FIELDS;");
- aComment.append("myMeshName=");aComment.append(aMeshName);
-
- UpdateAttributes(theStudy,
- aMesh->myFieldsEntry,
- "",
- "Fields",
- aComment.latin1());
+ QString aComment,aTmp;
+ const TMeshMap& aMeshMap = theInput->GetMeshMap();
+ TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
- anIsFieldsEntryUpdated = true;
- }
- const string& aFieldName = aFieldMapIter->first;
- const PField& aField = aFieldMapIter->second;
- const TValField& aValField = aField->myValField;
- QString aFieldNameWithUnit = GenerateFieldName(aFieldName,aField->myUnitNames[0]);
- aComment = "";
- aComment.sprintf("myComment=FIELD;myType=%d;",TFIELD);
- aComment.append("myMeshName=");aComment.append(aMeshName);aComment.append(";");
- aComment.append(aTmp.sprintf("myEntityId=%d;",anEntity));
- 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,
- aMeshOnEntity->myEntry);
- TValField::const_iterator aValFieldIter = aValField.begin();
- for(; aValFieldIter != aValField.end(); aValFieldIter++){
- int aTimeStamp = aValFieldIter->first;
- const PValForTime& aValForTime = aValFieldIter->second;
- aComment = "";
- aComment.sprintf("myComment=TIMESTAMP;myType=%d;",TTIMESTAMP);
- aComment.append("myMeshName=");aComment.append(aMeshName);aComment.append(";");
- 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);
- }
+ 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++)
+ {
+ 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)
+ {
+ aComment = "";
+ aComment.append("myComment=FIELDS;");
+ aComment.append("myMeshName=");aComment.append(aMeshName);
+
+ UpdateAttributes(
+ theStudy,
+ aMesh->myFieldsEntry,
+ "",
+ "Fields",
+ aComment.latin1());
+
+ anIsFieldsEntryUpdated = true;
+ }
+
+ const string& aFieldName = aFieldMapIter->first;
+ const PField& aField = aFieldMapIter->second;
+ const TValField& aValField = aField->myValField;
+ QString aFieldNameWithUnit = GenerateFieldName(aFieldName,aField->myUnitNames[0]);
+ aComment = "";
+ aComment.sprintf("myComment=FIELD;myType=%d;",TFIELD);
+ aComment.append("myMeshName=");aComment.append(aMeshName);aComment.append(";");
+ aComment.append(aTmp.sprintf("myEntityId=%d;",anEntity));
+ 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,
+ aMeshOnEntity->myEntry);
+
+ TValField::const_iterator aValFieldIter = aValField.begin();
+
+ for(; aValFieldIter != aValField.end(); aValFieldIter++)
+ {
+ int aTimeStamp = aValFieldIter->first;
+ const PValForTime& aValForTime = aValFieldIter->second;
+ aComment = "";
+ aComment.sprintf("myComment=TIMESTAMP;myType=%d;",TTIMESTAMP);
+ aComment.append("myMeshName=");aComment.append(aMeshName);aComment.append(";");
+ 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);
+ }
+ }
+ }
+
+ if(!anIsFieldsEntryUpdated && !theIsAtOnce)
+
+ RemoveSObject(theStudy, aMesh->myFieldsEntry);
}
- }
- if(!anIsFieldsEntryUpdated && !theIsAtOnce)
- RemoveSObject(theStudy,
- aMesh->myFieldsEntry);
- }
+ ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
+}
+
+
+// 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
+ cout<<theResult->GetFileInfoMultipr().filePath()<<endl;
+ if (strlen(theResult->GetFileInfoMultipr().filePath().latin1()) == 0)
+ return;
+
+ QApplication::setOverrideCursor(Qt::waitCursor);
+
+ try
+ {
+ multipr::Obj multiprObj;
+ multiprObj.create(theResult->GetFileInfoMultipr().filePath().latin1());
+ if (multiprObj.isValidDistributedMEDFile())
+ {
+ theResult->SetIsDistributedMEDMultipr(true);
- ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
- }
+ 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");
+ }
+
+ QApplication::restoreOverrideCursor();
+
+ ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
+}
//---------------------------------------------------------------
Result_i::TUpdateMinMaxSignal* myUpdateMinMaxSignal;
CORBA::Boolean* myIsGroupsDone;
CORBA::Boolean myIsBuildGroups;
- _PTR(Study) myStudy;
+ CORBA::Boolean* myIsPartsDone;
+ CORBA::Boolean myIsBuildParts;
+ _PTR(Study) myStudy;
TBuildArgs(Result_i* theResult,
VISU_Convertor* theInput,
Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal,
CORBA::Boolean* theIsGroupsDone,
CORBA::Boolean theIsBuildGroups,
- _PTR(Study) theStudy):
+ CORBA::Boolean* theIsPartsDone,
+ CORBA::Boolean theIsBuildParts,
+ _PTR(Study) theStudy):
myResult(theResult),
myInput(theInput),
myIsEntitiesDone(theIsEntitiesDone),
myUpdateMinMaxSignal(theUpdateMinMaxSignal),
myIsGroupsDone(theIsGroupsDone),
myIsBuildGroups(theIsBuildGroups),
- myStudy(theStudy)
+ myIsPartsDone(theIsPartsDone),
+ myIsBuildParts(theIsBuildParts),
+ myStudy(theStudy)
{}
};
void
BuildDataTree(TBuildArgs theBuildArgs)
{
+
BuildEntities(theBuildArgs.myResult,
theBuildArgs.myInput,
theBuildArgs.myIsEntitiesDone,
theBuildArgs.myIsBuildGroups,
theBuildArgs.myIsBuildFields,
theBuildArgs.myStudy);
- {
+
+ {
boost::thread aThread(boost::bind(&BuildGroups,
theBuildArgs.myResult,
theBuildArgs.myInput,
theBuildArgs.myUpdateMinMaxSignal,
theBuildArgs.myStudy));
}
+
+ /*
+ // MULTIPR
+ BuildParts(
+ theBuildArgs.myResult,
+ theBuildArgs.myInput,
+ theBuildArgs.myIsPartsDone,
+ theBuildArgs.myIsBuildParts,
+ false,
+ theBuildArgs.myStudy);
+ */
}
}
myIsBuildFields(theIsBuildFields),
myIsBuildMinMax(theIsBuildMinMax),
myIsBuildGroups(theIsBuildGroups),
+ myIsBuildParts(true),
myIsEntitiesDone(false),
myIsFieldsDone(false),
myIsGroupsDone(false),
myIsMinMaxDone(false),
+ myIsPartsDone(false),
myIsAllDone(false),
myInput(NULL)
{
myStudy = ProcessEvent(new TGetStudy(myStudyDocument->StudyId()));
+ myIsDistributedMEDMultipr = false;
}
//---------------------------------------------------------------
-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){
myIsBuildMinMax,
&myUpdateMinMaxSignal);
+ // MULTIPR
+ BuildParts(this,
+ myInput,
+ &myIsPartsDone,
+ myIsBuildParts,
+ theIsAtOnce,
+ myStudy);
+
}else{
- TBuildArgs aBuildArgs(this,
- myInput,
- &myIsEntitiesDone,
- aResultEntry,
- &myIsFieldsDone,
- myIsBuildFields,
- &myIsMinMaxDone,
- myIsBuildMinMax,
- &myUpdateMinMaxSignal,
- &myIsGroupsDone,
- myIsBuildGroups,
- myStudy);
- boost::thread aThread(boost::bind(&BuildDataTree,
- aBuildArgs));
+
+ if (strlen(GetFileInfoMultipr().filePath().latin1()) == 0)
+ {
+ // sequential MED file
+ TBuildArgs aBuildArgs(this,
+ myInput,
+ &myIsEntitiesDone,
+ aResultEntry,
+ &myIsFieldsDone,
+ myIsBuildFields,
+ &myIsMinMaxDone,
+ myIsBuildMinMax,
+ &myUpdateMinMaxSignal,
+ &myIsGroupsDone,
+ myIsBuildGroups,
+ &myIsPartsDone,
+ myIsBuildParts,
+ myStudy);
+ boost::thread aThread(boost::bind(&BuildDataTree, aBuildArgs));
+ }
+ 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);
+ }
}
return this;
VISU::Storable*
VISU::Result_i::
Create(const char* theFileName)
-{
+{
+
try{
myFileInfo.setFile(theFileName);
+
+ // 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("");
+ }
+
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());
return "";
}
-string
+std::string
VISU::Result_i
::GetEntry()
{
CORBA::String_var anEntry = mySObject->GetID();
- return string(anEntry);
+ return anEntry.in();
}
const SALOMEDS::SObject_var&
return components;
}
- VISU::PIDMapper anIDMapper = myInput->GetMeshOnEntity(theMeshName,
- CELL_ENTITY);
- VISU::TVTKOutput* aMesh = anIDMapper->GetVTKOutput();
+ VISU::PUnstructuredGridIDMapper anIDMapper = myInput->GetMeshOnEntity(theMeshName,
+ CELL_ENTITY);
+ vtkUnstructuredGrid* aMesh = anIDMapper->GetUnstructuredGridOutput();
if ( !aMesh || aMesh->GetNumberOfCells() == 0 ) {
MESSAGE( "No cells in the mesh: " << theMeshName );
return components;
}
+
+
+//=======================================================================
+// 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;
+}
+
#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;
+
+ // MULTIPR
+ QFileInfo myFileInfoMultipr;
+ std::map<std::string, std::string> myMapPartNameToMEDFilename;
+ std::map<std::string, char> mySelectedResolutionMultipr;
+ bool myIsDistributedMEDMultipr;
protected:
virtual Storable* Build(SALOMEDS::SObject_ptr theSObject,
CORBA::Boolean myIsFieldsDone;
CORBA::Boolean myIsGroupsDone;
CORBA::Boolean myIsMinMaxDone;
+ CORBA::Boolean myIsPartsDone; // MULTIPR
CORBA::Boolean myIsBuildFields;
CORBA::Boolean myIsBuildGroups;
CORBA::Boolean myIsBuildMinMax;
+ CORBA::Boolean myIsBuildParts; // MULTIPR
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;}
+ const QFileInfo& GetFileInfoMultipr() const { return myFileInfoMultipr;}
const std::string& GetFileName() const { return myInitFileName;}
const ECreationId& GetCreationId() const { return myCreationId;}
+
+ // 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;
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
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 = VISU::ScalarMap_i::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),
- 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),
+//---------------------------------------------------------------
+const string VISU::ScalarMapOnDeformedShape_i::myComment = "SCALARMAPONDEFORMEDSHAPE";
+
+//---------------------------------------------------------------
+const char*
+VISU::ScalarMapOnDeformedShape_i
+::GetComment() const
+{
+ return myComment.c_str();
+}
+
+
+//---------------------------------------------------------------
+VISU::ScalarMapOnDeformedShape_i
+::ScalarMapOnDeformedShape_i(EPublishInStudyMode thePublishInStudyMode) :
+ ColoredPrs3d_i(thePublishInStudyMode),
+ ScalarMap_i(thePublishInStudyMode),
myScalarMapOnDeformedShapePL(NULL),
myScalarIteration(1)
-{
-}
+{}
+
-VISU::Storable* VISU::ScalarMapOnDeformedShape_i::Create(const char* theMeshName, VISU::Entity theEntity,
- const char* theFieldName, int theIteration)
+//---------------------------------------------------------------
+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);
+ VISU::Storable* aRes = TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
SetScalarFieldName(theFieldName);
- SetScalarIteration(theIteration);
+ SetScalarIteration(theTimeStampNumber);
SetScalarMeshName(theMeshName);
int anEntity = theEntity;
SetScalarEntity(VISU::TEntity(anEntity));
- SetScalarField(myScalarMeshName.c_str(),myScalarFieldName.c_str(),myScalarIteration,myScalarEntity);
+ SetCScalarField(myScalarMeshName,myScalarFieldName,myScalarIteration,myScalarEntity);
return aRes;
}
-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);
+ if(!TSuperClass::Restore(theStudy, theMap))
+ return NULL;
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());
+ SetCScalarField(GetScalarMeshName(),
+ GetScalarFieldName(),
+ GetScalarIteration(),
+ GetScalarEntity());
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, "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());
+
+ this->SetCScalarField(anOrigin->GetScalarMeshName(),
+ anOrigin->GetScalarFieldName(),
+ theScalarIter,
+ anOrigin->GetScalarEntity());
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 VISU::ScalarMapOnDeformedShape_i::SetSourceRange(CORBA::Double theMinRange,CORBA::Double theMaxRange){
- vtkFloatingPointType aRange[2];
- aRange[0] = vtkFloatingPointType(theMinRange);
- aRange[1] = vtkFloatingPointType(theMaxRange);
- myScalarMapOnDeformedShapePL->SetScalarRange(aRange);
+
+//---------------------------------------------------------------
+CORBA::Boolean
+VISU::ScalarMapOnDeformedShape_i
+::IsColored()
+{
+ return myIsColored;
+}
+
+
+//---------------------------------------------------------------
+void
+VISU::ScalarMapOnDeformedShape_i
+::ShowColored(CORBA::Boolean theColored)
+{
+ 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);
}
-VISU_Actor* VISU::ScalarMapOnDeformedShape_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
+
+//---------------------------------------------------------------
+bool
+VISU::ScalarMapOnDeformedShape_i
+::CheckIsPossible()
+{
+ return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
+}
+
+
+//---------------------------------------------------------------
+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
+::SetCScalarField(const std::string& theMeshName,
+ const std::string& theFieldName,
+ int theIteration,
+ VISU::TEntity theEntity)
{
- 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);
- }
+ VISU::Result_i::TInput* anInput = GetCResult()->GetInput();
+ SetField(anInput->GetField(theMeshName,theEntity,theFieldName));
+
+ VISU::PUnstructuredGridIDMapper anIDMapper =
+ anInput->GetTimeStampOnMesh(theMeshName,
+ theEntity,
+ theFieldName,
+ theIteration);
+
+ vtkUnstructuredGrid* anOutput = anIDMapper->GetUnstructuredGridOutput();
+ if(myScalarMapOnDeformedShapePL && anOutput)
+ myScalarMapOnDeformedShapePL->SetScalars(anOutput);
+
this->SetScalarMeshName(theMeshName);
this->SetScalarFieldName(theFieldName);
this->SetScalarIteration(theIteration);
this->SetScalarEntity(theEntity);
}
-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 theIteration,
+ VISU::Entity theEntity)
{
- this->SetScalarField(theMeshName,theFieldName,(int)theIteration,VISU::TEntity(theEntity));
+ this->SetCScalarField(theMeshName,theFieldName,(int)theIteration,VISU::TEntity(theEntity));
}
-void VISU::ScalarMapOnDeformedShape_i::SetScalarMeshName(const char* theName){
- myScalarMeshName = theName;
+
+//---------------------------------------------------------------
+void
+VISU::ScalarMapOnDeformedShape_i
+::SetScalarMeshName(const std::string& theName)
+{
+ if(myScalarMeshName != theName){
+ myScalarMeshName = theName;
+ myParamsTime.Modified();
+ }
}
-std::string VISU::ScalarMapOnDeformedShape_i::GetScalarMeshName(){
+
+//---------------------------------------------------------------
+std::string
+VISU::ScalarMapOnDeformedShape_i
+::GetScalarMeshName()
+{
return myScalarMeshName;
}
-void VISU::ScalarMapOnDeformedShape_i::SetScalarFieldName(const char* theName){
- myScalarFieldName = theName;
+//---------------------------------------------------------------
+void
+VISU::ScalarMapOnDeformedShape_i
+::SetScalarFieldName(const std::string& theName)
+{
+ if(myScalarFieldName != theName){
+ myScalarFieldName = theName;
+ myParamsTime.Modified();
+ }
}
-std::string VISU::ScalarMapOnDeformedShape_i::GetScalarFieldName(){
+
+//---------------------------------------------------------------
+std::string
+VISU::ScalarMapOnDeformedShape_i
+::GetScalarFieldName()
+{
return myScalarFieldName;
}
-void VISU::ScalarMapOnDeformedShape_i::SetScalarIteration(const int theValue){
- myScalarIteration = theValue;
+//---------------------------------------------------------------
+void
+VISU::ScalarMapOnDeformedShape_i
+::SetScalarIteration(const int theValue)
+{
+ if(myScalarIteration != theValue){
+ myScalarIteration = theValue;
+ myParamsTime.Modified();
+ }
}
-int VISU::ScalarMapOnDeformedShape_i::GetScalarIteration(){
+//---------------------------------------------------------------
+int
+VISU::ScalarMapOnDeformedShape_i
+::GetScalarIteration()
+{
return myScalarIteration;
}
-void VISU::ScalarMapOnDeformedShape_i::SetScalarEntity(const VISU::TEntity theValue){
- myScalarEntity = theValue;
+//---------------------------------------------------------------
+void
+VISU::ScalarMapOnDeformedShape_i
+::SetScalarEntity(const VISU::TEntity theValue)
+{
+ if(myScalarEntity != theValue){
+ myScalarEntity = theValue;
+ myParamsTime.Modified();
+ }
}
-VISU::TEntity VISU::ScalarMapOnDeformedShape_i::GetScalarEntity(){
+//---------------------------------------------------------------
+VISU::TEntity
+VISU::ScalarMapOnDeformedShape_i
+::GetScalarEntity()
+{
return myScalarEntity;
}
-void VISU::ScalarMapOnDeformedShape_i::SetScalarEEntity(const VISU::Entity theValue){
- myScalarEntity = VISU::TEntity(theValue);
-}
-
-VISU::Entity VISU::ScalarMapOnDeformedShape_i::GetScalarEEntity(){
- return VISU::Entity(myScalarEntity);
+//---------------------------------------------------------------
+void
+VISU::ScalarMapOnDeformedShape_i
+::SetScalarEEntity(const VISU::Entity theValue)
+{
+ VISU::TEntity anEntity = VISU::TEntity(theValue);
+ if(myScalarEntity != anEntity){
+ myScalarEntity = anEntity;
+ myParamsTime.Modified();
+ }
}
-const VISU::PField&
+//---------------------------------------------------------------
+VISU::Entity
VISU::ScalarMapOnDeformedShape_i
-::GetField() const
-{
- return myScalarField;
+::GetScalarEEntity()
+{
+ return VISU::Entity(myScalarEntity);
}
class VISU_ScalarMapOnDeformedShapePL;
-namespace VISU{
+namespace VISU
+{
//! Class of Scalar Map on Deformed Shape presentation.
class ScalarMapOnDeformedShape_i : public virtual POA_VISU::ScalarMapOnDeformedShape,
typedef ScalarMap_i TSuperClass;
explicit
- ScalarMapOnDeformedShape_i(Result_i* theResult,
- bool theAddToStudy);
- 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
+ void
+ SetScale(CORBA::Double theScale);
+
+ virtual
+ CORBA::Double
+ GetScale();
+
+ virtual
+ CORBA::Boolean
+ IsColored();
- virtual CORBA::Boolean IsColored() { return myIsColored; }
- virtual void ShowColored(CORBA::Boolean theColored) { myIsColored = theColored; }
+ virtual
+ void
+ ShowColored(CORBA::Boolean theColored);
- virtual SALOMEDS::Color GetColor() { return myColor;}
- virtual void SetColor(const SALOMEDS::Color& theColor) { myColor = theColor;}
+ virtual
+ SALOMEDS::Color
+ GetColor();
- virtual void SetSourceRange(CORBA::Double theMinRange,CORBA::Double theMaxRange);
- virtual CORBA::Double GetSourceRangeMin();
- virtual CORBA::Double GetSourceRangeMax();
+ virtual
+ void
+ SetColor(const SALOMEDS::Color& theColor);
virtual
void
SameAs(const Prs3d_i* theOrigin);
- virtual const VISU::PField&
- GetField() const;
-
- VISU_ScalarMapOnDeformedShapePL* GetScalarMapOnDeformedShapePL(){ return myScalarMapOnDeformedShapePL;}
+ typedef VISU::ScalarMapOnDeformedShape TInterface;
+
+ VISU_ScalarMapOnDeformedShapePL*
+ GetSpecificPL()
+ {
+ return myScalarMapOnDeformedShapePL;
+ }
protected:
-
+ //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine
virtual
void
- DoHook();
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
+
+ //! Redefines VISU_ColoredPrs3d_i::CheckIsPossible
+ virtual
+ bool
+ CheckIsPossible();
VISU_ScalarMapOnDeformedShapePL *myScalarMapOnDeformedShapePL;
SALOMEDS::Color myColor;
std::string myScalarFieldName;
VISU::TEntity myScalarEntity;
int myScalarIteration;
- PField myScalarField;
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 VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
+ virtual
+ const char*
+ GetComment() const;
+
+ virtual
+ QString
+ GenerateName();
- virtual void UpdateActor(VISU_Actor* theActor) ;
+ virtual
+ VISU_Actor*
+ CreateActor();
- virtual void SetScalarField(const char* theMeshName,
- const char* theFieldName,
- int theIteration,
- VISU::TEntity theEntity);
+ virtual
+ void
+ UpdateActor(VISU_Actor* theActor) ;
+
+ virtual
+ void
+ SetCScalarField(const std::string& theMeshName,
+ const std::string& 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 void SetScalarIteration(const int theValue);
- virtual int GetScalarIteration();
- virtual void SetScalarMeshName(const char* theName);
- virtual std::string GetScalarMeshName();
- virtual void SetScalarEntity(const VISU::TEntity theValue);
- virtual VISU::TEntity GetScalarEntity();
- virtual void SetScalarEEntity(const VISU::Entity theValue);
- virtual VISU::Entity GetScalarEEntity();
+ virtual
+ void
+ SetScalarField(const char* theMeshName,
+ const char* theFieldName,
+ CORBA::Long theIteration,
+ VISU::Entity theEntity);
+
+ virtual
+ void
+ SetScalarFieldName(const std::string& theName);
+
+ virtual
+ std::string
+ GetScalarFieldName();
+
+ virtual
+ void
+ SetScalarIteration(const int theValue);
+
+ virtual
+ int
+ GetScalarIteration();
+
+ virtual
+ void
+ SetScalarMeshName(const std::string& theName);
+
+ virtual
+ std::string
+ GetScalarMeshName();
+
+ virtual
+ void
+ SetScalarEntity(const VISU::TEntity theValue);
+
+ virtual
+ VISU::TEntity
+ GetScalarEntity();
+
+ virtual
+ void
+ SetScalarEEntity(const VISU::Entity theValue);
+
+ virtual
+ VISU::Entity
+ GetScalarEEntity();
};
}
#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>
-using namespace VISU;
-using namespace std;
-
#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
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();
}
//----------------------------------------------------------------------------
VISU::ScalarMap_i::
-ScalarMap_i(Result_i* theResult,
- bool theAddToStudy) :
- PrsObject_i(theResult->GetStudyDocument()),
- Prs3d_i(theResult,theAddToStudy),
- ColoredPrs3d_i(theResult,theAddToStudy)
-{}
-
-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());
*/
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());
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() );
}
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;
- vtkFloatingPointType aScalarRange[2] = {theMin, theMax};
- myScalarMapPL->SetScalarRange(aScalarRange);
- myIsFixedRange = true;
+ TSuperClass::SetRange(theMin, theMax);
}
+//----------------------------------------------------------------------------
+void
+VISU::ScalarMap_i
+::SetSourceRange()
+{
+ TSuperClass::SetSourceRange();
+}
//----------------------------------------------------------------------------
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);
- myScalarMapPL->Init();
- 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(myTitle.c_str());
- 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"
+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;
-
+ //----------------------------------------------------------------------------
+ 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
virtual
Storable*
- Restore(const Storable::TRestoringMap& theMap);
-
- static
- 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);
+
+ private:
+ VISU_ScalarMapPL* myScalarMapPL;
};
}
#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(!VISU::ScalarMap_i::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),
- DeformedShape_i(theResult,theAddToStudy),
- myStreamLinesPL(NULL),
- myAppendFilter(vtkAppendFilter::New())
-{
+//---------------------------------------------------------------
+const char*
+VISU::StreamLines_i
+::GetComment() const
+{
+ return myComment.c_str();
}
-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),
- 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()");
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::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;
+ VISU::Prs3d_i* aPrs3d = NULL;
vtkPointSet* aSource = NULL;
if(!thePrs3d->_is_nil())
- if((aPrs3di = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(thePrs3d).in()))){
+ if((aPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(thePrs3d).in()))){
for(int i = myAppendFilter->GetNumberOfInputs()-1; i >= 0; i--)
myAppendFilter->RemoveInput(myAppendFilter->GetInput(i));
- myAppendFilter->AddInput(aPrs3di->GetPL()->GetMapper()->GetInput());
+ 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,
+ 1);
+ 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);
+
+ TSuperClass::CreatePipeLine(myStreamLinesPL);
+}
+
- DeformedShape_i::DoHook();
+//----------------------------------------------------------------------------
+bool
+VISU::StreamLines_i
+::CheckIsPossible()
+{
+ 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 StreamLines_i : public virtual POA_VISU::StreamLines,
public virtual DeformedShape_i
{
typedef DeformedShape_i TSuperClass;
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();
typedef VISU::StreamLines TInterface;
- VISU_StreamLinesPL* GetStreamLinesPL(){ return myStreamLinesPL;}
+ VISU_StreamLinesPL*
+ GetSpecificPL() const
+ {
+ return myStreamLinesPL;
+ }
+
protected:
- virtual void DoHook();
- virtual void SetSource(VISU::Prs3d_ptr thePrs3d);
- virtual void SetSource(VISU::Prs3d_i* thePrs3d);
- virtual void SetSource();
+ //! Extends VISU_ColoredPrs3d_i::CreatePipeLine
+ virtual
+ void
+ CreatePipeLine(VISU_PipeLine* thePipeLine);
+
+ //! Extends VISU_ColoredPrs3d_i::CheckIsPossible
+ virtual
+ bool
+ CheckIsPossible();
+
+ virtual
+ void
+ SetSource(VISU::Prs3d_ptr thePrs3d);
+
+ 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 void Update();
+ virtual
+ QString
+ GenerateName();
+ //! 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(),
"",
GetID(),
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);
}
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()));
+ 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()));
+ 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();
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);
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++) {
//jfa 03.08.2005:aData.myPrs[i]->SameAs(aData.myPrs[0]);
- aData.myPrs[i]->SameAsParams(aData.myPrs[0]);//jfa 03.08.2005
+ aData.myPrs[i]->SameAs(aData.myPrs[0]);//jfa 03.08.2005
}
}
string aStr = aAnimSObject->GetID();
#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),
- 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),
- DeformedShape_i(theResult,theSObject),
+//---------------------------------------------------------------
+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);
}
-VISU_PipeLine* VISU::Vectors_i::GetPipeLine(){
+//---------------------------------------------------------------
+VISU_PipeLine*
+VISU::Vectors_i
+::GetActorPipeLine()
+{
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 Vectors_i : public virtual POA_VISU::Vectors,
public virtual DeformedShape_i
{
typedef DeformedShape_i TSuperClass;
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
+ void
+ SameAs(const Prs3d_i* theOrigin);
+
+ virtual
+ ~Vectors_i();
+
+ virtual
+ VISU::VISUType
+ GetType()
+ {
+ return VISU::TVECTORS;
+ }
+
+ virtual
+ void
+ SetLineWidth(CORBA::Double theWidth);
- virtual VISU::VISUType GetType() { return VISU::TVECTORS;};
+ virtual
+ CORBA::Double
+ GetLineWidth();
+
+ virtual
+ void
+ SetGlyphType(VISU::Vectors::GlyphType theType);
- virtual void SetLineWidth(CORBA::Double theWidth);
- virtual CORBA::Double GetLineWidth();
+ virtual
+ VISU::Vectors::GlyphType
+ GetGlyphType();
- virtual void SetGlyphType(VISU::Vectors::GlyphType theType);
- virtual VISU::Vectors::GlyphType GetGlyphType();
+ virtual
+ void
+ SetGlyphPos(VISU::Vectors::GlyphPos thePos);
- virtual void SetGlyphPos(VISU::Vectors::GlyphPos thePos);
- virtual VISU::Vectors::GlyphPos GetGlyphPos();
+ virtual
+ VISU::Vectors::GlyphPos
+ GetGlyphPos();
typedef VISU::Vectors TInterface;
- VISU_VectorsPL* GetVectorsPL(){ return myVectorsPL;}
+ VISU_VectorsPL*
+ GetSpecificPL() const
+ {
+ return myVectorsPL;
+ }
+
protected:
- virtual void DoHook();
- virtual VISU_PipeLine* GetPipeLine();
+ //! 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();
+
+ //! 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_Actor* GetActor (VISU::Prs3d_i* thePrs, SVTK_ViewWindow* theViewWindow);
+ VISU_Actor* 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 {
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();
EXPORT_PYSCRIPTS = libVISU_Swig.py batchmode_visu.py batchmode_visu_table.py batchmode_visu_view3d.py \
visu_med.py visu_view3d.py visu.py visu_gui.py visu_prs_example.py \
visu_table.py visu_big_table.py visu_view.py visu_delete.py \
- visu_swig_test.py visu_split_views.py \
+ visu_swig_test.py visu_split_views.py visu_change_input.py visu_cache.py \
VISU_Example_01.py VISU_Example_02.py VISU_Example_03.py VISU_Example_04.py \
VISU_Example_05.py VISU_Example_06.py VISU_Example_07.py
EXPORT_SHAREDPYSCRIPTS = VISU_shared_modules.py
#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()
#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 );
}