DiscussionsIssue archiveOCCT:Modeling Data

Archived issue #0029745

Modeling Data - GeomAdaptor_Surface::VIntervals fails on periodic surfaces

CommunityOCCT:Modeling Dataclosed143 public notes

Search issues

Description

Suppose:
_ we have a V periodic NURBS Surface;
_ we have a GeomAdaptor_Surface with V limits outside of the period;
_ the surface has discontinuities;
_ we call GeomAdaptor_Surface::VIntervals to get a list of continuous subintervals.

That method will build an U iso-curve and get such intervals on that; at the end, however, that intervals are bounded with:
  T(T.Lower()) = myVFirst;
  T(T.Lower() + myNbVIntervals) = myVLast;

The problem arises since the value returned by the curve Intervals(...) method will be within the period, so those values will be invalid.


Example:
_ surface with periodic V knot vector ranging [0 ; 4];
_ surface adaptor with limits [5 ; 6].
_ Intervals(...) on the ISO curve returns [1,2,3];
_ the statements reported above will transform the result in [5,2,6].

This will lead to a crash in subsequent processing.



A solution along the line of the following might work:
  if (mySurface->IsVPeriodic())
    for (Standard_Integer i=T.Lower()+1;i<T.Lower()+myNbVIntervals;++i)
      T(i)+=myVFirst-T(T.Lower());
  T(T.Lower()) = myVFirst;
  T(T.Lower() + myNbVIntervals) = myVLast;


Notice the problem should also occur in U direction.

Steps to reproduce

QAcommand:
OCC29745 bc1 1 0 12

Public activity

143 archived notes

Participants are labeled by their role within this record.

01Commenter 2
Dear Author, can you attach more detailed steps to reproduce current bug, because according to this description it is hard to reproduce it
02Author
TL;DR
Changes made in 7.4.0 prevent this bug from happening again.
However, I'm not sure the new result is correct either.



The problem arose while importint a STeP model and I'm having an hard time reproducing it programmatically (even with 7.3.0).

In any case, please take a look at the following code:
  TColgp_Array2OfPnt Poles(1,2,1,3);
  Poles(1,1)=gp_Pnt(0,0,0); Poles(2,1)=gp_Pnt(0,0,1);
  Poles(1,2)=gp_Pnt(1,0,0); Poles(2,2)=gp_Pnt(1,0,1);
  Poles(1,3)=gp_Pnt(1,1,0); Poles(2,3)=gp_Pnt(1,1,1);
  //Poles(1,4)=gp_Pnt(0,0,0); Poles(2,4)=gp_Pnt(0,0,1);
  TColStd_Array1OfReal UKnots(1,2),VKnots(1,4),ResultsA(1,4),ResultsB(1,4);
  UKnots(1)=0; UKnots(2)=1;
  VKnots(1)=0; VKnots(2)=1; VKnots(3)=2; VKnots(4)=3;
  TColStd_Array1OfInteger UMult(1,2),VMult(1,4);
  UMult(1)=2; UMult(2)=2;
  VMult(1)=1; VMult(2)=1; VMult(3)=1; VMult(4)=1;
  Handle(Geom_BSplineSurface) S=new Geom_BSplineSurface(Poles,UKnots,VKnots,UMult,VMult,1,1,false,true);
  GeomAdaptor_Surface A(S,0,1,0,3);
  A.VIntervals(ResultsA,GeomAbs_C1);
  for (TColStd_Array1OfReal::const_iterator i(ResultsA.begin());i!=ResultsA.end();++i) std::cout<<*i<<" ";
  std::cout<<std::endl;
  GeomAdaptor_Surface B(S,0,1,3,6);
  B.VIntervals(ResultsB,GeomAbs_C1);
  for (TColStd_Array1OfReal::const_iterator i(ResultsB.begin());i!=ResultsB.end();++i) std::cout<<*i<<" ";
  std::cout<<std::endl;

Output I'd expect (but possibly I'm wrong):
0 1 2 3
3 4 5 6

Output I get (with OC 7.3.0):
0 1 2 3
3 6 0 0

Notice here two values are missing.
This is not the original problem I reported and which I'm unable to reproduce now: in that case what I was getting in the second line was the equivalent of 3 1 2 6.



7.4.0 changed this behaviour: at line 441 of GeomAdaptor_Surface.cxx, "break" was replaces with a "return".
So the code at the end of the function, that changes only the first and last value, is not executed, and what I originally reported cannot happen anymore.

Still I'm wondering whether "3 6" is to be expected or if we just exchanged a bug for another.
03Commenter 2
Fixed GeomAdaptor_Curve::LocalContinuity() for periodic surface
04Commenter 3
Branch [archived branch] has been updated by Commenter 2.

[revision removed]


Detailed log of new commits:

Author: Commenter 2
Date: Thu Jan 28 14:12:53 2021 +0300

    Fixed GeomAdaptor_Curve::NbIntervals() method to periodic curves

