Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.5new_solver
      Class Index
      File List
   Version 1.0.5dev
   Version 1.0.5b
   Version 1.0.4dev
   Version 1.0.4
Publications


Hosted by Get Ion Beam Simulator at SourceForge.net. Fast, secure and Free Open Source software downloads
geom3dplot.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2012,2013 Taneli Kalvas. All rights reserved.
6  *
7  * You can redistribute this software and/or modify it under the terms
8  * of the GNU General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this library (file "COPYING" included in the package);
19  * if not, write to the Free Software Foundation, Inc., 51 Franklin
20  * Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * If you have questions about your rights to use or distribute this
23  * software, please contact Berkeley Lab's Technology Transfer
24  * Department at TTD@lbl.gov. Other questions, comments and bug
25  * reports should be sent directly to the author via email at
26  * taneli.kalvas@jyu.fi.
27  *
28  * NOTICE. This software was developed under partial funding from the
29  * U.S. Department of Energy. As such, the U.S. Government has been
30  * granted for itself and others acting on its behalf a paid-up,
31  * nonexclusive, irrevocable, worldwide license in the Software to
32  * reproduce, prepare derivative works, and perform publicly and
33  * display publicly. Beginning five (5) years after the date
34  * permission to assert copyright is obtained from the U.S. Department
35  * of Energy, and subject to any subsequent five (5) year renewals,
36  * the U.S. Government is granted for itself and others acting on its
37  * behalf a paid-up, nonexclusive, irrevocable, worldwide license in
38  * the Software to reproduce, prepare derivative works, distribute
39  * copies to the public, perform publicly and display publicly, and to
40  * permit others to do so.
41  */
42 
43 
44 #ifndef GEOM3DPLOT_HPP
45 #define GEOM3DPLOT_HPP 1
46 
47 
48 #include <stdint.h>
49 #include <vector>
50 #include "geometry.hpp"
51 #include "particledatabase.hpp"
52 #include "transformation.hpp"
53 #include "vec3d.hpp"
54 #include "palette.hpp"
55 
56 
59 class Geom3DPlot {
60 
61  const Geometry &_geom;
62  const ParticleDataBase *_pdb;
63 
64  bool _sdata_enable;
65  std::vector<double> _sdata;
66  double _sdata_range[2];
67  Palette _sdata_palette;
68 
69  size_t _width;
70  size_t _height;
71 
72  double _near;
73  double _far;
74  Vec3D _camera;
75  Vec3D _target;
76  Vec3D _up;
77  double _zoom;
78 
79  Transformation _modeltrans;
80 
81  Vec3D _center;
82  double _scale;
83 
84  std::vector<bool> _senable; // Enable/disable surface plotting, starts from 7
85  std::vector<Vec3D> _csurface[6]; // Sequences of 3: x0,x1,x2
86  std::vector<Vec3D> _gsurface; // Sequences of 4: norm,x0,x1,x2
87  std::vector<Vec3D> _gcolor; // Surface color
88 
89  uint32_t _particle_div;
90  uint32_t _particle_offset;
91  bool _bbox;
92  uint32_t _clevel[6];
93 
94  void cplane_add_vertex( int32_t p, const int32_t i[3], const int32_t vb[3], double dx, double dy );
95  double cplane_dist( const int32_t i[3], const int32_t vb[3], int32_t dx, int32_t dy, int32_t dir );
96  int32_t case2d( const int32_t i[3], const int32_t vb[3] );
97  void build_cut_plane( int32_t p, const int32_t vb[3], int32_t level );
98  void build_cut_planes( void );
99  void build_geometry_surface( void );
100  Vec3D sdata_palette( double sval ) const;
101  void clear_surface_data( void );
102 
103  bool node_disabled( uint32_t i, uint32_t j, uint32_t k ) const;
104  bool cell_disabled( uint32_t i, uint32_t j, uint32_t k ) const;
105  bool face_disabled( const int i[3], const int vb[3] ) const;
106 
107  void draw_cut_planes( class Renderer *r );
108  void draw_model( class Renderer *r );
109  void draw_bbox( class Renderer *r );
110  void draw_beam( class Renderer *r );
111 
112 public:
113 
116  Geom3DPlot( const Geometry &geom,
117  const ParticleDataBase *pdb );
118 
121  ~Geom3DPlot();
122 
125  void set_size( uint32_t width, uint32_t height );
126 
129  void set_model_transformation( const Transformation &modeltrans );
130 
134 
137  void set_projection_frustum( double xnear, double xfar, double zoom );
138 
141  void get_projection_frustum( double &xnear, double &xfar, double &zoom ) const ;
142 
145  void set_projection_zoom( double zoom );
146 
149  double get_projection_zoom( void ) const;
150 
153  void set_view_look_at( const Vec3D &camera,
154  const Vec3D &target,
155  const Vec3D &up );
156 
159  void get_view_look_at( Vec3D &camera,
160  Vec3D &target,
161  Vec3D &up ) const;
162 
167  void rebuild_model( void );
168 
171  void reset_camera_and_rotation( void );
172 
177  void set_surface_triangle_color_range( double min, double max );
178 
181  void get_surface_triangle_color_range( double &min, double &max ) const;
182 
185  void set_surface_triangle_data( const std::vector<double> *data );
186 
191  void set_surface_triangle_data_plot( bool enable );
192 
195  bool get_surface_triangle_data_plot( void ) const;
196 
204  void set_particle_div( uint32_t particle_div, uint32_t particle_offset = 0 );
205 
208  uint32_t get_particle_div( void ) const;
209 
212  uint32_t get_particle_offset( void ) const;
213 
216  void set_bbox( bool bbox );
217 
220  bool get_bbox( void ) const;
221 
227  void set_clevel( uint32_t direction, uint32_t level );
228 
234  uint32_t get_clevel( uint32_t direction ) const;
235 
240  void set_solid_plot( uint32_t a, bool enable );
241 
246  bool get_solid_plot( uint32_t a ) const;
247 
250  void draw( class Renderer *r );
251 };
252 
253 
254 #endif
Geometry definition
3D renderer base class.
Definition: renderer.hpp:56
void reset_camera_and_rotation(void)
Reset camera settings and modelling transformation to default.
Definition: geom3dplot.cpp:383
void get_surface_triangle_color_range(double &min, double &max) const
Get surface triangle data ranges.
Definition: geom3dplot.cpp:153
Geometry 3D plotter.
Definition: geom3dplot.hpp:59
void set_projection_frustum(double xnear, double xfar, double zoom)
Set camera projection.
Definition: geom3dplot.cpp:98
void set_surface_triangle_color_range(double min, double max)
Set surface triangle data ranges.
Definition: geom3dplot.cpp:146
Palette for colormaps
uint32_t get_clevel(uint32_t direction) const
Get cut level for direction a.
Definition: geom3dplot.cpp:232
void rebuild_model(void)
Rebuild model.
Definition: geom3dplot.cpp:375
Class for palette definition.
Definition: palette.hpp:59
bool get_bbox(void) const
Get if bounding box is plotted.
Definition: geom3dplot.cpp:216
Three dimensional vectors.
Particle databases
void set_bbox(bool bbox)
Set if bounding box is plotted.
Definition: geom3dplot.cpp:210
double get_projection_zoom(void) const
Get camera zoom.
Definition: geom3dplot.cpp:120
void set_projection_zoom(double zoom)
Set camera zoom.
Definition: geom3dplot.cpp:114
Geometry defining class.
Definition: geometry.hpp:179
void draw(class Renderer *r)
Draw 3D geometry using renderer r.
Definition: geom3dplot.cpp:818
Transformation for homogenous three dimensional space.
Definition: transformation.hpp:69
void set_model_transformation(const Transformation &modeltrans)
Set modelling transformation.
Definition: geom3dplot.cpp:86
void set_particle_div(uint32_t particle_div, uint32_t particle_offset=0)
Set particle divisor and offset.
Definition: geom3dplot.cpp:191
bool get_surface_triangle_data_plot(void) const
Get if surface data is plotted.
Definition: geom3dplot.cpp:262
bool get_solid_plot(uint32_t a) const
Get if solid a is plotted.
Definition: geom3dplot.cpp:248
void get_projection_frustum(double &xnear, double &xfar, double &zoom) const
Get camera projection.
Definition: geom3dplot.cpp:106
void set_solid_plot(uint32_t a, bool enable)
Set if solid a is to be plotted.
Definition: geom3dplot.cpp:240
void set_size(uint32_t width, uint32_t height)
Set canvas size.
Definition: geom3dplot.cpp:79
void set_view_look_at(const Vec3D &camera, const Vec3D &target, const Vec3D &up)
Set camera positioning.
Definition: geom3dplot.cpp:126
Transformation get_model_transformation(void) const
Get modelling transformation.
Definition: geom3dplot.cpp:92
Geom3DPlot(const Geometry &geom, const ParticleDataBase *pdb)
Constructor.
Definition: geom3dplot.cpp:51
Three dimensional vector.
Definition: vec3d.hpp:58
Full transformation for three dimensional homogenous space.
void set_surface_triangle_data(const std::vector< double > *data)
Set surface triangle data for rendering.
Definition: geom3dplot.cpp:160
uint32_t get_particle_div(void) const
Get particle division.
Definition: geom3dplot.cpp:198
void set_surface_triangle_data_plot(bool enable)
Set if surface data is to be plotted.
Definition: geom3dplot.cpp:256
~Geom3DPlot()
Destructor.
Definition: geom3dplot.cpp:73
Particle database base class.
Definition: particledatabase.hpp:191
void set_clevel(uint32_t direction, uint32_t level)
Set cut level for direction a.
Definition: geom3dplot.cpp:222
void get_view_look_at(Vec3D &camera, Vec3D &target, Vec3D &up) const
Get camera positioning.
Definition: geom3dplot.cpp:136
uint32_t get_particle_offset(void) const
Get particle offset.
Definition: geom3dplot.cpp:204


Reference manual for Ion Beam Simulator 1.0.5new_solver
Generated by Doxygen 1.8.5 on Tue May 19 2015 09:15:42.