Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vary inner radius and tenia coli width along colon length #59

Merged
merged 28 commits into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
568578d
Modify mouse centre to correct length
mlin865 Jul 10, 2019
bd936d1
Modify default parameters for mouse segment profile
mlin865 Jul 10, 2019
a4eb98b
Merge remote-tracking branch 'abi/master' into mouseData
mlin865 Aug 6, 2019
cece0cb
Add mouse2 and correct code for cases where segment axis is parallel …
mlin865 Aug 14, 2019
5b583bb
Scale segment profile based on diameter along colon length
mlin865 Aug 26, 2019
0fd56c6
Create colon segment class object for passing to tubemesh
mlin865 Sep 11, 2019
e55561b
Vary radius and tenia coli width using parameter and derivative at st…
mlin865 Sep 27, 2019
90e45e8
Remove import math
mlin865 Sep 27, 2019
1ae7c8f
Remove 3rd component for v and d1
mlin865 Sep 30, 2019
52d654a
Change parameter name to start inner radius derivative, also end
mlin865 Sep 30, 2019
73029a6
Improve description for TubeMeshSegmentInnerPoints
mlin865 Sep 30, 2019
c44a641
Integrate simple mesentery case as one tenia coli in colonsegment mes…
mlin865 Sep 30, 2019
97a65b5
Remove passing of colon specific parameters to tubemesh
mlin865 Sep 30, 2019
b1a5935
Rename and move sampleParameterAlongLength to interpolation.py
mlin865 Oct 1, 2019
b12d266
Indent argument lines 2 onwards with 8 spaces
mlin865 Oct 1, 2019
00fc7e2
Use a boolean flag to control whether tenia coli are made
mlin865 Oct 1, 2019
3e48b5e
Remove 'Center' from function name and re-order function argument
mlin865 Oct 1, 2019
a1d183b
Store tubeTCWidthList in tubeMeshSegmentInnerPoints
mlin865 Oct 2, 2019
7fa7545
Reorganise to keep tubemesh generic and reorder nodes and elements
mlin865 Oct 22, 2019
4e38e01
Modify sampling function to not include parameter as a component of c…
mlin865 Oct 24, 2019
9fa3beb
Convert cm to mm
mlin865 Oct 25, 2019
5156eb9
Smooth d2 for nodes between segments
mlin865 Oct 30, 2019
8d9427c
Scale outer d2 using curvature along inner surface
mlin865 Oct 31, 2019
975f39a
Update parameters for human colon with literature values
mlin865 Nov 1, 2019
f6b4d55
Modify flag option
mlin865 Nov 3, 2019
912800b
Rename TubeMeshSegmentInnerPoints to ColonSegmentTubeMeshInnerPoints
mlin865 Nov 3, 2019
8c6db49
Modify flag to read in annotation groups for human colon
mlin865 Nov 3, 2019
e8a9300
Update parameters for pig colon
mlin865 Nov 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
217 changes: 188 additions & 29 deletions scaffoldmaker/meshtypes/meshtype_3d_colon1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import copy
from scaffoldmaker.meshtypes.meshtype_1d_path1 import MeshType_1d_path1, extractPathParametersFromRegion
from scaffoldmaker.meshtypes.meshtype_3d_colonsegmentsimplemesentery1 import MeshType_3d_colonsegmentsimplemesentery1, getColonSegmentInnerPointsNoTeniaColi
from scaffoldmaker.meshtypes.meshtype_3d_colonsegmentteniacoli1 import MeshType_3d_colonsegmentteniacoli1, getColonSegmentInnerPointsTeniaColi, getTeniaColi
from scaffoldmaker.meshtypes.meshtype_3d_colonsegmentsimplemesentery1 import MeshType_3d_colonsegmentsimplemesentery1, TubeMeshSegmentInnerPointsNoTeniaColi
from scaffoldmaker.meshtypes.meshtype_3d_colonsegmentteniacoli1 import MeshType_3d_colonsegmentteniacoli1, TubeMeshSegmentInnerPointsTeniaColi, getTeniaColi
from scaffoldmaker.meshtypes.scaffold_base import Scaffold_base
from scaffoldmaker.scaffoldpackage import ScaffoldPackage
from scaffoldmaker.utils.meshrefinement import MeshRefinement
Expand Down Expand Up @@ -66,19 +66,32 @@ class MeshType_3d_colon1(Scaffold_base):
'scaffoldSettings' : {
'Coordinate dimensions' : 3,
'Length' : 1.0,
'Number of elements' : 8
'Number of elements' : 7
},
'meshEdits' : zinc_utils.exnodeStringFromNodeValues(
[ Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2 ], [
[ [ 0.0, 0.0, 0.0 ], [ 0.6, 1.2, -0.2 ], [ 0.2, 0.1, 0.2 ], [ 0.6, 0.0, 0.30 ] ],
[ [ -0.2, 1.1, -0.3 ], [ -0.8, 0.4, 0.9 ], [ 0.2, 0.2, 0.1 ], [ 0.0, 0.1, 0.20 ] ],
[ [ -0.3, 0.2, 0.3 ], [ -0.4, -0.8, 0.0 ], [ 0.2, -0.1, 0.2 ], [ 0.1, 0.0, 0.20 ] ],
[ [ -1.1, -0.3, -0.4 ], [ -0.8, -0.3, -0.7 ], [ 0.1, -0.2, 0.1 ], [ 0.0, 0.0, 0.05 ] ],
[ [ -1.6, -0.4, 0.0 ], [ 0.4, -0.3, 1.4 ], [ 0.1, -0.3, 0.0 ], [ 0.0, 0.0, 0.05 ] ],
[ [ -0.7, -0.8, 0.0 ], [ 0.5, -0.1, -1.4 ], [ 0.0, -0.3, 0.0 ], [ 0.0, 0.0, 0.05 ] ],
[ [ -0.1, -0.6, -0.1 ], [ 0.2, -0.2, 0.9 ], [ 0.1, -0.3, -0.1 ], [ 0.0, 0.0, 0.05 ] ],
[ [ -0.2, -1.4, 0.5 ], [ -0.2, -0.4, 0.2 ], [ 0.1, -0.2, -0.2 ], [ 0.0, 0.0, 0.05 ] ] ] )
} ),
'Mouse 2' : ScaffoldPackage(MeshType_1d_path1, {
'scaffoldSettings' : {
'Coordinate dimensions' : 3,
'Length' : 1.0,
'Number of elements' : 4
},
'meshEdits' : zinc_utils.exnodeStringFromNodeValues(
[ Node.VALUE_LABEL_VALUE, Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2, Node.VALUE_LABEL_D2_DS1DS2 ], [
[ [ 0.3, -0.2, -0.6 ], [ 0.4, 1.3, -0.1 ], [ -0.1, 0.1, 0.4 ], [ 0.0, 0.0, 0.05 ] ],
[ [ 0.2, 1.4, -0.7 ], [ -1.9, -0.3, -0.5 ], [ -0.1, 0.0, 0.4 ], [ 0.0, 0.0, 0.05 ] ],
[ [ -0.6, -0.3, -0.9 ], [ -2.8, 0.0, -1.4 ], [ -0.3, 0.0, 0.2 ], [ 0.0, 0.0, 0.05 ] ],
[ [ -2.0, 0.8, -2.2 ], [ -1.8, 0.1, 0.0 ], [ 0.0, 0.0, 0.5 ], [ 0.0, 0.0, 0.05 ] ],
[ [ -2.6, 0.0, -1.6 ], [ 0.7, -1.2, 1.0 ], [ 0.0, 0.0, 0.5 ], [ 0.0, 0.0, 0.05 ] ],
[ [ -0.9, -0.9, -1.6 ], [ 1.3, 0.5, -1.6 ], [ 0.0, 0.3, 0.5 ], [ 0.0, 0.0, 0.05 ] ],
[ [ -0.3, 0.6, -1.7 ], [ 3.1, 0.3, 0.5 ], [ -0.2, 0.0, 0.2 ], [ 0.0, 0.0, 0.05 ] ],
[ [ 0.1, -1.0, -0.7 ], [ -0.3, -0.7, 0.4 ], [ 0.0, 0.0, 0.5 ], [ 0.0, 0.0, 0.05 ] ],
[ [ -0.4, -2.3, -0.1 ], [ -0.4, -0.6, 0.3 ], [ 0.0, 0.0, 0.5 ], [ 0.0, 0.0, 0.05 ] ] ] )
[ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 1.3 ], [ 0.0, -1.0, 0.0 ], [ 0.0, 0.0, 0.05 ] ],
[ [ 0.0, 0.0, 1.3 ], [ 0.0, 0.2, 2.8 ], [ 0.0, -1.0, 0.0 ], [ 0.0, 0.0, 0.05 ] ],
[ [ -1.4, -0.2, 1.3 ], [ 0.0, -0.3, -1.9 ], [ 0.0, -1.0, 0.0 ], [ 0.0, 0.0, 0.05 ] ],
[ [ -1.4, -0.1, -1.0 ], [ 0.1, 0.1, -1.7 ], [ 0.0, -1.0, 0.0 ], [ 0.0, 0.0, 0.05 ] ],
[ [ -1.4, 0.0, -2.8 ], [ 0.0, 0.0, -1.1 ], [ 0.0, -1.0, 0.0 ], [ 0.0, 0.0, 0.05 ] ] ] )
} ),
'Pig 1' : ScaffoldPackage(MeshType_1d_path1, {
'scaffoldSettings' : {
Expand Down Expand Up @@ -157,14 +170,17 @@ def getParameterSetNames():
'Human 1',
'Human 2',
'Mouse 1',
'Mouse 2',
'Pig 1']

@classmethod
def getDefaultOptions(cls, parameterSetName='Default'):
if 'Human 2' in parameterSetName:
centralPathOption = cls.centralPathDefaultScaffoldPackages['Human 2']
elif 'Mouse' in parameterSetName:
elif 'Mouse 1' in parameterSetName:
centralPathOption = cls.centralPathDefaultScaffoldPackages['Mouse 1']
elif 'Mouse 2' in parameterSetName:
centralPathOption = cls.centralPathDefaultScaffoldPackages['Mouse 2']
elif 'Pig' in parameterSetName:
centralPathOption = cls.centralPathDefaultScaffoldPackages['Pig 1']
else:
Expand All @@ -179,13 +195,48 @@ def getDefaultOptions(cls, parameterSetName='Default'):
'Central path' : copy.deepcopy(centralPathOption),
'Segment profile' : segmentProfileOption,
'Number of segments': 30,
'Proximal length': 12.0,
'Transverse length': 13.0,
'Distal length': 20.0,
'Proximal inner radius': 0.8,
'Proximal tenia coli width': 0.2,
'Proximal-transverse inner radius': 1.1,
'Proximal-transverse tenia coli width': 0.2,
'Transverse-distal inner radius': 1.25,
'Transverse-distal tenia coli width': 0.2,
'Distal inner radius': 1.5,
'Distal tenia coli width': 0.2,
'Refine' : False,
'Refine number of elements around' : 1,
'Refine number of elements along' : 1,
'Refine number of elements through wall' : 1
}
if 'Pig' in parameterSetName:
if 'Mouse' in parameterSetName:
options['Number of segments'] = 10
options['Proximal length'] = 3.0
options['Transverse length'] = 2.0
options['Distal length'] = 2.5
options['Proximal inner radius'] = 0.1
options['Proximal tenia coli width'] = 0.05
options['Proximal-transverse inner radius'] = 0.09
options['Proximal-transverse tenia coli width'] = 0.07
options['Transverse-distal inner radius'] = 0.07
options['Transverse-distal tenia coli width'] = 0.1
options['Distal inner radius'] = 0.07
options['Distal tenia coli width'] = 0.1
elif 'Pig' in parameterSetName:
options['Number of segments'] = 120
options['Proximal length'] = 50.0
options['Transverse length'] = 80.0
options['Distal length'] = 70.0
options['Proximal inner radius'] = 0.9
options['Proximal tenia coli width'] = 0.2
options['Proximal-transverse inner radius'] = 0.9
options['Proximal-transverse tenia coli width'] = 0.2
options['Transverse-distal inner radius'] = 0.9
options['Transverse-distal tenia coli width'] = 0.2
options['Distal inner radius'] = 0.9
options['Distal tenia coli width'] = 0.2
return options

@staticmethod
Expand All @@ -194,6 +245,17 @@ def getOrderedOptionNames():
'Central path',
'Segment profile',
'Number of segments',
'Proximal length',
'Transverse length',
'Distal length',
'Proximal inner radius',
'Proximal tenia coli width',
'Proximal-transverse inner radius',
'Proximal-transverse tenia coli width',
'Transverse-distal inner radius',
'Transverse-distal tenia coli width',
'Distal inner radius',
'Distal tenia coli width',
'Refine',
'Refine number of elements around',
'Refine number of elements along',
Expand Down Expand Up @@ -248,6 +310,20 @@ def checkOptions(cls, options):
'Refine number of elements through wall']:
if options[key] < 1:
options[key] = 1
for key in [
'Proximal length',
'Transverse length',
'Distal length',
'Proximal inner radius',
'Proximal tenia coli width',
'Proximal-transverse inner radius',
'Proximal-transverse tenia coli width',
'Transverse-distal inner radius',
'Transverse-distal tenia coli width',
'Distal inner radius',
'Distal tenia coli width']:
if options[key] < 0.0:
options[key] = 0.0

