Skip to content

Commit

Permalink
fix #5034. Apply Vector Field Node performance proposal solution. v00…
Browse files Browse the repository at this point in the history
…3. Escape calculation of vertices by polimorphizm. Some 'normal_array' of surface calcs source vertices so there is no need calc vertices by evaluate_array. So written function 'normal_vertices_array' is SvSurface and in some inheritance classes that return both params if needed.
  • Loading branch information
satabol committed Oct 29, 2023
1 parent c520951 commit 1f247fd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion utils/field/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ def _evaluate(self, vertices):
if self.only_2D:
return self.surface.evaluate_array(us, vs)

spline_normals, surf_vertices = self.surface.normal_array_with_source_vertices(us, vs)
spline_normals, surf_vertices = self.surface.normal_vertices_array(us, vs)
zs = vertices[:,self.orient_axis].flatten()
zs = zs[np.newaxis].T
v1 = zs * spline_normals
Expand Down
10 changes: 3 additions & 7 deletions utils/surface/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,7 @@ def normal(self, u, v):
# normals = [self._normal(u, v) for u,v in zip(us, vs)]
# return np.array(normals)

def normal_array(self, us, vs):
result_normals, *_ = self.normal_array_with_source_vertices(us, vs)
return result_normals

def normal_array_with_source_vertices(self, us, vs):
def normal_vertices_array(self, us, vs):
h = 0.001
_points = np.empty( (0, 3), dtype=np.float64)
_points_u_h = np.empty( (0, 3), dtype=np.float64)
Expand Down Expand Up @@ -316,7 +312,7 @@ def normal(self, u, v):
normal = normal / n
return normal

def normal_array(self, us, vs):
def normal_vertices_array(self, us, vs):
surf_vertices = self.evaluate_array(us, vs)
u_plus = self.evaluate_array(us + self.normal_delta, vs)
v_plus = self.evaluate_array(us, vs + self.normal_delta)
Expand All @@ -329,7 +325,7 @@ def normal_array(self, us, vs):
#if norm != 0:
normal = normal / norm
#self.info("Normals: %s", normal)
return normal
return normal, surf_vertices

class SvRevolutionSurface(SvSurface):
__description__ = "Revolution"
Expand Down
10 changes: 7 additions & 3 deletions utils/surface/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def normal(self, u, v):
return normal

def normal_array(self, us, vs):
normal, *_ = self.normal_vertices_array(us, vs)
return normal

def normal_vertices_array(self, us, vs):
surf_vertices = self.evaluate_array(us, vs)
u_plus = self.evaluate_array(us + self.normal_delta, vs)
v_plus = self.evaluate_array(us, vs + self.normal_delta)
Expand All @@ -50,7 +54,7 @@ def normal_array(self, us, vs):
#if norm != 0:
normal = normal / norm
#self.info("Normals: %s", normal)
return normal
return normal, surf_vertices

def derivatives_data_array(self, us, vs):
if hasattr(self, 'normal_delta'):
Expand Down Expand Up @@ -403,7 +407,7 @@ def evaluate_array(self, us, vs):
def normal(self, u, v):
return self.normal_array(np.array([u]), np.array([v]))[0]

def normal_array(self, us, vs):
def normal_vertices_array(self, us, vs):
surf_vertices = self.evaluate_array(us, vs)
u_plus = self.evaluate_array(us + self.normal_delta, vs)
v_plus = self.evaluate_array(us, vs + self.normal_delta)
Expand All @@ -416,5 +420,5 @@ def normal_array(self, us, vs):
#if norm != 0:
normal = normal / norm
#self.info("Normals: %s", normal)
return normal
return normal, surf_vertices

4 changes: 2 additions & 2 deletions utils/surface/rbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def evaluate_array(self, us, vs):
def normal(self, u, v):
return self.normal_array(np.array([u]), np.array([v]))[0]

def normal_array(self, us, vs):
def normal_vertices_array(self, us, vs):
surf_vertices = self.evaluate_array(us, vs)
u_plus = self.evaluate_array(us + self.normal_delta, vs)
v_plus = self.evaluate_array(us, vs + self.normal_delta)
Expand All @@ -82,5 +82,5 @@ def normal_array(self, us, vs):
#if norm != 0:
normal = normal / norm
#self.info("Normals: %s", normal)
return normal
return normal, surf_vertices

0 comments on commit 1f247fd

Please sign in to comment.