b311480e |
1 | // Created on: 1999-03-09 |
2 | // Created by: Roman LYGIN |
3 | // Copyright (c) 1999-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
91322f44 |
17 | |
42cf5bc1 |
18 | #include <BRep_Tool.hxx> |
7fd59977 |
19 | #include <DBRep.hxx> |
42cf5bc1 |
20 | #include <Draw.hxx> |
21 | #include <DrawTrSurf.hxx> |
22 | #include <Geom2d_BezierCurve.hxx> |
23 | #include <Geom2d_BSplineCurve.hxx> |
24 | #include <Geom2d_Curve.hxx> |
25 | #include <Geom2d_OffsetCurve.hxx> |
26 | #include <Geom2d_TrimmedCurve.hxx> |
27 | #include <Geom_BezierCurve.hxx> |
28 | #include <Geom_BezierSurface.hxx> |
29 | #include <Geom_BSplineCurve.hxx> |
30 | #include <Geom_BSplineSurface.hxx> |
31 | #include <Geom_Curve.hxx> |
32 | #include <Geom_OffsetCurve.hxx> |
33 | #include <Geom_OffsetSurface.hxx> |
34 | #include <Geom_Plane.hxx> |
35 | #include <Geom_RectangularTrimmedSurface.hxx> |
36 | #include <Geom_Surface.hxx> |
37 | #include <Geom_SweptSurface.hxx> |
38 | #include <Geom_TrimmedCurve.hxx> |
39 | #include <GeomAbs_Shape.hxx> |
7fd59977 |
40 | #include <ShapeCustom.hxx> |
41 | #include <ShapeCustom_BSplineRestriction.hxx> |
42 | #include <ShapeCustom_RestrictionParameters.hxx> |
42cf5bc1 |
43 | #include <ShapeFix.hxx> |
44 | #include <SWDRAW.hxx> |
45 | #include <SWDRAW_ShapeCustom.hxx> |
46 | #include <TColStd_Array1OfReal.hxx> |
47 | #include <TColStd_Array2OfInteger.hxx> |
7fd59977 |
48 | #include <TopAbs.hxx> |
7fd59977 |
49 | #include <TopExp_Explorer.hxx> |
50 | #include <TopLoc_Location.hxx> |
7fd59977 |
51 | #include <TopoDS.hxx> |
42cf5bc1 |
52 | #include <TopoDS_Edge.hxx> |
53 | #include <TopoDS_Face.hxx> |
54 | #include <TopoDS_Shape.hxx> |
7fd59977 |
55 | |
56 | static Standard_Integer ContToInteger( const GeomAbs_Shape Cont) |
57 | { |
58 | Standard_Integer result =0; |
59 | switch(Cont) { |
60 | case GeomAbs_C0: |
61 | case GeomAbs_G1: result = 0; break; |
62 | case GeomAbs_C1: |
63 | case GeomAbs_G2: result = 1; break; |
64 | case GeomAbs_C2: result = 2; break; |
65 | case GeomAbs_C3: result = 3; break; |
66 | default : result = 4; break; |
67 | } |
68 | return result; |
69 | } |
70 | |
71 | static Standard_Integer directfaces(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
72 | { |
73 | if (argc < 3) { di<<"Donner un nom de SHAPE + un nom de RESULTAT"<<"\n"; return 1 /* Error */; } |
74 | Standard_CString arg1 = argv[1]; |
75 | Standard_CString arg2 = argv[2]; |
76 | TopoDS_Shape Shape = DBRep::Get(arg2); |
77 | if (Shape.IsNull()) { di<<"Shape unknown : "<<arg2<<"\n"; return 1 /* Error */; } |
78 | |
79 | TopoDS_Shape result = ShapeCustom::DirectFaces (Shape); |
80 | if (result.IsNull()) { di<<"NO RESULT"<<"\n"; return 1; } |
81 | else if (result == Shape) { di<<"No modif"<<"\n"; return 0; } |
82 | di<<"DirectFaces -> Result : "<<arg1<<"\n"; |
83 | DBRep::Set (arg1,result); |
84 | return 0; // Done |
85 | } |
86 | |
87 | static Standard_Integer ckeckKnots(const TColStd_Array1OfReal& theKnots, |
88 | Standard_Real theFirst, |
89 | Standard_Real theLast) |
90 | { |
91 | Standard_Integer i =1, nb = theKnots.Length(); |
92 | Standard_Integer aNum =0; |
93 | for( ; i< nb; i++) |
94 | { |
95 | if(!aNum) |
96 | { |
97 | Standard_Real aDF = theKnots(i) - theFirst; |
98 | if(fabs(aDF) <= Precision::PConfusion() || |
99 | aDF > Precision::PConfusion()) |
100 | { |
101 | aNum++; |
102 | continue; |
103 | } |
104 | } |
105 | else |
106 | { |
107 | Standard_Real aDL = theKnots(i) - theLast; |
108 | if(fabs(aDL) <= Precision::PConfusion() || |
109 | aDL > Precision::PConfusion()) |
110 | break; |
111 | aNum++; |
112 | |
113 | } |
114 | |
115 | } |
116 | return aNum; |
117 | } |
118 | |
119 | static void expcurv2d(const Handle(Geom2d_Curve)& aCurve, TColStd_Array2OfInteger& Nb, const Standard_Integer Degree, |
120 | const Standard_Integer MaxSeg, |
121 | const Standard_Integer theCont, |
122 | Standard_Real theFirst, |
123 | Standard_Real theLast) |
124 | { |
125 | if(aCurve.IsNull()) return; |
126 | |
127 | if (aCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve))) { |
128 | Handle(Geom2d_TrimmedCurve) tmp = Handle(Geom2d_TrimmedCurve)::DownCast (aCurve); |
129 | Handle(Geom2d_Curve) BasCurve = tmp->BasisCurve(); |
130 | expcurv2d(BasCurve,Nb,Degree,MaxSeg,theCont,theFirst,theLast); |
131 | return; |
132 | } |
133 | if (aCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve))) { |
134 | Handle(Geom2d_OffsetCurve) tmp = Handle(Geom2d_OffsetCurve)::DownCast (aCurve); |
135 | Handle(Geom2d_Curve) BasCurve = tmp->BasisCurve(); |
136 | expcurv2d(BasCurve,Nb,Degree,MaxSeg,theCont,theFirst,theLast); |
137 | return; |
138 | } |
139 | Standard_Integer aCont = ContToInteger(aCurve->Continuity()); |
140 | if(aCurve->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) { |
141 | Handle(Geom2d_BSplineCurve) Bs = Handle(Geom2d_BSplineCurve)::DownCast(aCurve); |
142 | if(Bs->Degree() > Degree) Nb.ChangeValue(1,1)++; |
143 | if(Bs->NbKnots() -1 > MaxSeg) Nb.ChangeValue(1,2)++; |
144 | if(Bs->IsRational()) Nb.ChangeValue(1,3)++; |
145 | if(aCont < theCont && Bs->NbKnots() > 2) |
146 | { |
147 | TColStd_Array1OfReal aKnots(1,Bs->NbKnots()); |
148 | Bs->Knots(aKnots); |
149 | Standard_Integer nbInt = ckeckKnots(aKnots,theFirst,theLast); |
150 | if(nbInt >1) |
151 | Nb.ChangeValue(1,4)++; |
152 | } |
153 | return; |
154 | } |
155 | if (aCurve->IsKind(STANDARD_TYPE(Geom2d_BezierCurve))) { |
156 | Handle(Geom2d_BezierCurve) Bs = Handle(Geom2d_BezierCurve)::DownCast(aCurve); |
157 | if(Bs->Degree() > Degree) Nb.ChangeValue(2,1)++; |
158 | if(Bs->IsRational() > ((unsigned int)MaxSeg) ) Nb.ChangeValue(2,3)++; |
159 | if(aCont < theCont) |
160 | { |
161 | |
162 | Nb.ChangeValue(2,4)++; |
163 | } |
164 | return; |
165 | } |
166 | else |
167 | Nb.ChangeValue(1,5)++; |
168 | return; |
169 | } |
170 | |
171 | static void expcurv(const Handle(Geom_Curve)& aCurve, TColStd_Array2OfInteger& Nb, const Standard_Integer Degree, |
172 | const Standard_Integer MaxSeg, |
173 | const Standard_Integer theCont, |
174 | Standard_Real theFirst, |
175 | Standard_Real theLast) |
176 | { |
177 | if(aCurve.IsNull()) return; |
178 | if (aCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { |
179 | Handle(Geom_TrimmedCurve) tmp = Handle(Geom_TrimmedCurve)::DownCast (aCurve); |
180 | Handle(Geom_Curve) BasCurve = tmp->BasisCurve(); |
181 | expcurv(BasCurve,Nb,Degree,MaxSeg,theCont,theFirst,theLast); |
182 | return; |
183 | } |
184 | if (aCurve->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) { |
185 | Handle(Geom_OffsetCurve) tmp = Handle(Geom_OffsetCurve)::DownCast (aCurve); |
186 | Handle(Geom_Curve) BasCurve = tmp->BasisCurve(); |
187 | expcurv(BasCurve,Nb,Degree,MaxSeg,theCont,theFirst,theLast); |
188 | return; |
189 | } |
190 | |
191 | Standard_Integer aCont = ContToInteger(aCurve->Continuity()); |
192 | if(aCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { |
193 | Handle(Geom_BSplineCurve) Bs = Handle(Geom_BSplineCurve)::DownCast(aCurve); |
194 | if(Bs->Degree() > Degree) Nb.ChangeValue(1,1)++; |
195 | if(Bs->NbKnots() -1 > MaxSeg) Nb.ChangeValue(1,2)++; |
196 | if(Bs->IsRational()) Nb.ChangeValue(1,3)++; |
197 | if(aCont < theCont && Bs->NbKnots() > 2) |
198 | { |
199 | TColStd_Array1OfReal aKnots(1,Bs->NbKnots()); |
200 | Bs->Knots(aKnots); |
201 | Standard_Integer nbInt = ckeckKnots(aKnots,theFirst,theLast); |
202 | if(nbInt >1) |
203 | Nb.ChangeValue(1,4)++; |
204 | } |
205 | return; |
206 | } |
207 | if (aCurve->IsKind(STANDARD_TYPE(Geom_BezierCurve))) { |
208 | Handle(Geom_BezierCurve) Bs = Handle(Geom_BezierCurve)::DownCast(aCurve); |
209 | if(Bs->Degree() > Degree) Nb.ChangeValue(2,1)++; |
210 | if(Bs->IsRational() > ((unsigned int)MaxSeg) ) Nb.ChangeValue(2,3)++; |
211 | if(aCont < theCont) |
212 | Nb.ChangeValue(2,4)++; |
213 | return; |
214 | } |
215 | else |
216 | Nb.ChangeValue(1,5)++; |
217 | return; |
218 | } |
219 | static void expsurf(const Handle(Geom_Surface)& aSurface, TColStd_Array2OfInteger& NbSurf, const Standard_Integer Degree, |
220 | const Standard_Integer MaxSeg, |
221 | const Standard_Integer theCont) |
222 | { |
223 | if (aSurface.IsNull()) return; |
224 | if (aSurface->IsKind(STANDARD_TYPE(Geom_SweptSurface))) { |
225 | Handle(Geom_SweptSurface) aSurf = Handle(Geom_SweptSurface)::DownCast(aSurface); |
226 | Handle(Geom_Curve) BasCurve = aSurf->BasisCurve(); |
227 | expcurv(BasCurve,NbSurf,Degree,MaxSeg,theCont,BasCurve->FirstParameter(), |
228 | BasCurve->LastParameter()); |
229 | return; |
230 | } |
231 | if (aSurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { |
232 | Handle(Geom_RectangularTrimmedSurface) aSurf = Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface); |
233 | Handle(Geom_Surface) theSurf = aSurf->BasisSurface(); |
234 | expsurf(theSurf,NbSurf,Degree,MaxSeg,theCont); |
235 | return; |
236 | } |
237 | if(aSurface->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) { |
238 | Handle(Geom_OffsetSurface) aSurf = Handle(Geom_OffsetSurface)::DownCast(aSurface); |
239 | Handle(Geom_Surface) theSurf = aSurf->BasisSurface(); |
240 | expsurf(theSurf,NbSurf,Degree,MaxSeg,theCont); |
241 | return; |
242 | |
243 | } |
244 | Standard_Integer aCont = ContToInteger(aSurface->Continuity()); |
245 | |
246 | if (aSurface->IsKind(STANDARD_TYPE(Geom_BSplineSurface))) { |
247 | Handle(Geom_BSplineSurface) BS = Handle(Geom_BSplineSurface)::DownCast(aSurface); |
248 | if(BS->UDegree() > Degree || BS->VDegree() > Degree) NbSurf.ChangeValue(1,1)++; |
249 | if(((BS->NbUKnots()-1) * (BS->NbVKnots()-1)) >MaxSeg) NbSurf.ChangeValue(1,2)++; |
250 | if(BS->IsURational() || BS->IsVRational()) NbSurf.ChangeValue(1,3)++; |
251 | if(aCont < theCont) |
252 | NbSurf.ChangeValue(1,4)++; |
253 | return; |
254 | } |
255 | if (aSurface->IsKind(STANDARD_TYPE(Geom_BezierSurface))) { |
256 | Handle(Geom_BezierSurface) BS = Handle(Geom_BezierSurface)::DownCast(aSurface); |
257 | if(BS->UDegree() > Degree || BS->VDegree() > Degree) NbSurf.ChangeValue(2,1)++; |
258 | if(BS->IsURational() || BS->IsVRational()) NbSurf.ChangeValue(2,3)++; |
259 | if(aCont < theCont) |
260 | NbSurf.ChangeValue(2,4)++; |
261 | return; |
262 | } |
263 | if(aSurface->IsKind(STANDARD_TYPE(Geom_Plane))) |
264 | { |
265 | NbSurf.ChangeValue(1,5)++; |
266 | } |
267 | else |
268 | NbSurf.ChangeValue(2,5)++; |
269 | } |
270 | |
271 | static Standard_Integer expshape(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
272 | { |
273 | if (argc <4) { |
274 | di << "Incorrect number of arguments. Must be 3" << "\n"; |
275 | return 1 /* Error */; |
276 | } |
277 | Standard_CString arg2 = argv[1]; |
278 | TopoDS_Shape Shape = DBRep::Get(arg2); |
91322f44 |
279 | Standard_Integer Degree = Draw::Atoi(argv[2]); |
280 | Standard_Integer MaxSeg = Draw::Atoi(argv[3]); |
7fd59977 |
281 | GeomAbs_Shape aCont3 = GeomAbs_C0; |
282 | Standard_Integer k = 4; |
283 | if( argc > k) |
284 | { |
285 | if(strcmp(argv[k],"C0") == 0) aCont3 = GeomAbs_C0; |
286 | else if (strcmp(argv[k],"C1") == 0) aCont3 = GeomAbs_C1; |
287 | else if (strcmp(argv[k],"C2") == 0) aCont3 = GeomAbs_C2; |
288 | else if (strcmp(argv[k],"C3") == 0) aCont3 = GeomAbs_C3; |
289 | else if (strcmp(argv[k],"CN") == 0) aCont3 = GeomAbs_CN; |
290 | else if (strcmp(argv[k],"G1") == 0) aCont3 = GeomAbs_C0; |
291 | else if (strcmp(argv[k],"G2") == 0) aCont3 = GeomAbs_C1; |
292 | else { |
293 | di<< "Invalid argument Cont3e" << "\n"; return 1; } |
294 | |
295 | |
296 | } |
297 | |
298 | Standard_Integer aCont = ContToInteger(aCont3); |
299 | TColStd_Array2OfInteger NbSurf(1,2,1,5); |
300 | TColStd_Array2OfInteger NbCurv(1,2,1,5); |
301 | TColStd_Array2OfInteger NbCurv2d(1,2,1,5); |
302 | Standard_Integer nbSeam =0; |
303 | NbSurf.Init(0); |
304 | NbCurv.Init(0); |
305 | NbCurv2d.Init(0); |
306 | if (Shape.IsNull()) { di << "Shape unknown: " << arg2 << "\n"; return 1 /* Error */; } |
307 | TopExp_Explorer Ex; |
308 | |
309 | Standard_Integer nbF =1; |
310 | for (Ex.Init(Shape,TopAbs_FACE); Ex.More(); Ex.Next(),nbF++) { |
311 | TopoDS_Face F = TopoDS::Face(Ex.Current()); |
312 | TopLoc_Location L; |
313 | Handle(Geom_Surface) aSurface = BRep_Tool::Surface(F,L); |
314 | expsurf(aSurface,NbSurf,Degree,MaxSeg,aCont); |
315 | TopExp_Explorer exp; |
316 | |
317 | Standard_Integer nbE = 1; |
318 | for(exp.Init(F,TopAbs_EDGE); exp.More(); exp.Next(),nbE++) { |
319 | TopoDS_Edge E = TopoDS::Edge(exp.Current()); |
320 | if(BRep_Tool::IsClosed(E,F)) |
321 | nbSeam++; |
322 | Standard_Real First,Last; |
323 | Handle(Geom_Curve) aCurve = BRep_Tool::Curve(E,L,First, Last); |
324 | expcurv(aCurve,NbCurv,Degree,MaxSeg,aCont,First, Last); |
325 | Standard_Real First2d,Last2d; |
326 | Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(E,F,First2d,Last2d); |
327 | expcurv2d(aCurve2d,NbCurv2d,Degree,MaxSeg,aCont,First2d,Last2d); |
328 | } |
329 | } |
330 | di<<"Number of seam edges - "<<nbSeam<<"\n"; |
331 | //if(NbSurf.Value(1,1) !=0) |
332 | di<< "Number of BSpline surfaces with degree more then "<< Degree << " - " <<NbSurf.Value(1,1)<<"\n"; |
333 | //if(NbSurf.Value(1,2) !=0) |
334 | di<< "Number of BSpline surfaces with number of spans more then "<< MaxSeg << " - " <<NbSurf.Value(1,2)<<"\n"; |
335 | //if(NbSurf.Value(1,3) !=0) |
336 | di<< "Number of Rational BSpline surfaces " << NbSurf.Value(1,3)<<"\n"; |
337 | //if(NbSurf.Value(1,4) !=0) |
338 | di<< "Number of BSpline surfaces with continuity less than specified - " << NbSurf.Value(1,4)<<"\n"; |
339 | //if(NbSurf.Value(2,1) !=0) |
340 | di<< "Number of Bezier surfaces with degree more then "<< Degree << " - " <<NbSurf.Value(2,1)<<"\n"; |
341 | //if(NbSurf.Value(2,3) !=0) |
342 | di<< "Number of Rational Bezier surfaces " << " - " <<NbSurf.Value(2,3)<<"\n"; |
343 | //if(NbSurf.Value(2,4) !=0) |
344 | di<< "Number of Bezier surfaces with continuity less than specified - " << NbSurf.Value(2,4)<<"\n"; |
345 | |
346 | //if(NbSurf.Value(1,5) !=0) |
347 | di<< "Number of Planes - " << NbSurf.Value(1,5)<<"\n"; |
348 | //if(NbSurf.Value(2,5) !=0) |
349 | di<< "Number of other surfaces - " << NbSurf.Value(2,5)<<"\n"; |
350 | |
351 | //if(NbCurv.Value(1,1) !=0) |
352 | di<< "Number of BSpline curves with degree more then "<< Degree << " - " <<NbCurv.Value(1,1)<<"\n"; |
353 | //if(NbCurv.Value(1,2) !=0) |
354 | di<< "Number of BSpline curves with number of spans more then - "<< MaxSeg << " - " <<NbCurv.Value(1,2)<<"\n"; |
355 | //if(NbCurv.Value(1,3) !=0) |
356 | di<< "Number of Rational BSpline curves " << NbCurv.Value(1,3)<<"\n"; |
357 | //if(NbCurv.Value(1,4) !=0) |
358 | di<< "Number of BSpline curves with less continuity - " << NbCurv.Value(1,4)<<"\n"; |
359 | //if(NbCurv.Value(2,1) !=0) |
360 | di<< "Number of Bezier curves with degree more then - "<< Degree << " - " <<NbCurv.Value(2,1)<<"\n"; |
361 | //if(NbCurv.Value(2,3) !=0) |
362 | di<< "Number of Rational Bezier curves " << " - " <<NbCurv.Value(2,3)<<"\n"; |
363 | //if(NbCurv.Value(2,4) !=0) |
364 | di<< "Number of Bezier curves with less continuity - " << NbCurv.Value(2,4)<<"\n"; |
365 | |
366 | //if(NbCurv.Value(1,5) !=0) |
367 | di<< "Number of other curves - " << NbCurv.Value(1,5)<<"\n"; |
368 | |
369 | //if(NbCurv2d.Value(1,1) !=0) |
370 | di<< "Number of BSpline pcurves with degree more then - "<< Degree << " - " <<NbCurv2d.Value(1,1)<<"\n"; |
371 | //if(NbCurv2d.Value(1,2) !=0) |
372 | di<< "Number of BSpline pcurves with number of spans more then "<< MaxSeg << " - " <<NbCurv2d.Value(1,2)<<"\n"; |
373 | //if(NbCurv2d.Value(1,3) !=0) |
374 | di<< "Number of Rational BSpline pcurves - " << NbCurv2d.Value(1,3)<<"\n"; |
375 | // if(NbCurv2d.Value(1,4) !=0) |
376 | di<< "Number of BSpline pcurves with less continuity - " << NbCurv2d.Value(1,4)<<"\n"; |
377 | //if(NbCurv2d.Value(2,1) !=0) |
378 | di<< "Number of Bezier pcurves with degree more then "<< Degree <<" - " <<" - " <<NbCurv2d.Value(2,1)<<"\n"; |
379 | //if(NbCurv2d.Value(2,3) !=0) |
380 | di<< "Number of Rational Bezier pcurves " << " - " <<NbCurv2d.Value(2,3)<<"\n"; |
381 | //if(NbCurv2d.Value(2,4) !=0) |
382 | di<< "Number of Bezier pcurves with less continuity - " << NbCurv2d.Value(2,4)<<"\n"; |
383 | |
384 | //if(NbCurv2d.Value(1,5) !=0) |
385 | di<< "Number of other pcurves - " << NbCurv2d.Value(1,5)<<"\n"; |
386 | return 0; |
387 | } |
388 | |
389 | static Standard_Integer scaleshape(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
390 | { |
391 | if (argc !=4) { |
392 | di << "Incorrect number of arguments. Must be 4" << "\n"; |
393 | return 1 /* Error */; |
394 | } |
395 | Standard_CString arg2 = argv[2]; |
396 | TopoDS_Shape Shape = DBRep::Get(arg2); |
397 | if (Shape.IsNull()) { di << "Shape unknown: " << arg2 << "\n"; return 1 /* Error */; } |
398 | |
91322f44 |
399 | TopoDS_Shape result = ShapeCustom::ScaleShape (Shape, Draw::Atof(argv[3])); |
7fd59977 |
400 | if (result.IsNull()) { di << "NO RESULT" << "\n"; return 1; } |
401 | else if (result == Shape) { di << "NO MODIFICATIONS" << "\n"; return 0; } |
402 | DBRep::Set (argv[1],result); |
403 | return 0; |
404 | } |
405 | static Standard_Integer BSplRes(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
406 | { |
407 | if (argc < 11) { |
408 | di << "Incorrect number of arguments. Must be 10" << "\n"; |
409 | return 1 /* Error */; |
410 | } |
411 | Standard_CString arg2 = argv[2]; |
412 | TopoDS_Shape Shape = DBRep::Get(arg2); |
413 | if (Shape.IsNull()) { di << "Shape unknown: " << arg2 << "\n"; return 1 /* Error */; } |
414 | GeomAbs_Shape aCont3; |
415 | if(strcmp(argv[7],"C0") == 0) aCont3 = GeomAbs_C0; |
416 | else if (strcmp(argv[7],"C1") == 0) aCont3 = GeomAbs_C1; |
417 | else if (strcmp(argv[7],"C2") == 0) aCont3 = GeomAbs_C2; |
418 | else if (strcmp(argv[7],"C3") == 0) aCont3 = GeomAbs_C3; |
419 | else if (strcmp(argv[7],"CN") == 0) aCont3 = GeomAbs_CN; |
420 | else if (strcmp(argv[7],"G1") == 0) aCont3 = GeomAbs_C0; |
421 | else if (strcmp(argv[7],"G2") == 0) aCont3 = GeomAbs_C1; |
422 | else { |
423 | di<< "Invalid argument Cont3e" << "\n"; return 1; } |
424 | GeomAbs_Shape aCont2; |
425 | if(strcmp(argv[8],"C0") == 0) aCont2 = GeomAbs_C0; |
426 | else if (strcmp(argv[8],"C1") == 0) aCont2 = GeomAbs_C1; |
427 | else if (strcmp(argv[8],"C2") == 0) aCont2 = GeomAbs_C2; |
428 | else if (strcmp(argv[8],"C3") == 0) aCont2 = GeomAbs_C3; |
429 | else if (strcmp(argv[8],"CN") == 0) aCont2 = GeomAbs_CN; |
430 | else if (strcmp(argv[8],"G1") == 0) aCont2 = GeomAbs_C0; |
431 | else if (strcmp(argv[8],"G2") == 0) aCont2 = GeomAbs_C1; |
432 | else { |
433 | di<< "Invalid argument Cont3e" << "\n"; return 1; } |
434 | |
435 | Handle(ShapeCustom_RestrictionParameters) aParameters = new ShapeCustom_RestrictionParameters; |
91322f44 |
436 | TopoDS_Shape result = ShapeCustom::BSplineRestriction (Shape, Draw::Atof(argv[3]), Draw::Atof(argv[4]), Draw::Atoi(argv[5]),Draw::Atoi(argv[6]),aCont3,aCont2,(Standard_Boolean) Draw::Atoi(argv[9]),(Standard_Boolean) Draw::Atoi(argv[10]),aParameters); |
7fd59977 |
437 | if (result.IsNull()) { di << "NO RESULT" << "\n"; return 1; } |
438 | else if (result == Shape) { |
439 | di << "NO MODIFICATIONS" << "\n"; |
440 | DBRep::Set (argv[1],result); return 0; |
441 | } |
442 | ShapeFix::SameParameter(result,Standard_False); |
443 | |
444 | DBRep::Set (argv[1],result); |
445 | return 0; |
446 | } |
447 | |
448 | static Standard_Integer convtorevol(Draw_Interpretor& di, Standard_Integer argc, const char** argv) |
449 | { |
450 | if (argc < 3) { di<<"Convert surfaces to revolution: convtorevol result shape"<<"\n"; return 1; } |
451 | |
452 | Standard_CString arg1 = argv[1]; |
453 | Standard_CString arg2 = argv[2]; |
454 | TopoDS_Shape Shape = DBRep::Get(arg2); |
455 | if (Shape.IsNull()) { di<<"Shape unknown : "<<arg2<<"\n"; return 1; } |
456 | |
457 | TopoDS_Shape result = ShapeCustom::ConvertToRevolution (Shape); |
458 | if (result.IsNull()) { di<<"NO RESULT"<<"\n"; return 1; } |
459 | else if (result == Shape) { di<<"No modif"<<"\n"; return 0; } |
460 | di<<"ConvertToRevolution -> Result : "<<arg1<<"\n"; |
461 | DBRep::Set (arg1,result); |
462 | return 0; // Done |
463 | } |
464 | |
465 | //====================================================================== |
466 | //function : InitCommands |
467 | //purpose : |
468 | //======================================================================= |
469 | |
470 | void SWDRAW_ShapeCustom::InitCommands(Draw_Interpretor& theCommands) |
471 | { |
472 | static Standard_Integer initactor = 0; |
473 | if (initactor) return; initactor = 1; |
474 | |
475 | Standard_CString g = SWDRAW::GroupName(); |
476 | |
477 | theCommands.Add ("directfaces", "directfaces result shape", __FILE__, directfaces, g); |
478 | theCommands.Add ("expshape", "expshape shape maxdegree maxseg [min_continuity]", __FILE__, expshape, g); |
479 | theCommands.Add ("scaleshape", "scaleshape result shape scale", __FILE__, scaleshape, g); |
480 | theCommands.Add ("bsplres", "BSplineRestriction result shape tol3d tol2d reqdegree reqnbsegments continuity3d continuity2d PriorDeg RationalConvert", __FILE__,BSplRes, g); |
481 | theCommands.Add ("convtorevol", "convtorevol result shape", __FILE__, convtorevol, g); |
482 | } |