0024510: Remove unused local variables
[occt.git] / src / ViewerTest / ViewerTest_ObjectCommands.cxx
CommitLineData
b311480e 1// Created on: 1998-11-12
2// Created by: Robert COUBLANC
3// Copyright (c) 1998-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
7fd59977 17#ifdef HAVE_CONFIG_H
18#include <config.h>
19#endif
20
21#include <ViewerTest.hxx>
22
23#include <string.h>
24
25#include <Quantity_NameOfColor.hxx>
26#include <Draw_Interpretor.hxx>
27#include <Draw.hxx>
28#include <Draw_Appli.hxx>
29#include <DBRep.hxx>
30
b514beda 31#include <Font_BRepFont.hxx>
725ef85e 32#include <Font_FontMgr.hxx>
161c4476 33#include <OSD_Chronometer.hxx>
7fd59977 34#include <TCollection_AsciiString.hxx>
4952a30a 35#include <Visual3d_View.hxx>
7fd59977 36#include <V3d_Viewer.hxx>
37#include <V3d_View.hxx>
38#include <V3d.hxx>
39
40#include <AIS_Shape.hxx>
41#include <AIS_DisplayMode.hxx>
42#include <TColStd_MapOfInteger.hxx>
43#include <AIS_MapOfInteractive.hxx>
44#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
45#include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
46#include <ViewerTest_EventManager.hxx>
47
48#include <TopoDS_Solid.hxx>
49#include <BRepTools.hxx>
50#include <BRep_Builder.hxx>
51#include <TopAbs_ShapeEnum.hxx>
52
53#include <TopoDS.hxx>
54#include <BRep_Tool.hxx>
55#include <TopExp_Explorer.hxx>
56
57#include <BRepAdaptor_Curve.hxx>
58#include <BRepAdaptor_Surface.hxx>
59
60#include <TopAbs.hxx>
61#include <TopExp.hxx>
62#include <TopoDS_Vertex.hxx>
63#include <TopoDS_Shape.hxx>
64#include <TopoDS_Face.hxx>
65
66#include <Draw_Window.hxx>
67#include <AIS_ListIteratorOfListOfInteractive.hxx>
68#include <AIS_ListOfInteractive.hxx>
69#include <AIS_DisplayMode.hxx>
70#include <AIS_Shape.hxx>
71
72#include <AIS_InteractiveContext.hxx>
73#include <Geom_Plane.hxx>
74#include <gp_Pln.hxx>
7fd59977 75#include <TCollection_ExtendedString.hxx>
725ef85e 76#include <TCollection_HAsciiString.hxx>
7fd59977 77#include <GC_MakePlane.hxx>
78#include <gp_Circ.hxx>
79#include <AIS_Axis.hxx>
80#include <Geom_Axis2Placement.hxx>
81#include <Geom_Axis1Placement.hxx>
82#include <AIS_Trihedron.hxx>
83#include <AIS_Axis.hxx>
29d43f9c
A
84#include <gp_Trsf.hxx>
85#include <TopLoc_Location.hxx>
3fc57801 86
87#include <HLRAlgo_Projector.hxx>
88#include <HLRBRep_PolyAlgo.hxx>
89#include <HLRBRep_PolyHLRToShape.hxx>
90#include <Aspect_Window.hxx>
91
9558a876
A
92#include <Graphic3d_ArrayOfPoints.hxx>
93#include <Graphic3d_ArrayOfSegments.hxx>
94#include <Graphic3d_ArrayOfPolylines.hxx>
95#include <Graphic3d_ArrayOfTriangles.hxx>
96#include <Graphic3d_ArrayOfTriangleFans.hxx>
97#include <Graphic3d_ArrayOfTriangleStrips.hxx>
98#include <Graphic3d_ArrayOfQuadrangles.hxx>
99#include <Graphic3d_ArrayOfQuadrangleStrips.hxx>
100#include <Graphic3d_ArrayOfPolygons.hxx>
a577aaab 101#include <Graphic3d_AspectMarker3d.hxx>
9558a876
A
102#include <Graphic3d_Group.hxx>
103#include <Standard_Real.hxx>
104
329843e2
A
105#include <AIS_Circle.hxx>
106#include <AIS_Drawer.hxx>
107#include <BRepBuilderAPI_MakeEdge.hxx>
108#include <BRepBuilderAPI_MakeFace.hxx>
109#include <BRepBuilderAPI_MakeWire.hxx>
110#include <Geom_Circle.hxx>
111#include <GC_MakeCircle.hxx>
112#include <Prs3d_Presentation.hxx>
113#include <Select3D_SensitiveCircle.hxx>
114#include <SelectMgr_EntityOwner.hxx>
115#include <SelectMgr_Selection.hxx>
116#include <StdFail_NotDone.hxx>
117#include <StdPrs_ShadedShape.hxx>
a2d5ab2e 118#include <TopoDS_Wire.hxx>
ac04d101
SA
119
120#include <AIS_ConnectedShape.hxx>
792c785c 121#include <AIS_MultipleConnectedInteractive.hxx>
122#include <AIS_MultipleConnectedShape.hxx>
ac04d101
SA
123#include <TopLoc_Location.hxx>
124#include <TColStd_ListOfInteger.hxx>
125#include <TColStd_ListIteratorOfListOfInteger.hxx>
329843e2 126
ceae62f0
A
127#include <Select3D_SensitiveTriangle.hxx>
128#include <Select3D_SensitiveCurve.hxx>
a577aaab 129#include <Select3D_SensitivePoint.hxx>
ceae62f0
A
130#include <BRepAdaptor_Curve.hxx>
131#include <StdPrs_Curve.hxx>
132
133#include <BRepExtrema_ExtPC.hxx>
134#include <BRepExtrema_ExtPF.hxx>
135
a2d5ab2e 136#include <Prs3d_LineAspect.hxx>
a577aaab 137#include <Prs3d_PointAspect.hxx>
138
139#include <Image_AlienPixMap.hxx>
eb4320f2 140#include <TColStd_HArray1OfAsciiString.hxx>
a2d5ab2e 141
7fd59977 142#ifdef HAVE_STRINGS_H
143#include <strings.h>
144#endif
145
146#ifdef WNT
147#define _CRT_SECURE_NO_DEPRECATE
148#pragma warning (disable:4996)
149#endif
150
151extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
9558a876
A
152extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
153 const Handle(AIS_InteractiveObject)& theAISObj,
154 Standard_Boolean theReplaceIfExists = Standard_True);
1d0a9d4d 155extern int ViewerMainLoop(Standard_Integer argc, const char** argv);
7fd59977 156extern Handle(AIS_InteractiveContext)& TheAISContext();
157
158
159//==============================================================================
160//function : Vtrihedron 2d
161//purpose : Create a plane with a 2D trihedron from a faceselection
161c4476 162//Draw arg : vtri2d name
7fd59977 163//==============================================================================
164#include <AIS_PlaneTrihedron.hxx>
165
166
167
168static int VTrihedron2D (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
169
170{
171 // Verification des arguments
172 if ( argc!=2) {di<<argv[0]<<" error"<<"\n"; return 1;}
173
174 // Declarations
175 Standard_Integer myCurrentIndex;
161c4476 176 // Fermeture des contextes
7fd59977 177 TheAISContext()->CloseAllContexts();
178 // Ouverture d'un contexte local et recuperation de son index.
179 TheAISContext()->OpenLocalContext();
180 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
181 // On active les modes de selections faces.
182 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
183 di<<" Select a face ."<<"\n";
184
185 // Boucle d'attente waitpick.
186 Standard_Integer argccc = 5;
187 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
188 const char **argvvv = (const char **) bufff;
189 while (ViewerMainLoop( argccc, argvvv) ) { }
190 // fin de la boucle
191
192 TopoDS_Shape ShapeB;
193 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
194 ShapeB = TheAISContext()->SelectedShape();
195 }
196
197 TopoDS_Face FaceB=TopoDS::Face(ShapeB);
198
199 // Construction du Plane
200 // recuperation des edges des faces.
201 TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE);
202
203 TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() );
161c4476 204 // declarations
7fd59977 205 gp_Pnt A,B,C;
206
207 // si il y a plusieurs edges
208 if (FaceExpB.More() ) {
209 FaceExpB.Next();
210 TopoDS_Edge EdgeC=TopoDS::Edge(FaceExpB.Current() );
211 BRepAdaptor_Curve theCurveB(EdgeB);
212 BRepAdaptor_Curve theCurveC(EdgeC);
213 A=theCurveC.Value(0.1);
214 B=theCurveC.Value(0.9);
215 C=theCurveB.Value(0.5);
216 }
217 else {
218 // FaceB a 1 unique edge courbe
219 BRepAdaptor_Curve theCurveB(EdgeB);
220 A=theCurveB.Value(0.1);
221 B=theCurveB.Value(0.9);
222 C=theCurveB.Value(0.5);
223 }
224 // Construction du Geom_Plane
225 GC_MakePlane MkPlane(A,B,C);
226 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
227
228 // Construction de l'AIS_PlaneTrihedron
229 Handle(AIS_PlaneTrihedron) theAISPlaneTri= new AIS_PlaneTrihedron(theGeomPlane );
230
231 // Fermeture du contexte local.
232 TheAISContext()->CloseLocalContext(myCurrentIndex);
233
234 // on le display & bind
235 TheAISContext()->Display(theAISPlaneTri );
236 GetMapOfAIS().Bind ( theAISPlaneTri ,argv[1]);
237
161c4476 238 return 0;
7fd59977 239}
240
241
242
243//==============================================================================
244//function : VTriherdron
7fd59977 245//purpose : Create a trihedron. If no arguments are set, the default
246// trihedron (Oxyz) is created.
247//Draw arg : vtrihedron name [Xo] [Yo] [Zo] [Zu] [Zv] [Zw] [Xu] [Xv] [Xw]
248//==============================================================================
249
dc9b6d23 250static int VTrihedron (Draw_Interpretor& theDi,
251 Standard_Integer theArgsNb,
252 const char** theArgVec)
7fd59977 253{
dc9b6d23 254 if (theArgsNb != 2 && theArgsNb != 5 && theArgsNb != 11)
255 {
256 theDi << theArgVec[0] << " Syntax error\n";
257 return 1;
7fd59977 258 }
7fd59977 259
dc9b6d23 260 gp_Pnt anOrigin (0.0, 0.0, 0.0);
261 gp_Dir aDirZ = gp::DZ();
262 gp_Dir aDirX = gp::DX();
263 Standard_Integer anArgIter = 2; // 1st is an IO name
264 if (anArgIter < theArgsNb)
265 {
91322f44 266 anOrigin.SetX (Draw::Atof (theArgVec[anArgIter++]));
267 anOrigin.SetY (Draw::Atof (theArgVec[anArgIter++]));
268 anOrigin.SetZ (Draw::Atof (theArgVec[anArgIter++]));
dc9b6d23 269 if (anArgIter < theArgsNb)
270 {
91322f44 271 Standard_Real aX = Draw::Atof (theArgVec[anArgIter++]);
272 Standard_Real aY = Draw::Atof (theArgVec[anArgIter++]);
273 Standard_Real aZ = Draw::Atof (theArgVec[anArgIter++]);
dc9b6d23 274 aDirZ.SetCoord (aX, aY, aZ);
275
91322f44 276 aX = Draw::Atof (theArgVec[anArgIter++]);
277 aY = Draw::Atof (theArgVec[anArgIter++]);
278 aZ = Draw::Atof (theArgVec[anArgIter++]);
dc9b6d23 279 aDirX.SetCoord (aX, aY, aZ);
280 }
281 }
7fd59977 282
dc9b6d23 283 if (!aDirZ.IsNormal (aDirX, M_PI / 180.0))
284 {
285 theDi << theArgVec[0] << " - VectorX is not normal to VectorZ\n";
286 return 1;
287 }
7fd59977 288
dc9b6d23 289 Handle(Geom_Axis2Placement) aPlacement = new Geom_Axis2Placement (anOrigin, aDirZ, aDirX);
290 Handle(AIS_Trihedron) aShape = new AIS_Trihedron (aPlacement);
291 VDisplayAISObject (theArgVec[1], aShape);
161c4476 292 return 0;
7fd59977 293}
294
7fd59977 295//==============================================================================
296//function : VSize
297//author : ege
298//purpose : Change the size of a named or selected trihedron
299// if no name : it affects the trihedrons witch are selected otherwise nothing is donne
300// if no value, the value is set at 100 by default
301//Draw arg : vsize [name] [size]
302//==============================================================================
303
304static int VSize (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
305
306{
307 // Declaration de booleens
308 Standard_Boolean ThereIsName;
309 Standard_Boolean ThereIsCurrent;
310 Standard_Real value;
161c4476 311 Standard_Boolean hascol;
1d47d8d0 312
7fd59977 313 Quantity_NameOfColor col = Quantity_NOC_BLACK ;
7fd59977 314
315 // Verification des arguments
316 if ( argc>3 ) {di<<argv[0]<<" Syntaxe error"<<"\n"; return 1;}
317
318 // Verification du nombre d'arguments
319 if (argc==1) {ThereIsName=Standard_False;value=100;}
91322f44 320 else if (argc==2) {ThereIsName=Standard_False;value=Draw::Atof(argv[1]);}
321 else {ThereIsName=Standard_True;value=Draw::Atof(argv[2]);}
7fd59977 322
323 // On ferme le contexte local pour travailler dans le contexte global
161c4476 324 if(TheAISContext()->HasOpenedContext())
7fd59977 325 TheAISContext()->CloseLocalContext();
326
327 // On set le booleen ThereIsCurrent
328 if (TheAISContext() -> NbCurrents() > 0) {ThereIsCurrent=Standard_True;}
329 else {ThereIsCurrent=Standard_False;}
330
331
332
333 //===============================================================
334 // Il n'y a pas de nom mais des objets selectionnes
335 //===============================================================
161c4476 336 if (!ThereIsName && ThereIsCurrent)
7fd59977 337 {
338
339 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
340 it (GetMapOfAIS());
341
342 while ( it.More() ) {
343
344 Handle(AIS_InteractiveObject) aShape=
345 Handle(AIS_InteractiveObject)::DownCast(it.Key1());
346
347 if (!aShape.IsNull() && TheAISContext()->IsCurrent(aShape) )
348 {
349
161c4476 350 // On verifie que l'AIS InteraciveObject selectionne est bien
7fd59977 351 // un AIS_Trihedron
352 if (aShape->Type()==AIS_KOI_Datum && aShape->Signature()==3) {
353
354 if (aShape->HasColor()) {
355 hascol=Standard_True;
356
357 // On recupere la couleur de aShape
358 col=aShape->Color();}
359
360 else hascol=Standard_False;
361
362 // On downcast aShape de AIS_InteractiveObject a AIS_Trihedron
363 // pour lui appliquer la methode SetSize()
364 Handle(AIS_Trihedron) aTrihedron = *(Handle(AIS_Trihedron)*) &aShape;
365
366 // C'est bien un triedre,on chage sa valeur!
367 aTrihedron->SetSize(value);
368
369 // On donne la couleur au Trihedron
370 if(hascol) aTrihedron->SetColor(col);
371 else aTrihedron->UnsetColor();
372
373
374 // The trihedron hasn't be errased from the map
375 // so you just have to redisplay it
376 TheAISContext() ->Redisplay(aTrihedron,Standard_False);
377
378 }
379
380 }
381
382 it.Next();
383 }
384
385 TheAISContext() ->UpdateCurrentViewer();
386 }
387
388 //===============================================================
389 // Il n'y a pas d'arguments et aucuns objets selectionne Rien A Faire!
390 //===============================================================
391
392
393
394 //===============================================================
395 // Il y a un nom de triedre passe en argument
396 //===============================================================
397 if (ThereIsName) {
398 TCollection_AsciiString name=argv[1];
399
400 // on verifie que ce nom correspond bien a une shape
401 Standard_Boolean IsBound= GetMapOfAIS().IsBound2(name);
402
403 if (IsBound) {
404
405 // on recupere la shape dans la map des objets displayes
406 Handle(AIS_InteractiveObject) aShape =
407 Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
408
161c4476 409 // On verifie que l'AIS InteraciveObject est bien
7fd59977 410 // un AIS_Trihedron
411 if (!aShape.IsNull() &&
412 aShape->Type()==AIS_KOI_Datum && aShape->Signature()==3)
413 {
414
415 if (aShape->HasColor()) {
416 hascol=Standard_True;
417
418 // On recupere la couleur de aShape
419 col=aShape->Color();}
420
421 else hascol=Standard_False;
422
423 // On downcast aShape de AIS_InteractiveObject a AIS_Trihedron
424 // pour lui appliquer la methode SetSize()
425 Handle(AIS_Trihedron) aTrihedron = *(Handle(AIS_Trihedron)*) &aShape;
426
427 // C'est bien un triedre,on chage sa valeur
428 aTrihedron->SetSize(value);
429
430 // On donne la couleur au Trihedron
431 if(hascol) aTrihedron->SetColor(col);
432 else aTrihedron->UnsetColor();
433
434 // The trihedron hasn't be errased from the map
435 // so you just have to redisplay it
436 TheAISContext() ->Redisplay(aTrihedron,Standard_False);
437
438 TheAISContext() ->UpdateCurrentViewer();
439 }
440 }
441 }
161c4476 442 return 0;
7fd59977 443}
444
445
446//==============================================================================
447
448//==============================================================================
449//function : VPlaneTrihedron
450//purpose : Create a plane from a trihedron selection. If no arguments are set, the default
161c4476 451//Draw arg : vplanetri name
7fd59977 452//==============================================================================
453#include <AIS_Plane.hxx>
454
455
456
457static int VPlaneTrihedron (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
458
459{
460 // Verification des arguments
461 if ( argc!=2) {di<<argv[0]<<" error"<<"\n"; return 1;}
462
463 // Declarations
464 Standard_Integer myCurrentIndex;
465 // Fermeture des contextes locaux
466 TheAISContext()->CloseAllContexts();
467
161c4476 468 // On recupere tous les trihedrons de la GetMapOfAIS()
7fd59977 469 // et on active le mode de selection par face.
470 // =================================================
471
472 // Ouverture d'un contexte local et recuperation de son index.
473 TheAISContext()->OpenLocalContext(Standard_False);
474 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
475
476 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
477 it (GetMapOfAIS());
478 while(it.More()){
479 Handle(AIS_InteractiveObject) ShapeA =
480 Handle(AIS_InteractiveObject)::DownCast(it.Key1());
481 // On verifie que c'est bien un trihedron
482 if (!ShapeA.IsNull() &&
483 ShapeA->Type()==AIS_KOI_Datum && ShapeA->Signature()==3 ) {
484 // on le downcast
485 Handle(AIS_Trihedron) TrihedronA =((*(Handle(AIS_Trihedron)*)&ShapeA));
486 // on le charge dans le contexte et on active le mode Plane.
487 TheAISContext()->Load(TrihedronA,0,Standard_False);
488 TheAISContext()->Activate(TrihedronA,3);
489 }
490 it.Next();
491 }
492
493 di<<" Select a plane."<<"\n";
494 // Boucle d'attente waitpick.
495 Standard_Integer argccc = 5;
496 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
497 const char **argvvv = (const char **) bufff;
498 while (ViewerMainLoop( argccc, argvvv) ) { }
499 // fin de la boucle
500
501 Handle(AIS_InteractiveObject) theIOB;
502 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
503 theIOB = TheAISContext()->Interactive();
504 }
505 // on le downcast
506 Handle(AIS_Plane) PlaneB =((*(Handle(AIS_Plane)*)&theIOB));
507
508 // Fermeture du contexte local.
509 TheAISContext()->CloseLocalContext(myCurrentIndex);
510
511 // on le display & bind
512 TheAISContext()->Display(PlaneB );
513 GetMapOfAIS().Bind ( PlaneB ,argv[1]);
514
161c4476 515 return 0;
7fd59977 516}
517
518
519
520//==============================================================================
521// Fonction First click 2de click
161c4476 522//
7fd59977 523// vaxis vertex vertex
524// edge None
525// vaxispara edge vertex
526// vaxisortho edge Vertex
527// vaxisinter Face Face
528//==============================================================================
529
530//==============================================================================
531//function : VAxisBuilder
161c4476 532//purpose :
7fd59977 533//Draw arg : vaxis AxisName Xa Ya Za Xb Yb Zb
534//==============================================================================
535#include <TopoDS_Edge.hxx>
536#include <TopoDS_Vertex.hxx>
537#include <TopExp.hxx>
538#include <Geom_Line.hxx>
539
161c4476 540static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
7fd59977 541{
542 // Declarations
543 Standard_Boolean HasArg;
544 TCollection_AsciiString name;
545 Standard_Integer MyCurrentIndex;
546
547 // Verification
548 if (argc<2 || argc>8 ) {di<<" Syntaxe error"<<"\n";return 1;}
549 if (argc==8) HasArg=Standard_True;
550 else HasArg=Standard_False;
551
552 name=argv[1];
553 // Fermeture des contextes
554 TheAISContext()->CloseAllContexts();
555
556 // Cas ou il y a des arguments
557 // Purpose: Teste le constructeur AIS_Axis::AIS_Axis(x: Line from Geom)
558 if (HasArg) {
559 Standard_Real coord[6];
560 for(Standard_Integer i=0;i<=5;i++){
91322f44 561 coord[i]=Draw::Atof(argv[2+i]);
7fd59977 562 }
563 gp_Pnt p1(coord[0],coord[1],coord[2]), p2(coord[3],coord[4],coord[5]) ;
564
565 gp_Vec myVect (p1,p2);
566 Handle(Geom_Line) myLine=new Geom_Line (p1 ,myVect );
567 Handle(AIS_Axis) TheAxis=new AIS_Axis (myLine );
568 GetMapOfAIS().Bind (TheAxis,name);
569 TheAISContext()->Display(TheAxis);
570 }
571
572 // Pas d'arguments
573 else {
574 // fonction vaxis
575 // Purpose: Teste le constructeur AIS_Axis::AIS_Axis (x:Axis1Placement from Geom)
576 if ( !strcasecmp(argv[0], "vaxis")) {
577 TheAISContext()->OpenLocalContext();
578 MyCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
579
580 // Active le mode edge et le mode vertex
581 TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(1) );
582 TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(2) );
583 di<<" Select an edge or a vertex."<<"\n";
584
585 // Boucle d'attente waitpick.
586 Standard_Integer argcc = 5;
587 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
588 const char **argvv = (const char **) buff;
589 while (ViewerMainLoop( argcc, argvv) ) { }
161c4476 590 // fin de la boucle
7fd59977 591
592 // recuperation de la shape.
593 TopoDS_Shape ShapeA;
594 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
595 ShapeA = TheAISContext()->SelectedShape();
596 }
597 // recuperation de l'AIS_InteractiveObject
598 //Handle(AIS_InteractiveObject) myAISio=TheAISContext()->Current();
599 // down cast en AIS_Point si sig et type
600 // AIS_Point -> Geom_Pnt ....
601
602 if (ShapeA.ShapeType()==TopAbs_VERTEX) {
603 // on desactive le mode edge
604 TheAISContext()->DeactivateStandardMode(AIS_Shape::SelectionType(2) );
605 di<<" Select a different vertex."<<"\n";
606
607 TopoDS_Shape ShapeB;
608 do {
609 // Boucle d'attente waitpick.
610 Standard_Integer argccc = 5;
611 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
612 const char **argvvv = (const char **) bufff;
613 while (ViewerMainLoop( argccc, argvvv) ) { }
161c4476 614 // fin de la boucle
7fd59977 615 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
616 ShapeB = TheAISContext()->SelectedShape();
617 }
618
619
620 } while(ShapeB.IsSame(ShapeA) );
621
622 // Fermeture du context local
623 TheAISContext()->CloseLocalContext(MyCurrentIndex);
624
161c4476 625 // Construction de l'axe
7fd59977 626 gp_Pnt A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA) );
627 gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) );
628 gp_Vec V (A,B);
629 gp_Dir D (V);
630 Handle(Geom_Axis1Placement) OrigineAndVect=new Geom_Axis1Placement (A,D);
631 Handle(AIS_Axis) TheAxis=new AIS_Axis (OrigineAndVect);
632 GetMapOfAIS().Bind (TheAxis,name);
633 TheAISContext()->Display(TheAxis);
161c4476 634 }
7fd59977 635 else {
636 // Un unique edge (ShapeA) a ete picke
637 // Fermeture du context local
638 TheAISContext()->CloseLocalContext(MyCurrentIndex);
161c4476 639 // Constuction de l'axe
7fd59977 640 TopoDS_Edge ed =TopoDS::Edge(ShapeA);
641 TopoDS_Vertex Va,Vb;
642 TopExp::Vertices(ed,Va,Vb );
643 gp_Pnt A=BRep_Tool::Pnt(Va);
644 gp_Pnt B=BRep_Tool::Pnt(Vb);
645 gp_Vec V (A,B);
646 gp_Dir D (V);
647 Handle(Geom_Axis1Placement) OrigineAndVect=new Geom_Axis1Placement (A,D);
648 Handle(AIS_Axis) TheAxis=new AIS_Axis (OrigineAndVect);
649 GetMapOfAIS().Bind (TheAxis,name);
650 TheAISContext()->Display(TheAxis);
651 }
652
653 }
654
655 // Fonction axispara
656 // Purpose: Teste le constructeur AIS_Axis::AIS_Axis(x: Axis2Placement from Geom, y: TypeOfAxis from AIS)
657 else if ( !strcasecmp(argv[0], "vaxispara")) {
658
659 TheAISContext()->OpenLocalContext();
660 MyCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
661
161c4476 662 // Active le mode edge
7fd59977 663 TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(2) );
664 di<<" Select an edge."<<"\n";
665
666 // Boucle d'attente waitpick.
667 Standard_Integer argcc = 5;
668 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
669 const char **argvv = (const char **) buff;
670 while (ViewerMainLoop( argcc, argvv) ) { }
161c4476 671 // fin de la boucle
7fd59977 672
673 TopoDS_Shape ShapeA;
674 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
675 ShapeA = TheAISContext()->SelectedShape();
676 }
677 // Active le mode vertex et deactive edges
678 TheAISContext()->DeactivateStandardMode(AIS_Shape::SelectionType(2) );
679 TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(1) );
680 di<<" Select a vertex."<<"\n";
681
682 // Boucle d'attente waitpick.
683 Standard_Integer argccc = 5;
684 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
685 const char **argvvv = (const char **) bufff;
686 while (ViewerMainLoop( argccc, argvvv) ) { }
161c4476 687 // fin de la boucle
7fd59977 688
689 // On peut choisir un pnt sur l'edge
690 TopoDS_Shape ShapeB;
691 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
692 ShapeB = TheAISContext()->SelectedShape();
693 }
694 // Fermeture du context local
695 TheAISContext()->CloseLocalContext(MyCurrentIndex);
696
697 // Construction de l'axe
698 TopoDS_Edge ed=TopoDS::Edge(ShapeA) ;
699 gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) );
700 TopoDS_Vertex Va,Vc;
701 TopExp::Vertices(ed,Va,Vc );
702 gp_Pnt A=BRep_Tool::Pnt(Va);
703 gp_Pnt C=BRep_Tool::Pnt(Vc);
704 gp_Vec V (A,C);
705 gp_Dir D (V);
706 Handle(Geom_Axis1Placement) OrigineAndVect=new Geom_Axis1Placement (B,D);
707 Handle(AIS_Axis) TheAxis=new AIS_Axis (OrigineAndVect);
708 GetMapOfAIS().Bind (TheAxis,name);
709 TheAISContext()->Display(TheAxis);
710
711 }
712
713 // Fonction axisortho
714 else {
715 TheAISContext()->OpenLocalContext();
716 MyCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
717
161c4476 718 // Active le mode edge
7fd59977 719 TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(2) );
720 di<<" Select an edge."<<"\n";
721
722 // Boucle d'attente waitpick.
723 Standard_Integer argcc = 5;
724 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
725 const char **argvv = (const char **) buff;
726 while (ViewerMainLoop( argcc, argvv) ) { }
161c4476 727 // fin de la boucle
7fd59977 728
729 TopoDS_Shape ShapeA;
730 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
731 ShapeA = TheAISContext()->SelectedShape();
732 }
733 // Active le mode vertex et deactive edges
734 TheAISContext()->DeactivateStandardMode(AIS_Shape::SelectionType(2) );
735 TheAISContext()->ActivateStandardMode(AIS_Shape::SelectionType(1) );
736 di<<" Slect a vertex."<<"\n";
737
738 // Boucle d'attente waitpick.
739 Standard_Integer argccc = 5;
740 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
741 const char **argvvv = (const char **) bufff;
742 while (ViewerMainLoop( argccc, argvvv) ) { }
161c4476 743 // fin de la boucle
7fd59977 744
745 // On peut choisir un pnt sur l'edge
746 TopoDS_Shape ShapeB;
747 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
748 ShapeB = TheAISContext()->SelectedShape();
749 }
750 // Fermeture du context local
751 TheAISContext()->CloseLocalContext(MyCurrentIndex);
752
753 // Construction de l'axe
754 TopoDS_Edge ed=TopoDS::Edge(ShapeA) ;
755 gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) );
756 TopoDS_Vertex Va,Vc;
757 TopExp::Vertices(ed,Va,Vc );
758 gp_Pnt A=BRep_Tool::Pnt(Va);
759 gp_Pnt C=BRep_Tool::Pnt(Vc);
760 gp_Pnt E(A.Y()+A.Z()-C.Y()-C.Z() ,C.X()-A.X() ,C.X()-A.X() );
761 gp_Vec V (A,E);
762 gp_Dir D (V);
763 Handle(Geom_Axis1Placement) OrigineAndVect=new Geom_Axis1Placement (B,D);
764 Handle(AIS_Axis) TheAxis=new AIS_Axis (OrigineAndVect);
765 GetMapOfAIS().Bind (TheAxis,name);
766 TheAISContext()->Display(TheAxis);
767
768 }
769
770 }
771 return 0;
772}
773
774
775//==============================================================================
776// Fonction First click Result
161c4476 777//
7fd59977 778// vpoint vertex AIS_Point=Vertex
779// edge AIS_Point=Middle of the edge
780//==============================================================================
781
782//==============================================================================
783//function : VPointBuilder
784//purpose : Build an AIS_Point from coordinates or with a selected vertex or edge
785//Draw arg : vpoint PoinName [Xa] [Ya] [Za]
786//==============================================================================
787#include <TopoDS_Edge.hxx>
788#include <TopoDS_Vertex.hxx>
789#include <TopExp.hxx>
790#include <AIS_Point.hxx>
791#include <Geom_CartesianPoint.hxx>
792
161c4476 793static int VPointBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
7fd59977 794{
795 // Declarations
796 Standard_Boolean HasArg;
797 TCollection_AsciiString name;
798 Standard_Integer myCurrentIndex;
799
800 // Verification
801 if (argc<2 || argc>5 ) {di<<" Syntaxe error"<<"\n";return 1;}
802 if (argc==5) HasArg=Standard_True;
803 else HasArg=Standard_False;
804
805 name=argv[1];
806 // Fermeture des contextes
807 TheAISContext()->CloseAllContexts();
808
809 // Il y a des arguments: teste l'unique constructeur AIS_Pnt::AIS_Pnt(Point from Geom)
810 if (HasArg) {
811 Standard_Real thecoord[3];
812 for(Standard_Integer i=0;i<=2;i++)
91322f44 813 thecoord[i]=Draw::Atof(argv[2+i]);
7fd59977 814 Handle(Geom_CartesianPoint ) myGeomPoint= new Geom_CartesianPoint (thecoord[0],thecoord[1],thecoord[2]);
815 Handle(AIS_Point) myAISPoint=new AIS_Point(myGeomPoint );
816 GetMapOfAIS().Bind (myAISPoint,name);
817 TheAISContext()->Display(myAISPoint);
818 }
819
820 // Il n'a pas d'arguments
821 else {
822 TheAISContext()->OpenLocalContext();
823 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
824
825 // Active le mode Vertex et Edges
826 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
827 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
828 di<<" Select a vertex or an edge(build the middle)"<<"\n";
829
830 // Boucle d'attente waitpick.
831 Standard_Integer argcc = 5;
832 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
833 const char **argvv = (const char **) buff;
834 while (ViewerMainLoop( argcc, argvv) ) { }
835 // fin de la boucle
836
837 TopoDS_Shape ShapeA;
838 for (TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
839 ShapeA= TheAISContext()->SelectedShape();
840 }
841
842 if (ShapeA.ShapeType()==TopAbs_VERTEX ) {
843 // Un vertex a ete selectionne
844 // Fermeture du context local
845 TheAISContext()->CloseLocalContext(myCurrentIndex);
846
847 // Construction du point
848 gp_Pnt A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA ) );
849 Handle(Geom_CartesianPoint) myGeomPoint= new Geom_CartesianPoint (A );
850 Handle(AIS_Point) myAISPoint = new AIS_Point (myGeomPoint );
851 GetMapOfAIS().Bind(myAISPoint,name);
852 TheAISContext()->Display(myAISPoint);
853 }
854 else {
855 // Un Edge a ete selectionne
856 // Fermeture du context local
857 TheAISContext()->CloseLocalContext(myCurrentIndex);
858
859 // Construction du point milieu de l'edge
860 TopoDS_Edge myEdge=TopoDS::Edge(ShapeA);
861 TopoDS_Vertex myVertexA,myVertexB;
862 TopExp::Vertices (myEdge ,myVertexA ,myVertexB );
863 gp_Pnt A=BRep_Tool::Pnt(myVertexA );
864 gp_Pnt B=BRep_Tool::Pnt(myVertexB );
865 // M est le milieu de [AB]
866 Handle(Geom_CartesianPoint) myGeomPointM= new Geom_CartesianPoint ( (A.X()+B.X())/2 , (A.Y()+B.Y())/2 , (A.Z()+B.Z())/2 );
867 Handle(AIS_Point) myAISPointM = new AIS_Point (myGeomPointM );
868 GetMapOfAIS().Bind(myAISPointM,name);
869 TheAISContext()->Display(myAISPointM);
870 }
871
872 }
873 return 0;
874
875}
876
877//==============================================================================
ceae62f0 878// Function 1st click 2de click 3de click
7fd59977 879// vplane Vertex Vertex Vertex
880// Vertex Edge
881// Edge Vertex
882// Face
883// vplanepara Face Vertex
884// Vertex Face
885// vplaneortho Face Edge
886// Edge Face
887//==============================================================================
888
889//==============================================================================
890//function : VPlaneBuilder
ceae62f0 891//purpose : Build an AIS_Plane from selected entities or Named AIS components
9e8804b6 892//Draw arg : vplane PlaneName [AxisName] [PointName] [TypeOfSensitivity]
893// [PointName] [PointName] [PointName] [TypeOfSensitivity]
894// [PlaneName] [PointName] [TypeOfSensitivity]
7fd59977 895//==============================================================================
896
35e08fe8 897static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
ceae62f0
A
898 Standard_Integer argc,
899 const char** argv)
7fd59977 900{
901 // Declarations
ceae62f0
A
902 Standard_Boolean hasArg;
903 TCollection_AsciiString aName;
904 Standard_Integer aCurrentIndex;
7fd59977 905
906 // Verification
9e8804b6 907 if (argc<2 || argc>6 )
ceae62f0
A
908 {
909 std::cout<<" Syntax error\n";
910 return 1;
911 }
9e8804b6 912 if (argc == 6 || argc==5 || argc==4)
ceae62f0
A
913 hasArg=Standard_True;
914 else
915 hasArg=Standard_False;
7fd59977 916
ceae62f0
A
917 aName=argv[1];
918 // Close all contexts
7fd59977 919 TheAISContext()->CloseAllContexts();
920
ceae62f0
A
921 // There are some arguments
922 if (hasArg)
923 {
924 if (!GetMapOfAIS().IsBound2(argv[2] ))
925 {
926 std::cout<<"vplane: error 1st name doesn't exist in the GetMapOfAIS()\n";
927 return 1;
928 }
929 // Get shape from map
930 Handle(AIS_InteractiveObject) aShapeA =
7fd59977 931 Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[2] ));
932
ceae62f0
A
933 // The first argument is an AIS_Point
934 if (!aShapeA.IsNull() &&
935 aShapeA->Type()==AIS_KOI_Datum &&
936 aShapeA->Signature()==1)
937 {
938 // The second argument must also be an AIS_Point
939 if (argc<5 || !GetMapOfAIS().IsBound2(argv[3]))
940 {
941 std::cout<<"vplane: error 2nd name doesn't exist in the GetMapOfAIS()\n";
942 return 1;
943 }
944 // Get shape from map
945 Handle(AIS_InteractiveObject) aShapeB =
7fd59977 946 Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[3]));
ceae62f0
A
947 // If B is not an AIS_Point
948 if (aShapeB.IsNull() ||
949 (!(aShapeB->Type()==AIS_KOI_Datum && aShapeB->Signature()==1)))
7fd59977 950 {
ceae62f0 951 std::cout<<"vplane: error 2nd object is expected to be an AIS_Point.\n";
7fd59977 952 return 1;
953 }
ceae62f0
A
954 // The third object is an AIS_Point
955 if (!GetMapOfAIS().IsBound2(argv[4]) )
956 {
957 std::cout<<"vplane: error 3d name doesn't exist in the GetMapOfAIS().\n";
958 return 1;
959 }
960 // Get shape from map
961 Handle(AIS_InteractiveObject) aShapeC =
7fd59977 962 Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[4]));
ceae62f0
A
963 // If C is not an AIS_Point
964 if (aShapeC.IsNull() ||
965 (!(aShapeC->Type()==AIS_KOI_Datum && aShapeC->Signature()==1)))
7fd59977 966 {
ceae62f0 967 std::cout<<"vplane: error 3d object is expected to be an AIS_Point.\n";
7fd59977 968 return 1;
969 }
970
ceae62f0
A
971 // Treatment of objects A, B, C
972 // Downcast an AIS_IO to AIS_Point
973 Handle(AIS_Point) anAISPointA = Handle(AIS_Point)::DownCast( aShapeA);
974 Handle(AIS_Point) anAISPointB = Handle(AIS_Point)::DownCast( aShapeB);
975 Handle(AIS_Point) anAISPointC = Handle(AIS_Point)::DownCast( aShapeC);
7fd59977 976
ceae62f0
A
977 Handle(Geom_CartesianPoint ) aCartPointA =
978 Handle(Geom_CartesianPoint)::DownCast( anAISPointA->Component());
7fd59977 979
ceae62f0
A
980 Handle(Geom_CartesianPoint ) aCartPointB =
981 Handle(Geom_CartesianPoint)::DownCast( anAISPointB->Component());
7fd59977 982
ceae62f0
A
983 Handle(Geom_CartesianPoint ) aCartPointC =
984 Handle(Geom_CartesianPoint)::DownCast( anAISPointC->Component());
7fd59977 985
ceae62f0 986 // Verification that the three points are different
91322f44 987 if(Abs(aCartPointB->X()-aCartPointA->X())<=Precision::Confusion() &&
988 Abs(aCartPointB->Y()-aCartPointA->Y())<=Precision::Confusion() &&
989 Abs(aCartPointB->Z()-aCartPointA->Z())<=Precision::Confusion())
ceae62f0 990 {
7fd59977 991 // B=A
ceae62f0 992 std::cout<<"vplane error: same points"<<"\n";return 1;
7fd59977 993 }
91322f44 994 if(Abs(aCartPointC->X()-aCartPointA->X())<=Precision::Confusion() &&
995 Abs(aCartPointC->Y()-aCartPointA->Y())<=Precision::Confusion() &&
996 Abs(aCartPointC->Z()-aCartPointA->Z())<=Precision::Confusion())
ceae62f0 997 {
7fd59977 998 // C=A
ceae62f0 999 std::cout<<"vplane error: same points"<<"\n";return 1;
7fd59977 1000 }
91322f44 1001 if(Abs(aCartPointC->X()-aCartPointB->X())<=Precision::Confusion() &&
1002 Abs(aCartPointC->Y()-aCartPointB->Y())<=Precision::Confusion() &&
1003 Abs(aCartPointC->Z()-aCartPointB->Z())<=Precision::Confusion())
ceae62f0 1004 {
7fd59977 1005 // C=B
ceae62f0 1006 std::cout<<"vplane error: same points"<<"\n";return 1;
7fd59977 1007 }
1008
ceae62f0
A
1009 gp_Pnt A = aCartPointA->Pnt();
1010 gp_Pnt B = aCartPointB->Pnt();
1011 gp_Pnt C = aCartPointC->Pnt();
7fd59977 1012
ceae62f0 1013 // Construction of AIS_Plane
7fd59977 1014 GC_MakePlane MkPlane (A,B,C);
ceae62f0
A
1015 Handle(Geom_Plane) aGeomPlane = MkPlane.Value();
1016 Handle(AIS_Plane) anAISPlane = new AIS_Plane(aGeomPlane );
1017 GetMapOfAIS().Bind (anAISPlane,aName );
9e8804b6 1018 if (argc == 6)
1019 {
1020 Standard_Integer aType = Draw::Atoi (argv[5]);
1021 if (aType != 0 && aType != 1)
1022 {
1023 std::cout << "vplane error: wrong type of sensitivity!\n"
1024 << "Should be one of the following values:\n"
1025 << "0 - Interior\n"
1026 << "1 - Boundary"
1027 << std::endl;
1028 return 1;
1029 }
1030 else
1031 {
1032 anAISPlane->SetTypeOfSensitivity (Select3D_TypeOfSensitivity (aType));
1033 }
1034 }
ceae62f0 1035 TheAISContext()->Display(anAISPlane);
7fd59977 1036 }
1037
ceae62f0
A
1038 // The first argument is an AIS_Axis
1039 // Creation of a plane orthogonal to the axis through a point
1040 else if (aShapeA->Type()==AIS_KOI_Datum && aShapeA->Signature()==2 ) {
1041 // The second argument should be an AIS_Point
7fd59977 1042 if (argc!=4 || !GetMapOfAIS().IsBound2(argv[3] ) )
1043 {
ceae62f0 1044 std::cout<<"vplane: error 2d name doesn't exist in the GetMapOfAIS()\n";
7fd59977 1045 return 1;
1046 }
ceae62f0
A
1047 // Get shape from map
1048 Handle(AIS_InteractiveObject) aShapeB =
7fd59977 1049 Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[3]));
ceae62f0
A
1050 // If B is not an AIS_Point
1051 if (aShapeB.IsNull() ||
1052 (!(aShapeB->Type()==AIS_KOI_Datum && aShapeB->Signature()==1)))
7fd59977 1053 {
ceae62f0 1054 std::cout<<"vplane: error 2d object is expected to be an AIS_Point\n";
7fd59977 1055 return 1;
1056 }
1057
ceae62f0
A
1058 // Treatment of objects A and B
1059 Handle(AIS_Axis) anAISAxisA = Handle(AIS_Axis)::DownCast(aShapeA);
1060 Handle(AIS_Point) anAISPointB = Handle(AIS_Point)::DownCast(aShapeB);
7fd59977 1061
ceae62f0
A
1062 Handle(Geom_Line ) aGeomLineA = anAISAxisA ->Component();
1063 Handle(Geom_Point) aGeomPointB = anAISPointB->Component() ;
7fd59977 1064
ceae62f0
A
1065 gp_Ax1 anAxis = aGeomLineA->Position();
1066 Handle(Geom_CartesianPoint) aCartPointB =
1067 Handle(Geom_CartesianPoint)::DownCast(aGeomPointB);
7fd59977 1068
ceae62f0
A
1069 gp_Dir D =anAxis.Direction();
1070 gp_Pnt B = aCartPointB->Pnt();
7fd59977 1071
ceae62f0
A
1072 // Construction of AIS_Plane
1073 Handle(Geom_Plane) aGeomPlane = new Geom_Plane(B,D);
1074 Handle(AIS_Plane) anAISPlane = new AIS_Plane(aGeomPlane,B );
1075 GetMapOfAIS().Bind (anAISPlane,aName );
9e8804b6 1076 if (argc == 5)
1077 {
1078 Standard_Integer aType = Draw::Atoi (argv[4]);
1079 if (aType != 0 && aType != 1)
1080 {
1081 std::cout << "vplane error: wrong type of sensitivity!\n"
1082 << "Should be one of the following values:\n"
1083 << "0 - Interior\n"
1084 << "1 - Boundary"
1085 << std::endl;
1086 return 1;
1087 }
1088 else
1089 {
1090 anAISPlane->SetTypeOfSensitivity (Select3D_TypeOfSensitivity (aType));
1091 }
1092 }
ceae62f0 1093 TheAISContext()->Display(anAISPlane);
7fd59977 1094
1095 }
ceae62f0
A
1096 // The first argumnet is an AIS_Plane
1097 // Creation of a plane parallel to the plane passing through the point
1098 else if (aShapeA->Type()==AIS_KOI_Datum && aShapeA->Signature()==7)
1099 {
1100 // The second argument should be an AIS_Point
1101 if (argc!=4 || !GetMapOfAIS().IsBound2(argv[3]))
1102 {
1103 std::cout<<"vplane: error 2d name doesn't exist in the GetMapOfAIS()\n";
7fd59977 1104 return 1;
1105 }
ceae62f0
A
1106 // Get shape from map
1107 Handle(AIS_InteractiveObject) aShapeB =
7fd59977 1108 Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[3]));
ceae62f0
A
1109 // B should be an AIS_Point
1110 if (aShapeB.IsNull() ||
1111 (!(aShapeB->Type()==AIS_KOI_Datum && aShapeB->Signature()==1)))
7fd59977 1112 {
ceae62f0 1113 std::cout<<"vplane: error 2d object is expected to be an AIS_Point\n";
7fd59977 1114 return 1;
1115 }
1116
ceae62f0
A
1117 // Treatment of objects A and B
1118 Handle(AIS_Plane) anAISPlaneA = Handle(AIS_Plane)::DownCast(aShapeA);
1119 Handle(AIS_Point) anAISPointB = Handle(AIS_Point)::DownCast(aShapeB);
7fd59977 1120
ceae62f0
A
1121 Handle(Geom_Plane) aNewGeomPlane= anAISPlaneA->Component();
1122 Handle(Geom_Point) aGeomPointB = anAISPointB->Component();
7fd59977 1123
ceae62f0
A
1124 Handle(Geom_CartesianPoint) aCartPointB =
1125 Handle(Geom_CartesianPoint)::DownCast(aGeomPointB);
1126 gp_Pnt B= aCartPointB->Pnt();
7fd59977 1127
ceae62f0
A
1128 // Construction of an AIS_Plane
1129 Handle(AIS_Plane) anAISPlane = new AIS_Plane(aNewGeomPlane, B);
1130 GetMapOfAIS().Bind (anAISPlane, aName);
9e8804b6 1131 if (argc == 5)
1132 {
1133 Standard_Integer aType = Draw::Atoi (argv[4]);
1134 if (aType != 0 && aType != 1)
1135 {
1136 std::cout << "vplane error: wrong type of sensitivity!\n"
1137 << "Should be one of the following values:\n"
1138 << "0 - Interior\n"
1139 << "1 - Boundary"
1140 << std::endl;
1141 return 1;
1142 }
1143 else
1144 {
1145 anAISPlane->SetTypeOfSensitivity (Select3D_TypeOfSensitivity (aType));
1146 }
1147 }
ceae62f0
A
1148 TheAISContext()->Display(anAISPlane);
1149 }
1150 // Error
1151 else
1152 {
1153 std::cout<<"vplane: error 1st object is not an AIS\n";
1154 return 1;
7fd59977 1155 }
7fd59977 1156 }
ceae62f0
A
1157 // There are no arguments
1158 else
1159 {
1160 // Function vplane
1161 // Test the constructor AIS_Plane::AIS_Plane(Geom_Plane, Standard_Boolean )
1162 if (!strcasecmp(argv[0], "vplane"))
1163 {
7fd59977 1164 TheAISContext()->OpenLocalContext();
ceae62f0 1165 aCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
7fd59977 1166
ceae62f0
A
1167 // Active modes Vertex, Edge and Face
1168 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1));
1169 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2));
1170 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4));
1171 std::cout<<"Select a vertex, a face or an edge\n";
7fd59977 1172
ceae62f0 1173 // Wait for picking
7fd59977 1174 Standard_Integer argcc = 5;
1175 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1176 const char **argvv = (const char **) buff;
1177 while (ViewerMainLoop( argcc, argvv) ) { }
ceae62f0 1178 // end of the loop
7fd59977 1179
ceae62f0
A
1180 TopoDS_Shape aShapeA;
1181 for (TheAISContext()->InitSelected();
1182 TheAISContext()->MoreSelected();
1183 TheAISContext()->NextSelected())
1184 {
1185 aShapeA = TheAISContext()->SelectedShape();
7fd59977 1186 }
1187
ceae62f0
A
1188 // aShapeA is a Vertex
1189 if (aShapeA.ShapeType()==TopAbs_VERTEX )
1190 {
1191 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4));
1192 std::cout<<" Select an edge or a different vertex\n";
7fd59977 1193
ceae62f0 1194 // Wait for picking
7fd59977 1195 Standard_Integer argccc = 5;
1196 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1197 const char **argvvv = (const char **) bufff;
1198 while (ViewerMainLoop( argccc, argvvv) ) { }
ceae62f0 1199 // end of the loop
7fd59977 1200
ceae62f0
A
1201 TopoDS_Shape aShapeB;
1202 for (TheAISContext()->InitSelected();
1203 TheAISContext()->MoreSelected();
1204 TheAISContext()->NextSelected())
1205 {
1206 aShapeB = TheAISContext()->SelectedShape();
7fd59977 1207 }
ceae62f0
A
1208 // aShapeB is a Vertex
1209 if (aShapeB.ShapeType()==TopAbs_VERTEX)
1210 {
1211 // A and B are the same
1212 if (aShapeB.IsSame(aShapeA))
1213 {
1214 std::cout<<" vplane: error, same points selected\n";
1215 return 1;
1216 }
1217 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2));
1218 std::cout<<" Select a different vertex\n";
7fd59977 1219
ceae62f0 1220 // Wait for picking
7fd59977 1221 Standard_Integer argcccc = 5;
1222 const char *buffff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1223 const char **argvvvv = (const char **) buffff;
1224 while (ViewerMainLoop( argcccc, argvvvv) ) { }
ceae62f0 1225 // end of the loop
7fd59977 1226
ceae62f0
A
1227 TopoDS_Shape aShapeC;
1228 for (TheAISContext()->InitSelected();
1229 TheAISContext()->MoreSelected();
1230 TheAISContext()->NextSelected())
1231 {
1232 aShapeC = TheAISContext()->SelectedShape();
1233 }
1234 // aShapeC is the same as A or B
1235 if (aShapeC.IsSame(aShapeA)||aShapeC.IsSame(aShapeB))
1236 {
1237 std::cout<<" vplane: error, same points selected\n";
1238 return 1;
7fd59977 1239 }
7fd59977 1240
ceae62f0
A
1241 // Close the local context
1242 TheAISContext()->CloseLocalContext(aCurrentIndex);
1243
1244 // Construction of plane
1245 gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(aShapeA));
1246 gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(aShapeB));
1247 gp_Pnt C = BRep_Tool::Pnt(TopoDS::Vertex(aShapeC));
1248 GC_MakePlane MkPlane(A, B, C);
1249 Handle(Geom_Plane) aGeomPlane = MkPlane.Value();
1250 Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane);
1251 GetMapOfAIS().Bind (anAISPlane, aName);
1252 TheAISContext()->Display(anAISPlane);
7fd59977 1253 }
ceae62f0
A
1254 // ShapeB is an edge
1255 else
1256 {
1257 // Verify that the vertex is not on the edge ShapeB
1258 TopoDS_Edge anEdgeB = TopoDS::Edge(aShapeB);
1259 TopoDS_Vertex aVertA = TopoDS::Vertex(aShapeA);
7fd59977 1260
ceae62f0
A
1261 BRepExtrema_ExtPC OrthoProj(aVertA, anEdgeB);
1262 if (OrthoProj.SquareDistance(1)<Precision::Approximation())
1263 {
1264 // The vertex is on the edge
1265 std::cout<<" vplane: error point is on the edge\n";
1266 return 1;
1267 }
1268 else
1269 {
1270 // Close the local context
1271 TheAISContext()->CloseLocalContext(aCurrentIndex);
1272 // Construction of plane
1273 gp_Pnt A = BRep_Tool::Pnt(aVertA);
1274 TopoDS_Vertex aVBa, aVBb;
1275 TopExp::Vertices(anEdgeB ,aVBa ,aVBb);
1276 gp_Pnt aBa = BRep_Tool::Pnt(aVBa);
1277 gp_Pnt aBb = BRep_Tool::Pnt(aVBb);
1278 GC_MakePlane MkPlane (A, aBa, aBb);
1279 Handle(Geom_Plane) aGeomPlane = MkPlane.Value();
1280 Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane);
1281 GetMapOfAIS().Bind (anAISPlane, aName);
1282 TheAISContext()->Display(anAISPlane);
7fd59977 1283 }
7fd59977 1284 }
7fd59977 1285 }
ceae62f0
A
1286 // aShapeA is an edge
1287 else if (aShapeA.ShapeType()==TopAbs_EDGE)
1288 {
1289 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4));
1290 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2));
1291 std::cout<<" Select a vertex that don't belong to the edge\n";
7fd59977 1292
ceae62f0 1293 // Wait for picking
7fd59977 1294 Standard_Integer argccc = 5;
1295 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1296 const char **argvvv = (const char **) bufff;
1297 while (ViewerMainLoop( argccc, argvvv) ) { }
ceae62f0 1298 // end of the loop
7fd59977 1299
ceae62f0
A
1300 TopoDS_Shape aShapeB;
1301 for (TheAISContext()->InitSelected();
1302 TheAISContext()->MoreSelected();
1303 TheAISContext()->NextSelected())
1304 {
1305 aShapeB = TheAISContext()->SelectedShape();
7fd59977 1306 }
ceae62f0
A
1307 // aShapeB should be a Vertex
1308 // Check that the vertex aShapeB is not on the edge
1309 TopoDS_Edge anEdgeA = TopoDS::Edge(aShapeA);
1310 TopoDS_Vertex aVertB = TopoDS::Vertex(aShapeB);
1311
1312 BRepExtrema_ExtPC OrthoProj (aVertB, anEdgeA);
1313 if (OrthoProj.SquareDistance(1)<Precision::Approximation())
1314 {
1315 // The vertex is on the edge
1316 std::cout<<" vplane: error point is on the edge\n";
1317 return 1;
7fd59977 1318 }
ceae62f0
A
1319 else
1320 {
1321 // Close the local context
1322 TheAISContext()->CloseLocalContext(aCurrentIndex);
1323 // Construction of plane
1324 gp_Pnt B = BRep_Tool::Pnt(aVertB);
1325 TopoDS_Vertex aVAa, aVAb;
1326 TopExp::Vertices(anEdgeA, aVAa, aVAb);
1327 gp_Pnt Aa = BRep_Tool::Pnt(aVAa);
1328 gp_Pnt Ab = BRep_Tool::Pnt(aVAb);
7fd59977 1329 GC_MakePlane MkPlane (B,Aa,Ab);
ceae62f0
A
1330 Handle(Geom_Plane) aGeomPlane = MkPlane.Value();
1331 Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane);
1332 GetMapOfAIS().Bind (anAISPlane ,aName);
1333 TheAISContext()->Display(anAISPlane);
7fd59977 1334 }
7fd59977 1335 }
ceae62f0
A
1336 // aShapeA is a Face
1337 else
1338 {
1339 // Close the local context: nothing to select
1340 TheAISContext()->CloseLocalContext(aCurrentIndex);
1341 // Construction of plane
1342 TopoDS_Face aFace = TopoDS::Face(aShapeA);
1343 BRepAdaptor_Surface aSurface (aFace, Standard_False);
1344 if (aSurface.GetType()==GeomAbs_Plane)
1345 {
1346 gp_Pln aPlane = aSurface.Plane();
1347 Handle(Geom_Plane) aGeomPlane = new Geom_Plane(aPlane);
1348 Handle(AIS_Plane) anAISPlane = new AIS_Plane(aGeomPlane);
1349 GetMapOfAIS().Bind (anAISPlane, aName);
1350 TheAISContext()->Display(anAISPlane);
7fd59977 1351 }
ceae62f0
A
1352 else
1353 {
1354 std::cout<<" vplane: error\n";
1355 return 1;
7fd59977 1356 }
7fd59977 1357 }
7fd59977 1358 }
1359
ceae62f0 1360 // Function vPlanePara
7fd59977 1361 // ===================
ceae62f0
A
1362 // test the constructor AIS_Plane::AIS_Plane(Geom_Plane,gp_Pnt)
1363 else if (!strcasecmp(argv[0], "vplanepara"))
1364 {
7fd59977 1365 TheAISContext()->OpenLocalContext();
ceae62f0 1366 aCurrentIndex = TheAISContext()->IndexOfCurrentLocal();
7fd59977 1367
ceae62f0
A
1368 // Activate modes Vertex and Face
1369 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1));
1370 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4));
1371 std::cout<<" Select a vertex or a face\n";
7fd59977 1372
ceae62f0 1373 // Wait for picking
7fd59977 1374 Standard_Integer argcc = 5;
1375 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1376 const char **argvv = (const char **) buff;
1377 while (ViewerMainLoop( argcc, argvv) ) { }
ceae62f0 1378 // end of the loop
7fd59977 1379
ceae62f0
A
1380 TopoDS_Shape aShapeA;
1381 for (TheAISContext()->InitSelected();
1382 TheAISContext()->MoreSelected();
1383 TheAISContext()->NextSelected())
1384 {
1385 aShapeA = TheAISContext()->SelectedShape();
7fd59977 1386 }
1387
ceae62f0
A
1388 if (aShapeA.ShapeType()==TopAbs_VERTEX )
1389 {
1390 // aShapeA is a vertex
1391 // Deactivate the mode Vertex
1392 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(1));
1393 std::cout<<" Select a face\n";
7fd59977 1394
ceae62f0 1395 // Wait for picking
7fd59977 1396 Standard_Integer argccc = 5;
1397 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1398 const char **argvvv = (const char **) bufff;
1399 while (ViewerMainLoop( argccc, argvvv) ) { }
ceae62f0 1400 // end of the loop
7fd59977 1401
ceae62f0
A
1402 TopoDS_Shape aShapeB;
1403 for (TheAISContext()->InitSelected();
1404 TheAISContext()->MoreSelected();
1405 TheAISContext()->NextSelected())
1406 {
1407 // A vertex ShapeA can be on Face ShapeB
1408 aShapeB = TheAISContext()->SelectedShape();
7fd59977 1409 }
1410
ceae62f0
A
1411 // Close the local context
1412 TheAISContext()->CloseLocalContext(aCurrentIndex);
7fd59977 1413
ceae62f0
A
1414 // Construction of plane
1415 gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(aShapeA));
1416
1417 TopoDS_Face aFace = TopoDS::Face(aShapeB);
1418 BRepAdaptor_Surface aSurface (aFace, Standard_False);
1419 if (aSurface.GetType()==GeomAbs_Plane )
1420 {
1421 gp_Pln aPlane = aSurface.Plane();
1422 // Construct a plane parallel to aGeomPlane through A
1423 aPlane.SetLocation(A);
1424 Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane);
1425 Handle(AIS_Plane) aAISPlane = new AIS_Plane (aGeomPlane, A);
1426 GetMapOfAIS().Bind (aAISPlane ,aName);
1427 TheAISContext()->Display(aAISPlane);
7fd59977 1428 }
ceae62f0
A
1429 else
1430 {
1431 std::cout<<" vplanepara: error\n";
1432 return 1;
7fd59977 1433 }
7fd59977 1434 }
ceae62f0
A
1435 else
1436 {
1437 // ShapeA is a Face
1438 // Deactive the mode Face
1439 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4));
1440 std::cout<<" Select a vertex\n";
7fd59977 1441
ceae62f0 1442 // Wait for picking
7fd59977 1443 Standard_Integer argccc = 5;
1444 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1445 const char **argvvv = (const char **) bufff;
1446 while (ViewerMainLoop( argccc, argvvv) ) { }
ceae62f0 1447 // end of the loop
7fd59977 1448
ceae62f0
A
1449 TopoDS_Shape aShapeB;
1450 for (TheAISContext()->InitSelected();
1451 TheAISContext()->MoreSelected();
1452 TheAISContext()->NextSelected())
1453 {
1454 // A vertex ShapeB can be on Face ShapeA
1455 aShapeB = TheAISContext()->SelectedShape();
7fd59977 1456 }
ceae62f0
A
1457 // Close the local context
1458 TheAISContext()->CloseLocalContext(aCurrentIndex);
7fd59977 1459
ceae62f0
A
1460 // Construction of plane
1461 gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(aShapeB));
1462
1463 TopoDS_Face aFace=TopoDS::Face(aShapeA);
1464 BRepAdaptor_Surface aSurface (aFace, Standard_False);
1465 if (aSurface.GetType()==GeomAbs_Plane )
1466 {
1467 gp_Pln aPlane = aSurface.Plane();
1468 aPlane.SetLocation(B);
1469 Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane);
1470 // Construct a plane parallel to aGeomPlane through B
1471 Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane, B);
1472 GetMapOfAIS().Bind (anAISPlane, aName);
1473 TheAISContext()->Display(anAISPlane);
7fd59977 1474 }
ceae62f0
A
1475 else
1476 {
1477 std::cout<<" vplanepara: error"<<"\n";return 1;
7fd59977 1478 }
7fd59977 1479 }
7fd59977 1480 }
1481
ceae62f0 1482 // Function vplaneortho
7fd59977 1483 // ====================
ceae62f0
A
1484 // test the constructor AIS_Plane::AIS_Plane(Geom_Plane,gp_Pnt,gp_Pnt,gp_Pnt)
1485 else
1486 {
7fd59977 1487 TheAISContext()->OpenLocalContext();
ceae62f0 1488 aCurrentIndex = TheAISContext()->IndexOfCurrentLocal();
7fd59977 1489
ceae62f0
A
1490 // Activate the modes Edge and Face
1491 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2));
1492 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4));
1493 std::cout<<" Select a face and an edge coplanar\n";
7fd59977 1494
ceae62f0 1495 // Wait for picking
7fd59977 1496 Standard_Integer argcc = 5;
1497 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1498 const char **argvv = (const char **) buff;
1499 while (ViewerMainLoop( argcc, argvv) ) { }
ceae62f0 1500 // end of the loop
7fd59977 1501
ceae62f0
A
1502 TopoDS_Shape aShapeA;
1503 for (TheAISContext()->InitSelected();
1504 TheAISContext()->MoreSelected();
1505 TheAISContext()->NextSelected())
1506 {
1507 aShapeA = TheAISContext()->SelectedShape();
7fd59977 1508 }
1509
ceae62f0
A
1510 if (aShapeA.ShapeType()==TopAbs_EDGE )
1511 {
1512 // ShapeA is an edge, deactivate the mode Edge...
1513 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2));
1514 std::cout<<" Select a face\n";
7fd59977 1515
ceae62f0 1516 // Wait for picking
7fd59977 1517 Standard_Integer argccc = 5;
1518 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1519 const char **argvvv = (const char **) bufff;
1520 while (ViewerMainLoop( argccc, argvvv) ) { }
ceae62f0 1521 // end of the loop
7fd59977 1522
ceae62f0
A
1523 TopoDS_Shape aShapeB;
1524 for (TheAISContext()->InitSelected();
1525 TheAISContext()->MoreSelected();
1526 TheAISContext()->NextSelected())
1527 {
1528 // Edge ShapeA can be on Face ShapeB
1529 aShapeB = TheAISContext()->SelectedShape();
7fd59977 1530 }
1531
ceae62f0
A
1532 // Close the local context
1533 TheAISContext()->CloseLocalContext(aCurrentIndex);
7fd59977 1534
ceae62f0
A
1535 // Construction of plane
1536 TopoDS_Edge anEdgeA = TopoDS::Edge(aShapeA);
1537 TopoDS_Vertex aVAa, aVAb;
1538 TopExp::Vertices(anEdgeA, aVAa, aVAb);
1539 gp_Pnt Aa = BRep_Tool::Pnt(aVAa);
1540 gp_Pnt Ab = BRep_Tool::Pnt(aVAb);
1541 gp_Vec ab (Aa,Ab);
7fd59977 1542
1543 gp_Dir Dab (ab);
ceae62f0
A
1544 // Creation of rotation axis
1545 gp_Ax1 aRotAxis (Aa,Dab);
1546
1547 TopoDS_Face aFace = TopoDS::Face(aShapeB);
1548 // The edge must be parallel to the face
1549 BRepExtrema_ExtPF aHeightA (aVAa, aFace);
1550 BRepExtrema_ExtPF aHeightB (aVAb, aFace);
1551 // Compare to heights
1552 if (fabs(sqrt(aHeightA.SquareDistance(1)) - sqrt(aHeightB.SquareDistance(1)))
1553 >Precision::Confusion())
1554 {
1555 // the edge is not parallel to the face
1556 std::cout<<" vplaneortho error: the edge is not parallel to the face\n";
1557 return 1;
7fd59977 1558 }
ceae62f0
A
1559 // the edge is OK
1560 BRepAdaptor_Surface aSurface (aFace, Standard_False);
1561 if (aSurface.GetType()==GeomAbs_Plane)
1562 {
1563 gp_Pln aPlane = aSurface.Plane();
1564 // It rotates a half turn round the axis of rotation
1565 aPlane.Rotate(aRotAxis , M_PI/2);
1566
1567 Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane);
1568 // constructed aGeomPlane parallel to a plane containing the edge (center mid-edge)
1569 gp_Pnt aMiddle ((Aa.X()+Ab.X() )/2 ,(Aa.Y()+Ab.Y() )/2 ,(Aa.Z()+Ab.Z() )/2 );
1570 Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane, aMiddle);
1571 GetMapOfAIS().Bind (anAISPlane, aName);
1572 TheAISContext()->Display(anAISPlane);
7fd59977 1573 }
ceae62f0
A
1574 else
1575 {
1576 std::cout<<" vplaneortho: error\n";
1577 return 1;
7fd59977 1578 }
7fd59977 1579 }
ceae62f0
A
1580 else
1581 {
1582 // ShapeA is a Face, deactive the mode Face.
1583 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4));
1584 std::cout<<" Select an edge\n";
7fd59977 1585
ceae62f0 1586 // Wait for picking
7fd59977 1587 Standard_Integer argccc = 5;
1588 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1589 const char **argvvv = (const char **) bufff;
1590 while (ViewerMainLoop( argccc, argvvv) ) { }
ceae62f0 1591 // end of the loop
7fd59977 1592
ceae62f0
A
1593 TopoDS_Shape aShapeB;
1594 for (TheAISContext()->InitSelected();
1595 TheAISContext()->MoreSelected();
1596 TheAISContext()->NextSelected())
1597 {
1598 // Edge ShapeB can be on Face ShapeA
1599 aShapeB = TheAISContext()->SelectedShape();
7fd59977 1600 }
ceae62f0
A
1601 // Close the local context
1602 TheAISContext()->CloseLocalContext(aCurrentIndex);
1603
1604 // Construction of plane
1605 TopoDS_Edge anEdgeB = TopoDS::Edge(aShapeB);
1606 TopoDS_Vertex aVBa, aVBb;
1607 TopExp::Vertices(anEdgeB, aVBa, aVBb);
1608 gp_Pnt aBa = BRep_Tool::Pnt(aVBa);
1609 gp_Pnt aBb = BRep_Tool::Pnt(aVBb);
1610 gp_Vec ab (aBa,aBb);
7fd59977 1611 gp_Dir Dab (ab);
ceae62f0
A
1612 // Creation of rotation axe
1613 gp_Ax1 aRotAxis (aBa,Dab);
1614
1615 TopoDS_Face aFace = TopoDS::Face(aShapeA);
1616 // The edge must be parallel to the face
1617 BRepExtrema_ExtPF aHeightA (aVBa, aFace);
1618 BRepExtrema_ExtPF aHeightB (aVBb, aFace);
1619 // Comparing the two heights
1620 if (fabs(sqrt(aHeightA.SquareDistance(1)) - sqrt(aHeightB.SquareDistance(1)))
1621 >Precision::Confusion())
1622 {
1623 // the edge is not parallel to the face
1624 std::cout<<" vplaneortho error: the edge is not parallel to the face\n";
1625 return 1;
7fd59977 1626 }
ceae62f0
A
1627 // The edge is OK
1628 BRepAdaptor_Surface aSurface (aFace, Standard_False);
1629 if (aSurface.GetType()==GeomAbs_Plane)
1630 {
1631 gp_Pln aPlane = aSurface.Plane();
1632 // It rotates a half turn round the axis of rotation
1633 aPlane.Rotate(aRotAxis , M_PI/2);
1634 Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane);
1635 // constructed aGeomPlane parallel to a plane containing the edge theGeomPlane (center mid-edge)
1636 gp_Pnt aMiddle ((aBa.X()+aBb.X() )/2 , (aBa.Y()+aBb.Y() )/2 , (aBa.Z()+aBb.Z() )/2 );
1637 Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane, aMiddle);
1638 GetMapOfAIS().Bind (anAISPlane ,aName);
1639 TheAISContext()->Display(anAISPlane);
7fd59977 1640 }
ceae62f0
A
1641 else
1642 {
1643 std::cout<<" vplaneortho: error\n";
1644 return 1;
7fd59977 1645 }
7fd59977 1646 }
7fd59977 1647 }
7fd59977 1648 }
1649 return 0;
7fd59977 1650}
1651
1652
1653//==============================================================================
1654// Fonction vline
1655// --------------- Uniquement par parametre. Pas de selection dans le viewer.
1656//==============================================================================
1657
1658//==============================================================================
1659//function : VLineBuilder
161c4476 1660//purpose : Build an AIS_Line
7fd59977 1661//Draw arg : vline LineName [AIS_PointName] [AIS_PointName]
1662// [Xa] [Ya] [Za] [Xb] [Yb] [Zb]
1663//==============================================================================
1664#include <Geom_CartesianPoint.hxx>
1665#include <AIS_Line.hxx>
1666
1667
161c4476 1668static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
7fd59977 1669{
1670 Standard_Integer myCurrentIndex;
1671 // Verifications
1672 if (argc!=4 && argc!=8 && argc!=2 ) {di<<"vline error: number of arguments not correct "<<"\n";return 1; }
1673 // Fermeture des contextes
1674 TheAISContext()->CloseAllContexts();
1675
1676 // On recupere les parametres
1677 Handle(AIS_InteractiveObject) theShapeA;
1678 Handle(AIS_InteractiveObject) theShapeB;
1679
1680 // Parametres: AIS_Point AIS_Point
1681 // ===============================
1682 if (argc==4) {
1683 theShapeA=
1684 Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[2]));
1685 // On verifie que c'est bien une AIS_Point
1686 if (!theShapeA.IsNull() &&
1687 theShapeA->Type()==AIS_KOI_Datum && theShapeA->Signature()==1) {
1688 // on recupere le deuxieme AIS_Point
1689 theShapeB=
1690 Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(argv[3]));
1691 if (theShapeA.IsNull() ||
1692 (!(theShapeB->Type()==AIS_KOI_Datum && theShapeB->Signature()==1)))
1693 {
1694 di <<"vline error: wrong type of 2de argument."<<"\n";
1695 return 1;
1696 }
1697 }
161c4476 1698 else {di <<"vline error: wrong type of 1st argument."<<"\n";return 1; }
7fd59977 1699 // Les deux parametres sont du bon type. On verifie que les points ne sont pas confondus
1700 Handle(AIS_Point) theAISPointA= *(Handle(AIS_Point)*)& theShapeA;
1701 Handle(AIS_Point) theAISPointB= *(Handle(AIS_Point)*)& theShapeB;
1702
1703 Handle(Geom_Point ) myGeomPointBA= theAISPointA->Component();
1704 Handle(Geom_CartesianPoint ) myCartPointA= *((Handle(Geom_CartesianPoint)*)& myGeomPointBA);
1705 // Handle(Geom_CartesianPoint ) myCartPointA= *(Handle(Geom_CartesianPoint)*)& (theAISPointA->Component() ) ;
1706
1707 Handle(Geom_Point ) myGeomPointB= theAISPointB->Component();
1708 Handle(Geom_CartesianPoint ) myCartPointB= *((Handle(Geom_CartesianPoint)*)& myGeomPointB);
1709 // Handle(Geom_CartesianPoint ) myCartPointB= *(Handle(Geom_CartesianPoint)*)& (theAISPointB->Component() ) ;
1710
1711 if (myCartPointB->X()==myCartPointA->X() && myCartPointB->Y()==myCartPointA->Y() && myCartPointB->Z()==myCartPointA->Z() ) {
1712 // B=A
1713 di<<"vline error: same points"<<"\n";return 1;
1714 }
1715 // Les deux points sont OK...Construction de l'AIS_Line (en faite, le segment AB)
1716 Handle(AIS_Line) theAISLine= new AIS_Line(myCartPointA,myCartPointB );
1717 GetMapOfAIS().Bind(theAISLine,argv[1] );
1718 TheAISContext()->Display(theAISLine );
1719
1720 }
1721
1722 // Parametres 6 Reals
1723 // ==================
1724
1725 else if (argc==8) {
161c4476 1726 // On verifie que les deux points ne sont pas confondus
7fd59977 1727
1728 Standard_Real coord[6];
1729 for(Standard_Integer i=0;i<=2;i++){
91322f44 1730 coord[i]=Draw::Atof(argv[2+i]);
1731 coord[i+3]=Draw::Atof(argv[5+i]);
7fd59977 1732 }
1733
1734 Handle(Geom_CartesianPoint ) myCartPointA=new Geom_CartesianPoint (coord[0],coord[1],coord[2] );
1735 Handle(Geom_CartesianPoint ) myCartPointB=new Geom_CartesianPoint (coord[3],coord[4],coord[5] );
1736
1737 Handle(AIS_Line) theAISLine= new AIS_Line(myCartPointA,myCartPointB );
1738 GetMapOfAIS().Bind(theAISLine,argv[1] );
1739 TheAISContext()->Display(theAISLine );
1740
1741 }
1742
1743 // Pas de parametres: Selection dans le viewer.
1744 // ============================================
1745
1746 else {
1747 TheAISContext()->OpenLocalContext();
1748 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
1749
1750 // Active le mode Vertex.
1751 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
1752 di<<" Select a vertex "<<"\n";
1753
1754 // Boucle d'attente waitpick.
1755 Standard_Integer argcc = 5;
1756 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1757 const char **argvv = (const char **) buff;
1758 while (ViewerMainLoop( argcc, argvv) ) { }
1759 // fin de la boucle
1760
1761 TopoDS_Shape ShapeA;
1762 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
1763 ShapeA = TheAISContext()->SelectedShape();
1764 }
1765
1766 // ShapeA est un Vertex
1767 if (ShapeA.ShapeType()==TopAbs_VERTEX ) {
1768
1769 di<<" Select a different vertex."<<"\n";
1770
1771 TopoDS_Shape ShapeB;
1772 do {
1773
1774 // Boucle d'attente waitpick.
1775 Standard_Integer argccc = 5;
1776 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1777 const char **argvvv = (const char **) bufff;
1778 while (ViewerMainLoop( argccc, argvvv) ) { }
161c4476 1779 // fin de la boucle
7fd59977 1780
1781 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
1782 ShapeB = TheAISContext()->SelectedShape();
1783 }
1784
1785
1786 } while(ShapeB.IsSame(ShapeA) );
1787
1788 // Fermeture du context local
1789 TheAISContext()->CloseLocalContext(myCurrentIndex);
1790
1791 // Construction de la line
1792 gp_Pnt A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA) );
1793 gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) );
1794
1795 Handle(Geom_CartesianPoint ) myCartPointA=new Geom_CartesianPoint(A);
1796 Handle(Geom_CartesianPoint ) myCartPointB=new Geom_CartesianPoint(B);
1797
1798 Handle(AIS_Line) theAISLine= new AIS_Line(myCartPointA,myCartPointB );
1799 GetMapOfAIS().Bind(theAISLine,argv[1] );
1800 TheAISContext()->Display(theAISLine );
1801
1802 }
1803 else {
1804 di<<"vline error."<<"\n";
1805 }
1806
1807 }
1808
1809 return 0;
1810}
1811
329843e2
A
1812//==============================================================================
1813// class : FilledCircle
1814// purpose : creates filled circle based on AIS_InteractiveObject
1815// and Geom_Circle.
1816// This class is used to check method Matches() of class
1817// Select3D_SensitiveCircle with member myFillStatus = Standard_True,
1818// because none of AIS classes provides creation of
1819// Select3D_SensitiveCircle with member myFillStatus = Standard_True
1820// (look method ComputeSelection() )
1821//==============================================================================
1822
1823Handle(Geom_Circle) CreateCircle(gp_Pnt theCenter, Standard_Real theRadius)
1824{
1825 gp_Ax2 anAxes(theCenter, gp_Dir(gp_Vec(0., 0., 1.)));
1826 gp_Circ aCirc(anAxes, theRadius);
1827 Handle(Geom_Circle) aCircle = new Geom_Circle(aCirc);
1828 return aCircle;
1829}
1830
1831DEFINE_STANDARD_HANDLE(FilledCircle, AIS_InteractiveObject)
1832
1833class FilledCircle : public AIS_InteractiveObject
1834{
1835public:
1836 // CASCADE RTTI
1837 DEFINE_STANDARD_RTTI(FilledCircle);
1838
1839 FilledCircle(gp_Pnt theCenter, Standard_Real theRadius);
1840 FilledCircle(Handle(Geom_Circle) theCircle);
1841
1842private:
1843 TopoDS_Face ComputeFace();
1844
1845 // Virtual methods implementation
1846 void Compute ( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
1847 const Handle(Prs3d_Presentation)& thePresentation,
1848 const Standard_Integer theMode);
1849
1850 void ComputeSelection ( const Handle(SelectMgr_Selection)& theSelection,
1851 const Standard_Integer theMode);
1852
1853protected:
1854 Handle(Geom_Circle) myCircle;
1855 Standard_Boolean myFilledStatus;
1856
1857};
1858
1859IMPLEMENT_STANDARD_HANDLE(FilledCircle, AIS_InteractiveObject)
1860IMPLEMENT_STANDARD_RTTIEXT(FilledCircle, AIS_InteractiveObject)
1861
1862FilledCircle::FilledCircle(gp_Pnt theCenter, Standard_Real theRadius)
1863{
1864 myCircle = CreateCircle(theCenter, theRadius);
1865 myFilledStatus = Standard_True;
1866}
1867
1868FilledCircle::FilledCircle(Handle(Geom_Circle) theCircle)
1869{
1870 myCircle = theCircle;
1871 myFilledStatus = Standard_True;
1872}
1873
1874TopoDS_Face FilledCircle::ComputeFace()
1875{
1876 // Create edge from myCircle
1877 BRepBuilderAPI_MakeEdge anEdgeMaker(myCircle->Circ());
1878 TopoDS_Edge anEdge = anEdgeMaker.Edge();
1879
1880 // Create wire from anEdge
1881 BRepBuilderAPI_MakeWire aWireMaker(anEdge);
1882 TopoDS_Wire aWire = aWireMaker.Wire();
1883
1884 // Create face from aWire
1885 BRepBuilderAPI_MakeFace aFaceMaker(aWire);
1886 TopoDS_Face aFace = aFaceMaker.Face();
1887
1888 return aFace;
1889}
1890
35e08fe8 1891void FilledCircle::Compute(const Handle_PrsMgr_PresentationManager3d &/*thePresentationManager*/,
329843e2
A
1892 const Handle_Prs3d_Presentation &thePresentation,
1893 const Standard_Integer theMode)
1894{
1895 thePresentation->Clear();
1896
1897 TopoDS_Face aFace = ComputeFace();
1898
1899 if (aFace.IsNull()) return;
1900 if (theMode != 0) return;
1901
1902 StdPrs_ShadedShape::Add(thePresentation, aFace, myDrawer);
1903}
1904
1905void FilledCircle::ComputeSelection(const Handle_SelectMgr_Selection &theSelection,
35e08fe8 1906 const Standard_Integer /*theMode*/)
329843e2
A
1907{
1908 Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this);
1909 Handle(Select3D_SensitiveCircle) aSensitiveCircle = new Select3D_SensitiveCircle(anEntityOwner,
1910 myCircle, myFilledStatus);
1911 theSelection->Add(aSensitiveCircle);
1912}
7fd59977 1913
1914//==============================================================================
1915// Fonction vcircle
1916// ----------------- Uniquement par parametre. Pas de selection dans le viewer.
1917//==============================================================================
1918
1919//==============================================================================
1920//function : VCircleBuilder
161c4476 1921//purpose : Build an AIS_Circle
329843e2
A
1922//Draw arg : vcircle CircleName PlaneName PointName Radius IsFilled
1923// PointName PointName PointName IsFilled
7fd59977 1924//==============================================================================
329843e2
A
1925
1926void DisplayCircle (Handle (Geom_Circle) theGeomCircle,
1927 TCollection_AsciiString theName,
1928 Standard_Boolean isFilled)
1929{
1930 Handle(AIS_InteractiveObject) aCircle;
1931 if (isFilled)
1932 {
1933 aCircle = new FilledCircle(theGeomCircle);
1934 }
1935 else
1936 {
1937 aCircle = new AIS_Circle(theGeomCircle);
9e8804b6 1938 Handle(AIS_Circle)::DownCast (aCircle)->SetFilledCircleSens (Standard_False);
329843e2
A
1939 }
1940
1941 // Check if there is an object with given name
1942 // and remove it from context
1943 if (GetMapOfAIS().IsBound2(theName))
1944 {
1945 Handle(Standard_Transient) anObj = GetMapOfAIS().Find2(theName);
1946 Handle(AIS_InteractiveObject) anInterObj =
1947 Handle(AIS_InteractiveObject)::DownCast(anObj);
1948 TheAISContext()->Remove(anInterObj, Standard_False);
1949 GetMapOfAIS().UnBind2(theName);
1950 }
1951
1952 // Bind the circle to its name
1953 GetMapOfAIS().Bind(aCircle, theName);
1954
1955 // Display the circle
1956 TheAISContext()->Display(aCircle);
1957
1958}
7fd59977 1959
35e08fe8 1960static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const char** argv)
7fd59977 1961{
1962 Standard_Integer myCurrentIndex;
329843e2
A
1963 // Verification of the arguments
1964 if (argc>6 || argc<2)
1965 {
1966 std::cout << "vcircle error: expect 4 arguments.\n";
1967 return 1; // TCL_ERROR
1968 }
7fd59977 1969 TheAISContext()->CloseAllContexts();
1970
329843e2
A
1971 // There are all arguments
1972 if (argc == 6)
1973 {
1974 // Get arguments
1975 TCollection_AsciiString aName(argv[1]);
91322f44 1976 Standard_Boolean isFilled = (Standard_Boolean)Draw::Atoi(argv[5]);
329843e2 1977
7fd59977 1978 Handle(AIS_InteractiveObject) theShapeA;
1979 Handle(AIS_InteractiveObject) theShapeB;
1980
329843e2
A
1981 theShapeA =
1982 Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[2]));
1983 theShapeB =
1984 Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[3]));
1985
7fd59977 1986
1987 // Arguments: AIS_Point AIS_Point AIS_Point
1988 // ========================================
329843e2 1989 if (!theShapeA.IsNull() && !theShapeB.IsNull() &&
7fd59977 1990 theShapeA->Type()==AIS_KOI_Datum && theShapeA->Signature()==1)
1991 {
329843e2
A
1992 if (theShapeB->Type()!=AIS_KOI_Datum || theShapeB->Signature()!=1 )
1993 {
1994 std::cout << "vcircle error: 2d argument is unexpected to be a point.\n";
1995 return 1; // TCL_ERROR
7fd59977 1996 }
329843e2 1997 // The third object must be a point
7fd59977 1998 Handle(AIS_InteractiveObject) theShapeC =
329843e2 1999 Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(argv[4]));
7fd59977 2000 if (theShapeC.IsNull() ||
329843e2
A
2001 theShapeC->Type()!=AIS_KOI_Datum || theShapeC->Signature()!=1 )
2002 {
2003 std::cout << "vcircle error: 3d argument is unexpected to be a point.\n";
2004 return 1; // TCL_ERROR
2005 }
7fd59977 2006 // tag
329843e2
A
2007 // Verify that the three points are different
2008 Handle(AIS_Point) theAISPointA = Handle(AIS_Point)::DownCast(theShapeA);
2009 Handle(AIS_Point) theAISPointB = Handle(AIS_Point)::DownCast(theShapeB);
2010 Handle(AIS_Point) theAISPointC = Handle(AIS_Point)::DownCast(theShapeC);
2011
2012 Handle(Geom_Point) myGeomPointA = theAISPointA->Component();
2013 Handle(Geom_CartesianPoint) myCartPointA =
2014 Handle(Geom_CartesianPoint)::DownCast(myGeomPointA);
2015
2016 Handle(Geom_Point) myGeomPointB = theAISPointB->Component();
2017 Handle(Geom_CartesianPoint) myCartPointB =
2018 Handle(Geom_CartesianPoint)::DownCast(myGeomPointB);
2019
2020 Handle(Geom_Point) myGeomPointC = theAISPointC->Component();
2021 Handle(Geom_CartesianPoint) myCartPointC =
2022 Handle(Geom_CartesianPoint)::DownCast(myGeomPointC);
7fd59977 2023
2024 // Test A=B
91322f44 2025 if (Abs(myCartPointA->X()-myCartPointB->X()) <= Precision::Confusion() &&
2026 Abs(myCartPointA->Y()-myCartPointB->Y()) <= Precision::Confusion() &&
2027 Abs(myCartPointA->Z()-myCartPointB->Z()) <= Precision::Confusion() )
329843e2
A
2028 {
2029 std::cout << "vcircle error: Same points.\n";
2030 return 1; // TCL_ERROR
7fd59977 2031 }
2032 // Test A=C
91322f44 2033 if (Abs(myCartPointA->X()-myCartPointC->X()) <= Precision::Confusion() &&
2034 Abs(myCartPointA->Y()-myCartPointC->Y()) <= Precision::Confusion() &&
2035 Abs(myCartPointA->Z()-myCartPointC->Z()) <= Precision::Confusion() )
329843e2
A
2036 {
2037 std::cout << "vcircle error: Same points.\n";
2038 return 1; // TCL_ERROR
7fd59977 2039 }
2040 // Test B=C
91322f44 2041 if (Abs(myCartPointB->X()-myCartPointC->X()) <= Precision::Confusion() &&
2042 Abs(myCartPointB->Y()-myCartPointC->Y()) <= Precision::Confusion() &&
2043 Abs(myCartPointB->Z()-myCartPointC->Z()) <= Precision::Confusion() )
329843e2
A
2044 {
2045 std::cout << "vcircle error: Same points.\n";
2046 return 1;// TCL_ERROR
7fd59977 2047 }
329843e2
A
2048 // Construction of the circle
2049 GC_MakeCircle Cir = GC_MakeCircle (myCartPointA->Pnt(),
2050 myCartPointB->Pnt(), myCartPointC->Pnt() );
2051 Handle (Geom_Circle) theGeomCircle;
2052 try
2053 {
2054 theGeomCircle = Cir.Value();
2055 }
2056 catch (StdFail_NotDone)
2057 {
2058 std::cout << "vcircle error: can't create circle\n";
2059 return -1; // TCL_ERROR
2060 }
2061
2062 DisplayCircle(theGeomCircle, aName, isFilled);
7fd59977 2063 }
2064
329843e2 2065 // Arguments: AIS_Plane AIS_Point Real
7fd59977 2066 // ===================================
329843e2
A
2067 else if (theShapeA->Type() == AIS_KOI_Datum &&
2068 theShapeA->Signature() == 7 )
2069 {
2070 if (theShapeB->Type() != AIS_KOI_Datum ||
2071 theShapeB->Signature() != 1 )
2072 {
2073 std::cout << "vcircle error: 2d element is a unexpected to be a point.\n";
2074 return 1; // TCL_ERROR
2075 }
2076 // Ñheck that the radius is >= 0
91322f44 2077 if (Draw::Atof(argv[4]) <= 0 )
329843e2
A
2078 {
2079 std::cout << "vcircle error: the radius must be >=0.\n";
2080 return 1; // TCL_ERROR
7fd59977 2081 }
7fd59977 2082
329843e2
A
2083 // Recover the normal to the plane
2084 Handle(AIS_Plane) theAISPlane = Handle(AIS_Plane)::DownCast(theShapeA);
2085 Handle(AIS_Point) theAISPointB = Handle(AIS_Point)::DownCast(theShapeB);
7fd59977 2086
329843e2
A
2087 Handle(Geom_Plane) myGeomPlane = theAISPlane->Component();
2088 Handle(Geom_Point) myGeomPointB = theAISPointB->Component();
2089 Handle(Geom_CartesianPoint) myCartPointB =
2090 Handle(Geom_CartesianPoint)::DownCast(myGeomPointB);
7fd59977 2091
2092 gp_Pln mygpPlane = myGeomPlane->Pln();
2093 gp_Ax1 thegpAxe = mygpPlane.Axis();
2094 gp_Dir theDir = thegpAxe.Direction();
329843e2 2095 gp_Pnt theCenter = myCartPointB->Pnt();
91322f44 2096 Standard_Real TheR = Draw::Atof(argv[4]);
329843e2
A
2097 GC_MakeCircle Cir = GC_MakeCircle (theCenter, theDir ,TheR);
2098 Handle (Geom_Circle) theGeomCircle;
2099 try
2100 {
2101 theGeomCircle = Cir.Value();
2102 }
2103 catch (StdFail_NotDone)
2104 {
2105 std::cout << "vcircle error: can't create circle\n";
2106 return -1; // TCL_ERROR
2107 }
2108
2109 DisplayCircle(theGeomCircle, aName, isFilled);
7fd59977 2110
2111 }
2112
2113 // Error
329843e2
A
2114 else
2115 {
2116 std::cout << "vcircle error: 1st argument is a unexpected type.\n";
2117 return 1; // TCL_ERROR
7fd59977 2118 }
2119
2120 }
329843e2 2121 // No arguments: selection in the viewer
7fd59977 2122 // =========================================
329843e2
A
2123 else
2124 {
2125 // Get the name of the circle
2126 TCollection_AsciiString aName(argv[1]);
7fd59977 2127
2128 TheAISContext()->OpenLocalContext();
329843e2 2129 myCurrentIndex = TheAISContext()->IndexOfCurrentLocal();
7fd59977 2130
329843e2 2131 // Activate selection mode for vertices and faces
7fd59977 2132 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
2133 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
ceae62f0 2134 std::cout << " Select a vertex or a face\n";
7fd59977 2135
329843e2 2136 // Wait for picking
7fd59977 2137 Standard_Integer argcc = 5;
2138 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2139 const char **argvv = (const char **) buff;
2140 while (ViewerMainLoop( argcc, argvv) ) { }
329843e2 2141 // end of the loop
7fd59977 2142
2143 TopoDS_Shape ShapeA;
329843e2
A
2144 for(TheAISContext()->InitSelected();
2145 TheAISContext()->MoreSelected();
2146 TheAISContext()->NextSelected() )
2147 {
7fd59977 2148 ShapeA = TheAISContext()->SelectedShape();
2149 }
2150
329843e2
A
2151 // ShapeA is a Vertex
2152 if (ShapeA.ShapeType() == TopAbs_VERTEX )
2153 {
7fd59977 2154 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) );
ceae62f0 2155 std::cout << " Select a different vertex\n";
7fd59977 2156
2157 TopoDS_Shape ShapeB;
329843e2
A
2158 do
2159 {
2160 // Wait for picking
7fd59977 2161 Standard_Integer argccc = 5;
2162 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2163 const char **argvvv = (const char **) bufff;
2164 while (ViewerMainLoop( argccc, argvvv) ) { }
329843e2 2165 // end of the loop
7fd59977 2166
329843e2
A
2167 for(TheAISContext()->InitSelected();
2168 TheAISContext()->MoreSelected();
2169 TheAISContext()->NextSelected() )
2170 {
7fd59977 2171 ShapeB = TheAISContext()->SelectedShape();
2172 }
7fd59977 2173 } while(ShapeB.IsSame(ShapeA) );
2174
329843e2 2175 // Selection of ShapeC
ceae62f0 2176 std::cout << " Select the last vertex\n";
7fd59977 2177 TopoDS_Shape ShapeC;
329843e2
A
2178 do
2179 {
2180 // Wait for picking
7fd59977 2181 Standard_Integer argcccc = 5;
2182 const char *buffff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2183 const char **argvvvv = (const char **) buffff;
2184 while (ViewerMainLoop( argcccc, argvvvv) ) { }
329843e2 2185 // end of the loop
7fd59977 2186
329843e2
A
2187 for(TheAISContext()->InitSelected();
2188 TheAISContext()->MoreSelected();
2189 TheAISContext()->NextSelected() )
2190 {
7fd59977 2191 ShapeC = TheAISContext()->SelectedShape();
2192 }
7fd59977 2193 } while(ShapeC.IsSame(ShapeA) || ShapeC.IsSame(ShapeB) );
329843e2
A
2194
2195 // Get isFilled
2196 Standard_Boolean isFilled;
2197 std::cout << "Enter filled status (0 or 1)\n";
2198 cin >> isFilled;
7fd59977 2199
329843e2 2200 // Close the local context
7fd59977 2201 TheAISContext()->CloseLocalContext(myCurrentIndex);
2202
329843e2
A
2203 // Construction of the circle
2204 gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA));
2205 gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB));
2206 gp_Pnt C = BRep_Tool::Pnt(TopoDS::Vertex(ShapeC));
2207
2208 GC_MakeCircle Cir = GC_MakeCircle (A, B, C);
2209 Handle (Geom_Circle) theGeomCircle;
2210 try
2211 {
2212 theGeomCircle = Cir.Value();
2213 }
2214 catch (StdFail_NotDone)
2215 {
2216 std::cout << "vcircle error: can't create circle\n";
2217 return -1; // TCL_ERROR
2218 }
7fd59977 2219
329843e2 2220 DisplayCircle(theGeomCircle, aName, isFilled);
7fd59977 2221
2222 }
329843e2 2223 // Shape is a face
ceae62f0 2224 else
329843e2 2225 {
ceae62f0 2226 std::cout << " Select a vertex (in your face)\n";
7fd59977 2227 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) );
2228
2229 TopoDS_Shape ShapeB;
329843e2 2230 // Wait for picking
7fd59977 2231 Standard_Integer argccc = 5;
2232 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2233 const char **argvvv = (const char **) bufff;
2234 while (ViewerMainLoop( argccc, argvvv) ) { }
329843e2 2235 // end of the loop
7fd59977 2236
329843e2
A
2237 for(TheAISContext()->InitSelected();
2238 TheAISContext()->MoreSelected();
2239 TheAISContext()->NextSelected() )
2240 {
7fd59977 2241 ShapeB = TheAISContext()->SelectedShape();
2242 }
2243
329843e2
A
2244 // Recover the radius
2245 Standard_Real theRad;
2246 do
2247 {
2248 std::cout << " Enter the value of the radius:\n";
2249 cin >> theRad;
2250 } while (theRad <= 0);
2251
2252 // Get filled status
2253 Standard_Boolean isFilled;
2254 std::cout << "Enter filled status (0 or 1)\n";
2255 cin >> isFilled;
7fd59977 2256
329843e2 2257 // Close the local context
7fd59977 2258 TheAISContext()->CloseLocalContext(myCurrentIndex);
329843e2 2259 // Construction of the circle
7fd59977 2260
329843e2
A
2261 // Recover the normal to the plane. tag
2262 TopoDS_Face myFace = TopoDS::Face(ShapeA);
2263 BRepAdaptor_Surface mySurface (myFace, Standard_False);
2264 gp_Pln myPlane = mySurface.Plane();
2265 Handle(Geom_Plane) theGeomPlane = new Geom_Plane (myPlane);
7fd59977 2266 gp_Pln mygpPlane = theGeomPlane->Pln();
2267 gp_Ax1 thegpAxe = mygpPlane.Axis();
2268 gp_Dir theDir = thegpAxe.Direction();
2269
329843e2
A
2270 // Recover the center
2271 gp_Pnt theCenter = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB));
7fd59977 2272
329843e2
A
2273 // Ñonstruct the circle
2274 GC_MakeCircle Cir = GC_MakeCircle (theCenter, theDir ,theRad);
2275 Handle (Geom_Circle) theGeomCircle;
2276 try
2277 {
2278 theGeomCircle = Cir.Value();
2279 }
2280 catch (StdFail_NotDone)
2281 {
2282 std::cout << "vcircle error: can't create circle\n";
2283 return -1; // TCL_ERROR
2284 }
7fd59977 2285
329843e2
A
2286 DisplayCircle(theGeomCircle, aName, isFilled);
2287
7fd59977 2288 }
2289
7fd59977 2290 }
2291
2292 return 0;
2293}
2294
ceae62f0 2295
7fd59977 2296//===============================================================================================
2297//function : VDrawText
2298//author : psn
2299//purpose : Create a text.
2300//Draw arg : vdrawtext name [X] [Y] [Z] [R] [G] [B] [hor_align] [ver_align] [angle] [zoomable]
2301//===============================================================================================
2302#include <Graphic3d_Group.hxx>
2303#include <Graphic3d_Structure.hxx>
7fd59977 2304#include <Graphic3d_AspectText3d.hxx>
161c4476 2305#include <Graphic3d_AspectFillArea3d.hxx>
7fd59977 2306#include <Graphic3d_StructureManager.hxx>
2307#include <Graphic3d_VerticalTextAlignment.hxx>
2308#include <Graphic3d_HorizontalTextAlignment.hxx>
2309
aff395a3 2310#include <Font_NameOfFont.hxx>
2311
7fd59977 2312#include <Visual3d_ViewManager.hxx>
2313#include <ViewerTest_Tool.ixx>
2314
2315#include <Standard_DefineHandle.hxx>
2316
7fd59977 2317#include <Prs3d_Root.hxx>
2318#include <Prs3d_Text.hxx>
2319#include <Prs3d_TextAspect.hxx>
7fd59977 2320#include <Prs3d_ShadingAspect.hxx>
2321#include <PrsMgr_PresentationManager3d.hxx>
2322
2323#include <TCollection_ExtendedString.hxx>
2324#include <TCollection_AsciiString.hxx>
2325
2326#include <gp_Pnt.hxx>
2327#include <Quantity_NameOfColor.hxx>
161c4476 2328#include <Quantity_Color.hxx>
7fd59977 2329
2330
2331DEFINE_STANDARD_HANDLE(MyTextClass, AIS_InteractiveObject)
2332
13a22457
S
2333class MyTextClass:public AIS_InteractiveObject
2334{
7fd59977 2335public:
2336 // CASCADE RTTI
2337 DEFINE_STANDARD_RTTI(MyTextClass );
2338
2339 MyTextClass(){};
2340
161c4476 2341 MyTextClass
7fd59977 2342 (
2343 const TCollection_ExtendedString& , const gp_Pnt& ,
161c4476
K
2344 Quantity_Color color,
2345 Standard_Integer aHJust,
7fd59977 2346 Standard_Integer aVJust ,
161c4476
K
2347 Standard_Real Angle ,
2348 Standard_Boolean Zoom ,
2349 Standard_Real Height,
eeaaaefb 2350 Font_FontAspect FontAspect,
7fd59977 2351 Standard_CString Font
2352 );
2353
2354private:
2355
2356 void Compute ( const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
2357 const Handle(Prs3d_Presentation)& aPresentation,
2358 const Standard_Integer aMode);
2359
35e08fe8 2360 void ComputeSelection ( const Handle(SelectMgr_Selection)& /*aSelection*/,
2361 const Standard_Integer /*aMode*/){} ;
7fd59977 2362
2363protected:
2364 TCollection_ExtendedString aText;
2365 gp_Pnt aPosition;
2366 Standard_Real Red;
2367 Standard_Real Green;
2368 Standard_Real Blue;
2369 Standard_Real aAngle;
161c4476 2370 Standard_Real aHeight;
7fd59977 2371 Standard_Boolean aZoomable;
2372 Quantity_Color aColor;
eb4320f2 2373 TCollection_AsciiString aFont;
eeaaaefb 2374 Font_FontAspect aFontAspect;
7fd59977 2375 Graphic3d_HorizontalTextAlignment aHJustification;
2376 Graphic3d_VerticalTextAlignment aVJustification;
2377};
2378
2379
2380
2381IMPLEMENT_STANDARD_HANDLE(MyTextClass, AIS_InteractiveObject)
161c4476 2382IMPLEMENT_STANDARD_RTTIEXT(MyTextClass, AIS_InteractiveObject)
7fd59977 2383
2384
161c4476
K
2385MyTextClass::MyTextClass( const TCollection_ExtendedString& text, const gp_Pnt& position,
2386 Quantity_Color color = Quantity_NOC_YELLOW,
2387 Standard_Integer aHJust = Graphic3d_HTA_LEFT,
7fd59977 2388 Standard_Integer aVJust = Graphic3d_VTA_BOTTOM,
2389 Standard_Real angle = 0.0 ,
2390 Standard_Boolean zoomable = Standard_True,
2391 Standard_Real height = 12.,
eeaaaefb 2392 Font_FontAspect fontAspect = Font_FA_Regular,
7fd59977 2393 Standard_CString font = "Courier")
2394{
2395 aText = text;
161c4476 2396 aPosition = position;
7fd59977 2397 aHJustification = Graphic3d_HorizontalTextAlignment(aHJust);
2398 aVJustification = Graphic3d_VerticalTextAlignment(aVJust);
2399 aAngle = angle;
161c4476
K
2400 aZoomable = zoomable;
2401 aHeight = height;
7fd59977 2402 aColor = color;
2403 aFontAspect = fontAspect;
2404 aFont = font;
2405};
2406
2407
2408
2409//////////////////////////////////////////////////////////////////////////////
35e08fe8 2410void MyTextClass::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
7fd59977 2411 const Handle(Prs3d_Presentation)& aPresentation,
35e08fe8 2412 const Standard_Integer /*aMode*/)
7fd59977 2413{
2414
2415 aPresentation->Clear();
2416
2417 Handle_Prs3d_TextAspect asp = myDrawer->TextAspect();
2418
eb4320f2 2419 asp->SetFont(aFont.ToCString());
7fd59977 2420 asp->SetColor(aColor);
2421 asp->SetHeight(aHeight); // I am changing the myHeight value
2422
2423 asp->SetHorizontalJustification(aHJustification);
161c4476 2424 asp->SetVerticalJustification(aVJustification);
7fd59977 2425 asp->Aspect()->SetTextZoomable(aZoomable);
2426 asp->Aspect()->SetTextAngle(aAngle);
2427 asp->Aspect()->SetTextFontAspect(aFontAspect);
2428 Prs3d_Text::Draw(aPresentation, asp, aText, aPosition);
161c4476 2429
7fd59977 2430 /* This comment code is worked
2431 Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation);
2432 Handle(Graphic3d_AspectFillArea3d) aspect = myDrawer->ShadingAspect()->Aspect();
2433 Graphic3d_Vertex vertices_text;
2434 vertices_text.SetCoord(aPosition.X(),aPosition.Y(),aPosition.Y());
2435 TheGroup->SetPrimitivesAspect(aspect);
7fd59977 2436 TheGroup->Text(aText,vertices_text,aHeight,Standard_True);
7fd59977 2437 */
2438};
2439
2440static int VDrawText (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2441{
13a22457
S
2442 // Check arguments
2443 if (argc < 14)
7fd59977 2444 {
13a22457
S
2445 di<<"Error: "<<argv[0]<<" - invalid number of arguments\n";
2446 di<<"Usage: type help "<<argv[0]<<"\n";
2447 return 1; //TCL_ERROR
7fd59977 2448 }
13a22457
S
2449
2450 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
2451
2452 // Create 3D view if it doesn't exist
2453 if ( aContext.IsNull() )
161c4476 2454 {
13a22457
S
2455 ViewerTest::ViewerInit();
2456 aContext = ViewerTest::GetAISContext();
2457 if( aContext.IsNull() )
2458 {
2459 di << "Error: Cannot create a 3D view\n";
2460 return 1; //TCL_ERROR
2461 }
7fd59977 2462 }
2463
13a22457 2464 // Text position
91322f44 2465 const Standard_Real X = Draw::Atof(argv[2]);
2466 const Standard_Real Y = Draw::Atof(argv[3]);
2467 const Standard_Real Z = Draw::Atof(argv[4]);
13a22457 2468 const gp_Pnt pnt(X,Y,Z);
7fd59977 2469
13a22457 2470 // Text color
91322f44 2471 const Quantity_Parameter R = Draw::Atof(argv[5])/255.;
2472 const Quantity_Parameter G = Draw::Atof(argv[6])/255.;
2473 const Quantity_Parameter B = Draw::Atof(argv[7])/255.;
13a22457 2474 const Quantity_Color aColor( R, G, B, Quantity_TOC_RGB );
7fd59977 2475
13a22457 2476 // Text alignment
91322f44 2477 const int hor_align = Draw::Atoi(argv[8]);
2478 const int ver_align = Draw::Atoi(argv[9]);
7fd59977 2479
13a22457 2480 // Text angle
91322f44 2481 const Standard_Real angle = Draw::Atof(argv[10]);
7fd59977 2482
13a22457 2483 // Text zooming
91322f44 2484 const Standard_Boolean zoom = Draw::Atoi(argv[11]);
13a22457
S
2485
2486 // Text height
91322f44 2487 const Standard_Real height = Draw::Atof(argv[12]);
13a22457
S
2488
2489 // Text aspect
91322f44 2490 const Font_FontAspect aspect = Font_FontAspect(Draw::Atoi(argv[13]));
13a22457
S
2491
2492 // Text font
2493 TCollection_AsciiString font;
2494 if(argc < 15)
2495 font.AssignCat("Courier");
2496 else
2497 font.AssignCat(argv[14]);
2498
2499 // Text is multibyte
91322f44 2500 const Standard_Boolean isMultibyte = (argc < 16)? Standard_False : (Draw::Atoi(argv[15]) != 0);
13a22457
S
2501
2502 // Read text string
2503 TCollection_ExtendedString name;
2504 if (isMultibyte)
161c4476 2505 {
13a22457 2506 const char *str = argv[1];
f3f08423 2507 while ( *str || *(str+1)=='\x0A' || *(str+1)=='\x0B' || *(str+1)=='\x0C' || *(str+1)=='\x0D'
2508 || *(str+1)=='\x07' || *(str+1)=='\x08' || *(str+1)=='\x09' )
13a22457
S
2509 {
2510 unsigned short c1 = *str++;
2511 unsigned short c2 = *str++;
f3f08423 2512 if (!c2) break;
13a22457
S
2513 name += (Standard_ExtCharacter)((c1 << 8) | c2);
2514 }
7fd59977 2515 }
13a22457
S
2516 else
2517 {
2518 name += argv[1];
2519 }
2520
2521 if (name.Length())
2522 {
2523 Handle(MyTextClass) myT = new MyTextClass(name,pnt,aColor,hor_align,ver_align,angle,zoom,height,aspect,font.ToCString());
2524 aContext->Display(myT,Standard_True);
2525 }
2526
161c4476 2527 return 0;
7fd59977 2528}
2529
2530#include <math.h>
2531#include <gp_Pnt.hxx>
2532#include <Graphic3d_ArrayOfPoints.hxx>
2533#include <Graphic3d_ArrayOfPrimitives.hxx>
7fd59977 2534#include <Graphic3d_ArrayOfTriangles.hxx>
2535#include <Poly_Array1OfTriangle.hxx>
2536#include <Poly_Triangle.hxx>
2537#include <Poly_Triangulation.hxx>
2538#include <TColgp_Array1OfPnt.hxx>
2539#include <TShort_Array1OfShortReal.hxx>
2540#include <TShort_HArray1OfShortReal.hxx>
2541
2542#include <AIS_Triangulation.hxx>
7fd59977 2543#include <StdPrs_ToolShadedShape.hxx>
2544#include <Poly_Connect.hxx>
2545#include <TColgp_Array1OfDir.hxx>
2546#include <Graphic3d_GraphicDriver.hxx>
2547
7fd59977 2548#include <TColStd_Array1OfInteger.hxx>
2549#include <TColStd_HArray1OfInteger.hxx>
2550#include <Prs3d_ShadingAspect.hxx>
2551#include <Graphic3d_MaterialAspect.hxx>
2552#include <Graphic3d_AspectFillArea3d.hxx>
2553
2554#include <BRepPrimAPI_MakeCylinder.hxx>
2555#include <TopoDS_Shape.hxx>
2556#include <TopExp_Explorer.hxx>
2557#include <TopAbs.hxx>
2558#include <StdSelect_ShapeTypeFilter.hxx>
2559
2560
2561//===============================================================================================
2562//function : CalculationOfSphere
2563//author : psn
2564//purpose : Create a Sphere
2565//===============================================================================================
2566
161c4476 2567Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z ,
7fd59977 2568 int res ,
2569 double Radius ){
2570 double mRadius = Radius;
2571 double mCenter[3] = {X,Y,Z};
2572 int mThetaResolution;
2573 int mPhiResolution;
2574 double mStartTheta = 0;//StartTheta;
2575 double mEndTheta = 360;//EndTheta;
2576 double mStartPhi = 0;//StartPhi;
2577 double mEndPhi = 180;//EndPhi;
2578 res = res < 4 ? 4 : res;
2579
2580 mThetaResolution = res;
2581 mPhiResolution = res;
2582
2583 int i, j;
2584 int jStart, jEnd, numOffset;
7fd59977 2585 double x[3], n[3], deltaPhi, deltaTheta, phi, theta, radius;
2586 double startTheta, endTheta, startPhi, endPhi;
2587 int base, numPoles=0, thetaResolution, phiResolution;
2588
2589 int pts[3];
2590 int piece = -1;
2591 int numPieces = 1;
2592 if ( numPieces > mThetaResolution ) {
2593 numPieces = mThetaResolution;
2594 }
2595
2596 int localThetaResolution = mThetaResolution;
2597 double localStartTheta = mStartTheta;
2598 double localEndTheta = mEndTheta;
2599
2600 while ( localEndTheta < localStartTheta ) {
2601 localEndTheta += 360.0;
2602 }
2603
2604 deltaTheta = (localEndTheta - localStartTheta) / localThetaResolution;
2605
2606 // Change the ivars based on pieces.
2607 int start, end;
2608 start = piece * localThetaResolution / numPieces;
2609 end = (piece+1) * localThetaResolution / numPieces;
2610 localEndTheta = localStartTheta + (double)(end) * deltaTheta;
2611 localStartTheta = localStartTheta + (double)(start) * deltaTheta;
2612 localThetaResolution = end - start;
2613
7fd59977 2614 // Create north pole if needed
2615 int number_point = 0;
2616 int number_pointArray = 0;
2617
2618 if ( mStartPhi <= 0.0 ) {
2619 number_pointArray++;
2620 numPoles++;
2621 }
2622 if ( mEndPhi >= 180.0 ) {
2623 number_pointArray++;
2624 numPoles++;
2625 }
161c4476 2626
7fd59977 2627 // Check data, determine increments, and convert to radians
2628 startTheta = (localStartTheta < localEndTheta ? localStartTheta : localEndTheta);
c6541a0c 2629 startTheta *= M_PI / 180.0;
7fd59977 2630 endTheta = (localEndTheta > localStartTheta ? localEndTheta : localStartTheta);
c6541a0c 2631 endTheta *= M_PI / 180.0;
7fd59977 2632
2633
2634 startPhi = ( mStartPhi < mEndPhi ? mStartPhi : mEndPhi);
c6541a0c 2635 startPhi *= M_PI / 180.0;
7fd59977 2636 endPhi = ( mEndPhi > mStartPhi ? mEndPhi : mStartPhi);
c6541a0c 2637 endPhi *= M_PI / 180.0;
7fd59977 2638
2639 phiResolution = mPhiResolution - numPoles;
2640 deltaPhi = (endPhi - startPhi) / ( mPhiResolution - 1);
2641 thetaResolution = localThetaResolution;
2642 if ( fabs(localStartTheta - localEndTheta) < 360.0 ) {
2643 ++localThetaResolution;
2644 }
2645 deltaTheta = (endTheta - startTheta) / thetaResolution;
2646
2647 jStart = ( mStartPhi <= 0.0 ? 1 : 0);
2648 jEnd = ( mEndPhi >= 180.0 ? mPhiResolution - 1 : mPhiResolution);
2649
2650 // Create intermediate points
2651 for ( i = 0; i < localThetaResolution; i++ ) {
2652 for ( j = jStart; j < jEnd; j++ ) {
2653 number_pointArray++;
2654 }
2655 }
2656
2657 //Generate mesh connectivity
2658 base = phiResolution * localThetaResolution;
2659
2660 int number_triangle = 0 ;
2661 if ( mStartPhi <= 0.0 ) { // around north pole
2662 number_triangle += localThetaResolution;
2663 }
161c4476 2664
7fd59977 2665 if ( mEndPhi >= 180.0 ) { // around south pole
2666 number_triangle += localThetaResolution;
2667 }
2668
2669 // bands in-between poles
2670 for ( i=0; i < localThetaResolution; i++){
2671 for ( j=0; j < (phiResolution-1); j++){
2672 number_triangle +=2;
2673 }
2674 }
2675
2676 Handle( Poly_Triangulation ) polyTriangulation = new Poly_Triangulation(number_pointArray, number_triangle, false);
2677 TColgp_Array1OfPnt& PointsOfArray = polyTriangulation->ChangeNodes();
2678 Poly_Array1OfTriangle& pArrayTriangle = polyTriangulation->ChangeTriangles();
2679
2680 if ( mStartPhi <= 0.0 ){
2681 x[0] = mCenter[0];
2682 x[1] = mCenter[1];
2683 x[2] = mCenter[2] + mRadius;
2684 PointsOfArray.SetValue(1,gp_Pnt(x[0],x[1],x[2]));
2685 }
2686
2687 // Create south pole if needed
2688 if ( mEndPhi >= 180.0 ){
2689 x[0] = mCenter[0];
2690 x[1] = mCenter[1];
2691 x[2] = mCenter[2] - mRadius;
2692 PointsOfArray.SetValue(2,gp_Pnt(x[0],x[1],x[2]));
2693 }
2694
2695 number_point = 3;
2696 for ( i=0; i < localThetaResolution; i++){
c6541a0c 2697 theta = localStartTheta * M_PI / 180.0 + i*deltaTheta;
7fd59977 2698 for ( j = jStart; j < jEnd; j++){
2699 phi = startPhi + j*deltaPhi;
2700 radius = mRadius * sin((double)phi);
2701 n[0] = radius * cos((double)theta);
2702 n[1] = radius * sin((double)theta);
2703 n[2] = mRadius * cos((double)phi);
2704 x[0] = n[0] + mCenter[0];
2705 x[1] = n[1] + mCenter[1];
2706 x[2] = n[2] + mCenter[2];
2707 PointsOfArray.SetValue(number_point,gp_Pnt(x[0],x[1],x[2]));
2708 number_point++;
2709 }
2710 }
2711
2712 numPoles = 3;
2713 number_triangle = 1;
2714 if ( mStartPhi <= 0.0 ){// around north pole
2715 for (i=0; i < localThetaResolution; i++){
2716 pts[0] = phiResolution*i + numPoles;
2717 pts[1] = (phiResolution*(i+1) % base) + numPoles;
2718 pts[2] = 1;
2719 pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
2720 number_triangle++;
2721 }
2722 }
161c4476 2723
7fd59977 2724 if ( mEndPhi >= 180.0 ){ // around south pole
2725 numOffset = phiResolution - 1 + numPoles;
2726 for (i=0; i < localThetaResolution; i++){
2727 pts[0] = phiResolution*i + numOffset;
2728 pts[2] = ((phiResolution*(i+1)) % base) + numOffset;
2729 pts[1] = numPoles - 1;
2730 pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
2731 number_triangle++;
2732 }
2733 }
2734
2735 // bands in-between poles
161c4476 2736
7fd59977 2737 for (i=0; i < localThetaResolution; i++){
2738 for (j=0; j < (phiResolution-1); j++){
2739 pts[0] = phiResolution*i + j + numPoles;
2740 pts[1] = pts[0] + 1;
2741 pts[2] = ((phiResolution*(i+1)+j) % base) + numPoles + 1;
2742 pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
2743 number_triangle++;
2744 pts[1] = pts[2];
2745 pts[2] = pts[1] - 1;
2746 pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
2747 number_triangle++;
2748 }
2749 }
2750
2751 Poly_Connect* pc = new Poly_Connect(polyTriangulation);
2752
2753 Handle(TShort_HArray1OfShortReal) Normals = new TShort_HArray1OfShortReal(1, polyTriangulation->NbNodes() * 3);
2754
2755 Standard_Integer index[3];
2756 Standard_Real Tol = Precision::Confusion();
2757
2758 gp_Dir Nor;
2759 for (i = PointsOfArray.Lower(); i <= PointsOfArray.Upper(); i++) {
2760 gp_XYZ eqPlan(0, 0, 0);
2761 for ( pc->Initialize(i); pc->More(); pc->Next()) {
2762 pArrayTriangle(pc->Value()).Get(index[0], index[1], index[2]);
2763 gp_XYZ v1(PointsOfArray(index[1]).Coord()-PointsOfArray(index[0]).Coord());
2764 gp_XYZ v2(PointsOfArray(index[2]).Coord()-PointsOfArray(index[1]).Coord());
2765 gp_XYZ vv = v1^v2;
2766 Standard_Real mod = vv.Modulus();
2767 if(mod < Tol) continue;
2768 eqPlan += vv/mod;
2769 }
2770
2771 Standard_Real modmax = eqPlan.Modulus();
2772
161c4476 2773 if(modmax > Tol)
7fd59977 2774 Nor = gp_Dir(eqPlan);
161c4476 2775 else
7fd59977 2776 Nor = gp_Dir(0., 0., 1.);
2777
2778 Standard_Integer j = (i - PointsOfArray.Lower()) * 3;
2779 Normals->SetValue(j + 1, (Standard_ShortReal)Nor.X());
2780 Normals->SetValue(j + 2, (Standard_ShortReal)Nor.Y());
2781 Normals->SetValue(j + 3, (Standard_ShortReal)Nor.Z());
2782 }
2783
2784 delete pc;
2785 polyTriangulation->SetNormals(Normals);
2786
2787 return polyTriangulation;
2788}
2789
2790//===============================================================================================
2791//function : VDrawSphere
2792//author : psn
2793//purpose : Create an AIS shape.
7fd59977 2794//===============================================================================================
35e08fe8 2795static int VDrawSphere (Draw_Interpretor& /*di*/, Standard_Integer argc, const char** argv)
161c4476
K
2796{
2797 // check for errors
2798 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
2799 if (aContextAIS.IsNull())
2800 {
2801 std::cout << "Call vinit before!\n";
2802 return 1;
2803 }
2804 else if (argc < 3)
2805 {
2806 std::cout << "Use: " << argv[0]
58655684 2807 << " shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToShowEdges=0]\n";
161c4476
K
2808 return 1;
2809 }
7fd59977 2810
161c4476
K
2811 // read the arguments
2812 TCollection_AsciiString aShapeName (argv[1]);
91322f44 2813 Standard_Integer aResolution = Draw::Atoi (argv[2]);
2814 Standard_Real aCenterX = (argc > 5) ? Draw::Atof (argv[3]) : 0.0;
2815 Standard_Real aCenterY = (argc > 5) ? Draw::Atof (argv[4]) : 0.0;
2816 Standard_Real aCenterZ = (argc > 5) ? Draw::Atof (argv[5]) : 0.0;
2817 Standard_Real aRadius = (argc > 6) ? Draw::Atof (argv[6]) : 100.0;
2818 Standard_Boolean toShowEdges = (argc > 7) ? Draw::Atoi (argv[7]) : Standard_False;
7fd59977 2819
161c4476 2820 // remove AIS object with given name from map
208e6839 2821 VDisplayAISObject (aShapeName, Handle(AIS_InteractiveObject)());
161c4476
K
2822
2823 std::cout << "Compute Triangulation...\n";
2824 Handle(AIS_Triangulation) aShape
2825 = new AIS_Triangulation (CalculationOfSphere (aCenterX, aCenterY, aCenterZ,
2826 aResolution,
2827 aRadius));
2828 Standard_Integer aNumberPoints = aShape->GetTriangulation()->Nodes().Length();
2829 Standard_Integer aNumberTriangles = aShape->GetTriangulation()->Triangles().Length();
2830
161c4476
K
2831 // stupid initialization of Green color in RGBA space as integer
2832 // probably wrong for big-endian CPUs
2833 Standard_Integer aRed = 0;
2834 Standard_Integer aGreen = 255;
2835 Standard_Integer aBlue = 0;
2836 Standard_Integer anAlpha = 0; // not used
2837 Standard_Integer aColorInt = aRed;
2838 aColorInt += aGreen << 8;
2839 aColorInt += aBlue << 16;
2840 aColorInt += anAlpha << 24;
2841
2842 // setup colors array per vertex
2843 Handle(TColStd_HArray1OfInteger) aColorArray = new TColStd_HArray1OfInteger (1, aNumberPoints);
2844 for (Standard_Integer aNodeId = 1; aNodeId <= aNumberPoints; ++aNodeId)
2845 {
2846 aColorArray->SetValue (aNodeId, aColorInt);
7fd59977 2847 }
161c4476
K
2848 aShape->SetColors (aColorArray);
2849
2850 // show statistics
2851 Standard_Integer aPointsSize = aNumberPoints * 3 * sizeof(float); // 3x GLfloat
2852 Standard_Integer aNormalsSize = aNumberPoints * 3 * sizeof(float); // 3x GLfloat
2853 Standard_Integer aColorsSize = aNumberPoints * 3 * sizeof(float); // 3x GLfloat without alpha
2854 Standard_Integer aTrianglesSize = aNumberTriangles * 3 * sizeof(int); // 3x GLint
2855 Standard_Integer aPolyConnectSize = aNumberPoints * 4 + aNumberTriangles * 6 * 4;
2856 Standard_Integer aTotalSize = aPointsSize + aNormalsSize + aColorsSize + aTrianglesSize;
2857 aTotalSize >>= 20; //MB
2858 aNormalsSize >>= 20;
2859 aColorsSize >>= 20;
2860 aTrianglesSize >>= 20;
2861 aPolyConnectSize >>= 20;
2862 std::cout << "NumberOfPoints: " << aNumberPoints << "\n"
2863 << "NumberOfTriangles: " << aNumberTriangles << "\n"
2864 << "Amount of memory required for PolyTriangulation without Normals: " << (aTotalSize - aNormalsSize) << " Mb\n"
2865 << "Amount of memory for colors: " << aColorsSize << " Mb\n"
2866 << "Amount of memory for PolyConnect: " << aPolyConnectSize << " Mb\n"
2867 << "Amount of graphic card memory required: " << aTotalSize << " Mb\n";
7fd59977 2868
2869 // Setting material properties, very important for desirable visual result!
161c4476
K
2870 Graphic3d_MaterialAspect aMat (Graphic3d_NOM_PLASTIC);
2871 aMat.SetAmbient (0.2);
2872 aMat.SetSpecular (0.5);
2873 Handle(Graphic3d_AspectFillArea3d) anAspect
2874 = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID,
2875 Quantity_NOC_RED,
2876 Quantity_NOC_YELLOW,
2877 Aspect_TOL_SOLID,
2878 1.0,
2879 aMat,
2880 aMat);
7fd59977 2881 Handle(Prs3d_ShadingAspect) aShAsp = new Prs3d_ShadingAspect();
161c4476
K
2882 if (toShowEdges)
2883 {
2884 anAspect->SetEdgeOn();
2885 }
7fd59977 2886 else
161c4476
K
2887 {
2888 anAspect->SetEdgeOff();
2889 }
2890 aShAsp->SetAspect (anAspect);
2891 aShape->Attributes()->SetShadingAspect (aShAsp);
7fd59977 2892
208e6839 2893 VDisplayAISObject (aShapeName, aShape);
7fd59977 2894 return 0;
2895}
2896
3fc57801 2897//=============================================================================
2898//function : VComputeHLR
2899//purpose :
2900//=============================================================================
2901
2902static int VComputeHLR (Draw_Interpretor& di,
2903 Standard_Integer argc,
2904 const char** argv)
2905{
2906 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext ();
2907
2908 if (aContextAIS.IsNull ())
2909 {
2910 di << "Please call vinit before\n";
2911 return 1;
2912 }
2913
2914 if ( argc != 3 && argc != 12 )
2915 {
2916 di << "Usage: " << argv[0] << " ShapeName HlrName "
2917 << "[ eye_x eye_y eye_z dir_x dir_y dir_z upx upy upz ]" << "\n"
2918 << " ShapeName - name of the initial shape\n"
2919 << " HlrName - result hlr object from initial shape\n"
2920 << " eye, dir are eye position and look direction\n"
2921 << " up is the look up direction vector\n"
2922 << " Use vtop to see projected hlr shape\n";
2923 return 1;
2924 }
2925
2926 // shape and new object name
2927 TCollection_AsciiString aShapeName (argv[1]);
2928 TCollection_AsciiString aHlrName (argv[2]);
2929
2930 TopoDS_Shape aSh = DBRep::Get (argv[1]);
2931 if (aSh.IsNull())
2932 {
2933 BRep_Builder aBrepBuilder;
2934 BRepTools::Read (aSh, argv[1], aBrepBuilder);
2935 if (aSh.IsNull ())
2936 {
2937 di << "No shape with name " << argv[1] << " found\n";
2938 return 1;
2939 }
2940 }
2941
2942 if (GetMapOfAIS ().IsBound2 (aHlrName))
2943 {
2944 di << "Presentable object with name " << argv[2] << " already exists\n";
2945 return 1;
2946 }
2947
2948 // close local context
2949 if (aContextAIS->HasOpenedContext ())
2950 aContextAIS->CloseLocalContext ();
2951
2952 Handle(HLRBRep_PolyAlgo) aPolyAlgo = new HLRBRep_PolyAlgo();
2953 HLRBRep_PolyHLRToShape aHLRToShape;
2954
2955 gp_Pnt anEye;
2956 gp_Dir aDir;
2957 gp_Ax2 aProjAx;
2958 if (argc == 9)
2959 {
2960 gp_Dir anUp;
2961
91322f44 2962 anEye.SetCoord (Draw::Atof (argv[3]), Draw::Atof (argv[4]), Draw::Atof (argv[5]));
2963 aDir.SetCoord (Draw::Atof (argv[6]), Draw::Atof (argv[7]), Draw::Atof (argv[8]));
2964 anUp.SetCoord (Draw::Atof (argv[9]), Draw::Atof (argv[10]), Draw::Atof (argv[11]));
3fc57801 2965 aProjAx.SetLocation (anEye);
2966 aProjAx.SetDirection (aDir);
2967 aProjAx.SetYDirection (anUp);
2968 }
2969 else
2970 {
2971 gp_Dir aRight;
2972
2973 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
2974 Handle(V3d_View) aView = ViewerTest::CurrentView();
2975 Standard_Integer aWidth, aHeight;
2976 Standard_Real aCentX, aCentY, aCentZ, aDirX, aDirY, aDirZ;
2977 Standard_Real aRightX, aRightY, aRightZ;
2978 aView->Window()->Size (aWidth, aHeight);
2979
2980 aView->ConvertWithProj (aWidth, aHeight/2,
2981 aRightX, aRightY, aRightZ,
2982 aDirX, aDirY, aDirZ);
2983
2984 aView->ConvertWithProj (aWidth/2, aHeight/2,
2985 aCentX, aCentY, aCentZ,
2986 aDirX, aDirY, aDirZ);
2987
2988 anEye.SetCoord (-aCentX, -aCentY, -aCentZ);
2989 aDir.SetCoord (-aDirX, -aDirY, -aDirZ);
2990 aRight.SetCoord (aRightX - aCentX, aRightY - aCentY, aRightZ - aCentZ);
2991 aProjAx.SetLocation (anEye);
2992 aProjAx.SetDirection (aDir);
2993 aProjAx.SetXDirection (aRight);
2994 }
2995
2996 HLRAlgo_Projector aProjector (aProjAx);
2997 aPolyAlgo->Projector (aProjector);
2998 aPolyAlgo->Load (aSh);
2999 aPolyAlgo->Update ();
3000
3001 aHLRToShape.Update (aPolyAlgo);
3002
3003 // make hlr shape from input shape
3004 TopoDS_Compound aHlrShape;
3005 BRep_Builder aBuilder;
3006 aBuilder.MakeCompound (aHlrShape);
3007
3008 TopoDS_Shape aCompound = aHLRToShape.VCompound();
3009 if (!aCompound.IsNull ())
3010 {
3011 aBuilder.Add (aHlrShape, aCompound);
3012 }
3013
3014 // extract visible outlines
3015 aCompound = aHLRToShape.OutLineVCompound();
3016 if (!aCompound.IsNull ())
3017 {
3018 aBuilder.Add (aHlrShape, aCompound);
3019 }
3020
3021 // create an AIS shape and display it
3022 Handle(AIS_Shape) anObject = new AIS_Shape (aHlrShape);
3023 GetMapOfAIS().Bind (anObject, aHlrName);
3024 aContextAIS->Display (anObject);
3025
3026 aContextAIS->UpdateCurrentViewer ();
3027
3028 return 0;
3029}
3030
9558a876
A
3031// This class is a wrap for Graphic3d_ArrayOfPrimitives; it is used for
3032// manipulating and displaying such an array with AIS context
3033DEFINE_STANDARD_HANDLE(MyPArrayObject, AIS_InteractiveObject)
3034class MyPArrayObject : public AIS_InteractiveObject
3035{
3036
3037public:
3038
eb4320f2 3039 MyPArrayObject (Handle(TColStd_HArray1OfAsciiString) theArrayDescription,
a577aaab 3040 Handle(Graphic3d_AspectMarker3d) theMarkerAspect = NULL)
9558a876 3041 {
eb4320f2 3042 myArrayDescription = theArrayDescription;
a577aaab 3043 myMarkerAspect = theMarkerAspect;
9558a876
A
3044 }
3045
3046 DEFINE_STANDARD_RTTI(MyPArrayObject);
3047
3048private:
3049
3050 void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
3051 const Handle(Prs3d_Presentation)& aPresentation,
3052 const Standard_Integer aMode);
3053
a577aaab 3054 void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
3055 const Standard_Integer /*theMode*/);
9558a876 3056
eb4320f2 3057 bool CheckInputCommand (const TCollection_AsciiString theCommand,
3058 const Handle(TColStd_HArray1OfAsciiString) theArgsArray,
3059 Standard_Integer &theArgIndex,
3060 Standard_Integer theArgCount,
3061 Standard_Integer theMaxArgs);
3062
9558a876
A
3063protected:
3064
eb4320f2 3065 Handle(TColStd_HArray1OfAsciiString) myArrayDescription;
a577aaab 3066 Handle(Graphic3d_AspectMarker3d) myMarkerAspect;
9558a876
A
3067
3068};
3069
3070IMPLEMENT_STANDARD_HANDLE(MyPArrayObject, AIS_InteractiveObject)
3071IMPLEMENT_STANDARD_RTTIEXT(MyPArrayObject, AIS_InteractiveObject)
3072
35e08fe8 3073void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
9558a876 3074 const Handle(Prs3d_Presentation)& aPresentation,
35e08fe8 3075 const Standard_Integer /*aMode*/)
9558a876 3076{
9558a876 3077
eb4320f2 3078 // Parsing array description
9558a876
A
3079 Standard_Integer aVertexNum = 0, aBoundNum = 0, aEdgeNum = 0;
3080 Standard_Boolean hasVColors, hasBColors, hasNormals, hasInfos, hasTexels;
3081 hasVColors = hasNormals = hasBColors = hasInfos = hasTexels = Standard_False;
3082
eb4320f2 3083 Standard_Integer anArgIndex = 0;
3084 Standard_Integer anArgsCount = myArrayDescription->Length();
3085 TCollection_AsciiString anArrayType = myArrayDescription->Value (anArgIndex++);
3086
9558a876 3087 TCollection_AsciiString aCommand;
eb4320f2 3088 while (anArgIndex < anArgsCount)
9558a876 3089 {
eb4320f2 3090 aCommand = myArrayDescription->Value (anArgIndex);
9558a876 3091 aCommand.LowerCase();
9558a876
A
3092
3093 // vertex command
eb4320f2 3094 if (CheckInputCommand ("v", myArrayDescription, anArgIndex, 3, anArgsCount))
9558a876
A
3095 {
3096 // vertex has a normal or normal with color or texel
eb4320f2 3097 if (CheckInputCommand ("n", myArrayDescription, anArgIndex, 3, anArgsCount))
9558a876
A
3098 hasNormals = Standard_True;
3099
3100 // vertex has a color
eb4320f2 3101 if (CheckInputCommand ("c", myArrayDescription, anArgIndex, 3, anArgsCount))
9558a876
A
3102 hasVColors = Standard_True;
3103
3104 // vertex has a texel
eb4320f2 3105 if (CheckInputCommand ("t", myArrayDescription, anArgIndex, 2, anArgsCount))
9558a876
A
3106 hasTexels = Standard_True;
3107
3108 aVertexNum++;
3109 }
3110 // bound command
eb4320f2 3111 else if (CheckInputCommand ("b", myArrayDescription, anArgIndex, 1, anArgsCount))
9558a876
A
3112 {
3113 // bound has color
eb4320f2 3114 if (CheckInputCommand ("c", myArrayDescription, anArgIndex, 3, anArgsCount))
9558a876
A
3115 hasBColors = Standard_True;
3116
3117 aBoundNum++;
3118 }
3119 // edge command
eb4320f2 3120 else if (CheckInputCommand ("e", myArrayDescription, anArgIndex, 1, anArgsCount))
9558a876
A
3121 {
3122 // edge has a hide flag
eb4320f2 3123 if (CheckInputCommand ("h", myArrayDescription, anArgIndex, 0, anArgsCount))
9558a876
A
3124 hasInfos = Standard_True;
3125
3126 aEdgeNum++;
3127 }
3128 // unknown command
3129 else
eb4320f2 3130 anArgIndex++;
9558a876
A
3131 }
3132
9558a876
A
3133 Handle(Graphic3d_ArrayOfPrimitives) anArray;
3134 if (anArrayType == "points")
a577aaab 3135 {
9558a876 3136 anArray = new Graphic3d_ArrayOfPoints (aVertexNum);
a577aaab 3137 }
9558a876
A
3138 else if (anArrayType == "segments")
3139 anArray = new Graphic3d_ArrayOfSegments (aVertexNum, aEdgeNum, hasVColors);
3140 else if (anArrayType == "polylines")
3141 anArray = new Graphic3d_ArrayOfPolylines (aVertexNum, aBoundNum, aEdgeNum,
3142 hasVColors, hasBColors, hasInfos);
3143 else if (anArrayType == "triangles")
3144 anArray = new Graphic3d_ArrayOfTriangles (aVertexNum, aEdgeNum, hasNormals,
3145 hasVColors, hasTexels, hasInfos);
3146 else if (anArrayType == "trianglefans")
3147 anArray = new Graphic3d_ArrayOfTriangleFans (aVertexNum, aBoundNum,
3148 hasNormals, hasVColors,
3149 hasBColors, hasTexels);
3150 else if (anArrayType == "trianglestrips")
3151 anArray = new Graphic3d_ArrayOfTriangleStrips (aVertexNum, aBoundNum,
3152 hasNormals, hasVColors,
3153 hasBColors, hasTexels);
3154 else if (anArrayType == "quads")
3155 anArray = new Graphic3d_ArrayOfQuadrangles (aVertexNum, aEdgeNum,
3156 hasNormals, hasVColors,
3157 hasTexels, hasInfos);
3158 else if (anArrayType == "quadstrips")
3159 anArray = new Graphic3d_ArrayOfQuadrangleStrips (aVertexNum, aBoundNum,
3160 hasNormals, hasVColors,
3161 hasBColors, hasTexels);
3162 else if (anArrayType == "polygons")
3163 anArray = new Graphic3d_ArrayOfPolygons (aVertexNum, aBoundNum, aEdgeNum,
3164 hasNormals, hasVColors, hasBColors,
3165