コード例 #1
0
ファイル: cElHJaFacette.cpp プロジェクト: jakexie/micmac
bool cElHJaFacette::IsRecouvrt(bool & ThisIsEnDessus,
                               cElHJaFacette * aF2,bool ShowMes)
{
     bool isIVide = InterVide(mBox,aF2->mBox);

     if (ShowMes)
        cout << "Inter " << isIVide << "\n";
     else
     {
        if (isIVide)
           return false;
     }

     cElPolygone aP1;
     cElPolygone aP2;
     aP1.AddContour(mVPt,false);
     aP2.AddContour(aF2->mVPt,false);

     cElPolygone aP3 = aP1 * aP2;
     cElPolygone::tConstLC  &  aLC = aP3.Contours();

     if (aLC.empty())
     {
        if (ShowMes)
           cout << "No Intersection \n";
        return false;
     }

     REAL aSTot = 0;
     REAL aPerimTot = 0;
     REAL aZ1 = 0.0;
     REAL aZ2 = 0.0;
     cElPlan3D PL1 = Plan()->Plan();
     cElPlan3D PL2 =  aF2->Plan()->Plan();
     for (cElPolygone::tItConstLC itC=aLC.begin(); itC!=aLC.end() ; itC++)
     {
         cElPolygone::tContour aC = *itC;
         REAL aS = surf_or_poly(aC);
         REAL aP = perimetre_poly(aC);
         if (ShowMes)
            cout << "P= " << aP << " ;  S= " << aS << "\n";
         aSTot     += std::abs(aS);
         aPerimTot += std::abs(aP);
         for (INT aKP=0; aKP<INT(aC.size()) ; aKP++)
         {
             aZ1 += PL1.ZOfXY(aC[aKP]);
             aZ2 += PL2.ZOfXY(aC[aKP]);
         }
     }

     ThisIsEnDessus = (aZ1>aZ2);

     REAL aDiam = aSTot / std::max(aPerimTot,1e-5);

     if (ShowMes)
        cout << "Diam = " << aDiam << "\n";

     return aDiam > ElHJAEpsilon ;
}
コード例 #2
0
ファイル: cube.cpp プロジェクト: ppff/Cubicle-GUI
Cube::Cube()
{
    this->listePlan1= new QList<Plan>();

    for (int i = 0 ; i < 9 ; i++){
    Plan p=Plan();
             this->listePlan1->insert(i, p);
    }
}
コード例 #3
0
/** \brief standard constructor
 *
 * \detail sets up a standard CiM2 timetable
 */
Timetable::Timetable()
{
    _plans[PLAN_WEEKDAY]        = Plan(Time(6, 0),  Time(22, 0),    Time(2, 0), F_DAY_MON_TO_THU | F_DAY_FRIDAY);
    _plans[PLAN_MORNING_RUSH]   = Plan(Time(7, 0),  Time(7, 30),    Time(2, 0), F_DAY_MON_TO_THU | F_DAY_FRIDAY);
    _plans[PLAN_EVENING_RUSH]   = Plan(Time(17, 0), Time(17, 30),   Time(2, 0), F_DAY_MON_TO_THU | F_DAY_FRIDAY);
    _plans[PLAN_WEEKEND]        = Plan(Time(6, 0),  Time(21, 0),    Time(3, 0), F_DAY_SATURDAY | F_DAY_SUNDAY);
    _plans[PLAN_NIGHT]          = Plan(Time(0, 0),  Time(3, 0),     Time(3, 0), F_DAY_EVERY_DAY);
    _plans[PLAN_CUSTOM]         = Plan(Time(0, 0),  Time(0, 0),     Time(0, 0), F_DAY_NONE);
}
コード例 #4
0
bool VisibilityGraphPlanner::Plan(const Vector2& a,const Vector2& b,vector<Vector2>& path)
{
  Config qa(2),qb(2);
  qa.copy(a);
  qb.copy(b);
  MilestonePath mpath;
  if(!Plan(qa,qb,mpath)) {
    path.resize(0);
    return false;
  }
  path.resize(mpath.NumMilestones());
  for(size_t i=0;i<path.size();i++)
    path[i].set(mpath.GetMilestone(i));
  return true;
}
コード例 #5
0
/** \brief deserializes the timetable
 *
 */
void Timetable::deserialize(const Serializable::PropertyTree& pt)
{
    _plans[PLAN_WEEKDAY] = Plan(pt.get_child("plans.weekday"));
    _plans[PLAN_MORNING_RUSH] = Plan(pt.get_child("plans.morning-rush"));
    _plans[PLAN_EVENING_RUSH] = Plan(pt.get_child("plans.evening-rush"));
    _plans[PLAN_WEEKEND] = Plan(pt.get_child("plans.weekend"));
    _plans[PLAN_NIGHT] = Plan(pt.get_child("plans.night"));
    _plans[PLAN_CUSTOM] = Plan(pt.get_child("plans.custom"));

}
コード例 #6
0
ファイル: DijkstraPlanner.cpp プロジェクト: snailcoder/PASS
IntVector DijkstraPlanner::operator ()(int start, 
                                       int goal, 
                                       const PlanningGraph &graph) const {
  return Plan(start, goal, graph);
}
コード例 #7
0
ファイル: Game.cpp プロジェクト: ksundberg/CS1400
void lionheart::Game::doTurn(std::shared_ptr<Display> display)
{
  ++turns;
  //determine random turn order
  static std::random_device rd;
  static std::mt19937 engine(rd());
  for(auto&& u:units)
  {
    std::shuffle(std::begin(u), std::end(u), engine);
  }

  auto u0 = std::begin(units[0]);
  auto u1 = std::begin(units[1]);
  while (u0 != std::end(units[0]) && u1 != std::end(units[1]))
  {
    auto doAction = [&](Unit &unit,
                       std::shared_ptr<Player> p,
                       std::vector<std::shared_ptr<Unit>> &allies,
                       std::vector<std::shared_ptr<Unit>> &enemies)->bool
    {
        if (unit.isAlive())
        {
          std::shared_ptr<const Paths> paths = nullptr;
          if(unit.getMoveSpeed() == 5)
          {
            paths = mountedPaths;
          }
          else
          {
            paths = infantryPaths;
          }
          // get recommendations
          auto action = p->recommendAction(unit, buildReport(map, turns, allies, enemies), Plan(unit, allies, enemies,paths));
          // execute valid recommendations
          return action(map, unit, allies,enemies);
        }
		return false;
    };
    // do player 0 unit
    if (u0 != std::end(units[0]))
    {
      auto unit = *u0;
      auto result = doAction(*unit,player[0],units[0],units[1]);
      ++u0;

      if(display&&result)
      {
        display->show(getReport(),player[0]->getBlazon(),player[1]->getBlazon());
      }
    }
    // do player 1 unit
    if (u1 != std::end(units[1]))
    {
      auto unit = *u1;
      auto result = doAction(*unit,player[1],units[1],units[0]);
      ++u1;

      if(display&&result)
      {
        display->show(getReport(),player[0]->getBlazon(),player[1]->getBlazon());
      }
    }
  }
  // remove the fallen
  for (auto &&u : units)
  {
    u.erase(std::remove_if(std::begin(u),
                              std::end(u),
                              [](std::shared_ptr<Unit> const &unit)
    { return !unit->isAlive(); }),
               std::end(u));
  }
  if(!canContinue())
  {
    state = FINISHED;
  }
}