SplineSurface Handle problems in OCC ?

Imagine you want to create a BSplineSurface over an array initialized with valid point sample data. Therefore you write something like:

#include
...
int main(...)
{
Handle( Geom_BSplineSurface) surf;
TColgp_Array2OfPnt array( 1, 3, 1,10);

GeomAPI_PointsToBSplineSurface makeSurf;
makeSurf.Interpolate( array);
surf = makeSurf.Surface();

// until here anything is wonderful as it should be

// now let us try to get access on the number of u/v-points of the BSplineSurface
surf->NbUPoles();

// forget it, the compiler will now complain with some crap message as irrational as crap can be

}

This is the message:
invalid use of undefined type `class Geom_BSplineSurface
Handle_Geom_BSplineSurface.hxx:33: forward declaration of `class Geom_BSplineSurface'

=> The compiler is offended by the above line "surf->NbUPoles();"
But it makes no sense !

He complaints about all attempts to acces any kind of classmethods of Geom_BSplineSurface.

I tried excactly the same with a Geom_BSplineCurve and a 1-dimensional array of points.
It worked wonderful, no complaints by the compiler.

I felt like a new bug by the Matra team in our OCC-library.

Is this correct or not ?
Why this stupid useless time-consuming compiler messages ?

Any hint of, i.e. of the responsible persons for that class-code is most welcome.

Regards

MCV

Forum supervisor's picture

Hello,

try to check whether you include headers for all classes you use, namely :
#include <Geom_BSplineSurface.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <GeomAPI_PointsToBSplineSurface.hxx>

Best regards,
Forum Supervisor

MCV's picture

Yes Sir, I did include all these files.This problem only occurs using surfaces.
It works perfectly for curves.

By the way, I am using OCC 5.0 !!!
Could there be a slight problem with it ?

Thanks for answering.

MCV

Forum supervisor's picture

Hello,

please check that you do not include any header files for handles themselves, i.e. something like
<Handle_Geom_BSplineSurface.hxx>
You should not include headers for handles.

Best regards,
Forum Supervisor

MCV's picture

Thank you, I checked this too and there is no inclusion of any Handle-class.
I even tried to save the surface with the persistency-classes. This works fine. But you still cannot access any method of Handle_PGeom_BSplineSurface. The compiler will bring about the same error types.

What I do now, is reading the exported file by hand, seeking for the poles.

I am using gcc 2.95.3

Best Regards

MCV

m-aronsson's picture

Hi !

I hope that was a typo, you should not try to use Handle_PGeom_BSplineSurface, it is the Handle_Geom_BSplineSurface class you should use.

Mikael

MCV's picture

Hi,

no it was not a typo, I tried both PGeom and Geom.
Both produced the same mistake.

But I will try what you said. Your suggestion sounds quite good. I guess that´s it.

Thanks, I will write back soon.

MCV

m-aronsson's picture

Hi !

I am not sure why you get the errors but I will try to explain what the problem is.

The compiler only has a
"class Geom_BSplineSurface;" declared somewhere, so it knows that Geom_BSplineSurface is a class but it does not no anything about the instance variables and methods it support so you can only use it as a pointer.

The Handle_Geom_BSplineSurface -> operator returns a pointer to Geom_BSplineSurface and you try to use NbUPoles() on that pointer.

So in some way it does not have a Geom_BSplineSurface class declared in your code, which should not happen if the Geom_BSplineSurface.hxx file is included though, make sure you don't have any #ifdef that can mess up your life or something like that.

One thing you could do would be to remove the #include "Geom_BSplineSurface.hxx" and see if you get the same error message then.

Mikael