32 auto motionModel = dict.
getVal<
word>(
"motionModel");
34 if(motionModel !=
"multiRotatingAxisMotion")
37 " motionModel should be multiRotatingAxisMotion, but found "
38 << motionModel <<
endl;
42 auto& motionInfo = dict.
subDict(
"multiRotatingAxisMotionInfo");
49 for(
auto& aName: axisNames)
51 auto& axDict = motionInfo.subDict(aName);
53 if(
auto axPtr = makeUnique<rotatingAxis>(axDict); axPtr)
55 rotationAxis.push_back(
56 axDict.getValOrSet<
word>(
"rotationAxis",
"none"));
61 "could not read rotating axis from "<< axDict.globalName()<<
endl;
66 if( !axisNames.search(
"none") )
68 axisNames.push_back(
"none");
69 rotationAxis.push_back(
"none");
72 using intPair = std::pair<int32, int32>;
74 std::vector<intPair> numRotAxis;
76 for(
size_t i=0; i< axisNames.size(); i++)
78 word rotAxis = rotationAxis[i];
80 while(rotAxis !=
"none")
83 if(
int32 iAxis = axisNames.findi(rotAxis) ; iAxis != -1)
85 rotAxis = rotationAxis[iAxis];
89 "rotation axis name "<< rotAxis <<
"is does not exist!"<<
endl;
95 numRotAxis.push_back({
n,i});
98 auto compareFunc = [](
const intPair& a,
const intPair& b)
99 {
return a.first > b.first; };
103 sortedIndex_.clear();
107 for(
auto ax:numRotAxis)
109 axisName_.push_back(axisNames[ax.second]);
110 sortedIndex_.push_back(ax.second);
113 numAxis_ = axisName_.size();
115 axis_.reserve(numAxis_);
119 for(
auto& aName: axisName_)
123 auto& axDict = motionInfo.subDict(aName);
143 dict.
add(
"motionModel",
"multiRotatingAxisMotion");
145 auto& motionInfo = dict.
subDictOrCreate(
"multiRotatingAxisMotionInfo");
150 auto& axDict = motionInfo.subDictOrCreate(axisName_[i]);
151 if( !axis_.hostVectorAll()[i].write(
this,axDict))
154 " error in writing axis "<< axisName_[i] <<
" to dicrionary "
155 << motionInfo.globalName()<<
endl;
171 if(! readDictionary(dict) )
182 for(
int32 i=0; i<numAxis_; i++)
184 auto& ax = axis_[sortedIndex_[i]];
186 ax.setAxisList(getAxisListPtrHost());
191 axis_.modifyOnHost();
206 if( !motionInfo.
read(is) )
213 if( !readDictionary(motionInfo) )
return false;
226 if( !writeDictionary(motionInfo))
231 if( !motionInfo.
write(os) )
234 " error in writing dictionray to file. \n";