File: RoughnessCatalog.cpp

package info (click to toggle)
bornagain 23.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 103,936 kB
  • sloc: cpp: 423,131; python: 40,997; javascript: 11,167; awk: 630; sh: 318; ruby: 173; xml: 130; makefile: 51; ansic: 24
file content (152 lines) | stat: -rw-r--r-- 4,330 bytes parent folder | download | duplicates (2)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//  ************************************************************************************************
//
//  BornAgain: simulate and fit reflection and scattering
//
//! @file      GUI/Model/Sample/RoughnessCatalog.cpp
//! @brief     Implements class RoughnessCatalog.
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2022
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
//  ************************************************************************************************

#include "GUI/Model/Sample/RoughnessCatalog.h"
#include "Base/Util/Assert.h"
#include "GUI/Model/Sample/CrosscorrelationItems.h"
#include "GUI/Model/Sample/RoughnessItems.h"
#include "GUI/Model/Sample/TransientItems.h"

RoughnessItem* RoughnessCatalog::create(Type type)
{
    switch (type) {
    case Type::None:
        return nullptr;
    case Type::SelfAffineFractal:
        return new SelfAffineFractalRoughnessItem(0., .7, 25., 0.5);
    case Type::LinearGrowth:
        return new LinearGrowthRoughnessItem(0, 0, 0, 0, 0, 0.5);
    }
    ASSERT_NEVER;
}

QVector<RoughnessCatalog::Type> RoughnessCatalog::types()
{
    return {Type::None, Type::SelfAffineFractal, Type::LinearGrowth};
}

UiInfo RoughnessCatalog::uiInfo(Type type)
{
    switch (type) {
    case Type::None:
        return {"None", "", ""};
    case Type::SelfAffineFractal:
        return {"K-correlation", "K-correlation model of lateral correlation function", ""};
    case Type::LinearGrowth:
        return {"Linear growth", "Model of growing rougness", ""};
    }
    ASSERT_NEVER;
}

RoughnessCatalog::Type RoughnessCatalog::type(const RoughnessItem* item)
{
    if (!item)
        return Type::None;

    if (dynamic_cast<const SelfAffineFractalRoughnessItem*>(item))
        return Type::SelfAffineFractal;

    if (dynamic_cast<const LinearGrowthRoughnessItem*>(item))
        return Type::LinearGrowth;

    ASSERT_NEVER;
}

//--------------------------------------------------------------------------

TransientItem* TransientCatalog::create(Type type)
{
    switch (type) {
    case Type::Erf:
        return new ErfTransientItem();
    case Type::Tanh:
        return new TanhTransientItem();
    }
    ASSERT_NEVER;
}

QVector<TransientCatalog::Type> TransientCatalog::types()
{
    return {Type::Erf, Type::Tanh};
}

UiInfo TransientCatalog::uiInfo(Type type)
{
    switch (type) {
    case Type::Erf:
        return {"Erf", "Interlayer transient is Erf function", ""};
    case Type::Tanh:
        return {"Tanh", "Interlayer transient is Tanh function", ""};
    }
    ASSERT_NEVER;
}

TransientCatalog::Type TransientCatalog::type(const TransientItem* model)
{
    if (dynamic_cast<const ErfTransientItem*>(model))
        return Type::Erf;

    if (dynamic_cast<const TanhTransientItem*>(model))
        return Type::Tanh;

    ASSERT_NEVER;
}

//--------------------------------------------------------------------------

CrosscorrelationItem* CrosscorrelationCatalog::create(Type type)
{
    switch (type) {
    case Type::None:
        return nullptr;
    case Type::CommonDepth:
        return new CommonDepthCrosscorrelationItem(0);
    case Type::SpatialFrequency:
        return new SpatialFrequencyCrosscorrelationItem(0, 1, 2);
    }
    ASSERT_NEVER;
}

QVector<CrosscorrelationCatalog::Type> CrosscorrelationCatalog::types()
{
    return {Type::None, Type::CommonDepth, Type::SpatialFrequency};
}

UiInfo CrosscorrelationCatalog::uiInfo(Type type)
{
    switch (type) {
    case Type::None:
        return {"None", "", ""};
    case Type::CommonDepth:
        return {"Common Depth", "Roughness crosscorrelation does not depend on spatial frequency",
                ""};
    case Type::SpatialFrequency:
        return {"Spatial Frequency", "Roughness crosscorrelation depends on spatial frequency", ""};
    }
    ASSERT_NEVER;
}

CrosscorrelationCatalog::Type CrosscorrelationCatalog::type(const CrosscorrelationItem* item)
{
    if (!item)
        return Type::None;

    if (dynamic_cast<const CommonDepthCrosscorrelationItem*>(item))
        return Type::CommonDepth;

    if (dynamic_cast<const SpatialFrequencyCrosscorrelationItem*>(item))
        return Type::SpatialFrequency;

    ASSERT_NEVER;
}