rebl-AMR
geomSTL.h
Go to the documentation of this file.
1 #ifndef _GEOMSTL_H
2 #define _GEOMSTL_H
3 #include <string>
4 #include <vector>
5 #include <cassert>
6 #include <fstream>
7 #include <iostream>
8 #include <sstream>
9 #include <streambuf>
10 #include "definitions.h"
11 
17  struct point {
18  float x;
19  float y; ;
20  float z; ;
21  point() : x(0), y(0), z(0) {}
22  point(float xp, float yp, float zp) : x(xp), y(yp), z(zp) {}
23  };
29  struct triangle {
34  triangle(point normalp, point v1p, point v2p, point v3p) :
35  normal(normalp), v1(v1p), v2(v2p), v3(v3p) {}
36  };
37 
38 // std::ostream& operator<<(std::ostream& out, const triangle& t);
39 
45  struct stl_data {
46  std::string name;
47  std::vector<triangle> triangles;
48  //triangle *triangles;
49  stl_data(std::string namep) : name(namep) {}
50  };
51 
52 class Vec3 //Class for 3d Vector Magnitude and Normalization
53 {
54 public:
55  Vec3(void);
56  Vec3(float X, float Y, float Z);
57  ~Vec3(void);
58  float Length();
59  Vec3 Normalize();
60  Vec3 Vectors();
61  float X, Y, Z;
62 };
63 
64 
65 class GeomSTL{
66  private:
67  int geom_nn;
69  real *__restrict__ triangle_center;
70  real xyz[6];
71 
72  public:
73  GeomSTL(){};
74  void construct(real *xyz1);
75  stl_data parse_stl(const std::string& stl_path);
76  float parse_float( std::ifstream &s );
77  point parse_point( std::ifstream &s );
78  stl_data parseSTL( const std::string &stl_path );
79  void readSTLGeom( char *argv[], const real *xyz );
80  void checkMesh( std::vector<triangle> &triangles );
81 
82  template <size_t N, typename Nvalue, size_t M, typename Mvalue >
83  friend class ReblAmr;
84 
85 
86 
87 };
88 
89 
90 
91 #endif
void readSTLGeom(char *argv[], const real *xyz)
Definition: geomSTL.cpp:130
Vec3 Normalize()
Definition: geomSTL.cpp:33
float Y
Definition: geomSTL.h:61
structure to store normals and vertices of a triangle
Definition: geomSTL.h:29
Definition: geomSTL.h:52
Vec3 Vectors()
Definition: geomSTL.cpp:21
GeomSTL()
Definition: geomSTL.h:73
point normal
Definition: geomSTL.h:30
point parse_point(std::ifstream &s)
Definition: geomSTL.cpp:78
point v1
Definition: geomSTL.h:31
triangle(point normalp, point v1p, point v2p, point v3p)
Definition: geomSTL.h:34
Definition: ReblAmr.h:19
Definition: geomSTL.h:65
stl_data parse_stl(const std::string &stl_path)
Definition: geomSTL.cpp:86
float Z
Definition: geomSTL.h:61
point()
Definition: geomSTL.h:21
int geom_nn
Definition: geomSTL.h:67
Vec3(void)
Definition: geomSTL.cpp:5
std::string name
Definition: geomSTL.h:46
void checkMesh(std::vector< triangle > &triangles)
Definition: geomSTL.cpp:265
float parse_float(std::ifstream &s)
Definition: geomSTL.cpp:70
point v3
Definition: geomSTL.h:33
real xyz[6]
Definition: geomSTL.h:70
float z
Definition: geomSTL.h:19
float X
Definition: geomSTL.h:61
structure to store vector of triangles read in from *.stl file
Definition: geomSTL.h:45
double real
Definition: definitions.h:37
stl_data parseSTL(const std::string &stl_path)
Structure to hold coordinates of a point.
Definition: geomSTL.h:17
real *__restrict__ triangle_center
Definition: geomSTL.h:69
stl_data(std::string namep)
Definition: geomSTL.h:49
float y
Definition: geomSTL.h:19
real * geom_xyz
Definition: geomSTL.h:68
float Length()
Definition: geomSTL.cpp:16
point(float xp, float yp, float zp)
Definition: geomSTL.h:22
~Vec3(void)
Definition: geomSTL.cpp:48
void construct(real *xyz1)
Definition: geomSTL.cpp:119
float x
Definition: geomSTL.h:18
point v2
Definition: geomSTL.h:32
std::vector< triangle > triangles
Definition: geomSTL.h:47