Example #1
0
        /// <summary>
        /// 求导线(pRefPoint到pEndPoint)上的掘进点
        /// </summary>
        /// <params name="pRefPoint">参考导线点</params>
        /// <params name="pEndPoint">导线的终点</params>
        /// <params name="dDistance">距离参考导线点的距离</params>
        /// <returns>距参考导线点一定距离的点</returns>
        public static IPoint GetJJPoint(IPoint pRefPoint, IPoint pEndPoint, double dDistance)
        {
            if (pRefPoint.Z.Equals(Double.NaN))
            {
                pRefPoint.Z = 0;
            }

            if (pEndPoint.Z.Equals(Double.NaN))
            {
                pEndPoint.Z = 0;
            }

            IVector3D vector3D = new Vector3DClass();

            vector3D.ConstructDifference(pEndPoint, pRefPoint); //从参考点到导线终点的向量
            vector3D.Normalize();                               //向量单位化

            IPoint pJjPoint = new PointClass();

            pJjPoint.X = pRefPoint.X + dDistance * vector3D.XComponent;
            pJjPoint.Y = pRefPoint.Y + dDistance * vector3D.YComponent;
            pJjPoint.Z = pRefPoint.Z + dDistance * vector3D.ZComponent;

            return(pJjPoint);
        }
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            ICamera   scenecamera = (ICamera)m_sceneHookHelper.Camera;
            IVector3D pvector3D   = new Vector3DClass();

            pvector3D.ConstructDifference(scenecamera.Observer, scenecamera.Target);
            ISphere pShere = new SphereClass();

            pShere.Center = scenecamera.Target;
            pShere.Radius = scenecamera.ViewingDistance * Math.Tan(scenecamera.ViewFieldAngle * Math.PI / 180) * 0.5;
            IEnvelope penve = pShere.Envelope;

            m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds = penve;
            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
        //根据两点构建3D向量
        public static IVector3D CreateVector3DTwoPoints(IPoint toPoint, IPoint fromPoint)
        {
            if (fromPoint.Z.Equals(Double.NaN))
            {
                fromPoint.Z = 0;
            }
            if (toPoint.Z.Equals(Double.NaN))
            {
                toPoint.Z = 0;
            }
            IVector3D vector3D = new Vector3DClass();

            vector3D.ConstructDifference(toPoint, fromPoint);
            return(vector3D);
        }
Example #4
0
        /// <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);
                }
            }
        }
Example #5
0
        /// <summary>
        /// 求导线(pRefPoint到pEndPoint)上的掘进点
        /// </summary>
        /// <params name="pRefPoint">参考导线点</params>
        /// <params name="pEndPoint">导线的终点</params>
        /// <params name="dDistance">距离参考导线点的距离</params>
        /// <returns>距参考导线点一定距离的点</returns>
        public static IPoint GetJJPoint(IPoint pRefPoint, IPoint pEndPoint, double dDistance)
        {
            if (pRefPoint.Z.Equals(Double.NaN))
            {
                pRefPoint.Z = 0;
            }

            if (pEndPoint.Z.Equals(Double.NaN))
            {
                pEndPoint.Z = 0;
            }

            IVector3D vector3D = new Vector3DClass();
            vector3D.ConstructDifference(pEndPoint, pRefPoint); //从参考点到导线终点的向量
            vector3D.Normalize();  //向量单位化

            IPoint pJjPoint = new PointClass();
            pJjPoint.X = pRefPoint.X + dDistance * vector3D.XComponent;
            pJjPoint.Y = pRefPoint.Y + dDistance * vector3D.YComponent;
            pJjPoint.Z = pRefPoint.Z + dDistance * vector3D.ZComponent;

            return pJjPoint;
        }