b311480e |
1 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
b311480e |
14 | |
7fd59977 |
15 | // AppDef_MyLineTool.cxx |
7fd59977 |
16 | |
42cf5bc1 |
17 | #include <AppDef_MultiLine.hxx> |
7fd59977 |
18 | #include <AppDef_MultiPointConstraint.hxx> |
42cf5bc1 |
19 | #include <AppDef_MyLineTool.hxx> |
7fd59977 |
20 | #include <gp_Pnt.hxx> |
21 | #include <gp_Pnt2d.hxx> |
22 | #include <gp_Vec.hxx> |
23 | #include <gp_Vec2d.hxx> |
24 | |
25 | Standard_Integer AppDef_MyLineTool::FirstPoint(const AppDef_MultiLine&) |
26 | { |
27 | return 1; |
28 | } |
29 | |
30 | Standard_Integer AppDef_MyLineTool::LastPoint(const AppDef_MultiLine& ML) |
31 | { |
32 | return ML.NbMultiPoints(); |
33 | } |
34 | |
35 | Standard_Integer AppDef_MyLineTool::NbP2d(const AppDef_MultiLine& ML) |
36 | { |
37 | return ML.Value(1).NbPoints2d(); |
38 | } |
39 | |
40 | Standard_Integer AppDef_MyLineTool::NbP3d(const AppDef_MultiLine& ML) |
41 | { |
42 | return ML.Value(1).NbPoints(); |
43 | } |
44 | |
45 | |
46 | void AppDef_MyLineTool::Value(const AppDef_MultiLine& ML, |
47 | const Standard_Integer MPointIndex, |
48 | TColgp_Array1OfPnt& tabPt) |
49 | { |
50 | AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex); |
51 | Standard_Integer nbp3d = MPC.NbPoints(), low = tabPt.Lower(); |
52 | for (Standard_Integer i = 1; i <= nbp3d; i++) { |
53 | tabPt(i+low-1) = MPC.Point(i); |
54 | } |
55 | } |
56 | |
57 | void AppDef_MyLineTool::Value(const AppDef_MultiLine& ML, |
58 | const Standard_Integer MPointIndex, |
59 | TColgp_Array1OfPnt2d& tabPt2d) |
60 | { |
61 | AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex); |
2c26a53d |
62 | Standard_Integer nbp3d = MPC.NbPoints(); |
63 | Standard_Integer nbp2d = MPC.NbPoints2d(); |
64 | Standard_Integer low = tabPt2d.Lower(); |
7fd59977 |
65 | for (Standard_Integer i = 1; i <= nbp2d; i++) { |
2c26a53d |
66 | tabPt2d(i+low-1) = MPC.Point2d(nbp3d+i); |
7fd59977 |
67 | } |
68 | } |
69 | |
70 | void AppDef_MyLineTool::Value(const AppDef_MultiLine& ML, |
71 | const Standard_Integer MPointIndex, |
72 | TColgp_Array1OfPnt& tabPt, |
73 | TColgp_Array1OfPnt2d& tabPt2d) |
74 | { |
75 | AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex); |
76 | Standard_Integer i, nbp2d = MPC.NbPoints2d(), low2d = tabPt2d.Lower(); |
77 | Standard_Integer nbp3d = MPC.NbPoints(), low = tabPt.Lower(); |
78 | for (i = 1; i <= nbp3d; i++) { |
79 | tabPt(i+low-1) = MPC.Point(i); |
80 | } |
81 | for (i = 1; i <= nbp2d; i++) { |
82 | tabPt2d(i+low2d-1) = MPC.Point2d(nbp3d+i); |
83 | } |
84 | } |
85 | |
86 | |
87 | Standard_Boolean AppDef_MyLineTool::Tangency(const AppDef_MultiLine& ML, |
88 | const Standard_Integer MPointIndex, |
89 | TColgp_Array1OfVec& tabV) |
90 | { |
91 | AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex); |
92 | if (MPC.IsTangencyPoint()) { |
93 | Standard_Integer nbp3d = MPC.NbPoints(), low = tabV.Lower(); |
94 | for (Standard_Integer i = 1; i <= nbp3d; i++) { |
95 | tabV(i+low-1) = MPC.Tang(i); |
96 | } |
97 | return Standard_True; |
98 | } |
99 | else return Standard_False; |
100 | } |
101 | |
102 | Standard_Boolean AppDef_MyLineTool::Tangency(const AppDef_MultiLine& ML, |
103 | const Standard_Integer MPointIndex, |
104 | TColgp_Array1OfVec2d& tabV2d) |
105 | { |
106 | AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex); |
2c26a53d |
107 | if (MPC.IsTangencyPoint()) |
108 | { |
109 | Standard_Integer nbp3d = MPC.NbPoints(); |
7fd59977 |
110 | Standard_Integer nbp2d = MPC.NbPoints2d(), low = tabV2d.Lower(); |
111 | for (Standard_Integer i = 1; i <= nbp2d; i++) { |
2c26a53d |
112 | tabV2d(i+low-1) = MPC.Tang2d(nbp3d+i); |
7fd59977 |
113 | } |
114 | return Standard_True; |
115 | } |
116 | else return Standard_False; |
117 | } |
118 | |
119 | Standard_Boolean AppDef_MyLineTool::Tangency(const AppDef_MultiLine& ML, |
120 | const Standard_Integer MPointIndex, |
121 | TColgp_Array1OfVec& tabV, |
122 | TColgp_Array1OfVec2d& tabV2d) |
123 | { |
124 | AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex); |
125 | if (MPC.IsTangencyPoint()) { |
126 | Standard_Integer i, nbp3d = MPC.NbPoints(), low = tabV.Lower(); |
127 | Standard_Integer nbp2d = MPC.NbPoints2d(), low2d = tabV2d.Lower(); |
128 | for (i = 1; i <= nbp3d; i++) { |
129 | tabV(i+low-1) = MPC.Tang(i); |
130 | } |
131 | for (i = 1; i <= nbp2d; i++) { |
132 | tabV2d(i+low2d-1) = MPC.Tang2d(nbp3d+i); |
133 | } |
134 | return Standard_True; |
135 | } |
136 | else return Standard_False; |
137 | |
138 | } |
139 | |
140 | |
8157aa28 |
141 | AppDef_MultiLine AppDef_MyLineTool::MakeMLBetween(const AppDef_MultiLine& theML, |
7fd59977 |
142 | const Standard_Integer , |
143 | const Standard_Integer , |
144 | const Standard_Integer ) |
145 | { |
8157aa28 |
146 | return theML; // stub |
7fd59977 |
147 | } |
148 | |
2c26a53d |
149 | Standard_Boolean AppDef_MyLineTool::MakeMLOneMorePoint(const AppDef_MultiLine& , |
150 | const Standard_Integer, |
151 | const Standard_Integer, |
152 | const Standard_Integer, |
153 | AppDef_MultiLine&) |
154 | { |
155 | return Standard_False; |
156 | } |
157 | |
7fd59977 |
158 | Approx_Status AppDef_MyLineTool::WhatStatus(const AppDef_MultiLine&, |
159 | const Standard_Integer, |
160 | const Standard_Integer) |
161 | { |
162 | return Approx_NoPointsAdded; |
163 | } |
164 | |
165 | |
166 | Standard_Boolean AppDef_MyLineTool::Curvature(const AppDef_MultiLine& ML, |
167 | const Standard_Integer MPointIndex, |
168 | TColgp_Array1OfVec& tabV) |
169 | { |
170 | AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex); |
171 | if (MPC.IsCurvaturePoint()) { |
172 | Standard_Integer nbp3d = MPC.NbPoints(), low = tabV.Lower(); |
173 | for (Standard_Integer i = 1; i <= nbp3d; i++) { |
174 | tabV(i+low-1) = MPC.Curv(i); |
175 | } |
176 | return Standard_True; |
177 | } |
178 | else return Standard_False; |
179 | } |
180 | |
181 | Standard_Boolean AppDef_MyLineTool::Curvature(const AppDef_MultiLine& ML, |
182 | const Standard_Integer MPointIndex, |
183 | TColgp_Array1OfVec2d& tabV2d) |
184 | { |
185 | AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex); |
2c26a53d |
186 | if (MPC.IsCurvaturePoint()) |
187 | { |
188 | Standard_Integer nbp3d = MPC.NbPoints(); |
7fd59977 |
189 | Standard_Integer nbp2d = MPC.NbPoints2d(), low = tabV2d.Lower(); |
190 | for (Standard_Integer i = 1; i <= nbp2d; i++) { |
2c26a53d |
191 | tabV2d(i+low-1) = MPC.Curv2d(nbp3d+i); |
7fd59977 |
192 | } |
193 | return Standard_True; |
194 | } |
195 | else return Standard_False; |
196 | } |
197 | |
198 | |
199 | Standard_Boolean AppDef_MyLineTool::Curvature(const AppDef_MultiLine& ML, |
200 | const Standard_Integer MPointIndex, |
201 | TColgp_Array1OfVec& tabV, |
202 | TColgp_Array1OfVec2d& tabV2d) |
203 | |
204 | { |
205 | AppDef_MultiPointConstraint MPC = ML.Value(MPointIndex); |
206 | if (MPC.IsCurvaturePoint()) { |
207 | Standard_Integer i, nbp3d = MPC.NbPoints(), low = tabV.Lower(); |
208 | Standard_Integer nbp2d = MPC.NbPoints2d(), low2d = tabV2d.Lower(); |
209 | for (i = 1; i <= nbp3d; i++) { |
210 | tabV(i+low-1) = MPC.Curv(i); |
211 | } |
212 | for (i = 1; i <= nbp2d; i++) { |
213 | tabV2d(i+low2d-1) = MPC.Curv2d(nbp3d+i); |
214 | } |
215 | return Standard_True; |
216 | } |
217 | else return Standard_False; |
218 | |
219 | } |
220 | |
221 | |