18 #include "a_triangle.h"
19 #define DE(x) std::cerr << #x << ": " << x << std::endl;
24 void a_block_2d4::create_faces()
28 for (
int i=0;
i<4;
i++)
66 o <<
"*************" << std::endl;
67 o <<
"a_block_2d4:" << std::endl;
68 o <<
"*************" << std::endl;
69 o <<
"a_block_2d4 is a special type of a_block, a class used to model the blocks of a 'a_structure' (see a_structure_help for more information)" << std::endl;
70 o <<
"It is an quadrilateral prism (a polyhedron with 6 faces: 2 parallel quadrilateral faces and 4 rectangular faces joining them)." << std::endl;
71 o <<
"The geometry of a block is defined by the 4 points defining the quadrilateral middle surface and the thickness of the block." << std::endl;
72 o <<
"The points used to define the geometry of the block could be directly the coordinates of the corners of the block in a world (or global) coordinate system." << std::endl;
73 o <<
"In practice, it is more convenient to define the geometry of the block in a local coordinate system, possibly rotate it, and then to move it in its final position." << std::endl;
74 o <<
"Commands:" << std::endl;
75 o <<
"--------" << std::endl;
76 o <<
"a_block_2d4 B 'p1' 'p2' 'p3' 'p4' 't': create a block named B" << std::endl;
77 o <<
" 'pi' are points (a_point) defining the shape of the block" << std::endl;
78 o <<
" 't' is the thickness of the block (default: 1.0)" << std::endl;
79 o <<
"thickness 'val': set the constant thickness of the block" << std::endl;
80 o <<
"thickness: gets the thickness of the block" << std::endl;
81 o <<
"normal: normal to the definition plan of the block (world coordinates)" << std::endl;
82 o <<
"normall: gets normal to the definition plan of the block (local coordinates)" << std::endl;
108 a_point n = this->
normal();
114 return *
pos_*(*
v(r))-n;
115 return *
pos_*(*
v(r-4))+n;
120 a_triangle t1(*
v(0),*
v(1),*
v(2));
121 a_triangle t2(*
v(0),*
v(2),*
v(3));
126 return (c1*s1+c2*s2)/(s1+s2);
131 a_triangle t1(*
v(0),*
v(1),*
v(2));
132 a_triangle t2(*
v(0),*
v(2),*
v(3));
140 a_point d1 = *
v(1)-*
v(0);
141 a_point d2 = *
v(3)-*
v(0);
142 return cross(d1,d2).normalise();
182 for (
int i=0;
i<this->
nv();
i++)
184 a_point p0 = (*pos_)*(*this->
v(
i));
185 for (
int j=0; j<3; j++)
186 o << (p0+n)[j] <<
",";
188 for (
int i=0;
i<this->
nv();
i++)
190 a_point p0 = (*pos_)*(*this->
v(
i));
193 for (
int j=0; j<3; j++)
194 o << (p0-n)[j] <<
",";
197 o << (p0-n)[0] <<
"," << (p0-n)[1] <<
"," << (p0-n)[2] <<
")";
205 for (
int i=0;
i<this->
nv();
i++)
207 a_point p0 = (*pos_)*(*this->
v(
i));
210 for (
int i=0;
i<this->
nv();
i++)
212 a_point p0 = (*pos_)*(*this->
v(
i));
219 o << base+0 <<
" " << base+2 <<
" " << base+1 << std::endl;
220 o << base+0 <<
" " << base+3 <<
" " << base+2 << std::endl;
221 o << base+4 <<
" " << base+5 <<
" " << base+6 << std::endl;
222 o << base+4 <<
" " << base+6 <<
" " << base+7 << std::endl;
223 o << base+5 <<
" " << base+1 <<
" " << base+2 << std::endl;
224 o << base+5 <<
" " << base+2 <<
" " << base+6 << std::endl;
225 o << base+4 <<
" " << base+3 <<
" " << base+0 << std::endl;
226 o << base+4 <<
" " << base+7 <<
" " << base+3 << std::endl;
227 o << base+6 <<
" " << base+2 <<
" " << base+3 << std::endl;
228 o << base+6 <<
" " << base+3 <<
" " << base+7 << std::endl;
229 o << base+5 <<
" " << base+0 <<
" " << base+1 << std::endl;
230 o << base+5 <<
" " << base+4 <<
" " << base+0 << std::endl;
235 tri.addtriangle(this->
v3d(0),this->
v3d(2),this->
v3d(1));
236 tri.addtriangle(this->
v3d(0),this->
v3d(3),this->
v3d(2));
237 tri.addtriangle(this->
v3d(4),this->
v3d(5),this->
v3d(6));
238 tri.addtriangle(this->
v3d(4),this->
v3d(6),this->
v3d(7));
239 tri.addtriangle(this->
v3d(5),this->
v3d(1),this->
v3d(2));
240 tri.addtriangle(this->
v3d(5),this->
v3d(2),this->
v3d(6));
241 tri.addtriangle(this->
v3d(4),this->
v3d(3),this->
v3d(0));
242 tri.addtriangle(this->
v3d(4),this->
v3d(7),this->
v3d(3));
243 tri.addtriangle(this->
v3d(6),this->
v3d(2),this->
v3d(3));
244 tri.addtriangle(this->
v3d(6),this->
v3d(3),this->
v3d(7));
245 tri.addtriangle(this->
v3d(5),this->
v3d(0),this->
v3d(1));
246 tri.addtriangle(this->
v3d(5),this->
v3d(4),this->
v3d(0));
a_block_2d4 * cb_2d4(a_block *b)
a_point v3d(const int i) const
get vertex (world coordinate, 3D: 8 points: order v0-n, v0+n, v1+n, v1-n
virtual void writeg(std::ostream &o) const
write a brlcad description of the block
double thickness() const
get block thickness
static const std::string help()
get information about the class
double V() const
volume of the block
virtual void writetri(std::ostream &o) const
write a triangle face representation of the block
a_point normall() const
normal to the definition plan of the block (local coordinates)
virtual void write(std::ostream &o) const
void thickness(const double thickness)
set block thickness
virtual a_point cl() const
centre of gravity of the face (local coordinate system)
virtual void writeb(std::ostream &o) const
write a blender description of the block
double * thickness_p() const
get block thickness pointer
void trianglecloud(a_trianglecloud &) const
virtual void deepcopy(const a_block_2d4 &)
copy the block. create new edges
void writefaces(std::ostream &o, const int base) const
write a triangle file description of the block
virtual void read(std::istream &i)
input/output
virtual void copy(const a_block_2d4 &)
copy the block. do not create new edges
a_point normal() const
normal to the definition plan of the block (world coordinates)
static const std::string help()
get information about the class
virtual void copy(const a_block &)
virtual void write(std::ostream &o) const
void av(a_point *vertex)
add a vertex
std::vector< int > in() const
return inside faces
a_face * i(const int i)
get pointer to face
void ai(a_face *face)
add a face
a_point * v(const int i)
get pointer to vertex
virtual void deepcopy(const a_block &)
virtual void read(std::istream &i)
input/output
int nv() const
get number of vertices
void av(int ref)
add a vertex reference