@staticmethod
def generateBaseMesh(region, options):
Expand All @@ -260,14 +336,24 @@ def generateBaseMesh(region, options):
centralPath = options['Central path']
segmentProfile = options['Segment profile']
segmentCount = options['Number of segments']
proximalLength = options['Proximal length']
transverseLength = options['Transverse length']
distalLength = options['Distal length']
proximalInnerRadius = options['Proximal inner radius']
proximalTCWidth = options['Proximal tenia coli width']
proximalTransverseInnerRadius = options['Proximal-transverse inner radius']
proximalTransverseTCWidth = options['Proximal-transverse tenia coli width']
transverseDistalInnerRadius = options['Transverse-distal inner radius']
transverseDistalTCWidth = options['Transverse-distal tenia coli width']
distalInnerRadius = options['Distal inner radius']
distalTCWidth = options['Distal tenia coli width']
segmentScaffoldType = segmentProfile.getScaffoldType()
segmentSettings = segmentProfile.getScaffoldSettings()

if segmentScaffoldType == MeshType_3d_colonsegmentsimplemesentery1:
elementsCountAroundMZ = segmentSettings['Number of elements around mesenteric zone']
elementsCountAroundNonMZ = segmentSettings['Number of elements around non-mesenteric zone']
elementsCountAround = elementsCountAroundMZ + elementsCountAroundNonMZ
mzWidth = segmentSettings['Mesenteric zone width']
else: # segmentScaffoldType == MeshType_3d_colonsegmentteniacoli1:
elementsCountAroundTC = segmentSettings['Number of elements around tenia coli']
elementsCountAroundHaustrum = segmentSettings['Number of elements around haustrum']
Expand All @@ -276,13 +362,15 @@ def generateBaseMesh(region, options):
segmentLengthEndDerivativeFactor = segmentSettings['Segment length end derivative factor']
segmentLengthMidDerivativeFactor = segmentSettings['Segment length mid derivative factor']
tcCount = segmentSettings['Number of tenia coli']
tcWidth = segmentSettings['Tenia coli width']
tcThickness = segmentSettings['Tenia coli thickness']
elementsCountAround = (elementsCountAroundTC + elementsCountAroundHaustrum)*tcCount

