Go to the documentation of this file.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 "mesh.hpp"
00054 #include "types.hpp"
00055
00056
00069 struct Bound
00070 {
00071 bound_e type;
00072 double val;
00073
00076 Bound( bound_e t, double v ) : type(t), val(v) {}
00077
00080 Bound( std::istream &s ) {
00081 type = (bound_e)read_int32( s );
00082 val = read_double( s );
00083 }
00084
00087 void save( std::ostream &os ) const {
00088 write_int32( os, type );
00089 write_double( os, val );
00090 }
00091
00094 friend std::ostream &operator<<( std::ostream &os, const Bound &b );
00095 };
00096
00097
00131 class Geometry : public Mesh
00132 {
00133 uint32_t _n;
00134 std::vector<const Solid*> _sdata;
00135 std::vector<Bound> _bound;
00137 bool _built;
00138 signed char *_smesh;
00140 int32_t _brktc;
00145 bool vac_or_neu( int32_t i, int32_t j, int32_t k );
00146
00149 void check_definition();
00150
00151 Vec3D surface_normal_2d( const Vec3D &x ) const;
00152 Vec3D surface_normal_3d( const Vec3D &x ) const;
00153
00154 public:
00155
00161 Geometry( geom_mode_e geom_mode, Int3D size, Vec3D origo, double h );
00162
00165 Geometry( std::istream &is );
00166
00169 ~Geometry();
00170
00173 uint32_t number_of_solids() const;
00174
00179 uint32_t number_of_boundaries() const;
00180
00190 void set_solid( uint32_t n, const Solid *s );
00191
00196 const Solid *get_solid( uint32_t n ) const;
00197
00213 void set_boundary( uint32_t n, const Bound &b );
00214
00217 Bound get_boundary( uint32_t n ) const;
00218
00221 std::vector<Bound> get_boundaries() const;
00222
00236 void set_bracket_count( uint32_t n );
00237
00240 uint32_t get_bracket_count( void ) const;
00241
00248 uint32_t inside( const Vec3D &x ) const;
00249
00252 bool inside( uint32_t n, const Vec3D &x ) const;
00253
00263 double bracket_surface( uint32_t n, const Vec3D &xin, const Vec3D &xout, Vec3D &xsurf ) const;
00264
00269 Vec3D surface_normal( const Vec3D &x ) const;
00270
00273 bool built( void ) const { return( _built ); }
00274
00278 void build_mesh( void );
00279
00282 const signed char &mesh( int32_t i ) const { return( _smesh[i] ); }
00283
00286 const signed char &mesh( int32_t i, int32_t j ) const {
00287 return( _smesh[i + j*_size[0]] );
00288 }
00289
00292 const signed char &mesh( int32_t i, int32_t j, int32_t k ) const {
00293 return( _smesh[i + j*_size[0] + k*_size[0]*_size[1]] );
00294 }
00295
00298 signed char &mesh( int32_t i ) { return( _smesh[i] ); }
00299
00302 signed char &mesh( int32_t i, int32_t j ) {
00303 return( _smesh[i + j*_size[0]] );
00304 }
00305
00308 signed char &mesh( int32_t i, int32_t j, int32_t k ) {
00309 return( _smesh[i + j*_size[0] + k*_size[0]*_size[1]] );
00310 }
00311
00315 signed char mesh_check( int32_t i, int32_t j, int32_t k ) const;
00316
00319 void save( const std::string &filename ) const;
00320
00323 void save( std::ostream &os ) const;
00324
00327 void debug_print( std::ostream &os ) const;
00328 };
00329
00330
00331 #endif
00332