Skip to content

Commit

Permalink
Fix missing imports from maths.vectorops.
Browse files Browse the repository at this point in the history
  • Loading branch information
hsorby committed Jul 23, 2024
1 parent 9438333 commit 4824f65
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
3 changes: 1 addition & 2 deletions src/scaffoldmaker/meshtypes/meshtype_3d_lung2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import copy
import math
from cmlibs.maths.vectorops import cross, dot, mult, normalize, sub
from cmlibs.maths.vectorops import cross, dot, mult, normalize, sub, magnitude
from cmlibs.utils.zinc.field import Field, findOrCreateFieldCoordinates
from cmlibs.zinc.element import Element
from cmlibs.zinc.node import Node
Expand All @@ -20,7 +20,6 @@
from scaffoldmaker.utils.interpolation import computeCubicHermiteDerivativeScaling, interpolateCubicHermite, \
interpolateCubicHermiteDerivative
from scaffoldmaker.utils.meshrefinement import MeshRefinement
from scaffoldmaker.utils.vector import magnitude
from scaffoldmaker.utils.zinc_utils import disconnectFieldMeshGroupBoundaryNodes


Expand Down
4 changes: 2 additions & 2 deletions src/scaffoldmaker/meshtypes/meshtype_3d_stellate1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import math

from cmlibs.maths.vectorops import set_magnitude
from cmlibs.utils.zinc.field import findOrCreateFieldCoordinates, findOrCreateFieldGroup, \
findOrCreateFieldStoredMeshLocation, findOrCreateFieldStoredString
from cmlibs.zinc.element import Element
Expand All @@ -19,7 +20,6 @@
from scaffoldmaker.utils.interpolation import smoothCubicHermiteDerivativesLine
from scaffoldmaker.utils.matrix import rotateAboutZAxis
from scaffoldmaker.utils.meshrefinement import MeshRefinement
from scaffoldmaker.utils.vector import setMagnitude


class MeshType_3d_stellate1(Scaffold_base):
Expand Down Expand Up @@ -682,7 +682,7 @@ def createArm(halfArmArcAngleRadians, elementLengths, elementLengthCentral, elem
ds1 = [dcent[0], -dcent[1], dcent[2]]
elif (e1 == 0) and ((e2 == 0) or (e2 == elementsCount2)):
ds2 = [dcent[0], -dcent[1], dcent[2]] if (e2 == 0) else dcent
ds2 = setMagnitude(ds2, dipMag)
ds2 = set_magnitude(ds2, dipMag)
ds1 = rotateAboutZAxis(ds2, -math.pi / 2)
elif e1 == elementsCount1 and e2 == elementsCount2-1: # armEnd
ds1 = [elementWidth,0,0]
Expand Down
12 changes: 6 additions & 6 deletions src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import copy

from cmlibs.maths.vectorops import set_magnitude
from cmlibs.utils.zinc.field import findOrCreateFieldCoordinates
from cmlibs.utils.zinc.finiteelement import get_element_node_identifiers
from cmlibs.utils.zinc.general import ChangeManager
Expand All @@ -23,7 +24,6 @@
from scaffoldmaker.utils.cylindermesh import CylinderMesh, CylinderShape, CylinderEnds, CylinderCentralPath
from scaffoldmaker.utils.eft_utils import remapEftNodeValueLabelsVersion
from scaffoldmaker.utils.meshrefinement import MeshRefinement
from scaffoldmaker.utils.vector import setMagnitude
from scaffoldmaker.utils.zinc_utils import exnode_string_from_nodeset_field_parameters


Expand Down Expand Up @@ -51,11 +51,11 @@ class MeshType_3d_wholebody1(Scaffold_base):
[Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2,
Node.VALUE_LABEL_D_DS3, Node.VALUE_LABEL_D2_DS1DS3],
[[
(1, [[0.0, 0.0, 0.0], setMagnitude(axis1, cylinder1Settings['Length']), setMagnitude(axis2, 0.5),
[0.0, 0.0, 0.0], setMagnitude(axis3, 0.5), [0.0, 0.0, 0.0]]),
(2, [setMagnitude(axis1, cylinder1Settings['Length']),
setMagnitude(axis1, cylinder1Settings['Length']),
setMagnitude(axis2, 0.5), [0.0, 0.0, 0.0], setMagnitude(axis3, 0.5), [0.0, 0.0, 0.0]])
(1, [[0.0, 0.0, 0.0], set_magnitude(axis1, cylinder1Settings['Length']), set_magnitude(axis2, 0.5),
[0.0, 0.0, 0.0], set_magnitude(axis3, 0.5), [0.0, 0.0, 0.0]]),
(2, [set_magnitude(axis1, cylinder1Settings['Length']),
set_magnitude(axis1, cylinder1Settings['Length']),
set_magnitude(axis2, 0.5), [0.0, 0.0, 0.0], set_magnitude(axis3, 0.5), [0.0, 0.0, 0.0]])
]])
})
}
Expand Down
7 changes: 3 additions & 4 deletions src/scaffoldmaker/utils/derivativemoothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@

