MakeBottle Tutorial

Helo all,
finally I am able to compile the sample Tutorial of delivered with Open Cascade 5.0. However, I recieved the following Error, when trying to link,

LIBCMTD.lib(crt0.obj) : error LNK2001: Nichtaufgeloestes externes Symbol _main

I think the linker couldn't find the BRepLib.hxx.
can any body tell me, under which Toolkit could I find this Lib.

Thanks

MCV's picture

Oh yes oh yes, now the problems begin.
First of all give us more details on your topical state: Do you use Linux ? If yes, could you present us your ".profile"-file ? Maybe you oversaw to set some environment-variables for OCC 5.0.

Best Regards

MCV

Von mir aus demnächst auf Deutsch.

a_shaqra's picture

thanks for your answer and the offer to write in German. I'de rather write in English to let most of us in this forum keep track in the subject.

Am using Windows 2k and VC++

MfG

MCV's picture

Oh sorry, I am working with Linux not Windows.

But here are 2 very good addresses, they work Windows-based.

Best Regards

MCV

1. djorge@coimbra.ccg.pt
2. Francois.Lauzon@dbmreflex.com

Saravana's picture

I tried to run the tutorial file with WIN and VC++ environment, but i got the error as
The following environment variables were not found
$(QTDIR)

Any suggestions?

Saravana's picture

I tried to run the tutorial file with WIN and VC++ environment, but i got the error as
The following environment variables were not found
$(QTDIR)

Any suggestions?

Rob Bachrach's picture

If you just wish to run the tutorial, run the run.bat file in the tutorial directory.

If you wish to build it and you do not own a commercial version of Qt (see www.trolltech.com), you may be out of luck right now. First of all, the tutorial was build with Qt 2.3, which is no longer available. You can get a copy of Qt 3.2 by purchasing "C++ GUI Programming with Qt 3" from amazon.com. If you want to learn to use Qt it is a good idea. Otherwise, there are no OpenSource versions of Qt available for VC++ at the moment. When Qt 4.0 is released later this quarter, TrollTech is claiming they will release a VC++ OpenSource version. In either case, the tutorial source code may need some modifications to compile under 3.2 or 4.0.

Good luck,
Rob

Saravana's picture

Hi Rob!
How to run the Makebottle.hxx file in WinXP and VC++ 6.0 environment.
i am getting 68 errors and lots of warnings. I can run all the MFC samples except the makebottle program. could you please give some help, how to run or include makebottle program in opencascade MFC project.

Rob Bachrach's picture

I've never tried, but the code to actually create the bottle geometry contains no Qt code (MakeBottle.cxx). You could copy this into one of the MFC examples and add a toolbutton. The toolbutton should execute code that looks something like:

TopoDS_Shape aBottle=MakeBottle(50,70,30);
Handle(AIS_Shape) AISBottle=new AIS_Shape(aBottle);
myAISContext->SetMaterial(AISBottle,Graphic3d_NOM_GOLD);
myAISContext->SetDisplayMode(AISBottle,1,Standard_False);
myAISContext->Display(AISBottle, Standard_False);
myAISContext->SetCurrentObject(AISBottle,Standard_False);

That should allow you to draw the bottle in that tutorial.

Good luck,
Rob

Saravana's picture

I don't know how to do that, Can you please explain how to do implement the above steps. I am new to this environment. I have created the Viewer 3D AppWizard and complied it. it's giving perfect output. Now how can i add the makebottle.cxx file into the compiled AppWizard. sorry for the disturbance. Please explain me in detail

Rob Bachrach's picture

I do not normally use MFC or the VC++ environment. I actually use Qt for UI development. However, I gave it a shot and I'll do my best to describe the steps:

1 - Create a project using the 3D Viewer AppWizard (ie. bottle). I simply went through the wizard without selecting any custom options. I had to modify the project settings (link tab) to access the CASCADE libraries from the lib directory instead of libd. Compile the project and make sure it runs.

2 - Under the resource view, double click on IDR_3DTYPE under the Menu branch. This displays the menu that is displayed when a document exists in the application. Double click on the empty menu item at the bottom of the File menu and set its ID to ID_BOTTLE and the caption to &Bottle (there is probably a better place for this, but I did this quickly).

3 - Right click on the new menu item and select the class wizard. Let the application create the class wizard resources automatically and cancel if you get an error from IDR_3DTYPE. When presented with the class wizard, may sure the Doc class is selected (CBottleDoc), the ID_BOTTLE object ID, and the COMMAND message. Select the "Add Function" button to add the OnBottle function. Then, select the OnBottle function from the Member functions list and select Edit Code.

4 - Place the following code in the OnBottle function.
TopoDS_Shape aBottle=MakeBottle(50,70,30);
Handle(AIS_Shape) AISBottle=new AIS_Shape(aBottle);
myAISContext->SetMaterial(AISBottle,Graphic3d_NOM_GOLD);
myAISContext->SetDisplayMode(AISBottle,1,Standard_False);
myAISContext->Display(AISBottle, Standard_False);
myAISContext->SetCurrentObject(AISBottle,Standard_False);

5 - Select CBottleDoc from the ClassView, right click and select to add a member function. Set the return type to TopoDS_Shape, set the access to Private, and set the prototype to:
MakeBottle(const Standard_Real myWidth, const Standard_Real myHeight, const Standard_Real myThickness)
Copy the code from the MakeBottle function in MakeBottle.cxx of the tutorial into this function.

6 - Copy all the #include statements from MakeBottle.cxx into the StdAfx.h file in your project. If you are adventurous, remove any duplicates from what is already there.

7 - In the project settings link tab, append the following to the list of Object Libraries/Modules:
TKBool.lib TKBO.lib TKOffset.lib TKPrim.lib TKFeat.lib TKFillet.lib

8 - Compile and run the project. Select Bottle from the file menu (it may take some time to generate the geometry) and select the FitAll toolbutton.

I hope this helps. If you need a finished project, let me know and I can zip it up and e-mail it to you. I strongly suggest, however, that you go through some CASCADE free MFC/Visual C++ tutorials (get a book) before you try to learn CASCADE at the same time.

Rob

Vijayaragavan's picture

Hello
I have tried out make bottle sample in ocaf wizard...i am getting run time exception error because of tkv3d.lib...How to remove that error...Please help me or send the complete project to my mail id...

Vijayaragavan's picture

Hello
I have tried out make bottle sample in ocaf wizard...i am getting run time exception error because of tkv3d.lib...How to remove that error...Please help me or send the complete project to my mail id...

Nilesh's picture

hi rob,
myself and my friend are interested in doing the project in software development using OpenCascade.. we are M.Tech CAD/CAM students..
we are totally new to VC++ environment...
but we still tried to follow the steps you had suggested to SARVANA for makebottle application using VC++....
but we got the following error:-

c:\program files\microsoft visual studio\myprojects\bottle\bottledoc.cpp(5) : fatal error C1083: Cannot open precompiled header file: 'Debug/bottle.pch': No such file or directory
Error executing cl.exe.

bottleDoc.obj - 1 error(s), 0 warning(s)

don't no what to do.. can u suggest please

Rob Bachrach's picture

As I stated, I do not normally use the VC++ environment or the PCH mechanism. My only suggestion would be to try a "rebuild all" on the project and see what happens. Can anyone else help these poor lost soles?

Karl-Heinz's picture

Hallo,

This seems to be a problem of VC++, rather than one of OCC. You can try to change the settings for your project:
Project-> Settings-> C/C++ -> Category:Precompiled header -> Select: Do not use precompiled headers
(I'm using the german version of VC6++, so the description might be slightly different on your system)

good luck

Karl-Heinz

sas's picture

HI Rob!
Can u tell me how to get the dialog resource and main window at the same time as it is available in mfc samples. I tried, but i can't find where it is defined. I am new to occ and VC++.
pls help me with this.

Rob Bachrach's picture

I am not sure exactly what you mean. The main window itself does not have a resource. It is a MFC MDI window (CMainFrame). Check out play.cpp in the example to see when it is allocated. It is given a resource ID of IDR_MAINFRAME. This identifies the menu items, toolbars, and accelerators defined in the resource tabs.

Before diving too far into OCC, I strongly suggest you get yourself a cheap book or tutorial on VC++ and MFC to get started (baby steps). Sorry, this is not my area of expertise, so I don't have any recommendations.

Rob

Divya's picture

hi can you please let me if vc++ 9.o supports opencascade?

Svetlozar Kostadinov's picture

I've already recompiled successfully in VS 9.0 all the OCC stuff. Only without couple WOK projects dependent on TCL/TK headers. I will never use them.

Divya's picture

can u please tell me how to link the dependencies ie libraries?