How to use the OCC source codes & libraries with VC++ 6.0

Hi all,

I'm new to both VC++ and OpenCascade. I would like to know how the OCC source files & libraries can be used in VC++ 6.0.

For starters, I want to convert an IGES file to a BRep shape - the OCC files for this are "IGESToBrep_Reader.cxx" & "IGESToBrep_Reader.hxx". My question is how to run these files in VC++? What kind of a project do I need to create in VC++ (wind32, console, mfc or dll)? Also each of these files seems to have many more #include headers in their code, and each of these other headers have more headers and so on. So will I need to add all these .hxx files to the source files folder in my project?

I really hope someone helps me out as I'm running out of time for this project !

Thanks a bunch !!

CloneX's picture

OpenCASCADE builds as a set of dynamic link libraries so the first step is to build the DLL's. The VC6 workspace files are located in OpenCASCADE/ros/adm/win32. Load each one and build both the Release and Debug configurations using the "All" project. I suggest building in the following order:
+ FoundationClasses
+ ModelingData
+ ModelingAlgorithms
+ Visualization
+ ApplicationFramework
+ DataExchange
+ Draw
+ WOK

Once the DLL's are built you can hook them into your project by including the associated .lib files for whichever parts of OCC you need.

You should probably build some of the sample applications (particularly the ones that most closely match what you need) first so you can get an idea how to use OCC.

Hope this helps. Good luck,

Chris

Karthik Viswanathan's picture

Hey Chris,

Thanks a lot for your quick reply. I'll try out what you described and get back to you again if I need more help. I appreciate your help !

-Karthik

Karthik Viswanathan's picture

Hi Chris,

I build the OCC workspace files in the same order that you suggested. Like I said earlier, I want to convert an IGES file to an OCC model/Brep file. So, I created a new project in VC++. I created a new c++ source file and copied the example code given in the IGES manual (page 26) for translating from IGES to an OCC model into it. The code reads:

#include "IGESControl_Reader.hxx"
#include "TColStd_HSequenceOfTransient.hxx"
#include "TopoDS_Shape.hxx"

{
IGESControl_Reader myIgesReader;
Standard_Integer nIgesFaces,nTransFaces;
myIgesReader.ReadFile ("MyFile.igs");
//loads file MyFile.igs
Handle(TColStd_HSequenceOfTransient) myList = myIgesReader.GiveList("iges-faces");
//selects all IGES faces in the file and puts them into a list called //MyList,
nIgesFaces = myList->Length();
nTransFaces = myIgesReader.TransferList(myList);
//translates MyList,
cout<<"IGES Faces: "<

CloneX's picture

You need to add the OCC library info to your VC++ project. In the "Project Settings" dialog select the "Link" tab. Choose "General" category and add the required .lib files to the Object/library modules list. Next choose "Input" category and add $(CASROOT)\win32\lib in the Additional library path field.

The trick is figuring out what .lib files are needed. I used a freeware utility called DLL Export Viewer (http://www.nirsoft.net/utils/dll_export_viewer.html) to get a list of all exported functions in the OCC DLL's. Using that list and the linker error information you should be able to determine what libraries are required for your project.

Cheers,
Chris

Karthik Viswanathan's picture

Thanks for your help so far Chris.

Here's what I have done over the past few days:

I created a new "Win32 Console Application" project in VC++6.0. I added all the .cxx files from the folder 'C:\Opencascade\win32\ros\src\IGESToBRep' to my project. I added all the OCC libraries to my project. I also added a new source file containing just the 'int main() function (since it's a console application).

When I execute the project after building, all I get is a black console window which says "Press any key to continue". Now, like I mentioned earlier, I want to convert an IGES file to a BREP file and then get dimensions from the BREP file. How do I know what IGES file is being loaded into memory and being converted to a BREP file? When I execute the project, it doesn't ask me which IGES file I want to convert to BREP.

Thanks a bunch once again !

-Karthik

Karthik Viswanathan's picture

Just after I posted my message, I tried something different. I created a new console project and pasted the following code in my source file:

#include "IGESControl_Reader.hxx"
#include "TColStd_HSequenceOfTransient.hxx"
#include "TopoDS_Shape.hxx"

int main()
{
IGESControl_Reader myIgesReader;
Standard_Integer nIgesFaces,nTransFaces;
myIgesReader.ReadFile ("C:\Documents and Settings\Karthik\Desktop\iges_sample.igs");
//loads file MyFile.igs
Handle(TColStd_HSequenceOfTransient) myList = myIgesReader.GiveList("iges-faces");
//selects all IGES faces in the file and puts them into a list called //MyList,
nIgesFaces = myList->Length();
nTransFaces = myIgesReader.TransferList(myList);
//translates MyList,
cout<<"IGES Faces: "<

Ankit Surti's picture

First of all, get your C/C++ basics right! The method of specifying the file paths in C++ is different than in Windows. Just change the '\' to '//' and the file should open fine. Next, to display the read and translated file, you need to set an AIS context for it and use the associated Display method. I personally use the OCAF wizard to start my project rather than a Console Win32 Application. If you will use the wizard, it gives an option of including a Trihedron. Including it will help you trace what needs to be done to display the object (if you are going to work with the wizard now)!