本文整理汇总了C++中word::compare方法的典型用法代码示例。如果您正苦于以下问题:C++ word::compare方法的具体用法?C++ word::compare怎么用?C++ word::compare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类word
的用法示例。
在下文中一共展示了word::compare方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveGroundPoint
void TerrainManagerModuleOrographyModifications::moveGroundPoint(
point & p,scalar height0, scalar height, const word & addType){
// prepare:
const Foam::vector & n_up = moduleBase().cooSys->e(TerrainBlock::UP);
// add type 'add':
if(addType.compare("add") == 0){
if( height != 0 ) p += height * n_up;
}
// add type 'max':
else if(addType.compare("max") == 0){
const scalar h0 = dot(p,n_up);
if( height0 + height > h0 ){
p += (height0 + height - h0) * n_up;
}
}
// add type 'average':
else if(addType.compare("average") == 0){
if( height != 0 ){
const scalar h0 = dot(p,n_up);
scalar h = 0.5 * ( 2 * h0 + height0 + height );
p += (h - h0) * n_up;
}
}
// add type 'hill':
else if(addType.compare("hill") == 0){
if( height != 0.){
const scalar h0 = dot(p,n_up);
p += (height0 + height - h0) * n_up;
}
}
}
示例2: out
labelList TerrainManager::walkBox
(
label n,
const word & HL,
bool counterClockWise
) const{
// preapre:
labelList out(3,0);
label counter = 0;
label face = counterClockWise ? Block::SOUTH : Block::WEST;
bool isHigh = HL.compare("H") == 0 ? true : false;
// walk counter clock wise:
if(counterClockWise){
while(counter < n){
// west:
if(face == Block::WEST){
out[2] = isHigh ? Block::NWH : Block::NWL;
out[Block::Y]--;
if(out[Block::Y] < 0){
Info << "\nBLockManager: Error: walkBox overshoot." << endl;
Info << " n = " << n << endl;
Info << " nmax = " << walkBoxMaximum() << endl;
throw;
}
}
// north:
if(face == Block::NORTH){
out[2] = isHigh ? Block::NEH : Block::NEL;
out[Block::X]--;
if(out[Block::X] < 0){
out[Block::X]++;
out[2] = isHigh ? Block::NWH : Block::NWL;
face = Block::WEST;
}
}
// east:
if(face == Block::EAST){
out[2] = isHigh ? Block::SEH : Block::SEL;
out[Block::Y]++;
if(out[Block::Y] == blockNrs_[Block::Y] ){
out[Block::Y]--;
out[2] = isHigh ? Block::NEH : Block::NEL;
face = Block::NORTH;
}
}
// south:
if(face == Block::SOUTH){
out[2] = isHigh ? Block::SWH : Block::SWL;
out[Block::X]++;
if(out[Block::X] == blockNrs_[Block::X] ){
out[Block::X]--;
out[2] = isHigh ? Block::SEH : Block::SEL;
face = Block::EAST;
}
}
counter++;
}
}
// else walk clockwise:
else {
while(counter < n){
// south:
if(face == Block::SOUTH){
out[2] = isHigh ? Block::SEH : Block::SEL;
out[Block::X]--;
if(out[Block::X] < 0 ){
Info << "\nBLockManager: Error: walkBox overshoot." << endl;
Info << " n = " << n << endl;
Info << " nmax = " << walkBoxMaximum() << endl;
throw;
}
}
// east:
if(face == Block::EAST){
out[2] = isHigh ? Block::NEH : Block::NEL;
out[Block::Y]--;
if(out[Block::Y] < 0 ){
out[Block::Y]++;
out[2] = isHigh ? Block::SEH : Block::SEL;
face = Block::SOUTH;
}
}
// north:
if(face == Block::NORTH){
out[2] = isHigh ? Block::NWH : Block::NWL;
out[Block::X]++;
if(out[Block::X] == blockNrs_[Block::X]){
out[Block::X]--;
out[2] = isHigh ? Block::NEH : Block::NEL;
//.........这里部分代码省略.........