Beispiel #1
0
                private static Boolean HasEnoughArea(PartitionParam paramOutput, double targetArea)
                {
                    double outputArea = PolylineTools.GetArea(paramOutput.Outline);

                    if (outputArea > targetArea)
                    {
                        return(true);
                    }

                    return(false);
                }
Beispiel #2
0
            private static List <Polyline> TrimDifferenceByCore(List <Polyline> difference, Polyline coreUnion)
            {
                List <Polyline> pureOutline = new List <Polyline>();

                foreach (Polyline i in difference)
                {
                    PolylineTools.SetPolylineAlignCCW(i);
                    List <Polyline> tempTrimmed = RemoveOverlapSeg(i, coreUnion);
                    pureOutline.AddRange(tempTrimmed);
                }

                return(pureOutline);
            }
Beispiel #3
0
                //
                private int AreaFitnessComparer(PartitionParam outputA, PartitionParam outputB, double targetArea)
                {
                    //setting
                    double aArea = PolylineTools.GetArea(outputA.Outline);
                    double bArea = PolylineTools.GetArea(outputB.Outline);

                    double aLength = outputA.PartitionPost.GetLength();
                    double bLength = outputB.PartitionPost.GetLength();

                    double aCost = ComputeCost(aArea, targetArea);
                    double bCost = ComputeCost(bArea, targetArea);

                    //decider
                    bool isACostLarger = aCost > bCost;

                    //compare

                    if (isACostLarger)
                    {
                        if (bCost / aCost > areaInitiative)
                        {
                            if (aLength < bLength)
                            {
                                return(-1);
                            }
                        }

                        return(1);
                    }

                    else
                    {
                        if (aCost / bCost > areaInitiative)
                        {
                            if (bLength < aLength)
                            {
                                return(1);
                            }
                        }

                        return(-1);
                    }
                }
Beispiel #4
0
            private static List <Polyline> TrimDifferenceByOutline(List <Polyline> difference, Polyline outline)
            {
                List <Polyline> pureCore = new List <Polyline>();

                foreach (Polyline i in difference)
                {
                    PolylineTools.SetPolylineAlignCCW(i);
                    List <Polyline> tempTrimmed = RemoveOverlapSeg(i, outline);
                    pureCore.AddRange(tempTrimmed);
                }

                foreach (Polyline i in pureCore)
                {
                    if (i.IsClosed)
                    {
                        PolylineTools.SetPolylineAlignCW(i);
                    }
                }

                return(pureCore);
            }
Beispiel #5
0
            private static List <LabeledOutline> DistributeLabel(List <Polyline> difference, List <Polyline> outlinePure, List <List <RoomLine> > coreLabeled, Polyline coreUnion)
            {
                List <LabeledOutline> distributedLabels = new List <LabeledOutline>();

                if (outlinePure.Count == 1 && outlinePure.First().IsClosed)
                {
                    LabeledOutline nonSeperatedLabel = new LabeledOutline(difference.First(), outlinePure.First(), coreLabeled.First());
                    nonSeperatedLabel.DifferenceArea = PolylineTools.GetArea(difference.First()) - PolylineTools.GetArea(coreUnion);
                    distributedLabels.Add(nonSeperatedLabel);
                    return(distributedLabels);
                }

                int seperatedCount = difference.Count;

                for (int i = 0; i < seperatedCount; i++)
                {
                    LabeledOutline seperatedLabel = new LabeledOutline(difference[i], outlinePure[i], coreLabeled[i]);
                    seperatedLabel.DifferenceArea = PolylineTools.GetArea(difference[i]);
                    distributedLabels.Add(seperatedLabel);
                }

                return(distributedLabels);
            }
Beispiel #6
0
                //comparer method
                private List <PartitionParam> SieveByFillingRate(List <PartitionParam> unseived, Plane cornerBasis)
                {
                    List <PartitionParam> fillingSeived = new List <PartitionParam>();

                    foreach (PartitionParam i in unseived)
                    {
                        List <double> tempBoundingLength = GetBoundingLength(i.Outline, cornerBasis);
                        double        tempPolyArea       = PolylineTools.GetArea(i.Outline);
                        double        tempFillingRatio   = tempPolyArea / (tempBoundingLength[0] * tempBoundingLength[1]);

                        if (tempFillingRatio > fillingTolerance)
                        {
                            fillingSeived.Add(i);
                        }
                    }

                    if (fillingSeived.Count == 0)
                    {
                        return(unseived);
                    }

                    return(fillingSeived);
                }
Beispiel #7
0
                //중복코드 나중에 지워보자..
                private static PartitionParam DrawAtNoFoldOutline(PartitionParam param, double targetArea, List <Point3d> outlineVertex)
                {
                    Line     mainLine  = GetMainLine(param, outlineVertex);
                    Vector3d mainAlign = mainLine.UnitTangent;
                    Vector3d mainPerp  = VectorTools.RotateVectorXY(mainAlign, Math.PI / 2);
                    Point3d  origin    = param.OriginPost.Point;

                    double dotProduct   = Vector3d.Multiply(mainAlign, param.OriginPost.BaseLine.UnitNormal);
                    double dotTolerance = 0.005;

                    bool isMainDirecPreDiv = false;

                    if (Math.Abs(dotProduct) < dotTolerance)
                    {
                        int originIndex = param.OutlineLabel.Core.FindIndex
                                              (i => i.PureLine == param.OriginPost.BasePureLine);

                        param.OriginPost  = new PartitionOrigin(origin, param.OutlineLabel.Core[originIndex - 1]);
                        mainPerp          = VectorTools.RotateVectorXY(mainAlign, -Math.PI / 2);
                        isMainDirecPreDiv = true;
                    }

                    int iterNum = 10;
                    int breaker = 0;

                    double   lowerBound = 0;
                    double   upperBound = mainLine.Length;
                    Polyline polyOutput = new Polyline();

                    while (lowerBound < upperBound)
                    {
                        if (breaker > iterNum)
                        {
                            break;
                        }

                        double tempStatus = (upperBound - lowerBound) / 2 + lowerBound;

                        Point3d tempAnchor = origin + mainAlign * tempStatus;
                        if (isMainDirecPreDiv)
                        {
                            tempAnchor = origin + mainAlign * (mainLine.Length - tempStatus);
                        }

                        List <RoomLine> cornerPartitions = new List <RoomLine>();
                        cornerPartitions.Add(new RoomLine(new Line(origin, tempAnchor), LineType.Inner));
                        Line anchorToOutline = PCXTools.PCXByEquation(tempAnchor, param.OutlineLabel.Pure, mainPerp);
                        cornerPartitions.Add(new RoomLine(anchorToOutline, LineType.Inner));

                        Partition tempPartition = new Partition(cornerPartitions, param.OriginPost);
                        param.PartitionPost = tempPartition;

                        double tempArea = PolylineTools.GetArea(param.Outline);

                        if (targetArea > tempArea)
                        {
                            lowerBound = tempStatus;
                        }
                        else if (targetArea < tempArea)
                        {
                            upperBound = tempStatus;
                        }
                        else
                        {
                            lowerBound = tempArea;
                            upperBound = tempArea;
                        }

                        breaker++;
                    }

                    return(param);
                }