public static List <Polygon> OutlinePolygonsByShell(Shell shell, GridBasis basis) { double bottom = shell.BBox.Min.Z; double top = shell.BBox.Max.Z; Range1i levelRange = new Range1i(basis.Level(bottom), basis.Level(top)); List <Polygon> polygons = new List <Polygon>(); for (int level = levelRange.Low; level <= levelRange.High; ++level) { double height = basis.FloorHeight(level); Outline2d outline = shell.GetFloorOutline(height); if (outline == null) { continue; } if (outline.Polygons == null) { continue; } foreach (Polygon2d polygon in outline.Polygons) { polygons.Add(PolygonByPolygon2d(polygon, height)); } } return(polygons); }
internal Grid2d(Outline2d outline, GridBasis basis) { m_outline = outline; m_basis = basis; m_extents = m_basis.Extend(m_outline.BBox); m_axes = null; }
public Line2d ToLine(GridBasis basis, int ordinal) { return (new Line2d( new PointAxis2d.Value(m_abscissa, m_ordinate.Min).ToPoint(basis, ordinal), new PointAxis2d.Value(m_abscissa, m_ordinate.Max).ToPoint(basis, ordinal))); }
public static Value FromPoint2d(GridBasis basis, int ordinal, Point2d point, bool snap) { if (ordinal == 0) { int abscissa = basis.ToGrid(ordinal, point.X); if (!snap && !point.X.Compare(basis.FromGrid(ordinal, abscissa))) { return(null); } return(new Value(abscissa, point.Y)); } if (ordinal == 1) { int abscissa = basis.ToGrid(ordinal, point.Y); if (!snap && !point.Y.Compare(basis.FromGrid(ordinal, abscissa))) { return(null); } return(new Value(abscissa, point.X)); } return(null); }
internal void OutputBasis(ref string text, GridBasis basis) { string tag = "basis"; OutputHeader(ref text, tag); IndentIn(); List <Vector2d> vectors = basis.Vectors; for (int index = 0; index < vectors.Count; ++index) { OutputTextLine(ref text, "ordinal " + EncodeDouble(basis.GridSize(index)) + " " + EncodePoint2d(vectors[index])); } IndentOut(); OutputFooter(ref text, tag); }
public Point2d ToPoint(GridBasis basis, int ordinal) { double v0 = basis.FromGrid(ordinal, m_abscissa); double v1 = m_ordinate; if (ordinal == 0) { return(new Point2d(v0, v1)); } if (ordinal == 1) { return(new Point2d(v1, v0)); } return(null); }
internal void OutputAxes(ref string text, GridBasis basis, List <RangeAxis2d> axes) { if (axes == null) { return; } string tag = "axes"; OutputHeader(ref text, tag); IndentIn(); for (int index = 0; index < axes.Count; ++index) { OutputAxis(ref text, basis, index, axes[index]); } IndentOut(); OutputFooter(ref text, tag); }
internal void OutputAxis(ref string text, GridBasis basis, int ordinal, RangeAxis2d axis) { string tag = "axis"; OutputHeader(ref text, tag); IndentIn(); foreach (KeyValuePair <int, List <Range1d> > lineData in axis.Lines) { foreach (Range1d range in lineData.Value) { int v0 = basis.ToGrid(ordinal, range.Min); int v1 = basis.ToGrid(ordinal, range.Max); OutputTextLine(ref text, "seg " + EncodeInt(lineData.Key) + " " + EncodeInt(v0) + " " + EncodeInt(v1)); } } IndentOut(); OutputFooter(ref text, tag); }
public static Value FromLine2d(GridBasis basis, int ordinal, Line2d line, bool snap) { PointAxis2d.Value p0 = PointAxis2d.Value.FromPoint2d(basis, ordinal, line.StartPoint, snap); if (p0 == null) { return(null); } PointAxis2d.Value p1 = PointAxis2d.Value.FromPoint2d(basis, ordinal, line.EndPoint, snap); if (p1 == null) { return(null); } if (p0.Abscissa != p1.Abscissa) { return(null); } return(new Value(p0.Abscissa, new Range1d(p0.Ordinate, p1.Ordinate))); }
public static Grid2d ByOutline(Outline2d outline, GridBasis basis) { return(new Grid2d(outline, basis)); }
public RangeAxis2d(GridBasis basis, int ordinal) { m_basis = basis; m_ordinal = ordinal; m_lines = new SortedList <int, List <Range1d> >(); }
public PointAxis2d(GridBasis basis, int ordinal) { m_basis = basis; m_ordinal = ordinal; m_points = new SortedList <int, List <double> >(); }