0001 function varargout = viewBoundaryShape(shapeStruct)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 nextPlotState = get(gca, 'nextPlot');
0030 set(gca, 'nextPlot', 'add');
0031
0032
0033 if ~isempty(shapeStruct.hrep) && ~isempty(shapeStruct.hrep.A)
0034
0035
0036 incidenceMatrix = abs(bsxfun(@minus, ...
0037 shapeStruct.hrep.A * shapeStruct.vrep.V', ...
0038 shapeStruct.hrep.h)) < elkZerotol;
0039 hEdge = nan(1, size(incidenceMatrix, 1));
0040
0041 for iEdge = 1:size(incidenceMatrix, 1)
0042 vertexIndex = find(incidenceMatrix(iEdge, :));
0043 vertexMatrix(1, :) = shapeStruct.vrep.V(vertexIndex(1), :) + ...
0044 shapeStruct.lambda * shapeStruct.hrep.A(iEdge, :);
0045 vertexMatrix(2, :) = shapeStruct.vrep.V(vertexIndex(2), :) + ...
0046 shapeStruct.lambda * shapeStruct.hrep.A(iEdge, :);
0047
0048 hEdge(iEdge) = plot(vertexMatrix(:,1), ...
0049 vertexMatrix(:,2), 'r-');
0050 end
0051 set(hEdge, 'linewidth', 3, 'color', 'r');
0052 else
0053 hEdge = [];
0054 incidenceMatrix = [];
0055 end
0056
0057 if isfield(shapeStruct, 'lambda') && shapeStruct.lambda > 0
0058
0059
0060 nVertex = max(size(incidenceMatrix, 2), 1);
0061 hVertex = nan(1, nVertex);
0062 for iVertex = 1:nVertex
0063 if ~isempty(incidenceMatrix)
0064 edgeIndexVector = find(incidenceMatrix(:, iVertex));
0065 [edgeAngleVector tmp] = convertCartToPolar(...
0066 shapeStruct.hrep.A(edgeIndexVector, 1)', ...
0067 shapeStruct.hrep.A(edgeIndexVector, 2)');
0068 edgeAngleVector = sort(edgeAngleVector);
0069 if (edgeAngleVector(2) - edgeAngleVector(1)) > pi
0070 edgeAngleVector = [edgeAngleVector(2) edgeAngleVector(1)+2*pi];
0071 end
0072 phi = edgeAngleVector(1):0.01:edgeAngleVector(2);
0073 else
0074 phi = 0:0.01:2*pi;
0075 end
0076
0077 hVertex(iVertex) = plot(...
0078 shapeStruct.vrep.V(iVertex, 1) + shapeStruct.lambda*cos(phi), ...
0079 shapeStruct.vrep.V(iVertex, 2) + shapeStruct.lambda*sin(phi), 'k-');
0080 end
0081
0082 set(hVertex, 'linewidth', 3, 'color', 'k')
0083 else
0084 hVertex = [];
0085 end
0086
0087
0088 set(gca, 'dataAspectRatio', [1 1 1]);
0089 set(gca, 'nextPlot', nextPlotState);
0090
0091 if nargout == 2
0092 varargout{1} = hEdge;
0093 varargout{2} = hVertex;
0094 elseif nargout == 1
0095 varargout{1} = [hEdge, hVertex];
0096 end