Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update worker and 3D viewer #230

Merged
merged 12 commits into from
Dec 20, 2023
Merged

Conversation

trungleduc
Copy link
Member

@trungleduc trungleduc commented Dec 6, 2023

Code changes:

Update JCAD format:

  • new outputs field with the following schema
    "outputs": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": {
        "^.*$": {
          "type": "string"
        }
      }

This field contains the output of the post-processing operator. The 3D viewer uses this field to render the shapes without re-run all post-processing operators at startup,

  • New part type Post::Operator with the following schema:
{
  "type": "object",
  "description": "Post::Operator",
  "title": "IPostOperator",
  "required": ["Object"],
  "additionalProperties": true,
  "properties": {
    "Object": {
      "type": "string",
      "description": "The name of input object"
    }
  }
}

This is a base part for all post-processing operators, the extensions need to extend this schema with the part prefixed with Post:: to be picked by JupyterCad

New tokens

  • IJCadFormSchemaRegistryToken: token allowing extension to register new form schema, this helps create parameter form and dialog.
  • IJCadExternalCommandRegistryToken: token allowing extension to add buttons to the JupyterCad toolbar

New worker system

  • IJCadWorkerRegistryToken token now exposes a default worker using occ-worker and allows registering more workers for the post-processing operator.
  • An external worker needs to implement the IJCadWorker interface.
  • On creation, the 3D viewer will register its message handlers with the default worker and all external workers.

New rendering routine:

  • On startup, the 3D viewer will send a WorkerAction.LOAD_FILE message to the default worker, the default worker then returns the parsed OCC shapes with the same flag. The viewer will render the OCC shapes and use data from outputs field of the shared model to render the post-processing operators.
  • On object change, the 3D viewer will send a WorkerAction.LOAD_FILE message to the default worker and get back the parsed OCC shapes and also the BREP strings of objects required in the post-processing operator.
  • These BREP strings will be sent to the registered workers with the WorkerAction.POSTPROCESS message. Once the workers finish processing data, they send back to the 3D view the STL string of processed shapes with the MainAction.DISPLAY_POST message.
  • The STL strings of processed shapes are saved into the outputs field of the shared model.

closes #236

Copy link
Contributor

github-actions bot commented Dec 6, 2023

Binder 👈 Launch a Binder on branch trungleduc/jupytercad/worker-support

@trungleduc trungleduc changed the title Refactor worker Update worker and 3D viewer Dec 18, 2023
@trungleduc trungleduc marked this pull request as ready for review December 18, 2023 21:08
@trungleduc trungleduc added this to the 1.0.0 milestone Dec 18, 2023
packages/base/src/mainview.tsx Outdated Show resolved Hide resolved
...module
}).then(async oc => {
for (const lib of libs) {
await oc.loadDynamicLibrary(lib, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what is this and why is it needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had an issue with building the Salome extension because of missing interfaces in opencascade.js so I tried to remove the opencascade.js dependency since we only need the init function.
It turned out the problem was a missing typescript config in the Salome extension, we can roll back to using the function provided by opencascade.js

@@ -18,6 +18,15 @@
}
},
"additionalProperties": false
},
"outputs": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to provide a way to clean outputs in the future?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, adding it now, the output needs to be deleted when the operator is removed

Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@martinRenou martinRenou merged commit 3f7da9c into jupytercad:main Dec 20, 2023
7 checks passed
@trungleduc trungleduc deleted the worker-support branch May 7, 2024 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switching tabs does not update the main view properly
2 participants