Back to index

salome-smesh  6.5.0
Functions | Variables
DriverSTL_W_SMDS_Mesh.cxx File Reference
#include <stdio.h>
#include <limits>
#include "DriverSTL_W_SMDS_Mesh.h"
#include "SMDS_FaceOfNodes.hxx"
#include "SMDS_IteratorOnIterators.hxx"
#include "SMDS_Mesh.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_SetIterator.hxx"
#include "SMDS_VolumeTool.hxx"
#include "SMESH_TypeDefs.hxx"
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
#include <OSD_Protection.hxx>
#include <TCollection_AsciiString.hxx>
#include <gp_XYZ.hxx>
#include "utilities.h"

Go to the source code of this file.

Functions

static void writeInteger (const Standard_Integer &theVal, OSD_File &ofile)
static void writeFloat (const Standard_ShortReal &theVal, OSD_File &ofile)
static gp_XYZ getNormale (const SMDS_MeshNode *n1, const SMDS_MeshNode *n2, const SMDS_MeshNode *n3)
static int getTriangles (const SMDS_MeshElement *face, const SMDS_MeshNode **nodes)
 Decompose a mesh face into triangles.

Variables

static const int LABEL_SIZE = 80

Function Documentation

static gp_XYZ getNormale ( const SMDS_MeshNode *  n1,
const SMDS_MeshNode *  n2,
const SMDS_MeshNode *  n3 
) [static]

Definition at line 180 of file DriverSTL_W_SMDS_Mesh.cxx.

{
  SMESH_TNodeXYZ xyz1( n1 );
  SMESH_TNodeXYZ xyz2( n2 );
  SMESH_TNodeXYZ xyz3( n3 );
  gp_XYZ q1 = xyz2 - xyz1;
  gp_XYZ q2 = xyz3 - xyz1;
  gp_XYZ n  = q1 ^ q2;
  double len = n.Modulus();
  if ( len > std::numeric_limits<double>::min() )
    n /= len;

  return n;
}
static int getTriangles ( const SMDS_MeshElement *  face,
const SMDS_MeshNode **  nodes 
) [static]

Decompose a mesh face into triangles.

Return values:
int- number of triangles

Definition at line 204 of file DriverSTL_W_SMDS_Mesh.cxx.

{
  // WARNING: implementation must be coherent with counting triangles in writeBinary()
  int nbN = face->NbCornerNodes();
  const int nbTria = nbN-2;
  for ( int i = 0; nbN > 1; --nbN )
  {
    nodes[ i++ ] = face->GetNode( 0 );
    nodes[ i++ ] = face->GetNode( nbN-2 );
    nodes[ i++ ] = face->GetNode( nbN-1 );
  }
  return nbTria;
}
static void writeFloat ( const Standard_ShortReal &  theVal,
OSD_File &  ofile 
) [static]

Definition at line 160 of file DriverSTL_W_SMDS_Mesh.cxx.

{
  union {
    Standard_ShortReal f;
    char c[4]; 
  }u;

  u.f = theVal;

  Standard_Integer entier;

  entier  =  u.c[0] & 0xFF;
  entier |= (u.c[1] & 0xFF) << 0x08;
  entier |= (u.c[2] & 0xFF) << 0x10;
  entier |= (u.c[3] & 0xFF) << 0x18;

  ofile.Write((char *)&entier,sizeof(u.c));
}
static void writeInteger ( const Standard_Integer &  theVal,
OSD_File &  ofile 
) [static]

Definition at line 141 of file DriverSTL_W_SMDS_Mesh.cxx.

{
  union {
    Standard_Integer i;
    char c[4];
  }u;

  u.i = theVal;

  Standard_Integer entier;
  entier  =  u.c[0] & 0xFF;
  entier |= (u.c[1] & 0xFF) << 0x08;
  entier |= (u.c[2] & 0xFF) << 0x10;
  entier |= (u.c[3] & 0xFF) << 0x18;

  ofile.Write((char *)&entier,sizeof(u.c));
}

Variable Documentation

const int LABEL_SIZE = 80 [static]

Definition at line 48 of file DriverSTL_W_SMDS_Mesh.cxx.