
Sun, 06/11/2023 - 20:06
Forums:
Hi,
I am trying to create Spline surface and then convert it to a Face but the following code doesn't work. BRepBuilderAPI_MakeFace doesn't take Geom_BSplineSurface as input as it only takes Geom_Surface and I am not sure how to convert Geom_BSplineSurface into Geom_Surface. Can anyone pleas help ?
TopoDS_Face XYZ2Face(const TColgp_Array2OfPnt& points, int degMin = 4, int degMax = 4)
{
GeomAPI_PointsToBSplineSurface aPTBS;
aPTBS.Init(points, degMin, degMax, GeomAbs_C2, 1.e-9);
Handle(Geom_BSplineSurface) aSurface = aPTBS.Surface();
TopoDS_Face face = BRepBuilderAPI_MakeFace(aSurface, 1e-9).Face(); // This line fails.
return face;
}
Sun, 06/11/2023 - 21:19
This code should work.
I think, you need to make #include <Geom_BSplineSurface.hxx>
Best regards, Dmitrii.
Mon, 06/12/2023 - 03:45
Hi Dmitrii,
Thanks for your reply. I already have included that header file. I know it should work but it still doesn't with the latest OpenCASCADE version 7.7. BRepBuilderAPI_MakeFace is not able to resolve Handle(Geom_BSplineSurface) as input as it expects Handle(Geom_Surface) based on the supported constructor. Is there a way to cast Handle(Geom_BSplineSurface) -> Handle(Geom_Surface) ?
Best Regards
Samyak
Mon, 06/12/2023 - 10:59
Some compilers might have issues with resolving ambuguities (
BRepBuilderAPI_MakeFace
has several overloaded constructors). Try putting aHandle
upcast to a separate line:Mon, 06/12/2023 - 12:37
Hi,
Thanks for your reply. I have tried that already. It says no suitable conversion from opencascade::handle<Geom_BSplineSurface> to opencascade::handle<Geom_Surface> exists. This is so strange. This should obviously work straightaway. I am using OpenCASCADE-7.7.0-vc14-64 and my IDE is Visual Studio 2019. Any other suggestions ?
Regards
Samyak
Mon, 06/12/2023 - 13:12
I guess you need sharing a complete code sample to be able to reproduce and understand what might be wrong.
Mon, 06/12/2023 - 16:33
Compiles just fine for me.
Mon, 06/12/2023 - 14:23
A casting from child to father is a basic dinamic casting. You need to have the correct definitions (header files included) in order to process it.
VS 2019 has no problem with this task. I have pasted your code in VS15, VS17, VS19, VS22 and last gcc and clang and there is no problem if header is defined.
Please add "#include <Geom_Surface.hxx>" too.
Best regards, Dmitrii.