#include <cstdio>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cassert>
Go to the source code of this file.
|
int | read_obj (istream &is, vector< double > &coors, vector< int > &elems) |
|
void | read_ij (istream &is, vector< double > &coors, int dims[2]) |
|
void | write_ij (ostream &os, const vector< double > &coors, int dims[]) |
|
void read_ij |
( |
istream & |
is, |
|
|
vector< double > & |
coors, |
|
|
int |
dims[2] |
|
) |
| |
Definition at line 81 of file meshio.C.
References i, MAXLEN, p0, and p1.
Referenced by main().
85 do { is.getline( buf, MAXLEN); }
while ( buf[0]==
'#' && !is.eof());
86 sscanf( buf,
"%d %d", &dims[0], &dims[1]);
88 int np=dims[0]*dims[1];
92 for (
int i=0;
i<np; ++
i) {
93 do { is.getline( buf, MAXLEN); }
while ( buf[0]==
'#' && !is.eof());
95 sscanf( buf,
"%lf %lf %lf", &p0, &p1, &p2);
96 coors.push_back( p0); coors.push_back( p1); coors.push_back( p2);
int read_obj |
( |
istream & |
is, |
|
|
vector< double > & |
coors, |
|
|
vector< int > & |
elems |
|
) |
| |
Definition at line 39 of file meshio.C.
References i, j, MAXLEN, p0, and p1.
Referenced by main().
45 is.getline( buf, MAXLEN);
46 if ( strncmp( buf,
"#OBJ", 4)==0 && !is.eof()) {
47 face_type = buf[4] -
'0';
48 assert( face_type == 3 || face_type == 4 || face_type == 6);
49 do { is.getline( buf, MAXLEN); }
while ( buf[0]==
'#' && !is.eof());
52 if ( strcmp( buf,
"off")==0 || strcmp( buf,
"OFF")==0 )
53 do { is.getline( buf, MAXLEN); }
while ( buf[0]==
'#' && !is.eof());
54 sscanf( buf,
"%d %d", &np, &nf);
57 coors.reserve( np*3); elems.reserve( nf*face_type);
60 for (
int i=0;
i<np; ++
i) {
61 do { is.getline( buf, MAXLEN); }
while ( buf[0]==
'#' && !is.eof());
63 sscanf( buf,
"%lf %lf %lf", &p0, &p1, &p2);
64 coors.push_back( p0); coors.push_back( p1); coors.push_back( p2);
68 vector<int> f( face_type);
69 while( is.peek() ==
'#' && !is.eof()) is.getline( buf, MAXLEN);
70 for (
int i=0;
i<nf; ++
i) {
71 for (
int j=0;
j<face_type; ++
j) {
72 is >> f[
j]; assert( f[
j] >= 1 && f[
j] <= np);
73 elems.push_back( f[
j]);
void write_ij |
( |
ostream & |
os, |
|
|
const vector< double > & |
coors, |
|
|
int |
dims[] |
|
) |
| |
Definition at line 101 of file meshio.C.
References i.
102 os << dims[0] <<
" " << dims[1] << endl;
106 for (
unsigned int i=0;
i<coors.size();
i+=3) {
107 sprintf( buf,
"%.10E\t%.10E\t%.10E", coors[
i],
108 coors[i+1], coors[i+2]);