For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Defining a class inherited from TDocStd_Application

Steve Howgill's picture
Forums: 

I have defined a class from TDocStd_Application, (Using SampleOcaf as a guide). When I create an instance of this class in the constructor of my MFC application, my code crashes. The problem seems to be in the constructor of my derived OCAF application class, but the constructor contains no code. Could there be a compiler switch set incorrectly?
HELP!!!!!!!!!!!!!!!!!!!!!!!

Serge's picture

Hi Steve,

Check that all required variables like CSF_PluginDefaults, CSF_"app_name"Defaults, CSF_UnitsLexicon, CSF_UnitsDefinition are set.

Steve Howgill's picture

Serge

Thanks.
Presumably you mean checking that the variables are set as environment
variables in Settings/Control Panel/System/Environment. Everything
seems okay, but I am not sure what you mean by
CSF_"app_name"Defaults.

Kind Regards

Steve Howgill

Serge's picture

Hi,

I mean the variable that corresponds to the application resource file that is refered by method ResourcesName() in your application class.
Ex.
if ResourcesName returns SampleOCAF then
the variable name has to be:
CSF_SampleOCAFDefaults. By default it's named
CSF_StandardDefaults.

Regards,
Serge

Steve Howgill's picture

Serge,
I am setting the variables as listed below, but still can not get the app to run.
ResourcesName() returns "Resources"

try
{ myGraphicDevice = new Graphic3d_WNTGraphicDevice(); }
catch (Standard_Failure)
{
AfxMessageBox("Fatal Error in graphic initialisation");
}

char szDirectory [256] ;

_getcwd (szDirectory,sizeof szDirectory);
if (szDirectory[strlen(szDirectory)-1] != '\\') {
strcat(szDirectory,"\\");
}

SetEnvironmentVariable ( "CSF_ResourcesDefaults",szDirectory);

SetEnvironmentVariable ( "CSF_PluginDefaults",szDirectory);

myApp = new TLeo_Application();

// Set the local system units
try
{ UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); }
catch (Standard_Failure)
{
AfxMessageBox("Fatal Error in units initialisation");
}

Thanks for your help

Steve Howgill

Serge's picture

Hello Steve,

As it seems from your piece of the code the CSF_... variables are pointing to the current working directory, check whether it contains two files: Plugin and Resources -I think that you miss them.

Regards,
Serge

Steve Howgill's picture

Serge

The files Plugin and Resources do exist in the correct directory.

Regards

Steve Howgill

Serge's picture

Hi,

And what is content of the file Resources?

Regards,
Serge

Steve Howgill's picture

Serge

The file Resources contains the following:-

formatlist:Leo

Leo.Description: Leo Document Version 1.0
Leo.FileExtension: leo
Leo.StoragePlugin: ad696000-5b34-11d1-b5ba-00a0c9064368
Leo.RetrievalPlugin: ad696001-5b34-11d1-b5ba-00a0c9064368
LeoSchema: ad696002-5b34-11d1-b5ba-00a0c9064368
Leo.AttributeStoragePlugin: 47b0b826-d931-11d1-b5da-00a0c9064368
Leo.AttributeRetrievalPlugin: 47b0b827-d931-11d1-b5da-00a0c9064368

#
# standard attributes
#
MDTV-Standard.Description: Standard Document Version 1.0
MDTV-Standard.FileExtension: std
MDTV-Standard.StoragePlugin: ad696000-5b34-11d1-b5ba-00a0c9064368
MDTV-Standard.RetrievalPlugin: ad696001-5b34-11d1-b5ba-00a0c9064368
MDTV-StandardSchema: ad696002-5b34-11d1-b5ba-00a0c9064368
MDTV-Standard.AttributeStoragePlugin: 47b0b826-d931-11d1-b5da-00a0c9064368
MDTV-Standard.AttributeRetrievalPlugin: 47b0b827-d931-11d1-b5da-00a0c9064368

The file Plugin contains the following:-

! Description of available plugins
! ********************************
!
a148e300-5740-11d1-a904-080036aaa103.Location: FWOSPlugin

!
! base document drivers plugin
!
ad696000-5b34-11d1-b5ba-00a0c9064368.Location: PAppStdPlugin
ad696001-5b34-11d1-b5ba-00a0c9064368.Location: PAppStdPlugin
ad696002-5b34-11d1-b5ba-00a0c9064368.Location: PAppStdPlugin
47b0b826-d931-11d1-b5da-00a0c9064368.Location: PAppStdPlugin
47b0b827-d931-11d1-b5da-00a0c9064368.Location: PAppStdPlugin

Regards

Steve Howgill

Serge's picture

Steve,

Well, both file seem to be correct. If I were you I'd
check once again what are values of CSF_... varibales
in the runtime. I made several OCAF applications and
in the most cases a crash during launching the application is caused by incorrect settings of the variables. Those variables are required to successfully run the application:

CSF_"app_name"Defaults
CSF_PluginDefaults
CSF_GraphicShr
CSF_UnitsLexicon
CSF_UnitsDefinition

Of cousre, the reason of the crash may be in an invalid build of the application but more often its due
to incorrect variables.

Regards

Steve Howgill's picture

Serge,

I think I have found the problem.

I had the environment variable
CSF_PluginDefaults set to
C:\opencascade4.0\scr\StdResource;c:\opencascade4.0\scr\XCAFResources.
I have removed the XCAF value so that it now reads C:\opencascade4.0\scr\StdResource, rebooted NT and everything seems to be working O.K.

Many thanks for your help

Kind Regards

Steve Howgill

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.