7fd59977 |
1 | // File: GeomliteTest_ModificationCommands.cxx |
2 | // Created: Thu Apr 15 12:00 1997 |
3 | // Author: Joelle CHAUVET |
4 | // <jct@sgi38> |
5 | |
6 | #include <GeomliteTest.hxx> |
7 | #include <DrawTrSurf.hxx> |
8 | #include <Draw.hxx> |
9 | #include <Draw_Interpretor.hxx> |
10 | #include <Draw_Appli.hxx> |
11 | #include <Draw_Display.hxx> |
12 | |
13 | #include <Precision.hxx> |
14 | #include <GeomLib.hxx> |
15 | |
16 | #ifdef WNT |
17 | #include <stdio.h> |
18 | //#define strcasecmp strcmp Already defined |
19 | #endif |
20 | |
21 | |
22 | //======================================================================= |
23 | //function : extendcurve |
24 | //purpose : |
25 | //======================================================================= |
26 | |
27 | static Standard_Integer extendcurve (Draw_Interpretor& di, Standard_Integer n, const char** a) |
28 | { |
29 | if (n < 4) return 1; |
30 | |
31 | Handle(Geom_BoundedCurve) GB = |
32 | Handle(Geom_BoundedCurve)::DownCast(DrawTrSurf::GetCurve(a[1])); |
33 | if (GB.IsNull()) { |
34 | di << "extendcurve needs a Bounded curve"; |
35 | return 1; |
36 | } |
37 | |
38 | gp_Pnt P; |
39 | if ( !DrawTrSurf::GetPoint(a[2],P)) return 1; |
40 | Standard_Boolean apres = Standard_True; |
41 | if (n == 5) { |
42 | if (strcmp(a[4], "B") == 0) { |
43 | apres = Standard_False ; |
44 | } |
45 | } |
46 | Standard_Integer cont=atoi(a[3]); |
47 | GeomLib::ExtendCurveToPoint(GB,P,cont,apres); |
48 | DrawTrSurf::Set(a[1],GB); |
49 | return 0; |
50 | } |
51 | |
52 | //======================================================================= |
53 | //function : extendsurf |
54 | //purpose : |
55 | //======================================================================= |
56 | |
57 | static Standard_Integer extendsurf (Draw_Interpretor& di, Standard_Integer n, const char** a) |
58 | { |
59 | if (n < 4) return 1; |
60 | |
61 | Handle(Geom_BoundedSurface) GB = |
62 | Handle(Geom_BoundedSurface)::DownCast(DrawTrSurf::GetSurface(a[1])); |
63 | if (GB.IsNull()) { |
64 | di << "extendsurf needs a Bounded surface"; |
65 | return 1; |
66 | } |
67 | Standard_Real chord=atof(a[2]); |
68 | Standard_Integer cont=atoi(a[3]); |
69 | Standard_Boolean enU = Standard_True, apres = Standard_True; |
70 | if (n >= 5) { |
71 | if (strcmp(a[4], "V") == 0) { |
72 | enU = Standard_False ; |
73 | } |
74 | if (strcmp(a[4], "B") == 0) { |
75 | apres = Standard_False ; |
76 | } |
77 | } |
78 | if (n == 6) { |
79 | if (strcmp(a[5], "B") == 0) { |
80 | apres = Standard_False ; |
81 | } |
82 | } |
83 | |
84 | |
85 | GeomLib::ExtendSurfByLength(GB,chord,cont,enU,apres); |
86 | DrawTrSurf::Set(a[1],GB); |
87 | |
88 | return 0; |
89 | } |
90 | |
91 | |
92 | //======================================================================= |
93 | //function : samerange |
94 | //purpose : |
95 | //======================================================================= |
96 | |
97 | static Standard_Integer samerange (Draw_Interpretor& di, Standard_Integer n, const char** a) |
98 | { |
99 | if (n < 6) return 1; |
100 | Handle(Geom2d_Curve) C = DrawTrSurf::GetCurve2d(a[2]); |
101 | Handle(Geom2d_Curve) Res; |
102 | Standard_Real f, l, rf, rl; |
103 | f = atof(a[3]); |
104 | l = atof(a[4]); |
105 | rf = atof(a[5]); |
106 | rl = atof(a[6]); |
107 | |
108 | GeomLib::SameRange(Precision::PConfusion(), C, |
109 | f, l, rf, rl, Res); |
110 | |
111 | DrawTrSurf::Set(a[1],Res); |
112 | |
113 | return 0; |
114 | |
115 | } |
116 | |
117 | //======================================================================= |
118 | //function : ModificationCommands |
119 | //purpose : |
120 | //======================================================================= |
121 | |
122 | |
123 | void GeomliteTest::ModificationCommands(Draw_Interpretor& theCommands) |
124 | { |
125 | static Standard_Boolean loaded = Standard_False; |
126 | if (loaded) return; |
127 | loaded = Standard_True; |
128 | |
129 | DrawTrSurf::BasicCommands(theCommands); |
130 | |
131 | const char* g; |
132 | |
133 | g = "GEOMETRY Curves and Surfaces modification"; |
134 | |
135 | |
136 | theCommands.Add("extendcurve", |
137 | "extendcurve name point cont [A(fter)/B(efore)]", |
138 | __FILE__, |
139 | extendcurve , g); |
140 | |
141 | |
142 | theCommands.Add("extendsurf", |
143 | "extendsurf name length cont [U/V] [A(fter)/B(efore)]", |
144 | __FILE__, |
145 | extendsurf, g); |
146 | |
147 | |
148 | theCommands.Add("chgrange", |
149 | "chgrange newname curve2d first last RequestedFirst RequestedLast ]", |
150 | __FILE__, |
151 | samerange, g); |
152 | |
153 | } |
154 | |
155 | |
156 | |
157 | |