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