GeAutoDynamicArray
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/12/2012 at 08:11, xxxxxxxx wrote:
Actually if using new C4D SDK then datastructures from c4d_misc are better alternative.
BlockArray or BaseArray would be alternative for his case.I think that using gDelete or gNew is a bad idea in most cases in the main code.
They should be hidden in some data structures. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/12/2012 at 09:31, xxxxxxxx wrote:
^You're the second person I've heard say good things about the new arrays in R14.
I'm still coding for R12 & R13 so I can't use them. But I will definitely look at them if I ever get a chance to code things for R14. They sound like a nice addition to the SDK.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/12/2012 at 09:49, xxxxxxxx wrote:
c4d_misc can use some important C++11 features like move semantics and this is huge benefit.
Actually it should be possible to copy c4d_misc to R13 SDK and use it then.
The only question now is what is better to use new std or c4d_misc ?
If you need something like unordered_map then there is no alternative in c4d_misc for now. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/12/2012 at 17:08, xxxxxxxx wrote:
Thanks everyone,
I'm definately a 'noobie' at all this too Scott!! In the 3D game, programming is not my native tongue
I'm wishing to have a table built of arrays, hence why I had the for loop. I thought the resize would make another row in the table (so to speak) made of the initial array setup. I'm feeling this isn't the case.
I want an array Or something of the like) like the below:
row 1 [index 1] [index 2] [index 3] and so on for whatever amount I need (at this stage possibly 16).
Then I want to be able to add a row and fill it with the data as I go and as needed. So it could end up like the following:
row 1 [index 1] [index 2] [index 3]
row 2 [index 1] [index 2] [index 3]
row 3 [index 1] [index 2] [index 3]
row 4 [index 1] [index 2] [index 3]
And so on as needed by the plugin. I thought the ReSize was a bit like adding another row. So in my initial example, if the Array_Count = 5, then there would be 5 rows made, and hence the loop to set it up. If it changed (through user interaction) to 6, then the array should resize to 6 rows. My take on it was that the auto array kind of added another row...
I did some Googling etc but not being native at coding, it sounds like I've misunderstood what I read. How can I go about creating a table array then, or a c++ element of such that works in a table kind of fashion? It needs to be changeable, and if possible accessible by other objects.
WP. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/12/2012 at 18:51, xxxxxxxx wrote:
You don't use an array to make a table.
Tables are created by using nested loops. At least that's the common way to do it.Raw C++ EXAMPLE:
#include<iostream> using namespace std; int main () { //When the innermost loop finishes looping. The next outter loop runs...and so on... //You work from the inside loop and work your way out till the first for loop returns FALSE for(int col1=0; col1<1; col1++) { for(int col2=0; col2<1; col2++) { for(int col3=0; col3<3; col3++) //This loops three times creating three rows of data { cout<< col1 <<" "<< col2 << " " << col3 <<endl; } } } system ("pause"); // wait for user to close the output window return 0; }
An array produces a linear result. Or in other words. A row of data.
If you wanted to create a table of arrays. Then you'll need to create nested loops with an array inside of each nested for loop.
But if you just wanted to create a table of data. You don't need an array at all.-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/12/2012 at 01:37, xxxxxxxx wrote:
Originally posted by xxxxxxxx
c4d_misc can use some important C++11 features like move semantics and this is huge benefit. Actually it should be possible to copy c4d_misc to R13 SDK and use it then.The only question now is what is better to use new std or c4d_misc ?If you need something like unordered_map then there is no alternative in c4d_misc for now.
If you need an unordered map, the hashmap in c4d_misc should do the job.
Best regards,
Wilfried
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/12/2012 at 03:36, xxxxxxxx wrote:
Apparently what you need it a 3D array.
One comfortable but slow way to do this is to use array of array of array.BaseArray<BaseArray<BaseArray<Real>>>
Faster way to do this is to use 1d array and pack 3d inside.
way.BaseArray<Real>
const LONG xres = 8; const LONG yres = 8; const LONG zres = 8; BaseArray<BaseArray<BaseArray<Real>>> float_3x_array; //slow way float_3x_array.Resize(zres); for(LONG z=0; z<zres; ++z) { float_3x_array[z].Resize(yres); for(LONG y=0; y<yres; ++y) { float_3x_array[z][y].Resize(zres); for(LONG x=0; x<xres; ++x) { float_3x_array[z][y][x] = z*100.0 + y*10.0 + x; } } } BaseArray<Real> float_3d_array; //faster way float_3d_array.Resize(xres*yres*zres); //lambda function to translate 3d coordinates to 1d array coordinates. auto index3d = [&](LONG z, LONG y, LONG x) -> LONG { return ((z*yres + y)*xres) + x; }; for(LONG z=0; z<zres; ++z) { for(LONG y=0; y<yres; ++y) { for(LONG x=0; x<xres; ++x) { //float_3d_array[ ((z*yres + y)*xres) + x ] = z*100.0 + y*10.0 + x; float_3d_array[ index3d(z,y,x) ] = z*100.0 + y*10.0 + x; } } } for(LONG z=0; z<zres; ++z) { for(LONG y=0; y<yres; ++y) { for(LONG x=0; x<xres; ++x) { //if(float_3x_array[z][y][x] != float_3d_array[ ((z*yres + y)*xres) + x ] ) GePrint(" NOT OK "); if(float_3x_array[z][y][x] != float_3d_array[ index3d(z,y,x) ] ) GePrint(" NOT OK "); } } }
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/12/2012 at 03:39, xxxxxxxx wrote:
Yes I forgot about HashMap, may be because it is not in MiscTest inside.
Now the question is how to use it optimally this way?
HashMap<String,String>
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/12/2012 at 03:08, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Yes I forgot about <span style="color:#2b91af;">HashMap</span>, may be because it is not in MiscTest inside.Now the question is how to use it optimally this way?
<span style="color:#2b91af;">HashMap</span><String,String>
If you really want to use a string as key, have a look at hascode.h, which is include in c4d_misc too.
It contains an implemenation for generating keys based on C strings. Depending on the data format of the string class (e.g. UTF16) - and the speed you want/have to achieve (CRC might create very good hashes, but often CRCs are too slow) - you have to add additional methods for the key generation.
Best regards,
Wilfried
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/12/2012 at 04:27, xxxxxxxx wrote:
Yes I really need C4D String as a key.
Of course the Hash should be as fast as possible, so I use now my own modified String class witch my own Hash code for this.
Just curious why this is not included into SDK?
Are cases who String will be use as a key so rare ? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/12/2012 at 22:07, xxxxxxxx wrote:
Thanks Everyone for your contributions.
I've been busy Googling and trying to work my way around with the suggestions provided, to which I may have come up with a solution. I'm going to need to do some further experiments to see if it operates the way I had in mind - but thus far it seems to be OK...
Cheers,
WP.