Points&Forces (core)
Software tools facilitating the task of surveying architecture
a_dxf_file.cxx
Go to the documentation of this file.
1 /*
2 Copyright 2002-2011 Pierre SMARS (smars@yuntech.edu.tw)
3 This program is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, either version 2 of the License, or
6 (at your option) any later version.
7 
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 #include "a_dxf_file.h"
17 #include <fstream>
18 #include "a_dxf_group.h"
19 #include "a_dxf_entity.h"
20 #include "a_dxf_point.h"
21 #include "a_dxf_line.h"
22 
23 a_dxf_file::a_dxf_file(std::string name)
24 {
25  std::ifstream ff(name.c_str());
26  a_dxf_group group(&ff);
27  //loop through entitities
28  a_dxf_point point(&ff);
29  a_dxf_line line(&ff);
30  a_dxf_entity entity(&ff);
31  while (group.read())
32  {
33  if (group.code() != 0) throw file_error();
34  {
35  //read entity
36  if (group.data_is("POINT")) point.read();
37  else if (group.data_is("LINE")) line.read();
38  else entity.read();
39  }
40  }
41  ff.close();
42 }
43 
44 /*
45 a_dxf_file::a_dxf_file(std::string name)
46 {
47  std::ifstream ff(name.c_str());
48  a_dxf_group group(&ff);
49  //find entities
50  bool exist_entities = true;
51  bool exist_entities = false;
52  while (group.read())
53  {
54  // group.write();
55  if (group.data_is("ENTITIES"))
56  {
57  exist_entities = true;
58  break;
59  }
60  }
61  //loop through entitities
62  if (exist_entities)
63  {
64  a_dxf_point point(&ff);
65  a_dxf_line line(&ff);
66  a_dxf_entity entity(&ff);
67  while (group.read())
68  {
69 // group.write();
70  if (group.code() != 0) throw file_error();
71  {
72  //read entity
73  if (group.data_is("POINT")) point.read();
74  else if (group.data_is("LINE")) line.read();
75  else entity.read();
76  }
77  }
78  }
79 
80 }
81 */
a generic dxf entity
Definition: a_dxf_entity.h:29
a_dxf_file(std::string name)
Definition: a_dxf_file.cxx:23
a dxf group
Definition: a_dxf_group.h:30
int code()
Definition: a_dxf_group.h:36
bool data_is(std::string s)
Definition: a_dxf_group.h:40
a dxf line
Definition: a_dxf_line.h:30
bool read()
Definition: a_dxf_line.cxx:26
a dxf point
Definition: a_dxf_point.h:30