mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0030621: Implementation of building U-periodical surfaces.
draw_test_harness.md - description of new options in Draw commands AppDef_BSplineCompute.hxx, BRepApprox_TheComputeLineOfApprox.hxx, GeomInt_TheComputeLineOfWLApprox.hxx, Approx_BSplComputeLine.gxx - implementation of method SetPeriodic(...) and implementation periodic boundary conditions for multiline in order to get periodic multicurve. GeomAPI_PointsToBSplineSurface.hxx, GeomAPI_PointsToBSplineSurface.cxx - adding new parameter for methods Init(...) and Interpolate(...), implementation of building periodic tangents for first and last AppDef_MultiPointConstraint of multiline for U direction of surface. GeometryTest_APICommands.cxx - implementation of new functionality in Draw command surfapp and surfint GeomFill_NSections.cxx Fixing problem with bugs modalg_3 bug606_2
This commit is contained in:
parent
293211aee0
commit
d1775ee992
@ -1,4 +1,4 @@
|
|||||||
Draw Test Harness {#occt_user_guides__test_harness}
|
Draw Test Harness {#occt_user_guides__test_harness}
|
||||||
===============================
|
===============================
|
||||||
|
|
||||||
@tableofcontents
|
@tableofcontents
|
||||||
@ -5593,7 +5593,8 @@ Draw provides command to create curves and surfaces by approximation.
|
|||||||
|
|
||||||
* **2dapprox** fits a curve through 2d points;
|
* **2dapprox** fits a curve through 2d points;
|
||||||
* **appro** fits a curve through 3d points;
|
* **appro** fits a curve through 3d points;
|
||||||
* **surfapp** and **grilapp** fit a surface through 3d points;
|
* **surfapp** and **grilapp** fit a surface through 3d points by approximation;
|
||||||
|
* **surfint** fit a surface through 3d points by interpolation;
|
||||||
* **2dinterpolate** interpolates a curve.
|
* **2dinterpolate** interpolates a curve.
|
||||||
|
|
||||||
@subsubsection occt_draw_6_8_1 appro, dapprox
|
@subsubsection occt_draw_6_8_1 appro, dapprox
|
||||||
@ -5614,17 +5615,28 @@ Let us pick points and they will be fitted
|
|||||||
2dapprox c 10
|
2dapprox c 10
|
||||||
~~~~~
|
~~~~~
|
||||||
|
|
||||||
@subsubsection occt_draw_6_8_2 surfapp, grilapp
|
@subsubsection occt_draw_6_8_2 surfapp, grilapp, surfint
|
||||||
|
|
||||||
|
|
||||||
Syntax:
|
Syntax:
|
||||||
~~~~~
|
~~~~~
|
||||||
surfapp name nbupoints nbvpoints x y z ....
|
surfapp name nbupoints nbvpoints x y z ....
|
||||||
|
or
|
||||||
|
surfapp name nbupoints nbvpoints surf [periodic_flag = 0]
|
||||||
grilapp name nbupoints nbvpoints xo dx yo dy z11 z12 ...
|
grilapp name nbupoints nbvpoints xo dx yo dy z11 z12 ...
|
||||||
|
surfint name surf nbupoints nbvpoints [periodic_flag = 0]
|
||||||
~~~~~
|
~~~~~
|
||||||
|
|
||||||
* **surfapp** fits a surface through an array of u and v points, nbupoints*nbvpoints.
|
* **surfapp** fits a surface through an array of u and v points, nbupoints*nbvpoints.
|
||||||
* **grilapp** has the same function, but the x,y coordinates of the points are on a grid starting at x0,y0 with steps dx,dy.
|
* **grilapp** has the same function, but the x,y coordinates of the points are on a grid starting at x0,y0 with steps dx,dy.
|
||||||
|
* **surfapp** can take array of points from other input surface, if alternative syntax
|
||||||
|
**surfapp** name nbupoints nbvpoints surf [periodic_flag = 0]
|
||||||
|
is used.
|
||||||
|
Both command use for fitting approximation algorithm.
|
||||||
|
**surfint** uses interpolation algorithm and can take array of point only from other input surface.
|
||||||
|
Optional parameter **periodic_flag** allows to get correct periodical surfaces in U direction.
|
||||||
|
U direction of result surface corresponds colums of initial array of points.
|
||||||
|
If **periodic_flag** = 1, algorithm uses first row of array as last row and builds periodical surface.
|
||||||
|
|
||||||
**Example:**
|
**Example:**
|
||||||
~~~~~
|
~~~~~
|
||||||
|
@ -117,6 +117,12 @@ public:
|
|||||||
//! changes the first and the last constraint points.
|
//! changes the first and the last constraint points.
|
||||||
Standard_EXPORT void SetConstraints (const AppParCurves_Constraint firstC, const AppParCurves_Constraint lastC);
|
Standard_EXPORT void SetConstraints (const AppParCurves_Constraint firstC, const AppParCurves_Constraint lastC);
|
||||||
|
|
||||||
|
//! Sets periodic flag.
|
||||||
|
//! If thePeriodic = Standard_True, algorith tries to build periodic
|
||||||
|
//! multicurve using corresponding C1 boundary condition for first and last multipoints.
|
||||||
|
//! Multiline must be closed.
|
||||||
|
Standard_EXPORT void SetPeriodic(const Standard_Boolean thePeriodic);
|
||||||
|
|
||||||
//! returns False if at a moment of the approximation,
|
//! returns False if at a moment of the approximation,
|
||||||
//! the status NoApproximation has been sent by the user
|
//! the status NoApproximation has been sent by the user
|
||||||
//! when more points were needed.
|
//! when more points were needed.
|
||||||
@ -199,6 +205,7 @@ private:
|
|||||||
Standard_Integer mycont;
|
Standard_Integer mycont;
|
||||||
Standard_Real mylambda1;
|
Standard_Real mylambda1;
|
||||||
Standard_Real mylambda2;
|
Standard_Real mylambda2;
|
||||||
|
Standard_Boolean myPeriodic;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -117,6 +117,12 @@ public:
|
|||||||
//! changes the first and the last constraint points.
|
//! changes the first and the last constraint points.
|
||||||
Standard_EXPORT void SetConstraints (const AppParCurves_Constraint firstC, const AppParCurves_Constraint lastC);
|
Standard_EXPORT void SetConstraints (const AppParCurves_Constraint firstC, const AppParCurves_Constraint lastC);
|
||||||
|
|
||||||
|
//! Sets periodic flag.
|
||||||
|
//! If thePeriodic = Standard_True, algorith tries to build periodic
|
||||||
|
//! multicurve using corresponding C1 boundary condition for first and last multipoints.
|
||||||
|
//! Multiline must be closed.
|
||||||
|
Standard_EXPORT void SetPeriodic(const Standard_Boolean thePeriodic);
|
||||||
|
|
||||||
//! returns False if at a moment of the approximation,
|
//! returns False if at a moment of the approximation,
|
||||||
//! the status NoApproximation has been sent by the user
|
//! the status NoApproximation has been sent by the user
|
||||||
//! when more points were needed.
|
//! when more points were needed.
|
||||||
@ -199,6 +205,7 @@ private:
|
|||||||
Standard_Integer mycont;
|
Standard_Integer mycont;
|
||||||
Standard_Real mylambda1;
|
Standard_Real mylambda1;
|
||||||
Standard_Real mylambda2;
|
Standard_Real mylambda2;
|
||||||
|
Standard_Boolean myPeriodic;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -34,6 +34,145 @@
|
|||||||
#include <Precision.hxx>
|
#include <Precision.hxx>
|
||||||
#include <StdFail_NotDone.hxx>
|
#include <StdFail_NotDone.hxx>
|
||||||
#include <TColgp_Array1OfPnt.hxx>
|
#include <TColgp_Array1OfPnt.hxx>
|
||||||
|
#include <AppDef_BSpParLeastSquareOfMyBSplGradientOfBSplineCompute.hxx>
|
||||||
|
|
||||||
|
static void BuildParameters(const AppDef_MultiLine& theLine,
|
||||||
|
const Approx_ParametrizationType theParT,
|
||||||
|
TColStd_Array1OfReal& thePars)
|
||||||
|
{
|
||||||
|
Standard_Integer i, j, nbP3d = theLine.NbPoints();
|
||||||
|
Standard_Real dist;
|
||||||
|
Standard_Integer firstP = 1, lastP = theLine.NbMultiPoints();
|
||||||
|
const Standard_Integer aNbp = lastP - firstP + 1;
|
||||||
|
|
||||||
|
|
||||||
|
if (aNbp == 2) {
|
||||||
|
thePars(firstP) = 0.0;
|
||||||
|
thePars(lastP) = 1.0;
|
||||||
|
}
|
||||||
|
else if (theParT == Approx_ChordLength || theParT == Approx_Centripetal)
|
||||||
|
{
|
||||||
|
|
||||||
|
thePars(firstP) = 0.0;
|
||||||
|
dist = 0.0;
|
||||||
|
|
||||||
|
for (i = firstP + 1; i <= lastP; i++)
|
||||||
|
{
|
||||||
|
AppDef_MultiPointConstraint aMPC = theLine.Value(i - 1);
|
||||||
|
AppDef_MultiPointConstraint aMPC1 = theLine.Value(i);
|
||||||
|
|
||||||
|
dist = 0.0;
|
||||||
|
for (j = 1; j <= nbP3d; j++)
|
||||||
|
{
|
||||||
|
const gp_Pnt &aP1 = aMPC.Point(j),
|
||||||
|
&aP2 = aMPC1.Point(j);
|
||||||
|
dist += aP2.SquareDistance(aP1);
|
||||||
|
}
|
||||||
|
|
||||||
|
dist = Sqrt(dist);
|
||||||
|
if (theParT == Approx_ChordLength)
|
||||||
|
{
|
||||||
|
thePars(i) = thePars(i - 1) + dist;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{// Par == Approx_Centripetal
|
||||||
|
thePars(i) = thePars(i - 1) + Sqrt(dist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = firstP; i <= lastP; i++) thePars(i) /= thePars(lastP);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (i = firstP; i <= lastP; i++) {
|
||||||
|
thePars(i) = (Standard_Real(i) - firstP) /
|
||||||
|
(Standard_Real(lastP - Standard_Real(firstP)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void BuildPeriodicTangent(const AppDef_MultiLine& theLine,
|
||||||
|
const TColStd_Array1OfReal& thePars,
|
||||||
|
math_Vector& theTang)
|
||||||
|
{
|
||||||
|
Standard_Integer firstpt = 1, lastpt = theLine.NbMultiPoints();
|
||||||
|
Standard_Integer nbpoints = lastpt - firstpt + 1;
|
||||||
|
//
|
||||||
|
if (nbpoints <= 2)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
Standard_Integer i, nnpol, nnp = Min(nbpoints, 9);
|
||||||
|
nnpol = nnp;
|
||||||
|
Standard_Integer lastp = Min(lastpt, firstpt + nnp - 1);
|
||||||
|
Standard_Real U;
|
||||||
|
AppParCurves_Constraint Cons = AppParCurves_TangencyPoint;
|
||||||
|
if (nnp <= 4)
|
||||||
|
{
|
||||||
|
Cons = AppParCurves_PassPoint;
|
||||||
|
}
|
||||||
|
Standard_Integer nbP = 3 * theLine.NbPoints();
|
||||||
|
math_Vector V1(1, nbP), V2(1, nbP);
|
||||||
|
math_Vector P1(firstpt, lastp);
|
||||||
|
//
|
||||||
|
for (i = firstpt; i <= lastp; i++)
|
||||||
|
{
|
||||||
|
P1(i) = thePars(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
AppDef_BSpParLeastSquareOfMyBSplGradientOfBSplineCompute SQ1(theLine, firstpt, lastp, Cons, Cons, nnpol);
|
||||||
|
SQ1.Perform(P1);
|
||||||
|
const AppParCurves_MultiCurve& C1 = SQ1.BezierValue();
|
||||||
|
U = 0.0;
|
||||||
|
Standard_Integer j, nbP3d = theLine.NbPoints();
|
||||||
|
|
||||||
|
gp_Pnt aP;
|
||||||
|
gp_Vec aV;
|
||||||
|
j = 1;
|
||||||
|
for (i = 1; i <= nbP3d; i++) {
|
||||||
|
C1.D1(i, U, aP, aV);
|
||||||
|
V1(j) = aV.X();
|
||||||
|
V1(j + 1) = aV.Y();
|
||||||
|
V1(j + 2) = aV.Z();
|
||||||
|
j += 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_Integer firstp = Max(firstpt, lastpt - nnp + 1);
|
||||||
|
|
||||||
|
if (firstp == firstpt && lastp == lastpt) {
|
||||||
|
U = 1.0;
|
||||||
|
j = 1;
|
||||||
|
for (i = 1; i <= nbP3d; i++) {
|
||||||
|
C1.D1(i, U, aP, aV);
|
||||||
|
V2(j) = aV.X();
|
||||||
|
V2(j + 1) = aV.Y();
|
||||||
|
V2(j + 2) = aV.Z();
|
||||||
|
j += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
AppDef_BSpParLeastSquareOfMyBSplGradientOfBSplineCompute
|
||||||
|
SQ2(theLine, firstp, lastpt, Cons, Cons, nnpol);
|
||||||
|
|
||||||
|
math_Vector P2(firstp, lastpt);
|
||||||
|
for (i = firstp; i <= lastpt; i++) P2(i) = thePars(i);
|
||||||
|
SQ2.Perform(P2);
|
||||||
|
|
||||||
|
const AppParCurves_MultiCurve& C2 = SQ2.BezierValue();
|
||||||
|
U = 1.0;
|
||||||
|
j = 1;
|
||||||
|
for (i = 1; i <= nbP3d; i++) {
|
||||||
|
C2.D1(i, U, aP, aV);
|
||||||
|
V2(j) = aV.X();
|
||||||
|
V2(j + 1) = aV.Y();
|
||||||
|
V2(j + 2) = aV.Z();
|
||||||
|
j += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
theTang = 0.5*(V1 + V2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : GeomAPI_PointsToBSplineSurface
|
//function : GeomAPI_PointsToBSplineSurface
|
||||||
@ -125,9 +264,10 @@ GeomAPI_PointsToBSplineSurface::GeomAPI_PointsToBSplineSurface
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void GeomAPI_PointsToBSplineSurface::Interpolate(const TColgp_Array2OfPnt& Points)
|
void GeomAPI_PointsToBSplineSurface::Interpolate(const TColgp_Array2OfPnt& Points,
|
||||||
|
const Standard_Boolean thePeriodic)
|
||||||
{
|
{
|
||||||
Interpolate(Points, Approx_ChordLength);
|
Interpolate(Points, Approx_ChordLength, thePeriodic);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -136,13 +276,14 @@ void GeomAPI_PointsToBSplineSurface::Interpolate(const TColgp_Array2OfPnt& Point
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void GeomAPI_PointsToBSplineSurface::Interpolate(const TColgp_Array2OfPnt& Points,
|
void GeomAPI_PointsToBSplineSurface::Interpolate(const TColgp_Array2OfPnt& Points,
|
||||||
const Approx_ParametrizationType ParType)
|
const Approx_ParametrizationType ParType,
|
||||||
|
const Standard_Boolean thePeriodic)
|
||||||
{
|
{
|
||||||
Standard_Integer DegMin, DegMax;
|
Standard_Integer DegMin, DegMax;
|
||||||
DegMin = DegMax = 3;
|
DegMin = DegMax = 3;
|
||||||
GeomAbs_Shape CC = GeomAbs_C2;
|
GeomAbs_Shape CC = GeomAbs_C2;
|
||||||
Standard_Real Tol3d = -1.0;
|
Standard_Real Tol3d = -1.0;
|
||||||
Init(Points, ParType, DegMin, DegMax, CC, Tol3d);
|
Init(Points, ParType, DegMin, DegMax, CC, Tol3d, thePeriodic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -165,11 +306,12 @@ void GeomAPI_PointsToBSplineSurface::Init(const TColgp_Array2OfPnt& Points,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void GeomAPI_PointsToBSplineSurface::Init(const TColgp_Array2OfPnt& Points,
|
void GeomAPI_PointsToBSplineSurface::Init(const TColgp_Array2OfPnt& Points,
|
||||||
const Approx_ParametrizationType ParType,
|
const Approx_ParametrizationType ParType,
|
||||||
const Standard_Integer DegMin,
|
const Standard_Integer DegMin,
|
||||||
const Standard_Integer DegMax,
|
const Standard_Integer DegMax,
|
||||||
const GeomAbs_Shape Continuity,
|
const GeomAbs_Shape Continuity,
|
||||||
const Standard_Real Tol3D)
|
const Standard_Real Tol3D,
|
||||||
|
const Standard_Boolean thePeriodic)
|
||||||
{
|
{
|
||||||
Standard_Integer Imin = Points.LowerRow();
|
Standard_Integer Imin = Points.LowerRow();
|
||||||
Standard_Integer Imax = Points.UpperRow();
|
Standard_Integer Imax = Points.UpperRow();
|
||||||
@ -178,19 +320,30 @@ void GeomAPI_PointsToBSplineSurface::Init(const TColgp_Array2OfPnt& Points,
|
|||||||
|
|
||||||
Standard_Real Tol2D = Tol3D;
|
Standard_Real Tol2D = Tol3D;
|
||||||
|
|
||||||
// first approximate the V isos:
|
// first approximate the U isos:
|
||||||
|
Standard_Integer add = 1;
|
||||||
|
if (thePeriodic)
|
||||||
|
{
|
||||||
|
add = 2;
|
||||||
|
}
|
||||||
AppDef_MultiLine Line(Jmax-Jmin+1);
|
AppDef_MultiLine Line(Jmax-Jmin+1);
|
||||||
Standard_Integer i, j;
|
Standard_Integer i, j;
|
||||||
// Standard_Real X, Y;
|
|
||||||
|
|
||||||
for (j = Jmin; j <= Jmax; j++) {
|
for (j = Jmin; j <= Jmax; j++) {
|
||||||
AppDef_MultiPointConstraint MP(Imax-Imin+1, 0);
|
AppDef_MultiPointConstraint MP(Imax-Imin+add, 0);
|
||||||
for (i = Imin; i <= Imax; i++) {
|
for (i = Imin; i <= Imax; i++) {
|
||||||
MP.SetPoint(i, Points(i,j));
|
MP.SetPoint(i, Points(i,j));
|
||||||
}
|
}
|
||||||
|
if (thePeriodic)
|
||||||
|
{
|
||||||
|
MP.SetPoint(Imax+1, Points(1, j));
|
||||||
|
}
|
||||||
Line.SetValue(j, MP);
|
Line.SetValue(j, MP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Standard_Integer nbit = 2;
|
Standard_Integer nbit = 2;
|
||||||
Standard_Boolean UseSquares = Standard_False;
|
Standard_Boolean UseSquares = Standard_False;
|
||||||
if(Tol3D <= 1.e-3) UseSquares = Standard_True;
|
if(Tol3D <= 1.e-3) UseSquares = Standard_True;
|
||||||
@ -229,7 +382,7 @@ void GeomAPI_PointsToBSplineSurface::Init(const TColgp_Array2OfPnt& Points,
|
|||||||
const TColStd_Array1OfInteger& VMults = TheCurve.Multiplicities();
|
const TColStd_Array1OfInteger& VMults = TheCurve.Multiplicities();
|
||||||
|
|
||||||
|
|
||||||
Standard_Integer nbisosu = Imax-Imin+1;
|
Standard_Integer nbisosu = Imax-Imin+add;
|
||||||
AppDef_MultiLine Line2(nbisosu);
|
AppDef_MultiLine Line2(nbisosu);
|
||||||
|
|
||||||
for (i = 1; i <= nbisosu; i++) {
|
for (i = 1; i <= nbisosu; i++) {
|
||||||
@ -247,9 +400,43 @@ void GeomAPI_PointsToBSplineSurface::Init(const TColgp_Array2OfPnt& Points,
|
|||||||
AppDef_BSplineCompute TheComputer2
|
AppDef_BSplineCompute TheComputer2
|
||||||
(DegMin,DegMax,Tol3D,Tol2D,nbit,Standard_True,ParType,UseSquares);
|
(DegMin,DegMax,Tol3D,Tol2D,nbit,Standard_True,ParType,UseSquares);
|
||||||
if (Tol3D <= 0.0) {
|
if (Tol3D <= 0.0) {
|
||||||
|
if (thePeriodic)
|
||||||
|
{
|
||||||
|
TheComputer2.SetPeriodic(thePeriodic);
|
||||||
|
}
|
||||||
TheComputer2.Interpol(Line2);
|
TheComputer2.Interpol(Line2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (thePeriodic && Line2.NbMultiPoints() > 2)
|
||||||
|
{
|
||||||
|
TheComputer2.SetPeriodic(thePeriodic);
|
||||||
|
//
|
||||||
|
TColStd_Array1OfReal aPars(1, Line2.NbMultiPoints());
|
||||||
|
BuildParameters(Line2, ParType, aPars);
|
||||||
|
math_Vector aTang(1, 3 * Poles.Upper());
|
||||||
|
BuildPeriodicTangent(Line2, aPars, aTang);
|
||||||
|
Standard_Integer ind = 1;
|
||||||
|
TheCurve.Curve(ind, Poles);
|
||||||
|
AppDef_MultiPointConstraint MP1(Poles.Upper(), 0);
|
||||||
|
for (j = 1; j <= Poles.Upper(); j++) {
|
||||||
|
MP1.SetPoint(j, Poles(j));
|
||||||
|
Standard_Integer k = 3 * (j - 1);
|
||||||
|
gp_Vec aT(aTang(k + 1), aTang(k + 2), aTang(k + 3));
|
||||||
|
MP1.SetTang(j, aT);
|
||||||
|
}
|
||||||
|
Line2.SetValue(ind, MP1);
|
||||||
|
//
|
||||||
|
ind = Line2.NbMultiPoints();
|
||||||
|
TheCurve.Curve(ind, Poles);
|
||||||
|
AppDef_MultiPointConstraint MP2(Poles.Upper(), 0);
|
||||||
|
for (j = 1; j <= Poles.Upper(); j++) {
|
||||||
|
MP2.SetPoint(j, Poles(j));
|
||||||
|
Standard_Integer k = 3 * (j - 1);
|
||||||
|
gp_Vec aT(aTang(k + 1), aTang(k + 2), aTang(k + 3));
|
||||||
|
MP2.SetTang(j, aT);
|
||||||
|
}
|
||||||
|
Line2.SetValue(ind, MP2);
|
||||||
|
}
|
||||||
TheComputer2.Perform(Line2);
|
TheComputer2.Perform(Line2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,6 +460,10 @@ void GeomAPI_PointsToBSplineSurface::Init(const TColgp_Array2OfPnt& Points,
|
|||||||
|
|
||||||
mySurface = new Geom_BSplineSurface(ThePoles, UKnots, VKnots, UMults, VMults,
|
mySurface = new Geom_BSplineSurface(ThePoles, UKnots, VKnots, UMults, VMults,
|
||||||
UDegree, VDegree);
|
UDegree, VDegree);
|
||||||
|
if (thePeriodic && Line2.NbMultiPoints() > 2)
|
||||||
|
{
|
||||||
|
mySurface->SetUPeriodic();
|
||||||
|
}
|
||||||
|
|
||||||
myIsDone = Standard_True;
|
myIsDone = Standard_True;
|
||||||
}
|
}
|
||||||
@ -299,7 +490,7 @@ void GeomAPI_PointsToBSplineSurface::Init(const TColgp_Array2OfPnt& Points,
|
|||||||
Standard_Integer nbit = 2;
|
Standard_Integer nbit = 2;
|
||||||
if(Tol3D <= 1.e-3) nbit = 0;
|
if(Tol3D <= 1.e-3) nbit = 0;
|
||||||
|
|
||||||
// first approximate the V isos:
|
// first approximate the U isos:
|
||||||
Standard_Integer NbPointJ = Jmax-Jmin+1;
|
Standard_Integer NbPointJ = Jmax-Jmin+1;
|
||||||
Standard_Integer NbPointI = Imax-Imin+1;
|
Standard_Integer NbPointI = Imax-Imin+1;
|
||||||
Standard_Integer i, j;
|
Standard_Integer i, j;
|
||||||
@ -485,7 +676,7 @@ void GeomAPI_PointsToBSplineSurface::Init(const TColStd_Array2OfReal& ZPoints,
|
|||||||
|
|
||||||
Standard_Real Tol2D = Tol3D;
|
Standard_Real Tol2D = Tol3D;
|
||||||
|
|
||||||
// first approximate the V isos:
|
// first approximate the U isos:
|
||||||
AppDef_MultiLine Line(Jmax-Jmin+1);
|
AppDef_MultiLine Line(Jmax-Jmin+1);
|
||||||
math_Vector Param(Jmin, Jmax);
|
math_Vector Param(Jmin, Jmax);
|
||||||
Standard_Integer i, j;
|
Standard_Integer i, j;
|
||||||
|
@ -41,6 +41,36 @@ class StdFail_NotDone;
|
|||||||
//! - defining the data of the BSpline surface to be built,
|
//! - defining the data of the BSpline surface to be built,
|
||||||
//! - implementing the approximation algorithm
|
//! - implementing the approximation algorithm
|
||||||
//! or the interpolation algorithm, and consulting the results.
|
//! or the interpolation algorithm, and consulting the results.
|
||||||
|
//! In fact, class contains 3 algorithms, 2 for approximation and 1
|
||||||
|
//! for interpolation.
|
||||||
|
//! First approximation algorithm is based on usual least square criterium:
|
||||||
|
//! minimization of square distance between samplimg points and result surface.
|
||||||
|
//! Second approximation algorithm uses least square criterium and additional
|
||||||
|
//! minimization of some local characteristic of surface (first, second and third
|
||||||
|
//! partial derivative), which allows managing shape of surface.
|
||||||
|
//! Interpolation algorithm produces surface, which passes through sampling points.
|
||||||
|
//!
|
||||||
|
//! There is accordance between parametrization of result surface S(U, V) and
|
||||||
|
//! indexes of array Points(i, j): first index corresponds U parameter of surface,
|
||||||
|
//! second - V parameter of surface.
|
||||||
|
//! So, points of any j-th column Points(*, j) represent any V isoline of surface,
|
||||||
|
//! points of any i-th row Point(i, *) represent any U isoline of surface.
|
||||||
|
//!
|
||||||
|
//! For each sampling point parameters U, V are calculated according to
|
||||||
|
//! type of parametrization, which can be Approx_ChordLength, Approx_Centripetal
|
||||||
|
//! or Approx_IsoParametric. Default value is Approx_ChordLength.
|
||||||
|
//! For ChordLength parametrisation U(i) = U(i-1) + P(i).Distance(P(i-1)),
|
||||||
|
//! For Centripetal type U(i) = U(i-1) + Sqrt(P(i).Distance(P(i-1))).
|
||||||
|
//! Centripetal type can get better result for irregular distances between points.
|
||||||
|
//!
|
||||||
|
//! Approximation and interpolation algorithms can build periodical surface along U
|
||||||
|
//! direction, which corresponds colums of array Points(i, j),
|
||||||
|
//! if corresponding parameter (thePeriodic, see comments below) of called
|
||||||
|
//! methods is set to True. Algorithm uses first row Points(1, *) as periodic boundary,
|
||||||
|
//! so to avoid getting wrong surface it is necessary to keep distance between
|
||||||
|
//! corresponding points of first and last rows of Points:
|
||||||
|
//! Points(1, *) != Points(Upper, *).
|
||||||
|
|
||||||
class GeomAPI_PointsToBSplineSurface
|
class GeomAPI_PointsToBSplineSurface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -63,8 +93,11 @@ public:
|
|||||||
//! 1- his degree will be in the range [Degmin,Degmax]
|
//! 1- his degree will be in the range [Degmin,Degmax]
|
||||||
//! 2- his continuity will be at least <Continuity>
|
//! 2- his continuity will be at least <Continuity>
|
||||||
//! 3- the distance from the point <Points> to the
|
//! 3- the distance from the point <Points> to the
|
||||||
//! BSpline will be lower to Tol3D
|
//! BSpline will be lower to Tol3D.
|
||||||
Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt& Points, const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
|
|
||||||
|
Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt& Points,
|
||||||
|
const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
|
||||||
|
const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
|
||||||
|
|
||||||
//! Approximates a BSpline Surface passing through an
|
//! Approximates a BSpline Surface passing through an
|
||||||
//! array of Points. The resulting BSpline will have
|
//! array of Points. The resulting BSpline will have
|
||||||
@ -72,14 +105,22 @@ public:
|
|||||||
//! 1- his degree will be in the range [Degmin,Degmax]
|
//! 1- his degree will be in the range [Degmin,Degmax]
|
||||||
//! 2- his continuity will be at least <Continuity>
|
//! 2- his continuity will be at least <Continuity>
|
||||||
//! 3- the distance from the point <Points> to the
|
//! 3- the distance from the point <Points> to the
|
||||||
//! BSpline will be lower to Tol3D
|
//! BSpline will be lower to Tol3D.
|
||||||
Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt& Points, const Approx_ParametrizationType ParType, const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
|
|
||||||
|
Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt& Points,
|
||||||
|
const Approx_ParametrizationType ParType,
|
||||||
|
const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
|
||||||
|
const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
|
||||||
|
|
||||||
//! Approximates a BSpline Surface passing through an
|
//! Approximates a BSpline Surface passing through an
|
||||||
//! array of points using variational smoothing algorithm,
|
//! array of points using variational smoothing algorithm,
|
||||||
//! which tries to minimize additional criterium:
|
//! which tries to minimize additional criterium:
|
||||||
//! Weight1*CurveLength + Weight2*Curvature + Weight3*Torsion
|
//! Weight1*CurveLength + Weight2*Curvature + Weight3*Torsion.
|
||||||
Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt& Points, const Standard_Real Weight1, const Standard_Real Weight2, const Standard_Real Weight3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
|
|
||||||
|
Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColgp_Array2OfPnt& Points,
|
||||||
|
const Standard_Real Weight1, const Standard_Real Weight2, const Standard_Real Weight3,
|
||||||
|
const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2,
|
||||||
|
const Standard_Real Tol3D = 1.0e-3);
|
||||||
|
|
||||||
//! Approximates a BSpline Surface passing through an
|
//! Approximates a BSpline Surface passing through an
|
||||||
//! array of Points.
|
//! array of Points.
|
||||||
@ -97,7 +138,12 @@ public:
|
|||||||
//! BSpline will be lower to Tol3D
|
//! BSpline will be lower to Tol3D
|
||||||
//! 4- the parametrization of the surface will verify:
|
//! 4- the parametrization of the surface will verify:
|
||||||
//! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
|
//! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
|
||||||
Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColStd_Array2OfReal& ZPoints, const Standard_Real X0, const Standard_Real dX, const Standard_Real Y0, const Standard_Real dY, const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
|
|
||||||
|
Standard_EXPORT GeomAPI_PointsToBSplineSurface(const TColStd_Array2OfReal& ZPoints,
|
||||||
|
const Standard_Real X0, const Standard_Real dX,
|
||||||
|
const Standard_Real Y0, const Standard_Real dY,
|
||||||
|
const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
|
||||||
|
const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
|
||||||
|
|
||||||
//! Approximates a BSpline Surface passing through an
|
//! Approximates a BSpline Surface passing through an
|
||||||
//! array of Point. The resulting BSpline will have
|
//! array of Point. The resulting BSpline will have
|
||||||
@ -105,22 +151,29 @@ public:
|
|||||||
//! 1- his degree will be in the range [Degmin,Degmax]
|
//! 1- his degree will be in the range [Degmin,Degmax]
|
||||||
//! 2- his continuity will be at least <Continuity>
|
//! 2- his continuity will be at least <Continuity>
|
||||||
//! 3- the distance from the point <Points> to the
|
//! 3- the distance from the point <Points> to the
|
||||||
//! BSpline will be lower to Tol3D
|
//! BSpline will be lower to Tol3D.
|
||||||
Standard_EXPORT void Init (const TColgp_Array2OfPnt& Points, const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
|
|
||||||
|
Standard_EXPORT void Init (const TColgp_Array2OfPnt& Points,
|
||||||
|
const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
|
||||||
|
const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
|
||||||
|
|
||||||
//! Interpolates a BSpline Surface passing through an
|
//! Interpolates a BSpline Surface passing through an
|
||||||
//! array of Point. The resulting BSpline will have
|
//! array of Point. The resulting BSpline will have
|
||||||
//! the following properties:
|
//! the following properties:
|
||||||
//! 1- his degree will be 3.
|
//! 1- his degree will be 3.
|
||||||
//! 2- his continuity will be C2.
|
//! 2- his continuity will be C2.
|
||||||
Standard_EXPORT void Interpolate (const TColgp_Array2OfPnt& Points);
|
|
||||||
|
Standard_EXPORT void Interpolate (const TColgp_Array2OfPnt& Points,
|
||||||
|
const Standard_Boolean thePeriodic = Standard_False);
|
||||||
|
|
||||||
//! Interpolates a BSpline Surface passing through an
|
//! Interpolates a BSpline Surface passing through an
|
||||||
//! array of Point. The resulting BSpline will have
|
//! array of Point. The resulting BSpline will have
|
||||||
//! the following properties:
|
//! the following properties:
|
||||||
//! 1- his degree will be 3.
|
//! 1- his degree will be 3.
|
||||||
//! 2- his continuity will be C2.
|
//! 2- his continuity will be C2.
|
||||||
Standard_EXPORT void Interpolate (const TColgp_Array2OfPnt& Points, const Approx_ParametrizationType ParType);
|
|
||||||
|
Standard_EXPORT void Interpolate (const TColgp_Array2OfPnt& Points, const Approx_ParametrizationType ParType,
|
||||||
|
const Standard_Boolean thePeriodic = Standard_False);
|
||||||
|
|
||||||
//! Approximates a BSpline Surface passing through an
|
//! Approximates a BSpline Surface passing through an
|
||||||
//! array of Points.
|
//! array of Points.
|
||||||
@ -138,7 +191,12 @@ public:
|
|||||||
//! BSpline will be lower to Tol3D
|
//! BSpline will be lower to Tol3D
|
||||||
//! 4- the parametrization of the surface will verify:
|
//! 4- the parametrization of the surface will verify:
|
||||||
//! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
|
//! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
|
||||||
Standard_EXPORT void Init (const TColStd_Array2OfReal& ZPoints, const Standard_Real X0, const Standard_Real dX, const Standard_Real Y0, const Standard_Real dY, const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
|
|
||||||
|
Standard_EXPORT void Init (const TColStd_Array2OfReal& ZPoints,
|
||||||
|
const Standard_Real X0, const Standard_Real dX,
|
||||||
|
const Standard_Real Y0, const Standard_Real dY,
|
||||||
|
const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
|
||||||
|
const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
|
||||||
|
|
||||||
//! Interpolates a BSpline Surface passing through an
|
//! Interpolates a BSpline Surface passing through an
|
||||||
//! array of Points.
|
//! array of Points.
|
||||||
@ -154,7 +212,9 @@ public:
|
|||||||
//! 2- his continuity will be C2.
|
//! 2- his continuity will be C2.
|
||||||
//! 4- the parametrization of the surface will verify:
|
//! 4- the parametrization of the surface will verify:
|
||||||
//! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
|
//! S->Value( U, V) = gp_Pnt( U, V, Z(U,V) );
|
||||||
Standard_EXPORT void Interpolate (const TColStd_Array2OfReal& ZPoints, const Standard_Real X0, const Standard_Real dX, const Standard_Real Y0, const Standard_Real dY);
|
|
||||||
|
Standard_EXPORT void Interpolate (const TColStd_Array2OfReal& ZPoints,
|
||||||
|
const Standard_Real X0, const Standard_Real dX, const Standard_Real Y0, const Standard_Real dY);
|
||||||
|
|
||||||
//! Approximates a BSpline Surface passing through an
|
//! Approximates a BSpline Surface passing through an
|
||||||
//! array of Point. The resulting BSpline will have
|
//! array of Point. The resulting BSpline will have
|
||||||
@ -162,18 +222,27 @@ public:
|
|||||||
//! 1- his degree will be in the range [Degmin,Degmax]
|
//! 1- his degree will be in the range [Degmin,Degmax]
|
||||||
//! 2- his continuity will be at least <Continuity>
|
//! 2- his continuity will be at least <Continuity>
|
||||||
//! 3- the distance from the point <Points> to the
|
//! 3- the distance from the point <Points> to the
|
||||||
//! BSpline will be lower to Tol3D
|
//! BSpline will be lower to Tol3D.
|
||||||
Standard_EXPORT void Init (const TColgp_Array2OfPnt& Points, const Approx_ParametrizationType ParType, const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
|
|
||||||
|
Standard_EXPORT void Init (const TColgp_Array2OfPnt& Points,
|
||||||
|
const Approx_ParametrizationType ParType,
|
||||||
|
const Standard_Integer DegMin = 3, const Standard_Integer DegMax = 8,
|
||||||
|
const GeomAbs_Shape Continuity = GeomAbs_C2,
|
||||||
|
const Standard_Real Tol3D = 1.0e-3, const Standard_Boolean thePeriodic = Standard_False);
|
||||||
|
|
||||||
//! Approximates a BSpline Surface passing through an
|
//! Approximates a BSpline Surface passing through an
|
||||||
//! array of point using variational smoothing algorithm,
|
//! array of point using variational smoothing algorithm,
|
||||||
//! which tries to minimize additional criterium:
|
//! which tries to minimize additional criterium:
|
||||||
//! Weight1*CurveLength + Weight2*Curvature + Weight3*Torsion
|
//! Weight1*CurveLength + Weight2*Curvature + Weight3*Torsion.
|
||||||
Standard_EXPORT void Init (const TColgp_Array2OfPnt& Points, const Standard_Real Weight1, const Standard_Real Weight2, const Standard_Real Weight3, const Standard_Integer DegMax = 8, const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
|
|
||||||
|
Standard_EXPORT void Init (const TColgp_Array2OfPnt& Points,
|
||||||
|
const Standard_Real Weight1, const Standard_Real Weight2, const Standard_Real Weight3,
|
||||||
|
const Standard_Integer DegMax = 8,
|
||||||
|
const GeomAbs_Shape Continuity = GeomAbs_C2, const Standard_Real Tol3D = 1.0e-3);
|
||||||
|
|
||||||
//! Returns the approximate BSpline Surface
|
//! Returns the approximate BSpline Surface
|
||||||
Standard_EXPORT const Handle(Geom_BSplineSurface)& Surface() const;
|
Standard_EXPORT const Handle(Geom_BSplineSurface)& Surface() const;
|
||||||
Standard_EXPORT operator Handle(Geom_BSplineSurface)() const;
|
Standard_EXPORT operator Handle(Geom_BSplineSurface)() const;
|
||||||
|
|
||||||
Standard_EXPORT Standard_Boolean IsDone() const;
|
Standard_EXPORT Standard_Boolean IsDone() const;
|
||||||
|
|
||||||
|
@ -590,6 +590,7 @@ GeomFill_NSections::GeomFill_NSections(const TColGeom_SequenceOfCurve& NC,
|
|||||||
Standard_Integer nbIt = 0, degmin = 2, degmax = 6;
|
Standard_Integer nbIt = 0, degmin = 2, degmax = 6;
|
||||||
Standard_Boolean knownP = Nbpar > 0;
|
Standard_Boolean knownP = Nbpar > 0;
|
||||||
GeomFill_AppSurf anApprox(degmin, degmax, myPres3d, myPres3d, nbIt, knownP);
|
GeomFill_AppSurf anApprox(degmin, degmax, myPres3d, myPres3d, nbIt, knownP);
|
||||||
|
anApprox.SetContinuity(GeomAbs_C1);
|
||||||
Standard_Boolean SpApprox = Standard_True;
|
Standard_Boolean SpApprox = Standard_True;
|
||||||
anApprox.Perform(line, section, SpApprox);
|
anApprox.Perform(line, section, SpApprox);
|
||||||
|
|
||||||
|
@ -117,6 +117,12 @@ public:
|
|||||||
//! changes the first and the last constraint points.
|
//! changes the first and the last constraint points.
|
||||||
Standard_EXPORT void SetConstraints (const AppParCurves_Constraint firstC, const AppParCurves_Constraint lastC);
|
Standard_EXPORT void SetConstraints (const AppParCurves_Constraint firstC, const AppParCurves_Constraint lastC);
|
||||||
|
|
||||||
|
//! Sets periodic flag.
|
||||||
|
//! If thePeriodic = Standard_True, algorith tries to build periodic
|
||||||
|
//! multicurve using corresponding C1 boundary condition for first and last multipoints.
|
||||||
|
//! Multiline must be closed.
|
||||||
|
Standard_EXPORT void SetPeriodic(const Standard_Boolean thePeriodic);
|
||||||
|
|
||||||
//! returns False if at a moment of the approximation,
|
//! returns False if at a moment of the approximation,
|
||||||
//! the status NoApproximation has been sent by the user
|
//! the status NoApproximation has been sent by the user
|
||||||
//! when more points were needed.
|
//! when more points were needed.
|
||||||
@ -199,6 +205,7 @@ private:
|
|||||||
Standard_Integer mycont;
|
Standard_Integer mycont;
|
||||||
Standard_Real mylambda1;
|
Standard_Real mylambda1;
|
||||||
Standard_Real mylambda2;
|
Standard_Real mylambda2;
|
||||||
|
Standard_Boolean myPeriodic;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -286,50 +286,176 @@ static Standard_Integer grilapp(Draw_Interpretor& di, Standard_Integer n, const
|
|||||||
|
|
||||||
static Standard_Integer surfapp(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
static Standard_Integer surfapp(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||||
{
|
{
|
||||||
if ( n < 5 ) return 1;
|
if (n < 5) return 1;
|
||||||
|
|
||||||
Standard_Integer i,j;
|
Standard_Integer i, j;
|
||||||
Standard_Integer Nu = Draw::Atoi(a[2]);
|
Standard_Integer Nu = Draw::Atoi(a[2]);
|
||||||
Standard_Integer Nv = Draw::Atoi(a[3]);
|
Standard_Integer Nv = Draw::Atoi(a[3]);
|
||||||
TColgp_Array2OfPnt Points (1, Nu, 1, Nv);
|
TColgp_Array2OfPnt Points(1, Nu, 1, Nv);
|
||||||
|
Standard_Boolean IsPeriodic = Standard_False;
|
||||||
|
Standard_Boolean RemoveLast = Standard_False;
|
||||||
|
|
||||||
if ( n == 5) {
|
if (n >= 5 && n <= 6) {
|
||||||
Handle(Geom_Surface) Surf = DrawTrSurf::GetSurface(a[4]);
|
Handle(Geom_Surface) Surf = DrawTrSurf::GetSurface(a[4]);
|
||||||
if ( Surf.IsNull()) return 1;
|
if (Surf.IsNull()) return 1;
|
||||||
|
|
||||||
Standard_Real U, V, U1, V1, U2, V2;
|
Standard_Real U, V, U1, V1, U2, V2;
|
||||||
Surf->Bounds( U1, U2, V1, V2);
|
Surf->Bounds(U1, U2, V1, V2);
|
||||||
for ( j = 1; j <= Nv; j++) {
|
for (j = 1; j <= Nv; j++) {
|
||||||
V = V1 + (j-1) * (V2-V1) / (Nv-1);
|
V = V1 + (j - 1) * (V2 - V1) / (Nv - 1);
|
||||||
for ( i = 1; i <= Nu; i++) {
|
for (i = 1; i <= Nu; i++) {
|
||||||
U = U1 + (i-1) * (U2-U1) / (Nu-1);
|
U = U1 + (i - 1) * (U2 - U1) / (Nu - 1);
|
||||||
Points(i,j) = Surf->Value(U,V);
|
Points(i, j) = Surf->Value(U, V);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (n == 6)
|
||||||
|
{
|
||||||
|
Standard_Integer ip = Draw::Atoi(a[5]);
|
||||||
|
if (ip > 0) IsPeriodic = Standard_True;
|
||||||
|
}
|
||||||
|
if (IsPeriodic)
|
||||||
|
{
|
||||||
|
for (j = 1; j <= Nv; j++)
|
||||||
|
{
|
||||||
|
Standard_Real d = Points(1, j).Distance(Points(Nu, j));
|
||||||
|
if (d <= Precision::Confusion())
|
||||||
|
{
|
||||||
|
RemoveLast = Standard_True;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( n >= 16) {
|
else if (n >= 16) {
|
||||||
Standard_Integer Count = 4;
|
Standard_Integer Count = 4;
|
||||||
for ( j = 1; j <= Nv; j++) {
|
for (j = 1; j <= Nv; j++) {
|
||||||
for ( i = 1; i <= Nu; i++) {
|
for (i = 1; i <= Nu; i++) {
|
||||||
if ( Count > n) return 1;
|
if (Count > n) return 1;
|
||||||
Points(i,j) = gp_Pnt(Draw::Atof(a[Count]),Draw::Atof(a[Count+1]),Draw::Atof(a[Count+2]));
|
Points(i, j) = gp_Pnt(Draw::Atof(a[Count]), Draw::Atof(a[Count + 1]), Draw::Atof(a[Count + 2]));
|
||||||
Count += 3;
|
Count += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char name[100];
|
char name[100];
|
||||||
Standard_Integer Count = 1;
|
Standard_Integer Count = 1;
|
||||||
for ( j = 1; j <= Nv; j++) {
|
for (j = 1; j <= Nv; j++) {
|
||||||
for ( i = 1; i <= Nu; i++) {
|
for (i = 1; i <= Nu; i++) {
|
||||||
Sprintf(name,"point_%d",Count++);
|
Sprintf(name, "point_%d", Count++);
|
||||||
char* temp = name; // portage WNT
|
char* temp = name; // portage WNT
|
||||||
DrawTrSurf::Set(temp,Points(i,j));
|
DrawTrSurf::Set(temp, Points(i, j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(Geom_BSplineSurface) S = GeomAPI_PointsToBSplineSurface(Points);
|
GeomAPI_PointsToBSplineSurface anApprox;
|
||||||
DrawTrSurf::Set(a[1],S);
|
if (RemoveLast)
|
||||||
di << a[1];
|
{
|
||||||
|
TColgp_Array2OfPnt Points1(1, Nu - 1, 1, Nv);
|
||||||
|
for (j = 1; j <= Nv; j++)
|
||||||
|
{
|
||||||
|
for (i = 1; i <= Nu - 1; i++) {
|
||||||
|
Points1(i, j) = Points(i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
anApprox.Init(Points1, Approx_ChordLength, 3, 8, GeomAbs_C2, 1.e-3, IsPeriodic);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
anApprox.Init(Points, Approx_ChordLength, 3, 8, GeomAbs_C2, 1.e-3, IsPeriodic);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (anApprox.IsDone())
|
||||||
|
{
|
||||||
|
Handle(Geom_BSplineSurface) S = anApprox.Surface();
|
||||||
|
DrawTrSurf::Set(a[1], S);
|
||||||
|
di << a[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : surfint
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
static Standard_Integer surfint(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||||
|
{
|
||||||
|
if (n < 5) return 1;
|
||||||
|
|
||||||
|
Handle(Geom_Surface) Surf = DrawTrSurf::GetSurface(a[2]);
|
||||||
|
if (Surf.IsNull()) return 1;
|
||||||
|
Standard_Integer i, j;
|
||||||
|
Standard_Integer Nu = Draw::Atoi(a[3]);
|
||||||
|
Standard_Integer Nv = Draw::Atoi(a[4]);
|
||||||
|
TColgp_Array2OfPnt Points(1, Nu, 1, Nv);
|
||||||
|
|
||||||
|
Standard_Real U, V, U1, V1, U2, V2;
|
||||||
|
Surf->Bounds(U1, U2, V1, V2);
|
||||||
|
for (j = 1; j <= Nv; j++) {
|
||||||
|
V = V1 + (j - 1) * (V2 - V1) / (Nv - 1);
|
||||||
|
for (i = 1; i <= Nu; i++) {
|
||||||
|
U = U1 + (i - 1) * (U2 - U1) / (Nu - 1);
|
||||||
|
Points(i, j) = Surf->Value(U, V);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char name[100];
|
||||||
|
Standard_Integer Count = 1;
|
||||||
|
for (j = 1; j <= Nv; j++) {
|
||||||
|
for (i = 1; i <= Nu; i++) {
|
||||||
|
Sprintf(name, "point_%d", Count++);
|
||||||
|
char* temp = name; // portage WNT
|
||||||
|
DrawTrSurf::Set(temp, Points(i, j));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_Boolean IsPeriodic = Standard_False;
|
||||||
|
if (n > 5)
|
||||||
|
{
|
||||||
|
Standard_Integer ip = Draw::Atoi(a[5]);
|
||||||
|
if (ip > 0) IsPeriodic = Standard_True;
|
||||||
|
}
|
||||||
|
Standard_Boolean RemoveLast = Standard_False;
|
||||||
|
if (IsPeriodic)
|
||||||
|
{
|
||||||
|
for (j = 1; j <= Nv; j++)
|
||||||
|
{
|
||||||
|
Standard_Real d = Points(1, j).Distance(Points(Nu, j));
|
||||||
|
if (d <= Precision::Confusion())
|
||||||
|
{
|
||||||
|
RemoveLast = Standard_True;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const Approx_ParametrizationType ParType = Approx_ChordLength;
|
||||||
|
GeomAPI_PointsToBSplineSurface anApprox;
|
||||||
|
if (RemoveLast)
|
||||||
|
{
|
||||||
|
TColgp_Array2OfPnt Points1(1, Nu-1, 1, Nv);
|
||||||
|
for (j = 1; j <= Nv; j++)
|
||||||
|
{
|
||||||
|
for (i = 1; i <= Nu-1; i++) {
|
||||||
|
Points1(i, j) = Points(i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
anApprox.Interpolate(Points1, ParType, IsPeriodic);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
anApprox.Interpolate(Points, ParType, IsPeriodic);
|
||||||
|
}
|
||||||
|
if (anApprox.IsDone())
|
||||||
|
{
|
||||||
|
Handle(Geom_BSplineSurface) S = anApprox.Surface();
|
||||||
|
DrawTrSurf::Set(a[1], S);
|
||||||
|
di << a[1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
di << "Interpolation not done \n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -634,6 +760,11 @@ void GeometryTest::APICommands(Draw_Interpretor& theCommands)
|
|||||||
theCommands.Add("surfapp","surfapp result nbupoint nbvpoint x y z ....",
|
theCommands.Add("surfapp","surfapp result nbupoint nbvpoint x y z ....",
|
||||||
__FILE__,
|
__FILE__,
|
||||||
surfapp);
|
surfapp);
|
||||||
|
|
||||||
|
theCommands.Add("surfint", "surfint result surf nbupoint nbvpoint [uperiodic]",
|
||||||
|
__FILE__,
|
||||||
|
surfint);
|
||||||
|
|
||||||
theCommands.Add("grilapp",
|
theCommands.Add("grilapp",
|
||||||
"grilapp result nbupoint nbvpoint X0 dX Y0 dY z11 z12 .. z1nu .... ",
|
"grilapp result nbupoint nbvpoint X0 dX Y0 dY z11 z12 .. z1nu .... ",
|
||||||
__FILE__,grilapp);
|
__FILE__,grilapp);
|
||||||
|
@ -779,7 +779,6 @@ static Standard_Integer OCC606 ( Draw_Interpretor& di, Standard_Integer n, const
|
|||||||
{
|
{
|
||||||
OCC_CATCH_SIGNALS
|
OCC_CATCH_SIGNALS
|
||||||
GeomFill_NSections b_surface1(n_curves1, np);
|
GeomFill_NSections b_surface1(n_curves1, np);
|
||||||
b_surface1.ComputeSurface();
|
|
||||||
Handle(Geom_BSplineSurface) result_surf1 = b_surface1.BSplineSurface();
|
Handle(Geom_BSplineSurface) result_surf1 = b_surface1.BSplineSurface();
|
||||||
if (!result_surf1.IsNull())
|
if (!result_surf1.IsNull())
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ checknbshapes result -ref ${nbshapes_expected} -t -m "SECTION"
|
|||||||
regexp {Tolerance +MAX=([-0-9.+eE]+)} [tolerance result] full MaxTolerance
|
regexp {Tolerance +MAX=([-0-9.+eE]+)} [tolerance result] full MaxTolerance
|
||||||
puts "MaxTolerance=$MaxTolerance"
|
puts "MaxTolerance=$MaxTolerance"
|
||||||
|
|
||||||
set expected_MaxTolerance 4.8861510463442802e-005
|
set expected_MaxTolerance 5.0e-006
|
||||||
set tol_abs_MaxTolerance 0.0
|
set tol_abs_MaxTolerance 0.0
|
||||||
set tol_rel_MaxTolerance 0.01
|
set tol_rel_MaxTolerance 0.01
|
||||||
checkreal "MaxTolerance" ${MaxTolerance} ${expected_MaxTolerance} ${tol_abs_MaxTolerance} ${tol_rel_MaxTolerance}
|
checkreal "MaxTolerance" ${MaxTolerance} ${expected_MaxTolerance} ${tol_abs_MaxTolerance} ${tol_rel_MaxTolerance}
|
||||||
|
30
tests/bugs/modalg_7/bug30621
Normal file
30
tests/bugs/modalg_7/bug30621
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
puts "========"
|
||||||
|
puts "OCC30621"
|
||||||
|
puts "========"
|
||||||
|
puts "Implementation of building periodical surfaces by GeomAPI_PointsToBSplineSurface"
|
||||||
|
puts "========"
|
||||||
|
|
||||||
|
cylinder cc 1
|
||||||
|
trimv cc cc 0 1
|
||||||
|
surfint ri cc 11 3 1
|
||||||
|
surfapp ra 11 3 cc 1
|
||||||
|
|
||||||
|
if { [regexp "Continuity Status : C1" [surfaceCcontinuity 1 ri 0 .5 ri 1 .5]] == 1 } {
|
||||||
|
|
||||||
|
puts "OK : Good result of interpolation"
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
puts "Error : periodic interpolation fails"
|
||||||
|
|
||||||
|
}
|
||||||
|
if { [regexp "Continuity Status : C1" [surfaceCcontinuity 1 ra 0 .5 ra 1 .5]] == 1 } {
|
||||||
|
|
||||||
|
puts "OK : Good result of approximation"
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
puts "Error : periodic approximation fails"
|
||||||
|
|
||||||
|
}
|
||||||
|
checkview -display ri -with ra -2d -path ${imagedir}/${test_image}.png
|
@ -1,4 +1,4 @@
|
|||||||
puts "TODO OCC24418 ALL: Error in ii_1: T="
|
##puts "TODO OCC24418 ALL: Error in ii_1: T="
|
||||||
|
|
||||||
puts "========"
|
puts "========"
|
||||||
puts "OCC24418"
|
puts "OCC24418"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user