www.mxdraw.com
内容索引主面
前一个向上下一个
IMxDrawSpline 接口

控件样条线类型,二维的样条曲线,非均匀有理的B样条曲线

IDL
[ object, uuid(6494AA43-E0E6-4C5A-A7B2-9AB6014E5996), dual, nonextensible, helpstring("IMxDrawSpline interface"), pointer_default(unique) ]
interface IMxDrawSpline : IMxDrawCurve;

MxDrawSpline.idl

例如: JS 绘制一个带宽度的样条线。

        function DrawSpline() {
             var param = mxOcx.NewResbuf();
             mxOcx.SendStringToExecuteFun("_DrawSpline",param);
             var retparam = mxOcx.GetEntitysLastCmd();
             if (retparam == null)
                 return;

             if (retparam.Count == 0)
                 return;

             var spline = retparam.AtObject(0);
             if(spline == null)
             {
                return;
             }
            var aryPoints = spline.GetSamplePoints(0.1);
            if (aryPoints == null) {
                return;
            }

            if (aryPoints.Count < 2)
                return;

            var pt = aryPoints.Item(0);
            mxOcx.PathMoveTo(pt.x, pt.y);
            for(var i = 1; i < aryPoints.Count;i++)
            {
                pt = aryPoints.Item(i);
                mxOcx.PathLineTo(pt.x,pt.y)
            }

            mxOcx.LineWidth = 10;
            mxOcx.DrawPathToPolyline();

        }

 

例如: 离形样条线

    pEnt.QueryInterface(IMxDrawSpline, spl);
                if spl <> nil then
                begin
                  // 对象是个样条线。

                  // 得到样条线的外包
                  points := spl.GetBoundingBox2();

                  //   dApproxEps样条线的离形精度
                  dApproxEps := 0.01;

                  // 根据样条线的大小,动态确定离线精度。

                  if points.Count > 1 then
                  begin
                      // 外包的最小点,和最大点
                      minPt := points.Item(0);
                      maxPt := points.Item(1);

                      //    dApproxEps取外包最短边长的 1/20
                      if abs(minPt.x - maxPt.x) < abs(minPt.y - maxPt.y)then
                      begin
                        dApproxEps := abs(minPt.x - maxPt.x) / 20;
                      end
                      else
                      begin
                        dApproxEps := abs(minPt.y - maxPt.y) / 20;
                      end;

                      // 如果为 dApproxEps零,就默认取   0.01
                      if dApproxEps < 0.0000001 then
                           dApproxEps := 0.01;


                  end;

                 // showmessage(Format('dApproxEps:%g',[dApproxEps]) );

                 // 离散样条线.
                  points := spl.GetSamplePoints(dApproxEps);

                  // 遍历样条线上的所有点,可以把这些点,做为样条线的拟合点,用来重生样条线。

                   for jj := 1 to points.Count -1 do
                   begin
                         pt :=   points.Item(jj);
                         showmessage(Format('X:%g,Y:%g',[pt.x,pt.y]) );

                   end;

                end;

 

例如:得到startTangent

     MxDrawResbuf retT = spline.GetProp("startTangent");
     vx = retT.AtDouble(0);
     vy = retT.AtDouble(1);
     vz = retT.AtDouble(1);

 

例如:得到endTangent

     MxDrawResbuf retT = spline.GetProp("endTangent");
     vx = retT.AtDouble(0);
     vy = retT.AtDouble(1);
     vz = retT.AtDouble(1);
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!