Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OBJ_Reader Class Reference

#include <OBJ_Reader.h>

Public Member Functions

 OBJ_Reader ()
 
int read_mesh (const char *fname, const std::string &wname)
 

Private Types

enum  { MAXLEN =255 }
 

Private Member Functions

void get_nextline (std::istream &is, char *str)
 
void read_pane_coors (std::istream &is, const std::string &wname, int nn)
 
void read_pane_elems (std::istream &is, const std::string &wname, int ne)
 

Private Attributes

char buf [MAXLEN+1]
 

Detailed Description

Definition at line 39 of file OBJ_Reader.h.

Member Enumeration Documentation

anonymous enum
private
Enumerator
MAXLEN 

Definition at line 104 of file OBJ_Reader.h.

104 {MAXLEN=255};

Constructor & Destructor Documentation

OBJ_Reader ( )
inline

Definition at line 42 of file OBJ_Reader.h.

42 {}

Member Function Documentation

void get_nextline ( std::istream &  is,
char *  str 
)
inlineprivate

Definition at line 72 of file OBJ_Reader.h.

References MAXLEN.

Referenced by read_mesh(), read_pane_coors(), and read_pane_elems().

72  {
73  str[0] = '\0';
74  if ( is.eof()) { return; }
75  is.getline( str, MAXLEN);
76  }

Here is the caller graph for this function:

int read_mesh ( const char *  fname,
const std::string &  wname 
)
inline

Definition at line 46 of file OBJ_Reader.h.

References buf, COM_get_window_handle(), COM_new_window(), get_nextline(), read_pane_coors(), and read_pane_elems().

Referenced by main().

46  {
47  std::ifstream is( fname);
48  if ( is == NULL) {
49  std::cerr << "Error: Could not open file " << fname << std::endl;
50  exit(-1);
51  }
52 
53  // Create the window if not yet exist
54  int h=COM_get_window_handle(wname.c_str());
55  if ( h<=0) COM_new_window( wname.c_str());
56 
57  std::cout << "Reading file " << fname << std::endl;
58 
59  int nn, ne;
60  get_nextline( is, buf);
61  std::sscanf( buf, "%d %d", &nn, &ne);
62 
63  std::cout << "Reading " << nn << " nodes and "
64  << ne << " triangles " << std::endl;
65  read_pane_coors( is, wname, nn);
66  read_pane_elems( is, wname, ne);
67 
68  return 1;
69  }
void get_nextline(std::istream &is, char *str)
Definition: OBJ_Reader.h:72
void read_pane_coors(std::istream &is, const std::string &wname, int nn)
Definition: OBJ_Reader.h:79
void read_pane_elems(std::istream &is, const std::string &wname, int ne)
Definition: OBJ_Reader.h:91
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
Definition: roccom_c++.h:86
char buf[MAXLEN+1]
Definition: OBJ_Reader.h:105
int COM_get_window_handle(const char *wname)
Definition: roccom_c++.h:404

Here is the call graph for this function:

Here is the caller graph for this function:

void read_pane_coors ( std::istream &  is,
const std::string &  wname,
int  nn 
)
inlineprivate

Definition at line 79 of file OBJ_Reader.h.

References buf, COM_allocate_array(), COM_set_size(), get_nextline(), and i.

Referenced by read_mesh().

79  {
80  COM_set_size( (wname+".nc").c_str(), 1, nn);
81  SURF::Point_3<double> *ps;
82  COM_allocate_array( (wname+".nc").c_str(), 1, &(void*&)ps);
83 
84  for ( int i=0; i<nn; ++i) {
85  get_nextline( is, buf);
86  std::sscanf( buf, "%lf %lf %lf", &ps[i][0], &ps[i][1], &ps[i][2]);
87  }
88  }
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
Definition: roccom_c++.h:136
void get_nextline(std::istream &is, char *str)
Definition: OBJ_Reader.h:72
blockLoc i
Definition: read.cpp:79
void COM_allocate_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=0, int cap=0)
Allocate space for an attribute on a specific pane and return the address by setting addr...
Definition: roccom_c++.h:196
char buf[MAXLEN+1]
Definition: OBJ_Reader.h:105

Here is the call graph for this function:

Here is the caller graph for this function:

void read_pane_elems ( std::istream &  is,
const std::string &  wname,
int  ne 
)
inlineprivate

Definition at line 91 of file OBJ_Reader.h.

References buf, COM_allocate_array(), COM_set_size(), get_nextline(), and i.

Referenced by read_mesh().

91  {
92  // Note: Only supports triangular meshes now.
93  COM_set_size( (wname+".:t3:").c_str(), 1, ne);
94  SURF::Vector_3<int> *es;
95  COM_allocate_array( (wname+".:t3:").c_str(), 1, &(void*&)es);
96 
97  for (int i=0; i<ne; ++i) {
98  get_nextline( is, buf);
99  std::sscanf( buf, "%d %d %d", &es[i][0], &es[i][1], &es[i][2]);
100  }
101  }
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
Definition: roccom_c++.h:136
void get_nextline(std::istream &is, char *str)
Definition: OBJ_Reader.h:72
blockLoc i
Definition: read.cpp:79
void COM_allocate_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=0, int cap=0)
Allocate space for an attribute on a specific pane and return the address by setting addr...
Definition: roccom_c++.h:196
char buf[MAXLEN+1]
Definition: OBJ_Reader.h:105

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

char buf[MAXLEN+1]
private

Definition at line 105 of file OBJ_Reader.h.

Referenced by read_mesh(), read_pane_coors(), and read_pane_elems().


The documentation for this class was generated from the following file: