9 #include "fei_macros.hpp"
15 #include "fei_ArrayUtils.hpp"
16 #include "fei_FieldMask.hpp"
30 : maskID_(fm.maskID_),
31 fieldIDs_(fm.fieldIDs_),
32 fieldSizes_(fm.fieldSizes_),
33 fieldEqnOffsets_(fm.fieldEqnOffsets_)
35 numFields_ = fieldIDs_.size();
36 numIndices_ = fm.numIndices_;
41 const int* fieldSizes)
45 fieldEqnOffsets_(0, 4)
47 for(
int i=0; i<numFields; ++i) {
48 addField(fieldIDs[i], fieldSizes[i]);
66 if (fieldIDs_[0] != fieldID) {
72 for(
size_t i=0; i<fieldIDs_.size(); ++i) {
73 if (fieldIDs_[i] == fieldID) {
83 offset = fieldEqnOffsets_[idindex];
90 throw std::runtime_error(
"fei::FieldMask ERROR, fieldID should be >= 0.");
96 for(
unsigned i=idindex+1; i<fieldEqnOffsets_.size(); ++i) {
97 fieldEqnOffsets_[i] += fieldSize;
101 fieldIDs_.insert(fieldIDs_.begin()+insertPoint, fieldID);
103 fieldSizes_.insert(fieldSizes_.begin()+insertPoint, fieldSize);
105 fieldEqnOffsets_.push_back(1);
109 for(
unsigned i=0; i<fieldIDs_.size(); ++i) {
110 fieldEqnOffsets_[i] = eqnOffset;
111 eqnOffset += fieldSizes_[i];
112 numIndices_ += fieldSizes_[i];
115 numFields_ = fieldIDs_.size();
118 maskID_ = calculateMaskID();
121 int fei::FieldMask::calculateMaskID()
123 return( calculateMaskID(fieldIDs_.size(), &fieldIDs_[0]));
129 for(
int i=0; i<numFields; ++i) {
130 maskID += (fieldIDs[i]+1) +(i+1)*1000;
139 return( fm.maskID_ + (fieldID+1) + (fm.numFields_+1)*1000 );
int binarySearch(const T &item, const T *list, int len)
static int calculateMaskID(int numFields, const int *fieldIDs)
void addField(int fieldID, int fieldSize)
int getFieldEqnOffset(int fieldID, int &offset) const