Beispiel #1
0
                private static Boolean IsCrossed(PartitionParam setterParam)
                {
                    Partition       dividerTest = setterParam.PartitionPre;
                    PartitionOrigin originTest  = setterParam.OriginPost;

                    Vector3d normal         = originTest.BaseLine.UnitNormal;
                    Polyline trimmed        = setterParam.OutlineLabel.Difference;
                    double   coverAllLength = new BoundingBox(new List <Point3d>(trimmed)).Diagonal.Length * 2;
                    Line     testLine       = new Line(originTest.Point, originTest.Point + normal * coverAllLength);

                    foreach (RoomLine i in dividerTest.Lines)
                    {
                        if (i.UnitTangent == normal)
                        {
                            continue;
                        }

                        Point3d crossPt = CCXTools.GetCrossPt(testLine, i.PureLine);

                        if (PCXTools.IsPtOnLine(crossPt, i.PureLine, 0.005) && PCXTools.IsPtOnLine(crossPt, testLine, 0.005))
                        {
                            return(true);
                        }
                    }

                    return(false);
                }
Beispiel #2
0
                //sub method
                /*111공통된 부분 줄일 수 있음.. 일단은 구현*/
                private static void FindMinCorridor(PartitionParam setterParam)
                {
                    RoomLine nearestCorridor = FindNearestCorridor(setterParam.OutlineLabel.Core, setterParam.OriginPost.BaseLine);

                    if (setterParam.OriginPost.BasePureLine == nearestCorridor.PureLine)
                    {
                        FindCorrFromSameBase(setterParam);
                        return;
                    }

                    if (nearestCorridor.Length < RoomDimension.MinLengthForDoor)
                    {
                        SetOriginNextStart(setterParam);
                        FindCorrFromSameBase(setterParam);
                        return;
                    }

                    Point3d nearestBase         = nearestCorridor.StartPt;
                    Point3d baseWithMinCorridor = new Point3d(nearestBase + nearestCorridor.UnitTangent * RoomDimension.MinLengthForDoor);

                    PartitionOrigin originNext = new PartitionOrigin(baseWithMinCorridor, nearestCorridor);

                    setterParam.OriginPost = originNext;
                    return;
                }
Beispiel #3
0
                private static Point3d MakePerpPt(Partition dividerTest, PartitionOrigin originTest)
                {
                    //dSide: divider 쪽, oSide: origin 쪽
                    Point3d  dSidePt        = dividerTest.Lines[dividerTest.Lines.Count - 1].PointAt(1);
                    Vector3d dSideDirection = -originTest.BaseLine.UnitNormal;

                    Point3d  oSidePt        = originTest.Point;
                    Vector3d oSideDirection = originTest.BaseLine.UnitTangent;

                    //ABC is coefficient of linear Equation, Ax+By=C
                    double dSideA = dSideDirection.Y;
                    double dSideB = -dSideDirection.X;
                    double dSideC = dSideA * dSidePt.X + dSideB * dSidePt.Y;

                    double oSideA = oSideDirection.Y;
                    double oSideB = -oSideDirection.X;
                    double oSideC = oSideA * oSidePt.X + oSideB * oSidePt.Y;

                    //det=0: isParallel, 평행한 경우
                    double detTolerance = 0.005;
                    double det          = dSideA * oSideB - dSideB * oSideA;

                    if (Math.Abs(det) < detTolerance)
                    {
                        return(Point3d.Unset);
                    }

                    double perpX = (oSideB * dSideC - dSideB * oSideC) / det;
                    double perpY = (dSideA * oSideC - oSideA * dSideC) / det;

                    return(new Point3d(perpX, perpY, oSidePt.Z));
                }
Beispiel #4
0
                private static void SetOriginFromEndPt(PartitionParam setterParam)
                {
                    int testIndex = setterParam.OutlineLabel.Core.FindIndex
                                        (i => (i.PureLine == setterParam.OriginPost.BasePureLine));

                    if (testIndex == setterParam.OutlineLabel.Core.Count - 1)
                    {
                        return;
                    }

                    RoomLine formerCornerLine = setterParam.OutlineLabel.Core[testIndex];
                    RoomLine laterCornerLine  = setterParam.OutlineLabel.Core[testIndex + 1];

                    PartitionOrigin laterStart = new PartitionOrigin(laterCornerLine.PureLine.PointAt(0), laterCornerLine);
                    PartitionOrigin laterEnd   = new PartitionOrigin(laterCornerLine.PureLine.PointAt(1), laterCornerLine);

                    CornerState cornerStat = GetCCWCornerState(formerCornerLine.UnitTangent, laterCornerLine.UnitTangent);

                    if (cornerStat == CornerState.Concave)
                    {
                        setterParam.OriginPost = laterEnd;
                        SetNextDivOrigin(setterParam);
                        return;
                    }

                    return;
                }
