Points&Forces (survey)
Software tools facilitating the task of surveying architecture
Go to the documentation of this file.
1 /*
2  Copyright 2010-2012 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.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  GNU General Public License for more details.
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 #ifndef _A_ELEMENT_H_
17 #define _A_ELEMENT_H_
19 // .NAME a_element
20 // .SECTION Author
21 // Pierre Smars
23 class a_canvas;
25 #include "vtkActor.h"
26 #include "vtkPolyData.h"
27 #include "a_canvas.h"
28 #include <string>
29 #include <iostream>
30 #include <sstream>
31 #include <vector>
33 #include "a_point.h"
34 #include "a_image.h"
35 #include "a_text.h"
38 class a_element
39 {
40  public:
41  a_element();
42  ~a_element();
43  virtual void clear();
44  virtual std::string type() const {return "a_element";}
45  static const std::string help();
46  void setcanvas(a_canvas & can) {can_ = & can;}
47  void reset();
48  void render();
49  inline void name(std::string& aname) {name_ =aname;}
50  inline std::string name() const {return name_;}
51  inline bool empty() const {return polydata_->GetNumberOfCells() == 0;}
52  void empty(const bool code) {empty_ = code;}
53  void flushlog(); //copy the log information on the log file of a a_canvas when it is added to it
54  void color(double r, double g, double b);
55  void R(double v);
56  void G(double v);
57  void B(double v);
58  inline double R() const {return R_;}
59  inline double G() const {return G_;}
60  inline double B() const {return B_;}
61  void thickness(const int);
63  void greyscale(bool);
64  void zebra(bool);
66  bool greyscale() const;
67  void steps(const int);
68  int steps() const;
69  inline int thickness() const {return thickness_;}
70  inline vtkActor * actor() {return actor_;} //const?
71  inline vtkPolyData * polydata() {return polydata_;} //const?
72  inline bool operator==(const std::string& s) const {return name_==s;}
73  inline bool operator!=(const std::string& s) const {return name_!=s;}
74  void dxfout(std::ostream& o) const;
75  inline void visibility(const int code) {actor_->SetVisibility(code);this->render();}
76  inline bool isvisible() const {return actor_->GetVisibility()==1;}
77  inline bool isnotvisible() const {return actor_->GetVisibility()==0;}
78  void opacity(const double val);
79  void edges(const bool val);
80  void smooth(const bool val);
81  void relief(const a_point & p1, const a_point & p2);
83  void image(a_image & image);
84  void imageon();
85  void imageoff();
86  //: input/output
87  friend std::istream& operator>> (std::istream& i, a_element& l);
88  friend std::ostream& operator<< (std::ostream& o, const a_element& l);
89  virtual void read(std::istream& in) {};
90  virtual void write(std::ostream& o) const {};
91  void open(const std::string& file);
92  void save(const std::string& file);
93  void save_transform(const std::string& file);
94  void open_scalars(const std::string& file);
96  void reset_mapper_clipping();
98  void place(const double x, const double y, const double z);
99  void translate(const double x, const double y, const double z);
100  void origin(const double x, const double y, const double z);
101  void orient(const double pitch, const double roll, const double yaw);
102  void rotate(const double pitch, const double roll, const double yaw);
103  void scale(double s);
104  void scale(double s1, double s2, double s3);
105  a_point place() const;
106  a_point origin() const;
107  a_point orient() const;
108  double scale() const;
109  double small() const {return small_;}
110  void small(const double s) { small_=s;}
111  a_point center() const;
112  double size() const;
113  double minx() const;
114  double maxx() const;
115  double miny() const;
116  double maxy() const;
117  double minz() const;
118  double maxz() const;
120  protected:
121  void logname();
122  int addpoint(const a_point& p);
123  std::string name_;
124  vtkActor * actor_;
125  vtkPolyData * polydata_;
128  double R_; //colors
129  double G_;
130  double B_;
132  bool empty_;
133  std::vector<std::string> log0_;
134  void log(std::ostringstream& text);
135  double small_;
136 };
138 inline bool operator==(a_element * l, const std::string s) {return (*l) ==s;}
139 inline bool operator!=(a_element * l, const std::string s) {return (*l) !=s;}
140 void delete_vector(std::vector<a_element *> &);
142 #endif
void delete_vector(std::vector< a_element * > &)
Definition: a_element.cxx:665
bool operator!=(a_element *l, const std::string s)
Definition: a_element.h:139
bool operator==(a_element *l, const std::string s)
Definition: a_element.h:138
a vtk screen
Definition: a_canvas.h:40
layer used by screen to draw vector graphics
Definition: a_element.h:39
void open(const std::string &file)
Definition: a_element.cxx:411
vtkPolyData * polydata_
Definition: a_element.h:125
a_image * image_
Definition: a_element.h:127
double maxy() const
Definition: a_element.cxx:622
vtkActor * actor()
Definition: a_element.h:70
void log(std::ostringstream &text)
Definition: a_element.cxx:155
void logname()
Definition: a_element.cxx:109
bool operator==(const std::string &s) const
Definition: a_element.h:72
void setcanvas(a_canvas &can)
Definition: a_element.h:46
virtual void clear()
Definition: a_element.cxx:121
void name(std::string &aname)
Definition: a_element.h:49
void open_scalars(const std::string &file)
Definition: a_element.cxx:458
void smooth(const bool val)
Definition: a_element.cxx:325
friend std::ostream & operator<<(std::ostream &o, const a_element &l)
Definition: a_element.cxx:405
a_point origin() const
Definition: a_element.cxx:564
virtual void read(std::istream &in)
Definition: a_element.h:89
int addpoint(const a_point &p)
Definition: a_element.cxx:643
void dxfout(std::ostream &o) const
Definition: a_element.cxx:361
std::string name() const
Definition: a_element.h:50
bool isnotvisible() const
Definition: a_element.h:77
void small(const double s)
Definition: a_element.h:110
static const std::string help()
Definition: a_element.cxx:66
void translate(const double x, const double y, const double z)
Definition: a_element.cxx:506
void image(a_image &image)
Definition: a_element.cxx:365
void save(const std::string &file)
Definition: a_element.cxx:420
bool operator!=(const std::string &s) const
Definition: a_element.h:73
a_point place() const
Definition: a_element.cxx:557
double miny() const
Definition: a_element.cxx:615
double scale() const
Definition: a_element.cxx:578
void reset_mapper_clipping()
Definition: a_element.cxx:484
double small_
Definition: a_element.h:135
bool empty_
Definition: a_element.h:132
void save_transform(const std::string &file)
Definition: a_element.cxx:429
friend std::istream & operator>>(std::istream &i, a_element &l)
Definition: a_element.cxx:399
std::vector< std::string > log0_
Definition: a_element.h:133
double minz() const
Definition: a_element.cxx:629
void relief(const a_point &p1, const a_point &p2)
Definition: a_element.cxx:343
std::string name_
Definition: a_element.h:123
double maxx() const
Definition: a_element.cxx:608
void reset()
Definition: a_element.cxx:168
double R() const
Definition: a_element.h:58
bool isvisible() const
Definition: a_element.h:76
double maxz() const
Definition: a_element.cxx:636
void imageoff()
Definition: a_element.cxx:390
void visibility(const int code)
Definition: a_element.h:75
double size() const
Definition: a_element.cxx:592
double B_
Definition: a_element.h:130
void zebra(bool)
Definition: a_element.cxx:240
double G() const
Definition: a_element.h:59
void imageon()
Definition: a_element.cxx:379
void empty(const bool code)
Definition: a_element.h:52
double minx() const
Definition: a_element.cxx:601
bool greyscale() const
get the scalar viewing mode
Definition: a_element.cxx:274
void color(double r, double g, double b)
Definition: a_element.cxx:180
int thickness_
Definition: a_element.h:131
double R_
Definition: a_element.h:128
vtkActor * actor_
Definition: a_element.h:124
void flushlog()
Definition: a_element.cxx:132
double small() const
Definition: a_element.h:109
a_canvas * can_
Definition: a_element.h:126
void opacity(const double val)
Definition: a_element.cxx:300
a_point center() const
Definition: a_element.cxx:585
bool empty() const
Definition: a_element.h:51
double G_
Definition: a_element.h:129
virtual std::string type() const
Definition: a_element.h:44
void rotate(const double pitch, const double roll, const double yaw)
Definition: a_element.cxx:533
a_point orient() const
Definition: a_element.cxx:571
vtkPolyData * polydata()
Definition: a_element.h:71
int steps() const
Definition: a_element.cxx:294
void render()
Definition: a_element.cxx:127
int thickness() const
Definition: a_element.h:69
double B() const
Definition: a_element.h:60
virtual void write(std::ostream &o) const
Definition: a_element.h:90
void edges(const bool val)
Definition: a_element.cxx:311
double v(const uint32_t step, const uint32_t n)
Definition: generate.cxx:42
std::istringstream in
Definition: ply2tri.cxx:32