本文整理汇总了C++中DynamicArray::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicArray::clear方法的具体用法?C++ DynamicArray::clear怎么用?C++ DynamicArray::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicArray
的用法示例。
在下文中一共展示了DynamicArray::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateTrackingPose
/**
This method makes it possible to evaluate the debug pose at any phase angle
*/
void SimBiController::updateTrackingPose(DynamicArray<double>& trackingPose, double phiToUse){
if( phiToUse < 0 )
phiToUse = phi;
if( phiToUse > 1 )
phiToUse = 1;
trackingPose.clear();
this->character->getState(&trackingPose);
ReducedCharacterState debugRS(&trackingPose);
//always start from a neutral desired pose, and build from there...
for (int i=0;i<jointCount;i++){
debugRS.setJointRelativeOrientation(Quaternion(1, 0, 0, 0), i);
debugRS.setJointRelativeAngVelocity(Vector3d(), i);
controlParams[i].relToCharFrame = false;
}
//and this is the desired orientation for the root
Quaternion qRootD(1, 0, 0, 0);
SimBiConState* curState = states[FSMStateIndex];
for (int i=0;i<curState->getTrajectoryCount();i++){
//now we have the desired rotation angle and axis, so we need to see which joint this is intended for
int jIndex = curState->sTraj[i]->getJointIndex(stance);
//if the index is -1, it must mean it's the root's trajectory. Otherwise we should give an error
if (curState->sTraj[i]->relToCharFrame == true || jIndex == swingHipIndex)
controlParams[jIndex].relToCharFrame = true;
Vector3d d0, v0;
computeD0( phiToUse, &d0 );
computeV0( phiToUse, &v0 );
Quaternion newOrientation = curState->sTraj[i]->evaluateTrajectory(this, character->getJoint(jIndex), stance, phiToUse, d - d0, v - v0);
if (jIndex == -1){
qRootD = newOrientation;
}else{
debugRS.setJointRelativeOrientation(newOrientation, jIndex);
}
}
debugRS.setOrientation(qRootD);
//now, we'll make one more pass, and make sure that the orientations that are relative to the character frame are drawn that way
for (int i=0;i<jointCount;i++){
if (controlParams[i].relToCharFrame){
Quaternion temp;
Joint* j = character->getJoint(i);
ArticulatedRigidBody* parent = j->getParent();
while (parent != root){
j = parent->getParentJoint();
parent = j->getParent();
temp = debugRS.getJointRelativeOrientation(character->getJointIndex(j->name)) * temp;
}
temp = qRootD * temp;
temp = temp.getComplexConjugate() * debugRS.getJointRelativeOrientation(i);
debugRS.setJointRelativeOrientation(temp, i);
}
}
}
示例2: pointerArray
TEST(DynamicArray, pointerArray){
StevensDev::sgdm::DefaultAllocator<string*> strPtrAlloc;
DynamicArray<string*> pointerArray(&strPtrAlloc);
for( int i = 0; i < 100; ++i ){
string* strPtr = new string( std::to_string(i) );
pointerArray.push( strPtr );
EXPECT_EQ( *(pointerArray[i]), *strPtr );
delete strPtr;
}
for( int i = 0; i < 100; ++i ){
string* strPtr = new string( std::to_string(i) );
string* frontPtr = pointerArray.popFront();
EXPECT_EQ( *strPtr, *frontPtr );
delete strPtr;
delete frontPtr;
}
for( int i = 0; i < 100; ++i ){
string* strPtr = new string( std::to_string( i ) );
pointerArray.pushFront(strPtr);
EXPECT_EQ( *(pointerArray[0]), *strPtr );
delete strPtr;
}
for( int i = 0; i < 100; ++i ){
string* strPtr = new string( std::to_string( i ) );
string* frontPtr = pointerArray.pop();
EXPECT_EQ(*strPtr, *frontPtr);
delete strPtr;
delete frontPtr;
}
for( int i = 0; i < 100; ++i ){
string* strPtr = new string( std::to_string( i ) );
pointerArray.push( strPtr);
delete strPtr;
}
string* temp = pointerArray.removeAt( 20 );
EXPECT_EQ( "20", *temp );
EXPECT_EQ( 99, pointerArray.getLength() );
delete temp;
string* tempToInsert = new string( "hello, world" );
pointerArray.insertAt( 30, tempToInsert );
EXPECT_EQ( *tempToInsert, *(pointerArray[30]) );
delete tempToInsert;
DynamicArray<string*> cpArray = pointerArray;
for(size_t i = 0; i < pointerArray.getLength(); ++i)
EXPECT_EQ( *(cpArray[i]), *(pointerArray[i]) );
cpArray.clear();
EXPECT_EQ( 0, cpArray.getLength() );
}
示例3:
TEST( DynamicArray, copyConstructor ){
DynamicArray<string>* arrayCopy = new DynamicArray<string>( testArrayOne );
EXPECT_EQ( testArrayOne.getLength(), arrayCopy->getLength() );
for( int i = 0; i < testArrayOne.getLength(); ++i ){
EXPECT_TRUE( testArrayOne[i] == (*arrayCopy)[i] );
}
arrayCopy->clear();
EXPECT_EQ( 0, arrayCopy->getLength());
delete arrayCopy;
}