Go to the documentation of this file.
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";
bool readDictionary(const dictionary &dict)
Read from a dictionary.
#define fatalExit
Fatal exit.
bool read(iIstream &is) override
read from stream
FUNCTION_H bool write(iOstream &os) const
Write to output stream os.
dictionary & subDictOrCreate(const word &keyword)
search for a sub-dict with keyword create a new sub-dict if not found and return a ref to it fatalExi...
const char *const motionModelFile__
bool add(const word &keyword, const float &v)
add a float dataEntry
iOstream & endl(iOstream &os)
Add newline and flush stream.
wordList dictionaryKeywords() const
return a list of all dictionary (non-null) keywords
Defines an axis of rotation that rotates around itself and rotates around another axis.
Interface class for any input stream
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
bool writeDictionary(dictionary &dict) const
Write to a dictionary.
FUNCTION_H bool move(real t, real dt)
Move points.
#define ForAll(i, container)
bool write(iOstream &os) const override
write to stream
virtual const word & name() const
Return the name of the stream.
dictionary & subDict(const word &keyword)
ref to a subdictioanry fatalExit if not found
void sort(Vector< T, Allocator > &vec)
FUNCTION_H bool read(iIstream &is)
Read from input stream is.
T getVal(const word &keyword) const
get the value of data entry
FUNCTION_H multiRotatingAxisMotion()
Empty constructor.
#define ioErrorInFile(fileName, lineNumber)
Report an error in file operation with supplied fileName and lineNumber.
int32 lineNumber() const
Const access to the current stream line number.
Interface class for any output stream.
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...