Skip to content

Commit

Permalink
Merge pull request #80 from mlin865/cecum
Browse files Browse the repository at this point in the history
Multiple annotation groups
  • Loading branch information
rchristie authored Jul 22, 2020
2 parents 5928290 + 0788694 commit 5740b58
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 160 deletions.
21 changes: 11 additions & 10 deletions src/scaffoldmaker/meshtypes/meshtype_3d_cecum1.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,17 @@ def generateBaseMesh(cls, region, options):

# Create annotation
cecumGroup = AnnotationGroup(region, get_colon_term("caecum"))
annotationGroups = [cecumGroup]
annotationArrayAlong = (['caecum'] * elementsCountAlong)
annotationGroupsAlong = []
for i in range(elementsCountAlong):
annotationGroupsAlong.append([cecumGroup])

annotationArrayThroughWall = [''] * elementsCountThroughWall
annotationGroupsThroughWall = []
for i in range(elementsCountThroughWall):
annotationGroupsThroughWall.append([ ])

for nSegment in range(segmentCount):
# Make regular segments
xInner, d1Inner, d2Inner, transitElementList, segmentAxis, annotationGroupsAround, annotationArrayAround \
xInner, d1Inner, d2Inner, transitElementList, segmentAxis, annotationGroupsAround \
= colonSegmentTubeMeshInnerPoints.getColonSegmentTubeMeshInnerPoints(nSegment)

# Replace first half of first segment with apex and sample along apex and second half of segment
Expand Down Expand Up @@ -423,7 +426,6 @@ def generateBaseMesh(cls, region, options):
zRefList, innerRadiusAlongCecum, closedProximalEnd)

# Create coordinates and derivatives
annotationGroups += annotationGroupsAround
wallThicknessList = [wallThickness] * (elementsCountAlong + 1)

xList, d1List, d2List, d3List, curvatureList = tubemesh.getCoordinatesFromInner(xWarpedList, d1WarpedList,
Expand Down Expand Up @@ -465,24 +467,23 @@ def generateBaseMesh(cls, region, options):
# Create nodes and elements
if tcThickness > 0:
tubeTCWidthList = colonSegmentTubeMeshInnerPoints.getTubeTCWidthList()
xCecum, d1Cecum, d2Cecum, d3Cecum, annotationGroups, annotationArrayAround = getTeniaColi(
xCecum, d1Cecum, d2Cecum, d3Cecum, annotationGroupsAround = getTeniaColi(
region, xCecum, d1Cecum, d2Cecum, d3Cecum, curvatureList, tcCount, elementsCountAroundTC,
elementsCountAroundHaustrum, elementsCountAlong, elementsCountThroughWall,
tubeTCWidthList, tcThickness, sxRefList, annotationGroups, annotationArrayAround,
closedProximalEnd)
tubeTCWidthList, tcThickness, sxRefList, annotationGroupsAround, closedProximalEnd)

nextNodeIdentifier, nextElementIdentifier, annotationGroups = createNodesAndElementsTeniaColi(
region, xCecum, d1Cecum, d2Cecum, d3Cecum, xFlat, d1Flat, d2Flat, xTexture, d1Texture, d2Texture,
elementsCountAroundTC, elementsCountAroundHaustrum, elementsCountAlong, elementsCountThroughWall,
tcCount, annotationGroups, annotationArrayAround, annotationArrayAlong, annotationArrayThroughWall,
tcCount, annotationGroupsAround, annotationGroupsAlong, annotationGroupsThroughWall,
firstNodeIdentifier, firstElementIdentifier, useCubicHermiteThroughWall, useCrossDerivatives,
closedProximalEnd)

else:
nextNodeIdentifier, nextElementIdentifier, annotationGroups = tubemesh.createNodesAndElements(
region, xCecum, d1Cecum, d2Cecum, d3Cecum, xFlat, d1Flat, d2Flat, xTexture, d1Texture, d2Texture,
elementsCountAround, elementsCountAlong, elementsCountThroughWall,
annotationGroups, annotationArrayAround, annotationArrayAlong, annotationArrayThroughWall,
annotationGroupsAround, annotationGroupsAlong, annotationGroupsThroughWall,
firstNodeIdentifier, firstElementIdentifier, useCubicHermiteThroughWall, useCrossDerivatives,
closedProximalEnd)

Expand Down
48 changes: 28 additions & 20 deletions src/scaffoldmaker/meshtypes/meshtype_3d_colon1.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,38 +434,48 @@ def generateBaseMesh(cls, region, options):
interp.sampleParameterAlongLine(lengthList, haustrumInnerRadiusFactorList, elementsCountAlong)[0]
else:
haustrumInnerRadiusFactorAlongElementList = [haustrumInnerRadiusFactor]*(elementsCountAlong+1)

# Create annotation groups for colon sections
elementsAlongInProximal = round(proximalLength/elementAlongLength)
elementsAlongInTransverse = round(transverseLength/elementAlongLength)
elementsAlongInDistal = elementsCountAlong - elementsAlongInProximal - elementsAlongInTransverse
elementsCountAlongGroups = [elementsAlongInProximal, elementsAlongInTransverse, elementsAlongInDistal]

colonGroup = AnnotationGroup(region, get_colon_term("colon"))

if tcCount == 1:
proximalGroup = AnnotationGroup(region, get_colon_term("proximal colon"))
transverseGroup = AnnotationGroup(region, get_colon_term("transverse colon"))
distalGroup = AnnotationGroup(region, get_colon_term("distal colon"))
annotationGroups = [proximalGroup, transverseGroup, distalGroup]
annotationArrayAlong = (['proximal colon'] * elementsAlongInProximal +
['transverse colon'] * elementsAlongInTransverse +
['distal colon'] * elementsAlongInDistal)
annotationGroupAlong = [[colonGroup, proximalGroup],
[colonGroup, transverseGroup],
[colonGroup, distalGroup]]

elif tcCount == 2:
spiralGroup = AnnotationGroup(region, get_colon_term("spiral colon"))
transverseGroup = AnnotationGroup(region, get_colon_term("transverse colon"))
distalGroup = AnnotationGroup(region, get_colon_term("distal colon"))
annotationGroups = [spiralGroup, transverseGroup, distalGroup]
annotationArrayAlong = (['spiral colon'] * elementsAlongInProximal +
['transverse colon'] * elementsAlongInTransverse +
['distal colon'] * elementsAlongInDistal)
annotationGroupAlong = [[colonGroup, spiralGroup],
[colonGroup, transverseGroup],
[colonGroup, distalGroup]]

elif tcCount == 3:
ascendingGroup = AnnotationGroup(region, get_colon_term("ascending colon"))
transverseGroup = AnnotationGroup(region, get_colon_term("transverse colon"))
descendingGroup = AnnotationGroup(region, get_colon_term("descending colon"))
annotationGroups = [ascendingGroup, transverseGroup, descendingGroup]
annotationArrayAlong = (['ascending colon'] * elementsAlongInProximal +
['transverse colon'] * elementsAlongInTransverse +
['descending colon'] * elementsAlongInDistal)
annotationGroupAlong = [[colonGroup, ascendingGroup],
[colonGroup, transverseGroup],
[colonGroup, descendingGroup]]

annotationArrayThroughWall = ([''] * elementsCountThroughWall)
annotationGroupsAlong = []
for i in range(len(elementsCountAlongGroups)):
elementsCount = elementsCountAlongGroups[i]
for n in range(elementsCount):
annotationGroupsAlong.append(annotationGroupAlong[i])

annotationGroupsThroughWall = []
for i in range(elementsCountThroughWall):
annotationGroupsThroughWall.append([ ])

xExtrude = []
d1Extrude = []
Expand All @@ -483,7 +493,7 @@ def generateBaseMesh(cls, region, options):

for nSegment in range(segmentCount):
# Create inner points
xInner, d1Inner, d2Inner, transitElementList, segmentAxis, annotationGroupsAround, annotationArrayAround\
xInner, d1Inner, d2Inner, transitElementList, segmentAxis, annotationGroupsAround \
= colonSegmentTubeMeshInnerPoints.getColonSegmentTubeMeshInnerPoints(nSegment)

# Project reference point for warping onto central path
Expand All @@ -509,8 +519,6 @@ def generateBaseMesh(cls, region, options):

contractedWallThicknessList = colonSegmentTubeMeshInnerPoints.getContractedWallThicknessList()

annotationGroups += annotationGroupsAround

# Create coordinates and derivatives
xList, d1List, d2List, d3List, curvatureList = tubemesh.getCoordinatesFromInner(xExtrude, d1Extrude,
d2Extrude, d3UnitExtrude, contractedWallThicknessList,
Expand All @@ -522,10 +530,10 @@ def generateBaseMesh(cls, region, options):

if tcThickness > 0:
tubeTCWidthList = colonSegmentTubeMeshInnerPoints.getTubeTCWidthList()
xList, d1List, d2List, d3List, annotationGroups, annotationArrayAround = getTeniaColi(
xList, d1List, d2List, d3List, annotationArrayAround = getTeniaColi(
region, xList, d1List, d2List, d3List, curvatureList, tcCount, elementsCountAroundTC,
elementsCountAroundHaustrum, elementsCountAlong, elementsCountThroughWall,
tubeTCWidthList, tcThickness, sxRefExtrudeList, annotationGroups, annotationArrayAround,
tubeTCWidthList, tcThickness, sxRefExtrudeList, annotationGroupsAround,
closedProximalEnd)

# Create flat and texture coordinates
Expand All @@ -538,7 +546,7 @@ def generateBaseMesh(cls, region, options):
nextNodeIdentifier, nextElementIdentifier, annotationGroups = createNodesAndElementsTeniaColi(
region, xList, d1List, d2List, d3List, xFlat, d1Flat, d2Flat, xTexture, d1Texture, d2Texture,
elementsCountAroundTC, elementsCountAroundHaustrum, elementsCountAlong, elementsCountThroughWall,
tcCount, annotationGroups, annotationArrayAround, annotationArrayAlong, annotationArrayThroughWall,
tcCount, annotationGroupsAround, annotationGroupsAlong, annotationGroupsThroughWall,
firstNodeIdentifier, firstElementIdentifier, useCubicHermiteThroughWall, useCrossDerivatives,
closedProximalEnd)

Expand All @@ -552,7 +560,7 @@ def generateBaseMesh(cls, region, options):
nextNodeIdentifier, nextElementIdentifier, annotationGroups = tubemesh.createNodesAndElements(
region, xList, d1List, d2List, d3List, xFlat, d1Flat, d2Flat, xTexture, d1Texture, d2Texture,
elementsCountAround, elementsCountAlong, elementsCountThroughWall,
annotationGroups, annotationArrayAround, annotationArrayAlong, annotationArrayThroughWall,
annotationGroupsAround, annotationGroupsAlong, annotationGroupsThroughWall,
firstNodeIdentifier, firstElementIdentifier, useCubicHermiteThroughWall, useCrossDerivatives,
closedProximalEnd)

Expand Down
Loading

0 comments on commit 5740b58

Please sign in to comment.