Geometry.GetClosestLocationsWithinRadius operator

導入

v5.0

詳細

指定された検索半径内にあり、入力位置から最も近いサーフェイスを含むPointLocatorDataを戻します。デフォルトでは、入力位置はオブジェクトのローカル空間リファレンスに定義する必要があります。オプションで、ロケーションの最大数(戻り値の数)を制限することができます。制限範囲を大きくしすぎないようにするには、半径を非常に大きくします。

リファレンスポーズまたはメソッドなどの最短位置計算(最も近いサーフェイス、最も近いノット/頂点など)は、Geometry.SetupPointLocatorQueriesを使用してセットアップできる場合があります。このセットアップは以降に呼び出すすべてのGetClosestLocationsWithinRadiusおよびGeometry.GetClosestLocationsに影響します。

Geometry.SetupPointLocatorQueriesを使用して直近サーフェイス検索またはスムーズ化された直近サーフェイス検索をセットアップした場合は、PolygonMeshのアイランドごとにポイントロケータが 1 つ戻されます。このように接続するアイランドは、検索半径を変更した場合に戻された2 つのポイント間をユーザが移動(隣接ポイント間の移動ではなく隣接ポリゴン間の移動)できないように定義されます。NurbsSurfaceMeshでは最大1 つのポイントロケータが戻されます。

このメソッドを呼び出すと、高速化用のキャッシュが自動的に作成されます。詳細については、Geometry.SetupPointLocatorQueriesを参照してください。

「最短距離」のリレーションシップは、ジオメトリおよび入力位置の空間基準に対して相対的に変化します。詳細については、Geometry.SetupPointLocatorQueriesを参照してください。

同じトポロジを持つ任意のGeometryインスタンスについてポイントロケータが計算され、戻される場合があります。

スクリプト 構文

oReturn = Geometry.GetClosestLocationsWithinRadius( Position, Radius, [MaxNbToFind] );

戻り値

PointLocatorData

パラメータ

パラメータ タイプ 詳細
位置 1DArrayまたはSIVector3 ベクトルかXYZ array から位置を検索します。
半径 Double 検索範囲を定義する球の半径。
MaxNbToFind Long 検索するロケーションポイントの最大数(-1 の場合は無制限)。

デフォルト値: -1

VBScript の例

'
' This example uses PointLocatorData to find closest vertices on a polygon mesh
' within a specific radius, and then creates a cluster on these points.
'
NewScene , false
set root = Application.ActiveSceneRoot
set GridObj = root.AddGeometry("Grid", "MeshSurface")
set GridGeom = GridObj.ActivePrimitive.Geometry
Translate GridObj, 0, 0, -2.0, siRelative, siView, siObj, siXYZ
' Set up to closest vertex search
GridGeom.SetupPointLocatorQueries siClosestVertexOrKnot, GridObj.Kinematics.Global.Transform, null, -1
' Get all vertices within a radius of 2 units relatively to the world center
set PositionToQuery = XSIMath.CreateVector3()
PositionToQuery.Set 0,0,0
set PointLocatorsWithinTwoUnits = GridGeom.GetClosestLocationsWithinRadius(PositionToQuery, 2.0)
VerticesString = " "
Dim PtLocIndexToQuery(0)
Dim ClosestVerticesArray()
ReDim ClosestVerticesArray(PointLocatorsWithinTwoUnits.Count-1)
for i = 0 to PointLocatorsWithinTwoUnits.Count-1
        ' Even though the point locators have be defined to exactly match the vertex 
        ' positions, the search data is returned as a position on a specific triangle, 
        ' just as any other use of the Point Locator.  However the vertex that matches 
        ' can be determined because it will be weighted at 100%.
        PtLocIndexToQuery(0) = i
        SubTriangleVertices = GridGeom.GetTriangleVertexIndexArray(PointLocatorsWithinTwoUnits, PtLocIndexToQuery)
        SubTriangleWeights = GridGeom.GetTriangleWeightArray(PointLocatorsWithinTwoUnits, PtLocIndexToQuery)
        for ctr = 0 to UBound(SubTriangleVertices,2)
                VtxIdx = SubTriangleVertices(0,ctr)
                if SubTriangleWeights(1,ctr) > SubTriangleWeights(0,ctr) & SubTriangleWeights(1,ctr) > SubTriangleWeights(2,ctr) then
                        VtxIdx = SubTriangleVertices(1,ctr)
                elseif SubTriangleWeights(2,ctr) > SubTriangleWeights(0,ctr) & SubTriangleWeights(2,ctr) > SubTriangleWeights(1,ctr) then 
                        VtxIdx = SubTriangleVertices(2,ctr)
                end if
                ClosestVerticesArray(i) = VtxIdx
                VerticesString = VerticesString & VtxIdx
                if i <> PointLocatorsWithinTwoUnits.Count - 1 then
                        VerticesString = VerticesString & ", "
                end if
        next
next
' Create a cluster on these vertices
GridGeom.AddCluster siVertexCluster, "ClosestVertices", ClosestVerticesArray
Application.LogMessage "There are " & PointLocatorsWithinTwoUnits.Count & " grid vertices in the 2 unit sphere located at the world center."
Application.LogMessage "These vertices are (ordered by proximity):"
Application.LogMessage VerticesString
' Expected results:
'INFO : There are 13 grid vertices in the 2 unit sphere located at the world center.
'INFO : These vertices are (ordered by proximity):
'INFO :  42, 51, 41, 33, 43, 52, 32, 50, 34, 24, 60, 40, 44

関連項目

PointLocatorData Geometry Geometry.GetClosestLocations Geometry.GetRaycastIntersections Geometry.SetupPointLocatorQueries Geometry.GetSurfacePointLocatorsFromPoints Geometry.EvaluatePositions Geometry.EvaluateNormals Geometry.EvaluateClusterProperty PolygonMesh.GetPolygonIndexArray PolygonMesh.GetTriangleVertexIndexArray PolygonMesh.GetTriangleNodeIndexArray PolygonMesh.GetTriangleWeightArray PolygonMesh.ConstructPointLocators NurbsSurfaceMesh.GetSubSurfaceIndexArray NurbsSurfaceMesh.GetNormalizedUVArray NurbsSurfaceMesh.ConstructPointLocators