public static IMultiPatch EnvelopeToBoundingBox(IEnvelope2 ienvelope2_0) { object value = Missing.Value; double double_; double double_2; double double_3; double double_4; ienvelope2_0.QueryCoords(out double_, out double_2, out double_3, out double_4); double zMin = ienvelope2_0.ZMin; double zMax = ienvelope2_0.ZMax; IMultiPatch multiPatch = new MultiPatch() as IMultiPatch; IGeometryCollection geometryCollection = multiPatch as IGeometryCollection; IPointCollection pointCollection = new TriangleStrip(); Utils3D.MakeZMAware(pointCollection as IGeometry, true); pointCollection.AddPoint(Utils3D.Create3DPoint(double_, double_2, zMin), ref value, ref value); pointCollection.AddPoint(Utils3D.Create3DPoint(double_, double_2, zMax), ref value, ref value); pointCollection.AddPoint(Utils3D.Create3DPoint(double_3, double_2, zMin), ref value, ref value); pointCollection.AddPoint(Utils3D.Create3DPoint(double_3, double_2, zMax), ref value, ref value); pointCollection.AddPoint(Utils3D.Create3DPoint(double_3, double_4, zMin), ref value, ref value); pointCollection.AddPoint(Utils3D.Create3DPoint(double_3, double_4, zMax), ref value, ref value); pointCollection.AddPoint(Utils3D.Create3DPoint(double_, double_4, zMin), ref value, ref value); pointCollection.AddPoint(Utils3D.Create3DPoint(double_, double_4, zMax), ref value, ref value); pointCollection.AddPoint(Utils3D.Create3DPoint(double_, double_2, zMin), ref value, ref value); pointCollection.AddPoint(Utils3D.Create3DPoint(double_, double_2, zMax), ref value, ref value); geometryCollection.AddGeometry(pointCollection as IGeometry, ref value, ref value); return(multiPatch); }
public static IGroupElement CreateFacadesFromPolygon(IFeature ifeature_0, IFeature3DProperties ifeature3DProperties_0, clsTextureGroup clsTextureGroup_0, ISurface isurface_0, string string_0, IPolygon ipolygon_0, bool bool_0) { IGroupElement groupElement = null; IGroupElement result; try { IEncode3DProperties encode3DProperties = new GeometryEnvironment() as IEncode3DProperties; IGroupElement groupElement2 = new GroupElement() as IGroupElement; if (modFacades.m_limitAngle == 0.0) { modFacades.m_limitAngle = 0.5235987666666666; } IGeometry geometry = null; if (ifeature_0 != null) { if (ifeature3DProperties_0 != null && bool_0) { ifeature3DProperties_0.ApplyFeatureProperties(ifeature_0, out geometry, false); } else { geometry = ifeature_0.Shape; } } else if (ipolygon_0 != null) { geometry = ipolygon_0; } if (geometry == null) { result = null; return(result); } if (!(geometry is IMultiPatch)) { } IEnvelope envelope = geometry.Envelope; double num = envelope.ZMin; ISpatialReference spatialReference = BuildingProperty.Scene.SpatialReference; geometry.Project(spatialReference); string a = num.ToString(); if (a.Equals("非数字")) { num = 0.0; } double num2 = 0.0; if (ifeature3DProperties_0 != null) { I3DProperties i3DProperties = ifeature3DProperties_0 as I3DProperties; if (i3DProperties.OffsetExpressionString.Length > 0) { try { num2 = Convert.ToDouble(i3DProperties.OffsetExpressionString); } catch { } } if (geometry is IPolygon) { num += num2; } } IGeometryCollection geometryCollection = geometry as IGeometryCollection; int geometryCount = geometryCollection.GeometryCount; int num3; if (geometry is IMultiPatch) { geometryCount = geometryCollection.GeometryCount; num3 = geometryCollection.GeometryCount * 2 / 3; modFacades.m_extrusionHeight = geometry.Envelope.ZMax - geometry.Envelope.ZMin; } else { num3 = 0; geometryCount = geometryCollection.GeometryCount; } if (modFacades.m_extrusionHeight < 1.0) { modFacades.m_extrusionHeight = 1.0; } IPoint point = null; double num4 = 0.0; double num5 = 0.0; double num6 = 0.0; object value = Missing.Value; for (int i = num3; i < geometryCount; i++) { IGeometry geometry2 = geometryCollection.get_Geometry(i); esriGeometryType geometryType = geometry2.GeometryType; if (geometryType == esriGeometryType.esriGeometryRing || geometryType == esriGeometryType.esriGeometryPolyline) { IPointCollection pointCollection = geometry2 as IPointCollection; int pointCount = pointCollection.PointCount; if (pointCount >= 2) { int num7 = 0; int num8 = 1; bool flag = false; IPointCollection pointCollection2; double m; IMultiPatch multiPatch; IGeometryCollection geometryCollection2; IZAware iZAware; IMAware iMAware; IElement element; while (!flag) { bool flag2 = false; while (num8 < pointCount && !flag2) { if (num8 - num7 == 1) { IPoint point2 = pointCollection.get_Point(num7); point = pointCollection.get_Point(num8); num5 = point.X - point2.X; num6 = point.Y - point2.Y; num4 = Math.Sqrt(num5 * num5 + num6 * num6); if (isurface_0 != null) { num = isurface_0.get_Z(point.X, point.Y); num += num2; } } else { IPoint point2 = point; double num9 = num5; double num10 = num6; point = pointCollection.get_Point(num8); if (isurface_0 != null) { num = isurface_0.get_Z(point.X, point.Y); num += num2; } num5 = point.X - point2.X; num6 = point.Y - point2.Y; double num11 = Math.Sqrt(num9 * num9 + num10 * num10); double num12 = Math.Sqrt(num5 * num5 + num6 * num6); double num13 = (num9 * num5 + num10 * num6) / (num11 * num12); if (num13 < Math.Cos(modFacades.m_limitAngle)) { flag2 = true; break; } num4 += num12; } num8++; } if (flag2) { num8--; } else { num8--; } pointCollection2 = new TriangleStrip(); double num14 = 0.0; for (int j = num7; j <= num8; j++) { if (j > 0) { IPoint point2 = point; point = pointCollection.get_Point(j); num5 = point.X - point2.Y; num6 = point.Y - point2.Y; num14 += Math.Sqrt(num5 * num5 + num6 * num6); } else { point = pointCollection.get_Point(j); } point.Z = num; m = 0.0; encode3DProperties.PackTexture2D(num14 / num4, 0.0, out m); point.M = m; IClone clone = point as IClone; pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value); point.Z = num + modFacades.m_extrusionHeight; m = 0.0; encode3DProperties.PackTexture2D(num14 / num4, -1.0, out m); point.M = m; pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value); } multiPatch = new MultiPatch() as IMultiPatch; geometryCollection2 = (multiPatch as IGeometryCollection); iZAware = (multiPatch as IZAware); iZAware.ZAware = true; iMAware = (multiPatch as IMAware); iMAware.MAware = true; geometryCollection2.AddGeometry(pointCollection2 as IGeometry, ref value, ref value); if (clsTextureGroup_0 != null) { int index = modFacades.FindTextureByAspect(clsTextureGroup_0, num4 / modFacades.m_extrusionHeight); element = modFacades.CreateElement(multiPatch, clsTextureGroup_0.Symbols[index], string_0); } else { element = modFacades.CreateElement(multiPatch, null, string_0); } if (element != null) { groupElement2.AddElement(element); } num7 = num8; num8 = num7 + 1; if (num7 >= pointCount - 1) { flag = true; } } IVector3D vector3D = new Vector3D() as IVector3D; vector3D.XComponent = 0.0; vector3D.YComponent = 0.0; vector3D.ZComponent = 1.0; m = 0.0; encode3DProperties.PackNormal(vector3D, out m); pointCollection2 = new Ring(); for (int j = 0; j <= pointCount - 1; j++) { IPoint point3 = pointCollection.get_Point(j); point3.Z = num + modFacades.m_extrusionHeight; point3.M = 0.0; IClone clone = point3 as IClone; pointCollection2.AddPoint(clone.Clone() as IPoint, ref value, ref value); } IRing ring = pointCollection2 as IRing; ring.Close(); multiPatch = new MultiPatch() as IMultiPatch; geometryCollection2 = (multiPatch as IGeometryCollection); iZAware = (multiPatch as IZAware); iZAware.ZAware = true; iMAware = (multiPatch as IMAware); iMAware.MAware = true; geometryCollection2.AddGeometry(pointCollection2 as IGeometry, ref value, ref value); multiPatch.PutRingType(pointCollection2 as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing); if (clsTextureGroup_0 != null) { element = modFacades.CreateElement(multiPatch, clsTextureGroup_0.RoofSymbol, string_0 + ";ROOFCOLOR=" + clsTextureGroup_0.RoofColorRGB.ToString()); } else { element = modFacades.CreateElement(multiPatch, null, string_0 + ";ROOFCOLOR=1"); } if (element != null) { groupElement2.AddElement(element); } } } } if (groupElement2 != null) { IElementProperties elementProperties = groupElement2 as IElementProperties; elementProperties.Name = string_0; } groupElement = groupElement2; result = groupElement; return(result); } catch { } result = groupElement; return(result); }
public static IMultiPatch Cylinder(IPoint ipoint_0, double double_0, double double_1, double double_2, double double_3, double double_4, bool bool_0, bool bool_1) { double num = 36.0; object value = Missing.Value; double num2 = (double_2 - double_1) / num; double num3 = double_2 - double_1; IMultiPatch multiPatch = new MultiPatch() as IMultiPatch; IGeometryCollection geometryCollection = multiPatch as IGeometryCollection; IPointCollection pointCollection = new TriangleStrip(); IVector3D vector3D = new Vector3D() as IVector3D; IEncode3DProperties encode3DProperties = new GeometryEnvironment() as IEncode3DProperties; for (double num4 = double_2; num4 <= double_1; num4 += -num2) { double num5 = Utils3D.DegreesToRadians(num4); vector3D.PolarSet(-num5, 0.0, double_0); IPoint point = new Point(); point.X = ipoint_0.X + vector3D.XComponent; point.Y = ipoint_0.Y + vector3D.YComponent; point.Z = double_3; double num6 = (num4 - double_1) / num3; if (bool_0) { num6 = 1.0 + num6 * -1.0; } if (num6 <= 0.0) { num6 = 0.001; } else if (num6 >= 1.0) { num6 = 0.999; } double textureT; if (bool_1) { textureT = 0.0; } else { textureT = 1.0; } double m = 0.0; encode3DProperties.PackTexture2D(num6, textureT, out m); point.M = m; pointCollection.AddPoint(point, ref value, ref value); IClone clone = point as IClone; IPoint point2 = clone.Clone() as IPoint; point2.Z = double_4; if (bool_1) { textureT = 1.0; } else { textureT = 0.0; } m = 0.0; encode3DProperties.PackTexture2D(num6, textureT, out m); point2.M = m; pointCollection.AddPoint(point2, ref value, ref value); } IGeometry2 inGeometry = pointCollection as IGeometry2; geometryCollection.AddGeometry(inGeometry, ref value, ref value); IZAware iZAware = multiPatch as IZAware; iZAware.ZAware = true; IMAware iMAware = multiPatch as IMAware; iMAware.MAware = true; return(multiPatch); }