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

    BaseSort member variable?

    SDK Help
    0
    4
    399
    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 14/07/2016 at 12:06, xxxxxxxx wrote:

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

      ---------
      Hi,

      I'm looking for a way to implement a variable sorting crtiteria in my BaseSort class, but I'm not getting it to work. I just want to sort an array with vectors using a tolerance value (eps) :

        
      class SortVector : public maxon::BaseSort <SortVector>   
      {   
      public:   
           static Bool LessThan(Vector a, Vector b)   
           {   
                if (a.z < b.z - eps) return true;   
                if (a.z > b.z + eps) return false;   
                return (a.x < b.x);   
           }   
           SortVector(Float d)   
           {   
                eps = d;   
           }   
      public:   
           static Float eps;   
      };   
        
      //---------------------------------   
        
      maxon::BaseArray<Vector> points;   
      //... filling the array ...   
      SortVector sort(10);   
      sort.Sort(points);                  
      

      I want to start the sorting using the tolerance value, but the compiler gives me an unsolved symbol "eps" error because of the static declaration. But I can't omit static, because LessThan wouldn't know "eps". And finally I can't omit static for LessThan().

      It happens frequently, that I need additional variable parameters for sorting. How is the provided way to do this?

      Thanks of any help.

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

        On 14/07/2016 at 17:08, xxxxxxxx wrote:

        Did you forget to add the definition of SortVector::eps also in your actual code? Something like this in a
        translation unit (.cpp file).

        Float SortVector::eps = 1.0e-7;  // just an example value
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 15/07/2016 at 01:45, xxxxxxxx wrote:

          You only have the declaration of the static member but you also need to give it a definition (i.e. what Niklas provided) to actually make it exist.
          
          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 15/07/2016 at 03:21, xxxxxxxx wrote:

            Thanks. Have to read a chapter about static stuff I guess.

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