-
Notifications
You must be signed in to change notification settings - Fork 21
/
GeometricModel.cpp
136 lines (119 loc) · 4.64 KB
/
GeometricModel.cpp
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
//#############################################################################
//
// FILENAME: GeometricModel.cpp
//
// CLASSIFICATION: Unclassified
//
// DESCRIPTION:
//
// This file provides implementations for methods declared in the
// GeometricModel class.
//
// SOFTWARE HISTORY:
// Date Author Comment
// ----------- ------ -------
// 29-Nov-2012 JPK Initial Coding
// 06-Dec-2012 JPK De-inlined destructor and getFamily() methods
// Added inline definition for convenience method
// getCovarianceMatrix(). Replaced ParamType
// and ParamSet with param::Type and param::Set
// respectively. Removed all getOriginal* and
// setOriginal* methods and renamed getCurrent*
// and setCurrent* to get* and set* respectively.
// Moved Parameter struct inside class definition to
// avoid name clashes.
// 17-Dec-2012 BAH Documentation updates.
// 12-Feb-2013 JPK Renamed EXACT to Parameter Type to FIXED,
// Renamed FIXED Parameter Set to NON_ADJUSTABLE
//
// NOTES:
//
// Refer to GeometricModel.h for more information.
//
//#############################################################################
#define CSM_LIBRARY
#include "GeometricModel.h"
namespace csm {
//*****************************************************************************
// GeometricModel::~GeometricModel()
//*****************************************************************************
GeometricModel::~GeometricModel()
{}
//*****************************************************************************
// GeometricModel::getFamily()
//*****************************************************************************
std::string GeometricModel::getFamily() const
{
return CSM_GEOMETRIC_MODEL_FAMILY;
}
//*****************************************************************************
// GeometricModel::getParameterSetIndices()
//*****************************************************************************
std::vector<int> GeometricModel::getParameterSetIndices(param::Set pSet) const
{
const int NUM_PARMS = getNumParameters();
std::vector<int> indices;
indices.reserve(NUM_PARMS);
for (int i = 0; i < NUM_PARMS; ++i)
{
param::Type pType = getParameterType(i);
if (pType == param::FIXED)
{
if (pSet != param::ADJUSTABLE) indices.push_back(i);
}
else if ((pType != param::NONE) && (pSet != param::NON_ADJUSTABLE))
{
indices.push_back(i);
}
}
return indices;
}
//*****************************************************************************
// GeometricModel::getParameter()
//*****************************************************************************
GeometricModel::Parameter GeometricModel::getParameter(int index) const
{
//***
// Each of the individual "get" calls is responsible for range checking
// the provided index, so no need to do so here.
//***
return Parameter(getParameterName(index),
getParameterValue(index),
getParameterUnits(index),
getParameterType(index),
getParameterSharingCriteria(index));
}
//*****************************************************************************
// GeometricModel::getParameter()
//*****************************************************************************
void GeometricModel::setParameter(int index,const Parameter& param)
{
//***
// Derived classes may have the ability to adjust all parameter attributes,
// but no methods exist at this level to change anything but the value and
// type. Each of the individual "set" calls is responsible for range
// checking the desired index, so no need to do that here.
//***
setParameterValue (index,param.value);
setParameterType (index,param.type);
}
//*****************************************************************************
// GeometricModel::getParameters()
//*****************************************************************************
std::vector<GeometricModel::Parameter>
GeometricModel::getParameters(param::Set pSet) const
{
std::vector<Parameter> paramVctr;
const std::vector<int>& indices = getParameterSetIndices(pSet);
const int NUM_PARMS = indices.size();
if (NUM_PARMS > 0)
{
paramVctr.resize(NUM_PARMS);
for (int i = 0; i < NUM_PARMS; ++i)
{
paramVctr[i] = getParameter(indices[i]);
}
}
return paramVctr;
}
} // namespace csm