public static void MakeConstantZ(IGeometry igeometry_0, double double_0) { if (igeometry_0 is IZ) { Utils3D.MakeZMAware(igeometry_0, true); IZ iZ = igeometry_0 as IZ; iZ.CalculateNonSimpleZs(); iZ.SetConstantZ(double_0); } }
public static void MakeOffsetZ(IGeometry igeometry_0, double double_0) { if (igeometry_0 is IZ) { GeometryOperator.MakeZMAware(igeometry_0, true); IZ igeometry0 = igeometry_0 as IZ; igeometry0.CalculateNonSimpleZs(); igeometry0.OffsetZs(double_0); } }
/// <summary> /// 裁切一个几何对象,不需要传出 /// </summary> /// <param name="shape"></param> /// <param name="geometryType"></param> /// <param name="ply"></param> /// <param name="geoObjNum"></param> /// <returns></returns> private bool ClipGeometry(ref IGeometry inGeometry, esriGeometryType geometryType, IPolygon clipPolygon, string GeoObjNum) { IPolycurve pPolyCurve; bool returnValue = false; IGeometry tempGeometry = null; IGeometry tempGeometry1 = null; ITopologicalOperator topologyOper = clipPolygon as ITopologicalOperator; topologyOper.Simplify(); IRelationalOperator relationOper = clipPolygon as IRelationalOperator; IZAware zIn = inGeometry as IZAware; IMAware mAware; IPoint pPoint, pPoint1; IPointCollection pPtC; ICurve pCurve; IGeometryCollection pGeoC; bool HasM = true; IHitTest pHitTest; double dblHitDist = 0; int partIndex = 0; int segmentIndex = 0; bool bRightSide = true; IPoint hitPoint = new PointClass(); //返回击中位置 IPath pPath; IPointCollection pPointC; IPoint P1, P2; switch (geometryType) { case esriGeometryType.esriGeometryPoint: //如果点包含在多边形中 if (relationOper.Contains(inGeometry)) { //tempGeometry = inGeometry; returnValue = true; } break; case esriGeometryType.esriGeometryPolyline: //'如果多义线穿越多边形或包含在多边形中 if (relationOper.Contains(inGeometry)) { returnValue = true; //tempGeometry = inGeometry; } else //if(relationOper.Crosses(inGeometry)) 2008.1.29 TianK 注释掉 解决了裁切丢数据的问题 { pPolyCurve = inGeometry as IPolycurve; pPolyCurve.Generalize(0.03); if (DIRECTIONLINE.IndexOf(GeoObjNum) != -1) //如果是有方向的线性地物 { pHitTest = (IHitTest)inGeometry; mAware = inGeometry as IMAware; ////2008.1.27TianK 修改 确保裁切后的线不反向 if (mAware.MAware == true) { HasM = true; pPtC = inGeometry as IPointCollection; for (int i = 0; i < pPtC.PointCount; i++) { pPoint = pPtC.get_Point(i); pPoint.M = i; pPtC.UpdatePoint(i, pPoint); } } else { HasM = false; mAware.MAware = true; pPtC = inGeometry as IPointCollection; for (int i = 0; i < pPtC.PointCount; i++) { pPoint = pPtC.get_Point(i); pPoint.M = i; pPtC.UpdatePoint(i, pPoint); } } tempGeometry1 = topologyOper.Intersect(inGeometry, esriGeometryDimension.esriGeometry1Dimension); tempGeometry = (inGeometry as ITopologicalOperator).Difference(tempGeometry1); ////2008.1.27TianK 修改 确保裁切后的线不反向 mAware = tempGeometry as IMAware; mAware.MAware = true; pGeoC = tempGeometry as IGeometryCollection; for (int j = 0; j < pGeoC.GeometryCount; j++) { pPtC = pGeoC.get_Geometry(j) as IPointCollection; pPoint = pPtC.get_Point(0); pPoint1 = pPtC.get_Point(pPtC.PointCount - 1); if (double.IsNaN(pPoint.M)) { if (pHitTest.HitTest(pPoint, 0.01, esriGeometryHitPartType.esriGeometryPartBoundary, hitPoint, ref dblHitDist, ref partIndex, ref segmentIndex, ref bRightSide)) //如果击中该要素 { pPath = (IPath)(inGeometry as IGeometryCollection).get_Geometry(partIndex); pPointC = (IPointCollection)pPath; //接口跳转 P1 = pPointC.get_Point(segmentIndex); P2 = pPointC.get_Point(segmentIndex + 1); AddM_P1_P2(P1, P2, ref pPoint); pPtC.UpdatePoint(0, pPoint); } } if (double.IsNaN(pPoint1.M)) { if (pHitTest.HitTest(pPoint1, 0.01, esriGeometryHitPartType.esriGeometryPartBoundary, hitPoint, ref dblHitDist, ref partIndex, ref segmentIndex, ref bRightSide)) //如果击中该要素 { pPath = (IPath)(inGeometry as IGeometryCollection).get_Geometry(partIndex); pPointC = (IPointCollection)pPath; //接口跳转 P1 = pPointC.get_Point(segmentIndex); P2 = pPointC.get_Point(segmentIndex + 1); AddM_P1_P2(P1, P2, ref pPoint1); pPtC.UpdatePoint(pPtC.PointCount - 1, pPoint1); } } pPoint = pPtC.get_Point(0); pPoint1 = pPtC.get_Point(pPtC.PointCount - 1); if (pPoint.M >= pPoint1.M) { pCurve = pGeoC.get_Geometry(j) as ICurve; pCurve.ReverseOrientation(); } if (HasM) { for (int i = 0; i < pPtC.PointCount; i++) { pPoint = pPtC.get_Point(i); pPoint.M = 0; pPtC.UpdatePoint(i, pPoint); } } else { mAware.MAware = false; } } } else { int i; IPoint p; tempGeometry1 = topologyOper.Intersect(inGeometry, esriGeometryDimension.esriGeometry1Dimension); tempGeometry = (inGeometry as ITopologicalOperator).Difference(tempGeometry1); } if (zIn.ZAware) { IZAware zOut = tempGeometry as IZAware; zOut.ZAware = zIn.ZAware; IZ iz = tempGeometry as IZ; try { iz.CalculateNonSimpleZs(); } catch { //该值应该传入,表示如果栽得的线如果不能插值出Z值赋一个默认值,或再次计算 //可以根据inGeometry计算 iz.SetConstantZ(0); } } } break; case esriGeometryType.esriGeometryMultipoint: case esriGeometryType.esriGeometryPolygon: //如果多边形与裁剪多边形相交或在裁剪多边形中 if (relationOper.Contains(inGeometry)) { //tempGeometry = inGeometry; returnValue = true; } else //if( relationOper.Overlaps(inGeometry)) 2008.1.29 TianK 注释掉 { pPolyCurve = inGeometry as IPolycurve; pPolyCurve.Generalize(0.03); tempGeometry1 = topologyOper.Intersect(inGeometry, esriGeometryDimension.esriGeometry2Dimension); tempGeometry = (inGeometry as ITopologicalOperator).Difference(tempGeometry1); if (zIn.ZAware) { IZAware zOut = tempGeometry as IZAware; zOut.ZAware = zIn.ZAware; IZ iz = tempGeometry as IZ; try { iz.CalculateNonSimpleZs(); } catch { //该值应该传入,表示如果栽得的线如果不能插值出Z值赋一个默认值,或再次计算 //可以根据inGeometry计算 iz.SetConstantZ(0); } } } break; } if (tempGeometry != null && !tempGeometry.IsEmpty) { inGeometry = tempGeometry; } return(returnValue); }