I am working on some .NET code that processes lots of polygon geometries at the vertex level. In order to reduce COM interop overhead, I want to call IGeometryBridge2.GetPoints once instead of calling IPointCollection.Point repeatedly:
// using ESRI.ArcGIS.Geometry;
static IPoint[] GetVertices(this IPolygon singlepartPolygon)
{
var pointCollection = (IPointCollection4)singlepartPolygon;
var points = new IPoint[pointCollection.PointCount];
var geometryBridge = (IGeometryBridge2)new GeometryEnvironment();
geometryBridge.GetPoints(pointCollection, 0, ref points);
return points;
}
geometryBridge.GetPoints(…) throws a NotImplementedException.
(I have tried initialising the points array with empty Point instances before calling GetPoints, but this didn't make any difference. I tried geometryBridge.QueryPoints(…), too, and this failed with a different exception.)
Am I doing something wrong, or is this more likely to be a bug?
GeometryEnvironmentClass()instead ofGeometryEnvironment(). That is the .NET runtime callable wrapper (RCW) for the GeometryEnvironment COM type: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000151000000 – blah238 Feb 03 '13 at 14:06new GeometryEnvironment()is exactly the same asnew GeometryEnvironmentClass().GeometryEnvironment(which is an interface) is decorated with the CoClass attribute:CoClass(typeof(GeometryEnvironmentClass)), so that the compiler knows which class you are instantating. This is how the .NET COM type library importer converts types (for better compatibility with legacy languages and environments). – Petr Krebs Feb 04 '13 at 12:07