Edge Selection indices



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

    On 09/11/2012 at 01:32, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:    
    Platform:   Windows  ;   Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    I have a question about what the edge index of a selection represents with respect to either a triangular or quadrangular polygon?

    "Edges are indexed (4*poly)+edge where edge is from 0-3."

    If poly is a triangle and edge 2 is considered, is the edge from poly.c->poly.a or does it always represent poly.c->poly.a?  Here is my code.  Please help me validate that it is correctly considering the vertex indices represented by each edge:

            LONG    pi, ei;  
          for (LONG seg = 0L; bs->GetRange(seg,&a,&b); ++seg)  
          {  
              for (i=a; i<=b; ++i)  
              {  
                  pi =    i/4L;  
                  ei =    Mod(i,4L);  
                  if        (ei == 0L)  
                  {  
                      DetermineAsSourceVertex(verts, normal, polys[pi].a, side, mepsilon);  
                      DetermineAsSourceVertex(verts, normal, polys[pi].b, side, mepsilon);  
                  }  
                  else if (ei == 1L)  
                  {  
                      DetermineAsSourceVertex(verts, normal, polys[pi].b, side, mepsilon);  
                      DetermineAsSourceVertex(verts, normal, polys[pi].c, side, mepsilon);  
                  }  
                  else if (ei == 2L)  
                  {  
                      DetermineAsSourceVertex(verts, normal, polys[pi].c, side, mepsilon);  
                      if (polys[pi].c != polys[pi].d)  
                          DetermineAsSourceVertex(verts, normal, polys[pi].d, side, mepsilon);  
                      else  
                          DetermineAsSourceVertex(verts, normal, polys[pi].a, side, mepsilon);  
                  }  
                  else // ei == 3L  
                  {  
                      DetermineAsSourceVertex(verts, normal, polys[pi].d, side, mepsilon);  
                      DetermineAsSourceVertex(verts, normal, polys[pi].a, side, mepsilon);  
                  }  
              }  
          }  
    


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

    On 09/11/2012 at 03:55, xxxxxxxx wrote:

    Yes, that looks right to me. I have made the same assumptions in my plugins.

    /Filip



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

    On 20/11/2012 at 10:43, xxxxxxxx wrote:

    I just woke up and haven't had me coffee yet but... are you sure that side 2 is used at all if it's a triangle?  I may be crossing some info about one thing with another, but IIRC, side 2 is typically not used/indicated if it's a triangle, which would allow you to skip a test (not a big deal, either way).



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

    On 21/11/2012 at 05:45, xxxxxxxx wrote:

    Edge 3 (for 0-3 indices) would be omitted and skipped for a triangle.



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

    On 21/11/2012 at 08:39, xxxxxxxx wrote:

    My reference was from the PolyInfo structure, where you find this in the SDK docs...

      
    `.... S N I P ....  
      
      for (i=0; i<polygon_count; i++)  
      {  
      pli = n->GetPolyInfo(i);  
      
      for (side=0; side<4; side++) // test all 4 sides of a polygon  
      {  
        // only proceed if edge has not already been processed  
        // and edge really exists (***** for triangles side 2 from c..d does not exist as c==d ****** )  
        if (pli->mark[side] || side==2 && vadr[i].c==vadr[i].d) continue;  
        
        // one can also skip the side==2 && vadr[i].c==vadr[i].d test as pli->mark[2] is always TRUE for triangles  
        switch (side)  
        {  
          case 0: a=vadr[i].a; b=vadr[i].b; break;  
          case 1: a=vadr[i].b; b=vadr[i].c; break;  
          case 2: a=vadr[i].c; b=vadr[i].d; break;  
          case 3: a=vadr[i].d; b=vadr[i].a; break;  
        }  
        // do something with the edge a..b  
      }  
      }  
      `  
      
    0-1-2-3 are the indices for a-b/b-c/c-d/d-a. For triangles the face/edge index 2 is set to NOTOK (as c == d). e.g. a value of 5-8-2-1 for 'face' means: a-b neighbor face is 5, b-c neighbor face is 8 etc.   
    `  
    .... S N I P ....  
    `
    

    ...it seems to me that all references to edges (and/or edge numbering) would follow the same logic - since the c-d edge doesn't exist for triangles, it would/should not be listed/indicated.


Log in to reply