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