Select to view content in your preferred language

# How to create multi patch geometry from triangle-mesh coordinates using ArcPy

177
0
06-04-2024 12:04 AM
New Contributor

Any help to convert this AtcObjects code to ArcPy code?

public static IGeometry ConstructMultiPatchGeometryByTriangles(List<XPoint3D[]> mesh)
{
IGeometry unionedGeom = null;
ITopologicalOperator unionedOp = null;

if (mesh != null)
{
IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();
IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch;

for (int i = 0; i < mesh.Count; i++)
{
var triangle = mesh[i];
var firstPoint = triangle[0];
var secondPoint = triangle[1];
var thirdPoint = triangle[2];

IPointCollection TriangleStrip = new TriangleStripClass();

TriangleStrip.AddPoint(ConstructPoint3D(firstPoint.X, firstPoint.Y, firstPoint.Z), ref _missing, ref _missing);
TriangleStrip.AddPoint(ConstructPoint3D(secondPoint.X, secondPoint.Y, secondPoint.Z), ref _missing, ref _missing);
TriangleStrip.AddPoint(ConstructPoint3D(thirdPoint.X, thirdPoint.Y, thirdPoint.Z), ref _missing, ref _missing);

multiPatchGeometryCollection.AddGeometry(TriangleStrip as IGeometry, ref _missing, ref _missing);

}

var _geometry = multiPatch as IGeometry;

if (unionedGeom == null)
{
unionedGeom = _geometry;
}

unionedOp = (ITopologicalOperator)unionedGeom;

unionedGeom = unionedOp.Union(_geometry);
}

return unionedGeom;
}

Tags (6)
0 Replies