Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cornelius.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file cornelius.h
1 #ifndef CORNELIUS_H
2 #define CORNELIUS_H
3 
4 #include <iostream>
5 #include <fstream>
6 #include <math.h>
7 #include <stdlib.h>
8 
9 #include <fstream>
10 // using namespace std;
11 using std::string;
12 using std::vector;
13 using std::ofstream;
14 using std::ifstream;
15 using std::abs;
16 
23 class GeneralElement
24 {
25  protected:
26  static const int DIM = 4;
27  double *centroid;
28  double *normal;
31  virtual void calculate_centroid() {};
32  virtual void calculate_normal() {};
33  void check_normal_direction(double *normal, double *out);
34  public:
37  double *get_centroid();
38  double *get_normal();
39 };
40 
47 class Line : public GeneralElement
48 {
49  private:
50  static const int LINE_CORNERS = 2;
51  static const int LINE_DIM = 2;
52  int x1,x2;
53  int start_point;
54  int end_point;
55  double **corners;
56  double *out;
57  int *const_i;
58  void calculate_centroid();
59  void calculate_normal();
60  public:
61  Line();
62  ~Line();
63  void init(double**,double*,int*);
64  void flip_start_end();
65  double *get_start();
66  double *get_end();
67  double *get_out();
68 };
69 
76 class Polygon : public GeneralElement
77 {
78  private:
79  static const int MAX_LINES = 24;
80  static const int POLYGON_DIM = 3;
81  Line **lines;
82  int Nlines;
83  int x1,x2,x3;
84  int const_i;
85  void calculate_centroid();
86  void calculate_normal();
87  public:
88  Polygon();
89  ~Polygon();
90  void init(int);
91  bool add_line(Line*,int);
92  int get_Nlines();
93  Line** get_lines();
94  void print(ofstream &file,double*);
95 };
96 
103 class Polyhedron : public GeneralElement
104 {
105  private:
106  static const int MAX_POLYGONS = 24;
107  Polygon **polygons;
108  int Npolygons;
109  int Ntetrahedra;
110  int x1,x2,x3,x4;
111  bool lines_equal(Line*,Line*);
112  void tetravolume(double*,double*,double*,double*);
113  void calculate_centroid();
114  void calculate_normal();
115  public:
116  Polyhedron();
117  ~Polyhedron();
118  void init();
119  bool add_polygon(Polygon*,int);
120 };
121 
131 class Square
132 {
133  private:
134  static const int DIM = 4;
135  static const int SQUARE_DIM = 2;
136  static const int MAX_POINTS = 4;
137  static const int MAX_LINES = 2;
138  double **points;
139  double **cuts;
140  double **out;
141  double **points_temp;
142  double *out_temp;
143  int *const_i;
144  double *const_value;
145  int x1, x2;
146  double *dx;
147  int Ncuts;
148  int Nlines;
149  Line *lines;
150  int ambiguous;
151  void ends_of_edge(double);
152  void find_outside(double);
153  public:
154  Square();
155  ~Square();
156  void init(double**,int*,double*,double*);
157  void construct_lines(double);
158  int is_ambiguous();
159  int get_Nlines();
160  Line* get_lines();
161 };
162 
171 class Cube
172 {
173  private:
174  static const int DIM = 4;
175  static const int CUBE_DIM = 4;
176  static const int MAX_POLY = 8;
177  static const int NSQUARES = 6;
178  static const int STEPS = 2;
179  double ***cube;
180  Line **lines;
181  Polygon *polygons;
182  Square *squares;
183  int Nlines;
184  int Npolygons;
185  int ambiguous;
186  int const_i;
187  double const_value;
188  int x1,x2,x3;
189  double *dx;
190  void split_to_squares();
191  void check_ambiguous(int);
192  public:
193  Cube();
194  ~Cube();
195  void init(double***&,int,double,double*&);
196  void construct_polygons(double);
197  int get_Nlines();
198  int get_Npolygons();
199  int is_ambiguous();
201 };
202 
203 
212 class Hypercube
213 {
214  private:
215  static const int DIM = 4;
216  static const int MAX_POLY = 10;
217  static const int NCUBES = 8;
218  static const int STEPS = 2;
219  double ****hcube;
221  Polygon **polygons;
222  Cube *cubes;
223  int Npolyhedrons;
224  int ambiguous;
225  int x1,x2,x3,x4;
226  double *dx;
227  void split_to_cubes();
228  void check_ambiguous(double);
229  public:
230  Hypercube();
231  ~Hypercube();
232  void init(double****,double*);
233  void construct_polyhedrons(double);
234  int get_Npolyhedrons();
236 };
237 
250 class Cornelius
251 {
252  private:
253  static const int STEPS = 2;
254  static const int DIM = 4;
255  static const int MAX_ELEMENTS = 10;
256  int Nelements;
257  double **normals;
258  double **centroids;
259  int cube_dim;
260  int initialized;
261  int print_initialized;
262  double value0;
263  double *dx;
264  ofstream output_print;
265  void surface_3d(double***,double*,int);
266  Square cu2d;
267  Cube cu3d;
268  Hypercube cu4d;
269  public:
270  Cornelius();
271  ~Cornelius();
272  void init(int,double,double*);
273  void init_print(string);
274  void find_surface_2d(double**);
275  void find_surface_3d(double***);
276  void find_surface_3d_print(double***,double*);
277  void find_surface_4d(double****);
278  int get_Nelements();
279  double **get_normals();
280  double **get_centroids();
281  double **get_normals_4d();
282  double **get_centroids_4d();
283  double get_centroid_elem(int,int);
284  double get_normal_elem(int,int);
285 };
286 
287 #endif /* CORNELIUS_H */