Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

Implements 3D visualization capability for engineering and scientific file formats using VTK.js in the canvas panel, including a built-in MCP server for generating sample 3D shapes.

Changes

Core Implementation

  • New VtkViewer component handles 3D rendering for 11 formats: VTK legacy, VTK XML (VTP/VTU/VTI/VTS/VTR), STL, OBJ, PLY, GLTF/GLB
  • Extended CanvasPanel to route detected 3D files to VTK renderer
  • File type detection in useFiles.js recognizes engineering formats by extension

Rendering Pipeline

  • Automatic reader selection based on file format (vtkPolyDataReader, vtkSTLReader, etc.)
  • Handles both S3-stored files and inline base64 content from progress artifacts
  • Interactive controls: rotate (left-click drag), pan (right-click drag), zoom (scroll), reset view

VTK Example MCP Server

  • New MCP server in backend/mcp/vtk-example/ for generating 3D shapes on demand
  • Two tools: generate_3d_shape (single shapes) and generate_sample_files (all samples)
  • Generates cube, sphere, pyramid, cylinder, and torus in VTK/STL formats
  • Files automatically rendered as artifacts in canvas panel
  • Configured in config/defaults/mcp.json and available to all users
  • Includes standalone sample generator script (generate_samples.py)

Example Integration

// File type detection
getFileType('simulation.vtu')  // Returns 'vtk'

// Rendering in CanvasPanel
case 'vtk':
  return <VtkViewer fileContent={blob} filename={file.filename} />

Example Usage

Generate a sphere
Show me a torus
Create sample 3D files

Documentation & Testing

  • Comprehensive guide: supported formats, usage patterns, technical details, MCP server usage
  • 15 unit tests for file type detection
  • VTK Example MCP server with full documentation and README

Dependencies

Original prompt

This section details on the original issue you should resolve

<issue_title>add a engineering viz canvas rendering capability</issue_title>
<issue_description>use VTK.js to render common science and engineering files. </issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add VTK.js rendering capability for science and engineering files Add VTK.js rendering for engineering visualization files Nov 18, 2025
Copilot AI requested a review from garland3 November 18, 2025 04:55
Copilot finished work on behalf of garland3 November 18, 2025 04:55
Copy link
Collaborator

@copilot add an example mcp that returns files renderable by vtk. move the generation script to this folder. So make a new /backend/mcp/vtk-example mcp server

Copy link
Contributor Author

Copilot AI commented Nov 18, 2025

@copilot add an example mcp that returns files renderable by vtk. move the generation script to this folder. So make a new /backend/mcp/vtk-example mcp server

Created the vtk-example MCP server in backend/mcp/vtk-example/ with two tools:

  1. generate_3d_shape - Creates single shapes (cube, sphere, pyramid, cylinder, torus) in VTK/STL format
  2. generate_sample_files - Generates all 5 shapes at once

The generation script was moved to backend/mcp/vtk-example/generate_samples.py and improved to accept custom output directories.

The server is configured in config/defaults/mcp.json and automatically available to users. Files are returned as artifacts that auto-render in the canvas with the VTK.js viewer.

Commit: 1758ab4

Copilot AI changed the title Add VTK.js rendering for engineering visualization files Add VTK.js rendering for engineering visualization files with example MCP server Nov 18, 2025
Copilot finished work on behalf of garland3 November 18, 2025 05:26
@@ -0,0 +1,605 @@
import { useEffect, useRef, useState } from 'react'
import { RotateCw, ZoomIn, ZoomOut, Maximize2, Scissors, Play, Pause } from 'lucide-react'

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import RotateCw.

Copilot Autofix

AI 9 days ago

The best way to fix the problem is to remove any unused imports from the import statement on line 2. This will clarify which icons are actually used in the component, improve readability, and may have a small positive impact on the final bundle size.

Specifically:

  • Examine the code in frontend/src/components/VtkViewer.jsx and determine which (if any) of RotateCw, ZoomIn, ZoomOut, Maximize2, Scissors, Play, and Pause are actually used.
    • Remove each named import that is not referenced anywhere in the file.
    • Retain only those icons actively used (for e.g. in JSX as <ZoomIn />, etc.).
    • If none are used, remove the import statement entirely.
  • Make this change only to the import statement (lines 2–2).

No other changes, imports, or definitions are needed, and no dependencies.


Suggested changeset 1
frontend/src/components/VtkViewer.jsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/frontend/src/components/VtkViewer.jsx b/frontend/src/components/VtkViewer.jsx
--- a/frontend/src/components/VtkViewer.jsx
+++ b/frontend/src/components/VtkViewer.jsx
@@ -1,6 +1,6 @@
 import { useEffect, useRef, useState } from 'react'
-import { RotateCw, ZoomIn, ZoomOut, Maximize2, Scissors, Play, Pause } from 'lucide-react'
 
+
 // Import VTK.js modules
 import '@kitware/vtk.js/Rendering/Profiles/Geometry'
 import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow'
EOF
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from 'react'
import { RotateCw, ZoomIn, ZoomOut, Maximize2, Scissors, Play, Pause } from 'lucide-react'


// Import VTK.js modules
import '@kitware/vtk.js/Rendering/Profiles/Geometry'
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow'
Copilot is powered by AI and may make mistakes. Always verify output.


if __name__ == "__main__":
import sys

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'sys' is not used.

Copilot Autofix

AI 9 days ago

To fix the unused import issue, you should simply remove the line importing the sys module from scripts/generate_vtk_samples.py. This line appears at line 129 and can be deleted. No other changes are needed, as there is no use of sys anywhere else in the provided code. Only line 129 should be deleted, and care should be taken not to alter or remove any other code.


Suggested changeset 1
scripts/generate_vtk_samples.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/scripts/generate_vtk_samples.py b/scripts/generate_vtk_samples.py
--- a/scripts/generate_vtk_samples.py
+++ b/scripts/generate_vtk_samples.py
@@ -126,7 +126,6 @@
 
 
 if __name__ == "__main__":
-    import sys
     import os
     
     # Create test_data directory if it doesn't exist
EOF
@@ -126,7 +126,6 @@


if __name__ == "__main__":
import sys
import os

# Create test_data directory if it doesn't exist
Copilot is powered by AI and may make mistakes. Always verify output.
@github-actions
Copy link

🔒 Security Scan Results

Security Scan Summary

Scan Results

Python SAST (Bandit)

⚠️ Security issues found in Python code

Recommendations

  • Review all SARIF files uploaded to GitHub Security tab
  • Address high and critical severity vulnerabilities immediately
  • Run npm audit fix and pip-audit locally to fix dependencies
  • Consider implementing additional security controls

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.

add a engineering viz canvas rendering capability

2 participants