Thu, 05/19/2022 - 12:08
Forums:
Hi, I am trying to build the upper surface of a wing.
Standard_Real x, y, z;
TColgp_Array1OfPnt Poles(1, 18);
for (int i = 0; i < 18; i++)
{
x = m_pAirfoilModel->Xpt[i].first;
y = m_pAirfoilModel->Xpt[i].second;
z = 0;
Poles.SetValue(i + 1, gp_Pnt(x, y, z));
}
TColgp_Array1OfPnt RPoles(1, 18);
for (int i = 0; i < 18; i++)
{
x = m_pAirfoilModel->Xpt[i].first;
//x = m_pAirfoilModel->Xpt[i].first / 2.0;
//x += 500;
y = m_pAirfoilModel->Xpt[i].second;
//y = m_pAirfoilModel->Xpt[i].second / 2.0;
z = 7500;
RPoles.SetValue(i + 1, gp_Pnt(x, y, z));
}
Standard_Integer degree(2);
Standard_Integer PNum = 18;
Standard_Integer KNum = PNum + degree + 1;
TColStd_Array1OfReal knots(1, KNum);
for (int i = 0; i < KNum; ++i)
{
knots.SetValue(i + 1, i);
}
TColStd_Array1OfInteger mults(1, KNum);
for (int i = 0; i < KNum; ++i)
{
mults.SetValue(i + 1, 1);
std::cout << mults.Value(i + 1) << std::endl;
}
Handle(Geom_BSplineCurve) curve = new Geom_BSplineCurve(Poles, knots, mults, degree);
Handle(Geom_BSplineCurve) Rcurve = new Geom_BSplineCurve(RPoles, knots, mults, degree);
TopoDS_Edge airfoilProfile = BRepBuilderAPI_MakeEdge(curve);
TopoDS_Edge RairfoilProfile = BRepBuilderAPI_MakeEdge(Rcurve);
TopoDS_Wire Airfoil = BRepBuilderAPI_MakeWire(airfoilProfile);
TopoDS_Wire RAirfoil = BRepBuilderAPI_MakeWire(RairfoilProfile);
BRepOffsetAPI_ThruSections surface(Standard_False,Standard_True);
surface.AddWire(Airfoil);
surface.AddWire(RAirfoil);
surface.Build();
TopoDS_Shape myBody = surface.Shape();
Can someone please tell me what the mistake is? PS: Both wires are open. although when I use a closed wire it builds perfectly.