GOAT (Geometrical optics application tool) 0.1
Loading...
Searching...
No Matches
surface.h
Go to the documentation of this file.
1#ifndef SURFACE_H
2#define SURFACE_H
3
4#include <complex>
5#include <stdio.h>
6#include <stdlib.h>
7#include <fstream>
8#include <iostream>
9#include <math.h>
10#include "vector.h"
11#include "objectshape.h"
12#include <string.h>
13#include "triangle.h"
14
15#ifdef WITH_OCTREE
16#include "octree.h"
17#endif
18
19
20namespace GOAT
21{
22 namespace raytracing
23 {
24#ifndef SQRT3
25#define SQRT3 1.73205080756887729352744634150587236694280525381038062805580
26#endif
27
28#define OBJECTSHAPE_SURFACE_FILETYPE_NONE -1
29#define OBJECTSHAPE_SURFACE_FILETYPE_SRF 0
30#define OBJECTSHAPE_SURFACE_FILETYPE_STL 1
31
32
33
34 /* Klasse, die eine ObjectShape repr�sentiert, die aus Dreiecken zusammengebaut ist. Die Dreiecke werden durch die Klasse \ref refdreieck "triangle"
35 beschrieben */
55 class surface : public ObjectShape
56 {
57 public:
58
59 // Konstruktoren und Destruktor
60 // surface(int num); ///< Constructor for a surface object with num empty triangles
63 // surface(const ObjectShape &);
64 surface(const surface& Su);
76 std::complex<double> n,
77 const maths::Matrix<std::complex<double> > alpha = maths::CUNITY,
78 const maths::Vector<double> Ex = GOAT::maths::ex,
79 const maths::Vector<double> Ey = GOAT::maths::ey,
80 const maths::Vector<double> Ez = GOAT::maths::ez
81 );
82
96 std::complex<double> n,
97 int num, triangle* list,
98 const maths::Matrix<std::complex<double> > alpha = maths::CUNITY,
99 const maths::Vector<double> Ex = maths::ex,
100 const maths::Vector<double> Ey = maths::ey,
101 const maths::Vector<double> Ez = maths::ez);
102
103 // ~surface();
110 void getMinMax(double& min, double& max);
112 int numTriangles = 0;
113
114 // Erzeugen der Dreiecksliste
115 // 1. interaktiv
117 // Skaliere die Dreiecke
122 void scale(double sf);
123
124 // 2. Einlesen aus Datei FName
125 int createsurface(std::string FName);
126 int importBinSTL(std::string FName);
127 void exportSRF(std::string FName);
128 // Andere Hilfsfunktionen
129 // 1. R�ckgabe einer Klasse mit leerem S
131 // 2. Hinzuf�gen einer Liste S
137 void addTriangle(triangle* S, int num);
138
139 void clearS();
140 // string getFName() {return FName; }
141 std::string getFilename() { return FName; }
142 void setFilename(std::string FName)
143 {
144 this->FName = FName;
145 }
146
147 // Operatoren
149
150 // Die virtuellen Funktionen der ObjectShape-Klasse
162 void setr0(double r0);
163 void initQuad();
166 void setPos(double x, double y, double z) { setPos(maths::Vector<double>(x, y, z)); }
167 //double isInHost(void);
168 void binWrite(std::ofstream& os);
169 void binRead(std::ifstream& is);
170 // double volume();
171 double volume();
174 int getCurrentIndex() { return currentIndex; }
175 triangle& getTriangle(int i) { return S[i]; }
177
178 // protected:
181 std::string FName;
183
184#ifdef WITH_OCTREE
185 Octree<triangle> Tree;
186 int octreeRecursions=5;
187 void setOctreeRecursiondepth (int octreeRecursions);
188 int getOctreeRecursiondepth() {return Tree.MAX_RECURSIONS; }
189#endif
190 };
191
192 std::ostream& operator << (std::ostream& os, const surface& su);
193
204
212
221
229 surface& generateBullet(double a, double h, double t, maths::Matrix<double> M = maths::UNITY);
230
237 surface generateEllipsoid(double a, double b, int N, double r0 = 1.0, maths::Matrix<double> M = maths::UNITY); // generiert einen Rotationsellipsoiden mit Halbachsen a (z-Achse) und b
238
243 surface generatePill(double a, double b, double h, int N, double r0 = 1.0, maths::Matrix<double> M = maths::UNITY);
244
245 surface generatePolyBullet(int n, double a, double h, double t, maths::Matrix<double> M = maths::UNITY);
246
254 void getMinMax(int numTriangles, triangle *S, double& min, double& max);
255
256 }
257}
258#endif
259
This class represents a threedimensional (numeric) Matrix as a template.
Definition matrix.h:23
Template class for threedimensional vectors.
Definition vector.h:57
double sf
scaling factor, it is used to scale the shape of the object
maths::Vector< double > por
corners of the circumferent cuboid (lower left corner and upper right corner)
maths::Matrix< std::complex< double > > alpha
polarisability matrix
maths::Vector< double > pul
maths::Vector< double > P
position of the object
double r0
radius of the calculation sphere
std::complex< double > n
refractive index of the object
This template class is used for internal purposes and represents an octree.
Definition octree.h:28
This class represents objects those surface is described by triangles.
Definition surface.h:56
void setCenter2CoM()
Sets the Position to the center of mass (CoM)
void setPos(maths::Vector< double > r)
Set position of the object to r.
std::string getFilename()
returns the current file name
Definition surface.h:141
void setFilename(std::string FName)
Definition surface.h:142
void binRead(std::ifstream &is)
Reads object from binary file represented by istream is.
triangle & getTriangle(int i)
Returns the i-th triangle in the internal triangle list.
Definition surface.h:175
void initBounds(maths::Vector< double > &pul, maths::Vector< double > &por)
Calculates the bounding box (=circumferent cuboid) but without rotation. The cuboid is represented by...
maths::Vector< double > calcCoM()
calculates center of mass (needed by setCenter2CoM () )
int createsurface(std::string FName)
reads the triangle list from a file (proprietary file format, SRF)
void addTriangle(triangle *S, int num)
Adds triangles to the internal list of triangles.
void clearS()
clears the internal list of triangles
bool isInside(const maths::Vector< double > &p)
checks if point P is inside the object
void binWrite(std::ofstream &os)
Writes object to binary file represented by ostream os.
surface nosurface()
returns copy of the object without triangles
void setCenter(maths::Vector< double > P)
bool next(const maths::Vector< double > &r, const maths::Vector< double > &k, maths::Vector< double > &p)
Calculates the intersection point between a straight line and the surface object. The straight line i...
int getCurrentIndex()
Returns the index of the triangle that was last hit.
Definition surface.h:174
int importBinSTL(std::string FName)
import triangle list from binary STL-file
int filetype
type of the file connected with this surface object
Definition surface.h:176
surface & operator=(const surface &)
int currentIndex
Index of the triangle that was last hit.
Definition surface.h:180
triangle * S
list of all triangles
Definition surface.h:111
void setr0(double r0)
sets the radius of the calculation sphere (necessary only if this class is used outside Scene)
void exportSRF(std::string FName)
export triangle list to proprietary file format SRF
surface(const maths::Vector< double > &P, std::complex< double > n, const maths::Matrix< std::complex< double > > alpha=maths::CUNITY, const maths::Vector< double > Ex=GOAT::maths::ex, const maths::Vector< double > Ey=GOAT::maths::ey, const maths::Vector< double > Ez=GOAT::maths::ez)
void getMinMax(double &min, double &max)
calculates center of mass
void setPos(double x, double y, double z)
Set position of the object to a position vector represented by its components x,y and z.
Definition surface.h:166
maths::Matrix< double > computeInertia()
Calculates the inertia of the object.
double volume()
Calculates the volume of the object.
surface(const maths::Vector< double > &P, std::complex< double > n, int num, triangle *list, const maths::Matrix< std::complex< double > > alpha=maths::CUNITY, const maths::Vector< double > Ex=maths::ex, const maths::Vector< double > Ey=maths::ey, const maths::Vector< double > Ez=maths::ez)
maths::Vector< double > norm(const maths::Vector< double > &P)
Surface normal at point P (There is no check, if P is on the surface. This function is used for inter...
surface(maths::Vector< double > Oh)
Empty surface object with position Oh.
int numTriangles
number of triangles
Definition surface.h:112
maths::Vector< double > currentnorm
Normal vector of the triangle that was last hit.
Definition surface.h:179
int createsurface()
Creates a list of triangles, which describes the surface, from standard input.
void initQuad()
Boundaries of the circumferent cuboid is calculated. The cuboid is represented by the upper right cor...
std::string FName
File name (used to save the internal triangle list)
Definition surface.h:181
void scale(double sf)
scale the lengths of all triangles
surface(const surface &Su)
This class describes a triangle, represented by its corner points. It is intented for internal purpos...
Definition triangle.h:13
const Matrix< double > UNITY
Unity matrix (double-valued)
Definition matrix.h:474
const Matrix< std::complex< double > > CUNITY
Unity matrix (complex-valued)
Definition matrix.h:475
Raytracer used for ultrashort pulse calculation with raytracing only.
Definition asphericLens.h:6
surface operator-(const surface &s, const maths::Vector< double > &v)
subtracts vector v from all corners of the triangle list of the surface object s
surface generateHollowHexagonalCylinder(double a, double h, double t, maths::Matrix< double > M=maths::UNITY)
generates a cylinder with hexagonal cross section. At the upper and lower faces, there are pyramidal ...
void getMinMax(int numTriangles, triangle *S, double &min, double &max)
calculates the longest and shortest side length
surface generatePill(double a, double b, double h, int N, double r0=1.0, maths::Matrix< double > M=maths::UNITY)
Generates a cylinder with ellipsoidal caps.
surface generateEllipsoid(double a, double b, int N, double r0=1.0, maths::Matrix< double > M=maths::UNITY)
Generiert einen hexagonalen Zylinder mit Seitenl�nge a und H�he h und einer pyramidalen Spitze.
surface operator+(const surface &s, const maths::Vector< double > &v)
{
surface generateHexagonCylinder(double a, double h, maths::Matrix< double > M=maths::UNITY)
}
surface & generateBullet(double a, double h, double t, maths::Matrix< double > M=maths::UNITY)
generates a cylinder with hexagonal cross section with a pyramid-shaped tip on the upper surface.
std::ostream & operator<<(std::ostream &os, Box B)
output operator for the Box class
surface operator*(const maths::Matrix< double > &M, const surface &s)
surface generatePolyBullet(int n, double a, double h, double t, maths::Matrix< double > M=maths::UNITY)
This class is used for the iray class. This class is intended for internal use only....
Definition fresnel.h:7
#define OBJECTSHAPE_SURFACE_FILETYPE_NONE
Definition surface.h:28
This file contains the Vector template class and some useful functions around this class.