Construct a MultiPatch by using an input (non-point) geometry as one base and offsetting the Zs already set on the input geometry to get the second base.
[Visual Basic .NET] Public Sub ConstructExtrude ( _ ByVal OffsetZ As Double, _ ByVal baseGeom As IGeometry _ )
[C#] public void ConstructExtrude ( double OffsetZ, IGeometry baseGeom );
[C++]
HRESULT ConstructExtrude(
double OffsetZ,
IGeometry* baseGeom
);
[C++]Parameters
OffsetZ OffsetZ is a parameter of type double baseGeombaseGeom is a parameter of type IGeometry
Product Availability
Description
Creates a MultiPatch from a base non-point geometry by extruding the base geometry along the Z-axis by a given offset factor. The base Z value of the geometry is preserved and top Z value is calculated as an offset of each point in the input geometry. The resulting extrusion is parallel to the XY-plane only if the base geometry is parallel to the XY-plane.
Remarks
All non-linear segments are treated as linear segments when extrusion is performed. Only Polylines, Polygons, and Envelopes are allowed as input geometries.
private static object _missing = Type.Missing;
public static IGeometry GetMultiPatchGeometry()
{
const int DensificationDivisions = 20;
const double MaxDeviation = 0.1;
const double BaseZ = 0;
const double OffsetZ = -7;
//Extrusion: 3D Polyline Having Vertices With Varying Z Values, Extruded Relative To Existing
// Vertex Z Values Via ConstructExtrude()
IPointCollection polylinePointCollection = new PolylineClass();
polylinePointCollection.AddPoint(ConstructPoint2D(-10, -10), ref _missing, ref _missing);
polylinePointCollection.AddPoint(ConstructPoint2D(0, -5), ref _missing, ref _missing);
polylinePointCollection.AddPoint(ConstructPoint2D(0, 5), ref _missing, ref _missing);
polylinePointCollection.AddPoint(ConstructPoint2D(10, 10), ref _missing, ref _missing);
IPolyline polyline = polylinePointCollection as IPolyline;
polyline.Densify(polyline.Length / DensificationDivisions, MaxDeviation);
IGeometry polylineGeometry = polyline as IGeometry;
MakeZAware(polylineGeometry);
Random random = new Random();
for (int i = 0; i < polylinePointCollection.PointCount; i++)
{
IPoint polylinePoint = polylinePointCollection.get_Point(i);
polylinePointCollection.UpdatePoint(i, ConstructPoint3D(polylinePoint.X, polylinePoint.Y, BaseZ - 2 * Math.Sin(random.NextDouble())));
}
ITopologicalOperator topologicalOperator = polylineGeometry as ITopologicalOperator;
topologicalOperator.Simplify();
IConstructMultiPatch constructMultiPatch = new MultiPatchClass();
constructMultiPatch.ConstructExtrude(OffsetZ, polylineGeometry);
return constructMultiPatch as IGeometry;
}
private static IVector3D ConstructVector3D(double xComponent, double yComponent, double zComponent)
{
IVector3D vector3D = new Vector3DClass();
vector3D.SetComponents(xComponent, yComponent, zComponent);
return vector3D;
}
private static double GetRadians(double decimalDegrees)
{
return decimalDegrees * (Math.PI / 180);
}
private static IPoint ConstructPoint3D(double x, double y, double z)
{
IPoint point = ConstructPoint2D(x, y);
point.Z = z;
return point;
}
private static IPoint ConstructPoint2D(double x, double y)
{
IPoint point = new PointClass();
point.PutCoords(x, y);
return point;
}
private static void MakeZAware(IGeometry geometry)
{
IZAware zAware = geometry as IZAware;
zAware.ZAware = true;
}
See Also
IConstructMultiPatch Interface | IExtrude.ExtrudeFromTo Method | IExtrude.ExtrudeAbsolute Method | IConstructMultiPatch Interface | IConstructMultiPatch.ConstructExtrudeRelative Method | IConstructMultiPatch.ConstructExtrude Method | IConstructMultiPatch.ConstructExtrudeAbsolute Method | IConstructMultiPatch.ConstructExtrudeFromTo Method | IExtrude.Extrude Method | IExtrude Interface | IExtrude.ExtrudeBetween Method | IExtrude.ExtrudeAlongLine Method | IConstructMultiPatch.ConstructExtrudeAlongLine Method | IExtrude.ExtrudeRelative Method | IConstructMultiPatch.ConstructExtrudeBetween Method | IGlobeHeightProperties.ExtrusionExpressionString Property