static int MYVTKDEBUG = 0;
#ifdef _DEBUG_
-static int MYDEBUG = 1;
-static int MYDEBUGWITHFILES = 0;
+static int MYDEBUG = 0;
+static int MYDEBUGWITHFILES = 1;
#else
static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
namespace VISU
{
//---------------------------------------------------------------
- TSource::TSource():
+ TIsVTKDone::TIsVTKDone():
+ myIsVTKDone(false)
+ {}
+
+
+ //---------------------------------------------------------------
+ TSizeCounter::TSizeCounter():
myNbCells(0),
- myCellsSize(0),
+ myCellsSize(0)
+ {}
+
+
+ //---------------------------------------------------------------
+ TSource::TSource():
mySource(vtkUnstructuredGrid::New())
{
mySource->Delete();
//---------------------------------------------------------------
+ TAppendFilter::TAppendFilter():
+ myFilter(vtkAppendFilter::New())
+ {
+ myFilter->Delete();
+ }
+
+
+ //---------------------------------------------------------------
+ TPointCoords
+ ::TPointCoords():
+ myPoints(vtkPoints::New())
+ {
+ myPoints->Delete();
+ }
+
void
- TPoints
- ::Init(vtkIdType theNbCells,
+ TPointCoords
+ ::Init(vtkIdType theNbPoints,
vtkIdType theDim)
{
myDim = theDim;
- myNbCells = theNbCells;
- myCoord.resize(theNbCells*theDim);
+ myNbPoints = theNbPoints;
+ myCoord.resize(theNbPoints*theDim);
+ myPoints->SetNumberOfPoints(theNbPoints);
}
- TCPointSlice
- TPoints
- ::GetPointSlice(vtkIdType theCellId) const
+ TCCoordSlice
+ TPointCoords
+ ::GetCoordSlice(vtkIdType theNodeId) const
{
- return TCPointSlice(myCoord,std::slice(theCellId*myDim,myDim,1));
+ return TCCoordSlice(myCoord,std::slice(theNodeId*myDim,myDim,1));
}
- TPointSlice
- TPoints
- ::GetPointSlice(vtkIdType theCellId)
+ TCoordSlice
+ TPointCoords
+ ::GetCoordSlice(vtkIdType theNodeId)
+ {
+ return TCoordSlice(myCoord,std::slice(theNodeId*myDim,myDim,1));
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ TNamedPointCoords
+ ::Init(vtkIdType theNbPoints,
+ vtkIdType theDim)
{
- return TPointSlice(myCoord,std::slice(theCellId*myDim,myDim,1));
+ TPointCoords::Init(theNbPoints,theDim);
+ myPointsDim.resize(theDim);
}
+ std::string&
+ TNamedPointCoords
+ ::GetName(vtkIdType theDim)
+ {
+ return myPointsDim[theDim];
+ }
+
+ const std::string&
+ TNamedPointCoords
+ ::GetName(vtkIdType theDim) const
+ {
+ return myPointsDim[theDim];
+ }
//---------------------------------------------------------------
TMeshImpl::TMeshImpl():
//---------------------------------------------------------------
TProfileImpl::TProfileImpl():
- myIsAll(true),
- myAppendFilter(vtkAppendFilter::New())
- {
- myAppendFilter->Delete();
- }
+ myIsAll(true)
+ {}
//---------------------------------------------------------------
//---------------------------------------------------------------
enum ECoordName{eX, eY, eZ, eNone};
- typedef VISU::TCoord (*TGetCoord)(const VISU::TPointsCoord&, int);
+ typedef VISU::TCoord (*TGetCoord)(const VISU::TCCoordSlice& theCoordSlice);
- template<ECoordName TheCoordId>
+ template<ECoordName TCoordId>
VISU::TCoord
- GetCoord(const VISU::TPointsCoord& thePointsCoord,
- int theStartPos)
+ GetCoord(const VISU::TCCoordSlice& theCoordSlice)
{
- return thePointsCoord[theStartPos+TheCoordId];
+ return theCoordSlice[TCoordId];
}
template<>
VISU::TCoord
- GetCoord<eNone>(const VISU::TPointsCoord& thePointsCoord,
- int theStartPos)
+ GetCoord<eNone>(const VISU::TCCoordSlice& theCoordSlice)
{
return 0.0;
}
class TCoordHelper{
- const VISU::TPointsCoord& myPointsCoord;
TGetCoord* myGetCoord;
public:
- TCoordHelper(const VISU::TPointsCoord& thePointsCoord,
- TGetCoord* theGetCoord):
- myPointsCoord(thePointsCoord),
+ TCoordHelper(TGetCoord* theGetCoord):
myGetCoord(theGetCoord)
{}
- virtual ~TCoordHelper(){}
+
+ virtual
+ ~TCoordHelper()
+ {}
+
VISU::TCoord
- GetCoord(int theStartPos, int theCoodId)
+ GetCoord(VISU::TCCoordSlice& theCoordSlice,
+ int theCoordId)
{
- return (*myGetCoord[theCoodId])(myPointsCoord,theStartPos);
+ return (*myGetCoord[theCoordId])(theCoordSlice);
}
};
typedef std::auto_ptr<TCoordHelper> TCoordHelperPtr;
+ //---------------------------------------------------------------
void
GetPoints(VISU::TVTKSource& theSource,
VISU::PMeshImpl theMesh)
{
TVTKPoints& aPoints = theMesh->myPoints;
+ const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
if(!theMesh->myIsVTKDone){
TCoordHelperPtr aCoordHelperPtr;
- const VISU::TPointsCoord& anArray = theMesh->myPointsCoord;
{
int aMeshDimension = theMesh->myDim;
bool anIsDimPresent[3] = {false, false, false};
for(int iDim = 0; iDim < aMeshDimension; iDim++){
- string aDimName = theMesh->myPointsDim[iDim];
- if(aDimName == "x" || aDimName == "X")
+ const std::string& aName = aCoords.GetName(iDim);
+ if(aName == "x" || aName == "X")
anIsDimPresent[eX] = true;
- else if(aDimName == "y" || aDimName == "Y")
+ else if(aName == "y" || aName == "Y")
anIsDimPresent[eY] = true;
- else if(aDimName == "z" || aDimName == "Z")
+ else if(aName == "z" || aName == "Z")
anIsDimPresent[eZ] = true;
}
switch(aMeshDimension){
case 3:
- aCoordHelperPtr.reset(new TCoordHelper(anArray,aXYZGetCoord));
+ aCoordHelperPtr.reset(new TCoordHelper(aXYZGetCoord));
break;
case 2:
if(anIsDimPresent[eY] && anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(anArray,aYZGetCoord));
+ aCoordHelperPtr.reset(new TCoordHelper(aYZGetCoord));
else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(anArray,aXZGetCoord));
+ aCoordHelperPtr.reset(new TCoordHelper(aXZGetCoord));
else
- aCoordHelperPtr.reset(new TCoordHelper(anArray,aXYGetCoord));
+ aCoordHelperPtr.reset(new TCoordHelper(aXYGetCoord));
break;
case 1:
if(anIsDimPresent[eY])
- aCoordHelperPtr.reset(new TCoordHelper(anArray,aYGetCoord));
+ aCoordHelperPtr.reset(new TCoordHelper(aYGetCoord));
else if(anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(anArray,aZGetCoord));
+ aCoordHelperPtr.reset(new TCoordHelper(aZGetCoord));
else
- aCoordHelperPtr.reset(new TCoordHelper(anArray,aXGetCoord));
+ aCoordHelperPtr.reset(new TCoordHelper(aXGetCoord));
break;
}
}
- vtkIdType iEnd = theMesh->myPointsCoord.size();
- vtkIdType aNbPoints = iEnd / theMesh->myDim;
+ vtkIdType aNbPoints = aCoords.GetNbPoints();
aPoints->SetNumberOfPoints(aNbPoints);
-
+
INITMSG(MYDEBUG,"GetPoints - aNbPoints = "<<aNbPoints<<
"; aDim = "<<theMesh->myDim<<
endl);
- for(vtkIdType i = 0, j = 0; i < iEnd; i += theMesh->myDim, j++)
- aPoints->SetPoint(j,
- aCoordHelperPtr->GetCoord(i,eX),
- aCoordHelperPtr->GetCoord(i,eY),
- aCoordHelperPtr->GetCoord(i,eZ));
-
+ 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();
}
}
+ //---------------------------------------------------------------
void
PrintCells(int& theStartId,
vtkCellArray* theConnectivity,
anIdList->Delete();
}
+
+ //---------------------------------------------------------------
void
GetCellsOnEntity(VISU::TVTKSource& theSource,
const VISU::PMeshOnEntityImpl theMeshOnEntity,
}
+ //---------------------------------------------------------------
void
GetCellsOnGroup(VISU::TVTKSource& theSource,
VISU::PMeshImpl theMesh,
}
+ //---------------------------------------------------------------
void
- GetTimeStamp3(vtkFloatArray *theFloatArray,
- const vtkIdType& theNumberOfTuples,
- const std::string& theFieldName,
- VISU::PFieldImpl theField,
- VISU::PValForTimeImpl theValForTime)
+ GetTimeStampOnProfile2(vtkFloatArray *theFloatArray,
+ const vtkIdType& theNumberOfTuples,
+ const std::string& theFieldName,
+ VISU::PFieldImpl theField,
+ VISU::PValForTimeImpl theValForTime)
{
//theFloatArray->DebugOn();
theFloatArray->SetNumberOfTuples(theNumberOfTuples);
int aStep = aNbComp*aNbGauss;
int aNbElem = anArray.size()/aStep;
- INITMSG(MYDEBUG,"GetTimeStamp3 - aGeom = "<<aGeom<<
+ INITMSG(MYDEBUG,"GetTimeStampOnProfile2 - aGeom = "<<aGeom<<
"; aNbElem = "<<aNbElem<<
"; aNbComp = "<<aNbComp<<
"; aNbGauss = "<<aNbGauss<<
theFloatArray->SetTuple3(aTupleId++,aValue[0],aValue[1],aValue[2]);
}
else
- EXCEPTION(runtime_error,"GetTimeStamp3 - There is no an algorithm for representation of the field !!!");
+ EXCEPTION(runtime_error,"GetTimeStampOnProfile2 - There is no an algorithm for representation of the field !!!");
break;
}
}
}
+
+ //---------------------------------------------------------------
std::string
GenerateFieldName(const VISU::PFieldImpl theField,
const VISU::PValForTimeImpl theValForTime)
return aFieldName;
}
+
+ //---------------------------------------------------------------
void
- GetTimeStamp2(VISU::TVTKSource& theSource,
- const VISU::PFieldImpl theField,
- const VISU::PValForTimeImpl theValForTime)
+ GetTimeStampOnProfile(VISU::TVTKSource& theSource,
+ const VISU::PFieldImpl theField,
+ const VISU::PValForTimeImpl theValForTime)
{
int aNbTuples = theField->myDataSize/theField->myNbComp;
string aFieldName = GenerateFieldName(theField,theValForTime);
- INITMSG(MYDEBUG,"GetTimeStamp2 - aNbTuples = "<<aNbTuples<<endl);
+ INITMSG(MYDEBUG,"GetTimeStampOnProfile - aNbTuples = "<<aNbTuples<<endl);
vtkDataSetAttributes* aDataSetAttributes;
switch(theField->myEntity){
aDataSetAttributes->SetVectors(aFloatArray);
}
- GetTimeStamp3(aFloatArray,
- aNbTuples,
- aFieldName,
- theField,
- theValForTime);
+ GetTimeStampOnProfile2(aFloatArray,
+ aNbTuples,
+ aFieldName,
+ theField,
+ theValForTime);
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetCells(VISU::TVTKSource& theSource,
+ PSubProfileImpl theSubProfile,
+ PMeshOnEntityImpl theMeshOnEntity)
+ {
+ vtkIdType aNbCells = theSubProfile->myNbCells;
+ vtkIdType aCellsSize = theSubProfile->myCellsSize;
+ vtkIdType aGeom = theSubProfile->myGeom;
+ vtkIdType aNbNodes = VTKGeom2NbNodes(aGeom);
+
+ const TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID;
+ const TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect;
+ TGeom2Cell2Connect::const_iterator aConnectIter = aGeom2Cell2Connect.find(aGeom);
+ if(aConnectIter == aGeom2Cell2Connect.end())
+ EXCEPTION(runtime_error,"GetCells >> There is no elements for the GEOM("<<aGeom<<")");
+
+ const TCell2Connect& aCell2Connect = aConnectIter->second;
+
+ vtkCellArray* aConnectivity = vtkCellArray::New();
+ aConnectivity->Allocate(aCellsSize,0);
+ vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+ aCellTypesArray->SetNumberOfComponents(1);
+ aCellTypesArray->SetNumberOfTuples(aNbCells);
+
+ if(theSubProfile->myStatus == eAddAll){
+ VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin();
+ for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){
+ const TConnect& anArray = aCell2Connect[anId];
+ PrintCells(aConnId,aConnectivity,anArray);
+ aCellTypesArray->SetValue(anId,(unsigned char)aGeom);
+ aConnId += aNbNodes;
+ anId++;
+ }
+ }else{
+ 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];
+ PrintCells(aConnId,aConnectivity,anArray);
+ aCellTypesArray->SetValue(anId,(unsigned char)aGeom);
+ aConnId += aNbNodes;
+ anId++;
+ }
+ }
+
+ vtkIdType *pts = 0, npts = 0;
+ vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+
+ aCellLocationsArray->SetNumberOfComponents(1);
+ aCellLocationsArray->SetNumberOfTuples(aNbCells);
+ aConnectivity->InitTraversal();
+ for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
+ aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
+ theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
+
+ aCellLocationsArray->Delete();
+ aCellTypesArray->Delete();
+ aConnectivity->Delete();
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetMeshOnSubProfile(PMeshImpl theMesh,
+ PMeshOnEntityImpl theMeshOnEntity,
+ PProfileImpl theProfile,
+ PSubProfileImpl theSubProfile)
+ {
+ INITMSG(MYDEBUG,"GetMeshOnSubProfile - aGeom = "<<theSubProfile->myGeom<<endl);
+
+ TVTKSource& aSource = theSubProfile->mySource;
+ if(theSubProfile->myIsVTKDone)
+ return;
+
+ GetPoints(aSource,theMesh);
+ INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
+ GetCells(aSource,theSubProfile,theMeshOnEntity);
+ BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
+
+ theSubProfile->myIsVTKDone = true;
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetMeshOnProfile(PMeshImpl theMesh,
+ PMeshOnEntityImpl theMeshOnEntity,
+ PProfileImpl theProfile)
+ {
+ if(theProfile->myIsVTKDone)
+ return;
+
+ TVTKAppendFilter& anAppendFilter = theProfile->myFilter;
+ if(theProfile->myIsAll){
+ TVTKSource& aSource = theMeshOnEntity->mySource;
+ anAppendFilter->AddInput(aSource.GetPointer());
+ }else{
+ const TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
+ TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
+ for(; anIter != aGeom2SubProfile.end(); anIter++){
+ PSubProfileImpl aSubProfile = anIter->second;
+ if(aSubProfile->myStatus == eRemoveAll)
+ continue;
+
+ GetMeshOnSubProfile(theMesh,
+ theMeshOnEntity,
+ theProfile,
+ aSubProfile);
+
+ TVTKSource& aSource = aSubProfile->mySource;
+ anAppendFilter->AddInput(aSource.GetPointer());
+ }
+ }
+ anAppendFilter->Update(); // Fix on VTK
+
+ theProfile->myIsVTKDone = true;
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetSource(VISU::TVTKSource& theSource,
+ PGaussSubMeshImpl theGaussSubMesh,
+ 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);
+
+ const TVTKPoints& aPoints = aCoords.GetPoints();
+ vtkIdList *anIdList = vtkIdList::New();
+ anIdList->SetNumberOfIds(1);
+ for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
+ TCCoordSlice aSlice = aCoords.GetCoordSlice(aPointId);
+
+ float 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);
+ aConnectivity->InsertNextCell(anIdList);
+ aCellTypesArray->SetValue(aPointId,(unsigned char)VTK_VERTEX);
+ }
+ anIdList->Delete();
+
+ vtkIntArray* aCellLocationsArray = vtkIntArray::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));
+
+ TVTKSource& aSource = theGaussSubMesh->mySource;
+ aSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
+ aSource->SetPoints(aPoints.GetPointer());
+
+ aCellLocationsArray->Delete();
+ aCellTypesArray->Delete();
+ aConnectivity->Delete();
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetGaussSubMesh(PMeshImpl theMesh,
+ PMeshOnEntityImpl theMeshOnEntity,
+ PGaussMeshImpl theGaussMesh,
+ PGaussSubMeshImpl theGaussSubMesh)
+ {
+ PGaussImpl aGauss = theGaussSubMesh->myGauss;
+ INITMSG(MYDEBUG,"GetGaussSubMesh - aGeom = "<<aGauss->myGeom<<endl);
+
+ TVTKSource& aSource = theGaussSubMesh->mySource;
+ if(theGaussSubMesh->myIsVTKDone)
+ return;
+
+ GetSource(aSource,theGaussSubMesh,theMeshOnEntity);
+ INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
+ BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
+
+ theGaussSubMesh->myIsVTKDone = true;
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetGaussMesh(PMeshImpl theMesh,
+ PMeshOnEntityImpl theMeshOnEntity,
+ PGaussMeshImpl theGaussMesh)
+ {
+ if(theGaussMesh->myIsVTKDone)
+ return;
+
+ TVTKAppendFilter& anAppendFilter = theGaussMesh->myFilter;
+ const TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
+ TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
+ for(; anIter != aGeom2GaussSubMesh.end(); anIter++){
+ PGaussSubMeshImpl aGaussSubMesh = anIter->second;
+ if(aGaussSubMesh->myStatus == eRemoveAll)
+ continue;
+
+ GetGaussSubMesh(theMesh,
+ theMeshOnEntity,
+ theGaussMesh,
+ aGaussSubMesh);
+
+ TVTKSource& aSource = aGaussSubMesh->mySource;
+ anAppendFilter->AddInput(aSource.GetPointer());
+ }
+ anAppendFilter->Update(); // Fix on VTK
+
+ theGaussMesh->myIsVTKDone = true;
}
+
+
}
+//---------------------------------------------------------------
VISU_Convertor_impl
::VISU_Convertor_impl()
{
myIsDone = false;
}
+
+//---------------------------------------------------------------
VISU_Convertor_impl
::~VISU_Convertor_impl()
{}
+
+//---------------------------------------------------------------
VISU_Convertor::TOutput*
VISU_Convertor_impl
::GetMeshOnEntity(const string& theMeshName,
return aSource.GetPointer();
}
+
+//---------------------------------------------------------------
VISU_Convertor::TOutput*
VISU_Convertor_impl
::GetMeshOnGroup(const string& theMeshName,
}
-void
-GetCells(VISU::TVTKSource& theSource,
- PSubProfileImpl theSubProfile,
- PMeshOnEntityImpl theMeshOnEntity)
-{
- vtkIdType aNbCells = theSubProfile->myNbCells;
- vtkIdType aCellsSize = theSubProfile->myCellsSize;
- vtkIdType aGeom = theSubProfile->myGeom;
- vtkIdType aNbNodes = VTKGeom2NbNodes(aGeom);
-
- const TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID;
- const TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect;
- TGeom2Cell2Connect::const_iterator aConnectIter = aGeom2Cell2Connect.find(aGeom);
- if(aConnectIter == aGeom2Cell2Connect.end())
- EXCEPTION(runtime_error,"GetCells >> There is no elements for the GEOM("<<aGeom<<")");
-
- const TCell2Connect& aCell2Connect = aConnectIter->second;
-
- vtkCellArray* aConnectivity = vtkCellArray::New();
- aConnectivity->Allocate(aCellsSize,0);
- vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
- aCellTypesArray->SetNumberOfComponents(1);
- aCellTypesArray->SetNumberOfTuples(aNbCells);
-
- if(theSubProfile->myStatus == eAddAll){
- VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin();
- for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){
- const TConnect& anArray = aCell2Connect[anId];
- PrintCells(aConnId,aConnectivity,anArray);
- aCellTypesArray->SetValue(anId,(unsigned char)aGeom);
- aConnId += aNbNodes;
- anId++;
- }
- }else{
- 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];
- PrintCells(aConnId,aConnectivity,anArray);
- aCellTypesArray->SetValue(anId,(unsigned char)aGeom);
- aConnId += aNbNodes;
- anId++;
- }
- }
-
- vtkIdType *pts = 0, npts = 0;
- vtkIntArray* aCellLocationsArray = vtkIntArray::New();
-
- aCellLocationsArray->SetNumberOfComponents(1);
- aCellLocationsArray->SetNumberOfTuples(aNbCells);
- aConnectivity->InitTraversal();
- for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
- aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
- theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
-
- aCellLocationsArray->Delete();
- aCellTypesArray->Delete();
- aConnectivity->Delete();
-}
-
-
-void
-GetMeshOnSubProfile(PMeshImpl theMesh,
- PMeshOnEntityImpl theMeshOnEntity,
- PProfileImpl theProfile,
- PSubProfileImpl theSubProfile)
-{
- INITMSG(MYDEBUG,"GetMeshOnSubProfile - aGeom = "<<theSubProfile->myGeom<<endl);
-
- TVTKSource& aSource = theSubProfile->mySource;
- if(theSubProfile->myIsVTKDone)
- return;
-
- GetPoints(aSource,theMesh);
- INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
- GetCells(aSource,theSubProfile,theMeshOnEntity);
- BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
-
- theSubProfile->myIsVTKDone = true;
-}
-
-
-void
-GetMeshOnProfile(PMeshImpl theMesh,
- PMeshOnEntityImpl theMeshOnEntity,
- PProfileImpl theProfile)
-{
- if(theProfile->myIsVTKDone)
- return;
-
- TVTKAppendFilter& anAppendFilter = theProfile->myAppendFilter;
- if(theProfile->myIsAll){
- TVTKSource& aSource = theMeshOnEntity->mySource;
- anAppendFilter->AddInput(aSource.GetPointer());
- }else{
- const TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
- TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
- for(; anIter != aGeom2SubProfile.end(); anIter++){
- PSubProfileImpl aSubProfile = anIter->second;
- if(aSubProfile->myStatus == eRemoveAll)
- continue;
-
- GetMeshOnSubProfile(theMesh,
- theMeshOnEntity,
- theProfile,
- aSubProfile);
-
- TVTKSource& aSource = aSubProfile->mySource;
- anAppendFilter->AddInput(aSource.GetPointer());
- }
- }
- anAppendFilter->Update(); // Fix on VTK
- theProfile->myIsVTKDone = true;
-}
-
-
+//---------------------------------------------------------------
VISU_Convertor::TOutput*
VISU_Convertor_impl
::GetTimeStampOnMesh(const string& theMeshName,
"; theFieldName = '"<<theFieldName<<"'"<<
"; theStampsNum = "<<theStampsNum<<
endl);
+
//Cheching possibility do the query
- TFindTimeStamp aFindTimeStamp =
- FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
+ TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
+ theEntity,
+ theFieldName,
+ theStampsNum);
+
PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
GetMeshOnEntity(aVTKMeshOnEntity->myMeshName,aVTKMeshOnEntity->myEntity);
PProfileImpl aProfile = aValForTime->myProfile;
- GetMeshOnProfile(aMesh,aVTKMeshOnEntity,aProfile);
+ PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh;
+ const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
+ INITMSG(MYDEBUG,"aGeom2GaussSubMesh.size() = "<<aGeom2GaussSubMesh.size()<<endl);
+ if(aGeom2GaussSubMesh.empty()){
+ GetMeshOnProfile(aMesh,aVTKMeshOnEntity,aProfile);
- TVTKAppendFilter& anAppendFilter = aProfile->myAppendFilter;
-
- aSource->ShallowCopy(anAppendFilter->GetOutput());
- GetTimeStamp2(aSource,aField,aValForTime);
+ TVTKAppendFilter& anAppendFilter = aProfile->myFilter;
+ aSource->ShallowCopy(anAppendFilter->GetOutput());
+ GetTimeStampOnProfile(aSource,aField,aValForTime);
+ }else{
+ GetGaussMesh(aMesh,aVTKMeshOnEntity,aGaussMesh);
+
+ TVTKAppendFilter& anAppendFilter = aGaussMesh->myFilter;
+ aSource->ShallowCopy(anAppendFilter->GetOutput());
+ //GetTimeStampOnProfile(aSource,aField,aValForTime);
+ }
aValForTime->myIsVTKDone = true;
return aSource.GetPointer();
}
+
+//---------------------------------------------------------------
VISU::PMeshImpl
VISU_Convertor_impl
::FindMesh(const string& theMeshName)
}
+//---------------------------------------------------------------
VISU_Convertor_impl::TFindMeshOnEntity
VISU_Convertor_impl
::FindMeshOnEntity(const string& theMeshName,
}
+//---------------------------------------------------------------
float
VISU_Convertor_impl
::GetSize()
}
}
-namespace{
+namespace
+{
using namespace SALOME_MED;
const int MED_NBR_GEOMETRIE_MAILLE = 15;
MED_POINT1,
};
- int GetEntity2Geom(const VISU::TEntity& theEntity, medGeometryElement*& theVector)
+
+ //---------------------------------------------------------------
+ int
+ GetEntity2Geom(const VISU::TEntity& theEntity, medGeometryElement*& theVector)
{
switch(theEntity){
case CELL_ENTITY: theVector = CELLGEOM; return MED_NBR_GEOMETRIE_MAILLE; break;
return -1;
}
- int MEDGeom2NbNodes(int theMEDGeomType)
+
+ //---------------------------------------------------------------
+ int
+ MEDGeom2NbNodes(int theMEDGeomType)
{
switch(theMEDGeomType){
case MED_NONE: return 0;
return -1;
}
- int MEDGeomToVTK(medGeometryElement theMEDGeomType)
+
+ //---------------------------------------------------------------
+ int
+ MEDGeomToVTK(medGeometryElement theMEDGeomType)
{
switch(theMEDGeomType){
case MED_NONE: return VTK_EMPTY_CELL;
return -1;
}
- medGeometryElement VTKGeomToMED(int theVTKGeomType)
+
+ //---------------------------------------------------------------
+ medGeometryElement
+ VTKGeomToMED(int theVTKGeomType)
{
switch(theVTKGeomType){
case VTK_VERTEX: return MED_POINT1;
return medGeometryElement(-1);
}
- VISU::TEntity MEDEntityToVTK(medEntityMesh theMEDEntity)
+ //---------------------------------------------------------------
+ VISU::TEntity
+ MEDEntityToVTK(medEntityMesh theMEDEntity)
{
switch(theMEDEntity){
case MED_NODE: return NODE_ENTITY;
return VISU::TEntity(-1);
}
- medEntityMesh VTKEntityToMED(VISU::TEntity theVTKEntity)
+ //---------------------------------------------------------------
+ medEntityMesh
+ VTKEntityToMED(VISU::TEntity theVTKEntity)
{
switch(theVTKEntity){
case NODE_ENTITY: return MED_NODE;
}
return medEntityMesh(-1);
}
+
- string GetSObjectName(SALOMEDS::SObject_ptr aSObject){
+ //---------------------------------------------------------------
+ std::string
+ GetSObjectName(SALOMEDS::SObject_ptr aSObject)
+ {
SALOMEDS::GenericAttribute_var anAttr;
if (aSObject->FindAttribute(anAttr,"AttributeName")) {
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
return "";
}
+
+ //---------------------------------------------------------------
void
GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize,
SALOME_MED::MESH_ptr theMEDMesh,
}
+ //---------------------------------------------------------------
void
GetCellsSize(vtkIdType& theNbCells, vtkIdType& theCellsSize,
SALOME_MED::FAMILY_ptr theMEDFamily)
}
+ //---------------------------------------------------------------
void
GetCellsSize(VISU::PCMesh theMesh,
SALOME_MED::MESH_ptr theMEDMesh,
TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
VISU::PCMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[theEntity];
if(theEntity == NODE_ENTITY){
- theMesh->myNbPoints = theMEDMesh->getNumberOfNodes();
aMeshOnEntity->myNbCells = theMesh->myNbPoints;
aMeshOnEntity->myCellsSize = 2*theMesh->myNbPoints;
vtkIdType aNbCells, aCellsSize;
GetCellsSize(aNbCells,aCellsSize,theMEDMesh,CELL_ENTITY);
if(aNbCells > 0){
-
TMeshOnEntityMap::iterator aIter = aMeshOnEntityMap.find(CELL_ENTITY);
if (aIter != aMeshOnEntityMap.end()){
VISU::PCMeshOnEntity aMeshOnCells = aIter->second;
-
aMeshOnCells->myEntity = VISU::CELL_ENTITY;
aMeshOnCells->myMeshName = theMesh->myName;
aMeshOnCells->myNbCells = aNbCells;
}
+//---------------------------------------------------------------
VISU_Convertor*
VISU_MEDFieldConvertor::Build()
{
CORBA::String_var aFieldName = myField->getName();
PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
+ aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
aMesh->myDim = aMEDMesh->getSpaceDimension();
- aMesh->myPointsDim.resize(aMesh->myDim);
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;
}
+//---------------------------------------------------------------
VISU_Convertor*
VISU_MEDConvertor::Build()
{
return Build(aTimeStampIterator);
}
+
namespace{
using namespace boost;
- struct TSObjectByName{
+ //---------------------------------------------------------------
+ struct TSObjectByName
+ {
std::string myName;
typedef tuple<SALOMEDS::SObject_var> TRet;
};
- struct TMeshByName{
+
+ //---------------------------------------------------------------
+ struct TMeshByName
+ {
std::string myName;
typedef tuple<SALOME_MED::MESH_var,SALOMEDS::SObject_var> TRet;
}
};
+
+ //---------------------------------------------------------------
template<typename TFun>
typename TFun::TRet
Find(SALOMEDS::SObject_ptr theStartSObj,
}
+
+//---------------------------------------------------------------
VISU_Convertor*
VISU_MEDConvertor::Build(SALOME_MED::MED_ptr theMED)
{
PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
SALOME_MED::MESH_var aMEDMesh = boost::get<0>(aMeshByNameRet);
+ aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
aMesh->myDim = aMEDMesh->getSpaceDimension();
aMesh->myName = aMeshName.in();
- aMesh->myPointsDim.resize(aMesh->myDim);
aMesh->myMesh = aMEDMesh;
+ TNamedPointCoords& aCoords = aMesh->myNamedPointCoords;
+ aCoords.Init(aMesh->myNbPoints,aMesh->myDim);
+
if(MYDEBUG)
MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
}
+//---------------------------------------------------------------
VISU_Convertor*
VISU_MEDConvertor::Build(SALOMEDS::ChildIterator_ptr theTimeStampIterator)
{
CORBA::String_var aFieldName = aMEDField->getName();
PCMesh aMesh = myMeshMap[aMeshName.in()](new TCMesh());
+ aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
aMesh->myDim = aMEDMesh->getSpaceDimension();
- aMesh->myPointsDim.resize(aMesh->myDim);
aMesh->myName = aMeshName.in();
- aMesh->myNbPoints = aMEDMesh->getNumberOfNodes();
aMesh->myMesh = aMEDMesh;
+
+ TNamedPointCoords& aCoords = aMesh->myNamedPointCoords;
+ aCoords.Init(aMesh->myNbPoints,aMesh->myDim);
+
if(MYDEBUG) MESSAGE("VISU_MEDConvertor::Build - aMeshName = '"<<aMeshName<<"'; myDim = "<<aMesh->myDim);
TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
}
+//---------------------------------------------------------------
int
VISU_MEDConvertor::LoadMeshOnEntity(VISU::PMeshOnEntityImpl theMeshOnEntity,
const string& theFamilyName)
}
+//---------------------------------------------------------------
int
VISU_MEDConvertor::LoadMeshOnGroup(VISU::PMeshImpl theMesh,
const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
}
+//---------------------------------------------------------------
int
VISU_MEDConvertor::LoadFieldOnMesh(VISU::PMeshImpl theMesh,
VISU::PMeshOnEntityImpl theMeshOnEntity,
return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated);
}
+
+//---------------------------------------------------------------
int
VISU_MEDConvertor::LoadPoints(VISU::PCMesh theMesh,
const string& theFamilyName)
//Check on existing family
PCMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY];
PCFamily aFamily = GetFamily(aMeshOnEntity,theFamilyName);
+
//Check on loading already done
- bool isPointsLoaded = !theMesh->myPointsCoord.empty();
- if(isPointsLoaded)
+ if(theMesh->myIsCDone)
if(!aFamily)
return 0;
- else if(!aFamily->myGeom2SubMeshID.empty())
+ else if(!aFamily->myIsCDone)
return 0;
if(MYDEBUG)
- MESSAGE("LoadPoints - isPointsLoaded = "<<isPointsLoaded<<"; theFamilyName = '"<<theFamilyName<<"'");
+ MESSAGE("LoadPoints - theFamilyName = '"<<theFamilyName<<"'");
SALOME_MED::MESH_var& aMedMesh = theMesh->myMesh;
- int iNumElemEnd = aMedMesh->getNumberOfNodes();
- TPointsCoord& aPointsCoord = theMesh->myPointsCoord;
+ int aDim = theMesh->myDim;
+ TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
+ int aNbElem = aCoords.GetNbPoints();
- if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "<<iNumElemEnd);
+ if(MYDEBUG) MESSAGE("LoadPoints - aNbElem = "<<aNbElem);
- if (iNumElemEnd <= 0)
+ if(aNbElem <= 0)
throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!");
- aPointsCoord.resize(theMesh->myDim*iNumElemEnd,0.0);
- SALOME_MED::double_array_var coord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
- if(!isPointsLoaded){
- for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
- for(int iDim = 0, iNumElem2Dim = iNumElem*theMesh->myDim; iDim < theMesh->myDim; iDim++, iNumElem2Dim++)
- aPointsCoord[iNumElem2Dim] = coord[iNumElem2Dim];
+ SALOME_MED::double_array_var aCCoord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
+ if(!theMesh->myIsCDone){
+ 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++];
+ }
if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");
TCell2Connect& aCell2Connect = aMeshOnEntity->myGeom2Cell2Connect[VTK_VERTEX];
- aCell2Connect.resize(iNumElemEnd);
- for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)
- aCell2Connect[iNumElem] = TConnect(1,iNumElem);
+ aCell2Connect.resize(aNbElem);
+ for(int iElem = 0; iElem < aNbElem; iElem++)
+ aCell2Connect[iElem] = TConnect(1,iElem);
+
+ theMesh->myIsCDone = true;
}
- if(aFamily){
- if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily Geom2SubMeshID");
-
- SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily;
- CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
- TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[VTK_VERTEX];
- if(!anIsOnAllElements){
- SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
- SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]);
- int iNumElemEndTmp = iNumElemEnd;
- iNumElemEnd = aCellNumForType->length();
- for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) {
- int tmp = aCellNumForType[iNumElem]-1;
- if(0 > tmp || tmp >= iNumElemEndTmp) {
- static QString aString;
- aString.sprintf("LoadPoints >> iNumElemEndTmp(%d) <= aCellNumForType[%d]=%d < 0 !!!",iNumElemEnd,iNumElem,tmp);
- throw std::runtime_error(aString.latin1());
+ if(aFamily){
+ if(!aFamily->myIsCDone){
+ if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily Geom2SubMeshID");
+
+ SALOME_MED::FAMILY_var aMedFamily = aFamily->myFamily;
+ CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
+ TSubMeshID& aSubMeshID = aFamily->myGeom2SubMeshID[VTK_VERTEX];
+
+ if(!anIsOnAllElements){
+ SALOME_MED::medGeometryElement_array_var aGeom = aMedFamily->getTypes();
+ SALOME_MED::long_array_var aCellNumForType = aMedFamily->getNumber(aGeom[0]);
+ int aMaxElemId = aNbElem;
+ aNbElem = aCellNumForType->length();
+ for(int iElem = 0; iElem < aNbElem; iElem++){
+ int aTmp = aCellNumForType[iElem]-1;
+ if(0 > aTmp || aTmp >= aMaxElemId){
+ static QString aString;
+ aString.sprintf("LoadPoints - aMaxElemId(%d) <= aCellNumForType[%d]=%d < 0",aMaxElemId,iElem,aTmp);
+ throw std::runtime_error(aString.latin1());
+ }
+ aSubMeshID.push_back(aTmp);
+ }
+ }else{
+ for(int iElem = 0; iElem < aNbElem; iElem++){
+ aSubMeshID.push_back(iElem);
}
- aSubMeshID.push_back(tmp);
- }
- }else{
- for(int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++){
- aSubMeshID.push_back(iNumElem);
}
+
+ aFamily->myIsCDone = true;
}
}
+
return 1;
}
+//---------------------------------------------------------------
int
VISU_MEDConvertor::LoadCellsOnEntity(VISU::PCMesh theMesh,
VISU::PCMeshOnEntity theMeshOnEntity,
const TEntity& aVEntity = theMeshOnEntity->myEntity;
int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(aVEntity);
- int aNbPoints = theMesh->myPointsCoord.size()/theMesh->myDim;
+ const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
+ int aNbPoints = aCoords.GetNbPoints();
if(!isCellsLoaded){
for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++){
SALOME_MED::medGeometryElement aGeom = aGeomElems[iGeom];
if(theField->myEntity == NODE_ENTITY){
TValForCellsWithType& aValForCellsWithType =
theValForTime->myValForCells[VTK_VERTEX];
- int iNumElemEnd = theMesh->myPointsCoord.size()/theMesh->myDim*theField->myNbComp;
+
+ const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
+ int aNbPoints = aCoords.GetNbPoints();
+ int iNumElemEnd = aNbPoints*theField->myNbComp;
if(MYDEBUG) MESSAGE("ImportField - iNumElemEnd = "<<iNumElemEnd);
aValForCellsWithType.resize(iNumElemEnd);
for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++)