Пример #1
0
        //return-> unit:m
        //lowpointz-> unit:m
        BG.DPoint3d GetVirtualPileAxisBottomPoint(double lowpointz)
        {
            BG.DSegment3d pileaxis           = new BG.DSegment3d(m_pile.PilePropertyInfo.PileTopPoint.Point3dToDPoint3d(), m_pile.PilePropertyInfo.PileBottomPoint.Point3dToDPoint3d());
            double        pileaxiszlength    = pileaxis.Extent.Z;
            double        virtualaxiszlength = pileaxis.StartPoint.Z - lowpointz;
            double        scale = Math.Abs(virtualaxiszlength / pileaxiszlength);

            return(pileaxis.PointAtFraction(scale));
        }
Пример #2
0
        public override BD.StatusInt OnElementModify(BDE.Element element)
        {
            BDE.ShapeElement shape = element as BDE.ShapeElement;
            if (shape == null)
            {
                return(BD.StatusInt.Error);
            }
            BG.CurveVector  curveVector = shape.GetCurveVector();
            BG.DTransform3d world2LoaclDTransform3D;
            BG.DTransform3d loacl2WorlDTransform3D;
            BG.DRange3d     shapeRange3D;
            curveVector.IsPlanar(out loacl2WorlDTransform3D, out world2LoaclDTransform3D, out shapeRange3D);
            BG.DMatrix3d       rotMatrix3D = loacl2WorlDTransform3D.Matrix;
            List <BG.DPoint3d> points      = new List <BG.DPoint3d>();

            curveVector.GetPrimitive(0).TryGetLineString(points);

            BG.DSegment3d linex = new BG.DSegment3d(points[0], points[1]);
            BG.DSegment3d liney = new BG.DSegment3d(points[0], points[3]);

            int ucellnum = 0;
            int vcellnum = 0;

            if (isOutRect)
            {
                ucellnum = (int)Math.Ceiling(linex.Length / uaxisoffset);
                vcellnum = (int)Math.Ceiling(liney.Length / vaxisoffset);
            }
            else
            {
                ucellnum = (int)Math.Floor(linex.Length / uaxisoffset);
                vcellnum = (int)Math.Floor(liney.Length / vaxisoffset);
            }

            double ufraction = uaxisoffset / linex.Length;
            double vfraction = vaxisoffset / liney.Length;

            for (int i = 0; i < vcellnum; i++)
            {
                BG.DPoint3d yaxisPoint = liney.PointAtFraction(i * vfraction);
                for (int j = 0; j < ucellnum; j++)
                {
                    BG.DPoint3d  xaxisPoint  = linex.PointAtFraction(j * ufraction);
                    BG.DVector3d xyDVector3D = BG.DVector3d.Add(BG.DPoint3d.Subtract(xaxisPoint, points[0]), BG.DPoint3d.Subtract(yaxisPoint, points[0]));
                    BG.DPoint3d  putPoint3D  = BG.DPoint3d.Add(points[0], xyDVector3D);
                    CellFunction.PlaceCell(new ArmorCellInfo()
                    {
                        CellName  = cellName,
                        CellTrans = rotMatrix3D,
                        Origin    = putPoint3D
                    });
                    Bentley.UI.Threading.DispatcherHelper.DoEvents();
                }
            }
            return(BD.StatusInt.Success);
        }
Пример #3
0
        BG.DSegment3d GetMinDistanceBetweenToLine(BG.DSegment3d lineAB, BG.DSegment3d lineCD)
        {
            //var lineab = lineAB.DSegement3dToLine3D();
            //var linecd = lineCD.DSegement3dToLine3D();
            //var closetline = lineab.ClosestPointsBetween(linecd, true);
            //return new Bentley.GeometryNET.DSegment3d(closetline.Item1.Point3DToDPoint3d(), closetline.Item2.Point3DToDPoint3d());
            BG.DSegment3d crossline;
            double        fa, fb;
            bool          isCross;

            isCross = BG.DSegment3d.ClosestApproachSegment(lineAB, lineCD, out crossline, out fa, out fb);

            if (0 <= fa && fa <= 1 && 0 <= fb && fb <= 1)
            {
                return(new BG.DSegment3d(lineAB.PointAtFraction(fa), lineCD.PointAtFraction(fb)));
            }
            else
            {
                //double A_LineCD, B_LineCD, C_LineAB, D_LineAB;
                BG.DPoint3d P_A_LineCD, P_B_LineCD, P_C_LineAB, P_D_LineAB;
                double      f;
                lineCD.ClosestFractionAndPoint(lineAB.StartPoint, true, out f, out P_A_LineCD);
                lineCD.ClosestFractionAndPoint(lineAB.EndPoint, true, out f, out P_B_LineCD);
                lineAB.ClosestFractionAndPoint(lineCD.StartPoint, true, out f, out P_C_LineAB);
                lineAB.ClosestFractionAndPoint(lineCD.EndPoint, true, out f, out P_D_LineAB);
                var closedis = new double[]
                {
                    lineAB.StartPoint.Distance(P_A_LineCD),
                    lineAB.EndPoint.Distance(P_B_LineCD),
                    lineCD.StartPoint.Distance(P_C_LineAB),
                    lineCD.EndPoint.Distance(P_D_LineAB)
                };
                BG.DSegment3d minsegement = new Bentley.GeometryNET.DSegment3d();
                switch (closedis.FindIndex(n => n == closedis.Min()))
                {
                case 0:
                    minsegement = new BG.DSegment3d(lineAB.StartPoint, P_A_LineCD);
                    break;

                case 1:
                    minsegement = new BG.DSegment3d(lineAB.EndPoint, P_B_LineCD);
                    break;

                case 2:
                    minsegement = new BG.DSegment3d(P_C_LineAB, lineCD.StartPoint);
                    break;

                case 3:
                    minsegement = new BG.DSegment3d(P_D_LineAB, lineCD.EndPoint);
                    break;
                }
                return(minsegement);
            }
        }