Update to match the changes in SMDS

This commit is contained in:
jrt 2003-09-04 12:03:27 +00:00
parent 49b22b1c40
commit 8d2ecd75b0
30 changed files with 3371 additions and 2941 deletions

View File

@ -29,35 +29,43 @@ using namespace std;
#include "utilities.h" #include "utilities.h"
DriverDAT_R_SMDS_Mesh::DriverDAT_R_SMDS_Mesh() { DriverDAT_R_SMDS_Mesh::DriverDAT_R_SMDS_Mesh()
{
; ;
} }
DriverDAT_R_SMDS_Mesh::~DriverDAT_R_SMDS_Mesh() { DriverDAT_R_SMDS_Mesh::~DriverDAT_R_SMDS_Mesh()
{
; ;
} }
void DriverDAT_R_SMDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) { void DriverDAT_R_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
{
myMesh = aMesh; myMesh = aMesh;
} }
void DriverDAT_R_SMDS_Mesh::SetFile(string aFile) { void DriverDAT_R_SMDS_Mesh::SetFile(string aFile)
{
myFile = aFile; myFile = aFile;
} }
void DriverDAT_R_SMDS_Mesh::SetFileId(FILE* aFileId) { void DriverDAT_R_SMDS_Mesh::SetFileId(FILE * aFileId)
{
myFileId = aFileId; myFileId = aFileId;
} }
void DriverDAT_R_SMDS_Mesh::SetMeshId(int aMeshId) { void DriverDAT_R_SMDS_Mesh::SetMeshId(int aMeshId)
{
myMeshId = aMeshId; myMeshId = aMeshId;
} }
void DriverDAT_R_SMDS_Mesh::Add() { void DriverDAT_R_SMDS_Mesh::Add()
{
; ;
} }
void DriverDAT_R_SMDS_Mesh::Read() { void DriverDAT_R_SMDS_Mesh::Read()
{
int i, j; int i, j;
int nbNodes, nbCells; int nbNodes, nbCells;
@ -94,8 +102,10 @@ void DriverDAT_R_SMDS_Mesh::Read() {
fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n"); fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
fprintf(stdout, "(************************)\n"); fprintf(stdout, "(************************)\n");
for (i=0;i<nbNodes;i++) { for (i = 0; i < nbNodes; i++)
fscanf(myFileId,"%d %e %e %e\n",&intNumPoint,&coordX,&coordY,&coordZ); {
fscanf(myFileId, "%d %e %e %e\n", &intNumPoint, &coordX, &coordY,
&coordZ);
ok = myMesh->AddNodeWithID(coordX, coordY, coordZ, intNumPoint); ok = myMesh->AddNodeWithID(coordX, coordY, coordZ, intNumPoint);
} }
@ -109,25 +119,29 @@ void DriverDAT_R_SMDS_Mesh::Read() {
fprintf(stdout, "%d elements\n", nbCells); fprintf(stdout, "%d elements\n", nbCells);
for (i=0; i<nbCells; i++) { for (i = 0; i < nbCells; i++)
{
fscanf(myFileId, "%d %d", &intNumMaille, &ValElement); fscanf(myFileId, "%d %d", &intNumMaille, &ValElement);
Degre = abs(ValElement / 100); Degre = abs(ValElement / 100);
nbNoeuds = ValElement - (Degre * 100); nbNoeuds = ValElement - (Degre * 100);
// Recuperation des noeuds de la maille // Recuperation des noeuds de la maille
for (j=0; j<nbNoeuds; j++) { for (j = 0; j < nbNoeuds; j++)
{
fscanf(myFileId, "%d", &NoeudMaille); fscanf(myFileId, "%d", &NoeudMaille);
NoeudsMaille[j] = NoeudMaille; NoeudsMaille[j] = NoeudMaille;
} }
// Analyse des cas de cellules // Analyse des cas de cellules
switch (ValElement) { switch (ValElement)
{
case 102:; case 102:;
case 103:; case 103:;
{ {
ValDegre = 3; ValDegre = 3;
nbNoeuds = 2; nbNoeuds = 2;
ok = myMesh->AddEdgeWithID(NoeudsMaille[0],NoeudsMaille[1],intNumMaille); ok = myMesh->AddEdgeWithID(NoeudsMaille[0], NoeudsMaille[1],
intNumMaille);
break; break;
} }
case 204:; case 204:;
@ -135,7 +149,8 @@ void DriverDAT_R_SMDS_Mesh::Read() {
{ {
ValDegre = 9; ValDegre = 9;
nbNoeuds = 4; nbNoeuds = 4;
ok = myMesh->AddFaceWithID(NoeudsMaille[0],NoeudsMaille[1],NoeudsMaille[2],NoeudsMaille[3],intNumMaille); ok = myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1],
NoeudsMaille[2], NoeudsMaille[3], intNumMaille);
break; break;
} }
case 203:; case 203:;
@ -143,7 +158,8 @@ void DriverDAT_R_SMDS_Mesh::Read() {
{ {
ValDegre = 5; ValDegre = 5;
nbNoeuds = 3; nbNoeuds = 3;
ok = myMesh->AddFaceWithID(NoeudsMaille[0],NoeudsMaille[1],NoeudsMaille[2],intNumMaille); ok = myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1],
NoeudsMaille[2], intNumMaille);
break; break;
} }
case 308:; case 308:;
@ -151,14 +167,18 @@ void DriverDAT_R_SMDS_Mesh::Read() {
{ {
ValDegre = 12; ValDegre = 12;
nbNoeuds = 8; nbNoeuds = 8;
if (ValElement==320) { if (ValElement == 320)
{
//A voir, correspondance VTK //A voir, correspondance VTK
NoeudsMaille[4] = NoeudsMaille[8]; NoeudsMaille[4] = NoeudsMaille[8];
NoeudsMaille[5] = NoeudsMaille[9]; NoeudsMaille[5] = NoeudsMaille[9];
NoeudsMaille[6] = NoeudsMaille[10]; NoeudsMaille[6] = NoeudsMaille[10];
NoeudsMaille[7] = NoeudsMaille[11]; NoeudsMaille[7] = NoeudsMaille[11];
} }
ok = myMesh->AddVolumeWithID(NoeudsMaille[0],NoeudsMaille[1],NoeudsMaille[2],NoeudsMaille[3],NoeudsMaille[4],NoeudsMaille[5],NoeudsMaille[6],NoeudsMaille[7],intNumMaille); ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
NoeudsMaille[2], NoeudsMaille[3], NoeudsMaille[4],
NoeudsMaille[5], NoeudsMaille[6], NoeudsMaille[7],
intNumMaille);
break; break;
} }
case 304:; case 304:;
@ -168,7 +188,8 @@ void DriverDAT_R_SMDS_Mesh::Read() {
nbNoeuds = 4; nbNoeuds = 4;
if (ValElement == 310) if (ValElement == 310)
NoeudsMaille[3] = NoeudsMaille[6]; NoeudsMaille[3] = NoeudsMaille[6];
ok = myMesh->AddVolumeWithID(NoeudsMaille[0],NoeudsMaille[1],NoeudsMaille[2],NoeudsMaille[3],intNumMaille); ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
NoeudsMaille[2], NoeudsMaille[3], intNumMaille);
break; break;
} }
case 306:; case 306:;
@ -176,7 +197,8 @@ void DriverDAT_R_SMDS_Mesh::Read() {
{ {
ValDegre = 12; ValDegre = 12;
nbNoeuds = 8; nbNoeuds = 8;
if (ValElement==315) { if (ValElement == 315)
{
NoeudsMaille[3] = NoeudsMaille[6]; NoeudsMaille[3] = NoeudsMaille[6];
NoeudsMaille[4] = NoeudsMaille[7]; NoeudsMaille[4] = NoeudsMaille[7];
NoeudsMaille[5] = NoeudsMaille[8]; NoeudsMaille[5] = NoeudsMaille[8];
@ -186,7 +208,9 @@ void DriverDAT_R_SMDS_Mesh::Read() {
NoeudsMaille[5] = NoeudsMaille[4]; NoeudsMaille[5] = NoeudsMaille[4];
NoeudsMaille[4] = NoeudsMaille[3]; NoeudsMaille[4] = NoeudsMaille[3];
NoeudsMaille[3] = NoeudsMaille[2]; NoeudsMaille[3] = NoeudsMaille[2];
ok = myMesh->AddVolumeWithID(NoeudsMaille[0],NoeudsMaille[1],NoeudsMaille[2],NoeudsMaille[3],NoeudsMaille[4],NoeudsMaille[5],intNumMaille); ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1],
NoeudsMaille[2], NoeudsMaille[3], NoeudsMaille[4],
NoeudsMaille[5], intNumMaille);
break; break;
} }

View File

@ -32,22 +32,21 @@
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "Mesh_Reader.h" #include "Mesh_Reader.h"
class DriverDAT_R_SMDS_Mesh : public Mesh_Reader { class DriverDAT_R_SMDS_Mesh:public Mesh_Reader
{
public : public:DriverDAT_R_SMDS_Mesh();
DriverDAT_R_SMDS_Mesh();
~DriverDAT_R_SMDS_Mesh(); ~DriverDAT_R_SMDS_Mesh();
void Add(); void Add();
void Read(); void Read();
void SetMesh(Handle(SMDS_Mesh)& aMesh); void SetMesh(SMDS_Mesh * aMesh);
void SetFile(string); void SetFile(string);
void SetFileId(FILE *); void SetFileId(FILE *);
void SetMeshId(int); void SetMeshId(int);
private : private: SMDS_Mesh * myMesh;
Handle_SMDS_Mesh myMesh;
string myFile; string myFile;
FILE *myFileId; FILE *myFileId;
int myMeshId; int myMeshId;

View File

@ -30,24 +30,29 @@ using namespace std;
#include "utilities.h" #include "utilities.h"
int getOne() { int getOne()
{
printf("in getOne"); printf("in getOne");
return (1); return (1);
} }
extern "C" { extern "C"
{
// Document_Reader* maker() { // Document_Reader* maker() {
DriverDAT_R_SMESHDS_Document* maker() { DriverDAT_R_SMESHDS_Document *maker()
{
fprintf(stdout, "here in maker\n"); fprintf(stdout, "here in maker\n");
return new DriverDAT_R_SMESHDS_Document; return new DriverDAT_R_SMESHDS_Document;
} }
} }
DriverDAT_R_SMESHDS_Document::DriverDAT_R_SMESHDS_Document() { DriverDAT_R_SMESHDS_Document::DriverDAT_R_SMESHDS_Document()
{
myFile = string(""); myFile = string("");
} }
DriverDAT_R_SMESHDS_Document::~DriverDAT_R_SMESHDS_Document() { DriverDAT_R_SMESHDS_Document::~DriverDAT_R_SMESHDS_Document()
{
; ;
} }
@ -59,7 +64,8 @@ DriverDAT_R_SMESHDS_Document::~DriverDAT_R_SMESHDS_Document() {
//myDocument = aDoc; //myDocument = aDoc;
//} //}
void DriverDAT_R_SMESHDS_Document::Read() { void DriverDAT_R_SMESHDS_Document::Read()
{
int myMeshId; int myMeshId;
MESSAGE("in read"); MESSAGE("in read");
@ -92,14 +98,14 @@ void DriverDAT_R_SMESHDS_Document::Read() {
string myClass = string("SMESHDS_Mesh"); string myClass = string("SMESHDS_Mesh");
string myExtension = string("DAT"); string myExtension = string("DAT");
for (int meshIt=1;meshIt<=nmaa;meshIt++) { for (int meshIt = 1; meshIt <= nmaa; meshIt++)
{
myMeshId = myDocument->NewMesh(); myMeshId = myDocument->NewMesh();
Handle(SMDS_Mesh) myMesh = myDocument->GetMesh(myMeshId); SMDS_Mesh * myMesh = myDocument->GetMesh(myMeshId);
DriverDAT_R_SMESHDS_Mesh *myReader = new DriverDAT_R_SMESHDS_Mesh; DriverDAT_R_SMESHDS_Mesh *myReader = new DriverDAT_R_SMESHDS_Mesh;
myReader->SetMesh(myMesh); myReader->SetMesh(myMesh);
myReader->SetFile(myFile); myReader->SetFile(myFile);
//myReader->SetFileId(fid); //myReader->SetFileId(fid);
@ -108,5 +114,4 @@ void DriverDAT_R_SMESHDS_Document::Read() {
} }
} }

View File

@ -30,36 +30,44 @@ using namespace std;
#include "utilities.h" #include "utilities.h"
DriverDAT_R_SMESHDS_Mesh::DriverDAT_R_SMESHDS_Mesh() { DriverDAT_R_SMESHDS_Mesh::DriverDAT_R_SMESHDS_Mesh()
{
; ;
} }
DriverDAT_R_SMESHDS_Mesh::~DriverDAT_R_SMESHDS_Mesh() { DriverDAT_R_SMESHDS_Mesh::~DriverDAT_R_SMESHDS_Mesh()
{
; ;
} }
void DriverDAT_R_SMESHDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) { void DriverDAT_R_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
//myMesh = Handle(SMESHDS_Mesh)::DownCast(aMesh); {
//myMesh = SMESHDS_Mesh *::DownCast(aMesh);
myMesh = aMesh; myMesh = aMesh;
} }
void DriverDAT_R_SMESHDS_Mesh::SetFile(string aFile) { void DriverDAT_R_SMESHDS_Mesh::SetFile(string aFile)
{
myFile = aFile; myFile = aFile;
} }
void DriverDAT_R_SMESHDS_Mesh::SetFileId(FILE* aFileId) { void DriverDAT_R_SMESHDS_Mesh::SetFileId(FILE * aFileId)
{
myFileId = aFileId; myFileId = aFileId;
} }
void DriverDAT_R_SMESHDS_Mesh::SetMeshId(int aMeshId) { void DriverDAT_R_SMESHDS_Mesh::SetMeshId(int aMeshId)
{
myMeshId = aMeshId; myMeshId = aMeshId;
} }
void DriverDAT_R_SMESHDS_Mesh::Add() { void DriverDAT_R_SMESHDS_Mesh::Add()
{
; ;
} }
void DriverDAT_R_SMESHDS_Mesh::Read() { void DriverDAT_R_SMESHDS_Mesh::Read()
{
string myClass = string("SMDS_Mesh"); string myClass = string("SMDS_Mesh");
string myExtension = string("DAT"); string myExtension = string("DAT");

View File

@ -32,22 +32,21 @@
#include "SMESHDS_Mesh.hxx" #include "SMESHDS_Mesh.hxx"
#include "Mesh_Reader.h" #include "Mesh_Reader.h"
class DriverDAT_R_SMESHDS_Mesh : public Mesh_Reader { class DriverDAT_R_SMESHDS_Mesh:public Mesh_Reader
{
public : public:DriverDAT_R_SMESHDS_Mesh();
DriverDAT_R_SMESHDS_Mesh();
~DriverDAT_R_SMESHDS_Mesh(); ~DriverDAT_R_SMESHDS_Mesh();
void Add(); void Add();
void Read(); void Read();
void SetMesh(Handle(SMDS_Mesh)& aMesh); void SetMesh(SMDS_Mesh * aMesh);
void SetFile(string); void SetFile(string);
void SetFileId(FILE *); void SetFileId(FILE *);
void SetMeshId(int); void SetMeshId(int);
private : private: SMDS_Mesh * myMesh;
Handle_SMDS_Mesh myMesh;
string myFile; string myFile;
FILE *myFileId; FILE *myFileId;
int myMeshId; int myMeshId;

View File

@ -29,42 +29,46 @@ using namespace std;
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_MeshEdgesIterator.hxx"
#include "SMDS_MeshFacesIterator.hxx"
#include "SMDS_MeshNodesIterator.hxx"
#include "SMDS_MeshVolumesIterator.hxx"
#include "utilities.h" #include "utilities.h"
DriverDAT_W_SMDS_Mesh::DriverDAT_W_SMDS_Mesh() { DriverDAT_W_SMDS_Mesh::DriverDAT_W_SMDS_Mesh()
{
; ;
} }
DriverDAT_W_SMDS_Mesh::~DriverDAT_W_SMDS_Mesh() { DriverDAT_W_SMDS_Mesh::~DriverDAT_W_SMDS_Mesh()
{
; ;
} }
void DriverDAT_W_SMDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) { void DriverDAT_W_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
{
myMesh = aMesh; myMesh = aMesh;
} }
void DriverDAT_W_SMDS_Mesh::SetFile(string aFile) { void DriverDAT_W_SMDS_Mesh::SetFile(string aFile)
{
myFile = aFile; myFile = aFile;
} }
void DriverDAT_W_SMDS_Mesh::SetFileId(FILE* aFileId) { void DriverDAT_W_SMDS_Mesh::SetFileId(FILE * aFileId)
{
myFileId = aFileId; myFileId = aFileId;
} }
void DriverDAT_W_SMDS_Mesh::SetMeshId(int aMeshId) { void DriverDAT_W_SMDS_Mesh::SetMeshId(int aMeshId)
{
myMeshId = aMeshId; myMeshId = aMeshId;
} }
void DriverDAT_W_SMDS_Mesh::Add() { void DriverDAT_W_SMDS_Mesh::Add()
{
; ;
} }
void DriverDAT_W_SMDS_Mesh::Write() { void DriverDAT_W_SMDS_Mesh::Write()
{
int nbNodes, nbCells; int nbNodes, nbCells;
int i; int i;
@ -88,7 +92,7 @@ void DriverDAT_W_SMDS_Mesh::Write() {
nbNodes = myMesh->NbNodes(); nbNodes = myMesh->NbNodes();
/* Combien de mailles, faces ou aretes ? */ /* Combien de mailles, faces ou aretes ? */
Standard_Integer nb_of_nodes, nb_of_edges,nb_of_faces, nb_of_volumes; int nb_of_nodes, nb_of_edges, nb_of_faces, nb_of_volumes;
nb_of_edges = myMesh->NbEdges(); nb_of_edges = myMesh->NbEdges();
nb_of_faces = myMesh->NbFaces(); nb_of_faces = myMesh->NbFaces();
nb_of_volumes = myMesh->NbVolumes(); nb_of_volumes = myMesh->NbVolumes();
@ -107,12 +111,12 @@ void DriverDAT_W_SMDS_Mesh::Write() {
fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n"); fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
fprintf(stdout, "(************************)\n"); fprintf(stdout, "(************************)\n");
SMDS_MeshNodesIterator itNodes(myMesh); SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
for (;itNodes.More();itNodes.Next()) { while(itNodes->more())
const Handle(SMDS_MeshElement)& elem = itNodes.Value(); {
const Handle(SMDS_MeshNode)& node = myMesh->GetNode(1,elem); const SMDS_MeshNode * node = itNodes->next();
fprintf(myFileId, "%d %e %e %e\n", node->GetID(), node->X(),
fprintf(myFileId,"%d %e %e %e\n",node->GetID(),node->X(),node->Y(),node->Z()); node->Y(), node->Z());
} }
/**************************************************************************** /****************************************************************************
@ -123,65 +127,77 @@ void DriverDAT_W_SMDS_Mesh::Write() {
fprintf(stdout, "(**************************)"); fprintf(stdout, "(**************************)");
/* Ecriture des connectivites, noms, numeros des mailles */ /* Ecriture des connectivites, noms, numeros des mailles */
SMDS_MeshEdgesIterator itEdges(myMesh); SMDS_Iterator<const SMDS_MeshEdge *> * itEdges=myMesh->edgesIterator();
for (;itEdges.More();itEdges.Next()) { while(itEdges->more())
const Handle(SMDS_MeshElement)& elem = itEdges.Value(); {
const SMDS_MeshElement * elem = itEdges->next();
switch (elem->NbNodes()) { switch (elem->NbNodes())
case 2 : { {
case 2:
{
fprintf(myFileId, "%d %d ", elem->GetID(), 102); fprintf(myFileId, "%d %d ", elem->GetID(), 102);
break; break;
} }
case 3 : { case 3:
{
fprintf(myFileId, "%d %d ", elem->GetID(), 103); fprintf(myFileId, "%d %d ", elem->GetID(), 103);
break; break;
} }
} }
for (i=0;i<elem->NbNodes();i++) SMDS_Iterator<const SMDS_MeshElement *> * it=elem->nodesIterator();
fprintf(myFileId,"%d ",elem->GetConnection(i+1)); while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID());
fprintf(myFileId, "\n"); fprintf(myFileId, "\n");
} }
SMDS_MeshFacesIterator itFaces(myMesh); SMDS_Iterator<const SMDS_MeshFace *> * itFaces=myMesh->facesIterator();
for (;itFaces.More();itFaces.Next()) { while(itFaces->more())
const Handle(SMDS_MeshElement)& elem = itFaces.Value(); {
const SMDS_MeshElement * elem = itFaces->next();
switch (elem->NbNodes()) { switch (elem->NbNodes())
case 3 : { {
case 3:
{
fprintf(myFileId, "%d %d ", elem->GetID(), 203); fprintf(myFileId, "%d %d ", elem->GetID(), 203);
break; break;
} }
case 4 : { case 4:
{
fprintf(myFileId, "%d %d ", elem->GetID(), 204); fprintf(myFileId, "%d %d ", elem->GetID(), 204);
break; break;
} }
case 6 : { case 6:
{
fprintf(myFileId, "%d %d ", elem->GetID(), 206); fprintf(myFileId, "%d %d ", elem->GetID(), 206);
break; break;
} }
} }
for (i=0;i<elem->NbNodes();i++) SMDS_Iterator<const SMDS_MeshElement *> * it=elem->nodesIterator();
fprintf(myFileId,"%d ",elem->GetConnection(i+1)); while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID());
fprintf(myFileId, "\n"); fprintf(myFileId, "\n");
} }
SMDS_MeshVolumesIterator itVolumes(myMesh); SMDS_Iterator<const SMDS_MeshVolume *> * itVolumes=myMesh->volumesIterator();
for (;itVolumes.More();itVolumes.Next()) { while(itVolumes->more())
const Handle(SMDS_MeshElement)& elem = itVolumes.Value(); {
const SMDS_MeshElement * elem = itVolumes->next();
switch (elem->NbNodes()) { switch (elem->NbNodes())
case 8 : { {
case 8:
{
fprintf(myFileId, "%d %d ", elem->GetID(), 308); fprintf(myFileId, "%d %d ", elem->GetID(), 308);
break; break;
} }
} }
for (i=0;i<elem->NbNodes();i++) SMDS_Iterator<const SMDS_MeshElement *> * it=elem->nodesIterator();
fprintf(myFileId,"%d ",elem->GetConnection(i+1)); while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID());
fprintf(myFileId, "\n"); fprintf(myFileId, "\n");
} }

View File

@ -33,22 +33,21 @@
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "Mesh_Writer.h" #include "Mesh_Writer.h"
class DriverDAT_W_SMDS_Mesh : public Mesh_Writer { class DriverDAT_W_SMDS_Mesh:public Mesh_Writer
{
public : public:DriverDAT_W_SMDS_Mesh();
DriverDAT_W_SMDS_Mesh();
~DriverDAT_W_SMDS_Mesh(); ~DriverDAT_W_SMDS_Mesh();
void Add(); void Add();
void Write(); void Write();
void SetMesh(Handle(SMDS_Mesh)& aMesh); void SetMesh(SMDS_Mesh * aMesh);
void SetFile(string); void SetFile(string);
void SetFileId(FILE *); void SetFileId(FILE *);
void SetMeshId(int); void SetMeshId(int);
private : private: SMDS_Mesh * myMesh;
Handle_SMDS_Mesh myMesh;
string myFile; string myFile;
FILE *myFileId; FILE *myFileId;
int myMeshId; int myMeshId;

View File

@ -32,16 +32,19 @@ using namespace std;
extern "C" extern "C"
{ {
Document_Writer* Wmaker() { Document_Writer *Wmaker()
{
return new DriverDAT_W_SMESHDS_Document; return new DriverDAT_W_SMESHDS_Document;
} }
} }
DriverDAT_W_SMESHDS_Document::DriverDAT_W_SMESHDS_Document() { DriverDAT_W_SMESHDS_Document::DriverDAT_W_SMESHDS_Document()
{
; ;
} }
DriverDAT_W_SMESHDS_Document::~DriverDAT_W_SMESHDS_Document() { DriverDAT_W_SMESHDS_Document::~DriverDAT_W_SMESHDS_Document()
{
; ;
} }
@ -53,9 +56,10 @@ DriverDAT_W_SMESHDS_Document::~DriverDAT_W_SMESHDS_Document() {
//myDocument = aDocument; //myDocument = aDocument;
//} //}
void DriverDAT_W_SMESHDS_Document::Write() { void DriverDAT_W_SMESHDS_Document::Write()
{
Handle(SMESHDS_Mesh) myMesh; SMESHDS_Mesh * myMesh;
/**************************************************************************** /****************************************************************************
* OUVERTURE DU FICHIER EN ECRITURE * * OUVERTURE DU FICHIER EN ECRITURE *
@ -86,9 +90,10 @@ void DriverDAT_W_SMESHDS_Document::Write() {
//numero++; //numero++;
//myMesh = myDocument->GetMesh(numero); //myMesh = myDocument->GetMesh(numero);
myDocument->InitMeshesIterator(); myDocument->InitMeshesIterator();
for (;myDocument->MoreMesh();myDocument->NextMesh()) { while(myDocument->MoreMesh())
{
numero++; numero++;
myMesh = myDocument->CurrentMesh(); myMesh = myDocument->NextMesh();
DriverDAT_W_SMESHDS_Mesh *myWriter = new DriverDAT_W_SMESHDS_Mesh; DriverDAT_W_SMESHDS_Mesh *myWriter = new DriverDAT_W_SMESHDS_Mesh;
//Mesh_Writer* myWriter = Driver::GetMeshWriter(myExtension, myClass); //Mesh_Writer* myWriter = Driver::GetMeshWriter(myExtension, myClass);

View File

@ -30,39 +30,46 @@ using namespace std;
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_MeshEdgesIterator.hxx"
#include "SMDS_MeshFacesIterator.hxx"
#include "SMDS_MeshNodesIterator.hxx"
#include "SMDS_MeshVolumesIterator.hxx"
#include "utilities.h" #include "utilities.h"
DriverDAT_W_SMESHDS_Mesh::DriverDAT_W_SMESHDS_Mesh() { DriverDAT_W_SMESHDS_Mesh::DriverDAT_W_SMESHDS_Mesh()
{
; ;
} }
DriverDAT_W_SMESHDS_Mesh::~DriverDAT_W_SMESHDS_Mesh() { DriverDAT_W_SMESHDS_Mesh::~DriverDAT_W_SMESHDS_Mesh()
{
; ;
} }
void DriverDAT_W_SMESHDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) { void DriverDAT_W_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
//myMesh = Handle(SMESHDS_Mesh)::DownCast(aMesh); {
//myMesh = SMESHDS_Mesh *::DownCast(aMesh);
myMesh = aMesh; myMesh = aMesh;
} }
void DriverDAT_W_SMESHDS_Mesh::SetFile(string aFile) { void DriverDAT_W_SMESHDS_Mesh::SetFile(string aFile)
{
myFile = aFile; myFile = aFile;
} }
void DriverDAT_W_SMESHDS_Mesh::SetFileId(FILE* aFileId) { void DriverDAT_W_SMESHDS_Mesh::SetFileId(FILE * aFileId)
{
myFileId = aFileId; myFileId = aFileId;
} }
void DriverDAT_W_SMESHDS_Mesh::SetMeshId(int aMeshId) { void DriverDAT_W_SMESHDS_Mesh::SetMeshId(int aMeshId)
{
myMeshId = aMeshId; myMeshId = aMeshId;
} }
void DriverDAT_W_SMESHDS_Mesh::Write() { void DriverDAT_W_SMESHDS_Mesh::Write()
{
string myClass = string("SMDS_Mesh"); string myClass = string("SMDS_Mesh");
string myExtension = string("DAT"); string myExtension = string("DAT");
@ -76,9 +83,10 @@ void DriverDAT_W_SMESHDS_Mesh::Write() {
myWriter->Write(); myWriter->Write();
} }
void DriverDAT_W_SMESHDS_Mesh::Add() {
void DriverDAT_W_SMESHDS_Mesh::Add()
{
int nbNodes, nbCells; int nbNodes, nbCells;
int i; int i;
@ -101,7 +109,7 @@ void DriverDAT_W_SMESHDS_Mesh::Add() {
nbNodes = myMesh->NbNodes(); nbNodes = myMesh->NbNodes();
/* Combien de mailles, faces ou aretes ? */ /* Combien de mailles, faces ou aretes ? */
Standard_Integer nb_of_nodes, nb_of_edges,nb_of_faces, nb_of_volumes; int nb_of_nodes, nb_of_edges, nb_of_faces, nb_of_volumes;
nb_of_edges = myMesh->NbEdges(); nb_of_edges = myMesh->NbEdges();
nb_of_faces = myMesh->NbFaces(); nb_of_faces = myMesh->NbFaces();
nb_of_volumes = myMesh->NbVolumes(); nb_of_volumes = myMesh->NbVolumes();
@ -117,13 +125,14 @@ void DriverDAT_W_SMESHDS_Mesh::Add() {
fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n"); fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
fprintf(stdout, "(************************)\n"); fprintf(stdout, "(************************)\n");
SMDS_MeshNodesIterator itNodes(myMesh); SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
for (;itNodes.More();itNodes.Next()) { while(itNodes->more())
const Handle(SMDS_MeshElement)& elem = itNodes.Value(); {
const Handle(SMDS_MeshNode)& node = myMesh->GetNode(1,elem); const SMDS_MeshNode * node = itNodes->next();
fprintf(myFileId, "%d %e %e %e\n", node->GetID(), node->X(),
fprintf(myFileId,"%d %e %e %e\n",node->GetID(),node->X(),node->Y(),node->Z()); node->Y(), node->Z());
} }
delete itNodes;
/**************************************************************************** /****************************************************************************
* ECRITURE DES ELEMENTS * * ECRITURE DES ELEMENTS *
@ -133,69 +142,86 @@ void DriverDAT_W_SMESHDS_Mesh::Add() {
fprintf(stdout, "(**************************)"); fprintf(stdout, "(**************************)");
/* Ecriture des connectivites, noms, numeros des mailles */ /* Ecriture des connectivites, noms, numeros des mailles */
SMDS_MeshEdgesIterator itEdges(myMesh); SMDS_Iterator<const SMDS_MeshEdge*> * itEdges=myMesh->edgesIterator();
for (;itEdges.More();itEdges.Next()) { while(itEdges->more())
const Handle(SMDS_MeshElement)& elem = itEdges.Value(); {
const SMDS_MeshEdge * elem = itEdges->next();
switch (elem->NbNodes()) { switch (elem->NbNodes())
case 2 : { {
case 2:
{
fprintf(myFileId, "%d %d ", elem->GetID(), 102); fprintf(myFileId, "%d %d ", elem->GetID(), 102);
break; break;
} }
case 3 : { case 3:
{
fprintf(myFileId, "%d %d ", elem->GetID(), 103); fprintf(myFileId, "%d %d ", elem->GetID(), 103);
break; break;
} }
} }
for (i=0;i<elem->NbNodes();i++) SMDS_Iterator<const SMDS_MeshElement *> * itNodes=elem->nodesIterator();
fprintf(myFileId,"%d ",elem->GetConnection(i+1)); while(itNodes->more())
fprintf(myFileId, "%d ", itNodes->next()->GetID());
fprintf(myFileId, "\n"); fprintf(myFileId, "\n");
} }
delete itEdges;
SMDS_MeshFacesIterator itFaces(myMesh); SMDS_Iterator<const SMDS_MeshFace *> * itFaces=myMesh->facesIterator();
for (;itFaces.More();itFaces.Next()) { while(itFaces->more())
const Handle(SMDS_MeshElement)& elem = itFaces.Value(); {
const SMDS_MeshElement * elem = itFaces->next();
switch (elem->NbNodes()) { switch (elem->NbNodes())
case 3 : { {
case 3:
{
fprintf(myFileId, "%d %d ", elem->GetID(), 203); fprintf(myFileId, "%d %d ", elem->GetID(), 203);
break; break;
} }
case 4 : { case 4:
{
fprintf(myFileId, "%d %d ", elem->GetID(), 204); fprintf(myFileId, "%d %d ", elem->GetID(), 204);
break; break;
} }
case 6 : { case 6:
{
fprintf(myFileId, "%d %d ", elem->GetID(), 206); fprintf(myFileId, "%d %d ", elem->GetID(), 206);
break; break;
} }
} }
for (i=0;i<elem->NbNodes();i++) SMDS_Iterator<const SMDS_MeshElement *> * itNodes=elem->nodesIterator();
fprintf(myFileId,"%d ",elem->GetConnection(i+1)); while(itNodes->more())
fprintf(myFileId, "%d ", itNodes->next()->GetID());
fprintf(myFileId, "\n"); fprintf(myFileId, "\n");
} }
delete itFaces;
SMDS_MeshVolumesIterator itVolumes(myMesh); SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=myMesh->volumesIterator();
for (;itVolumes.More();itVolumes.Next()) { while(itVolumes->more())
const Handle(SMDS_MeshElement)& elem = itVolumes.Value(); {
const SMDS_MeshElement * elem = itVolumes->next();
switch (elem->NbNodes()) { switch (elem->NbNodes())
case 8 : { {
case 8:
{
fprintf(myFileId, "%d %d ", elem->GetID(), 308); fprintf(myFileId, "%d %d ", elem->GetID(), 308);
break; break;
} }
} }
for (i=0;i<elem->NbNodes();i++) SMDS_Iterator<const SMDS_MeshElement *> * itNodes=elem->nodesIterator();
fprintf(myFileId,"%d ",elem->GetConnection(i+1)); while(itNodes->more())
fprintf(myFileId, "%d ", itNodes->next()->GetID());
fprintf(myFileId, "\n"); fprintf(myFileId, "\n");
} }
delete itVolumes;
fclose(myFileId); fclose(myFileId);
} }

View File

@ -33,22 +33,21 @@
#include "SMESHDS_Mesh.hxx" #include "SMESHDS_Mesh.hxx"
#include "Mesh_Writer.h" #include "Mesh_Writer.h"
class DriverDAT_W_SMESHDS_Mesh : public Mesh_Writer { class DriverDAT_W_SMESHDS_Mesh:public Mesh_Writer
{
public : public:DriverDAT_W_SMESHDS_Mesh();
DriverDAT_W_SMESHDS_Mesh();
~DriverDAT_W_SMESHDS_Mesh(); ~DriverDAT_W_SMESHDS_Mesh();
void Add(); void Add();
void Write(); void Write();
void SetMesh(Handle(SMDS_Mesh)& aMesh); void SetMesh(SMDS_Mesh * aMesh);
void SetFile(string); void SetFile(string);
void SetFileId(FILE *); void SetFileId(FILE *);
void SetMeshId(int); void SetMeshId(int);
private : private: SMDS_Mesh * myMesh;
Handle_SMDS_Mesh myMesh;
string myFile; string myFile;
FILE *myFileId; FILE *myFileId;
int myMeshId; int myMeshId;

View File

@ -28,41 +28,49 @@ using namespace std;
#include "DriverMED_R_SMDS_Mesh.h" #include "DriverMED_R_SMDS_Mesh.h"
#include "utilities.h" #include "utilities.h"
DriverMED_R_SMDS_Mesh::DriverMED_R_SMDS_Mesh() { DriverMED_R_SMDS_Mesh::DriverMED_R_SMDS_Mesh()
{
} }
DriverMED_R_SMDS_Mesh::~DriverMED_R_SMDS_Mesh() { DriverMED_R_SMDS_Mesh::~DriverMED_R_SMDS_Mesh()
{
; ;
} }
void DriverMED_R_SMDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) { void DriverMED_R_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
{
myMesh = aMesh; myMesh = aMesh;
} }
void DriverMED_R_SMDS_Mesh::SetFile(string aFile) { void DriverMED_R_SMDS_Mesh::SetFile(string aFile)
{
myFileId = -1; myFileId = -1;
myFile = aFile; myFile = aFile;
} }
void DriverMED_R_SMDS_Mesh::SetFileId(med_idt aFileId) { void DriverMED_R_SMDS_Mesh::SetFileId(med_idt aFileId)
{
myFileId = aFileId; myFileId = aFileId;
} }
void DriverMED_R_SMDS_Mesh::SetMeshId(int aMeshId) { void DriverMED_R_SMDS_Mesh::SetMeshId(int aMeshId)
{
myMeshId = aMeshId; myMeshId = aMeshId;
} }
void DriverMED_R_SMDS_Mesh::Add() { void DriverMED_R_SMDS_Mesh::Add()
{
; ;
} }
void DriverMED_R_SMDS_Mesh::Read() { void DriverMED_R_SMDS_Mesh::Read()
{
med_err ret = 0; med_err ret = 0;
int i, j, k, l; int i, j, k, l;
int numero; int numero;
char message[200]; char message[200];
Standard_Boolean ok; bool ok;
/* nombre d'objets MED */ /* nombre d'objets MED */
char nom_universel[MED_TAILLE_LNOM + 1]; char nom_universel[MED_TAILLE_LNOM + 1];
med_int long_fichier_en_tete; med_int long_fichier_en_tete;
@ -98,15 +106,18 @@ void DriverMED_R_SMDS_Mesh::Read() {
med_booleen inoele, inuele; med_booleen inoele, inuele;
med_connectivite typ_con; med_connectivite typ_con;
med_geometrie_element typgeo; med_geometrie_element typgeo;
med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] = {MED_POINT1,MED_SEG2, med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] =
{ MED_POINT1, MED_SEG2,
MED_SEG3, MED_TRIA3, MED_SEG3, MED_TRIA3,
MED_TRIA6, MED_QUAD4, MED_TRIA6, MED_QUAD4,
MED_QUAD8, MED_TETRA4, MED_QUAD8, MED_TETRA4,
MED_TETRA10, MED_HEXA8, MED_TETRA10, MED_HEXA8,
MED_HEXA20, MED_PENTA6, MED_HEXA20, MED_PENTA6,
MED_PENTA15, MED_PYRA5, MED_PENTA15, MED_PYRA5,
MED_PYRA13}; MED_PYRA13
med_int desmai[MED_NBR_GEOMETRIE_MAILLE] = {0,2,3,3,3,4,4,4,4,6,6,5,5,5,5}; };
med_int desmai[MED_NBR_GEOMETRIE_MAILLE] =
{ 0, 2, 3, 3, 3, 4, 4, 4, 4, 6, 6, 5, 5, 5, 5 };
med_int nmailles[MED_NBR_GEOMETRIE_MAILLE]; med_int nmailles[MED_NBR_GEOMETRIE_MAILLE];
char nommai[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = { "MED_POINT1", char nommai[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = { "MED_POINT1",
"MED_SEG2", "MED_SEG2",
@ -122,17 +133,24 @@ void DriverMED_R_SMDS_Mesh::Read() {
"MED_PENTA6", "MED_PENTA6",
"MED_PENTA15", "MED_PENTA15",
"MED_PYRA5", "MED_PYRA5",
"MED_PYRA13"}; "MED_PYRA13"
med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] = {MED_TRIA3,MED_TRIA6, };
MED_QUAD4,MED_QUAD8}; med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] =
{ MED_TRIA3, MED_TRIA6,
MED_QUAD4, MED_QUAD8
};
med_int desfac[MED_NBR_GEOMETRIE_FACE] = { 3, 3, 4, 4 }; med_int desfac[MED_NBR_GEOMETRIE_FACE] = { 3, 3, 4, 4 };
med_int nfaces[MED_NBR_GEOMETRIE_FACE]; med_int nfaces[MED_NBR_GEOMETRIE_FACE];
char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM+1] = {"MED_TRIA3","MED_TRIA6", char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM + 1] =
"MED_QUAD4","MED_QUAD8"}; { "MED_TRIA3", "MED_TRIA6",
med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] = {MED_SEG2,MED_SEG3}; "MED_QUAD4", "MED_QUAD8"
};
med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] =
{ MED_SEG2, MED_SEG3 };
med_int desare[MED_NBR_GEOMETRIE_ARETE] = { 2, 3 }; med_int desare[MED_NBR_GEOMETRIE_ARETE] = { 2, 3 };
med_int naretes[MED_NBR_GEOMETRIE_ARETE]; med_int naretes[MED_NBR_GEOMETRIE_ARETE];
char nomare[MED_NBR_GEOMETRIE_ARETE] [MED_TAILLE_NOM+1] = {"MED_SEG2","MED_SEG3"}; char nomare[MED_NBR_GEOMETRIE_ARETE][MED_TAILLE_NOM + 1] =
{ "MED_SEG2", "MED_SEG3" };
/* familles */ /* familles */
med_int nfam; med_int nfam;
med_int natt, ngro; med_int natt, ngro;
@ -157,7 +175,8 @@ void DriverMED_R_SMDS_Mesh::Read() {
myFileId = MEDouvrir(file2Read, MED_LECT); myFileId = MEDouvrir(file2Read, MED_LECT);
if (myFileId < 0) if (myFileId < 0)
{ {
fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read); fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n",
file2Read);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
numero = 1; numero = 1;
@ -168,7 +187,6 @@ void DriverMED_R_SMDS_Mesh::Read() {
typ_con = MED_NOD; typ_con = MED_NOD;
mode_coo = MED_FULL_INTERLACE; mode_coo = MED_FULL_INTERLACE;
/**************************************************************************** /****************************************************************************
* NOMBRES D'OBJETS MED * * NOMBRES D'OBJETS MED *
****************************************************************************/ ****************************************************************************/
@ -189,7 +207,8 @@ void DriverMED_R_SMDS_Mesh::Read() {
fprintf(stdout, "- Dimension du maillage : %d\n", mdim); fprintf(stdout, "- Dimension du maillage : %d\n", mdim);
/* Combien de noeuds ? */ /* Combien de noeuds ? */
nnoe = MEDnEntMaa(myFileId,nommaa,MED_COOR,MED_NOEUD,MED_POINT1,typ_con); nnoe =
MEDnEntMaa(myFileId, nommaa, MED_COOR, MED_NOEUD, MED_POINT1, typ_con);
if (nnoe < 0) if (nnoe < 0)
{ {
fprintf(stderr, ">> ERREUR : lecture du nombre de noeuds \n"); fprintf(stderr, ">> ERREUR : lecture du nombre de noeuds \n");
@ -200,14 +219,16 @@ void DriverMED_R_SMDS_Mesh::Read() {
/* Combien de mailles, faces ou aretes ? */ /* Combien de mailles, faces ou aretes ? */
for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++) for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
{ {
nmailles[i] = MEDnEntMaa(myFileId,nommaa,MED_CONN,MED_MAILLE,typmai[i], nmailles[i] =
MEDnEntMaa(myFileId, nommaa, MED_CONN, MED_MAILLE, typmai[i],
typ_con); typ_con);
if (nmailles[i] < 0) if (nmailles[i] < 0)
{ {
fprintf(stderr, ">> ERREUR : lecture du nombre de mailles \n"); fprintf(stderr, ">> ERREUR : lecture du nombre de mailles \n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
fprintf (stdout,"- Nombre de mailles de type %s : %d \n",nommai[i],nmailles[i]); fprintf(stdout, "- Nombre de mailles de type %s : %d \n", nommai[i],
nmailles[i]);
} }
for (i = 0; i < MED_NBR_GEOMETRIE_FACE; i++) for (i = 0; i < MED_NBR_GEOMETRIE_FACE; i++)
@ -219,19 +240,22 @@ void DriverMED_R_SMDS_Mesh::Read() {
fprintf(stderr, ">> ERREUR : lecture du nombre de faces \n"); fprintf(stderr, ">> ERREUR : lecture du nombre de faces \n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
fprintf (stdout,"- Nombre de faces de type %s : %d \n",nomfac[i],nfaces[i]); fprintf(stdout, "- Nombre de faces de type %s : %d \n", nomfac[i],
nfaces[i]);
} }
for (i = 0; i < MED_NBR_GEOMETRIE_ARETE; i++) for (i = 0; i < MED_NBR_GEOMETRIE_ARETE; i++)
{ {
naretes[i] = MEDnEntMaa(myFileId,nommaa,MED_CONN,MED_ARETE,typare[i], naretes[i] =
MEDnEntMaa(myFileId, nommaa, MED_CONN, MED_ARETE, typare[i],
typ_con); typ_con);
if (naretes[i] < 0) if (naretes[i] < 0)
{ {
fprintf(stderr, ">> ERREUR : lecture du nombre d'aretes \n"); fprintf(stderr, ">> ERREUR : lecture du nombre d'aretes \n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
fprintf (stdout,"- Nombre d'aretes de type %s : %d \n",nomare[i],naretes[i]); fprintf(stdout, "- Nombre d'aretes de type %s : %d \n", nomare[i],
naretes[i]);
} }
/* nombre de familles */ /* nombre de familles */
@ -252,36 +276,41 @@ void DriverMED_R_SMDS_Mesh::Read() {
/* Allocations memoires */ /* Allocations memoires */
/* table des coordonnees /* table des coordonnees
profil : (dimension * nombre de noeuds ) */ * profil : (dimension * nombre de noeuds ) */
coo = (med_float *) malloc(sizeof(med_float) * nnoe * mdim); coo = (med_float *) malloc(sizeof(med_float) * nnoe * mdim);
/* table des numeros, des numeros de familles des noeuds /* table des numeros, des numeros de familles des noeuds
profil : (nombre de noeuds) */ * profil : (nombre de noeuds) */
numnoe = (med_int *) malloc(sizeof(med_int) * nnoe); numnoe = (med_int *) malloc(sizeof(med_int) * nnoe);
nufano = (med_int *) malloc(sizeof(med_int) * nnoe); nufano = (med_int *) malloc(sizeof(med_int) * nnoe);
/* table des noms des noeuds /* table des noms des noeuds
profil : (nnoe*MED_TAILLE_PNOM+1) */ * profil : (nnoe*MED_TAILLE_PNOM+1) */
nomnoe = (char *)malloc(MED_TAILLE_PNOM * nnoe + 1); nomnoe = (char *)malloc(MED_TAILLE_PNOM * nnoe + 1);
/* lecture des noeuds : /* lecture des noeuds :
- coordonnees * - coordonnees
- noms (optionnel dans un fichier MED) * - noms (optionnel dans un fichier MED)
- numeros (optionnel dans un fichier MED) * - numeros (optionnel dans un fichier MED)
- numeros des familles */ * - numeros des familles */
ret = MEDnoeudsLire(myFileId, nommaa, mdim, coo, mode_coo, &rep, ret = MEDnoeudsLire(myFileId, nommaa, mdim, coo, mode_coo, &rep,
nomcoo,unicoo,nomnoe,&inonoe,numnoe,&inunoe, nomcoo, unicoo, nomnoe, &inonoe, numnoe, &inunoe, nufano, nnoe);
nufano,nnoe);
if (ret < 0) if (ret < 0)
strcpy(message, ">> ERREUR : lecture des noeuds \n"); strcpy(message, ">> ERREUR : lecture des noeuds \n");
if (inunoe) { if (inunoe)
for (int i=0;i<nnoe;i++) { {
ok = myMesh->AddNodeWithID(coo[i*3],coo[i*3+1],coo[i*3+2],numnoe[i]); for (int i = 0; i < nnoe; i++)
{
ok = myMesh->AddNodeWithID(coo[i * 3], coo[i * 3 + 1],
coo[i * 3 + 2], numnoe[i]);
//fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],coo[i*3+2]); //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],coo[i*3+2]);
} }
} }
else { else
for (int i=0;i<nnoe;i++) { {
ok = myMesh->AddNodeWithID(coo[i*3],coo[i*3+1],coo[i*3+2],i+1); for (int i = 0; i < nnoe; i++)
{
ok = myMesh->AddNodeWithID(coo[i * 3], coo[i * 3 + 1],
coo[i * 3 + 2], i + 1);
//fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],i); //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],i);
} }
} }
@ -332,88 +361,141 @@ void DriverMED_R_SMDS_Mesh::Read() {
taille * nmailles[i]); taille * nmailles[i]);
nomele = (char *)malloc(sizeof(char) * MED_TAILLE_PNOM * nomele = (char *)malloc(sizeof(char) * MED_TAILLE_PNOM *
nmailles[i] + 1); nmailles[i] + 1);
numele = (med_int*)malloc(sizeof(med_int)* numele = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
nmailles[i]); nufael = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
nufael = (med_int*)malloc(sizeof(med_int)*
nmailles[i]);
/* lecture des données */ /* lecture des données */
ret = MEDelementsLire(myFileId,nommaa,mdim,connectivite,mode_coo, ret =
nomele,&inoele,numele,&inuele,nufael, MEDelementsLire(myFileId, nommaa, mdim, connectivite,
nmailles[i],MED_MAILLE,typmai[i], mode_coo, nomele, &inoele, numele, &inuele, nufael,
typ_con); nmailles[i], MED_MAILLE, typmai[i], typ_con);
SCRUTE(typmai[i]); SCRUTE(typmai[i]);
switch (typmai[i]) switch (typmai[i])
{ {
case MED_SEG2 : { case MED_SEG2:
if (inuele) { {
for (j=0;j<nmailles[i];j++) { if (inuele)
{
for (j = 0; j < nmailles[i]; j++)
{
elem_id = *(numele + j); elem_id = *(numele + j);
ok = myMesh->AddEdgeWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),elem_id); ok = myMesh->AddEdgeWithID(*(connectivite +
j * (taille)),
*(connectivite + j * (taille) + 1), elem_id);
} }
} }
else { else
for (j=0;j<nmailles[i];j++) { {
for (j = 0; j < nmailles[i]; j++)
{
cmpt++; cmpt++;
ok = myMesh->AddEdgeWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),cmpt); ok = myMesh->AddEdgeWithID(*(connectivite +
j * (taille)),
*(connectivite + j * (taille) + 1), cmpt);
} }
} }
break; break;
} }
case MED_TRIA3 : { case MED_TRIA3:
if (inuele) { {
for (j=0;j<nmailles[i];j++) { if (inuele)
{
for (j = 0; j < nmailles[i]; j++)
{
elem_id = *(numele + j); elem_id = *(numele + j);
ok = myMesh->AddFaceWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),elem_id); ok = myMesh->AddFaceWithID(*(connectivite +
j * (taille)),
*(connectivite + j * (taille) + 1),
*(connectivite + j * (taille) + 2), elem_id);
//fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2)); //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2));
} }
} }
else { else
for (j=0;j<nmailles[i];j++) { {
for (j = 0; j < nmailles[i]; j++)
{
cmpt++; cmpt++;
ok = myMesh->AddFaceWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),cmpt); ok = myMesh->AddFaceWithID(*(connectivite +
j * (taille)),
*(connectivite + j * (taille) + 1),
*(connectivite + j * (taille) + 2), cmpt);
//fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2)); //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2));
} }
} }
break; break;
} }
case MED_QUAD4 : { case MED_QUAD4:
if (inuele) { {
for (j=0;j<nmailles[i];j++) { if (inuele)
{
for (j = 0; j < nmailles[i]; j++)
{
elem_id = *(numele + j); elem_id = *(numele + j);
ok = myMesh->AddFaceWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),elem_id); ok = myMesh->AddFaceWithID(*(connectivite +
j * (taille)),
*(connectivite + j * (taille) + 1),
*(connectivite + j * (taille) + 2),
*(connectivite + j * (taille) + 3), elem_id);
//fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3)); //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3));
} }
} }
else { else
for (j=0;j<nmailles[i];j++) { {
for (j = 0; j < nmailles[i]; j++)
{
cmpt++; cmpt++;
ok = myMesh->AddFaceWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),cmpt); ok = myMesh->AddFaceWithID(*(connectivite +
j * (taille)),
*(connectivite + j * (taille) + 1),
*(connectivite + j * (taille) + 2),
*(connectivite + j * (taille) + 3), cmpt);
//fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3)); //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3));
} }
} }
break; break;
} }
case MED_HEXA8 : { case MED_HEXA8:
if (inuele) { {
for (j=0;j<nmailles[i];j++) { if (inuele)
{
for (j = 0; j < nmailles[i]; j++)
{
elem_id = *(numele + j); elem_id = *(numele + j);
ok = myMesh->AddVolumeWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7),elem_id); ok = myMesh->AddVolumeWithID(*(connectivite +
j * (taille)),
*(connectivite + j * (taille) + 1),
*(connectivite + j * (taille) + 2),
*(connectivite + j * (taille) + 3),
*(connectivite + j * (taille) + 4),
*(connectivite + j * (taille) + 5),
*(connectivite + j * (taille) + 6),
*(connectivite + j * (taille) + 7), elem_id);
//fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),*(connectivite+j*(taille-nsup)+4),*(connectivite+j*(taille-nsup)+5),*(connectivite+j*(taille-nsup)+6),*(connectivite+j*(taille-nsup)+7)); //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),*(connectivite+j*(taille-nsup)+4),*(connectivite+j*(taille-nsup)+5),*(connectivite+j*(taille-nsup)+6),*(connectivite+j*(taille-nsup)+7));
} }
} }
else { else
for (j=0;j<nmailles[i];j++) { {
for (j = 0; j < nmailles[i]; j++)
{
cmpt++; cmpt++;
ok = myMesh->AddVolumeWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7),cmpt); ok = myMesh->AddVolumeWithID(*(connectivite +
j * (taille)),
*(connectivite + j * (taille) + 1),
*(connectivite + j * (taille) + 2),
*(connectivite + j * (taille) + 3),
*(connectivite + j * (taille) + 4),
*(connectivite + j * (taille) + 5),
*(connectivite + j * (taille) + 6),
*(connectivite + j * (taille) + 7), cmpt);
//fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7)); //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7));
} }
} }
break; break;
} }
default : { default:
{
break; break;
} }
} }
@ -464,7 +546,8 @@ void DriverMED_R_SMDS_Mesh::Read() {
} }
if (ret == 0) if (ret == 0)
fprintf(stdout,"- Famille %d a %d attributs et %d groupes \n",i+1,natt,ngro); fprintf(stdout, "- Famille %d a %d attributs et %d groupes \n",
i + 1, natt, ngro);
/* nom,numero,attributs,groupes */ /* nom,numero,attributs,groupes */
if (ret == 0) if (ret == 0)
@ -473,16 +556,19 @@ void DriverMED_R_SMDS_Mesh::Read() {
attval = (med_int *) malloc(sizeof(med_int) * natt); attval = (med_int *) malloc(sizeof(med_int) * natt);
attdes = (char *)malloc(MED_TAILLE_DESC * natt + 1); attdes = (char *)malloc(MED_TAILLE_DESC * natt + 1);
gro = (char *)malloc(MED_TAILLE_LNOM * ngro + 1); gro = (char *)malloc(MED_TAILLE_LNOM * ngro + 1);
ret = MEDfamInfo(myFileId,nommaa,i+1,nomfam,&numfam,attide,attval, ret =
attdes,&natt,gro,&ngro); MEDfamInfo(myFileId, nommaa, i + 1, nomfam, &numfam, attide,
fprintf(stdout," - Famille de nom %s et de numero %d : \n",nomfam,numfam); attval, attdes, &natt, gro, &ngro);
fprintf(stdout, " - Famille de nom %s et de numero %d : \n",
nomfam, numfam);
fprintf(stdout, " - Attributs : \n"); fprintf(stdout, " - Attributs : \n");
for (j = 0; j < natt; j++) for (j = 0; j < natt; j++)
{ {
strncpy(str1,attdes+j*MED_TAILLE_DESC,MED_TAILLE_DESC); strncpy(str1, attdes + j * MED_TAILLE_DESC,
MED_TAILLE_DESC);
str1[MED_TAILLE_DESC] = '\0'; str1[MED_TAILLE_DESC] = '\0';
fprintf(stdout," ide = %d - val = %d - des = %s\n",*(attide+j), fprintf(stdout, " ide = %d - val = %d - des = %s\n",
*(attval+j),str1); *(attide + j), *(attval + j), str1);
} }
free(attide); free(attide);
free(attval); free(attval);

View File

@ -35,22 +35,21 @@ extern "C"
#include <med.h> #include <med.h>
} }
class DriverMED_R_SMDS_Mesh : public Mesh_Reader { class DriverMED_R_SMDS_Mesh:public Mesh_Reader
{
public : public:DriverMED_R_SMDS_Mesh();
DriverMED_R_SMDS_Mesh();
~DriverMED_R_SMDS_Mesh(); ~DriverMED_R_SMDS_Mesh();
void Add(); void Add();
void Read(); void Read();
void SetMesh(Handle(SMDS_Mesh)& aMesh); void SetMesh(SMDS_Mesh * aMesh);
void SetFile(string); void SetFile(string);
void SetFileId(med_idt); void SetFileId(med_idt);
void SetMeshId(int); void SetMeshId(int);
private : private: SMDS_Mesh * myMesh;
Handle_SMDS_Mesh myMesh;
string myFile; string myFile;
med_idt myFileId; med_idt myFileId;
int myMeshId; int myMeshId;

View File

@ -29,17 +29,21 @@ using namespace std;
#include "DriverMED_R_SMESHDS_Mesh.h" #include "DriverMED_R_SMESHDS_Mesh.h"
#include "utilities.h" #include "utilities.h"
extern "C" { extern "C"
Document_Reader* maker() { {
Document_Reader *maker()
{
return new DriverMED_R_SMESHDS_Document; return new DriverMED_R_SMESHDS_Document;
} }
} }
DriverMED_R_SMESHDS_Document::DriverMED_R_SMESHDS_Document() { DriverMED_R_SMESHDS_Document::DriverMED_R_SMESHDS_Document()
{
; ;
} }
DriverMED_R_SMESHDS_Document::~DriverMED_R_SMESHDS_Document() { DriverMED_R_SMESHDS_Document::~DriverMED_R_SMESHDS_Document()
{
; ;
} }
@ -47,13 +51,14 @@ DriverMED_R_SMESHDS_Document::~DriverMED_R_SMESHDS_Document() {
// myFile = aFile; // myFile = aFile;
//} //}
void DriverMED_R_SMESHDS_Document::Read() { void DriverMED_R_SMESHDS_Document::Read()
{
med_err ret = 0; med_err ret = 0;
med_idt fid; med_idt fid;
med_int nmaa; med_int nmaa;
Standard_Integer myMeshId; int myMeshId;
//string myFile = string("/home/home_users/cai/projects/salome_prev04/SALOME_ROOT/data/fra1.med"); //string myFile = string("/home/home_users/cai/projects/salome_prev04/SALOME_ROOT/data/fra1.med");
@ -82,16 +87,16 @@ void DriverMED_R_SMESHDS_Document::Read() {
string myClass = string("SMESHDS_Mesh"); string myClass = string("SMESHDS_Mesh");
string myExtension = string("MED"); string myExtension = string("MED");
for (int meshIt = 1; meshIt <= nmaa; meshIt++)
for (int meshIt=1;meshIt<=nmaa;meshIt++) { {
myMeshId = myDocument->NewMesh(); myMeshId = myDocument->NewMesh();
printf("MeshId = %d\n", myMeshId); printf("MeshId = %d\n", myMeshId);
Handle(SMDS_Mesh) myMesh = myDocument->GetMesh(myMeshId); SMDS_Mesh * myMesh = myDocument->GetMesh(myMeshId);
SCRUTE(myMesh); SCRUTE(myMesh);
// Handle (SMDS_Mesh) MMM =......... // Handle (SMDS_Mesh) MMM =.........
//ex Handle(SMESHDS_Mesh) myMesh2 =Handle(SMESHDS_Mesh)::DownCast(MMM); //ex SMESHDS_Mesh * myMesh2 =SMESHDS_Mesh *::DownCast(MMM);
DriverMED_R_SMESHDS_Mesh *myReader = new DriverMED_R_SMESHDS_Mesh; DriverMED_R_SMESHDS_Mesh *myReader = new DriverMED_R_SMESHDS_Mesh;
@ -112,7 +117,7 @@ void DriverMED_R_SMESHDS_Document::Read() {
ret = MEDfermer(fid); ret = MEDfermer(fid);
if (ret != 0) if (ret != 0)
fprintf(stderr,">> ERREUR : erreur a la fermeture du fichier %s\n",file2Read); fprintf(stderr, ">> ERREUR : erreur a la fermeture du fichier %s\n",
file2Read);
} }

View File

@ -31,32 +31,39 @@ using namespace std;
#include <stdlib.h> #include <stdlib.h>
DriverMED_R_SMESHDS_Mesh::DriverMED_R_SMESHDS_Mesh() { DriverMED_R_SMESHDS_Mesh::DriverMED_R_SMESHDS_Mesh()
{
myFileId = -1; myFileId = -1;
} }
DriverMED_R_SMESHDS_Mesh::~DriverMED_R_SMESHDS_Mesh() { DriverMED_R_SMESHDS_Mesh::~DriverMED_R_SMESHDS_Mesh()
{
; ;
} }
void DriverMED_R_SMESHDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) { void DriverMED_R_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
//myMesh = Handle(SMESHDS_Mesh)::DownCast(aMesh); {
//myMesh = SMESHDS_Mesh *::DownCast(aMesh);
myMesh = aMesh; myMesh = aMesh;
} }
void DriverMED_R_SMESHDS_Mesh::SetFile(string aFile) { void DriverMED_R_SMESHDS_Mesh::SetFile(string aFile)
{
myFile = aFile; myFile = aFile;
} }
void DriverMED_R_SMESHDS_Mesh::SetFileId(med_idt aFileId) { void DriverMED_R_SMESHDS_Mesh::SetFileId(med_idt aFileId)
{
myFileId = aFileId; myFileId = aFileId;
} }
void DriverMED_R_SMESHDS_Mesh::SetMeshId(int aMeshId) { void DriverMED_R_SMESHDS_Mesh::SetMeshId(int aMeshId)
{
myMeshId = aMeshId; myMeshId = aMeshId;
} }
void DriverMED_R_SMESHDS_Mesh::Read() { void DriverMED_R_SMESHDS_Mesh::Read()
{
string myClass = string("SMDS_Mesh"); string myClass = string("SMDS_Mesh");
string myExtension = string("MED"); string myExtension = string("MED");
@ -72,7 +79,8 @@ void DriverMED_R_SMESHDS_Mesh::Read() {
} }
void DriverMED_R_SMESHDS_Mesh::Add() { void DriverMED_R_SMESHDS_Mesh::Add()
{
string myClass = string("SMDS_Mesh"); string myClass = string("SMDS_Mesh");
string myExtension = string("MED"); string myExtension = string("MED");
@ -89,13 +97,14 @@ void DriverMED_R_SMESHDS_Mesh::Add() {
} }
void DriverMED_R_SMESHDS_Mesh::ReadMySelf() { void DriverMED_R_SMESHDS_Mesh::ReadMySelf()
{
med_err ret = 0; med_err ret = 0;
int i, j, k, l; int i, j, k, l;
int numero; int numero;
char message[200]; char message[200];
Standard_Boolean ok; bool ok;
/* nombre d'objets MED */ /* nombre d'objets MED */
char nom_universel[MED_TAILLE_LNOM + 1]; char nom_universel[MED_TAILLE_LNOM + 1];
med_int long_fichier_en_tete; med_int long_fichier_en_tete;
@ -131,15 +140,18 @@ void DriverMED_R_SMESHDS_Mesh::ReadMySelf() {
med_booleen inoele, inuele; med_booleen inoele, inuele;
med_connectivite typ_con; med_connectivite typ_con;
med_geometrie_element typgeo; med_geometrie_element typgeo;
med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] = {MED_POINT1,MED_SEG2, med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] =
{ MED_POINT1, MED_SEG2,
MED_SEG3, MED_TRIA3, MED_SEG3, MED_TRIA3,
MED_TRIA6, MED_QUAD4, MED_TRIA6, MED_QUAD4,
MED_QUAD8, MED_TETRA4, MED_QUAD8, MED_TETRA4,
MED_TETRA10, MED_HEXA8, MED_TETRA10, MED_HEXA8,
MED_HEXA20, MED_PENTA6, MED_HEXA20, MED_PENTA6,
MED_PENTA15, MED_PYRA5, MED_PENTA15, MED_PYRA5,
MED_PYRA13}; MED_PYRA13
med_int desmai[MED_NBR_GEOMETRIE_MAILLE] = {0,2,3,3,3,4,4,4,4,6,6,5,5,5,5}; };
med_int desmai[MED_NBR_GEOMETRIE_MAILLE] =
{ 0, 2, 3, 3, 3, 4, 4, 4, 4, 6, 6, 5, 5, 5, 5 };
med_int nmailles[MED_NBR_GEOMETRIE_MAILLE]; med_int nmailles[MED_NBR_GEOMETRIE_MAILLE];
char nommai[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = { "MED_POINT1", char nommai[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = { "MED_POINT1",
"MED_SEG2", "MED_SEG2",
@ -155,17 +167,24 @@ void DriverMED_R_SMESHDS_Mesh::ReadMySelf() {
"MED_PENTA6", "MED_PENTA6",
"MED_PENTA15", "MED_PENTA15",
"MED_PYRA5", "MED_PYRA5",
"MED_PYRA13"}; "MED_PYRA13"
med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] = {MED_TRIA3,MED_TRIA6, };
MED_QUAD4,MED_QUAD8}; med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] =
{ MED_TRIA3, MED_TRIA6,
MED_QUAD4, MED_QUAD8
};
med_int desfac[MED_NBR_GEOMETRIE_FACE] = { 3, 3, 4, 4 }; med_int desfac[MED_NBR_GEOMETRIE_FACE] = { 3, 3, 4, 4 };
med_int nfaces[MED_NBR_GEOMETRIE_FACE]; med_int nfaces[MED_NBR_GEOMETRIE_FACE];
char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM+1] = {"MED_TRIA3","MED_TRIA6", char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM + 1] =
"MED_QUAD4","MED_QUAD8"}; { "MED_TRIA3", "MED_TRIA6",
med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] = {MED_SEG2,MED_SEG3}; "MED_QUAD4", "MED_QUAD8"
};
med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] =
{ MED_SEG2, MED_SEG3 };
med_int desare[MED_NBR_GEOMETRIE_ARETE] = { 2, 3 }; med_int desare[MED_NBR_GEOMETRIE_ARETE] = { 2, 3 };
med_int naretes[MED_NBR_GEOMETRIE_ARETE]; med_int naretes[MED_NBR_GEOMETRIE_ARETE];
char nomare[MED_NBR_GEOMETRIE_ARETE] [MED_TAILLE_NOM+1] = {"MED_SEG2","MED_SEG3"}; char nomare[MED_NBR_GEOMETRIE_ARETE][MED_TAILLE_NOM + 1] =
{ "MED_SEG2", "MED_SEG3" };
/* familles */ /* familles */
med_int nfam; med_int nfam;
med_int natt, ngro; med_int natt, ngro;
@ -193,7 +212,8 @@ void DriverMED_R_SMESHDS_Mesh::ReadMySelf() {
myFileId = MEDouvrir(file2Read, MED_LECT); myFileId = MEDouvrir(file2Read, MED_LECT);
if (myFileId < 0) if (myFileId < 0)
{ {
fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read); fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n",
file2Read);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
numero = 1; numero = 1;
@ -207,7 +227,7 @@ void DriverMED_R_SMESHDS_Mesh::ReadMySelf() {
mode_coo = MED_FULL_INTERLACE; mode_coo = MED_FULL_INTERLACE;
mdim = 3; mdim = 3;
Handle(SMESHDS_Mesh) mySMESHDSMesh = Handle(SMESHDS_Mesh)::DownCast(myMesh); SMESHDS_Mesh * mySMESHDSMesh = dynamic_cast<SMESHDS_Mesh *>(myMesh);
//TopoDS_Shape myShape = mySMESHDSMesh->ShapeToMesh(); //TopoDS_Shape myShape = mySMESHDSMesh->ShapeToMesh();
@ -220,18 +240,19 @@ void DriverMED_R_SMESHDS_Mesh::ReadMySelf() {
/* lecture du nom et de la dimension du maillage */ /* lecture du nom et de la dimension du maillage */
/*! fprintf(stdout,"%d %d\n",myFileId,numero); /*! fprintf(stdout,"%d %d\n",myFileId,numero);
ret = MEDmaaInfo(myFileId,numero,nommaa,&mdim); * ret = MEDmaaInfo(myFileId,numero,nommaa,&mdim);
fprintf(stdout,"%d\n",ret); * fprintf(stdout,"%d\n",ret);
if (ret < 0) * if (ret < 0)
{ * {
fprintf(stderr,">> ERREUR : lecture du nom du maillage \n"); * fprintf(stderr,">> ERREUR : lecture du nom du maillage \n");
exit(EXIT_FAILURE); * exit(EXIT_FAILURE);
} * }
fprintf(stdout,"- Nom du maillage : <<%s>>\n",nommaa); * fprintf(stdout,"- Nom du maillage : <<%s>>\n",nommaa);
fprintf(stdout,"- Dimension du maillage : %d\n",mdim); * fprintf(stdout,"- Dimension du maillage : %d\n",mdim);
*/ */
/* Combien de noeuds ? */ /* Combien de noeuds ? */
nnoe = MEDnEntMaa(myFileId,nommaa,MED_COOR,MED_NOEUD,MED_POINT1,typ_con); nnoe =
MEDnEntMaa(myFileId, nommaa, MED_COOR, MED_NOEUD, MED_POINT1, typ_con);
if (nnoe < 0) if (nnoe < 0)
{ {
fprintf(stderr, ">> ERREUR : lecture du nombre de noeuds \n"); fprintf(stderr, ">> ERREUR : lecture du nombre de noeuds \n");
@ -242,14 +263,16 @@ void DriverMED_R_SMESHDS_Mesh::ReadMySelf() {
/* Combien de mailles, faces ou aretes ? */ /* Combien de mailles, faces ou aretes ? */
for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++) for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
{ {
nmailles[i] = MEDnEntMaa(myFileId,nommaa,MED_CONN,MED_MAILLE,typmai[i], nmailles[i] =
MEDnEntMaa(myFileId, nommaa, MED_CONN, MED_MAILLE, typmai[i],
typ_con); typ_con);
if (nmailles[i] < 0) if (nmailles[i] < 0)
{ {
fprintf(stderr, ">> ERREUR : lecture du nombre de mailles \n"); fprintf(stderr, ">> ERREUR : lecture du nombre de mailles \n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
fprintf (stdout,"- Nombre de mailles de type %s : %d \n",nommai[i],nmailles[i]); fprintf(stdout, "- Nombre de mailles de type %s : %d \n", nommai[i],
nmailles[i]);
} }
for (i = 0; i < MED_NBR_GEOMETRIE_FACE; i++) for (i = 0; i < MED_NBR_GEOMETRIE_FACE; i++)
@ -261,19 +284,22 @@ void DriverMED_R_SMESHDS_Mesh::ReadMySelf() {
fprintf(stderr, ">> ERREUR : lecture du nombre de faces \n"); fprintf(stderr, ">> ERREUR : lecture du nombre de faces \n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
fprintf (stdout,"- Nombre de faces de type %s : %d \n",nomfac[i],nfaces[i]); fprintf(stdout, "- Nombre de faces de type %s : %d \n", nomfac[i],
nfaces[i]);
} }
for (i = 0; i < MED_NBR_GEOMETRIE_ARETE; i++) for (i = 0; i < MED_NBR_GEOMETRIE_ARETE; i++)
{ {
naretes[i] = MEDnEntMaa(myFileId,nommaa,MED_CONN,MED_ARETE,typare[i], naretes[i] =
MEDnEntMaa(myFileId, nommaa, MED_CONN, MED_ARETE, typare[i],
typ_con); typ_con);
if (naretes[i] < 0) if (naretes[i] < 0)
{ {
fprintf(stderr, ">> ERREUR : lecture du nombre d'aretes \n"); fprintf(stderr, ">> ERREUR : lecture du nombre d'aretes \n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
fprintf (stdout,"- Nombre d'aretes de type %s : %d \n",nomare[i],naretes[i]); fprintf(stdout, "- Nombre d'aretes de type %s : %d \n", nomare[i],
naretes[i]);
} }
/* nombre de familles */ /* nombre de familles */
@ -296,36 +322,41 @@ void DriverMED_R_SMESHDS_Mesh::ReadMySelf() {
/* Allocations memoires */ /* Allocations memoires */
/* table des coordonnees /* table des coordonnees
profil : (dimension * nombre de noeuds ) */ * profil : (dimension * nombre de noeuds ) */
coo = (med_float *) malloc(sizeof(med_float) * nnoe * mdim); coo = (med_float *) malloc(sizeof(med_float) * nnoe * mdim);
/* table des numeros, des numeros de familles des noeuds /* table des numeros, des numeros de familles des noeuds
profil : (nombre de noeuds) */ * profil : (nombre de noeuds) */
numnoe = (med_int *) malloc(sizeof(med_int) * nnoe); numnoe = (med_int *) malloc(sizeof(med_int) * nnoe);
nufano = (med_int *) malloc(sizeof(med_int) * nnoe); nufano = (med_int *) malloc(sizeof(med_int) * nnoe);
/* table des noms des noeuds /* table des noms des noeuds
profil : (nnoe*MED_TAILLE_PNOM+1) */ * profil : (nnoe*MED_TAILLE_PNOM+1) */
nomnoe = (char *)malloc(MED_TAILLE_PNOM * nnoe + 1); nomnoe = (char *)malloc(MED_TAILLE_PNOM * nnoe + 1);
/* lecture des noeuds : /* lecture des noeuds :
- coordonnees * - coordonnees
- noms (optionnel dans un fichier MED) * - noms (optionnel dans un fichier MED)
- numeros (optionnel dans un fichier MED) * - numeros (optionnel dans un fichier MED)
- numeros des familles */ * - numeros des familles */
ret = MEDnoeudsLire(myFileId, nommaa, mdim, coo, mode_coo, &rep, ret = MEDnoeudsLire(myFileId, nommaa, mdim, coo, mode_coo, &rep,
nomcoo,unicoo,nomnoe,&inonoe,numnoe,&inunoe, nomcoo, unicoo, nomnoe, &inonoe, numnoe, &inunoe, nufano, nnoe);
nufano,nnoe);
if (ret < 0) if (ret < 0)
strcpy(message, ">> ERREUR : lecture des noeuds \n"); strcpy(message, ">> ERREUR : lecture des noeuds \n");
if (inunoe) { if (inunoe)
for (int i=0;i<nnoe;i++) { {
ok = mySMESHDSMesh->AddNodeWithID(coo[i*3],coo[i*3+1],coo[i*3+2],numnoe[i]); for (int i = 0; i < nnoe; i++)
{
ok = mySMESHDSMesh->AddNodeWithID(coo[i * 3], coo[i * 3 + 1],
coo[i * 3 + 2], numnoe[i]);
//fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],coo[i*3+2]); //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],coo[i*3+2]);
} }
} }
else { else
for (int i=0;i<nnoe;i++) { {
ok = mySMESHDSMesh->AddNodeWithID(coo[i*3],coo[i*3+1],coo[i*3+2],i+1); for (int i = 0; i < nnoe; i++)
{
ok = mySMESHDSMesh->AddNodeWithID(coo[i * 3], coo[i * 3 + 1],
coo[i * 3 + 2], i + 1);
//fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],i); //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],i);
family[*(nufano + i)].push_back(numnoe[i]); family[*(nufano + i)].push_back(numnoe[i]);
} }
@ -375,72 +406,119 @@ void DriverMED_R_SMESHDS_Mesh::ReadMySelf() {
taille * nmailles[i]); taille * nmailles[i]);
nomele = (char *)malloc(sizeof(char) * MED_TAILLE_PNOM * nomele = (char *)malloc(sizeof(char) * MED_TAILLE_PNOM *
nmailles[i] + 1); nmailles[i] + 1);
numele = (med_int*)malloc(sizeof(med_int)* numele = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
nmailles[i]); nufael = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
nufael = (med_int*)malloc(sizeof(med_int)*
nmailles[i]);
/* lecture des données */ /* lecture des données */
ret = MEDelementsLire(myFileId,nommaa,mdim,connectivite,mode_coo, ret =
nomele,&inoele,numele,&inuele,nufael, MEDelementsLire(myFileId, nommaa, mdim, connectivite,
nmailles[i],MED_MAILLE,typmai[i], mode_coo, nomele, &inoele, numele, &inuele, nufael,
typ_con); nmailles[i], MED_MAILLE, typmai[i], typ_con);
switch (typmai[i]) switch (typmai[i])
{ {
case MED_TRIA3 : { case MED_TRIA3:
if (inuele) { {
for (j=0;j<nmailles[i];j++) { if (inuele)
{
for (j = 0; j < nmailles[i]; j++)
{
elem_id = *(numele + j); elem_id = *(numele + j);
ok = mySMESHDSMesh->AddFaceWithID(*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),elem_id); ok = mySMESHDSMesh->AddFaceWithID(*(connectivite +
j * (taille - nsup)),
*(connectivite + j * (taille - nsup) + 1),
*(connectivite + j * (taille - nsup) + 2),
elem_id);
//fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2)); //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2));
} }
} }
else { else
for (j=0;j<nmailles[i];j++) { {
for (j = 0; j < nmailles[i]; j++)
{
cmpt++; cmpt++;
ok = mySMESHDSMesh->AddFaceWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),cmpt); ok = mySMESHDSMesh->AddFaceWithID(*(connectivite +
j * (taille)),
*(connectivite + j * (taille) + 1),
*(connectivite + j * (taille) + 2), cmpt);
//fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2)); //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2));
} }
} }
break; break;
} }
case MED_QUAD4 : { case MED_QUAD4:
if (inuele) { {
for (j=0;j<nmailles[i];j++) { if (inuele)
{
for (j = 0; j < nmailles[i]; j++)
{
elem_id = *(numele + j); elem_id = *(numele + j);
ok = mySMESHDSMesh->AddFaceWithID(*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),elem_id); ok = mySMESHDSMesh->AddFaceWithID(*(connectivite +
j * (taille - nsup)),
*(connectivite + j * (taille - nsup) + 1),
*(connectivite + j * (taille - nsup) + 2),
*(connectivite + j * (taille - nsup) + 3),
elem_id);
//fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3)); //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3));
} }
} }
else { else
for (j=0;j<nmailles[i];j++) { {
for (j = 0; j < nmailles[i]; j++)
{
cmpt++; cmpt++;
ok = myMesh->AddFaceWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),cmpt); ok = myMesh->AddFaceWithID(*(connectivite +
j * (taille)),
*(connectivite + j * (taille) + 1),
*(connectivite + j * (taille) + 2),
*(connectivite + j * (taille) + 3), cmpt);
//fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3)); //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3));
} }
} }
break; break;
} }
case MED_HEXA8 : { case MED_HEXA8:
if (inuele) { {
for (j=0;j<nmailles[i];j++) { if (inuele)
{
for (j = 0; j < nmailles[i]; j++)
{
elem_id = *(numele + j); elem_id = *(numele + j);
ok = mySMESHDSMesh->AddVolumeWithID(*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),*(connectivite+j*(taille-nsup)+4),*(connectivite+j*(taille-nsup)+5),*(connectivite+j*(taille-nsup)+6),*(connectivite+j*(taille-nsup)+7),elem_id); ok = mySMESHDSMesh->AddVolumeWithID(*(connectivite +
j * (taille - nsup)),
*(connectivite + j * (taille - nsup) + 1),
*(connectivite + j * (taille - nsup) + 2),
*(connectivite + j * (taille - nsup) + 3),
*(connectivite + j * (taille - nsup) + 4),
*(connectivite + j * (taille - nsup) + 5),
*(connectivite + j * (taille - nsup) + 6),
*(connectivite + j * (taille - nsup) + 7),
elem_id);
//fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),*(connectivite+j*(taille-nsup)+4),*(connectivite+j*(taille-nsup)+5),*(connectivite+j*(taille-nsup)+6),*(connectivite+j*(taille-nsup)+7)); //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),*(connectivite+j*(taille-nsup)+4),*(connectivite+j*(taille-nsup)+5),*(connectivite+j*(taille-nsup)+6),*(connectivite+j*(taille-nsup)+7));
} }
} }
else { else
for (j=0;j<nmailles[i];j++) { {
for (j = 0; j < nmailles[i]; j++)
{
cmpt++; cmpt++;
ok = mySMESHDSMesh->AddVolumeWithID(*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7),cmpt); ok = mySMESHDSMesh->AddVolumeWithID(*(connectivite +
j * (taille)),
*(connectivite + j * (taille) + 1),
*(connectivite + j * (taille) + 2),
*(connectivite + j * (taille) + 3),
*(connectivite + j * (taille) + 4),
*(connectivite + j * (taille) + 5),
*(connectivite + j * (taille) + 6),
*(connectivite + j * (taille) + 7), cmpt);
//fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7)); //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7));
} }
} }
break; break;
} }
default : { default:
{
break; break;
} }
} }
@ -489,7 +567,8 @@ void DriverMED_R_SMESHDS_Mesh::ReadMySelf() {
} }
if (ret == 0) if (ret == 0)
fprintf(stdout,"- Famille %d a %d attributs et %d groupes \n",i+1,natt,ngro); fprintf(stdout, "- Famille %d a %d attributs et %d groupes \n",
i + 1, natt, ngro);
/* nom,numero,attributs,groupes */ /* nom,numero,attributs,groupes */
if (ret == 0) if (ret == 0)
@ -498,23 +577,27 @@ void DriverMED_R_SMESHDS_Mesh::ReadMySelf() {
attval = (med_int *) malloc(sizeof(med_int) * natt); attval = (med_int *) malloc(sizeof(med_int) * natt);
attdes = (char *)malloc(MED_TAILLE_DESC * natt + 1); attdes = (char *)malloc(MED_TAILLE_DESC * natt + 1);
gro = (char *)malloc(MED_TAILLE_LNOM * ngro + 1); gro = (char *)malloc(MED_TAILLE_LNOM * ngro + 1);
ret = MEDfamInfo(myFileId,nommaa,i+1,nomfam,&numfam,attide,attval, ret =
attdes,&natt,gro,&ngro); MEDfamInfo(myFileId, nommaa, i + 1, nomfam, &numfam, attide,
attval, attdes, &natt, gro, &ngro);
fam = string(nomfam); fam = string(nomfam);
fam_type = fam.substr(1, 1); fam_type = fam.substr(1, 1);
fam_id = fam.substr(2, 1); fam_id = fam.substr(2, 1);
if ((fam_type==string("V"))||(fam_type==string("A"))||(fam_type==string("F"))) if ((fam_type == string("V")) || (fam_type == string("A")) ||
(fam_type == string("F")))
LinkMeshToShape(fam_type, fam_id, family[i]); LinkMeshToShape(fam_type, fam_id, family[i]);
fprintf(stdout," - Famille de nom %s et de numero %d : \n",nomfam,numfam); fprintf(stdout, " - Famille de nom %s et de numero %d : \n",
nomfam, numfam);
fprintf(stdout, " - Attributs : \n"); fprintf(stdout, " - Attributs : \n");
for (j = 0; j < natt; j++) for (j = 0; j < natt; j++)
{ {
strncpy(str1,attdes+j*MED_TAILLE_DESC,MED_TAILLE_DESC); strncpy(str1, attdes + j * MED_TAILLE_DESC,
MED_TAILLE_DESC);
str1[MED_TAILLE_DESC] = '\0'; str1[MED_TAILLE_DESC] = '\0';
fprintf(stdout," ide = %d - val = %d - des = %s\n",*(attide+j), fprintf(stdout, " ide = %d - val = %d - des = %s\n",
*(attval+j),str1); *(attide + j), *(attval + j), str1);
} }
free(attide); free(attide);
free(attval); free(attval);
@ -535,37 +618,39 @@ void DriverMED_R_SMESHDS_Mesh::ReadMySelf() {
} }
void DriverMED_R_SMESHDS_Mesh::LinkMeshToShape(string fam_type, string fam_id, vector<int> myNodes) { void DriverMED_R_SMESHDS_Mesh::LinkMeshToShape(string fam_type, string fam_id,
vector < int >myNodes)
{
Handle(SMESHDS_Mesh) mySMESHDSMesh = Handle(SMESHDS_Mesh)::DownCast(myMesh); SMESHDS_Mesh * mySMESHDSMesh = dynamic_cast<SMESHDS_Mesh *>(myMesh);
int id = atoi(fam_id.c_str()); int id = atoi(fam_id.c_str());
if (fam_type==string("V")) { //Linked to a vertex if (fam_type == string("V"))
for (int i=0;i<myNodes.size();i++) { { //Linked to a vertex
Handle(SMDS_MeshElement) elem = mySMESHDSMesh->FindNode(myNodes[i]); for (int i = 0; i < myNodes.size(); i++)
const Handle(SMDS_MeshNode)& node = mySMESHDSMesh->GetNode(1,elem); {
const SMDS_MeshNode * node = mySMESHDSMesh->FindNode(myNodes[i]);
//const TopoDS_Vertex& S;//le recuperer !!! //const TopoDS_Vertex& S;//le recuperer !!!
//mySMESHDSMesh->SetNodeOnVertex (node,S); //mySMESHDSMesh->SetNodeOnVertex (node,S);
} }
} }
else else if (fam_type == string("E"))
if (fam_type==string("E")) { //Linked to an edge { //Linked to an edge
for (int i=0;i<myNodes.size();i++) { for (int i = 0; i < myNodes.size(); i++)
Handle(SMDS_MeshElement) elem = mySMESHDSMesh->FindNode(myNodes[i]); {
const Handle(SMDS_MeshNode)& node = mySMESHDSMesh->GetNode(1,elem); const SMDS_MeshNode * node = mySMESHDSMesh->FindNode(myNodes[i]);
//const TopoDS_Edge& S;//le recuperer !!! //const TopoDS_Edge& S;//le recuperer !!!
//mySMESHDSMesh->SetNodeOnEdge (node,S); //mySMESHDSMesh->SetNodeOnEdge (node,S);
} }
} }
else else if (fam_type == string("F"))
if (fam_type==string("F")) { //Linked to a face { //Linked to a face
for (int i=0;i<myNodes.size();i++) { for (int i = 0; i < myNodes.size(); i++)
Handle(SMDS_MeshElement) elem = mySMESHDSMesh->FindNode(myNodes[i]); {
const Handle(SMDS_MeshNode)& node = mySMESHDSMesh->GetNode(1,elem); const SMDS_MeshNode * node = mySMESHDSMesh->FindNode(myNodes[i]);
//const TopoDS_Face& S;//le recuperer !!! //const TopoDS_Face& S;//le recuperer !!!
//mySMESHDSMesh->SetNodeOnFace (node,S); //mySMESHDSMesh->SetNodeOnFace (node,S);
} }
} }
} }

View File

@ -36,25 +36,24 @@ extern "C"
#include <med.h> #include <med.h>
} }
class DriverMED_R_SMESHDS_Mesh : public Mesh_Reader { class DriverMED_R_SMESHDS_Mesh:public Mesh_Reader
{
public : public:DriverMED_R_SMESHDS_Mesh();
DriverMED_R_SMESHDS_Mesh();
~DriverMED_R_SMESHDS_Mesh(); ~DriverMED_R_SMESHDS_Mesh();
void Read(); void Read();
void ReadMySelf(); void ReadMySelf();
void Add(); void Add();
void SetMesh(Handle(SMDS_Mesh)& aMesh); void SetMesh(SMDS_Mesh * aMesh);
void SetFile(string); void SetFile(string);
void SetFileId(med_idt); void SetFileId(med_idt);
void SetMeshId(int); void SetMeshId(int);
void LinkMeshToShape(string, string, vector < int >); void LinkMeshToShape(string, string, vector < int >);
private : private: SMDS_Mesh * myMesh;
Handle_SMDS_Mesh myMesh;
string myFile; string myFile;
med_idt myFileId; med_idt myFileId;
int myMeshId; int myMeshId;

View File

@ -29,48 +29,56 @@ using namespace std;
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_MeshFacesIterator.hxx"
#include "SMDS_MeshNodesIterator.hxx"
#include "SMDS_MeshVolumesIterator.hxx"
#include "utilities.h" #include "utilities.h"
#include <vector> #include <vector>
DriverMED_W_SMDS_Mesh::DriverMED_W_SMDS_Mesh() { DriverMED_W_SMDS_Mesh::DriverMED_W_SMDS_Mesh()
{
; ;
} }
DriverMED_W_SMDS_Mesh::~DriverMED_W_SMDS_Mesh() { DriverMED_W_SMDS_Mesh::~DriverMED_W_SMDS_Mesh()
{
; ;
} }
void DriverMED_W_SMDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) { void DriverMED_W_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
{
myMesh = aMesh; myMesh = aMesh;
} }
void DriverMED_W_SMDS_Mesh::SetFile(string aFile) { void DriverMED_W_SMDS_Mesh::SetFile(string aFile)
{
myFile = aFile; myFile = aFile;
} }
void DriverMED_W_SMDS_Mesh::SetFileId(med_idt aFileId) { void DriverMED_W_SMDS_Mesh::SetFileId(med_idt aFileId)
{
myFileId = aFileId; myFileId = aFileId;
} }
void DriverMED_W_SMDS_Mesh::SetMeshId(int aMeshId) { void DriverMED_W_SMDS_Mesh::SetMeshId(int aMeshId)
{
myMeshId = aMeshId; myMeshId = aMeshId;
} }
void DriverMED_W_SMDS_Mesh::Add() { void DriverMED_W_SMDS_Mesh::Add()
{
; ;
} }
void DriverMED_W_SMDS_Mesh::Write() { void DriverMED_W_SMDS_Mesh::Write()
{
med_err ret = 0; med_err ret = 0;
int i, j, k, l; int i, j, k, l;
int numero; int numero;
char message[200]; char message[200];
Standard_Boolean ok; bool ok;
/* nombre d'objets MED */ /* nombre d'objets MED */
char nom_universel[MED_TAILLE_LNOM + 1]; char nom_universel[MED_TAILLE_LNOM + 1];
med_int long_fichier_en_tete; med_int long_fichier_en_tete;
@ -106,15 +114,18 @@ void DriverMED_W_SMDS_Mesh::Write() {
med_booleen inoele, inuele; med_booleen inoele, inuele;
med_connectivite typ_con; med_connectivite typ_con;
med_geometrie_element typgeo; med_geometrie_element typgeo;
med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] = {MED_POINT1,MED_SEG2, med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] =
{ MED_POINT1, MED_SEG2,
MED_SEG3, MED_TRIA3, MED_SEG3, MED_TRIA3,
MED_TRIA6, MED_QUAD4, MED_TRIA6, MED_QUAD4,
MED_QUAD8, MED_TETRA4, MED_QUAD8, MED_TETRA4,
MED_TETRA10, MED_HEXA8, MED_TETRA10, MED_HEXA8,
MED_HEXA20, MED_PENTA6, MED_HEXA20, MED_PENTA6,
MED_PENTA15, MED_PYRA5, MED_PENTA15, MED_PYRA5,
MED_PYRA13}; MED_PYRA13
med_int desmai[MED_NBR_GEOMETRIE_MAILLE] = {0,2,3,3,3,4,4,4,4,6,6,5,5,5,5}; };
med_int desmai[MED_NBR_GEOMETRIE_MAILLE] =
{ 0, 2, 3, 3, 3, 4, 4, 4, 4, 6, 6, 5, 5, 5, 5 };
med_int nmailles[MED_NBR_GEOMETRIE_MAILLE]; med_int nmailles[MED_NBR_GEOMETRIE_MAILLE];
char nommai[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = { "MED_POINT1", char nommai[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = { "MED_POINT1",
"MED_SEG2", "MED_SEG2",
@ -130,17 +141,24 @@ void DriverMED_W_SMDS_Mesh::Write() {
"MED_PENTA6", "MED_PENTA6",
"MED_PENTA15", "MED_PENTA15",
"MED_PYRA5", "MED_PYRA5",
"MED_PYRA13"}; "MED_PYRA13"
med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] = {MED_TRIA3,MED_TRIA6, };
MED_QUAD4,MED_QUAD8}; med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] =
{ MED_TRIA3, MED_TRIA6,
MED_QUAD4, MED_QUAD8
};
med_int desfac[MED_NBR_GEOMETRIE_FACE] = { 3, 3, 4, 4 }; med_int desfac[MED_NBR_GEOMETRIE_FACE] = { 3, 3, 4, 4 };
med_int nfaces[MED_NBR_GEOMETRIE_FACE]; med_int nfaces[MED_NBR_GEOMETRIE_FACE];
char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM+1] = {"MED_TRIA3","MED_TRIA6", char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM + 1] =
"MED_QUAD4","MED_QUAD8"}; { "MED_TRIA3", "MED_TRIA6",
med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] = {MED_SEG2,MED_SEG3}; "MED_QUAD4", "MED_QUAD8"
};
med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] =
{ MED_SEG2, MED_SEG3 };
med_int desare[MED_NBR_GEOMETRIE_ARETE] = { 2, 3 }; med_int desare[MED_NBR_GEOMETRIE_ARETE] = { 2, 3 };
med_int naretes[MED_NBR_GEOMETRIE_ARETE]; med_int naretes[MED_NBR_GEOMETRIE_ARETE];
char nomare[MED_NBR_GEOMETRIE_ARETE] [MED_TAILLE_NOM+1] = {"MED_SEG2","MED_SEG3"}; char nomare[MED_NBR_GEOMETRIE_ARETE][MED_TAILLE_NOM + 1] =
{ "MED_SEG2", "MED_SEG3" };
/* familles */ /* familles */
med_int nfam; med_int nfam;
med_int natt, ngro; med_int natt, ngro;
@ -155,12 +173,12 @@ void DriverMED_W_SMDS_Mesh::Write() {
* OUVERTURE DU FICHIER EN ECRITURE * * OUVERTURE DU FICHIER EN ECRITURE *
****************************************************************************/ ****************************************************************************/
/*! char* file2Read = (char*)myFile.c_str(); /*! char* file2Read = (char*)myFile.c_str();
myFileId = MEDouvrir(file2Read,MED_REMP); * myFileId = MEDouvrir(file2Read,MED_REMP);
if (myFileId < 0) * if (myFileId < 0)
{ * {
fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read); * fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read);
exit(EXIT_FAILURE); * exit(EXIT_FAILURE);
} * }
*/ */
typ_con = MED_NOD; typ_con = MED_NOD;
mode_coo = MED_FULL_INTERLACE; mode_coo = MED_FULL_INTERLACE;
@ -182,7 +200,6 @@ void DriverMED_W_SMDS_Mesh::Write() {
ret = MEDmaaCr(myFileId, nommaa, mdim); ret = MEDmaaCr(myFileId, nommaa, mdim);
printf("%d\n", ret); printf("%d\n", ret);
/* Combien de noeuds ? */ /* Combien de noeuds ? */
nnoe = myMesh->NbNodes(); nnoe = myMesh->NbNodes();
//SCRUTE(nnoe); //SCRUTE(nnoe);
@ -190,8 +207,8 @@ void DriverMED_W_SMDS_Mesh::Write() {
for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++) for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
nmailles[i] = 0; nmailles[i] = 0;
SMDS_MeshFacesIterator itFaces(myMesh); SMDS_Iterator<const SMDS_MeshFace *> * itFaces=myMesh->facesIterator();
Standard_Integer nb_of_nodes, nb_of_faces; int nb_of_nodes, nb_of_faces;
nb_of_faces = myMesh->NbFaces(); nb_of_faces = myMesh->NbFaces();
//SCRUTE(nb_of_faces); //SCRUTE(nb_of_faces);
@ -201,25 +218,30 @@ void DriverMED_W_SMDS_Mesh::Write() {
//vector<Integer_vector> elem_Id; //vector<Integer_vector> elem_Id;
//elem_Id.resize(MED_NBR_GEOMETRIE_MAILLE); //elem_Id.resize(MED_NBR_GEOMETRIE_MAILLE);
for (;itFaces.More();itFaces.Next()) { while(itFaces->more())
const Handle(SMDS_MeshElement)& elem = itFaces.Value(); {
const SMDS_MeshFace * elem = itFaces->next();
nb_of_nodes = elem->NbNodes(); nb_of_nodes = elem->NbNodes();
switch (nb_of_nodes) { switch (nb_of_nodes)
case 3 : { {
case 3:
{
//elem_Id[3][nmailles[3]] = elem->GetID(); //elem_Id[3][nmailles[3]] = elem->GetID();
elem_Id[3].push_back(elem->GetID()); elem_Id[3].push_back(elem->GetID());
nmailles[3]++; nmailles[3]++;
break; break;
} }
case 4 : { case 4:
{
//elem_Id[5][nmailles[5]] = elem->GetID(); //elem_Id[5][nmailles[5]] = elem->GetID();
elem_Id[5].push_back(elem->GetID()); elem_Id[5].push_back(elem->GetID());
nmailles[5]++; nmailles[5]++;
break; break;
} }
case 6 : { case 6:
{
//elem_Id[4][nmailles[4]] = elem->GetID(); //elem_Id[4][nmailles[4]] = elem->GetID();
elem_Id[4].push_back(elem->GetID()); elem_Id[4].push_back(elem->GetID());
nmailles[4]++; nmailles[4]++;
@ -229,14 +251,16 @@ void DriverMED_W_SMDS_Mesh::Write() {
} }
SMDS_MeshVolumesIterator itVolumes(myMesh); SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=myMesh->volumesIterator();
while(itVolumes->more())
for (;itVolumes.More();itVolumes.Next()) { {
const Handle(SMDS_MeshElement)& elem = itVolumes.Value(); const SMDS_MeshVolume * elem = itVolumes->next();
nb_of_nodes = elem->NbNodes(); nb_of_nodes = elem->NbNodes();
switch (nb_of_nodes) { switch (nb_of_nodes)
case 8 : { {
case 8:
{
//elem_Id[9][nmailles[9]] = elem->GetID(); //elem_Id[9][nmailles[9]] = elem->GetID();
elem_Id[9].push_back(elem->GetID()); elem_Id[9].push_back(elem->GetID());
nmailles[9]++; nmailles[9]++;
@ -254,22 +278,21 @@ void DriverMED_W_SMDS_Mesh::Write() {
/* Allocations memoires */ /* Allocations memoires */
/* table des coordonnees /* table des coordonnees
profil : (dimension * nombre de noeuds ) */ * profil : (dimension * nombre de noeuds ) */
coo = (med_float *) malloc(sizeof(med_float) * nnoe * mdim); coo = (med_float *) malloc(sizeof(med_float) * nnoe * mdim);
/* table des numeros, des numeros de familles des noeuds /* table des numeros, des numeros de familles des noeuds
profil : (nombre de noeuds) */ * profil : (nombre de noeuds) */
numnoe = (med_int *) malloc(sizeof(med_int) * nnoe); numnoe = (med_int *) malloc(sizeof(med_int) * nnoe);
nufano = (med_int *) malloc(sizeof(med_int) * nnoe); nufano = (med_int *) malloc(sizeof(med_int) * nnoe);
/* table des noms des noeuds /* table des noms des noeuds
profil : (nnoe*MED_TAILLE_PNOM+1) */ * profil : (nnoe*MED_TAILLE_PNOM+1) */
nomnoe = ""; nomnoe = "";
i = 0; i = 0;
SMDS_MeshNodesIterator itNodes(myMesh); SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
for (;itNodes.More();itNodes.Next()) { while(itNodes->more())
const Handle(SMDS_MeshElement)& elem = itNodes.Value(); {
const Handle(SMDS_MeshNode)& node = myMesh->GetNode(1,elem); const SMDS_MeshNode * node = itNodes->next();
coo[i * 3] = node->X(); coo[i * 3] = node->X();
coo[i * 3 + 1] = node->Y(); coo[i * 3 + 1] = node->Y();
coo[i * 3 + 2] = node->Z(); coo[i * 3 + 2] = node->Z();
@ -279,10 +302,10 @@ void DriverMED_W_SMDS_Mesh::Write() {
} }
/* ecriture des noeuds : /* ecriture des noeuds :
- coordonnees * - coordonnees
- noms (optionnel dans un fichier MED) * - noms (optionnel dans un fichier MED)
- numeros (optionnel dans un fichier MED) * - numeros (optionnel dans un fichier MED)
- numeros des familles */ * - numeros des familles */
ret = MEDnoeudsEcr(myFileId, nommaa, mdim, coo, mode_coo, MED_CART, ret = MEDnoeudsEcr(myFileId, nommaa, mdim, coo, mode_coo, MED_CART,
nomcoo, unicoo, nomnoe, MED_FAUX, numnoe, MED_VRAI, nomcoo, unicoo, nomnoe, MED_FAUX, numnoe, MED_VRAI,
nufano, nnoe, MED_REMP); nufano, nnoe, MED_REMP);
@ -326,24 +349,29 @@ void DriverMED_W_SMDS_Mesh::Write() {
taille * nmailles[i]); taille * nmailles[i]);
nomele = (char *)malloc(sizeof(char) * MED_TAILLE_PNOM * nomele = (char *)malloc(sizeof(char) * MED_TAILLE_PNOM *
nmailles[i] + 1); nmailles[i] + 1);
numele = (med_int*)malloc(sizeof(med_int)* numele = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
nmailles[i]); nufael = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
nufael = (med_int*)malloc(sizeof(med_int)*
nmailles[i]);
nomele = ""; nomele = "";
nbNodes = typmai[i] % 100; nbNodes = typmai[i] % 100;
//penser a mater les (taille-nsup) //penser a mater les (taille-nsup)
for (j=0;j<nmailles[i];j++) { for (j = 0; j < nmailles[i]; j++)
{
myId = elem_Id[i][j]; myId = elem_Id[i][j];
const Handle(SMDS_MeshElement)& elem = myMesh->FindElement(myId); const SMDS_MeshElement * elem =
myMesh->FindElement(myId);
*(numele + j) = myId; *(numele + j) = myId;
//elem_id=*(numele+j); //elem_id=*(numele+j);
//fprintf(stdout,"%d \n",myId); //fprintf(stdout,"%d \n",myId);
for (k=0; k<nbNodes; k++) { SMDS_Iterator<const SMDS_MeshElement *> * itNode=
elem->nodesIterator();
while(itNode->more())
{
//*(connectivite+j*(taille-1)+k)=cnx[k]; //*(connectivite+j*(taille-1)+k)=cnx[k];
*(connectivite+j*(taille-nsup)+k) = elem->GetConnection(k+1); *(connectivite + j * (taille - nsup) + k) =
itNode->next()->GetID();
//fprintf(stdout,"%d ",*(connectivite+j*(taille-nsup)+k)); //fprintf(stdout,"%d ",*(connectivite+j*(taille-nsup)+k));
} }
nufael[j] = 0; nufael[j] = 0;
@ -352,7 +380,10 @@ void DriverMED_W_SMDS_Mesh::Write() {
/* ecriture des données */ /* ecriture des données */
ret=MEDelementsEcr(myFileId,nommaa,mdim,connectivite,mode_coo,nomele,MED_FAUX,numele,MED_VRAI,nufael,nmailles[i],MED_MAILLE,typmai[i],typ_con,MED_REMP); ret =
MEDelementsEcr(myFileId, nommaa, mdim, connectivite,
mode_coo, nomele, MED_FAUX, numele, MED_VRAI, nufael,
nmailles[i], MED_MAILLE, typmai[i], typ_con, MED_REMP);
if (ret < 0) if (ret < 0)
MESSAGE(">> ERREUR : lecture des mailles \n"); MESSAGE(">> ERREUR : lecture des mailles \n");
@ -371,9 +402,9 @@ void DriverMED_W_SMDS_Mesh::Write() {
****************************************************************************/ ****************************************************************************/
/*! ret = MEDfermer(myFileId); /*! ret = MEDfermer(myFileId);
*
if (ret != 0) * if (ret != 0)
fprintf(stderr,">> ERREUR : erreur a la fermeture du fichier %s\n",file2Read); * fprintf(stderr,">> ERREUR : erreur a la fermeture du fichier %s\n",file2Read);
*/ */
} }

View File

@ -37,22 +37,21 @@ extern "C"
#include <med.h> #include <med.h>
} }
class DriverMED_W_SMDS_Mesh : public Mesh_Writer { class DriverMED_W_SMDS_Mesh:public Mesh_Writer
{
public : public:DriverMED_W_SMDS_Mesh();
DriverMED_W_SMDS_Mesh();
~DriverMED_W_SMDS_Mesh(); ~DriverMED_W_SMDS_Mesh();
void Add(); void Add();
void Write(); void Write();
void SetMesh(Handle(SMDS_Mesh)& aMesh); void SetMesh(SMDS_Mesh * aMesh);
void SetFile(string); void SetFile(string);
void SetFileId(med_idt); void SetFileId(med_idt);
void SetMeshId(int); void SetMeshId(int);
private : private: SMDS_Mesh * myMesh;
Handle_SMDS_Mesh myMesh;
string myFile; string myFile;
med_idt myFileId; med_idt myFileId;
int myMeshId; int myMeshId;

View File

@ -33,16 +33,19 @@ using namespace std;
extern "C" extern "C"
{ {
Document_Writer* Wmaker() { Document_Writer *Wmaker()
{
return new DriverMED_W_SMESHDS_Document; return new DriverMED_W_SMESHDS_Document;
} }
} }
DriverMED_W_SMESHDS_Document::DriverMED_W_SMESHDS_Document() { DriverMED_W_SMESHDS_Document::DriverMED_W_SMESHDS_Document()
{
; ;
} }
DriverMED_W_SMESHDS_Document::~DriverMED_W_SMESHDS_Document() { DriverMED_W_SMESHDS_Document::~DriverMED_W_SMESHDS_Document()
{
; ;
} }
@ -54,7 +57,8 @@ DriverMED_W_SMESHDS_Document::~DriverMED_W_SMESHDS_Document() {
//myDocument = aDocument; //myDocument = aDocument;
//} //}
void DriverMED_W_SMESHDS_Document::Write() { void DriverMED_W_SMESHDS_Document::Write()
{
med_err ret = 0; med_err ret = 0;
med_idt fid; med_idt fid;
@ -63,7 +67,7 @@ void DriverMED_W_SMESHDS_Document::Write() {
med_connectivite typ_con; med_connectivite typ_con;
SCRUTE(myFile); SCRUTE(myFile);
Handle(SMESHDS_Mesh) myMesh; SMESHDS_Mesh * myMesh;
/******** Nombre de maillages ********/ /******** Nombre de maillages ********/
nb_of_meshes = myDocument->NbMeshes(); //voir avec Yves nb_of_meshes = myDocument->NbMeshes(); //voir avec Yves
@ -81,9 +85,10 @@ void DriverMED_W_SMESHDS_Document::Write() {
myDocument->InitMeshesIterator(); myDocument->InitMeshesIterator();
if (nb_of_meshes != 0) if (nb_of_meshes != 0)
for (;myDocument->MoreMesh();myDocument->NextMesh()) { while(myDocument->MoreMesh())
{
numero++; numero++;
myMesh = myDocument->CurrentMesh(); myMesh = myDocument->NextMesh();
DriverMED_W_SMESHDS_Mesh *myWriter = new DriverMED_W_SMESHDS_Mesh; DriverMED_W_SMESHDS_Mesh *myWriter = new DriverMED_W_SMESHDS_Mesh;
@ -95,6 +100,4 @@ void DriverMED_W_SMESHDS_Document::Write() {
//myWriter->Write(); //myWriter->Write();
myWriter->Add(); myWriter->Add();
} }
} }

View File

@ -27,65 +27,44 @@
using namespace std; using namespace std;
#include "DriverMED_W_SMESHDS_Mesh.h" #include "DriverMED_W_SMESHDS_Mesh.h"
#include "DriverMED_W_SMDS_Mesh.h" #include "DriverMED_W_SMDS_Mesh.h"
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_MeshFacesIterator.hxx"
#include "SMDS_MeshEdgesIterator.hxx"
#include "SMDS_MeshNodesIterator.hxx"
#include "SMDS_MeshVolumesIterator.hxx"
#include "SMESHDS_SubMesh.hxx"
#include "SMDS_MapIteratorOfExtendedMap.hxx"
#include "SMDS_MapOfMeshElement.hxx"
#include "SMDS_Position.hxx"
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_CompSolid.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Shape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <map>
#include <set>
#include <vector> #include <vector>
#include "utilities.h" #include "utilities.h"
DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh() { DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh()
{
; ;
} }
DriverMED_W_SMESHDS_Mesh::~DriverMED_W_SMESHDS_Mesh() { DriverMED_W_SMESHDS_Mesh::~DriverMED_W_SMESHDS_Mesh()
{
; ;
} }
void DriverMED_W_SMESHDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) { void DriverMED_W_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
{
myMesh = aMesh; myMesh = aMesh;
} }
void DriverMED_W_SMESHDS_Mesh::SetFile(string aFile) { void DriverMED_W_SMESHDS_Mesh::SetFile(string aFile)
{
myFile = aFile; myFile = aFile;
} }
void DriverMED_W_SMESHDS_Mesh::SetFileId(med_idt aFileId) { void DriverMED_W_SMESHDS_Mesh::SetFileId(med_idt aFileId)
{
myFileId = aFileId; myFileId = aFileId;
} }
void DriverMED_W_SMESHDS_Mesh::SetMeshId(int aMeshId) { void DriverMED_W_SMESHDS_Mesh::SetMeshId(int aMeshId)
{
myMeshId = aMeshId; myMeshId = aMeshId;
} }
void DriverMED_W_SMESHDS_Mesh::Write() { void DriverMED_W_SMESHDS_Mesh::Write()
{
string myClass = string("SMDS_Mesh"); string myClass = string("SMDS_Mesh");
string myExtension = string("MED"); string myExtension = string("MED");
@ -99,16 +78,16 @@ void DriverMED_W_SMESHDS_Mesh::Write() {
myWriter->Write(); myWriter->Write();
} }
void DriverMED_W_SMESHDS_Mesh::Add() { void DriverMED_W_SMESHDS_Mesh::Add()
{
med_err ret = 0; med_err ret = 0;
int i, j, k, l; int i, j, k, l;
int numero; int numero;
char message[200]; char message[200];
Standard_Boolean ok; bool ok;
/* nombre d'objets MED */ /* nombre d'objets MED */
char nom_universel[MED_TAILLE_LNOM + 1]; char nom_universel[MED_TAILLE_LNOM + 1];
med_int long_fichier_en_tete; med_int long_fichier_en_tete;
@ -145,15 +124,18 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
med_booleen inoele, inuele; med_booleen inoele, inuele;
med_connectivite typ_con; med_connectivite typ_con;
med_geometrie_element typgeo; med_geometrie_element typgeo;
med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] = {MED_POINT1,MED_SEG2, med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] =
{ MED_POINT1, MED_SEG2,
MED_SEG3, MED_TRIA3, MED_SEG3, MED_TRIA3,
MED_TRIA6, MED_QUAD4, MED_TRIA6, MED_QUAD4,
MED_QUAD8, MED_TETRA4, MED_QUAD8, MED_TETRA4,
MED_TETRA10, MED_HEXA8, MED_TETRA10, MED_HEXA8,
MED_HEXA20, MED_PENTA6, MED_HEXA20, MED_PENTA6,
MED_PENTA15, MED_PYRA5, MED_PENTA15, MED_PYRA5,
MED_PYRA13}; MED_PYRA13
med_int desmai[MED_NBR_GEOMETRIE_MAILLE] = {0,2,3,3,3,4,4,4,4,6,6,5,5,5,5}; };
med_int desmai[MED_NBR_GEOMETRIE_MAILLE] =
{ 0, 2, 3, 3, 3, 4, 4, 4, 4, 6, 6, 5, 5, 5, 5 };
med_int nmailles[MED_NBR_GEOMETRIE_MAILLE]; med_int nmailles[MED_NBR_GEOMETRIE_MAILLE];
char nommai[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = { "MED_POINT1", char nommai[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = { "MED_POINT1",
"MED_SEG2", "MED_SEG2",
@ -169,17 +151,24 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
"MED_PENTA6", "MED_PENTA6",
"MED_PENTA15", "MED_PENTA15",
"MED_PYRA5", "MED_PYRA5",
"MED_PYRA13"}; "MED_PYRA13"
med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] = {MED_TRIA3,MED_TRIA6, };
MED_QUAD4,MED_QUAD8}; med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] =
{ MED_TRIA3, MED_TRIA6,
MED_QUAD4, MED_QUAD8
};
med_int desfac[MED_NBR_GEOMETRIE_FACE] = { 3, 3, 4, 4 }; med_int desfac[MED_NBR_GEOMETRIE_FACE] = { 3, 3, 4, 4 };
med_int nfaces[MED_NBR_GEOMETRIE_FACE]; med_int nfaces[MED_NBR_GEOMETRIE_FACE];
char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM+1] = {"MED_TRIA3","MED_TRIA6", char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM + 1] =
"MED_QUAD4","MED_QUAD8"}; { "MED_TRIA3", "MED_TRIA6",
med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] = {MED_SEG2,MED_SEG3}; "MED_QUAD4", "MED_QUAD8"
};
med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] =
{ MED_SEG2, MED_SEG3 };
med_int desare[MED_NBR_GEOMETRIE_ARETE] = { 2, 3 }; med_int desare[MED_NBR_GEOMETRIE_ARETE] = { 2, 3 };
med_int naretes[MED_NBR_GEOMETRIE_ARETE]; med_int naretes[MED_NBR_GEOMETRIE_ARETE];
char nomare[MED_NBR_GEOMETRIE_ARETE] [MED_TAILLE_NOM+1] = {"MED_SEG2","MED_SEG3"}; char nomare[MED_NBR_GEOMETRIE_ARETE][MED_TAILLE_NOM + 1] =
{ "MED_SEG2", "MED_SEG3" };
typ_con = MED_NOD; typ_con = MED_NOD;
mode_coo = MED_FULL_INTERLACE; mode_coo = MED_FULL_INTERLACE;
@ -195,7 +184,6 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
char *file2Read = (char *)myFile.c_str(); char *file2Read = (char *)myFile.c_str();
MESSAGE(" file2Read " << file2Read) MESSAGE(" file2Read " << file2Read)
myFileId = MEDouvrir(file2Read, MED_REMP); myFileId = MEDouvrir(file2Read, MED_REMP);
if (myFileId < 0) if (myFileId < 0)
{ {
@ -221,12 +209,13 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
bool dimY = true; bool dimY = true;
bool dimZ = true; bool dimZ = true;
SMDS_MeshNodesIterator myItNodes(myMesh);
int inode = 0; int inode = 0;
for (;myItNodes.More();myItNodes.Next()) { SMDS_Iterator<const SMDS_MeshNode *> * myItNodes=myMesh->nodesIterator();
const Handle(SMDS_MeshElement)& elem = myItNodes.Value(); while(myItNodes->more())
const Handle(SMDS_MeshNode)& node = myMesh->GetNode(1,elem); {
if ( inode == 0 ) { const SMDS_MeshNode * node = myItNodes->next();
if (inode == 0)
{
nodeRefX = fabs(node->X()); nodeRefX = fabs(node->X());
nodeRefY = fabs(node->Y()); nodeRefY = fabs(node->Y());
nodeRefZ = fabs(node->Z()); nodeRefZ = fabs(node->Z());
@ -236,7 +225,8 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
SCRUTE(nodeRefY); SCRUTE(nodeRefY);
SCRUTE(nodeRefZ); SCRUTE(nodeRefZ);
if ( inode !=0 ) { if (inode != 0)
{
if ((fabs(fabs(node->X()) - nodeRefX) > epsilon) && dimX) if ((fabs(fabs(node->X()) - nodeRefX) > epsilon) && dimX)
dimX = false; dimX = false;
if ((fabs(fabs(node->Y()) - nodeRefY) > epsilon) && dimY) if ((fabs(fabs(node->Y()) - nodeRefY) > epsilon) && dimY)
@ -244,27 +234,34 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
if ((fabs(fabs(node->Z()) - nodeRefZ) > epsilon) && dimZ) if ((fabs(fabs(node->Z()) - nodeRefZ) > epsilon) && dimZ)
dimZ = false; dimZ = false;
} }
if ( !dimX && !dimY && !dimZ ) { if (!dimX && !dimY && !dimZ)
{
mdim = 3; mdim = 3;
break; break;
} }
inode++; inode++;
} }
if ( mdim != 3 ) { if (mdim != 3)
{
if (dimX && dimY && dimZ) if (dimX && dimY && dimZ)
mdim = 0; mdim = 0;
else if ( !dimX ) { else if (!dimX)
{
if (dimY && dimZ) if (dimY && dimZ)
mdim = 1; mdim = 1;
else if ((dimY && !dimZ) || (!dimY && dimZ)) else if ((dimY && !dimZ) || (!dimY && dimZ))
mdim = 2; mdim = 2;
} else if ( !dimY ) { }
else if (!dimY)
{
if (dimX && dimZ) if (dimX && dimZ)
mdim = 1; mdim = 1;
else if ((dimX && !dimZ) || (!dimX && dimZ)) else if ((dimX && !dimZ) || (!dimX && dimZ))
mdim = 2; mdim = 2;
} else if ( !dimZ ) { }
else if (!dimZ)
{
if (dimY && dimX) if (dimY && dimX)
mdim = 1; mdim = 1;
else if ((dimY && !dimX) || (!dimY && dimX)) else if ((dimY && !dimX) || (!dimY && dimX))
@ -290,23 +287,27 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++) for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
nmailles[i] = 0; nmailles[i] = 0;
Standard_Integer nb_of_nodes, nb_of_faces, nb_of_edges; int nb_of_nodes, nb_of_faces, nb_of_edges;
vector < int >elem_Id[MED_NBR_GEOMETRIE_MAILLE]; vector < int >elem_Id[MED_NBR_GEOMETRIE_MAILLE];
SMDS_MeshEdgesIterator itEdges(myMesh);
nb_of_edges = myMesh->NbEdges(); nb_of_edges = myMesh->NbEdges();
for (;itEdges.More();itEdges.Next()) { SMDS_Iterator<const SMDS_MeshEdge *> * itEdges=myMesh->edgesIterator();
const Handle(SMDS_MeshElement)& elem = itEdges.Value(); while(itEdges->more())
{
const SMDS_MeshEdge * elem = itEdges->next();
nb_of_nodes = elem->NbNodes(); nb_of_nodes = elem->NbNodes();
switch (nb_of_nodes) { switch (nb_of_nodes)
case 2 : { {
case 2:
{
elem_Id[1].push_back(elem->GetID()); elem_Id[1].push_back(elem->GetID());
nmailles[1]++; nmailles[1]++;
break; break;
} }
case 3 : { case 3:
{
elem_Id[2].push_back(elem->GetID()); elem_Id[2].push_back(elem->GetID());
nmailles[2]++; nmailles[2]++;
break; break;
@ -314,26 +315,30 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
} }
} }
SMDS_MeshFacesIterator itFaces(myMesh);
nb_of_faces = myMesh->NbFaces(); nb_of_faces = myMesh->NbFaces();
for (;itFaces.More();itFaces.Next()) { SMDS_Iterator<const SMDS_MeshFace *> * itFaces=myMesh->facesIterator();
const Handle(SMDS_MeshElement)& elem = itFaces.Value(); while(itFaces->more())
{
const SMDS_MeshElement * elem = itFaces->next();
nb_of_nodes = elem->NbNodes(); nb_of_nodes = elem->NbNodes();
switch (nb_of_nodes) { switch (nb_of_nodes)
case 3 : { {
case 3:
{
elem_Id[3].push_back(elem->GetID()); elem_Id[3].push_back(elem->GetID());
nmailles[3]++; nmailles[3]++;
break; break;
} }
case 4 : { case 4:
{
elem_Id[5].push_back(elem->GetID()); elem_Id[5].push_back(elem->GetID());
nmailles[5]++; nmailles[5]++;
break; break;
} }
case 6 : { case 6:
{
elem_Id[4].push_back(elem->GetID()); elem_Id[4].push_back(elem->GetID());
nmailles[4]++; nmailles[4]++;
break; break;
@ -342,13 +347,16 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
} }
SMDS_MeshVolumesIterator itVolumes(myMesh); SMDS_Iterator<const SMDS_MeshVolume *> * itVolumes=myMesh->volumesIterator();
for (;itVolumes.More();itVolumes.Next()) { while(itVolumes->more())
const Handle(SMDS_MeshElement)& elem = itVolumes.Value(); {
const SMDS_MeshElement * elem = itVolumes->next();
nb_of_nodes = elem->NbNodes(); nb_of_nodes = elem->NbNodes();
switch (nb_of_nodes) { switch (nb_of_nodes)
case 8 : { {
case 8:
{
elem_Id[9].push_back(elem->GetID()); elem_Id[9].push_back(elem->GetID());
nmailles[9]++; nmailles[9]++;
break; break;
@ -356,8 +364,6 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
} }
} }
/**************************************************************************** /****************************************************************************
* ECRITURE DES NOEUDS * * ECRITURE DES NOEUDS *
****************************************************************************/ ****************************************************************************/
@ -367,14 +373,14 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
/* Allocations memoires */ /* Allocations memoires */
/* table des coordonnees /* table des coordonnees
profil : (dimension * nombre de noeuds ) */ * profil : (dimension * nombre de noeuds ) */
coo = (med_float *) malloc(sizeof(med_float) * nnoe * mdim); coo = (med_float *) malloc(sizeof(med_float) * nnoe * mdim);
/* table des numeros, des numeros de familles des noeuds /* table des numeros, des numeros de familles des noeuds
profil : (nombre de noeuds) */ * profil : (nombre de noeuds) */
numnoe = (med_int *) malloc(sizeof(med_int) * nnoe); numnoe = (med_int *) malloc(sizeof(med_int) * nnoe);
nufano = (med_int *) malloc(sizeof(med_int) * nnoe); nufano = (med_int *) malloc(sizeof(med_int) * nnoe);
/* table des noms des noeuds /* table des noms des noeuds
profil : (nnoe*MED_TAILLE_PNOM+1) */ * profil : (nnoe*MED_TAILLE_PNOM+1) */
nomnoe = ""; nomnoe = "";
/* PN pour aster, il faut une famille 0 pour les noeuds et une autre pour les elements */ /* PN pour aster, il faut une famille 0 pour les noeuds et une autre pour les elements */
@ -388,56 +394,66 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
med_int attval = 0; med_int attval = 0;
med_int numfam = 0; med_int numfam = 0;
med_int attvalabs = 1; med_int attvalabs = 1;
ret = MEDfamCr(myFileId,nommaa,nomfam,numfam, &attide,&attval,attdes,natt,gro,ngro); ret =
MEDfamCr(myFileId, nommaa, nomfam, numfam, &attide, &attval, attdes,
natt, gro, ngro);
ASSERT(ret == 0); ASSERT(ret == 0);
/* PN : FIN Creation de la famille 0 */ /* PN : FIN Creation de la famille 0 */
map < int, int >mapNoeud; map < int, int >mapNoeud;
typedef pair < set < int >::iterator, bool > IsFamily; typedef pair < set < int >::iterator, bool > IsFamily;
int nbFamillesNoeud; int nbFamillesNoeud;
i = 0; i = 0;
set < int >FamilySet; set < int >FamilySet;
nbFamillesNoeud = 0; nbFamillesNoeud = 0;
int verifienbnoeuds = 0; int verifienbnoeuds = 0;
med_int *rien = 0; med_int *rien = 0;
SMDS_MeshNodesIterator itNodes(myMesh); SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
for (;itNodes.More();itNodes.Next()) while(itNodes->more())
{ {
const Handle(SMDS_MeshElement)& elem = itNodes.Value(); const SMDS_MeshNode * node = itNodes->next();
const Handle(SMDS_MeshNode)& node = myMesh->GetNode(1,elem);
if(mdim==3){ if (mdim == 3)
{
coo[i * 3] = node->X(); coo[i * 3] = node->X();
coo[i * 3 + 1] = node->Y(); coo[i * 3 + 1] = node->Y();
coo[i * 3 + 2] = node->Z(); coo[i * 3 + 2] = node->Z();
} else if(mdim==2) { }
if ( dimX ) { else if (mdim == 2)
{
if (dimX)
{
coo[i * 2] = node->Y(); coo[i * 2] = node->Y();
coo[i * 2 + 1] = node->Z(); coo[i * 2 + 1] = node->Z();
} }
if ( dimY ) { if (dimY)
{
coo[i * 2] = node->X(); coo[i * 2] = node->X();
coo[i * 2 + 1] = node->Z(); coo[i * 2 + 1] = node->Z();
} }
if ( dimZ ) { if (dimZ)
{
coo[i * 2] = node->X(); coo[i * 2] = node->X();
coo[i * 2 + 1] = node->Y(); coo[i * 2 + 1] = node->Y();
} }
} else { }
if ( dimX ) { else
{
if (dimX)
{
coo[i * 2] = node->Y(); coo[i * 2] = node->Y();
coo[i * 2 + 1] = node->Z(); coo[i * 2 + 1] = node->Z();
} }
if ( dimY ) { if (dimY)
{
coo[i * 2] = node->X(); coo[i * 2] = node->X();
coo[i * 2 + 1] = node->Z(); coo[i * 2 + 1] = node->Z();
} }
if ( dimZ ) { if (dimZ)
{
coo[i * 2] = node->X(); coo[i * 2] = node->X();
coo[i * 2 + 1] = node->Y(); coo[i * 2 + 1] = node->Y();
} }
@ -462,7 +478,8 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
sprintf(famille, "F%d", nufano[i]); sprintf(famille, "F%d", nufano[i]);
// CreateFamily(strdup(nommaa),strdup(famille),nufano[i],attvalabs++); // CreateFamily(strdup(nommaa),strdup(famille),nufano[i],attvalabs++);
attvalabs++; attvalabs++;
CreateFamily(strdup(nommaa),strdup(famille),nufano[i],numfamille); CreateFamily(strdup(nommaa), strdup(famille), nufano[i],
numfamille);
//MESSAGE("---famille-noeud--- "<<nbFamillesNoeud<<" "<<nufano[i]); //MESSAGE("---famille-noeud--- "<<nbFamillesNoeud<<" "<<nufano[i]);
nbFamillesNoeud++; nbFamillesNoeud++;
} }
@ -496,7 +513,7 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
if (ret == 0) if (ret == 0)
{ {
int nbFamillesElts = 0; int nbFamillesElts = 0;
Handle(SMESHDS_Mesh) mySMESHDSMesh = Handle(SMESHDS_Mesh)::DownCast(myMesh); SMESHDS_Mesh * mySMESHDSMesh = dynamic_cast<SMESHDS_Mesh *>(myMesh);
TopTools_IndexedMapOfShape myIndexToShape; TopTools_IndexedMapOfShape myIndexToShape;
TopExp::MapShapes(mySMESHDSMesh->ShapeToMesh(), myIndexToShape); TopExp::MapShapes(mySMESHDSMesh->ShapeToMesh(), myIndexToShape);
@ -512,14 +529,14 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
{ {
//MESSAGE ("********* Traitement de la Famille "<<-t); //MESSAGE ("********* Traitement de la Famille "<<-t);
Handle(SMESHDS_SubMesh) SM = mySMESHDSMesh->MeshElements(S); SMESHDS_SubMesh * SM = mySMESHDSMesh->MeshElements(S);
const TColStd_ListOfInteger& indElt = SM->GetIDElements(); const vector<int>& indElt = SM->GetIDElements();
TColStd_ListIteratorOfListOfInteger ite(indElt); vector<int>::const_iterator ite=indElt.begin();
bool plein = false; bool plein = false;
for (; ite.More(); ite.Next()) for (; ite!=indElt.end(); ite++)
{ {
int eltId = ite.Value(); int eltId = *ite;
mapFamille[eltId] = -t; mapFamille[eltId] = -t;
plein = true; plein = true;
} }
@ -528,7 +545,8 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
nbFamillesElts++; nbFamillesElts++;
char famille[MED_TAILLE_NOM + 1]; char famille[MED_TAILLE_NOM + 1];
sprintf(famille, "E%d", t); sprintf(famille, "E%d", t);
CreateFamily(strdup(nommaa),strdup(famille),-t,attvalabs++); CreateFamily(strdup(nommaa), strdup(famille), -t,
attvalabs++);
} }
} }
} }
@ -545,17 +563,22 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
edim = typmai[i] / 100; edim = typmai[i] / 100;
nsup = 0; nsup = 0;
if (mdim == 2 || mdim == 3) if (mdim == 2 || mdim == 3)
if (edim == 1) nsup = 1; if (edim == 1)
nsup = 1;
if (mdim == 3) if (mdim == 3)
if (edim == 2) nsup = 1; if (edim == 2)
nsup = 1;
//SCRUTE(nsup); //SCRUTE(nsup);
taille = nsup + typmai[i] % 100; taille = nsup + typmai[i] % 100;
//SCRUTE(taille); //SCRUTE(taille);
/* allocation memoire */ /* allocation memoire */
connectivite = (med_int*)malloc(sizeof(med_int)* taille*nmailles[i]); connectivite =
nomele = (char*)malloc(sizeof(char)*MED_TAILLE_PNOM* nmailles[i]+1); (med_int *) malloc(sizeof(med_int) * taille * nmailles[i]);
nomele =
(char *)malloc(sizeof(char) * MED_TAILLE_PNOM *
nmailles[i] + 1);
numele = (med_int *) malloc(sizeof(med_int) * nmailles[i]); numele = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
nufael = (med_int *) malloc(sizeof(med_int) * nmailles[i]); nufael = (med_int *) malloc(sizeof(med_int) * nmailles[i]);
nomele = ""; nomele = "";
@ -564,16 +587,21 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
for (j = 0; j < nmailles[i]; j++) for (j = 0; j < nmailles[i]; j++)
{ {
myId = elem_Id[i][j]; myId = elem_Id[i][j];
const Handle(SMDS_MeshElement)& elem = myMesh->FindElement(myId); const SMDS_MeshElement * elem =
myMesh->FindElement(myId);
//*(numele+j) = myId; //*(numele+j) = myId;
*(numele + j) = indice++; *(numele + j) = indice++;
for (k=0; k<nbNodes; k++) SMDS_Iterator<const SMDS_MeshElement *> * itk=elem->nodesIterator();
for (k = 0; itk->more(); k++)
{ {
*(connectivite+j*taille+k) = mapNoeud[elem->GetConnection(k+1)]; *(connectivite + j * taille + k) =
//SCRUTE(*(connectivite+j*taille+k)); mapNoeud[itk->next()->GetID()];
} }
if (nsup) *(connectivite+j*taille + nbNodes) = 0; delete itk;
if (nsup)
*(connectivite + j * taille + nbNodes) = 0;
if (besoinfamilledemaille == 1) if (besoinfamilledemaille == 1)
{ {
@ -599,12 +627,15 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
/* ecriture des données */ /* ecriture des données */
med_int *rien = 0; med_int *rien = 0;
ret=MEDelementsEcr( myFileId,nommaa,mdim,connectivite,mode_coo,nomele,MED_FAUX,numele, ret =
MED_VRAI,nufael,nmailles[i],MED_MAILLE,typmai[i],typ_con,MED_REMP); MEDelementsEcr(myFileId, nommaa, mdim, connectivite,
mode_coo, nomele, MED_FAUX, numele, MED_VRAI, nufael,
nmailles[i], MED_MAILLE, typmai[i], typ_con, MED_REMP);
ASSERT(ret == 0); ASSERT(ret == 0);
//SCRUTE(ret); //SCRUTE(ret);
if (ret < 0) MESSAGE(">> ERREUR : ecriture des mailles \n"); if (ret < 0)
MESSAGE(">> ERREUR : ecriture des mailles \n");
/* liberation memoire */ /* liberation memoire */
free(connectivite); free(connectivite);
@ -624,13 +655,15 @@ void DriverMED_W_SMESHDS_Mesh::Add() {
ret = MEDfermer(myFileId); ret = MEDfermer(myFileId);
if (ret != 0) if (ret != 0)
fprintf(stderr,">> ERREUR : erreur a la fermeture du fichier %s\n",file2Read); fprintf(stderr, ">> ERREUR : erreur a la fermeture du fichier %s\n",
file2Read);
MESSAGE("fichier ferme"); MESSAGE("fichier ferme");
} }
void DriverMED_W_SMESHDS_Mesh::CreateFamily(char* nommaa, char* famille, int i,med_int k) { void DriverMED_W_SMESHDS_Mesh::CreateFamily(char *nommaa, char *famille, int i,
med_int k)
{
med_int ngro = 0; med_int ngro = 0;
med_int natt; med_int natt;
@ -649,14 +682,12 @@ void DriverMED_W_SMESHDS_Mesh::CreateFamily(char* nommaa, char* famille, int i,m
attide[0] = k; attide[0] = k;
attval[0] = k; attval[0] = k;
//MESSAGE("-------- Creation de la Famille : "<< famille << "numero " << i << " --------------"); //MESSAGE("-------- Creation de la Famille : "<< famille << "numero " << i << " --------------");
med_int ret = MEDfamCr(myFileId, nommaa, fam2, i, attide, attval, attdes, natt, gro, ngro); med_int ret =
MEDfamCr(myFileId, nommaa, fam2, i, attide, attval, attdes, natt, gro,
ngro);
ASSERT(ret == 0); ASSERT(ret == 0);
delete[]attide; delete[]attide;
delete[]attval; delete[]attval;
} }

View File

@ -37,15 +37,15 @@ extern "C"
#include <med.h> #include <med.h>
} }
class DriverMED_W_SMESHDS_Mesh : public Mesh_Writer { class DriverMED_W_SMESHDS_Mesh:public Mesh_Writer
{
public : public:DriverMED_W_SMESHDS_Mesh();
DriverMED_W_SMESHDS_Mesh();
~DriverMED_W_SMESHDS_Mesh(); ~DriverMED_W_SMESHDS_Mesh();
void Add(); void Add();
void Write(); void Write();
void SetMesh(Handle(SMDS_Mesh)& aMesh); void SetMesh(SMDS_Mesh * aMesh);
void SetFile(string); void SetFile(string);
void SetFileId(med_idt); void SetFileId(med_idt);
@ -53,8 +53,7 @@ class DriverMED_W_SMESHDS_Mesh : public Mesh_Writer {
void CreateFamily(char *, char *, int, med_int); void CreateFamily(char *, char *, int, med_int);
private : private: SMDS_Mesh * myMesh;
Handle_SMDS_Mesh myMesh;
string myFile; string myFile;
med_idt myFileId; med_idt myFileId;
int myMeshId; int myMeshId;

View File

@ -3,35 +3,43 @@ using namespace std;
#include "utilities.h" #include "utilities.h"
DriverUNV_R_SMDS_Mesh::DriverUNV_R_SMDS_Mesh() { DriverUNV_R_SMDS_Mesh::DriverUNV_R_SMDS_Mesh()
{
; ;
} }
DriverUNV_R_SMDS_Mesh::~DriverUNV_R_SMDS_Mesh() { DriverUNV_R_SMDS_Mesh::~DriverUNV_R_SMDS_Mesh()
{
; ;
} }
void DriverUNV_R_SMDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) { void DriverUNV_R_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
{
myMesh = aMesh; myMesh = aMesh;
} }
void DriverUNV_R_SMDS_Mesh::SetFile(string aFile) { void DriverUNV_R_SMDS_Mesh::SetFile(string aFile)
{
myFile = aFile; myFile = aFile;
} }
void DriverUNV_R_SMDS_Mesh::SetFileId(FILE* aFileId) { void DriverUNV_R_SMDS_Mesh::SetFileId(FILE * aFileId)
{
myFileId = aFileId; myFileId = aFileId;
} }
void DriverUNV_R_SMDS_Mesh::SetMeshId(int aMeshId) { void DriverUNV_R_SMDS_Mesh::SetMeshId(int aMeshId)
{
myMeshId = aMeshId; myMeshId = aMeshId;
} }
void DriverUNV_R_SMDS_Mesh::Add() { void DriverUNV_R_SMDS_Mesh::Add()
{
; ;
} }
void DriverUNV_R_SMDS_Mesh::Read() { void DriverUNV_R_SMDS_Mesh::Read()
{
int cell = 0, node = 0, n1, n2, n3, n4, n_nodes, nodes[6], blockId, i; int cell = 0, node = 0, n1, n2, n3, n4, n_nodes, nodes[6], blockId, i;
char *s1, *s2, *s3; char *s1, *s2, *s3;
@ -57,63 +65,87 @@ void DriverUNV_R_SMDS_Mesh::Read() {
found_block2411 = false; found_block2411 = false;
found_block2412 = false; found_block2412 = false;
do { do
{
while (i1==-1) { while (i1 == -1)
{
fscanf(myFileId, "%d\n", &blockId); fscanf(myFileId, "%d\n", &blockId);
switch (blockId) { switch (blockId)
case 2411 : { {
case 2411:
{
MESSAGE("BlockId " << blockId); MESSAGE("BlockId " << blockId);
fscanf(myFileId, "%d", &node); fscanf(myFileId, "%d", &node);
//MESSAGE("Node "<<node); //MESSAGE("Node "<<node);
while (node!=-1) { while (node != -1)
{
fscanf(myFileId, "%d %d %d\n", &n1, &n2, &n3); fscanf(myFileId, "%d %d %d\n", &n1, &n2, &n3);
fscanf(myFileId, "%s %s %s\n", s1, s2, s3); fscanf(myFileId, "%s %s %s\n", s1, s2, s3);
str1 = string(s1); str1 = string(s1);
str2 = string(s2); str2 = string(s2);
str3 = string(s3); str3 = string(s3);
if (str1.find("D")!=string::npos) str1.replace(str1.find("D"),1,"E"); if (str1.find("D") != string::npos)
if (str2.find("D")!=string::npos) str2.replace(str2.find("D"),1,"E"); str1.replace(str1.find("D"), 1, "E");
if (str3.find("D")!=string::npos) str3.replace(str3.find("D"),1,"E"); if (str2.find("D") != string::npos)
ok = myMesh->AddNodeWithID(atof(str1.c_str()),atof(str2.c_str()),atof(str3.c_str()),node); str2.replace(str2.find("D"), 1, "E");
if (str3.find("D") != string::npos)
str3.replace(str3.find("D"), 1, "E");
ok = myMesh->AddNodeWithID(atof(str1.c_str()),
atof(str2.c_str()), atof(str3.c_str()), node);
fscanf(myFileId, "%d", &node); fscanf(myFileId, "%d", &node);
} }
i1 = 0; i1 = 0;
found_block2411 = true; found_block2411 = true;
break; break;
} }
case 2412 : { case 2412:
{
MESSAGE("BlockId " << blockId); MESSAGE("BlockId " << blockId);
fscanf(myFileId, "%d", &cell); fscanf(myFileId, "%d", &cell);
//MESSAGE("Cell "<<cell); //MESSAGE("Cell "<<cell);
while (cell!=-1) { while (cell != -1)
fscanf(myFileId,"%d %d %d %d %d\n",&n1,&n2,&n3,&n4,&n_nodes); {
fscanf(myFileId, "%d %d %d %d %d\n", &n1, &n2, &n3, &n4,
&n_nodes);
if ((n1==71)||(n1==72)||(n1==74)||(n1==91)||(n1==92)) {//203 if ((n1 == 71) || (n1 == 72) || (n1 == 74) || (n1 == 91) ||
if (n_nodes==3) { (n1 == 92))
{ //203
if (n_nodes == 3)
{
for (i = 1; i <= n_nodes; i++) for (i = 1; i <= n_nodes; i++)
fscanf(myFileId, "%d", &nodes[i - 1]); fscanf(myFileId, "%d", &nodes[i - 1]);
ok = myMesh->AddFaceWithID(nodes[0],nodes[1],nodes[2],cell); ok = myMesh->AddFaceWithID(nodes[0], nodes[1],
nodes[2], cell);
} }
else if (n_nodes==6) {//206 else if (n_nodes == 6)
{ //206
for (i = 1; i <= n_nodes; i++) for (i = 1; i <= n_nodes; i++)
fscanf(myFileId, "%d", &nodes[i - 1]); fscanf(myFileId, "%d", &nodes[i - 1]);
ok = myMesh->AddFaceWithID(nodes[0],nodes[2],nodes[4],cell); ok = myMesh->AddFaceWithID(nodes[0], nodes[2],
nodes[4], cell);
} }
} }
else if ((n1==11)||(n1==21)||(n1==24)||(n1==25)) {//103 else if ((n1 == 11) || (n1 == 21) || (n1 == 24) ||
(n1 == 25))
{ //103
fgets(s2, 100, myFileId); fgets(s2, 100, myFileId);
if (n_nodes==3) { if (n_nodes == 3)
{
for (i = 1; i <= n_nodes; i++) for (i = 1; i <= n_nodes; i++)
fscanf(myFileId, "%d", &nodes[i - 1]); fscanf(myFileId, "%d", &nodes[i - 1]);
ok = myMesh->AddEdgeWithID(nodes[0],nodes[1],cell); ok = myMesh->AddEdgeWithID(nodes[0], nodes[1],
cell);
//MESSAGE("in 103 "<<cell); //MESSAGE("in 103 "<<cell);
} }
else if (n_nodes==2) {//102 else if (n_nodes == 2)
{ //102
for (i = 1; i <= n_nodes; i++) for (i = 1; i <= n_nodes; i++)
fscanf(myFileId, "%d", &nodes[i - 1]); fscanf(myFileId, "%d", &nodes[i - 1]);
ok = myMesh->AddEdgeWithID(nodes[0],nodes[1],cell); ok = myMesh->AddEdgeWithID(nodes[0], nodes[1],
cell);
//MESSAGE("in 102 "<<cell); //MESSAGE("in 102 "<<cell);
} }
} }
@ -126,7 +158,8 @@ void DriverUNV_R_SMDS_Mesh::Read() {
found_block2412 = true; found_block2412 = true;
break; break;
} }
case -1 : { case -1:
{
break; break;
} }
default: default:

View File

@ -6,22 +6,21 @@
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "Mesh_Reader.h" #include "Mesh_Reader.h"
class DriverUNV_R_SMDS_Mesh : public Mesh_Reader { class DriverUNV_R_SMDS_Mesh:public Mesh_Reader
{
public : public:DriverUNV_R_SMDS_Mesh();
DriverUNV_R_SMDS_Mesh();
~DriverUNV_R_SMDS_Mesh(); ~DriverUNV_R_SMDS_Mesh();
void Add(); void Add();
void Read(); void Read();
void SetMesh(Handle(SMDS_Mesh)& aMesh); void SetMesh(SMDS_Mesh * aMesh);
void SetFile(string); void SetFile(string);
void SetFileId(FILE *); void SetFileId(FILE *);
void SetMeshId(int); void SetMeshId(int);
private : private: SMDS_Mesh * myMesh;
Handle_SMDS_Mesh myMesh;
string myFile; string myFile;
FILE *myFileId; FILE *myFileId;
int myMeshId; int myMeshId;

View File

@ -4,24 +4,29 @@ using namespace std;
#include "utilities.h" #include "utilities.h"
int getOne() { int getOne()
{
printf("in getOne"); printf("in getOne");
return (1); return (1);
} }
extern "C" { extern "C"
{
// Document_Reader* maker() { // Document_Reader* maker() {
DriverUNV_R_SMESHDS_Document* maker() { DriverUNV_R_SMESHDS_Document *maker()
{
fprintf(stdout, "here in maker\n"); fprintf(stdout, "here in maker\n");
return new DriverUNV_R_SMESHDS_Document; return new DriverUNV_R_SMESHDS_Document;
} }
} }
DriverUNV_R_SMESHDS_Document::DriverUNV_R_SMESHDS_Document() { DriverUNV_R_SMESHDS_Document::DriverUNV_R_SMESHDS_Document()
{
myFile = string(""); myFile = string("");
} }
DriverUNV_R_SMESHDS_Document::~DriverUNV_R_SMESHDS_Document() { DriverUNV_R_SMESHDS_Document::~DriverUNV_R_SMESHDS_Document()
{
; ;
} }
@ -33,7 +38,8 @@ DriverUNV_R_SMESHDS_Document::~DriverUNV_R_SMESHDS_Document() {
//myDocument = aDoc; //myDocument = aDoc;
//} //}
void DriverUNV_R_SMESHDS_Document::Read() { void DriverUNV_R_SMESHDS_Document::Read()
{
int myMeshId; int myMeshId;
SCRUTE(myFile); SCRUTE(myFile);
@ -65,14 +71,14 @@ void DriverUNV_R_SMESHDS_Document::Read() {
string myClass = string("SMESHDS_Mesh"); string myClass = string("SMESHDS_Mesh");
string myExtension = string("UNV"); string myExtension = string("UNV");
for (int meshIt=1;meshIt<=nmaa;meshIt++) { for (int meshIt = 1; meshIt <= nmaa; meshIt++)
{
myMeshId = myDocument->NewMesh(); myMeshId = myDocument->NewMesh();
Handle(SMDS_Mesh) myMesh = myDocument->GetMesh(myMeshId); SMDS_Mesh * myMesh = myDocument->GetMesh(myMeshId);
DriverUNV_R_SMESHDS_Mesh *myReader = new DriverUNV_R_SMESHDS_Mesh; DriverUNV_R_SMESHDS_Mesh *myReader = new DriverUNV_R_SMESHDS_Mesh;
myReader->SetMesh(myMesh); myReader->SetMesh(myMesh);
myReader->SetFile(myFile); myReader->SetFile(myFile);
//myReader->SetFileId(fid); //myReader->SetFileId(fid);
@ -81,5 +87,4 @@ void DriverUNV_R_SMESHDS_Document::Read() {
} }
} }

View File

@ -4,36 +4,44 @@ using namespace std;
#include "utilities.h" #include "utilities.h"
DriverUNV_R_SMESHDS_Mesh::DriverUNV_R_SMESHDS_Mesh() { DriverUNV_R_SMESHDS_Mesh::DriverUNV_R_SMESHDS_Mesh()
{
; ;
} }
DriverUNV_R_SMESHDS_Mesh::~DriverUNV_R_SMESHDS_Mesh() { DriverUNV_R_SMESHDS_Mesh::~DriverUNV_R_SMESHDS_Mesh()
{
; ;
} }
void DriverUNV_R_SMESHDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) { void DriverUNV_R_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
//myMesh = Handle(SMESHDS_Mesh)::DownCast(aMesh); {
//myMesh = SMESHDS_Mesh *::DownCast(aMesh);
myMesh = aMesh; myMesh = aMesh;
} }
void DriverUNV_R_SMESHDS_Mesh::SetFile(string aFile) { void DriverUNV_R_SMESHDS_Mesh::SetFile(string aFile)
{
myFile = aFile; myFile = aFile;
} }
void DriverUNV_R_SMESHDS_Mesh::SetFileId(FILE* aFileId) { void DriverUNV_R_SMESHDS_Mesh::SetFileId(FILE * aFileId)
{
myFileId = aFileId; myFileId = aFileId;
} }
void DriverUNV_R_SMESHDS_Mesh::SetMeshId(int aMeshId) { void DriverUNV_R_SMESHDS_Mesh::SetMeshId(int aMeshId)
{
myMeshId = aMeshId; myMeshId = aMeshId;
} }
void DriverUNV_R_SMESHDS_Mesh::Add() { void DriverUNV_R_SMESHDS_Mesh::Add()
{
; ;
} }
void DriverUNV_R_SMESHDS_Mesh::Read() { void DriverUNV_R_SMESHDS_Mesh::Read()
{
string myClass = string("SMDS_Mesh"); string myClass = string("SMDS_Mesh");
string myExtension = string("UNV"); string myExtension = string("UNV");

View File

@ -6,22 +6,21 @@
#include "SMESHDS_Mesh.hxx" #include "SMESHDS_Mesh.hxx"
#include "Mesh_Reader.h" #include "Mesh_Reader.h"
class DriverUNV_R_SMESHDS_Mesh : public Mesh_Reader { class DriverUNV_R_SMESHDS_Mesh:public Mesh_Reader
{
public : public:DriverUNV_R_SMESHDS_Mesh();
DriverUNV_R_SMESHDS_Mesh();
~DriverUNV_R_SMESHDS_Mesh(); ~DriverUNV_R_SMESHDS_Mesh();
void Add(); void Add();
void Read(); void Read();
void SetMesh(Handle(SMDS_Mesh)& aMesh); void SetMesh(SMDS_Mesh * aMesh);
void SetFile(string); void SetFile(string);
void SetFileId(FILE *); void SetFileId(FILE *);
void SetMeshId(int); void SetMeshId(int);
private : private: SMDS_Mesh * myMesh;
Handle_SMDS_Mesh myMesh;
string myFile; string myFile;
FILE *myFileId; FILE *myFileId;
int myMeshId; int myMeshId;

View File

@ -3,10 +3,10 @@ using namespace std;
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_MeshEdgesIterator.hxx"
#include "SMDS_MeshFacesIterator.hxx"
#include "SMDS_MeshNodesIterator.hxx"
#include "SMDS_MeshVolumesIterator.hxx"
#include <utilities.h> #include <utilities.h>
@ -19,35 +19,43 @@ using namespace std;
#define sELT_BEAM_DESC1 "%10d %2d 1 1 7 %1d\n" #define sELT_BEAM_DESC1 "%10d %2d 1 1 7 %1d\n"
#define sELT_BEAM_DESC2 " 0 1 1\n" #define sELT_BEAM_DESC2 " 0 1 1\n"
DriverUNV_W_SMDS_Mesh::DriverUNV_W_SMDS_Mesh() { DriverUNV_W_SMDS_Mesh::DriverUNV_W_SMDS_Mesh()
{
; ;
} }
DriverUNV_W_SMDS_Mesh::~DriverUNV_W_SMDS_Mesh() { DriverUNV_W_SMDS_Mesh::~DriverUNV_W_SMDS_Mesh()
{
; ;
} }
void DriverUNV_W_SMDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) { void DriverUNV_W_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
{
myMesh = aMesh; myMesh = aMesh;
} }
void DriverUNV_W_SMDS_Mesh::SetFile(string aFile) { void DriverUNV_W_SMDS_Mesh::SetFile(string aFile)
{
myFile = aFile; myFile = aFile;
} }
void DriverUNV_W_SMDS_Mesh::SetFileId(FILE* aFileId) { void DriverUNV_W_SMDS_Mesh::SetFileId(FILE * aFileId)
{
myFileId = aFileId; myFileId = aFileId;
} }
void DriverUNV_W_SMDS_Mesh::SetMeshId(int aMeshId) { void DriverUNV_W_SMDS_Mesh::SetMeshId(int aMeshId)
{
myMeshId = aMeshId; myMeshId = aMeshId;
} }
void DriverUNV_W_SMDS_Mesh::Add() { void DriverUNV_W_SMDS_Mesh::Add()
{
; ;
} }
void DriverUNV_W_SMDS_Mesh::Write() { void DriverUNV_W_SMDS_Mesh::Write()
{
int nbNodes, nbCells; int nbNodes, nbCells;
int i; int i;
@ -71,7 +79,7 @@ void DriverUNV_W_SMDS_Mesh::Write() {
nbNodes = myMesh->NbNodes(); nbNodes = myMesh->NbNodes();
/* Combien de mailles, faces ou aretes ? */ /* Combien de mailles, faces ou aretes ? */
Standard_Integer nb_of_nodes, nb_of_edges,nb_of_faces, nb_of_volumes; int nb_of_nodes, nb_of_edges, nb_of_faces, nb_of_volumes;
nb_of_edges = myMesh->NbEdges(); nb_of_edges = myMesh->NbEdges();
nb_of_faces = myMesh->NbFaces(); nb_of_faces = myMesh->NbFaces();
nb_of_volumes = myMesh->NbVolumes(); nb_of_volumes = myMesh->NbVolumes();
@ -90,18 +98,19 @@ void DriverUNV_W_SMDS_Mesh::Write() {
fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n"); fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
fprintf(stdout, "(************************)\n"); fprintf(stdout, "(************************)\n");
SMDS_MeshNodesIterator itNodes(myMesh);
fprintf(myFileId, "%s\n", sUNV_SEPARATOR); fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
fprintf(myFileId, "%s\n", sNODE_UNV_ID); fprintf(myFileId, "%s\n", sNODE_UNV_ID);
for (;itNodes.More();itNodes.Next()) { SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
const Handle(SMDS_MeshElement)& elem = itNodes.Value(); while(itNodes->more())
const Handle(SMDS_MeshNode )& node = myMesh->GetNode(1, elem); {
const SMDS_MeshNode * node = itNodes->next();
fprintf(myFileId, sNODE_UNV_DESCR, node->GetID()); fprintf(myFileId, sNODE_UNV_DESCR, node->GetID());
fprintf(myFileId, "%25.16E%25.16E%25.16E\n", node->X(), node->Y(), node->Z()); fprintf(myFileId, "%25.16E%25.16E%25.16E\n", node->X(), node->Y(),
node->Z());
} }
delete itNodes;
fprintf(myFileId, "%s\n", sUNV_SEPARATOR); fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
/**************************************************************************** /****************************************************************************
@ -115,81 +124,106 @@ void DriverUNV_W_SMDS_Mesh::Write() {
fprintf(myFileId, "%s\n", sUNV_SEPARATOR); fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
fprintf(myFileId, "%s\n", sELT_UNV_ID); fprintf(myFileId, "%s\n", sELT_UNV_ID);
SMDS_MeshEdgesIterator itEdges(myMesh); SMDS_Iterator<const SMDS_MeshEdge *> * itEdges=myMesh->edgesIterator();
for (;itEdges.More();itEdges.Next()) { while(itEdges->more())
const Handle(SMDS_MeshElement)& elem = itEdges.Value(); {
const SMDS_MeshElement * elem = itEdges->next();
SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
switch (elem->NbNodes()) { switch (elem->NbNodes())
case 2 : { {
fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 21, elem->NbNodes()); case 2:
fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 21,
elem->NbNodes());
fprintf(myFileId, sELT_BEAM_DESC2); fprintf(myFileId, sELT_BEAM_DESC2);
fprintf(myFileId, "%10d%10d\n", elem->GetConnection(1), elem->GetConnection(2)); fprintf(myFileId, "%10d%10d\n", itn->next()->GetID(),
itn->next()->GetID());
break;
case 3:
fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 24,
elem->NbNodes());
fprintf(myFileId, sELT_BEAM_DESC2);
fprintf(myFileId, "%10d%10d%10d\n", itn->next()->GetID(),
itn->next()->GetID(), itn->next()->GetID());
break; break;
} }
case 3 : { delete itn;
fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 24, elem->NbNodes());
fprintf(myFileId, sELT_BEAM_DESC2);
fprintf(myFileId, "%10d%10d%10d\n",elem->GetConnection(1), elem->GetConnection(2), elem->GetConnection(3));
break;
}
}
} }
delete itEdges;
SMDS_MeshFacesIterator itFaces(myMesh); SMDS_Iterator<const SMDS_MeshFace*> * itFaces=myMesh->facesIterator();
for (;itFaces.More();itFaces.Next()) { while(itFaces->more())
const Handle(SMDS_MeshElement)& elem = itFaces.Value(); {
const SMDS_MeshElement * elem = itFaces->next();
switch (elem->NbNodes()) { switch (elem->NbNodes())
{
case 3: case 3:
// linear triangle // linear triangle
fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 74, elem->NbNodes()); fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 74,
elem->NbNodes());
break; break;
case 4: case 4:
// linear quadrilateral // linear quadrilateral
fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 71, elem->NbNodes()); fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 71,
elem->NbNodes());
break; break;
case 6: case 6:
// parabolic triangle // parabolic triangle
fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 72, elem->NbNodes()); fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 72,
elem->NbNodes());
break; break;
case 8: case 8:
// parabolic quadrilateral // parabolic quadrilateral
fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 75, elem->NbNodes()); fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 75,
elem->NbNodes());
break; break;
default: default:
fprintf(myFileId, "element not registered\n"); fprintf(myFileId, "element not registered\n");
} }
for (i=0;i<elem->NbNodes();i++) SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
fprintf(myFileId,"%10d",elem->GetConnection(i+1)); while(itn->more()) fprintf(myFileId, "%10d", itn->next()->GetID());
delete itn;
fprintf(myFileId, "\n"); fprintf(myFileId, "\n");
} }
delete itFaces;
SMDS_MeshVolumesIterator itVolumes(myMesh); SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=myMesh->volumesIterator();
for (;itVolumes.More();itVolumes.Next()) { while(itVolumes->more())
const Handle(SMDS_MeshElement)& elem = itVolumes.Value(); {
const SMDS_MeshElement * elem = itVolumes->next();
switch (elem->NbNodes()) { switch (elem->NbNodes())
{
case 4: case 4:
// linear tetrahedron // linear tetrahedron
fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 111, elem->NbNodes()); fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 111,
elem->NbNodes());
break; break;
case 6: case 6:
// linear tetrahedron // linear tetrahedron
fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 112, elem->NbNodes()); fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 112,
elem->NbNodes());
break; break;
case 8: case 8:
// linear brick // linear brick
fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 115, elem->NbNodes()); fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 115,
elem->NbNodes());
break; break;
} }
for (i=0;i<elem->NbNodes();i++) SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
fprintf(myFileId,"%10d",elem->GetConnection(i+1)); while(itn->more()) fprintf(myFileId, "%10d", itn->next()->GetID());
delete itn;
fprintf(myFileId, "\n"); fprintf(myFileId, "\n");
} }
delete itVolumes;
fprintf(myFileId, "%s\n", sUNV_SEPARATOR); fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
fclose(myFileId); fclose(myFileId);

View File

@ -7,22 +7,21 @@
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "Mesh_Writer.h" #include "Mesh_Writer.h"
class DriverUNV_W_SMDS_Mesh : public Mesh_Writer { class DriverUNV_W_SMDS_Mesh:public Mesh_Writer
{
public : public:DriverUNV_W_SMDS_Mesh();
DriverUNV_W_SMDS_Mesh();
~DriverUNV_W_SMDS_Mesh(); ~DriverUNV_W_SMDS_Mesh();
void Add(); void Add();
void Write(); void Write();
void SetMesh(Handle(SMDS_Mesh)& aMesh); void SetMesh(SMDS_Mesh * aMesh);
void SetFile(string); void SetFile(string);
void SetFileId(FILE *); void SetFileId(FILE *);
void SetMeshId(int); void SetMeshId(int);
private : private: SMDS_Mesh * myMesh;
Handle_SMDS_Mesh myMesh;
string myFile; string myFile;
FILE *myFileId; FILE *myFileId;
int myMeshId; int myMeshId;

View File

@ -6,16 +6,19 @@ using namespace std;
extern "C" extern "C"
{ {
Document_Writer* Wmaker() { Document_Writer *Wmaker()
{
return new DriverUNV_W_SMESHDS_Document; return new DriverUNV_W_SMESHDS_Document;
} }
} }
DriverUNV_W_SMESHDS_Document::DriverUNV_W_SMESHDS_Document() { DriverUNV_W_SMESHDS_Document::DriverUNV_W_SMESHDS_Document()
{
; ;
} }
DriverUNV_W_SMESHDS_Document::~DriverUNV_W_SMESHDS_Document() { DriverUNV_W_SMESHDS_Document::~DriverUNV_W_SMESHDS_Document()
{
; ;
} }
@ -27,9 +30,10 @@ DriverUNV_W_SMESHDS_Document::~DriverUNV_W_SMESHDS_Document() {
//myDocument = aDocument; //myDocument = aDocument;
//} //}
void DriverUNV_W_SMESHDS_Document::Write() { void DriverUNV_W_SMESHDS_Document::Write()
{
Handle(SMESHDS_Mesh) myMesh; SMESHDS_Mesh * myMesh;
/**************************************************************************** /****************************************************************************
* OUVERTURE DU FICHIER EN ECRITURE * * OUVERTURE DU FICHIER EN ECRITURE *
@ -60,9 +64,10 @@ void DriverUNV_W_SMESHDS_Document::Write() {
//numero++; //numero++;
//myMesh = myDocument->GetMesh(numero); //myMesh = myDocument->GetMesh(numero);
myDocument->InitMeshesIterator(); myDocument->InitMeshesIterator();
for (;myDocument->MoreMesh();myDocument->NextMesh()) { while(myDocument->MoreMesh())
{
numero++; numero++;
myMesh = myDocument->CurrentMesh(); myMesh = myDocument->NextMesh();
DriverUNV_W_SMESHDS_Mesh *myWriter = new DriverUNV_W_SMESHDS_Mesh; DriverUNV_W_SMESHDS_Mesh *myWriter = new DriverUNV_W_SMESHDS_Mesh;
//Mesh_Writer* myWriter = Driver::GetMeshWriter(myExtension, myClass); //Mesh_Writer* myWriter = Driver::GetMeshWriter(myExtension, myClass);

View File

@ -4,10 +4,10 @@ using namespace std;
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_MeshEdgesIterator.hxx"
#include "SMDS_MeshFacesIterator.hxx"
#include "SMDS_MeshNodesIterator.hxx"
#include "SMDS_MeshVolumesIterator.hxx"
#include "utilities.h" #include "utilities.h"
@ -20,32 +20,39 @@ using namespace std;
#define sELT_BEAM_DESC1 "%10d %2d 1 1 7 %1d\n" #define sELT_BEAM_DESC1 "%10d %2d 1 1 7 %1d\n"
#define sELT_BEAM_DESC2 " 0 1 1\n" #define sELT_BEAM_DESC2 " 0 1 1\n"
DriverUNV_W_SMESHDS_Mesh::DriverUNV_W_SMESHDS_Mesh() { DriverUNV_W_SMESHDS_Mesh::DriverUNV_W_SMESHDS_Mesh()
{
; ;
} }
DriverUNV_W_SMESHDS_Mesh::~DriverUNV_W_SMESHDS_Mesh() { DriverUNV_W_SMESHDS_Mesh::~DriverUNV_W_SMESHDS_Mesh()
{
; ;
} }
void DriverUNV_W_SMESHDS_Mesh::SetMesh(Handle(SMDS_Mesh)& aMesh) { void DriverUNV_W_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh)
//myMesh = Handle(SMESHDS_Mesh)::DownCast(aMesh); {
//myMesh = SMESHDS_Mesh *::DownCast(aMesh);
myMesh = aMesh; myMesh = aMesh;
} }
void DriverUNV_W_SMESHDS_Mesh::SetFile(string aFile) { void DriverUNV_W_SMESHDS_Mesh::SetFile(string aFile)
{
myFile = aFile; myFile = aFile;
} }
void DriverUNV_W_SMESHDS_Mesh::SetFileId(FILE* aFileId) { void DriverUNV_W_SMESHDS_Mesh::SetFileId(FILE * aFileId)
{
myFileId = aFileId; myFileId = aFileId;
} }
void DriverUNV_W_SMESHDS_Mesh::SetMeshId(int aMeshId) { void DriverUNV_W_SMESHDS_Mesh::SetMeshId(int aMeshId)
{
myMeshId = aMeshId; myMeshId = aMeshId;
} }
void DriverUNV_W_SMESHDS_Mesh::Write() { void DriverUNV_W_SMESHDS_Mesh::Write()
{
string myClass = string("SMDS_Mesh"); string myClass = string("SMDS_Mesh");
string myExtension = string("UNV"); string myExtension = string("UNV");
@ -59,9 +66,10 @@ void DriverUNV_W_SMESHDS_Mesh::Write() {
myWriter->Write(); myWriter->Write();
} }
void DriverUNV_W_SMESHDS_Mesh::Add() {
void DriverUNV_W_SMESHDS_Mesh::Add()
{
int nbNodes, nbCells; int nbNodes, nbCells;
int i; int i;
@ -84,7 +92,7 @@ void DriverUNV_W_SMESHDS_Mesh::Add() {
nbNodes = myMesh->NbNodes(); nbNodes = myMesh->NbNodes();
/* Combien de mailles, faces ou aretes ? */ /* Combien de mailles, faces ou aretes ? */
Standard_Integer nb_of_nodes, nb_of_edges,nb_of_faces, nb_of_volumes; int nb_of_nodes, nb_of_edges, nb_of_faces, nb_of_volumes;
nb_of_edges = myMesh->NbEdges(); nb_of_edges = myMesh->NbEdges();
nb_of_faces = myMesh->NbFaces(); nb_of_faces = myMesh->NbFaces();
nb_of_volumes = myMesh->NbVolumes(); nb_of_volumes = myMesh->NbVolumes();
@ -100,18 +108,20 @@ void DriverUNV_W_SMESHDS_Mesh::Add() {
fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n"); fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
fprintf(stdout, "(************************)\n"); fprintf(stdout, "(************************)\n");
SMDS_MeshNodesIterator itNodes(myMesh);
fprintf(myFileId, "%s\n", sUNV_SEPARATOR); fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
fprintf(myFileId, "%s\n", sNODE_UNV_ID); fprintf(myFileId, "%s\n", sNODE_UNV_ID);
for (;itNodes.More();itNodes.Next()) { SMDS_Iterator<const SMDS_MeshNode *> * itNodes=myMesh->nodesIterator();
const Handle(SMDS_MeshElement)& elem = itNodes.Value(); while(itNodes->more())
const Handle(SMDS_MeshNode )& node = myMesh->GetNode(1, elem); {
const SMDS_MeshNode * node = itNodes->next();
fprintf(myFileId, sNODE_UNV_DESCR, node->GetID()); fprintf(myFileId, sNODE_UNV_DESCR, node->GetID());
fprintf(myFileId, "%25.16E%25.16E%25.16E\n", node->X(), node->Y(), node->Z()); fprintf(myFileId, "%25.16E%25.16E%25.16E\n", node->X(), node->Y(),
node->Z());
} }
delete itNodes;
fprintf(myFileId, "%s\n", sUNV_SEPARATOR); fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
/**************************************************************************** /****************************************************************************
@ -125,83 +135,105 @@ void DriverUNV_W_SMESHDS_Mesh::Add() {
fprintf(myFileId, "%s\n", sUNV_SEPARATOR); fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
fprintf(myFileId, "%s\n", sELT_UNV_ID); fprintf(myFileId, "%s\n", sELT_UNV_ID);
SMDS_MeshEdgesIterator itEdges(myMesh); SMDS_Iterator<const SMDS_MeshEdge *> * itEdges=myMesh->edgesIterator();
for (;itEdges.More();itEdges.Next()) { while(itEdges->more())
const Handle(SMDS_MeshElement)& elem = itEdges.Value(); {
const SMDS_MeshEdge * elem = itEdges->next();
SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
switch (elem->NbNodes()) { switch (elem->NbNodes())
case 2 : { {
fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 21, elem->NbNodes()); case 2:
fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 21,
elem->NbNodes());
fprintf(myFileId, sELT_BEAM_DESC2); fprintf(myFileId, sELT_BEAM_DESC2);
fprintf(myFileId, "%10d%10d\n", elem->GetConnection(1), elem->GetConnection(2)); fprintf(myFileId, "%10d%10d\n", itn->next()->GetID(),
itn->next()->GetID());
break;
case 3:
fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 24,
elem->NbNodes());
fprintf(myFileId, sELT_BEAM_DESC2);
fprintf(myFileId, "%10d%10d%10d\n", itn->next()->GetID(),
itn->next()->GetID(), itn->next()->GetID());
break; break;
} }
case 3 : { delete itn;
fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 24, elem->NbNodes());
fprintf(myFileId, sELT_BEAM_DESC2);
fprintf(myFileId, "%10d%10d%10d\n",elem->GetConnection(1), elem->GetConnection(2), elem->GetConnection(3));
break;
}
}
} }
delete itEdges;
SMDS_MeshFacesIterator itFaces(myMesh); SMDS_Iterator<const SMDS_MeshFace*> * itFaces=myMesh->facesIterator();
for (;itFaces.More();itFaces.Next()) { while(itFaces->more())
const Handle(SMDS_MeshElement)& elem = itFaces.Value(); {
const SMDS_MeshElement * elem = itFaces->next();
switch (elem->NbNodes()) { switch (elem->NbNodes())
{
case 3: case 3:
// linear triangle // linear triangle
fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 74, elem->NbNodes()); fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 74,
elem->NbNodes());
break; break;
case 4: case 4:
// linear quadrilateral // linear quadrilateral
fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 71, elem->NbNodes()); fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 71,
elem->NbNodes());
break; break;
case 6: case 6:
// parabolic triangle // parabolic triangle
fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 72, elem->NbNodes()); fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 72,
elem->NbNodes());
break; break;
case 8: case 8:
// parabolic quadrilateral // parabolic quadrilateral
fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 75, elem->NbNodes()); fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 75,
elem->NbNodes());
break; break;
default: default:
fprintf(myFileId, "element not registered\n"); fprintf(myFileId, "element not registered\n");
} }
for (i=0;i<elem->NbNodes();i++) SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
fprintf(myFileId,"%10d",elem->GetConnection(i+1)); while(itn->more()) fprintf(myFileId, "%10d", itn->next()->GetID());
delete itn;
fprintf(myFileId, "\n"); fprintf(myFileId, "\n");
} }
delete itFaces;
SMDS_MeshVolumesIterator itVolumes(myMesh); SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=myMesh->volumesIterator();
for (;itVolumes.More();itVolumes.Next()) { while(itVolumes->more())
const Handle(SMDS_MeshElement)& elem = itVolumes.Value(); {
const SMDS_MeshElement * elem = itVolumes->next();
switch (elem->NbNodes()) { switch (elem->NbNodes())
{
case 4: case 4:
// linear tetrahedron // linear tetrahedron
fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 111, elem->NbNodes()); fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 111,
elem->NbNodes());
break; break;
case 6: case 6:
// linear tetrahedron // linear tetrahedron
fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 112, elem->NbNodes()); fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 112,
elem->NbNodes());
break; break;
case 8: case 8:
// linear brick // linear brick
fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 115, elem->NbNodes()); fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 115,
elem->NbNodes());
break; break;
} }
for (i=0;i<elem->NbNodes();i++) SMDS_Iterator<const SMDS_MeshElement*> *itn=elem->nodesIterator();
fprintf(myFileId,"%10d",elem->GetConnection(i+1)); while(itn->more()) fprintf(myFileId, "%10d", itn->next()->GetID());
delete itn;
fprintf(myFileId, "\n"); fprintf(myFileId, "\n");
} }
delete itVolumes;
fprintf(myFileId, "%s\n", sUNV_SEPARATOR); fprintf(myFileId, "%s\n", sUNV_SEPARATOR);
fclose(myFileId); fclose(myFileId);
} }

View File

@ -7,22 +7,21 @@
#include "SMESHDS_Mesh.hxx" #include "SMESHDS_Mesh.hxx"
#include "Mesh_Writer.h" #include "Mesh_Writer.h"
class DriverUNV_W_SMESHDS_Mesh : public Mesh_Writer { class DriverUNV_W_SMESHDS_Mesh:public Mesh_Writer
{
public : public:DriverUNV_W_SMESHDS_Mesh();
DriverUNV_W_SMESHDS_Mesh();
~DriverUNV_W_SMESHDS_Mesh(); ~DriverUNV_W_SMESHDS_Mesh();
void Add(); void Add();
void Write(); void Write();
void SetMesh(Handle(SMDS_Mesh)& aMesh); void SetMesh(SMDS_Mesh * aMesh);
void SetFile(string); void SetFile(string);
void SetFileId(FILE *); void SetFileId(FILE *);
void SetMeshId(int); void SetMeshId(int);
private : private: SMDS_Mesh * myMesh;
Handle_SMDS_Mesh myMesh;
string myFile; string myFile;
FILE *myFileId; FILE *myFileId;
int myMeshId; int myMeshId;