This document is archived and information here might be outdated. Recommended version. |
MultiPatch Ring Types.
Constant | Value | Description |
---|---|---|
esriMultiPatchInvalidRing | 1 | Invalid Ring. |
esriMultiPatchUndefinedRing | 2 | Ring type has not been defined. |
esriMultiPatchFirstRing | 4 | The beginning FirstRing in a FirstRing/Ring sequence. |
esriMultiPatchRing | 8 | A following Ring in a FirstRing/Ring sequence or a beginning Ring in a solo Ring group. |
esriMultiPatchOuterRing | 16 | The beginning OuterRing in an OuterRing/InnerRing sequence. |
esriMultiPatchInnerRing | 32 | A following InnerRing in an OuterRing/InnerRing sequence. |
esriMultiPatchBeginningRingMask | 28 | A mask of valid beginning rings (OuterRings, FirstRings, and solo Rings). |
esriMultiPatchFollowingRingMask | 40 | A mask of valid following rings (InnerRings and Rings). |
esriMultiPatchProblemCaseRingMask | 3 | A mask of problematic rings (UndefinedRings and InvalidRings). |
private static object _missing = Type.Missing;
public static IGeometry GetMultiPatchGeometry()
{
const int XRange = 16;
const int YRange = 16;
const int InteriorRingCount = 25;
const double HoleRange = 0.5;
//RingGroup: Square Lying In XY Plane With Single Exterior Ring
// And Multiple Interior Rings
IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass();
IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch;
//Exterior Ring
IPointCollection exteriorRingPointCollection = new RingClass();
exteriorRingPointCollection.AddPoint(ConstructPoint3D(0.5 * (XRange + 2), -0.5 * (YRange + 2), 0), ref _missing, ref _missing);
exteriorRingPointCollection.AddPoint(ConstructPoint3D(-0.5 * (XRange + 2), -0.5 * (YRange + 2), 0), ref _missing, ref _missing);
exteriorRingPointCollection.AddPoint(ConstructPoint3D(-0.5 * (XRange + 2), 0.5 * (YRange + 2), 0), ref _missing, ref _missing);
exteriorRingPointCollection.AddPoint(ConstructPoint3D(0.5 * (XRange + 2), 0.5 * (YRange + 2), 0), ref _missing, ref _missing);
IRing exteriorRing = exteriorRingPointCollection as IRing;
exteriorRing.Close();
multiPatchGeometryCollection.AddGeometry(exteriorRing as IGeometry, ref _missing, ref _missing);
multiPatch.PutRingType(exteriorRing, esriMultiPatchRingType.esriMultiPatchOuterRing);
//Interior Rings
Random random = new Random();
for (int i = 0; i < InteriorRingCount; i++)
{
double interiorRingOriginX = XRange * (random.NextDouble() - 0.5);
double interiorRingOriginY = YRange * (random.NextDouble() - 0.5);
IPointCollection interiorRingPointCollection = new RingClass();
interiorRingPointCollection.AddPoint(ConstructPoint3D(interiorRingOriginX - 0.5 * HoleRange, interiorRingOriginY - 0.5 * HoleRange, 0), ref _missing, ref _missing);
interiorRingPointCollection.AddPoint(ConstructPoint3D(interiorRingOriginX + 0.5 * HoleRange, interiorRingOriginY - 0.5 * HoleRange, 0), ref _missing, ref _missing);
interiorRingPointCollection.AddPoint(ConstructPoint3D(interiorRingOriginX + 0.5 * HoleRange, interiorRingOriginY + 0.5 * HoleRange, 0), ref _missing, ref _missing);
interiorRingPointCollection.AddPoint(ConstructPoint3D(interiorRingOriginX - 0.5 * HoleRange, interiorRingOriginY + 0.5 * HoleRange, 0), ref _missing, ref _missing);
IRing interiorRing = interiorRingPointCollection as IRing;
interiorRing.Close();
multiPatchGeometryCollection.AddGeometry(interiorRing as IGeometry, ref _missing, ref _missing);
multiPatch.PutRingType(interiorRing, esriMultiPatchRingType.esriMultiPatchInnerRing);
}
return multiPatchGeometryCollection as IGeometry;
}
public static IPoint ConstructPoint3D(double x, double y, double z)
{
IPoint point = ConstructPoint2D(x, y);
point.Z = z;
return point;
}
public static IPoint ConstructPoint2D(double x, double y)
{
IPoint point = new PointClass();
point.PutCoords(x, y);
return point;
}