diff --git a/Core/HardParticle/FormFactorBox.cpp b/Core/HardParticle/FormFactorBox.cpp index d2604da1e301ee905ab9b5ea9c7814dc1b551a0c..519e7efc12ffa47b34b872ab11bb9efb32788d97 100644 --- a/Core/HardParticle/FormFactorBox.cpp +++ b/Core/HardParticle/FormFactorBox.cpp @@ -22,7 +22,7 @@ //! @param width: width of the base in nanometers //! @param height: height of the box in nanometers FormFactorBox::FormFactorBox(double length, double width, double height) - : m_length(length), m_width(width), m_height(height) + : FormFactorPolygonalPrism(height), m_length(length), m_width(width) { setName(BornAgain::FFBoxType); registerParameter(BornAgain::Length, &m_length).setUnit(BornAgain::UnitsNm).setNonnegative(); @@ -34,7 +34,7 @@ FormFactorBox::FormFactorBox(double length, double width, double height) complex_t FormFactorBox::evaluate_for_q(cvector_t q) const { complex_t qzHdiv2 = m_height / 2 * q.z(); - return m_height * m_length * m_width * MathFunctions::sinc(m_length / 2 * q.x()) + return m_length * m_width * m_height * MathFunctions::sinc(m_length / 2 * q.x()) * MathFunctions::sinc(m_width / 2 * q.y()) * MathFunctions::sinc(qzHdiv2) * exp_I(qzHdiv2); } @@ -49,4 +49,8 @@ IFormFactor* FormFactorBox::sliceFormFactor(ZLimits limits, const IRotation& rot void FormFactorBox::onChange() { + double a = m_length/2; + double b = m_width/2; + std::vector<kvector_t> V{{a, b, 0.}, {-a, b, 0.}, {-a, -b, 0.}, {a, -b, 0}}; + setPrism(true, V); } diff --git a/Core/HardParticle/FormFactorBox.h b/Core/HardParticle/FormFactorBox.h index de00ff51de08fb7122c78d0a59c87023a067e6b5..285ff12875a7f943d2aca7bb0f36c1b3d169637c 100644 --- a/Core/HardParticle/FormFactorBox.h +++ b/Core/HardParticle/FormFactorBox.h @@ -15,12 +15,12 @@ #ifndef FORMFACTORBOX_H #define FORMFACTORBOX_H -#include "IFormFactorBorn.h" +#include "FormFactorPolyhedron.h" //! A rectangular prism (parallelepiped). //! @ingroup hardParticle -class BA_CORE_API_ FormFactorBox : public IFormFactorBorn +class BA_CORE_API_ FormFactorBox : public FormFactorPolygonalPrism { public: FormFactorBox(double length, double width, double height); @@ -33,11 +33,10 @@ public: void accept(INodeVisitor* visitor) const override final { visitor->visit(this); } double getLength() const { return m_length; } - double getHeight() const { return m_height; } double getWidth() const { return m_width; } + double volume() const override final { return m_length*m_height*m_width; } double radialExtension() const override final { return m_length / 2.0; } - complex_t evaluate_for_q(cvector_t q) const override final; protected: @@ -49,7 +48,6 @@ protected: private: double m_length; double m_width; - double m_height; }; #endif // FORMFACTORBOX_H diff --git a/Core/HardParticle/FormFactorPolyhedron.h b/Core/HardParticle/FormFactorPolyhedron.h index 694005341cbf18615d3b74d93d870752ed9e8bd3..c1bb59bd8223a4dfc951d359f070ed3dbefd30bf 100644 --- a/Core/HardParticle/FormFactorPolyhedron.h +++ b/Core/HardParticle/FormFactorPolyhedron.h @@ -143,10 +143,10 @@ public: double bottomZ(const IRotation& rotation) const override final; double topZ(const IRotation& rotation) const override final; - complex_t evaluate_for_q(cvector_t q) const override final; - double volume() const override final; + virtual complex_t evaluate_for_q(cvector_t q) const override; + virtual double volume() const override; double getHeight() const { return m_height; } - double radialExtension() const override final { return std::sqrt(m_base->area()); } + virtual double radialExtension() const override { return std::sqrt(m_base->area()); } protected: std::unique_ptr<PolyhedralFace> m_base; diff --git a/Tests/UnitTests/Core/Sample/FormFactorBasicTest.cpp b/Tests/UnitTests/Core/Sample/FormFactorBasicTest.cpp index e23e68c405e038c7142e638a74cf701f8fb63657..e00663d5ad6cb21b34c914df96a9e90e5a35a230 100644 --- a/Tests/UnitTests/Core/Sample/FormFactorBasicTest.cpp +++ b/Tests/UnitTests/Core/Sample/FormFactorBasicTest.cpp @@ -126,8 +126,8 @@ TEST_F(FormFactorBasicTest, Box) EXPECT_EQ(height, particle.getHeight()); EXPECT_EQ(3., particle.radialExtension()); EXPECT_DOUBLE_EQ(volume, particle.volume()); - // TODO EXPECT_EQ(0., particle.bottomZ(RotationZ())); - // TODO EXPECT_EQ(height, particle.topZ(RotationZ())); + EXPECT_EQ(0., particle.bottomZ(RotationZ())); + EXPECT_EQ(height, particle.topZ(RotationZ())); test_ff(&particle); }