交点算出(2円)

Namespace: FVIL.Caliper
Assembly: FVILbasic (in FVILbasic.dll) Version: 3.1.0.0 (3.1.0.17)

Syntax

C#
public static List<CFviPoint> CrossPoint(
	CFviCircle circle1,
	CFviCircle circle2
)
Visual Basic
Public Shared Function CrossPoint ( 
	circle1 As CFviCircle,
	circle2 As CFviCircle
) As List(Of CFviPoint)

Parameters

circle1
Type: FVIL.Data..::..CFviCircle
円1
circle2
Type: FVIL.Data..::..CFviCircle
円2

Return Value

Type: List<(Of <(<'CFviPoint>)>)>
2つの円の交点を求めます。 検出される交点は、0~2 個です。 見つかった交点が List に格納されます。 交点が見つからない時は要素数が 0 個の List を返します。

正常に実行できなかった場合は例外を発行します。 例外の原因と発生位置を特定するには、発行された例外クラスの ErrorCode メンバと Function メンバを参照してください。

エラーコード:

ErrorCode メンバ内容
51FVIL.ErrorCode.LICENSE_ERROR ライセンスキーが見つからない為、実行できません。 または、 FVIL._SetUp.InitVisionLibrary が実行されていません。
11FVIL.ErrorCode.INVALID_PARAMETERパラメータに誤りがあります。
29FVIL.ErrorCode.NOT_CALCULABLE計算不可能です。
1FVIL.ErrorCode.FAILED_TO_ALLOCATEメモリが確保できません。

Examples

C# Copy imageCopy
//    $Revision: 1.3 $

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using fvalgcli;    // FvPluginXXXX attribute requires fvalgcli

namespace User.SampleCode
{
    public partial class Caliper
    {
        /// <summary>
        /// 交点算出(2円)の測定.
        /// </summary>
        /// <remarks>
        /// FVIL.Caliper.Function.CrossPoint(FVIL.Data.CFviCircle,FVIL.Data.CFviCircle)
        /// </remarks>
        [FvPluginExecute]
        public void CrossPoint_circle_circle()
        {
            // 1) 2円の生成.
            FVIL.Data.CFviCircle circle1 = new FVIL.Data.CFviCircle(140, 140, 80);
            FVIL.Data.CFviCircle circle2 = new FVIL.Data.CFviCircle(100, 160, 70);

            // 2) 計測実行.
            List<FVIL.Data.CFviPoint> points = FVIL.Caliper.Function.CrossPoint(circle1, circle2);

            // 確認用.
            {
                // 画像、描画表示クラス、オーバーレイのインスタンスの生成.
                FVIL.Data.CFviImage image = new FVIL.Data.CFviImage(320, 240, FVIL.ImageType.UC8, 1);
                FVIL.GDI.CFviDisplay display = new FVIL.GDI.CFviDisplay();
                FVIL.GDI.CFviOverlay overlay = new FVIL.GDI.CFviOverlay();

                {
                    // 描画図形の生成.
                    // 入力円1
                    FVIL.GDI.CFviGdiCircle gcircle1 = new FVIL.GDI.CFviGdiCircle(circle1);
                    gcircle1.Pen.Color = Color.Green;
                    gcircle1.Pen.Width = 1;
                    gcircle1.Pen.Style = FVIL.GDI.PenStyle.Solid;

                    // 入力円2
                    FVIL.GDI.CFviGdiCircle gcircle2 = new FVIL.GDI.CFviGdiCircle(circle2);
                    gcircle2.Pen.Color = Color.Green;
                    gcircle2.Pen.Width = 1;
                    gcircle2.Pen.Style = FVIL.GDI.PenStyle.Solid;

                    // 結果点.
                    System.Collections.Generic.List<FVIL.GDI.CFviGdiPoint> gpoints = new List<FVIL.GDI.CFviGdiPoint>();
                    for (int index = 0; index < points.Count; index++)
                    {
                        gpoints.Add(new FVIL.GDI.CFviGdiPoint(points[index]));
                        gpoints[index].Pen.Color = Color.Red;
                        gpoints[index].Pen.Width = 4;
                    }

                    // 描画図形の追加.
                    overlay.Figures.Add(gcircle1);
                    overlay.Figures.Add(gcircle2);
                    foreach (FVIL.GDI.CFviGdiPoint gpoint in gpoints)
                    {
                        overlay.Figures.Add(gpoint);
                    }
                    overlay.Enable = true; 
                }

                // 画像表示クラスへの追加.
                display.Overlays.Add(overlay);
                display.Image = image;
                display.DisplayRect = image.Window;

                // 描画イメージの保存.
                FVIL.Data.CFviImage dstimage = new FVIL.Data.CFviImage();
                display.SaveImage(dstimage);
                FVIL.File.Function.SaveImageFile(Defs.ResultDir + "/Caliper.CrossPoint_circle_circle.png", dstimage);
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

Imports System.Collections.Generic
Imports System.Text
Imports System.Drawing
Imports fvalgcli
' FvPluginXXXX attribute requires fvalgcli
Namespace SampleCode
    Public Partial Class Caliper
        ''' <summary>
        ''' 交点算出(2円)の測定.
        ''' </summary>
        ''' <remarks>
        ''' FVIL.Caliper.Function.CrossPoint(FVIL.Data.CFviCircle,FVIL.Data.CFviCircle)
        ''' </remarks>
        <FvPluginExecute> _
        Public Sub CrossPoint_circle_circle()
            ' 1) 2円の生成.
            Dim circle1 As New FVIL.Data.CFviCircle(140, 140, 80)
            Dim circle2 As New FVIL.Data.CFviCircle(100, 160, 70)

            ' 2) 計測実行.
            Dim points As List(Of FVIL.Data.CFviPoint) = FVIL.Caliper.[Function].CrossPoint(circle1, circle2)

            ' 確認用.
            If True Then
                ' 画像、描画表示クラス、オーバーレイのインスタンスの生成.
                Dim image As New FVIL.Data.CFviImage(320, 240, FVIL.ImageType.UC8, 1)
                Dim display As New FVIL.GDI.CFviDisplay()
                Dim overlay As New FVIL.GDI.CFviOverlay()

                If True Then
                    ' 描画図形の生成.
                    ' 入力円1
                    Dim gcircle1 As New FVIL.GDI.CFviGdiCircle(circle1)
                    gcircle1.Pen.Color = Color.Green
                    gcircle1.Pen.Width = 1
                    gcircle1.Pen.Style = FVIL.GDI.PenStyle.Solid

                    ' 入力円2
                    Dim gcircle2 As New FVIL.GDI.CFviGdiCircle(circle2)
                    gcircle2.Pen.Color = Color.Green
                    gcircle2.Pen.Width = 1
                    gcircle2.Pen.Style = FVIL.GDI.PenStyle.Solid

                    ' 結果点.
                    Dim gpoints As System.Collections.Generic.List(Of FVIL.GDI.CFviGdiPoint) = New List(Of FVIL.GDI.CFviGdiPoint)()
                    For index As Integer = 0 To points.Count - 1
                        gpoints.Add(New FVIL.GDI.CFviGdiPoint(points(index)))
                        gpoints(index).Pen.Color = Color.Red
                        gpoints(index).Pen.Width = 4
                    Next

                    ' 描画図形の追加.
                    overlay.Figures.Add(gcircle1)
                    overlay.Figures.Add(gcircle2)
                    For Each gpoint As FVIL.GDI.CFviGdiPoint In gpoints
                        overlay.Figures.Add(gpoint)
                    Next
                    overlay.Enable = True
                End If

                ' 画像表示クラスへの追加.
                display.Overlays.Add(overlay)
                display.Image = image
                display.DisplayRect = image.Window

                ' 描画イメージの保存.
                Dim dstimage As New FVIL.Data.CFviImage()
                display.SaveImage(dstimage)
                FVIL.File.[Function].SaveImageFile(Defs.ResultDir & "/Caliper.CrossPoint_circle_circle.png", dstimage)
            End If
        End Sub
    End Class
End Namespace

Exceptions

ExceptionCondition
FVIL..::..CFviExceptionこの例外の原因については、上記のエラーコード表をご参照ください。

See Also