public void SelectRandomly(double dblPortion) { var iptlt = this.ObjIGeoLtLt[0].AsExpectedClassEb <IPoint, object>().ToList(); var remainIptLt = new List <IPoint>(Convert.ToInt32(dblPortion * iptlt.Count)); var rand = new Random(); foreach (var ipt in iptlt) { var dblrand = rand.NextDouble(); if (dblrand < dblPortion) { remainIptLt.Add(ipt); } } CSaveFeature.SaveIGeoEb(remainIptLt, esriGeometryType.esriGeometryPoint, dblPortion.ToString()); //long lngEndTime = System.Environment.TickCount;//记录结束时间 //ParameterInitialize.tsslTime.Text = "Running Time: " + Convert.ToString(lngEndTime - lngStartTime) + "ms"; //显示运行时 }
public void Transform() { int intInterLS = 0; int intInterSS = 1; int intSg = 2; var pParameterInitialize = CConstants.ParameterInitialize; var pstrFieldNameLtLt = this.strFieldNameLtLt; var pObjValueLtLtLt = this.ObjValueLtLtLt; var InterLSIplLt = this.ObjIGeoLtLt[intInterLS].Select(obj => obj as IPolyline5).ToList(); var InterSSIplLt = this.ObjIGeoLtLt[intInterSS].Select(obj => obj as IPolyline5).ToList(); var SgIplLt = this.ObjIGeoLtLt[intSg].Select(obj => obj as IPolyline5).ToList(); var pStopwatch = new Stopwatch(); pStopwatch.Start(); var intInterLSFaceNumIndex1 = CSaveFeature.FindFieldNameIndex(pstrFieldNameLtLt[intInterLS], "FaceNum1"); var intInterLSFaceNumIndex2 = CSaveFeature.FindFieldNameIndex(pstrFieldNameLtLt[intInterLS], "FaceNum2"); var intSgFaceNumIndex = CSaveFeature.FindFieldNameIndex(pstrFieldNameLtLt[intSg], "FaceNum"); //count the faces var intInterLSFaceNumSS = new SortedSet <int>(); foreach (var objlt in pObjValueLtLtLt[intInterLS]) { intInterLSFaceNumSS.Add((int)objlt[intInterLSFaceNumIndex1]); intInterLSFaceNumSS.Add((int)objlt[intInterLSFaceNumIndex2]); } var intInterLSFaceCount = intInterLSFaceNumSS.Count; //record the ipolylines into corresponding faces (lists) var InterLSIplLtLt = new List <List <IPolyline5> >(intInterLSFaceCount); var InterSSIplLtLt = new List <List <IPolyline5> >(intInterLSFaceCount); InterLSIplLtLt.EveryElementNew(); InterSSIplLtLt.EveryElementNew(); var pInterLSObjValueLtLt = pObjValueLtLtLt[intInterLS]; //the value table of LSLayer for (int i = 0; i < pInterLSObjValueLtLt.Count; i++) { //pLSObjValueLtLt[i][intInterLSFaceNumIndex1] is the index of a face InterLSIplLtLt[(int)pInterLSObjValueLtLt[i][intInterLSFaceNumIndex1]].Add(InterLSIplLt[i]); InterLSIplLtLt[(int)pInterLSObjValueLtLt[i][intInterLSFaceNumIndex2]].Add(InterLSIplLt[i]); //we use the same index, i.e.,pLSObjValueLtLt[i][intInterLSFaceNumIndex1], as we use for LS InterSSIplLtLt[(int)pInterLSObjValueLtLt[i][intInterLSFaceNumIndex1]].Add(InterSSIplLt[i]); InterSSIplLtLt[(int)pInterLSObjValueLtLt[i][intInterLSFaceNumIndex2]].Add(InterSSIplLt[i]); } var SgIplLtLt = new List <List <IPolyline5> >(intInterLSFaceCount); var intSgIndexLtLt = new List <List <int> >(intInterLSFaceCount); SgIplLtLt.EveryElementNew(); intSgIndexLtLt.EveryElementNew(); var pSgObjValueLtLt = pObjValueLtLtLt[intSg]; //the value table of LSLayer for (int i = 0; i < pSgObjValueLtLt.Count; i++) { //pLSObjValueLtLt[i][intInterLSFaceNumIndex1] is the index of a face SgIplLtLt[(int)pSgObjValueLtLt[i][intSgFaceNumIndex]].Add(SgIplLt[i]); //we record the index of every polyline //so that later we can store the transformed polylines with the same orders as SgIplLt intSgIndexLtLt[(int)pSgObjValueLtLt[i][intSgFaceNumIndex]].Add(i); } //var dlgTransform = SetDlgTransform(pParameterInitialize.cboTransform.Text); var TransSgIGeoLt = new List <IGeometry>(SgIplLt.Count); TransSgIGeoLt.EveryElementValue(null); CHelpFunc.Displaytspb(0.5, intInterLSFaceCount); _intStart = 0; _intEndCount = intInterLSFaceCount; UpdateStartEnd(); for (int i = _intStart; i < _intEndCount; i++) { Console.WriteLine("Face Num: " + i); if (SgIplLtLt[i].Count != 0) //face 0 is the outer face, the count is zero { List <CPolyline> TransSgCplLt; switch (pParameterInitialize.cboTransform.Text) { case "CT Max Common Chords": TransSgCplLt = CTTransform(InterLSIplLtLt[i], InterSSIplLtLt[i], SgIplLtLt[i], true); break; case "Compatible Triangulations": TransSgCplLt = CTTransform(InterLSIplLtLt[i], InterSSIplLtLt[i], SgIplLtLt[i], false); break; case "Rubber Sheeting": TransSgCplLt = RSTransform(InterLSIplLtLt[i], InterSSIplLtLt[i], SgIplLtLt[i]); break; default: throw new ArgumentOutOfRangeException("a case doesn't exist!"); } //var TransSgCplEb = dlgTransform(InterLSIplLtLt[i], InterSSIplLtLt[i], SgIplLtLt[i]); int intCount = 0; foreach (var TransSgCpl in TransSgCplLt) { TransSgIGeoLt[intSgIndexLtLt[i][intCount++]] = TransSgCpl.JudgeAndSetAEGeometry(); } } CHelpFunc.Displaytspb(i + 1, intInterLSFaceCount); } CHelpFunc.DisplayRunTime(pStopwatch.ElapsedMilliseconds); CSaveFeature.SaveIGeoEb(TransSgIGeoLt, esriGeometryType.esriGeometryPolyline, "TransSgCPlLt", this.strFieldNameLtLt[intSg], this.esriFieldTypeLtLt[intSg], _ObjValueLtLtLt[intSg]); }