Commit | Line | Data |
---|---|---|

b311480e | 1 | -- Created on: 1993-06-24 |

2 | -- Created by: Modelistation | |

3 | -- Copyright (c) 1993-1999 Matra Datavision | |

4 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS | |

5 | -- | |

6 | -- The content of this file is subject to the Open CASCADE Technology Public | |

7 | -- License Version 6.5 (the "License"). You may not use the content of this file | |

8 | -- except in compliance with the License. Please obtain a copy of the License | |

9 | -- at http://www.opencascade.org and read it completely before using this file. | |

10 | -- | |

11 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |

12 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |

13 | -- | |

14 | -- The Original Code and all software distributed under the License is | |

15 | -- distributed on an "AS IS" basis, without warranty of any kind, and the | |

16 | -- Initial Developer hereby disclaims all such warranties, including without | |

17 | -- limitation, any warranties of merchantability, fitness for a particular | |

18 | -- purpose or non-infringement. Please see the License for the specific terms | |

19 | -- and conditions governing the rights and limitations under the License. | |

20 | ||

7fd59977 | 21 | |

22 | ||

23 | generic class Projection from AppParCurves | |

24 | (MultiLine as any; | |

25 | ToolLine as any) -- as ToolLine(MultiLine) | |

26 | ||

27 | ||

28 | ---Purpose: This algorithm uses the algorithms LeastSquare, | |

29 | -- ResConstraint and a Projection method to approximate a set | |

30 | -- of points (AppDef_MultiLine) with a minimization of the | |

31 | -- sum(square(|F(i)-Qi|)) by changing the parameter. | |

32 | ||

33 | ||

34 | ||

35 | uses Vector from math, | |

36 | MultiCurve from AppParCurves, | |

37 | HArray1OfConstraintCouple from AppParCurves | |

38 | ||

39 | ||

40 | raises OutOfRange from Standard, | |

41 | NotDone from StdFail | |

42 | ||

43 | ||

44 | private class ProLeastSquare instantiates LeastSquare from AppParCurves | |

45 | (MultiLine, ToolLine); | |

46 | ||

47 | private class ProConstraint instantiates ResolConstraint from AppParCurves | |

48 | (MultiLine, ToolLine); | |

49 | ||

50 | private class ProFunction instantiates Function from AppParCurves | |

51 | (MultiLine, ToolLine, ProLeastSquare, ProConstraint); | |

52 | ||

53 | ||

54 | is | |

55 | ||

56 | Create(SSP: MultiLine; FirstPoint, LastPoint: Integer; | |

57 | TheConstraints: HArray1OfConstraintCouple; | |

58 | Parameters: in out Vector; Deg: Integer; | |

59 | Tol3d, Tol2d: Real; NbIterations: Integer = 200) | |

60 | ---Purpose: Tries to minimize the sum (square(||Qui - Bi*Pi||)) | |

61 | -- where Pui describe the approximating Bezier curves'Poles | |

62 | -- and Qi the MultiLine points with a parameter ui. | |

63 | -- In this algorithm, the parameters ui are the unknowns. | |

64 | -- The tolerance required on this sum is given by Tol. | |

65 | -- The desired degree of the resulting curve is Deg. | |

66 | -- SSP is returned with the new parameter. | |

67 | ||

68 | returns Projection from AppParCurves; | |

69 | ||

70 | ||

71 | IsDone(me) | |

72 | ---Purpose: returns True if all has been correctly done. | |

73 | ||

74 | returns Boolean | |

75 | is static; | |

76 | ||

77 | ||

78 | Value(me) | |

79 | ---Purpose: returns all the Bezier curves approximating the | |

80 | -- MultiLine SSP after minimization of the parameter. | |

81 | ||

82 | returns MultiCurve from AppParCurves | |

83 | raises NotDone from StdFail | |

84 | is static; | |

85 | ||

86 | ||

87 | Error(me; Index: Integer) | |

88 | ---Purpose: returns the difference between the old and the new | |

89 | -- approximation. | |

90 | -- An exception is raised if NotDone. | |

91 | -- An exception is raised if Index<1 or Index>NbParameters. | |

92 | ||

93 | returns Real | |

94 | raises NotDone from StdFail, | |

95 | OutOfRange from Standard | |

96 | is static; | |

97 | ||

98 | ||

99 | MaxError3d(me) | |

100 | ---Purpose: returns the maximum difference between the old and the | |

101 | -- new approximation. | |

102 | ||

103 | returns Real | |

104 | raises NotDone from StdFail | |

105 | is static; | |

106 | ||

107 | ||

108 | MaxError2d(me) | |

109 | ---Purpose: returns the maximum difference between the old and the | |

110 | -- new approximation. | |

111 | ||

112 | returns Real | |

113 | raises NotDone from StdFail | |

114 | is static; | |

115 | ||

116 | ||

117 | AverageError(me) | |

118 | ---Purpose: returns the average error between the old and the | |

119 | -- new approximation. | |

120 | ||

121 | returns Real | |

122 | raises NotDone from StdFail | |

123 | is static; | |

124 | ||

125 | ||

126 | fields | |

127 | ||

128 | SCU: MultiCurve from AppParCurves; | |

129 | ParError: Vector from math; | |

130 | AvError: Real; | |

131 | MError3d: Real; | |

132 | MError2d: Real; | |

133 | Done: Boolean; | |

134 | ||

135 | end Projection from AppParCurves; |