Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Fast access dynamic list [SOLVED]

    SDK Help
    0
    20
    1.4k
    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 02/09/2014 at 05:28, xxxxxxxx wrote:

      Yes, BaseArrays are dynamic. Very similar interface to std::vector, but conforms the Maxon naming
      conventions and does not use C++ exceptions, unlike the std libraries.

      @WickedP: You do not necessarily need to use resize(), you can just use std::vector::push_back()
      if you don't know the number of elements already. If you think you know how many elements you
      need at least, you can use std::vector::reserve() to suggest an initial capacity of the vector, it's size
      will still be 0 after calling it though.

      The BaseArray class has the same functions, Resize() and EnsureCapacity().

      Simple example for triangulating a Polygon object.

      Int32 polygonCount = op->GetPolygonCount();
      const CPolygon* polygons = op->GetPolygonR();
        
      maxon::BaseArray<CPolygon> triangles;
      triangles.EnsureCapacity(polygonCount);
        
      for (Int32 index=0; index < polygonCount; ++index)
      {
          const CPolygon& poly = polygons[index];
          triangles.Append(CPolygon(poly.a, poly.b, poly.c));
          if (poly.c != poly.d)
              triangles.Append(CPolygon(poly.c, poly.d, poly.a));
      }
      

      Best,
      -Niklas

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

        On 02/09/2014 at 06:09, xxxxxxxx wrote:

        Howdy,

        Originally posted by xxxxxxxx

        ...Maxon does not suggest using the std library...

        I've heard that many times, but what is the reason for not using std library?

        Adios,
        Cactus Dan

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

          On 02/09/2014 at 07:21, xxxxxxxx wrote:

          In your example, Niklas, you used triangles.EnsureCapacity(polygonCount);
          But I really don't know in advance how many elements I will be storing.
          Can I simply Append items to the end and the array will grow?

          Is it really faster that using BaseContainers? Because as it is now, it is working fast (but not very, very fast when dealing with hundreds of thousands of values, or more).

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

            On 02/09/2014 at 13:55, xxxxxxxx wrote:

            @Rui
            Arrays can use either a known size value. Or not use a known size value.
            This is in R13 code. But I'm guessing the R14++ BaseArrays have the same option.

                LONG arrsize = 3;  
              GeDynamicArray<LONG>myarray(arrsize);  //With known array size  
              
              GeDynamicArray<LONG>myarray;           //Without known array size
            

            @Dan
            I asked the same question a long time ago and one of the devs said that the reason the std library is not supported is due to the debugging.
            I don't remember his exact words. But it was something along the lines of the debugging errors are not always compatible or reliable in relation to the C4D SDK. So they can't be held responsible for it, or support it.
            And I think he also mentioned possible problems when using things like try & catch too.

            I use it as well as Boost and Win32 stuff all of the time. And never have any problems.
            But I also know that when I do that I'm on my own. And Maxon can't offer any help if I have a problem.

            -ScottA

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

              On 03/09/2014 at 01:43, xxxxxxxx wrote:

              The GeDynamicArray class is extremely inefficient and very slow, I do not recommend to use it.
              @Rui: Yes, EnsureCapacity() is just a hint to the array, but you can leave it out as well.
              @Dan: What Scott said is right, but I don't remember either what exactly I was told about it. 
              You could get problems using the std library and not enabling exception handling. And in the end,
              I just think they don't want to support it because that would mean additional work.

              Best,
              -Niklas

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

                On 03/09/2014 at 07:15, xxxxxxxx wrote:

                I'm still using R13 Niklas. So I can't use the new BaseArray stuff. That's why I'm still not very familiar with them.
                If I need speedy arrays for something. I have to go off the support grid and use a vector array.

                I've been told there's a hack to make BaseArrays in R13. But I could never get it to work.

                -ScottA

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

                  On 03/09/2014 at 16:24, xxxxxxxx wrote:

                  Howdy,

                  Originally posted by xxxxxxxx

                  ...You could get problems using the std library and not enabling exception handling...

                  Ah, OK I see. Yes, I got that warning in Visual Studio, and enabling exception handling did get rid of that.

                  Adios,
                  Cactus Dan

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

                    On 07/09/2014 at 09:38, xxxxxxxx wrote:

                    I am completely relying on the STL and Effex runs as stable as it can get. 🙂 I am only using C4D structures when I directly modify C4D data.

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

                      On 07/09/2014 at 10:45, xxxxxxxx wrote:

                      Well, it's the official Maxon side. I never experienced anything bad that I could pinpoint on using
                      the standard library, either. 🙂

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

                        On 07/09/2014 at 11:07, xxxxxxxx wrote:

                        Yep, I think it is as you said, posing an additional support criteria. Well, it's understandable I guess 🙂

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