diff --git a/Sample/HardParticle/Pyramid2.cpp b/Sample/HardParticle/Pyramid2.cpp index 3ad3ad53e24b6ff67090e2b2c963c91aeaa9131e..636236a94821a9295d9c0f18953b4b64d7683c5c 100644 --- a/Sample/HardParticle/Pyramid2.cpp +++ b/Sample/HardParticle/Pyramid2.cpp @@ -15,14 +15,7 @@ #include "Sample/HardParticle/Pyramid2.h" #include "Base/Math/Constants.h" #include "Base/Math/Functions.h" - -const ff::Topology Pyramid2::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, 6, 7}, true}}, - false}; +#include <ff/Make.h> Pyramid2::Pyramid2(const std::vector<double> P) : IFormFactorPolyhedron(P) @@ -31,52 +24,11 @@ Pyramid2::Pyramid2(const std::vector<double> P) , m_height(m_P[2]) , m_alpha(m_P[3]) { - validateOrThrow(); + pimpl.reset(ff::make::Pyramid2(m_length, m_width, m_height, m_alpha)); + m_validated = true; } Pyramid2::Pyramid2(double length, double width, double height, double alpha) : Pyramid2(std::vector<double>{length, width, height, alpha}) { } - -std::string Pyramid2::validate() const -{ - std::vector<std::string> errs; - requestGt0(errs, m_length, "length"); - requestGt0(errs, m_width, "width"); - requestGt0(errs, m_height, "height"); - requestIn(errs, m_alpha, "alpha", 0, M_PI_2); - if (!errs.empty()) - return jointError(errs); - - const double D = m_length / 2; - const double W = m_width / 2; - const double R = m_height * Math::cot(m_alpha); - if (R > D) - errs.push_back("parameters violate condition H * ctg(alpha) <= m_length / 2"); - if (R > W) - errs.push_back("parameters violate condition H * ctg(alpha) <= m_width / 2"); - if (!errs.empty()) - return jointError(errs); - - // center of mass - double zcom = m_height / 2 * (6 * W * D - 4 * (W + D) * R + 3 * R * R) - / (6 * W * D - 3 * (W + D) * R + 2 * R * R); - const double d = D - R; - const double w = W - R; - - setPolyhedron(topology, -zcom, - {// base: - {-D, -W, -zcom}, - {D, -W, -zcom}, - {D, W, -zcom}, - {-D, W, -zcom}, - // top: - {-d, -w, m_height - zcom}, - {d, -w, m_height - zcom}, - {d, w, m_height - zcom}, - {-d, w, m_height - zcom}}); - - m_validated = true; - return ""; -} diff --git a/Sample/HardParticle/Pyramid2.h b/Sample/HardParticle/Pyramid2.h index faf0257c54b6a11ed627bde7bb41e3011286f54f..8d035ab97c48ace03f9d5913920f04eff2116601 100644 --- a/Sample/HardParticle/Pyramid2.h +++ b/Sample/HardParticle/Pyramid2.h @@ -56,8 +56,6 @@ public: return m_alpha; } - std::string validate() const override; - private: static const ff::Topology topology; diff --git a/auto/Wrap/libBornAgainSample.py b/auto/Wrap/libBornAgainSample.py index 71a524912a49926d4d25e4f1533fab906c836498..454cd827fc5de284102b85c475828e7d5a597f60 100644 --- a/auto/Wrap/libBornAgainSample.py +++ b/auto/Wrap/libBornAgainSample.py @@ -5807,10 +5807,6 @@ class Pyramid2(IFormFactorPolyhedron): def alpha(self): r"""alpha(Pyramid2 self) -> double""" return _libBornAgainSample.Pyramid2_alpha(self) - - def validate(self): - r"""validate(Pyramid2 self) -> std::string""" - return _libBornAgainSample.Pyramid2_validate(self) __swig_destroy__ = _libBornAgainSample.delete_Pyramid2 # Register Pyramid2 in _libBornAgainSample: diff --git a/auto/Wrap/libBornAgainSample_wrap.cpp b/auto/Wrap/libBornAgainSample_wrap.cpp index 6360e4f695745c8e8679c0fdb5d6097841510936..2298d902b0b0670640bb68062fc68a7e0223230a 100644 --- a/auto/Wrap/libBornAgainSample_wrap.cpp +++ b/auto/Wrap/libBornAgainSample_wrap.cpp @@ -55545,29 +55545,6 @@ fail: } -SWIGINTERN PyObject *_wrap_Pyramid2_validate(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - Pyramid2 *arg1 = (Pyramid2 *) 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_Pyramid2, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Pyramid2_validate" "', argument " "1"" of type '" "Pyramid2 const *""'"); - } - arg1 = reinterpret_cast< Pyramid2 * >(argp1); - result = ((Pyramid2 const *)arg1)->validate(); - resultobj = SWIG_From_std_string(static_cast< std::string >(result)); - return resultobj; -fail: - return NULL; -} - - SWIGINTERN PyObject *_wrap_delete_Pyramid2(PyObject *self, PyObject *args) { PyObject *resultobj = 0; Pyramid2 *arg1 = (Pyramid2 *) 0 ; @@ -62517,7 +62494,6 @@ static PyMethodDef SwigMethods[] = { { "Pyramid2_width", _wrap_Pyramid2_width, METH_O, "Pyramid2_width(Pyramid2 self) -> double"}, { "Pyramid2_height", _wrap_Pyramid2_height, METH_O, "Pyramid2_height(Pyramid2 self) -> double"}, { "Pyramid2_alpha", _wrap_Pyramid2_alpha, METH_O, "Pyramid2_alpha(Pyramid2 self) -> double"}, - { "Pyramid2_validate", _wrap_Pyramid2_validate, METH_O, "Pyramid2_validate(Pyramid2 self) -> std::string"}, { "delete_Pyramid2", _wrap_delete_Pyramid2, METH_O, "delete_Pyramid2(Pyramid2 self)"}, { "Pyramid2_swigregister", Pyramid2_swigregister, METH_O, NULL}, { "Pyramid2_swiginit", Pyramid2_swiginit, METH_VARARGS, NULL},