05Commenter 2
For previous commit
06Commenter 2
Debbuging
07Commenter 3
Branch [archived branch] has been updated forcibly by Commenter 2.

[revision removed]
08Commenter 2
Fixed GeomAdaptor_Curve::Intervals() method to periodic curves
09Commenter 3
Branch [archived branch] has been updated forcibly by Commenter 2.

[revision removed]
10Commenter 3
Branch [archived branch] has been updated by Commenter 2.

[revision removed]


Detailed log of new commits:

Author: Commenter 2
Date: Fri Feb 5 11:44:33 2021 +0300

    some fixes for negative intervals

Author: Commenter 2
Date: Thu Feb 4 15:17:42 2021 +0300

    delete bad definition

11Commenter 3
Branch [archived branch] has been updated by Commenter 2.

[revision removed]


Detailed log of new commits:

Author: Commenter 2
Date: Fri Feb 5 16:54:21 2021 +0300

    Change definition of local continuity only within one period

12Commenter 2
Analyzing results and fixing regressions
13Commenter 2
Debuging
14Commenter 3
Branch [archived branch] has been created by Commenter 2.

[revision removed]


Detailed log of new commits:

Author: Commenter 2
Date: Fri Jan 15 10:50:18 2021 +0300

    0029745: Modeling Data - GeomAdaptor_Surface::VIntervals fails on periodic surfaces
    
    Fixed GeomAdaptor_Curve::LocalContinuity() for periodic surface within one period
    Fixed GeomAdaptor_Curve::NbIntervals() method to periodic curves
    Fixed GeomAdaptor_Curve::Intervals() method to periodic curves
15Commenter 3
Branch [archived branch] has been updated forcibly by Commenter 2.

[revision removed]
16Commenter 16
Dear Andrey, I think that Geom2dAdaptor_Curve should be modified too in order to have the same behaviour for 2d and 3d curves. In general, codes for 2d and 3d cases must be practically the same, because works only with 1d parameters of splines, so think about using any template approach.
17Commenter 17
Review
18Commenter 3
Branch [archived branch] has been created by Commenter 2.

[revision removed]


Detailed log of new commits:

Author: Commenter 2
Date: Fri Jan 15 10:50:18 2021 +0300

    update tests
    
    change test
    
    0029745: Modeling Data - GeomAdaptor_Surface::VIntervals fails on periodic surfaces
    
    Fixed GeomAdaptor_Curve::LocalContinuity() for periodic surface within one period.
    Fixed GeomAdaptor_Curve::NbIntervals() method to periodic curves.
    Fixed GeomAdaptor_Curve::Intervals() method to periodic curves.
    Deleted definition of length from tests.
    Update Geom2dAdaptor_Curve to the same behavior.
19Commenter 3
Branch [archived branch] has been updated forcibly by Commenter 2.

[revision removed]
20Commenter 3
Branch [archived branch] has been updated forcibly by Commenter 2.

[revision removed]
21Commenter 2
Branch for review:
OCCT - CR29745_2
22Commenter 2
23Commenter 23
Fix seems to be wrong because it does not provide correct results if trim interval crosses boundary between sequential periodic intervals.
24Commenter 3
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: Commenter 1
Date: Thu Nov 11 05:55:32 2021 +0300

    0029745: Modeling Algorithms - GeomAdaptor_Surface::VIntervals fails on periodic surfaces
    
    Fixed GeomAdaptor_Curve::LocalContinuity() for periodic surface;
    Fixed GeomAdaptor_Curve::NbIntervals() method for periodic curves
25Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
26Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
27Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
28Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
29Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
30Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
31Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
32Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
33Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
34Commenter 34
Analyzing results and fixing regressions
35Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
36Commenter 36
Debuging
37Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
38Commenter 38
Analyzing results and fixing regressions
39Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
40Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
41Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
42Commenter 42
Testing
43Commenter 3
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: Commenter 1
Date: Wed Dec 15 01:58:57 2021 +0300

    0029745: Modeling Data - GeomAdaptor_Surface::VIntervals fails on periodic surfaces
    Fixed GeomAdaptor_Curve::LocalContinuity() for periodic curves.
    Fixed GeomAdaptor_Curve::NbIntervals() for periodic curves.
    Fixed GeomAdaptor_Curve::Intervals() for periodic curves.
    Deleted definition of length from tests.
44Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
45Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
46Commenter 46
Analyzing results and fixing regressions
47Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
48Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
49Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
50Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
51Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
52Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
53Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
54Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
55Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
56Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
57Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
58Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
59Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
60Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
61Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
62Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
63Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
64Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
65Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
66Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
67Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
68Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
69Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
70Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
71Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
72Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
73Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
74Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
75Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
76Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
77Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
78Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
79Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
80Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
81Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
82Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
83Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
84Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
85Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
86Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
87Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
88Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
89Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
90Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
91Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
92Commenter 92
Branch for review:
OCCT - CR29745_4

