/// <summary> /// erstellt die Liste aller Verbindungen, anhand aller Einträge /// in der CTSPPointList /// </summary> public void generateFromPointList(CTSPLibFileParser.E_EDGE_WEIGHT_TYPE edgeWeightType) { if (edgeWeightType == CTSPLibFileParser.E_EDGE_WEIGHT_TYPE.E_EXPLICIT) { throw new Exception("Unbekannter Fehler in der Verarbeitung."); } // jetzt kann die Liste neu gefüllt werden CTSPPointList pointList = CTSPPointList.getInstance(); // die Liste neu initialiseren initList(pointList.length()); for (int originCityIndex = 0; originCityIndex < pointList.length(); originCityIndex++) { for (int destinationCityIndex = originCityIndex + 1; destinationCityIndex < pointList.length(); destinationCityIndex++) { addConnection(new CConnection(pointList.getPoint(originCityIndex), pointList.getPoint(destinationCityIndex), edgeWeightType)); Debug.WriteLineIf(length() % 100000 == 0, length()); } // Zeit für die GC lassen // Sonst gibt es Fehler, weil diese nicht genug Zeit bekommt ihr Ding zu machen System.Threading.Thread.Sleep(1); } Debug.WriteLine("Verbindungen erstellt: " + length()); }
public void addPoint(CTSPPoint point) { if (mPoints.length() == 0) { mTourLength = 0; } else { CTSPPoint lastPointInList = mPoints.getPoint(mPoints.length() - 1); CConnection additinalConnection = CConnectionList.getInstance().getConnection(lastPointInList, point); mTourLength += additinalConnection.getDistance(); } mPoints.addPoint(point); }
protected T_BOUNDS getBounds(CTSPPointList citys) { T_BOUNDS ret = new T_BOUNDS(); if (citys.length() > 0) { ret.left = double.MaxValue; ret.bottom = double.MaxValue; for (int cityIndex = 0; cityIndex < citys.length(); cityIndex++) { CTSPPoint city = citys.getPoint(cityIndex); if (city.x < ret.left) { ret.left = city.x; } if (city.y < ret.bottom) { ret.bottom = city.y; } if (city.x > ret.right) { ret.right = city.x; } if (city.y > ret.top) { ret.top = city.y; } } } else { ret.left = 0; ret.bottom = 0; ret.right = this.Width; ret.top = this.Height; } return(ret); }
private void drawPoints() { Gl.glPointSize(5); Gl.glColor3f(1.0f, 0f, 0f); // Städte Zeichnen CTSPPointList pointList = CTSPPointList.getInstance(); for (int pointIndex = 0; pointIndex < pointList.length(); pointIndex++) { CTSPPoint point = pointList.getPoint(pointIndex); Gl.glBegin(Gl.GL_POINTS); Gl.glVertex3d(point.x, point.y, POINT_DRAW_LAYER); Gl.glEnd(); } }