From 2f59db9a47a36416ccb25bc5097c864c5c015ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0brahim=20Uysal?= Date: Wed, 6 Mar 2024 21:42:51 +0300 Subject: [PATCH] add: extend at 1d --- marble-sculp/api.py | 69 +++++++++++ marble-sculp/test.json | 264 ++++++++++++++++++++--------------------- 2 files changed, 201 insertions(+), 132 deletions(-) diff --git a/marble-sculp/api.py b/marble-sculp/api.py index 942003a..c2f812d 100644 --- a/marble-sculp/api.py +++ b/marble-sculp/api.py @@ -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 @@ -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): @@ -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) diff --git a/marble-sculp/test.json b/marble-sculp/test.json index bc1de47..078f1f3 100644 --- a/marble-sculp/test.json +++ b/marble-sculp/test.json @@ -1,233 +1,233 @@ [ { "dip": 40, - "dip_direction": 65, - "px": 0, - "py": 0, - "pz": 1 + "dipDirection": 65, + "positionX": 0, + "positionY": 0, + "positionZ": 1 }, { "dip": 32, - "dip_direction": 64, - "px": 0.055, - "py": 0, - "pz": 1 + "dipDirection": 64, + "positionX": 0.055, + "positionY": 0, + "positionZ": 1 }, { "dip": 38, - "dip_direction": 72, - "px": 0, - "py": 0.54, - "pz": 1 + "dipDirection": 72, + "positionX": 0, + "positionY": 0.54, + "positionZ": 1 }, { "dip": 38, - "dip_direction": 68, - "px": 0, - "py": 2.32, - "pz": 1 + "dipDirection": 68, + "positionX": 0, + "positionY": 2.32, + "positionZ": 1 }, { "dip": 45, - "dip_direction": 335, - "px": 0, - "py": 5.75, - "pz": 1 + "dipDirection": 335, + "positionX": 0, + "positionY": 5.75, + "positionZ": 1 }, { "dip": 39, - "dip_direction": 71, - "px": 0, - "py": 4.015, - "pz": 1 + "dipDirection": 71, + "positionX": 0, + "positionY": 4.015, + "positionZ": 1 }, { "dip": 35, - "dip_direction": 70, - "px": 0, - "py": 4.972, - "pz": 1 + "dipDirection": 70, + "positionX": 0, + "positionY": 4.972, + "positionZ": 1 }, { "dip": 38, - "dip_direction": 68, - "px": 0, - "py": 7.52, - "pz": 1 + "dipDirection": 68, + "positionX": 0, + "positionY": 7.52, + "positionZ": 1 }, { "dip": 38, - "dip_direction": 337, - "px": 0, - "py": 10.33, - "pz": 1 + "dipDirection": 337, + "positionX": 0, + "positionY": 10.33, + "positionZ": 1 }, { "dip": 60, - "dip_direction": 340, - "px": 0, - "py": 10.177, - "pz": 1 + "dipDirection": 340, + "positionX": 0, + "positionY": 10.177, + "positionZ": 1 }, { "dip": 37, - "dip_direction": 67, - "px": 0, - "py": 8.473, - "pz": 1 + "dipDirection": 67, + "positionX": 0, + "positionY": 8.473, + "positionZ": 1 }, { "dip": 46, - "dip_direction": 340, - "px": 0, - "py": 11.016, - "pz": 1 + "dipDirection": 340, + "positionX": 0, + "positionY": 11.016, + "positionZ": 1 }, { "dip": 39, - "dip_direction": 67, - "px": 0, - "py": 10.165, - "pz": 1 + "dipDirection": 67, + "positionX": 0, + "positionY": 10.165, + "positionZ": 1 }, { "dip": 60, - "dip_direction": 341, - "px": 0, - "py": 12.377, - "pz": 1 + "dipDirection": 341, + "positionX": 0, + "positionY": 12.377, + "positionZ": 1 }, { "dip": 37, - "dip_direction": 66, - "px": 0, - "py": 11.523, - "pz": 1 + "dipDirection": 66, + "positionX": 0, + "positionY": 11.523, + "positionZ": 1 }, { "dip": 39, - "dip_direction": 66, - "px": 0, - "py": 12.915, - "pz": 1 + "dipDirection": 66, + "positionX": 0, + "positionY": 12.915, + "positionZ": 1 }, { "dip": 55, - "dip_direction": 334, - "px": 0, - "py": 15.55, - "pz": 1 + "dipDirection": 334, + "positionX": 0, + "positionY": 15.55, + "positionZ": 1 }, { "dip": 35, - "dip_direction": 65, - "px": 0, - "py": 14.422, - "pz": 1 + "dipDirection": 65, + "positionX": 0, + "positionY": 14.422, + "positionZ": 1 }, { "dip": 52, - "dip_direction": 330, - "px": 0, - "py": 18.531, - "pz": 1 + "dipDirection": 330, + "positionX": 0, + "positionY": 18.531, + "positionZ": 1 }, { "dip": 36, - "dip_direction": 68, - "px": 0, - "py": 17.024, - "pz": 1 + "dipDirection": 68, + "positionX": 0, + "positionY": 17.024, + "positionZ": 1 }, { "dip": 37, - "dip_direction": 66, - "px": 0, - "py": 17.123, - "pz": 1 + "dipDirection": 66, + "positionX": 0, + "positionY": 17.123, + "positionZ": 1 }, { "dip": 50, - "dip_direction": 330, - "px": 0, - "py": 20.039, - "pz": 1 + "dipDirection": 330, + "positionX": 0, + "positionY": 20.039, + "positionZ": 1 }, { "dip": 55, - "dip_direction": 340, - "px": 0, - "py": 21.3, - "pz": 1 + "dipDirection": 340, + "positionX": 0, + "positionY": 21.3, + "positionZ": 1 }, { "dip": 62, - "dip_direction": 338, - "px": 0, - "py": 21.282, - "pz": 1 + "dipDirection": 338, + "positionX": 0, + "positionY": 21.282, + "positionZ": 1 }, { "dip": 72, - "dip_direction": 335, - "px": 0, - "py": 21.425, - "pz": 1 + "dipDirection": 335, + "positionX": 0, + "positionY": 21.425, + "positionZ": 1 }, { "dip": 35, - "dip_direction": 65, - "px": 0, - "py": 19.772, - "pz": 1 + "dipDirection": 65, + "positionX": 0, + "positionY": 19.772, + "positionZ": 1 }, { "dip": 73, - "dip_direction": 334, - "px": 0, - "py": 22.306, - "pz": 1 + "dipDirection": 334, + "positionX": 0, + "positionY": 22.306, + "positionZ": 1 }, { "dip": 38, - "dip_direction": 68, - "px": 0, - "py": 22.32, - "pz": 1 + "dipDirection": 68, + "positionX": 0, + "positionY": 22.32, + "positionZ": 1 }, { "dip": 70, - "dip_direction": 330, - "px": 0, - "py": 25.264, - "pz": 1 + "dipDirection": 330, + "positionX": 0, + "positionY": 25.264, + "positionZ": 1 }, { "dip": 52, - "dip_direction": 15, - "px": 0, - "py": 26.181, - "pz": 1 + "dipDirection": 15, + "positionX": 0, + "positionY": 26.181, + "positionZ": 1 }, { "dip": 29, - "dip_direction": 66, - "px": 0, - "py": 23.796, - "pz": 1 + "dipDirection": 66, + "positionX": 0, + "positionY": 23.796, + "positionZ": 1 }, { "dip": 69, - "dip_direction": 328, - "px": 0, - "py": 27.584, - "pz": 1 + "dipDirection": 328, + "positionX": 0, + "positionY": 27.584, + "positionZ": 1 }, { "dip": 71, - "dip_direction": 325, - "px": 0, - "py": 28.744, - "pz": 1 + "dipDirection": 325, + "positionX": 0, + "positionY": 28.744, + "positionZ": 1 } ] \ No newline at end of file