[go: up one dir, main page]

File: Topology.cpp

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 (49 lines) | stat: -rw-r--r-- 1,932 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
//  ************************************************************************************************
//
//  libformfactor: efficient and accurate computation of scattering form factors
//
//! @file      ff/Topology.cpp
//! @brief     implements classes PolygonalTopology, Topology
//!
//! @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)
//
//  ************************************************************************************************

#include "ff/Topology.h"
#include <cstddef>

bool ff::FacialTopology::operator==(const ff::FacialTopology& rhs) const
{
    return rhs.vertexIndices == vertexIndices && rhs.symmetry_S2 == symmetry_S2;
}

//! Returns a vector of edges (i,j) with vertex indices ordered i < j.
std::vector<std::pair<int, int>> ff::FacialTopology::edges_undirected() const
{
    std::vector<std::pair<int, int>> result;
    for (size_t i = 0; i < vertexIndices.size(); i++) {
        if (vertexIndices[i] < vertexIndices[(i + 1) % vertexIndices.size()])
            result.emplace_back(vertexIndices[i], vertexIndices[(i + 1) % vertexIndices.size()]);
        else
            result.emplace_back(vertexIndices[(i + 1) % vertexIndices.size()], vertexIndices[i]);
    }
    return result;
}

//! Returns a vector of edges (i,j) with i,j in the order defined in vertexIndices.
std::vector<std::pair<int, int>> ff::FacialTopology::edges_directed() const
{
    std::vector<std::pair<int, int>> result;
    for (size_t i = 0; i < vertexIndices.size(); i++) {
        result.emplace_back(vertexIndices[i], vertexIndices[(i + 1) % vertexIndices.size()]);
    }
    return result;
}

bool ff::Topology::operator==(const Topology& rhs) const
{
    return rhs.faces == faces && rhs.symmetry_Ci == symmetry_Ci;
}