-// Copyright (C) 2010-2011 CEA/DEN, EDF R&D
+// Copyright (C) 2010-2013 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include "vtkMultiProcessController.h"
#include <string>
+#include <vector>
+#include <algorithm>
using namespace std;
// vtkCxxRevisionMacro(vtkMedDriver30, "$Revision$")
}
this->ReadNumberOfEntity(grid, MED_CELL, MED_NODAL);
- this->ReadNumberOfEntity(grid, MED_CELL, MED_DESCENDING);
+ //this->ReadNumberOfEntity(grid, MED_CELL, MED_DESCENDING); // VSR: 29.11.2013: commented according to the issue 22327: descending connectivity is wrongly processed
this->ReadNumberOfEntity(grid, MED_DESCENDING_FACE, MED_NODAL);
this->ReadNumberOfEntity(grid, MED_DESCENDING_FACE, MED_DESCENDING);
this->ReadNumberOfEntity(grid, MED_DESCENDING_EDGE, MED_NODAL);
family->SetId(familyid);
- if(familyid <= 0)
- {
- family->SetPointOrCell(vtkMedUtilities::OnCell);
- mesh->AppendCellFamily(family);
- }
- else
- {
- family->SetPointOrCell(vtkMedUtilities::OnPoint);
- mesh->AppendPointFamily(family);
+ // Fix for the issue "0021721: [CEA 590] Invalid groups on cells
+ if( familyid == 0 ) {
+ family->SetPointOrCell( vtkMedUtilities::OnCell );
+ mesh->AppendCellFamily( family );
+ } else {
+ //rnv: improve algorithm to determine entity of the family:
+ // 1) Read Nb nodes
+ // 2) Read families of the nodes
+ // 3) If list of the families of the nodes contains familyid => vtkMedUtilities::OnPoint
+ // otherwise => vtkMedUtilities::OnCell
+ med_bool v1, v2;
+ med_int size = MEDmeshnEntity(
+ this->FileId,
+ meshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_NODE,
+ MED_NO_GEOTYPE,
+ MED_COORDINATE,
+ MED_NO_CMODE,
+ &v1,
+ &v2 );
+ if( size < 0 ) {
+ vtkErrorMacro( "vtkMedDriver30::ReadInformation(vtkMedFamily* family)"
+ <<" cannot read nb Nodes" );
+ return;
}
-
+
+ vector<med_int> n_fams;
+ n_fams.resize( size );
+
+ med_int ret_val = MEDmeshEntityFamilyNumberRd( this->FileId,
+ meshName,
+ MED_NO_DT,
+ MED_NO_IT,
+ MED_NODE,
+ MED_NO_GEOTYPE ,
+ &n_fams[0] );
+ // Remove ZERO FAMILY
+ remove( n_fams.begin(),n_fams.end(), 0 );
+
+ bool isOnPoints = ( ret_val >= 0) && (find( n_fams.begin(), n_fams.end(), familyid ) != n_fams.end() );
+ if( isOnPoints ) {
+ family->SetPointOrCell(vtkMedUtilities::OnPoint);
+ mesh->AppendPointFamily(family);
+ } else {
+ family->SetPointOrCell(vtkMedUtilities::OnCell);
+ mesh->AppendCellFamily(family);
+ }
+ }
+
family->AllocateNumberOfGroup(ngroup);
// if there where no group, set the name to the default value
if(has_no_group)
if(mesh == NULL)
return;
+ //rnv begin: fix the "22335: [CEA 954] Paravis 7.2.0 doesn't read ELNO fields" regression.
+ // this piece of code needed for the reading ELNO fields
+ std::set<vtkMedEntity> tmp_entities;
std::set<vtkMedEntity> entities;
- mesh->GatherMedEntities(entities);
+ mesh->GatherMedEntities(tmp_entities);
- vtkMedEntity pointEntity;
- pointEntity.EntityType = MED_NODE;
- pointEntity.GeometryType = MED_NONE;
- pointEntity.GeometryName = MED_NAME_BLANK;
- entities.insert(pointEntity);
+ std::set<vtkMedEntity>::iterator tmp_entity_it = tmp_entities.begin();
+ while(tmp_entity_it != tmp_entities.end())
+ {
+ vtkMedEntity entity = *tmp_entity_it;
+ tmp_entity_it++;
+ entities.insert(entity);
+ if(entity.EntityType == MED_CELL)
+ {
+ vtkMedEntity newEntity;
+ newEntity.EntityType = MED_NODE_ELEMENT;
+ newEntity.GeometryType = entity.GeometryType;
+ newEntity.GeometryName = entity.GeometryName;
+ entities.insert(newEntity);
+ }
+ }
+ //rnv end
std::set<vtkMedEntity>::iterator entity_it = entities.begin();
while(entity_it != entities.end())