HELLO,
I need to create a code which make the parallel copy of an existing shape, I use the "mdlElmdscr_copyParallel" function.
The original shape is created by the "mdlShape_create" function, it looks like this:
The result that I should get have to be like this:
But, this is what I really get:
this is an extract of the source code:
Dpoint3d *pt = NULL; MSElement elm; DVec3d direction; double distance; MSElementDescr *solideDscrP = NULL, *trouDscrP = NULL, *elmDscrP = NULL; for( i = 0; i < nbXY_Ovoide; i++ ) { pt[i].x = mdlCnv_masterUnitsToUors( XY_Ovoide[i].x ); pt[i].y = mdlCnv_masterUnitsToUors( XY_Ovoide[i].y ); } mdlShape_create( &elm, NULL, &pt[0], nbXY_Ovoide, 0 ); if( mdlElmdscr_new( &trouDscrP, NULL, &elm ) == ERROR ) return; distance = mdlModelRef_getUorPerMaster (ACTIVEMODEL) * 0.1; mdlVec_fromXY (&direction, distance , 0.0); mdlElmdscr_copyParallel ( &solideDscrP , trouDscrP, &direction, distance, NULL); if( mdlElmdscr_createShapeWithHoles( &elmDscrP, solideDscrP, trouDscrP ) != SUCCESS ) break;
Unknown said: Dpoint3d *pt = NULL; ... pt[i].x = mdlCnv_masterUnitsToUors( XY_Ovoide[i].x ); pt[i].y = mdlCnv_masterUnitsToUors( XY_Ovoide[i].y );
You have a pointer that points to address zero. When you assign data to the contents of that pointer, I don't know what happens.
I guess that you intended, but forgot, to allocate some memory for an array of points.
If you're writing C++, then take advantage of the Standard Library and in particular std::vector<DPoint3d> More information here .
Regards, Jon Summers LA Solutions
This is just an extract of code, I do note copy the hole code in my post. I have allocated already the memory:
pt = CALLOC( MAX_VERTICES, sizeof( Dpoint3d ) );I use language C.
Unknown said:pt = CALLOC( MAX_VERTICES, sizeof( Dpoint3d ) );
Why use dynamic allocation when the array is a fixed size? In other words;
DPoint3d vertices [MAX_VERTICES];
Unknown said:mdlElmdscr_copyParallel ( &solideDscrP... )
UInt32 filePos = mdlElmdscr_add (solideDscrP); if (0 != filePos) { /* ... */ }
What happens if you add the copy to your DGN model, before attempting the group hole operation?
Unknown said:mdlElmdscr_copyParallel ( &solideDscrP , trouDscrP, &direction, distance, NULL); if( mdlElmdscr_createShapeWithHoles( &elmDscrP, solideDscrP, trouDscrP ) != SUCCESS )
You perform two distinct operations: copy parallel then create group hole.
You check the second operation but not the first: you don't know whether copy parallel succeeded or not before you create group hole. I suggest that you test for SUCCESS and add the copied element to your model. We don't know which has failed.
Remove the group hole operation temporarily: it's unrelated to your original question.