Skip to content

Commit

Permalink
cmp
Browse files Browse the repository at this point in the history
  • Loading branch information
claudioperez committed Feb 6, 2025
1 parent b5d6d5c commit fb18efc
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 136 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,9 @@ Documentation is available at [https://veux.io/](https://veux.io).
## Features

- **Detailed** Render frames with extruded cross sections
- **Persistence**: Save your finite element visualizations as persistent 3D models that can be revisited and analyzed at any time.
- **Portability**: Share your models effortlessly with colleagues, enabling seamless collaboration and review.
- **Persistence**: Save finite element visualizations as persistent 3D models that can be revisited and analyzed at any time.
- **Portability**: Share renderings effortlessly with colleagues, enabling seamless collaboration and review.
- **Accessibility**: View and interact with the models using any standard 3D model viewer, eliminating the need for specialized software or Python installation.
- **Versatility**: A wide selection of rendering backends and output file types, including
optimized 3D web formats like `.glb`. Generated 3D models can be loaded directly into programs like PowerPoint and animated.
- Correctly render models that treat both `y` or `z` as the
vertical coordinate.

--------------------------------------------------------------------

Expand Down
69 changes: 50 additions & 19 deletions docs/_templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,40 +186,71 @@ <h2 class="">Gallery</h2>
<section>
<div class="container">
<h2>Ecosystem</h2>
<div class="col-md-8 mx-auto text-center">
<p>
<em><strong>veux</strong></em> is a part of the larger <a href="https://stairlab.berkeley.edu">STAIRLab</a> ecosystem.
STAIRLab is a research group at the University of California, Berkeley, that focuses on the development of
computational tools for the analysis and design of structures and infrastructure systems.
</p>
<hr class="my-4">
<div class="row g-3">
<div class="col-sm-6 mb-2">
<a class="d-block pe-lg-4 text-decoration-none lh-sm" href="https://chrystalchern.github.io/mdof/">
<h4 class="mb-0 fs-5 fw-semibold">mdof</h4>
<small class="text-body-secondary">Fast and friendly system identification.</small>
</a>
</div>
<div class="col-sm-6 mb-2">
<a class="d-block pe-lg-4 text-decoration-none lh-sm" href="https://github.com/claudioperez/OpenSeesRT">
<h4 class="mb-0 fs-5 fw-semibold">sees</h4>
<small class="text-body-secondary">Fast and stateless bindings to the OpenSees Framework for finite element analysis.</small>
</a>
</div>
<div class="col-sm-6 mb-2">
<a class="d-block pe-lg-4 text-decoration-none lh-sm" href="https://pypi.org/project/irie">
<h4 class="mb-0 fs-5 fw-semibold">irie</h4>
<small class="text-body-secondary">An infrastructure resilience engine.</small>
</a>
</div>
</div>
</div>
</div>
</section>

<section>
<div class="container">
<table style="width: 83.4204%; height: 221px;"> <!-- -->
<tbody>
<tr style="height: 107px;">
<td style="height: 107px;"><a href="https://peer.berkeley.edu/"><img decoding="async" class="wp-image-593 size-full aligncenter" src="https://stairlab.berkeley.edu/wp-content/uploads/2025/01/PEER_logo_old.svg" alt="PEER logo"></a></td>
<td style="height: 107px;"><a href="https://dot.ca.gov/" rel="nofollow"><img decoding="async" class="aligncenter" src="https://raw.githubusercontent.com/claudioperez/sdof/master/docs/assets/Caltrans.svg.png" alt="Caltrans Logo" width="100"></a></td>
<td style="height: 107px;"><a href="https://www.conservation.ca.gov"><img decoding="async" class="size-medium aligncenter" src="https://www.conservation.ca.gov/_catalogs/masterpage/DOC/images/DOC-logo-mobile.svg" width="300" height="89"></a></td>
<td style="height: 107px;"><img decoding="async" src="https://earimediaprodweb.azurewebsites.net/Api/v1/Multimedia/d4957b87-a007-48a9-8a66-d298a625b80c/Rendition/low-res/Content/Public" alt="Berkeley Lab logo [IMAGE] | EurekAlert! Science News Releases"></td>
</tr>
<tr style="height: 114px;">
<td style="height: 114px; width: 22.6732%;"><a href="https://nsf.gov/" rel="nofollow"><img decoding="async" class="aligncenter" src="https://raw.githubusercontent.com/STAIRlab/.github/master/profile/assets/NSF_4-Color_bitmap_Logo.png" alt="NSF Logo" width="100"></a></td>
<td style="height: 114px; width: 19.8796%;"><a href="https://steer.network/" rel="nofollow"><img decoding="async" class="aligncenter" src="https://raw.githubusercontent.com/STAIRlab/.github/master/profile/assets/StEER-logo_thumb-2_lg.png" alt="StEER Logo" width="100"></a></td>
<td style="height: 114px; width: 22.6342%;"><a href="https://nsf.gov/" rel="nofollow"><img decoding="async" class="aligncenter" src="https://raw.githubusercontent.com/STAIRlab/.github/master/profile/assets/StEER-logo_words%20only.png" alt="NSF Logo" width="100"></a></td>
<td style="width: 17.9355%; height: 107px;"><img decoding="async" class="aligncenter" src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/26/Bart-logo.svg/1280px-Bart-logo.svg.png" alt="File:Bart-logo.svg - Wikipedia"></td>
</tr>
</tbody>
<hr class="my-4">
<div class="col-md-8 mx-auto text-center">
<table style="width: 83.4204%; height: 221px;"> <!-- -->
<tbody>
<tr style="height: 107px;">
<td style="height: 107px;"><a href="https://peer.berkeley.edu/"><img decoding="async" class="wp-image-593 size-full aligncenter" src="https://stairlab.berkeley.edu/wp-content/uploads/2025/01/PEER_logo_old.svg" alt="PEER logo"></a></td>
<td style="height: 107px;"><a href="https://dot.ca.gov/" rel="nofollow"><img decoding="async" class="aligncenter" src="https://raw.githubusercontent.com/claudioperez/sdof/master/docs/assets/Caltrans.svg.png" alt="Caltrans Logo" width="100"></a></td>
<td style="height: 107px;"><a href="https://www.conservation.ca.gov"><img decoding="async" class="size-medium aligncenter" src="https://www.conservation.ca.gov/_catalogs/masterpage/DOC/images/DOC-logo-mobile.svg" width="300" height="89"></a></td>
<td style="height: 107px;"><img decoding="async" src="https://earimediaprodweb.azurewebsites.net/Api/v1/Multimedia/d4957b87-a007-48a9-8a66-d298a625b80c/Rendition/low-res/Content/Public" alt="Berkeley Lab logo [IMAGE] | EurekAlert! Science News Releases"></td>
</tr>
<tr style="height: 114px;">
<td style="height: 114px; width: 22.6732%;"><a href="https://nsf.gov/" rel="nofollow"><img decoding="async" class="aligncenter" src="https://raw.githubusercontent.com/STAIRlab/.github/master/profile/assets/NSF_4-Color_bitmap_Logo.png" alt="NSF Logo" width="100"></a></td>
<td style="height: 114px; width: 19.8796%;"><a href="https://steer.network/" rel="nofollow"><img decoding="async" class="aligncenter" src="https://raw.githubusercontent.com/STAIRlab/.github/master/profile/assets/StEER-logo_thumb-2_lg.png" alt="StEER Logo" width="100"></a></td>
<td style="height: 114px; width: 22.6342%;"><a href="https://nsf.gov/" rel="nofollow"><img decoding="async" class="aligncenter" src="https://raw.githubusercontent.com/STAIRlab/.github/master/profile/assets/StEER-logo_words%20only.png" alt="NSF Logo" width="100"></a></td>
<td style="width: 17.9355%; height: 107px;"><img decoding="async" class="aligncenter" src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/26/Bart-logo.svg/1280px-Bart-logo.svg.png" alt="File:Bart-logo.svg - Wikipedia"></td>
</tr>
</tbody>
</table>
</div>
</div>
</section>

<footer id="footer" class="footer">
<div class="container is-max-widescreen">
<div id=footer-columns class=columns>
<div class=footer-logo-column>
<div id="footer-columns" class="columns">
<div class="footer-logo-column">
<a href="https://stairlab.berkeley.edu"><img id=footer-logo src="{{ pathto('_static/images', 1) }}/stairlab_large.svg"
alt="STAIRLab logo."></a>
</div>
<div class="link-column">
<div class=footer-column>
<div class=footer-header></div>
<div class="footer-column">
<div class="footer-header"></div>
<ul class=link-list style=padding-left:30px;margin-top:20px>
<li class="link-list"><a class=footer-link href="https://pypi.org/project/veux/">Install</a></li>
<li class="link-list"><a class=footer-link href="./library/index.html">Documentation</a></li>
Expand Down
67 changes: 9 additions & 58 deletions src/veux/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,21 @@
# Summer 2024
import sys
import bottle
from .viewer import Viewer
from PIL import Image
import numpy as np
from io import BytesIO

class Server:
def __init__(self, glb=None, html=None, artist=None, viewer=None):
# Create App
def __init__(self, viewer=None, html=None):
self._app = bottle.Bottle()

if glb is not None:
self._source = "glb"
html = Viewer(path="./model.glb",
data=glb,
viewer=viewer).get_html()

# Create routes
self._app.route("/model.glb")(lambda : glb )
self._app.route("/")(lambda : html )

@self._app.route('/black_ground.hdr')
def serve_black_ground_hdr():
width, height = 1024, 512

# Create a blank HDR image
hdr_image = np.ones((height, width, 3), dtype=np.float32) # Start with white
horizon = int(height * 0.6)
hdr_image[horizon:, :] = 0.0 # Black ground

# Create the HDR header
hdr_header = (
"#?RADIANCE\n"
"FORMAT=32-bit_rle_rgbe\n\n"
f"-Y {height} +X {width}\n"
)

# Convert the RGB values to Radiance RGBE format
rgbe_image = np.zeros((height, width, 4), dtype=np.uint8)
brightest = np.maximum.reduce(hdr_image, axis=2)
nonzero_mask = brightest > 0
mantissa, exponent = np.frexp(brightest[nonzero_mask])
rgbe_image[nonzero_mask, :3] = (hdr_image[nonzero_mask] / mantissa[:, None] * 255).astype(np.uint8)
rgbe_image[nonzero_mask, 3] = (exponent + 128).astype(np.uint8)

# Encode the HDR data to memory
hdr_data = BytesIO()
hdr_data.write(hdr_header.encode('ascii')) # Write the header
hdr_data.write(rgbe_image.tobytes()) # Write the pixel data

# Serve the HDR file
return bottle.HTTPResponse(
body=hdr_data.getvalue(),
status=200,
headers={"Content-Type": "image/vnd.radiance"}
)

if html is not None:
self._app.route("/")(lambda : html )
return

elif artist is not None:
self._source = "artist"
if viewer is not None:

else:
self._source = "html"
# Create routes
html = viewer.get_html()
self._app.route("/")(lambda : html )
for path, page in viewer.resources():
self._app.route(path)(page)

def run(self, port=None):
if port is None:
Expand All @@ -81,7 +32,7 @@ def run(self, port=None):
try:
bottle.run(self._app, host="localhost", port=port, quiet=True)
except KeyboardInterrupt:
pass
print()

if __name__ == "__main__":

Expand Down
106 changes: 53 additions & 53 deletions src/veux/viewer/model-viewer.min.js

Large diffs are not rendered by default.

0 comments on commit fb18efc

Please sign in to comment.