BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
CantellatedCube.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Sample/HardParticle/CantellatedCube.cpp
6 //! @brief Implements class CantellatedCube.
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 
16 
17 const ff::PolyhedralTopology CantellatedCube::topology = {{
18  /* 0 */ {{0, 1, 2, 3}, true},
19  /* 1 */ {{0, 8, 5, 1}, true},
20  /* 2 */ {{1, 9, 6, 2}, true},
21  /* 3 */ {{2, 10, 7, 3}, true},
22  /* 4 */ {{3, 11, 4, 0}, true},
23  /* 5 */ {{0, 4, 8}, false},
24  /* 6 */ {{1, 5, 9}, false},
25  /* 7 */ {{2, 6, 10}, false},
26  /* 8 */ {{3, 7, 11}, false},
27  /* 9 */ {{4, 12, 16, 8}, true},
28  /* 10 */ {{5, 13, 17, 9}, true},
29  /* 11 */ {{4, 11, 19, 12}, true},
30  /* 12 */ {{5, 8, 16, 13}, true},
31  /* 13 */ {{7, 10, 18, 15}, true},
32  /* 14 */ {{6, 9, 17, 14}, true},
33  /* 15 */ {{7, 15, 19, 11}, true},
34  /* 16 */ {{6, 14, 18, 10}, true},
35  /* 17 */ {{13, 21, 17}, false},
36  /* 18 */ {{12, 20, 16}, false},
37  /* 19 */ {{15, 23, 19}, false},
38  /* 20 */ {{14, 22, 18}, false},
39  /* 21 */ {{14, 17, 21, 22}, true},
40  /* 22 */ {{13, 16, 20, 21}, true},
41  /* 23 */ {{12, 19, 23, 20}, true},
42  /* 24 */ {{15, 18, 22, 23}, true},
43  /* 25 */ {{20, 23, 22, 21}, true},
44  },
45  true};
46 
47 CantellatedCube::CantellatedCube(const std::vector<double> P)
49  , m_length(m_P[0])
50  , m_removed_length(m_P[1])
51 {
52  checkNodeArgs();
53  if (m_removed_length > 0.5 * m_length) {
54  std::ostringstream ostr;
55  ostr << "::CantellatedCube() -> Error in class initialization ";
56  ostr << "with parameters 'length':" << m_length;
57  ostr << " 'removed_length':" << m_removed_length << "\n\n";
58  ostr << "Check for removed_length <= 0.5*length failed.";
59  throw std::runtime_error(ostr.str());
60  }
61  double a = m_length / 2;
62  double c = a - m_removed_length;
63 
64  setPolyhedron(topology, -a, {{-c, -c, +a}, // point 0
65  {+c, -c, +a}, {+c, +c, +a}, {-c, +c, +a}, {-a, -c, +c}, // point 4
66  {+c, -a, +c}, {+a, +c, +c}, {-c, +a, +c}, {-c, -a, +c}, // point 8
67  {+a, -c, +c}, {+c, +a, +c}, {-a, +c, +c}, {-a, -c, -c}, // point 12
68  {+c, -a, -c}, {+a, +c, -c}, {-c, +a, -c}, {-c, -a, -c}, // point 16
69  {+a, -c, -c}, {+c, +a, -c}, {-a, +c, -c}, {-c, -c, -a}, // point 20
70  {+c, -c, -a}, {+c, +c, -a}, {-c, +c, -a}});
71 }
72 
73 CantellatedCube::CantellatedCube(double length, double removed_length)
74  : CantellatedCube(std::vector<double>{length, removed_length})
75 {
76 }
Defines class CantellatedCube.
A cube, with truncation of all edges and corners, as in Croset (2017) Fig 7.
const double & m_length
CantellatedCube(double length, double removed_length)
double length() const
const double & m_removed_length
static const ff::PolyhedralTopology topology
A polyhedron, for form factor computation.
void setPolyhedron(const ff::PolyhedralTopology &topology, double z_bottom, const std::vector< R3 > &vertices)
Called by child classes to set faces and other internal variables.
void checkNodeArgs() const
Raises exception if a parameter value is invalid.
Definition: INode.cpp:27