Ejemplo n.º 1
0
bool Polyangle::split(Polyangle & p1, Polyangle & p2, Polyangle & route, const Droite & d, const double largeurDemiRoute) const
{
    //calcul des deux parallèles a ma droite de coupe
    Vector2D orthoAB = Vector2D(-d.getD().y(), d.getD().x());
    Droite para1(d.getO() + orthoAB * largeurDemiRoute, d.getD());
    Droite para2(d.getO() - orthoAB * largeurDemiRoute, d.getD());

    Polyangle pTemp;
    if(!split(p1, pTemp, para1))return false;
    return pTemp.split(route, p2, para2);

}
Ejemplo n.º 2
0
TEST(SaveLoadTest, SaveLoadLatestVersion)
{
    // Use the temp application.
    TaskSystem *pTempApp1 = new TaskSystem();
    TaskSystem* pPreviousApp = SetWorkingBrain(pTempApp1);

    {
        Parameter para(_T("OS"), _T("Windows7"));
        para.SetComments(_T("global"));
        GetWorkingBrain()->GetVariableManager()->AddUserParameter(para);
    }

    CString conditionId = _T("DoesRegExist");
    {
        ConditionPtr pRegCondition = Condition::Create(_T("RegisterKeyExistsCondition"), GetWorkingBrain()->GetBehaviorManager());
        Parameter objectId(OBJECT_ID, conditionId);
        Parameter para1(_T("RootKey"), _T("HKEY_LOCAL_MACHINE"));
        Parameter para2(_T("SubKey"), _T("Software\\Microsoft"));

        pRegCondition->GetParameterTable().AddParameter(objectId);
        pRegCondition->GetParameterTable().AddParameter(para1);
        pRegCondition->GetParameterTable().AddParameter(para2);

        //GetWorkingBrain()->GetBehaviorManager()->RegisterCondition(pRegCondition);
    }

    CString actionId = _T("DemoToRunSysCmd");
    {
        ActionPtr pNewAction = Action::Create(_T("RunSystemCommandAction"), GetWorkingBrain()->GetBehaviorManager());
        Parameter objectId(OBJECT_ID, actionId);
        objectId.SetComments(_T("Object Id is used to reference this object everywhere."));
        Parameter objectType;
        pNewAction->GetParameterTable().GetParameter(OBJECT_TYPE, objectType);
        objectType.SetComments(_T("Object type indicates which behavior body will this action invokes."));
        Parameter cmd(APPLICATION_NAME, _T("regedit.exe"));
        cmd.SetComments(_T("Indicate which command will be run"));
        pNewAction->GetParameterTable().AddParameter(objectId);
        pNewAction->GetParameterTable().AddParameter(objectType);
        pNewAction->GetParameterTable().AddParameter(cmd);

        //GetWorkingBrain()->GetBehaviorManager()->RegisterAction(pNewAction);
        GetWorkingBrain()->GetBehaviorManager()->AddActionTask(pNewAction);
    }

    CString fileName(_T("C:\\braintest.xml"));

    // Save
    bool ret = GetWorkingBrain()->XmlOut(fileName);
    EXPECT_EQ(true, ret);

    // Load
    TaskSystem *pTempApp2 = new TaskSystem();

    SetWorkingBrain(pTempApp2);

    ret = GetWorkingBrain()->XmlIn(fileName);
    EXPECT_EQ(true, ret);

    {
        ActionPtr pAction = GetWorkingBrain()->GetBehaviorManager()->GetActionById(actionId);
        EXPECT_EQ(true, (pAction != NULL));
    }

    {
        ConditionPtr pCondition = GetWorkingBrain()->GetBehaviorManager()->GetConditionById(conditionId);
        EXPECT_EQ(true, (pCondition != NULL));
    }

    // Recover
    SetWorkingBrain(pPreviousApp);
}