https://github.com/lace/hobart-svg
Render polygons, polylines, and mesh cross sections to SVG
https://github.com/lace/hobart-svg
cross-section mesh polygons polylines svg
Last synced: 6 months ago
JSON representation
Render polygons, polylines, and mesh cross sections to SVG
- Host: GitHub
- URL: https://github.com/lace/hobart-svg
- Owner: lace
- License: bsd-2-clause
- Created: 2018-10-12T02:12:15.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2023-09-01T08:54:13.000Z (about 2 years ago)
- Last Synced: 2025-04-14T00:11:55.759Z (6 months ago)
- Topics: cross-section, mesh, polygons, polylines, svg
- Language: Python
- Size: 167 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# hobart-svg
[][pypi]
[][pypi]
[][build]
[][docs build]
[][black]Render polygons, polylines, and mesh cross sections to SVG.
[pypi]: https://pypi.org/project/hobart-svg/
[black]: https://black.readthedocs.io/en/stable/
[build]: https://circleci.com/gh/lace/hobart-svg/tree/master
[docs build]: https://hobart-svg.readthedocs.io/en/latest/Features
--------- Render 2D and 3D polygons and polylines to SVG, with automatic computation
of the bounding rectangle.
- Render cross sections of [lacecore][]-style polygonal meshes.[lacecore]: https://github.com/lace/lacecore
Installation
------------```sh
pip install hobart-svg
```Usage
-----```sh
python -m hobart_svg.cli horizontal-xs \
--reference vitra_with_xs.dae \
examples/vitra/vitra_without_materials.obj \
15 30 45 60
``````py
from hobart_svg import render_longest_xsection_to_svg
import lacecore
import numpy as np
from polliwog import Plane
import vgmesh = lacecore.load_obj(filename="mesh.obj", triangulate=True)
plane = Plane(
reference_point=np.array([0.0, 30.0, 0.0]),
normal=vg.basis.y
)render_longest_xsection_to_svg(
mesh=mesh,
plane=plane,
filename="cross_section.svg")
``````py
from hobart_svg import render_longest_xsection_to_svg
import lacecore
from polliwog import Plane
from tri_again import Scenemesh = lacecore.load_obj(
filename="examples/vitra/vitra_without_materials.obj",
triangulate=True
)
plane = Plane(
reference_point=np.array([-0.869231, 60.8882, -20.1071]),
normal=vg.normalize(np.array([0., 0.1, -1.]))
)
xs = render_longest_xsection_to_svg(
mesh=mesh,
plane=plane,
filename="vitra_cross_section.svg"
)Scene().add_meshes(mesh).add_lines(xs).write("vitra_with_cross_section.dae")
```## Development
First, [install Poetry][].
After cloning the repo, run `./bootstrap.zsh` to initialize a virtual
environment with the project's dependencies.Subsequently, run `./dev.py install` to update the dependencies.
[install poetry]: https://python-poetry.org/docs/#installatio
License
-------The project is licensed under the two-clause BSD license.