public void TestMultipatchConversionWithTriangleStrip() { Rectangular[] positions = new[] { new Rectangular(0.0, 0.0), new Rectangular(0.0, 1.0), new Rectangular(1.0, 0.0), new Rectangular(1.0, 1.0), new Rectangular(2.0, 0.0), new Rectangular(2.0, 1.0), new Rectangular(3.0, 0.0) }; CartographicExtent extent = new CartographicExtent(0.0, 0.0, 3.0, 1.0); int[] parts = new[] { 0 }; MultiPatchPartType[] partTypes = new[] { MultiPatchPartType.TriangleStrip }; double[] zValues = new[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }; double[] measures = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures); MultiPatch patch = new MultiPatch(multipatch, m_document, Color.Blue); patch.Write(); string result = m_stringWriter.ToString(); Regex trianglePattern = new Regex(m_trianglePattern); Assert.AreEqual(5, trianglePattern.Matches(result).Count); }
public void TestMultipatchConversionWithMultipleRings() { Rectangular[] positions = new[] { new Rectangular(0.0, 5.0), new Rectangular(5.0, 10.0), new Rectangular(10.0, 5.0), new Rectangular(5.0, 0.0), new Rectangular(0.0, 5.0), new Rectangular(2.0, 5.0), new Rectangular(5.0, 2.0), new Rectangular(8.0, 5.0), new Rectangular(5.0, 8.0), new Rectangular(2.0, 5.0) }; CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0); int[] parts = new[] { 0, 5 }; MultiPatchPartType[] partTypes = new[] { MultiPatchPartType.Ring, MultiPatchPartType.Ring }; double[] zValues = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; double[] measures = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures); MultiPatch patch = new MultiPatch(multipatch, m_document, Color.Blue); patch.Write(); string result = m_stringWriter.ToString(); Regex polygonPattern = new Regex(m_polygonPattern); Assert.AreEqual(2, polygonPattern.Matches(result).Count); }
public void TestMultipatchConversionWithInnerAndOuterRings() { Rectangular[] positions = new[] { new Rectangular(0.0, 5.0), new Rectangular(5.0, 10.0), new Rectangular(10.0, 5.0), new Rectangular(5.0, 0.0), new Rectangular(0.0, 5.0), new Rectangular(2.0, 5.0), new Rectangular(5.0, 2.0), new Rectangular(8.0, 5.0), new Rectangular(5.0, 8.0), new Rectangular(2.0, 5.0) }; CartographicExtent extent = new CartographicExtent(0.0, 0.0, 10.0, 10.0); int[] parts = new[] { 0, 5 }; MultiPatchPartType[] partTypes = new[] { MultiPatchPartType.OuterRing, MultiPatchPartType.InnerRing }; double[] zValues = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; double[] measures = new[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; MultiPatchShape multipatch = new MultiPatchShape(0, m_metadata, extent, parts, partTypes, positions, 0.0, 0.0, zValues, 0.0, 0.0, measures); MultiPatch patch = new MultiPatch(multipatch, m_document, Color.Blue); patch.Write(); string result = m_stringWriter.ToString(); Assert.IsTrue(Regex.IsMatch(result, m_polygonPattern)); }
/// <summary> /// Writes the MultiPatch shape to its <see cref="CzmlDocument"/> as a series of polygon packets. /// </summary> public override void Write() { MultiPatchShape multipatch = (MultiPatchShape)m_shape; List <Polygon> polygons = new List <Polygon>(); StringDictionary metadata = new StringDictionary(); var fields = multipatch.GetMetadataFields(); foreach (String field in fields) { metadata.Add(field, multipatch.GetMetadataValue(field)); } for (int i = 0; i < multipatch.Count; i++) { List <ShapePart> polygonParts = new List <ShapePart>(); PolygonShape temp; switch (multipatch.GetPartType(i)) { case MultiPatchPartType.TriangleFan: case MultiPatchPartType.TriangleStrip: for (int j = 2; j < multipatch[i].Count; j++) { int firstIndex = (multipatch.GetPartType(i) == MultiPatchPartType.TriangleFan) ? 0 : j - 2; Cartographic[] vertices = new Cartographic[] { multipatch[i][firstIndex], multipatch[i][j - 1], multipatch[i][j] }; ShapePart triangle = new ShapePart(vertices, 0, vertices.Length); PolygonShape p = new PolygonShape(multipatch.RecordNumber, metadata, multipatch.Extent, new ShapePart[] { triangle }); (new Polygon(p, m_document, m_color)).Write(); } break; case MultiPatchPartType.Ring: while (i < multipatch.Count && multipatch.GetPartType(i) == MultiPatchPartType.Ring) { temp = new PolygonShape(multipatch.RecordNumber, metadata, multipatch.Extent, new ShapePart[] { multipatch[i] }); (new Polygon(temp, m_document, m_color)).Write(); i++; } i--; break; case MultiPatchPartType.OuterRing: case MultiPatchPartType.FirstRing: polygonParts.Add(multipatch[i]); MultiPatchPartType comparisonType = (multipatch.GetPartType(i) == MultiPatchPartType.OuterRing) ? MultiPatchPartType.InnerRing : MultiPatchPartType.Ring; while (++i < multipatch.Count && multipatch.GetPartType(i) == comparisonType) { polygonParts.Add(multipatch[i]); } temp = new PolygonShape(multipatch.RecordNumber, metadata, multipatch.Extent, polygonParts.ToArray()); (new Polygon(temp, m_document, m_color)).Write(); i--; break; } } }
/// <summary> /// Constructs a new multipatch <see cref="CzmlShape"/> from a <see cref="MultiPatchShape"/>. /// </summary> /// <param name="multiPatch">The shapefile multipatch shape</param>. /// <param name="document">The <see cref="CzmlDocument"/> to which the shape's CZML is written.</param> /// <param name="color">A color for the shape's visualization.</param> public MultiPatch(MultiPatchShape multiPatch, CzmlDocument document, Color color) : base(document, color) { m_shape = multiPatch; }