Points&Forces (survey)
Software tools facilitating the task of surveying architecture
a_block.h
Go to the documentation of this file.
1 /*
2 Copyright 2010-2016 Pierre SMARS (smars@yuntech.edu.tw)
3 This program is free software: you can redistribute it and/or modify
4 it under he 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 #ifndef _A_BLOCK_H_
17 #define _A_BLOCK_H_
18 
19 #include <iostream>
20 #include <vector>
21 #include "a_wrench.h"
22 #include "a_twist.h"
23 #include "a_face.h"
24 #include "a_material.h"
25 #include "a_trianglecloud.h"
26 
27 class a_block
28 {
29 public:
30  a_block();
31  virtual ~a_block();
32  void clear();
34  static const std::string help();
35  virtual void copy(const a_block&);
36  virtual void deepcopy(const a_block&);
38  void g(a_point* g) {g_ = g;}
40  a_point * g() const {return g_;}
42  virtual double V() const = 0;
44  a_point c() const;
46  virtual a_point cl() const = 0;
47  virtual std::string name() const {return "a_block";}
49  double m() const;
51  double Ws() const;
53  a_wrench W() const;
55  a_wrench fe() const;
57  a_wrench ft() const;
59  a_wrench W(const a_block& be) const;
61  a_wrench ft(const a_block& be) const;
63  a_block * nextblock() const;
65  double potential() const;
67  void clearinternal();
69  void clearexternal();
71  void clearall();
73  a_block * compute();
77  a_material * material() const {return material_;}
79  inline int nv() const {return vertices_.size();}
81  virtual int nvt() const = 0;
83  inline int ni() const {return faces_.size();}
85  virtual int nit() const = 0;
87  void av(a_point * vertex) {vertices_.push_back(vertex);}
89  void ai(a_face * face) {faces_.push_back(face);}
91  a_point * v(const int i);
93  a_point * v(const int i) const;
95  virtual a_point v3d(const int i) const = 0;
97  a_face * i(const int i);
99  a_face * i(const int i) const;
101  a_twist * pos() const {return pos_;}
103  void place(const int fi, a_block * block, const int fe, double u, double v);
105  std::vector<int> in() const;
107  std::vector<int> out() const;
109  void exit(int ref);
111  int exit() const {return exit_face_;}
113  int entrance(int ref);
115  void criteria(a_fcriteria * criteria);
117  bool ok() const;
119  double penalty() const;
121  virtual void read(std::istream &i);
122  virtual void write(std::ostream &o) const;
124  virtual void writetri(std::ostream &o) const = 0;
126  virtual void writeb(std::ostream &o) const = 0;
128  virtual void writeg(std::ostream &o) const = 0;
129  void writeverts(std::ostream &o) const;
131  virtual void writefaces(std::ostream &o, const int base = 0) const = 0;
132  virtual void trianglecloud(a_trianglecloud&) const = 0;
133  friend std::istream& operator>> (std::istream& i, a_block& b);
134  friend std::ostream& operator<< (std::ostream& o, const a_block& b);
135 
138  class no_block_error {};
139 
140 protected:
141  std::vector<a_point *> vertices_;
142  std::vector<a_face *> faces_;
147  a_point * g_;
148 };
149 
150 #endif
151 
a_block * compute()
compute the exit force from all the forces on the block, return next block or 0 if last one or proble...
Definition: a_block.cxx:310
virtual void writefaces(std::ostream &o, const int base=0) const =0
write a triangle file description of the block
static const std::string help()
get information about the class
Definition: a_block.cxx:46
double potential() const
potential energy
Definition: a_block.cxx:246
virtual void copy(const a_block &)
Definition: a_block.cxx:99
int entrance(int ref)
set exit face specifying where the force enters
Definition: a_block.cxx:409
int exit_face_
Definition: a_block.h:145
void clearinternal()
clear all the internal face forces
Definition: a_block.cxx:253
a_wrench W() const
weight wrench in world coordinate
Definition: a_block.cxx:178
a_point * g() const
get gravity
Definition: a_block.h:40
virtual void write(std::ostream &o) const
Definition: a_block.cxx:473
friend std::ostream & operator<<(std::ostream &o, const a_block &b)
Definition: a_block.cxx:502
void av(a_point *vertex)
add a vertex
Definition: a_block.h:87
a_wrench fe() const
external force on block in world coordinate
Definition: a_block.cxx:186
virtual ~a_block()
Definition: a_block.cxx:31
void place(const int fi, a_block *block, const int fe, double u, double v)
place a face of the block on the face of another block
Definition: a_block.cxx:355
void writeverts(std::ostream &o) const
Definition: a_block.cxx:488
std::vector< int > in() const
return inside faces
Definition: a_block.cxx:373
void g(a_point *g)
set gravity
Definition: a_block.h:38
void clearall()
clear all the forces on faces
Definition: a_block.cxx:273
a_twist * pos_
Definition: a_block.h:146
std::vector< a_point * > vertices_
Definition: a_block.h:141
virtual void writeb(std::ostream &o) const =0
write a blender description of the block
double penalty() const
penalty value used for optimization
Definition: a_block.cxx:298
virtual void trianglecloud(a_trianglecloud &) const =0
a_wrench ft() const
total force on block in world coordinate
Definition: a_block.cxx:200
a_point c() const
centre of mass (in world coordinate)
Definition: a_block.cxx:162
virtual int nit() const =0
get number of faces (not only the reference faces)
virtual std::string name() const
Definition: a_block.h:47
a_face * i(const int i)
get pointer to face
Definition: a_block.cxx:148
bool ok() const
check if forces on face are acceptable
Definition: a_block.cxx:288
void criteria(a_fcriteria *criteria)
set resistance criteria
Definition: a_block.cxx:282
virtual a_point v3d(const int i) const =0
get vertex (world coordinate, 3D)
int ni() const
get number of faces
Definition: a_block.h:83
virtual void writeg(std::ostream &o) const =0
write a brlcad description of the block
virtual void writetri(std::ostream &o) const =0
write a triangle face representation of the block
a_twist * pos() const
get pointer to position handle
Definition: a_block.h:101
void ai(a_face *face)
add a face
Definition: a_block.h:89
std::vector< a_face * > faces_
Definition: a_block.h:142
a_block()
Definition: a_block.cxx:21
void clearexternal()
clear all the external face forces
Definition: a_block.cxx:263
a_material * material_
Definition: a_block.h:143
a_point * v(const int i)
get pointer to vertex
Definition: a_block.cxx:134
friend std::istream & operator>>(std::istream &i, a_block &b)
Definition: a_block.cxx:496
virtual a_point cl() const =0
centre of mass (in local system)
int exit() const
get exit face
Definition: a_block.h:111
a_point * g_
Definition: a_block.h:147
virtual void deepcopy(const a_block &)
Definition: a_block.cxx:110
bool material_auto_
Definition: a_block.h:144
virtual int nvt() const =0
get number of vertices (not only the reference vertices)
virtual void read(std::istream &i)
input/output
Definition: a_block.cxx:449
int nv() const
get number of vertices
Definition: a_block.h:79
double m() const
mass
Definition: a_block.cxx:167
void clear()
Definition: a_block.cxx:37
std::vector< int > out() const
return outside faces
Definition: a_block.cxx:385
virtual double V() const =0
volume of the block
a_material * material() const
get pointer to material
Definition: a_block.h:77
double Ws() const
weight
Definition: a_block.cxx:172
a_block * nextblock() const
block connected (return 0 if end or problem)
Definition: a_block.cxx:229
Definition: a_face.h:33
a twist class
Definition: a_twist.h:31
a wrench class
Definition: a_wrench.h:30