Re: Displaying transient elements

MicroStation V8i

This is where you can find and contribute to discussions, ideas, and other information about MicroStation V8i.

Displaying transient elements

  • rated by 0 members
  • This post has 23 Replies |
  • 1 Follower
  • We have successfully implemented a workaround using  Brien Bastings advice here. The problem is with the final “TRUE” in the following code:

    mdlTransient_addElemDescr(NULL, pdb_complexDP, FALSE, 0x00ff,  NORMALDRAW, FALSE, FALSE, TRUE);

    When changing this to “False” the speed is increased substantially (almost instantaneous). The problem is that now the views now need to be manually “Refreshed” for the new graphics to be displayed. We would consider this a bug as previous versions were able to use the “TRUE” value and not have issues with the slow graphics. I would respectfully request that the “TRUE” setting in XM and above implement the same solution as our workaround without the need for programming the manual refresh of the views.

  • Jon Summers:
    The best thing about the MicroStationAPI is that it's C++ and not C#.

    Right, but sometimes it could be nice to have MDL + MicroStation API ported to .NET... Sometimes I'm just bored by wrapping MDL to .NET...

    Dan

  • Change is Progress?

    The antithesis of Bentley's approach is Microsoft's, where constant change introduces not just new APIs, but APIs that are replaced with something new before anyone has time to fully comprehend them.

    Who, for example, adopted the curious syntactic confetti introduced with C++ Visual Studio 2003? Microsoft themselves decided it was a step too far and dropped it with Viz Studio 2005. A technology with a lifetime of two years looks poor compared to Bentley's longevity.

    The best thing about the MicroStationAPI is that it's C++ and not C#. C++ is a standard, and we can use Microsoft's C++ compiler to compile standard code that is not subject to Microsoft marketing whims. Use the C++ Standard Library and Boost to enable productive code composition that remains standards-compliant.

    Michael Stark: I don't think, that anyone of us was aware of the transient API

    The first usage I can find of the mdlTransient_api in our code is dated 1996. It was used to add a non-persistent plot border to the V7 version of Plot Composer.

    Regards, Jon Summers
    LA Solutions

  • I don't think, that anyone of us was aware of the transient API before XM. At least for myself, I really thought it was introduced for the change to DirectX. No idea that it is that old :)

    It is always good to get such information, and we are glad about the insights. Even if we sound sometimes, as if we don't want to introduce new concepts, it's more questioning the things behind, and always keeping in mind that most of us are payed by someone else :)

    Michael

  • MichaelStark:
    As much as we love the ongoing enhancements to the MicroStation API, there are 2 problems (and from there I agree with Dan).

    > 1. Version support: Roy can not use the IViewTransient API in a version prior to V8i

    Ok...but then you can never take advantage of any new features either...

    > 2. Even those who are willing to learn and change, need to declare, why they are changing running code

    A big problem with writing applications for MicroStation is that we rarely get rid of obsolete/increasingly incorrect apis. There will be 5 ways to do anything 4 of which will be wrong (sometimes all 5 are wrong!). I have a lot of sympathy for you guys...it's very difficult to know what is right and what is not. Yes, it's always a little painful porting to the new version...that's just the nature of programming, apis change as new features are added and a product evolves. At the end of the day everyone would be better off if the wrong ways of doing things were no longer available.

    Since the mdlTransient  api was introduced about 19 years ago we've changed both the file format and display system (not to mention countless operating systems)...and we jumped through hoops in an attempt to preserve the published functions. The reality is that the new display system (which is a huge improvement over the old one) just doesn't work the same way...so the old approach using the mdlTransient_ api isn't the best/most efficient way to get geometry on the screen...how long should we keep it around? As long as it's available new code will be written that uses it...which is unfortunate when there's a better approach. A some point it just won't be possible to preserve a C api that goes back to the IGDS days and lots of stuff will need to be removed/deprecated.

    * It's pretty ridiculous given the rate at which computers/software changes that you can still use a MicroStation api written 19 years ago...

    -B

     

  • Brien,

    As much as we love the ongoing enhancements to the MicroStation API, there are 2 problems (and from there I agree with Dan).

    1. Version support: Roy can not use the IViewTransient API in a version prior to V8i

    2. Time: Even those who are willing to learn and change, need to declare, why they are changing running code (i.e. for my 3D work transients didn't get any timing problem 'til now).

    If there's a need to support a specific version, my boss is up to decide if we take the time :)

    Roy,

    you should really use mdlElmdscr_initOrAddToChainWithTail it speeds up collecting elements, the more you have, the more the time it saves (prevents Ustn from searching the end of the chain for each new append).

    Michael

  • Brien Bastings:
    it will be a happy day when I can open the source file for the mdlTransient_ functions and hold down the delete key! :)

    Something is telling me that this day will be not as happy for third party programmers which are using it a lot in their applications... There are many C programmers loving old school waterfall programming Crying

  • Roy Gallier:

    Jon Summers:
    The MicroStationAPI lets you get much closer to MicroStation's core when you want to display something transient. It makes the mdlTransient_api obsolescent.

    Mark Anderson,

    Is the above statment the whole truth? Could you give reasons WHY mdlTransient_addElemDescr slower in V8i than in V8 2004?

    -Roy

    mdlTransient_addElemDescr(NULL, pdb_complexDP, FALSE, 0x00ff,  NORMALDRAW, FALSE, FALSE, TRUE);

    It's hideously inefficient to incurr all the element overhead when you just want to display geometry to the view, that's why creating an IViewTransient is so much better than creating elements...so yes, the mdlTransient_ api is indeed obsolete.

    Now, the reason mdlTransient_addElemDescr is faster for the pre-D3D MicroStation versions is that you did not incurr a lot of per-element overhead to display a single element. That last argument to mdlTransient_addElemDescr is the problem...we have to do a whole lot more work to get each element to appear as you create it since you've requested that it be displayed immediately. The "new" display system is fast for drawing lots of elements at once...not starting/stopping to display them 1 at a time.

    Dan's suggestion was to make a single call to mdlTransient_addElemDescr with a chain of element descriptors (created using mdlElmdscr_initOrAddToChainWithTail...not mdlElmdscr_appendDescr, i.e. you're not creating a complex element)...then for the initial display we'd draw a lot of elements in 1 go walking the edP->h.next pointers.

    I would encourge you to take a look at the IViewTransient api...it will be a happy day when I can open the source file for the mdlTransient_ functions and hold down the delete key! :)

    HTH

    -B

  • Jon Summers:
    The MicroStationAPI lets you get much closer to MicroStation's core when you want to display something transient. It makes the mdlTransient_api obsolescent.

    Mark Anderson,

    Is the above statment the whole truth? Could you give reasons WHY mdlTransient_addElemDescr slower in V8i than in V8 2004?

    -Roy

  • MicroStationAPI & Transients

    Roy, there was a conversation about this topic earlier this year. The recommendation from Bentley is to use the MicroStationAPI for transient display with V8i and later.

    The MicroStationAPI lets you get much closer to MicroStation's core when you want to display something transient. It makes the mdlTransient_api obsolescent.

    View Transients

    To make a long response short, the easiest way would be to look at this MicroStationAPI C++ Project about View Transients.

    Regards, Jon Summers
    LA Solutions

  • These are not chainable elements and need to remain separate elements.

  • Display speed of 246,248 lines

    08.05.02.70  =  13 sec.
    08.11.07.171 = 202 sec. (diff. workstation same spec.)
    08.11.07.405 = 209 sec.
    08.11.07.443 = 209 sec.

  • You should use chain to group elements and then add this chain to transient...

  • Has this issue been resolved? We are having the same issue displaying a large number of elements with the following code:

    MSElementDescr  *pdb_complexDP;

    mdlTransient_addElemDescr(NULL, pdb_complexDP, FALSE, 0x00ff,  NORMALDRAW, FALSE, FALSE, TRUE);

  • Ray,

     If you are trying to display 50k+ points you may want to look at the IViewTransient stuff in the MicroStation API.  It can handle the large point clouds that it looks like you are headed towards.

    HTH,

    mark anderson [Bentley]

  • Ray

    if you do the add and the free directly after another, how should it display anything ? Take a look at the code from Mark. The transient is a global var, where the created mesh (from a number of points) is either added or replaced with each callback (time after time). But the transient  is only freed when the program is unloaded. That's one of the possibilities, the other might be a cleanup function if you are in a primitive command (set with mdlSystem_setFunction(STATE_COMMAND_CLEANUP...)) and need the transient only for this command (asures free, even if your command is broken).

    HTH MIchael

    BTW what is the mdlElmdscr_new good for ? You still have an Elementdescr ! if you add the original you must not free it, if you need a copy use the mdlElmdsr_duplicate(Single) for that !

  • No, still does it.  Actually it is not locking up, but because the number of points (50,000 +), it appears to lock up.  I tried it on a small dataset and it does finish, but still doesn't hilite the elements at the end.

    Ray

  • Ray:
    It stll locks up when I do
    
    msTransientElmP = mdlTransient_addElemDescr(NULL, myTransientDescrP, FALSE,0x00FF, HILITE, FALSE, FALSE, TRUE);
    

    Try this:

    
    msTransientElmP = mdlTransient_addElemDescr( msTransientElmP, myTransientDescrP, FALSE,0x00FF, HILITE, FALSE, FALSE, TRUE);
    

    Regards, Jon Summers
    LA Solutions

  • Jon,

    That was the problem with it being slow, however it stll locks up when I do

     msTransientElmP = mdlTransient_addElemDescr(NULL, myTransientDescrP, FALSE,0x00FF, HILITE, FALSE, FALSE, TRUE);

    Ray

  • Ray:
    The loop takes forever ...
    
    MSElementDescr *myTransientDescrP=NULL; 
    process element {
    MSElementDescr *tempEdP = NULL, *tailEdP = NULL;
    mdlElmdscr_new (&tempEdP, NULL, &elmDescP->el); 
    mdlElmdscr_initOrAddToChainWithTail (&myTransientDescrP, &tailEdP, tempEdP); 
    } 
    
    

    It's not clear from that pseudocode what is in the loop. If you're initialising tailEdP to NULL each iteration, that could explain why the loop is slow. Try this:

    
    MSElementDescr* myTransientDescrP = NULL; 
    MSElementDescr* tailEdP = NULL; 
    process element {
        MSElementDescr* tempEdP = NULL;
        mdlElmdscr_new (&tempEdP, NULL, &elmDescP->el); 
        mdlElmdscr_initOrAddToChainWithTail (&myTransientDescrP, &tailEdP, tempEdP); 
    } 
    
    

    Regards, Jon Summers
    LA Solutions

  • Michael,

    I would rather use the collect element method and just call mdlTransient_addElemDescr once at the end because the number of element involved.  So here is what I tried:

    MSElementDescr *myTransientDescrP=NULL;

    process element {
    MSElementDescr *tempEdP = NULL, *tailEdP = NULL;
    mdlElmdscr_new (&tempEdP, NULL, &elmDescP->el);
    mdlElmdscr_initOrAddToChainWithTail (&myTransientDescrP, &tailEdP, tempEdP); 
    }

    // display after done

    if(myTransientDescrP!=NULL) {
    msTransientElmP = mdlTransient_addElemDescr(NULL, myTransientDescrP, FALSE,0x00FF, HILITE, FALSE, FALSE, TRUE);
    mdlTransient_free (&msTransientElmP, FALSE);
    mdlElmdscr_freeAll (&myTransientDescrP);
    }

    But the loop takes forever and when I get to display it seems to lock up doing the mdlTransient_addElemDescr.  If I set the intitial display to FALSE then it completes but displays nothing.

    Ray

  • romanboysurface.zip

    I have attached my favorite example that builds transient elements and displays them.  Take a look at the animate command in here.

    Enjoy,

    Mark Anderson [Bentley]

  • This is confusing me

    You have to hold the transient Descriptor that is returned from mdlTransient_add..., but you're just using a local var that is destroyed as soon as your leaving the function. Not only that you never will see anything, you create a memory leak. 

    Instead of giving the edpp to the function, return teh result from mdlTransient_addElemDescr and use mdlTransient_addElement with the element you want.

    Normally the whole thing might be in a loop

    TransDescrP myTrans = NULL;
    while (elmDescP) { // your loop from above
       myTrans = mdlTransient_addElemDescr(myTrans, elmDescP, FALSE,0x00FF, HILITE, FALSE, FALSE, TRUE);
       // use inital display !

    don't forget to clear the transient at your cleanup function or whenyou leave the program.

    HTH Michael

    Edit: if you like to collect the elements, use mdlElmdscr_initOrAddToChain in the loop  and do only one call to mdlTransient_addElemDescr() after the loop.

  • I have been following some threads on creating and displaying transient elments.  I am trying the method of adding descriptors to a chain and then add chain to transient descriptor as follows:

    MSElementDescr *myTransientDescrP=NULL;

    // loop thru elements{
    putInTransient(&myTransientDescrP,&elmDescP->el);
    }

    // display transient after all elements are put in transient, not sure if this is right because nothing displays
    mdlTransient_displaySingleInViews(msTransientElmP,myTransientDescrP,HILITE);

     

    Private void putInTransient

    (

    MSElementDescr **edPP,

    MSElement *elP

    )

    {

    MSElementDescr *tempEdP = NULL, *tailEdP = NULL;

    mdlElmdscr_new (&tempEdP, NULL, elP);

    mdlElmdscr_initOrAddToChainWithTail (edPP, &tailEdP, tempEdP); // Assumes *edPP was initialized to NULL...

    if(msTransientElmP == NULL)

    msTransientElmP=mdlTransient_addElemDescr(NULL,*edPP,0,0x00ff, HILITE,FALSE,FALSE,FALSE);

    else

    msTransientElmP=mdlTransient_addElemDescr(msTransientElmP,*edPP,0,0x00ff, HILITE,FALSE,FALSE,FALSE);

    mdlElmdscr_freeAll (edPP);

    }

     

    My problem is I can't get anything to display at the end.

    Ray

Page 1 of 1 (24 items)