Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
wrlsurf2hdf.C File Reference
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include "TRAIL.H"
#include "roccom.h"
Include dependency graph for wrlsurf2hdf.C:

Go to the source code of this file.

Functions

void CheckCoordinates (double *coords, int number_of_points, double tol)
 
int main (int argc, char *argv[])
 

Function Documentation

void CheckCoordinates ( double *  coords,
int  number_of_points,
double  tol 
)

Definition at line 9 of file wrlsurf2hdf.C.

References i.

10 {
11  for(int i = 0; i < number_of_points*3;i++)
12  {
13  if(std::fabs(coords[i]) < tol && (coords[i] != 0.0)){
14  std::cout << "WRLSURF2HDF> WARNING: node " << (i/3)+1 << "/"
15  << number_of_points << " "
16  << (((i%3)==0 ? "x " : ((i%3) < 2) ? "y " : "z "))
17  << "coordinate = " << coords[i] << std::endl;
18  coords[i] = 0.0;
19  }
20  }
21 }
blockLoc i
Definition: read.cpp:79
int main ( int  argc,
char *  argv[] 
)

Definition at line 24 of file wrlsurf2hdf.C.

References Mesh::Connectivity::AddElement(), CheckCoordinates(), COM_init(), Mesh::NodalCoordinates::init(), Mesh::Connectivity::Nelem(), Mesh::NodalCoordinates::Size(), Mesh::Connectivity::Sync(), TRAIL_SurfaceMesh2Window(), TRAIL_WriteWindow(), and x.

25 {
26  COM_init(&argc,&argv);
27  std::string line;
28  std::getline(std::cin,line);
29  std::string::size_type x = 0;
31  std::vector<double> coords;
32  // nc.resize(0);
33  x = line.find("point [");
34  while(x == std::string::npos && !std::cin.eof()){
35  std::getline(std::cin,line);
36  x = line.find("point [");
37  }
38  if(std::cin.eof()){
39  std::cerr << "File error 1." << std::endl;
40  exit(1);
41  }
42  std::getline(std::cin,line);
43  x = line.find("]");
44  unsigned int count = 1;
45  while(x == std::string::npos && !std::cin.eof()){
46  std::istringstream Istr(line);
47  double xc, yc, zc;
48  Istr >> xc >> yc >> zc;
49 
50  coords.push_back(xc);
51  coords.push_back(yc);
52  coords.push_back(zc);
53  std::getline(std::cin,line);
54  x = line.find("]");
55  }
56  if(std::cin.eof()){
57  std::cerr << "File error 2." << std::endl;
58  exit(1);
59  }
60  unsigned int number_of_nodes = coords.size()/3;
61  CheckCoordinates(&(coords[0]),number_of_nodes,1.0e-9);
62  nc.init(number_of_nodes,&(coords[0]));
63  getline(std::cin,line);
64  x = line.find("coordIndex [");
65  while(x == std::string::npos && !std::cin.eof()){
66  getline(std::cin,line);
67  x = line.find("coordIndex [");
68  }
69  if(std::cin.eof()){
70  std::cerr << "File error 3." << std::endl;
71  exit(1);
72  }
74  std::vector<Mesh::IndexType> element(3);
75  std::getline(std::cin,line);
76  x = line.find("]");
77  while(x == std::string::npos && !std::cin.eof()){
78  std::istringstream Istr(line);
79  std::string delim;
80  int dummy;
81  Istr >> element[0] >> delim >> element[1] >> delim >> element[2] >> delim >> dummy;
82  element[0]+=1;
83  element[1]+=1;
84  element[2]+=1;
85  ec.AddElement(element);
86  std::getline(std::cin,line);
87  x = line.find("]");
88  }
89  if(std::cin.eof()){
90  std::cerr << "File error 4." << std::endl;
91  exit(1);
92  }
93  ec.Sync();
94  unsigned int nvert = nc.Size();
95  unsigned int ntri = ec.Nelem();
96  std::cout << "Number of vertices: " << nvert << std::endl
97  << "Number of triangles: " << ntri << std::endl;
98  TRAIL_SurfaceMesh2Window("tempwin",1,nc,ec);
99  TRAIL_WriteWindow("tempwin",".","","",0,0,MPI_COMM_NULL,NULL);
100  return(0);
101 }
void Sync()
Definition: Mesh.C:246
void AddElement(const std::vector< IndexType > &elem)
Definition: Mesh.C:235
General connectivity object.
Definition: Mesh.H:334
void CheckCoordinates(double *coords, int number_of_points, double tol)
Definition: Rocon.C:74
bool TRAIL_WriteWindow(const std::string &wname, const std::string &path, const std::string &twin, const std::string &tpath, double t, unsigned int id, MPI_Comm comm, std::ostream *=NULL)
Definition: TRAIL.C:2811
IndexType Size() const
Definition: Mesh.C:49
void int int REAL * x
Definition: read.cpp:74
IndexType Nelem() const
Definition: Mesh.H:364
int TRAIL_SurfaceMesh2Window(const std::string &wname, int pane_id, Mesh::NodalCoordinates &, Mesh::Connectivity &)
Creates a window from a Mesh object. (copies data)
Definition: TRAIL.C:414
void COM_init(int *argc, char ***argv)
Definition: roccom_c++.h:57

Here is the call graph for this function: