28 g_ =
new a_point(0.,0.,-9.81);
39 for(std::vector<a_point *>::iterator it =
vertices_.begin(); it !=
vertices_.end(); ++it) (*it)->clear();
40 for(std::vector<a_face *>::iterator it =
faces_.begin(); it !=
faces_.end(); ++it) (*it)->clear();
49 o <<
"*********" << std::endl;
50 o <<
"a_block:" << std::endl;
51 o <<
"*********" << std::endl;
52 o <<
"This class is used to model the blocks of a 'a_structure' (see a_structure_help for more information)" << std::endl;
53 o <<
"This is a virtual class, it cannot be used directly, see a_block_... for usable classes" << std::endl;
54 o <<
"Commands:" << std::endl;
55 o <<
"--------" << std::endl;
56 o <<
"clear: clear the block object" << std::endl;
57 o <<
"deepcopy 'b': make a completely independant copy of block 'b'" << std::endl;
58 o <<
"g 'val': sets value of the acceleration of gravity to 'val'" << std::endl;
59 o <<
"g: gets value of gravity" << std::endl;
60 o <<
"c: gets centre of mass in world coordinates" << std::endl;
61 o <<
"cl: get centre of mass in local coordinates" << std::endl;
62 o <<
"name: gets class name" << std::endl;
63 o <<
"m: gets mass" << std::endl;
64 o <<
"Ws: gets scalar value of weight" << std::endl;
65 o <<
"W: gets weight (returns a wrench, see a_wrench_help)" << std::endl;
66 o <<
"fe: gets external force on block (returns a wrench)" << std::endl;
67 o <<
"ft: gets total force on block (returns a wrench)" << std::endl;
68 o <<
"potential: gets potential energy" << std::endl;
69 o <<
"nextblock: block connected (return 0 if end or problem)" << std::endl;
70 o <<
"clearinternal: clear all the internal face forces" << std::endl;
71 o <<
"clearexternal: clear all the external face forces" << std::endl;
72 o <<
"clearall: clear all the forces on faces" << std::endl;
73 o <<
"material 'material': link a material" << std::endl;
74 o <<
"material: gets material" << std::endl;
75 o <<
"nv: gets number of vertices" << std::endl;
76 o <<
"nvt: gets number of vertices (not only the reference vertices)" << std::endl;
77 o <<
"ni: gets number of faces" << std::endl;
78 o <<
"nit: gets number of faces (not only the reference faces)" << std::endl;
79 o <<
"av 'a_point': add a vertex" << std::endl;
80 o <<
"ai 'a_face': add a face" << std::endl;
81 o <<
"v 'ref': gets vertex 'ref' (starts from 0)" << std::endl;
82 o <<
"v3d 'ref': gets vertex 'ref' (world coordinate, 3D)" << std::endl;
83 o <<
"i 'ref': gets face 'ref'" << std::endl;
84 o <<
"pos: gets position handle (a a_twist, see a_twist_help)" << std::endl;
85 o <<
"in: gets insides faces" << std::endl;
86 o <<
"out: gets outside faces" << std::endl;
87 o <<
"exit 'ref': set exit face" << std::endl;
88 o <<
"exit: gets exit face" << std::endl;
89 o <<
"entrance 'ref': set exit face specifying where the force enters" << std::endl;
90 o <<
"criteria: set resistance criteria" << std::endl;
91 o <<
"ok: check whether forces on face are acceptable" << std::endl;
92 o <<
"penalty: gets penalty value used for optimization" << std::endl;
93 o <<
"writeb 'file': write block in blender format" << std::endl;
94 o <<
"writeg 'file': write block in brlcad format" << std::endl;
95 o <<
"trianglecloud 'a_trianglecloud': write block in a 'a_trianglecloud' object (points&forces)" << std::endl;
101 for (
int i=0;
i<b.
nv();
i++)
112 for (
int i=0;
i<b.
nv();
i++)
114 a_point *
v =
new a_point(*(b.
v(
i)));
164 return (*
pos_)*this->
cl();
174 double g = this->
g()->norm();
180 a_point
c = this->
c();
181 a_point
g = *this->
g();
182 double m = this->
m();
226 return w2+this->
ft();
231 int ri = this->
exit();
248 a_point
c = this->
c();
249 a_point n = -this->
g()->normalise();
250 return this->
Ws()*(c*n);
315 for (
int i=0;
i<
ni();
i++)
358 a_point ci = fip->
c();
360 a_point nxi = fip->
nx();
361 a_point nxe = -fep->
nx();
362 a_point nyi = fip->
ny();
363 a_point nye = -fep->
ny();
364 double ax = angle(nxi,nxe);
365 double ay = angle(nyi,nye);
366 a_point pt = fep->
c()+u*nxe+
v*nye;
375 std::vector<int> list;
376 for (
int i=0;
i<
ni();
i++)
387 std::vector<int> list;
388 for (
int i=0;
i<
ni();
i++)
399 for (
int i=0;
i<this->
ni();
i++)
416 for (
int i=0;
i<this->
ni();
i++)
457 for (
int i=0;
i<
nv;
i++)
459 a_point * vertex =
new a_point;
467 for (
int i=0;
i<
ni;
i++)
475 o << this->
name() << std::endl;
477 o <<
nv << std::endl;
478 for (
int i=0;
i<
nv;
i++)
479 o << this->
v(
i) << std::endl;
480 o << this->
g() << std::endl;
482 o <<
ni << std::endl;
483 for (
int i=0;
i<
ni;
i++)
485 o << *(this->
pos()) << std::endl;
490 int nv = this->
nvt();
491 for (
int i=0;
i<
nv;
i++)
492 o << this->
v3d(
i) << std::endl;
std::ostream & operator<<(std::ostream &o, const a_block &b)
std::istream & operator>>(std::istream &in, a_block &b)
a_block * compute()
compute the exit force from all the forces on the block, return next block or 0 if last one or proble...
static const std::string help()
get information about the class
double potential() const
potential energy
virtual void copy(const a_block &)
int entrance(int ref)
set exit face specifying where the force enters
void clearinternal()
clear all the internal face forces
a_wrench W() const
weight wrench in world coordinate
a_point * g() const
get gravity
virtual void write(std::ostream &o) const
void av(a_point *vertex)
add a vertex
a_wrench fe() const
external force on block in world coordinate
void material(a_material *material)
link a material
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
void writeverts(std::ostream &o) const
std::vector< int > in() const
return inside faces
void g(a_point *g)
set gravity
void clearall()
clear all the forces on faces
std::vector< a_point * > vertices_
double penalty() const
penalty value used for optimization
a_wrench ft() const
total force on block in world coordinate
a_point c() const
centre of mass (in world coordinate)
virtual std::string name() const
a_face * i(const int i)
get pointer to face
bool ok() const
check if forces on face are acceptable
void criteria(a_fcriteria *criteria)
set resistance criteria
virtual a_point v3d(const int i) const =0
get vertex (world coordinate, 3D)
int ni() const
get number of faces
a_twist * pos() const
get pointer to position handle
std::vector< a_face * > faces_
void clearexternal()
clear all the external face forces
a_point * v(const int i)
get pointer to vertex
virtual a_point cl() const =0
centre of mass (in local system)
int exit() const
get exit face
virtual void deepcopy(const a_block &)
virtual int nvt() const =0
get number of vertices (not only the reference vertices)
virtual void read(std::istream &i)
input/output
int nv() const
get number of vertices
std::vector< int > out() const
return outside faces
virtual double V() const =0
volume of the block
a_material * material() const
get pointer to material
a_block * nextblock() const
block connected (return 0 if end or problem)
virtual a_point nx() const =0
direction of face (in world coordinate)
bool in() const
face is connected to other faces, inside the structure
virtual void clear()
set force to 0
void lface(a_face *f)
set connected face
a_point c() const
centre of mass (in world coordinate)
void exit(bool exit)
set as an exit face
int rf() const
get face reference in connected block
virtual void write(std::ostream &o) const
void f(const a_wrench &f)
set force on the face
virtual a_point ny() const =0
normal to the vertices of the block (in world coordinate)
bool out() const
face is not connected to other faces, on the boudary
a_block * block()
get block
void density(const double density)
void rotate(const a_point &pt, const a_point &dir, double v)
void translate(const a_point &d)
iterative transformation