diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_lung2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_lung2.py index 6fdd1389..6850320d 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_lung2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_lung2.py @@ -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 @@ -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 diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_stellate1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_stellate1.py index 14b9d107..f8fcef16 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_stellate1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_stellate1.py @@ -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 @@ -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): @@ -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] diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py index 7f057495..17c36e4f 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py @@ -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 @@ -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 @@ -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]]) ]]) }) } diff --git a/src/scaffoldmaker/utils/derivativemoothing.py b/src/scaffoldmaker/utils/derivativemoothing.py index 7686037a..254fb903 100644 --- a/src/scaffoldmaker/utils/derivativemoothing.py +++ b/src/scaffoldmaker/utils/derivativemoothing.py @@ -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: @@ -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) @@ -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: diff --git a/src/scaffoldmaker/utils/tubenetworkmesh.py b/src/scaffoldmaker/utils/tubenetworkmesh.py index 464fbb1b..8f81388a 100644 --- a/src/scaffoldmaker/utils/tubenetworkmesh.py +++ b/src/scaffoldmaker/utils/tubenetworkmesh.py @@ -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 @@ -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 @@ -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)