Class DGraph2Util
Utility functions for DGraph2 data structure
Namespace: g3
Assembly: cs.temp.dll.dll
Syntax
public static class DGraph2Util
Methods
ChainOpenPaths(DGraph2Util.Curves, Double)
merge members of c.Paths that have unique endpoint pairings.
Does not extract closed loops that contain junction vertices,
unless the 'other' end of those junctions is dangling.
Also, horribly innefficient!
Declaration
public static void ChainOpenPaths(DGraph2Util.Curves c, double epsilon = 2.2204460492503131E-16)
Parameters
DisconnectJunction(DGraph2, Int32, Double)
foreach edge [vid,b] connected to junction vertex vid, remove, add new vertex c,
and then add new edge [b,c]. Optionally move c a bit back along edge from vid.
Declaration
public static void DisconnectJunction(DGraph2 graph, int vid, double shrinkFactor = 1)
Parameters
DisconnectJunctions(DGraph2)
Find and remove any junction (ie valence>2) vertices of the graph.
At a junction, the pair of best-aligned (ie straightest) edges are left
connected, and all the other edges are disconnected
[TODO] currently there is no DGraph2.SetEdge(), so the 'other' edges
are deleted and new edges inserted. Hence, edge IDs are not preserved.
Declaration
public static int DisconnectJunctions(DGraph2 graph)
Parameters
Type |
Name |
Description |
DGraph2 |
graph |
|
Returns
Decompose graph into simple polylines and polygons.
Declaration
public static DGraph2Util.Curves ExtractCurves(DGraph2 graph)
Parameters
Type |
Name |
Description |
DGraph2 |
graph |
|
Returns
FindRayIntersection(Vector2d, Vector2d, out Int32, out Double, DGraph2)
Declaration
public static bool FindRayIntersection(Vector2d o, Vector2d d, out int hit_eid, out double hit_ray_t, DGraph2 graph)
Parameters
Returns
NextEdgeAndVtx(Int32, Int32, DGraph2)
If we are at edge eid, which as one vertex prev_vid, find 'other' vertex, and other edge connected to that vertex,
and return pair [next_edge, shared_vtx]
Returns [int.MaxValue, shared_vtx] if shared_vtx is not valence=2 (ie stops at boundaries and complex junctions)
Declaration
public static Index2i NextEdgeAndVtx(int eid, int prev_vid, DGraph2 graph)
Parameters
Returns
PathLength(DGraph2, IList<Int32>)
compute length of path through graph
Declaration
public static double PathLength(DGraph2 graph, IList<int> pathVertices)
Parameters
Returns
VertexLaplacian(DGraph2, Int32, out Boolean)
If vid has two or more neighbours, returns uniform laplacian, otherwise returns vid position
Declaration
public static Vector2d VertexLaplacian(DGraph2 graph, int vid, out bool isValid)
Parameters
Returns
WalkToNextNonRegularVtx(DGraph2, Int32, Int32)
walk through graph from fromVtx, in direction of eid, until we hit the next junction vertex
Declaration
public static List<int> WalkToNextNonRegularVtx(DGraph2 graph, int fromVtx, int eid)
Parameters
Returns