BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
box.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/ba3d/mesh/box.cpp
6 //! @brief Implements utility functions in ba3d namespace
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #include "Base/Util/Assert.h"
17 
18 namespace GUI::RealSpace {
19 
21 {
22  float const D = .5f;
23 
24  Vertices vs_;
25  vs_.reserve(8);
26  for (float x : {-D, +D})
27  for (float y : {-D, +D})
28  for (float z : {-D, +D})
29  vs_.append(Vector3D(x, y, z));
30 
31  ASSERT(8 == vs_.count());
32 
33  Vertices vs;
34  vs.reserve(36);
35 
36  vs.addQuad(vs_, 0, 2, 6, 4);
37  vs.addQuad(vs_, 1, 5, 7, 3);
38  vs.addQuad(vs_, 0, 1, 3, 2);
39  vs.addQuad(vs_, 4, 6, 7, 5);
40  vs.addQuad(vs_, 0, 4, 5, 1);
41  vs.addQuad(vs_, 2, 3, 7, 6);
42 
43  ASSERT(36 == vs.count());
44 
45  return makeMesh(vs);
46 }
47 
48 } // namespace GUI::RealSpace
static Mesh meshBox()
Definition: box.cpp:20
static Mesh makeMesh(const Vertices &vs, Vertices const *ns=nullptr)
Definition: geometry.cpp:117
QVector< Vert_Normal > Mesh
Definition: geometry.h:66
Defines Geometry class.
void addQuad(const Vector3D &, const Vector3D &, const Vector3D &, const Vector3D &)
Definition: geometry.cpp:42