Error creating objects derived BRepPrimAPI_MakeBox

Hello. I tried to create an object called CBox Derived from BRepPrimAPI_MakeBox in the Document of an MFC application. In the header file i have ---------------------------- BRepPrimAPI_MakeBox CBox; ---------------------------- I tried initialising it by many ways in the *.cpp file but none worked. I tried to initialise it this way BRepPrimAPI_MakeBox CBox(0,0,0); it didn't work. I tried Box = BRepPrimAPI_MakeBox (0.,0.,0.) it didn't work neither. But i have this error in the constructor: "error C2512: 'BRepPrimAPI_MakeBox' : no appropriate default constructor available"....

So i wanted to know what to do to create my class. When consulting the 'BRepPrimAPI_MakeBox.cxx i saw that the elements used in it are all const. Does it mean that we can't use variables ? I spent my whole day trying to get past this pb, but i just can't find an issue. Your help would be greatly appreciated. Thank You Omar Msaaf

Francois Lauzon's picture

Hello Omar,

from what you wrote, you have to initialize your CBox in the constructor of the class that is using it, for example:

CBoxUser::CBoxUser() : CBox(0,0,0)

I don't know what you want to do, but when you create the CBox like this, you won't be able to modify it because BRepPrimAPI_MakeBox seems to build the box when his constructor is called. You might want to remove CBox from your header and create it only when you know the value to pass in the constructor of BRepPrimAPI_MakeBox.

Anyway, hope it help. Francois.

Philippe Centa's picture

In the Modelization Algorithm User's Guide you read :

TopoDS_Solid theBox = BRepPrimAPI_MakeBox (10.,20.,30.);

But as far as I understand you have created a class CBox inheriting BRepPrimAPI_MakeBox . So : in your header file you write CBox::CBox (Standard_real dx, Standard_Real dy, Standard-Real dz) and in tour .cpp : TopoDS_Solid theBox = CBox (10.,20.,30.); should be OK.

By the way (0.,0.,0.) would create an ultra-flat box ...

Hope it helps.

Philippe Centa's picture

I did it a little short in my previous answer :

As far as I understand you have created a class CBox inheriting BRepPrimAPI_MakeBox

So : in your header file you write CBox::CBox : BRepPrimAPI_MakeBox (Standard_real dx, Standard_Real dy, Standard-Real dz)

in your cpp you write : theBox = CBox (10.,20.,30.);

Regards.