Points&Forces (survey)
Software tools facilitating the task of surveying architecture
a_structure.h
Go to the documentation of this file.
1 /*
2 Copyright 2010-2014 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 #ifndef _A_STRUCTURE_H_
17 #define _A_STRUCTURE_H_
18 
19 #include <iostream>
20 #include <vector>
21 #include "a_block.h"
22 #include "a_ocriteria.h"
23 #include "a_trianglecloud.h"
24 #include "a_linecloud.h"
25 
33 {
34 public:
35  a_structure();
36  ~a_structure();
37  void clear();
39  static const std::string help();
41  int nb() const {return blocks_.size();}
43  int rb(const a_block* b) const;
45  double V() const;
47  a_point c() const;
49  double m() const;
51  double Ws() const;
53  a_wrench W();
55  a_wrench fe();
57  a_wrench ft();
59  double potential() const;
61  int add_block(a_block * b);
63  void link_blocks(int b1, int f1, int b2, int f2);
65  a_block * b(const int i) const;
67  bool connected() const;
69  std::vector<int> out() const;
71  std::vector<int> in() const;
73  std::vector<int> nodes() const;
75  void clearinternal();
77  void clearexternal();
79  void clearall();
83  double objective() const;
85  void criteria(a_fcriteria * criteria);
87  bool ok() const;
89  double penalty() const;
91  void penalty_factor(const double v) {penalty_factor_=v;}
93  double penalty_factor() const {return penalty_factor_;}
95  double objectivep() const;
97  void rotate(int rb, int f, const a_point& x, const a_point& dir, double r);
99  void rotate(int b, int f, double v, double r);
101  void slide(int b, int f, double u, double v);
103  void material(a_material * material);
105  a_block * compute(int b, int f);
107  //rb1: block reference (1st block is 0) rb1 should be in between rf1 and rf3!!!
108  //rb2: rb2 should be in between rb1 and rb3
109  //rb3: rb3 should be in between rf1 and rf3!!!
110  //rfi: face of the block
111  //ui: excentricity in the direction of u in local reference system of face (def depends of face)
112  //uj: excentricity in the direction of v in local reference system of face (def depends of face)
113  void compute( const int rb1, const int rf1, const double u1, const double v1,
114  const int rb2, const int rf2, const double u2, const double v2,
115  const int rb3, const int rf3, const double u3, const double v3);
117  double min( const int face,
118  const int rb1, const int rf1, const double u1,
119  const int rb2, const int rf2, const double u2,
120  const int rb3, const int rf3, const double u3);
122  double mindir( const a_point & dir,
123  const int rb1, const int rf1, double &u1,
124  const int rb2, const int rf2, double &u2,
125  const int rb3, const int rf3, double &u3);
127  double max( const int face,
128  const int rb1, const int rf1, const double u1,
129  const int rb2, const int rf2, const double u2,
130  const int rb3, const int rf3, const double u3);
132  void min( const int rb1, const int rf1,
133  const int rb2, const int rf2);
135  void max( const int rb1, const int rf1,
136  const int rb2, const int rf2);
137  void minsteep( const int rb1, const int rf1,
138  const int rb2, const int rf2);
140  virtual void writetri(std::ostream &o) const;
142  virtual void writeb(std::ostream &o) const;
144  virtual void writeg(std::ostream &o) const;
145  void trianglecloud(a_trianglecloud&) const;
146  void polyline(a_linecloud&) const;
148  friend std::istream& operator>> (std::istream& i, a_structure& s);
149  friend std::ostream& operator<< (std::ostream& o, const a_structure& s);
150 
152  class range_error {};
153 
154 protected:
156  bool check_block(const int rb) const;
158  bool check_blockref(const int rb, const int rf) const;
160  bool faceonexit(const int rb1, const int rf1, const int rb2, const int rf2);
162  void midblock( const int rb1, const int rf1,
163  const int rb2, const int rf2,
164  a_block *& rb, int&rf);
166  void optimise( const bool is_min,
167  const int rb1, const int rf1,
168  const int rb2, const int rf2);
170  void storeexits(std::vector<int>&) const;
172  void restoreexits(std::vector<int>&);
174  double grad1( const int rb1, const int rf1,
175  const int rb2, const int rf2,
176  const int rb3, const int rf3, const double * u);
178  double grad2( const int rb1, const int rf1,
179  const int rb2, const int rf2,
180  const int rb3, const int rf3,
181  const double * u);
183  double grad3( const int rb1, const int rf1,
184  const int rb2, const int rf2,
185  const int rb3, const int rf3,
186  const double * u);
187  std::vector<a_block *> blocks_;
190 };
191 
192 #endif
193 
structure class
Definition: a_structure.h:33
int rb(const a_block *b) const
get reference of a block (-1 if no block)
std::vector< int > nodes() const
get list of blocks connected to more than 2 other blocks (sources of hyperstaticity)
void rotate(int rb, int f, const a_point &x, const a_point &dir, double r)
rotate of angle r (rad) all blocks connected to rb, around x using axis dir
void penalty_factor(const double v)
set penalty factor
Definition: a_structure.h:91
void minsteep(const int rb1, const int rf1, const int rb2, const int rf2)
a_ocriteria * objective_
Definition: a_structure.h:188
double max(const int face, const int rb1, const int rf1, const double u1, const int rb2, const int rf2, const double u2, const int rb3, const int rf3, const double u3)
vary force on face to get a maximal objective function, respecting face criteria
void trianglecloud(a_trianglecloud &) const
a_wrench W()
get weight (wrench)
void polyline(a_linecloud &) const
double min(const int face, const int rb1, const int rf1, const double u1, const int rb2, const int rf2, const double u2, const int rb3, const int rf3, const double u3)
vary force on face to get a minimal objective function, respecting face criteria
void restoreexits(std::vector< int > &)
restore face exits situation
a_block * compute(int b, int f)
compute as far as possible the forces on the blocks, starting from block b, entrance face f,...
double V() const
get volume of structure
void clearexternal()
clear all the external face forces
double penalty_factor() const
get penalty factor
Definition: a_structure.h:93
bool connected() const
check whether all blocks are connected
void clear()
Definition: a_structure.cxx:48
double penalty_factor_
Definition: a_structure.h:189
bool faceonexit(const int rb1, const int rf1, const int rb2, const int rf2)
check whether rf2 in an exit face
std::vector< int > out() const
get list of extreme blocks (blocks connected only to 1 other block)
void clearall()
clear all the forces on faces
int nb() const
get number of blocks
Definition: a_structure.h:41
static const std::string help()
get information about the class
Definition: a_structure.cxx:54
double objectivep() const
get value of objective function + penalty*penalty_factor_
double grad2(const int rb1, const int rf1, const int rb2, const int rf2, const int rb3, const int rf3, const double *u)
grad of objective function + penalty
void slide(int b, int f, double u, double v)
slide of (u,v) all blocks connected to b in the plane of f
virtual void writeb(std::ostream &o) const
write structure in blender format
void clearinternal()
clear all the internal face forces
double potential() const
get potential energy
int add_block(a_block *b)
add a block to the structure
a_wrench ft()
get total force on structure fe+W (wrench)
std::vector< int > in() const
get list of internal blocks (blocks connected at least to 2 other blocks)
double mindir(const a_point &dir, const int rb1, const int rf1, double &u1, const int rb2, const int rf2, double &u2, const int rb3, const int rf3, double &u3)
vary force on faces (in proportion to dir) to get a minimal objective function, respecting face crite...
double Ws() const
get weight (scalar)
a_wrench fe()
get external force on structure (wrench)
void material(a_material *material)
link a material
double grad1(const int rb1, const int rf1, const int rb2, const int rf2, const int rb3, const int rf3, const double *u)
grad of objective function + penalty
bool ok() const
check if forces on face are acceptable
void criteria(a_fcriteria *criteria)
set resistance criteria
a_block * b(const int i) const
get pointer to the block i
void optimise(const bool is_min, const int rb1, const int rf1, const int rb2, const int rf2)
compute inside forces leading to an optimal objective function, respecting face criteria
double grad3(const int rb1, const int rf1, const int rb2, const int rf2, const int rb3, const int rf3, const double *u)
grad of objective function + penalty
void objective(a_ocriteria *objective)
set objective function (used for optimisation)
Definition: a_structure.h:81
void link_blocks(int b1, int f1, int b2, int f2)
link 2 blocks: [b1: ref_block1, f1: ref_face1, b2:...]
virtual void writetri(std::ostream &o) const
write a triangle file
friend std::ostream & operator<<(std::ostream &o, const a_structure &s)
double objective() const
get value of objective function
void midblock(const int rb1, const int rf1, const int rb2, const int rf2, a_block *&rb, int &rf)
block and face in between two face blocks
std::vector< a_block * > blocks_
Definition: a_structure.h:187
virtual void writeg(std::ostream &o) const
write structure in brlcad format
double m() const
mass
bool check_block(const int rb) const
check whether references are in range
double penalty() const
penalty value used for optimization
bool check_blockref(const int rb, const int rf) const
check whether references are in range
a_point c() const
get centre of mass
friend std::istream & operator>>(std::istream &i, a_structure &s)
input/output
void storeexits(std::vector< int > &) const
store face exits situation
a wrench class
Definition: a_wrench.h:30