예제 #1
0
        void DFS(int baseLineID)
        {
            //foreach (CarStallMeta carMeta in CarStallMeta.META_LIST)

            CarStallRow c = new CarStallRow(
                baseLineID,
                zone.edges[baseLineID],
                CarStallMeta.NINETY_DEGREE,
                zone);
            // RoadRow r = new RoadRow(baseLineID,  zone.edges[baseLineID], RoadMeta.NORMAL_ROAD);

            // create new result and metric
            RowSolverResult branchC = (RowSolverResult)this.SOLVER_RESULT_FACTORY.CreateNew();
            // RowSolverResult branchR = (RowSolverResult) this.SOLVER_RESULT_FACTORY.CreateNew();
            Metric mC = this.METRIC_FACTORY.CreateNew();

            // Metric mR = this.METRIC_FACTORY.CreateNew();
            SetMetricAndResult(mC, branchC);
            // SetMetricAndResult(mR, branchR);


            RowNode startC = GrowNode(null, c, branchC);

            // RowNode startR = GrowNode(null, r, branchR);
            //  RowNode startC = c;
            // RowNode startR = r;
            branchC.Add(startC);
            //  branchR.Add(startR);

            Grow(startC, branchC, baseLineID);
            // Grow(startR, branchR, baseLineID);
        }
예제 #2
0
        public void ChangeToInnerLine()
        {
            List <RowNode> replaceList = new List <RowNode>();

            for (int i = 0; i < this.list.Count; i++)
            {
                RowNode node = list[i];
                // intersect
                double leftParam;
                double thisParam;
                double rightParam;
                Intersection.LineLine(node.highLine, list[(i + 1) % list.Count].highLine, out leftParam, out thisParam);
                Intersection.LineLine(node.highLine, list[(i + list.Count - 1) % list.Count].highLine, out rightParam, out thisParam);
                Line     newRefLine = new Line(node.highLine.PointAt(leftParam), node.highLine.PointAt(rightParam));
                Vector3d moveBack   = new Vector3d(node.zone.offsetDirection[i]);
                moveBack.Reverse();
                moveBack.Unitize();
                newRefLine.Transform(Transform.Translation(moveBack * node.metaItem.GetClearHeight()));

                RowNode replaceNode = new CarStallRow(
                    i,
                    newRefLine,
                    (CarStallMeta)node.metaItem,
                    node.zone
                    );
                replaceList.Add(replaceNode);
            }
            this.list = replaceList;
        }
예제 #3
0
 public override void Calculate()
 {
     this.metricValue = 0;
     foreach (RowNode node in solverResult.result)
     {
         if (node is CarStallRow)
         {
             CarStallRow carNode = ((CarStallRow)node);
             double      temp    = carNode.GetLineLength() / carNode.GetClearHeight();
             this.metricValue += temp;
         }
     }
 }
예제 #4
0
        void Grow(BoundarySolverResult branch, int baseLineID)
        {
            if (baseLineID >= this.zone.edges.Length)
            {
                // Change branch
                branch.ChangeToInnerLine();
                resultRepository.Add(branch);


                return;
            }

            foreach (CarStallMeta meta in CarStallMeta.SINGLE_META_LIST)
            {
                RowNode newNode = new CarStallRow(
                    baseLineID,
                    zone.OffsetInZone(zone.edges[baseLineID], baseLineID, 0),
                    meta,
                    zone);
                branch.Add(newNode);
                Grow(branch.Clone(), baseLineID + 1);
                branch.RemoveLast();
            }
        }
