Beispiel #1
0
int main() {
   /* Debugging Code */ 
   //double minX = 0.05859357, maxX = 0.44921857;
   //double minY = 2.03125, maxY = 2.421875;
   //int width = 20, height = 20;

   double minX = -10, maxX = 10, minY = -7.5, maxY = 7.5;
   int width = 512, height = 384;
   Canvas canvas;
   InitCanvas(&canvas, minX, maxX, minY, maxY, width, height);

   Point eye = CreatePoint(0.0, 0.0, -14.0);
   Point blueSphere = CreatePoint(1.0, 1.0, 0.0);
   Point redSphere = CreatePoint(0.5, 1.5, -3.0);
   Point lightPoint = CreatePoint(-100.0, 100.0, -100.0);

   Color blue = CreateColor(0.0, 0.0, 1.0);
   Color red = CreateColor(1.0, 0.0, 0.0);
   Color ambient = CreateColor(1.0, 1.0, 1.0);
   Color lightColor = CreateColor(1.5, 1.5, 1.5);
   
   Finish largeFinish = CreateFinish(0.2, 0.4, 0.5, 0.05);
   Finish smallFinish = CreateFinish(0.4, 0.4, 0.5, 0.05);

   Light light = CreateLight(lightPoint, lightColor);
   Sphere spheres[2];
   spheres[0] = CreateSphere(blueSphere, 2.0, blue, largeFinish);
   spheres[1] = CreateSphere(redSphere, 0.5, red, smallFinish);
   
   castAllRays(&canvas, eye, spheres, ambient, light, 2);
   return 0;
}
bool 
AbstractTaskFactory::Replace(const OrderedTaskPoint &new_tp,
                             const unsigned position,
                             const bool auto_mutate)
{
  if (auto_mutate) {
    if (IsValidType(new_tp, position))
      // ok to replace directly
      return task.Replace(new_tp, position);

    // will need to convert type of candidate
    OrderedTaskPoint *tp;
    if (position == 0) {
      // candidate must be transformed into a startpoint
      tp = CreateStart(new_tp.GetWaypoint());
    } else if (IsPositionFinish(position) &&
               position + 1 == task.TaskSize()) {
      // this point must be mutated into a finish
      tp = CreateFinish(new_tp.GetWaypoint());
    } else {
      // this point must be mutated into an intermediate
      tp = CreateIntermediate(new_tp.GetWaypoint());
    }

    bool success = task.Replace(*tp, position);
    delete tp;
    return success;
  }

  return task.Replace(new_tp, position);
}
bool
AbstractTaskFactory::MutateClosedFinishPerTaskType()
{
  if (task.TaskSize() < 2)
    return false;

  if (!IsPositionFinish(task.TaskSize() - 1))
    return false;

  bool changed = false;

  if (constraints.is_closed) {
    if (!IsClosed()) {
      const OrderedTaskPoint &tp = task.GetPoint(task.TaskSize() - 1);
      if (tp.GetType() == TaskPointType::FINISH) {
        FinishPoint *fp = CreateFinish(task.GetPoint(0).GetWaypoint());
        assert(fp);
        Remove(task.TaskSize() - 1, false);
        Append(*fp, false);
        delete fp;
        changed = true;
      }
    }
  }
  return changed;
}
bool
AbstractTaskFactory::CheckAddFinish()
{
 if (task.TaskSize() < 2)
   return false;

 if (task.HasFinish())
   return false;

 FinishPoint *fp = CreateFinish(task.GetPoint(task.TaskSize() - 1).GetWaypoint());
 assert(fp);
 Remove(task.TaskSize() - 1, false);
 Append(*fp, false);
 delete fp;

 return true;
}
bool 
AbstractTaskFactory::Append(const OrderedTaskPoint &new_tp,
                            const bool auto_mutate)
{
  if (task.IsFull())
    return false;

  if (auto_mutate) {
    if (!task.TaskSize()) {
      // empty task, so add as a start point
      if (IsValidType(new_tp, task.TaskSize())) {
        // candidate is ok, so add it
        return task.Append(new_tp);
      } else {
        // candidate must be transformed into a startpoint
        StartPoint* sp = CreateStart(new_tp.GetWaypoint());
        bool success = task.Append(*sp);
        delete sp;
        return success;
      }
    }

    // non-empty task

    if (task.HasFinish()) {
      // old finish must be mutated into an intermediate point
      IntermediateTaskPoint* sp =
        CreateIntermediate(task.GetTaskPoint(task.TaskSize() - 1).GetWaypoint());

      task.Replace(*sp, task.TaskSize()-1);
      delete sp;
    }

    if (IsValidType(new_tp, task.TaskSize()))
      // ok to append directly
      return task.Append(new_tp);

    // this point must be mutated into a finish
    FinishPoint* sp = CreateFinish(new_tp.GetWaypoint());
    bool success = task.Append(*sp);
    delete sp;
    return success;
  }

  return task.Append(new_tp);
}
Beispiel #6
0
bool wxGenericFileDialog::Create( wxWindow *parent,
                                  const wxString& message,
                                  const wxString& defaultDir,
                                  const wxString& defaultFile,
                                  const wxString& wildCard,
                                  long  style,
                                  const wxPoint& pos,
                                  const wxSize& sz,
                                  const wxString& name,
                                  bool  bypassGenericImpl )
{
    if (!CreatePrepare(parent, message, defaultDir, defaultFile,
                       wildCard, style, pos, sz, name, bypassGenericImpl))
    {
        return false;
    }

    bool is_pda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA);
    CreateDefaultControls(this, wildCard, is_pda);
    CreateFinish(is_pda);

    return true;
}
bool 
AbstractTaskFactory::Remove(const unsigned position, 
                            const bool auto_mutate)
{
  if (position >= task.TaskSize())
    return false;

  if (auto_mutate) {
    if (position == 0) {
      // special case, remove start point..
      if (task.TaskSize() == 1) {
        return task.Remove(0);
      } else {
        // create new start point from next point
        StartPoint* sp = CreateStart(task.GetTaskPoint(1).GetWaypoint());
        bool success = task.Remove(0) && task.Replace(*sp, 0);
        delete sp;
        return success;
      }
    } else if (IsPositionFinish(position - 1) &&
               position + 1 == task.TaskSize()) {
      // create new finish from previous point
      FinishPoint *sp =
        CreateFinish(task.GetTaskPoint(position - 1).GetWaypoint());
      bool success = task.Remove(position) &&
        task.Replace(*sp, position - 1);
      delete sp;
      return success;
    } else {
      // intermediate point deleted, nothing special to do
      return task.Remove(position);
    }
  }

  return task.Remove(position);
}
OrderedTaskPoint*
AbstractTaskFactory::CreatePoint(const TaskPointFactoryType type,
                                 const Waypoint &wp,
                                 fixed start_radius,
                                 fixed turnpoint_radius,
                                 fixed finish_radius) const
{
  GetPointDefaultSizes(type, start_radius, turnpoint_radius, finish_radius);

  switch (type) {
  case TaskPointFactoryType::START_SECTOR:
    return CreateStart(SymmetricSectorZone::CreateFAISectorZone(wp.location,
                                                                false),
                       wp);
  case TaskPointFactoryType::START_LINE:
    return CreateStart(new LineSectorZone(wp.location, start_radius), wp);
  case TaskPointFactoryType::START_CYLINDER:
    return CreateStart(new CylinderZone(wp.location, start_radius), wp);
  case TaskPointFactoryType::START_BGA:
    return CreateStart(KeyholeZone::CreateBGAStartSectorZone(wp.location), wp);
  case TaskPointFactoryType::FAI_SECTOR:
    return CreateASTPoint(SymmetricSectorZone::CreateFAISectorZone(wp.location,
                                                                   true),
                          wp);
  case TaskPointFactoryType::SYMMETRIC_QUADRANT:
    return CreateASTPoint(new SymmetricSectorZone(wp.location,
                                                  turnpoint_radius), wp);
  case TaskPointFactoryType::KEYHOLE_SECTOR:
    return CreateASTPoint(KeyholeZone::CreateDAeCKeyholeZone(wp.location), wp);
  case TaskPointFactoryType::BGAFIXEDCOURSE_SECTOR:
    return CreateASTPoint(KeyholeZone::CreateBGAFixedCourseZone(wp.location), wp);
  case TaskPointFactoryType::BGAENHANCEDOPTION_SECTOR:
    return CreateASTPoint(KeyholeZone::CreateBGAEnhancedOptionZone(wp.location), wp);
  case TaskPointFactoryType::AST_CYLINDER:
    return CreateASTPoint(new CylinderZone(wp.location, turnpoint_radius), wp);
  case TaskPointFactoryType::MAT_CYLINDER:
    return CreateAATPoint(CylinderZone::CreateMatCylinderZone(wp.location),
                          wp);
  case TaskPointFactoryType::AAT_CYLINDER:
    return CreateAATPoint(new CylinderZone(wp.location, turnpoint_radius), wp);
  case TaskPointFactoryType::AAT_SEGMENT:
    return CreateAATPoint(new SectorZone(wp.location, turnpoint_radius), wp);
  case TaskPointFactoryType::AAT_ANNULAR_SECTOR:
    return CreateAATPoint(new AnnularSectorZone(wp.location, turnpoint_radius), wp);
  case TaskPointFactoryType::AAT_KEYHOLE:
    return CreateAATPoint(KeyholeZone::CreateCustomKeyholeZone(wp.location,
                                                               turnpoint_radius,
                                                               Angle::QuarterCircle()),
                          wp);
  case TaskPointFactoryType::FINISH_SECTOR:
    return CreateFinish(SymmetricSectorZone::CreateFAISectorZone(wp.location,
                                                                 false),
                        wp);
  case TaskPointFactoryType::FINISH_LINE:
    return CreateFinish(new LineSectorZone(wp.location, finish_radius), wp);
  case TaskPointFactoryType::FINISH_CYLINDER:
    return CreateFinish(new CylinderZone(wp.location, finish_radius), wp);

  case TaskPointFactoryType::COUNT:
    gcc_unreachable();
  }

  gcc_unreachable();
}
FinishPoint* 
AbstractTaskFactory::CreateFinish(const Waypoint &wp) const
{
  return CreateFinish(GetDefaultFinishType(), wp);
}