@COMMENCE@
EXPORT_HEADERS = \
+ VISU_TypeList.hxx \
VISU_IDMapper.hxx \
VISU_Convertor.hxx \
VISU_ConvertorDef.hxx \
static int MYDEBUG = 0;
#endif
-//#define _DEXCEPT_
+#define _DEXCEPT_
typedef vtkUnstructuredGrid TOutput;
#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 <VISU_TypeList.hxx>
+#include <vtkVoidArray.h>
+#include <vtkBitArray.h>
+#include <vtkCharArray.h>
+#include <vtkUnsignedCharArray.h>
+#include <vtkShortArray.h>
+#include <vtkUnsignedShortArray.h>
+#include <vtkIntArray.h>
+#include <vtkUnsignedIntArray.h>
+#include <vtkLongArray.h>
+#include <vtkUnsignedLongArray.h>
+#include <vtkFloatArray.h>
+#include <vtkDoubleArray.h>
+#include <vtkIdTypeArray.h>
#include <qstring.h>
#include <qfileinfo.h>
::SetVoidArray() const
{
vtkDataArray* aDataArray = myPoints->GetData();
- aDataArray->SetVoidArray(myCoord->GetValuePtr(), myCoord->size(), false);
+ aDataArray->SetVoidArray(myCoord->GetValuePtr(), myCoord->size(), true);
}
vtkPoints*
::GetPoints() const
{
if(!myIsVTKDone){
+ TTimerLog aTimerLog(MYDEBUG,"TPointCoords::GetPoints()");
vtkIdType aNbPoints = GetNbPoints();
vtkIdType aDim = GetDim();
endl);
if(GetDim() == 3){
+ INITMSG(MYDEBUG,"TPointCoords::GetPoints - SetVoidArray()"<<endl);
SetVoidArray();
}else{
for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
::GetPoints() const
{
if(!myIsVTKDone){
+ TTimerLog aTimerLog(MYDEBUG,"TNamedPointCoords::GetPoints()");
TCoordHelperPtr aCoordHelperPtr;
bool anIsDimPresent[3] = {false, false, false};
for(int iDim = 0; iDim < GetDim(); iDim++){
endl);
if(anIsDimPresent[eX] && anIsDimPresent[eY] && anIsDimPresent[eZ]){
+ INITMSG(MYDEBUG,"TNamedPointCoords::GetPoints - SetVoidArray()"<<endl);
SetVoidArray();
}else{
for(vtkIdType aNodeId = 0; aNodeId < GetNbPoints(); aNodeId++){
//---------------------------------------------------------------
TFieldImpl
::TFieldImpl():
- myDataSize(0)
+ myDataSize(0),
+ myDataType(0)
{}
void
TFieldImpl
- ::InitArrays(vtkIdType theNbComp)
+ ::Init(vtkIdType theNbComp,
+ vtkIdType theDataType)
{
myNbComp = theNbComp;
+ myDataType = theDataType;
myCompNames.resize(theNbComp);
myUnitNames.resize(theNbComp);
myMinMaxArr.resize(theNbComp + 1);
}
}
+ vtkIdType
+ TFieldImpl
+ ::GetDataType() const
+ {
+ return myDataType;
+ }
+
TMinMax
TFieldImpl
::GetMinMax(vtkIdType theCompID)
//---------------------------------------------------------------
void
- TMeshValue
+ TMeshValueBase
::Init(vtkIdType theNbElem,
vtkIdType theNbGauss,
vtkIdType theNbComp)
myNbElem = theNbElem;
myNbGauss = theNbGauss;
myNbComp = theNbComp;
-
myStep = theNbComp*theNbGauss;
+ }
+
+ vtkIdType
+ TMeshValueBase
+ ::GetNbElem() const
+ {
+ return myNbElem;
+ }
+
+ vtkIdType
+ TMeshValueBase
+ ::GetNbComp() const
+ {
+ return myNbComp;
+ }
+
+ vtkIdType
+ TMeshValueBase
+ ::GetNbGauss() const
+ {
+ return myNbGauss;
+ }
+
+ size_t
+ TMeshValueBase
+ ::size() const
+ {
+ return myNbElem * myStep;
+ }
+
+
+ //----------------------------------------------------------------------------
+ const PMeshValue&
+ TGeom2Value
+ ::GetMeshValue(EGeometry theGeom) const
+ {
+ TGeom2MeshValue::const_iterator anIter = myGeom2MeshValue.find(theGeom);
+ if(anIter == myGeom2MeshValue.end())
+ EXCEPTION(runtime_error,"TGeom2Value::GetMeshValue - myGeom2MeshValue.find(theGeom) fails");
+ return anIter->second;
+ }
+
+ PMeshValue&
+ TGeom2Value
+ ::GetMeshValue(EGeometry theGeom)
+ {
+ return myGeom2MeshValue[theGeom];
+ }
+
+
+ //----------------------------------------------------------------------------
+ TGeom2MeshValue&
+ TGeom2Value
+ ::GetGeom2MeshValue()
+ {
+ return myGeom2MeshValue;
+ }
+
+ const TGeom2MeshValue&
+ TGeom2Value
+ ::GetGeom2MeshValue() const
+ {
+ return myGeom2MeshValue;
+ }
+
+ PMeshValue
+ TGeom2Value
+ ::GetFirstMeshValue() const
+ {
+ if(myGeom2MeshValue.size() == 1)
+ return myGeom2MeshValue.begin()->second;
+ return PMeshValue();
+ }
+
+ namespace TL
+ {
+ //----------------------------------------------------------------------------
+ typedef TList<void,
+ TList<bool,
+ TList<char,
+ TList<unsigned char,
+ TList<short,
+ TList<unsigned short,
+ TList<int,
+ TList<unsigned int,
+ TList<long,
+ TList<unsigned long,
+ TList<float,
+ TList<double,
+ TList<vtkIdType,
+ TNullType> > > > > > > > > > > > >
+ TVTKBasicTypeList;
+
+
+ //----------------------------------------------------------------------------
+ typedef TList<vtkVoidArray,
+ TList<vtkBitArray,
+ TList<vtkCharArray,
+ TList<vtkUnsignedCharArray,
+ TList<vtkShortArray,
+ TList<vtkUnsignedShortArray,
+ TList<vtkIntArray,
+ TList<vtkUnsignedIntArray,
+ TList<vtkLongArray,
+ TList<vtkUnsignedLongArray,
+ TList<vtkFloatArray,
+ TList<vtkDoubleArray,
+ TList<vtkIdTypeArray,
+ TNullType> > > > > > > > > > > > >
+ TVTKArrayTypeList;
+
+
+ typedef TList<TInt2Type<VTK_VOID>,
+ TList<TInt2Type<VTK_BIT>,
+ TList<TInt2Type<VTK_CHAR>,
+ TList<TInt2Type<VTK_UNSIGNED_CHAR>,
+ TList<TInt2Type<VTK_SHORT>,
+ TList<TInt2Type<VTK_UNSIGNED_SHORT>,
+ TList<TInt2Type<VTK_INT>,
+ TList<TInt2Type<VTK_UNSIGNED_INT>,
+ TList<TInt2Type<VTK_LONG>,
+ TList<TInt2Type<VTK_UNSIGNED_LONG>,
+ TList<TInt2Type<VTK_FLOAT>,
+ TList<TInt2Type<VTK_DOUBLE>,
+ TList<TInt2Type<VTK_ID_TYPE>,
+ TNullType> > > > > > > > > > > > >
+ TVTKBasicEnumList;
+
+
+ //----------------------------------------------------------------------------
+ template <unsigned int type_enum>
+ struct TEnum2VTKBasicType
+ {
+ typedef typename TTypeAt<TVTKBasicTypeList, TIndexOf<TVTKBasicEnumList, TInt2Type<type_enum> >::value >::TResult TResult;
+ };
+
+ //----------------------------------------------------------------------------
+ template <unsigned int type_enum>
+ struct TEnum2VTKArrayType
+ {
+ typedef typename TTypeAt<TVTKArrayTypeList, TIndexOf<TVTKBasicEnumList, TInt2Type<type_enum> >::value >::TResult TResult;
+ };
+
+ //----------------------------------------------------------------------------
+ template <class T>
+ struct TVTKBasicType2Enum
+ {
+ typedef typename TTypeAt<TVTKBasicEnumList, TIndexOf<TVTKBasicTypeList, T>::value >::TResult TResult;
+ };
- myValue.resize(theNbElem*myStep);
}
- TCValueSliceArr
- TMeshValue
- ::GetGaussValueSliceArr(vtkIdType theElemId) const
+
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ void
+ InitTimeStampOnProfile(const TVTKSource& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime,
+ const VISU::TEntity& theEntity);
+
+
+ //----------------------------------------------------------------------------
+ void
+ GetTimeStampOnProfile(const TVTKSource& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime,
+ const VISU::TEntity& theEntity)
{
- 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;
+ vtkIdType aDataType = theField->GetDataType();
+ switch(aDataType){
+ case VTK_DOUBLE:
+ InitTimeStampOnProfile<VTK_DOUBLE>(theSource, theField, theValForTime, theEntity);
+ break;
+ case VTK_FLOAT:
+ InitTimeStampOnProfile<VTK_FLOAT>(theSource, theField, theValForTime, theEntity);
+ break;
+ case VTK_INT:
+ InitTimeStampOnProfile<VTK_INT>(theSource, theField, theValForTime, theEntity);
+ break;
+ case VTK_LONG:
+ InitTimeStampOnProfile<VTK_LONG>(theSource, theField, theValForTime, theEntity);
+ break;
+ default:
+ EXCEPTION(runtime_error,
+ "GetTimeStampOnProfile - handling unsupported data type - "<<aDataType);
}
- return aValueSliceArr;
}
- TValueSliceArr
- TMeshValue
- ::GetGaussValueSliceArr(vtkIdType theElemId)
+
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ struct TDataArrayHolder
{
- 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;
+ typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
+ typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
+ TVTKDataArray* myDataArray;
+
+ TDataArrayHolder(TVTKDataArray* theDataArray):
+ myDataArray(theDataArray)
+ {}
+
+ void
+ WritePointer(TVTKDataArray* theDataArray,
+ vtkIdType theTupleId,
+ TVTKBasicType* thePointer)
+ {
+ vtkIdType aNumberOfComponents = theDataArray->GetNumberOfComponents();
+ vtkIdType aPosition = theTupleId * aNumberOfComponents;
+ TVTKBasicType *aPtr = theDataArray->WritePointer(aPosition, aNumberOfComponents);
+ for(vtkIdType anId = 0; anId < aNumberOfComponents; anId++)
+ *aPtr++ = *thePointer++;
}
- return aValueSliceArr;
- }
- TCValueSliceArr
- TMeshValue
- ::GetCompValueSliceArr(vtkIdType theElemId) const
+ virtual
+ void
+ SetTuple(vtkIdType theTupleId,
+ TVTKBasicType* thePointer)
+ {
+ this->WritePointer(myDataArray, theTupleId, thePointer);
+ }
+ };
+
+
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ struct TDataArrayHolder2: TDataArrayHolder<EDataType>
{
- 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;
+ typedef TDataArrayHolder<EDataType> TSuperClass;
+ typedef typename TSuperClass::TVTKDataArray TVTKDataArray;
+ typedef typename TSuperClass::TVTKBasicType TVTKBasicType;
+ TVTKDataArray* myDataArray2;
+
+ TDataArrayHolder2(TVTKDataArray* theDataArray,
+ TVTKDataArray* theDataArray2):
+ TSuperClass(theDataArray),
+ myDataArray2(theDataArray2)
+ {}
+
+ virtual
+ void
+ SetTuple(vtkIdType theTupleId,
+ TVTKBasicType* thePointer)
+ {
+ this->WritePointer(myDataArray, theTupleId, thePointer);
+ this->WritePointer(myDataArray2, theTupleId, thePointer);
}
- return aValueSliceArr;
- }
+ };
+
- TValueSliceArr
- TMeshValue
- ::GetCompValueSliceArr(vtkIdType theElemId)
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ struct TTimeStampOnProfileInitArray
{
- 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;
+ typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
+ typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
+ typedef TTMeshValue<TVTKBasicType> TMeshValue;
+ typedef SharedPtr<TMeshValue> TMeshValuePtr;
+
+ typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
+ typedef SharedPtr<TTDataArrayHolder> PDataArrayHolder;
+ PDataArrayHolder myDataArrayHolder;
+
+ TTimeStampOnProfileInitArray(const PDataArrayHolder& theDataArrayHolder):
+ myDataArrayHolder(theDataArrayHolder)
+ {}
+
+ void
+ Execute(const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime)
+ {
+ vtkIdType aNbComp = theField->myNbComp;
+ vtkIdType aSize = max(3, aNbComp);
+ TVector<TVTKBasicType> aDataValues(aSize);
+
+ const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
+ TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin();
+ for(int aTupleId = 0; anIter != aGeom2MeshValue.end(); anIter++){
+ EGeometry aEGeom = anIter->first;
+ const TMeshValuePtr aMeshValue = anIter->second;
+
+ vtkIdType aNbElem = aMeshValue->GetNbElem();
+ vtkIdType aNbGauss = aMeshValue->GetNbGauss();
+
+ INITMSG(MYDEBUG,
+ "- aEGeom = "<<aEGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ endl);
+
+ for(vtkIdType iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
+ typename TMeshValue::TCValueSliceArr aValueSliceArr = aMeshValue->GetCompValueSliceArr(iElem);
+ for(vtkIdType iComp = 0; iComp < aNbComp; iComp++){
+ const typename TMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[iComp];
+ aDataValues[iComp] = TVTKBasicType();
+ for(vtkIdType iGauss = 0; iGauss < aNbGauss; iGauss++){
+ aDataValues[iComp] += aValueSlice[iGauss];
+ }
+ aDataValues[iComp] /= aNbGauss;
+ }
+ this->myDataArrayHolder->SetTuple(aTupleId, &aDataValues[0]);
+ }
+ }
}
- return aValueSliceArr;
+ };
+
+
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ void
+ InitTimeStampOnProfile(const TVTKSource& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime,
+ const VISU::TEntity& theEntity)
+ {
+ vtkIdType 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();
+ }
+
+ typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
+ TVTKDataArray *aSelectedDataArray = TVTKDataArray::New();
+ vtkIdType aNbComp = theField->myNbComp;
+ switch(aNbComp) {
+ case 1:
+ aSelectedDataArray->SetNumberOfComponents(1);
+ aDataSetAttributes->SetScalars(aSelectedDataArray);
+ break;
+ default:
+ aSelectedDataArray->SetNumberOfComponents(3);
+ aDataSetAttributes->SetVectors(aSelectedDataArray);
+ }
+ aSelectedDataArray->SetNumberOfTuples(aNbTuples);
+ aSelectedDataArray->SetName(aFieldName.c_str());
+
+ TVTKDataArray *aFullDataArray = TVTKDataArray::New();
+ aFullDataArray->SetNumberOfComponents(aNbComp);
+ aFullDataArray->SetNumberOfTuples(aNbTuples);
+ aFullDataArray->SetName("VISU_FIELD");
+ aDataSetAttributes->AddArray(aFullDataArray);
+
+ INITMSG(MYDEBUG,"InitTimeStampOnProfile "<<
+ "- theEntity = "<<theEntity<<
+ "; aNbTuples = "<<aNbTuples<<
+ "; aNbComp = "<<aNbComp<<
+ endl);
+ TTimerLog aTimerLog(MYDEBUG,"InitTimeStampOnProfile");
+
+ const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
+ typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
+ typedef TTMeshValue<TVTKBasicType> TMeshValue;
+ typedef SharedPtr<TMeshValue> TMeshValuePtr;
+
+ typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
+ typedef SharedPtr<TTDataArrayHolder> PDataArrayHolder;
+
+ TMeshValuePtr aMeshValue = theValForTime->GetFirstMeshValue();
+ if(aGeom2MeshValue.size() == 1 && aMeshValue->GetNbGauss() == 1){
+ aFullDataArray->SetVoidArray(aMeshValue->GetPointer(),
+ aMeshValue->size(),
+ true);
+ INITMSG(MYDEBUG,"InitTimeStampOnProfile - aFullDataArray->SetVoidArray()"<<endl);
+ if(aNbComp == 1){
+ aSelectedDataArray->SetVoidArray(aMeshValue->GetPointer(),
+ aMeshValue->size(),
+ true);
+ INITMSG(MYDEBUG,"InitTimeStampOnProfile - aSelectedDataArray->SetVoidArray()"<<endl);
+ }else{
+ PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder(aSelectedDataArray));
+ TTimeStampOnProfileInitArray<EDataType>(aDataArrayHolder).Execute(theField, theValForTime);
+ }
+ }else{
+ typedef TDataArrayHolder2<EDataType> TTDataArrayHolder2;
+ PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder2(aSelectedDataArray, aFullDataArray));
+ TTimeStampOnProfileInitArray<EDataType>(aDataArrayHolder).Execute(theField, theValForTime);
+ }
+
+ aSelectedDataArray->Delete();
+ aFullDataArray->Delete();
}
- unsigned long int
- TMeshValue
- ::GetMemorySize() const
+
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ void
+ InitTimeStampOnGaussMesh(const TVTKSource& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime);
+
+ void
+ GetTimeStampOnGaussMesh(const TVTKSource& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime)
{
- size_t aSize = sizeof(TMeshValue);
- aSize += myValue.size() * sizeof(vtkFloatingPointType);
- return aSize;
+ vtkIdType aDataType = theField->GetDataType();
+ switch(aDataType){
+ case VTK_DOUBLE:
+ InitTimeStampOnGaussMesh<VTK_DOUBLE>(theSource, theField, theValForTime);
+ break;
+ case VTK_FLOAT:
+ InitTimeStampOnGaussMesh<VTK_FLOAT>(theSource, theField, theValForTime);
+ break;
+ case VTK_INT:
+ InitTimeStampOnGaussMesh<VTK_INT>(theSource, theField, theValForTime);
+ break;
+ case VTK_LONG:
+ InitTimeStampOnGaussMesh<VTK_LONG>(theSource, theField, theValForTime);
+ break;
+ default:
+ EXCEPTION(runtime_error,
+ "GetTimeStampOnGaussMesh - handling unsupported data type - "<<aDataType);
+ }
}
+ //----------------------------------------------------------------------------
+ template<int EDataType>
+ struct TTimeStampOnGaussMeshInitArray
+ {
+ typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
+ typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
+ typedef TTMeshValue<TVTKBasicType> TMeshValue;
+ typedef SharedPtr<TMeshValue> TMeshValuePtr;
+
+ typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
+ typedef SharedPtr<TTDataArrayHolder> PDataArrayHolder;
+ PDataArrayHolder myDataArrayHolder;
+
+ TTimeStampOnGaussMeshInitArray(const PDataArrayHolder& theDataArrayHolder):
+ myDataArrayHolder(theDataArrayHolder)
+ {}
+
+ void
+ Execute(const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime)
+ {
+ vtkIdType aNbComp = theField->myNbComp;
+ vtkIdType aSize = max(3, aNbComp);
+ TVector<TVTKBasicType> aDataValues(aSize);
+
+ const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
+
+ PGaussMeshImpl aGaussMesh = theValForTime->myGaussMesh;
+ const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
+ TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
+ for(int aTupleId = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
+ EGeometry aEGeom = anIter->first;
+
+ PGaussSubMeshImpl aGaussSubMesh = anIter->second;
+ if(!aGaussSubMesh->myIsDone)
+ continue;
+
+ TGeom2MeshValue::const_iterator anIter2 = aGeom2MeshValue.find(aEGeom);
+ if(anIter2 == aGeom2MeshValue.end()){
+ EXCEPTION(runtime_error,
+ "TTimeStampOnGaussMeshInitArray >> Can't find values for corresponding Gauss Points SubMesh");
+ }
+ TMeshValuePtr aMeshValue = anIter2->second;
+ vtkIdType aNbGauss = aMeshValue->GetNbGauss();
+ vtkIdType aNbElem = aMeshValue->GetNbElem();
+
+ if(aNbGauss < 1)
+ continue;
+
+ const TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
+
+ INITMSG(MYDEBUG,
+ "- aEGeom = "<<aEGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ "; aCoords.GetNbPoints() = "<<aCoords.GetNbPoints()<<
+ endl);
+
+ if(aCoords.GetNbPoints() == aNbElem*aNbGauss){
+ for(int iElem = 0; iElem < aNbElem; iElem++){
+ typename TMeshValue::TCValueSliceArr aValueSliceArr = aMeshValue->GetGaussValueSliceArr(iElem);
+ for(int iGauss = 0; iGauss < aNbGauss; iGauss++, aTupleId++){
+ const typename TMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
+ for(int iComp = 0; iComp < aNbComp; iComp++){
+ aDataValues[iComp] = aValueSlice[iComp];
+ }
+ this->myDataArrayHolder->SetTuple(aTupleId, &aDataValues[0]);
+ }
+ }
+ }else{
+ for(int iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
+ typename TMeshValue::TCValueSliceArr aValueSliceArr = aMeshValue->GetCompValueSliceArr(iElem);
+ for(int iComp = 0; iComp < aNbComp; iComp++){
+ const typename TMeshValue::TCValueSlice& aValueSlice = aValueSliceArr[iComp];
+ aDataValues[iComp] = TVTKBasicType();
+ for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
+ aDataValues[iComp] += aValueSlice[iGauss];
+ }
+ aDataValues[iComp] /= aNbGauss;
+ }
+ this->myDataArrayHolder->SetTuple(aTupleId, &aDataValues[0]);
+ }
+ }
+ }
+ }
+ };
+
+
+ template<int EDataType>
+ void
+ InitTimeStampOnGaussMesh(const TVTKSource& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime)
+ {
+ vtkIdType 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();
+ }
+
+ typedef typename TL::TEnum2VTKArrayType<EDataType>::TResult TVTKDataArray;
+ TVTKDataArray *aSelectedDataArray = TVTKDataArray::New();
+ vtkIdType aNbComp = theField->myNbComp;
+ switch(aNbComp){
+ case 1:
+ aSelectedDataArray->SetNumberOfComponents(1);
+ aDataSetAttributes->SetScalars(aSelectedDataArray);
+ break;
+ default:
+ aSelectedDataArray->SetNumberOfComponents(3);
+ aDataSetAttributes->SetVectors(aSelectedDataArray);
+ }
+ aSelectedDataArray->SetNumberOfTuples(aNbTuples);
+ aSelectedDataArray->SetName(aFieldName.c_str());
+
+ TVTKDataArray *aFullDataArray = TVTKDataArray::New();
+ aFullDataArray->SetNumberOfComponents(aNbComp);
+ aFullDataArray->SetNumberOfTuples(aNbTuples);
+ aFullDataArray->SetName("VISU_FIELD");
+ aDataSetAttributes->AddArray(aFullDataArray);
+
+ INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh "<<
+ "- aNbTuples = "<<aNbTuples<<
+ "; aNbComp = "<<aNbComp<<
+ endl);
+ TTimerLog aTimerLog(MYDEBUG,"InitTimeStampOnGaussMesh");
+
+ const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue();
+ typedef typename TL::TEnum2VTKBasicType<EDataType>::TResult TVTKBasicType;
+ typedef TTMeshValue<TVTKBasicType> TMeshValue;
+ typedef SharedPtr<TMeshValue> TMeshValuePtr;
+
+ typedef TDataArrayHolder<EDataType> TTDataArrayHolder;
+ typedef SharedPtr<TTDataArrayHolder> PDataArrayHolder;
+
+ TMeshValuePtr aMeshValue = theValForTime->GetFirstMeshValue();
+ if(aGeom2MeshValue.size() == 1){
+ aFullDataArray->SetVoidArray(aMeshValue->GetPointer(),
+ aMeshValue->size(),
+ true);
+ INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh - aFullDataArray->SetVoidArray()"<<endl);
+ if(aNbComp == 1){
+ aSelectedDataArray->SetVoidArray(aMeshValue->GetPointer(),
+ aMeshValue->size(),
+ true);
+ INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh - aSelectedDataArray->SetVoidArray()"<<endl);
+ }else{
+ PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder(aSelectedDataArray));
+ TTimeStampOnGaussMeshInitArray<EDataType>(aDataArrayHolder).Execute(theField, theValForTime);
+ }
+ }else{
+ typedef TDataArrayHolder2<EDataType> TTDataArrayHolder2;
+ PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder2(aSelectedDataArray, aFullDataArray));
+ TTimeStampOnGaussMeshInitArray<EDataType>(aDataArrayHolder).Execute(theField, theValForTime);
+ }
+
+ aSelectedDataArray->Delete();
+ aFullDataArray->Delete();
+ }
//---------------------------------------------------------------
TValForTimeImpl
myIDMapperFilter(new TIDMapperFilter())
{}
- const TMeshValue&
+ const PMeshValue&
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;
+ return myGeom2Value.GetMeshValue(theGeom);
}
- TMeshValue&
+ PMeshValue&
TValForTimeImpl
::GetMeshValue(EGeometry theGeom)
{
- return myGeom2Value[theGeom];
+ return myGeom2Value.GetMeshValue(theGeom);
+ }
+
+ TGeom2MeshValue&
+ TValForTimeImpl
+ ::GetGeom2MeshValue()
+ {
+ return myGeom2Value.GetGeom2MeshValue();
+ }
+
+ const TGeom2MeshValue&
+ TValForTimeImpl
+ ::GetGeom2MeshValue() const
+ {
+ return myGeom2Value.GetGeom2MeshValue();
+ }
+
+ PMeshValue
+ TValForTimeImpl
+ ::GetFirstMeshValue() const
+ {
+ return myGeom2Value.GetFirstMeshValue();
}
int
{
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;
::GetMemorySize()
{
size_t aSize = sizeof(TValForTimeImpl);
- TGeom2Value::const_iterator anIter = myGeom2Value.begin();
- TGeom2Value::const_iterator anIterEnd = myGeom2Value.end();
+ const TGeom2MeshValue& aGeom2MeshValue = GetGeom2MeshValue();
+ TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin();
+ TGeom2MeshValue::const_iterator anIterEnd = aGeom2MeshValue.end();
for(; anIter != anIterEnd; anIter++){
- const TMeshValue& aMeshValue = anIter->second;
- aSize += aMeshValue.GetMemorySize();
+ const PMeshValue& aMeshValue = anIter->second;
+ aSize += aMeshValue->GetMemorySize();
aSize += sizeof(EGeometry);
}
return aSize;
const PSubMeshImpl& theSubMesh,
const vtkIdType theGeom)
{
+ TTimerLog aTimerLog(MYDEBUG,"GetCellsOnSubMesh");
const VISU::TCell2Connect& anArray = theSubMesh->myCell2Connect;
vtkIdType aCellsSize = theSubMesh->myCellsSize;
vtkIdType aNbCells = theSubMesh->myNbCells;
}
- //---------------------------------------------------------------
- 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 PMeshOnEntityImpl& theMeshOnEntity,
const PProfileImpl& theProfile)
{
- INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<<theMeshOnEntity->myEntity<<endl);
-
if(theProfile->myIsVTKDone)
return;
+ TTimerLog aTimerLog(MYDEBUG,"GetMeshOnProfile");
+ INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<<theMeshOnEntity->myEntity<<endl);
+
theProfile->myMeshOnEntity = theMeshOnEntity.get();
const TVTKAppendFilter& anAppendFilter = theProfile->GetFilter();
anAppendFilter->SetPoints(theMesh->GetPoints());
}
- //---------------------------------------------------------------
- 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)
{
PGaussImpl aGauss = theGaussSubMesh->myGauss;
- INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<<aGauss->myGeom<<endl);
if(!theGaussSubMesh->myIsDone)
return;
if(theGaussSubMesh->myIsVTKDone)
return;
+ TTimerLog aTimerLog(MYDEBUG,"GetGaussSubMesh");
+ INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<<aGauss->myGeom<<endl);
+
const TVTKSource& aSource = theGaussSubMesh->GetSource();
GetSource(aSource,theGaussSubMesh,theMeshOnEntity);
+
INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
if(theGaussMesh->myIsVTKDone)
return;
- INITMSG(MYDEBUG,"BuildGaussMesh"<<endl);
+ TTimerLog aTimerLog(MYDEBUG,"BuildGaussMesh");
const TVTKAppendFilter& anAppendFilter = theGaussMesh->GetFilter();
const TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
try{
#endif
if(!aMeshOnEntity->myIsVTKDone){
+ TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetMeshOnEntity");
const TVTKAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter();
if(MYVTKDEBUG) anAppendFilter->DebugOn();
const VISU::PProfileImpl& theProfile,
const VISU::TEntity& theEntity)
{
- LoadMeshOnEntity(theMesh,theMeshOnEntity);
- GetMeshOnEntity(theMeshOnEntity->myMeshName,theMeshOnEntity->myEntity);
- GetMeshOnProfile(theMesh,theMeshOnEntity,theProfile);
+ 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);
-
+ ::GetTimeStampOnProfile(aSource, theField, theValForTime, theEntity);
return anOutput;
}
try{
#endif
if(!anIDMapperFilter->myIsVTKDone){
+ TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnMesh");
LoadValForTimeOnMesh(aMesh,aMeshOnEntity,aField,aValForTime);
TVTKOutput* anOutput;
try{
#endif
if(!aGaussPtsIDFilter->myIsVTKDone){
+ TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnGaussPts");
LoadValForTimeOnGaussPts(aMesh,aMeshOnEntity,aField,aValForTime);
GetMeshOnEntity(aVTKMeshOnEntity->myMeshName,aVTKMeshOnEntity->myEntity);
mutable TContainerType myCoord; //!< Keeps the node coordinates container itself
public:
- //! To initilize the class
+ //! To initilize the class instance
void
Init(vtkIdType theNbPoints,
vtkIdType theDim,
myCoord = theCoord;
}
+ //! Gets pointer to the first element in the node coordinates array
+ virtual
+ TCoord*
+ GetPointer() = 0;
+
+ //! Gets pointer to the first element in the node coordinates array (const version)
virtual
const TCoord*
GetPointer() const = 0;
std::slice(theNodeId * this->GetDim(), this->GetDim(), 1));
}
- virtual
- TCoord*
- GetPointer() = 0;
-
//! Get slice of coordinates for defined node
virtual
TCoordSlice
//! Specialize TField to provide VTK mapping for the entity
struct TFieldImpl: virtual TField
{
- vtkIdType myDataSize; //!< Keeps size of the assigned data
+ TFieldImpl();
- TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD
+ //! To initialize the data structure
+ void
+ Init(vtkIdType theNbComp,
+ vtkIdType theDataType);
+
+ //! Gets type idetificator of the mesh data.
+ vtkIdType
+ GetDataType() const;
//! Implement the TField::GetMinMax
virtual
TMinMax
GetMinMax(vtkIdType theCompID);
- //! To initialize the data structure
- void
- InitArrays(vtkIdType theNbComp);
-
- TFieldImpl();
+ vtkIdType myDataSize; //!< Keeps size of the assigned data
+ vtkIdType myDataType; //!< Keeps type idetificator of the mesh data
+ TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD
};
typedef SharedPtr<TFieldImpl> PFieldImpl;
//---------------------------------------------------------------
- typedef TVector<vtkFloatingPointType> TValue;
- typedef TSlice<vtkFloatingPointType> TValueSlice;
- typedef TCSlice<vtkFloatingPointType> TCValueSlice;
+ //! Define a base class for the container to get access to data assigned to mesh
+ class TMeshValueBase
+ {
+ public:
+ //! To intitilize the data strucutre
+ void
+ Init(vtkIdType theNbElem,
+ vtkIdType theNbGauss,
+ vtkIdType theNbComp);
- typedef TVector<TCValueSlice> TCValueSliceArr;
- typedef TVector<TValueSlice> TValueSliceArr;
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize() const = 0;
- //! Define a container to get access to data assigned to mesh
- struct TMeshValue
- {
- TValue myValue; //!< Keeps all values as one dimensional sequence
+ //! Gets number of mesh elements where the data assigned to.
+ vtkIdType
+ GetNbElem() const;
+
+ //! Gets number of components of corresponding MED FIELD.
+ vtkIdType
+ GetNbComp() const;
+
+ //! Gets number of Gauss Points.
+ vtkIdType
+ GetNbGauss() const;
+ size_t
+ size() const;
+
+ protected:
vtkIdType myNbElem; //!< Defines number of mesh elements where the data assigned to
vtkIdType myNbComp; //!< Keeps number of components of corresponding MED FIELD
vtkIdType myNbGauss; //!< Defines number of Gauss Points
- vtkIdType myStep; //! Internal variable
+ vtkIdType myStep; //!< Internal variable
+ };
+ typedef SharedPtr<TMeshValueBase> PMeshValue;
- //! To intitilize the data strucutre
- void
- Init(vtkIdType theNbElem,
- vtkIdType theNbGauss,
- vtkIdType theNbComp);
+
+ //---------------------------------------------------------------
+ //! Define a container to get access to data assigned to mesh
+ template<class TValueType>
+ class TTMeshValue: public virtual TMeshValueBase
+ {
+ public:
+ typedef TSlice<TValueType> TValueSlice;
+ typedef TCSlice<TValueType> TCValueSlice;
+
+ typedef TVector<TCValueSlice> TCValueSliceArr;
+ typedef TVector<TValueSlice> TValueSliceArr;
+
+ virtual
+ const TValueType*
+ GetPointer() const = 0;
+
+ virtual
+ TValueType*
+ GetPointer() = 0;
//! To get assigned values first by Gauss Points and then by components (constant version)
TCValueSliceArr
- GetGaussValueSliceArr(vtkIdType theElemId) const;
+ GetGaussValueSliceArr(vtkIdType theElemId) const
+ {
+ TCValueSliceArr aValueSliceArr(this->myNbGauss);
+ vtkIdType anId = theElemId * this->myStep;
+ for(vtkIdType aGaussId = 0; aGaussId < this->myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TCValueSlice(this->GetPointer(),
+ this->size(),
+ std::slice(anId, this->myNbComp, 1));
+ anId += this->myNbComp;
+ }
+ return aValueSliceArr;
+ }
//! To get assigned values first by Gauss Points and then by components
TValueSliceArr
- GetGaussValueSliceArr(vtkIdType theElemId);
+ GetGaussValueSliceArr(vtkIdType theElemId)
+ {
+ TValueSliceArr aValueSliceArr(this->myNbGauss);
+ vtkIdType anId = theElemId * this->myStep;
+ for(vtkIdType aGaussId = 0; aGaussId < this->myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TValueSlice(this->GetPointer(),
+ this->size(),
+ std::slice(anId, this->myNbComp, 1));
+ anId += this->myNbComp;
+ }
+ return aValueSliceArr;
+ }
//! To get assigned values first by components and then by Gauss Points (constant version)
TCValueSliceArr
- GetCompValueSliceArr(vtkIdType theElemId) const;
+ GetCompValueSliceArr(vtkIdType theElemId) const
+ {
+ TCValueSliceArr aValueSliceArr(this->myNbComp);
+ vtkIdType anId = theElemId * this->myStep;
+ for(vtkIdType aCompId = 0; aCompId < this->myNbComp; aCompId++){
+ aValueSliceArr[aCompId] =
+ TCValueSlice(this->GetPointer(),
+ this->size(),
+ std::slice(anId, this->myNbGauss, this->myNbComp));
+ anId += 1;
+ }
+ return aValueSliceArr;
+ }
//! To get assigned values first by components and then by Gauss Points
TValueSliceArr
- GetCompValueSliceArr(vtkIdType theElemId);
+ GetCompValueSliceArr(vtkIdType theElemId)
+ {
+ TValueSliceArr aValueSliceArr(this->myNbComp);
+ vtkIdType anId = theElemId * this->myStep;
+ for(vtkIdType aCompId = 0; aCompId < this->myNbComp; aCompId++){
+ aValueSliceArr[aCompId] =
+ TValueSlice(this->GetPointer(),
+ this->size(),
+ std::slice(anId, this->myNbGauss, this->myNbComp));
+ anId += 1;
+ }
+ return aValueSliceArr;
+ }
//! Gets memory size used by the instance (bytes).
virtual
unsigned long int
- GetMemorySize() const;
+ GetMemorySize() const
+ {
+ return this->size() * sizeof(TValueType);
+ }
};
//---------------------------------------------------------------
- typedef std::map<EGeometry,TMeshValue> TGeom2Value;
+ //! Define a container to get access to data assigned to mesh
+ template<class TValueType, class TContainerType>
+ class TTMeshValueHolder: public virtual TTMeshValue<TValueType>
+ {
+ protected:
+ mutable TContainerType myContainer; //!< Keeps the mesh values container itself
+
+ public:
+ //! To initilize the class instance
+ void
+ Init(vtkIdType theNbElem,
+ vtkIdType theNbGauss,
+ vtkIdType theNbComp,
+ const TContainerType& theContainer)
+ {
+ TMeshValueBase::Init(theNbElem, theNbGauss, theNbComp);
+ myContainer = theContainer;
+ }
+ };
+
+
+ //---------------------------------------------------------------
+ typedef std::map<EGeometry, PMeshValue> TGeom2MeshValue;
+
+ class TGeom2Value: public virtual TBaseStructure
+ {
+ TGeom2MeshValue myGeom2MeshValue;
+ public:
+
+ //! Gets mesh data for defined geometrical type (constant version)
+ const PMeshValue&
+ GetMeshValue(EGeometry theGeom) const;
+
+ //! Gets mesh data for defined geometrical type
+ PMeshValue&
+ GetMeshValue(EGeometry theGeom);
+
+ //! Gets container of the whole mesh data
+ TGeom2MeshValue&
+ GetGeom2MeshValue();
+
+ //! Gets container of the whole mesh data (constant version)
+ const TGeom2MeshValue&
+ GetGeom2MeshValue() const;
+
+ //! Gets mesh data for the first geometry
+ PMeshValue
+ GetFirstMeshValue() const;
+ };
+
+
+ //---------------------------------------------------------------
typedef std::map<EGeometry,vtkIdType> TGeom2NbGauss;
//! Specialize TValForTime to provide VTK mapping for the entity
TValForTimeImpl();
+ TGeom2MeshValue&
+ GetGeom2MeshValue();
+
+ const TGeom2MeshValue&
+ GetGeom2MeshValue() const;
+
//! Get mesh data for defined geometrical type (constant version)
- const TMeshValue&
+ const PMeshValue&
GetMeshValue(EGeometry theGeom) const;
//! Get mesh data for defined geometrical type
- TMeshValue&
+ PMeshValue&
GetMeshValue(EGeometry theGeom);
+ //! Gets mesh data for the first geometry
+ PMeshValue
+ GetFirstMeshValue() const;
+
//! Get number of Gauss Points for defined geometrical type
virtual
int
continue;
TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ vtkIdType aDataType = VTK_DOUBLE;
+ if(aFieldInfo->GetType() != MED::eFLOAT64)
+ aDataType = VTK_INT;
PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
PMEDField aField = aFieldMap[aFieldName](new TMEDField());
aField->myId = iField;
- aField->InitArrays(aNbComp);
+ aField->Init(aNbComp, aDataType);
aField->myEntity = aVEntity;
aField->myName = aFieldName;
aField->myMeshName = aMeshName;
PMEDSubProfile aSubProfile(anIter->second);
TInt aNbElem = aSubProfile->myNbCells;
- theField->myDataSize += aNbElem*aNbComp;
+ theField->myDataSize += aNbElem * aNbComp;
if(aSubProfile->myStatus != eRemoveAll){
TInt aNbGauss = theValForTime->GetNbGauss(aEGeom);
"; aNbGauss = "<<aNbGauss<<
endl);
- TMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
- aVMeshValue.Init(aNbElem,aNbGauss,aNbComp);
+ PMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom);
+ typedef typename TimeStampValueType::TElement TElement;
+ typedef TTMEDMeshValue<TElement> TVMeshValue;
+ TVMeshValue* aMeshValue = new TVMeshValue();
MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
- const typename TimeStampValueType::TTMeshValue& aMMeshValue = theTimeStampValue->GetMeshValue(aMGeom);
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- TValueSliceArr aVValueSliceArr = aVMeshValue.GetGaussValueSliceArr(iElem);
- typename TimeStampValueType::TTMeshValue::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
- ADDMSG(MYVALUEDEBUG,"{");
- for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
- TValueSlice& aVValueSlice = aVValueSliceArr[iGauss];
- const typename TimeStampValueType::TTMeshValue::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");
+ typedef typename TimeStampValueType::PTMeshValue PTMeshValue;
+ PTMeshValue aMeshValuePtr = theTimeStampValue->GetMeshValuePtr(aMGeom);
+ aMeshValue->Init(aNbElem, aNbGauss, aNbComp, aMeshValuePtr);
+ aVMeshValue.reset(aMeshValue);
}
}
}
};
+ //---------------------------------------------------------------
+ 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;
--- /dev/null
+// VISU OBJECT : interactive object for VISU entities implementation
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File : VISU_ColoredPrs3dCache_i.hh
+// Author : Oleg UVAROV
+// Module : VISU
+
+#ifndef VISU_TypeList_HeaderFile
+#define VISU_TypeList_HeaderFile
+
+namespace VISU
+{
+ namespace TL
+ {
+ //----------------------------------------------------------------------------
+ template <class T, class U>
+ struct TList
+ {
+ typedef T THead;
+ typedef U TTail;
+ };
+
+ template <int v>
+ struct TInt2Type
+ {
+ enum { value = v };
+ };
+
+ struct TNullType {};
+
+ //----------------------------------------------------------------------------
+ template <class TypeList, unsigned int index>
+ struct TTypeAt;
+
+ template <class THead, class TTail>
+ struct TTypeAt<TList<THead, TTail>, 0>
+ {
+ typedef THead TResult;
+ };
+
+
+ template <class THead, class TTail, unsigned int index>
+ struct TTypeAt<TList<THead, TTail>, index>
+ {
+ typedef typename TTypeAt<TTail, index - 1>::TResult TResult;
+ };
+
+ //----------------------------------------------------------------------------
+ template <class TypeList, class T>
+ struct TIndexOf;
+
+ template <class T>
+ struct TIndexOf<TNullType, T>
+ {
+ enum { value = -1 };
+ };
+
+ template <class T, class TTail>
+ struct TIndexOf<TList<T, TTail>, T>
+ {
+ enum { value = 0 };
+ };
+
+ template <class THead, class TTail, class T>
+ struct TIndexOf<TList<THead, TTail>, T>
+ {
+ private:
+ enum { temp = TIndexOf<TTail, T>::value };
+ public:
+ enum { value = temp == -1? -1 : 1 + temp };
+ };
+
+ //----------------------------------------------------------------------------
+ }
+}
+
+#endif
#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)
+
+//----------------------------------------------------------------------------
+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)
{
- if(theNbElems < 1 )
+ 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(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);
#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());
}
}
+
+
+//----------------------------------------------------------------------------
#include "VISU_ScalarMap_i.hh"
#include "VISU_ColoredPrs3d_i.hh"
#include "VISU_Result_i.hh"
+#include "VISU_TypeList.hxx"
namespace VISU
{
namespace TL
{
- //----------------------------------------------------------------------------
- template <class T, class U>
- struct TList
- {
- typedef T THead;
- typedef U TTail;
- };
-
- template <int v>
- struct TInt2Type
- {
- enum { value = v };
- };
-
- struct TNullType {};
-
//----------------------------------------------------------------------------
typedef TList<ScalarMapOnDeformedShape_i,
TList<DeformedShape_i,
TColoredPrs3dEnumList;
- //----------------------------------------------------------------------------
- template <class TypeList, unsigned int index>
- struct TTypeAt;
-
- template <class THead, class TTail>
- struct TTypeAt<TList<THead, TTail>, 0>
- {
- typedef THead TResult;
- };
-
-
- template <class THead, class TTail, unsigned int index>
- struct TTypeAt<TList<THead, TTail>, index>
- {
- typedef typename TTypeAt<TTail, index - 1>::TResult TResult;
- };
-
- //----------------------------------------------------------------------------
- template <class TypeList, class T>
- struct TIndexOf;
-
- template <class T>
- struct TIndexOf<TNullType, T>
- {
- enum { value = -1 };
- };
-
- template <class T, class TTail>
- struct TIndexOf<TList<T, TTail>, T>
- {
- enum { value = 0 };
- };
-
- template <class THead, class TTail, class T>
- struct TIndexOf<TList<THead, TTail>, T>
- {
- private:
- enum { temp = TIndexOf<TTail, T>::value };
- public:
- enum { value = temp == -1? -1 : 1 + temp };
- };
-
//----------------------------------------------------------------------------
template <unsigned int type_enum>
struct TColoredEnum2Type
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;
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
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)
}
-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);
+ 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
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;
};
+ //---------------------------------------------------------------
+ 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
{