#ifdef _DEBUG_
static int MYDEBUG = 1;
-static int MYDEBUGWITHFILES = 0;
+static int MYDEBUGWITHFILES = 1;
#else
static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
::TGaussMeshImpl()
{}
- //---------------------------------------------------------------
TGaussPointID
TGaussMeshImpl
::GetObjID(int theVtkI) const
return aRetVID;
}
+
//---------------------------------------------------------------
- pair<int,int>
+ vtkIdType
TMeshOnEntityImpl
- ::GetCellsDims(const string& theFamilyName) const
+ ::GetElemVTKID(vtkIdType theID) const
{
- if(theFamilyName == "")
- return make_pair(myNbCells,myCellsSize);
+ TObj2VTKID::const_iterator anIter = std::find(myObj2VTKID.begin(),
+ myObj2VTKID.end(),
+ theID);
+ if(anIter != myObj2VTKID.end())
+ return *anIter;
+ return -1;
+ }
- TFamilyMap::const_iterator aFamilyMapIter = myFamilyMap.find(theFamilyName);
- if(aFamilyMapIter == myFamilyMap.end())
- throw std::runtime_error("GetCellsDims >> There is no family on the mesh with entity !!!");
+ vtkIdType
+ TMeshOnEntityImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ return myObj2VTKID[theID];
+ }
- PFamilyImpl aFamily = aFamilyMapIter->second;
- return make_pair(aFamily->myNbCells,aFamily->myCellsSize);
+ //---------------------------------------------------------------
+ TNbASizeCells
+ TGroupImpl
+ ::GetNbASizeCells() const
+ {
+ vtkIdType aNbCells = 0, aCellsSize = 0;
+ TFamilySet::const_iterator anIter = myFamilySet.begin();
+ for(; anIter == myFamilySet.end(); anIter++){
+ PFamilyImpl aFamily = *anIter;
+ aNbCells += aFamily->myNbCells;
+ aCellsSize += aFamily->myCellsSize;
+ }
+ return make_pair(aNbCells,aCellsSize);
}
//---------------------------------------------------------------
void
GetCellsOnEntity(const TVTKSource& theSource,
- const PMeshOnEntityImpl& theMeshOnEntity,
- const std::string& theFamilyName = "")
+ const PMeshOnEntityImpl& theMeshOnEntity)
{
- //Check on existing family
- PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName);
- //Main part of code
- pair<int,int> aCellsDim = theMeshOnEntity->GetCellsDims(theFamilyName);
- int aNbCells = aCellsDim.first, aCellsSize = aCellsDim.second;
+ INITMSG(MYDEBUG,"GetCellsOnEntity"<<endl);
+
+ vtkIdType aNbCells = theMeshOnEntity->myNbCells;
+ vtkIdType aCellsSize = theMeshOnEntity->myCellsSize;
+
vtkCellArray* aConnectivity = vtkCellArray::New();
aConnectivity->Allocate(aCellsSize,0);
vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
aCellTypesArray->SetNumberOfComponents(1);
aCellTypesArray->SetNumberOfTuples(aNbCells);
- INITMSG(MYDEBUG,"GetCellsOnEntity - isFamilyPresent = "<<bool(aFamily)<<
- endl);
+
const VISU::TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect;
VISU::TGeom2Cell2Connect::const_iterator aGeom2Cell2ConnectIter = aGeom2Cell2Connect.begin();
- for(int i = 0, j = 0; aGeom2Cell2ConnectIter != aGeom2Cell2Connect.end(); aGeom2Cell2ConnectIter++){
+ for(vtkIdType i = 0, j = 0; aGeom2Cell2ConnectIter != aGeom2Cell2Connect.end(); aGeom2Cell2ConnectIter++){
const VISU::TCell2Connect& anArray = aGeom2Cell2ConnectIter->second;
vtkIdType aGeom = aGeom2Cell2ConnectIter->first;
INITMSG(MYDEBUG,"aGeom = "<<aGeom<<
"; anArray.size() = "<<anArray.size()<<
endl);
- if(!aFamily)
- for(int k = 0, kEnd = anArray.size(); k < kEnd; k++, i++){
- PrintCells(i,aConnectivity,anArray[k]);
- aCellTypesArray->SetValue(j++,(unsigned char)aGeom);
- }
- else{
- const VISU::TGeom2SubMeshID& aGeom2SubMeshID = aFamily->myGeom2SubMeshID;
- if(aGeom2SubMeshID.empty())
- EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!");
-
- VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aGeom);
- if(aGeom2SubMeshIDIter == aGeom2SubMeshID.end())
- continue;
-
- const VISU::TSubMeshID& aSubMeshID = aGeom2SubMeshIDIter->second;
-
- INITMSG(MYDEBUG,"aSubMeshID.size() = "<<aSubMeshID.size()<<
- endl);
-
- VISU::TSubMeshID::const_iterator aSubMeshIDIter = aSubMeshID.begin();
- for(; aSubMeshIDIter != aSubMeshID.end(); aSubMeshIDIter++, i++){
- PrintCells(i,aConnectivity,anArray[*aSubMeshIDIter]);
- aCellTypesArray->SetValue(j++,(unsigned char)aGeom);
- }
+ for(vtkIdType k = 0, kEnd = anArray.size(); k < kEnd; k++, i++){
+ PrintCells(i,aConnectivity,anArray[k]);
+ aCellTypesArray->SetValue(j++,(unsigned char)aGeom);
}
}
vtkIdType *pts = 0, npts = 0;
for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
+
if(MYVTKDEBUG) aConnectivity->DebugOn();
+
aCellLocationsArray->Delete();
aCellTypesArray->Delete();
aConnectivity->Delete();
//---------------------------------------------------------------
void
- GetCellsOnGroup(const TVTKSource& theSource,
- const PMeshImpl& theMesh,
- const TFamilySet& theFamilySet)
+ GetCellsOnFamily(const TVTKSource& theSource,
+ const PMeshOnEntityImpl& theMeshOnEntity,
+ const PFamilyImpl& theFamily)
{
- //Calculate dimentions of the group
- INITMSG(MYDEBUG,"GetCellsOnGroup\n");
- int aNbCells = 0, aCellsSize = 0;
- VISU::TFamilySet::const_iterator aFamilyIter = theFamilySet.begin();
- for(; aFamilyIter != theFamilySet.end(); aFamilyIter++){
- VISU::PFamilyImpl aFamily = *aFamilyIter;
- aCellsSize += aFamily->myCellsSize;
- aNbCells += aFamily->myNbCells;
- }
+ INITMSG(MYDEBUG,"GetCellsOnFamily"<<endl);
+
+ vtkIdType aNbCells = theFamily->myNbCells;
+ vtkIdType aCellsSize = theFamily->myCellsSize;
+
vtkCellArray* aConnectivity = vtkCellArray::New();
aConnectivity->Allocate(aCellsSize,0);
vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
aCellTypesArray->SetNumberOfComponents(1);
aCellTypesArray->SetNumberOfTuples(aNbCells);
- aFamilyIter = theFamilySet.begin();
- for(int i = 0, j = 0; aFamilyIter != theFamilySet.end(); aFamilyIter++){
- VISU::PFamilyImpl aFamily = *aFamilyIter;
- const std::string& aFamilyName = aFamily->myName;
- const VISU::TEntity& anEntity = aFamily->myEntity;
- PMeshOnEntityImpl aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
- const VISU::TGeom2Cell2Connect &aGeom2Cell2Connect = aMeshOnEntity->myGeom2Cell2Connect;
- VISU::TGeom2Cell2Connect::const_iterator aGeom2Cell2ConnectIter = aGeom2Cell2Connect.begin();
- for(; aGeom2Cell2ConnectIter != aGeom2Cell2Connect.end(); aGeom2Cell2ConnectIter++){
- const VISU::TCell2Connect& anArray = aGeom2Cell2ConnectIter->second;
- vtkIdType aGeom = aGeom2Cell2ConnectIter->first;
- INITMSG(MYDEBUG,"aGeom = "<<aGeom<<"; anArray.size() = "<<anArray.size()<<"\n");
-
- const VISU::TGeom2SubMeshID& aGeom2SubMeshID = aFamily->myGeom2SubMeshID;
- if(aGeom2SubMeshID.empty())
- EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!");
-
- VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aGeom);
- if(aGeom2SubMeshIDIter != aGeom2SubMeshID.end()){
- const VISU::TSubMeshID& aSubMeshID = aGeom2SubMeshIDIter->second;
- INITMSG(MYDEBUG,"aSubMeshID.size() = "<<aSubMeshID.size()<<"\n");
- VISU::TSubMeshID::const_iterator aSubMeshIDIter = aSubMeshID.begin();
- for(; aSubMeshIDIter != aSubMeshID.end(); aSubMeshIDIter++, i++){
- PrintCells(i,aConnectivity,anArray[*aSubMeshIDIter]);
- aCellTypesArray->SetValue(j++,(unsigned char)aGeom);
- }
- }
+
+ const VISU::TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect;
+ VISU::TGeom2Cell2Connect::const_iterator aGeom2Cell2ConnectIter = aGeom2Cell2Connect.begin();
+ for(vtkIdType i = 0, j = 0; aGeom2Cell2ConnectIter != aGeom2Cell2Connect.end(); aGeom2Cell2ConnectIter++){
+ const VISU::TCell2Connect& anArray = aGeom2Cell2ConnectIter->second;
+ vtkIdType aGeom = aGeom2Cell2ConnectIter->first;
+ const VISU::TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
+ if(aGeom2SubMeshID.empty())
+ EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!");
+
+ VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aGeom);
+ if(aGeom2SubMeshIDIter == aGeom2SubMeshID.end())
+ continue;
+
+ const VISU::TSubMeshID& aSubMeshID = aGeom2SubMeshIDIter->second;
+
+ INITMSG(MYDEBUG,"aGeom = "<<aGeom<<
+ "; aSubMeshID.size() = "<<aSubMeshID.size()<<
+ endl);
+
+ VISU::TSubMeshID::const_iterator aSubMeshIDIter = aSubMeshID.begin();
+ for(; aSubMeshIDIter != aSubMeshID.end(); aSubMeshIDIter++, i++){
+ PrintCells(i,aConnectivity,anArray[*aSubMeshIDIter]);
+ aCellTypesArray->SetValue(j++,(unsigned char)aGeom);
}
}
vtkIdType *pts = 0, npts = 0;
aCellLocationsArray->SetNumberOfComponents(1);
aCellLocationsArray->SetNumberOfTuples(aNbCells);
aConnectivity->InitTraversal();
- for(int i = 0; aConnectivity->GetNextCell(npts,pts); i++)
+ for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
+
+ if(MYVTKDEBUG) aConnectivity->DebugOn();
+
aCellLocationsArray->Delete();
aCellTypesArray->Delete();
aConnectivity->Delete();
- }
+ }
//---------------------------------------------------------------
if(MYDEBUGWITHFILES){
std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
- std::string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
+ std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-Conv.vtk";
VISU::WriteToFile(aSource.GetPointer(),aFileName);
}
if(!aFamily->myIsVTKDone){
if(MYVTKDEBUG) aSource->DebugOn();
+ GetMeshOnEntity(theMeshName,theEntity);
+
LoadFamilyOnEntity(aMesh,aMeshOnEntity,aFamily);
GetPoints(aSource,aMesh);
- GetCellsOnEntity(aSource,aMeshOnEntity,theFamilyName);
+ GetCellsOnFamily(aSource,aMeshOnEntity,aFamily);
aFamily->myIsVTKDone = true;
if(MYDEBUGWITHFILES){
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")+"-";
+ std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-Conv.vtk";
VISU::WriteToFile(aSource.GetPointer(),aFileName);
}
if(MYDEBUGWITHFILES){
std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
std::string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1();
- std::string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
+ std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
aFileName += aMeshName + "-" + aGroupName + "-Conv.vtk";
VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
}
if(MYDEBUGWITHFILES){
string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1();
- string aPrefix = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
+ string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-";
string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk";
VISU::WriteToFile(aSource.GetPointer(),aFileName);
if(MYDEBUGWITHFILES){
string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1();
- string aPrefix = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
+ string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-";
string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk";
VISU::WriteToFile(aSource.GetPointer(),aFileName);
PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
- vtkIdType aNbCells = aGroup->myNbCells, aCellsSize = aGroup->myCellsSize;
+ TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells();
+ vtkIdType aNbCells = aNbASizeCells.first;
+ vtkIdType aCellsSize = aNbASizeCells.second;
vtkIdType aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
vtkIdType aLocationsSize = aNbCells*sizeof(int);
float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
"- aFamilyName = '"<<aFamilyName<<"'"<<
"; aVEntity = "<<aVEntity<<
"\n");
-
- aGroup->myNbCells += aFamily->myNbCells;
- aGroup->myCellsSize += aFamily->myCellsSize;
}
}
- if(!aFamilySet.empty() && aGroup->myNbCells > 0){
- BEGMSG(MY_GROUP_DEBUG,
- "- myNbCells = "<<aGroup->myNbCells<<
- "; myCellsSize = "<<aGroup->myCellsSize<<
- "\n");
+ if(!aFamilySet.empty())
aGroupMap.insert(VISU::TGroupMap::value_type(aGroupName,aGroup));
- }
}
}
}
}}
}
+
theMeshOnEntity->myIsDone = true;
return 1;
TInt anId = theFamily->myId;
const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo;
+ TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
+
const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size;
MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin();
TGeom2Cell2Connect& aGeom2Cell2Connect = theMeshOnEntity->myGeom2Cell2Connect;
-
for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){
const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first;
- int aVGeom = MEDGeomToVTK(aMGeom);
- INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"\n");
+ MED::PElemInfo anElemInfo;
switch(aMGeom){
case MED::ePOLYGONE: {
- MED::PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
- TInt aNbElem = aPolygoneInfo->GetNbElem();
-
- TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aVGeom];
- for(int iElem = 0; iElem < aNbElem; iElem++)
- if(aPolygoneInfo->GetFamNum(iElem) == anId)
- aSubMeshID.push_back(iElem);
-
+ anElemInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom);
break;
}
case MED::ePOLYEDRE: {
- MED::PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
- TInt aNbElem = aPolyedreInfo->GetNbElem();
-
- TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aVGeom];
- for(int iElem = 0; iElem < aNbElem; iElem++)
- if(aPolyedreInfo->GetFamNum(iElem) == anId)
- aSubMeshID.push_back(iElem);
-
+ anElemInfo = theMed->GetPPolyedreInfo(aMeshInfo,aMEntity,aMGeom);
break;
}
default: {
- int aVNbNodes = VTKGeom2NbNodes(aVGeom);
-
- MED::PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
- TInt aNbElem = aCellInfo->GetNbElem();
-
- TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[aVGeom];
- for(int iElem = 0; iElem < aNbElem; iElem++)
- if(aCellInfo->GetFamNum(iElem) == anId)
- aSubMeshID.push_back(iElem);
+ anElemInfo = theMed->GetPCellInfo(aMeshInfo,aMEntity,aMGeom);
+ break;
}}
+ if(anElemInfo){
+ if(TInt aNbElem = anElemInfo->GetNbElem()){
+ TSubMeshID aSubMeshID;
+ for(TInt iElem = 0; iElem < aNbElem; iElem++)
+ if(anElemInfo->GetFamNum(iElem) == anId)
+ aSubMeshID.push_back(iElem);
+ if(!aSubMeshID.empty()){
+ TInt aVGeom = MEDGeomToVTK(aMGeom);
+ INITMSG(MYDEBUG,"aMGeom = "<<aMGeom<<"\n");
+ aGeom2SubMeshID.insert(TGeom2SubMeshID::value_type(aVGeom,aSubMeshID));
+ }
+ }
+ }
}
theFamily->myIsDone = true;