internal SweepComparator(com.epl.geometry.EditShape shape, double tol, bool bIsSimple) : base(true) { m_shape = shape; m_sweep_y = com.epl.geometry.NumberUtils.TheNaN; m_sweep_x = 0; m_prev_x = 0; m_prev_y = com.epl.geometry.NumberUtils.TheNaN; m_tolerance = tol; m_tolerance_10 = 10 * tol; m_prevx_2 = com.epl.geometry.NumberUtils.TheNaN; m_prevx_1 = com.epl.geometry.NumberUtils.TheNaN; m_b_intersection_detected = false; m_prev_1 = -1; m_prev_2 = -1; m_vertex_1 = -1; m_vertex_2 = -1; m_current_node = -1; m_b_is_simple = bIsSimple; m_temp_simple_edge_1 = new com.epl.geometry.SweepComparator.SimpleEdge(); m_temp_simple_edge_2 = new com.epl.geometry.SweepComparator.SimpleEdge(); int s = System.Math.Min(shape.GetTotalPointCount() * 3 / 2, (int)(67)); /* SIMPLEDGE_CACHESIZE */ int cache_size = System.Math.Min((int)7, s); // m_simple_edges_buffer.reserve(cache_size);//must be reserved and // never grow beyond reserved size m_simple_edges_buffer = new System.Collections.Generic.List <com.epl.geometry.SweepComparator.SimpleEdge>(); m_simple_edges_recycle = new System.Collections.Generic.List <com.epl.geometry.SweepComparator.SimpleEdge>(); m_simple_edges_cache = new System.Collections.Generic.List <com.epl.geometry.SweepComparator.SimpleEdge>(); for (int i = 0; i < cache_size; i++) { m_simple_edges_cache.Add(null); } }
internal static bool Execute(com.epl.geometry.EditShape shape, com.epl.geometry.Envelope2D extent, double tolerance, com.epl.geometry.ProgressTracker progress_tracker) { if (!CanBeCracked(shape)) { // make sure it contains some segments, // otherwise no need to crack. return(false); } com.epl.geometry.Cracker cracker = new com.epl.geometry.Cracker(progress_tracker); cracker.m_shape = shape; cracker.m_tolerance = tolerance; // Use brute force for smaller shapes, and a planesweep for bigger // shapes. bool b_cracked = false; if (shape.GetTotalPointCount() < 15) { // what is a good number? b_cracked = cracker.CrackBruteForce_(); } else { bool b_cracked_1 = cracker.CrackerPlaneSweep_(); return(b_cracked_1); } return(b_cracked); }
public static bool Execute(com.epl.geometry.EditShape shape, double tolerance, com.epl.geometry.ProgressTracker progressTracker, bool filter_degenerate_segments) { com.epl.geometry.CrackAndCluster cracker = new com.epl.geometry.CrackAndCluster(progressTracker); cracker.m_shape = shape; cracker.m_tolerance = tolerance; cracker.m_filter_degenerate_segments = filter_degenerate_segments; return(cracker._do()); }
internal static bool Execute(com.epl.geometry.EditShape shape, int geometry, com.epl.geometry.IndexMultiDCList sorted_vertices, bool fixSelfTangency) { com.epl.geometry.RingOrientationFixer fixer = new com.epl.geometry.RingOrientationFixer(); fixer.m_shape = shape; fixer.m_geometry = geometry; fixer.m_sorted_vertices = sorted_vertices; fixer.m_fixSelfTangency = fixSelfTangency; return(fixer.FixRingOrientation_()); }
// Clusters vertices of the shape. Returns True, if some vertices were moved // (clustered). // Uses reciprocal clustering (cluster vertices that are mutual nearest // neighbours) /* * static boolean executeReciprocal(EditShape shape, double tolerance) { * Clusterer clusterer = new Clusterer(); clusterer.m_shape = shape; * clusterer.m_tolerance = tolerance; clusterer.m_sqr_tolerance = tolerance * * tolerance; clusterer.m_cell_size = 2 * tolerance; * clusterer.m_inv_cell_size = 1.0 / clusterer.m_cell_size; return * clusterer.clusterReciprocal_(); } */ // Clusters vertices of the shape. Returns True, if some vertices were moved // (clustered). // Uses non-reciprocal clustering (cluster any vertices that are closer than // the tolerance in the first-found-first-clustered order) internal static bool ExecuteNonReciprocal(com.epl.geometry.EditShape shape, double tolerance) { com.epl.geometry.Clusterer clusterer = new com.epl.geometry.Clusterer(); clusterer.m_shape = shape; clusterer.m_tolerance = tolerance; clusterer.m_sqr_tolerance = tolerance * tolerance; clusterer.m_cell_size = 2 * tolerance; clusterer.m_inv_cell_size = 1.0 / clusterer.m_cell_size; return(clusterer.ClusterNonReciprocal_()); }
public ClusterHashFunction(Clusterer _enclosing, com.epl.geometry.EditShape shape, com.epl.geometry.Point2D origin, double sqr_tolerance, double inv_cell_size, int hash_values) { this._enclosing = _enclosing; this.m_shape = shape; this.m_sqr_tolerance = sqr_tolerance; this.m_inv_cell_size = inv_cell_size; this.m_origin = origin; this.m_hash_values = hash_values; this.m_pt.SetNaN(); this.m_pt_2.SetNaN(); }
public static bool Execute(com.epl.geometry.EditShape shape, int geometry, int knownSimpleResult, bool fixSelfTangency, com.epl.geometry.ProgressTracker progressTracker) { com.epl.geometry.Simplificator simplificator = new com.epl.geometry.Simplificator(); simplificator.m_shape = shape; // simplificator.m_bWinding = bWinding; simplificator.m_geometry = geometry; simplificator.m_knownSimpleResult = knownSimpleResult; simplificator.m_fixSelfTangency = fixSelfTangency; simplificator.m_progressTracker = progressTracker; return(simplificator._simplify()); }
internal ConvexHull() { /* * Constructor for a Convex_hull object. Used for dynamic insertion of geometries to create a convex hull. */ m_tree_hull = new com.epl.geometry.Treap(); m_tree_hull.SetCapacity(20); m_shape = new com.epl.geometry.EditShape(); m_geometry_handle = m_shape.CreateGeometry(com.epl.geometry.Geometry.Type.MultiPoint); m_path_handle = m_shape.InsertPath(m_geometry_handle, -1); m_call_back = new com.epl.geometry.ConvexHull.CallBackShape(this); }
internal static bool CanBeCracked(com.epl.geometry.EditShape shape) { for (int geometry = shape.GetFirstGeometry(); geometry != -1; geometry = shape.GetNextGeometry(geometry)) { if (!com.epl.geometry.Geometry.IsMultiPath(shape.GetGeometryType(geometry))) { continue; } return(true); } return(false); }
internal SweepMonkierComparator(com.epl.geometry.EditShape shape, double tol) { m_shape = shape; m_tolerance = tol; m_b_intersection_detected = false; m_vertex_1 = -1; m_env = new com.epl.geometry.Envelope1D(); m_point_of_interest = new com.epl.geometry.Point2D(); m_point_of_interest.SetNaN(); m_line_1 = new com.epl.geometry.Line(); m_current_node = -1; m_min_dist = com.epl.geometry.NumberUtils.DoubleMax(); }
// Used for IsSimple. internal static bool NeedsCracking(bool allowCoincident, com.epl.geometry.EditShape shape, double tolerance, com.epl.geometry.NonSimpleResult result, com.epl.geometry.ProgressTracker progress_tracker) { if (!CanBeCracked(shape)) { return(false); } com.epl.geometry.Cracker cracker = new com.epl.geometry.Cracker(progress_tracker); cracker.m_shape = shape; cracker.m_tolerance = tolerance; cracker.m_bAllowCoincident = allowCoincident; if (cracker.NeedsCrackingImpl_()) { if (result != null) { result.Assign(cracker.m_non_simple_result); } return(true); } // Now swap the coordinates to catch horizontal cases. com.epl.geometry.Transformation2D transform = new com.epl.geometry.Transformation2D(); transform.SetSwapCoordinates(); shape.ApplyTransformation(transform); cracker = new com.epl.geometry.Cracker(progress_tracker); cracker.m_shape = shape; cracker.m_tolerance = tolerance; cracker.m_bAllowCoincident = allowCoincident; bool b_res = cracker.NeedsCrackingImpl_(); transform.SetSwapCoordinates(); shape.ApplyTransformation(transform); // restore shape if (b_res) { if (result != null) { result.Assign(cracker.m_non_simple_result); } return(true); } return(false); }
// no cuts private void Generate_polygon_cuts_() { com.epl.geometry.AttributeStreamOfInt32 cutHandles = new com.epl.geometry.AttributeStreamOfInt32(0); com.epl.geometry.EditShape shape = new com.epl.geometry.EditShape(); int sideIndex = shape.CreateGeometryUserIndex(); int cutteeHandle = shape.AddGeometry(m_cuttee); int cutterHandle = shape.AddGeometry(m_cutter); com.epl.geometry.TopologicalOperations topoOp = new com.epl.geometry.TopologicalOperations(); try { topoOp.SetEditShapeCrackAndCluster(shape, m_tolerance, m_progressTracker); topoOp.Cut(sideIndex, cutteeHandle, cutterHandle, cutHandles); com.epl.geometry.Polygon cutteeRemainder = (com.epl.geometry.Polygon)shape.GetGeometry(cutteeHandle); com.epl.geometry.MultiPath left = new com.epl.geometry.Polygon(); com.epl.geometry.MultiPath right = new com.epl.geometry.Polygon(); m_cuts.Clear(); m_cuts.Add(left); m_cuts.Add(right); for (int icutIndex = 0; icutIndex < cutHandles.Size(); icutIndex++) { com.epl.geometry.Geometry cutGeometry; { // intersection com.epl.geometry.EditShape shapeIntersect = new com.epl.geometry.EditShape(); int geometryA = shapeIntersect.AddGeometry(cutteeRemainder); int geometryB = shapeIntersect.AddGeometry(shape.GetGeometry(cutHandles.Get(icutIndex))); topoOp.SetEditShape(shapeIntersect, m_progressTracker); int intersectHandle = topoOp.Intersection(geometryA, geometryB); cutGeometry = shapeIntersect.GetGeometry(intersectHandle); if (cutGeometry.IsEmpty()) { continue; } int side = shape.GetGeometryUserIndex(cutHandles.Get(icutIndex), sideIndex); if (side == 2) { left.Add((com.epl.geometry.MultiPath)cutGeometry, false); } else { if (side == 1) { right.Add((com.epl.geometry.MultiPath)cutGeometry, false); } else { m_cuts.Add((com.epl.geometry.MultiPath)cutGeometry); } } } { // Undefined // difference com.epl.geometry.EditShape shapeDifference = new com.epl.geometry.EditShape(); int geometryA = shapeDifference.AddGeometry(cutteeRemainder); int geometryB = shapeDifference.AddGeometry(shape.GetGeometry(cutHandles.Get(icutIndex))); topoOp.SetEditShape(shapeDifference, m_progressTracker); cutteeRemainder = (com.epl.geometry.Polygon)shapeDifference.GetGeometry(topoOp.Difference(geometryA, geometryB)); } } if (!cutteeRemainder.IsEmpty() && cutHandles.Size() > 0) { m_cuts.Add((com.epl.geometry.MultiPath)cutteeRemainder); } if (left.IsEmpty() && right.IsEmpty()) { m_cuts.Clear(); } } finally { // no cuts topoOp.RemoveShape(); } }
internal static bool Execute(com.epl.geometry.EditShape shape, double tolerance, com.epl.geometry.ProgressTracker progress_tracker) { return(com.epl.geometry.Cracker.Execute(shape, shape.GetEnvelope2D(), tolerance, progress_tracker)); }
internal Edges(com.epl.geometry.EditShape shape) { m_shape = shape; m_first_free = -1; }
internal override int Compare(com.epl.geometry.Treap treap, int left, int node) { int right = treap.GetElement(node); com.epl.geometry.RingOrientationFixer.Edges edges = this.m_helper.m_edges; double x_1; if (this.m_left_elm == left) { x_1 = this.m_leftx; } else { this.m_seg_1 = edges.GetSegment(left); if (this.m_seg_1 == null) { com.epl.geometry.EditShape shape = edges.GetShape(); shape.QueryLineConnector(edges.GetStart(left), this.m_line_1); this.m_seg_1 = this.m_line_1; x_1 = this.m_line_1.IntersectionOfYMonotonicWithAxisX(this.m_helper.m_y_scanline, 0); } else { x_1 = this.m_seg_1.IntersectionOfYMonotonicWithAxisX(this.m_helper.m_y_scanline, 0); } this.m_leftx = x_1; this.m_left_elm = left; } com.epl.geometry.Segment seg_2 = edges.GetSegment(right); double x2; if (seg_2 == null) { com.epl.geometry.EditShape shape = edges.GetShape(); shape.QueryLineConnector(edges.GetStart(right), this.m_line_2); seg_2 = this.m_line_2; x2 = this.m_line_2.IntersectionOfYMonotonicWithAxisX(this.m_helper.m_y_scanline, 0); } else { x2 = seg_2.IntersectionOfYMonotonicWithAxisX(this.m_helper.m_y_scanline, 0); } if (x_1 == x2) { bool bStartLower1 = edges.IsBottomUp(left); bool bStartLower2 = edges.IsBottomUp(right); // apparently these edges originate from same vertex and the // scanline is on the vertex. move scanline a little. double y1 = !bStartLower1?this.m_seg_1.GetStartY() : this.m_seg_1.GetEndY(); double y2 = !bStartLower2?seg_2.GetStartY() : seg_2.GetEndY(); double miny = System.Math.Min(y1, y2); double y = (miny + this.m_helper.m_y_scanline) * 0.5; if (y == this.m_helper.m_y_scanline) { // assert(0);//ST: not a bug. just curious to see this // happens. y = miny; } // apparently, one of the segments is almost // horizontal line. x_1 = this.m_seg_1.IntersectionOfYMonotonicWithAxisX(y, 0); x2 = seg_2.IntersectionOfYMonotonicWithAxisX(y, 0); System.Diagnostics.Debug.Assert((x_1 != x2)); } return(x_1 < x2 ? -1 : (x_1 > x2 ? 1 : 0)); }
public static void TestEditShape__() { { // Single part polygon com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon(); poly.StartPath(10, 10); poly.LineTo(10, 12); poly.LineTo(14, 15); poly.LineTo(10, 11); com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape(); int geom = editShape.AddGeometry(poly); com.epl.geometry.Polygon poly2 = (com.epl.geometry.Polygon)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(poly.Equals(poly2)); } { // Two part poly com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon(); poly.StartPath(10, 10); poly.LineTo(10, 12); poly.LineTo(14, 15); poly.LineTo(10, 11); poly.StartPath(100, 10); poly.LineTo(100, 12); poly.LineTo(14, 150); poly.LineTo(10, 101); poly.LineTo(100, 11); com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape(); int geom = editShape.AddGeometry(poly); com.epl.geometry.Polygon poly2 = (com.epl.geometry.Polygon)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(poly.Equals(poly2)); } { // Single part polyline com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline(); poly.StartPath(10, 10); poly.LineTo(10, 12); poly.LineTo(14, 15); poly.LineTo(10, 11); com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape(); int geom = editShape.AddGeometry(poly); com.epl.geometry.Polyline poly2 = (com.epl.geometry.Polyline)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(poly.Equals(poly2)); } { // Two part poly com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline(); poly.StartPath(10, 10); poly.LineTo(10, 12); poly.LineTo(14, 15); poly.LineTo(10, 11); poly.StartPath(100, 10); poly.LineTo(100, 12); poly.LineTo(14, 150); poly.LineTo(10, 101); poly.LineTo(100, 11); com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape(); int geom = editShape.AddGeometry(poly); com.epl.geometry.Polyline poly2 = (com.epl.geometry.Polyline)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(poly.Equals(poly2)); } { // Five part poly. Close one of parts to test if it works. com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline(); poly.StartPath(10, 10); poly.LineTo(10, 12); poly.LineTo(14, 15); poly.LineTo(10, 11); poly.StartPath(100, 10); poly.LineTo(100, 12); poly.LineTo(14, 150); poly.LineTo(10, 101); poly.LineTo(100, 11); poly.StartPath(1100, 101); poly.LineTo(1300, 132); poly.LineTo(144, 150); poly.LineTo(106, 1051); poly.LineTo(1600, 161); poly.StartPath(100, 190); poly.LineTo(1800, 192); poly.LineTo(184, 8150); poly.LineTo(1080, 181); poly.StartPath(1030, 10); poly.LineTo(1300, 132); poly.LineTo(314, 3150); poly.LineTo(310, 1301); poly.LineTo(3100, 311); com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape(); int geom = editShape.AddGeometry(poly); editShape.SetClosedPath(editShape.GetNextPath(editShape.GetFirstPath(geom)), true); ((com.epl.geometry.MultiPathImpl)poly._getImpl()).ClosePathWithLine(1); com.epl.geometry.Polyline poly2 = (com.epl.geometry.Polyline)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(poly.Equals(poly2)); } { // Test erase com.epl.geometry.Polyline poly = new com.epl.geometry.Polyline(); poly.StartPath(10, 10); poly.LineTo(10, 12); poly.LineTo(314, 3150); poly.LineTo(310, 1301); poly.LineTo(3100, 311); com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape(); int geom = editShape.AddGeometry(poly); int vertex = editShape.GetFirstVertex(editShape.GetFirstPath(geom)); vertex = editShape.RemoveVertex(vertex, true); vertex = editShape.GetNextVertex(vertex); editShape.RemoveVertex(vertex, true); com.epl.geometry.Polyline poly2 = (com.epl.geometry.Polyline)editShape.GetGeometry(geom); poly.SetEmpty(); poly.StartPath(10, 12); poly.LineTo(310, 1301); poly.LineTo(3100, 311); NUnit.Framework.Assert.IsTrue(poly.Equals(poly2)); } { // Test erase com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon(); poly.StartPath(10, 10); poly.LineTo(10, 12); poly.LineTo(314, 3150); poly.LineTo(310, 1301); poly.LineTo(3100, 311); com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape(); int geom = editShape.AddGeometry(poly); int vertex = editShape.GetFirstVertex(editShape.GetFirstPath(geom)); vertex = editShape.RemoveVertex(vertex, true); vertex = editShape.GetNextVertex(vertex); editShape.RemoveVertex(vertex, true); com.epl.geometry.Polygon poly2 = (com.epl.geometry.Polygon)editShape.GetGeometry(geom); poly.SetEmpty(); poly.StartPath(10, 12); poly.LineTo(310, 1301); poly.LineTo(3100, 311); NUnit.Framework.Assert.IsTrue(poly.Equals(poly2)); } { // Test Filter Close Points com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon(); poly.StartPath(10, 10); poly.LineTo(10, 10.001); poly.LineTo(10.001, 10); com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape(); int geom = editShape.AddGeometry(poly); editShape.FilterClosePoints(0.002, true, false); com.epl.geometry.Polygon poly2 = (com.epl.geometry.Polygon)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(poly2.IsEmpty()); } { // Test Filter Close Points com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon(); poly.StartPath(10, 10); poly.LineTo(10, 10.0025); poly.LineTo(11.0, 10); com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape(); int geom = editShape.AddGeometry(poly); editShape.FilterClosePoints(0.002, true, false); com.epl.geometry.Polygon poly2 = (com.epl.geometry.Polygon)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(!poly2.IsEmpty()); } { // Test Filter Close Points com.epl.geometry.Polygon poly = new com.epl.geometry.Polygon(); poly.StartPath(10, 10); poly.LineTo(10, 10.001); poly.LineTo(11.0, 10); com.epl.geometry.EditShape editShape = new com.epl.geometry.EditShape(); int geom = editShape.AddGeometry(poly); editShape.FilterClosePoints(0.002, true, false); com.epl.geometry.Polygon poly2 = (com.epl.geometry.Polygon)editShape.GetGeometry(geom); NUnit.Framework.Assert.IsTrue(poly2.IsEmpty()); } { // Test attribute splitting 1 com.epl.geometry.Polyline polyline = new com.epl.geometry.Polyline(); polyline.StartPath(0, 0); polyline.LineTo(1, 1); polyline.LineTo(2, 2); polyline.LineTo(3, 3); polyline.LineTo(4, 4); polyline.StartPath(5, 5); polyline.LineTo(6, 6); polyline.LineTo(7, 7); polyline.LineTo(8, 8); polyline.LineTo(9, 9); polyline.AddAttribute(com.epl.geometry.VertexDescription.Semantics.Z); polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 0, 0, 4); polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 1, 0, 8); polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 2, 0, 12); polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 3, 0, 16); polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 4, 0, 20); polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 5, 0, 22); polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 6, 0, 26); polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 7, 0, 30); polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 8, 0, 34); polyline.SetAttribute(com.epl.geometry.VertexDescription.Semantics.Z, 9, 0, 38); com.epl.geometry.EditShape shape = new com.epl.geometry.EditShape(); int geometry = shape.AddGeometry(polyline); com.epl.geometry.AttributeStreamOfInt32 vertex_handles = new com.epl.geometry.AttributeStreamOfInt32(0); for (int path = shape.GetFirstPath(geometry); path != -1; path = shape.GetNextPath(path)) { for (int vertex = shape.GetFirstVertex(path); vertex != -1; vertex = shape.GetNextVertex(vertex)) { if (vertex != shape.GetLastVertex(path)) { vertex_handles.Add(vertex); } } } double[] t = new double[1]; for (int i = 0; i < vertex_handles.Size(); i++) { int vertex = vertex_handles.Read(i); t[0] = 0.5; shape.SplitSegment(vertex, t, 1); } com.epl.geometry.Polyline chopped_polyline = (com.epl.geometry.Polyline)shape.GetGeometry(geometry); NUnit.Framework.Assert.IsTrue(chopped_polyline.GetPointCount() == 18); double att_ = 4; for (int i_1 = 0; i_1 < 18; i_1++) { double att = chopped_polyline.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.Z, i_1, 0); NUnit.Framework.Assert.IsTrue(att == att_); att_ += 2; } } { // Test attribute splitting 2 com.epl.geometry.Polyline line1 = new com.epl.geometry.Polyline(); com.epl.geometry.Polyline line2 = new com.epl.geometry.Polyline(); line1.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M); line2.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M); line1.StartPath(0, 0); line1.LineTo(10, 10); line2.StartPath(10, 0); line2.LineTo(0, 10); line1.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 0, 0, 7); line1.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 1, 0, 17); line2.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 0, 0, 5); line2.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 1, 0, 15); com.epl.geometry.EditShape shape = new com.epl.geometry.EditShape(); int g1 = shape.AddGeometry(line1); int g2 = shape.AddGeometry(line2); com.epl.geometry.CrackAndCluster.Execute(shape, 0.001, null, true); com.epl.geometry.Polyline chopped_line1 = (com.epl.geometry.Polyline)shape.GetGeometry(g1); com.epl.geometry.Polyline chopped_line2 = (com.epl.geometry.Polyline)shape.GetGeometry(g2); double att1 = chopped_line1.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 1, 0); double att2 = chopped_line2.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 1, 0); NUnit.Framework.Assert.IsTrue(att1 == 12); NUnit.Framework.Assert.IsTrue(att2 == 10); } { // Test attribute splitting 3 com.epl.geometry.Polygon polygon = new com.epl.geometry.Polygon(); polygon.AddAttribute(com.epl.geometry.VertexDescription.Semantics.M); polygon.StartPath(0, 0); polygon.LineTo(0, 10); polygon.LineTo(10, 10); polygon.LineTo(10, 0); polygon.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 0, 0, 7); polygon.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 1, 0, 17); polygon.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 2, 0, 23); polygon.SetAttribute(com.epl.geometry.VertexDescription.Semantics.M, 3, 0, 43); com.epl.geometry.EditShape shape = new com.epl.geometry.EditShape(); int geometry = shape.AddGeometry(polygon); com.epl.geometry.AttributeStreamOfInt32 vertex_handles = new com.epl.geometry.AttributeStreamOfInt32(0); int start_v = shape.GetFirstVertex(shape.GetFirstPath(geometry)); int v = start_v; do { vertex_handles.Add(v); v = shape.GetNextVertex(v); }while (v != start_v); double[] t = new double[1]; for (int i = 0; i < vertex_handles.Size(); i++) { int v1 = vertex_handles.Read(i); t[0] = 0.5; shape.SplitSegment(v1, t, 1); } com.epl.geometry.Polygon cut_polygon = (com.epl.geometry.Polygon)shape.GetGeometry(geometry); NUnit.Framework.Assert.IsTrue(cut_polygon.GetPointCount() == 8); com.epl.geometry.Point2D pt0 = cut_polygon.GetXY(0); double a0 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 0, 0); NUnit.Framework.Assert.IsTrue(a0 == 25); com.epl.geometry.Point2D pt1 = cut_polygon.GetXY(1); double a1 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 1, 0); NUnit.Framework.Assert.IsTrue(a1 == 7); com.epl.geometry.Point2D pt2 = cut_polygon.GetXY(2); double a2 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 2, 0); NUnit.Framework.Assert.IsTrue(a2 == 12); com.epl.geometry.Point2D pt3 = cut_polygon.GetXY(3); double a3 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 3, 0); NUnit.Framework.Assert.IsTrue(a3 == 17); com.epl.geometry.Point2D pt4 = cut_polygon.GetXY(4); double a4 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 4, 0); NUnit.Framework.Assert.IsTrue(a4 == 20); com.epl.geometry.Point2D pt5 = cut_polygon.GetXY(5); double a5 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 5, 0); NUnit.Framework.Assert.IsTrue(a5 == 23); com.epl.geometry.Point2D pt6 = cut_polygon.GetXY(6); double a6 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 6, 0); NUnit.Framework.Assert.IsTrue(a6 == 33); com.epl.geometry.Point2D pt7 = cut_polygon.GetXY(7); double a7 = cut_polygon.GetAttributeAsDbl(com.epl.geometry.VertexDescription.Semantics.M, 7, 0); NUnit.Framework.Assert.IsTrue(a7 == 43); } }