elementsCountAlongSegment = segmentSettings['Number of elements along segment']
elementsCountThroughWall = segmentSettings['Number of elements through wall']
radius = segmentSettings['Inner radius']
startRadius = segmentSettings['Start inner radius']
startRadiusDerivative = segmentSettings['Start radius derivative']
endRadius = segmentSettings['End inner radius']
endRadiusDerivative = segmentSettings['End radius derivative']
wallThickness = segmentSettings['Wall thickness']
useCrossDerivatives = segmentSettings['Use cross derivatives']
useCubicHermiteThroughWall = not(segmentSettings['Use linear through wall'])
Expand All @@ -291,6 +379,11 @@ def generateBaseMesh(region, options):
tmpRegion = region.createRegion()
centralPath.generate(tmpRegion)
cx, cd1, cd2, cd12 = extractPathParametersFromRegion(tmpRegion)
# for i in range(len(cx)):
# print('cx = ', i+1, cx[i])
# print('cd1 = ', i+1, cd1[i])
# print('cd2 = ', i+1, cd2[i])
# print('cd12 = ', i+1, cd12[i])
del tmpRegion

# find arclength of colon
Expand All @@ -302,28 +395,38 @@ def generateBaseMesh(region, options):
arcLength = interp.getCubicHermiteArcLength(cx[e], sd1[e], cx[e + 1], sd1[e + 1])
length += arcLength
segmentLength = length / segmentCount
# print('Length = ', length)

