Points&Forces (core)
Software tools facilitating the task of surveying architecture
dxf
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_dxf_entity.h
a_dxf_file.h
a_dxf_group.h
a_dxf_line.h
a_dxf_point.h
a_dxf_entity
a generic dxf entity
Definition:
a_dxf_entity.h:29
a_dxf_entity::read
bool read()
Definition:
a_dxf_entity.cxx:19
a_dxf_file::file_error
Definition:
a_dxf_file.h:35
a_dxf_file::a_dxf_file
a_dxf_file(std::string name)
Definition:
a_dxf_file.cxx:23
a_dxf_group
a dxf group
Definition:
a_dxf_group.h:30
a_dxf_group::code
int code()
Definition:
a_dxf_group.h:36
a_dxf_group::data_is
bool data_is(std::string s)
Definition:
a_dxf_group.h:40
a_dxf_group::read
bool read()
Definition:
a_dxf_group.cxx:21
a_dxf_line
a dxf line
Definition:
a_dxf_line.h:30
a_dxf_line::read
bool read()
Definition:
a_dxf_line.cxx:26
a_dxf_point
a dxf point
Definition:
a_dxf_point.h:30
a_dxf_point::read
bool read()
Definition:
a_dxf_point.cxx:25
Generated on Tue Sep 6 2022 18:50:16 for Points&Forces (core) by
1.9.1