Skip to content

Commit e56fc19

Browse files
authored
Merge pull request #160 from Geode-solutions/feat/preview-surface
feat(createSurface): Add preview for surfaces creation
2 parents 0788ef7 + 3c063e2 commit e56fc19

5 files changed

Lines changed: 15 additions & 4 deletions

File tree

opengeodeweb_viewer_schemas.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2443,7 +2443,8 @@
24432443
"type": "string",
24442444
"enum": [
24452445
"points",
2446-
"curve"
2446+
"curve",
2447+
"surface"
24472448
]
24482449
},
24492450
"closed": {

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,3 @@ wslink==1.12.4
6363
yarl>=1
6464
# via aiohttp
6565

66-
opengeodeweb-microservice==1.*,>=1.1.3

src/opengeodeweb_viewer/rpc/viewer/schemas/preview_points.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"type": "string",
3030
"enum": [
3131
"points",
32-
"curve"
32+
"curve",
33+
"surface"
3334
]
3435
},
3536
"closed": {

src/opengeodeweb_viewer/rpc/viewer/schemas/preview_points.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def __post_init__(self) -> None:
1717
class Style(Enum):
1818
CURVE = "curve"
1919
POINTS = "points"
20+
SURFACE = "surface"
2021

2122

2223
@dataclass

src/opengeodeweb_viewer/rpc/viewer/viewer_protocols.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def previewPoints(self, rpc_params: RpcParams) -> None:
423423
for i, pt in enumerate(points_data):
424424
self._preview_points.InsertNextPoint(pt.x, pt.y, pt.z)
425425
self._preview_verts.InsertNextCell(1, [i])
426-
if style_name == "curve" and i == 0:
426+
if style_name in ["curve", "surface"] and i == 0:
427427
colors.InsertNextTuple3(60, 153, 131)
428428
else:
429429
colors.InsertNextTuple3(102, 102, 102)
@@ -432,11 +432,20 @@ def previewPoints(self, rpc_params: RpcParams) -> None:
432432
self._preview_polydata.GetPointData().SetActiveScalars("Colors")
433433

434434
lines = vtkCellArray()
435+
polys = vtkCellArray()
435436
if style_name == "curve":
436437
for i in range(len(points_data) - 1):
437438
lines.InsertNextCell(2, [i, i + 1])
438439
if params.closed and len(points_data) >= 2:
439440
lines.InsertNextCell(2, [len(points_data) - 1, 0])
441+
elif style_name == "surface":
442+
for i in range(len(points_data) - 1):
443+
lines.InsertNextCell(2, [i, i + 1])
444+
if len(points_data) >= 3:
445+
lines.InsertNextCell(2, [len(points_data) - 1, 0])
446+
polys.InsertNextCell(len(points_data), list(range(len(points_data))))
447+
440448
self._preview_polydata.SetLines(lines)
449+
self._preview_polydata.SetPolys(polys)
441450
self._preview_polydata.Modified()
442451
self.render(-1)

0 commit comments

Comments
 (0)