# Generate variation of radius & tc width along length
lengthList = [0.0, proximalLength, proximalLength + transverseLength, length]
innerRadiusList = [proximalInnerRadius, proximalTransverseInnerRadius, transverseDistalInnerRadius, distalInnerRadius]

innerRadiusSegmentList, dInnerRadiusSegmentList = sampleParameterAlongLength(innerRadiusList, lengthList, segmentCount)
tcWidthList = [proximalTCWidth, proximalTransverseTCWidth, transverseDistalTCWidth, distalTCWidth]
tcWidthSegmentList, dTCWidthSegmentList = sampleParameterAlongLength(tcWidthList, lengthList, segmentCount)

# Generate inner surface of a colon segment
if segmentScaffoldType == MeshType_3d_colonsegmentsimplemesentery1:
annotationGroups, annotationArray, transitElementList, uList, arcLengthOuterMidLength, xInner, d1Inner, d2Inner, segmentAxis = getColonSegmentInnerPointsNoTeniaColi(region, elementsCountAroundMZ, elementsCountAroundNonMZ,
elementsCountAlongSegment, mzWidth, radius, segmentLength, wallThickness)
tubeMeshSegmentInnerPoints = TubeMeshSegmentInnerPointsNoTeniaColi(region, elementsCountAroundMZ,
elementsCountAroundNonMZ, elementsCountAlongSegment, segmentLength, wallThickness)

