//private void FindFrcpt2AndTocpt2SweepLine(List<CAtBd> pSgAtBdLt, List<CAtBd> pBSAtBdLt, CParameterThreshold ParameterThreshold) //{ // double dblVerySmall = ParameterThreshold.dblVerySmall; // int intGIDCount = 0; // SortedSet<CPoint> EventQueueYGID = new SortedSet<CPoint>(new CCptYGIDReverseCompare()); // for (int i = 0; i < pSgAtBdLt.Count; i++) // { // CPoint cpt0 = pSgAtBdLt[i].CptLt[0]; // CPoint cptlast = pSgAtBdLt[i].CptLt[pSgAtBdLt[i].CptLt.Count - 1]; // cpt0.LID = i; // cpt0.GID = intGIDCount; // cpt0.strBelong = "Sg"; // EventQueueYGID.Add(cpt0); // intGIDCount++; // cptlast.LID = i; // cptlast.GID = intGIDCount; // cptlast.strBelong = "Sg"; // EventQueueYGID.Add(cptlast); // intGIDCount++; // } // for (int i = 0; i < pBSAtBdLt.Count; i++) // { // foreach (CPoint cpt in pBSAtBdLt[i].CptLt) // { // cpt.GID = intGIDCount; // cpt.LID = i; // cpt.strBelong = "BS"; // //BSCptLt.Add(cpt); // intGIDCount++; // //make two copies // CPoint ucpt = new CPoint(cpt.ID, cpt.X, cpt.Y + dblVerySmall); // ucpt.GID = intGIDCount; // ucpt.LID = cpt.LID; // ucpt.strBelong = cpt.strBelong; // ucpt.strSweepStatus = "Up"; // ucpt.CorrespondingPt = cpt; // EventQueueYGID.Add(ucpt); // intGIDCount++; // CPoint dcpt = new CPoint(cpt.ID, cpt.X, cpt.Y - dblVerySmall); // dcpt.GID = intGIDCount; // dcpt.LID = cpt.LID; // dcpt.strBelong = cpt.strBelong; // dcpt.strSweepStatus = "Down"; // dcpt.CorrespondingPt = cpt; // EventQueueYGID.Add(dcpt); // intGIDCount++; // } // } // //sweep // SortedSet<CPoint> StripCPtXGID = new SortedSet<CPoint>(new CCptXGIDCompare()); // //double dblSweepY = EventQueueYTD.ElementAt(0).Key.Y; // foreach (CPoint cpt in EventQueueYGID) // { // if (cpt.strBelong == "BS") // { // if (cpt.strSweepStatus == "Up") // { // StripCPtXGID.Add(cpt.CorrespondingPt); // } // else if (cpt.strSweepStatus == "Down") // { // StripCPtXGID.Remove(cpt.CorrespondingPt); // } // } // else // { // CPoint frcpt = new CPoint(-1, -1, cpt.X - dblVerySmall, cpt.Y); // CPoint tocpt = new CPoint(intGIDCount, intGIDCount, cpt.X + dblVerySmall, cpt.Y); // SortedSet<CPoint> StripView = StripCPtXGID.GetViewBetween(frcpt, tocpt); // foreach (CPoint cptview in StripView) // { // if (cpt.ID == 0) // { // pSgAtBdLt[cpt.LID].Frcpt2 = cptview; // } // else // { // pSgAtBdLt[cpt.LID].Tocpt2 = cptview; // } // break; // we only need one // } // frcpt = null; // tocpt = null; // } // } //} //private void FindFrcpt2AndTocpt2Grid(List<CAtBd> pSgAtBdLt, List<CAtBd> pBSAtBdLt, CParameterThreshold ParameterThreshold) //{ // List<CPolyline> SgCPlLt = CHelpFunc.GetCplLtFromAtBdLt(pSgAtBdLt); // List<CPolyline> BScpllt = CHelpFunc.GetCplLtFromAtBdLt(pBSAtBdLt); // IEnvelope pSgEnvelope = CHelpFunc.GetEnvelope(SgCPlLt); // IEnvelope pBSEnvelope = CHelpFunc.GetEnvelope(BScpllt); // IEnvelope pUnionEnvelope = new EnvelopeClass(); // pUnionEnvelope.XMin = Math.Min(pSgEnvelope.XMin, pBSEnvelope.XMin); // pUnionEnvelope.YMin = Math.Min(pSgEnvelope.YMin, pBSEnvelope.YMin); // pUnionEnvelope.XMax = Math.Max(pSgEnvelope.XMax, pBSEnvelope.XMax); // pUnionEnvelope.YMax = Math.Max(pSgEnvelope.YMax, pBSEnvelope.YMax); // int intSgPtNum = SgCPlLt.Count * 2; // int intBSPtNum = CHelpFunc.SumPointsNumber(BScpllt); // int intMaxPtNum = Math.Max(intSgPtNum, intBSPtNum); // int intRowColCount = Convert.ToInt32(Math.Sqrt(Convert.ToDouble(intMaxPtNum))); // double dblWidth = Math.Max((pUnionEnvelope.XMax - pUnionEnvelope.XMin) / Convert.ToDouble(intRowColCount), CConstants.dblVerySmall); // double dblHeight = Math.Max((pUnionEnvelope.YMax - pUnionEnvelope.YMin) / Convert.ToDouble(intRowColCount), CConstants.dblVerySmall); // intRowColCount++; //+1, so that the bordered point can be covered // C5.LinkedList<CPoint>[,] aSgCptLkGrid = new C5.LinkedList<CPoint>[intRowColCount, intRowColCount]; // C5.LinkedList<CPoint>[,] aBSCptLkGrid = new C5.LinkedList<CPoint>[intRowColCount, intRowColCount]; // for (int i = 0; i < intRowColCount; i++) // { // for (int j = 0; j < intRowColCount; j++) // { // aSgCptLkGrid[i, j] = new C5.LinkedList<CPoint>(); // aBSCptLkGrid[i, j] = new C5.LinkedList<CPoint>(); // } // } // //Fill points in Grids // for (int i = 0; i < pSgAtBdLt.Count; i++) // { // List<CPoint> cptlt = pSgAtBdLt[i].CptLt; // cptlt[0].BelongedCPolyline = pSgAtBdLt[i] as CPolyline; // cptlt[cptlt.Count - 1].BelongedCPolyline = pSgAtBdLt[i] as CPolyline; // CHelpFunc.FillCptinGrid(cptlt[0], dblWidth, dblHeight, pUnionEnvelope, aSgCptLkGrid); // CHelpFunc.FillCptinGrid(cptlt[cptlt.Count - 1], dblWidth, dblHeight, pUnionEnvelope, aSgCptLkGrid); // } // for (int i = 0; i < pBSAtBdLt.Count; i++) // { // List<CPoint> cptlt = pBSAtBdLt[i].CptLt; // foreach (CPoint cpt in cptlt) // { // cpt.LID = i; // CHelpFunc.FillCptinGrid(cpt, dblWidth, dblHeight, pUnionEnvelope, aBSCptLkGrid); // } // } // for (int i = 0; i < intRowColCount; i++) // { // for (int j = 0; j < intRowColCount; j++) // { // //the first column // int intJ = j - 1; // if (intJ >= 0) // { // //Lower // if (i - 1 >= 0) // { // LookingForNeighboursInGrid(ref aSgCptLkGrid[i, j], aBSCptLkGrid[i - 1, intJ], pSgAtBdLt, pBSAtBdLt, CConstants.dblVerySmall); // } // //Midle // LookingForNeighboursInGrid(ref aSgCptLkGrid[i, j], aBSCptLkGrid[i, intJ], pSgAtBdLt, pBSAtBdLt, CConstants.dblVerySmall); // //Upper // if (i + 1 < intRowColCount) // { // LookingForNeighboursInGrid(ref aSgCptLkGrid[i, j], aBSCptLkGrid[i + 1, intJ], pSgAtBdLt, pBSAtBdLt, CConstants.dblVerySmall); // } // } // //the second column // intJ = j; // //Lower // if (i - 1 >= 0) // { // LookingForNeighboursInGrid(ref aSgCptLkGrid[i, j], aBSCptLkGrid[i - 1, intJ], pSgAtBdLt, pBSAtBdLt, CConstants.dblVerySmall); // } // //Midle // LookingForNeighboursInGrid(ref aSgCptLkGrid[i, j], aBSCptLkGrid[i, intJ], pSgAtBdLt, pBSAtBdLt, CConstants.dblVerySmall); // //Upper // if (i + 1 < intRowColCount) // { // LookingForNeighboursInGrid(ref aSgCptLkGrid[i, j], aBSCptLkGrid[i + 1, intJ], pSgAtBdLt, pBSAtBdLt, CConstants.dblVerySmall); // } // //the third column // intJ = j + 1; // if (intJ < intRowColCount) // { // //Lower // if (i - 1 >= 0) // { // LookingForNeighboursInGrid(ref aSgCptLkGrid[i, j], aBSCptLkGrid[i - 1, intJ], pSgAtBdLt, pBSAtBdLt, CConstants.dblVerySmall); // } // //Midle // LookingForNeighboursInGrid(ref aSgCptLkGrid[i, j], aBSCptLkGrid[i, intJ], pSgAtBdLt, pBSAtBdLt, CConstants.dblVerySmall); // //Upper // if (i + 1 < intRowColCount) // { // LookingForNeighboursInGrid(ref aSgCptLkGrid[i, j], aBSCptLkGrid[i + 1, intJ], pSgAtBdLt, pBSAtBdLt, CConstants.dblVerySmall); // } // } // } // } //} //private void LookingForNeighboursInGrid(ref C5.LinkedList<CPoint> SgCptLkGrid, C5.LinkedList<CPoint> BSCptLkGrid, List<CAtBd> pSgAtBdLt, List<CAtBd> pBSAtBdLt, double dblVerySmall) //{ // foreach (CPoint Sgcpt in SgCptLkGrid) // { // if (Sgcpt.CorrespondingPt == null) // { // foreach (CPoint BScpt in BSCptLkGrid) // { // if (Sgcpt.Equals2D(BScpt, dblVerySmall) == true) // { // Sgcpt.CorrespondingPt = BScpt; // if (Sgcpt.ID == 0) // { // //Sgcpt. // pSgAtBdLt[Sgcpt.LID].Frcpt2 = BScpt; // //pSgAtBdLt[Sgcpt.LID].pFrAtBd = pBSAtBdLt[BScpt.LID]; // } // else // { // pSgAtBdLt[Sgcpt.LID].Tocpt2 = BScpt; // //pSgAtBdLt[Sgcpt.LID].pToAtBd = pBSAtBdLt[BScpt.LID]; // } // break; // we only need one // } // } // } // } //} #endregion /// <summary> /// /// </summary> /// <param name="pBSAtBdLt"></param> /// <param name="pSSAtBdLt"></param> /// <param name="ParameterThreshold"></param> /// <remarks>the number of Administrative Boundaries in pBSAtBdLt and that in pSSAtBdLt are the same.Besides, the topological structrues are the same</remarks> private double CalRatioofPtNum(List <CAtBd> pBSAtBdLt, List <CAtBd> pSSAtBdLt, CParameterThreshold ParameterThreshold) { int intBSInnerPtNum = 0; int intSSInnerPtNum = 0; List <CPoint> BSEndPtLt = new List <CPoint>(pBSAtBdLt.Count * 2); //List<CPoint> SSEndPtLt = new List<CPoint>(); for (int i = 0; i < pBSAtBdLt.Count; i++) { intBSInnerPtNum += (pBSAtBdLt[i].CptLt.Count - 2); intSSInnerPtNum += (pSSAtBdLt[i].CptLt.Count - 2); BSEndPtLt.Add(pBSAtBdLt[i].CptLt[0]); BSEndPtLt.Add(pBSAtBdLt[i].CptLt[pBSAtBdLt[i].CptLt.Count - 1]); } var CorrCptsLt = CGeoFunc.LookingForNeighboursByGrids(BSEndPtLt, CConstants.dblVerySmallCoord); int intIntersection = CGeoFunc.GetNumofIntersections(CorrCptsLt); //do we need this?******************************************************************************* //int intAloneEnds = CGeoFunc.GetNumofAloneEnds(EndPtLt, CorrCptsLt); //int intRealPtNum = intInnerPtNum + intSgIntersection + intAloneEnds; //notice that there are the same intersections of the larger-scale polylines and the smaller-scale polylines int intBSRealPtNum = intBSInnerPtNum + intIntersection; int intSSRealPtNum = intSSInnerPtNum + intIntersection; double dblRatioofPtNum = Convert.ToDouble(intBSRealPtNum) / Convert.ToDouble(intSSRealPtNum); return(dblRatioofPtNum); }
private void btnStatistic_Click(object sender, EventArgs e) { double dblProp = 0; List <double> dbllt = new List <double>(); List <CPoint> CResultPtLt = _DataRecords.ParameterResult.CResultPtLt; for (int i = 0; i <= 100; i++) { CPolyline cpl = CGeoFunc.GetTargetcpl(CResultPtLt, dblProp); dbllt.Add(cpl.pPolyline.Length); dblProp = dblProp + 0.01; } CHelpFuncExcel.ExportDataltToExcel(dbllt, "Length", _DataRecords.ParameterInitialize.strSavePath); //if (dblProp < 0 || dblProp > 1) //{ // MessageBox.Show("请输入正确参数!"); // return null; //} //List<CPoint> CResultPtLt = pDataRecords.ParameterResult.CResultPtLt; //CPolyline cpl = this.CGeoFunc.GetTargetcpl(CResultPtLt, dblProp); //// 清除绘画痕迹 //IMapControl4 m_mapControl = pDataRecords.ParameterInitialize.m_mapControl; //IGraphicsContainer pGra = m_mapControl.Map as IGraphicsContainer; //pGra.DeleteAllElements(); //m_mapControl.ActiveView.Refresh(); //this.ViewPolyline(m_mapControl, cpl); //显示生成的线段 //return cpl; }
/// <summary> /// from time t to n-1 /// </summary> /// <param name="crg"></param> /// <returns></returns> private IEnumerable <double> EstimateMinComp_EdgeNumber(CRegion crg, CRegion lscrg) { var intEdgeCountSS = new SortedSet <int>(new CIntCompare()); foreach (var pCorrCphs in crg.AdjCorrCphsSD.Keys) { intEdgeCountSS.Add(pCorrCphs.intSharedCEdgeCount); } IEnumerator <int> intEdgeCountSSEt = intEdgeCountSS.GetEnumerator(); int intEdgeCountAtmost = crg.intExteriorEdgeCount + 2 * crg.intInteriorEdgeCount; int intEstCount = crg.GetCphCount(); while (intEstCount > 1) { intEdgeCountSSEt.MoveNext(); //if intEstCount == lscrg.GetCphCount(), we are estimating from the start map (t==1) //we define that the estimation value of the start map is 0, therefore we skip intEstCount == lscrg.GetCphCount() if (intEstCount < lscrg.GetCphCount()) { int intAverageEdgeCount = Convert.ToInt32( Math.Floor(Convert.ToDouble(intEdgeCountAtmost) / Convert.ToDouble(intEstCount))); yield return(CGeoFunc.CalCompRegularPolygon(intAverageEdgeCount)); } intEdgeCountAtmost -= (2 * intEdgeCountSSEt.Current); intEstCount--; } }
//public override void JudgeAndFormCEdgeLt() //{ // if (this.CEdgeLt == null) // { // FormCEdgeLt(); // } //} /// <summary> /// /// </summary> /// <returns></returns> /// <remarks>SetPolygon will first set IPoint</remarks> public IPolygon4 SetPolygon() { //Build a polygon segment-by-segment. IPolygon4 polygon = new PolygonClass(); IGeometryCollection geometryCollection = (IGeometryCollection)polygon; var exteriorCptLt = this.CptLt; if (CGeoFunc.IsClockwise(exteriorCptLt, true) == false) { exteriorCptLt = exteriorCptLt.AsEnumerable().Reverse().ToList(); //this will not change this.CptLt } geometryCollection.AddGeometry(CGeoFunc.GetIrgFromCptLt(exteriorCptLt)); //add the holes if (this.HoleCpgLt != null) { foreach (var holecpg in this.HoleCpgLt) { var interiorCptLt = holecpg.CptLt; if (CGeoFunc.IsClockwise(exteriorCptLt, true) == true) { interiorCptLt = interiorCptLt.AsEnumerable().Reverse().ToList(); //this will not change holecpg.CptLt } geometryCollection.AddGeometry(CGeoFunc.GetIrgFromCptLt(interiorCptLt)); } } //polygon.Close(); this.pPolygon = polygon; return(polygon); }
public static bool IsCutValid(List <CPoint> cptlt, CEdgeGrid pEdgeGrid, double dblThreshold, out int intIndexMaxDis) { var tplWithinTDis = IsWithinTDis(cptlt, dblThreshold); intIndexMaxDis = tplWithinTDis.Item2; if (tplWithinTDis.Item1 == false) { return(false); } //if the baseline is outside of the polygon, then the baseline is not a valid choice throw new ArgumentException( "IsClockwise is not helpful. instead test if the edge between the two edges. see CCptbCtgl"); if (CGeoFunc.IsClockwise(cptlt, false) == false) { return(false); } var cedgebaseline = new CEdge(cptlt[0], cptlt.Last()); //we don't test the four edges var IgnoreCEdgeSS = new SortedSet <CEdge> { cedgebaseline.FrCpt.InCEdge, cedgebaseline.FrCpt.OutCEdge, cedgebaseline.ToCpt.InCEdge, cedgebaseline.ToCpt.OutCEdge }; var blnIntersect = pEdgeGrid.BlnIntersect(cedgebaseline, true, true, true, IgnoreCEdgeSS); return(!blnIntersect); }
/// <summary> /// 插入一定数量的点 /// </summary> /// <param name="cptlt">点列</param> /// <param name="intInsertNum">需插入点的数量</param> private void InsertVertex(List<CPoint> cptlt, int intInsertNum) { //将每个点及与其之前点的距离存入按距离从小到大存入数组 SortedList<double, CPoint> dblDisLt = new SortedList<double, CPoint>(new CCmpDbl()); for (int i = 1; i < cptlt.Count; i++) { double dblDis = CGeoFunc.CalDis(cptlt[i - 1], cptlt[i]); dblDisLt.Add(dblDis, cptlt[i]); } //插入intInsertNum个点(每次在最长边的中点插入点) for (int i = 0; i < intInsertNum; i++) { CPoint cpt0 = dblDisLt.Values[dblDisLt.Values.Count -1]; int intIndex = cptlt.IndexOf(cpt0); //创建要插入的点 double dblnewX = (cptlt[intIndex - 1].X + cptlt[intIndex].X) / 2; double dblnewY = (cptlt[intIndex - 1].Y + cptlt[intIndex].Y) / 2; CPoint newcpt = new CPoint(0, dblnewX, dblnewY); newcpt.CorrespondingPtLt = new List<CPoint>(); cptlt.Insert(intIndex, newcpt);//插入点 //删除原来的点及距离记录,插入两个新记录 double dblnewDis = dblDisLt.Keys[dblDisLt.Values.Count - 1] / 2; dblDisLt.RemoveAt(dblDisLt.Values.Count - 1); dblDisLt.Add(dblnewDis, newcpt); dblDisLt.Add(dblnewDis, cpt0); } }
public void CGABM() { List <CPolyline> pInterLSCPlLt = this.ObjCGeoLtLt[0].AsExpectedClassEb <CPolyline, CGeoBase>().ToList(); List <CPolyline> pInterSSCPlLt = this.ObjCGeoLtLt[1].AsExpectedClassEb <CPolyline, CGeoBase>().ToList(); List <CPolyline> pInterLSSgCPlLt = this.ObjCGeoLtLt[2].AsExpectedClassEb <CPolyline, CGeoBase>().ToList(); List <CPolyline> pInterSSSgCPlLt = this.ObjCGeoLtLt[3].AsExpectedClassEb <CPolyline, CGeoBase>().ToList(); _CorrCptsLtLt = CGeoFunc.GetCorrCptsLtLt(pInterLSCPlLt, pInterSSCPlLt); _SgCorrCptsLtLt = CGeoFunc.GetCorrCptsLtLt(pInterLSSgCPlLt, pInterSSSgCPlLt); CHelpFunc.SetMoveVectorForCorrCptsLtLt(_CorrCptsLtLt); CHelpFunc.SetMoveVectorForCorrCptsLtLt(_SgCorrCptsLtLt); //to save memory this.ObjCGeoLtLt[0] = null; this.ObjCGeoLtLt[1] = null; this.ObjCGeoLtLt[2] = null; this.ObjCGeoLtLt[3] = null; //CTranslation pTranslation=new CTranslation (); //double dblSum = pTranslation.CalTranslationCorr(_CorrCptsLtLt); //double dblSumSg = pTranslation.CalTranslationCorr(_SgCorrCptsLtLt); }
/// <summary> /// Deflection (i.e. the integral distance between two line segments) /// </summary> /// <param name="LastCorrCpts">the last pair of corresponding points</param> /// <param name="CurrentCorrCpts">the current pair of corresponding points</param> /// <param name="pStandardVectorCpt"></param> /// <returns>the integral distance between the two line segments</returns> private static double CalDeflection(CCorrCpts LastCorrCpts, CCorrCpts CurrentCorrCpts, double dblFrTotalLength, double dblToTotalLength) { double dblfrlength = CGeoFunc.CalDis(LastCorrCpts.FrCpt, CurrentCorrCpts.FrCpt); double dbltolength = CGeoFunc.CalDis(LastCorrCpts.ToCpt, CurrentCorrCpts.ToCpt); return(CalDeflectionSub(LastCorrCpts, CurrentCorrCpts, dblfrlength, dbltolength)); }
/// <summary> /// /// </summary> /// <param name="cptlt"></param> /// <param name="pEnvelopeLayer"></param> /// <param name="pEnvelopeIpe"></param> /// <param name="dblFactor"></param> /// <param name="intSubtract">In ipe, the first vertex and the last vertex are not identical. /// Therefore, 0 if shape is polyline, 1 if shape is polygon</param> /// <returns></returns> /// <remarks> ///*********************polyline***************************** ///<path stroke="1 0.643 0.161" pen="fat"> ///96 192 m ///160 144 l ///208 224 l ///</path> ///*********************multi polylines***************************** ///<path stroke="0 1 0.161" pen="fat"> ///96 96 m ///112 32 l ///176 48 l ///208 112 l ///256 80 m ///256 32 l ///304 32 l ///336 80 l ///</path> ///*********************polygon****************************************** ///<path stroke="1 0.643 0.208" fill="0.212 0.388 0.047" pen="fat"> ///400 224 m ///352 128 l ///448 80 l ///544 192 l ///h ///</path> ///*********************polygon with two holes********************* ///<path stroke="1 0.2 0.502" fill="0.094 1 0" pen="fat"> ///400 224 m ///352 128 l ///448 80 l ///544 192 l ///h ///416 176 m ///384 160 l ///416 128 l ///h ///448 192 m ///448 144 l ///496 176 l ///h ///</path> /// </remarks> public static string AddCoordinates(List <CPoint> cptlt, IEnvelope pEnvelopeLayer, CEnvelope pEnvelopeIpe, double dblFactor, int intSubtract = 0) { int intRealCount = cptlt.Count - intSubtract; double[] dblx = new double[intRealCount]; double[] dbly = new double[intRealCount]; for (int i = 0; i < intRealCount; i++) { dblx[i] = CGeoFunc.CoordinateTransform( cptlt[i].X, pEnvelopeLayer.XMin, pEnvelopeIpe.XMin, dblFactor); dbly[i] = CGeoFunc.CoordinateTransform( cptlt[i].Y, pEnvelopeLayer.YMin, pEnvelopeIpe.YMin, dblFactor); } string str = AddXY(dblx[0], dbly[0]) + " m\n"; for (int j = 1; j < dblx.Length; j++) { str += AddXY(dblx[j], dbly[j]) + " l\n"; } return(str); }
/// <summary> /// 显示并返回多个插值线段 /// </summary> /// <param name="pDataRecords">数据记录</param> /// <param name="dblProp">差值参数</param> /// <returns>插值线段</returns> public static List <CPolyline> DisplayInterpolations(CDataRecords pDataRecords, double dblProp) { if (dblProp < 0 || dblProp > 1) { MessageBox.Show("请输入正确参数!"); return(null); } List <List <CPoint> > CResultPtLtLt = pDataRecords.ParameterResult.CResultPtLtLt; List <CPolyline> cpllt = new List <CPolyline>(); for (int i = 0; i < CResultPtLtLt.Count; i++) { CPolyline cpl = CGeoFunc.GetTargetcpl(CResultPtLtLt[i], dblProp); cpllt.Add(cpl); } // 清除绘画痕迹 IMapControl4 m_mapControl = pDataRecords.ParameterInitialize.m_mapControl; IGraphicsContainer pGra = m_mapControl.Map as IGraphicsContainer; pGra.DeleteAllElements(); //m_mapControl.ActiveView.Refresh(); //由于在下一步“ViewPolyline”中有刷新的命令,此语句可省略 ViewPolylines(m_mapControl, cpllt); //显示生成的线段 return(cpllt); }
private CPolygon DetectFaceForSg(CPolyline SgCpl, CDCEL pInterLSDCEL) { var identitycpt = CGeoFunc.GetInbetweenCpt(SgCpl.CptLt[0], SgCpl.CptLt[1], 0.5); //comparing to the method which traverses along DCEL, this method only needs to detect the face once return(pInterLSDCEL.DetectCloestLeftCorrectCEdge(identitycpt).cpgIncidentFace); }
public void SetAxisAngleAndReverseLt() { var cpg = this; cpg.JudgeAndFormCEdgeLt(); cpg.CEdgeLt.ForEach(cedge => cedge.JudgeAndSetAxisAngle()); var fAxisAngleLt = new List <double>(cpg.CEdgeLt.Count); foreach (var cedge in this.CEdgeLt) { cedge.JudgeAndSetAxisAngle(); fAxisAngleLt.Add(cedge.dblAxisAngle); } //the index of ReverseAxisAngleLt indicates the index of the starting point var fReverseAxisAngleLt = new List <double>(cpg.CEdgeLt.Count); fReverseAxisAngleLt.Add(CGeoFunc.CalReversedCEdgeAxisAngle(fAxisAngleLt.Last())); for (int i = 1; i < fAxisAngleLt.Count; i++) { fReverseAxisAngleLt.Add(CGeoFunc.CalReversedCEdgeAxisAngle(fAxisAngleLt[i - 1])); } this.AxisAngleLt = fAxisAngleLt; this.ReverseAxisAngleLt = fReverseAxisAngleLt; }
private CPolyline DisplayInterpolation(double dblProp, IMapControl4 m_mapControl) { List <CCorrCpts> pCorrCptsLt = _DataRecords.ParameterResult.CCorrCptsLt; int intPtNum = pCorrCptsLt.Count; List <CPoint> newcptlt = new List <CPoint>(); //先确定最后两个点 double dblLastX = (1 - dblProp) * pCorrCptsLt[intPtNum - 1].FrCpt.X + dblProp * pCorrCptsLt[intPtNum - 1].ToCpt.X; double dblLastY = (1 - dblProp) * pCorrCptsLt[intPtNum - 1].FrCpt.Y + dblProp * pCorrCptsLt[intPtNum - 1].ToCpt.Y; CPoint newlastcpt = new CPoint(intPtNum - 1, dblLastX, dblLastY); double dblLast1X = (1 - dblProp) * pCorrCptsLt[intPtNum - 2].FrCpt.X + dblProp * pCorrCptsLt[intPtNum - 2].ToCpt.X; double dblLast1Y = (1 - dblProp) * pCorrCptsLt[intPtNum - 2].FrCpt.Y + dblProp * pCorrCptsLt[intPtNum - 2].ToCpt.Y; CPoint newlast1cpt = new CPoint(intPtNum - 2, dblLast1X, dblLast1Y); newcptlt.Insert(0, newlastcpt); newcptlt.Insert(0, newlast1cpt); double dblPreAxisAngle = CGeoFunc.CalAxisAngle(newlast1cpt, newlastcpt); //前一个线段的绝对角 for (int i = pCorrCptsLt.Count - 3; i >= 0; i--) { //目标夹角大小 double dblAngle = (1 - dblProp) * _adblFrAngle[i] + dblProp * _adblToAngle[i]; //绝对角 double dblCurAxisAngle = dblPreAxisAngle - dblAngle; //当前线段的绝对角(0到2*PI) if (dblCurAxisAngle >= 2 * Math.PI) { dblCurAxisAngle = dblCurAxisAngle - 2 * Math.PI; } else if (dblCurAxisAngle < 0) { dblCurAxisAngle = dblCurAxisAngle + 2 * Math.PI; } //目标长度 double dblLength = (1 - dblProp) * _adblFrLength[i] + dblProp * _adblToLength[i]; //新坐标 double dblNewX = newcptlt[0].X + dblLength * Math.Cos(dblCurAxisAngle); double dblNewY = newcptlt[0].Y + dblLength * Math.Sin(dblCurAxisAngle); CPoint newcpt = new CPoint(i, dblNewX, dblNewY); newcptlt.Insert(0, newcpt); //更新dblPreAxisAngle(将向量旋转180°) if (dblCurAxisAngle >= Math.PI) { dblPreAxisAngle = dblCurAxisAngle - Math.PI; } else { dblPreAxisAngle = dblCurAxisAngle + Math.PI; } } CPolyline newcpl = new CPolyline(0, newcptlt); IGraphicsContainer pGra = m_mapControl.Map as IGraphicsContainer; pGra.DeleteAllElements(); CHelpFunc.ViewPolyline(m_mapControl, newcpl); return(newcpl); }
private void FindFrcpt2AndTocpt2Grid(List <CAtBd> pSgAtBdLt, List <CAtBd> pBSAtBdLt, CParameterThreshold ParameterThreshold) { //SgCptLt for pSgAtBdLt List <CPoint> SgCptLt = new List <CPoint>(pSgAtBdLt.Count * 2); foreach (CAtBd pAtBd in pSgAtBdLt) { CPoint cpt0 = pAtBd.CptLt[0]; cpt0.BelongedObject = pAtBd; CPoint cptlast = pAtBd.CptLt[pAtBd.CptLt.Count - 1]; cptlast.BelongedObject = pAtBd; SgCptLt.Add(cpt0); SgCptLt.Add(cptlast); } //BSCptLt for pBSAtBdLt int intCount = 0; foreach (CAtBd pAtBd in pBSAtBdLt) { intCount += pAtBd.CptLt.Count; } List <CPoint> BSCptLt = new List <CPoint>(intCount); foreach (CAtBd pAtBd in pBSAtBdLt) { foreach (CPoint cpt in pAtBd.CptLt) { //cpt.BelongedObject = pAtBd; BSCptLt.Add(cpt); } } //LookingForNeighboursByGrids var CorrCptsLt = CGeoFunc.LookingForNeighboursByGrids(SgCptLt, BSCptLt, CConstants.dblVerySmallCoord); //FindFrcpt2AndTocpt2 foreach (CCorrCpts CorrCpt in CorrCptsLt) { CorrCpt.FrCpt.isTraversed = false; } foreach (CCorrCpts CorrCpt in CorrCptsLt) { CPoint frcpt = CorrCpt.FrCpt; if (frcpt.isTraversed == false) //we only need one { CAtBd pAtBd = frcpt.BelongedObject as CAtBd; if (frcpt.ID == 0) { pAtBd.Frcpt2 = CorrCpt.ToCpt; } else { pAtBd.Tocpt2 = CorrCpt.ToCpt; } frcpt.isTraversed = true; } } }
private void Preprocess(List <CPoint> frcptlt, List <CPoint> tocptlt, bool isDP = false) { CGeoFunc.CalAbsAndRatioLengthFromStart(frcptlt, isDP); CGeoFunc.CalAbsAndRatioLengthFromStart(tocptlt, isDP); this.dblFrTotalLength = frcptlt.Last().dblAbsLengthFromStart; this.dblToTotalLength = tocptlt.Last().dblAbsLengthFromStart; }
//this method takes a lot of time, please do not use it if not necessary public IPolyline5 SetPolyline() { var cptlt = new List <CPoint>(2); cptlt.Add(_FrCpt); cptlt.Add(_ToCpt); _pPolyline = CGeoFunc.GetIplFromCptLt(cptlt); return(_pPolyline); }
public static double CalLengthPaths(Paths paths) { double dblLength = 0; foreach (var path in paths) { dblLength += CGeoFunc.CalLengthForIntptEb(path); } return(dblLength); }
public static IEnumerable <CEdge> GenerateCEdgeEbByPathsCptEbEb(IEnumerable <IEnumerable <CPoint> > pathsCptEbEb) { foreach (var cptEb in pathsCptEbEb) { foreach (var cedge in CGeoFunc.FormCEdgeEb(cptEb, true)) { yield return(cedge); } } }
//public virtual void SetCEdgeLtLtLength() //{ // this.CEdgeLtLt.ForEach(cedgelt => cedgelt.ForEach(cedge => cedge.SetLength())); //} public virtual double SetLengthSimple() { this.dblLengthSimple = CGeoFunc.CalLengthForCptEb(this.CptLt); if (this.dblLengthSimple == 0) { throw new ArgumentNullException("mightbe forgot to set _CptLt for a polygon!"); } return(this.dblLengthSimple); }
private static double GetDividedMinAngle(CEdge newCEdge, CEdge firstCEdge, CEdge secondCEdge, CEdge thirdCEdge, CEdge fourthCEdge) { var dblAngle1 = CGeoFunc.CalAngle_Counterclockwise(firstCEdge.dblAxisAngle, newCEdge.dblAxisAngle); var dblAngle2 = CGeoFunc.CalAngle_Counterclockwise(newCEdge.dblAxisAngle, secondCEdge.dblAxisAngle); var dblAngle3 = Math.PI - CGeoFunc.CalAngle_Counterclockwise(newCEdge.dblAxisAngle, thirdCEdge.dblAxisAngle); var dblAngle4 = Math.PI - CGeoFunc.CalAngle_Counterclockwise(fourthCEdge.dblAxisAngle, newCEdge.dblAxisAngle); return(Math.Min(dblAngle1, Math.Min(dblAngle2, Math.Min(dblAngle3, dblAngle4)))); }
/// <summary> /// QueryMovedPt /// </summary> /// <param name="dblRatioforMovePt">the ratio of length1 (start point to target point) to length2 (start point to end point) on a base line</param> /// <param name="dblLengthforMovePt">the distance of the original point (on the polyline) to the targest point (on the base line)</param> /// <param name="dblAngleDiffforMovePt">the angle difference of segment1 (target point to original point) and segment2 (target point to end point)</param> /// <param name="dblProp">t</param> /// <param name="intID">ID of the original point</param> /// <returns></returns> public CPoint QueryMovedPt(double dblRatioforMovePt, double dblLengthforMovePt, double dblAngleDiffforMovePt, double dblProp, int intID) { double dblAngle = _dblAxisAngle - dblAngleDiffforMovePt; CPoint targetcpt = CGeoFunc.GetInbetweenCpt(_FrCpt, _ToCpt, dblRatioforMovePt); double dblresultLength = (1 - dblProp) * dblLengthforMovePt; double dblresultX = targetcpt.X + dblresultLength * Math.Cos(dblAngle); double dblresultY = targetcpt.Y + dblresultLength * Math.Sin(dblAngle); return(new CPoint(intID, dblresultX, dblresultY)); }
private void DetermineOuterOrHole(List <CPolygon> rawfaceLt) { foreach (CPolygon cpg in rawfaceLt) { var AxisAngleCEdgeLt = cpg.LeftMostCpt.AxisAngleCEdgeLt; //find UpperCorrectAxisAngleCEdge and LowerCorrectAxisAngleCEdge //UpperCorrectAxisAngleCEdge has angle most close to 90 degrees //LowerCorrectAxisAngleCEdge has angle most close to 270 degrees var UpperCorrectAxisAngleCEdge = AxisAngleCEdgeLt[0]; var dblUpperAngleToHalfPI = MakeAngleCorrect( CGeoFunc.CalAngle_Counterclockwise(AxisAngleCEdgeLt[0].dblAxisAngle, CConstants.dblHalfPI)); var LowerCorrectAxisAngleCEdge = AxisAngleCEdgeLt[0]; var dblLowerAngleToHalfPI = dblUpperAngleToHalfPI; for (int i = 1; i < AxisAngleCEdgeLt.Count; i++) { double dblAngleToHalfPI = MakeAngleCorrect( CGeoFunc.CalAngle_Counterclockwise(AxisAngleCEdgeLt[i].dblAxisAngle, CConstants.dblHalfPI)); if (dblAngleToHalfPI <= dblUpperAngleToHalfPI) { dblUpperAngleToHalfPI = dblAngleToHalfPI; UpperCorrectAxisAngleCEdge = AxisAngleCEdgeLt[i]; } if (dblAngleToHalfPI > dblLowerAngleToHalfPI) { dblLowerAngleToHalfPI = dblAngleToHalfPI; LowerCorrectAxisAngleCEdge = AxisAngleCEdgeLt[i]; } } cpg.IsHole = false; //a hole means that the direction is clockwise var TestCEdgeStartAtExtreme = cpg.cedgeStartAtLeftMost; do { if (TestCEdgeStartAtExtreme.cpgIncidentFace.GID == cpg.GID) //TestCEdgeStartAtExtreme belongs to face cpg { //if the component is a hole, the following must hold if (TestCEdgeStartAtExtreme.GID == UpperCorrectAxisAngleCEdge.GID && TestCEdgeStartAtExtreme.cedgePrev.GID == LowerCorrectAxisAngleCEdge.cedgeTwin.GID) { cpg.IsHole = true; //inner boundary break; } } TestCEdgeStartAtExtreme = TestCEdgeStartAtExtreme.GetLargerAxisAngleCEdge(); } while (TestCEdgeStartAtExtreme.GID != cpg.cedgeStartAtLeftMost.GID); } }
/// <summary>递归找到对应河流,同时记录对应支流对应交汇点</summary> /// <param name="CCorrespondRiverLt">对应河流记录列</param> /// <param name="pBSRiver">大比例尺表达河流</param> /// <param name="pSSRiver">小比例尺表达河流</param> /// <param name="pParameterThreshold">阈值参数</param> /// <remarks ></remarks> private void RecursiveFindCorrespondRiverLt(ref List <CCorrespondRiver> CCorrespondRiverLt, CRiver pBSRiver, CRiver pSSRiver, CParameterThreshold pParameterThreshold) { //建立河流对应关系 pBSRiver.CCorrRiver = pSSRiver; pSSRiver.CCorrRiver = pBSRiver; CCorrespondRiver pCorrespondRiver = new CCorrespondRiver(pSSRiver, pBSRiver); pCorrespondRiver.blnCorr = true; CCorrespondRiverLt.Add(pCorrespondRiver); //如果小比例尺表达河流分支不存在 if (pSSRiver.CTributaryLt == null) { return; } //数据准备 pBSRiver.CCorrTriJunctionPtLt = new List <CPoint>(); pSSRiver.CCorrTriJunctionPtLt = new List <CPoint>(); List <CRiver> pBSTributaryLt = pBSRiver.CTributaryLt; List <CRiver> pSSTributaryLt = new List <CRiver>(); pSSTributaryLt.AddRange(pSSRiver.CTributaryLt); //遍历寻找对应河流 for (int i = 0; i < pBSTributaryLt.Count; i++) { bool blnIsOverlap = false; for (int j = 0; j < pSSTributaryLt.Count; j++) { blnIsOverlap = CGeoFunc.IsOverlap(pBSTributaryLt[i], pSSTributaryLt[j], pParameterThreshold.dblOverlapRatio); //判断两河流是否重叠 if (blnIsOverlap == true) { pBSRiver.CCorrTriJunctionPtLt.Add(pBSTributaryLt[i].Tocpt2); pSSRiver.CCorrTriJunctionPtLt.Add(pSSTributaryLt[j].Tocpt2); RecursiveFindCorrespondRiverLt(ref CCorrespondRiverLt, pBSTributaryLt[i], pSSTributaryLt[j], pParameterThreshold); //递归找到对应河流 pSSTributaryLt.RemoveAt(j); break; } } } //记录对应交汇点的目的是有助于将原河流进行对应分割以提高精度 //大多数情况下,交汇点都是“三叉路口”,此时数组"CCorrTriJunctionPtLt"中不会有重合点 //但当交汇点为“四、五甚至更多叉路口”时,数组"CCorrTriJunctionPtLt"中有重合点,应只保留其中一个点 for (int i = pBSRiver.CCorrTriJunctionPtLt.Count - 1; i > 0; i--) { if (pBSRiver.CCorrTriJunctionPtLt[i].Equals2D(pBSRiver.CCorrTriJunctionPtLt[i - 1])) { pBSRiver.CCorrTriJunctionPtLt.RemoveAt(i); pSSRiver.CCorrTriJunctionPtLt.RemoveAt(i); } } }
public static string DrawIpt(IPoint ipt, IEnvelope pEnvelopeLayer, CEnvelope pEnvelopeIpe, string strShape, CColor StrokeColor, string strWidth = "normal") { double dblFactor = pEnvelopeIpe.Height / pEnvelopeLayer.Height; double dblx = CGeoFunc.CoordinateTransform( ipt.X, pEnvelopeLayer.XMin, pEnvelopeIpe.XMin, dblFactor); double dbly = CGeoFunc.CoordinateTransform( ipt.Y, pEnvelopeLayer.YMin, pEnvelopeIpe.YMin, dblFactor); return(drawIpeMark(dblx, dbly, strShape, AddColor(StrokeColor), strWidth)); }
//private static CPolygon GenerateCpgEbByPolyNode(PolyNode cpgnode, int intID, bool blnReverse = false) //{ // var cptlt = ContourToCptEb(cpgnode.Contour, blnReverse).ToList(); // var holecptlt = GetOLHCptLtEb(cpgnode, blnReverse).ToLtLt(); // return new CPolygon(intID, cptlt, holecptlt); //} //public static IEnumerable<CPolygon> GenerateOLHCpgEbByPolyTree(PolyTree pPolyTree, int intID, bool blnReverse = false) //{ // foreach (var polyNode in pPolyTree.Childs) // { // yield return GenerateOLHCpgEbByPolyNode(polyNode, intID, blnReverse); // } //} private static CPolygon GenerateOLHCpgEbByPolyNode(PolyNode cpgnode, int intID, bool blnReverse = false) { //tiny edges cause problems for our Imai-Iri algorithm var cptlt = CGeoFunc.RemoveClosePointsForCptEb(ConvertPathToCptEb(cpgnode.Contour, blnReverse)).ToList(); var holecptlt = GetOLHCptLtEb(cpgnode, blnReverse).ToLtLt(); var cpg = new CPolygon(intID, cptlt, holecptlt); //CSaveFeature.SaveCpgEb(clipperMethods.ScaleCpgEb(CHelpFunc.MakeLt(cpg), 1 / CConstants.dblFclipper), "Cpg"); return(cpg); }
public override void FormCEdgeLt() { this.CEdgeLt = CGeoFunc.FormCEdgeEb(this.CptLt).ToList(); if (this.HoleCpgLt != null) { foreach (var holecpg in this.HoleCpgLt) { holecpg.FormCEdgeLt(); } } }
private static bool IsBaselineRightHandSide(CEdge CEdgeBaseline, CEdge CEdgeRef) { double dblAngle = CGeoFunc.CalAngle_Counterclockwise(CEdgeBaseline, CEdgeRef); if (dblAngle < Math.PI) //it doesn't matter we are simplifying a exterior ring or a interior ring (hole) { return(true); } else { return(false); } }
public CPatch Unite(CPatch other, double dblSharedSegLength) { var unitedcph = UniteNoAttribute(other); unitedcph.dblArea = this.dblArea + other.dblArea; unitedcph.dblLength = this.dblLength + other.dblLength - 2 * dblSharedSegLength; if (CConstants.blnComputeMinComp == true || CConstants.blnComputeAvgComp == true) { unitedcph.dblComp = CGeoFunc.CalCompactness(unitedcph.dblArea, unitedcph.dblLength); } return(unitedcph); }
private void btnReduce_Click(object sender, EventArgs e) { try { _dblProp = _dblProp - 0.02; pbScale.Value = Convert.ToInt16(100 * _dblProp); _RelativeInterpolationCplLt = CGeoFunc.DisplayInterpolationMix(_DataRecords, _dblProp); } catch (Exception) { MessageBox.Show("不能再减小了!"); } }
private double FindMinLength(List<CPoint> cptlt) { double dblMinDis = double.MaxValue; for (int i = 0; i < cptlt.Count - 1; i++) { double dblDis = CGeoFunc.CalDis(cptlt[i], cptlt[i + 1]); if (dblDis < dblMinDis) { dblMinDis = dblDis; } } return dblMinDis; }