Beispiel #5
0
 public PartitionParam(Partition dividerPre, Partition dividerPost, PartitionOrigin originPost, LabeledOutline outlineLabel)
 {
     this.PartitionPre  = dividerPre;
     this.PartitionPost = dividerPost;
     this.OriginPost    = originPost;
     this.OutlineLabel  = outlineLabel;
 }
Beispiel #6
0
                private static Boolean IsEndPt(PartitionOrigin testOrigin)
                {
                    double nearTolerance = 0.005;
                    double distance      = testOrigin.BaseLine.EndPt.DistanceTo(testOrigin.Point);

                    if (distance <= nearTolerance)
                    {
                        return(true);
                    }

                    return(false);
                }
Beispiel #7
0
            private Partition DrawInitialDivider(RoomLine firstRoomLine, Polyline outlinePure)
            {
                PartitionOrigin originInitial = new PartitionOrigin(firstRoomLine.PureLine.PointAt(0), firstRoomLine);

                Line            lineInitial        = PCXTools.PCXByEquationStrict(originInitial.Point, outlinePure, originInitial.BaseLine.UnitNormal);
                List <RoomLine> lineInitialLabeled = new List <RoomLine> {
                    new RoomLine(lineInitial, LineType.Inner)
                };                                                                                                    //외곽선과 겹칠 경우 추가 요
                Partition dividerInitial = new Partition(lineInitialLabeled, originInitial);

                return(dividerInitial);
            }
Beispiel #8
0
                public Partition(Partition otherPartition)
                {
                    List <RoomLine> cloneLines  = new List <RoomLine>();
                    PartitionOrigin cloneOrigin = new PartitionOrigin();

                    //assign
                    foreach (RoomLine i in otherPartition.Lines)
                    {
                        cloneLines.Add(i);
                    }

                    cloneOrigin = new PartitionOrigin(otherPartition.Origin);

                    //return
                    this.Lines  = cloneLines;
                    this.Origin = cloneOrigin;
                }
Beispiel #9
0
                private static void FindCorrFromSameBase(PartitionParam setterParam)
                {
                    RoomLine nearestCorridor = setterParam.OriginPost.BaseLine;

                    double originToCorridorEnd = new Vector3d(nearestCorridor.PointAt(1) - setterParam.OriginPost.Point).Length;

                    if (originToCorridorEnd < RoomDimension.MinLengthForDoor)
                    {
                        SetOriginNextStart(setterParam);
                        FindCorrFromSameBase(setterParam);
                        return;
                    }

                    Point3d nearestBase         = setterParam.OriginPost.Point;
                    Point3d baseWithMinCorridor = new Point3d(nearestBase + nearestCorridor.UnitTangent * RoomDimension.MinLengthForDoor);

                    PartitionOrigin originNext = new PartitionOrigin(baseWithMinCorridor, nearestCorridor);

                    setterParam.OriginPost = originNext;
                    return;
                }
Beispiel #10
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));
                }
Beispiel #11
0
                private static Boolean IsOnOriginBase(Point3d ptTest, PartitionOrigin originTest)
                {
                    Line testLine = new Line(originTest.Point, originTest.BaseLine.PointAt(1));

                    return(PCXTools.IsPtOnLine(ptTest, testLine, 0));
                }
Beispiel #12
0
 public Partition(List <RoomLine> dividingLine, PartitionOrigin thisLineOrigin)
 {
     this.Lines  = dividingLine;
     this.Origin = thisLineOrigin;
 }
Beispiel #13
0
 public PartitionOrigin(PartitionOrigin otherOrigin)
 {
     this.Point    = otherOrigin.Point;
     this.BaseLine = new RoomLine(otherOrigin.BaseLine);
 }