Grasshopper

algorithmic modeling for Rhino

Hi,

As starling polylines components are based on custom, discrete class (polymesh) I had to remake basic mesh stuff (creating topology, finding connected vertices, faces, adjacent faces etc.) I also added offset component, which works exact as wbOffset but with polylines (offset bunch of polylines like they were a mesh).

Here comes my problem : what is a basic scheme (pseudo-code) to redefine face and/or vertex normals to flip them uniformely ? Is breath-first search somehow used to compute each face only once ? Do I have to measure all angles ?

Views: 2764

Replies to This Discussion

Okay I am totally out of my depths at this level of complexity, but maybe if you want to use a breadth-first search of the faces, you could search all adjacent polygons to your start face, and flip their vertex order if their direction around the shared edge is wrong. In the image below:

So in this example, if 0 is your start face, you'd want to guarantee that for face 1, its vertices on the shared edge go in the order D-E and not E-D. In the example above you'd want to flip the vertex order on face 2 because the vector at the shared edge is parallel to the one in face 0 rather than anti-parallel. 

Assuming your mesh doesn't pull any nasty mobius strip topology tricks, I think this is sufficient to guarantee that your face vertex lists are all clockwise (or all counter-clockwise), which is in turn sufficient for the calculation of the face normal according to newell's method. (the cross product of two adjacent edge vectors).

Also note (I learned this the hard way) if you can't guarantee that the polygons are convex, you need to calculate the cross product for EVERY pair of edges rather than just two, and then take the sum of all the cross products.

So to sum up, in my best attempt at a pseudocode version of the above (I will most certainly butcher BFS but clearly you have an idea how it works):

breadth-first search across the faces of the polymesh

for each face check the vector of the adjacent edge against the vector of the same edge in the previous face 

if they are parallel flip the order of the vertices in the polygon

calculate the normal using newell's method

next

I make no guarantees that this will even work! But I hope maybe it spurs your thinking a bit :) It's a pretty interesting problem, so please share what solution ends up working - I am eager to learn for myself!

Thanks ! I was thinking in that direction too, it seems to be the easiest attempt to flip normals. I am just wondering now is there any "array magic" that can be used here.... wonder how rhino itself makes normal uniform.

Hi Mateusz,

The upcoming release of Weaverbird will contain this functionality with the same scheme as other wb components, but of course please feel free to implement this, too. Faces orientation unification can really be as Andrew is suggesting. Wb already does this in the two bevel (chamfer) components. There are cases that are not solvable, I believe, e.g. with the mentioned Moebius strip or with non-2-manifold edges.

Giulio

Hi Giulio,

Starling components dont even try to step into classic (3 and 4gonal) mesh editing territories. What I've already published is set of tools that enables editing set of polylines (like hex grid) in the manner that is known rather from mesh capabilities... see the image :

Are you suggesting there isnt a sure fire way to know which way the normals come out for some weaver bird solutions?

Therfore I would love to know if I could unify the normals of a mesh to make it an object. Rather than it being an inside out object - if you know what i mean?? After the meshing process?

Any ideas?

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service