曲線補間をして、補間点群を取得

Namespace: fvalgcli
Assembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)

Syntax

C#
public static DPNT_T_PTR fnFIE_draw_curve_get_point_set(
	DPNT_T_PTR pnts,
	int num_pnt,
	f_draw_curve_mode mode,
	ref int num_inter
)
Visual Basic
Public Shared Function fnFIE_draw_curve_get_point_set ( 
	pnts As DPNT_T_PTR,
	num_pnt As Integer,
	mode As f_draw_curve_mode,
	ByRef num_inter As Integer
) As DPNT_T_PTR

Parameters

pnts
Type: fvalgcli..::..DPNT_T_PTR
頂点データ
num_pnt
Type: System..::..Int32
頂点の数
mode
Type: fvalgcli..::..f_draw_curve_mode
曲線の種類
  • F_DRAW_CUBIC_BSPLINE :3次Bスプライン曲線
  • F_DRAW_QUADRATIC_BEZIER :2次ベジェ曲線
  • F_DRAW_CUBIC_CATMULL_ROM :3次カットマル-ロム曲線
num_inter
Type: System..::..Int32%
求められた補間点群の数

Return Value

Type: DPNT_T_PTR
求められた曲線近似による補間点群の配列の先頭アドレスを返します。 メモリ不足、不正なパラメータが渡された場合、ライセンスエラー、未初期化エラー などで失敗した場合は、IntPtr.Zero を返します。

Examples

C# Copy imageCopy
//    $Revision: 1.1 $

using System;
using System.Collections.Generic;
using System.Text;
using fvalgcli;

namespace TC
{
    public partial class FIE
    {
        /// <summary>
        /// 曲線補間をした補間点群の取得.
        /// </summary>
        [FvPluginExecute]
        public void fnFIE_draw_curve_get_point_set()
        {
            // 戻り値として、エラーコードではなく求められた補間点群の配列の先頭アドレス(DPNT_T *)が返される.
            DPNT_T_PTR pnts = DPNT_T_PTR.Zero;        // 頂点データ.
            DPNT_T_PTR ret_obj = DPNT_T_PTR.Zero;
            FHANDLE ret_img = FHANDLE.Zero;            // 出力用画像.
            DOUBLE_PTR dens_val = IntPtr.Zero;
            const int num_pnt = 10;                    // 頂点の数.
            const f_draw_curve_mode mode = f_draw_curve_mode.F_DRAW_CUBIC_BSPLINE;    // 曲線の種類.
            int num_inter = 0;                        // 求められた補間点群の数.

            // 結果確認用画像のサイズ.
            const int width = 64;
            const int height = 64;

            try
            {
                // 配列の確保(アンマネージヒープに確保される).
                pnts = DPNT_T_PTR.alloc(num_pnt);

                // 頂点データの設定.
                for (int i = 0; i < num_pnt; i++)
                {
                    double x = i * (width / (num_pnt - 1));
                    double y = (height - 1) * (0x1 & i);
                    pnts[i] = DPNT_T.init(x, y);
                }

                // 処理の実行.
                ret_obj = api.fnFIE_draw_curve_get_point_set(pnts, num_pnt, mode, ref num_inter);

                // エラー判定.
                Assert.IsFalse(ret_obj == DPNT_T_PTR.Zero, "エラーが発生しました。");

                // 求められた補間点群を画像にプロットしファイルに保存する.
                {
                    ret_img = api.fnFIE_img_root_alloc((int)f_imgtype.F_IMG_UC8, 1, width, height);
                    api.fnFIE_img_clear(ret_img, 0);

                    dens_val = DOUBLE_PTR.alloc(1);
                    dens_val[0] = 255;

                    for (int i = 0; i < num_inter; i++)
                    {
                        api.fnFIE_draw_point(ret_img, dens_val, ret_obj[i]);
                    }

                    api.fnFIE_save_png(ResultDir + "/fnFIE_draw_curve_get_point_set.png", ret_img, -1);
                }

            }
            finally
            {
                // オブジェクトの開放.
                ret_obj.Dispose();
                ret_img.Dispose();
                pnts.Dispose();
                dens_val.Dispose();
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli

Public Partial Class FIE
    ''' <summary>
    ''' 曲線補間をした補間点群の取得.
    ''' </summary>
    <FvPluginExecute> _
    Public Sub fnFIE_draw_curve_get_point_set()
        ' 戻り値として、エラーコードではなく求められた補間点群の配列の先頭アドレス(DPNT_T *)が返される.
        Dim pnts As DPNT_T_PTR = DPNT_T_PTR.Zero
        ' 頂点データ.
        Dim ret_obj As DPNT_T_PTR = DPNT_T_PTR.Zero
        Dim ret_img As FHANDLE = FHANDLE.Zero
        ' 出力用画像.
        Dim dens_val As DOUBLE_PTR = IntPtr.Zero
        Const  num_pnt As Integer = 10
        ' 頂点の数.
        Const  mode As f_draw_curve_mode = f_draw_curve_mode.F_DRAW_CUBIC_BSPLINE
        ' 曲線の種類.
        Dim num_inter As Integer = 0
        ' 求められた補間点群の数.
        ' 結果確認用画像のサイズ.
        Const  width As Integer = 64
        Const  height As Integer = 64

        Try
            ' 配列の確保(アンマネージヒープに確保される).
            pnts = DPNT_T_PTR.alloc(num_pnt)

            ' 頂点データの設定.
            For i As Integer = 0 To num_pnt - 1
                Dim x As Double = i * (width \ (num_pnt - 1))
                Dim y As Double = (height - 1) * (&H1 And i)
                pnts(i) = DPNT_T.init(x, y)
            Next

            ' 処理の実行.
            ret_obj = api.fnFIE_draw_curve_get_point_set(pnts, num_pnt, mode, num_inter)

            ' エラー判定.
            Assert.IsFalse(ret_obj = DPNT_T_PTR.Zero, "エラーが発生しました。")

            ' 求められた補間点群を画像にプロットしファイルに保存する.
            If True Then
                ret_img = api.fnFIE_img_root_alloc(CInt(f_imgtype.F_IMG_UC8), 1, width, height)
                api.fnFIE_img_clear(ret_img, 0)

                dens_val = DOUBLE_PTR.alloc(1)
                dens_val(0) = 255

                For i As Integer = 0 To num_inter - 1
                    api.fnFIE_draw_point(ret_img, dens_val, ret_obj(i))
                Next

                api.fnFIE_save_png(ResultDir & "/fnFIE_draw_curve_get_point_set.png", ret_img, -1)

            End If
        Finally
            ' オブジェクトの開放.
            ret_obj.Dispose()
            ret_img.Dispose()
            pnts.Dispose()
            dens_val.Dispose()
        End Try
    End Sub
End Class

See Also