Diagram for .NET / User's Guide / Document Object Model / Models / Shapes / Routable Connectors and Routing

In This Topic
    Routable Connectors and Routing
    In This Topic

    Routing is the process of finding a path between two points, which strives not to cross any obstacles and also tries to obey certain aesthetic criterias, such as minimal number of turns, port orientation etc.

    Routing works with three corner stone objects:

    A route tries to avoid the current set of obstacles, residing in the manager container, by obtaining routing points from the routing manager.

     Routes

    You can force the reroute of a route with the help of the Reroute method, which must be implemented by each routable shape. Routes can be configured to automatically reroute themselves. This is specified by the RerouteAutomatically property (accept a value from the RerouteAutomatically enumeration). Currently the automatic reroute modes are: 

    • Never - the route is never automatically rerouted. You can still reroute the route by executing the Reroute command (from the context menu or from code).
    • Always - the route is automatically rerouted when any of the obstacles have changed (i.e. there is a possibility for the route to be rerouted in a better way).
    • When Needed - the route is automatically rerouted when an obstacle is placed on it (i.e. the route needs to be rerouted cause it crosses an obstacle).
     Routing Manager
    The routing manager is responsible for creating and maintaining routing graphs for the current set of obstacles existing in the container to which the manager is attached. The route finding uses a generic A-Star algorithm, which is by far the best known algorithm for fast finding of a route in a graph.

    The routing manager can be enabled or disabled, which is specified by the Enabled property. When the routing manager is disabled it will only reroute routes when routes request it (for example if you call the Reroute command from the context menu). Disabling the routing manager will globally disable automatic routing.

    The manager currently supports two types of routing graphs: grid and mesh.
     Grid Routing

    Grid routing is applicable for routable connectors of type Dynamic HV. In grid routing the manager always outputs a set of points, which are the vertices of an imaginary grid and hence the produced line segments are orthogonal. The grid can be built from the intersection of the lines formed by the obstacles sides or sides and centers - specified by the RoutingGridType property (accepts values of the of the RoutingGridType enumeration). 

    Also applicable for grid routing is the obstacle type, which is specified by the RouteObstacleType property of each shape (accepts values from the RouteObstacleType enumeration). Currently the obstacle type can be one of the following:

    • Route Around - a HV connector avoids the obstacle horizontally and vertically
    • Route Through - a HV connector does not avoid the obstacle (the route goes through the obstacle)
    • Route Through Horizontally - a HV connector can pass only horizontally through the obstacle
    • Route Through Vertically - a HV connector can pass only vertically through the obstacle
     Mesh Routing
    Mesh routing is applicable for routable connectors of type Dynamic Polyline and Curve. In mesh routing the manager outputs a set of points, which connect the start and end points in the shortest possible way. The mesh routing graph vertices are constructed by the obstacles corners - specified by the RoutingMeshType property (accepts values of the RoutingMeshType enumeration).
     Related Examples
    Windows Forms: Document Object Model - Shapes - Routable Connectors
    See Also