Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.6dev
      Class Index
      File List
   Version 1.0.6
   Version 1.0.5new_solver
   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,2022 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 <cairo.h>
51 #include "geometry.hpp"
52 #include "particledatabase.hpp"
53 #include "transformation.hpp"
54 #include "vec3d.hpp"
55 #include "palette.hpp"
56 
57 
60 class Geom3DPlot {
61 
62  const Geometry &_geom;
63  const ParticleDataBase *_pdb;
64 
65  bool _sdata_enable;
66  std::vector<double> _sdata;
67  double _sdata_range[2];
68  Palette _sdata_palette;
69 
70  size_t _width;
71  size_t _height;
72 
73  double _near;
74  double _far;
75  Vec3D _camera;
76  Vec3D _target;
77  Vec3D _up;
78  double _zoom;
79 
80  Transformation _modeltrans;
81 
82  Vec3D _center;
83  double _scale;
84 
85  std::vector<bool> _senable; // Enable/disable surface plotting, starts from 7
86  std::vector<Vec3D> _csurface[6]; // Sequences of 3: x0,x1,x2
87  std::vector<Vec3D> _gsurface; // Sequences of 4: norm,x0,x1,x2
88  std::vector<Vec3D> _gcolor; // Surface color
89 
90  uint32_t _particle_div;
91  uint32_t _particle_offset;
92  bool _bbox;
93  uint32_t _clevel[6];
94 
95  void cplane_add_vertex( int32_t p, const int32_t i[3], const int32_t vb[3], double dx, double dy );
96  double cplane_dist( const int32_t i[3], const int32_t vb[3], int32_t dx, int32_t dy, int32_t dir );
97  int32_t case2d( const int32_t i[3], const int32_t vb[3] );
98  void build_cut_plane( int32_t p, const int32_t vb[3], int32_t level );
99  void build_cut_planes( void );
100  void build_geometry_surface( void );
101  Vec3D sdata_palette( double sval ) const;
102  void clear_surface_data( void );
103 
104  bool node_disabled( uint32_t i, uint32_t j, uint32_t k ) const;
105  bool cell_disabled( uint32_t i, uint32_t j, uint32_t k ) const;
106  bool face_disabled( const int i[3], const int vb[3] ) const;
107 
108  void draw_cut_planes( class Renderer *r );
109  void draw_model( class Renderer *r );
110  void draw_bbox( class Renderer *r );
111  void draw_beam( class Renderer *r );
112 
113 public:
114 
117  Geom3DPlot( const Geometry &geom,
118  const ParticleDataBase *pdb );
119 
122  ~Geom3DPlot();
123 
126  void set_size( uint32_t width, uint32_t height );
127 
130  void set_model_transformation( const Transformation &modeltrans );
131 
135 
138  void set_projection_frustum( double xnear, double xfar, double zoom );
139 
142  void get_projection_frustum( double &xnear, double &xfar, double &zoom ) const ;
143 
146  void set_projection_zoom( double zoom );
147 
150  double get_projection_zoom( void ) const;
151 
154  void set_view_look_at( const Vec3D &camera,
155  const Vec3D &target,
156  const Vec3D &up );
157 
160  void get_view_look_at( Vec3D &camera,
161  Vec3D &target,
162  Vec3D &up ) const;
163 
168  void rebuild_model( void );
169 
172  void reset_camera_and_rotation( void );
173 
178  void set_surface_triangle_color_range( double min, double max );
179 
182  void get_surface_triangle_color_range( double &min, double &max ) const;
183 
186  void set_surface_triangle_data( const std::vector<double> *data );
187 
192  void set_surface_triangle_data_plot( bool enable );
193 
196  bool get_surface_triangle_data_plot( void ) const;
197 
205  void set_particle_div( uint32_t particle_div, uint32_t particle_offset = 0 );
206 
209  uint32_t get_particle_div( void ) const;
210 
213  uint32_t get_particle_offset( void ) const;
214 
217  void set_bbox( bool bbox );
218 
221  bool get_bbox( void ) const;
222 
228  void set_clevel( uint32_t direction, uint32_t level );
229 
235  uint32_t get_clevel( uint32_t direction ) const;
236 
241  void set_solid_plot( uint32_t a, bool enable );
242 
247  bool get_solid_plot( uint32_t a ) const;
248 
251  void draw( cairo_t *cairo, class Renderer *r );
252 };
253 
254 
255 #endif
Geometry 3D plotter.
Definition: geom3dplot.hpp:60
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
void set_particle_div(uint32_t particle_div, uint32_t particle_offset=0)
Set particle divisor and offset.
Definition: geom3dplot.cpp:191
Transformation get_model_transformation(void) const
Get modelling transformation.
Definition: geom3dplot.cpp:92
void set_surface_triangle_color_range(double min, double max)
Set surface triangle data ranges.
Definition: geom3dplot.cpp:146
bool get_surface_triangle_data_plot(void) const
Get if surface data is plotted.
Definition: geom3dplot.cpp:262
void rebuild_model(void)
Rebuild model.
Definition: geom3dplot.cpp:375
void reset_camera_and_rotation(void)
Reset camera settings and modelling transformation to default.
Definition: geom3dplot.cpp:383
bool get_bbox(void) const
Get if bounding box is plotted.
Definition: geom3dplot.cpp:216
void set_projection_zoom(double zoom)
Set camera zoom.
Definition: geom3dplot.cpp:114
void set_surface_triangle_data_plot(bool enable)
Set if surface data is to be plotted.
Definition: geom3dplot.cpp:256
uint32_t get_clevel(uint32_t direction) const
Get cut level for direction a.
Definition: geom3dplot.cpp:232
bool get_solid_plot(uint32_t a) const
Get if solid a is plotted.
Definition: geom3dplot.cpp:248
void draw(cairo_t *cairo, class Renderer *r)
Draw 3D geometry using renderer r.
Definition: geom3dplot.cpp:818
void get_projection_frustum(double &xnear, double &xfar, double &zoom) const
Get camera projection.
Definition: geom3dplot.cpp:106
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
void set_projection_frustum(double xnear, double xfar, double zoom)
Set camera projection.
Definition: geom3dplot.cpp:98
void set_bbox(bool bbox)
Set if bounding box is plotted.
Definition: geom3dplot.cpp:210
Geom3DPlot(const Geometry &geom, const ParticleDataBase *pdb)
Constructor.
Definition: geom3dplot.cpp:51
double get_projection_zoom(void) const
Get camera zoom.
Definition: geom3dplot.cpp:120
uint32_t get_particle_offset(void) const
Get particle offset.
Definition: geom3dplot.cpp:204
~Geom3DPlot()
Destructor.
Definition: geom3dplot.cpp:73
uint32_t get_particle_div(void) const
Get particle division.
Definition: geom3dplot.cpp:198
void set_model_transformation(const Transformation &modeltrans)
Set modelling transformation.
Definition: geom3dplot.cpp:86
void set_surface_triangle_data(const std::vector< double > *data)
Set surface triangle data for rendering.
Definition: geom3dplot.cpp:160
void set_solid_plot(uint32_t a, bool enable)
Set if solid a is to be plotted.
Definition: geom3dplot.cpp:240
void get_surface_triangle_color_range(double &min, double &max) const
Get surface triangle data ranges.
Definition: geom3dplot.cpp:153
Geometry defining class.
Definition: geometry.hpp:180
Class for palette definition.
Definition: palette.hpp:59
Particle database base class.
Definition: particledatabase.hpp:191
3D renderer base class.
Definition: renderer.hpp:56
Transformation for homogenous three dimensional space.
Definition: transformation.hpp:70
Three dimensional vector.
Definition: vec3d.hpp:58
Geometry definition
Palette for colormaps
Particle databases
Full transformation for three dimensional homogenous space.
Three dimensional vectors.


Reference manual for Ion Beam Simulator 1.0.6dev
Generated by Doxygen 1.9.1 on Thu Sep 11 2025 09:37:24.