Adding test cases from chl grid
[occt.git] / src / GeomliteTest / GeomliteTest_ModificationCommands.cxx
CommitLineData
b311480e 1// Created on: 1997-04-15
2// Created by: Joelle CHAUVET
3// Copyright (c) 1997-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
22#include <GeomliteTest.hxx>
23#include <DrawTrSurf.hxx>
24#include <Draw.hxx>
25#include <Draw_Interpretor.hxx>
26#include <Draw_Appli.hxx>
27#include <Draw_Display.hxx>
28
29#include <Precision.hxx>
30#include <GeomLib.hxx>
31
32#ifdef WNT
33#include <stdio.h>
34//#define strcasecmp strcmp Already defined
35#endif
36
37
38//=======================================================================
39//function : extendcurve
40//purpose :
41//=======================================================================
42
43static Standard_Integer extendcurve (Draw_Interpretor& di, Standard_Integer n, const char** a)
44{
45 if (n < 4) return 1;
46
47 Handle(Geom_BoundedCurve) GB =
48 Handle(Geom_BoundedCurve)::DownCast(DrawTrSurf::GetCurve(a[1]));
49 if (GB.IsNull()) {
50 di << "extendcurve needs a Bounded curve";
51 return 1;
52 }
53
54 gp_Pnt P;
55 if ( !DrawTrSurf::GetPoint(a[2],P)) return 1;
56 Standard_Boolean apres = Standard_True;
57 if (n == 5) {
58 if (strcmp(a[4], "B") == 0) {
59 apres = Standard_False ;
60 }
61 }
62 Standard_Integer cont=atoi(a[3]);
63 GeomLib::ExtendCurveToPoint(GB,P,cont,apres);
64 DrawTrSurf::Set(a[1],GB);
65 return 0;
66}
67
68//=======================================================================
69//function : extendsurf
70//purpose :
71//=======================================================================
72
73static Standard_Integer extendsurf (Draw_Interpretor& di, Standard_Integer n, const char** a)
74{
75 if (n < 4) return 1;
76
77 Handle(Geom_BoundedSurface) GB =
78 Handle(Geom_BoundedSurface)::DownCast(DrawTrSurf::GetSurface(a[1]));
79 if (GB.IsNull()) {
80 di << "extendsurf needs a Bounded surface";
81 return 1;
82 }
83 Standard_Real chord=atof(a[2]);
84 Standard_Integer cont=atoi(a[3]);
85 Standard_Boolean enU = Standard_True, apres = Standard_True;
86 if (n >= 5) {
87 if (strcmp(a[4], "V") == 0) {
88 enU = Standard_False ;
89 }
90 if (strcmp(a[4], "B") == 0) {
91 apres = Standard_False ;
92 }
93 }
94 if (n == 6) {
95 if (strcmp(a[5], "B") == 0) {
96 apres = Standard_False ;
97 }
98 }
99
100
101 GeomLib::ExtendSurfByLength(GB,chord,cont,enU,apres);
102 DrawTrSurf::Set(a[1],GB);
103
104 return 0;
105}
106
107
108//=======================================================================
109//function : samerange
110//purpose :
111//=======================================================================
112
113static Standard_Integer samerange (Draw_Interpretor& di, Standard_Integer n, const char** a)
114{
115 if (n < 6) return 1;
116 Handle(Geom2d_Curve) C = DrawTrSurf::GetCurve2d(a[2]);
117 Handle(Geom2d_Curve) Res;
118 Standard_Real f, l, rf, rl;
119 f = atof(a[3]);
120 l = atof(a[4]);
121 rf = atof(a[5]);
122 rl = atof(a[6]);
123
124 GeomLib::SameRange(Precision::PConfusion(), C,
125 f, l, rf, rl, Res);
126
127 DrawTrSurf::Set(a[1],Res);
128
129 return 0;
130
131}
132
133//=======================================================================
134//function : ModificationCommands
135//purpose :
136//=======================================================================
137
138
139void GeomliteTest::ModificationCommands(Draw_Interpretor& theCommands)
140{
141 static Standard_Boolean loaded = Standard_False;
142 if (loaded) return;
143 loaded = Standard_True;
144
145 DrawTrSurf::BasicCommands(theCommands);
146
147 const char* g;
148
149 g = "GEOMETRY Curves and Surfaces modification";
150
151
152 theCommands.Add("extendcurve",
153 "extendcurve name point cont [A(fter)/B(efore)]",
154 __FILE__,
155 extendcurve , g);
156
157
158 theCommands.Add("extendsurf",
159 "extendsurf name length cont [U/V] [A(fter)/B(efore)]",
160 __FILE__,
161 extendsurf, g);
162
163
164 theCommands.Add("chgrange",
165 "chgrange newname curve2d first last RequestedFirst RequestedLast ]",
166 __FILE__,
167 samerange, g);
168
169}
170
171
172
173