Skip to content
Snippets Groups Projects
Commit af1d52cb authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

med polish for nico

- names for elementary entities ("families")
- stats for model-based views
- deal with mmed/rmed
parent f9f3183e
No related branches found
No related tags found
No related merge requests found
// $Id: Visibility.cpp,v 1.32 2008-03-20 11:44:02 geuzaine Exp $ // $Id: Visibility.cpp,v 1.33 2008-04-16 22:10:52 geuzaine Exp $
// //
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -48,7 +48,8 @@ class VisLessThan{ ...@@ -48,7 +48,8 @@ class VisLessThan{
} }
}; };
static void setLabels(void *a, void *b){ static void setLabels(void *a, void *b)
{
Symbol *s = (Symbol *)a; Symbol *s = (Symbol *)a;
for(int j = 0; j < List_Nbr(s->val); j++) { for(int j = 0; j < List_Nbr(s->val); j++) {
double tag; double tag;
...@@ -60,26 +61,18 @@ static void setLabels(void *a, void *b){ ...@@ -60,26 +61,18 @@ static void setLabels(void *a, void *b){
void VisibilityManager::update(int type) void VisibilityManager::update(int type)
{ {
_labels.clear(); _labels.clear();
// get old labels from parser
if(Tree_Nbr(Symbol_T)) Tree_Action(Symbol_T, setLabels);
GModel *m = GModel::current();
// add new labels for physicals
if(type == 1){
GModel::piter it = m->firstPhysicalName();
while(it != m->lastPhysicalName()){
setLabel(it->first, it->second);
++it;
}
}
for(unsigned int i = 0; i < _entities.size(); i++) for(unsigned int i = 0; i < _entities.size(); i++)
delete _entities[i]; delete _entities[i];
_entities.clear(); _entities.clear();
GModel *m = GModel::current();
// get old labels from parser
if(Tree_Nbr(Symbol_T)) Tree_Action(Symbol_T, setLabels);
if(type == 0){ // elementary entities if(type == 0){ // elementary entities
for(GModel::piter it = m->firstElementaryName(); it != m->lastElementaryName(); ++it)
setLabel(it->first, it->second);
for(GModel::viter it = m->firstVertex(); it != m->lastVertex(); it++) for(GModel::viter it = m->firstVertex(); it != m->lastVertex(); it++)
_entities.push_back(new VisElementary(*it)); _entities.push_back(new VisElementary(*it));
for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); it++) for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); it++)
...@@ -90,6 +83,8 @@ void VisibilityManager::update(int type) ...@@ -90,6 +83,8 @@ void VisibilityManager::update(int type)
_entities.push_back(new VisElementary(*it)); _entities.push_back(new VisElementary(*it));
} }
else if(type == 1){ // physical entities else if(type == 1){ // physical entities
for(GModel::piter it = m->firstPhysicalName(); it != m->lastPhysicalName(); ++it)
setLabel(it->first, it->second);
std::map<int, std::vector<GEntity*> > groups[4]; std::map<int, std::vector<GEntity*> > groups[4];
m->getPhysicalGroups(groups); m->getPhysicalGroups(groups);
for(int i = 0; i < 4; i++){ for(int i = 0; i < 4; i++){
......
...@@ -71,7 +71,7 @@ class GModel ...@@ -71,7 +71,7 @@ class GModel
std::set<GEdge*, GEntityLessThan> edges; std::set<GEdge*, GEntityLessThan> edges;
std::set<GVertex*, GEntityLessThan> vertices; std::set<GVertex*, GEntityLessThan> vertices;
std::set<int> meshPartitions; std::set<int> meshPartitions;
std::map<int, std::string> physicalNames; std::map<int, std::string> physicalNames, elementaryNames;
public: public:
GModel(std::string name=""); GModel(std::string name="");
...@@ -154,9 +154,11 @@ class GModel ...@@ -154,9 +154,11 @@ class GModel
// Returns the highest number associated with a physical entity // Returns the highest number associated with a physical entity
int getMaxPhysicalNumber(); int getMaxPhysicalNumber();
// Get an iterator on the physical name // Get an iterator on the elementary/physical names
piter firstPhysicalName() { return physicalNames.begin(); } piter firstPhysicalName() { return physicalNames.begin(); }
piter lastPhysicalName() { return physicalNames.end(); } piter lastPhysicalName() { return physicalNames.end(); }
piter firstElementaryName() { return elementaryNames.begin(); }
piter lastElementaryName() { return elementaryNames.end(); }
// Get the number of physical names // Get the number of physical names
int numPhysicalNames(){ return physicalNames.size(); } int numPhysicalNames(){ return physicalNames.size(); }
......
// $Id: GModelIO_MED.cpp,v 1.31 2008-04-16 12:31:37 geuzaine Exp $ // $Id: GModelIO_MED.cpp,v 1.32 2008-04-16 22:10:53 geuzaine Exp $
// //
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
// //
...@@ -315,19 +315,20 @@ int GModel::readMED(const std::string &name, int meshIndex) ...@@ -315,19 +315,20 @@ int GModel::readMED(const std::string &name, int meshIndex)
Msg(GERROR, "Could not read MED groups or attributes"); Msg(GERROR, "Could not read MED groups or attributes");
return 0; return 0;
} }
if(numGroups > 0){ // get physicals std::vector<med_int> attribId(numAttrib + 1);
std::vector<med_int> attribId(numAttrib + 1); std::vector<med_int> attribVal(numAttrib + 1);
std::vector<med_int> attribVal(numAttrib + 1); std::vector<char> attribDes(MED_TAILLE_DESC * numAttrib + 1);
std::vector<char> attribDes(MED_TAILLE_DESC * numAttrib + 1); std::vector<char> groupNames(MED_TAILLE_LNOM * numGroups + 1);
std::vector<char> groupNames(MED_TAILLE_LNOM * numGroups + 1); char familyName[MED_TAILLE_NOM + 1];
char familyName[MED_TAILLE_NOM + 1]; med_int familyNum;
med_int familyNum; if(MEDfamInfo(fid, meshName, i + 1, familyName, &familyNum, &attribId[0],
if(MEDfamInfo(fid, meshName, i + 1, familyName, &familyNum, &attribId[0], &attribVal[0], &attribDes[0], &numAttrib, &groupNames[0],
&attribVal[0], &attribDes[0], &numAttrib, &groupNames[0], &numGroups) < 0) {
&numGroups) < 0) { Msg(GERROR, "Could not read info for MED family %d", i + 1);
Msg(GERROR, "Could not read info for MED family %d", i + 1); }
} else{
else{ elementaryNames[-familyNum] = familyName;
if(numGroups > 0){
GEntity *ge; // family tags are unique (for all dimensions) GEntity *ge; // family tags are unique (for all dimensions)
if((ge = getRegionByTag(-familyNum))){} if((ge = getRegionByTag(-familyNum))){}
else if((ge = getFaceByTag(-familyNum))){} else if((ge = getFaceByTag(-familyNum))){}
......
// $Id: OpenFile.cpp,v 1.183 2008-04-07 12:13:16 geuzaine Exp $ // $Id: OpenFile.cpp,v 1.184 2008-04-16 22:10:53 geuzaine Exp $
// //
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -359,7 +359,9 @@ int MergeFile(const char *name, int warn_if_missing) ...@@ -359,7 +359,9 @@ int MergeFile(const char *name, int warn_if_missing)
else if(!strcmp(ext, ".mesh") || !strcmp(ext, ".MESH")){ else if(!strcmp(ext, ".mesh") || !strcmp(ext, ".MESH")){
status = m->readMESH(name); status = m->readMESH(name);
} }
else if(!strcmp(ext, ".med") || !strcmp(ext, ".MED")){ else if(!strcmp(ext, ".med") || !strcmp(ext, ".MED") ||
!strcmp(ext, ".mmed") || !strcmp(ext, ".MMED") ||
!strcmp(ext, ".rmed") || !strcmp(ext, ".RMED")){
status = GModel::readMED(name); status = GModel::readMED(name);
if(status > 1) status = PView::readMED(name); if(status > 1) status = PView::readMED(name);
} }
......
// $Id: PViewDataGModel.cpp,v 1.49 2008-04-06 09:20:17 geuzaine Exp $ // $Id: PViewDataGModel.cpp,v 1.50 2008-04-16 22:10:53 geuzaine Exp $
// //
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -99,6 +99,7 @@ SBoundingBox3d PViewDataGModel::getBoundingBox(int step) ...@@ -99,6 +99,7 @@ SBoundingBox3d PViewDataGModel::getBoundingBox(int step)
int PViewDataGModel::getNumScalars(int step) int PViewDataGModel::getNumScalars(int step)
{ {
if(_steps.empty()) return 0; if(_steps.empty()) return 0;
// to generalize
if(_steps[0]->getNumComponents() == 1) return getNumElements(0); if(_steps[0]->getNumComponents() == 1) return getNumElements(0);
return 0; return 0;
} }
...@@ -106,6 +107,7 @@ int PViewDataGModel::getNumScalars(int step) ...@@ -106,6 +107,7 @@ int PViewDataGModel::getNumScalars(int step)
int PViewDataGModel::getNumVectors(int step) int PViewDataGModel::getNumVectors(int step)
{ {
if(_steps.empty()) return 0; if(_steps.empty()) return 0;
// to generalize
if(_steps[0]->getNumComponents() == 3) return getNumElements(0); if(_steps[0]->getNumComponents() == 3) return getNumElements(0);
return 0; return 0;
} }
...@@ -113,33 +115,95 @@ int PViewDataGModel::getNumVectors(int step) ...@@ -113,33 +115,95 @@ int PViewDataGModel::getNumVectors(int step)
int PViewDataGModel::getNumTensors(int step) int PViewDataGModel::getNumTensors(int step)
{ {
if(_steps.empty()) return 0; if(_steps.empty()) return 0;
// to generalize
if(_steps[0]->getNumComponents() == 9) return getNumElements(0); if(_steps[0]->getNumComponents() == 9) return getNumElements(0);
return 0; return 0;
} }
int PViewDataGModel::getNumLines(int step)
{
if(_steps.empty()) return 0;
GModel *m = _steps[0]->getModel(); // to generalize
int n = 0;
for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); ++it)
n += (*it)->lines.size();
return n;
}
int PViewDataGModel::getNumTriangles(int step)
{
if(_steps.empty()) return 0;
GModel *m = _steps[0]->getModel(); // to generalize
int n = 0;
for(GModel::fiter it = m->firstFace(); it != m->lastFace(); ++it)
n += (*it)->triangles.size();
return n;
}
int PViewDataGModel::getNumQuadrangles(int step)
{
if(_steps.empty()) return 0;
GModel *m = _steps[0]->getModel(); // to generalize
int n = 0;
for(GModel::fiter it = m->firstFace(); it != m->lastFace(); ++it)
n += (*it)->quadrangles.size();
return n;
}
int PViewDataGModel::getNumTetrahedra(int step)
{
if(_steps.empty()) return 0;
GModel *m = _steps[0]->getModel(); // to generalize
int n = 0;
for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); ++it)
n += (*it)->tetrahedra.size();
return n;
}
int PViewDataGModel::getNumHexahedra(int step)
{
if(_steps.empty()) return 0;
GModel *m = _steps[0]->getModel(); // to generalize
int n = 0;
for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); ++it)
n += (*it)->hexahedra.size();
return n;
}
int PViewDataGModel::getNumPrisms(int step)
{
if(_steps.empty()) return 0;
GModel *m = _steps[0]->getModel(); // to generalize
int n = 0;
for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); ++it)
n += (*it)->prisms.size();
return n;
}
int PViewDataGModel::getNumPyramids(int step)
{
if(_steps.empty()) return 0;
GModel *m = _steps[0]->getModel(); // to generalize
int n = 0;
for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); ++it)
n += (*it)->pyramids.size();
return n;
}
int PViewDataGModel::getNumEntities(int step) int PViewDataGModel::getNumEntities(int step)
{ {
if(step < 0 || _steps.empty()){ if(_steps.empty()) return 0;
int num = 0; // to generalize
for(unsigned int i = 0; i < _steps.size(); i++) if(step < 0) return _steps[0]->getNumEntities();
num += _steps[i]->getNumEntities();
return num;
}
return _steps[step]->getNumEntities(); return _steps[step]->getNumEntities();
} }
int PViewDataGModel::getNumElements(int step, int ent) int PViewDataGModel::getNumElements(int step, int ent)
{ {
if(step < 0 || _steps.empty()){ if(_steps.empty()) return 0;
int num = 0; // to generalize
for(unsigned int i = 0; i < _steps.size(); i++){ if(step < 0 && ent < 0) return _steps[0]->getModel()->getNumMeshElements();
if(ent < 0) if(step < 0) return _steps[0]->getEntity(ent)->getNumMeshElements();
num += _steps[i]->getModel()->getNumMeshElements();
else
num += _steps[i]->getEntity(ent)->getNumMeshElements();
}
return num;
}
if(ent < 0) return _steps[step]->getModel()->getNumMeshElements(); if(ent < 0) return _steps[step]->getModel()->getNumMeshElements();
return _steps[step]->getEntity(ent)->getNumMeshElements(); return _steps[step]->getEntity(ent)->getNumMeshElements();
} }
......
...@@ -154,6 +154,14 @@ class PViewDataGModel : public PViewData { ...@@ -154,6 +154,14 @@ class PViewDataGModel : public PViewData {
int getNumScalars(int step=-1); int getNumScalars(int step=-1);
int getNumVectors(int step=-1); int getNumVectors(int step=-1);
int getNumTensors(int step=-1); int getNumTensors(int step=-1);
int getNumPoints(int step=-1){ return 0; }
int getNumLines(int step=-1);
int getNumTriangles(int step=-1);
int getNumQuadrangles(int step=-1);
int getNumTetrahedra(int step=-1);
int getNumHexahedra(int step=-1);
int getNumPrisms(int step=-1);
int getNumPyramids(int step=-1);
int getNumEntities(int step=-1); int getNumEntities(int step=-1);
int getNumElements(int step=-1, int ent=-1); int getNumElements(int step=-1, int ent=-1);
int getDimension(int step, int ent, int ele); int getDimension(int step, int ent, int ele);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment