Skip to content

Commit

Permalink
Create marker points using new style
Browse files Browse the repository at this point in the history
  • Loading branch information
rchristie committed Jul 3, 2023
1 parent 53e9d79 commit c13ddbd
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions src/scaffoldmaker/meshtypes/meshtype_3d_bladder1.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,14 @@ def generateBaseMesh(cls, region, options):

fm = region.getFieldmodule()
fm.beginChange()
cache = fm.createFieldcache()
mesh = fm.findMeshByDimension(3)

firstNodeIdentifier = 1
firstElementIdentifier = 1

# Geometric coordinates
geometricCentralPath = BladderCentralPath(region, centralPath, elementsCountAlongDome, elementsCountAlongNeck)
xFinal, d1Final, d2Final, d3Final = findBladderNodes3D(elementsCountAlongDome, elementsCountAlongNeck, elementsCountAround,
xFinal, d1Final, d2Final, d3Final = getBladderCoordinates(elementsCountAlongDome, elementsCountAlongNeck, elementsCountAround,
elementsCountThroughWall, wallThickness, geometricCentralPath)

sx_dome_group = geometricCentralPath.sx_dome_group
Expand All @@ -426,7 +425,7 @@ def generateBaseMesh(cls, region, options):
# Material coordinates
tmp_region = region.createRegion()
materialCentralPath = BladderCentralPath(tmp_region, materialCentralPath, elementsCountAlongDome, elementsCountAlongNeck)
xOrgan, d1Organ, d2Organ, d3Organ = findBladderNodes3D(elementsCountAlongDome, elementsCountAlongNeck, elementsCountAround,
xOrgan, d1Organ, d2Organ, d3Organ = getBladderCoordinates(elementsCountAlongDome, elementsCountAlongNeck, elementsCountAround,
elementsCountThroughWall, materialWallThickness, materialCentralPath)
del tmp_region

Expand Down Expand Up @@ -463,13 +462,16 @@ def generateBaseMesh(cls, region, options):
xFinal, d1Final, d2Final, bladderCentralPathLength, urethraOpeningRadius, wallThickness)

# Create nodes and elements
bladderCoordinatesFieldName = "bladder coordinates"
nodeIdentifier, elementIdentifier, annotationGroups = tubemesh.createNodesAndElements(
region, xFinal, d1Final, d2Final, d3Final, xFlat, d1Flat, d2Flat, xOrgan, d1Organ, d2Organ, "bladder coordinates",
elementsCountAround, elementsCountAlongBladder, elementsCountThroughWall,
region, xFinal, d1Final, d2Final, d3Final, xFlat, d1Flat, d2Flat, xOrgan, d1Organ, d2Organ,
bladderCoordinatesFieldName, elementsCountAround, elementsCountAlongBladder, elementsCountThroughWall,
annotationGroupsAround, annotationGroupsAlong, annotationGroupsThroughWall,
firstNodeIdentifier, firstElementIdentifier,
useCubicHermiteThroughWall, useCrossDerivatives, closedProximalEnd=True)

bladderCoordinates = fm.findFieldByName(bladderCoordinatesFieldName)

# Define trackSurface to put the ureter markers on
xTrackSurface = []
d1TrackSurface = []
Expand All @@ -489,16 +491,9 @@ def generateBaseMesh(cls, region, options):
ureter1Position = trackSurfaceBladder.createPositionProportion(ureterPositionAroundFactor, neckStartPositionAlongFactor)
ureterElementPositionAround = ureter1Position.e1

# Annotation fiducial point
markerGroup = findOrCreateFieldGroup(fm, "marker")
markerName = findOrCreateFieldStoredString(fm, name="marker_name")
markerLocation = findOrCreateFieldStoredMeshLocation(fm, mesh, name="marker_location")
# Annotation fiducial points

nodes = fm.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES)
markerPoints = markerGroup.getOrCreateNodesetGroup(nodes)
markerTemplateInternal = nodes.createNodetemplate()
markerTemplateInternal.defineField(markerName)
markerTemplateInternal.defineField(markerLocation)

# Define markers for apex and ureter junctions with bladder
apexGroup = findOrCreateAnnotationGroupForTerm(annotationGroups, region, get_bladder_term("apex of urinary bladder"))
Expand All @@ -519,12 +514,12 @@ def generateBaseMesh(cls, region, options):
bladderNodesetGroup = bladderGroup.getNodesetGroup(nodes)
for marker in markerList:
annotationGroup = marker["group"]
markerPoint = markerPoints.createNode(nodeIdentifier, markerTemplateInternal)
cache.setNode(markerPoint)
markerLocation.assignMeshLocation(cache, mesh.findElementByIdentifier(marker["elementId"]), marker["xi"])
markerName.assignString(cache, annotationGroup.getName())
annotationGroup.getNodesetGroup(nodes).addNode(markerPoint)
bladderNodesetGroup.addNode(markerPoint)
element = mesh.findElementByIdentifier(marker["elementId"])
# create marker points with element locations
markerNode = annotationGroup.createMarkerNode(nodeIdentifier, element=element, xi=marker["xi"])
# calculate bladder coordinates automatically from element:xi
annotationGroup.setMarkerMaterialCoordinates(bladderCoordinates)
bladderNodesetGroup.addNode(markerNode)
nodeIdentifier += 1

fm.endChange()
Expand Down Expand Up @@ -1149,8 +1144,8 @@ def __init__(self, region, centralPath, elementsCountAlongDome, elementsCountAlo
self.bladderCentralPathLength = bladderCentralPathLength
self.domeLength = domeLength

def findBladderNodes3D(elementsCountAlongDome, elementsCountAlongNeck, elementsCountAround, elementsCountThroughWall,
wallThickness, centralPath):
def getBladderCoordinates(elementsCountAlongDome, elementsCountAlongNeck, elementsCountAround, elementsCountThroughWall,
wallThickness, centralPath):

sx_dome_group = centralPath.sx_dome_group
sx_neck_group = centralPath.sx_neck_group
Expand Down

0 comments on commit c13ddbd

Please sign in to comment.