Back to index

salome-smesh  6.5.0
Classes | Typedefs | Functions
UNV2411 Namespace Reference

Classes

struct  MESHDRIVERUNV_EXPORT

Typedefs

typedef int TNodeLab
typedef std::vector< TRecord > TDataSet

Functions

MESHDRIVERUNV_EXPORT void Read (std::ifstream &in_stream, TDataSet &theDataSet)
MESHDRIVERUNV_EXPORT void Write (std::ofstream &out_stream, const TDataSet &theDataSet)

Typedef Documentation

typedef std::vector<TRecord> UNV2411::TDataSet

Definition at line 44 of file UNV2411_Structure.hxx.

typedef int UNV2411::TNodeLab

Definition at line 33 of file UNV2411_Structure.hxx.


Function Documentation

void UNV2411::Read ( std::ifstream &  in_stream,
TDataSet theDataSet 
)

always 3 coordinates in the UNV file, no matter which dimensionality libMesh is in

Definition at line 41 of file UNV2411_Structure.cxx.

{
  if(!in_stream.good())
    EXCEPTION(runtime_error,"ERROR: Input file not good.");

  /*
   * adjust the \p istream to our
   * position
   */
  if(!beginning_of_dataset(in_stream,_label_dataset))
    EXCEPTION(runtime_error,"ERROR: Could not find "<<_label_dataset<<" dataset!");

  std::string num_buf;
  while ( !in_stream.eof() )
  {
    TRecord aRec;
    in_stream >> aRec.label ;
    if ( aRec.label == -1 ) {
      // end of dataset is reached
      break;
    }

    in_stream>>aRec.exp_coord_sys_num;
    in_stream>>aRec.disp_coord_sys_num;
    in_stream>>aRec.color;

    /*
     * take care of the
     * floating-point data
     */
    for(int d = 0; d < 3; d++){
      in_stream>>num_buf;
      aRec.coord[d] = D_to_e(num_buf);
    }

    theDataSet.push_back(aRec);
  }
}

Here is the call graph for this function:

void UNV2411::Write ( std::ofstream &  out_stream,
const TDataSet theDataSet 
)

Definition at line 85 of file UNV2411_Structure.cxx.

{
  if(!out_stream.good())
    EXCEPTION(runtime_error,"ERROR: Output file not good.");
  
  /*
   * Write beginning of dataset
   */
  out_stream<<"    -1\n";
  out_stream<<"  "<<_label_dataset<<"\n";

  TDataSet::const_iterator anIter = theDataSet.begin();
  for(; anIter != theDataSet.end(); anIter++)
  {
    const TRecord& aRec = *anIter;
    char buf[78];
    sprintf(buf, "%10d%10d%10d%10d\n", 
            aRec.label,
            aRec.exp_coord_sys_num,
            aRec.disp_coord_sys_num,
            aRec.color);
    out_stream<<buf;

    // the coordinates
    sprintf(buf, "%25.16E%25.16E%25.16E\n", 
            aRec.coord[0],
            aRec.coord[1],
            aRec.coord[2]);
    out_stream<<buf;
  }
  
  
  /*
   * Write end of dataset
   */
  out_stream<<"    -1\n";
}