多角形の凸性のチェック(浮動小数点型)

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

Syntax

C#
public static int fnFIE_cg_convex_polygon_check_d(
	DPNT_T_PTR vrtx,
	int num,
	ref int convex_type
)
Visual Basic
Public Shared Function fnFIE_cg_convex_polygon_check_d ( 
	vrtx As DPNT_T_PTR,
	num As Integer,
	ByRef convex_type As Integer
) As Integer

Parameters

vrtx
Type: fvalgcli..::..DPNT_T_PTR
多角形の頂点
num
Type: System..::..Int32
頂点数( vrtx の要素数)
convex_type
Type: System..::..Int32%
多角形の凸形状
  • 0 多角形は凸ではない
  • 1 多角形は凸である

Return Value

Type: Int32
以下のエラーコードを返します。

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_INVALID_PARAM 不正なパラメータが渡された 頂点数が3未満
F_ERR_NO_LICENCEライセンスエラー、または未初期化エラー

Remarks

Examples

C# Copy imageCopy
//    $Revision: 1.1 $

//#define NOT_CONVEX

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

using fvalgcli;

namespace TC
{
    public partial class FIE
    {
        [FvPluginExecute]
        public void fnFIE_cg_convex_polygon_check_d()
        {
            int status = (int)f_err.F_ERR_NONE;

            DPNT_T_PTR vrtx = DPNT_T_PTR.Zero;    // 多角形の頂点.
            int num;                            // 頂点数( vrtx の要素数).
            int convex_type = new int();        // 多角形の凸形状(0:凸ではない、1:凸である).

            int ans_convex_type;

            // 多角形を設定する.
            const double size = 10.0;

            try
            {
                num = 5;
                vrtx = DPNT_T_PTR.alloc(num);

                vrtx[1] = DPNT_T.init(0.0, 0.0);

                vrtx[0] = DPNT_T.init(0.0, vrtx[1].y + size);

                vrtx[2] = DPNT_T.init(vrtx[0].x + size, 0.0);

                vrtx[3] = DPNT_T.init(vrtx[0].x + size, vrtx[1].y + size);


#if !NOT_CONVEX
                // 凸である.
                vrtx[4] = DPNT_T.init( vrtx[0].x + size / 2.0, vrtx[0].y + 1);
                ans_convex_type = 1;
#else
                // 凸ではない.
                vrtx[4] = DPNT_T.init( vrtx[0].x + size / 2.0, vrtx[0].y - 1);
                ans_convex_type = 0;
#endif
                // 多角形の凸性のチェック(浮動小数点型).
                status = api.fnFIE_cg_convex_polygon_check_d(vrtx, num, ref convex_type);

                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status);

                // 結果を出力する.
                ConsoleOut.WriteFunctionName(":\t");
                Console.Write("convex_type = {0} ...", convex_type);
                ConsoleOut.IsTrue(ans_convex_type == convex_type);
            }
            finally
            {
                vrtx.Dispose();
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

'#Const NOT_CONVEX = True

Imports System.Collections.Generic
Imports System.Text

Imports fvalgcli

Public Partial Class FIE
    <FvPluginExecute> _
    Public Sub fnFIE_cg_convex_polygon_check_d()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim vrtx As DPNT_T_PTR = DPNT_T_PTR.Zero
        ' 多角形の頂点.
        Dim num As Integer
        ' 頂点数( vrtx の要素数).
        Dim convex_type As New Integer()
        ' 多角形の凸形状(0:凸ではない、1:凸である).
        Dim ans_convex_type As Integer

        ' 多角形を設定する.
        Const  size As Double = 10.0

        Try
            num = 5
            vrtx = DPNT_T_PTR.alloc(num)

            vrtx(1) = DPNT_T.init(0.0, 0.0)

            vrtx(0) = DPNT_T.init(0.0, vrtx(1).y + size)

            vrtx(2) = DPNT_T.init(vrtx(0).x + size, 0.0)

            vrtx(3) = DPNT_T.init(vrtx(0).x + size, vrtx(1).y + size)


            #If Not NOT_CONVEX Then
            ' 凸である.
            vrtx(4) = DPNT_T.init(vrtx(0).x + size / 2.0, vrtx(0).y + 1)
            ans_convex_type = 1
            #Else
            ' 凸ではない.
            vrtx(4) = DPNT_T.init(vrtx(0).x + size / 2.0, vrtx(0).y - 1)
            ans_convex_type = 0
            #End If
            ' 多角形の凸性のチェック(浮動小数点型).
            status = api.fnFIE_cg_convex_polygon_check_d(vrtx, num, convex_type)

            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err))

            ' 結果を出力する.
            ConsoleOut.WriteFunctionName(":" & vbTab)
            Console.Write("convex_type = {0} ...", convex_type)
            ConsoleOut.IsTrue(ans_convex_type = convex_type)
        Finally
            vrtx.Dispose()
        End Try
    End Sub
End Class

See Also