<p>I'm assuming you are rendering this object as a set of triangles. To do what you are trying to do, you will need to store all your triangles (and vertices) in some sort of buffer or list. Then, for each triangle, test if all three of its sides are matched with another triangle side. If so, it is enclosed and inside the object. Otherwise, it is outside the object. Some basic pseudo-code (I apologize for all the foreach loops :) )</p>

<pre><code>foreach t in triangles:
    all_sides_touched = True
    foreach side_t in t:
        this_side_touched = False
        foreach u in triangles.exclude(t):    // run through all other triangles to test
            foreach side_u in u:
                if side_t.equals(side_u):  this_side_touched = True
        all_sides_touched = all_sides_touched and this_side_touched
    if not all_sides_touched:
        foreach side in t:
            foreach point in side:
                // do whatever you want to do with outside vertices
</code></pre>

CC BY-SA 3.0
2017-07-28T18:04:53.583Z
2017-07-28T18:04:53.583Z
clabe45
<p>A close solution would be like <a href="https://stackoverflow.com/questions/11779797/how-to-detect-border-vertices-of-an-open-mesh-3d-model">How to detect border vertices of an open mesh 3d model? | Stack Overflow</a></p>

<p>For edge, you test in the edge is connected to at least 2 triangles. If it is not the case, the edge is a border under the assumption that the mesh is a manifold.</p>

CC BY-SA 3.0
2017-08-01T14:29:07.837Z
2018-04-09T08:58:03.337Z
2018-04-09T08:58:03.337Z
AlexM
<p>I trying to highlight vertices which are on "borders", imagine half of sphere for example. Also for example I added image geomtry with triangles and highlighted necessary vertices. Any ideas? Thanks
<img src="https://i.sstatic.net/o1NfK.jpg" alt="Graph"></p>

CC BY-SA 3.0
2017-07-31T07:04:36.717Z
There is a similar question in stackoverflow which could help you: https://stackoverflow.com/questions/14108553/get-border-edges-of-mesh-in-winding-order
AlexM
CC BY-SA 3.0
2017-07-28T15:28:12.563Z
How are you currently storing your mesh data? For example do you have a  half-edge data structure, or just vertex/index buffers, or something else?
Nathan Reed
<mathematics>
How to find vertices on borders of geometry
Nikita Krupitskas
# How to find vertices on borders of geometry

(Asked by: username_0 on 2017-07-28)

I trying to highlight vertices which are on "borders", imagine half of sphere for example. Also for example I added image geomtry with triangles and highlighted necessary vertices. Any ideas? Thanks
![Graph](https://i.sstatic.net/o1NfK.jpg)

**Tags:** mathematics

> **Comments:**
> **username_2**: How are you currently storing your mesh data? For example do you have a  half-edge data structure, or just vertex/index buffers, or something else?  
> **username_1**: There is a similar question in stackoverflow which could help you: https://stackoverflow.com/questions/14108553/get-border-edges-of-mesh-in-winding-order  

---

## 2 answers

### Answer by username_3 on 2017-07-28. Score: 1

I'm assuming you are rendering this object as a set of triangles. To do what you are trying to do, you will need to store all your triangles (and vertices) in some sort of buffer or list. Then, for each triangle, test if all three of its sides are matched with another triangle side. If so, it is enclosed and inside the object. Otherwise, it is outside the object. Some basic pseudo-code (I apologize for all the foreach loops :) )

```
foreach t in triangles:
    all_sides_touched = True
    foreach side_t in t:
        this_side_touched = False
        foreach u in triangles.exclude(t):    // run through all other triangles to test
            foreach side_u in u:
                if side_t.equals(side_u):  this_side_touched = True
        all_sides_touched = all_sides_touched and this_side_touched
    if not all_sides_touched:
        foreach side in t:
            foreach point in side:
                // do whatever you want to do with outside vertices

```


---

### Answer by username_1 on 2017-08-01. Score: 0

A close solution would be like [How to detect border vertices of an open mesh 3d model? | Stack Overflow](https://stackoverflow.com/questions/11779797/how-to-detect-border-vertices-of-an-open-mesh-3d-model)

For edge, you test in the edge is connected to at least 2 triangles. If it is not the case, the edge is a border under the assumption that the mesh is a manifold.


---

