public static IGeometry GetExample5() { 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(GeometryUtilities.ConstructPoint3D(0.5 * (XRange + 2), -0.5 * (YRange + 2), 0), ref _missing, ref _missing); exteriorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-0.5 * (XRange + 2), -0.5 * (YRange + 2), 0), ref _missing, ref _missing); exteriorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-0.5 * (XRange + 2), 0.5 * (YRange + 2), 0), ref _missing, ref _missing); exteriorRingPointCollection.AddPoint(GeometryUtilities.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(GeometryUtilities.ConstructPoint3D(interiorRingOriginX - 0.5 * HoleRange, interiorRingOriginY - 0.5 * HoleRange, 0), ref _missing, ref _missing); interiorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(interiorRingOriginX + 0.5 * HoleRange, interiorRingOriginY - 0.5 * HoleRange, 0), ref _missing, ref _missing); interiorRingPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(interiorRingOriginX + 0.5 * HoleRange, interiorRingOriginY + 0.5 * HoleRange, 0), ref _missing, ref _missing); interiorRingPointCollection.AddPoint(GeometryUtilities.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); }
private void EndPatch() { object missing = Type.Missing; if (_currentPatch == null) { return; } var geometryCollection = (IGeometryCollection)_multiPatch; var ring = _currentPatch as IRing; if (ring != null) { ((IZAware)ring).ZAware = true; if (!ring.IsClosed) { ring.Close(); } else if (ring.FromPoint.Z != ring.ToPoint.Z) { ((IPointCollection)ring).AddPoint(ring.FromPoint, ref missing, ref missing); } } geometryCollection.AddGeometry(_currentPatch, ref missing, ref missing); if (ring != null && _currentRingType != esriMultiPatchRingType.esriMultiPatchRing) { _multiPatch.PutRingType(ring, _currentRingType); } _currentPatch = null; }
//---------------------------------------------------------------------------------- public static IGeometry MaakRingenMP() { IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass(); IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch; IPointCollection RingPointCollection; //Lees aantal ringen int aantalringen = ImportInArcscene.binReader.ReadInt32(); for (int i = 0; i < aantalringen; i++) { //Lees buitenringvlag Boolean buitenringvlag = leesboolean(); //Ringtype definieren esriMultiPatchRingType ringtype; if (buitenringvlag) { ringtype = esriMultiPatchRingType.esriMultiPatchOuterRing; } else { ringtype = esriMultiPatchRingType.esriMultiPatchInnerRing; } //Ring RingPointCollection = MaakRingPointCollection(); multiPatchGeometryCollection.AddGeometry(RingPointCollection as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(RingPointCollection as IRing, ringtype); } return(multiPatchGeometryCollection as IGeometry); }
protected static IMultiPatch CopyWithConvertedInnerRings( [NotNull] IMultiPatch multiPatch, [NotNull] IEnumerable <int> outerRingIndexes) { IMultiPatch result = GeometryFactory.Clone(multiPatch); var allFollowingRings = new List <IRing>(); foreach (int outerRingIndex in outerRingIndexes) { var ring = (IRing)((IGeometryCollection)result).Geometry[outerRingIndex]; int followingRingCount = result.FollowingRingCount[ring]; var followingRings = new IRing[followingRingCount]; GeometryUtils.GeometryBridge.QueryFollowingRings(result, ring, ref followingRings); allFollowingRings.AddRange(followingRings); } foreach (IRing followingRing in allFollowingRings) { result.PutRingType(followingRing, esriMultiPatchRingType.esriMultiPatchOuterRing); } return(result); }
public static IGeometry GetExample3() { //RingGroup: Upright Square With Hole IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass(); IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch; //Exterior Ring 1 IPointCollection exteriorRing1PointCollection = new RingClass(); exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 0, -5), ref _missing, ref _missing); exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 0, -5), ref _missing, ref _missing); exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 0, 5), ref _missing, ref _missing); exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 0, 5), ref _missing, ref _missing); IRing exteriorRing1 = exteriorRing1PointCollection as IRing; exteriorRing1.Close(); multiPatchGeometryCollection.AddGeometry(exteriorRing1 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(exteriorRing1, esriMultiPatchRingType.esriMultiPatchOuterRing); //Interior Ring 1 IPointCollection interiorRing1PointCollection = new RingClass(); interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 0, -4), ref _missing, ref _missing); interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 0, -4), ref _missing, ref _missing); interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 0, 4), ref _missing, ref _missing); interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 0, 4), ref _missing, ref _missing); IRing interiorRing1 = interiorRing1PointCollection as IRing; interiorRing1.Close(); multiPatchGeometryCollection.AddGeometry(interiorRing1 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(interiorRing1, esriMultiPatchRingType.esriMultiPatchInnerRing); return(multiPatchGeometryCollection as IGeometry); }
private static void AddRing(IMultiPatch result, Linestring closedLinestring, IRing ringTemplate, esriMultiPatchRingType ringType, int?pointId) { IRing ring = CreateRing(closedLinestring, ringTemplate); if (pointId != null) { GeometryUtils.AssignConstantPointID((IPointCollection)ring, pointId.Value); } ((IGeometryCollection)result).AddGeometry(ring); result.PutRingType(ring, ringType); }
/// <summary> /// 生成可视与不可视域的多面体 张琪 20110621 /// </summary> /// <param name="bIsVis">是否可视</param> /// <param name="pObsPt">观察点</param> /// <param name="pTarPt">目标点</param> /// <param name="pVisLine">可视线要素</param> /// <param name="pInVisLine">不可视线要素</param> /// <param name="pVisPatch">可视多面体</param> /// <param name="pInVisPatch">不可视多面体</param> /// <param name="dTargetHeight"></param> public void CreateVerticalLOSPatches(bool bIsVis, ESRI.ArcGIS.Geometry.IPoint pObsPt, ESRI.ArcGIS.Geometry.IPoint pTarPt, IPolyline pVisLine, IPolyline pInVisLine, IGeometryCollection pVisPatch, IGeometryCollection pInVisPatch, double dTargetHeight) { IGeometryCollection pGeomColl = pVisLine as IGeometryCollection; //存储可视域线要素 IMultiPatch pVisMPatch = pVisPatch as IMultiPatch; IMultiPatch pInVisMPatch = pInVisPatch as IMultiPatch; //生成不可视域要素 dTargetHeight = pTarPt.Z; double dist1 = 0; double dist2; IPointCollection pPc; IClone pClone; ESRI.ArcGIS.Geometry.IPoint pLastVisPoint = null; IPointCollection pVisFan = new TriangleFanClass();//用于存储可视域多面体要素 object before = Type.Missing; object after = Type.Missing; for (int i = 0; i < pGeomColl.GeometryCount; i++)//遍历可视域线要素 { pPc = pGeomColl.get_Geometry(i) as IPointCollection; if (i == 0)//当为第一个可视域线要素是先要存储观察点要素 { pClone = pObsPt as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pClone = pPc.get_Point(0) as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); ESRI.ArcGIS.Geometry.IPoint pStartPoint = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; } pClone = pPc as IClone; pVisFan.AddPointCollection(pClone.Clone() as IPointCollection); //将可视域线要素的点集合存储于pVisFan中 if (i == pGeomColl.GeometryCount - 1) //当为可视域最后一个线要素时 { IVector3D pV = new Vector3DClass(); ESRI.ArcGIS.Geometry.IPoint p1; pClone = pObsPt as IClone; p1 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p1.Z = 0; ESRI.ArcGIS.Geometry.IPoint p2; pClone = pPc.get_Point(pPc.PointCount - 1) as IClone; p2 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p2.Z = 0; pV.ConstructDifference(p1, p2); dist1 = pV.Magnitude; pLastVisPoint = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; if (pInVisLine == null) { if (pTarPt.Z > pPc.get_Point(pPc.PointCount - 1).Z)//当被观察点高程高于最后一点要素时则到被观点都是可视的 { pClone = pTarPt as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); } } } pVisPatch.AddGeometry(pVisFan as IGeometry, ref before, ref after); //根据获得的点要素集生成TriangleFanClass } if (pInVisLine != null) //当不可视域的线要素不为空时 { pGeomColl = pInVisLine as IGeometryCollection; IPointCollection pInVisRing = new RingClass();//用于存储不可视域点要素集并生成RingClass for (int i = 0; i < pGeomColl.GeometryCount; i++) { pPc = pGeomColl.get_Geometry(i) as IPointCollection; pClone = pPc.get_Point(0) as IClone; pInVisRing.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pClone = pPc as IClone; pInVisRing.AddPointCollection(pClone.Clone() as IPointCollection); if (i == pGeomColl.GeometryCount - 1) { IVector3D pV = new Vector3DClass(); pClone = pObsPt as IClone; ESRI.ArcGIS.Geometry.IPoint p1 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p1.Z = 0; pClone = pPc.get_Point(pPc.PointCount - 1) as IClone; ESRI.ArcGIS.Geometry.IPoint p2 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p2.Z = 0; pV.ConstructDifference(p1, p2); dist2 = pV.Magnitude; if (dist1 < dist2) { pClone = pObsPt as IClone; p1 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p1.Z = 0; pClone = pPc.get_Point(0) as IClone; p2 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p2.Z = 0; pV.ConstructDifference(p1, p2); double theDist1; theDist1 = pV.Magnitude; double slope = (pObsPt.Z - pPc.get_Point(0).Z) / theDist1; pClone = pPc.get_Point(pPc.PointCount - 1) as IClone; ESRI.ArcGIS.Geometry.IPoint pEndPoint = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p2 = pClone.Clone() as ESRI.ArcGIS.Geometry.IPoint; p2.Z = 0; pV.ConstructDifference(p1, p2); double theDist2 = pV.Magnitude; double deltaZ = theDist2 * slope; double theHeight = pObsPt.Z - deltaZ; pEndPoint.Z = theHeight; pClone = pEndPoint as IClone; pInVisRing.AddPoint(pClone.Clone() as IPoint, ref before, ref after); if (bIsVis)//为True时说明不可视域线要素空间范围内存在可视区域 { pVisFan = new TriangleFanClass(); pClone = pObsPt as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pClone = pTarPt as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pVisPatch.AddGeometry(pVisFan as IGeometry, ref before, ref after); } else { dTargetHeight = pEndPoint.Z; } } else { if (bIsVis) { if (pTarPt.Z > pLastVisPoint.Z) { pVisFan = new TriangleFanClass(); pClone = pObsPt as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pClone = pTarPt as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pClone = pLastVisPoint as IClone; pVisFan.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pVisPatch.AddGeometry(pVisFan as IGeometry, ref before, ref after); } } } } pClone = pPc.get_Point(0) as IClone; pInVisRing.AddPoint(pClone.Clone() as IPoint, ref before, ref after); pInVisPatch.AddGeometry(pInVisRing as IGeometry, ref before, ref after);//获取每段不可视域线要素点集合并生成RingClass pInVisMPatch.PutRingType(pInVisRing as IRing, esriMultiPatchRingType.esriMultiPatchRing); } } }
public static IGeometry GetExample2() { //RingGroup: Multiple Exterior Rings With Corresponding Interior Rings IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass(); IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch; //Exterior Ring 1 IPointCollection exteriorRing1PointCollection = new RingClass(); exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 1, 0), ref _missing, ref _missing); exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 4, 0), ref _missing, ref _missing); exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 4, 0), ref _missing, ref _missing); exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 1, 0), ref _missing, ref _missing); IRing exteriorRing1 = exteriorRing1PointCollection as IRing; exteriorRing1.Close(); multiPatchGeometryCollection.AddGeometry(exteriorRing1 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(exteriorRing1, esriMultiPatchRingType.esriMultiPatchOuterRing); //Interior Ring 1 IPointCollection interiorRing1PointCollection = new RingClass(); interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3.5, 1.5, 0), ref _missing, ref _missing); interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3.5, 3.5, 0), ref _missing, ref _missing); interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1.5, 3.5, 0), ref _missing, ref _missing); interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1.5, 1.5, 0), ref _missing, ref _missing); IRing interiorRing1 = interiorRing1PointCollection as IRing; interiorRing1.Close(); multiPatchGeometryCollection.AddGeometry(interiorRing1 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(interiorRing1, esriMultiPatchRingType.esriMultiPatchInnerRing); //Exterior Ring 2 IPointCollection exteriorRing2PointCollection = new RingClass(); exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, -1, 0), ref _missing, ref _missing); exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, -1, 0), ref _missing, ref _missing); exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, -4, 0), ref _missing, ref _missing); exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, -4, 0), ref _missing, ref _missing); IRing exteriorRing2 = exteriorRing2PointCollection as IRing; exteriorRing2.Close(); multiPatchGeometryCollection.AddGeometry(exteriorRing2 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(exteriorRing2, esriMultiPatchRingType.esriMultiPatchOuterRing); //Interior Ring 2 IPointCollection interiorRing2PointCollection = new RingClass(); interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1.5, -1.5, 0), ref _missing, ref _missing); interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3.5, -1.5, 0), ref _missing, ref _missing); interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3.5, -3.5, 0), ref _missing, ref _missing); interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1.5, -3.5, 0), ref _missing, ref _missing); IRing interiorRing2 = interiorRing2PointCollection as IRing; interiorRing2.Close(); multiPatchGeometryCollection.AddGeometry(interiorRing2 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(interiorRing2, esriMultiPatchRingType.esriMultiPatchInnerRing); //Exterior Ring 3 IPointCollection exteriorRing3PointCollection = new RingClass(); exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 1, 0), ref _missing, ref _missing); exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 1, 0), ref _missing, ref _missing); exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 4, 0), ref _missing, ref _missing); exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 4, 0), ref _missing, ref _missing); IRing exteriorRing3 = exteriorRing3PointCollection as IRing; exteriorRing3.Close(); multiPatchGeometryCollection.AddGeometry(exteriorRing3 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(exteriorRing3, esriMultiPatchRingType.esriMultiPatchOuterRing); //Interior Ring 3 IPointCollection interiorRing3PointCollection = new RingClass(); interiorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1.5, 1.5, 0), ref _missing, ref _missing); interiorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3.5, 1.5, 0), ref _missing, ref _missing); interiorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3.5, 3.5, 0), ref _missing, ref _missing); interiorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1.5, 3.5, 0), ref _missing, ref _missing); IRing interiorRing3 = interiorRing3PointCollection as IRing; interiorRing3.Close(); multiPatchGeometryCollection.AddGeometry(interiorRing3 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(interiorRing3, esriMultiPatchRingType.esriMultiPatchInnerRing); //Exterior Ring 4 IPointCollection exteriorRing4PointCollection = new RingClass(); exteriorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, -1, 0), ref _missing, ref _missing); exteriorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, -4, 0), ref _missing, ref _missing); exteriorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, -4, 0), ref _missing, ref _missing); exteriorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, -1, 0), ref _missing, ref _missing); IRing exteriorRing4 = exteriorRing4PointCollection as IRing; exteriorRing4.Close(); multiPatchGeometryCollection.AddGeometry(exteriorRing4 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(exteriorRing4, esriMultiPatchRingType.esriMultiPatchOuterRing); //Interior Ring 4 IPointCollection interiorRing4PointCollection = new RingClass(); interiorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1.5, -1.5, 0), ref _missing, ref _missing); interiorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1.5, -3.5, 0), ref _missing, ref _missing); interiorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3.5, -3.5, 0), ref _missing, ref _missing); interiorRing4PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3.5, -1.5, 0), ref _missing, ref _missing); IRing interiorRing4 = interiorRing4PointCollection as IRing; interiorRing4.Close(); multiPatchGeometryCollection.AddGeometry(interiorRing4 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(interiorRing4, esriMultiPatchRingType.esriMultiPatchInnerRing); return(multiPatchGeometryCollection as IGeometry); }
public static IGeometry GetExample4() { //RingGroup: Upright Square Composed Of Multiple Exterior Rings And Multiple Interior Rings IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass(); IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch; //Exterior Ring 1 IPointCollection exteriorRing1PointCollection = new RingClass(); exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 0, -5), ref _missing, ref _missing); exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 0, -5), ref _missing, ref _missing); exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 0, 5), ref _missing, ref _missing); exteriorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 0, 5), ref _missing, ref _missing); IRing exteriorRing1 = exteriorRing1PointCollection as IRing; exteriorRing1.Close(); multiPatchGeometryCollection.AddGeometry(exteriorRing1 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(exteriorRing1, esriMultiPatchRingType.esriMultiPatchOuterRing); //Interior Ring 1 IPointCollection interiorRing1PointCollection = new RingClass(); interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 0, -4), ref _missing, ref _missing); interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 0, -4), ref _missing, ref _missing); interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(4, 0, 4), ref _missing, ref _missing); interiorRing1PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-4, 0, 4), ref _missing, ref _missing); IRing interiorRing1 = interiorRing1PointCollection as IRing; interiorRing1.Close(); multiPatchGeometryCollection.AddGeometry(interiorRing1 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(interiorRing1, esriMultiPatchRingType.esriMultiPatchInnerRing); //Exterior Ring 2 IPointCollection exteriorRing2PointCollection = new RingClass(); exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, 0, -3), ref _missing, ref _missing); exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, 0, -3), ref _missing, ref _missing); exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-3, 0, 3), ref _missing, ref _missing); exteriorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(3, 0, 3), ref _missing, ref _missing); IRing exteriorRing2 = exteriorRing2PointCollection as IRing; exteriorRing2.Close(); multiPatchGeometryCollection.AddGeometry(exteriorRing2 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(exteriorRing2, esriMultiPatchRingType.esriMultiPatchOuterRing); //Interior Ring 2 IPointCollection interiorRing2PointCollection = new RingClass(); interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-2, 0, -2), ref _missing, ref _missing); interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(2, 0, -2), ref _missing, ref _missing); interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(2, 0, 2), ref _missing, ref _missing); interiorRing2PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-2, 0, 2), ref _missing, ref _missing); IRing interiorRing2 = interiorRing2PointCollection as IRing; interiorRing2.Close(); multiPatchGeometryCollection.AddGeometry(interiorRing2 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(interiorRing2, esriMultiPatchRingType.esriMultiPatchInnerRing); //Exterior Ring 3 IPointCollection exteriorRing3PointCollection = new RingClass(); exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 0, -1), ref _missing, ref _missing); exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 0, -1), ref _missing, ref _missing); exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 0, 1), ref _missing, ref _missing); exteriorRing3PointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 0, 1), ref _missing, ref _missing); IRing exteriorRing3 = exteriorRing3PointCollection as IRing; exteriorRing3.Close(); multiPatchGeometryCollection.AddGeometry(exteriorRing3 as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(exteriorRing3, esriMultiPatchRingType.esriMultiPatchOuterRing); return(multiPatchGeometryCollection as IGeometry); }
public void CanConvertMultipatchWithOuterInnerRingSequence() { ISpatialReference sr = SpatialReferenceUtils.CreateSpatialReference( WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LHN95); IRing outerRing0 = GeometryUtils.GetRings( GeometryFactory.CreatePolygon( 2601000, 1200000, 2602000, 1201000, 432)) .Single(); outerRing0.SpatialReference = sr; IRing outerRing1 = GeometryUtils.GetRings( GeometryFactory.CreatePolygon( 2600000, 1200000, 2601000, 1201000, 432)) .Single(); outerRing1.SpatialReference = sr; IRing innerRing = GeometryFactory.CreateRing(new[] { new WKSPointZ() { X = 2600100, Y = 1200100, Z = 432 }, new WKSPointZ() { X = 2600200, Y = 1200100, Z = 432 }, new WKSPointZ() { X = 2600200, Y = 1200200, Z = 432 }, new WKSPointZ() { X = 2600100, Y = 1200200, Z = 432 }, new WKSPointZ() { X = 2600100, Y = 1200100, Z = 432 }, }); innerRing.SpatialReference = sr; IMultiPatch multipatch = GeometryFactory.CreateEmptyMultiPatch(outerRing0); object emptyRef = Type.Missing; ((IGeometryCollection)multipatch).AddGeometry(outerRing0, ref emptyRef, ref emptyRef); multipatch.PutRingType(outerRing0, esriMultiPatchRingType.esriMultiPatchFirstRing); ((IGeometryCollection)multipatch).AddGeometry(outerRing1, ref emptyRef, ref emptyRef); multipatch.PutRingType(outerRing1, esriMultiPatchRingType.esriMultiPatchOuterRing); ((IGeometryCollection)multipatch).AddGeometry(innerRing, ref emptyRef, ref emptyRef); multipatch.PutRingType(innerRing, esriMultiPatchRingType.esriMultiPatchInnerRing); WkbGeometryWriter writer = new WkbGeometryWriter(); byte[] wkb = writer.WriteMultipatch(multipatch); WkbGeometryReader reader = new WkbGeometryReader(); IGeometry rehydrated = reader.ReadGeometry(new MemoryStream(wkb)); Assert.IsTrue(GeometryUtils.AreEqual(multipatch, rehydrated)); }
public static void CreateVerticalLOSPatches(bool bool_0, IPoint ipoint_0, IPoint ipoint_1, IPolyline ipolyline_0, IPolyline ipolyline_1, IGeometryCollection igeometryCollection_0, IGeometryCollection igeometryCollection_1, out double double_0) { int i; IPointCollection geometry; IClone point; IPointCollection triangleFanClass; IVector3D vector3DClass; IPoint point1; IPoint point2; object value = Missing.Value; IGeometryCollection ipolyline0 = ipolyline_0 as IGeometryCollection; IMultiPatch igeometryCollection1 = igeometryCollection_1 as IMultiPatch; double_0 = ipoint_1.Z; double magnitude = 0; IPoint point3 = null; for (i = 0; i < ipolyline0.GeometryCount; i++) { geometry = ipolyline0.Geometry[i] as IPointCollection; if (i == 0) { point = geometry.Point[0] as IClone; IPoint point4 = point.Clone() as IPoint; } point = geometry as IClone; triangleFanClass = new TriangleFan(); point = ipoint_0 as IClone; triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value); point = geometry as IClone; triangleFanClass.AddPointCollection(point.Clone() as IPointCollection); if (i == ipolyline0.GeometryCount - 1) { vector3DClass = new Vector3D() as IVector3D; point = ipoint_0 as IClone; point1 = point.Clone() as IPoint; point1.Z = 0; point = geometry.Point[geometry.PointCount - 1] as IClone; point2 = point.Clone() as IPoint; point2.Z = 0; vector3DClass.ConstructDifference(point1, point2); magnitude = vector3DClass.Magnitude; point3 = point.Clone() as IPoint; if (ipolyline_1 == null && ipoint_1.Z > geometry.Point[geometry.PointCount - 1].Z) { point = ipoint_1 as IClone; triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value); } } igeometryCollection_0.AddGeometry(triangleFanClass as IGeometry, ref value, ref value); } if (ipolyline_1 != null) { ipolyline0 = ipolyline_1 as IGeometryCollection; for (i = 0; i < ipolyline0.GeometryCount; i++) { geometry = ipolyline0.Geometry[i] as IPointCollection; point = geometry as IClone; IPointCollection ringClass = new Ring(); point = geometry as IClone; ringClass.AddPointCollection(point.Clone() as IPointCollection); if (i == ipolyline0.GeometryCount - 1) { vector3DClass = new Vector3D() as IVector3D; point = ipoint_0 as IClone; point1 = point.Clone() as IPoint; point1.Z = 0; point = geometry.Point[geometry.PointCount - 1] as IClone; point2 = point.Clone() as IPoint; point2.Z = 0; vector3DClass.ConstructDifference(point1, point2); if (magnitude < vector3DClass.Magnitude) { point = ipoint_0 as IClone; point1 = point.Clone() as IPoint; point1.Z = 0; point = geometry.Point[0] as IClone; point2 = point.Clone() as IPoint; point2.Z = 0; vector3DClass.ConstructDifference(point1, point2); double num = vector3DClass.Magnitude; double z = (ipoint_0.Z - geometry.Point[0].Z) / num; point = geometry.Point[geometry.PointCount - 1] as IClone; IPoint z1 = point.Clone() as IPoint; point2 = point.Clone() as IPoint; point2.Z = 0; vector3DClass.ConstructDifference(point1, point2); double magnitude1 = vector3DClass.Magnitude; z1.Z = ipoint_0.Z - magnitude1 * z; point = z1 as IClone; ringClass.AddPoint(point.Clone() as IPoint, ref value, ref value); if (!bool_0) { double_0 = z1.Z; } else { triangleFanClass = new TriangleFan(); point = ipoint_0 as IClone; triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value); point = ipoint_1 as IClone; triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value); point = z1 as IClone; triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value); igeometryCollection_0.AddGeometry(triangleFanClass as IGeometry, ref value, ref value); } } else if (bool_0 && ipoint_1.Z > point3.Z) { triangleFanClass = new TriangleFan(); point = ipoint_0 as IClone; triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value); point = ipoint_1 as IClone; triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value); point = point3 as IClone; triangleFanClass.AddPoint(point.Clone() as IPoint, ref value, ref value); igeometryCollection_0.AddGeometry(triangleFanClass as IGeometry, ref value, ref value); } } point = ringClass.Point[0] as IClone; ringClass.AddPoint(point.Clone() as IPoint, ref value, ref value); igeometryCollection_1.AddGeometry(ringClass as IGeometry, ref value, ref value); igeometryCollection1.PutRingType(ringClass as IRing, esriMultiPatchRingType.esriMultiPatchRing); } } }
public static IGeometry GetExample3() { //Composite: House Composed Of 7 Ring, 1 TriangleStrip, And 1 Triangles Parts IGeometryCollection multiPatchGeometryCollection = new MultiPatchClass(); IMultiPatch multiPatch = multiPatchGeometryCollection as IMultiPatch; //Base (Exterior Ring) IPointCollection basePointCollection = new RingClass(); basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 0), ref _missing, ref _missing); basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 0), ref _missing, ref _missing); basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 0), ref _missing, ref _missing); basePointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 0), ref _missing, ref _missing); basePointCollection.AddPoint(basePointCollection.get_Point(0), ref _missing, ref _missing); multiPatchGeometryCollection.AddGeometry(basePointCollection as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(basePointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing); //Front With Cutaway For Door (Exterior Ring) IPointCollection frontPointCollection = new RingClass(); frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 6), ref _missing, ref _missing); frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 0), ref _missing, ref _missing); frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 1, 0), ref _missing, ref _missing); frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 1, 4), ref _missing, ref _missing); frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -1, 4), ref _missing, ref _missing); frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -1, 0), ref _missing, ref _missing); frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 0), ref _missing, ref _missing); frontPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 6), ref _missing, ref _missing); frontPointCollection.AddPoint(frontPointCollection.get_Point(0), ref _missing, ref _missing); multiPatchGeometryCollection.AddGeometry(frontPointCollection as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(frontPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing); //Back (Exterior Ring) IPointCollection backPointCollection = new RingClass(); backPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 6), ref _missing, ref _missing); backPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 6), ref _missing, ref _missing); backPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 0), ref _missing, ref _missing); backPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 0), ref _missing, ref _missing); backPointCollection.AddPoint(backPointCollection.get_Point(0), ref _missing, ref _missing); multiPatchGeometryCollection.AddGeometry(backPointCollection as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(backPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing); //Right Side (Ring Group) //Exterior Ring IPointCollection rightSideExteriorPointCollection = new RingClass(); rightSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 6), ref _missing, ref _missing); rightSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 6), ref _missing, ref _missing); rightSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 0), ref _missing, ref _missing); rightSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 0), ref _missing, ref _missing); rightSideExteriorPointCollection.AddPoint(rightSideExteriorPointCollection.get_Point(0), ref _missing, ref _missing); multiPatchGeometryCollection.AddGeometry(rightSideExteriorPointCollection as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(rightSideExteriorPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing); //Interior Ring IPointCollection rightSideInteriorPointCollection = new RingClass(); rightSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 4, 4), ref _missing, ref _missing); rightSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, 4, 2), ref _missing, ref _missing); rightSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 4, 2), ref _missing, ref _missing); rightSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, 4, 4), ref _missing, ref _missing); rightSideInteriorPointCollection.AddPoint(rightSideInteriorPointCollection.get_Point(0), ref _missing, ref _missing); multiPatchGeometryCollection.AddGeometry(rightSideInteriorPointCollection as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(rightSideInteriorPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchInnerRing); //Left Side (Ring Group) //Exterior Ring IPointCollection leftSideExteriorPointCollection = new RingClass(); leftSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 6), ref _missing, ref _missing); leftSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 0), ref _missing, ref _missing); leftSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 0), ref _missing, ref _missing); leftSideExteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 6), ref _missing, ref _missing); leftSideExteriorPointCollection.AddPoint(leftSideExteriorPointCollection.get_Point(0), ref _missing, ref _missing); multiPatchGeometryCollection.AddGeometry(leftSideExteriorPointCollection as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(leftSideExteriorPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchOuterRing); //Interior Ring IPointCollection leftSideInteriorPointCollection = new RingClass(); leftSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, -4, 4), ref _missing, ref _missing); leftSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, -4, 4), ref _missing, ref _missing); leftSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-1, -4, 2), ref _missing, ref _missing); leftSideInteriorPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(1, -4, 2), ref _missing, ref _missing); leftSideInteriorPointCollection.AddPoint(leftSideInteriorPointCollection.get_Point(0), ref _missing, ref _missing); multiPatchGeometryCollection.AddGeometry(leftSideInteriorPointCollection as IGeometry, ref _missing, ref _missing); multiPatch.PutRingType(leftSideInteriorPointCollection as IRing, esriMultiPatchRingType.esriMultiPatchInnerRing); //Roof IPointCollection roofPointCollection = new TriangleStripClass(); roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 6), ref _missing, ref _missing); roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 6), ref _missing, ref _missing); roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 0, 9), ref _missing, ref _missing); roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 0, 9), ref _missing, ref _missing); roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 6), ref _missing, ref _missing); roofPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 6), ref _missing, ref _missing); multiPatchGeometryCollection.AddGeometry(roofPointCollection as IGeometry, ref _missing, ref _missing); //Triangular Area Between Roof And Front/Back IPointCollection triangularAreaPointCollection = new TrianglesClass(); //Area Between Roof And Front triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 0, 9), ref _missing, ref _missing); triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, 4, 6), ref _missing, ref _missing); triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(5, -4, 6), ref _missing, ref _missing); //Area Between Roof And Back triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 0, 9), ref _missing, ref _missing); triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, -4, 6), ref _missing, ref _missing); triangularAreaPointCollection.AddPoint(GeometryUtilities.ConstructPoint3D(-5, 4, 6), ref _missing, ref _missing); multiPatchGeometryCollection.AddGeometry(triangularAreaPointCollection as IGeometry, ref _missing, ref _missing); return(multiPatchGeometryCollection as IGeometry); }