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

Commit

Permalink
fix: faster insert for polyhedrons
Browse files Browse the repository at this point in the history
  • Loading branch information
uysalibov committed Apr 17, 2024
1 parent 3b1b789 commit 9c2d1e2
Show file tree
Hide file tree
Showing 3 changed files with 25,507 additions and 6 deletions.
18 changes: 12 additions & 6 deletions marble-sculp/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,13 @@ def polyhedron(self, size: List[int], pos: List[int], data: List[Discontinous]):
self.db["outputpolyhedrons"].delete_many({"rpId": ObjectId(self.filename)})
self.db["outputvertex"].delete_many({"rpId": ObjectId(self.filename)})
self.db["outputfaces"].delete_many({"rpId": ObjectId(self.filename)})
polyhedrons = []
vertexes = []
faces = []
for q, i in enumerate(objects):
self.add(i)
if self.db is not None:
self.db["outputpolyhedrons"].insert_one(
polyhedrons.append(
{
"rpId": ObjectId(self.filename),
"polyhedronId": q + 1,
Expand All @@ -175,7 +178,7 @@ def polyhedron(self, size: List[int], pos: List[int], data: List[Discontinous]):
}
)
for vq, vertex in enumerate(i.vertices):
self.db["outputvertex"].insert_one(
vertexes.append(
{
"rpId": ObjectId(self.filename),
"polyhedronId": q + 1,
Expand All @@ -189,18 +192,21 @@ def polyhedron(self, size: List[int], pos: List[int], data: List[Discontinous]):
)

for fq, face in enumerate(i.faces):
self.db["outputfaces"].insert_one(
faces.append(
{
"rpId": ObjectId(self.filename),
"polyhedronId": q + 1,
"faceId": fq + 1,
"vertexes": face,
"vertexes": face if type(face) == list else face.tolist(),
"createdAt": datetime.now(),
"updatedAt": datetime.now(),
}
)

print(len(objects), len(processed))
if self.db is not None:
self.db["outputpolyhedrons"].insert_many(polyhedrons)
self.db["outputvertex"].insert_many(vertexes)
self.db["outputfaces"].insert_many(faces)
print(len(objects), len(polyhedrons), len(vertexes), len(faces))


if __name__ == "__main__":
Expand Down
Loading

0 comments on commit 9c2d1e2

Please sign in to comment.