Skip to content

buildFromPolygon throws std::length_error #20

Description

@janis-github

Here is the source:

await SkeletonBuilder.init()

const data = [
  [7481, 274],
  [10509, 115],
  [10555, 964],
  [7481, 1126],
  [7481, 1866],
  [4356, 1866],
  [4356, -1896],
  [7481, -1896],
  [7481, 274],
]

SkeletonBuilder.buildFromPolygon([data])

It produces the following error:

Uncaught P std::length_error: vector
    at __cxa_throw (/Users/janis/react/node_modules/straight-skeleton/dist/index.js:1:1019020)
    at $func147 (wasm/002de27a.wat:35918:1)
    at $func138 (wasm/002de27a.wat:35424:1)
    at $func880 (wasm/002de27a.wat:131102:1)
    at $func903 (wasm/002de27a.wat:136677:1)
    at $func874 (wasm/002de27a.wat:128794:1)
    at $func1307 (wasm/002de27a.wat:190838:1)
    at $func1497 (wasm/002de27a.wat:221464:1)
    at $func41 (wasm/002de27a.wat:20708:1)
    at $create_straight_skeleton (wasm/002de27a.wat:28542:1)

Would it be possible to know why this happens? Maybe there is something specific with the polygon what triggers it that would suggest a workaround?

This polygon works fine:

const data = [
  [7481, 274],
  [10509, 215],  // changing 115 to 215 here fixes the crash!
  [10555, 964],
  [7481, 1126],
  [7481, 1866],
  [4356, 1866],
  [4356, -1896],
  [7481, -1896],
  [7481, 274],
]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions