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
mydxfspline.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2011,2014 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 MY_DXF_SPLINE_HPP
45 #define MY_DXF_SPLINE_HPP 1
46 
47 
48 #include "mydxfentities.hpp"
49 
50 
51 /* Spline flags */
52 #define SPLINE_CLOSED_MASK 1
53 #define SPLINE_PERIODIC_MASK 2
54 #define SPLINE_RATIONAL_MASK 4
55 #define SPLINE_PLANAR_MASK 8
56 #define SPLINE_LINEAR_MASK 16
57 
58 
64 {
65 
66  uint16_t _degree;
67  double _knot_tol;
68  double _cont_tol;
69  double _fit_tol;
70  Vec3D _normal;
71  Vec3D _tangent0;
72  Vec3D _tangent1;
73  std::vector<double> _knot;
74  std::vector<Vec3D> _cont;
75  std::vector<Vec3D> _fit;
76  int16_t _flags;
78  std::vector<Vec3D> _polyline;
80  void make_cyclic( void );
81  void add_to_start( const Vec3D &x );
82  void add_to_end( const Vec3D &x );
83  void check_knots( void ) const;
84  Vec3D point( double t ) const;
85  Vec3D deboor( double t, int i, int k ) const;
86  void build_polyline( void );
87 
88  void plot_polyline_points( cairo_t *cairo, const Transformation *t ) const;
89  void plot_knot_points( cairo_t *cairo, const Transformation *t ) const;
90  void plot_control_points( cairo_t *cairo, const Transformation *t ) const;
91 
92 public:
93 
96  MyDXFSpline( class MyDXFFile *dxf );
97 
100  virtual ~MyDXFSpline() {}
101 
104  virtual MyDXFSpline *copy( void ) const { return( new MyDXFSpline( *this ) ); }
105 
112  virtual void explode( class MyDXFEntities *ent, MyDXFFile *dxf, const Transformation *t ) const;
113 
116  virtual void write( class MyDXFFile *dxf, std::ofstream &ostr );
117 
120  virtual EntityType get_type( void ) const { return( ENTITY_SPLINE ); }
121 
124  virtual Vec3D start( void ) const;
125 
128  virtual Vec3D end( void ) const;
129 
132  virtual void set_start( const Vec3D &s );
133 
136  virtual void set_end( const Vec3D &e );
137 
146  virtual int ray_cross( double x, double y ) const;
147 
153  bool geom_same( const MyDXFSpline &spline, double eps = 1.0e-6 ) const;
154 
157  bool closed( void ) const { return( _flags & SPLINE_CLOSED_MASK ); }
158 
161  bool periodic( void ) const { return( _flags & SPLINE_PERIODIC_MASK ); }
162 
165  bool rational( void ) const { return( _flags & SPLINE_RATIONAL_MASK ); }
166 
174  virtual void plot( const class MyDXFFile *dxf, cairo_t *cairo,
175  const Transformation *t, const double range[4] ) const;
176 
179  virtual void get_bbox( Vec3D &min, Vec3D &max,
180  const class MyDXFFile *dxf, const Transformation *t ) const;
181 
184  virtual void scale( class MyDXFFile *dxf, double s );
185 
188  virtual void translate( class MyDXFFile *dxf, const Vec3D &dx );
189 
194  virtual void rotate_z( class MyDXFFile *dxf, double a );
195 
198  virtual void debug_print( std::ostream &os ) const;
199 };
200 
201 
202 #endif
203 
DXF entity database.
Definition: mydxfentities.hpp:286
DXF file class.
Definition: mydxffile.hpp:70
DXF path entity base class.
Definition: mydxfentities.hpp:187
DXF spline entity class.
Definition: mydxfspline.hpp:64
virtual void translate(class MyDXFFile *dxf, const Vec3D &dx)
Translate entity by dx.
Definition: mydxfspline.cpp:736
MyDXFSpline(class MyDXFFile *dxf)
Construct line entity by reading from DXF file.
Definition: mydxfspline.cpp:48
virtual MyDXFSpline * copy(void) const
Get a new copy of entity.
Definition: mydxfspline.hpp:104
bool periodic(void) const
Is spline periodic?
Definition: mydxfspline.hpp:161
virtual ~MyDXFSpline()
Virtual destructor.
Definition: mydxfspline.hpp:100
bool closed(void) const
Is entity closed path?
Definition: mydxfspline.hpp:157
bool rational(void) const
Is spline rational?
Definition: mydxfspline.hpp:165
virtual void plot(const class MyDXFFile *dxf, cairo_t *cairo, const Transformation *t, const double range[4]) const
Plot entity with cairo.
Definition: mydxfspline.cpp:654
virtual EntityType get_type(void) const
Get entity type.
Definition: mydxfspline.hpp:120
virtual Vec3D end(void) const
Get end point of path entity.
Definition: mydxfspline.cpp:360
bool geom_same(const MyDXFSpline &spline, double eps=1.0e-6) const
Check if two entities are geometrically same.
Definition: mydxfspline.cpp:429
virtual void write(class MyDXFFile *dxf, std::ofstream &ostr)
Write dxf file to stream.
Definition: mydxfspline.cpp:309
virtual void set_end(const Vec3D &e)
Set end point of path entity.
Definition: mydxfspline.cpp:372
virtual void debug_print(std::ostream &os) const
Print debugging information to stream os.
Definition: mydxfspline.cpp:435
virtual void explode(class MyDXFEntities *ent, MyDXFFile *dxf, const Transformation *t) const
Explode into entities.
Definition: mydxfspline.cpp:294
virtual Vec3D start(void) const
Get start point of path entity.
Definition: mydxfspline.cpp:354
virtual void get_bbox(Vec3D &min, Vec3D &max, const class MyDXFFile *dxf, const Transformation *t) const
Return bounding box of entity.
Definition: mydxfspline.cpp:705
virtual int ray_cross(double x, double y) const
Check for ray crossing.
Definition: mydxfspline.cpp:378
virtual void rotate_z(class MyDXFFile *dxf, double a)
Rotate entity around origin.
Definition: mydxfspline.cpp:748
virtual void set_start(const Vec3D &s)
Set start point of path entity.
Definition: mydxfspline.cpp:366
virtual void scale(class MyDXFFile *dxf, double s)
Scale entity by factor s.
Definition: mydxfspline.cpp:724
Transformation for homogenous three dimensional space.
Definition: transformation.hpp:70
Three dimensional vector.
Definition: vec3d.hpp:58
DXF Entities.
EntityType
Entity type.
Definition: mydxfentities.hpp:60


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