mydxfblocks.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2010 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 #ifndef MY_DXF_BLOCKS_HPP
44 #define MY_DXF_BLOCKS_HPP 1
45 
46 
47 #include <stdint.h>
48 #include <vector>
49 #include <string>
50 #include "vec3d.hpp"
51 #include "mydxffile.hpp"
52 #include "mydxfentities.hpp"
53 #include "transformation.hpp"
54 
55 
59 {
60 
61  std::string _block_handle;
62  std::string _block_layer;
63 
64  std::string _endblk_handle;
65  std::string _endblk_layer;
66 
67  std::string _path;
68  std::string _owner_handle;
69  std::string _name; // Name reference used by INSERT
70 
71  int16_t _type;
72  Vec3D _p; // Base point
73 
74  class MyDXFEntities *_entities;
75 
76 public:
77 
78  MyDXFBlock( class MyDXFFile *dxf );
79  ~MyDXFBlock();
80 
83  void write( class MyDXFFile *dxf, std::ofstream &ostr );
84 
87  const std::string &name( void ) { return( _name ); }
88 
91  class MyDXFEntities *get_entities( void ) { return( _entities ); }
92 
95  const class MyDXFEntities *get_entities( void ) const { return( _entities ); }
96 
102  void explode( class MyDXFEntities *ent, MyDXFFile *dxf, const Transformation *t ) const;
103 
111  void plot( const class MyDXFFile *dxf, cairo_t *cairo,
112  const Transformation *t, const double range[4] ) const;
113 
116  void get_bbox( Vec3D &min, Vec3D &max,
117  const class MyDXFFile *dxf, const Transformation *t ) const;
118 
121  void scale( class MyDXFFile *dxf, double s );
122 
125  void translate( class MyDXFFile *dxf, const Vec3D &dx );
126 
127  friend std::ostream &operator<<( std::ostream &os, const MyDXFBlock &blk );
128 };
129 
130 
131 
137 {
138 
139  std::vector<MyDXFBlock *> _blocks;
140 
141 public:
142 
143  MyDXFBlocks( class MyDXFFile *dxf );
144  ~MyDXFBlocks();
145 
148  void write( class MyDXFFile *dxf, std::ofstream &ostr );
149 
150  uint32_t size( void ) const { return( _blocks.size() ); }
151 
152  MyDXFBlock *get_by_name( const std::string &name );
153  const MyDXFBlock *get_by_name( const std::string &name ) const;
154 
155  MyDXFBlock *operator()( int a ) { return( _blocks[a] ); }
156 
157  const MyDXFBlock *operator()( int a ) const { return( _blocks[a] ); }
158 
159  void clear( void );
160 
163  void debug_print( std::ostream &os ) const;
164 };
165 
166 
167 
168 
169 
170 #endif
171 
172 
173 
174 
void get_bbox(Vec3D &min, Vec3D &max, const class MyDXFFile *dxf, const Transformation *t) const
Return bounding box of entities within the block.
uint32_t size(void) const
Definition: mydxfblocks.hpp:150
void write(class MyDXFFile *dxf, std::ofstream &ostr)
Write dxf file to stream.
void explode(class MyDXFEntities *ent, MyDXFFile *dxf, const Transformation *t) const
Explode block into entities.
const MyDXFBlock * operator()(int a) const
Definition: mydxfblocks.hpp:157
friend std::ostream & operator<<(std::ostream &os, const MyDXFBlock &blk)
DXF Entities.
Three dimensional vectors.
void clear(void)
DXF block class.
Definition: mydxfblocks.hpp:58
class MyDXFEntities * get_entities(void)
Get a pointer to the entities of block.
Definition: mydxfblocks.hpp:91
MyDXFBlock(class MyDXFFile *dxf)
DXF File.
void write(class MyDXFFile *dxf, std::ofstream &ostr)
Write dxf file to stream.
DXF file class.
Definition: mydxffile.hpp:68
Transformation for homogenous three dimensional space.
Definition: transformation.hpp:59
DXF blocks class.
Definition: mydxfblocks.hpp:136
void translate(class MyDXFFile *dxf, const Vec3D &dx)
Translate entity by dx.
class MyDXFEntities * get_entities(void) const
Get a const pointer to the entities of block.
Definition: mydxfblocks.hpp:95
void scale(class MyDXFFile *dxf, double s)
Scale entities within block by factor s.
MyDXFBlock * operator()(int a)
Definition: mydxfblocks.hpp:155
void debug_print(std::ostream &os) const
Print debugging information to os.
MyDXFBlocks(class MyDXFFile *dxf)
MyDXFBlock * get_by_name(const std::string &name)
DXF entity database.
Definition: mydxfentities.hpp:279
Three dimensional vector.
Definition: vec3d.hpp:58
Full transformation for three dimensional homogenous space.
void plot(const class MyDXFFile *dxf, cairo_t *cairo, const Transformation *t, const double range[4]) const
Plot block with cairo.
const std::string & name(void)
Return name of block.
Definition: mydxfblocks.hpp:87