static int MYVTKDEBUG = 0;
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
static int MYDEBUGWITHFILES = 0;
#else
static int MYDEBUG = 0;
TPointCoords::Init(theNbPoints,theDim);
myPointsDim.resize(theDim);
myVectorID = theVectorID;
+
+ for(vtkIdType anID = 0, anEnd = theVectorID.size(); anID < anEnd; anID++)
+ myObj2VTKID[theVectorID[anID]] = anID;
}
std::string&
}
+ vtkIdType
+ TNamedPointCoords
+ ::GetVTKID(vtkIdType theID) const
+ {
+ if(myObj2VTKID.empty())
+ return theID;
+ else{
+ TObj2VTKID::const_iterator anIter = myObj2VTKID.find(theID);
+ if(anIter != myObj2VTKID.end())
+ return anIter->second;
+ }
+ return -1;
+ }
+
//---------------------------------------------------------------
TMeshImpl::TMeshImpl():
myNamedPointCoords(new TNamedPointCoords()),
}
- vtkIdType
- TSubProfileImpl
- ::GetNodeObjID(vtkIdType theID) const
- {
- return theID;
- }
-
vtkIdType
TSubProfileImpl
::GetElemObjID(vtkIdType theID) const
TProfileImpl
::GetNodeObjID(vtkIdType theID) const
{
- vtkIdType anInputID;
- const TVTKAppendFilter& anAppendFilter = GetFilter();
- vtkIdType aID = anAppendFilter->GetNodeObjId(theID,anInputID);
- const TSubProfileImpl& aSubProfileImpl = mySubProfileArr[anInputID];
- return aSubProfileImpl.GetNodeObjID(aID);
+ return myNamedPointCoords->GetObjID(theID);
}
vtkIdType
const TSubProfileImpl& aSubProfileImpl = mySubProfileArr[anInputID];
return aSubProfileImpl.GetElemObjID(aID);
}
- //modified by NIZNHY-PKV Tue Aug 30 11:18:46 2005f
- //---------------------------------------------------------------
- vtkCell* TProfileImpl::GetElemCell(int theObjID)
+
+ vtkIdType
+ TProfileImpl
+ ::GetElemVTKID(vtkIdType theID) const
{
- int aVtkID;
- vtkIdType aObjID;
- //
- aObjID=GetElemObjID(theObjID);
- const TVTKAppendFilter& anAppendFilter = GetFilter();
- aVtkID=anAppendFilter->GetElemVtkID(aObjID);
- return anAppendFilter->GetOutput()->GetCell(aVtkID);
+ if(myElemObj2VTKID.empty())
+ return theID;
+ else{
+ TElemObj2VTKID::const_iterator anIter = myElemObj2VTKID.find(theID);
+ if(anIter != myElemObj2VTKID.end())
+ return anIter->second;
+ }
+ return -1;
}
- //---------------------------------------------------------------
- float* TProfileImpl::GetNodeCoord(int theObjID)
+
+ vtkIdType
+ TProfileImpl
+ ::GetNodeVTKID(vtkIdType theID) const
{
- int aVtkID;
- vtkIdType aObjID;
- //
- aObjID=GetNodeObjID(theObjID);
- const TVTKAppendFilter& anAppendFilter = GetFilter();
- aVtkID=anAppendFilter->GetElemVtkID(theObjID);
- return anAppendFilter->GetOutput()->GetPoint(aVtkID);
+ return myNamedPointCoords->GetVTKID(theID);
}
- //modified by NIZNHY-PKV Tue Aug 30 11:18:49 2005t
+
+ vtkCell*
+ TProfileImpl
+ ::GetElemCell(int theObjID)
+ {
+ vtkIdType aVtkID = GetElemVTKID(theObjID);
+ return GetFilter()->GetOutput()->GetCell(aVtkID);
+ }
+
+ float*
+ TProfileImpl
+ ::GetNodeCoord(int theObjID)
+ {
+ vtkIdType aVtkID = GetNodeVTKID(theObjID);
+ return GetFilter()->GetOutput()->GetPoint(aVtkID);
+ }
+
//---------------------------------------------------------------
TGaussSubMeshImpl::TGaussSubMeshImpl():
void
GetCellsOnEntity(const TVTKSource& theSource,
const PMeshOnEntityImpl& theMeshOnEntity,
- const std::string& theFamilyName)
+ const std::string& theFamilyName = "")
{
//Check on existing family
PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName);
void
GetCells(const TVTKSource& theSource,
const PSubProfileImpl& theSubProfile,
+ const PProfileImpl& theProfile,
const PMeshOnEntityImpl& theMeshOnEntity)
{
vtkIdType aNbCells = theSubProfile->myNbCells;
aCellTypesArray->SetNumberOfComponents(1);
aCellTypesArray->SetNumberOfTuples(aNbCells);
+ VISU::TElemObj2VTKID& anElemObj2VTKID = theProfile->myElemObj2VTKID;
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);
+
+ anElemObj2VTKID[theSubProfile->GetElemObjID(anId)] = anId;
+
aConnId += aNbNodes;
anId++;
}
const TConnect& anArray = aCell2Connect[aSubId];
PrintCells(aConnId,aConnectivity,anArray);
aCellTypesArray->SetValue(anId,(unsigned char)aGeom);
+
+ anElemObj2VTKID[theSubProfile->GetElemObjID(anId)] = anId;
+
aConnId += aNbNodes;
anId++;
}
GetPoints(aSource,theMesh);
INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
- GetCells(aSource,theSubProfile,theMeshOnEntity);
+ GetCells(aSource,theSubProfile,theProfile,theMeshOnEntity);
BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
theSubProfile->myIsVTKDone = true;
}
+ //---------------------------------------------------------------
+ void
+ PrintMemorySize(vtkUnstructuredGrid* theDataSet)
+ {
+ theDataSet->Update();
+ BEGMSG(1,"GetPoints() = "<<float(theDataSet->GetPoints()->GetActualMemorySize()*1000)<<endl);
+ BEGMSG(1,"GetCells() = "<<float(theDataSet->GetCells()->GetActualMemorySize()*1000)<<endl);
+ BEGMSG(1,"GetCellTypesArray() = "<<float(theDataSet->GetCellTypesArray()->GetActualMemorySize()*1000)<<endl);
+ BEGMSG(1,"GetCellLocationsArray() = "<<float(theDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000)<<endl);
+ theDataSet->BuildLinks();
+ BEGMSG(1,"GetCellLinks() = "<<float(theDataSet->GetCellLinks()->GetActualMemorySize()*1000)<<endl);
+ BEGMSG(1,"GetPointData() = "<<float(theDataSet->GetPointData()->GetActualMemorySize()*1000)<<endl);
+ BEGMSG(1,"GetCellData() = "<<float(theDataSet->GetCellData()->GetActualMemorySize()*1000)<<endl);
+ BEGMSG(1,"GetActualMemorySize() = "<<float(theDataSet->GetActualMemorySize()*1000)<<endl);
+ }
}
const VISU::TEntity& theEntity,
const string& theFamilyName)
{
- INITMSG(MYDEBUG,"GetMeshOnEntity"<<
+ if(theFamilyName == "")
+ return GetMeshOnEntity2(theMeshName,theEntity);
+ else
+ return GetFamilyOnEntity(theMeshName,theEntity,theFamilyName);
+}
+
+
+//---------------------------------------------------------------
+VISU_Convertor::TOutput*
+VISU_Convertor_impl
+::GetMeshOnEntity2(const string& theMeshName,
+ const VISU::TEntity& theEntity)
+{
+ INITMSG(MYDEBUG,"GetMeshOnEntity2"<<
"; theMeshName = '"<<theMeshName<<"'"<<
"; theEntity = "<<theEntity<<
- "; theFamilyName = '"<<theFamilyName<<"'"<<
endl);
//Cheching possibility do the query
- TFindMeshOnEntity aFindMeshOnEntity = FindMeshOnEntity(theMeshName,
- theEntity,
- theFamilyName);
+ TFindMeshOnEntity aFindMeshOnEntity =
+ FindMeshOnEntity(theMeshName,theEntity);
+
PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
- PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity);
PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
- TVTKSource aSource;
- bool *anIsInitialized;
- if(aFamily){
- aSource = aFamily->GetSource();
- anIsInitialized = &(aFamily->myIsVTKDone);
- }else{
- aSource = aMeshOnEntity->GetSource();
- anIsInitialized = &(aMeshOnEntity->myIsVTKDone);
+ //Main part of code
+ const TVTKSource& aSource = aMeshOnEntity->GetSource();
+#ifndef _DEXCEPT_
+ try{
+#endif
+ if(!aMeshOnEntity->myIsVTKDone){
+ if(MYVTKDEBUG) aSource->DebugOn();
+
+ LoadMeshOnEntity(aMeshOnEntity);
+ GetPoints(aSource,aMesh);
+ GetCellsOnEntity(aSource,aMeshOnEntity);
+
+ aMeshOnEntity->myIsVTKDone = true;
+
+ if(MYDEBUGWITHFILES){
+ std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
+ std::string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
+ aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-Conv.vtk";
+ VISU::WriteToFile(aSource.GetPointer(),aFileName);
+ }
+ }
+
+ if(MYVTKDEBUG){
+ GetMeshOnEntitySize(theMeshName,theEntity);
+ PrintMemorySize(aSource.GetPointer());
+ }
+
+#ifndef _DEXCEPT_
+ }catch(...){
+ throw;
}
+#endif
+
+ return aSource.GetPointer();
+}
+
+
+//---------------------------------------------------------------
+VISU_Convertor::TOutput*
+VISU_Convertor_impl
+::GetFamilyOnEntity(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFamilyName)
+{
+ INITMSG(MYDEBUG,"GetFamilyOnEntity"<<
+ "; theMeshName = '"<<theMeshName<<"'"<<
+ "; theEntity = "<<theEntity<<
+ "; theFamilyName = '"<<theFamilyName<<"'"<<
+ endl);
+
+ //Cheching possibility do the query
+ TFindFamilyOnEntity aFindFamilyOnEntity =
+ FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
+
+ PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);;
+ PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
+ PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
//Main part of code
+ const TVTKSource& aSource = aFamily->GetSource();
#ifndef _DEXCEPT_
try{
#endif
- if(!(*anIsInitialized)){
+ if(!aFamily->myIsVTKDone){
if(MYVTKDEBUG) aSource->DebugOn();
LoadMeshOnEntity(aMeshOnEntity,theFamilyName);
GetPoints(aSource,aMesh);
GetCellsOnEntity(aSource,aMeshOnEntity,theFamilyName);
- (*anIsInitialized) = true;
+ aFamily->myIsVTKDone = true;
if(MYDEBUGWITHFILES){
- string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
- string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1();
- string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
+ std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
+ std::string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1();
+ std::string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-Conv.vtk";
VISU::WriteToFile(aSource.GetPointer(),aFileName);
}
if(MYVTKDEBUG){
GetMeshOnEntitySize(theMeshName,theEntity,theFamilyName);
- aSource->Update();
- BEGMSG(MYVTKDEBUG,"GetPoints() = "<<float(aSource->GetPoints()->GetActualMemorySize()*1000)<<endl);
- BEGMSG(MYVTKDEBUG,"GetCells() = "<<float(aSource->GetCells()->GetActualMemorySize()*1000)<<endl);
- BEGMSG(MYVTKDEBUG,"GetCellTypesArray() = "<<float(aSource->GetCellTypesArray()->GetActualMemorySize()*1000)<<endl);
- BEGMSG(MYVTKDEBUG,"GetCellLocationsArray() = "<<float(aSource->GetCellLocationsArray()->GetActualMemorySize()*1000)<<endl);
- aSource->BuildLinks();
- BEGMSG(MYVTKDEBUG,"GetCellLinks() = "<<float(aSource->GetCellLinks()->GetActualMemorySize()*1000)<<endl);
- BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<float(aSource->GetActualMemorySize()*1000)<<endl);
+ PrintMemorySize(aSource.GetPointer());
}
+
#ifndef _DEXCEPT_
}catch(...){
throw;
return aSource.GetPointer();
}
+
//---------------------------------------------------------------
VISU::PProfile
-VISU_Convertor_impl::GetProfile(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName,
- int theStampsNum)
+VISU_Convertor_impl
+::GetProfile(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theStampsNum)
{
GetTimeStampOnMesh(theMeshName, theEntity, theFieldName, theStampsNum);
TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
return aProfile;
}
+
//---------------------------------------------------------------
VISU_Convertor::TOutput*
VISU_Convertor_impl
VISU_Convertor_impl::TFindMeshOnEntity
VISU_Convertor_impl
::FindMeshOnEntity(const string& theMeshName,
- const VISU::TEntity& theEntity,
- const string& theFamilyName)
+ const VISU::TEntity& theEntity)
{
PMeshImpl aMesh = FindMesh(theMeshName);
VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
EXCEPTION(runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
-
+
return TFindMeshOnEntity(aMesh,
- aMeshOnEntityMap[theEntity],
- GetFamily(aMeshOnEntity,theFamilyName));
+ aMeshOnEntity);
+}
+
+
+//---------------------------------------------------------------
+VISU_Convertor_impl::TFindFamilyOnEntity
+VISU_Convertor_impl
+::FindFamilyOnEntity(const string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const string& theFamilyName)
+{
+ PMeshImpl aMesh = FindMesh(theMeshName);
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
+ if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
+ EXCEPTION(runtime_error,"FindFamilyOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
+
+ PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
+
+ return TFindFamilyOnEntity(aMesh,
+ aMeshOnEntity,
+ VISU::GetFamily(aMeshOnEntity,theFamilyName));
}
}
+//---------------------------------------------------------------
float
VISU_Convertor_impl
::GetMeshOnEntitySize(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const std::string& theFamilyName)
+{
+ if(theFamilyName == "")
+ return GetMeshOnEntitySize2(theMeshName,theEntity);
+ else
+ return GetFamilyOnEntitySize(theMeshName,theEntity,theFamilyName);
+}
+
+
+//---------------------------------------------------------------
+float
+VISU_Convertor_impl
+::GetMeshOnEntitySize2(const std::string& theMeshName,
+ const VISU::TEntity& theEntity)
{
TFindMeshOnEntity aFindMeshOnEntity =
- FindMeshOnEntity(theMeshName,theEntity,theFamilyName);
+ FindMeshOnEntity(theMeshName,theEntity);
+
PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
- PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity);
PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
- vtkIdType aNbCells, aCellsSize;
-
- if(!aFamily){
- aNbCells = aMeshOnEntity->myNbCells;
- aCellsSize = aMeshOnEntity->myCellsSize;
- }else{
- aNbCells = aFamily->myNbCells;
- aCellsSize = aFamily->myCellsSize;
+ vtkIdType aNbCells = aMeshOnEntity->myNbCells;
+ vtkIdType aCellsSize = aMeshOnEntity->myCellsSize;
+
+ vtkIdType aConnectivitySize = aCellsSize*sizeof(vtkIdType);
+ vtkIdType aTypesSize = aNbCells*sizeof(char);
+ vtkIdType aLocationsSize = aNbCells*sizeof(int);
+ float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
+ vtkIdType aLinksSize = aMesh->myNbPoints *
+ (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
+ aLinksSize = 0;
+ vtkIdType aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
+
+ MSG(MYDEBUG,"GetMeshOnEntitySize2 "<<
+ "- aResult = "<<float(aResult)<<
+ "; theMeshName = '"<<theMeshName<<"'"<<
+ "; theEntity = "<<theEntity);
+ if(MYDEBUG){
+ INITMSG(MYVTKDEBUG,"- aPointsSize = "<<float(aPointsSize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<float(aConnectivitySize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<float(aTypesSize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<float(aLocationsSize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<float(aLinksSize)<<"\n");
}
+ aResult = vtkIdType(aResult*ERR_SIZE_CALC);
+ return aResult;
+}
+
+
+//---------------------------------------------------------------
+float
+VISU_Convertor_impl
+::GetFamilyOnEntitySize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFamilyName)
+{
+ TFindFamilyOnEntity aFindFamilyOnEntity =
+ FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
+ PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);
+ PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
+ PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
+
+ vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
+ vtkIdType aNbCells = aFamily->myNbCells;
+ vtkIdType aCellsSize = aFamily->myCellsSize;
+
vtkIdType aConnectivitySize = aCellsSize*sizeof(vtkIdType);
vtkIdType aTypesSize = aNbCells*sizeof(char);
vtkIdType aLocationsSize = aNbCells*sizeof(int);
(vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
aLinksSize = 0;
vtkIdType aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
+
+ MSG(MYDEBUG,"GetFamilyOnEntitySize "<<
+ "- aResult = "<<float(aResult)<<
+ "; theMeshName = '"<<theMeshName<<"'"<<
+ "; theEntity = "<<theEntity<<
+ "; theFamilyName = '"<<theFamilyName<<"'");
if(MYDEBUG){
- MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aPointsSize = "<<float(aPointsSize));
- MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aConnectivitySize = "<<float(aConnectivitySize));
- MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aTypesSize = "<<float(aTypesSize));
- MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aLocationsSize = "<<float(aLocationsSize));
- MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aLinksSize = "<<float(aLinksSize));
+ INITMSG(MYVTKDEBUG,"- aPointsSize = "<<float(aPointsSize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<float(aConnectivitySize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<float(aTypesSize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<float(aLocationsSize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<float(aLinksSize)<<"\n");
}
- MSG(MYDEBUG,"GetMeshOnEntitySize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<
- "'; theEntity = "<<theEntity<<"; theFamilyName = '"<<theFamilyName<<"'");
aResult = vtkIdType(aResult*ERR_SIZE_CALC);
return aResult;
}
+//---------------------------------------------------------------
VISU_Convertor_impl::TFindMeshOnGroup
VISU_Convertor_impl
::FindMeshOnGroup(const std::string& theMeshName,
const VISU::TEntity& theEntity,
const string& theFieldName)
{
- TFindMeshOnEntity aFindMeshOnEntity = FindMeshOnEntity(theMeshName,theEntity,"");
+ TFindMeshOnEntity aFindMeshOnEntity =
+ FindMeshOnEntity(theMeshName,theEntity);
+
PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
- PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity);
PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;