Saturday, January 29, 2011

Boundary Edges





(note: deprecated for SI 2012+, since it now has intrinsic ice attributes for retrieving boundary components)

 (Please note that this is an approximated method and its not meant to be literally correct. But it should output correct results about 95% of the time. That said, let's get started!)

Download Link: Is Edge Boundary Compound


Finding boundary edges is a pretty common task requested in computer graphics. It can be used to fill holes, amongst other things.

In my opinion, "isBoundary" should be a default ice attribute for an Edge. But you know, life is not easy... so let's take a look at how can we find it by ourselves:


Step 1: How to define a boundary edge? 

Simply put, edges are conections between polygons, and the difference between boundary and regular edges are the number of polygons connected to them. Once we know how to define it, it's time for the ice stuff:


Step 2: Getting the adjacent polygons.

To retrieve the adjacent polygons of an edge we can get its position and do a geometry query from that.
The problem is that only the closest polygon position is returned, thus we have reached just half of our way to getting the 2 connected faces. 

To get the other polygon (and this is where it gets a bit hacky) I found that we could subtract the polygon vector from the edge vector and multiply it by a tiny bit, so that the lookup position gets slightly shifted and the next query will hopefully give us a different (and oposite) adjacent polygon.


Step 3: Isolating the boundaries 

As soon as we have the new result from the other "get closest location" node, we can compare the polygon positions. If the edge is connecting 2 faces, it will return 2 different polygon positions... But if the edge is a boundary, the new search position will fail to reach to any other polygon, and will fall back to the same requested before. From now on a simple if node comparing the two positions will reveal the boundaries.

 ...and as we started working on the edge perspective since the beggining of the ice graph, our output will gracefully stay in a "boolean per edge" context.


Conclusion / Tips

Although this is working great so far in my tests, I should point out that this method fails in case of super folded polygons (closest polygon lookup does not return the adjacent face to the edge we are searching from), so please consider before using this method. Also be sure to put the icetree above the modeling stack, so that it always compute after any topo ops you have. And lastly, If you are getting strange results, try playing with the search shift to see how it goes.

If you don't want to rebuild the ice tree by yourself, just download the compound (link on top of the article).

Hope you find it useful!

3 comments:

  1. There is a very easy way to do this without ICE, just follow the steps:

    1-Select all edges
    2-Shrink selection
    3-Invert selection

    This way you have all boundary edges selected!

    Best regards
    Filipe Alves

    ReplyDelete
  2. Or you could use the Border Edges selection filter.

    Adam.

    ReplyDelete