0024624: Lost word in license statement in source files
[occt.git] / src / GeomliteTest / GeomliteTest_ModificationCommands.cxx
1 // Created on: 1997-04-15
2 // Created by: Joelle CHAUVET
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <GeomliteTest.hxx>
18 #include <DrawTrSurf.hxx>
19 #include <Draw.hxx>
20 #include <Draw_Interpretor.hxx>
21 #include <Draw_Appli.hxx>
22 #include <Draw_Display.hxx>
23
24 #include <Precision.hxx>
25 #include <GeomLib.hxx>
26
27 #ifdef WNT
28 #include <stdio.h>
29 //#define strcasecmp strcmp Already defined
30 #endif
31
32
33 //=======================================================================
34 //function : extendcurve
35 //purpose  : 
36 //=======================================================================
37
38 static Standard_Integer extendcurve (Draw_Interpretor& di, Standard_Integer n, const char** a)
39 {
40   if (n < 4) return 1;
41
42   Handle(Geom_BoundedCurve) GB = 
43     Handle(Geom_BoundedCurve)::DownCast(DrawTrSurf::GetCurve(a[1]));
44   if (GB.IsNull())  {
45     di << "extendcurve needs a Bounded curve";
46     return 1;
47   }
48
49   gp_Pnt  P;
50   if ( !DrawTrSurf::GetPoint(a[2],P)) return 1;
51   Standard_Boolean apres = Standard_True;
52   if (n == 5) {
53       if (strcmp(a[4], "B") == 0) {
54         apres = Standard_False ;
55       }
56   }
57   Standard_Integer cont=Draw::Atoi(a[3]);  
58   GeomLib::ExtendCurveToPoint(GB,P,cont,apres);
59   DrawTrSurf::Set(a[1],GB);
60   return 0;
61 }
62
63 //=======================================================================
64 //function : extendsurf
65 //purpose  : 
66 //=======================================================================
67
68 static Standard_Integer extendsurf (Draw_Interpretor& di, Standard_Integer n, const char** a)
69 {
70   if (n < 4) return 1;
71
72   Handle(Geom_BoundedSurface) GB = 
73     Handle(Geom_BoundedSurface)::DownCast(DrawTrSurf::GetSurface(a[1]));
74   if (GB.IsNull())  {
75     di << "extendsurf needs a Bounded surface";
76     return 1;
77   }
78   Standard_Real chord=Draw::Atof(a[2]);
79   Standard_Integer cont=Draw::Atoi(a[3]);
80   Standard_Boolean enU = Standard_True, apres = Standard_True;
81   if (n >= 5) {
82       if (strcmp(a[4], "V") == 0) {
83         enU = Standard_False ;
84       }
85       if (strcmp(a[4], "B") == 0) {
86         apres = Standard_False ;
87       }
88   }
89   if (n == 6) {
90       if (strcmp(a[5], "B") == 0) {
91         apres = Standard_False ;
92       }
93   }
94
95
96   GeomLib::ExtendSurfByLength(GB,chord,cont,enU,apres);
97   DrawTrSurf::Set(a[1],GB);
98
99   return 0;
100 }
101
102
103 //=======================================================================
104 //function :  samerange
105 //purpose  : 
106 //=======================================================================
107
108 static Standard_Integer samerange (Draw_Interpretor& /*di*/, Standard_Integer n, const char** a)
109 {
110   if (n < 6) return 1;
111   Handle(Geom2d_Curve) C = DrawTrSurf::GetCurve2d(a[2]);
112   Handle(Geom2d_Curve) Res;
113   Standard_Real f, l, rf, rl;
114   f = Draw::Atof(a[3]);
115   l = Draw::Atof(a[4]);
116   rf = Draw::Atof(a[5]);
117   rl = Draw::Atof(a[6]);
118
119   GeomLib::SameRange(Precision::PConfusion(), C, 
120                      f, l, rf, rl, Res);
121
122   DrawTrSurf::Set(a[1],Res);
123
124   return 0;
125
126 }
127
128 //=======================================================================
129 //function : ModificationCommands
130 //purpose  : 
131 //=======================================================================
132
133
134 void  GeomliteTest::ModificationCommands(Draw_Interpretor& theCommands)
135 {
136   static Standard_Boolean loaded = Standard_False;
137   if (loaded) return;
138   loaded = Standard_True;
139
140   DrawTrSurf::BasicCommands(theCommands);
141
142   const char* g;
143
144   g = "GEOMETRY Curves and Surfaces modification";
145
146
147   theCommands.Add("extendcurve",
148                   "extendcurve name point cont [A(fter)/B(efore)]",
149                    __FILE__,
150                   extendcurve , g);
151
152
153   theCommands.Add("extendsurf",
154                   "extendsurf name length cont [U/V] [A(fter)/B(efore)]",
155                   __FILE__,
156                    extendsurf, g);
157
158   
159   theCommands.Add("chgrange",
160                   "chgrange newname curve2d first last  RequestedFirst RequestedLast ]",
161                   __FILE__,
162                    samerange, g);
163
164 }
165
166
167
168