Points&Forces (core)
Software tools facilitating the task of surveying architecture
a_dxf_line.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_line.h"
17 #include "a_dxf_group.h"
18 
19 //---------------------------------------------------------------------------
20 a_dxf_line::a_dxf_line(std::istream * file) : a_dxf_entity(file)
21 {
22  x1_ok = false; y1_ok = false; z1_ok = false;
23  x2_ok = false; y2_ok = false; z2_ok = false;
24 }
25 //---------------------------------------------------------------------------
27 {
28  a_dxf_group group(file_);
29  layer_ = "0";
30  for (;;)
31  {
32  group.read();
33  if (group.code()==8)
34  layer_ = group.data();
35  if (group.code()==10)
36  {
37  x1_ = group.data_double();
38  x1_ok = true;
39  }
40  if (group.code()==20)
41  {
42  y1_ = group.data_double();
43  y1_ok = true;
44  }
45  if (group.code()==30)
46  {
47  z1_ = group.data_double();
48  z1_ok = true;
49  }
50  if (group.code()==11)
51  {
52  x2_ = group.data_double();
53  x2_ok = true;
54  }
55  if (group.code()==21)
56  {
57  y2_ = group.data_double();
58  y2_ok = true;
59  }
60  if (group.code()==31)
61  {
62  z2_ = group.data_double();
63  z2_ok = true;
64  }
65  if (group.code()==0)
66  break;
67  }
68  group.putback();
69  if (x1_ok && y1_ok && z1_ok && x2_ok && y2_ok && z2_ok)
70  return true;
71  else
72  return false;
73 }
a generic dxf entity
Definition: a_dxf_entity.h:29
std::string layer_
Definition: a_dxf_entity.h:38
std::istream * file_
Definition: a_dxf_entity.h:37
a dxf group
Definition: a_dxf_group.h:30
double data_double()
Definition: a_dxf_group.cxx:90
int code()
Definition: a_dxf_group.h:36
void putback()
Definition: a_dxf_group.cxx:68
std::string data()
Definition: a_dxf_group.h:37
bool y2_ok
Definition: a_dxf_line.h:46
bool read()
Definition: a_dxf_line.cxx:26
double x2_
Definition: a_dxf_line.h:45
bool z1_ok
Definition: a_dxf_line.h:44
bool x1_ok
Definition: a_dxf_line.h:42
double y2_
Definition: a_dxf_line.h:46
a_dxf_line(std::istream *file)
Definition: a_dxf_line.cxx:20
bool x2_ok
Definition: a_dxf_line.h:45
double z2_
Definition: a_dxf_line.h:47
bool z2_ok
Definition: a_dxf_line.h:47
bool y1_ok
Definition: a_dxf_line.h:43
double x1_
Definition: a_dxf_line.h:42
double z1_
Definition: a_dxf_line.h:44
double y1_
Definition: a_dxf_line.h:43