Skip to content

Commit 382eb74

Browse files
committed
fix: adding vector/value points
1 parent 66ac1c1 commit 382eb74

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
from ._surface import Surface
22
from ._bounding_box import BoundingBox
3+
from ._point import ValuePoints, VectorPoints

LoopStructural/datatypes/_point.py

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
1-
# from dataclasses import dataclass
1+
from dataclasses import dataclass
2+
import numpy as np
23

34

4-
# @dataclass
5-
# class Value:
5+
@dataclass
6+
class ValuePoints:
7+
locations: np.ndarray
8+
values: np.ndarray
9+
name: str
10+
11+
def to_dict(self):
12+
return {
13+
"locations": self.locations,
14+
"values": self.values,
15+
"name": self.name,
16+
}
17+
18+
def vtk(self):
19+
import pyvista as pv
20+
21+
points = pv.PolyData(self.locations)
22+
points["values"] = self.values
23+
return points
24+
25+
26+
@dataclass
27+
class VectorPoints:
28+
locations: np.ndarray
29+
vectors: np.ndarray
30+
name: str
31+
32+
def to_dict(self):
33+
return {
34+
"locations": self.locations,
35+
"vectors": self.vectors,
36+
"name": self.name,
37+
}
38+
39+
def vtk(self):
40+
import pyvista as pv
41+
42+
points = pv.PolyData(self.locations)
43+
points.point_data.set_vectors(self.vectors, 'vectors')
44+
geom = pv.Arrow()
45+
46+
# Perform the glyph
47+
return points.glyph(orient="vectors", geom=geom)

0 commit comments

Comments
 (0)