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); }
//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; }
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; }
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); }
private static void SetPreEndToOrigin(PartitionParam param) { int currentIndex = param.OutlineLabel.Core.FindIndex (i => (i.PureLine == param.OriginPost.BasePureLine)); if (currentIndex == 0) { return; } RoomLine baseLinePre = param.OutlineLabel.Core[currentIndex - 1]; param.OriginPost = new PartitionOrigin(baseLinePre.EndPt, baseLinePre); return; }
//setter랑 중복코드 있음!! private static void SetPostStartToOrigin(PartitionParam param) { int currentIndex = param.OutlineLabel.Core.FindIndex (i => (i.PureLine == param.OriginPost.BasePureLine)); if (currentIndex == param.OutlineLabel.Core.Count - 1) { return; } RoomLine baseLinePost = param.OutlineLabel.Core[currentIndex + 1]; param.OriginPost = new PartitionOrigin(baseLinePost.StartPt, baseLinePost); return; }
//main method public static RoomLine FindNearestCorridor(List <RoomLine> coreSeg, RoomLine baseLine) { RoomLine nearestCorridor = new RoomLine(); int baseIndex = coreSeg.FindIndex(i => (i.PureLine == baseLine.PureLine)); for (int i = baseIndex; i < coreSeg.Count; i++) { if (coreSeg[i].Type == LineType.Corridor) { nearestCorridor = coreSeg[i]; break; } } return(nearestCorridor); }
private static void SetOriginNextStart(PartitionParam setterParam) { int currentIndex = setterParam.OutlineLabel.Core.FindIndex (i => (i.PureLine == setterParam.OriginPost.BasePureLine)); if (currentIndex == setterParam.OutlineLabel.Core.Count - 1) { return; } RoomLine baseLineNext = setterParam.OutlineLabel.Core[currentIndex + 1]; setterParam.OriginPost = new PartitionOrigin(baseLineNext.PointAt(0), baseLineNext); return; }
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; }
//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)); } }
public RoomLine(RoomLine roomLine) { this.PureLine = roomLine.PureLine; this.Type = roomLine.Type; }
public PartitionOrigin(Point3d basePt, RoomLine baseLine) { this.Point = basePt; this.BaseLine = baseLine; }