jianbaoxia
CAD master
Hi Bros, I'm JianBaoXia.
I meet a problem when use Geom_BSplineSurface. It's look so simple, however, I don't know where I'm wrong.
It's just like below:
I get a BSplineSurface, and want to get it's imformations, I get error in code:
And the error is "There is no appropriate constructor from " "const TColStd_Array2OfReal *" to "NCollection_Array2<Standard_Real>" ".
As we know the definition of TColStd_Array2OfReal is:
I have no idea where is wrong, I must ignore something.
There is complete Demo:
I meet a problem when use Geom_BSplineSurface. It's look so simple, however, I don't know where I'm wrong.
It's just like below:
Code:
Handle(Geom_BSplineSurface) aFace_00 = new Geom_BSplineSurface(pole, uk, vk, um, vm, ud, vd);
TColgp_Array2OfPnt poles_00 = aFace_00->Poles();
TColStd_Array2OfReal weights_00 = aFace_00->Weights();
TColStd_Array1OfReal uknots = aFace_00->UKnots();
TColStd_Array1OfReal vknots = aFace_00->VKnots();
TColStd_Array1OfInteger umult = aFace_00->UMultiplicities();
TColStd_Array1OfInteger vmult = aFace_00->VMultiplicities();
Standard_Integer udegree = aFace_00->UDegree();
Standard_Integer vdegree = aFace_00->VDegree();
Code:
ColStd_Array2OfReal weights_00 = aFace_00->Weights();
As we know the definition of TColStd_Array2OfReal is:
Code:
typedef NCollection_Array2<Standard_Real> TColStd_Array2OfReal;
I have no idea where is wrong, I must ignore something.
There is complete Demo:
Code:
//
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
//
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepAlgoAPI_Section.hxx>
#include <BRepFeat_Gluer.hxx>
#include <BRepAlgoAPI_Cut.hxx>
//
#include <gp_Pln.hxx>
//
#include <TopoDS.hxx>
#include <TopExp_Explorer.hxx>
//
#include <ShapeAnalysis.hxx>
#include <ShapeAnalysis_Surface.hxx>
//
#include <STEPControl_Writer.hxx>
#include <STEPControl_Reader.hxx>
#include <Interface_Static.hxx>
//
#include <BRepBndLib.hxx>
//
#include <BRepBuilderAPI_Copy.hxx>
#include <BRepBuilderAPI_Transform.hxx>
//
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
//
#include <Geom_BSplineCurve.hxx>
#include <Geom_BSplineSurface.hxx>
//
#include <GeomLProp_CLProps.hxx>
//
#include <Geom_BezierSurface.hxx>
//
#include <TColGeom_Array2OfBezierSurface.hxx>
//
#include <GeomConvert_CompBezierSurfacesToBSplineSurface.hxx>
int main()
{
std::string filePath = "C:/Users/14656/Desktop/Program/Open Cascade/Demo/";
// Create BSplineSurface
TColgp_Array2OfPnt array1(1, 3, 1, 3);
array1.SetValue(1, 1, gp_Pnt(1, 1, 1));
array1.SetValue(1, 2, gp_Pnt(2, 1, 2));
array1.SetValue(1, 3, gp_Pnt(3, 1, 1));
array1.SetValue(2, 1, gp_Pnt(1, 2, 1));
array1.SetValue(2, 2, gp_Pnt(2, 2, 2));
array1.SetValue(2, 3, gp_Pnt(3, 2, 0));
array1.SetValue(3, 1, gp_Pnt(1, 3, 2));
array1.SetValue(3, 2, gp_Pnt(2, 3, 1));
array1.SetValue(3, 3, gp_Pnt(3, 3, 0));
TColgp_Array2OfPnt array2(1, 3, 1, 3);
array2.SetValue(1, 1, gp_Pnt(3, 1, 1));
array2.SetValue(1, 2, gp_Pnt(4, 1, 1));
array2.SetValue(1, 3, gp_Pnt(5, 1, 2));
array2.SetValue(2, 1, gp_Pnt(3, 2, 0));
array2.SetValue(2, 2, gp_Pnt(4, 2, 1));
array2.SetValue(2, 3, gp_Pnt(5, 2, 2));
array2.SetValue(3, 1, gp_Pnt(3, 3, 0));
array2.SetValue(3, 2, gp_Pnt(4, 3, 0));
array2.SetValue(3, 3, gp_Pnt(5, 3, 1));
TColgp_Array2OfPnt array3(1, 3, 1, 3);
array3.SetValue(1, 1, gp_Pnt(1, 3, 2));
array3.SetValue(1, 2, gp_Pnt(2, 3, 1));
array3.SetValue(1, 3, gp_Pnt(3, 3, 0));
array3.SetValue(2, 1, gp_Pnt(1, 4, 1));
array3.SetValue(2, 2, gp_Pnt(2, 4, 0));
array3.SetValue(2, 3, gp_Pnt(3, 4, 1));
array3.SetValue(3, 1, gp_Pnt(1, 5, 1));
array3.SetValue(3, 2, gp_Pnt(2, 5, 1));
array3.SetValue(3, 3, gp_Pnt(3, 5, 2));
TColgp_Array2OfPnt array4(1, 3, 1, 3);
array4.SetValue(1, 1, gp_Pnt(3, 3, 0));
array4.SetValue(1, 2, gp_Pnt(4, 3, 0));
array4.SetValue(1, 3, gp_Pnt(5, 3, 1));
array4.SetValue(2, 1, gp_Pnt(3, 4, 1));
array4.SetValue(2, 2, gp_Pnt(4, 4, 1));
array4.SetValue(2, 3, gp_Pnt(5, 4, 1));
array4.SetValue(3, 1, gp_Pnt(3, 5, 2));
array4.SetValue(3, 2, gp_Pnt(4, 5, 2));
array4.SetValue(3, 3, gp_Pnt(5, 5, 1));
Handle(Geom_BezierSurface) BZ1 = new Geom_BezierSurface(array1);
TopoDS_Face BZFace1 = BRepBuilderAPI_MakeFace(BZ1, 1e-7);
Handle(Geom_BezierSurface) BZ2 = new Geom_BezierSurface(array2);
TopoDS_Face BZFace2 = BRepBuilderAPI_MakeFace(BZ2, 1e-7);
Handle(Geom_BezierSurface) BZ3 = new Geom_BezierSurface(array3);
TopoDS_Face BZFace3 = BRepBuilderAPI_MakeFace(BZ3, 1e-7);
Handle(Geom_BezierSurface) BZ4 = new Geom_BezierSurface(array4);
TopoDS_Face BZFace4 = BRepBuilderAPI_MakeFace(BZ4, 1e-7);
TColGeom_Array2OfBezierSurface bezierarray(1, 2, 1, 2);
bezierarray.SetValue(1, 1, BZ1);
bezierarray.SetValue(1, 2, BZ2);
bezierarray.SetValue(2, 1, BZ3);
bezierarray.SetValue(2, 2, BZ4);
GeomConvert_CompBezierSurfacesToBSplineSurface BB = GeomConvert_CompBezierSurfacesToBSplineSurface(bezierarray);
TColgp_Array2OfPnt pole = BB.Poles()->Array2();
TColStd_Array1OfReal uk = BB.UKnots()->Array1();
TColStd_Array1OfReal vk = BB.VKnots()->Array1();
TColStd_Array1OfInteger um = BB.UMultiplicities()->Array1();
TColStd_Array1OfInteger vm = BB.VMultiplicities()->Array1();
Standard_Integer ud = BB.UDegree();
Standard_Integer vd = BB.VDegree();
Handle(Geom_BSplineSurface) aFace_00 = new Geom_BSplineSurface(pole, uk, vk, um, vm, ud, vd);
// Get information
TColgp_Array2OfPnt poles_00 = aFace_00->Poles();
TColStd_Array2OfReal weights_00 = aFace_00->Weights();
TColStd_Array1OfReal uknots = aFace_00->UKnots();
TColStd_Array1OfReal vknots = aFace_00->VKnots();
TColStd_Array1OfInteger umult = aFace_00->UMultiplicities();
TColStd_Array1OfInteger vmult = aFace_00->VMultiplicities();
Standard_Integer udegree = aFace_00->UDegree();
Standard_Integer vdegree = aFace_00->VDegree();
return 0;
}