Version: 6.3.1
Public Types | Public Member Functions | Protected Attributes

DriverDAT_W_SMDS_Mesh Class Reference

#include <DriverDAT_W_SMDS_Mesh.h>

Inheritance diagram for DriverDAT_W_SMDS_Mesh:
Inheritance graph
[legend]

Public Types

enum  Status {
  DRS_OK, DRS_EMPTY, DRS_WARN_RENUMBER, DRS_WARN_SKIP_ELEM,
  DRS_FAIL
}

Public Member Functions

virtual Status Perform ()
void SetMesh (SMDS_Mesh *theMesh)
void SetMeshId (int theMeshId)
void SetFile (const std::string &theFileName)

Protected Attributes

SMDS_MeshmyMesh
std::string myFile
int myMeshId

Detailed Description

Definition at line 34 of file DriverDAT_W_SMDS_Mesh.h.


Member Enumeration Documentation

enum Driver_Mesh::Status [inherited]
Enumerator:
DRS_OK 
DRS_EMPTY 
DRS_WARN_RENUMBER 
DRS_WARN_SKIP_ELEM 
DRS_FAIL 

Definition at line 48 of file Driver_Mesh.h.

              {
    DRS_OK,
    DRS_EMPTY,          // a file contains no mesh with the given name
    DRS_WARN_RENUMBER,  // a file has overlapped ranges of element numbers,
                        // so the numbers from the file are ignored
    DRS_WARN_SKIP_ELEM, // some elements were skipped due to incorrect file data
    DRS_FAIL            // general failure (exception etc.)
  };

Member Function Documentation

Driver_Mesh::Status DriverDAT_W_SMDS_Mesh::Perform ( ) [virtual]

Implements Driver_Mesh.

Definition at line 35 of file DriverDAT_W_SMDS_Mesh.cxx.

References SMESH.DRS_FAIL, SMESH.DRS_OK, SMDS_MeshElement.GetID(), SMDS_MeshElement.NbNodes(), ex29_refine.node(), SMDS_MeshElement.nodesIterator(), SMDS_MeshNode.X(), SMDS_MeshNode.Y(), and SMDS_MeshNode.Z().

Referenced by SMESH_Mesh.ExportDAT().

{
  Kernel_Utils::Localizer loc;
  Status aResult = DRS_OK;

  int nbNodes, nbCells;
  //int i;
  
  char *file2Read = (char *)myFile.c_str();
  FILE* aFileId = fopen(file2Read, "w+");
  if (aFileId < 0) {
    fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read);
    return DRS_FAIL;
  }
  SCRUTE(myMesh);
  /****************************************************************************
   *                       NOMBRES D'OBJETS                                    *
   ****************************************************************************/
  fprintf(stdout, "\n(****************************)\n");
  fprintf(stdout, "(* INFORMATIONS GENERALES : *)\n");
  fprintf(stdout, "(****************************)\n");
  
  /* Combien de noeuds ? */
  nbNodes = myMesh->NbNodes();
  
  /* Combien de mailles, faces ou aretes ? */
  int /*nb_of_nodes,*/ nb_of_edges, nb_of_faces, nb_of_volumes;
  nb_of_edges = myMesh->NbEdges();
  nb_of_faces = myMesh->NbFaces();
  nb_of_volumes = myMesh->NbVolumes();
  nbCells = nb_of_edges + nb_of_faces + nb_of_volumes;
  SCRUTE(nb_of_edges);
  SCRUTE(nb_of_faces);
  SCRUTE(nb_of_volumes);
  
  fprintf(stdout, "%d %d\n", nbNodes, nbCells);
  fprintf(aFileId, "%d %d\n", nbNodes, nbCells);
  
  /****************************************************************************
   *                       ECRITURE DES NOEUDS                                 *
   ****************************************************************************/
  fprintf(stdout, "\n(************************)\n");
  fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n");
  fprintf(stdout, "(************************)\n");
  
  SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator();
  while(itNodes->more()){               
    const SMDS_MeshNode * node = itNodes->next();
    fprintf(aFileId, "%d %e %e %e\n", node->GetID(), node->X(), node->Y(), node->Z());
  }
        
  /****************************************************************************
   *                       ECRITURE DES ELEMENTS                                *
   ****************************************************************************/
  fprintf(stdout, "\n(**************************)\n");
  fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n");
  fprintf(stdout, "(**************************)");
  /* Ecriture des connectivites, noms, numeros des mailles */
  
  SMDS_EdgeIteratorPtr itEdges=myMesh->edgesIterator();
  while(itEdges->more()){
    const SMDS_MeshElement * elem = itEdges->next();
    switch (elem->NbNodes()) {
    case 2:
      fprintf(aFileId, "%d %d ", elem->GetID(), 102);
      break;
    case 3:
      fprintf(aFileId, "%d %d ", elem->GetID(), 103);
      break;
    }
    SMDS_ElemIteratorPtr it=elem->nodesIterator();
    while(it->more()) 
      fprintf(aFileId, "%d ", it->next()->GetID());
    fprintf(aFileId, "\n");
  }
  
  SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator();
  while(itFaces->more()){
    const SMDS_MeshElement * elem = itFaces->next();
    switch (elem->NbNodes()) {
    case 3:
      fprintf(aFileId, "%d %d ", elem->GetID(), 203);
      break;
    case 4:
      fprintf(aFileId, "%d %d ", elem->GetID(), 204);
      break;
    case 6:
      fprintf(aFileId, "%d %d ", elem->GetID(), 206);
      break;
    }
    SMDS_ElemIteratorPtr it=elem->nodesIterator();
    while(it->more()) 
      fprintf(aFileId, "%d ", it->next()->GetID());
    fprintf(aFileId, "\n");
  }

  SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator();
  while(itVolumes->more()){
    const SMDS_MeshElement * elem = itVolumes->next();
    switch (elem->NbNodes()) {
    case 8:
      fprintf(aFileId, "%d %d ", elem->GetID(), 308);
      break;
    }

    SMDS_ElemIteratorPtr it=elem->nodesIterator();
    while(it->more()) 
      fprintf(aFileId, "%d ", it->next()->GetID());

    fprintf(aFileId, "\n");
  }
  
  fclose(aFileId);

  return aResult;
}
void Driver_Mesh::SetFile ( const std::string &  theFileName) [inherited]
void Driver_SMDS_Mesh::SetMesh ( SMDS_Mesh theMesh) [inherited]
void Driver_Mesh::SetMeshId ( int  theMeshId) [inherited]

Field Documentation

std::string Driver_Mesh.myFile [protected, inherited]
SMDS_Mesh* Driver_SMDS_Mesh.myMesh [protected, inherited]
int Driver_Mesh.myMeshId [protected, inherited]

Definition at line 63 of file Driver_Mesh.h.

Referenced by DriverMED_W_SMESHDS_Mesh.Perform(), and Driver_Mesh.SetMeshId().

Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS