Jump to content

Edge Selection by index dilemma


Recommended Posts

c4d.PolygonObject has a method called SetSelectedEdges() which is documented as follow (quoted from most current help, i.e. from C4D S22)

PolygonObject.SetSelectedEdges(self, e, pSel, ltype)
Set the selected, hidden or phong break edges.
The edges are indexed uniquely by a Neighbor object, so each edge has a single index.

Note

 

This is a convenience wrapper around GetEdgeS(), GetEdgeH() and GetPhongBreak().

Parameters:
  • e (c4d.utils.Neighbor) – The neighbor object with information about the edge topology. Must be initialized with all polygons, i.e. with Neighbor.Init().
  • pSel (c4d.BaseSelect) – The edge to select.
  • ltype (int) –

    The type of selection to get:

    EDGESELECTIONTYPE_SELECTION Selected edges.
    EDGESELECTIONTYPE_HIDDEN Hidden edges.
    EDGESELECTIONTYPE_PHONG Phong edges.
Return type:

bool

Returns:

True if the selection succeeded, otherwise False.

OK, that's great, I populate the c4d.BaseSelect with all of the edge indices (using the Neighbor object's definition of logical edge indices) that I want to select and the c4d.utils.Neighbor object takes care of figuring out which physical edges and polygons they belong to, in order to make sure that the selection is "valid." What is the definition of validity here? Well apparently, we need to make sure to select all physical edges across all polygons that share said physical edges. In other words, instead of selecting a physical edge once, we would have to select it potentially multiple times, once for each of the polygons sharing said edge. The help for GetEdgeS(), tells us this information in the red Warning text:

PolygonObject.GetEdgeS(self)
Get the selected edges.
The edges are indexed by 4 * polygon + edge where polygon is the polygon index and edge is the edge index between 0 and 3.

Warning

If you change this selection you must make sure that its still valid, so that shared edges have a well-defined selection status.
It is safer to use SetSelectedEdges().
Return type: c4d.BaseSelect
Returns: A reference to the selection of visible edges.

The Warning text tells us to use SetSelectedEdges() with a Neighbor object to make sure that any edges we select which are shared by multiple polygons (i.e., non-boundary edges) get selected with respect to all polygons that share said edges (the definition of "valid," as previously described). OK, that certainly sounds convenient. Instead of trying to fish for all of the physical edges across all polygons when I would like to select an edge. I can just choose a single edge by index in the Neighbor object and let it figure out what physical edges my logical edge represents.

The Problem

How in the world can I choose the edges to select by index from the Neighbor object (for use in my BaseSelect), if the c4d.utils.Neighbor class offers no way to get the properties of logical edges by their index (as stored somewhere internally in the Neighbor object). The only thing I see available is a GetEdgeCount() method which returns the number of (logically distinct) edges and in effect defines the set of logical Edge indices as a range from 0 to GetEdgeCount()-1. What I don't see is a method to get the properties of an edge by logical edge index. It seems to me that the notion of a logical edge index is completely opaque to users of the Neighbor class and if this is the case, how can one refer to edges by their logical index in the Neighbor object, not knowing what edges they are referencing?

As a case in point, below is the entire API for the c4d.utils.Neighbor class (aside from polygon assignment via Init() and discard via Flush(), which are not relevant to the discussion).

There is not a single method here that tells me which actual edge (or properties of an edge) a logical edge index refers to, so I that I can select edges by index in a BaseSelect object and use the BaseSelect to define a selection range for the pSel argument of the PolygonObject.SetSelectEdges() method.

# Note that, for all of the methods below that use these, a, b, and pnt are point indices 
# in the polygon and poly is the polygon index. The notion of an edge index is nowhere
# to be seen!

Neighbor.GetNeighbor(self, a, b, poly)
Neighbor.GetPointPolys(self, pnt)
Neighbor.GetEdgePolys(self, a, b)
# Get the total number of edges found.
Neighbor.GetEdgeCount(self)
# Get a dict that contains neighbor information about the given polygon. 
# One can use this to browse through all available edges using the following code
# (My edit: Gives you the kitchen sink. Does not give you any info about edge indices
#           in the Neighbor object, though, and how they relate to specific edges.)
Neighbor.GetPolyInfo(self, poly)    
# Gets the points that are attached through one edge to the given point.
Neighbor.GetPointOneRingPoints(self, pnt)

Am I overlooking something?

 

 

Link to post
  • Silver Contributor

You've got some replies in your thread over at the plugincafé. I propose to continue the discussion overthere.

Link to post
12 hours ago, C4DS said:

You've got some replies in your thread over at the plugincafé. I propose to continue the discussion overthere.

Nothing actionable, I am afraid, and a misunderstanding of the question posed. I was hoping someone here would know the answer.

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...