對於二三維同步中的三維視圖確定是須要經過二維元素來符號化成三維元素的,以前項目測試臨時採用這個自代的圓管狀:測試
esriSimple3DLineStyle AxisStyle = esriSimple3DLineStyle.esriS3DLSTube; 進行符號化,可是這個自帶樣式不能作更多的擴展,仍然須要對它進行手動 graphic,今天花了半天時間看了下官方的例子,總算是搗鼓出了將指定座標的兩個點連成的線符號化成正方體狀,中間也碰到一些問題。本覺得 arcengine提供了至關好的API,我只用傳入兩個點或是一根線,再給它一個Polygon,它就能幫我沿着這個線的方向畫成正方體了,但是弄來弄 去,不是位置不對,就是角度有問題,官方的例子過於簡單,拿到個人應用中根本不能使用,因而分析了一下緣由,採用如下三步:spa
第一步: 空間有根線,起點和終點確定能夠獲得,我要沿這個線符號化成立方體,那麼兩點的長度確定要用到。咱們就在座標原點沿Z座標畫一個立方體,高就是上面提到的線長。orm
第二步: 咱們假定這根線的起點爲(0,0,0),即我自定義的原點,經過IVector3D接口很容易獲得這根線的偏移角度。這樣就在原點把上面那個立方體給進行兩次旋轉獲得正確的線段走向。接口
第三步: 將第二步的立方體平移到起點位置,完工。get
- public static IGeometry getCubeTubeByLinePoint(IPoint fPoint, IPoint tPoint, double width, double height)
- {
-
-
-
- IVector3D tarPointV3D = GeometryUtilities.ConstructVector3D(tPoint.X - fPoint.X, tPoint.Y - fPoint.Y, tPoint.Z - fPoint.Z);
-
- IVector3D axisOfRotationVector3D_Y = GeometryUtilities.ConstructVector3D(0, 10, 0);
- IVector3D axisOfRotationVector3D_Z = GeometryUtilities.ConstructVector3D(0, 0, 10);
-
-
- ILine extrusionLine = new LineClass();
- extrusionLine.FromPoint = fPoint;
- extrusionLine.ToPoint = tPoint;
- double myToZ = extrusionLine.Length;
-
-
-
- IPointCollection polygonPointCollection = new PolygonClass();
- polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-(height / 2), (width / 2)),ref _missing, ref _missing);
- polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D((height / 2), (width / 2)), ref _missing, ref _missing);
- polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D((height / 2), -(width / 2)), ref _missing, ref _missing);
- polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-(height / 2), -(width / 2)), ref _missing, ref _missing);
-
- IPolygon polygon = polygonPointCollection as IPolygon;
- polygon.Close();
-
- IGeometry polygonGeometry = polygonPointCollection as IGeometry;
-
- ITopologicalOperator topologicalOperator = polygonGeometry as ITopologicalOperator;
- topologicalOperator.Simplify();
-
-
-
- IConstructMultiPatch constructMultiPatch = new MultiPatchClass();
- constructMultiPatch.ConstructExtrudeFromTo(0, myToZ, polygonGeometry);
-
-
- ITransform3D transform3D = constructMultiPatch as ITransform3D;
- transform3D.RotateVector3D(axisOfRotationVector3D_Y, tarPointV3D.Inclination);
- transform3D.RotateVector3D(axisOfRotationVector3D_Z, GeometryUtilities.GetRadians(90) - tarPointV3D.Azimuth);
-
-
- transform3D.Move3D(fPoint.X, fPoint.Y, fPoint.Z);
-
- return constructMultiPatch as IGeometry;
- }