Picking mesh elements that are not on the border of the mesh












4














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:



enter image description here



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.










share|improve this question






















  • RegionBoundary? To get coordinates you can do RegionBoundary@mesh // MeshCoordinates
    – b3m2a1
    27 mins ago












  • @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
    20 mins ago










  • 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
    19 mins ago
















4














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:



enter image description here



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.










share|improve this question






















  • RegionBoundary? To get coordinates you can do RegionBoundary@mesh // MeshCoordinates
    – b3m2a1
    27 mins ago












  • @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
    20 mins ago










  • 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
    19 mins ago














4












4








4







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:



enter image description here



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.










share|improve this question













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:



enter image description here



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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 41 mins ago









Aaron StevensAaron Stevens

294110




294110












  • RegionBoundary? To get coordinates you can do RegionBoundary@mesh // MeshCoordinates
    – b3m2a1
    27 mins ago












  • @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
    20 mins ago










  • 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
    19 mins ago


















  • RegionBoundary? To get coordinates you can do RegionBoundary@mesh // MeshCoordinates
    – b3m2a1
    27 mins ago












  • @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
    20 mins ago










  • 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
    19 mins ago
















RegionBoundary? To get coordinates you can do RegionBoundary@mesh // MeshCoordinates
– b3m2a1
27 mins ago






RegionBoundary? To get coordinates you can do RegionBoundary@mesh // MeshCoordinates
– b3m2a1
27 mins ago














@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
20 mins ago




@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
20 mins ago












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
19 mins ago




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
19 mins ago










2 Answers
2






active

oldest

votes


















3














vm = VoronoiMesh[pts, {-1, 1}]
HighlightMesh[vm, MeshCellIndex[vm, {2, "Interior"}]]


enter image description here



Related: Boundary cells of a mesh?



Show[vm, Epilog -> {Opacity[.7, Orange], MeshPrimitives[vm, {2, "Interior"}]}]


enter image description here






share|improve this answer























  • Yep that was the simple answer I was expecting haha. Thanks!
    – Aaron Stevens
    17 mins ago



















5














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}]]


enter image description here






share|improve this answer





















    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    3














    vm = VoronoiMesh[pts, {-1, 1}]
    HighlightMesh[vm, MeshCellIndex[vm, {2, "Interior"}]]


    enter image description here



    Related: Boundary cells of a mesh?



    Show[vm, Epilog -> {Opacity[.7, Orange], MeshPrimitives[vm, {2, "Interior"}]}]


    enter image description here






    share|improve this answer























    • Yep that was the simple answer I was expecting haha. Thanks!
      – Aaron Stevens
      17 mins ago
















    3














    vm = VoronoiMesh[pts, {-1, 1}]
    HighlightMesh[vm, MeshCellIndex[vm, {2, "Interior"}]]


    enter image description here



    Related: Boundary cells of a mesh?



    Show[vm, Epilog -> {Opacity[.7, Orange], MeshPrimitives[vm, {2, "Interior"}]}]


    enter image description here






    share|improve this answer























    • Yep that was the simple answer I was expecting haha. Thanks!
      – Aaron Stevens
      17 mins ago














    3












    3








    3






    vm = VoronoiMesh[pts, {-1, 1}]
    HighlightMesh[vm, MeshCellIndex[vm, {2, "Interior"}]]


    enter image description here



    Related: Boundary cells of a mesh?



    Show[vm, Epilog -> {Opacity[.7, Orange], MeshPrimitives[vm, {2, "Interior"}]}]


    enter image description here






    share|improve this answer














    vm = VoronoiMesh[pts, {-1, 1}]
    HighlightMesh[vm, MeshCellIndex[vm, {2, "Interior"}]]


    enter image description here



    Related: Boundary cells of a mesh?



    Show[vm, Epilog -> {Opacity[.7, Orange], MeshPrimitives[vm, {2, "Interior"}]}]


    enter image description here







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 16 mins ago

























    answered 20 mins ago









    kglrkglr

    177k9198408




    177k9198408












    • Yep that was the simple answer I was expecting haha. Thanks!
      – Aaron Stevens
      17 mins ago


















    • Yep that was the simple answer I was expecting haha. Thanks!
      – Aaron Stevens
      17 mins ago
















    Yep that was the simple answer I was expecting haha. Thanks!
    – Aaron Stevens
    17 mins ago




    Yep that was the simple answer I was expecting haha. Thanks!
    – Aaron Stevens
    17 mins ago











    5














    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}]]


    enter image description here






    share|improve this answer


























      5














      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}]]


      enter image description here






      share|improve this answer
























        5












        5








        5






        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}]]


        enter image description here






        share|improve this answer












        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}]]


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 26 mins ago









        Henrik SchumacherHenrik Schumacher

        49.8k469142




        49.8k469142






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            濃尾地震

            How to rewrite equation of hyperbola in standard form

            No ethernet ip address in my vocore2