On Wed, Jan 11, 2012 at 2:26 PM, I wrote:
> This could probably be improved, but it gives the basic idea:
>
> triclos=: 4 :0
> ids=. i.#x
> whilst. -. old -: ids do.
> old=. ids
> ids=. (3 #"0 <./"1 y { ids) y} ids
> end.
> (<./"1 y { ids) </. y
> )
>
> XYZ triclose TRI
>
> The result is the fewest possible boxes of triangles where all
> triangles within a box can be reached using edges of other triangles
> in that box.
>
> Note that if you have reason for independent points to be located at
> the same spot, and you want connections from a triangle using one of
> those instances to be connected with all triangles using any of the
> other instances you would change the first line to:
>
> ids=. i.~x
This will not work the way I intended it to work.
Instead:
triclos=: 4 :0
ids=. (~.,y) { i.~ x
whilst. ~. old -: ids do.
old=. ids
ids=. y <.//.&, 3#"0 <./"1 y { ids
end.
(<./"1 y { ids) </. y
)
The first line can be simplified to:
ids=. ~.,y
if points are unique (if a unique xyz index finds a unique vertex).
Sorry about that.
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm