[go: up one dir, main page]

File: Polyhedron.h

package info (click to toggle)
libformfactor 0.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,288 kB
  • sloc: cpp: 17,289; python: 382; makefile: 15
file content (60 lines) | stat: -rw-r--r-- 2,178 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//  ************************************************************************************************
//
//  libformfactor: efficient and accurate computation of scattering form factors
//
//! @file      ff/Polyhedron.h
//! @brief     Defines class Polyhedron.
//!
//! @homepage  https://jugit.fz-juelich.de/mlz/libformfactor
//! @license   GNU General Public License v3 or higher (see LICENSE)
//! @copyright Forschungszentrum Jülich GmbH 2022
//! @author    Joachim Wuttke, Scientific Computing Group at MLZ (see CITATION)
//
//  ************************************************************************************************

#ifndef FF_POLYHEDRON_H
#define FF_POLYHEDRON_H

#include "ff/IBody.h"
#include <memory>

namespace ff {

class Face;

//! A polyhedron, implementation class for use in IFormFactorPolyhedron

class Polyhedron : public IBody {
public:
    Polyhedron(const Topology& topology, const std::vector<R3>& vertices, const R3& location = {});
    ~Polyhedron() override;

    double radius() const override { return m_radius; }
    double volume() const override { return m_volume; }
    complex_t formfactor_at_center(const C3& q) const override;
    const std::vector<R3>& vertices() const override { return m_absolute_vertices; }
    const std::vector<R3>& relative_vertices() const { return m_vertices; }
    double z_bottom() const override;
    R3 center_of_mass() const override;
    const std::vector<Face>& faces() const;
    //! Returns wether a vertex v is located inside of the polyhedron.
    bool is_inside(const R3& v, int nsamples = 2) const;

    const Topology& topology() const;
    //! Returns a copy of this Polyhedron clipped with the residing body constrained by zMin,zMax.
    Polyhedron* clipped(double zMin,double zMax) const;
private:
    // given geometry
    const std::unique_ptr<const Topology> m_topology;
    const std::vector<R3> m_vertices; // relative to location

    // caches, precomputed from given geometry
    const std::vector<R3> m_absolute_vertices; // relative to origin
    const std::vector<Face> m_faces;
    const double m_radius;
    const double m_volume;
};

} // namespace ff

#endif // FF_POLYHEDRON_H