microsoft / msagljs

A JavaScript graph layout engine: port of MSAGL
https://microsoft.github.io/msagljs/
MIT License
146 stars 15 forks source link

Fix for spline PathOptimizer::getSleeve #63

Open redexp opened 1 year ago

redexp commented 1 year ago

Good day

I was playing around with this lib and stuck with error that on this line

if (t.containsPoint(this.poly.end)) {

t is undefined It's because method private getSleeve(sourceTriangle: Tr) gets sourceTriangle === undefined. Looking in code I found that this method used only ones

    const sleeve: FrontEdge[] = this.getSleeve(this.findSourceTriangle(localCdt))
    if (sleeve == null) {

so result of this method could be null or undefined and I decided to add check for sourceTriangle like

  private getSleeve(sourceTriangle: Tr): FrontEdge[] {
    if (!sourceTriangle) return;

and error gone

Why this.findSourceTriangle(localCdt) returns undefined I don't know, but I can give you my graph in json and code how I use it.

levnach commented 1 year ago

Thanks, sure, especially if it is a small graph.