else: # segmentScaffoldType == MeshType_3d_colonsegmentteniacoli1:
annotationGroups, annotationArray, transitElementList, uList, arcLengthOuterMidLength, xInner, d1Inner, d2Inner, segmentAxis = getColonSegmentInnerPointsTeniaColi(region, elementsCountAroundTC, elementsCountAroundHaustrum,
elementsCountAlongSegment, tcCount, tcWidth, radius, cornerInnerRadiusFactor, haustrumInnerRadiusFactor,
segmentLengthEndDerivativeFactor, segmentLengthMidDerivativeFactor, segmentLength, wallThickness)
tubeMeshSegmentInnerPoints = TubeMeshSegmentInnerPointsTeniaColi(region,
elementsCountAroundTC, elementsCountAroundHaustrum, elementsCountAlongSegment,
tcCount, segmentLengthEndDerivativeFactor, segmentLengthMidDerivativeFactor,
segmentLength, wallThickness, cornerInnerRadiusFactor, haustrumInnerRadiusFactor)

# Generate tube mesh
annotationGroups, nextNodeIdentifier, nextElementIdentifier, xList, d1List, d2List, d3List, sx, curvatureAlong, factorList = tubemesh.generatetubemesh(region,
elementsCountAround, elementsCountAlongSegment, elementsCountThroughWall, segmentCount, cx, cd1, cd2, cd12,
xInner, d1Inner, d2Inner, wallThickness, segmentAxis, segmentLength, useCrossDerivatives, useCubicHermiteThroughWall,
annotationGroups, annotationArray, transitElementList, uList, arcLengthOuterMidLength)
annotationGroups, nextNodeIdentifier, nextElementIdentifier, xList, d1List, d2List, d3List, sx, curvatureAlong, factorList, uList, relaxedLengthList, tubeTCWidthList = tubemesh.generatetubemesh(region,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't return anything specific to a segment profile from this function either (relaxedLengthList, tubeTCWidthList; not sure what ulist is). Probable solution is to store these in the tubeMeshSegmentInnerPoints? Alternative is to return a generic map of names to lists of values.

elementsCountAround, elementsCountAlongSegment, elementsCountThroughWall, segmentCount, cx, cd1, cd2, cd12, innerRadiusSegmentList, dInnerRadiusSegmentList,
tcWidthSegmentList, dTCWidthSegmentList, tubeMeshSegmentInnerPoints, wallThickness, segmentLength, useCrossDerivatives, useCubicHermiteThroughWall)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't pass TC width here - see comments on tubemesh class.


