diff --git a/Sample/HardParticle/Polyhedra.cpp b/Sample/HardParticle/Polyhedra.cpp index 28e0a27fd1f464a27320076cf38f905df45fbee6..c97a65cb7d14c7cf573efe3b78259e02b3a2d85c 100644 --- a/Sample/HardParticle/Polyhedra.cpp +++ b/Sample/HardParticle/Polyhedra.cpp @@ -221,18 +221,6 @@ Pyramid6::Pyramid6(double base_edge, double height, double alpha) } -const ff::Topology Bipyramid4::topology = {{{{3, 2, 1, 0}, true}, - {{0, 1, 5, 4}, false}, - {{1, 2, 6, 5}, false}, - {{2, 3, 7, 6}, false}, - {{3, 0, 4, 7}, false}, - {{4, 5, 9, 8}, false}, - {{5, 6, 10, 9}, false}, - {{6, 7, 11, 10}, false}, - {{7, 4, 8, 11}, false}, - {{8, 9, 10, 11}, true}}, - false}; - Bipyramid4::Bipyramid4(const std::vector<double> P) : IFormFactorPolyhedron(P) , m_length(m_P[0]) @@ -240,7 +228,8 @@ Bipyramid4::Bipyramid4(const std::vector<double> P) , m_height_ratio(m_P[2]) , m_alpha(m_P[3]) { - validateOrThrow(); + pimpl.reset(ff::make::Bipyramid4(m_length, m_height, m_height_ratio, m_alpha)); + m_validated = true; } Bipyramid4::Bipyramid4(double length, double height, double height_ratio, double alpha) @@ -248,65 +237,10 @@ Bipyramid4::Bipyramid4(double length, double height, double height_ratio, double { } -std::string Bipyramid4::validate() const -{ - std::vector<std::string> errs; - requestGt0(errs, m_length, "length"); - requestGt0(errs, m_height, "height"); - requestGt0(errs, m_height_ratio, "height_ratio"); - - const double cot_alpha = Math::cot(m_alpha); - if (m_alpha <= 0 || !std::isfinite(cot_alpha) || cot_alpha < 0) - errs.push_back("pyramid angle alpha=" + std::to_string(m_alpha) + " out of bounds"); - - if (!errs.empty()) - return jointError(errs); - - const double x = m_height_ratio; - const double r = cot_alpha * 2 * m_height / m_length; - if (std::max(1., x) * r > 1) - errs.push_back( - "parameters violate condition 2*height <= length*tan(alpha)*min(1,1/height_ratio)"); - if (!errs.empty()) - return jointError(errs); - - const double a = m_length / 2 * (1 - r); - const double b = m_length / 2; - const double c = m_length / 2 * (1 - r * x); - - const double dzcom = - m_height * ((x * x - 1) / 2 - 2 * r * (x * x * x - 1) / 3 + r * r * (x * x * x * x - 1) / 4) - / ((x + 1) - r * (x * x + 1) + r * r * (x * x * x + 1) / 3); - const double za = -dzcom - m_height; - const double zb = -dzcom; - const double zc = -dzcom + x * m_height; - - setPolyhedron(topology, za, - {// base: - {-a, -a, za}, - {a, -a, za}, - {a, a, za}, - {-a, a, za}, - // middle - {-b, -b, zb}, - {b, -b, zb}, - {b, b, zb}, - {-b, b, zb}, - // top - {-c, -c, zc}, - {c, -c, zc}, - {c, c, zc}, - {-c, c, zc}}); - - m_validated = true; - return ""; -} - // ************************************************************************************************ // Others // ************************************************************************************************ - CantellatedCube::CantellatedCube(const std::vector<double> P) : IFormFactorPolyhedron(P) , m_length(m_P[0]) diff --git a/Sample/HardParticle/Polyhedra.h b/Sample/HardParticle/Polyhedra.h index 5d3bcb279122027da2ff9374ea350359b77d5c4a..2a875d30c097bcbaf96c25700e1b9d893474540a 100644 --- a/Sample/HardParticle/Polyhedra.h +++ b/Sample/HardParticle/Polyhedra.h @@ -515,7 +515,6 @@ public: { return m_alpha; } - std::string validate() const override; #endif // USER_API private: diff --git a/auto/Wrap/libBornAgainSample.py b/auto/Wrap/libBornAgainSample.py index 35db6497f48b6556426737a529f765d77cc5506a..3e29a4ccabee4ddac6d078196e12f7caa0280d79 100644 --- a/auto/Wrap/libBornAgainSample.py +++ b/auto/Wrap/libBornAgainSample.py @@ -5278,10 +5278,6 @@ class Bipyramid4(IFormFactorPolyhedron): def alpha(self): r"""alpha(Bipyramid4 self) -> double""" return _libBornAgainSample.Bipyramid4_alpha(self) - - def validate(self): - r"""validate(Bipyramid4 self) -> std::string""" - return _libBornAgainSample.Bipyramid4_validate(self) __swig_destroy__ = _libBornAgainSample.delete_Bipyramid4 # Register Bipyramid4 in _libBornAgainSample: diff --git a/auto/Wrap/libBornAgainSample_wrap.cpp b/auto/Wrap/libBornAgainSample_wrap.cpp index 5db938ded7ce3a94427b65d716a0b7980d66c564..f159f6c9f2e7ccad9353dc285a0f82fe582a96be 100644 --- a/auto/Wrap/libBornAgainSample_wrap.cpp +++ b/auto/Wrap/libBornAgainSample_wrap.cpp @@ -51704,29 +51704,6 @@ fail: } -SWIGINTERN PyObject *_wrap_Bipyramid4_validate(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - Bipyramid4 *arg1 = (Bipyramid4 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - std::string result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Bipyramid4, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Bipyramid4_validate" "', argument " "1"" of type '" "Bipyramid4 const *""'"); - } - arg1 = reinterpret_cast< Bipyramid4 * >(argp1); - result = ((Bipyramid4 const *)arg1)->validate(); - resultobj = SWIG_From_std_string(static_cast< std::string >(result)); - return resultobj; -fail: - return NULL; -} - - SWIGINTERN PyObject *_wrap_delete_Bipyramid4(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Bipyramid4 *arg1 = (Bipyramid4 *) 0 ; @@ -62187,7 +62164,6 @@ static PyMethodDef SwigMethods[] = { { "Bipyramid4_height", _wrap_Bipyramid4_height, METH_O, "Bipyramid4_height(Bipyramid4 self) -> double"}, { "Bipyramid4_heightRatio", _wrap_Bipyramid4_heightRatio, METH_O, "Bipyramid4_heightRatio(Bipyramid4 self) -> double"}, { "Bipyramid4_alpha", _wrap_Bipyramid4_alpha, METH_O, "Bipyramid4_alpha(Bipyramid4 self) -> double"}, - { "Bipyramid4_validate", _wrap_Bipyramid4_validate, METH_O, "Bipyramid4_validate(Bipyramid4 self) -> std::string"}, { "delete_Bipyramid4", _wrap_delete_Bipyramid4, METH_O, "delete_Bipyramid4(Bipyramid4 self)"}, { "Bipyramid4_swigregister", Bipyramid4_swigregister, METH_O, NULL}, { "Bipyramid4_swiginit", Bipyramid4_swiginit, METH_VARARGS, NULL},