diff --git a/Sample/HardParticle/Sphere.cpp b/Sample/HardParticle/Sphere.cpp index c14f54032ac90480164f77089843a31be6739c9b..72b406e6c685e23c45242aa8c42721694d4e09b9 100644 --- a/Sample/HardParticle/Sphere.cpp +++ b/Sample/HardParticle/Sphere.cpp @@ -23,7 +23,7 @@ Sphere::Sphere(const std::vector<double> P, bool position_at_center) , m_radius(m_P[0]) , m_position_at_center(position_at_center) { - checkNodeArgs(); + validateOrThrow(); } Sphere::Sphere(double radius, bool position_at_center) @@ -60,3 +60,10 @@ complex_t Sphere::formfactor_at_bottom(C3 q) const result *= exp_I(q.z() * m_radius); return result; } + +std::string Sphere::validate() const +{ + if (m_radius<=0) + return jointError("Sphere", {"nonpositive value of radius="+std::to_string(m_radius)}); + return ""; +} diff --git a/Sample/HardParticle/Sphere.h b/Sample/HardParticle/Sphere.h index 7a2dae233abcd6a865965025d4151d4c6f316cfc..2a3646fd5009cec7dee3ba626ea957275e400a12 100644 --- a/Sample/HardParticle/Sphere.h +++ b/Sample/HardParticle/Sphere.h @@ -28,7 +28,7 @@ public: Sphere* clone() const override { return new Sphere(m_radius, m_position_at_center); } std::string className() const final { return "Sphere"; } - std::vector<ParaMeta> parDefs() const final { return {{"Radius", "nm", "radius", 0, +INF, 0}}; } + std::vector<ParaMeta> parDefs() const final { return {{"Radius", "nm"}}; } double radius() const { return m_radius; } @@ -40,6 +40,8 @@ public: complex_t formfactor_at_bottom(C3 q) const override; + std::string validate() const final; + protected: bool canSliceAnalytically(const IRotation*) const override { return true; } diff --git a/auto/Wrap/doxygenSample.i b/auto/Wrap/doxygenSample.i index 7da5bcdd7808db49e1e80fcbbfc6c7fb29750dbc..960ca875a76f7440d92753ebbbcecc4f65838328 100644 --- a/auto/Wrap/doxygenSample.i +++ b/auto/Wrap/doxygenSample.i @@ -4488,6 +4488,9 @@ Sphere::topZ"; %feature("docstring") Sphere::formfactor_at_bottom "complex_t Sphere::formfactor_at_bottom(C3 q) const override Sphere::formfactor_at_bottom"; +%feature("docstring") Sphere::validate "std::string Sphere::validate() const final +Sphere::validate"; + // File: classSpheroid.xml %feature("docstring") Spheroid " diff --git a/auto/Wrap/libBornAgainSample.py b/auto/Wrap/libBornAgainSample.py index 1800c3810677dd37edafd4386d7fbdcf37eb09a7..64657afcdf71f343ea145feb5300cf6dcbfbd0b2 100644 --- a/auto/Wrap/libBornAgainSample.py +++ b/auto/Wrap/libBornAgainSample.py @@ -8455,6 +8455,14 @@ class Sphere(IFormFactor): Sphere::formfactor_at_bottom """ return _libBornAgainSample.Sphere_formfactor_at_bottom(self, q) + + def validate(self): + r""" + validate(Sphere self) -> std::string + std::string Sphere::validate() const final + Sphere::validate + """ + return _libBornAgainSample.Sphere_validate(self) __swig_destroy__ = _libBornAgainSample.delete_Sphere # Register Sphere in _libBornAgainSample: diff --git a/auto/Wrap/libBornAgainSample_wrap.cpp b/auto/Wrap/libBornAgainSample_wrap.cpp index b0b85354da558612780d732c1e06cc25629ae327..a78e12bcc74f0165ae004f6b5ea3fe911c594bf4 100644 --- a/auto/Wrap/libBornAgainSample_wrap.cpp +++ b/auto/Wrap/libBornAgainSample_wrap.cpp @@ -52082,6 +52082,29 @@ fail: } +SWIGINTERN PyObject *_wrap_Sphere_validate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + Sphere *arg1 = (Sphere *) 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_Sphere, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Sphere_validate" "', argument " "1"" of type '" "Sphere const *""'"); + } + arg1 = reinterpret_cast< Sphere * >(argp1); + result = ((Sphere const *)arg1)->validate(); + resultobj = SWIG_From_std_string(static_cast< std::string >(result)); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_delete_Sphere(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; Sphere *arg1 = (Sphere *) 0 ; @@ -64960,6 +64983,11 @@ static PyMethodDef SwigMethods[] = { "complex_t Sphere::formfactor_at_bottom(C3 q) const override\n" "Sphere::formfactor_at_bottom\n" ""}, + { "Sphere_validate", _wrap_Sphere_validate, METH_O, "\n" + "Sphere_validate(Sphere self) -> std::string\n" + "std::string Sphere::validate() const final\n" + "Sphere::validate\n" + ""}, { "delete_Sphere", _wrap_delete_Sphere, METH_O, "delete_Sphere(Sphere self)"}, { "Sphere_swigregister", Sphere_swigregister, METH_O, NULL}, { "Sphere_swiginit", Sphere_swiginit, METH_VARARGS, NULL},