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

Revisions based on comments from Colon Pull request #43 #44

Merged
merged 46 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
abd363e
Interpolate from and inner and outer ellipses
mlin865 Dec 21, 2018
f34de1e
Create haustra profile
mlin865 Feb 11, 2019
ac2a599
Rename 3D Colon 1 to 3D Haustra 1
mlin865 Feb 12, 2019
36cd65b
Add cross derivatives
mlin865 Feb 12, 2019
503b53e
Generate colon from haustra unit with tubeMesh
mlin865 Feb 18, 2019
7ab6261
Change default number of haustra and remove comments
mlin865 Feb 18, 2019
0047e3b
Add new central line for human colon
mlin865 Feb 18, 2019
78825e7
Merge remote-tracking branch 'abi/master' into tubeMesh
mlin865 Feb 18, 2019
59f2c28
Rotate faces along colon to align with binormal axes
mlin865 Feb 19, 2019
cb172ae
Add new central line to describe 3D colon
mlin865 Feb 19, 2019
c2e85ca
Set default options to human colon
mlin865 Feb 24, 2019
6a0bb31
Remove import of unnecessary files
mlin865 Mar 4, 2019
618ac0f
Clean up and update comments
mlin865 Mar 4, 2019
4626e97
Support multiple parameter sets
mlin865 Mar 4, 2019
9484eb2
Merge remote-tracking branch 'abi/master' into noDeformation
mlin865 Mar 4, 2019
64059f6
Correct haustra to singular form when referring to elements along hau…
mlin865 Mar 5, 2019
e42c2a3
Change default to central line profile for colon
mlin865 Mar 5, 2019
9422238
Change tube type options for input outside range
mlin865 Mar 5, 2019
b05320f
Change tube type options for inputs outside range
mlin865 Mar 5, 2019
fc111e0
Add newline to end of script
mlin865 Mar 5, 2019
30c8e3f
Rename and move function for getting rotation matrix to utils
mlin865 Mar 5, 2019
773bc77
Update names of radius/fold/curvature parameters
mlin865 Mar 5, 2019
9e1c094
Create and return list of annotation groups
mlin865 Mar 5, 2019
50f33ac
Remove @author from code
mlin865 Mar 5, 2019
795b5e3
Update terminologies for haustra segments
mlin865 Mar 6, 2019
bc1c7a8
Support multiple parameter sets, add scaffold base class
mlin865 Mar 6, 2019
6d611f2
Change default number of haustra segments
mlin865 Mar 6, 2019
3be4634
Check option for number of elements along haustrum
mlin865 Mar 6, 2019
e497a69
Update option name for refine number of elements along haustrum
mlin865 Mar 6, 2019
c5a10a0
Generate mesh from inner surface points
mlin865 Mar 6, 2019
0c361c5
Remove wallThickness from list of function inputs
mlin865 Mar 6, 2019
fbde02b
Rename and clean up function for generating outer points
mlin865 Mar 6, 2019
3da322b
Remove temporary parameter set Section 1
mlin865 Mar 6, 2019
7c00ad6
Merge tubeMesh files into 1 and discard centrallinetube1 meshtype
mlin865 Mar 7, 2019
bae844c
Update function call to getRotationMatrixFromAxisAngle
mlin865 Mar 7, 2019
d477b28
Make sure newline at end of script
mlin865 Mar 7, 2019
e822e35
Update review changes to haustra scaffold
mlin865 Mar 7, 2019
a4e9065
Add annotation groups
mlin865 Mar 7, 2019
25d8008
Update colon meshtype to use haustra meshtype
mlin865 Mar 7, 2019
0651221
Set arcLengthDerivatives=true
mlin865 Mar 7, 2019
17766f6
Remove arcLengthDerivatives = True
mlin865 Mar 8, 2019
cdd2da9
Switch from computeCubicHermiteArcLength to getCubicHermiteArcLength
mlin865 Mar 8, 2019
c7f07f1
Rename options for haustrum length derivative factors
mlin865 Mar 11, 2019
d92ca43
Rename haustrum length
mlin865 Mar 11, 2019
6cb34d7
Rename haustrum inner radius factor
mlin865 Mar 11, 2019
ed38d64
Update to generate mesh using tubemesh
mlin865 Mar 11, 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
144 changes: 0 additions & 144 deletions scaffoldmaker/meshtypes/meshtype_3d_centrallinetube1.py

