triextract


Untitled

Extracts a subtriangulation within a polygon

Syntax

subTR = triextract(TR,pgon)
subTR = triextract(TR,pgon,ExtractionCriterion)

Description

subTR = triextract(TR,pgon), returns a (sub)triangulation consisting of elements of the input triangulation, TR, that are fully contained within the input polyshape pgon.
subTR = triextract(TR,pgon,ExtractionCriterion), same as above but where the criterion for elements to be included in the extracted triangulation can be specified as ‘excludePartiallyIn’ (default) or ‘includePartiallyIn’.

Examples

Example 1 Extracting a regional triangulation
Consider the test triangulation
load testTR
figure; hold on; box on; daspect([1 1 1]);
triplot(testTR); axis([-100 -57 5 50])
To obtain a regional triangulation of the Gulf of Mexico, for example, a polyshape covering its extent can be defined
pgon = polyshape([-99 -89 -89 -81.7 -81.7 -99],[17 17 20 23.2 33 33]);
plot(pgon)
title(‘Original triangulation and extraction region’)
and then used to extract out the subtriangulation
subTR = triextract(testTR,pgon);
figure;
triplot(subTR,‘r’)
title(‘Extracted triangulation’);
Example 2 Demonstration of the extraction criterion
Consider the triangulation of a simple rectangular domain obtained by using the trirectangle function
TR = trirectangle([0 0,1,1],5,4,‘X-X’);
and define a simple diamond polyshape within this domain
pgon = polyshape([0.1 0.5 0.9 0.5],[0.5 0.05 0.5 0.95]);
Looking at a plot of the two, it can be seen that some elements are partially contained within the polyshape
figure; hold on; box on; axis([0 1 0 1]);
title(‘Original triangulation and polyshape’);
triplot(TR,‘b’,‘LineWidth’,2.0);
plot(pgon);
Now, the default setting of the triextract function is to only include elements of the input triangulation that are fully contained within the the input polyshape, i.e.,
subTR = triextract(TR,pgon);
as can be verified by a plot of the results
figure; hold on; box on; axis([0 1 0 1]);
title(‘Extracted triangulation with default extraction criterion’);
triplot(subTR,‘r’,‘LineWidth’,2.0);
plot(pgon);
To also include elements of the input triangulation that are only partially within the polyshape, one can specify the extraction criterion as
subTR = triextract(TR,pgon,‘includePartiallyIn’);
which changes the extracted subtriangulation as shown below
figure; hold on; box on; axis([0 1 0 1]);
title(‘Extracted triangulation with adjustment to the extraction criterion’);
triplot(subTR,‘r’,‘LineWidth’,2.0);
plot(pgon);

This function is part of……..

TriTools_Logo.png