Example #1
0
                private static Boolean IsOriginEndConcave(PartitionParam param)
                {
                    int originCurrentIndex = param.OutlineLabel.Core.FindIndex
                                                 (i => (i.PureLine == param.OriginPost.BasePureLine));

                    RoomLine cornerLinePre  = new RoomLine();
                    RoomLine cornerLinePost = new RoomLine();


                    if (originCurrentIndex == param.OutlineLabel.Core.Count - 1)
                    {
                        return(false);
                    }

                    cornerLinePre  = param.OutlineLabel.Core[originCurrentIndex];
                    cornerLinePost = param.OutlineLabel.Core[originCurrentIndex + 1];



                    PartitionSetter.CornerState cornerStat = PartitionSetter.GetCCWCornerState(cornerLinePre.UnitTangent, cornerLinePost.UnitTangent);

                    if (cornerStat == PartitionSetter.CornerState.Concave)
                    {
                        return(true);
                    }

                    return(false);
                }
Example #2
0
                //main method
                public static PartitionParam DrawEachPartition(PartitionParam param, double targetArea)
                {
                    PartitionParam tempParam = new PartitionParam(param);

                    PartitionSetter.SetNextDivOrigin(tempParam);

                    if (IsOverlap(tempParam))
                    {
                        MoveOriginProperly(tempParam);
                    }

                    if (IsOriginEndConcave(tempParam))
                    {
                        return(DrawAtConcaveCorner(tempParam, targetArea));
                    }

                    return(DrawAtThisBaseEnd(tempParam, targetArea));
                }
Example #3
0
            //sub method
            private Partition SetInitialDivider(LabeledOutline outlineLabel)
            {
                RoomLine firstRoomLine = outlineLabel.Core[0];

                if (firstRoomLine.Type == LineType.Corridor)
                {
                    return(DrawInitialDivider(firstRoomLine, outlineLabel.Pure));
                }

                RoomLine nearestCorridor = PartitionSetter.FindNearestCorridor(outlineLabel.Core, firstRoomLine);
                int      parallelDecider = firstRoomLine.UnitTangent.IsParallelTo(nearestCorridor.UnitTangent);

                if (parallelDecider == 0) //첫번째 라인과 복도가 평행이 아닌 경우, not parallel
                {
                    return(DrawInitialDivider(nearestCorridor, outlineLabel.Pure));
                }
                else //평행인 경우
                {
                    return(DrawInitialDivider(firstRoomLine, outlineLabel.Pure));
                }
            }
Example #4
0
                private static PartitionParam PushOriginToEnd(PartitionParam param)
                {
                    List <RoomLine> coreSeg      = param.OutlineLabel.Core;
                    int             indexCurrent = coreSeg.FindIndex(i => i.PureLine == param.OriginPost.BasePureLine);

                    if (indexCurrent >= coreSeg.Count - 2) // 사실상 마지막 세그먼트인 경우..
                    {
                        param.OriginPost.Point = param.OriginPost.BaseLine.EndPt;
                        return(DrawOrtho(param));
                    }

                    PartitionSetter.CornerState cornerStat =
                        PartitionSetter.GetCCWCornerState(coreSeg[indexCurrent].UnitTangent, coreSeg[indexCurrent + 1].UnitTangent);

                    if (cornerStat == PartitionSetter.CornerState.Concave)
                    {
                        SetPostParallelToOrigin(param);
                        return(DrawOrtho(param));
                    }

                    param.OriginPost.Point = param.OriginPost.BaseLine.EndPt;
                    return(DrawOrtho(param));
                }
Example #5
0
                private static PartitionParam PushOriginToStart(PartitionParam param)
                {
                    List <RoomLine> coreSeg      = param.OutlineLabel.Core;
                    int             indexCurrent = param.OutlineLabel.Core.FindIndex
                                                       (i => i.PureLine == param.OriginPost.BasePureLine);

                    if (indexCurrent < 2) //이 경우는 거의 없을듯..
                    {
                        return(DrawOrtho(param));
                    }

                    PartitionSetter.CornerState cornerStat =
                        PartitionSetter.GetCCWCornerState(coreSeg[indexCurrent - 1].UnitTangent, coreSeg[indexCurrent - 1].UnitTangent);

                    if (cornerStat == PartitionSetter.CornerState.Concave)
                    {
                        PartitionOrigin newOrigin = new PartitionOrigin(coreSeg[indexCurrent - 2].EndPt, coreSeg[indexCurrent - 2]);
                        param.OriginPost = newOrigin;
                        return(DrawOrtho(param));
                    }

                    param.OriginPost.Point = param.OriginPost.BaseLine.StartPt;
                    return(DrawOrtho(param));
                }