From 9280bd83a7195ed2bc6abac2566637bcf89a1344 Mon Sep 17 00:00:00 2001
From: Joachim Wuttke <j.wuttke@fz-juelich.de>
Date: Fri, 7 Jan 2022 18:05:20 +0100
Subject: [PATCH] Prism: move m_vertices here

---
 Sample/HardParticle/IFormFactorPrism.cpp | 10 ++++++++--
 Sample/HardParticle/IFormFactorPrism.h   |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Sample/HardParticle/IFormFactorPrism.cpp b/Sample/HardParticle/IFormFactorPrism.cpp
index 0cbdf37a2d4..8765cb9ca2f 100644
--- a/Sample/HardParticle/IFormFactorPrism.cpp
+++ b/Sample/HardParticle/IFormFactorPrism.cpp
@@ -22,16 +22,22 @@ IFormFactorPrism::~IFormFactorPrism() = default;
 void IFormFactorPrism::setPrism(bool symmetry_Ci, const std::vector<R3>& vertices)
 {
     pimpl = std::make_unique<ff::Prism>(symmetry_Ci, height(), vertices);
+
+    m_vertices.clear();
+    for (const R3& vertex : vertices) {
+        m_vertices.push_back(vertex);
+        m_vertices.push_back(vertex + R3{0, 0, height()});
+    }
 }
 
 double IFormFactorPrism::bottomZ(const IRotation* rotation) const
 {
-    return BottomZ(pimpl->vertices(), rotation);
+    return BottomZ(m_vertices, rotation);
 }
 
 double IFormFactorPrism::topZ(const IRotation* rotation) const
 {
-    return TopZ(pimpl->vertices(), rotation);
+    return TopZ(m_vertices, rotation);
 }
 
 //! Returns the volume of this prism.
diff --git a/Sample/HardParticle/IFormFactorPrism.h b/Sample/HardParticle/IFormFactorPrism.h
index 9637ede456f..f9d1426826b 100644
--- a/Sample/HardParticle/IFormFactorPrism.h
+++ b/Sample/HardParticle/IFormFactorPrism.h
@@ -46,6 +46,7 @@ protected:
 
 private:
     std::unique_ptr<ff::Prism> pimpl;
+    std::vector<R3> m_vertices; //! for topZ, bottomZ computation only
 };
 
 #endif // BORNAGAIN_SAMPLE_HARDPARTICLE_IFORMFACTORPRISM_H
-- 
GitLab