/// <summary> /// Takes a set of line definitions and gets the contours and /// connections corresponding to those lines. /// </summary> /// <param name="model">The model to add parsed content to.</param> /// <param name="lines">The set of line definitions.</param> public static void ParseLines(Model model, List <string> lines) { foreach (string line in lines) { // split the line into name, qualifiers, and description portions string[] mainSplit = line.Split(MAIN_SEPERATORS, StringSplitOptions.None); // get the name and description string name = mainSplit[0]; string desc = mainSplit[2]; // split the qualifiers section by spaces to separate arguments string[] args = mainSplit[1].Split(SPACE_SEPERATOR, StringSplitOptions.RemoveEmptyEntries); // if there are qualifiers given, check for relevant options bool isOpen = GetIsOpen(args); ContourType type = GetContourType(args); model.AddContour(new Contour(name, desc, type, isOpen)); // add connections to other contours GetConnections(model, args, name, SourcePoint.Start); GetConnections(model, args, name, SourcePoint.Finish); } }
/// <summary> /// Deep copy constructor. /// </summary> /// <param name="contour">A contour to copy.</param> public Contour(Contour contour) { m_name = contour.Name; m_description = contour.Description; m_type = contour.Type; m_isOpen = contour.IsOpen; // copy all points m_points = new List <Vector3>(contour.m_points); }
public Element(int i) { id = i; vertIndices = new int[3] { -1, -1, -1 }; neighborIndices = new int[3] { -1, -1, -1 }; intersections = new Vector3[3]; type = ContourType.Unknow; flag = false; }
//public static int GetLevel(Polygon p, double[] lev) //{ // double zmin = double.MaxValue; // double zmax = double.MinValue; // foreach (Coordinate c in p.ExteriorRing.Coordinates) // { // if (c.Z < zmin) zmin = c.Z; // if (c.Z > zmax) zmax = c.Z; // } // foreach (LineString ls in p.InteriorRings) // { // foreach (Coordinate c in ls.Coordinates) // { // if (c.Z < zmin) zmin = c.Z; // if (c.Z > zmax) zmax = c.Z; // } // } // if (zmin == zmax) // { // if (zmin == lev[0]) return -1; // if (zmin == lev[lev.Count() - 1]) return lev.Count(); // } // for (int i = 0; i < lev.Count(); i++) // { // if (lev[i] == zmin && lev[i + 1] == zmax) // { // return i; // } // } // return -100; //} public static void CreateMinMaxEvery(DotSpatial.Data.Raster r, ContourType type, out double MinContour, out double MaxContour, out double every) { double min = r.Minimum; double max = r.Maximum; if (min == max) { min = Math.Floor(min); max = Math.Ceiling(max); if (min == max) { max += 1; } } double dz = max - min; double Order = Math.Pow(10, Math.Floor(Math.Log10(dz))); if (Order == dz) { Order /= 10; } if (dz / Order < 2) { Order /= 10; } MinContour = Math.Floor(min / Order) * Order; MaxContour = Math.Ceiling(max / Order) * Order; if (MaxContour < max) { MaxContour += Order; } every = Order; if (type == ContourType.Line) { MinContour += every; MaxContour -= every; if (MaxContour <= MinContour) { MaxContour = MinContour + every; } } }
public static void CreateMinMaxEvery(Raster r, ContourType type, out double minContour, out double maxContour, out double every) { double min = r.Minimum; double max = r.Maximum; if (min == max) { min = Math.Floor(min); max = Math.Ceiling(max); if (min == max) { max += 1; } } double dz = max - min; double order = Math.Pow(10, Math.Floor(Math.Log10(dz))); if (order == dz) { order /= 10; } if (dz / order < 2) { order /= 10; } minContour = Math.Floor(min / order) * order; maxContour = Math.Ceiling(max / order) * order; if (maxContour < max) { maxContour += order; } every = order; if (type == ContourType.Line) { minContour += every; maxContour -= every; if (maxContour <= minContour) { maxContour = minContour + every; } } }
/// <summary> /// Constructor. /// </summary> public Contour(string name, string description, ContourType type, bool isOpen) { if (string.IsNullOrWhiteSpace(name)) { Logger.Error("Attemped to create a contour with an invalid name: " + name); } m_name = name; if (string.IsNullOrWhiteSpace(description)) { Logger.Error("Attemped to create a contour with an invalid description: " + description); } m_description = description; m_type = type; m_isOpen = isOpen; }
/// <summary> /// Restarts the iterator and jumps all the segments of this path up to the length value. /// </summary> public virtual void JumpToSegment(double length) { _isIteratorDone = false; if (length <= 0f) { _nextIndex = 0; return; } double accLength = 0; var lastPoint = new double [2]; for (_nextIndex = 0; _nextIndex < _outerInstance._types.Length; _nextIndex++) { var segmentLength = _outerInstance._segmentsLength[_nextIndex]; if (accLength + segmentLength >= length && _outerInstance._types[_nextIndex] != ContourType.MoveTo) { var estimatedPoint = new double [2]; _outerInstance.GetPointAtLength(_outerInstance._types[_nextIndex], _outerInstance._coordinates[_nextIndex], lastPoint[0], lastPoint[1], (length - accLength) / segmentLength, estimatedPoint); // This segment makes us go further than length so we go back one step, // set a moveto and offset the length of the next segment by the length // of this segment that we've already used. _currentType = ContourType.MoveTo; _currentCoords[0] = estimatedPoint[0]; _currentCoords[1] = estimatedPoint[1]; _currentSegmentLength = 0; // We need to offset next path length to account for the segment we've just // skipped. _mOffsetLength = length - accLength; return; } accLength += segmentLength; GetShapeEndPoint(_outerInstance._types[_nextIndex], _outerInstance._coordinates[_nextIndex], lastPoint); } }
public override bool Next() { if (_nextIndex >= _outerInstance._types.Length) { _isIteratorDone = true; return(false); } if (_nextIndex >= 1) { // We've already called next() once so there is a previous segment in this path. // We want to get the coordinates where the path ends. GetShapeEndPoint(_currentType, _currentCoords, _mLastPoint); } else { // This is the first segment, no previous point so initialize to 0, 0 _mLastPoint[0] = _mLastPoint[1] = 0f; } _currentType = _outerInstance._types[_nextIndex]; _currentSegmentLength = _outerInstance._segmentsLength[_nextIndex] - _mOffsetLength; if (_mOffsetLength > 0f && (_currentType == ContourType.Bezier || _currentType == ContourType.Arc)) { // We need to skip part of the start of the current segment (because // mOffsetLength > 0) var points = new float[8]; if (_nextIndex < 1) { points[0] = points[1] = 0f; } else { GetShapeEndPoint(_outerInstance._types[_nextIndex - 1], _outerInstance._coordinates[_nextIndex - 1], points); } Array.Copy(_outerInstance._coordinates[_nextIndex], 0, points, 2, _outerInstance._coordinates[_nextIndex].Length); var t0 = (_outerInstance._segmentsLength[_nextIndex] - _currentSegmentLength) / _outerInstance._segmentsLength[_nextIndex]; if (_currentType == ContourType.Bezier) { CubicCurveSegment(points, t0, 1f); } else { QuadCurveSegment(points, t0, 1f); } Array.Copy(points, 2, _currentCoords, 0, _outerInstance._coordinates[_nextIndex].Length); } else { Array.Copy(_outerInstance._coordinates[_nextIndex], 0, _currentCoords, 0, _outerInstance._coordinates[_nextIndex].Length); } _mOffsetLength = 0f; _nextIndex++; return(true); }
public static DotSpatial.Data.FeatureSet Execute(DotSpatial.Data.Raster rst, ContourType contourType, string FieldName = "Value", double[] levels = null) { double[] lev = levels; noData = rst.NoDataValue; type = contourType; DotSpatial.Data.Raster iRst = RasterCheck(rst, lev);; string field; if (FieldName == null) { field = "Value"; } else { field = FieldName; } double[] x = new double[rst.NumColumns]; double[] y = new double[rst.NumRows]; for (int i = 0; i < rst.NumColumns; i++) { x[i] = rst.Extent.MinX + rst.CellWidth * i + rst.CellWidth / 2; } for (int i = 0; i < rst.NumRows; i++) { y[i] = rst.Extent.MaxY - rst.CellHeight * i - rst.CellHeight / 2; } DotSpatial.Data.FeatureSet fs = null; switch (type) { case ContourType.Line: { fs = new DotSpatial.Data.FeatureSet(DotSpatial.Topology.FeatureType.Line); fs.DataTable.Columns.Add(field, typeof(double)); for (int z = 0; z < levels.Length; z++) { IList <IGeometry> cont = GetContours(ref iRst, x, y, lev[z]); foreach (var g in cont) { var f = (DotSpatial.Data.Feature)fs.AddFeature(ToDotSpatialLineString((ILineString)g)); f.DataRow[field] = lev[z]; } } } break; case ContourType.Polygon: { fs = new DotSpatial.Data.FeatureSet(DotSpatial.Topology.FeatureType.Polygon); fs.DataTable.Columns.Add("Lev", typeof(int)); fs.DataTable.Columns.Add("Label", typeof(string)); Collection <IGeometry> Contours = new Collection <IGeometry>(); for (int z = 0; z < levels.Count(); z++) { IList <IGeometry> cont = GetContours(ref iRst, x, y, lev[z]); foreach (var g in cont) { Contours.Add(new LineString(g.Coordinates)); } } Coordinate[] Boundary = new Coordinate[5]; Boundary[0] = new Coordinate(x[0], y[0]); Boundary[1] = new Coordinate(x[0], y[rst.NumRows - 1]); Boundary[2] = new Coordinate(x[rst.NumColumns - 1], y[rst.NumRows - 1]); Boundary[3] = new Coordinate(x[rst.NumColumns - 1], y[0]); Boundary[4] = new Coordinate(x[0], y[0]); Contours.Add(new LineString(Boundary)); Collection <IGeometry> NodedContours = new Collection <IGeometry>(); GeometryNoder geomNoder = new GeometryNoder(new PrecisionModel(1000d)); foreach (var c in geomNoder.Node(Contours)) { NodedContours.Add(c); } Polygonizer polygonizer = new Polygonizer(); polygonizer.Add(NodedContours); foreach (IPolygon p in polygonizer.GetPolygons()) { Point pnt = (Point)p.InteriorPoint; int c = (int)((pnt.X - iRst.Extent.MinX) / iRst.CellWidth); int r = (int)((iRst.Extent.MaxY - pnt.Y) / iRst.CellHeight); double z = ((DotSpatial.Data.Raster)iRst).Value[r, c]; int Cls = GetLevel(z, lev); string label = "Undefined"; if (Cls == -1) { label = "< " + lev[0].ToString(); } if (Cls == lev.Count()) { label = "> " + lev[lev.Count() - 1].ToString(); } if (Cls >= 0 & Cls < lev.Count()) { label = lev[Cls].ToString() + " - " + lev[Cls + 1].ToString(); } DotSpatial.Topology.Polygon dsp = ToDotSpatialPolygon(p); DotSpatial.Data.Feature f = (DotSpatial.Data.Feature)fs.AddFeature(dsp); f.DataRow["Lev"] = Cls; f.DataRow["Label"] = label; } } break; } return(fs); }
public void Initialize() { type = ContourType.Unknow; }
public void GetProperties() { Model model = new Model(); Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); ModelObjectEnumerator modelObjectEnum = modelObjectSelector.GetSelectedObjects(); if (modelObjectEnum.GetSize() == 1) { while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Tekla.Structures.Model.BaseWeld) { BaseWeld weld = (BaseWeld)modelObjectEnum.Current; refText = weld.ReferenceText; if (weld.AroundWeld) { around = Bool.True; } else { around = Bool.False; } sizeAbove = weld.SizeAbove.ToString(); if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_NONE) { weldTypeAbove = WeldType.WELD_TYPE_NONE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_FILLET) { weldTypeAbove = WeldType.WELD_TYPE_FILLET; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_GROOVE_SINGLE_V_BUTT) { weldTypeAbove = WeldType.WELD_TYPE_BEVEL_GROOVE_SINGLE_V_BUTT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_GROOVE_SINGLE_BEVEL_BUTT) { weldTypeAbove = WeldType.WELD_TYPE_BEVEL_GROOVE_SINGLE_BEVEL_BUTT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SQUARE_GROOVE_SQUARE_BUTT) { weldTypeAbove = WeldType.WELD_TYPE_SQUARE_GROOVE_SQUARE_BUTT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SINGLE_V_BUTT_WITH_BROAD_ROOT_FACE) { weldTypeAbove = WeldType.WELD_TYPE_SINGLE_V_BUTT_WITH_BROAD_ROOT_FACE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SINGLE_BEVEL_BUTT_WITH_BROAD_ROOT_FACE) { weldTypeAbove = WeldType.WELD_TYPE_SINGLE_BEVEL_BUTT_WITH_BROAD_ROOT_FACE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_U_GROOVE_SINGLE_U_BUTT) { weldTypeAbove = WeldType.WELD_TYPE_U_GROOVE_SINGLE_U_BUTT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_J_GROOVE_J_BUTT) { weldTypeAbove = WeldType.WELD_TYPE_J_GROOVE_J_BUTT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_FLARE_V_GROOVE) { weldTypeAbove = WeldType.WELD_TYPE_FLARE_V_GROOVE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_FLARE_BEVEL_GROOVE) { weldTypeAbove = WeldType.WELD_TYPE_FLARE_BEVEL_GROOVE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_EDGE_FLANGE) { weldTypeAbove = WeldType.WELD_TYPE_EDGE_FLANGE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_CORNER_FLANGE) { weldTypeAbove = WeldType.WELD_TYPE_CORNER_FLANGE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_PLUG) { weldTypeAbove = WeldType.WELD_TYPE_PLUG; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_BACKING) { weldTypeAbove = WeldType.WELD_TYPE_BEVEL_BACKING; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SPOT) { weldTypeAbove = WeldType.WELD_TYPE_SPOT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SEAM) { weldTypeAbove = WeldType.WELD_TYPE_SEAM; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SLOT) { weldTypeAbove = WeldType.WELD_TYPE_SLOT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_PARTIAL_PENETRATION_SINGLE_BEVEL_BUTT_PLUS_FILLET) { weldTypeAbove = WeldType.WELD_TYPE_PARTIAL_PENETRATION_SINGLE_BEVEL_BUTT_PLUS_FILLET; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_PARTIAL_PENETRATION_SQUARE_GROOVE_PLUS_FILLET) { weldTypeAbove = WeldType.WELD_TYPE_PARTIAL_PENETRATION_SQUARE_GROOVE_PLUS_FILLET; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_MELT_THROUGH) { weldTypeAbove = WeldType.WELD_TYPE_MELT_THROUGH; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_V_BUTT) { weldTypeAbove = WeldType.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_V_BUTT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_BEVEL_BUTT) { weldTypeAbove = WeldType.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_BEVEL_BUTT; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_EDGE) { weldTypeAbove = WeldType.WELD_TYPE_EDGE; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_ISO_SURFACING) { weldTypeAbove = WeldType.WELD_TYPE_ISO_SURFACING; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_FOLD) { weldTypeAbove = WeldType.WELD_TYPE_FOLD; } else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_INCLINED) { weldTypeAbove = WeldType.WELD_TYPE_INCLINED; } else { Console.WriteLine(weld.TypeAbove); } if (weld.ContourAbove == BaseWeld.WeldContourEnum.WELD_CONTOUR_NONE) { contourTypeAbove = ContourType.None; } else if (weld.ContourAbove == BaseWeld.WeldContourEnum.WELD_CONTOUR_FLUSH) { contourTypeAbove = ContourType.Flush; } sizeBelow = weld.SizeBelow.ToString(); if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_NONE) { weldTypeBelow = WeldType.WELD_TYPE_NONE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_FILLET) { weldTypeBelow = WeldType.WELD_TYPE_FILLET; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_GROOVE_SINGLE_V_BUTT) { weldTypeBelow = WeldType.WELD_TYPE_BEVEL_GROOVE_SINGLE_V_BUTT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_GROOVE_SINGLE_BEVEL_BUTT) { weldTypeBelow = WeldType.WELD_TYPE_BEVEL_GROOVE_SINGLE_BEVEL_BUTT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SQUARE_GROOVE_SQUARE_BUTT) { weldTypeBelow = WeldType.WELD_TYPE_SQUARE_GROOVE_SQUARE_BUTT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SINGLE_V_BUTT_WITH_BROAD_ROOT_FACE) { weldTypeBelow = WeldType.WELD_TYPE_SINGLE_V_BUTT_WITH_BROAD_ROOT_FACE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SINGLE_BEVEL_BUTT_WITH_BROAD_ROOT_FACE) { weldTypeBelow = WeldType.WELD_TYPE_SINGLE_BEVEL_BUTT_WITH_BROAD_ROOT_FACE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_U_GROOVE_SINGLE_U_BUTT) { weldTypeBelow = WeldType.WELD_TYPE_U_GROOVE_SINGLE_U_BUTT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_J_GROOVE_J_BUTT) { weldTypeBelow = WeldType.WELD_TYPE_J_GROOVE_J_BUTT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_FLARE_V_GROOVE) { weldTypeBelow = WeldType.WELD_TYPE_FLARE_V_GROOVE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_FLARE_BEVEL_GROOVE) { weldTypeBelow = WeldType.WELD_TYPE_FLARE_BEVEL_GROOVE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_EDGE_FLANGE) { weldTypeBelow = WeldType.WELD_TYPE_EDGE_FLANGE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_CORNER_FLANGE) { weldTypeBelow = WeldType.WELD_TYPE_CORNER_FLANGE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_PLUG) { weldTypeBelow = WeldType.WELD_TYPE_PLUG; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_BACKING) { weldTypeBelow = WeldType.WELD_TYPE_BEVEL_BACKING; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SPOT) { weldTypeBelow = WeldType.WELD_TYPE_SPOT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SEAM) { weldTypeBelow = WeldType.WELD_TYPE_SEAM; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SLOT) { weldTypeBelow = WeldType.WELD_TYPE_SLOT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_PARTIAL_PENETRATION_SINGLE_BEVEL_BUTT_PLUS_FILLET) { weldTypeBelow = WeldType.WELD_TYPE_PARTIAL_PENETRATION_SINGLE_BEVEL_BUTT_PLUS_FILLET; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_PARTIAL_PENETRATION_SQUARE_GROOVE_PLUS_FILLET) { weldTypeBelow = WeldType.WELD_TYPE_PARTIAL_PENETRATION_SQUARE_GROOVE_PLUS_FILLET; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_MELT_THROUGH) { weldTypeBelow = WeldType.WELD_TYPE_MELT_THROUGH; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_V_BUTT) { weldTypeBelow = WeldType.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_V_BUTT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_BEVEL_BUTT) { weldTypeBelow = WeldType.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_BEVEL_BUTT; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_EDGE) { weldTypeBelow = WeldType.WELD_TYPE_EDGE; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_ISO_SURFACING) { weldTypeBelow = WeldType.WELD_TYPE_ISO_SURFACING; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_FOLD) { weldTypeBelow = WeldType.WELD_TYPE_FOLD; } else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_INCLINED) { weldTypeBelow = WeldType.WELD_TYPE_INCLINED; } else { Console.WriteLine(weld.TypeBelow); } if (weld.ContourBelow == BaseWeld.WeldContourEnum.WELD_CONTOUR_NONE) { contourTypeBelow = ContourType.None; } else if (weld.ContourBelow == BaseWeld.WeldContourEnum.WELD_CONTOUR_FLUSH) { contourTypeBelow = ContourType.Flush; } } } } else { sizeAbove = ""; weldTypeAbove = new WeldType(); contourTypeAbove = new ContourType(); sizeBelow = ""; weldTypeBelow = new WeldType(); contourTypeBelow = new ContourType(); refText = ""; around = new Bool(); } }
public static DotSpatial.Data.FeatureSet Execute(DotSpatial.Data.Raster rst, ContourType contourType, string FieldName = "Value", double[] levels = null) { double[] lev = levels; noData = rst.NoDataValue; type = contourType; DotSpatial.Data.Raster iRst = RasterCheck(rst, lev); ; string field; if (FieldName == null) { field = "Value"; } else { field = FieldName; } double[] x = new double[rst.NumColumns]; double[] y = new double[rst.NumRows]; for (int i = 0; i < rst.NumColumns; i++) { x[i] = rst.Extent.MinX + rst.CellWidth * i + rst.CellWidth / 2; } for (int i = 0; i < rst.NumRows; i++) { y[i] = rst.Extent.MaxY - rst.CellHeight * i - rst.CellHeight / 2; } DotSpatial.Data.FeatureSet fs = null; switch (type) { case ContourType.Line: { fs = new DotSpatial.Data.FeatureSet(DotSpatial.Topology.FeatureType.Line); fs.DataTable.Columns.Add(field, typeof(double)); for (int z = 0; z < levels.Count(); z++) { IList<IGeometry> cont = GetContours(ref iRst, x, y, lev[z]); foreach (Geometry g in cont) { DotSpatial.Data.Feature f = (DotSpatial.Data.Feature)fs.AddFeature(ToDotSpatialLineString((ILineString)g)); f.DataRow[field] = lev[z]; } } } break; case ContourType.Polygon: { fs = new DotSpatial.Data.FeatureSet(DotSpatial.Topology.FeatureType.Polygon); fs.DataTable.Columns.Add("Lev", typeof(int)); fs.DataTable.Columns.Add("Label", typeof(string)); Collection<IGeometry> Contours = new Collection<IGeometry>(); for (int z = 0; z < levels.Count(); z++) { IList<IGeometry> cont = GetContours(ref iRst, x, y, lev[z]); foreach (Geometry g in cont) { Contours.Add(new LineString(g.Coordinates)); } } Coordinate[] Boundary = new Coordinate[5]; Boundary[0] = new Coordinate(x[0], y[0]); Boundary[1] = new Coordinate(x[0], y[rst.NumRows - 1]); Boundary[2] = new Coordinate(x[rst.NumColumns - 1], y[rst.NumRows - 1]); Boundary[3] = new Coordinate(x[rst.NumColumns - 1], y[0]); Boundary[4] = new Coordinate(x[0], y[0]); Contours.Add(new LineString(Boundary)); Collection<IGeometry> NodedContours = new Collection<IGeometry>(); GeometryNoder geomNoder = new GeometryNoder(new PrecisionModel(1000d)); foreach (LineString c in geomNoder.Node(Contours)) { NodedContours.Add(c); } Polygonizer polygonizer = new Polygonizer(); polygonizer.Add(NodedContours); foreach (Polygon p in polygonizer.GetPolygons()) { Point pnt = (Point)p.InteriorPoint; int c = (int)((pnt.X - iRst.Extent.MinX) / iRst.CellWidth); int r = (int)((iRst.Extent.MaxY - pnt.Y) / iRst.CellHeight); double z = ((DotSpatial.Data.Raster)iRst).Value[r, c]; int Cls = GetLevel(z, lev); string label = "Undefined"; if (Cls == -1) label = "< " + lev[0].ToString(); if (Cls == lev.Count()) label = "> " + lev[lev.Count() - 1].ToString(); if (Cls >= 0 & Cls < lev.Count()) label = lev[Cls].ToString() + " - " + lev[Cls + 1].ToString(); DotSpatial.Topology.Polygon dsp = ToDotSpatialPolygon(p); DotSpatial.Data.Feature f = (DotSpatial.Data.Feature)fs.AddFeature(dsp); f.DataRow["Lev"] = Cls; f.DataRow["Label"] = label; } } break; } return fs; }
public void GetProperties() { Model model = new Model(); ModelObjectEnumerator modelobjenum = model.GetModelObjectSelector().GetSelectedObjects(); if (modelobjenum.GetSize() == 1) { while (modelobjenum.MoveNext()) { if (modelobjenum.Current is Tekla.Structures.Model.BaseWeld) { BaseWeld weld = (BaseWeld)modelobjenum.Current; refText = weld.ReferenceText; if (weld.AroundWeld) around = Bool.True; else around = Bool.False; sizeAbove = weld.SizeAbove.ToString(); if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_NONE) weldTypeAbove = WeldType.WELD_TYPE_NONE; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_FILLET) weldTypeAbove = WeldType.WELD_TYPE_FILLET; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_GROOVE_SINGLE_V_BUTT) weldTypeAbove = WeldType.WELD_TYPE_BEVEL_GROOVE_SINGLE_V_BUTT; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_GROOVE_SINGLE_BEVEL_BUTT) weldTypeAbove = WeldType.WELD_TYPE_BEVEL_GROOVE_SINGLE_BEVEL_BUTT; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SQUARE_GROOVE_SQUARE_BUTT) weldTypeAbove = WeldType.WELD_TYPE_SQUARE_GROOVE_SQUARE_BUTT; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SINGLE_V_BUTT_WITH_BROAD_ROOT_FACE) weldTypeAbove = WeldType.WELD_TYPE_SINGLE_V_BUTT_WITH_BROAD_ROOT_FACE; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SINGLE_BEVEL_BUTT_WITH_BROAD_ROOT_FACE) weldTypeAbove = WeldType.WELD_TYPE_SINGLE_BEVEL_BUTT_WITH_BROAD_ROOT_FACE; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_U_GROOVE_SINGLE_U_BUTT) weldTypeAbove = WeldType.WELD_TYPE_U_GROOVE_SINGLE_U_BUTT; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_J_GROOVE_J_BUTT) weldTypeAbove = WeldType.WELD_TYPE_J_GROOVE_J_BUTT; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_FLARE_V_GROOVE) weldTypeAbove = WeldType.WELD_TYPE_FLARE_V_GROOVE; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_FLARE_BEVEL_GROOVE) weldTypeAbove = WeldType.WELD_TYPE_FLARE_BEVEL_GROOVE; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_EDGE_FLANGE) weldTypeAbove = WeldType.WELD_TYPE_EDGE_FLANGE; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_CORNER_FLANGE) weldTypeAbove = WeldType.WELD_TYPE_CORNER_FLANGE; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_PLUG) weldTypeAbove = WeldType.WELD_TYPE_PLUG; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_BACKING) weldTypeAbove = WeldType.WELD_TYPE_BEVEL_BACKING; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SPOT) weldTypeAbove = WeldType.WELD_TYPE_SPOT; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SEAM) weldTypeAbove = WeldType.WELD_TYPE_SEAM; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_SLOT) weldTypeAbove = WeldType.WELD_TYPE_SLOT; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_PARTIAL_PENETRATION_SINGLE_BEVEL_BUTT_PLUS_FILLET) weldTypeAbove = WeldType.WELD_TYPE_PARTIAL_PENETRATION_SINGLE_BEVEL_BUTT_PLUS_FILLET; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_PARTIAL_PENETRATION_SQUARE_GROOVE_PLUS_FILLET) weldTypeAbove = WeldType.WELD_TYPE_PARTIAL_PENETRATION_SQUARE_GROOVE_PLUS_FILLET; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_MELT_THROUGH) weldTypeAbove = WeldType.WELD_TYPE_MELT_THROUGH; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_V_BUTT) weldTypeAbove = WeldType.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_V_BUTT; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_BEVEL_BUTT) weldTypeAbove = WeldType.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_BEVEL_BUTT; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_EDGE) weldTypeAbove = WeldType.WELD_TYPE_EDGE; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_ISO_SURFACING) weldTypeAbove = WeldType.WELD_TYPE_ISO_SURFACING; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_FOLD) weldTypeAbove = WeldType.WELD_TYPE_FOLD; else if (weld.TypeAbove == BaseWeld.WeldTypeEnum.WELD_TYPE_INCLINED) weldTypeAbove = WeldType.WELD_TYPE_INCLINED; else Console.WriteLine(weld.TypeAbove); if (weld.ContourAbove == BaseWeld.WeldContourEnum.WELD_CONTOUR_NONE) contourTypeAbove = ContourType.None; else if (weld.ContourAbove == BaseWeld.WeldContourEnum.WELD_CONTOUR_FLUSH) contourTypeAbove = ContourType.Flush; sizeBelow = weld.SizeBelow.ToString(); if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_NONE) weldTypeBelow = WeldType.WELD_TYPE_NONE; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_FILLET) weldTypeBelow = WeldType.WELD_TYPE_FILLET; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_GROOVE_SINGLE_V_BUTT) weldTypeBelow = WeldType.WELD_TYPE_BEVEL_GROOVE_SINGLE_V_BUTT; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_GROOVE_SINGLE_BEVEL_BUTT) weldTypeBelow = WeldType.WELD_TYPE_BEVEL_GROOVE_SINGLE_BEVEL_BUTT; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SQUARE_GROOVE_SQUARE_BUTT) weldTypeBelow = WeldType.WELD_TYPE_SQUARE_GROOVE_SQUARE_BUTT; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SINGLE_V_BUTT_WITH_BROAD_ROOT_FACE) weldTypeBelow = WeldType.WELD_TYPE_SINGLE_V_BUTT_WITH_BROAD_ROOT_FACE; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SINGLE_BEVEL_BUTT_WITH_BROAD_ROOT_FACE) weldTypeBelow = WeldType.WELD_TYPE_SINGLE_BEVEL_BUTT_WITH_BROAD_ROOT_FACE; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_U_GROOVE_SINGLE_U_BUTT) weldTypeBelow = WeldType.WELD_TYPE_U_GROOVE_SINGLE_U_BUTT; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_J_GROOVE_J_BUTT) weldTypeBelow = WeldType.WELD_TYPE_J_GROOVE_J_BUTT; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_FLARE_V_GROOVE) weldTypeBelow = WeldType.WELD_TYPE_FLARE_V_GROOVE; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_FLARE_BEVEL_GROOVE) weldTypeBelow = WeldType.WELD_TYPE_FLARE_BEVEL_GROOVE; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_EDGE_FLANGE) weldTypeBelow = WeldType.WELD_TYPE_EDGE_FLANGE; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_CORNER_FLANGE) weldTypeBelow = WeldType.WELD_TYPE_CORNER_FLANGE; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_PLUG) weldTypeBelow = WeldType.WELD_TYPE_PLUG; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_BEVEL_BACKING) weldTypeBelow = WeldType.WELD_TYPE_BEVEL_BACKING; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SPOT) weldTypeBelow = WeldType.WELD_TYPE_SPOT; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SEAM) weldTypeBelow = WeldType.WELD_TYPE_SEAM; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_SLOT) weldTypeBelow = WeldType.WELD_TYPE_SLOT; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_PARTIAL_PENETRATION_SINGLE_BEVEL_BUTT_PLUS_FILLET) weldTypeBelow = WeldType.WELD_TYPE_PARTIAL_PENETRATION_SINGLE_BEVEL_BUTT_PLUS_FILLET; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_PARTIAL_PENETRATION_SQUARE_GROOVE_PLUS_FILLET) weldTypeBelow = WeldType.WELD_TYPE_PARTIAL_PENETRATION_SQUARE_GROOVE_PLUS_FILLET; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_MELT_THROUGH) weldTypeBelow = WeldType.WELD_TYPE_MELT_THROUGH; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_V_BUTT) weldTypeBelow = WeldType.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_V_BUTT; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_BEVEL_BUTT) weldTypeBelow = WeldType.STEEP_FLANKED_BEVEL_GROOVE_SINGLE_BEVEL_BUTT; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_EDGE) weldTypeBelow = WeldType.WELD_TYPE_EDGE; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_ISO_SURFACING) weldTypeBelow = WeldType.WELD_TYPE_ISO_SURFACING; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_FOLD) weldTypeBelow = WeldType.WELD_TYPE_FOLD; else if (weld.TypeBelow == BaseWeld.WeldTypeEnum.WELD_TYPE_INCLINED) weldTypeBelow = WeldType.WELD_TYPE_INCLINED; else Console.WriteLine(weld.TypeBelow); if (weld.ContourBelow == BaseWeld.WeldContourEnum.WELD_CONTOUR_NONE) contourTypeBelow = ContourType.None; else if (weld.ContourBelow == BaseWeld.WeldContourEnum.WELD_CONTOUR_FLUSH) contourTypeBelow = ContourType.Flush; } } } else { sizeAbove = ""; weldTypeAbove = new WeldType(); contourTypeAbove = new ContourType(); sizeBelow = ""; weldTypeBelow = new WeldType(); contourTypeBelow = new ContourType(); refText = ""; around = new Bool(); } }
private void CreateContours(double[,] points, double[] contourX, double[] contourY, double[] contourZ, int gridSize, int steps, ContourType contourType) { Dictionary <Vector2, List <Vector2> >[] contours = new Dictionary <Vector2, List <Vector2> > [contourZ.Length]; for (int heightCount = 0; heightCount < contourZ.Length; ++heightCount) //Loop through the different Z height segments { contours[heightCount] = new Dictionary <Vector2, List <Vector2> >(); } Conrec.Contour(points, contourX, contourY, contourZ, contours); //Get contours for the points. Returns an array of contours for the different heights. foreach (Dictionary <Vector2, List <Vector2> > contourList in contours) { List <List <Vector2> > contourChains = Chains.Process(contourList); contourChains = Chains.Simplify(contourChains); foreach (List <Vector2> chains in contourChains) { List <OSMWayND> wayPaths = new List <OSMWayND>(); List <OSMWayTag> wayTags = new List <OSMWayTag>(); foreach (Vector2 node in chains) { osmNodes.Add(CreateNode(unindexedNodeOffset++, new Vector3((node.x - gridSize) - ((steps * gridSize) / 2), 0, (node.y - gridSize) - ((steps * gridSize) / 2)))); wayPaths.Add(new OSMWayND { @ref = (uint)unindexedNodeOffset - 1 }); } wayPaths.Add(new OSMWayND { @ref = (uint)(unindexedNodeOffset - chains.Count) }); //Back to the first chain switch (contourType) { case ContourType.Ground: wayTags.Add(new OSMWayTag { k = "natural", v = "coastline" }); break; case ContourType.Water: wayTags.Add(new OSMWayTag { k = "natural", v = "water" }); break; } osmWays.Add(new OSMWay { changeset = 50000000, id = (uint)unindexedWayOffset++, timestamp = DateTime.Now, user = "******", nd = wayPaths.ToArray(), tag = wayTags.ToArray(), version = 1 }); } } }
/// <summary> /// Creates a featureset from the given raster. /// </summary> /// <param name="rst">Raster used for creation.</param> /// <param name="contourType">The contour type used for creation.</param> /// <param name="fieldName">Name of the field that gets added to the featureset to put the level values into.</param> /// <param name="levels">The levels to sort the features into.</param> /// <returns>The featureset that was created from the raster.</returns> public static FeatureSet Execute(Raster rst, ContourType contourType, string fieldName = "Value", double[] levels = null) { double[] lev = levels; noData = rst.NoDataValue; type = contourType; Raster iRst = RasterCheck(rst, lev); string field = fieldName ?? "Value"; double[] x = new double[rst.NumColumns]; double[] y = new double[rst.NumRows]; for (int i = 0; i < rst.NumColumns; i++) { x[i] = rst.Extent.MinX + (rst.CellWidth * i) + (rst.CellWidth / 2); } for (int i = 0; i < rst.NumRows; i++) { y[i] = rst.Extent.MaxY - (rst.CellHeight * i) - (rst.CellHeight / 2); } FeatureSet fs = null; switch (type) { case ContourType.Line: fs = new FeatureSet(FeatureType.Line); fs.DataTable.Columns.Add(field, typeof(double)); if (levels != null) { for (int z = 0; z < levels.Length; z++) { IList <IGeometry> cont = GetContours(ref iRst, x, y, lev[z]); foreach (var g in cont) { var f = (Feature)fs.AddFeature((ILineString)g); f.DataRow[field] = lev[z]; } } } break; case ContourType.Polygon: fs = new FeatureSet(FeatureType.Polygon); fs.DataTable.Columns.Add("Lev", typeof(int)); fs.DataTable.Columns.Add("Label", typeof(string)); Collection <IGeometry> contours = new Collection <IGeometry>(); if (levels != null) { for (int z = 0; z < levels.Length; z++) { IList <IGeometry> cont = GetContours(ref iRst, x, y, lev[z]); foreach (var g in cont) { contours.Add(new LineString(g.Coordinates)); } } Coordinate[] boundary = new Coordinate[5]; boundary[0] = new Coordinate(x[0], y[0]); boundary[1] = new Coordinate(x[0], y[rst.NumRows - 1]); boundary[2] = new Coordinate(x[rst.NumColumns - 1], y[rst.NumRows - 1]); boundary[3] = new Coordinate(x[rst.NumColumns - 1], y[0]); boundary[4] = new Coordinate(x[0], y[0]); contours.Add(new LineString(boundary)); Collection <IGeometry> nodedContours = new Collection <IGeometry>(); IPrecisionModel pm = new PrecisionModel(1000d); GeometryNoder geomNoder = new GeometryNoder(pm); foreach (var c in geomNoder.Node(contours)) { nodedContours.Add(c); } Polygonizer polygonizer = new Polygonizer(); polygonizer.Add(nodedContours); foreach (IPolygon p in polygonizer.GetPolygons().OfType <IPolygon>()) { IPoint pnt = p.InteriorPoint; int c = (int)((pnt.X - iRst.Extent.MinX) / iRst.CellWidth); int r = (int)((iRst.Extent.MaxY - pnt.Y) / iRst.CellHeight); double z = iRst.Value[r, c]; int cls = GetLevel(z, lev); string label = "Undefined"; if (cls == -1) { label = "< " + lev[0]; } else if (cls == lev.Length) { label = "> " + lev[lev.Length - 1]; } else if (cls >= 0 & cls < lev.Length) { label = lev[cls] + " - " + lev[cls + 1]; } IFeature f = fs.AddFeature(p); f.DataRow["Lev"] = cls; f.DataRow["Label"] = label; } } break; } return(fs); }
//public static int GetLevel(Polygon p, double[] lev) //{ // double zmin = double.MaxValue; // double zmax = double.MinValue; // foreach (Coordinate c in p.ExteriorRing.Coordinates) // { // if (c.Z < zmin) zmin = c.Z; // if (c.Z > zmax) zmax = c.Z; // } // foreach (LineString ls in p.InteriorRings) // { // foreach (Coordinate c in ls.Coordinates) // { // if (c.Z < zmin) zmin = c.Z; // if (c.Z > zmax) zmax = c.Z; // } // } // if (zmin == zmax) // { // if (zmin == lev[0]) return -1; // if (zmin == lev[lev.Count() - 1]) return lev.Count(); // } // for (int i = 0; i < lev.Count(); i++) // { // if (lev[i] == zmin && lev[i + 1] == zmax) // { // return i; // } // } // return -100; //} public static void CreateMinMaxEvery(DotSpatial.Data.Raster r, ContourType type, out double MinContour, out double MaxContour, out double every) { double min = r.Minimum; double max = r.Maximum; if (min == max) { min = Math.Floor(min); max = Math.Ceiling(max); if (min == max) { max += 1; } } double dz = max - min; double Order = Math.Pow(10, Math.Floor(Math.Log10(dz))); if (Order == dz) Order /= 10; if (dz / Order < 2) Order /= 10; MinContour = Math.Floor(min / Order) * Order; MaxContour = Math.Ceiling(max / Order) * Order; if (MaxContour < max) MaxContour += Order; every = Order; if (type == ContourType.Line) { MinContour += every; MaxContour -= every; if (MaxContour <= MinContour) { MaxContour = MinContour + every; } } }
protected LineStrip() { Type = ContourType.Open; Edges = new List <TK>(); Elements = new LinkedList <LineStripElement <T, TK> >(); }
private void CreateContours(double[,] points, double[] contourX, double[] contourY, double[] contourZ, int gridSize, int steps, ContourType contourType) { Dictionary<Vector2, List<Vector2>>[] contours = new Dictionary<Vector2, List<Vector2>>[contourZ.Length]; for (int heightCount = 0; heightCount < contourZ.Length; ++heightCount) //Loop through the different Z height segments { contours[heightCount] = new Dictionary<Vector2, List<Vector2>>(); } Conrec.Contour(points, contourX, contourY, contourZ, contours); //Get contours for the points. Returns an array of contours for the different heights. foreach (Dictionary<Vector2, List<Vector2>> contourList in contours) { List<List<Vector2>> contourChains = Chains.Process(contourList); contourChains = Chains.Simplify(contourChains); foreach (List<Vector2> chains in contourChains) { List<OSMWayND> wayPaths = new List<OSMWayND>(); List<OSMWayTag> wayTags = new List<OSMWayTag>(); foreach (Vector2 node in chains) { osmNodes.Add(CreateNode(unindexedNodeOffset++, new Vector3((node.x - gridSize) - ((steps * gridSize) / 2), 0, (node.y - gridSize) - ((steps * gridSize) / 2)))); wayPaths.Add(new OSMWayND { @ref = (uint)unindexedNodeOffset - 1 }); } wayPaths.Add(new OSMWayND { @ref = (uint)(unindexedNodeOffset - chains.Count) }); //Back to the first chain switch(contourType) { case ContourType.Ground: wayTags.Add(new OSMWayTag { k = "natural", v = "coastline" }); break; case ContourType.Water: wayTags.Add(new OSMWayTag { k = "natural", v = "water" }); break; } osmWays.Add(new OSMWay { changeset = 50000000, id = (uint)unindexedWayOffset++, timestamp = DateTime.Now, user = "******", nd = wayPaths.ToArray(), tag = wayTags.ToArray(), version = 1 }); } } }
public static extern void gluNextContour(IntPtr tess, ContourType type);