Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
add: extend at 1d
Browse files Browse the repository at this point in the history
  • Loading branch information
uysalibov committed Mar 6, 2024
1 parent ab907da commit 2f59db9
Show file tree
Hide file tree
Showing 2 changed files with 201 additions and 132 deletions.
69 changes: 69 additions & 0 deletions marble-sculp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from dotenv import dotenv_values
from contextlib import asynccontextmanager
from pymongo import MongoClient
import os

from typing import Callable
from pyinstrument import Profiler
Expand All @@ -26,6 +27,10 @@

config = dotenv_values(".env")

for i in ["site", "rp", "disc", "dfn", "poly", "extend", "extend1d"]:
if not os.path.exists(f"static/{i}"):
os.makedirs(f"static/{i}")


@asynccontextmanager
async def lifespan(app: FastAPI):
Expand Down Expand Up @@ -328,5 +333,69 @@ async def extend(request: Request, payload: DiscModel):
)


@app.post("/extend1d")
async def extend1d(request: Request, payload: DiscModel):
scene = Scene()
marb = Marble(
size=[payload.sizeX, payload.sizeY, payload.sizeZ],
pos=[payload.positionX, payload.positionY, payload.positionZ],
)
# scene.add(marb)

discons = []
a = 0
processed = []

for u in range(1, 2):
for i in range(-1 * u, 2 * u - (u - 1)):
a += 1
# if i == 0 and j == 0:
# continue
for d in range(len(payload.data)):
discon = deepcopy(payload.data[d])

temp_circ = Circle(radius=10)
temp_circ.rotate(discon["dip"], discon["dipDirection"])
temp_circ.move(
i * payload.sizeX + payload.positionX + discon["positionX"],
payload.positionY + discon["positionY"],
payload.positionZ + discon["positionZ"],
)
# scene.add(temp_circ)
# print(temp_circ.normal)

disc = temp_circ.intersections(marb.edges, marb.vertices)
if disc:
if [
round(disc.pos[0], 5),
round(disc.pos[1], 5),
round(disc.pos[2], 5),
] in processed:
continue
processed.append(
[
round(disc.pos[0], 5),
round(disc.pos[1], 5),
round(disc.pos[2], 5),
]
)
# scene.add(temp_circ)
# scene.add(disc)

discon["positionX"] = (
i * payload.sizeX + payload.positionX + discon["positionX"]
)
discon["positionY"] = payload.positionY + discon["positionY"]
discon["positionZ"] = payload.positionZ + discon["positionZ"]
discons.append(discon)

scene.polyhedron(
size=[payload.sizeX, payload.sizeY, payload.sizeZ],
pos=[payload.positionX, payload.positionY, payload.positionZ],
data=discons,
)
scene.convert_obj(filename="extend1d/" + payload.filename)


if __name__ == "__main__":
uvicorn.run("api:app", reload=True, workers=5)
Loading

0 comments on commit 2f59db9

Please sign in to comment.