Picking mesh elements that are not on the border of the mesh
As an example, let's say I use a set of random points to create a Voronoi mesh
pts = RandomReal[{-1, 1}, {100, 2}];
VoronoiMesh[pts, {-1, 1}]
and get something that looks like this:
My question is: Is there an efficient way to determine which of the regions (mesh elements, whatever you call them) are not touching the edge of the mesh? I know that there are a lot of built in functions that give properties of elements in a mesh, but I am unfamiliar with them, and I can't seem to find an efficient way to do this beyond "looping" through all elements and just picking which elements do not have points that touch the edge.
performance-tuning mesh
add a comment |
As an example, let's say I use a set of random points to create a Voronoi mesh
pts = RandomReal[{-1, 1}, {100, 2}];
VoronoiMesh[pts, {-1, 1}]
and get something that looks like this:
My question is: Is there an efficient way to determine which of the regions (mesh elements, whatever you call them) are not touching the edge of the mesh? I know that there are a lot of built in functions that give properties of elements in a mesh, but I am unfamiliar with them, and I can't seem to find an efficient way to do this beyond "looping" through all elements and just picking which elements do not have points that touch the edge.
performance-tuning mesh
RegionBoundary
? To get coordinates you can doRegionBoundary@mesh // MeshCoordinates
– b3m2a1
yesterday
@b3m2a1 I mean to find the "shapes" that are not touching the outside. I don't need the coordinates of the outer edge.
– Aaron Stevens
yesterday
Ah I did a lazy read through and figured you wanted the boundary. Always possible to take a complement with the boundary cells, though, to get the interior.
– b3m2a1
yesterday
add a comment |
As an example, let's say I use a set of random points to create a Voronoi mesh
pts = RandomReal[{-1, 1}, {100, 2}];
VoronoiMesh[pts, {-1, 1}]
and get something that looks like this:
My question is: Is there an efficient way to determine which of the regions (mesh elements, whatever you call them) are not touching the edge of the mesh? I know that there are a lot of built in functions that give properties of elements in a mesh, but I am unfamiliar with them, and I can't seem to find an efficient way to do this beyond "looping" through all elements and just picking which elements do not have points that touch the edge.
performance-tuning mesh
As an example, let's say I use a set of random points to create a Voronoi mesh
pts = RandomReal[{-1, 1}, {100, 2}];
VoronoiMesh[pts, {-1, 1}]
and get something that looks like this:
My question is: Is there an efficient way to determine which of the regions (mesh elements, whatever you call them) are not touching the edge of the mesh? I know that there are a lot of built in functions that give properties of elements in a mesh, but I am unfamiliar with them, and I can't seem to find an efficient way to do this beyond "looping" through all elements and just picking which elements do not have points that touch the edge.
performance-tuning mesh
performance-tuning mesh
asked yesterday
Aaron StevensAaron Stevens
319110
319110
RegionBoundary
? To get coordinates you can doRegionBoundary@mesh // MeshCoordinates
– b3m2a1
yesterday
@b3m2a1 I mean to find the "shapes" that are not touching the outside. I don't need the coordinates of the outer edge.
– Aaron Stevens
yesterday
Ah I did a lazy read through and figured you wanted the boundary. Always possible to take a complement with the boundary cells, though, to get the interior.
– b3m2a1
yesterday
add a comment |
RegionBoundary
? To get coordinates you can doRegionBoundary@mesh // MeshCoordinates
– b3m2a1
yesterday
@b3m2a1 I mean to find the "shapes" that are not touching the outside. I don't need the coordinates of the outer edge.
– Aaron Stevens
yesterday
Ah I did a lazy read through and figured you wanted the boundary. Always possible to take a complement with the boundary cells, though, to get the interior.
– b3m2a1
yesterday
RegionBoundary
? To get coordinates you can do RegionBoundary@mesh // MeshCoordinates
– b3m2a1
yesterday
RegionBoundary
? To get coordinates you can do RegionBoundary@mesh // MeshCoordinates
– b3m2a1
yesterday
@b3m2a1 I mean to find the "shapes" that are not touching the outside. I don't need the coordinates of the outer edge.
– Aaron Stevens
yesterday
@b3m2a1 I mean to find the "shapes" that are not touching the outside. I don't need the coordinates of the outer edge.
– Aaron Stevens
yesterday
Ah I did a lazy read through and figured you wanted the boundary. Always possible to take a complement with the boundary cells, though, to get the interior.
– b3m2a1
yesterday
Ah I did a lazy read through and figured you wanted the boundary. Always possible to take a complement with the boundary cells, though, to get the interior.
– b3m2a1
yesterday
add a comment |
2 Answers
2
active
oldest
votes
vm = VoronoiMesh[pts, {-1, 1}]
HighlightMesh[vm, MeshCellIndex[vm, {2, "Interior"}]]
Related: Boundary cells of a mesh?
Show[vm, Epilog -> {Opacity[.7, Orange], MeshPrimitives[vm, {2, "Interior"}]}]
Yep that was the simple answer I was expecting haha. Thanks!
– Aaron Stevens
yesterday
2
@kglr Wow, I'm impressed. Where did you find this syntax? The doc page ofMeshCellIndex
does not show it as example...
– Henrik Schumacher
yesterday
1
@HenrikSchumacher, blind search trying some objects returned byvm["Properties"]
:)
– kglr
yesterday
@HenrikSchumacher Exactly what I was thinking! I'll definitely look at those properties though and see if there are other useful things.
– Aaron Stevens
yesterday
add a comment |
For planar MeshRegion
that arise from DelaunayMesh
or VoronoiMesh
, usually
R["InteriorFaces"]
should work.
A more general and more transparent ways is to use the package "IGraphM`"
by Szabolcs as follows:
Needs["IGraphM`"]
A = IGMeshCellAdjacencyMatrix[R, 1, 2];
bndedges = Random`Private`PositionsOf[Total[A, {2}], 1];
interiorfaces = Random`Private`PositionsOf[Total[A[[bndedges]]], 0];
HighlightMesh[R, Thread[{2, interiorfaces}]]
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f189008%2fpicking-mesh-elements-that-are-not-on-the-border-of-the-mesh%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
vm = VoronoiMesh[pts, {-1, 1}]
HighlightMesh[vm, MeshCellIndex[vm, {2, "Interior"}]]
Related: Boundary cells of a mesh?
Show[vm, Epilog -> {Opacity[.7, Orange], MeshPrimitives[vm, {2, "Interior"}]}]
Yep that was the simple answer I was expecting haha. Thanks!
– Aaron Stevens
yesterday
2
@kglr Wow, I'm impressed. Where did you find this syntax? The doc page ofMeshCellIndex
does not show it as example...
– Henrik Schumacher
yesterday
1
@HenrikSchumacher, blind search trying some objects returned byvm["Properties"]
:)
– kglr
yesterday
@HenrikSchumacher Exactly what I was thinking! I'll definitely look at those properties though and see if there are other useful things.
– Aaron Stevens
yesterday
add a comment |
vm = VoronoiMesh[pts, {-1, 1}]
HighlightMesh[vm, MeshCellIndex[vm, {2, "Interior"}]]
Related: Boundary cells of a mesh?
Show[vm, Epilog -> {Opacity[.7, Orange], MeshPrimitives[vm, {2, "Interior"}]}]
Yep that was the simple answer I was expecting haha. Thanks!
– Aaron Stevens
yesterday
2
@kglr Wow, I'm impressed. Where did you find this syntax? The doc page ofMeshCellIndex
does not show it as example...
– Henrik Schumacher
yesterday
1
@HenrikSchumacher, blind search trying some objects returned byvm["Properties"]
:)
– kglr
yesterday
@HenrikSchumacher Exactly what I was thinking! I'll definitely look at those properties though and see if there are other useful things.
– Aaron Stevens
yesterday
add a comment |
vm = VoronoiMesh[pts, {-1, 1}]
HighlightMesh[vm, MeshCellIndex[vm, {2, "Interior"}]]
Related: Boundary cells of a mesh?
Show[vm, Epilog -> {Opacity[.7, Orange], MeshPrimitives[vm, {2, "Interior"}]}]
vm = VoronoiMesh[pts, {-1, 1}]
HighlightMesh[vm, MeshCellIndex[vm, {2, "Interior"}]]
Related: Boundary cells of a mesh?
Show[vm, Epilog -> {Opacity[.7, Orange], MeshPrimitives[vm, {2, "Interior"}]}]
edited yesterday
answered yesterday
kglrkglr
178k9198409
178k9198409
Yep that was the simple answer I was expecting haha. Thanks!
– Aaron Stevens
yesterday
2
@kglr Wow, I'm impressed. Where did you find this syntax? The doc page ofMeshCellIndex
does not show it as example...
– Henrik Schumacher
yesterday
1
@HenrikSchumacher, blind search trying some objects returned byvm["Properties"]
:)
– kglr
yesterday
@HenrikSchumacher Exactly what I was thinking! I'll definitely look at those properties though and see if there are other useful things.
– Aaron Stevens
yesterday
add a comment |
Yep that was the simple answer I was expecting haha. Thanks!
– Aaron Stevens
yesterday
2
@kglr Wow, I'm impressed. Where did you find this syntax? The doc page ofMeshCellIndex
does not show it as example...
– Henrik Schumacher
yesterday
1
@HenrikSchumacher, blind search trying some objects returned byvm["Properties"]
:)
– kglr
yesterday
@HenrikSchumacher Exactly what I was thinking! I'll definitely look at those properties though and see if there are other useful things.
– Aaron Stevens
yesterday
Yep that was the simple answer I was expecting haha. Thanks!
– Aaron Stevens
yesterday
Yep that was the simple answer I was expecting haha. Thanks!
– Aaron Stevens
yesterday
2
2
@kglr Wow, I'm impressed. Where did you find this syntax? The doc page of
MeshCellIndex
does not show it as example...– Henrik Schumacher
yesterday
@kglr Wow, I'm impressed. Where did you find this syntax? The doc page of
MeshCellIndex
does not show it as example...– Henrik Schumacher
yesterday
1
1
@HenrikSchumacher, blind search trying some objects returned by
vm["Properties"]
:)– kglr
yesterday
@HenrikSchumacher, blind search trying some objects returned by
vm["Properties"]
:)– kglr
yesterday
@HenrikSchumacher Exactly what I was thinking! I'll definitely look at those properties though and see if there are other useful things.
– Aaron Stevens
yesterday
@HenrikSchumacher Exactly what I was thinking! I'll definitely look at those properties though and see if there are other useful things.
– Aaron Stevens
yesterday
add a comment |
For planar MeshRegion
that arise from DelaunayMesh
or VoronoiMesh
, usually
R["InteriorFaces"]
should work.
A more general and more transparent ways is to use the package "IGraphM`"
by Szabolcs as follows:
Needs["IGraphM`"]
A = IGMeshCellAdjacencyMatrix[R, 1, 2];
bndedges = Random`Private`PositionsOf[Total[A, {2}], 1];
interiorfaces = Random`Private`PositionsOf[Total[A[[bndedges]]], 0];
HighlightMesh[R, Thread[{2, interiorfaces}]]
add a comment |
For planar MeshRegion
that arise from DelaunayMesh
or VoronoiMesh
, usually
R["InteriorFaces"]
should work.
A more general and more transparent ways is to use the package "IGraphM`"
by Szabolcs as follows:
Needs["IGraphM`"]
A = IGMeshCellAdjacencyMatrix[R, 1, 2];
bndedges = Random`Private`PositionsOf[Total[A, {2}], 1];
interiorfaces = Random`Private`PositionsOf[Total[A[[bndedges]]], 0];
HighlightMesh[R, Thread[{2, interiorfaces}]]
add a comment |
For planar MeshRegion
that arise from DelaunayMesh
or VoronoiMesh
, usually
R["InteriorFaces"]
should work.
A more general and more transparent ways is to use the package "IGraphM`"
by Szabolcs as follows:
Needs["IGraphM`"]
A = IGMeshCellAdjacencyMatrix[R, 1, 2];
bndedges = Random`Private`PositionsOf[Total[A, {2}], 1];
interiorfaces = Random`Private`PositionsOf[Total[A[[bndedges]]], 0];
HighlightMesh[R, Thread[{2, interiorfaces}]]
For planar MeshRegion
that arise from DelaunayMesh
or VoronoiMesh
, usually
R["InteriorFaces"]
should work.
A more general and more transparent ways is to use the package "IGraphM`"
by Szabolcs as follows:
Needs["IGraphM`"]
A = IGMeshCellAdjacencyMatrix[R, 1, 2];
bndedges = Random`Private`PositionsOf[Total[A, {2}], 1];
interiorfaces = Random`Private`PositionsOf[Total[A[[bndedges]]], 0];
HighlightMesh[R, Thread[{2, interiorfaces}]]
answered yesterday
Henrik SchumacherHenrik Schumacher
49.8k469143
49.8k469143
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f189008%2fpicking-mesh-elements-that-are-not-on-the-border-of-the-mesh%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
RegionBoundary
? To get coordinates you can doRegionBoundary@mesh // MeshCoordinates
– b3m2a1
yesterday
@b3m2a1 I mean to find the "shapes" that are not touching the outside. I don't need the coordinates of the outer edge.
– Aaron Stevens
yesterday
Ah I did a lazy read through and figured you wanted the boundary. Always possible to take a complement with the boundary cells, though, to get the interior.
– b3m2a1
yesterday