多角形の凸性のチェック(整数型)

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(
	PNT_T_PTR vrtx,
	int num,
	ref int convex_type
)
Visual Basic
Public Shared Function fnFIE_cg_convex_polygon_check ( 
	vrtx As PNT_T_PTR,
	num As Integer,
	ByRef convex_type As Integer
) As Integer

Parameters

vrtx
Type: fvalgcli..::..PNT_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()
        {
            int status = (int)f_err.F_ERR_NONE;

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

            try
            {
                // 多角計を設定する.
                num = 5;
                vrtx = PNT_T_PTR.alloc(num);

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

#if !NOT_CONVEX
                // 凸である.
                vrtx[4] = PNT_T.init( vrtx[0].x + size / 2,vrtx[0].y + 1) ;
                ans_convex_type = 1;
#else
                // 凸ではない.
                vrtx[4] = PNT_T.init( vrtx[0].x + size / 2,vrtx[0].y - 1) ;
                ans_convex_type = 0;
#endif
                // 多角形の凸性のチェック(整数型).
                status = api.fnFIE_cg_convex_polygon_check(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()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim vrtx As PNT_T_PTR = PNT_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 Integer = 10

        Try
            ' 多角計を設定する.
            num = 5
            vrtx = PNT_T_PTR.alloc(num)

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

            #If Not NOT_CONVEX Then
            ' 凸である.
            vrtx(4) = PNT_T.init(vrtx(0).x + size \ 2, vrtx(0).y + 1)
            ans_convex_type = 1
            #Else
            ' 凸ではない.
            vrtx(4) = PNT_T.init(vrtx(0).x + size \ 2, vrtx(0).y - 1)
            ans_convex_type = 0
            #End If
            ' 多角形の凸性のチェック(整数型).
            status = api.fnFIE_cg_convex_polygon_check(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