import math

from cmlibs.maths.vectorops import magnitude
from cmlibs.maths.vectorops import magnitude, set_magnitude
from cmlibs.utils.zinc.field import findOrCreateFieldGroup
from cmlibs.utils.zinc.general import ChangeManager
from cmlibs.zinc.element import Element, Elementbasis
from cmlibs.zinc.field import Field
from scaffoldmaker.utils.interpolation import DerivativeScalingMode, getCubicHermiteArcLength, \
interpolateHermiteLagrangeDerivative, interpolateLagrangeHermiteDerivative
from scaffoldmaker.utils.vector import setMagnitude


class EdgeCurve:
Expand Down Expand Up @@ -355,7 +354,7 @@ def smooth(self, updateDirections=False, maxIterations=10, arcLengthTolerance=1.
if mag <= 0.0:
print('Node', nodeIdentifier, 'value', nodeValueLabel, 'version', nodeVersion,
'has negative mag', mag)
x = setMagnitude(x, mag)
x = set_magnitude(x, mag)
self._field.setNodeParameters(fieldcache, -1, nodeValueLabel, nodeVersion, x)
for derivativeKey, derivativeEdges in self._derivativeMap.items():
edgeCount = len(derivativeEdges)
Expand Down Expand Up @@ -403,7 +402,7 @@ def smooth(self, updateDirections=False, maxIterations=10, arcLengthTolerance=1.
if mag <= 0.0:
print('Derivative smoothing: Node', nodeIdentifier, 'label', nodeValueLabel,
'version', nodeVersion, 'has negative magnitude', mag)
x = setMagnitude(x, mag)
x = set_magnitude(x, mag)
self._field.setNodeParameters(fieldcache, -1, nodeValueLabel, nodeVersion, x)
# record modified nodes while ChangeManager is in effect
if self._editNodesetGroup:
Expand Down
5 changes: 2 additions & 3 deletions src/scaffoldmaker/utils/tubenetworkmesh.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Specialisation of Network Mesh for building 2-D and 3-D tube mesh networks.
"""
from cmlibs.maths.vectorops import add, cross, dot, magnitude, mult, normalize, sub
from cmlibs.maths.vectorops import add, cross, dot, magnitude, mult, normalize, sub, rejection
from cmlibs.zinc.element import Element, Elementbasis
from cmlibs.zinc.node import Node
from scaffoldmaker.utils.eft_utils import determineCubicHermiteSerendipityEft, HermiteNodeLayoutManager
Expand All @@ -13,7 +13,6 @@
from scaffoldmaker.utils.networkmesh import NetworkMesh, NetworkMeshBuilder, NetworkMeshGenerateData, \
NetworkMeshJunction, NetworkMeshSegment, pathValueLabels
from scaffoldmaker.utils.tracksurface import TrackSurface
from scaffoldmaker.utils.vector import vectorRejection
from scaffoldmaker.utils.zinc_utils import get_nodeset_path_ordered_field_parameters
import copy
import math
Expand Down Expand Up @@ -1375,7 +1374,7 @@ def resampleTubeCoordinates(rawTubeCoordinates, fixedElementsCountAlong=None,
# first smooth to get d1 with new directions not tangential to surface
td1 = smoothCubicHermiteDerivativesLoop(sx[p], sd1[p])
# constraint to be tangential to surface
td1 = [vectorRejection(td1[q], normalize(cross(sd1[p][q], sd2[p][q]))) for q in range(elementsCountAround)]
td1 = [rejection(td1[q], normalize(cross(sd1[p][q], sd2[p][q]))) for q in range(elementsCountAround)]
# smooth magnitudes only
sd1[p] = smoothCubicHermiteDerivativesLoop(sx[p], td1, fixAllDirections=True)

Expand Down

0 comments on commit 4824f65

Please sign in to comment.