示例#1
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);
            }
示例#2
0
            private Point3d SearchLandingCenter()
            {
                double vTolerance = 1;
                double vLimit     = 0;

                Point3d decidingPt1 = BaseLine.PointAt(0.01) - UpstairDirec / UpstairDirec.Length * vTolerance;
                Point3d decidingPt2 = BaseLine.PointAt(0.09) - UpstairDirec / UpstairDirec.Length * vTolerance;

                double candidate1 = PCXTools.PCXByEquationStrict(decidingPt1, Landing, -UpstairDirec).Length + vTolerance;
                double candidate2 = PCXTools.PCXByEquationStrict(decidingPt2, Landing, -UpstairDirec).Length + vTolerance;

                if (candidate1 > candidate2)
                {
                    vLimit = candidate2;
                }
                else
                {
                    vLimit = candidate1;
                }

                Point3d basePt = BaseLine.PointAt(0.5) - (UpstairDirec / UpstairDirec.Length) * vLimit / 2.0;

                return(basePt);
            }
示例#3
0
                private static PartitionParam DrawAtMultiFoldOutline(PartitionParam param, double targetArea, List <Point3d> outlineVertex)
                {
                    Line           mainLine          = GetMainLine(param, outlineVertex);
                    List <Point3d> canMakePerpVertex = new List <Point3d>();

                    Vector3d mainAlign = mainLine.UnitTangent;
                    Vector3d mainPerp  = VectorTools.RotateVectorXY(mainAlign, Math.PI / 2);
                    Point3d  origin    = param.OriginPost.Point;
                    bool     isMainAlignSameAsPostNormal = mainAlign.IsParallelTo(param.OriginPost.BaseLine.UnitNormal, 0.005) == 1;

                    if (!isMainAlignSameAsPostNormal)
                    {
                        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);
                    }

                    int lastVertexIndex = outlineVertex.Count - 1;

                    for (int i = 1; i < lastVertexIndex; i++)
                    {
                        Vector3d toPreVector  = new Vector3d(outlineVertex[i - 1] - outlineVertex[i]);
                        Vector3d toPostVector = new Vector3d(outlineVertex[i + 1] - outlineVertex[i]);
                        Vector3d toMainVector = -mainPerp;

                        if (IsBetweenVector(toPreVector, toPostVector, toMainVector))
                        {
                            canMakePerpVertex.Add(outlineVertex[i]);
                        }
                    }

                    //SeivePerpVertex
                    List <Point3d> finalVertex = new List <Point3d>();


                    foreach (Point3d i in outlineVertex)
                    {
                        Line toBaseLine = PCXTools.PCXByEquationStrict(i, CurveTools.ToPolyline(mainLine.ToNurbsCurve()), -mainPerp);
                        Line toOutline  = PCXTools.PCXByEquationStrict(toBaseLine.PointAt(1), param.OutlineLabel.Pure, mainPerp);

                        if (toOutline.PointAt(1).DistanceTo(i) < 0.5)
                        {
                            finalVertex.Add(i);
                        }
                    }


                    //DrawAtEachVertex
                    List <PartitionParam> outputCandidate = new List <PartitionParam>();

                    foreach (Point3d i in finalVertex)
                    {
                        Line    toBaseLine = PCXTools.PCXByEquationStrict(i, CurveTools.ToPolyline(mainLine.ToNurbsCurve()), -mainPerp);
                        Point3d tempAnchor = toBaseLine.PointAt(1);
                        Line    toOutline  = PCXTools.PCXByEquationStrict(tempAnchor, param.OutlineLabel.Pure, mainPerp);

                        if (toOutline.PointAt(1).DistanceTo(i) > 0.5)
                        {
                            continue;
                        }

                        List <RoomLine> tempPartition = new List <RoomLine>();
                        tempPartition.Add(new RoomLine(new Line(origin, tempAnchor), LineType.Inner));
                        tempPartition.Add(new RoomLine(new Line(tempAnchor, i), LineType.Inner));

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

                        outputCandidate.Add(tempParam);
                    }

                    outputCandidate.Add(PartitionMaker.DrawOrtho(param));

                    //TestCandidate
                    //나중에 수정.. 지금은 면적일치정도로만..
                    Plane                 cornerPlane = new Plane(origin, mainAlign, mainPerp);
                    CornerComparer        comparer    = new CornerComparer();
                    List <PartitionParam> seived      = comparer.Seive(outputCandidate, targetArea, cornerPlane);

                    return(seived[0]);
                }