Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Iterate through all Edges of PolygonObject[SOLVED]

    SDK Help
    0
    4
    441
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      On 29/04/2015 at 22:21, xxxxxxxx wrote:

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

      ---------
      Hello,

      I want to iterate through all edges of an PolygonObject and get their vectors. How can I do that?
      I've done this already with Python by using a BaseSelect, but I think, there must be a better way.

      Thanks 😉

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 30/04/2015 at 06:21, xxxxxxxx wrote:

        I found the solution in the SDK documentation:

        Example:
        The following code browses through all available edges:
        Int32 a, b;
        Neighbor neighbor;
        if (!neighbor.Init(pcnt, vadr, vcnt, nullptr))
        return false;
        for (i=0; i<polyCount; i++)
        {
        > PolyInfo* polyInfo = neighbor->GetPolyInfo(i);
        >
        > for (side=0; side<4; side++) // Test all 4 sides of a polygon
        >
        > {
        >
        >> // Only proceed if the edge has not already been processed and edge really exists
        >>
        >> // For triangles side 2 from c..d does not exist as c==d
        >>
        >> // One can also skip the side==2 && vadr _.c==vadr _.d test as pli- >mark[2] is always true for triangles
        >>
        >> if (pli->mark[side] || side==2 && vadr _.c==vadr _.d)
        >>
        >>> continue;
        >>
        >> switch (side)
        >>
        >> {
        >>
        >>> case 0: a = vadr _.a; b = vadr _.b; break;
        >>>
        >>> case 1: a = vadr _.b; b = vadr _.c; break;
        >>>
        >>> case 2: a = vadr _.c; b = vadr _.d; break;
        >>>
        >>> case 3: a = vadr _.d; b = vadr _.a; break;
        >>
        >> }
        >
        >> // Do something with the edge a..b
        >
        > }
        }

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 30/04/2015 at 08:31, xxxxxxxx wrote:

          Actually there's also the AtomArray in our cinema4dsdk examples, which shows this in "living" code.

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 30/04/2015 at 18:14, xxxxxxxx wrote:

            Thanks for the hint. The other examples are also very interesting!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post