00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef GEOMETRY_HPP
00044 #define GEOMETRY_HPP 1
00045
00046
00047 #include <stdint.h>
00048 #include <vector>
00049 #include <iostream>
00050 #include "file.hpp"
00051 #include "vec3d.hpp"
00052 #include "solid.hpp"
00053 #include "types.hpp"
00054
00055
00068 struct Bound
00069 {
00070 bound_e type;
00071 double val;
00072
00075 Bound( bound_e t, double v ) : type(t), val(v) {}
00076
00079 Bound( std::istream &s ) {
00080 type = (bound_e)read_int32( s );
00081 val = read_double( s );
00082 }
00083
00086 void save( std::ostream &fout ) const {
00087 write_int32( fout, type );
00088 write_double( fout, val );
00089 }
00090 };
00091
00092
00126 class Geometry
00127 {
00128 geom_mode_e _geom_mode;
00129 Int3D _size;
00130 Vec3D _origo;
00131 Vec3D _max;
00132 double _h;
00134 int32_t _n;
00135 std::vector<const Solid*> _sdata;
00136 std::vector<Bound> _bound;
00138 bool _built;
00139 signed char *_smesh;
00141 int32_t _brktc;
00146 bool vac_or_neu( int32_t i, int32_t j, int32_t k );
00147
00148 public:
00149
00155 Geometry( geom_mode_e geom_mode, Int3D size, Vec3D origo, double h );
00156
00159 Geometry( std::istream &s );
00160
00163 ~Geometry();
00164
00167 geom_mode_e geom_mode( void ) const { return( _geom_mode ); }
00168
00171 int32_t dim( void ) const;
00172
00175 Int3D size( void ) const { return( _size ); }
00176
00179 int32_t size( int i ) const { return( _size[i] ); }
00180
00183 int32_t nodecount( void ) const { return( _size[0]*_size[1]*_size[2] ); }
00184
00187 Vec3D origo( void ) const { return( _origo ); }
00188
00191 double origo( int i ) const { return( _origo[i] ); }
00192
00196 Vec3D max( void ) const { return( _max ); }
00197
00201 double max( int i ) const { return( _max[i] ); }
00202
00205 double h( void ) const { return( _h ); }
00206
00216 void set_solid( int32_t n, const Solid *s );
00217
00222 const Solid *get_solid( int32_t n ) const;
00223
00239 void set_boundary( int32_t n, const Bound &b );
00240
00243 Bound get_boundary( int32_t n ) const;
00244
00247 std::vector<Bound> get_boundaries() const;
00248
00262 void set_bracket_count( int32_t n );
00263
00266 int32_t get_bracket_count( void ) const;
00267
00274 int32_t inside( const Vec3D &x ) const;
00275
00278 bool inside( int32_t n, const Vec3D &x ) const;
00279
00289 double bracket_surface( int32_t n, const Vec3D &xin, const Vec3D &xout, Vec3D &xsurf ) const;
00290
00293 bool built( void ) const { return( _built ); }
00294
00298 void build_mesh( void );
00299
00302 const signed char &mesh( int32_t i ) const { return( _smesh[i] ); }
00303
00306 const signed char &mesh( int32_t i, int32_t j ) const {
00307 return( _smesh[i + j*_size[0]] );
00308 }
00309
00312 const signed char &mesh( int32_t i, int32_t j, int32_t k ) const {
00313 return( _smesh[i + j*_size[0] + k*_size[0]*_size[1]] );
00314 }
00315
00318 signed char &mesh( int32_t i ) { return( _smesh[i] ); }
00319
00322 signed char &mesh( int32_t i, int32_t j ) {
00323 return( _smesh[i + j*_size[0]] );
00324 }
00325
00328 signed char &mesh( int32_t i, int32_t j, int32_t k ) {
00329 return( _smesh[i + j*_size[0] + k*_size[0]*_size[1]] );
00330 }
00331
00335 signed char mesh_check( int32_t i, int32_t j, int32_t k ) const;
00336
00339 void save( std::ostream &s ) const;
00340
00343 void debug_print( void ) const;
00344 };
00345
00346
00347 #endif
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365