THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/02/2012 at 15:34, xxxxxxxx wrote:
Cinema 4D Version: r12
Language(s) : C++ ; PYTHON ;
I noticed in Maya they have a function that lets the developers select shells of an object.
Which basically does what the ExplodeSegements command does in C4D. But without creating the actual shelled polygons in the scene.
Their devs. can grab points, polys, and edges of these shells and work on them inside of memory. Without having to physically create the shells in the scene.
I was wondering if it would be possible to see the source code for the ES command. So that we could possibly chop out the insert objects part of it. And possibly work on the shells of a polygon object in memory. Without being forced to physically add them as copies to the OM.
Or is there more to it than that?
On 03/02/2012 at 03:27, xxxxxxxx wrote:
Not sure, if I understand your request correctly, but wouldn't this be accomplishable by using the correction transformer?
On 03/02/2012 at 08:05, xxxxxxxx wrote:
I think we're talking about different things.
I'd like to know how to select the individual groups of isolated polygon clusters within a single polygon object. And put each of these groups of polygons, points, edges into it's own array so I could select or make changes to them. Without having to physically create them.
I can't figure out how to loop through a single polygon object. And collect all of those connected polygon groups per loop iteration. So I can put them into their own arrays and work on them as individual objects.
Seeing the code for the ExplodeSegments command might help me figure out how to do that.
On 03/02/2012 at 09:32, xxxxxxxx wrote:
Oh, ok, I misunderstood...
On 03/02/2012 at 09:51, xxxxxxxx wrote:
Still thinking about it...
You want to accomplish this, without searching the polygon array for shared points, right?
On 03/02/2012 at 10:00, xxxxxxxx wrote:
Hard for me to answer that one. Because I don't know the results I'd get from it.
If you know a way to find these polygon shells(or islands) by looking through the polygon for shared points. I'd be interested in seeing it.
It might end up being what I need.
I've been googling this subject. And I can't find any C++ or Python code that explains how to do it.
Yet this is something that is built into most 3D programs. In some manner.
It must be a fairly general knowledge kind of thing...But I can't seem to find much information on doing it.
On 03/02/2012 at 10:17, xxxxxxxx wrote:
I'm lacking the time right now, but I try to sketch my rather basic thoughts on this...
Basically two polygons sharing one or more points are connected.
So you could take the first poly, and search all others for shared points. Any found polygon would add to your current segment. This would have to continue until you searched the polygon array for all points contained in the current segment. Then you'd start over with another unconnected poly for the next segment.
For any object with more than a few polygons, this sounds awfully slow to me. Perhaps one could reorder the polygons first in some way, in order to speed up the search. Perhaps one could collect/grow segments in parallel without caring, if these are actually connected and in the end check the gathered segments for connection.
Sorry for being so vague. Tomorrow I'll brainstorm some more on it. On the other hand, I think, as you seem to be way more experienced than I am, you already had these thoughts yourself and dumped them for perhaps obvious reasons (slow, too tedious, ...).
On 03/02/2012 at 10:54, xxxxxxxx wrote:
I had thought of something similar to that:
-Select point index(0)
-Execute the SelectConnected command
-The first shell is now selected. So I put them into a new array
Now comes the part I get stuck on.
How do I jump to the next vertice that isn't in that shell?
And how do I not accidentally select a vertice I've already previously selected and placed into an array while I'm looping through the verts?
On 03/02/2012 at 17:36, xxxxxxxx wrote:
Ah... SelectConnected command... I was quickly looking through the API, when writing my last post, but in the rush hadn't found it.
Regarding your problem... after a few beer, my first impulse says: hash table! Yeah!
While still in the process of finding the segments, you could store the polygons in a hash table (or some other nifty data structure, that speeds up the search) rather than in an array (personally I like to use sglib, but there surely is some more C++ like solution as well, sglib should nevertheless work well. And don't fear, it's not an actual library, but rather a tricky headerfile (pure ANSI C) providing different sorts of data structures, like my beloved red-black-trees... sorry drifting away...). Having done so, like one hash table per segment, you can easily look up any polygon.
So after each segment you can walk through the object's polygon array, checking for each polygon, if it is already covered by a segment. And if one is not, the new segment starts (store the point up to which you already walked the polygon array, so you need not search this part again).
The hash table can also nicely prevent adding the same poly twice to a segment.
And then in the end you can simply transfer your hash tables back into polygon arrays.
Perhaps the beer speaks out of these thoughts... dump them, if they are rubbish.