# Shared Edge(s)

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 23/02/2005 at 16:02, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   9.1
Platform:
Language(s) :     C++  ;

---------
I am sure this is pretty trivial, but I am curious how anyone has gone about determining a shared edge between polygons? any clean algorithms for doing this?

TIA

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 23/02/2005 at 17:24, xxxxxxxx wrote:

Well, one way is to find two vertex references shared between polygons. If two polygons both reference the same two vertices, then they MUST share an edge (or a degenerate edge = point (where both sets of shared vertices are equivalent vectors). This will NOT work if the polygons have equivalent vertices, but unshared references (e.g.: right next to each other, but not welded). Then you'd also have to include vector comparisons between vertices.

Clarification:

Polygons contain reference indices into a vertex array (point array), not the actual vertices themselves.

So, if polygon pA references vertices (8,9,11,12) and polygon pB references vertices (24,11,9,13), they share an edge at (9,11).

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 24/02/2005 at 06:48, xxxxxxxx wrote:

Thanks for that Robert. In your opinion since I have a PolygonObject that contains my selected polys should I use the Neighbor class or something similar to iterate the vertex arrays for each polygon, or is there some other way?

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 24/02/2005 at 08:44, xxxxxxxx wrote:

Haven't used the Neighbor class, but it sure looks like it's made just for this determination. :)

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 24/02/2005 at 15:06, xxxxxxxx wrote:

hmmm I may be making this more difficult than I need. Is there a simplistic way to pull out individual polys from a BaseSelect holding GetPolygonS? I need to inspect individual polygons at this point

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 24/02/2005 at 15:21, xxxxxxxx wrote:

How are you doing it?

The standard approach is given in the Docs:

``````
CPolygon *polyArray = polyObject->GetPolygon();
BaseSelect *bs = polyObject->GetPolygonS();
LONG seg=0,a,b,x;

while (bs->GetRange(seg++,&a;,&b;)
{
for (x=a; x<=b; ++x)
{
// ... do something - x is the selected element
polyArray[x].a; //e.g. & etc.
}
}
``````

I think one thing that Maxon needs to clarify with most of their arrays and selections is that they always contain the points/edges/polygons/etc. count for the entire object. A selection set has the same size as the number of points, edges, or polygons that it is working with. But what is selected is set to 1 (TRUE) instead of 0 (FALSE). So, it is not a subset, it is a full set with a subset selected within. And it is not a pointer set, just indices into the array.

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 24/02/2005 at 16:41, xxxxxxxx wrote:

well I mean what I am trying to do is simple (at least it should be...) I want to select two polys and rotate the shared edge around. I know it's been done but it is something I have been wanting to "figure" out. Something that was definitely missing from my code was the use of CPolygon. That helps for sure, but now I just need to figure out the mechanism to rotate the shared edge. Is that in the docs as well?

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 24/02/2005 at 18:59, xxxxxxxx wrote:

Might be. :)

When you say 'rotate shared edge', what do you mean? Swap the vertex indices in each polygon so that the share edge is going the opposite the other polygon vertices? Or do you mean actually apply a rotation, say, at the midpoint of the shared edge?

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 24/02/2005 at 19:52, xxxxxxxx wrote:

hehe.. thanks for bearing with me :-)

when I say 'rotate a shared edge' I mean just that. In terms of functionality think or the EdgeRotate, or SpinPoly plugins here.

• THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 25/02/2005 at 10:51, xxxxxxxx wrote:

This is a simple matter of treating the adjacent polygons as one (get both their indices and put them together) and changing vertex indicing between them (polygon subdivision).

ETA: Nonconvex Ngons may prove to be tricky. Not all vertex pairs produce valid edges.