PointLocatorData.Count operator

導入

v5.0

詳細

PointLocatorData に含まれる Point locators の数を Long として戻します。

C#構文

// get accessor

Int32 rtn = PointLocatorData.Count;

JScript の例

/*

	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(null, false);

var root = Application.ActiveSceneRoot;

var GridObj = root.AddGeometry("Grid", "MeshSurface");

Translate(GridObj, 0, 0, -2.0, siRelative, siView, siObj, siXYZ);

var GridGeom = GridObj.ActivePrimitive.Geometry;

// 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

var PositionToQuery = XSIMath.CreateVector3(0,0,0);

var PointLocatorsWithinTwoUnits = GridGeom.GetClosestLocationsWithinRadius(PositionToQuery, 2.0);

var VerticesString = " ";

var ClosestVerticesArray = new Array();

var PtLocIndexToQuery = new Array();

for( i=0; i<PointLocatorsWithinTwoUnits.Count; i++ ) {

	// 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;

	var SubTriangleVertices = GridGeom.GetTriangleVertexIndexArray(

		PointLocatorsWithinTwoUnits, PtLocIndexToQuery).toArray();

	var SubTriangleWeights = GridGeom.GetTriangleWeightArray(

		PointLocatorsWithinTwoUnits, PtLocIndexToQuery).toArray();

	var VtxIdx = SubTriangleVertices[0];

	if(SubTriangleWeights[1] > SubTriangleWeights[0] && SubTriangleWeights[1] > SubTriangleWeights[2])

		VtxIdx = SubTriangleVertices[1];

	else if(SubTriangleWeights[2] > SubTriangleWeights[0] && SubTriangleWeights[2] > SubTriangleWeights[1])

		VtxIdx = SubTriangleVertices[2];

	ClosestVerticesArray[i] = VtxIdx;

	VerticesString += VtxIdx

	if( i != PointLocatorsWithinTwoUnits.Count-1) {

		VerticesString += ", ";

	}

}

// 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 5 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

関連項目

PointLocatorData Geometry Geometry.GetClosestLocations Geometry.GetClosestLocationsWithinRadius 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