How to modify Vertices in LineString (3D) with MDL

Hi everyone,

I am trying to write an MDL for Microstation V8i (Select Series 4) which should transform the heights according to a certain height-modelling for different element-types.

I am using a Loop over all graphical Elements with a callback-function, which first creates an Duplicate of the MSElementDscr-Object

mdlElmdscr_duplicate(&newedP, edP);

first and afterwards calls the specific Transformation-function according to the element-type.

It works already for some Elements, like e.g. for Line_3d-Elements:

Private int HoehTrans_htransLine
(
    MSElementDescr	**edPP		// <=> Zeiger auf MSElementDescr-Objekt
)
  {
    int test1=FALSE, test2=FALSE;
    
    // Height-Transformation
    test1=test_transHPoint(&(*edPP)->el.line_3d.start);
    test2=test_transHPoint(&(*edPP)->el.line_3d.end);

    if(test1==TRUE && test2==TRUE) return TRUE;
    else return FALSE;
  }

The same thing should be done for Line_String_3d-Elements as well with the following Code:

Private int HoehTrans_htransLineString
(
    MSElementDescr	**edPP		// <=> Zeiger auf MSElementDescr-Objekt
)
  {
    int test=FALSE i;
    int pnum;
    DPoint3d** pList;

    // Speicher fuer Punktliste allokieren
    pnum=(*edPP)->el.line_string_3d.numverts;
    pList= (DPoint3d**) calloc(pnum, sizeof(DPoint3d*));
    for(i=0; i<pnum; i++) pList[i]= (DPoint3d*) calloc(1, sizeof(DPoint3d));

    // Hoehen-Transformation
    test=HoehTrans_transHList(&(*edPP)->el.line_string_3d.vertice, pnum);
    
    if(test==TRUE) return TRUE;
    else return FALSE;
  }

The connected height-transformation test-function Looks like this:

Private int test_transHList
(
    DPoint3d** pointPL,			//<=> IN/OUT: zu transformierende DPunkt3d-Liste
    int pnum					// => IN: Anzahl der Punkte in Liste
)
  {
    double dh=150.0;
    int ret=FALSE, i;
    
    if(pointPL!=NULL)
    {
        for(i=0; i<pnum; i++) pointPL[i]->z+=dh;
        ret=TRUE;
    }
    return ret;
  }

My Problem is now, that I get an Compiler-error  in the function "HoehTrans_htransLineString" for the Line

-    test=HoehTrans_transHList(&(*edPP)->el.line_string_3d.vertice, pnum);

that says:

"conversion of Parameter 1 from  'DPoint3d (*)[1]' in 'DPoint3d **' not possible"

Because the number of Vertices in the Element is not only "ONE", why  is the '(&(*edPP)->el.line_string_3d.vertice'-Parameter of the LineString-Element not  a field-pointer 'DPoint3d**' ??

Did I understand something wrong, or is it just a simple error in the Code?

In case of the Line-Element I rewrite finally in the callback-function the changed MSElementDscr-Object to file using and would like to do that with the LineString in the same way:

mdlElmdscr_rewrite(newedP, NULL, filePos);

Many thanks in advance for your help!

Best regards,

Ines Wieland

  • Is there any side-effect when using the function mdlElmdscr_transform()for the current transformation? Or is there any effect on the whole complex element by this function?

    mdlElmdscr_transform follows h.next pointers. When modifying individual entries in an element descriptor chain, or components of a complex element you would typically want to use mdlElmdscr_duplicateSingle before calling mdlElmdscr_transform to isolate the component. You then use mdlElmdscr_replace to update the original.



    Answer Verified By: Ines Wieland 

  • Many thanks Brien, that solves the displacement-problem!

    I changed the mdHoehTrans_htransComplex-function in the following way and it works now:

    Private int HoehTrans_htransComplex
    (
        MSElementDescr	**edPP		// <=> Zeiger auf MSElementDescr-Objekt
    )
      {
        MSElementDescr *pComponent = (*edPP)->h.firstElem;
        MSElementDescr *pPartial;
        int elType = mdlElement_getType(&(*edPP)->el);
        int test = -1;
        
        if(elType != CMPLX_STRING_ELM  && elType != CMPLX_SHAPE_ELM) return -1;
        
        // Loop over all components
        while(pComponent)
        {
    	   elType = mdlElement_getType(&pComponent->el);
           // Duplicate the Component for element-changes
    	   if(mdlElmdscr_duplicateSingle(&pPartial, pComponent) != SUCCESS) return retErr;
    	   
    	   // call transformation-function according to element-type
    	   switch(elType)
    	   {
    		case LINE_ELM:				//case 3
    			test=HoehTrans_htransLine(&pPartial);
    			break;
    		case LINE_STRING_ELM:		//case 4
    		case SHAPE_ELM:			//case 6
    			test=HoehTrans_htransLineString(&pPartial);
    			break;
    		case CMPLX_STRING_ELM:		//case 12
    		case CMPLX_SHAPE_ELM:		//case 14
    			test=HoehTrans_htransComplex(&pPartial);
    			break;
    		case ARC_ELM:				//case 15
    			test=HoehTrans_htransEllipse(&pPartial);
    			break;
    		default:					// other cases
    			return -1;
    			break;
    		}	// Ende SWITCH-Block
    		if(test != SUCCESS) return -1;
            
            // replace changed Element-Descriptor
    		mdlElmdscr_replaceDscr(&pComponent, pPartial);
    		
    		// go to next Element
    		pComponent = pComponent->h.next;
    	}
        // Validation to update boundary-box etc.
        mdlElmdscr_validate((*edPP), mdlModelRef_getActive());
    
        return SUCCESS;
      }
    

    Many thanks and best regards to all commentators

    Ines Wieland