OCAF - how to save my document?

I've written a simple application which creates a document, loads a few BREP models and then adds a number of labels with TNaming_NamedShape attributes to the data framework.

In my application, I view the data framework with the OCAFbrowser and it is correct (see attached image). However when I try to save the document I get an access violation.

I'm using the AppStd_Application class and creating a document using the Standard file format "MDTV-Standard". Should this work?

If so, do the TopoDS_Shapes get written out as or well or do I have to make additional calls to have them saved?

Thank you.

Attachments: 
Dennis G.'s picture

Hello Blair Downie,

Everything that is registered to your Document should be saved. Without any code snippets it's hard to say what causes the access violation.
Perhaps this link contains some valuable information for you:

http://opencascade.blogspot.com/2008/12/adding-colors-and-names-to-your....

Cheers,
Dennis

Blair Downie's picture

Dennis,

I've attached the program, which contains Cascade API calls and calls to our own API. We do automated mesh generation and have a number of interfaces to CAD systems or kernels. We're experimenting with our Cascade interface and adding modeling operations.

Anyhow line 116 in the code calls AppStd_Application::SaveAs which is where my problem occurrs.

One thing I did not mention before, is that when I create the application I get a warning that it can't find the FWOSPlugin location listed in the Plugin file. I'm not sure what that plugin is for, so is this warning significant?

Thanks,
Blair Downie

Attachments: 
Roman Lygin's picture

If you meet this warning about FWOSPlugin, this can likely indicate a root-cause of your failure to save OCAF document.
Please make sure that:
1. CSF_PluginDefaults env var points to a directory where Plugin file is located (by default, %CASROOT%\src\StdResource - see http://www.opencascade.org/org/gettingstarted/install/envvar/)
2. If you have a custom Plugin file, FWOSPlugin is in it
a148e300-5740-11d1-a904-080036aaa103.Location: FWOSPlugin

3. FWOSPlugin.dll can be found in %PATH%.

(I thought I once post a detailed list of prerequisites of what is needed to enable OCAF saving/opening on the forum but cannot find the post :-(. If anyone finds it please put a link here. Perhaps this FAQ is worth a blog post...)

Hope this helps.
Roman

---
opencascade.blogspot.com - the Open CASCADE blog
www.cadexchanger.com - CAD Exchanger, your 3D data translator

Ugo Capeto's picture

Roman:
I think it would be nice to have that as a blog post.
I also want to do something similar to what Blair is doing and it'd be nice to have a detailed tutorial on the blog, just for doing the standard attribute stuff.

Roman Lygin's picture

Ugo, thanks.
Just in case, I re-read the OCAF User's Guide and think its par. 4.3.3 'Saving the document' should be fine. A code excerpt in the post about XDE where I showed XCAF_Application subclass http://opencascade.blogspot.com/2008/12/adding-colors-and-names-to-your....) can hopefully also be helpful too.
Roman
---
opencascade.blogspot.com - the Open CASCADE blog
www.cadexchanger.com - CAD Exchanger, your 3D data translator

Ugo Capeto's picture

yeah, i tried to read the blog post but it gives me headaches. i don't think i am stupid but that whole C++ stuff gives me hives. now, you're saying i have to use XDE on top of OCAF just for having non-transient IDs for shapes :)

Roman Lygin's picture

Nope, you don't need to. XDE is tool for colors, names, and other attributes. For integers (or strings) and shapes basis OCAF is fine.

Blair Downie's picture

Solved my problem ... I was running my program on the PC within a Cygwin shell and the environment variables used Unix style syntax (i.e. forward slashes for directory seperators).

Section 4.3.3 in the Application Framework User's Guide was very helpful. Perhaps a note that says if you're just using standard attributes you don't have to create your own sub-class of TDocStd_Application. AppStd_Application works just fine.

fatmice's picture

i have the same problem.can you help me?
how do you solve the problem? thank you...