11-05-2007 04:31 AM
typedef
struct {long dimSizes[3];
unsigned char Numeric[1];
} TD2;
typedef
TD2 **TD2Hdl;A classification model created by using
static
BOOL bCreateClassification3DModel(){
hClassification3DModel_g = (TD2**)DSNewHandle(
sizeof(TD2) + (sizeof(BYTE) * ((lSizeA_g * lSizeB_g * lSizeC_g) - 1))); if (hClassification3DModel_g == NULL) return FALSE;(*hClassification3DModel_g)->dimSizes[0] = lSizeA_g;
(*hClassification3DModel_g)->dimSizes[1] = lSizeB_g;
(*hClassification3DModel_g)->dimSizes[2] = lSizeB_g;
return TRUE;}
Now i want to write to the model. How do I set values into this model?
Is (*hClassification3DModel_g)->Numeric = 4; the rigth way to go?
11-06-2007 12:38 AM
11-06-2007 05:30 AM
Kresh wrote:
Hello everyone.I´m kinda new to the world of LabView.I´m using a LabView program to create a 3d classification model. The main program is written in Visual C++ (native)I got this structtypedef
struct {long dimSizes[3];
unsigned char Numeric[1];
} TD2;
typedef
TD2 **TD2Hdl;A classification model created by using
static
BOOL bCreateClassification3DModel(){
hClassification3DModel_g = (TD2**)DSNewHandle(
sizeof(TD2) + (sizeof(BYTE) * ((lSizeA_g * lSizeB_g * lSizeC_g) - 1))); if (hClassification3DModel_g == NULL) return FALSE;(*hClassification3DModel_g)->dimSizes[0] = lSizeA_g;
(*hClassification3DModel_g)->dimSizes[1] = lSizeB_g;
(*hClassification3DModel_g)->dimSizes[2] = lSizeB_g;
return TRUE;}
Now i want to write to the model. How do I set values into this model?
Is (*hClassification3DModel_g)->Numeric = 4; the rigth way to go?
11-06-2007 05:39 AM
Thanks.
I´m new at this company and I´ve got this project from the guy developing before me. So I´m stuck since its already in production, but lets see if we can get some changes into the code.
11-06-2007 05:55 AM
for
(k = 0; k < lSizeC_g; k++){
11-06-2007 06:37 AM
Would seem quite right to me. Could be optimized with pointer auto increment depending on the dimension order you have. Also there is always a good chance that you have to fiddle with the order of the dimensions anyhow (what size of the three sizes does correspond with i, j, k, and how you want them in LabVIEW. But that is something I never can wrap my head around and always end up with trieal and error.
Kresh wrote:
So if I want to iterate over the entire structure. Is this somewhat the right way to do it.for
(k = 0; k < lSizeC_g; k++){
for (i = 0; i < lSizeA_g; i++){
for (j = 0; j < lSizeB_g; j++) {
(*hClassification3DModel_g)->Numeric[i + lSizeA_g * j + (lSizeA_g + lSizeB_g) * k] = 4;
}}}
11-06-2007 06:48 AM
hmmm shouldnt it be
(*hClassification3DModel_g)->Numeric[i + lSizeA_g * j + (lSizeA_g + lSizeB_g) * k] = 4;
changed to
(*hClassification3DModel_g)->Numeric[j + (lSizeA_g * i) + ((lSizeA_g * lSizeB_g) * k)] = 4;
And due to the numeric beeing a unsigned char, do I need to typecast the values?
I´m doing a learning by burning but all help whould be awsome.
11-06-2007 07:02 AM
Kresh wrote:
hmmm shouldnt it be
(*hClassification3DModel_g)->Numeric[i + lSizeA_g * j + (lSizeA_g + lSizeB_g) * k] = 4;
changed to
(*hClassification3DModel_g)->Numeric[j + (lSizeA_g * i) + ((lSizeA_g * lSizeB_g) * k)] = 4;
And due to the numeric beeing a unsigned char, do I need to typecast the values?
I´m doing a learning by burning but all help whould be awsome.
11-06-2007 08:10 AM
ok, it seems to work.
The reason I asked about the i, j, k was cuz I´ve got this line that reads from the struct
data = pMtrxA + ((
sizeof(unsigned char) * lSizeA_g * lSizeB_g * k) + (i * sizeof(unsigned char) * lSizeB_g) + (sizeof(unsigned char) *j));So I thought I´d map the i,j,k to resp. lSize in my writing to the struct.
Thanks for all the help with this.
I cant in all the world figure out why the guy choose to do 3d-modeling in LabView. But I just have to put up a smile and work with what i got.