diff --git a/ShoulderCase/@Glenoid/getAnatomicalExtremeRimPoints.m b/ShoulderCase/@Glenoid/getAnatomicalExtremeRimPoints.m new file mode 100644 index 0000000..5bb292c --- /dev/null +++ b/ShoulderCase/@Glenoid/getAnatomicalExtremeRimPoints.m @@ -0,0 +1,23 @@ +function output = getAnatomicalExtremeRimPoints(obj) + % Return the points of the extreme points of the glenoid rim according to the + % scapula coordinate system. + % There might be several points returned for a given direction, most likely for + % the medio-lateral direction. + + rimPoints = obj.getRimPoints(); + coordSys = obj.scapula.coordSys; + + output.lateral = selectPointsFromDotProductWithAxis(rimPoints,coordSys.ML,@max); + output.medial = selectPointsFromDotProductWithAxis(rimPoints,coordSys.ML,@min); + output.inferior = selectPointsFromDotProductWithAxis(rimPoints,coordSys.IS,@min); + output.superior = selectPointsFromDotProductWithAxis(rimPoints,coordSys.IS,@max); + output.posterior = selectPointsFromDotProductWithAxis(rimPoints,coordSys.PA,@min); + output.anterior = selectPointsFromDotProductWithAxis(rimPoints,coordSys.PA,@max); +end + +function output = selectPointsFromDotProductWithAxis(points,axis,selectFunction) + dotProductResults = points*axis'; + selectedPoints = find(dotProductResults == selectFunction(dotProductResults)); + output = points(selectedPoints,:); +end + diff --git a/ShoulderCase/@Glenoid/getRimPoints.m b/ShoulderCase/@Glenoid/getRimPoints.m new file mode 100644 index 0000000..9912e2d --- /dev/null +++ b/ShoulderCase/@Glenoid/getRimPoints.m @@ -0,0 +1,3 @@ +function output = getRimPoints(obj) + output = obj.surface.points(obj.getRimPointsIndices(),:); +end \ No newline at end of file diff --git a/ShoulderCase/@Glenoid/getRimPointsIndices.m b/ShoulderCase/@Glenoid/getRimPointsIndices.m new file mode 100644 index 0000000..cc2ab70 --- /dev/null +++ b/ShoulderCase/@Glenoid/getRimPointsIndices.m @@ -0,0 +1,24 @@ +function output = getRimPointsIndices(obj) + % Return the indices of the points on the rim of the glenoid surface. + % To find the rim points, this function analyses the faces of the glenoid.surface + % structure. These faces are triangles, each triangle is defined by three points + % of the glenoid's surface. The points on the rim are defined to be the points + % that appear in the faces 4 times or less (usually 3 or 4 times). Consequently, + % the other points that appear more than 4 times in the faces (usually 5 or 6 + % times) are expected to be the inner points of the surface. + % + % WARNING: This is an empirical method to define which points are the rim points. + % It is not based on the glenoid's surface tesselation algorithm and might + % return false positive and false negative points. + % For example, P200 shoulderAuto rim points found with the current function + % feature several 4-occurence points that are inner points of the surface. There + % are also 5-occurence rim points that are not detected. + % Fix hint to try: Run a new triangulation algorithm on the glenoid points ( + % like the matlab's delaunay() funtion). + + trianglePointsIndices = obj.surface.faces; + pointsOccurence = arrayfun(@(pointIndex)sum(trianglePointsIndices == pointIndex,"all"),... + unique(trianglePointsIndices)); + rimPointsIndices = find(pointsOccurence <= 4); + output = rimPointsIndices; +end \ No newline at end of file