Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ea0d922
Basic structure drawing
angelsolaorbaiceta Apr 3, 2025
f1f8a53
Drawing the solution
angelsolaorbaiceta Apr 4, 2025
6c5f8eb
Drawing the solution
angelsolaorbaiceta Apr 12, 2025
aecbd4e
Drawing
angelsolaorbaiceta Apr 14, 2025
0d3b0fa
Merge branch 'master' into feat/structures-ui
angelsolaorbaiceta Apr 14, 2025
56e432e
Nice solution display
angelsolaorbaiceta Apr 16, 2025
4a9a8d2
Bindable lines in editor
angelsolaorbaiceta Apr 18, 2025
1e739e6
Highlight colors in the editor
angelsolaorbaiceta Apr 19, 2025
5821db2
Remove refs
angelsolaorbaiceta Apr 19, 2025
c43996d
Show errors
angelsolaorbaiceta Apr 19, 2025
ddb3234
Debounce parsing the structure
angelsolaorbaiceta Apr 19, 2025
b35c311
Tweaks
angelsolaorbaiceta Apr 19, 2025
29e07d4
Docker file
angelsolaorbaiceta Apr 19, 2025
6f03f75
Better popover
angelsolaorbaiceta Apr 19, 2025
c9c00aa
Help modal
angelsolaorbaiceta Apr 20, 2025
5ebc335
Scale field
angelsolaorbaiceta Apr 20, 2025
bea1ac7
Resizing the editor
angelsolaorbaiceta Apr 21, 2025
63754fc
External constraints
angelsolaorbaiceta Apr 22, 2025
7a3c580
Labels for bars
angelsolaorbaiceta Apr 22, 2025
f705cd3
Load labels
angelsolaorbaiceta Apr 22, 2025
e11d81a
Set position on mount
angelsolaorbaiceta Apr 22, 2025
bb8f6a6
Centralize state
angelsolaorbaiceta Apr 22, 2025
faa1279
Improve labels in SVG
angelsolaorbaiceta Apr 23, 2025
82dfffb
Improvements
angelsolaorbaiceta Apr 23, 2025
71fb2e4
Show bar length in label
angelsolaorbaiceta Apr 23, 2025
8e33f1b
Fix zoom
angelsolaorbaiceta Apr 24, 2025
6566234
Fixed scale values
angelsolaorbaiceta Apr 25, 2025
5496446
Improvements
angelsolaorbaiceta Apr 25, 2025
3582f1d
Improvements
angelsolaorbaiceta Apr 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
FROM node:20-slim AS frontend-builder

WORKDIR /frontend

COPY structures/frontend/package*.json ./
RUN npm ci

COPY structures/frontend/ ./
RUN npm run build

FROM python:3.12-slim

WORKDIR /app
Expand All @@ -10,6 +20,9 @@ RUN poetry install --no-interaction --no-ansi --no-dev
COPY structures/ ./structures/
RUN find ./structures -type d \( -name tests -o -name __pycache__ \) -exec rm -rf {} +

# Copy the built Svelte app into the static directory
COPY --from=frontend-builder /frontend/build/ ./structures/server/static/

COPY geom2d/ ./geom2d/
RUN find ./geom2d -type d \( -name tests -o -name __pycache__ \) -exec rm -rf {} +

Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
struct.serve:
poetry run python -m structures.server.main
DEV_MODE=true poetry run python -m structures.server.main

fe.serve:
cd structures/frontend && npm run dev

fe.build:
cd structures/frontend && npm run build

docker.build:
docker build -t hardcore-2dstructures:latest .
docker build -t asolaor/hardcore-2dstructures:0.2 .
41 changes: 21 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ python = "^3.12"
tornado = "^6.4.2"

[tool.poetry.group.dev.dependencies]
ruff = "^0.0.287"
ruff = "^0.11.4"

[tool.ruff]
line-length = 88
Expand Down
28 changes: 17 additions & 11 deletions structures/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

The _structures_ package defines the modeling and resolution of truss structures.

![](../img/truss_structure.svg "Truss structure")
![](../img/truss_structure.svg 'Truss structure')

Once resolved, the solution generation diagram looks like the following:

![](../img/plane_truss_result.svg)

The _structures_ package is split into sub-packages:


- [_model_](#model)
- [_solution_](#solution)
- [_parse_](#parse)
Expand All @@ -28,7 +27,6 @@ A node is the point where one or more bars meet.

A `Node` can be instantiated using an id an a position:


```python
from geom2d import Point
from structures.model.node import StrNode
Expand All @@ -53,8 +51,8 @@ from geom2d import Point, Vector
from structures.model.node import StrNode

node = StrNode(
_id=1,
position=Point(10, 35),
_id=1,
position=Point(10, 35),
loads=[Vector(0, -50), Vector(100, 0)],
dx_constrained=True,
dy_constrained=True
Expand All @@ -75,8 +73,8 @@ from structures.model.bar import StrBar
node_one = StrNode(1, Point(10, 35))
node_two = StrNode(2, Point(150, 400))
bar = StrBar(
_id=1,
start_node=node_one,
_id=1,
start_node=node_one,
end_node=node_two,
cross_section=25,
young_mod=20000000
Expand Down Expand Up @@ -178,10 +176,10 @@ from geom2d import Vector
from structures.generation.gen_baltimore import generate_baltimore_structure

generate_baltimore_structure(
spans=6,
span=250,
height=300,
cross_sec=45,
spans=6,
span=250,
height=300,
cross_sec=45,
young=20000000,
node_load=Vector(1000, -2000)
)
Expand Down Expand Up @@ -250,3 +248,11 @@ with open('result.svg', 'w') as file:
The result of this code would be an SVG like the following:

![](../img/plane_truss_result.svg)

## Server

Run locally in DEV mode:

```bash
$ DEV_MODE=true python -m structures.server.main
```
24 changes: 24 additions & 0 deletions structures/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
node_modules

# Output
.output
.vercel
.netlify
.wrangler
/.svelte-kit
/build
/dist

# OS
.DS_Store
Thumbs.db

# Env
.env
.env.*
!.env.example
!.env.test

# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
1 change: 1 addition & 0 deletions structures/frontend/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
6 changes: 6 additions & 0 deletions structures/frontend/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Package Managers
package-lock.json
pnpm-lock.yaml
yarn.lock
bun.lock
bun.lockb
16 changes: 16 additions & 0 deletions structures/frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"semi": false,
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte"
}
}
]
}
8 changes: 8 additions & 0 deletions structures/frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# TODO

- General CSS improvements
- Scaling problem
- Adjust units if they are m or ft
- (nice) Hiding the editor
- (nice) Tree view of the solution
- (nice) Generate warren truss
34 changes: 34 additions & 0 deletions structures/frontend/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import prettier from 'eslint-config-prettier'
import js from '@eslint/js'
import { includeIgnoreFile } from '@eslint/compat'
import svelte from 'eslint-plugin-svelte'
import globals from 'globals'
import { fileURLToPath } from 'node:url'
import svelteConfig from './svelte.config.js'
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url))

/** @type {import('eslint').Linter.Config[]} */
export default [
includeIgnoreFile(gitignorePath),
js.configs.recommended,
...svelte.configs.recommended,
prettier,
...svelte.configs.prettier,
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
},
{
files: ['**/*.svelte', '**/*.svelte.js'],

languageOptions: {
parserOptions: {
svelteConfig
}
}
}
]
12 changes: 12 additions & 0 deletions structures/frontend/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"module": "NodeNext",
"moduleResolution": "NodeNext"
}
}
Loading