STEPCAFControl_Reader and Progress Indication

Is there a way to receive progress information during the ReadFile and/or Transfer routine in STEPCAFControl_Reader?

Thanks,

Dennis

Roman Lygin's picture

Hi Dennis,

If you mean a progress indicator, the following should work:
STEPCAFControl_Reader aReader = ...;
Handle(Message_ProgressIndicator) aProgressIndicator = aReader.Reader().WS()->MapReader()->GetProgress();

Hope this helps.
Roman

Dirk B's picture

Hello Roman and Dennis!
I think one should rather derive from Message_ProgressIndicator and call aReader.Reader().WS()->MapReader()->SetProgress(...) on a variable of the derived class. There is an example for this in the function stepread in XSDRAWSTEP.cxx. I have tried to implement my own progress indicator, but it doesn't work. Has anybody made some experience with this?

Thanks,

Dirk

Roman Lygin's picture

Hi Dirk,

Yes, you first have to derive your own class from abstract Message_ProgressIndicator and set it into the translator objects. The code I used above is how to *retrieve* it assuming that it was set somewhere else before.

I successfully implemented my own indicator in the past (e.g. to show Windows progress bar inside the window status bar). OCC ships with an example you mentioned in XSDRAWSTEP.cxx. It is Draw_ProgressIndicator which is descendant implementation using Tcl widgets and output stream to report progress. There is a bug however in Open CASCADE 6.3.0 - the command to set/change this indicator in DRAW has not been added. Up to 6.2.1 progress indicator lived as XSDRAW_ProgressIndicator and there was a command XProgress. In 6.3.0 the indicator moved into lower Draw package, but XProgress equivalent did not get migrated.

What are your particular problem with your own progress indicator ?

Dirk B's picture

Hi Roman!
Here's my code:

//##header##:
#ifndef MYPROGRESSINDICATOR_H
#define MYPROGRESSINDICATOR_H

# include
# include
# include

DEFINE_STANDARD_HANDLE (MyProgressIndicator, Message_ProgressIndicator)
class MyProgressIndicator : public Message_ProgressIndicator
{
public:
MyProgressIndicator();
virtual Standard_Boolean Show( const Standard_Boolean force );
DEFINE_STANDARD_RTTI (MyProgressIndicator)
};
#endif

//##implementation##:
#include "stdafx.h"
#include "myprogressindicator.h"

IMPLEMENT_STANDARD_HANDLE (MyProgressIndicator, Message_ProgressIndicator)
IMPLEMENT_STANDARD_RTTI (MyProgressIndicator, Message_ProgressIndicator)

IMPLEMENT_STANDARD_TYPE (MyProgressIndicator)
IMPLEMENT_STANDARD_SUPERTYPE (Message_ProgressIndicator)
IMPLEMENT_STANDARD_SUPERTYPE (MMgt_TShared)
IMPLEMENT_STANDARD_SUPERTYPE (Standard_Transient)
IMPLEMENT_STANDARD_SUPERTYPE_ARRAY ()
IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY (Message_ProgressIndicator)
IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY (MMgt_TShared)
IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY (Standard_Transient)
IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_END ()
IMPLEMENT_STANDARD_TYPE_END (MyProgressIndicator)

MyProgressIndicator::MyProgressIndicator() :
Message_ProgressIndicator()
{
}

Standard_Boolean MyProgressIndicator::Show( const Standard_Boolean force )
{
OutputDebugString( "MyProgressIndicator::Show was called\n" );
return true;
}

I then used

STEPCAFControl_Reader reader;
Handle(MyProgressIndicator) aPI = new MyProgressIndicator();
reader.Reader().WS()->MapReader()->SetProgress( aPI );

to install my indicator. Now I expected that the Show method is called when the indicator made some progress, but it never is called. What am I doing wrong?

Thanks,

Dirk

Roman Lygin's picture

Hi Dirk,

Very quick comments - did not try the code below. I encourage you to look at XSDRAWSTEP.cxx to understand how the indicator is used.

1. You first need to set its scale (range)
aPI->SetScale (1, 100, 1);
2. Looking at STEPCAFControl_Reader.cxx I think OCC team did not (yet?) introduce the progress indicator into it, so your indicator will not be fully smoothly growing, and you will have to advance some phases manually, for instance:
aPI->NewScope(20, "Loading");
aPI->Show();
reader.ReadFile ("myfile.stp");
aPI->EndScope();
aPI->NewScope(80, "Translation");
aPI->Show();
reader.Transfer (aDoc);
aPI->EndScope();

3. by the way, you can declare a handle simpler than yo do. Use IMPLEMENT_STANDARD_RTTIEXT instead of IMPLEMENT_STANDARD_RTTI, and omit all IMPLEMENT_STANDARD_TYPE and IMPLEMENT_STANDARD_SUPERTYPE macro. That will do all the work.

Hope this helps.
Roman

Dirk B's picture

Roman, thanks for the quick reply, especially 3.! I tried your code and MyProgressIndicator::Show gets called 3 times, as expected. Too bad the indicator doesn't get updated from within STEPCAFControl_Reader.

Regards,

Dirk

Cauchy Ding's picture

Hi Dirk,

I modified the OCC iges and step I/O source, and add a Callback function into the class. I think OCC should provide this Callback Function when it's born, but what a pity it doesn't. The same thing happened in the faces sewing API.

-Ding

Roman Lygin's picture

Please also see my recent post on the blog. Part 3 (http://opencascade.blogspot.com/2009/01/how-do-you-measure-your-progress...) contains an example for IGES. STEP should be similar.

---
opencascade.blogspot.com - blog on Open CASCADE