Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2002-06-17 |
2 | // Created by: QA Admin | |
3 | // Copyright (c) 2002-2012 OPEN CASCADE SAS | |
4 | // | |
5 | // The content of this file is subject to the Open CASCADE Technology Public | |
6 | // License Version 6.5 (the "License"). You may not use the content of this file | |
7 | // except in compliance with the License. Please obtain a copy of the License | |
8 | // at http://www.opencascade.org and read it completely before using this file. | |
9 | // | |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |
12 | // | |
13 | // The Original Code and all software distributed under the License is | |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the | |
15 | // Initial Developer hereby disclaims all such warranties, including without | |
16 | // limitation, any warranties of merchantability, fitness for a particular | |
17 | // purpose or non-infringement. Please see the License for the specific terms | |
18 | // and conditions governing the rights and limitations under the License. | |
19 | ||
1cd84fee | 20 | #include <QABugs.hxx> |
7fd59977 | 21 | #ifdef HAVE_CONFIG_H |
22 | #include <config.h> | |
23 | #endif | |
91322f44 | 24 | #include <Draw.hxx> |
25 | #include <Draw_Interpretor.hxx> | |
26 | #include <TopLoc_Location.hxx> | |
27 | #include <TopoDS_Face.hxx> | |
28 | #include <TopoDS.hxx> | |
29 | #include <DBRep.hxx> | |
30 | #include <Geom_Surface.hxx> | |
31 | #include <BRep_Tool.hxx> | |
32 | #include <GeomInt_IntSS.hxx> | |
33 | #include <BRepBuilderAPI_MakeEdge.hxx> | |
7fd59977 | 34 | #include <Standard_ErrorHandler.hxx> |
4269bd1b | 35 | #include <Graphic3d_ClipPlane.hxx> |
91322f44 | 36 | #include <tcl.h> |
7fd59977 | 37 | |
64531d9c | 38 | #include <fstream> |
39 | ||
7fd59977 | 40 | static int BUC60623(Draw_Interpretor& di, Standard_Integer argc, const char ** a) |
41 | { | |
42 | if(argc!=4) | |
43 | { | |
44 | di << "Usage : " << a[0] << " result Shape1 Shape2" << "\n"; | |
45 | return -1; | |
46 | } | |
47 | ||
48 | TopLoc_Location L1; | |
49 | TopLoc_Location L2; | |
50 | TopoDS_Face F1 = TopoDS::Face(DBRep::Get(a[2],TopAbs_FACE)); | |
51 | TopoDS_Face F2 = TopoDS::Face(DBRep::Get(a[3],TopAbs_FACE)); | |
52 | Handle(Geom_Surface) GSF1 = BRep_Tool::Surface(F1, L1); | |
53 | Handle(Geom_Surface) GSF2 = BRep_Tool::Surface(F2, L2); | |
54 | GeomInt_IntSS Inter; | |
55 | Inter.Perform(GSF1,GSF2, BRep_Tool::Tolerance(F1)); | |
56 | if (!Inter.IsDone()) { | |
57 | di << "Intersection not done" << "\n"; | |
58 | return 1; | |
59 | } | |
60 | Standard_Integer nbsol = Inter.NbLines(); | |
61 | if(!nbsol) { | |
62 | di << "The number of solutions is zero!" << "\n"; | |
63 | return 0; | |
64 | } | |
65 | Handle(Geom_Curve) Sol = Inter.Line(1); | |
66 | if(!Sol.IsNull()) { | |
67 | DBRep::Set(a[1], BRepBuilderAPI_MakeEdge(Sol)); | |
68 | return 0; | |
69 | } else di << "The first solution is Null!" << "\n"; | |
70 | ||
71 | di << "fini" << "\n"; | |
72 | return 0; | |
73 | } | |
74 | ||
75 | #include<ViewerTest.hxx> | |
76 | #include<AIS_InteractiveContext.hxx> | |
77 | #include<AIS_Shape.hxx> | |
78 | ||
79 | static int BUC60569(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
80 | { | |
81 | if(argc!=2) | |
82 | { | |
83 | di << "Usage : " << argv[0] << " shape" << "\n"; | |
84 | return -1; | |
85 | } | |
86 | ||
87 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); | |
88 | if(myAISContext.IsNull()) { | |
89 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
90 | return -1; | |
91 | } | |
92 | ||
93 | TopoDS_Shape theShape = DBRep::Get(argv[1]); | |
94 | ||
95 | Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape ); | |
96 | myAISContext->Display( anAISShape, Standard_True ); | |
97 | myAISContext->OpenLocalContext(); | |
98 | myAISContext->ActivateStandardMode(TopAbs_FACE); | |
99 | return 0; | |
100 | } | |
101 | ||
102 | static int BUC60614(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
103 | { | |
104 | if(argc!=2) | |
105 | { | |
106 | di << "Usage : "<< argv[0] << " shape" << "\n"; | |
107 | return -1; | |
108 | } | |
109 | ||
110 | // di.Eval("vinit"); | |
111 | ||
112 | TopoDS_Shape theShape = DBRep::Get(argv[1]); | |
113 | ||
114 | // ViewerTest::GetAISContext(); | |
115 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); | |
116 | if(myAISContext.IsNull()) { | |
117 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
118 | return -1; | |
119 | } | |
120 | Handle(AIS_Shape) anAISShape = new AIS_Shape( theShape ); | |
121 | myAISContext->Display( anAISShape, Standard_True ); | |
122 | myAISContext->OpenLocalContext(); | |
123 | myAISContext->ActivateStandardMode(TopAbs_COMPOUND); | |
124 | // myAISContext->ActivateStandardMode(TopAbs_SOLID); | |
125 | // di.Eval("vfit"); | |
126 | // cout << "vfini" << endl; | |
127 | return 0; | |
128 | } | |
129 | ||
130 | #include<BRep_Builder.hxx> | |
131 | #include<BRepTools_ShapeSet.hxx> | |
132 | #include<BRepTools.hxx> | |
133 | #include<BRepAdaptor_HSurface.hxx> | |
134 | #include<TopOpeBRep_PointClassifier.hxx> | |
135 | #include<Precision.hxx> | |
136 | #ifdef WNT | |
137 | #include<stdio.h> | |
138 | #endif | |
139 | ||
140 | static int BUC60609(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { | |
7fd59977 | 141 | gp_Pnt2d uvSurf; |
7fd59977 | 142 | TopAbs_State state; |
143 | ||
ceeaafcb | 144 | if (argc == 3) { |
145 | // BUC60609 shape name | |
146 | } else if ( argc == 5 ) { | |
147 | // BUC60609 shape name U V | |
148 | } else { | |
149 | di << "Usage : "<< argv[0] << " shape name [U V]" << "\n"; | |
7fd59977 | 150 | return(-1); |
151 | } | |
7fd59977 | 152 | |
f1e162f2 | 153 | TCollection_AsciiString aFilePath(argv[1]); |
7fd59977 | 154 | |
155 | filebuf fic; | |
156 | istream in(&fic); | |
f1e162f2 | 157 | if (!fic.open(aFilePath.ToCString(),ios::in)) { |
158 | di << "Cannot open file for reading : " << aFilePath << "\n"; | |
7fd59977 | 159 | return(-1); |
160 | } | |
161 | ||
162 | TopoDS_Shape theShape; | |
163 | char typ[255]; | |
164 | in >> typ; | |
165 | if (!in.fail()) { | |
166 | if( !strcmp(typ, "DBRep_DrawableShape") ){ | |
167 | BRep_Builder B; | |
168 | BRepTools_ShapeSet S(B); | |
169 | S.Read(in); | |
170 | S.Read(theShape,in); | |
171 | }else{ | |
f1e162f2 | 172 | di << "Wrong entity type in " << aFilePath << "\n"; |
7fd59977 | 173 | return(-1); |
174 | } | |
175 | } | |
176 | ||
177 | const TopoDS_Face &face = TopoDS::Face (theShape); | |
178 | ||
179 | if(argc > 2){ | |
180 | DBRep::Set(argv[2],face); | |
181 | } | |
182 | ||
7fd59977 | 183 | Standard_Real faceUMin,faceUMax,faceVMin,faceVMax; |
184 | ||
185 | BRepTools::UVBounds (face, faceUMin,faceUMax,faceVMin,faceVMax); | |
186 | ||
187 | di << "The bounds of the trimmed face:" << "\n"; | |
188 | di << faceUMin << " <= U <= " << faceUMax << "\n"; | |
189 | di << faceVMin << " <= V <= " << faceVMax << "\n"; | |
190 | ||
191 | Handle(BRepAdaptor_HSurface) hsurfa = new BRepAdaptor_HSurface(face); | |
192 | ||
193 | TopOpeBRep_PointClassifier PClass; | |
194 | ||
195 | di << "Now test the point classifier by inputting U,V values" << "\n"; | |
196 | di << "inside or outside the bounds displayed above" << "\n"; | |
197 | di << "Type stop to exit" << "\n"; | |
198 | ||
199 | // Please register this: | |
200 | // *********************************************** | |
201 | // Note also that for periodic surfaces such as nimpod_1.topo, | |
202 | // the U/V values may be +- 2pi compared to the actual face bounds | |
203 | // (because U,V is probably coming from a Geom package routine). | |
204 | // Hence IT WOULD BE USEFUL IF TopOpeBRep_PointClassifier COULD | |
205 | // COPE WITH PERIODIC SURFACES, i.e. U,V +-Period giving same result. | |
206 | // ************************************************* | |
7fd59977 | 207 | |
ceeaafcb | 208 | if (argc == 3) { |
209 | uvSurf = gp_Pnt2d(0.14,5.1); | |
210 | state = PClass.Classify(face,uvSurf,Precision::PConfusion()); | |
211 | if(state == TopAbs_IN || state == TopAbs_ON){ | |
212 | di << "U=" << 0.14 << " V=" << 5.1 << " classified INSIDE" << "\n"; | |
213 | }else{ | |
214 | di << "U=" << 0.14 << " V=" << 5.1 << " classified OUTSIDE" << "\n"; | |
215 | } | |
216 | ||
217 | uvSurf = gp_Pnt2d(1.28,5.1); | |
218 | state = PClass.Classify(face,uvSurf,Precision::PConfusion()); | |
219 | if(state == TopAbs_IN || state == TopAbs_ON){ | |
220 | di << "U=" << 1.28 << " V=" << 5.1 << " classified INSIDE" << "\n"; | |
221 | }else{ | |
222 | di << "U=" << 1.28 << " V=" << 5.1 << " classified OUTSIDE" << "\n"; | |
223 | } | |
224 | } else { | |
91322f44 | 225 | uvSurf = gp_Pnt2d(Draw::Atof(argv[3]),Draw::Atof(argv[4])); |
ceeaafcb | 226 | state = PClass.Classify(face,uvSurf,Precision::PConfusion()); |
227 | if(state == TopAbs_IN || state == TopAbs_ON){ | |
91322f44 | 228 | di << "U=" << Draw::Atof(argv[3]) << " V=" << Draw::Atof(argv[4]) << " classified INSIDE" << "\n"; |
ceeaafcb | 229 | }else{ |
91322f44 | 230 | di << "U=" << Draw::Atof(argv[3]) << " V=" << Draw::Atof(argv[4]) << " classified OUTSIDE" << "\n"; |
7fd59977 | 231 | } |
232 | } | |
233 | return 0; | |
234 | } | |
235 | ||
ceeaafcb | 236 | |
7fd59977 | 237 | #if ! defined(WNT) |
238 | void stringerror(int state) | |
239 | { | |
240 | printf("%s",((state&ios::eofbit) !=0)? " [eof]": ""); | |
241 | printf("%s",((state&ios::failbit)!=0)? " [fail]":""); | |
242 | printf("%s",((state&ios::badbit) !=0)? " [bad]": ""); | |
243 | printf("%s\n",(state==ios::goodbit)? " [ok]": ""); | |
244 | } | |
245 | ||
246 | ||
247 | //#if defined(LIN) | |
248 | //#include <strstream> | |
249 | //#else | |
250 | //#include <strstream.h> | |
251 | //#endif | |
252 | #ifdef HAVE_IOSTREAM | |
253 | #include <iostream> | |
254 | #include <sstream> | |
255 | using namespace std; | |
256 | #elif defined (HAVE_IOSTREAM_H) | |
257 | #include <iostream.h> | |
258 | #include <strstream.h> | |
259 | #else | |
260 | #error "check config.h file or compilation options: either HAVE_IOSTREAM or HAVE_IOSTREAM_H should be defined" | |
261 | #endif | |
262 | static int UKI61075(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** /*argv*/) { | |
263 | double da,db; | |
264 | char buffer1[128]; | |
265 | #ifndef USE_STL_STREAM | |
266 | ostrstream stringout1(buffer1,sizeof(buffer1)); | |
267 | istrstream stringin1(buffer1,sizeof(buffer1)); | |
268 | #else | |
269 | ostringstream stringout1(buffer1); | |
270 | istringstream stringin1(buffer1); | |
271 | #endif | |
272 | char buffer2[128]; | |
273 | #ifndef USE_STL_STREAM | |
274 | ostrstream stringout2(buffer2,sizeof(buffer2)); | |
275 | istrstream stringin2(buffer2,sizeof(buffer2)); | |
276 | #else | |
277 | ostringstream stringout2(buffer1); | |
278 | istringstream stringin2(buffer1); | |
279 | #endif | |
280 | ||
281 | stringout1.precision(17); | |
282 | stringout2.precision(17); | |
283 | ||
284 | da=-(DBL_MAX); | |
285 | db=DBL_MAX; | |
286 | printf("Valeurs originales :\n\t%.17lg %.17lg\n",da,db); | |
287 | ||
288 | stringout1<<da<<' '<<db<<"\n"; | |
289 | #ifndef USE_STL_STREAM | |
290 | buffer1[stringout1.pcount()]='\0'; | |
291 | #else | |
292 | buffer1[stringout1.str().length()]= '\0' ; | |
293 | #endif | |
294 | ||
295 | printf("Valeurs ecrites dans le fichier :\n\t%s",buffer1); | |
296 | ||
297 | da=db=0.; | |
298 | stringin1>>da>>db; | |
299 | printf("Valeurs relues :\n\t%.17lg %.17lg",da,db); | |
300 | stringerror(stringin1.rdstate()); | |
301 | ||
302 | stringout2<<da<<' '<<db<<"\n"; | |
303 | #ifndef USE_STL_STREAM | |
304 | buffer2[stringout2.pcount()]='\0'; | |
305 | #else | |
306 | buffer2[stringout2.str().length()]='\0'; | |
307 | #endif | |
308 | ||
309 | printf("Valeurs reecrites :\n\t%s",buffer2); | |
310 | ||
311 | da=db=0.; | |
312 | stringin2>>da>>db; | |
313 | printf("Valeurs relues a nouveau :\n\t%.17lg %.17lg",da,db); | |
314 | stringerror(stringin2.rdstate()); | |
315 | ||
316 | return(0); | |
317 | } | |
318 | #endif | |
319 | ||
320 | #include<BRepAlgoAPI_Section.hxx> | |
321 | #include<BRepAlgo_Section.hxx> | |
322 | ||
323 | #include<Geom_Plane.hxx> | |
324 | #include<DrawTrSurf.hxx> | |
325 | ||
326 | //static Standard_CString St = " \"trimsphere\"/\"sphere\" [result] [name] [plane]"; | |
327 | static Standard_CString St = " \"trimsphere\"/\"sphere\" [result] [name] [plane] [BRepAlgoAPI/BRepAlgo = 1/0]"; | |
328 | ||
329 | static int BUC60585(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { | |
330 | ||
331 | //if(argc<2) { | |
332 | // cerr << "Usage : " << argv[0] << St << endl; | |
333 | // return -1; | |
334 | //} | |
335 | if(argc < 2 || argc > 6) { | |
336 | di << "Usage : " << argv[0] << " shape1 shape2 shape3 shape4 shape5 shape6 [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n"; | |
337 | return 1; | |
338 | } | |
339 | Standard_Boolean IsBRepAlgoAPI = Standard_True; | |
340 | if (argc == 6) { | |
91322f44 | 341 | Standard_Integer IsB = Draw::Atoi(argv[5]); |
7fd59977 | 342 | if (IsB != 1) { |
343 | IsBRepAlgoAPI = Standard_False; | |
344 | #if ! defined(BRepAlgo_def04) | |
345 | // di << "Error: There is not BRepAlgo_Section class" << "\n"; | |
346 | // return 1; | |
347 | #endif | |
348 | } | |
349 | } | |
350 | ||
351 | ||
352 | gp_Dir N; | |
353 | if(!strcmp(argv[1],"trimsphere")) { | |
354 | ////////////////////////////////////////// | |
355 | // Uncomment for trimmed sphere bug: | |
356 | // filename = "trimsphere.topo"; | |
357 | N=gp_Dir( 0.0, -1.0, 0.0 ); | |
358 | ////////////////////////////////////////// | |
359 | } else if(!strcmp(argv[1],"sphere")) { | |
360 | ||
361 | ////////////////////////////////////////// | |
362 | // Uncomment for untrimmed sphere bug: | |
363 | ||
364 | // filename="sphere.topo"; | |
365 | N=gp_Dir( 0.0, -0.75103523489975432, -0.66026212668838646 ); | |
366 | ||
367 | ////////////////////////////////////////// | |
368 | } else { | |
369 | di << "Usage : " << argv[0] << St << "\n"; | |
370 | return -1; | |
371 | } | |
372 | ||
373 | // MKV 30.03.05 | |
374 | #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST) | |
375 | const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY); | |
376 | #else | |
377 | Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY); | |
378 | #endif | |
379 | ||
380 | Standard_Character *filename = new Standard_Character [strlen(DD)+17]; | |
91322f44 | 381 | Sprintf(filename,"%s/%s.topo",DD,argv[1]); |
7fd59977 | 382 | |
383 | filebuf fic; | |
384 | istream in(&fic); | |
385 | if (!fic.open(filename,ios::in)) { | |
386 | di << "Cannot open file for reading : " << filename << "\n"; | |
f1e162f2 | 387 | delete [] filename; |
7fd59977 | 388 | return -1; |
389 | } | |
390 | ||
391 | // Read in the shape | |
392 | ||
393 | BRep_Builder B; | |
394 | BRepTools_ShapeSet S(B); | |
395 | S.Read(in); | |
396 | TopoDS_Shape theShape; | |
397 | S.Read(theShape,in); | |
398 | ||
399 | // Create the plane | |
400 | ||
401 | gp_Pnt O( 2036.25, -97.5, -1460.499755859375 ); | |
402 | gp_Dir A( 1.0, 0.0, 0.0 ); | |
403 | ||
404 | gp_Ax3 PLA( O, N, A ); | |
405 | gp_Pln Pl(PLA); | |
406 | ||
407 | // Perform the section | |
408 | ||
409 | //#if ! defined(BRepAlgoAPI_def01) | |
410 | // BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False); | |
411 | //#else | |
412 | // BRepAlgo_Section Sec( theShape, Pl, Standard_False); | |
413 | //#endif | |
414 | ||
415 | TopoDS_Shape res; | |
416 | ||
417 | try{ | |
418 | OCC_CATCH_SIGNALS | |
419 | // Sec.Approximation(Standard_True); | |
420 | ||
421 | //Sec.Build(); | |
422 | //if(!Sec.IsDone()){ | |
423 | // cout << "Error performing intersection: not done." << endl; | |
424 | // delete filename; | |
425 | // return -1; | |
426 | //} | |
427 | //res = Sec.Shape(); | |
428 | ||
429 | if (IsBRepAlgoAPI) { | |
430 | di << "BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False)" <<"\n"; | |
431 | BRepAlgoAPI_Section Sec( theShape, Pl, Standard_False); | |
432 | Sec.Build(); | |
433 | if(!Sec.IsDone()){ | |
434 | di << "Error performing intersection: not done." << "\n"; | |
f1e162f2 | 435 | delete [] filename; |
7fd59977 | 436 | return -1; |
437 | } | |
438 | res = Sec.Shape(); | |
439 | } else { | |
440 | di << "BRepAlgo_Section Sec( theShape, Pl, Standard_False)" <<"\n"; | |
441 | BRepAlgo_Section Sec( theShape, Pl, Standard_False); | |
442 | Sec.Build(); | |
443 | if(!Sec.IsDone()){ | |
444 | di << "Error performing intersection: not done." << "\n"; | |
f1e162f2 | 445 | delete [] filename; |
7fd59977 | 446 | return -1; |
447 | } | |
448 | res = Sec.Shape(); | |
449 | } | |
450 | ||
451 | }catch(Standard_Failure){ | |
452 | Handle(Standard_Failure) error = Standard_Failure::Caught(); | |
453 | di << "Error performing intersection: not done." << "\n"; | |
f1e162f2 | 454 | delete [] filename; |
7fd59977 | 455 | return -1; |
456 | } | |
457 | ||
458 | if(argc>3) DBRep::Set(argv[3],theShape); | |
459 | ||
460 | if(argc>2) DBRep::Set(argv[2],res); | |
461 | ||
462 | if(argc>4) { | |
463 | Handle(Geom_Geometry) result; | |
464 | Handle(Geom_Plane) C = new Geom_Plane(Pl); | |
465 | result=C; | |
466 | DrawTrSurf::Set(argv[4],result); | |
467 | } | |
468 | ||
469 | di << "Done" << "\n"; | |
470 | ||
f1e162f2 | 471 | delete [] filename; |
7fd59977 | 472 | |
473 | return 0; | |
474 | } | |
475 | ||
476 | #include<TopoDS_Compound.hxx> | |
477 | ||
478 | static int BUC60547(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { | |
479 | if(argc!=2) { | |
480 | di << "Usage : " << argv[0] << " name" << "\n"; | |
481 | return -1; | |
482 | } | |
483 | ||
484 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); | |
485 | if(myAISContext.IsNull()) { | |
486 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
487 | return -1; | |
488 | } | |
489 | ||
490 | // MKV 30.03.05 | |
491 | #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST) | |
492 | const Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY); | |
493 | #else | |
494 | Standard_Character *DD = Tcl_GetVar(di.Interp(),"Draw_DataDir",TCL_GLOBAL_ONLY); | |
495 | #endif | |
496 | ||
497 | Standard_Character *Ch = new Standard_Character[strlen(argv[1])+3]; | |
498 | ||
499 | Standard_Character *FileName = new Standard_Character[strlen(DD)+13]; | |
500 | ||
501 | TopoDS_Shape free_1,free_2,free_3,free_4; | |
502 | BRep_Builder B; | |
91322f44 | 503 | Sprintf(FileName,"%s/%s",DD,"buc60547a.brep"); |
7fd59977 | 504 | BRepTools::Read(free_1,FileName,B); |
91322f44 | 505 | Sprintf(FileName,"%s/%s",DD,"buc60547b.brep"); |
7fd59977 | 506 | BRepTools::Read(free_2,FileName,B); |
91322f44 | 507 | Sprintf(FileName,"%s/%s",DD,"buc60547c.brep"); |
7fd59977 | 508 | BRepTools::Read(free_3,FileName,B); |
91322f44 | 509 | Sprintf(FileName,"%s/%s",DD,"buc60547d.brep"); |
7fd59977 | 510 | BRepTools::Read(free_4,FileName,B); |
91322f44 | 511 | Sprintf(Ch,"%s_%i",argv[1],1); |
7fd59977 | 512 | DBRep::Set(Ch,free_1); |
513 | di << Ch << " "; | |
91322f44 | 514 | Sprintf(Ch,"%s_%i",argv[1],2); |
7fd59977 | 515 | DBRep::Set(Ch,free_2); |
516 | di << Ch << " "; | |
91322f44 | 517 | Sprintf(Ch,"%s_%i",argv[1],3); |
7fd59977 | 518 | DBRep::Set(Ch,free_3); |
519 | di << Ch << " "; | |
91322f44 | 520 | Sprintf(Ch,"%s_%i",argv[1],4); |
7fd59977 | 521 | DBRep::Set(Ch,free_4); |
522 | di << Ch << " "; | |
523 | ||
524 | // Handle(AIS_Shape) S1 = new AIS_Shape(free_1); | |
525 | // Handle(AIS_Shape) S2 = new AIS_Shape(free_2); | |
526 | // Handle(AIS_Shape) S3 = new AIS_Shape(free_3); | |
527 | // Handle(AIS_Shape) S4 = new AIS_Shape(free_4); | |
528 | ||
529 | // Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); | |
530 | ||
531 | // myAISContext->Display(S1); | |
532 | // myAISContext->Display(S2); | |
533 | // myAISContext->Display(S3); | |
534 | // myAISContext->Display(S4); | |
535 | ||
536 | // di.Eval("vfit"); | |
537 | ||
538 | TopoDS_Compound Com; | |
539 | BRep_Builder bui; | |
540 | bui.MakeCompound(Com); | |
541 | bui.Add(Com,free_1); | |
542 | bui.Add(Com,free_2); | |
543 | bui.Add(Com,free_3); | |
544 | bui.Add(Com,free_4); | |
545 | ||
91322f44 | 546 | Sprintf(Ch,"%s_%c",argv[1],'c'); |
7fd59977 | 547 | DBRep::Set(Ch,Com); |
548 | di << Ch << " "; | |
549 | ||
550 | Handle(AIS_Shape) SC = new AIS_Shape(Com); | |
551 | myAISContext->Display(SC); // nothing on the screen If I save the compound : | |
552 | ||
91322f44 | 553 | Sprintf(FileName,"%s/%s",DD,"free.brep"); |
7fd59977 | 554 | |
555 | BRepTools::Write(Com,FileName); | |
556 | ||
f1e162f2 | 557 | delete [] Ch; |
558 | delete [] FileName; | |
7fd59977 | 559 | |
560 | return 0; | |
561 | } | |
562 | ||
563 | #include<BRepBuilderAPI_MakeVertex.hxx> | |
564 | #include<TCollection_ExtendedString.hxx> | |
565 | #include<AIS_LengthDimension.hxx> | |
566 | ||
567 | static Standard_Integer BUC60632(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a) | |
568 | { | |
569 | ||
570 | Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext(); | |
571 | if(myAIScontext.IsNull()) { | |
572 | di << "use 'vinit' command before " << a[0] << "\n"; | |
573 | return -1; | |
574 | } | |
575 | myAIScontext->EraseAll(); | |
576 | ||
577 | TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0,0,0)); | |
578 | TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10,10,0)); | |
579 | ||
580 | Handle(AIS_Shape) Ve1 = new AIS_Shape(V1); | |
581 | Handle(AIS_Shape) Ve2 = new AIS_Shape(V2); | |
582 | ||
583 | myAIScontext->Display(Ve1); | |
584 | myAIScontext->Display(Ve2); | |
585 | ||
586 | Handle(Geom_Plane) Plane1 = new Geom_Plane(gp_Pnt(0,0,0),gp_Dir(0,0,1)); | |
587 | TCollection_ExtendedString Ext1("Dim1"); | |
91322f44 | 588 | Handle(AIS_LengthDimension) Dim1 = new AIS_LengthDimension(V1,V2,Plane1,Draw::Atof(a[2]),Ext1); |
7fd59977 | 589 | |
91322f44 | 590 | myAIScontext->SetDisplayMode(Dim1, Draw::Atoi(a[1])); |
7fd59977 | 591 | myAIScontext->Display(Dim1); |
592 | return 0; | |
593 | } | |
594 | ||
595 | #include<TopoDS_Wire.hxx> | |
596 | ||
597 | static Standard_Integer BUC60652(Draw_Interpretor& di, Standard_Integer argc, const char ** argv ) | |
598 | { | |
599 | if(argc!=2) { | |
600 | di << "Usage : BUC60652 fase" << "\n"; | |
601 | return 1; | |
602 | } | |
603 | TopoDS_Shape shape = DBRep::Get( argv[1] ); | |
604 | TopoDS_Face face = TopoDS::Face( shape ); | |
605 | TopoDS_Wire ow = BRepTools::OuterWire( face ); | |
606 | DBRep::Set( "w", ow ); | |
607 | return 0; | |
608 | } | |
609 | ||
610 | #include <BRepAlgo_BooleanOperations.hxx> | |
611 | ||
612 | static Standard_Integer defNbPntMax = 30; | |
613 | static Standard_Real defTol3d = 1.e-7; | |
614 | static Standard_Real defTol2d = 1.e-7; | |
615 | static Standard_Boolean defRelativeTol=Standard_True; | |
616 | Standard_Integer NbPntMax = defNbPntMax; | |
617 | Standard_Real Toler3d =defTol3d; | |
618 | Standard_Real Toler2d = defTol2d; | |
619 | Standard_Boolean RelativeTol= defRelativeTol; | |
620 | // //== // ksection : operateur section appelant BRepAlgo_BooleanOperation | |
621 | //== // ksection : operateur section appelant BRepAlgo_BooleanOperations | |
622 | //======================================================================= | |
623 | Standard_Integer ksection(Draw_Interpretor& di, Standard_Integer n, const char ** a) { | |
624 | if (n < 8) { | |
625 | di << "Usage : " << a[0] << " resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol" << "\n"; | |
626 | return -1; | |
627 | } | |
628 | // a[1]= resultat | |
629 | // a[2]= shell1 | |
630 | // a[3]= shell2 | |
631 | // a[4]= NbPntMax | |
632 | // a[5]= Toler3d | |
633 | // a[6]= Toler2d | |
634 | // a[7]= RelativeTol | |
635 | TopoDS_Shape s1 = DBRep::Get(a[2],TopAbs_SHELL); | |
636 | TopoDS_Shape s2 = DBRep::Get(a[3],TopAbs_SHELL); | |
637 | if (s1.IsNull() || s2.IsNull()) return 1; | |
91322f44 | 638 | NbPntMax=Draw::Atoi(a[4]); |
639 | Toler3d=Draw::Atof(a[5]); | |
640 | Toler2d=Draw::Atof(a[6]); | |
641 | RelativeTol=Draw::Atoi(a[7]); | |
7fd59977 | 642 | |
643 | di << "BRepAlgo_BooleanOperations myalgo" << "\n"; | |
644 | BRepAlgo_BooleanOperations myalgo; | |
645 | ||
646 | myalgo.Shapes(s1, s2); | |
647 | myalgo.SetApproxParameters(NbPntMax,Toler3d,Toler2d,RelativeTol); | |
648 | TopoDS_Shape res; res = myalgo.Section(); | |
649 | DBRep::Set(a[1],res); | |
650 | return 0; | |
651 | } | |
652 | ||
653 | #include <Geom_Axis2Placement.hxx> | |
654 | #include <AIS_Trihedron.hxx> | |
655 | ||
656 | static Standard_Integer BUC60574(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a) | |
657 | { | |
658 | ||
659 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); | |
660 | if(myAISContext.IsNull()) { | |
661 | di << "use 'vinit' command before " << a[0] << "\n"; | |
662 | return -1; | |
663 | } | |
664 | ||
665 | Handle(Geom_Axis2Placement) atrihedronAxis = new Geom_Axis2Placement(gp::XOY()); | |
666 | Handle(AIS_Trihedron) atri = new AIS_Trihedron(atrihedronAxis); | |
667 | gp_Trsf aTrsf; | |
668 | gp_Vec trans(5,5,5); | |
669 | aTrsf.SetTranslation(trans); | |
670 | TopLoc_Location aLoc(aTrsf); | |
671 | myAISContext->SetLocation(atri,aLoc); | |
672 | myAISContext->Display(atri,0,-1,Standard_True, Standard_True); | |
673 | myAISContext->OpenLocalContext(Standard_False, | |
674 | Standard_True,Standard_False,Standard_False); | |
675 | myAISContext->Load(atri,3,Standard_True); | |
676 | ||
677 | return 0; | |
678 | } | |
679 | ||
680 | #include <TopoDS_Solid.hxx> | |
681 | #include <BRepPrimAPI_MakeBox.hxx> | |
682 | #include <BRepPrimAPI_MakeSphere.hxx> | |
683 | ||
684 | #include <BRepAlgoAPI_Fuse.hxx> | |
685 | #include <BRepAlgo_Fuse.hxx> | |
686 | ||
7fd59977 | 687 | #include <V3d_View.hxx> |
688 | #include <gce_MakePln.hxx> | |
689 | ||
7fd59977 | 690 | static Standard_Integer BUC60699(Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a) |
691 | { | |
692 | ||
693 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); | |
694 | if(myAISContext.IsNull()) { | |
695 | di << "use 'vinit' command before " << a[0] << "\n"; | |
696 | return -1; | |
697 | } | |
698 | TopoDS_Solid B1 = BRepPrimAPI_MakeBox (1,1,1).Solid(); | |
699 | TopAbs_ShapeEnum theType = B1.ShapeType(); | |
700 | if ( theType == TopAbs_SOLID ) { | |
701 | di << "It is a solid." << "\n"; | |
702 | } else { | |
703 | di << "It is not solid." << "\n"; | |
704 | } | |
705 | myAISContext->Display(new AIS_Shape(B1)); | |
706 | myAISContext->OpenLocalContext(); | |
707 | TopAbs_ShapeEnum amode = TopAbs_SOLID; | |
708 | myAISContext->ActivateStandardMode(amode); | |
709 | di.Eval("vfit"); | |
710 | di.Eval("QAMoveTo 200 200"); | |
711 | di.Eval("QASelect 200 200"); | |
712 | myAISContext->InitSelected() ; | |
713 | if ( myAISContext->MoreSelected() ) { | |
714 | if (myAISContext->HasSelectedShape() ) { | |
715 | di << "has selected shape : OK" << "\n"; | |
716 | } else { | |
717 | di << "has selected shape : bugged - Faulty " << "\n"; | |
718 | } | |
719 | } | |
720 | return 0; | |
721 | } | |
722 | ||
723 | static Standard_Integer GER61394(Draw_Interpretor& di, Standard_Integer argc, const char ** argv ) | |
724 | { | |
725 | if(argc > 2) { | |
726 | di << "Usage : " << argv[0] << " [1/0]" << "\n"; | |
727 | return -1; | |
728 | } | |
729 | ||
730 | Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext(); | |
731 | if(myAIScontext.IsNull()) { | |
732 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
733 | return -1; | |
734 | } | |
735 | Handle(V3d_View) myV3dView = ViewerTest::CurrentView(); | |
736 | ||
91322f44 | 737 | if((argc == 2) && (Draw::Atof(argv[1]) == 0)) |
7fd59977 | 738 | myV3dView->SetAntialiasingOff(); |
739 | else | |
740 | myV3dView->SetAntialiasingOn(); | |
741 | myV3dView->Update(); | |
742 | return 0; | |
743 | } | |
744 | ||
745 | ||
746 | #define DEFAULT_COLOR Quantity_NOC_GOLDENROD | |
747 | ||
748 | //======================================================================= | |
749 | //function : GetColorFromName | |
750 | //purpose : get the Quantity_NameOfColor from a string | |
751 | //======================================================================= | |
752 | ||
753 | static Quantity_NameOfColor GetColorFromName( const char *name ) | |
754 | { | |
755 | Quantity_NameOfColor ret = DEFAULT_COLOR; | |
756 | ||
757 | Standard_Boolean Found = Standard_False; | |
758 | Standard_CString colstring; | |
759 | for(Standard_Integer i=0;i<=514 && !Found;i++) | |
760 | { | |
761 | colstring = Quantity_Color::StringName(Quantity_NameOfColor(i)); | |
762 | if (!strcasecmp(name,colstring)) { | |
763 | ret = (Quantity_NameOfColor)i; | |
764 | Found = Standard_True; | |
765 | } | |
766 | } | |
767 | ||
768 | return ret; | |
769 | } | |
770 | ||
771 | static Standard_Integer setcolor (Draw_Interpretor& di,Standard_Integer argc, const char ** argv ) | |
772 | { | |
773 | ||
774 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); | |
775 | if(myAISContext.IsNull()) { | |
776 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
777 | return -1; | |
778 | } | |
779 | ||
780 | Handle(V3d_View) myV3dView = ViewerTest::CurrentView(); | |
781 | ||
782 | switch (argc){ | |
783 | ||
784 | case 2: | |
785 | { | |
786 | di <<"case 2 : This command will change the background color to " << argv[1]<< "\n"; | |
787 | // setcolor <name> | |
788 | // Change the background color of the view with a predefined name Graphic3d_NOC_<name> | |
789 | ||
790 | myV3dView -> SetBackgroundColor(GetColorFromName(argv[1])); | |
791 | myV3dView -> Redraw(); | |
792 | break; | |
793 | } | |
794 | ||
795 | case 3: | |
796 | { | |
797 | di <<"case 3 : This command will change the color of the objects to "<< argv[2]<< "\n"; | |
798 | // setcolor <object> <name> | |
799 | // Change the object color with a predefined name | |
800 | ||
801 | TopoDS_Shape aShape = DBRep::Get(argv[1]); | |
802 | Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape); | |
803 | myAISContext->SetColor(myShape,GetColorFromName(argv[2]),Standard_True); | |
804 | myAISContext->Display(myShape,Standard_True); | |
805 | myAISContext->UpdateCurrentViewer(); | |
806 | // return 0; | |
807 | break; | |
808 | } | |
809 | case 4: | |
810 | { | |
811 | di <<"case 4 : This command will change the background color to <r> <g> <b> :"<< argv[1] << argv[2] << argv[3] << "\n"; | |
812 | ||
813 | // setcolor <r> <g> <b> | |
814 | // Change the background color of the view with the color values <r>,<g>,<b> | |
815 | // A color value must be defined in the space [0.,1.] | |
816 | ||
91322f44 | 817 | Standard_Real QuantityOfRed = Draw::Atoi(argv[1]); |
818 | Standard_Real QuantityOfGreen = Draw::Atoi(argv[2]); | |
819 | Standard_Real QuantityOfBlue = Draw::Atoi(argv[3]); | |
7fd59977 | 820 | myV3dView->SetBackgroundColor(Quantity_TOC_RGB,QuantityOfRed,QuantityOfGreen,QuantityOfBlue); |
821 | myV3dView->Redraw(); | |
822 | break; | |
823 | } | |
824 | ||
825 | case 5: | |
826 | { | |
827 | di <<"case 5 : This command will change the color of the objects to <r> <g> <b> : "<<argv[2]<< argv[3]<< argv[4]<< "\n"; | |
828 | ||
829 | // setcolor <object> <r> <g> <b> | |
830 | // change the object color with RGB values. | |
831 | ||
832 | ||
91322f44 | 833 | Standard_Real QuantityOfRed = Draw::Atof(argv[2]); |
834 | Standard_Real QuantityOfGreen = Draw::Atof(argv[3]); | |
835 | Standard_Real QuantityOfBlue = Draw::Atof(argv[4]); | |
7fd59977 | 836 | |
837 | TopoDS_Shape aShape = DBRep::Get(argv[1]); | |
838 | Handle(AIS_InteractiveObject) myShape = new AIS_Shape (aShape); | |
839 | myAISContext->SetColor(myShape,Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB),Standard_True); | |
840 | myAISContext->Display(myShape,Standard_True); | |
841 | myAISContext->UpdateCurrentViewer(); | |
842 | // myShape->SetColor(Quantity_Color(QuantityOfRed,QuantityOfGreen,QuantityOfBlue,Quantity_TOC_RGB)); | |
843 | // myShape->Redisplay(); | |
844 | break; | |
845 | } | |
846 | } | |
847 | return 0; | |
848 | } | |
849 | ||
850 | static Standard_Integer BUC60726 (Draw_Interpretor& di,Standard_Integer argc, const char ** argv ) | |
851 | { | |
852 | Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext(); | |
853 | if(myAISContext.IsNull()) { | |
854 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
855 | return -1; | |
856 | } | |
857 | ||
858 | if(argc != 2) { | |
859 | di << "Usage : " << argv[0] << " 0/1" << "\n"; | |
860 | } | |
861 | ||
91322f44 | 862 | if(Draw::Atoi(argv[1]) == 0) { |
7fd59977 | 863 | myAISContext->CloseAllContexts(); |
864 | BRepPrimAPI_MakeBox B(gp_Pnt(-400.,-400.,-100.),200.,150.,100.); | |
865 | Handle(AIS_Shape) aBox = new AIS_Shape(B.Shape()); | |
866 | myAISContext->Display(aBox); | |
91322f44 | 867 | } else if(Draw::Atoi(argv[1]) == 1) { |
7fd59977 | 868 | myAISContext->CloseAllContexts(); |
869 | myAISContext->OpenLocalContext(); | |
870 | myAISContext->ActivateStandardMode(TopAbs_EDGE); | |
91322f44 | 871 | } else if(Draw::Atoi(argv[1]) == 2) { |
7fd59977 | 872 | myAISContext->CloseAllContexts(); |
873 | myAISContext->OpenLocalContext(); | |
874 | myAISContext->ActivateStandardMode(TopAbs_FACE); | |
875 | } else { | |
876 | di << "Usage : " << argv[0] << " 0/1" << "\n"; | |
877 | return -1; | |
878 | } | |
879 | ||
880 | return 0; | |
881 | } | |
882 | ||
883 | #include <BRepBndLib.hxx> | |
884 | #include <Bnd_HArray1OfBox.hxx> | |
885 | ||
35e08fe8 | 886 | static Standard_Integer BUC60729 (Draw_Interpretor& /*di*/,Standard_Integer /*argc*/, const char ** /*argv*/ ) |
7fd59977 | 887 | { |
888 | Bnd_Box aMainBox; | |
889 | TopoDS_Shape aShape = BRepPrimAPI_MakeBox(1,1,1).Solid(); | |
890 | ||
891 | BRepBndLib::Add(aShape , aMainBox ); | |
892 | ||
893 | Standard_Integer siMaxNbrBox = 6; | |
894 | Bnd_BoundSortBox m_BoundSortBox; | |
895 | m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox ); | |
896 | TopExp_Explorer aExplorer(aShape,TopAbs_FACE); | |
897 | Standard_Integer i; | |
898 | ||
899 | ||
900 | // Bnd_Box __emptyBox; // Box is void ! | |
901 | // Handle_Bnd_HArray1OfBox __aSetOfBox = new Bnd_HArray1OfBox( 1, siMaxNbrBox, __emptyBox ); | |
902 | ||
903 | for (i=1,aExplorer.ReInit(); aExplorer.More(); aExplorer.Next(),i++ ) | |
904 | { | |
905 | const TopoDS_Shape& aFace = aExplorer.Current(); | |
906 | Bnd_Box aBox; | |
907 | BRepBndLib::Add( aFace, aBox ); | |
908 | m_BoundSortBox.Add( aBox, i ); | |
909 | // __aSetOfBox->SetValue( i, aBox ); | |
910 | } | |
911 | // m_BoundSortBox.Initialize( aMainBox, siMaxNbrBox ); | |
912 | ||
913 | return 0; | |
914 | } | |
915 | ||
916 | static Standard_Integer BUC60724(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ ) | |
917 | { | |
918 | TCollection_AsciiString as1(""); | |
919 | TCollection_AsciiString as2('\0'); | |
5cbfdb41 | 920 | if(as1.ToCString() == NULL || as1.Length() != 0 || as1.ToCString()[0] != '\0') |
921 | di << "Error : the first string is not zero string : " << as1.ToCString() << "\n"; | |
7fd59977 | 922 | |
5cbfdb41 | 923 | if(as2.ToCString() == NULL || as2.Length() != 0 || as2.ToCString()[0] != '\0') |
924 | di << "Error : the second string is not zero string : " << as2.ToCString() << "\n"; | |
7fd59977 | 925 | |
926 | return 0; | |
927 | } | |
928 | ||
929 | #include <UnitsAPI.hxx> | |
930 | ||
931 | static Standard_Integer BUC60727(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/ ) | |
932 | { | |
933 | di <<"Program Test" << "\n"; | |
934 | UnitsAPI::SetLocalSystem(UnitsAPI_MDTV); //length is mm | |
935 | di <<"AnyToLS (3,mm) = " << UnitsAPI::AnyToLS(3.,"mm") << "\n"; // result was WRONG. | |
936 | ||
937 | return 0; | |
938 | } | |
939 | ||
940 | #include <gp_Circ.hxx> | |
941 | #include <Geom_Circle.hxx> | |
942 | #include <GeomAPI.hxx> | |
943 | #include <Geom2d_CartesianPoint.hxx> | |
944 | #include <Geom2dGcc_QualifiedCurve.hxx> | |
945 | #include <Geom2dGcc_Circ2d2TanRad.hxx> | |
946 | #include <Geom2d_Circle.hxx> | |
947 | #include <ProjLib.hxx> | |
948 | ||
949 | static Standard_Integer BUC60792(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv ) | |
950 | { | |
951 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
952 | if(aContext.IsNull()) { | |
953 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
954 | return -1; | |
955 | } | |
956 | ||
957 | gp_Pnt pt3d(0, 20, 150); | |
958 | gp_Ax2 anAx2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0), gp_Dir(0, 0, 1)); | |
959 | gp_Circ circ(anAx2, 50.0); | |
960 | Handle_Geom_Circle gcir = new Geom_Circle(circ); | |
961 | Handle_Geom_Plane pln = new Geom_Plane(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0))); | |
962 | Handle_Geom2d_Curve gcir1 = GeomAPI::To2d(gcir, pln->Pln()); | |
963 | TopoDS_Shape sh1 = BRepBuilderAPI_MakeEdge(gcir1, pln).Shape(); | |
964 | Handle_AIS_Shape ais1 = new AIS_Shape(sh1); | |
965 | aContext->SetColor(ais1, Quantity_NOC_INDIANRED); | |
966 | aContext->Display(ais1); | |
967 | DBRep::Set("sh0",sh1); | |
968 | gp_Pnt2d thepoint; | |
969 | // local_get_2Dpointfrom3Dpoint(pt3d, pln->Pln(), thepoint); | |
970 | thepoint = ProjLib::Project(pln->Pln(),pt3d); | |
971 | Handle_Geom2d_CartesianPoint ThePoint = new Geom2d_CartesianPoint(thepoint); | |
972 | Geom2dAdaptor_Curve acur1(gcir1) ; | |
973 | Geom2dGcc_QualifiedCurve qcur1(acur1, GccEnt_outside) ; | |
974 | Geom2dGcc_Circ2d2TanRad cirtanrad(qcur1, ThePoint, 200.0, 0.0001); | |
975 | printf("\n No. of solutions = %d\n", cirtanrad.NbSolutions()); | |
976 | Handle_Geom2d_Circle gccc; | |
977 | if( cirtanrad.NbSolutions() ) { | |
978 | for( int i = 1; i<=cirtanrad.NbSolutions(); i++) { | |
979 | gp_Circ2d ccc = cirtanrad.ThisSolution(i); | |
980 | gccc = new Geom2d_Circle(ccc); | |
981 | TopoDS_Shape sh = BRepBuilderAPI_MakeEdge(gccc, pln).Shape(); | |
982 | Standard_Character aStr[5]; | |
91322f44 | 983 | Sprintf(aStr,"sh%d",i); |
7fd59977 | 984 | DBRep::Set(aStr,sh); |
985 | Handle_AIS_Shape ais = new AIS_Shape(sh); | |
986 | if( i ==1 ) | |
987 | aContext->SetColor(ais, Quantity_NOC_GREEN); | |
988 | if( i == 2) | |
989 | aContext->SetColor(ais, Quantity_NOC_HOTPINK); | |
990 | aContext->Display(ais); | |
991 | Standard_Real ParSol1, ParSol2, ParArg1, ParArg2; | |
992 | gp_Pnt2d PntSol1, PntSol2; | |
993 | cirtanrad.Tangency1(i, ParSol1, ParArg1, PntSol1); | |
994 | printf("%f\t%f\t\t%f\t%f\n",ParSol1, ParArg1,PntSol1.X(),PntSol1.Y()); | |
995 | cirtanrad.Tangency2(i, ParSol2, ParArg2, PntSol2); | |
996 | printf("%f\t%f\t\t%f\t%f\n",ParSol2, ParArg2,PntSol2.X(),PntSol2.Y()); | |
997 | } | |
998 | } | |
999 | return 0; | |
1000 | } | |
1001 | ||
1002 | #include <TColgp_Array2OfPnt.hxx> | |
1003 | #include <Geom_BezierSurface.hxx> | |
1004 | #include <BRepBuilderAPI_MakeFace.hxx> | |
1005 | #include <BRepBuilderAPI_MakeWire.hxx> | |
1006 | #include <Geom_OffsetSurface.hxx> | |
1007 | #include <BRepFilletAPI_MakeFillet2d.hxx> | |
1008 | #include <GeomProjLib.hxx> | |
1009 | #include <Geom_TrimmedCurve.hxx> | |
1010 | ||
1011 | static Standard_Integer BUC60811(Draw_Interpretor& di, Standard_Integer argc, const char ** argv ) | |
1012 | { | |
1013 | if(argc == 4) { | |
1014 | TopLoc_Location L1; | |
1015 | TopoDS_Edge aEdge = TopoDS::Edge(DBRep::Get(argv[2],TopAbs_EDGE)); | |
1016 | TopoDS_Face aFace = TopoDS::Face(DBRep::Get(argv[3],TopAbs_FACE)); | |
1017 | Standard_Real f = 0.0, l = 0.0; | |
1018 | Handle(Geom_Curve) GC = BRep_Tool::Curve(aEdge,f,l); | |
1019 | Handle(Geom_Surface) GS = BRep_Tool::Surface(aFace, L1); | |
1020 | GC = new Geom_TrimmedCurve(GC, f, l); | |
1021 | Handle(Geom_Curve) projCurve = GeomProjLib::Project(GC,GS); | |
1022 | BRepBuilderAPI_MakeWire *myWire; | |
1023 | myWire = new BRepBuilderAPI_MakeWire(); | |
1024 | myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge()); | |
1025 | DBRep::Set(argv[1],myWire->Wire()); | |
1026 | return 0; | |
1027 | } | |
1028 | ||
1029 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
1030 | if(aContext.IsNull()) { | |
1031 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
1032 | return -1; | |
1033 | } | |
1034 | ||
1035 | //step 1. creating a Bezier Surface and a patch | |
1036 | TopoDS_Face FP; | |
1037 | TopoDS_Shape FP1; | |
1038 | TopoDS_Solid solid; | |
1039 | Handle(AIS_Shape) ais1; | |
1040 | Handle_AIS_Shape ais2; | |
1041 | Handle(Geom_BezierSurface) BZ1; | |
1042 | TColgp_Array2OfPnt array1(1,3,1,3); | |
1043 | array1.SetValue(1,1,gp_Pnt(0,100,0)); | |
1044 | array1.SetValue(1,2,gp_Pnt(200,100,0)); | |
1045 | array1.SetValue(1,3,gp_Pnt(400,100,0)); | |
1046 | array1.SetValue(2,1,gp_Pnt(0,200,100)); | |
1047 | array1.SetValue(2,2,gp_Pnt(200,200,100)); | |
1048 | array1.SetValue(2,3,gp_Pnt(400,200,100)); | |
1049 | array1.SetValue(3,1,gp_Pnt(0,300,0)); | |
1050 | array1.SetValue(3,2,gp_Pnt(200,300,0)); | |
1051 | array1.SetValue(3,3,gp_Pnt(400,300,0)); | |
1052 | BZ1 = new Geom_BezierSurface(array1); | |
1c72dff6 | 1053 | BRepBuilderAPI_MakeFace bzf1( BZ1, Precision::Confusion() ); |
7fd59977 | 1054 | TopoDS_Face F1= bzf1.Face(); |
1055 | ais1 = new AIS_Shape(F1); | |
1056 | DBRep::Set("F1",F1); | |
1057 | aContext->SetMaterial(ais1,Graphic3d_NOM_ALUMINIUM,Standard_False); | |
1058 | aContext->Display(ais1); | |
1059 | BRep_Builder B; | |
1060 | TopoDS_Shell shell; | |
1061 | B.MakeShell(shell); | |
1062 | B.Add(shell, bzf1); | |
1063 | B.MakeSolid(solid); | |
1064 | B.Add(solid,shell); | |
1065 | gp_Dir D(0, 0, 1.0f); | |
1066 | BRepBuilderAPI_MakeWire mkw; | |
1067 | gp_Pnt p1 = gp_Pnt(150., 150.0, 260.); | |
1068 | gp_Pnt p2 = gp_Pnt(350., 150., 260.); | |
1069 | BRepBuilderAPI_MakeEdge* E1 = new BRepBuilderAPI_MakeEdge(p1,p2); | |
1070 | mkw.Add(*E1); | |
1071 | p1 = gp_Pnt(350., 150., 260.); | |
1072 | p2 = gp_Pnt(350., 250., 260.); | |
1073 | BRepBuilderAPI_MakeEdge* E2 = new BRepBuilderAPI_MakeEdge(p1,p2); | |
1074 | mkw.Add(*E2); | |
1075 | p1 = gp_Pnt(350., 250., 260.); | |
1076 | p2 = gp_Pnt(300., 250.0, 260.); | |
1077 | BRepBuilderAPI_MakeEdge* E3 = new BRepBuilderAPI_MakeEdge(p1,p2); | |
1078 | mkw.Add(*E3); | |
1079 | p1 = gp_Pnt(300., 250.0, 260.); | |
1080 | p2 = gp_Pnt(200., 200.0, 260.); | |
1081 | BRepBuilderAPI_MakeEdge* E4 = new BRepBuilderAPI_MakeEdge(p1,p2); | |
1082 | mkw.Add(*E4); | |
1083 | p1 = gp_Pnt(200., 200.0, 260.); | |
1084 | p2 = gp_Pnt(150., 200.0, 260.); | |
1085 | BRepBuilderAPI_MakeEdge* E5 = new BRepBuilderAPI_MakeEdge(p1,p2); | |
1086 | mkw.Add(*E5); | |
1087 | p1 = gp_Pnt(150., 200.0, 260.); | |
1088 | p2 = gp_Pnt(150., 150.0, 260.); | |
1089 | BRepBuilderAPI_MakeEdge* E6 = new BRepBuilderAPI_MakeEdge(p1,p2); | |
1090 | mkw.Add(*E6); | |
1091 | FP = BRepBuilderAPI_MakeFace(mkw.Wire()); | |
1092 | ais2 = new AIS_Shape( FP ); | |
1093 | aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False); | |
1094 | aContext->Display( ais2 ); | |
1095 | ||
1096 | DBRep::Set("FP",FP); | |
1097 | ||
1098 | //step 2. offseting the surface. | |
1099 | Handle_Geom_OffsetSurface offsurf; | |
1100 | offsurf = new Geom_OffsetSurface(BZ1, -100); | |
1c72dff6 | 1101 | BRepBuilderAPI_MakeFace bzf2( offsurf, Precision::Confusion() ); |
7fd59977 | 1102 | TopoDS_Face F2= bzf2.Face(); |
1103 | Handle_AIS_Shape ais22 = new AIS_Shape(F2); | |
1104 | aContext->Display(ais22); | |
1105 | DBRep::Set("F2",F2); | |
1106 | ||
1107 | //step 3. filleting the patch. | |
1108 | //( I want to project wire of this patch on offseted surface above) | |
1109 | BRepFilletAPI_MakeFillet2d fillet( FP ); | |
1110 | TopExp_Explorer Ex; | |
1111 | Ex.Init(FP, TopAbs_VERTEX); | |
1112 | TopoDS_Vertex v1 = TopoDS::Vertex(Ex.Current()); | |
1113 | fillet.AddFillet(v1, 20); | |
c281a4a4 | 1114 | di << "\n" << "Error is " << fillet.Status() << "\n"; |
1115 | // printf("\nError is %d ", fillet.Status()); | |
7fd59977 | 1116 | Ex.Next(); |
1117 | TopoDS_Vertex V2 = TopoDS::Vertex(Ex.Current()); | |
1118 | fillet.AddFillet(V2, 20); | |
c281a4a4 | 1119 | di << "\n" << "Error is " << fillet.Status() << "\n"; |
1120 | // printf("\nError is %d ", fillet.Status()); | |
7fd59977 | 1121 | fillet.Build(); |
1122 | FP1 = fillet.Shape(); | |
1123 | ais2 = new AIS_Shape( FP1 ); | |
1124 | aContext->SetMaterial(ais2,Graphic3d_NOM_ALUMINIUM,Standard_False); | |
1125 | aContext->Display( ais2 ); | |
1126 | ||
1127 | DBRep::Set("FP1",FP1); | |
1128 | ||
1129 | //step 4. Projecting the wire of this patch on offsetted surface. | |
1130 | // TopExp_Explorer Ex; | |
1131 | BRepBuilderAPI_MakeWire *myWire; | |
1132 | myWire = new BRepBuilderAPI_MakeWire(); | |
1133 | for (Ex.Init( FP1, TopAbs_EDGE); Ex.More(); Ex.Next()) | |
1134 | { | |
1135 | TopoDS_Edge e1 = TopoDS::Edge(Ex.Current()); | |
1136 | Standard_Real f = 0.0, l = 0.0; | |
1137 | Handle_Geom_Curve newBSplin = BRep_Tool::Curve(e1, f, l); | |
1138 | newBSplin = new Geom_TrimmedCurve(newBSplin, f, l); | |
1139 | Handle(Geom_Curve) projCurve = GeomProjLib::Project(newBSplin,offsurf); | |
1140 | myWire->Add((BRepBuilderAPI_MakeEdge(projCurve)).Edge()); | |
1141 | } | |
1142 | Handle_AIS_Shape ais33 = new AIS_Shape( myWire->Wire() ); | |
1143 | aContext->Display(ais33); | |
1144 | ||
1145 | DBRep::Set("Wire",myWire->Wire()); | |
1146 | ||
1147 | return 0; | |
1148 | } | |
1149 | ||
1150 | #include<GeomAPI_ExtremaCurveCurve.hxx> | |
1151 | ||
1152 | static int BUC60825(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1153 | ||
1154 | { | |
1155 | if(argc < 3){ | |
1156 | printf("Usage: %s edge1 edge2",argv[0]); | |
1157 | return(-1); | |
1158 | } | |
1159 | ||
1160 | TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(argv[1])), | |
1161 | E2 = TopoDS::Edge(DBRep::Get(argv[2])); | |
1162 | ||
1163 | Standard_Real fp , lp; | |
1164 | ||
1165 | Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1 , fp , lp), | |
1166 | C2 = BRep_Tool::Curve(E2 , fp , lp); | |
1167 | ||
1168 | GeomAPI_ExtremaCurveCurve aExt(C1 , C2); | |
1169 | ||
1170 | di << "NB RESULTS : " << aExt.NbExtrema() << "\n"; | |
1171 | ||
1172 | return 0; | |
1173 | } | |
1174 | ||
1175 | #include <BRepBuilderAPI_MakePolygon.hxx> | |
1176 | #include <BRepOffsetAPI_ThruSections.hxx> | |
1177 | ||
1178 | static int OCC10006(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1179 | { | |
1180 | if(argc > 2) { | |
1181 | di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n"; | |
1182 | return 1; | |
1183 | } | |
1184 | Standard_Boolean IsBRepAlgoAPI = Standard_True; | |
1185 | if (argc == 2) { | |
91322f44 | 1186 | Standard_Integer IsB = Draw::Atoi(argv[1]); |
7fd59977 | 1187 | if (IsB != 1) { |
1188 | IsBRepAlgoAPI = Standard_False; | |
1189 | #if ! defined(BRepAlgo_def01) | |
1190 | // di << "Error: There is not BRepAlgo_Fuse class" << "\n"; | |
1191 | // return 1; | |
1192 | #endif | |
1193 | } | |
1194 | } | |
1195 | ||
1196 | double bottompoints1[12] = { 10, -10, 0, 100, -10, 0, 100, -100, 0, 10, -100, 0}; | |
1197 | double toppoints1[12] = { 0, 0, 10, 100, 0, 10, 100, -100, 10, 0, -100, 10}; | |
1198 | double bottompoints2[12] = { 0, 0, 10.00, 100, 0, 10.00, 100, -100, 10.00, 0, -100, 10.00}; | |
1199 | double toppoints2[12] = { 0, 0, 250, 100, 0, 250, 100, -100, 250, 0, -100, 250}; | |
1200 | BRepBuilderAPI_MakePolygon bottompolygon1, toppolygon1, bottompolygon2, toppolygon2; | |
1201 | gp_Pnt tmppnt; | |
1202 | for (int i=0;i<4;i++) { | |
1203 | tmppnt.SetCoord(bottompoints1[3*i], bottompoints1[3*i+1], bottompoints1[3*i+2]); | |
1204 | bottompolygon1.Add(tmppnt); | |
1205 | tmppnt.SetCoord(toppoints1[3*i], toppoints1[3*i+1], toppoints1[3*i+2]); | |
1206 | toppolygon1.Add(tmppnt); | |
1207 | tmppnt.SetCoord(bottompoints2[3*i], bottompoints2[3*i+1], bottompoints2[3*i+2]); | |
1208 | bottompolygon2.Add(tmppnt); | |
1209 | tmppnt.SetCoord(toppoints2[3*i], toppoints2[3*i+1], toppoints2[3*i+2]); | |
1210 | toppolygon2.Add(tmppnt); | |
1211 | } | |
1212 | bottompolygon1.Close(); | |
1213 | DBRep::Set("B1",bottompolygon1.Shape()); | |
1214 | toppolygon1.Close(); | |
1215 | DBRep::Set("T1",toppolygon1.Shape()); | |
1216 | bottompolygon2.Close(); | |
1217 | DBRep::Set("B2",bottompolygon2.Shape()); | |
1218 | toppolygon2.Close(); | |
1219 | DBRep::Set("T2",toppolygon2.Shape()); | |
1220 | BRepOffsetAPI_ThruSections loft1(Standard_True, Standard_True); | |
1221 | loft1.AddWire(bottompolygon1.Wire()); | |
1222 | loft1.AddWire(toppolygon1.Wire()); | |
1223 | loft1.Build(); | |
1224 | BRepOffsetAPI_ThruSections loft2(Standard_True, Standard_True); | |
1225 | loft2.AddWire(bottompolygon2.Wire()); | |
1226 | loft2.AddWire(toppolygon2.Wire()); | |
1227 | loft2.Build(); | |
1228 | if (loft1.Shape().IsNull() || loft2.Shape().IsNull()) | |
1229 | return 1; | |
1230 | DBRep::Set("TS1",loft1.Shape()); | |
1231 | DBRep::Set("TS2",loft2.Shape()); | |
1232 | ||
1233 | //#if ! defined(BRepAlgoAPI_def01) | |
1234 | // BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape()); | |
1235 | //#else | |
1236 | // BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape()); | |
1237 | //#endif | |
1238 | if (IsBRepAlgoAPI) { | |
1239 | di << "BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n"; | |
1240 | BRepAlgoAPI_Fuse result(loft1.Shape(), loft2.Shape()); | |
1241 | DBRep::Set("F",result.Shape()); | |
1242 | } else { | |
1243 | di << "BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape())" <<"\n"; | |
1244 | BRepAlgo_Fuse result(loft1.Shape(), loft2.Shape()); | |
1245 | DBRep::Set("F",result.Shape()); | |
1246 | } | |
1247 | ||
1248 | // DBRep::Set("F",result.Shape()); | |
1249 | return 0; | |
1250 | } | |
1251 | ||
1252 | #include <Geom_RectangularTrimmedSurface.hxx> | |
1253 | #include <GC_MakeTrimmedCone.hxx> | |
1254 | ||
1255 | static Standard_Integer BUC60856(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv ) | |
1256 | { | |
1257 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
1258 | if(aContext.IsNull()) { | |
1259 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
1260 | return -1; | |
1261 | } | |
1262 | ||
1263 | gp_Ax2 Cone_Ax; | |
302f96fb | 1264 | double R1=8, R2=16, angle; |
7fd59977 | 1265 | gp_Pnt P0(0,0,0), |
1266 | P1(0,0,20), P2(0,0,45); | |
c6541a0c | 1267 | angle = 2*M_PI; |
7fd59977 | 1268 | Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value(); |
1c72dff6 | 1269 | TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape(); |
7fd59977 | 1270 | Handle(AIS_Shape) ais1 = new AIS_Shape(myshape); |
1271 | aContext->Display(ais1); | |
1272 | aContext->SetColor(ais1, Quantity_NOC_BLUE1); | |
1273 | ||
1274 | Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2,R1, 0).Value(); | |
1c72dff6 | 1275 | TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape(); |
7fd59977 | 1276 | Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2); |
1277 | aContext->Display(ais2); | |
1278 | aContext->SetColor(ais2, Quantity_NOC_RED); | |
1279 | return 0; | |
1280 | } | |
1281 | ||
7fd59977 | 1282 | //========================================================================== |
1283 | //function : CoordLoad | |
1284 | // chargement d une face dans l explorer. | |
1285 | //========================================================================== | |
64531d9c | 1286 | static Standard_Integer coordload (Draw_Interpretor& theDi, |
1287 | Standard_Integer theArgsNb, | |
1288 | const char** theArgVec) | |
7fd59977 | 1289 | { |
64531d9c | 1290 | if (theArgsNb < 3) |
1291 | { | |
1292 | return 1; | |
1293 | } | |
1294 | ||
1295 | std::ifstream aFile (theArgVec[2], ios::in); | |
1296 | if (!aFile) | |
1297 | { | |
1298 | theDi << "unable to open " << theArgVec[2] << " for input\n"; | |
1299 | return 2; | |
1300 | } | |
1301 | ||
1302 | char aLine[80]; | |
1303 | memset (aLine, 0, 40); | |
1304 | aFile.getline (aLine, 80); | |
1305 | ||
1306 | gp_Pnt aPnt (0.0, 0.0, 0.0); | |
1307 | aLine[40] = '\0'; | |
1308 | aPnt.SetY (Draw::Atof (&aLine[20])); | |
1309 | aLine[20] = '\0'; | |
1310 | aPnt.SetX (Draw::Atof (aLine)); | |
1311 | TopoDS_Vertex aVert1 = BRepBuilderAPI_MakeVertex (aPnt); | |
1312 | BRepBuilderAPI_MakeWire aMakeWire; | |
1313 | for (;;) | |
1314 | { | |
1315 | memset (aLine, 0, 40); | |
1316 | aFile.getline (aLine, 80); | |
1317 | if (!aFile) | |
7fd59977 | 1318 | { |
64531d9c | 1319 | break; |
7fd59977 | 1320 | } |
7fd59977 | 1321 | |
64531d9c | 1322 | aLine[40] = '\0'; |
1323 | aPnt.SetY (Draw::Atof (&aLine[20])); | |
1324 | aLine[20] = '\0'; | |
1325 | aPnt.SetX (Draw::Atof (aLine)); | |
1326 | TopoDS_Vertex aVert2 = BRepBuilderAPI_MakeVertex (aPnt); | |
1327 | aMakeWire.Add (BRepBuilderAPI_MakeEdge (aVert1, aVert2)); | |
1328 | aVert1 = aVert2; | |
1329 | } | |
1330 | aFile.close(); | |
7fd59977 | 1331 | |
64531d9c | 1332 | if (!aMakeWire.IsDone()) |
1333 | { | |
1334 | DBRep::Set (theArgVec[1], TopoDS_Face()); | |
1335 | return 0; | |
7fd59977 | 1336 | } |
7fd59977 | 1337 | |
64531d9c | 1338 | BRepBuilderAPI_MakeFace aMakeFace (aMakeWire.Wire()); |
1339 | DBRep::Set (theArgVec[1], aMakeFace.IsDone() ? aMakeFace.Face() : TopoDS_Face()); | |
7fd59977 | 1340 | return 0; |
1341 | } | |
7fd59977 | 1342 | |
1343 | static Standard_Integer TestMem (Draw_Interpretor& /*di*/, | |
1344 | Standard_Integer /*nb*/, | |
1345 | const char ** /*arg*/) | |
1346 | { | |
1347 | TCollection_ExtendedString aString(1024*1024, 'A'); | |
1348 | return 0; | |
1349 | } | |
1350 | ||
1351 | static Standard_Integer BUC60876_ (Draw_Interpretor& di, | |
1352 | Standard_Integer argc, | |
1353 | const char ** argv) | |
1354 | { | |
1355 | Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); | |
1356 | if(aContext.IsNull()) { | |
1357 | di << "use 'vinit' command before " << argv[0] << "\n"; | |
1358 | return -1; | |
1359 | } | |
1360 | if((argc != 2) && (argc != 3)) { | |
1361 | di<< "usage : " << argv[0] << " shape [mode==1]" << "\n"; | |
1362 | return -1; | |
1363 | } | |
1364 | TopoDS_Shape aShape = DBRep::Get(argv[1]); | |
1365 | Handle(AIS_InteractiveObject) anIO = new AIS_Shape(aShape); | |
1366 | // Handle(AIS_InteractiveObject) anIOa = ViewerTest::GetAISShapeFromName(argv[1]); | |
91322f44 | 1367 | anIO->SetHilightMode((argc == 3) ? Draw::Atoi(argv[2]) : 1); |
7fd59977 | 1368 | aContext->Display(anIO); |
1369 | return 0; | |
1370 | } | |
1371 | ||
1372 | //======================================================================= | |
1373 | //function : buc60773 | |
1374 | //purpose : | |
1375 | //======================================================================= | |
1376 | ||
1377 | #include<TCollection_HAsciiString.hxx> | |
1378 | ||
1379 | static Standard_Integer BUC60773 (Draw_Interpretor& /*di*/, Standard_Integer /*n*/, const char ** /*a*/) | |
1380 | { | |
1381 | Handle(TCollection_HAsciiString) hAscii = new TCollection_HAsciiString(); | |
1382 | Standard_CString aStr = hAscii->ToCString(); | |
1383 | TCollection_AsciiString aAscii(aStr); | |
1384 | ||
1385 | return 0; | |
1386 | } | |
1387 | ||
1388 | #include<BRepPrimAPI_MakeCylinder.hxx> | |
1389 | #include<BRepPrimAPI_MakeCone.hxx> | |
1390 | ||
1391 | static int TestCMD(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) | |
1392 | ||
1393 | { | |
1394 | if(argc > 2) { | |
1395 | di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n"; | |
1396 | return 1; | |
1397 | } | |
1398 | Standard_Boolean IsBRepAlgoAPI = Standard_True; | |
1399 | if (argc == 2) { | |
91322f44 | 1400 | Standard_Integer IsB = Draw::Atoi(argv[1]); |
7fd59977 | 1401 | if (IsB != 1) { |
1402 | IsBRepAlgoAPI = Standard_False; | |
1403 | #if ! defined(BRepAlgo_def01) | |
1404 | // di << "Error: There is not BRepAlgo_Fuse class" << "\n"; | |
1405 | // return 1; | |
1406 | #endif | |
1407 | } | |
1408 | } | |
1409 | ||
1410 | //Cylindre 36.085182 20.0 8.431413 88.04671 20.0 38.931416 10.0 | |
1411 | ||
1412 | Standard_Real x11 = 36.085182; | |
1413 | Standard_Real y11 = 20.0; | |
1414 | Standard_Real z11 = 8.431413; | |
1415 | Standard_Real x12 = 88.04671; | |
1416 | Standard_Real y12 = 20.0; | |
1417 | Standard_Real z12 = 38.931416; | |
1418 | Standard_Real radius = 10.0; | |
1419 | ||
1420 | gp_Pnt base1(x11, y11, z11); | |
1421 | gp_Dir vect1(x12-x11, y12-y11, z12-z11); | |
1422 | gp_Ax2 axis1(base1, vect1); | |
1423 | Standard_Real height1 = sqrt( ((x12-x11)*(x12-x11)) + ((y12-y11)*(y12-y11)) + ((z12-z11)*(z12-z11)) ); | |
1424 | BRepPrimAPI_MakeCylinder cylinder(axis1, radius, height1); | |
1425 | ||
1426 | TopoDS_Shape SCyl = cylinder.Shape(); | |
1427 | DBRep::Set("cyl", SCyl); | |
1428 | ||
1429 | ||
1430 | //Cone 70.7262 20.0 28.431412 105.36722 20.0 48.431416 6.0 3.0 | |
1431 | Standard_Real x21 = 70.7262; | |
1432 | Standard_Real y21 = 20.0; | |
1433 | Standard_Real z21 = 28.431412; | |
1434 | Standard_Real x22 = 105.36722; | |
1435 | Standard_Real y22 = 20.0; | |
1436 | Standard_Real z22 = 48.431416; | |
1437 | Standard_Real radius1 = 6.0; | |
1438 | Standard_Real radius2 = 3.0; | |
1439 | ||
1440 | gp_Pnt base2(x21, y21, z21); | |
1441 | gp_Dir vect2(x22-x21, y22-y21, z22-z21); | |
1442 | gp_Ax2 axis2(base2, vect2); | |
1443 | Standard_Real height2 = sqrt( ((x22-x21)*(x22-x21)) + ((y22-y21)*(y22-y21)) + ((z22-z21)*(z22-z21)) ); | |
1444 | BRepPrimAPI_MakeCone cone(axis2, radius1, radius2, height2); | |
1445 | ||
1446 | TopoDS_Shape SCon = cone.Shape(); | |
1447 | DBRep::Set("con", SCon); | |
1448 | ||
1449 | //#if ! defined(BRepAlgoAPI_def01) | |
1450 | // BRepAlgoAPI_Fuse SFuse(SCyl, SCon); | |
1451 | //#else | |
1452 | // BRepAlgo_Fuse SFuse(SCyl, SCon); | |
1453 | //#endif | |
1454 | // | |
1455 | // if(! SFuse.IsDone() ) | |
1456 | // cout<<"Error: Boolean fuse operation failed !"<<endl; | |
1457 | // | |
1458 | // TopoDS_Shape fuse = SFuse.Shape(); | |
1459 | ||
1460 | TopoDS_Shape fuse; | |
1461 | if (IsBRepAlgoAPI) { | |
1462 | di << "BRepAlgoAPI_Fuse SFuse(SCyl, SCon)" <<"\n"; | |
1463 | BRepAlgoAPI_Fuse SFuse(SCyl, SCon); | |
1464 | if(! SFuse.IsDone() ) | |
1465 | di<<"Error: Boolean fuse operation failed !"<<"\n"; | |
1466 | fuse = SFuse.Shape(); | |
1467 | } else { | |
1468 | di << "BRepAlgo_Fuse SFuse(SCyl, SCon)" <<"\n"; | |
1469 | BRepAlgo_Fuse SFuse(SCyl, SCon); | |
1470 | if(! SFuse.IsDone() ) | |
1471 | di<<"Error: Boolean fuse operation failed !"<<"\n"; | |
1472 | fuse = SFuse.Shape(); | |
1473 | } | |
1474 | ||
1475 | DBRep::Set("fus", fuse); | |
1476 | ||
1477 | return 0; | |
1478 | } | |
1479 | ||
1480 | #include <Dico_DictionaryOfInteger.hxx> | |
1481 | #include <TColStd_HSequenceOfAsciiString.hxx> | |
1482 | #include <TopExp.hxx> | |
1483 | #include <TopoDS_Iterator.hxx> | |
1484 | ||
1485 | //--------------------------------------------------------------------------------------- | |
1486 | ||
1487 | static Standard_Integer statface (Draw_Interpretor& di,Standard_Integer /*argc*/, const char ** argv ) | |
1488 | ||
1489 | { | |
1490 | TopoDS_Shape aShape = DBRep::Get(argv[1]); | |
1491 | if(aShape.IsNull()) | |
1492 | { | |
1493 | di<<"Invalid input shape"<<"\n"; | |
1494 | return 1; | |
1495 | } | |
1496 | Handle(Dico_DictionaryOfInteger) aDico = new Dico_DictionaryOfInteger(); | |
1497 | Handle(TColStd_HSequenceOfAsciiString) aSequence = new TColStd_HSequenceOfAsciiString; | |
1498 | Standard_CString aString; | |
302f96fb | 1499 | Standard_Integer i=1,j=1,l=1,aa=1; |
7fd59977 | 1500 | TopExp_Explorer expl; |
1501 | Standard_Real f3d,l3d; | |
1502 | for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next()) | |
1503 | { | |
1504 | // SURFACES | |
1505 | TopoDS_Face aFace = TopoDS::Face (expl.Current()); | |
1506 | Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace); | |
1507 | aString = aSurface->DynamicType()->Name(); | |
1508 | ||
1509 | if(aDico->GetItem(aString,aa) != 0) | |
1510 | { | |
1511 | aDico->GetItem(aString,aa); | |
1512 | aDico->SetItem(aString,aa+1); | |
1513 | } else { | |
1514 | aDico->SetItem(aString,1); | |
1515 | aSequence->Append(aString); | |
1516 | aa=1; | |
1517 | i++; | |
1518 | } | |
1519 | } | |
1520 | // PCURVES | |
1521 | for(expl.Init(aShape,TopAbs_FACE);expl.More();expl.Next()) | |
1522 | { | |
1523 | TopoDS_Face aFace = TopoDS::Face (expl.Current()); | |
1524 | TopoDS_Iterator anIt(aFace); | |
1525 | TopoDS_Wire aWire = TopoDS::Wire (anIt.Value()); | |
1526 | TopoDS_Iterator it (aWire); | |
1527 | for (; it.More(); it.Next()) { | |
1528 | TopoDS_Edge Edge = TopoDS::Edge (it.Value()); | |
1529 | Handle(Geom2d_Curve) aCurve2d = BRep_Tool::CurveOnSurface(Edge,aFace,f3d,l3d); | |
1530 | aString = aCurve2d->DynamicType()->Name(); | |
1531 | if(aDico->GetItem(aString,aa) != 0) | |
1532 | { | |
1533 | aDico->GetItem(aString,aa); | |
1534 | aDico->SetItem(aString,aa+1); | |
1535 | } else { | |
1536 | aDico->SetItem(aString,1); | |
1537 | aSequence->Append(aString); | |
1538 | i++; | |
1539 | aa=1; | |
1540 | } | |
1541 | } | |
1542 | } | |
1543 | // 3d CURVES | |
1544 | TopExp_Explorer exp; | |
1545 | for (exp.Init(aShape,TopAbs_EDGE); exp.More(); exp.Next()) | |
1546 | { | |
1547 | TopoDS_Edge Edge = TopoDS::Edge (exp.Current()); | |
1548 | Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (Edge,f3d,l3d); | |
1549 | if(aCurve3d.IsNull()) | |
1550 | { | |
1551 | l++; | |
1552 | goto aLabel; | |
1553 | } | |
1554 | aString = aCurve3d->DynamicType()->Name(); | |
1555 | if(aDico->GetItem(aString,aa) != 0) | |
1556 | { | |
1557 | aDico->GetItem(aString,aa); | |
1558 | aDico->SetItem(aString,aa+1); | |
1559 | } else { | |
1560 | aDico->SetItem(aString,1); | |
1561 | aSequence->Append(aString); | |
1562 | i++; | |
1563 | aa=1; | |
1564 | } | |
1565 | aLabel:; | |
1566 | } | |
1567 | // Output | |
1568 | di<<"\n"; | |
1569 | for(j=1;j<i;j++) | |
1570 | { | |
1571 | aDico->GetItem(aSequence->Value(j),aa); | |
1572 | di<<aa<<" -- "<<aSequence->Value(j).ToCString()<<"\n"; | |
1573 | } | |
1574 | ||
1575 | di<<"\n"; | |
1576 | di<<"Degenerated edges :"<<"\n"; | |
1577 | di<<l<<" -- "<<"Degenerated edges "<<"\n"; | |
1578 | ||
1579 | return 0; | |
1580 | ||
1581 | } | |
1582 | ||
1583 | #include <BRepBuilderAPI_Transform.hxx> | |
1584 | ||
1585 | static Standard_Integer BUC60841(Draw_Interpretor& di, Standard_Integer argc, const char ** argv ) | |
1586 | { | |
1587 | if(argc > 2) { | |
1588 | di << "Usage : " << argv[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n"; | |
1589 | return 1; | |
1590 | } | |
1591 | Standard_Boolean IsBRepAlgoAPI = Standard_True; | |
1592 | if (argc == 2) { | |
91322f44 | 1593 | Standard_Integer IsB = Draw::Atoi(argv[1]); |
7fd59977 | 1594 | if (IsB != 1) { |
1595 | IsBRepAlgoAPI = Standard_False; | |
1596 | #if ! defined(BRepAlgo_def01) | |
1597 | // di << "Error: There is not BRepAlgo_Fuse class" << "\n"; | |
1598 | // return 1; | |
1599 | #endif | |
1600 | } | |
1601 | } | |
1602 | ||
1603 | gp_Ax2 Ax2 = gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)); | |
1604 | BRepPrimAPI_MakeCylinder cyl(Ax2, 260, 150); | |
1605 | //BRepPrimAPI_MakeCylinder cyl(gp_Ax2(gp_Pnt(0, 621, 78), gp_Dir(0, 1,0)), 260, 150); | |
1606 | ||
1607 | TopoDS_Shape sh1 = cyl.Shape(); | |
1608 | DBRep::Set("sh1",sh1); | |
1609 | gp_Trsf trsf1, trsf2; | |
1610 | trsf1.SetTranslation(gp_Pnt(0.000000,700.000000,-170.000000), | |
1611 | gp_Pnt(0.000000,700.000000,-95.000000)); | |
1612 | trsf2.SetRotation(gp_Ax1(gp_Pnt(0.000000,700.000000,-170.000000), | |
1613 | gp_Dir(0.000000,0.000000,1.000000)), 0.436111); | |
1614 | BRepBuilderAPI_Transform trans1(sh1, trsf1); | |
1615 | TopoDS_Shape sh2 = trans1.Shape(); | |
1616 | DBRep::Set("sh2",sh2); | |
1617 | ||
1618 | //#if ! defined(BRepAlgoAPI_def01) | |
1619 | // BRepAlgoAPI_Fuse fuse1(sh1, sh2); | |
1620 | //#else | |
1621 | // BRepAlgo_Fuse fuse1(sh1, sh2); | |
1622 | //#endif | |
1623 | // | |
1624 | // TopoDS_Shape fsh1 = fuse1.Shape(); | |
1625 | ||
1626 | TopoDS_Shape fsh1; | |
1627 | if (IsBRepAlgoAPI) { | |
1628 | di << "BRepAlgoAPI_Fuse fuse1(sh1, sh2)" <<"\n"; | |
1629 | BRepAlgoAPI_Fuse fuse1(sh1, sh2); | |
1630 | fsh1 = fuse1.Shape(); | |
1631 | } else { | |
1632 | di << "BRepAlgo_Fuse fuse1(sh1, sh2)" <<"\n"; | |
1633 | BRepAlgo_Fuse fuse1(sh1, sh2); | |
1634 | fsh1 = fuse1.Shape(); | |
1635 | } | |
1636 | ||
1637 | DBRep::Set("fsh1",fsh1); | |
1638 | BRepBuilderAPI_Transform trans2(fsh1, trsf2); | |
1639 | TopoDS_Shape sh3 = trans2.Shape(); | |
1640 | DBRep::Set("sh3",sh3); | |
1641 | ||
1642 | //#if ! defined(BRepAlgoAPI_def01) | |
1643 | // BRepAlgoAPI_Fuse fuse2(fsh1,sh3); | |
1644 | //#else | |
1645 | // BRepAlgo_Fuse fuse2(fsh1,sh3); | |
1646 | //#endif | |
1647 | // | |
1648 | // TopoDS_Shape fsh2 = fuse2.Shape(); | |
1649 | ||
1650 | TopoDS_Shape fsh2; | |
1651 | if (IsBRepAlgoAPI) { | |
1652 | di << "BRepAlgoAPI_Fuse fuse2(fsh1,sh3)" <<"\n"; | |
1653 | BRepAlgoAPI_Fuse fuse2(fsh1,sh3); | |
1654 | fsh2 = fuse2.Shape(); | |
1655 | } else { | |
1656 | di << "BRepAlgo_Fuse fuse2(fsh1,sh3)" <<"\n"; | |
1657 | BRepAlgo_Fuse fuse2(fsh1,sh3); | |
1658 | fsh2 = fuse2.Shape(); | |
1659 | } | |
1660 | ||
1661 | DBRep::Set("fsh2",fsh2); | |
1662 | Handle_AIS_Shape aisp1 = new AIS_Shape(fsh2); | |
1663 | // aContext->Display(aisp1); | |
1664 | return 0; | |
1665 | } | |
1666 | ||
1667 | #include <ShapeBuild_Edge.hxx> | |
1668 | ||
1669 | static Standard_Integer BUC60874(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** argv ) | |
1670 | { | |
1671 | TopoDS_Edge e = TopoDS::Edge(DBRep::Get(argv[1],TopAbs_EDGE)); | |
1672 | ShapeBuild_Edge().BuildCurve3d(e); | |
1673 | DBRep::Set("ED",e); | |
1674 | return 0; | |
1675 | } | |
1676 | ||
1677 | ||
1678 | #include<TDF_Label.hxx> | |
1679 | #include<TDataStd_TreeNode.hxx> | |
1680 | ||
1681 | #include<DDocStd.hxx> | |
1682 | ||
1683 | #include<DDF.hxx> | |
1684 | ||
1685 | #include<TDocStd_Modified.hxx> | |
1686 | #include<TDF_ListIteratorOfDeltaList.hxx> | |
1687 | #include<TDocStd_Document.hxx> | |
1688 | #include<TDocStd_Application.hxx> | |
1689 | #include<TDF_Delta.hxx> | |
1690 | #include<TDataXtd_Constraint.hxx> | |
1691 | #include<TPrsStd_AISPresentation.hxx> | |
1692 | #include<TPrsStd_AISViewer.hxx> | |
1693 | #include<TNaming_Builder.hxx> | |
1694 | #include<TNaming_Naming.hxx> | |
1695 | #include<TNaming_NamedShape.hxx> | |
1696 | ||
1697 | static int BUC60817(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { | |
1698 | if(argc!=2) { | |
1699 | di << "Usage : " << argv[0] << " D" << "\n"; | |
1700 | di<<1; | |
1701 | return 0; | |
1702 | } | |
1703 | ||
1704 | Handle(TDF_Data) DF; | |
1705 | if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;} | |
1706 | ||
1707 | TDF_Label L1,L2; | |
1708 | Handle(TDataStd_TreeNode) TN1,TN2; | |
1709 | ||
1710 | DDF::AddLabel(DF,"0:2",L1); | |
1711 | TN1 = TDataStd_TreeNode::Set(L1); | |
1712 | ||
1713 | DDF::AddLabel(DF,"0:3",L2); | |
1714 | TN2 = TDataStd_TreeNode::Set(L2); | |
1715 | ||
1716 | TN1->Append(TN2); | |
1717 | if(!(TN2->IsDescendant(TN1))) {di<<3;return 0;} | |
1718 | if((TN1->IsDescendant(TN2))) {di<<4;return 0;} | |
1719 | ||
1720 | di<<0; | |
1721 | return 0; | |
1722 | } | |
1723 | ||
1724 | static int BUC60831_1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { | |
1725 | if(argc!=2) { | |
1726 | di << "Usage : " << argv[0] << " D" << "\n"; | |
1727 | di<<-1; | |
1728 | return 0; | |
1729 | } | |
1730 | ||
1731 | Handle(TDF_Data) DF; | |
1732 | if (!DDF::GetDF(argv[1],DF)) {di<<-2;return 0;} | |
1733 | ||
1734 | TDF_Label L; | |
1735 | DDF::FindLabel(DF,"0:1",L,Standard_False); | |
1736 | Handle(TDocStd_Modified) MDF; | |
1737 | if (!L.Root().FindAttribute (TDocStd_Modified::GetID(), MDF)) { | |
1738 | MDF = new TDocStd_Modified(); | |
1739 | L.Root().AddAttribute(MDF); | |
1740 | } | |
1741 | ||
1742 | di<<!MDF->IsEmpty(); | |
1743 | return 0; | |
1744 | } | |
1745 | ||
1746 | static int BUC60831_2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { | |
1747 | if(argc!=3) { | |
1748 | di << "Usage : " << argv[0] << " D Label" << "\n"; | |
1749 | di<<1; | |
1750 | return 0; | |
1751 | } | |
1752 | ||
1753 | Handle(TDF_Data) DF; | |
1754 | if (!DDF::GetDF(argv[1],DF)) {di<<2;return 0;} | |
1755 | ||
1756 | TDF_Label L; | |
1757 | DDF::FindLabel(DF,argv[2],L,Standard_False); | |
1758 | ||
1759 | TDocStd_Modified::Add(L); | |
1760 | ||
1761 | di<<0; | |
1762 | return 0; | |
1763 | } | |
1764 | ||
1765 | static int BUC60836(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { | |
1766 | if(argc!=2) { | |
1767 | di << "Usage : " << argv[0] << " D" << "\n"; | |
1768 | di<<1; | |
1769 | return 0; | |
1770 | } | |
1771 | ||
1772 | ||
1773 | Handle(TDF_Data) aDF; | |
1774 | if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;} | |
1775 | ||
1776 | Handle(TDocStd_Document) aDocument; | |
1777 | if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<3;return 0;} | |
1778 | ||
1779 | TDF_Label L; | |
1780 | Handle(TDataStd_TreeNode) TN; | |
1781 | ||
1782 | aDocument->NewCommand(); | |
1783 | DDF::AddLabel(aDF,"0:2",L); | |
1784 | TN = TDataStd_TreeNode::Set(L); | |
1785 | ||
1786 | aDocument->NewCommand(); | |
1787 | DDF::AddLabel(aDF,"0:3",L); | |
1788 | TN = TDataStd_TreeNode::Set(L); | |
1789 | ||
1790 | aDocument->NewCommand(); | |
1791 | DDF::AddLabel(aDF,"0:4",L); | |
1792 | TN = TDataStd_TreeNode::Set(L); | |
1793 | aDocument->NewCommand(); | |
1794 | ||
1795 | TDF_DeltaList Us,Rs; | |
1796 | Us = aDocument->GetUndos(); | |
1797 | Rs = aDocument->GetUndos(); | |
1798 | ||
1799 | Standard_Integer i; | |
1800 | char Names[10][5]={"n1","n2","n3","n4","n5","n6","n7","n8","n9","n10"}; | |
1801 | ||
1802 | TDF_ListIteratorOfDeltaList IDL; | |
1803 | for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){ | |
1804 | Handle(TDF_Delta) D = IDL.Value(); | |
1805 | TCollection_ExtendedString S(Names[i-1]); | |
1806 | D->SetName(S); | |
1807 | // cout<<" U"<<i<<"="<<D->Name()<<endl; | |
1808 | } | |
1809 | ||
1810 | aDocument->Undo(); | |
1811 | aDocument->Undo(); | |
1812 | ||
1813 | Us = aDocument->GetUndos(); | |
1814 | Rs = aDocument->GetRedos(); | |
1815 | ||
1816 | for(IDL.Initialize(Us),i=1;IDL.More();IDL.Next(),i++){ | |
1817 | Handle(TDF_Delta) D = IDL.Value(); | |
1818 | // cout<<" U"<<i<<"="<<D->Name()<<endl; | |
1819 | } | |
1820 | ||
1821 | TCollection_ExtendedString n2name ("n2"); | |
1822 | for(IDL.Initialize(Rs),i=1;IDL.More();IDL.Next(),i++){ | |
1823 | Handle(TDF_Delta) D = IDL.Value(); | |
1824 | if ( i == 1 && ! D->Name().IsEqual (n2name) ) | |
1825 | { | |
1826 | di << 4; | |
1827 | return 0; | |
1828 | } | |
1829 | } | |
1830 | ||
1831 | di<<0; | |
1832 | return 0; | |
1833 | } | |
1834 | ||
1835 | static int BUC60847(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { | |
1836 | if(argc!=3) { | |
1837 | di << "Usage : " << argv[0] << " D Shape" << "\n"; | |
1838 | di<<1; | |
1839 | return 0; | |
1840 | } | |
1841 | ||
1842 | Handle(TDF_Data) aDF; | |
1843 | if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;} | |
1844 | ||
1845 | TopoDS_Shape s = DBRep::Get(argv[2]); | |
1846 | if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;} | |
1847 | TDF_Label L; | |
1848 | DDF::AddLabel(aDF, "0:2", L); | |
1849 | TNaming_Builder SI (L); | |
1850 | SI.Generated(s); | |
1851 | ||
1852 | Handle(TNaming_NamedShape) NS = new TNaming_NamedShape; | |
1853 | ||
1854 | TNaming_Naming aNN; | |
1855 | NS=aNN.Name(L,s,s); | |
1856 | // if (!NS->IsEmpty()) {di<<3;return 0;} | |
1857 | if (NS->IsEmpty()) {di<<4;return 0;} | |
1858 | di<<0; | |
1859 | return 0; | |
1860 | } | |
1861 | ||
1862 | static int BUC60862(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { | |
1863 | if(argc!=3) { | |
1864 | di << "Usage : " << argv[0] << " D Shape" << "\n"; | |
1865 | di<<1; | |
1866 | return 0; | |
1867 | } | |
1868 | ||
1869 | Handle(TDF_Data) aDF; | |
1870 | if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;} | |
1871 | ||
1872 | TopoDS_Shape s = DBRep::Get(argv[2]); | |
1873 | if (s.IsNull()) { di <<"shape not found"<< "\n"; di<<3;return 0;} | |
1874 | TDF_Label L; | |
1875 | DDF::AddLabel(aDF, "0:2", L); | |
1876 | TNaming_Builder SI (L); | |
1877 | SI.Generated(s); | |
1878 | ||
1879 | Handle(TNaming_NamedShape) NS = new TNaming_NamedShape; | |
1880 | ||
1881 | TNaming_Naming aNN; | |
1882 | NS=aNN.Name(L,s,s); | |
1883 | if (NS->IsEmpty()) {di<<4;return 0;} | |
1884 | di<<0; | |
1885 | return 0; | |
1886 | } | |
1887 | ||
1888 | static int BUC60867(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { | |
1889 | if (argc == 2) { | |
1890 | TCollection_ExtendedString path (argv[1]); | |
1891 | Handle(TDocStd_Application) A; | |
1892 | if (!DDocStd::Find(A)) {di<<1;return 0;} | |
1893 | Handle(TDocStd_Document) D; | |
1894 | Standard_Integer insession = A->IsInSession(path); | |
1895 | if (insession > 0) { | |
1896 | di <<"document " << insession << " is already in session" << "\n"; | |
1897 | di<<2; | |
1898 | return 0; | |
1899 | } | |
15e8b082 M |
1900 | PCDM_ReaderStatus Result = A->Open(path,D); |
1901 | if(Result==PCDM_RS_OK){ | |
7fd59977 | 1902 | di<<0; |
1903 | return 0; | |
1904 | } | |
1905 | } | |
1906 | di<<3; | |
1907 | return 0; | |
1908 | } | |
1909 | ||
1910 | static int BUC60910(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { | |
1911 | if(argc!=2) { | |
1912 | di << "Usage : " << argv[0] << " D" << "\n"; | |
1913 | di<<1; | |
1914 | return 0; | |
1915 | } | |
1916 | ||
1917 | Handle(TDF_Data) aDF; | |
1918 | if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;} | |
1919 | ||
1920 | TDF_Label L; | |
1921 | DDF::AddLabel(aDF, "0:2", L); | |
1922 | ||
1923 | Handle(TPrsStd_AISPresentation) AISP = new TPrsStd_AISPresentation; | |
1924 | ||
1925 | AISP->Set(L,TDataXtd_Constraint::GetID()); | |
1926 | ||
1927 | if (AISP->HasOwnMode()) {di<<3;return 0;} | |
1928 | AISP->SetMode(3); | |
1929 | Standard_Integer Mode = AISP->Mode(); | |
1930 | if (Mode!=3) {di<<4;return 0;} | |
1931 | if (!AISP->HasOwnMode()) {di<<5;return 0;} | |
1932 | AISP->UnsetMode(); | |
1933 | if (AISP->HasOwnMode()) {di<<6;return 0;} | |
1934 | di<<0; | |
1935 | return 0; | |
1936 | } | |
1937 | ||
1938 | static int BUC60925(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { | |
1939 | if(argc!=2) { | |
1940 | di << "Usage : " << argv[0] << " D" << "\n"; | |
1941 | di<<1; | |
1942 | return 0; | |
1943 | } | |
1944 | ||
1945 | Handle(TDF_Data) aDF; | |
1946 | if (!DDF::GetDF(argv[1],aDF)) {di<<2;return 0;} | |
1947 | ||
1948 | TDF_Label L; | |
1949 | DDF::AddLabel(aDF, "0:2", L); | |
1950 | TDF_LabelMap LM; | |
1951 | LM.Add(L); | |
1952 | ||
1953 | Handle(TNaming_NamedShape) NS = new TNaming_NamedShape; | |
1954 | // Handle(TNaming_Name) NN = new TNaming_Name; | |
1955 | TNaming_Name NN; | |
1956 | ||
1957 | NN.Type(TNaming_IDENTITY); | |
1958 | NN.Append(NS); | |
1959 | Standard_Boolean Res = NN.Solve(L,LM); | |
1960 | ||
1961 | if (Res!=Standard_False) {di<<3;return 0;} | |
1962 | di<<0; | |
1963 | return 0; | |
1964 | } | |
1965 | ||
1966 | static int BUC60932(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { | |
1967 | if(argc!=2) { | |
1968 | di << "Usage : " << argv[0] << " D" << "\n"; | |
1969 | di<<1; | |
1970 | return 0; | |
1971 | } | |
1972 | ||
1973 | ||
1974 | Handle(TDocStd_Document) aDocument; | |
1975 | if (!DDocStd::GetDocument(argv[1], aDocument)) {di<<2;return 0;} | |
1976 | ||
1977 | if(!aDocument->InitDeltaCompaction()) {di<<3;return 0;} | |
1978 | if(!aDocument->PerformDeltaCompaction()) {di<<4;return 0;} | |
1979 | ||
1980 | di<<0; | |
1981 | return 0; | |
1982 | } | |
1983 | ||
1984 | //======================================================================= | |
1985 | //function : AISWidth | |
1986 | //purpose : AISWidth (DOC,entry,[width]) | |
1987 | // abv: testing command for checking bug BUC60917 in TPrsStd_AISPresentation | |
1988 | //======================================================================= | |
1989 | ||
1990 | static int AISWidth(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { | |
1991 | ||
1992 | if (argc >= 3) { | |
1993 | Handle(TDocStd_Document) D; | |
1994 | if (!DDocStd::GetDocument(argv[1],D)) {di<<(-1);return 0;} | |
1995 | TDF_Label L; | |
1996 | if (!DDF::FindLabel(D->GetData(),argv[2],L)) {di<<(-2);return 0;} | |
1997 | ||
1998 | Handle(TPrsStd_AISViewer) viewer; | |
1999 | if( !TPrsStd_AISViewer::Find(L, viewer) ) {di<<(-3);return 0;} | |
2000 | ||
2001 | Handle(TPrsStd_AISPresentation) prs; | |
2002 | if(L.FindAttribute( TPrsStd_AISPresentation::GetID(), prs) ) { | |
2003 | if( argc == 4 ) { | |
91322f44 | 2004 | prs->SetWidth(Draw::Atof(argv[3])); |
7fd59977 | 2005 | TPrsStd_AISViewer::Update(L); |
2006 | } | |
2007 | else { | |
2008 | if (prs->HasOwnWidth()){ | |
2009 | // cout << "Width = " << prs->Width() << endl; | |
2010 | di<<prs->Width(); | |
2011 | } | |
2012 | else{ | |
2013 | di << "AISWidth: Warning : Width wasn't set" << "\n"; | |
2014 | di<<(-4); | |
2015 | } | |
2016 | } | |
2017 | return 0; | |
2018 | } | |
2019 | } | |
2020 | di << "AISWidth : Error" << "\n"; | |
2021 | di<<(-5); | |
2022 | return 0; | |
2023 | } | |
2024 | ||
2025 | //======================================================================= | |
2026 | //function : BUC60921 ( & BUC60954 ) | |
2027 | //purpose : Test memory allocation of OCAF in Undo/Redo operations | |
2028 | //======================================================================= | |
2029 | ||
2030 | static Standard_Integer BUC60921 (Draw_Interpretor& di, | |
2031 | Standard_Integer nb, | |
2032 | const char ** arg) | |
2033 | { | |
2034 | if (nb >= 4) { | |
2035 | Handle(TDocStd_Document) D; | |
2036 | if (!DDocStd::GetDocument(arg[1],D)) {di<<1;return 0;} | |
2037 | TDF_Label L; | |
2038 | DDF::AddLabel(D->GetData(),arg[2],L); | |
2039 | ||
2040 | BRep_Builder B; | |
2041 | TopoDS_Shape S; | |
2042 | BRepTools::Read ( S, arg[3], B ); | |
2043 | ||
2044 | TNaming_Builder tnBuild(L); | |
2045 | tnBuild.Generated(S); | |
2046 | // di << "File " << arg[3] << " added"; | |
2047 | di<<0; | |
2048 | return 0; | |
2049 | } | |
2050 | di << "BUC60921 Doc label brep_file: directly read brep file and put shape to the label" << "\n"; | |
2051 | di<<2; | |
2052 | return 0; | |
2053 | } | |
2054 | ||
2055 | #include<IGESControl_Reader.hxx> | |
2056 | #include<BRepPrimAPI_MakeHalfSpace.hxx> | |
2057 | ||
2058 | static Standard_Integer BUC60951_(Draw_Interpretor& di, Standard_Integer argc, const char ** a) | |
2059 | { | |
2060 | //if(argc!=2) | |
2061 | // { | |
2062 | // cerr << "Usage : " << a[0] << " file.igs" << endl; | |
2063 | // return -1; | |
2064 | // } | |
2065 | if(argc < 2 || argc > 3) { | |
2066 | di << "Usage : " << a[0] << " [BRepAlgoAPI/BRepAlgo = 1/0]" << "\n"; | |
2067 | return 1; | |
2068 | } | |
2069 | Standard_Boolean IsBRepAlgoAPI = Standard_True; | |
2070 | if (argc == 3) { | |
91322f44 | 2071 | Standard_Integer IsB = Draw::Atoi(a[2]); |
7fd59977 | 2072 | if (IsB != 1) { |
2073 | IsBRepAlgoAPI = Standard_False; | |
2074 | #if ! defined(BRepAlgo_def01) | |
2075 | // di << "Error: There is not BRepAlgo_Fuse class" << "\n"; | |
2076 | // return 1; | |
2077 | #endif | |
2078 | } | |
2079 | } | |
2080 | ||
2081 | Handle(AIS_InteractiveContext) myContext = ViewerTest::GetAISContext(); | |
2082 | ||
2083 | if(myContext.IsNull()) { | |
2084 | di << "use 'vinit' command before " << a[0] << "\n"; | |
2085 | return -1; | |
2086 | } | |
2087 | ||
2088 | // IGESControlStd_Reader reader; | |
2089 | IGESControl_Reader reader; | |
2090 | reader.ReadFile(a[1]); | |
2091 | reader.TransferRoots(); | |
2092 | TopoDS_Shape shape = reader.OneShape(); | |
2093 | printf("\n iges1 shape type = %d", shape.ShapeType() ); | |
2094 | TopTools_IndexedMapOfShape list; | |
2095 | TopExp::MapShapes(shape, TopAbs_FACE, list); | |
2096 | printf("\n No. of faces = %d", list.Extent()); | |
2097 | ||
2098 | TopoDS_Shell shell; | |
2099 | BRep_Builder builder; | |
2100 | builder.MakeShell(shell); | |
2101 | for(int i=1;i<=list.Extent(); i++) { | |
2102 | TopoDS_Face face = TopoDS::Face(list.FindKey(i)); | |
2103 | builder.Add(shell, face); | |
2104 | } | |
2105 | ||
2106 | BRepPrimAPI_MakeHalfSpace half(shell, gp_Pnt(0, 0, 20)); | |
2107 | TopoDS_Solid sol = half.Solid(); | |
2108 | gp_Ax2 anAx2(gp_Pnt(-800.0, 0.0, 0), gp_Dir(0, 0, -1)); | |
2109 | BRepPrimAPI_MakeCylinder cyl(anAx2, 50, 300); | |
2110 | TopoDS_Shape sh = cyl.Shape(); | |
2111 | ||
2112 | //#if ! defined(BRepAlgoAPI_def01) | |
2113 | // BRepAlgoAPI_Fuse fuse(sol, sh); | |
2114 | //#else | |
2115 | // BRepAlgo_Fuse fuse(sol, sh); | |
2116 | //#endif | |
2117 | // | |
2118 | // sh = fuse.Shape(); | |
2119 | ||
2120 | if (IsBRepAlgoAPI) { | |
2121 | di << "BRepAlgoAPI_Fuse fuse(sol, sh)" <<"\n"; | |
2122 | BRepAlgoAPI_Fuse fuse(sol, sh); | |
2123 | sh = fuse.Shape(); | |
2124 | } else { | |
2125 | di << "BRepAlgo_Fuse fuse(sol, sh)" <<"\n"; | |
2126 | BRepAlgo_Fuse fuse(sol, sh); | |
2127 | sh = fuse.Shape(); | |
2128 | } | |
2129 | ||
2130 | Handle(AIS_Shape) res = new AIS_Shape(sh); | |
2131 | myContext->Display( res ); | |
2132 | return 0; | |
2133 | } | |
2134 | ||
1cd84fee | 2135 | void QABugs::Commands_3(Draw_Interpretor& theCommands) { |
2136 | const char *group = "QABugs"; | |
7fd59977 | 2137 | |
2138 | theCommands.Add("BUC60623","BUC60623 result Shape1 Shape2",__FILE__,BUC60623,group); | |
2139 | theCommands.Add("BUC60569","BUC60569 shape",__FILE__,BUC60569,group); | |
2140 | theCommands.Add("BUC60614","BUC60614 shape",__FILE__,BUC60614,group); | |
ceeaafcb | 2141 | theCommands.Add("BUC60609","BUC60609 shape name [U V]",__FILE__,BUC60609,group); |
7fd59977 | 2142 | #if ! defined(WNT) |
2143 | theCommands.Add("UKI61075","UKI61075",__FILE__,UKI61075,group); | |
2144 | #endif | |
2145 | theCommands.Add("BUC60585",St,__FILE__,BUC60585,group); | |
2146 | theCommands.Add("BUC60547","BUC60547 name",__FILE__,BUC60547,group); | |
2147 | theCommands.Add("BUC60632","BUC60632 mode length",__FILE__,BUC60632,group); | |
2148 | theCommands.Add("BUC60652","BUC60652 face",__FILE__,BUC60652,group); | |
2149 | theCommands.Add("ksection","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group); | |
2150 | theCommands.Add("BUC60682","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group); | |
2151 | theCommands.Add("BUC60669","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group); | |
2152 | theCommands.Add("PRO19626","ksection resultat shell1 shell2 NbPntMax Toler3d Toler2d RelativeTol",__FILE__,ksection,group); | |
2153 | theCommands.Add("BUC60574","BUC60574 ",__FILE__,BUC60574,group); | |
2154 | ||
7fd59977 | 2155 | theCommands.Add("BUC60699","BUC60699 ",__FILE__,BUC60699,group); |
2156 | theCommands.Add("GER61394","GER61394 [1/0]",__FILE__,GER61394,group); | |
2157 | theCommands.Add("GER61351","GER61351 name/object name/r g b/object r g b",__FILE__,setcolor,group); | |
2158 | theCommands.Add("setcolor","setcolor name/object name/r g b/object r g b",__FILE__,setcolor,group); | |
2159 | ||
2160 | theCommands.Add("BUC60726","BUC60726 0/1",__FILE__,BUC60726,group); | |
2161 | theCommands.Add("BUC60729","BUC60729",__FILE__,BUC60729,group); | |
2162 | theCommands.Add("BUC60724","BUC60724",__FILE__,BUC60724,group); | |
2163 | theCommands.Add("BUC60727","BUC60727",__FILE__,BUC60727,group); | |
2164 | theCommands.Add("BUC60792","BUC60792",__FILE__,BUC60792,group); | |
2165 | theCommands.Add("BUC60811","BUC60811",__FILE__,BUC60811,group); | |
2166 | ||
2167 | theCommands.Add("BUC60825","BUC60825",__FILE__,BUC60825,group); | |
2168 | ||
2169 | theCommands.Add("OCC10006","OCC10006 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,OCC10006,group); | |
2170 | ||
2171 | theCommands.Add("BUC60856","BUC60856",__FILE__,BUC60856,group); | |
2172 | ||
7fd59977 | 2173 | theCommands.Add("coordload","load coord from file",__FILE__,coordload); |
7fd59977 | 2174 | |
2175 | theCommands.Add("TestMem","TestMem",__FILE__,TestMem,group); | |
2176 | theCommands.Add("BUC60945","BUC60945",__FILE__,TestMem,group); | |
2177 | theCommands.Add("BUC60876","BUC60876 shape",__FILE__,BUC60876_,group); | |
2178 | theCommands.Add("BUC60773","BUC60773",__FILE__,BUC60773,group); | |
2179 | ||
2180 | theCommands.Add("TestCMD","TestCMD [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,TestCMD,group); | |
2181 | ||
2182 | theCommands.Add("statface","statface face",__FILE__,statface,group); | |
2183 | ||
2184 | theCommands.Add("BUC60841","BUC60841 [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60841,group); | |
2185 | ||
2186 | theCommands.Add("BUC60874","BUC60874",__FILE__,BUC60874,group); | |
2187 | ||
2188 | theCommands.Add("BUC60817","BUC60817 D",__FILE__,BUC60817,group); | |
2189 | theCommands.Add("BUC60831_1","BUC60831_1 D",__FILE__,BUC60831_1,group); | |
2190 | theCommands.Add("BUC60831_2","BUC60831_2 D Label",__FILE__,BUC60831_2,group); | |
2191 | theCommands.Add("BUC60836","BUC60836 D",__FILE__,BUC60836,group); | |
2192 | theCommands.Add("BUC60847","BUC60847 D Shape",__FILE__,BUC60847,group); | |
2193 | theCommands.Add("BUC60862","BUC60862 D Shape",__FILE__,BUC60862,group); | |
2194 | theCommands.Add("BUC60867","BUC60867",__FILE__,BUC60867,group); | |
2195 | theCommands.Add("BUC60910","BUC60910 D",__FILE__,BUC60910,group); | |
2196 | theCommands.Add("BUC60925","BUC60925 D",__FILE__,BUC60925,group); | |
2197 | theCommands.Add("BUC60932","BUC60932 D",__FILE__,BUC60932,group); | |
2198 | theCommands.Add("AISWidth","AISWidth (DOC,entry,[width])",__FILE__,AISWidth,group); | |
2199 | theCommands.Add("BUC60921","BUC60921 Doc label brep_file",__FILE__,BUC60921,group); | |
2200 | ||
2201 | theCommands.Add("BUC60951","BUC60951 file.igs [BRepAlgoAPI/BRepAlgo = 1/0]",__FILE__,BUC60951_, group ); | |
2202 | ||
2203 | } |