# Generate tenia coli
if segmentScaffoldType == MeshType_3d_colonsegmentteniacoli1:
annotationGroupsTC, nextNodeIdentifier, nextElementIdentifier = getTeniaColi(region, nextNodeIdentifier, nextElementIdentifier,
useCrossDerivatives, useCubicHermiteThroughWall, xList, d1List, d2List, d3List, elementsCountAroundTC, elementsCountAroundHaustrum,
elementsCountAlong, elementsCountThroughWall, wallThickness, tcWidth, tcThickness, sx, curvatureAlong, factorList, uList,
arcLengthOuterMidLength, length, tcCount)
useCrossDerivatives, useCubicHermiteThroughWall, xList, d1List, d2List, d3List, segmentCount, elementsCountAroundTC, elementsCountAroundHaustrum,
elementsCountAlong, elementsCountThroughWall, wallThickness, tubeTCWidthList, tcThickness, sx, curvatureAlong, factorList,
length, tcCount, uList, relaxedLengthList)

annotationGroups += annotationGroupsTC

Expand All @@ -350,3 +453,59 @@ def generateMesh(cls, region, options):
meshrefinement = MeshRefinement(baseRegion, region, baseAnnotationGroups)
meshrefinement.refineAllElementsCubeStandard3d(refineElementsCountAround, refineElementsCountAlong, refineElementsCountThroughWall)
return meshrefinement.getAnnotationGroups()

def sampleParameterAlongLength(paramList, lengthList, segmentCount):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As written this function is general purpose so could go in tubemesh? But read comments below first...
Update: sampling needs to be done in the tube mesh segment generator as described elsewhere.

"""
Generate parameter value and rate of change at segment intersections
along total length. Parameter is assumed to vary with a cubic hermite
function.
:param paramList: List of parameter values at length locations specified
in lengthList.
:param lengthList: List of length locations.
:param segmentCount: Number of segments along total length.
:return paramList, dParamList: Parameter values and rate of change at each segment.
"""

nx = []
nd1 = []
xList = []
d1List = []
for i in range(len(lengthList)):
v = [lengthList[i], paramList[i], 0.0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for 3rd component for v and d1 as smooth function handles n components.

d1 = [(lengthList[i+1] - lengthList[i]) if i < len(lengthList)-1 else (lengthList[i] - lengthList[i-1]), 0.0, 0.0]
nx.append(v)
nd1.append(d1)
smoothd1 = interp.smoothCubicHermiteDerivativesLine(nx, nd1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, could have proximal, (mid) transverse and distal parameters and assume zero derivatives? That would make this function colon-specific. What are researchers likely to measure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline with Richard. Decided to keep things as they are now and will modify later when requirements change.


# Get total arclength
arcLength = 0.0
for e in range(len(nx)-1):
arcLength += interp.getCubicHermiteArcLength(nx[e], smoothd1[e], nx[e + 1], smoothd1[e + 1])

# Find parameter value at each segment
xTol = 1.0E-6
for n in range(segmentCount + 1):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this loop the same as interp.sampleCubicHermiteCurves (also interp.sampleCubicHermiteCurvesSmooth)? These would be more efficient than using getCubicHermiteCurvesPointsAtArcDistance...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interp.sampleCubicHermiteCurves will sample the curve describing how parameter changes along the centre line into equal arclength, but here I want to sample along the center line and get the parameter value along each of these points on the center line.

arcStart = 0.0
arcEnd = arcLength
xi = 1.0/segmentCount * n
for iter in range(100):
arcDistance = (arcStart + arcEnd)*0.5
x, d1, _, _ = interp.getCubicHermiteCurvesPointAtArcDistance(nx, smoothd1, arcDistance)
diff = x[0] - xi*lengthList[-1]
if abs(diff) > xTol:
if diff < 0.0:
arcStart = arcDistance
else:
arcEnd = arcDistance
else:
xList.append(x)
d1List.append(d1)
break
if iter > 99:
print('Search for sampleParameterAlongLength - Max iters reached:',iter)
smoothdList = interp.smoothCubicHermiteDerivativesLine(xList, d1List)

paramList = [c[1] for c in xList]
dParamList = [c[1] for c in smoothdList]

return paramList, dParamList
Loading