1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14 
15 // AppDef_MyLineTool.cxx
16 
17 #include <AppDef_MultiLine.hxx>
18 #include <AppDef_MultiPointConstraint.hxx>
19 #include <AppDef_MyLineTool.hxx>
20 #include <gp_Pnt.hxx>
21 #include <gp_Pnt2d.hxx>
22 #include <gp_Vec.hxx>
23 #include <gp_Vec2d.hxx>
24 
FirstPoint(const AppDef_MultiLine &)25 Standard_Integer AppDef_MyLineTool::FirstPoint(const AppDef_MultiLine&)
26 {
27   return 1;
28 }
29 
LastPoint(const AppDef_MultiLine & ML)30 Standard_Integer AppDef_MyLineTool::LastPoint(const AppDef_MultiLine& ML)
31 {
32   return ML.NbMultiPoints();
33 }
34 
NbP2d(const AppDef_MultiLine & ML)35 Standard_Integer AppDef_MyLineTool::NbP2d(const AppDef_MultiLine& ML)
36 {
37   return ML.Value(1).NbPoints2d();
38 }
39 
NbP3d(const AppDef_MultiLine & ML)40 Standard_Integer AppDef_MyLineTool::NbP3d(const AppDef_MultiLine& ML)
41 {
42   return ML.Value(1).NbPoints();
43 }
44 
45 
Value(const AppDef_MultiLine & ML,const Standard_Integer MPointIndex,TColgp_Array1OfPnt & tabPt)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 
Value(const AppDef_MultiLine & ML,const Standard_Integer MPointIndex,TColgp_Array1OfPnt2d & tabPt2d)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);
62   Standard_Integer nbp3d = MPC.NbPoints();
63   Standard_Integer nbp2d = MPC.NbPoints2d();
64   Standard_Integer low = tabPt2d.Lower();
65   for (Standard_Integer i = 1; i <= nbp2d; i++) {
66     tabPt2d(i+low-1) = MPC.Point2d(nbp3d+i);
67   }
68 }
69 
Value(const AppDef_MultiLine & ML,const Standard_Integer MPointIndex,TColgp_Array1OfPnt & tabPt,TColgp_Array1OfPnt2d & tabPt2d)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 
Tangency(const AppDef_MultiLine & ML,const Standard_Integer MPointIndex,TColgp_Array1OfVec & tabV)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 
Tangency(const AppDef_MultiLine & ML,const Standard_Integer MPointIndex,TColgp_Array1OfVec2d & tabV2d)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);
107   if (MPC.IsTangencyPoint())
108   {
109     Standard_Integer nbp3d = MPC.NbPoints();
110     Standard_Integer nbp2d = MPC.NbPoints2d(), low = tabV2d.Lower();
111     for (Standard_Integer i = 1; i <= nbp2d; i++) {
112       tabV2d(i+low-1) = MPC.Tang2d(nbp3d+i);
113     }
114     return Standard_True;
115   }
116   else return Standard_False;
117 }
118 
Tangency(const AppDef_MultiLine & ML,const Standard_Integer MPointIndex,TColgp_Array1OfVec & tabV,TColgp_Array1OfVec2d & tabV2d)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 
MakeMLBetween(const AppDef_MultiLine & theML,const Standard_Integer,const Standard_Integer,const Standard_Integer)141 AppDef_MultiLine AppDef_MyLineTool::MakeMLBetween(const AppDef_MultiLine& theML,
142 						   const Standard_Integer ,
143 						   const Standard_Integer ,
144 						   const Standard_Integer )
145 {
146   return theML; // stub
147 }
148 
MakeMLOneMorePoint(const AppDef_MultiLine &,const Standard_Integer,const Standard_Integer,const Standard_Integer,AppDef_MultiLine &)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 
WhatStatus(const AppDef_MultiLine &,const Standard_Integer,const Standard_Integer)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 
Curvature(const AppDef_MultiLine & ML,const Standard_Integer MPointIndex,TColgp_Array1OfVec & tabV)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 
Curvature(const AppDef_MultiLine & ML,const Standard_Integer MPointIndex,TColgp_Array1OfVec2d & tabV2d)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);
186   if (MPC.IsCurvaturePoint())
187   {
188     Standard_Integer nbp3d = MPC.NbPoints();
189     Standard_Integer nbp2d = MPC.NbPoints2d(), low = tabV2d.Lower();
190     for (Standard_Integer i = 1; i <= nbp2d; i++) {
191       tabV2d(i+low-1) = MPC.Curv2d(nbp3d+i);
192     }
193     return Standard_True;
194   }
195   else return Standard_False;
196 }
197 
198 
Curvature(const AppDef_MultiLine & ML,const Standard_Integer MPointIndex,TColgp_Array1OfVec & tabV,TColgp_Array1OfVec2d & tabV2d)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 
222