This file was deleted.

141 changes: 141 additions & 0 deletions scaffoldmaker/meshtypes/meshtype_3d_colon1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
"""
Generates a 3-D colon mesh along the central line, with variable
numbers of elements around, along and through wall, with
variable radius and thickness along.
"""

from scaffoldmaker.meshtypes.meshtype_3d_haustra1 import MeshType_3d_haustra1, getColonHaustraSegmentInnerPoints
from scaffoldmaker.meshtypes.scaffold_base import Scaffold_base
from scaffoldmaker.utils.matrix import *
from scaffoldmaker.utils.meshrefinement import MeshRefinement
from scaffoldmaker.utils.tubemesh import *

class MeshType_3d_colon1(Scaffold_base):
'''
Generates a 3-D colon mesh with variable numbers
of elements around, along the central line, and through wall.
The colon is created by a function that generates a haustra
segment and uses tubemesh to map the segment along a central
line profile.
'''
@staticmethod
def getName():
return '3D Colon 1'

@staticmethod
def getParameterSetNames():
return [
'Default',
'Human 1']

@staticmethod
def getDefaultOptions(parameterSetName='Default'):
options = MeshType_3d_haustra1.getDefaultOptions(parameterSetName)
options['Number of elements around'] = 15
options['Number of elements along haustrum'] = 4
options['Inner radius'] = 1.0
options['Haustrum length mid derivative factor'] = 2.0
options['Wall thickness'] = 0.05
optionsColon = {
'Number of haustra segments': 30,
'Tube type': 2
}
options.update(optionsColon)
if 'Human 1' in parameterSetName:
options['Tube type'] = 3
return options

@staticmethod
def getOrderedOptionNames():
optionNames = MeshType_3d_haustra1.getOrderedOptionNames()
optionNames.remove('Haustrum length')
for optionName in [
'Number of haustra segments',
'Tube type']:
optionNames.insert(3, optionName)
return optionNames

def checkOptions(options):
MeshType_3d_haustra1.checkOptions(options)
if options['Number of haustra segments'] < 1:
options['Number of haustra segments'] = 1
if options['Tube type'] < 1:
options['Tube type'] = 1
if options['Tube type'] > 3:
options['Tube type'] = 3

@staticmethod
def generateBaseMesh(region, options):
"""
Generate the base tricubic Hermite mesh. See also generateMesh().
:param region: Zinc region to define model in. Must be empty.
:param options: Dict containing options. See getDefaultOptions().
:return: annotationGroups
"""
elementsCountAround = options['Number of elements around']
elementsCountAlongHaustrum = options['Number of elements along haustrum']
elementsCountThroughWall = options['Number of elements through wall']
haustraSegmentCount = options['Number of haustra segments']
radius = options['Inner radius']
cornerInnerRadiusFactor = options['Corner inner radius factor']
haustrumInnerRadiusFactor = options['Haustrum inner radius factor']
haustrumLengthEndDerivativeFactor = options['Haustrum length end derivative factor']
haustrumLengthMidDerivativeFactor = options['Haustrum length mid derivative factor']
wallThickness = options['Wall thickness']
tubeType = options['Tube type']
useCrossDerivatives = options['Use cross derivatives']
useCubicHermiteThroughWall = not(options['Use linear through wall'])
elementsCountAlong = int(elementsCountAlongHaustrum*haustraSegmentCount)