Results of testing:
http://jenkins-test-occt/view/CR29745_4-master-abulychev-ext/
93Commenter 4
Dear Commenter 4, algorithm seems to have a bug. I wrote Draw command "intervals", and two test curves (bc and bc1) with C0 knot inside knots:
for example, bc1 has degree 7 and knots:
   1 : 0 7
   2 : 0.2 6
   3 : 0.4 5
   4 : 0.5 7
   5 : 0.6 4
   6 : 0.8 3
   7 : 1 7
C0 knot is .5
Syntax of command is "intervals curve2d/3d continuity t1 t2"
For searching C1 intervals inside parametric interval [0, 1] result is correct;
Draw[94]> intervals bc1 1 0 1
NbIntervals = 2
0
0.5
1
For searching intervals on shifted parametric interval [0.1, 1.1] result is wrong:
Draw[96]> intervals bc1 1 0.1 1.1
NbIntervals = 1
0.10000000000000001
1.1000000000000001

I would like you to include "intervals" in GeometryTest_CurveCommand.cxx and use it instead of your useless test command OCC29745.
bc, bc1, intervals.cxx are attached.
94Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
95Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
96Commenter 98
bug29745_2 (1,292 bytes)   
bug29745_1 (238 bytes)   
97Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
98Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
99Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
100Commenter 5
@abulychev, (next time?) please consider splitting cosmetic changes into a separate commit / bug, so that logical changes will be more clear in diff.
If you see some existing legacy code improperly formatted - it is preferred creating a separate issue in "Coding" category; auto-formatting tools might be also helpful (when used with correct rules and with caution).
101Commenter 103
Algorithm seems still has bugs:
if we change knots for curve bc (attached in my previous note), new knot array is:
   1 : 1 1
   2 : 3.0943951023932 1
   3 : 5.18879020478639 2
   4 : 7.28318530717959 1
we can have strange result of test command OCC29745:
Draw[20]> OCC29745 bc 1 0 8
NbIntervals: 3; 0 1 5.1887902047863896 7.2831853071795898 8
NbIntervals, which is calculated by method GeomAdaptor_Curve::NbIntervals(...) is wrong, because method Intervals(...) really generates 4 intervals.
Besides, method Intervals(...) resizes input array, which initially was created as Array(1, 4). It is looks like side effect and not specified for this method.
Small remarks for OCC29745:
    theDI << "Usage : intervals curve2d/3d continuity t1 t2"; - it is wrong
  theCommands.Add("OCC29745", "GeomAdaptor_Surface::VIntervals fails on periodic surfaces",
    __FILE__, OCC29745, group);
wrong help string.
102Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
103Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
104Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
105Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
106Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
107Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
108Commenter 110
Dear ifv, remarks fixed. Branch ready for review. Results of testing: http://jenkins-test-occt/view/CR29745_4-master-abulychev-ext/
109Commenter 4
Dear Commenter 4, explain please why there is special treatment of 2*pi in method DefinPeriods (see lines 324-328). As far as could understand, this method must work with any values of curve periods and 2pi is no different from the other values.

Method WriteIntervals still has resizing input array. This is unacceptable in method Intervals(...), as I wrote in my previous remarks.
Typical using these method in many CASCADE algorithms is something like that:
NbIntervals = Curve->NbIntervals(Cont);
Array TIntervals(1, NbIntervals+1);
Curve->Intervals(TIntervals, Cont);
for(i = 1; i <= NbIntrervals; ++i)
{
  //Treatment i-th Interval
}
As you can see, NbIntervals is used in loop, but not TIntrervals.Upper(), If really TIntervals.Upper()-1 > NbIntervals, some intervals are not treated.
Do you understand?
110Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
111Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
112Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
113Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
114Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
115Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
116Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
117Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
118Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
119Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
120Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
121Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
122Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
123Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
124Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
125Commenter 6
Dear Commenter 6, please check my fixes.
Remarks fixed. The WriteIntervals method doesn't have resizing of the input array now. Extra code has been removed. Branch for check: CR29745_4.
Results of testing: http://jenkins-test-occt/view/CR29745_4-master-abulychev-ext/
126Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
127Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
128Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
129Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
130Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
131Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
132Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
133Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
134Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
135Commenter 3
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
136Commenter 138
Branch for review:
OCCT - CR29745_4

Results of testing:
http://jenkins-test-occt/view/CR29745_4-master-abulychev-ext/
137Commenter 139
Branch CR29745_4 seems to be valid

Branch for integration:
OCCT - CR29745_4
Products - not
138Commenter 140
Combination -
OCCT branch : [archived branch]
master SHA - [revision removed]
[revision removed]
Products branch : [archived branch] SHA - [revision removed]
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 18490.900000000318 / 18508.35000000038 [-0.09%]
Products
Total CPU difference: 11719.920000000124 / 11705.520000000122 [+0.12%]
Windows-64-VC14:
OCCT
Total CPU difference: 20552.71875 / 20452.9375 [+0.49%]
Products
Total CPU difference: 13242.609375 / 13195.0 [+0.36%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
139Commenter 3
Branch [archived branch] has been deleted by Commenter 5.

[revision removed]
140Commenter 3
Branch [archived branch] has been deleted by Commenter 5.

[revision removed]
141Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]
142Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]
143Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]