예제 #5
0
        void Grow(RowNode node, RowSolverResult branch, int baseLineID)
        {
            // Cut Branch
            if (branch.singleRowNum < 0)
            {
                return;
            }

            // reach end.. base case
            if (branch.totalWidth > zone.maxOffsetLength[baseLineID])
            {
                branch.StepBack();
                resultRepository.Add(branch);
                return;
            }

            // recursive
            // add RoadRow
            if (node != null && node is CarStallRow)
            {
                RoadRow r = new RoadRow(
                    baseLineID,
                    zone.OffsetInZone(node.referenceLine, baseLineID, node.GetClearHeight()),
                    RoadMeta.NORMAL_ROAD,
                    zone
                    );

                RowSolverResult newBranch = branch.Clone();
                RowNode         newNode   = GrowNode(node, r, newBranch);
                Grow(newNode, newBranch, baseLineID);
            }
            // add CarRow
            else
            {
                foreach (CarStallMeta carMeta in CarStallMeta.META_LIST)
                {
                    CarStallRow c = new CarStallRow(
                        baseLineID,
                        zone.OffsetInZone(node.referenceLine, baseLineID, node.GetClearHeight()),
                        carMeta,
                        zone
                        );
                    // Grow a Car Branch
                    RowSolverResult carBranch = branch.Clone();
                    RowNode         carNode   = GrowNode(node, c, carBranch);
                    Grow(carNode, carBranch, baseLineID);
                }
            }



            /* OLD IMPLEMENTATION
             * foreach (CarStallMeta carMeta in CarStallMeta.META_LIST)
             * {
             *
             *  // If exceed the maxWidth(base case)
             *  if (branch.totalWidth + carMeta.GetClearHeight() >= zone.maxOffsetLength[baseLineID])
             *  {
             *      resultRepository.Add(branch);
             *      continue;
             *      if (!IsLegalAddition(node))
             *      {
             *          continue;
             *      }
             *      else
             *      {
             *          resultRepository.Add(branch);
             *
             *          if (resultRepository.Count >= BEST_RESULT_NUMBER)
             *          {
             *              resultRepository.Remove(resultRepository.Min);
             *          }
             *
             *          continue;
             *      }
             *  }
             *
             *  // recursive case
             *  // if node.referenceLine is None:
             *  // self.resultRepository.append(branch)
             *  // return
             *
             *
             *  // if this node is CarStall
             *  if (node is CarStallRow)
             *  {
             *      // not connected to Road
             *      if (!node.IsConnectedToRoadRow())
             *      {
             *          RoadRow r = new RoadRow(
             *              baseLineID,
             *              zone.OffsetInZone(node.referenceLine, baseLineID, node.GetClearHeight()),
             *              RoadMeta.NORMAL_ROAD
             *              );
             *
             *          RowSolverResult newBranch = Copy.DeepClone(branch);
             *          RowNode newNode = GrowNode(node, r, newBranch);
             *          Grow(newNode, newBranch, baseLineID);
             *      }
             *      // if connected to Road
             *      else
             *      {
             *          CarStallRow c = new CarStallRow(
             *                  baseLineID,
             *                  zone.OffsetInZone(node.referenceLine, baseLineID, node.GetClearHeight()),
             *                  carMeta
             *                  );
             *
             *          RoadRow r = new RoadRow(
             *                  baseLineID,
             *                  zone.OffsetInZone(node.referenceLine, baseLineID, node.GetClearHeight()),
             *                  RoadMeta.NORMAL_ROAD
             *                  );
             *
             *          // Grow a Car Branch
             *          RowSolverResult carBranch = Copy.DeepClone(branch);
             *          RowNode carNode = GrowNode(node, c, carBranch);
             *          Grow(carNode, carBranch, baseLineID);
             *
             *          // Grow a Road Branch
             *          RowSolverResult roadBranch = Copy.DeepClone(branch);
             *          RowNode roadNode = GrowNode(node, c, roadBranch);
             *          Grow(roadNode, roadBranch, baseLineID);
             *      }
             *  }
             *  // if this node is a Road
             *  else if (node is RoadRow)
             *  {
             *      CarStallRow c = new CarStallRow(
             *                  baseLineID,
             *                  zone.OffsetInZone(node.referenceLine, baseLineID, node.GetClearHeight()),
             *                  carMeta
             *                  );
             *      RowSolverResult newBranch = Copy.DeepClone(branch);
             *      RowNode newNode = GrowNode(node, c, newBranch);
             *      Grow(newNode, newBranch, baseLineID);
             *
             *  }
             * }
             */
        }