Example #1
0
                private static PartitionParam DrawAtPreCrossed(PartitionParam preParam)
                {
                    PartitionParam lastParam = new PartitionParam(preParam);

                    lastParam.OriginPost.BaseLine = preParam.OutlineLabel.Core[preParam.OutlineLabel.Core.Count - 2];
                    lastParam.OriginPost.Point    = lastParam.OriginPost.BaseLine.EndPt;

                    return(PartitionMaker.DrawOrtho(lastParam));
                }
Example #2
0
                //main method
                public static PartitionParam Draw(PartitionParam preParam, PartitionParam initialParam)
                {
                    if (preParam.OutlineLabel.Pure.IsClosed)
                    {
                        return(DrawAtDoughnutType(preParam, initialParam));
                    }

                    PartitionParam lastParam = new PartitionParam(preParam);

                    lastParam.OriginPost.BaseLine = preParam.OutlineLabel.Core.Last();
                    lastParam.OriginPost.Point    = preParam.OutlineLabel.Core.Last().EndPt;

                    if (IsCrossed(lastParam))
                    {
                        return(DrawAtPreCrossed(preParam));
                    }

                    return(PartitionMaker.DrawOrtho(lastParam));
                }
Example #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]);
                }