Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/korijn/vtku3dexporter
Export a VTK scene into U3D (Universal 3D) format
https://github.com/korijn/vtku3dexporter
c-plus-plus python vtk vtk-module
Last synced: 3 months ago
JSON representation
Export a VTK scene into U3D (Universal 3D) format
- Host: GitHub
- URL: https://github.com/korijn/vtku3dexporter
- Owner: Korijn
- License: apache-2.0
- Created: 2021-11-24T15:23:19.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-07T02:56:27.000Z (4 months ago)
- Last Synced: 2024-10-07T16:04:59.329Z (3 months ago)
- Topics: c-plus-plus, python, vtk, vtk-module
- Language: C++
- Homepage:
- Size: 138 KB
- Stars: 3
- Watchers: 6
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vtk-u3dexporter
[![Build Wheels](https://github.com/ClinicalGraphics/VTKU3DExporter/actions/workflows/build_wheels.yml/badge.svg)](https://github.com/ClinicalGraphics/VTKU3DExporter/actions/workflows/build_wheels.yml)
[![PyPI Version](https://img.shields.io/pypi/v/vtk-u3dexporter.svg)](https://pypi.python.org/pypi/vtk-u3dexporter)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)`vtk-u3dexporter` is a VTK module for exporting a VTK 3D scene to the U3D file format, which can be embedded into PDF files.
It is available as both C++ class and a Python package.
## Installation
You can install `vtk-u3dexporter` via pip:
```sh
pip install vtk-u3dexporter
```## Usage
Here is a brief example of how to use `vtk-u3dexporter` to export a simple cube scene:
```python
import os
import vtk
from vtk import vtkU3DExporter# Define the cube source
cube = vtk.vtkCubeSource()# Define the cube mapper
cubeMapper = vtk.vtkPolyDataMapper()
cubeMapper.SetInputConnection(cube.GetOutputPort())# Define the cube actor
cubeActor = vtk.vtkActor()
cubeActor.SetMapper(cubeMapper)# Define the render window and renderer
renderWindow = vtk.vtkRenderWindow()
renderWindow.OffScreenRenderingOn()
renderer = vtk.vtkRenderer()
renderWindow.AddRenderer(renderer)# Add the cube to the renderer
renderer.AddActor(cubeActor)# Automatically reset the camera
renderer.ResetCamera()# Define the output file name, which will have the ".u3d" extension appended automatically
filePath = "cube"# Export to U3D
u3dExporter = vtkU3DExporter.vtkU3DExporter()
u3dExporter.SetFileName(filePath)
u3dExporter.SetInput(renderWindow)
u3dExporter.Write()# Check that the file exists
assert os.path.exists(f"{filePath}.u3d")
```In this example, we create a simple cube scene using VTK, add it to a renderer, and then export it to U3D format using `vtk-u3dexporter`. We then verify that the output file exists.
## License
`vtk-u3dexporter` is distributed under the Apache License 2.0. Please see the [LICENSE][LICENSE] file for details.
[LICENSE]: https://github.com/ClinicalGraphics/VTKU3DExporter/blob/main/LICENSE
## Resources
* [VTK website](https://docs.vtk.org)
* [U3D file format specification](https://www.ecma-international.org/publications-and-standards/standards/ecma-363/)