if tubeType == 1: # Straight tube
cx = [[-4.0, 1.0, 3.0], [ 1.0, 2.0, 0.0 ] ]
cd1 = [[ 5.0, 1.0, -3.0 ], [ 5.0, 1.0, -3.0 ]]
elif tubeType == 2: # Human colon in x-y plane
cx = [ [ 0.0, 0.0, 0.0], [0.0, 10.0, 0.0], [5.0, 9.0, 0.0], [ 10.0, 10.0, 0.0 ], [ 10.0, -2.0, 0.0], [ 7.0, -4.0, 0.0] ]
cd1 = [ [ 0.0, 10.0, 0.0 ], [ 5.0, 5.0, 0.0 ], [5.0, 0.0, 0.0], [ 5.0, -5.0, 0.0 ], [ -3.0, -5.0, 0.0 ], [ -3.0, 0.0, 0.0 ]]
elif tubeType == 3: # Human colon in 3D
cx = [ [ 0.0, 0.0, 0.0], [0.0, 10.0, 3.0], [5.0, 9.0, 0.0], [ 10.0, 10.0, 2.0 ], [15.0, 15.0, 7.0], [ 20.0, -2.0, 0.0], [ 10.0, -4.0, -0.0] ]
cd1 = [ [ 0.0, 10.0, 3.0 ], [ 5.0, 5.0, 0.0 ], [5.0, 0.0, 0.0], [ 10.0, -5.0, 0.0 ], [12.0, 12.0, 0.0], [ 5.0, -12.0, -5.0 ], [ -8.0, 0.0, 0.0 ]]

# find arclength of colon
length = 0.0
elementsCountIn = len(cx) - 1
sd1 = smoothCubicHermiteDerivativesLine(cx, cd1, fixAllDirections = True,
magnitudeScalingMode = DerivativeScalingMode.HARMONIC_MEAN)
for e in range(elementsCountIn):
arcLength = getCubicHermiteArcLength(cx[e], sd1[e], cx[e + 1], sd1[e + 1])
length += arcLength
haustrumLength = length / haustraSegmentCount

# Generate inner surface of a haustra segment
xHaustraInner, d1HaustraInner, d2HaustraInner, haustraSegmentAxis = getColonHaustraSegmentInnerPoints(elementsCountAround, elementsCountAlongHaustrum, radius, cornerInnerRadiusFactor,
haustrumInnerRadiusFactor, haustrumLengthEndDerivativeFactor, haustrumLengthMidDerivativeFactor, haustrumLength)

# Generate tube mesh
annotationGroups, nextNodeIdentifier, nextElementIdentifier = generatetubemesh(region, elementsCountAround, elementsCountAlongHaustrum, elementsCountThroughWall, haustraSegmentCount,
cx, cd1, xHaustraInner, d1HaustraInner, d2HaustraInner, wallThickness, haustraSegmentAxis, haustrumLength, useCrossDerivatives, useCubicHermiteThroughWall)

return annotationGroups

@classmethod
def generateMesh(cls, region, options):
"""
Generate base or refined mesh.
:param region: Zinc region to create mesh in. Must be empty.
:param options: Dict containing options. See getDefaultOptions().
:return: list of AnnotationGroup for mesh.
"""
if not options['Refine']:
cls.generateBaseMesh(region, options)
return

refineElementsCountAround = options['Refine number of elements around']
refineElementsCountAlong = options['Refine number of elements along haustrum']
refineElementsCountThroughWall = options['Refine number of elements through wall']

baseRegion = region.createRegion()
baseAnnotationGroups = cls.generateBaseMesh(baseRegion, options)

meshrefinement = MeshRefinement(baseRegion, region, baseAnnotationGroups)
meshrefinement.refineAllElementsCubeStandard3d(refineElementsCountAround, refineElementsCountAlong, refineElementsCountThroughWall)
return meshrefinement.getAnnotationGroups()
Loading