Detecting Boundary Edges in ICE

Here you can find ICE tutorials and learning material
Post Reply
fabricio.chamon
Posts: 94
Joined: 09 Jun 2009, 23:47

Detecting Boundary Edges in ICE

Post by fabricio.chamon » 31 Jan 2011, 13:57

(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.

Image

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. See image below:

Image

Once we know hot 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:

Image

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.

Image

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.

Image
Click to vew a bigger image

Image
The search shift should be as small as possible to avoid querying polygons too far or unrelated to the actual edge. A value of 0.01 is good for most scenarios.


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:

Image

Image

...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!

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests