1 // Created on: 1998-11-12
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <ViewerTest.hxx>
19 #include <AIS_PlaneTrihedron.hxx>
21 #include <Quantity_NameOfColor.hxx>
22 #include <Draw_Interpretor.hxx>
24 #include <Draw_Appli.hxx>
26 #include <DBRep_DrawableShape.hxx>
28 #include <Font_BRepFont.hxx>
29 #include <Font_BRepTextBuilder.hxx>
30 #include <Font_FontMgr.hxx>
31 #include <Message.hxx>
32 #include <NCollection_List.hxx>
34 #include <OSD_Chronometer.hxx>
35 #include <TCollection_AsciiString.hxx>
36 #include <V3d_Viewer.hxx>
37 #include <V3d_View.hxx>
40 #include <AIS_Shape.hxx>
41 #include <AIS_DisplayMode.hxx>
42 #include <AIS_PointCloud.hxx>
43 #include <TColStd_MapOfInteger.hxx>
44 #include <AIS_MapOfInteractive.hxx>
45 #include <ViewerTest_AutoUpdater.hxx>
46 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
47 #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
48 #include <ViewerTest_EventManager.hxx>
50 #include <TopoDS_Solid.hxx>
51 #include <BRepTools.hxx>
52 #include <BRep_Builder.hxx>
53 #include <TopAbs_ShapeEnum.hxx>
56 #include <BRep_Tool.hxx>
57 #include <TopExp_Explorer.hxx>
59 #include <BRepAdaptor_Curve.hxx>
60 #include <BRepAdaptor_Surface.hxx>
64 #include <TopoDS_Vertex.hxx>
65 #include <TopoDS_Shape.hxx>
66 #include <TopoDS_Face.hxx>
68 #include <Draw_Window.hxx>
69 #include <AIS_ListIteratorOfListOfInteractive.hxx>
70 #include <AIS_ListOfInteractive.hxx>
71 #include <AIS_ColoredShape.hxx>
72 #include <AIS_DisplayMode.hxx>
73 #include <AIS_Shape.hxx>
75 #include <AIS_InteractiveContext.hxx>
76 #include <Geom_Plane.hxx>
78 #include <TCollection_ExtendedString.hxx>
79 #include <TCollection_HAsciiString.hxx>
80 #include <GC_MakePlane.hxx>
81 #include <gp_Circ.hxx>
82 #include <AIS_Axis.hxx>
83 #include <Geom_Axis2Placement.hxx>
84 #include <Geom_Axis1Placement.hxx>
85 #include <AIS_Trihedron.hxx>
86 #include <AIS_Axis.hxx>
87 #include <gp_Trsf.hxx>
88 #include <gp_Quaternion.hxx>
89 #include <TopLoc_Location.hxx>
91 #include <HLRAlgo_Projector.hxx>
92 #include <HLRBRep_Algo.hxx>
93 #include <HLRBRep_PolyAlgo.hxx>
94 #include <HLRBRep_PolyHLRToShape.hxx>
95 #include <HLRBRep_HLRToShape.hxx>
96 #include <Aspect_Window.hxx>
98 #include <Graphic3d_ArrayOfPoints.hxx>
99 #include <Graphic3d_ArrayOfSegments.hxx>
100 #include <Graphic3d_ArrayOfPolylines.hxx>
101 #include <Graphic3d_ArrayOfTriangles.hxx>
102 #include <Graphic3d_ArrayOfTriangleFans.hxx>
103 #include <Graphic3d_ArrayOfTriangleStrips.hxx>
104 #include <Graphic3d_ArrayOfQuadrangles.hxx>
105 #include <Graphic3d_ArrayOfQuadrangleStrips.hxx>
106 #include <Graphic3d_ArrayOfPolygons.hxx>
107 #include <Graphic3d_AttribBuffer.hxx>
108 #include <Graphic3d_AspectMarker3d.hxx>
109 #include <Graphic3d_Group.hxx>
110 #include <Standard_Real.hxx>
112 #include <AIS_Circle.hxx>
113 #include <BRepBuilderAPI_MakeEdge.hxx>
114 #include <BRepBuilderAPI_MakeFace.hxx>
115 #include <BRepBuilderAPI_MakeWire.hxx>
116 #include <Geom_Circle.hxx>
117 #include <GC_MakeCircle.hxx>
118 #include <Select3D_SensitiveCircle.hxx>
119 #include <SelectMgr_EntityOwner.hxx>
120 #include <SelectMgr_Selection.hxx>
121 #include <StdFail_NotDone.hxx>
122 #include <StdPrs_ShadedShape.hxx>
123 #include <TopoDS_Wire.hxx>
125 #include <AIS_MultipleConnectedInteractive.hxx>
126 #include <AIS_ConnectedInteractive.hxx>
127 #include <AIS_TextLabel.hxx>
128 #include <TopLoc_Location.hxx>
129 #include <TColStd_ListOfInteger.hxx>
130 #include <TColStd_ListIteratorOfListOfInteger.hxx>
132 #include <Select3D_SensitiveSegment.hxx>
133 #include <Select3D_SensitivePrimitiveArray.hxx>
134 #include <Select3D_SensitivePoint.hxx>
135 #include <BRepAdaptor_Curve.hxx>
136 #include <StdPrs_Curve.hxx>
138 #include <BRepExtrema_ExtPC.hxx>
139 #include <BRepExtrema_ExtPF.hxx>
141 #include <Prs3d_Arrow.hxx>
142 #include <Prs3d_ArrowAspect.hxx>
143 #include <Prs3d_DatumAttribute.hxx>
144 #include <Prs3d_DatumAspect.hxx>
145 #include <Prs3d_Drawer.hxx>
146 #include <Prs3d_VertexDrawMode.hxx>
147 #include <Prs3d_LineAspect.hxx>
148 #include <Prs3d_PointAspect.hxx>
149 #include <Prs3d_Presentation.hxx>
150 #include <Prs3d_TextAspect.hxx>
152 #include <Image_AlienPixMap.hxx>
153 #include <TColStd_HArray1OfAsciiString.hxx>
154 #include <TColStd_HSequenceOfAsciiString.hxx>
156 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
157 extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
158 const Handle(AIS_InteractiveObject)& theAISObj,
159 Standard_Boolean theReplaceIfExists = Standard_True);
160 extern Handle(AIS_InteractiveContext)& TheAISContext();
164 static bool convertToColor (const Handle(TColStd_HSequenceOfAsciiString)& theColorValues,
165 Quantity_Color& theColor)
167 const char* anArgs[3] =
169 theColorValues->Size() >= 1 ? theColorValues->Value (1).ToCString() : "",
170 theColorValues->Size() >= 2 ? theColorValues->Value (2).ToCString() : "",
171 theColorValues->Size() >= 3 ? theColorValues->Value (3).ToCString() : ""
173 return ViewerTest::ParseColor (theColorValues->Size(), anArgs, theColor) != 0;
176 static bool convertToDatumPart (const TCollection_AsciiString& theValue,
177 Prs3d_DatumParts& theDatumPart)
179 TCollection_AsciiString aValue = theValue;
181 if (aValue == "origin") theDatumPart = Prs3d_DP_Origin;
182 else if (aValue == "xaxis") theDatumPart = Prs3d_DP_XAxis;
183 else if (aValue == "yaxis") theDatumPart = Prs3d_DP_YAxis;
184 else if (aValue == "zaxis") theDatumPart = Prs3d_DP_ZAxis;
185 else if (aValue == "xarrow") theDatumPart = Prs3d_DP_XArrow;
186 else if (aValue == "yarrow") theDatumPart = Prs3d_DP_YArrow;
187 else if (aValue == "zarrow") theDatumPart = Prs3d_DP_ZArrow;
188 else if (aValue == "xoyaxis") theDatumPart = Prs3d_DP_XOYAxis;
189 else if (aValue == "yozaxis") theDatumPart = Prs3d_DP_YOZAxis;
190 else if (aValue == "xozaxis") theDatumPart = Prs3d_DP_XOZAxis;
191 else if (aValue == "whole") theDatumPart = Prs3d_DP_None;
199 static void convertToDatumParts (const TCollection_AsciiString& theValue,
200 NCollection_List<Prs3d_DatumParts>& theParts)
202 TCollection_AsciiString aValue = theValue;
203 const Standard_Integer aSplitPos = theValue.Search ("|");
204 Prs3d_DatumParts aPart = Prs3d_DP_None;
207 convertToDatumParts (theValue.SubString (aSplitPos + 1, theValue.Length()), theParts);
208 if (aSplitPos == 1) // first symbol
212 aValue = theValue.SubString (1, aSplitPos - 1);
214 if (convertToDatumPart (aValue, aPart))
216 theParts.Append (aPart);
220 static bool convertToDatumAttribute (const TCollection_AsciiString& theValue,
221 Prs3d_DatumAttribute& theAttribute)
223 TCollection_AsciiString aValue = theValue;
225 if (aValue == "xaxislength") theAttribute = Prs3d_DA_XAxisLength;
226 else if (aValue == "yaxislength") theAttribute = Prs3d_DA_YAxisLength;
227 else if (aValue == "zaxislength") theAttribute = Prs3d_DA_ZAxisLength;
228 else if (aValue == "tuberadiuspercent") theAttribute = Prs3d_DP_ShadingTubeRadiusPercent;
229 else if (aValue == "coneradiuspercent") theAttribute = Prs3d_DP_ShadingConeRadiusPercent;
230 else if (aValue == "conelengthpercent") theAttribute = Prs3d_DP_ShadingConeLengthPercent;
231 else if (aValue == "originradiuspercent") theAttribute = Prs3d_DP_ShadingOriginRadiusPercent;
232 else if (aValue == "shadingnumberoffacettes") theAttribute = Prs3d_DP_ShadingNumberOfFacettes;
238 static void convertToDatumAttributes (const TCollection_AsciiString& theValue,
239 NCollection_List<Prs3d_DatumAttribute>& theAttributes)
241 TCollection_AsciiString aValue = theValue;
242 const Standard_Integer aSplitPos = theValue.Search ("|");
243 Prs3d_DatumAttribute anAttribute = Prs3d_DA_XAxisLength;
246 convertToDatumAttributes (theValue.SubString (aSplitPos + 1, theValue.Length()), theAttributes);
247 if (aSplitPos == 1) // first symbol
251 aValue = theValue.SubString (1, aSplitPos - 1);
253 if (convertToDatumAttribute (aValue, anAttribute))
255 theAttributes.Append (anAttribute);
259 static bool convertToDatumAxes (const TCollection_AsciiString& theValue,
260 Prs3d_DatumAxes& theDatumAxes)
262 TCollection_AsciiString aValue = theValue;
264 if (aValue == "x") theDatumAxes = Prs3d_DA_XAxis;
265 else if (aValue == "y") theDatumAxes = Prs3d_DA_YAxis;
266 else if (aValue == "z") theDatumAxes = Prs3d_DA_ZAxis;
267 else if (aValue == "xy") theDatumAxes = Prs3d_DA_XYAxis;
268 else if (aValue == "zy") theDatumAxes = Prs3d_DA_YZAxis;
269 else if (aValue == "xz") theDatumAxes = Prs3d_DA_XZAxis;
270 else if (aValue == "xyz") theDatumAxes = Prs3d_DA_XYZAxis;
278 static Standard_Boolean setTrihedronParams (Standard_Integer theArgsNb,
279 const char** theArgVec,
280 Handle(AIS_Trihedron) theTrihedron)
282 NCollection_DataMap<TCollection_AsciiString, Handle(TColStd_HSequenceOfAsciiString)> aMapOfArgs;
283 TCollection_AsciiString aParseKey;
284 for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
286 TCollection_AsciiString anArg (theArgVec [anArgIt]);
287 if (anArg.Value (1) == '-'
288 && !anArg.IsRealValue())
291 aParseKey.Remove (1);
292 aParseKey.LowerCase();
293 std::string aKey = aParseKey.ToCString();
294 aMapOfArgs.Bind (aParseKey, new TColStd_HSequenceOfAsciiString());
298 if (aParseKey.IsEmpty())
303 aMapOfArgs (aParseKey)->Append (anArg);
307 if ((aMapOfArgs.IsBound ("xaxis") && !aMapOfArgs.IsBound ("zaxis"))
308 || (!aMapOfArgs.IsBound ("xaxis") && aMapOfArgs.IsBound ("zaxis")))
310 Message::SendFail ("Syntax error: -xaxis and -zaxis parameters are to set together");
311 return Standard_False;
314 Handle(TColStd_HSequenceOfAsciiString) aValues;
315 Handle(Geom_Axis2Placement) aComponent = theTrihedron->Component();
316 if (aMapOfArgs.Find ("origin", aValues))
318 aComponent->SetLocation (gp_Pnt (aValues->Value (1).RealValue(),
319 aValues->Value (2).RealValue(),
320 aValues->Value (3).RealValue()));
322 Handle(TColStd_HSequenceOfAsciiString) aXValues, aZValues;
323 if (aMapOfArgs.Find ("xaxis", aXValues) && aMapOfArgs.Find ("zaxis", aZValues))
325 gp_Dir aXDir (aXValues->Value (1).RealValue(),
326 aXValues->Value (2).RealValue(),
327 aXValues->Value (3).RealValue());
329 gp_Dir aZDir (aZValues->Value (1).RealValue(),
330 aZValues->Value (2).RealValue(),
331 aZValues->Value (3).RealValue());
333 if (!aZDir.IsNormal (aXDir, M_PI / 180.0))
335 Message::SendFail ("Syntax error - parameters 'xaxis' and 'zaxis' are not applied as VectorX is not normal to VectorZ");
336 return Standard_False;
339 aComponent->SetAx2 (gp_Ax2 (aComponent->Location(), aZDir, aXDir));
342 if (aMapOfArgs.Find ("dispmode", aValues))
344 TCollection_AsciiString aValue (aValues->Value (1));
345 bool isWireframe = true;
346 if (aValue.IsEqual ("sh") || aValue.IsEqual ("shading"))
348 theTrihedron->SetDatumDisplayMode (isWireframe ? Prs3d_DM_WireFrame
352 if (aMapOfArgs.Find ("hidelabels", aValues))
354 Standard_Boolean toHideLabels = Standard_True;
355 if (aValues->Size() == 1)
357 ViewerTest::ParseOnOff (aValues->First().ToCString(), toHideLabels);
359 else if (aValues->Size() != 0)
361 Message::SendFail ("Syntax error: -hidelabels expects parameter 'on' or 'off' after");
362 return Standard_False;
365 if (!theTrihedron->Attributes()->HasOwnDatumAspect())
367 theTrihedron->Attributes()->SetDatumAspect (new Prs3d_DatumAspect());
369 theTrihedron->Attributes()->DatumAspect()->SetDrawLabels (!toHideLabels);
372 if (aMapOfArgs.Find ("hidearrows", aValues))
374 Standard_Boolean toHideArrows = Standard_True;
375 if (aValues->Size() == 1)
377 ViewerTest::ParseOnOff (aValues->First().ToCString(), toHideArrows);
379 else if (aValues->Size() != 0)
381 Message::SendFail ("Syntax error: -hidearrows expects parameter 'on' or 'off' after");
382 return Standard_False;
385 if (!theTrihedron->Attributes()->HasOwnDatumAspect())
387 theTrihedron->Attributes()->SetDatumAspect (new Prs3d_DatumAspect());
389 theTrihedron->Attributes()->DatumAspect()->SetDrawArrows (!toHideArrows);
392 if (aMapOfArgs.Find ("color", aValues))
394 NCollection_List<Prs3d_DatumParts> aParts;
395 if (aValues->Size() < 2)
397 Message::SendFail ("Syntax error: -color wrong parameters");
398 return Standard_False;
401 convertToDatumParts (aValues->Value(1), aParts);
402 aValues->Remove (1); // datum part is processed
403 Quantity_Color aColor;
404 if (!convertToColor (aValues, aColor))
406 Message::SendFail ("Syntax error: -color wrong parameters");
407 return Standard_False;
410 for (NCollection_List<Prs3d_DatumParts>::Iterator anIterator (aParts); anIterator.More(); anIterator.Next())
412 Prs3d_DatumParts aDatumPart = anIterator.Value();
413 if (aDatumPart == Prs3d_DP_None)
415 theTrihedron->SetColor (aColor);
419 theTrihedron->SetDatumPartColor (aDatumPart, aColor);
424 if (aMapOfArgs.Find ("textcolor", aValues))
426 Quantity_Color aColor;
427 if (!convertToColor (aValues, aColor))
429 Message::SendFail ("Syntax error: -textcolor wrong parameters");
430 return Standard_False;
432 theTrihedron->SetTextColor (aColor);
435 if (aMapOfArgs.Find ("arrowcolor", aValues))
437 Quantity_Color aColor;
438 if (!convertToColor (aValues, aColor))
440 Message::SendFail ("Syntax error: -arrowcolor wrong parameters");
441 return Standard_False;
443 theTrihedron->SetArrowColor (aColor);
446 if (aMapOfArgs.Find ("attribute", aValues))
448 NCollection_List<Prs3d_DatumAttribute> anAttributes;
449 if (aValues->Size() != 2)
451 Message::SendFail ("Syntax error: -attribute wrong parameters");
452 return Standard_False;
455 convertToDatumAttributes (aValues->Value (1), anAttributes);
456 if (!theTrihedron->Attributes()->HasOwnDatumAspect())
457 theTrihedron->Attributes()->SetDatumAspect(new Prs3d_DatumAspect());
458 for (NCollection_List<Prs3d_DatumAttribute>::Iterator anIterator (anAttributes); anIterator.More(); anIterator.Next())
460 theTrihedron->Attributes()->DatumAspect()->SetAttribute (anIterator.Value(), aValues->Value (2).RealValue());
464 if (aMapOfArgs.Find ("priority", aValues))
466 Prs3d_DatumParts aDatumPart;
467 if (aValues->Size() < 2
468 || !convertToDatumPart (aValues->Value (1), aDatumPart))
470 Message::SendFail ("Syntax error: -priority wrong parameters");
471 return Standard_False;
473 theTrihedron->SetSelectionPriority (aDatumPart, aValues->Value (2).IntegerValue());
476 if (aMapOfArgs.Find ("labels", aValues)
477 || aMapOfArgs.Find ("label", aValues))
479 Prs3d_DatumParts aDatumPart = Prs3d_DP_None;
480 if (aValues->Size() >= 2
481 && convertToDatumPart(aValues->Value(1), aDatumPart)
482 && aDatumPart >= Prs3d_DP_XAxis
483 && aDatumPart <= Prs3d_DP_ZAxis) // labels are set to axes only
485 theTrihedron->SetLabel (aDatumPart, aValues->Value (2));
489 Message::SendFail ("Syntax error: -labels wrong parameters");
490 return Standard_False;
494 if (aMapOfArgs.Find ("drawaxes", aValues))
496 Prs3d_DatumAxes aDatumAxes = Prs3d_DA_XAxis;
497 if (aValues->Size() < 1
498 || !convertToDatumAxes (aValues->Value (1), aDatumAxes))
500 Message::SendFail ("Syntax error: -drawaxes wrong parameters");
501 return Standard_False;
503 if (!theTrihedron->Attributes()->HasOwnDatumAspect())
504 theTrihedron->Attributes()->SetDatumAspect(new Prs3d_DatumAspect());
505 theTrihedron->Attributes()->DatumAspect()->SetDrawDatumAxes (aDatumAxes);
507 return Standard_True;
510 //! Auxiliary function to parse font aspect style argument
511 static Standard_Boolean parseFontStyle (const TCollection_AsciiString& theArg,
512 Font_FontAspect& theAspect)
514 if (theArg == "regular"
515 || *theArg.ToCString() == 'r')
517 theAspect = Font_FA_Regular;
518 return Standard_True;
520 else if (theArg == "bolditalic"
521 || theArg == "bold-italic"
522 || theArg == "italic-bold"
523 || theArg == "italicbold")
525 theAspect = Font_FA_BoldItalic;
526 return Standard_True;
528 else if (theArg == "bold"
529 || *theArg.ToCString() == 'b')
531 theAspect = Font_FA_Bold;
532 return Standard_True;
534 else if (theArg == "italic"
535 || *theArg.ToCString() == 'i')
537 theAspect = Font_FA_Italic;
538 return Standard_True;
540 return Standard_False;
543 //! Auxiliary function to parse font strict level argument
544 static Standard_Integer parseFontStrictLevel (const Standard_Integer theArgNb,
545 const char** theArgVec,
546 Font_StrictLevel& theLevel)
550 TCollection_AsciiString anArg (theArgVec[0]);
554 theLevel = Font_StrictLevel_Any;
557 else if (anArg == "aliases")
559 theLevel = Font_StrictLevel_Aliases;
562 else if (anArg == "strict")
564 theLevel = Font_StrictLevel_Strict;
568 theLevel = Font_StrictLevel_Strict;
573 //==============================================================================
574 //function : Vtrihedron 2d
575 //purpose : Create a plane with a 2D trihedron from a faceselection
576 //Draw arg : vtri2d name
577 //==============================================================================
578 static int VTrihedron2D (Draw_Interpretor& /*theDI*/,
579 Standard_Integer theArgsNum,
580 const char** theArgVec)
584 Message::SendFail() << "Syntax error: wrong number of arguments.";
588 TopTools_ListOfShape aShapes;
589 ViewerTest::GetSelectedShapes (aShapes);
591 if (aShapes.Extent() != 1)
593 Message::SendFail ("Error: wrong number of selected shapes.");
597 const TopoDS_Shape& aShape = aShapes.First();
599 TopoDS_Face aFace = TopoDS::Face (aShape);
600 TopExp_Explorer aFaceExp (aFace, TopAbs_EDGE);
601 TopoDS_Edge anEdge0 = TopoDS::Edge (aFaceExp.Current());
607 TopoDS_Edge anEdge1 = TopoDS::Edge (aFaceExp.Current() );
608 BRepAdaptor_Curve aCurve0 (anEdge0);
609 BRepAdaptor_Curve aCurve1 (anEdge1);
610 A = aCurve1.Value (0.1);
611 B = aCurve1.Value (0.9);
612 C = aCurve0.Value (0.5);
616 BRepAdaptor_Curve aCurve0 (anEdge0);
617 A = aCurve0.Value (0.1);
618 B = aCurve0.Value (0.9);
619 C = aCurve0.Value (0.5);
622 GC_MakePlane aMkPlane (A,B,C);
624 Handle(AIS_PlaneTrihedron) anAISPlaneTri = new AIS_PlaneTrihedron (aMkPlane.Value());
625 TCollection_AsciiString aName (theArgVec[1]);
627 VDisplayAISObject (aName, anAISPlaneTri);
632 //=======================================================================
633 //function : VTrihedron
635 //=======================================================================
636 static int VTrihedron (Draw_Interpretor& ,
637 Standard_Integer theArgsNb,
638 const char** theArgVec)
642 Message::SendFail ("Syntax error: the wrong number of input parameters");
646 TCollection_AsciiString aName (theArgVec[1]);
647 gp_Pln aWorkingPlane;
648 Standard_Boolean toUpdate = Standard_True;
650 NCollection_DataMap<TCollection_AsciiString, Standard_Real> aRealParams;
651 NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString> aStringParams;
653 Handle(AIS_Trihedron) aTrihedron;
654 Handle(AIS_InteractiveObject) anObject;
655 if (GetMapOfAIS().Find2 (aName, anObject))
657 aTrihedron = Handle(AIS_Trihedron)::DownCast (anObject);
658 if (aTrihedron.IsNull())
660 Message::SendFail ("Syntax error: no trihedron with this name");
666 Handle(Geom_Axis2Placement) aPlacement = new Geom_Axis2Placement (gp_Pnt (0.0, 0.0, 0.0),
668 aTrihedron = new AIS_Trihedron (aPlacement);
671 if (!setTrihedronParams (theArgsNb, theArgVec, aTrihedron))
676 // Redisplay a dimension after parameter changing.
677 if (ViewerTest::GetAISContext()->IsDisplayed (aTrihedron))
679 ViewerTest::GetAISContext()->Redisplay (aTrihedron, toUpdate);
683 VDisplayAISObject (theArgVec[1], aTrihedron);
689 //==============================================================================
692 //purpose : Change the size of a named or selected trihedron
693 // if no name : it affects the trihedrons witch are selected otherwise nothing is donne
694 // if no value, the value is set at 100 by default
695 //Draw arg : vsize [name] [size]
696 //==============================================================================
698 static int VSize (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
701 // Declaration de booleens
702 Standard_Boolean ThereIsName;
703 Standard_Boolean ThereIsCurrent;
705 Standard_Boolean hascol;
707 Quantity_Color col = Quantity_NOC_BLACK;
709 // Verification des arguments
710 if ( argc>3 ) {di<<argv[0]<<" Syntaxe error\n"; return 1;}
712 // Verification du nombre d'arguments
713 if (argc==1) {ThereIsName=Standard_False;value=100;}
714 else if (argc==2) {ThereIsName=Standard_False;value=Draw::Atof(argv[1]);}
715 else {ThereIsName=Standard_True;value=Draw::Atof(argv[2]);}
717 // On set le booleen ThereIsCurrent
718 if (TheAISContext() -> NbSelected() > 0) {ThereIsCurrent=Standard_True;}
719 else {ThereIsCurrent=Standard_False;}
723 //===============================================================
724 // Il n'y a pas de nom mais des objets selectionnes
725 //===============================================================
726 if (!ThereIsName && ThereIsCurrent)
729 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
732 while ( it.More() ) {
734 Handle(AIS_InteractiveObject) aShape = it.Key1();
736 if (!aShape.IsNull() && TheAISContext()->IsSelected(aShape) )
739 // On verifie que l'AIS InteraciveObject selectionne est bien
741 if (aShape->Type()==AIS_KOI_Datum && aShape->Signature()==3) {
743 if (aShape->HasColor())
745 hascol = Standard_True;
747 // On recupere la couleur de aShape
752 hascol = Standard_False;
755 // On downcast aShape de AIS_InteractiveObject a AIS_Trihedron
756 // pour lui appliquer la methode SetSize()
757 Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast (aShape);
759 // C'est bien un triedre,on chage sa valeur!
760 aTrihedron->SetSize(value);
762 // On donne la couleur au Trihedron
763 if(hascol) aTrihedron->SetColor(col);
764 else aTrihedron->UnsetColor();
767 // The trihedron hasn't be errased from the map
768 // so you just have to redisplay it
769 TheAISContext() ->Redisplay(aTrihedron,Standard_False);
778 TheAISContext() ->UpdateCurrentViewer();
781 //===============================================================
782 // Il n'y a pas d'arguments et aucuns objets selectionne Rien A Faire!
783 //===============================================================
787 //===============================================================
788 // Il y a un nom de triedre passe en argument
789 //===============================================================
791 TCollection_AsciiString name=argv[1];
793 // on verifie que ce nom correspond bien a une shape
794 Handle(AIS_InteractiveObject) aShape;
795 if (GetMapOfAIS().Find2(name, aShape))
797 // On verifie que l'AIS InteraciveObject est bien
799 if (!aShape.IsNull() &&
800 aShape->Type()==AIS_KOI_Datum && aShape->Signature()==3)
802 if (aShape->HasColor())
804 hascol=Standard_True;
806 // On recupere la couleur de aShape
811 hascol = Standard_False;
814 // On downcast aShape de AIS_InteractiveObject a AIS_Trihedron
815 // pour lui appliquer la methode SetSize()
816 Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast (aShape);
818 // C'est bien un triedre,on chage sa valeur
819 aTrihedron->SetSize(value);
821 // On donne la couleur au Trihedron
822 if(hascol) aTrihedron->SetColor(col);
823 else aTrihedron->UnsetColor();
825 // The trihedron hasn't be errased from the map
826 // so you just have to redisplay it
827 TheAISContext() ->Redisplay(aTrihedron,Standard_False);
829 TheAISContext() ->UpdateCurrentViewer();
837 //==============================================================================
839 //==============================================================================
840 //function : VPlaneTrihedron
841 //purpose : Create a plane from a trihedron selection. If no arguments are set, the default
842 //Draw arg : vplanetri name
843 //==============================================================================
844 #include <AIS_Plane.hxx>
848 static int VPlaneTrihedron (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
851 // Verification des arguments
852 if ( argc!=2) {di<<argv[0]<<" error\n"; return 1;}
854 if (TheAISContext()->NbSelected() != 1)
856 Message::SendFail ("Error: Wrong number of selected shapes.");
860 TheAISContext()->InitSelected();
861 Handle(AIS_InteractiveObject) aTest = TheAISContext()->SelectedInteractive();
862 Handle(AIS_Plane) aPlane = Handle(AIS_Plane)::DownCast (aTest);
865 Message::SendFail ("Error: Selected shape is not a plane.");
869 VDisplayAISObject (argv[1], aPlane);
876 //==============================================================================
877 // Fonction First click 2de click
879 // vaxis vertex vertex
881 // vaxispara edge vertex
882 // vaxisortho edge Vertex
883 // vaxisinter Face Face
884 //==============================================================================
886 //==============================================================================
887 //function : VAxisBuilder
889 //Draw arg : vaxis AxisName Xa Ya Za Xb Yb Zb
890 //==============================================================================
891 #include <TopoDS_Edge.hxx>
892 #include <TopoDS_Vertex.hxx>
893 #include <TopExp.hxx>
894 #include <Geom_Line.hxx>
896 static int VAxisBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
899 Standard_Boolean HasArg;
900 TCollection_AsciiString name;
903 if (argc<2 || argc>8 ) {di<<" Syntaxe error\n";return 1;}
904 if (argc==8) HasArg=Standard_True;
905 else HasArg=Standard_False;
909 TopTools_ListOfShape aShapes;
910 ViewerTest::GetSelectedShapes (aShapes);
912 // Cas ou il y a des arguments
913 // Purpose: Teste le constructeur AIS_Axis::AIS_Axis(x: Line from Geom)
915 Standard_Real coord[6];
916 for(Standard_Integer i=0;i<=5;i++){
917 coord[i]=Draw::Atof(argv[2+i]);
919 gp_Pnt p1(coord[0],coord[1],coord[2]), p2(coord[3],coord[4],coord[5]) ;
921 gp_Vec myVect (p1,p2);
922 Handle(Geom_Line) myLine=new Geom_Line (p1 ,myVect );
923 Handle(AIS_Axis) TheAxis=new AIS_Axis (myLine );
924 GetMapOfAIS().Bind (TheAxis,name);
925 TheAISContext()->Display(TheAxis, Standard_True);
931 // Purpose: Teste le constructeur AIS_Axis::AIS_Axis (x:Axis1Placement from Geom)
932 if ( !strcasecmp(argv[0], "vaxis")) {
933 if (aShapes.Extent() != 2 && aShapes.Extent() != 1)
935 Message::SendFail ("Error: Wrong number of selected shapes.");
939 const TopoDS_Shape& aShapeA = aShapes.First();
940 if (aShapeA.ShapeType() == TopAbs_VERTEX)
942 if (aShapes.Extent() != 2)
944 Message::SendFail ("Error: Wrong number of selected shapes.");
948 const TopoDS_Shape& aShapeB = aShapes.Last();
949 if (aShapeB.ShapeType() != TopAbs_VERTEX)
951 Message::SendFail ("Syntax error: You should select two vertices or one edge.");
955 // Construction de l'axe
956 gp_Pnt A = BRep_Tool::Pnt (TopoDS::Vertex (aShapeA));
957 gp_Pnt B = BRep_Tool::Pnt (TopoDS::Vertex (aShapeB));
960 Handle(Geom_Axis1Placement) OrigineAndVect=new Geom_Axis1Placement (A,D);
961 Handle(AIS_Axis) TheAxis=new AIS_Axis (OrigineAndVect);
962 GetMapOfAIS().Bind (TheAxis,name);
963 TheAISContext()->Display (TheAxis, Standard_True);
967 TopoDS_Edge ed =TopoDS::Edge (aShapeA);
969 TopExp::Vertices(ed,Va,Vb );
970 gp_Pnt A=BRep_Tool::Pnt(Va);
971 gp_Pnt B=BRep_Tool::Pnt(Vb);
974 Handle(Geom_Axis1Placement) OrigineAndVect=new Geom_Axis1Placement (A,D);
975 Handle(AIS_Axis) TheAxis=new AIS_Axis (OrigineAndVect);
976 GetMapOfAIS().Bind (TheAxis,name);
977 TheAISContext()->Display (TheAxis, Standard_True);
983 // Purpose: Teste le constructeur AIS_Axis::AIS_Axis(x: Axis2Placement from Geom, y: TypeOfAxis from AIS)
984 else if ( !strcasecmp(argv[0], "vaxispara"))
986 if (aShapes.Extent() != 2)
988 Message::SendFail ("Error: Wrong number of selected shapes.");
992 const TopoDS_Shape& aShapeA = aShapes.First();
993 const TopoDS_Shape& aShapeB = aShapes.Last();
994 if (!(aShapeA.ShapeType() == TopAbs_EDGE
995 && aShapeB.ShapeType() == TopAbs_VERTEX))
997 Message::SendFail ("Syntax error: You should select face and then vertex.");
1001 TopoDS_Edge ed=TopoDS::Edge (aShapeA);
1002 gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(aShapeB));
1003 TopoDS_Vertex Va,Vc;
1004 TopExp::Vertices(ed,Va,Vc );
1005 gp_Pnt A=BRep_Tool::Pnt(Va);
1006 gp_Pnt C=BRep_Tool::Pnt(Vc);
1009 Handle(Geom_Axis1Placement) OrigineAndVect=new Geom_Axis1Placement (B,D);
1010 Handle(AIS_Axis) TheAxis=new AIS_Axis (OrigineAndVect);
1011 GetMapOfAIS().Bind (TheAxis,name);
1012 TheAISContext()->Display (TheAxis, Standard_True);
1016 // Fonction axisortho
1019 if (aShapes.Extent() != 2)
1021 Message::SendFail ("Error: Wrong number of selected shapes.");
1025 const TopoDS_Shape& aShapeA = aShapes.First();
1026 const TopoDS_Shape& aShapeB = aShapes.Last();
1027 if (!(aShapeA.ShapeType() == TopAbs_EDGE
1028 && aShapeB.ShapeType() == TopAbs_VERTEX))
1030 Message::SendFail ("Syntax error: You should select face and then vertex.");
1034 // Construction de l'axe
1035 TopoDS_Edge ed=TopoDS::Edge(aShapeA) ;
1036 gp_Pnt B=BRep_Tool::Pnt(TopoDS::Vertex(aShapeB) );
1037 TopoDS_Vertex Va,Vc;
1038 TopExp::Vertices(ed,Va,Vc );
1039 gp_Pnt A=BRep_Tool::Pnt(Va);
1040 gp_Pnt C=BRep_Tool::Pnt(Vc);
1041 gp_Pnt E(A.Y()+A.Z()-C.Y()-C.Z() ,C.X()-A.X() ,C.X()-A.X() );
1044 Handle(Geom_Axis1Placement) OrigineAndVect=new Geom_Axis1Placement (B,D);
1045 Handle(AIS_Axis) TheAxis=new AIS_Axis (OrigineAndVect);
1046 GetMapOfAIS().Bind (TheAxis,name);
1047 TheAISContext()->Display (TheAxis, Standard_True);
1056 //==============================================================================
1057 // Fonction First click Result
1059 // vpoint vertex AIS_Point=Vertex
1060 // edge AIS_Point=Middle of the edge
1061 //==============================================================================
1063 //==============================================================================
1064 //function : VPointBuilder
1066 //==============================================================================
1067 #include <TopoDS_Edge.hxx>
1068 #include <TopoDS_Vertex.hxx>
1069 #include <TopExp.hxx>
1070 #include <AIS_Point.hxx>
1071 #include <Geom_CartesianPoint.hxx>
1073 static int VPointBuilder(Draw_Interpretor& ,
1074 Standard_Integer theArgNb,
1075 const char** theArgVec)
1077 TCollection_AsciiString aName;
1078 gp_Pnt aPnt (RealLast(), 0.0, 0.0);
1079 bool is2d = false, isNoSel = false;
1080 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
1082 TCollection_AsciiString anArg (theArgVec[anArgIter]);
1088 else if (anArg == "-nosel"
1089 || anArg == "-noselection")
1093 else if (aName.IsEmpty())
1095 aName = theArgVec[anArgIter];
1097 else if (aPnt.X() == RealLast()
1098 && anArgIter + 1 < theArgNb
1099 && Draw::ParseReal (theArgVec[anArgIter + 0], aPnt.ChangeCoord().ChangeCoord (1))
1100 && Draw::ParseReal (theArgVec[anArgIter + 1], aPnt.ChangeCoord().ChangeCoord (2)))
1102 if (anArgIter + 2 < theArgNb
1103 && TCollection_AsciiString (theArgVec[anArgIter + 2]) != "-2d"
1104 && Draw::ParseReal (theArgVec[anArgIter + 2], aPnt.ChangeCoord().ChangeCoord (3)))
1115 Message::SendFail() << "Syntax error at argument '" << anArg << "'\n";
1120 if (aPnt.X() == RealLast())
1122 TopTools_ListOfShape aShapes;
1123 ViewerTest::GetSelectedShapes (aShapes);
1124 TopoDS_Shape aShapeA;
1125 if (aShapes.Extent() == 1)
1127 aShapeA = aShapes.First();
1129 switch (!aShapeA.IsNull() ? aShapeA.ShapeType() : TopAbs_SHAPE)
1133 aPnt = BRep_Tool::Pnt (TopoDS::Vertex (aShapeA));
1136 case TopAbs_EDGE: // edge middle point
1138 const TopoDS_Edge& anEdge = TopoDS::Edge (aShapeA);
1139 TopoDS_Vertex aVertPair[2];
1140 TopExp::Vertices (anEdge, aVertPair[0], aVertPair[1]);
1141 const gp_Pnt A = BRep_Tool::Pnt (aVertPair[0]);
1142 const gp_Pnt B = BRep_Tool::Pnt (aVertPair[1]);
1143 aPnt = (A.XYZ() + B.XYZ()) / 2;
1148 Message::SendFail() << "Error: Wrong number of selected shapes.\n"
1149 << "\tYou should select one edge or vertex.";
1157 aPnt.SetY (-aPnt.Y());
1159 Handle(Geom_CartesianPoint ) aGeomPoint = new Geom_CartesianPoint (aPnt);
1160 Handle(AIS_Point) aPointPrs = new AIS_Point (aGeomPoint);
1163 aPointPrs->SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_UPPER));
1164 aPointPrs->SetZLayer (Graphic3d_ZLayerId_TopOSD);
1166 ViewerTest::Display (aName, aPointPrs);
1169 ViewerTest::GetAISContext()->Deactivate (aPointPrs);
1174 //==============================================================================
1175 // Function 1st click 2de click 3de click
1176 // vplane Vertex Vertex Vertex
1180 // vplanepara Face Vertex
1182 // vplaneortho Face Edge
1184 //==============================================================================
1186 //==============================================================================
1187 //function : VPlaneBuilder
1188 //purpose : Build an AIS_Plane from selected entities or Named AIS components
1189 //Draw arg : vplane PlaneName [AxisName] [PointName] [TypeOfSensitivity]
1190 // [PointName] [PointName] [PointName] [TypeOfSensitivity]
1191 // [PlaneName] [PointName] [TypeOfSensitivity]
1192 //==============================================================================
1194 static Standard_Integer VPlaneBuilder (Draw_Interpretor& /*di*/,
1195 Standard_Integer argc,
1199 Standard_Boolean hasArg;
1200 TCollection_AsciiString aName;
1203 if (argc<2 || argc>6 )
1205 Message::SendFail ("Syntax error: wrong number of arguments");
1208 if (argc == 6 || argc==5 || argc==4)
1209 hasArg=Standard_True;
1211 hasArg=Standard_False;
1215 // There are some arguments
1218 Handle(AIS_InteractiveObject) aShapeA;
1219 if (!GetMapOfAIS().Find2 (argv[2], aShapeA))
1221 Message::SendFail ("Syntax error: 1st name is not displayed");
1225 // The first argument is an AIS_Point
1226 if (!aShapeA.IsNull() &&
1227 aShapeA->Type()==AIS_KOI_Datum &&
1228 aShapeA->Signature()==1)
1230 // The second argument must also be an AIS_Point
1231 Handle(AIS_InteractiveObject) aShapeB;
1232 if (argc<5 || !GetMapOfAIS().Find2 (argv[3], aShapeB))
1234 Message::SendFail ("Syntax error: 2nd name is not displayed");
1237 // If B is not an AIS_Point
1238 if (aShapeB.IsNull() ||
1239 (!(aShapeB->Type()==AIS_KOI_Datum && aShapeB->Signature()==1)))
1241 Message::SendFail ("Syntax error: 2nd object is expected to be an AIS_Point");
1244 // The third object is an AIS_Point
1245 Handle(AIS_InteractiveObject) aShapeC;
1246 if (!GetMapOfAIS().Find2(argv[4], aShapeC))
1248 Message::SendFail ("Syntax error: 3d name is not displayed");
1251 // If C is not an AIS_Point
1252 if (aShapeC.IsNull() ||
1253 (!(aShapeC->Type()==AIS_KOI_Datum && aShapeC->Signature()==1)))
1255 Message::SendFail ("Syntax error: 3d object is expected to be an AIS_Point");
1259 // Treatment of objects A, B, C
1260 // Downcast an AIS_IO to AIS_Point
1261 Handle(AIS_Point) anAISPointA = Handle(AIS_Point)::DownCast( aShapeA);
1262 Handle(AIS_Point) anAISPointB = Handle(AIS_Point)::DownCast( aShapeB);
1263 Handle(AIS_Point) anAISPointC = Handle(AIS_Point)::DownCast( aShapeC);
1265 Handle(Geom_CartesianPoint ) aCartPointA =
1266 Handle(Geom_CartesianPoint)::DownCast( anAISPointA->Component());
1268 Handle(Geom_CartesianPoint ) aCartPointB =
1269 Handle(Geom_CartesianPoint)::DownCast( anAISPointB->Component());
1271 Handle(Geom_CartesianPoint ) aCartPointC =
1272 Handle(Geom_CartesianPoint)::DownCast( anAISPointC->Component());
1274 // Verification that the three points are different
1275 if(Abs(aCartPointB->X()-aCartPointA->X())<=Precision::Confusion() &&
1276 Abs(aCartPointB->Y()-aCartPointA->Y())<=Precision::Confusion() &&
1277 Abs(aCartPointB->Z()-aCartPointA->Z())<=Precision::Confusion())
1280 Message::SendFail ("Error: same points");
1283 if(Abs(aCartPointC->X()-aCartPointA->X())<=Precision::Confusion() &&
1284 Abs(aCartPointC->Y()-aCartPointA->Y())<=Precision::Confusion() &&
1285 Abs(aCartPointC->Z()-aCartPointA->Z())<=Precision::Confusion())
1288 Message::SendFail ("Error: same points");
1291 if(Abs(aCartPointC->X()-aCartPointB->X())<=Precision::Confusion() &&
1292 Abs(aCartPointC->Y()-aCartPointB->Y())<=Precision::Confusion() &&
1293 Abs(aCartPointC->Z()-aCartPointB->Z())<=Precision::Confusion())
1296 Message::SendFail ("Error: same points");
1300 gp_Pnt A = aCartPointA->Pnt();
1301 gp_Pnt B = aCartPointB->Pnt();
1302 gp_Pnt C = aCartPointC->Pnt();
1304 // Construction of AIS_Plane
1305 GC_MakePlane MkPlane (A,B,C);
1306 Handle(Geom_Plane) aGeomPlane = MkPlane.Value();
1307 Handle(AIS_Plane) anAISPlane = new AIS_Plane(aGeomPlane );
1308 GetMapOfAIS().Bind (anAISPlane,aName );
1311 Standard_Integer aType = Draw::Atoi (argv[5]);
1312 if (aType != 0 && aType != 1)
1314 Message::SendFail("Syntax error: wrong type of sensitivity.\n"
1315 "Should be one of the following values:\n"
1322 anAISPlane->SetTypeOfSensitivity (Select3D_TypeOfSensitivity (aType));
1325 TheAISContext()->Display (anAISPlane, Standard_True);
1328 // The first argument is an AIS_Axis
1329 // Creation of a plane orthogonal to the axis through a point
1330 else if (aShapeA->Type()==AIS_KOI_Datum && aShapeA->Signature()==2 ) {
1331 // The second argument should be an AIS_Point
1332 Handle(AIS_InteractiveObject) aShapeB;
1333 if (argc!=4 || !GetMapOfAIS().Find2 (argv[3], aShapeB))
1335 Message::SendFail ("Syntax error: 2d name is not displayed");
1338 // If B is not an AIS_Point
1339 if (aShapeB.IsNull() ||
1340 (!(aShapeB->Type()==AIS_KOI_Datum && aShapeB->Signature()==1)))
1342 Message::SendFail ("Syntax error: 2d object is expected to be an AIS_Point");
1346 // Treatment of objects A and B
1347 Handle(AIS_Axis) anAISAxisA = Handle(AIS_Axis)::DownCast(aShapeA);
1348 Handle(AIS_Point) anAISPointB = Handle(AIS_Point)::DownCast(aShapeB);
1350 Handle(Geom_Line ) aGeomLineA = anAISAxisA ->Component();
1351 Handle(Geom_Point) aGeomPointB = anAISPointB->Component() ;
1353 gp_Ax1 anAxis = aGeomLineA->Position();
1354 Handle(Geom_CartesianPoint) aCartPointB =
1355 Handle(Geom_CartesianPoint)::DownCast(aGeomPointB);
1357 gp_Dir D =anAxis.Direction();
1358 gp_Pnt B = aCartPointB->Pnt();
1360 // Construction of AIS_Plane
1361 Handle(Geom_Plane) aGeomPlane = new Geom_Plane(B,D);
1362 Handle(AIS_Plane) anAISPlane = new AIS_Plane(aGeomPlane,B );
1363 GetMapOfAIS().Bind (anAISPlane,aName );
1366 Standard_Integer aType = Draw::Atoi (argv[4]);
1367 if (aType != 0 && aType != 1)
1369 Message::SendFail ("Syntax error: wrong type of sensitivity!\n"
1370 "Should be one of the following values:\n"
1377 anAISPlane->SetTypeOfSensitivity (Select3D_TypeOfSensitivity (aType));
1380 TheAISContext()->Display (anAISPlane, Standard_True);
1383 // The first argumnet is an AIS_Plane
1384 // Creation of a plane parallel to the plane passing through the point
1385 else if (aShapeA->Type()==AIS_KOI_Datum && aShapeA->Signature()==7)
1387 // The second argument should be an AIS_Point
1388 Handle(AIS_InteractiveObject) aShapeB;
1389 if (argc!=4 || !GetMapOfAIS().Find2 (argv[3], aShapeB))
1391 Message::SendFail ("Syntax error: 2d name is not displayed");
1394 // B should be an AIS_Point
1395 if (aShapeB.IsNull() ||
1396 (!(aShapeB->Type()==AIS_KOI_Datum && aShapeB->Signature()==1)))
1398 Message::SendFail ("Syntax error: 2d object is expected to be an AIS_Point");
1402 // Treatment of objects A and B
1403 Handle(AIS_Plane) anAISPlaneA = Handle(AIS_Plane)::DownCast(aShapeA);
1404 Handle(AIS_Point) anAISPointB = Handle(AIS_Point)::DownCast(aShapeB);
1406 Handle(Geom_Plane) aNewGeomPlane= anAISPlaneA->Component();
1407 Handle(Geom_Point) aGeomPointB = anAISPointB->Component();
1409 Handle(Geom_CartesianPoint) aCartPointB =
1410 Handle(Geom_CartesianPoint)::DownCast(aGeomPointB);
1411 gp_Pnt B= aCartPointB->Pnt();
1413 // Construction of an AIS_Plane
1414 Handle(AIS_Plane) anAISPlane = new AIS_Plane(aNewGeomPlane, B);
1415 GetMapOfAIS().Bind (anAISPlane, aName);
1418 Standard_Integer aType = Draw::Atoi (argv[4]);
1419 if (aType != 0 && aType != 1)
1421 Message::SendFail ("Syntax error: wrong type of sensitivity!\n"
1422 "Should be one of the following values:\n"
1429 anAISPlane->SetTypeOfSensitivity (Select3D_TypeOfSensitivity (aType));
1432 TheAISContext()->Display (anAISPlane, Standard_True);
1437 Message::SendFail ("Syntax error: 1st object is not an AIS");
1441 // There are no arguments
1444 TopTools_ListOfShape aShapes;
1445 ViewerTest::GetSelectedShapes (aShapes);
1448 // Test the constructor AIS_Plane::AIS_Plane(Geom_Plane, Standard_Boolean )
1449 if (!strcasecmp(argv[0], "vplane"))
1451 if (aShapes.Extent() < 1 || aShapes.Extent() > 3)
1453 Message::SendFail() << "Error: Wront number of selected shapes.\n"
1454 << "\tYou should one of variant: face, edge and vertex or three vertices.";
1458 const TopoDS_Shape& aShapeA = aShapes.First();
1459 if (aShapeA.ShapeType() == TopAbs_VERTEX)
1461 if (aShapes.Extent() == 2)
1463 const TopoDS_Shape& aShapeB = aShapes.Last();
1464 if (aShapeB.ShapeType() != TopAbs_EDGE)
1466 Message::SendFail ("Syntax error: Together with vertex should be edge.");
1470 // Verify that the vertex is not on the edge ShapeB
1471 TopoDS_Edge anEdgeB = TopoDS::Edge(aShapeB);
1472 TopoDS_Vertex aVertA = TopoDS::Vertex(aShapeA);
1474 BRepExtrema_ExtPC OrthoProj(aVertA, anEdgeB);
1475 if (OrthoProj.SquareDistance(1)<Precision::Approximation())
1477 // The vertex is on the edge
1478 Message::SendFail ("Error: point is on the edge");
1483 gp_Pnt A = BRep_Tool::Pnt(aVertA);
1484 TopoDS_Vertex aVBa, aVBb;
1485 TopExp::Vertices(anEdgeB ,aVBa ,aVBb);
1486 gp_Pnt aBa = BRep_Tool::Pnt(aVBa);
1487 gp_Pnt aBb = BRep_Tool::Pnt(aVBb);
1488 GC_MakePlane MkPlane (A, aBa, aBb);
1489 Handle(Geom_Plane) aGeomPlane = MkPlane.Value();
1490 Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane);
1491 GetMapOfAIS().Bind (anAISPlane, aName);
1492 TheAISContext()->Display (anAISPlane, Standard_True);
1495 else if (aShapes.Extent() == 3)
1497 TopTools_ListOfShape::Iterator anIter (aShapes);
1500 const TopoDS_Shape& aShapeB = anIter.Value();
1503 const TopoDS_Shape& aShapeC = anIter.Value();
1505 if (!(aShapeB.ShapeType() == TopAbs_VERTEX
1506 && aShapeC.ShapeType() == TopAbs_VERTEX))
1508 Message::SendFail ("Syntax error: You should one of variant: face, edge and vertex or three vertices.");
1512 gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(aShapeA));
1513 gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(aShapeB));
1514 gp_Pnt C = BRep_Tool::Pnt(TopoDS::Vertex(aShapeC));
1515 GC_MakePlane MkPlane(A, B, C);
1516 Handle(Geom_Plane) aGeomPlane = MkPlane.Value();
1517 Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane);
1518 GetMapOfAIS().Bind (anAISPlane, aName);
1519 TheAISContext()->Display (anAISPlane, Standard_True);
1523 Message::SendFail ("Syntax error: You should one of variant: face, edge and vertex or three vertices.");
1527 else if (aShapeA.ShapeType() == TopAbs_EDGE)
1529 if (aShapes.Extent() != 2)
1531 Message::SendFail ("Error: wrong number of selected shapes.");
1535 const TopoDS_Shape& aShapeB = aShapes.Last();
1536 if (aShapeB.ShapeType() != TopAbs_VERTEX)
1538 Message::SendFail ("Syntax error: Together with edge should be vertex.");
1542 // Check that the vertex aShapeB is not on the edge
1543 TopoDS_Edge anEdgeA = TopoDS::Edge(aShapeA);
1544 TopoDS_Vertex aVertB = TopoDS::Vertex(aShapeB);
1546 BRepExtrema_ExtPC OrthoProj (aVertB, anEdgeA);
1547 if (OrthoProj.SquareDistance(1)<Precision::Approximation())
1549 // The vertex is on the edge
1550 Message::SendFail ("Error point is on the edge");
1554 gp_Pnt B = BRep_Tool::Pnt(aVertB);
1555 TopoDS_Vertex aVAa, aVAb;
1556 TopExp::Vertices(anEdgeA, aVAa, aVAb);
1557 gp_Pnt Aa = BRep_Tool::Pnt(aVAa);
1558 gp_Pnt Ab = BRep_Tool::Pnt(aVAb);
1559 GC_MakePlane MkPlane (B,Aa,Ab);
1560 Handle(Geom_Plane) aGeomPlane = MkPlane.Value();
1561 Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane);
1562 GetMapOfAIS().Bind (anAISPlane ,aName);
1563 TheAISContext()->Display (anAISPlane, Standard_True);
1565 else if (aShapeA.ShapeType() == TopAbs_FACE)
1567 TopoDS_Face aFace = TopoDS::Face(aShapeA);
1568 BRepAdaptor_Surface aSurface (aFace, Standard_False);
1569 if (aSurface.GetType()==GeomAbs_Plane)
1571 gp_Pln aPlane = aSurface.Plane();
1572 Handle(Geom_Plane) aGeomPlane = new Geom_Plane(aPlane);
1573 Handle(AIS_Plane) anAISPlane = new AIS_Plane(aGeomPlane);
1574 GetMapOfAIS().Bind (anAISPlane, aName);
1575 TheAISContext()->Display (anAISPlane, Standard_True);
1579 Message::SendFail ("Error: surface is not Plane");
1585 Message::SendFail ("Syntax error: You should one of variant: face, edge and vertex or three vertices");
1590 // Function vPlanePara
1591 // ===================
1592 // test the constructor AIS_Plane::AIS_Plane(Geom_Plane,gp_Pnt)
1593 else if (!strcasecmp(argv[0], "vplanepara"))
1595 if (aShapes.Extent() != 2)
1597 Message::SendFail ("Error: Wrong number of selected shapes.");
1601 const TopoDS_Shape* aShapeA = &aShapes.First();
1602 const TopoDS_Shape* aShapeB = &aShapes.Last();
1603 if (aShapeA->ShapeType() != TopAbs_VERTEX)
1605 std::swap (aShapeA, aShapeB);
1608 if (!(aShapeA->ShapeType() == TopAbs_VERTEX
1609 && aShapeB->ShapeType() == TopAbs_FACE))
1611 Message::SendFail ("Syntax error: you should select face and vertex.");
1615 gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(*aShapeA));
1617 TopoDS_Face aFace = TopoDS::Face(*aShapeB);
1618 BRepAdaptor_Surface aSurface (aFace, Standard_False);
1619 if (aSurface.GetType() == GeomAbs_Plane)
1621 gp_Pln aPlane = aSurface.Plane();
1622 // Construct a plane parallel to aGeomPlane through A
1623 aPlane.SetLocation(A);
1624 Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane);
1625 Handle(AIS_Plane) aAISPlane = new AIS_Plane (aGeomPlane, A);
1626 GetMapOfAIS().Bind (aAISPlane ,aName);
1627 TheAISContext()->Display (aAISPlane, Standard_True);
1631 Message::SendFail ("Error: Builded surface is not a plane.");
1636 // Function vplaneortho
1637 // ====================
1638 // test the constructor AIS_Plane::AIS_Plane(Geom_Plane,gp_Pnt,gp_Pnt,gp_Pnt)
1641 if (aShapes.Extent() != 2)
1643 Message::SendFail ("Error: wrong number of selected shapes.");
1647 const TopoDS_Shape* aShapeA = &aShapes.First();
1648 const TopoDS_Shape* aShapeB = &aShapes.Last();
1650 if (aShapeA->ShapeType() != TopAbs_EDGE)
1652 std::swap (aShapeA, aShapeB);
1655 if (!(aShapeA->ShapeType() == TopAbs_EDGE
1656 && aShapeB->ShapeType() == TopAbs_FACE))
1658 Message::SendFail ("Error: you should select edge and face.");
1662 // Construction of plane
1663 TopoDS_Edge anEdgeA = TopoDS::Edge(*aShapeA);
1664 TopoDS_Vertex aVAa, aVAb;
1665 TopExp::Vertices(anEdgeA, aVAa, aVAb);
1666 gp_Pnt Aa = BRep_Tool::Pnt(aVAa);
1667 gp_Pnt Ab = BRep_Tool::Pnt(aVAb);
1671 // Creation of rotation axis
1672 gp_Ax1 aRotAxis (Aa,Dab);
1674 TopoDS_Face aFace = TopoDS::Face(*aShapeB);
1675 // The edge must be parallel to the face
1676 BRepExtrema_ExtPF aHeightA (aVAa, aFace);
1677 BRepExtrema_ExtPF aHeightB (aVAb, aFace);
1678 // Compare to heights
1679 if (fabs(sqrt(aHeightA.SquareDistance(1)) - sqrt(aHeightB.SquareDistance(1)))
1680 >Precision::Confusion())
1682 // the edge is not parallel to the face
1683 Message::SendFail ("Error: the edge is not parallel to the face");
1687 BRepAdaptor_Surface aSurface (aFace, Standard_False);
1688 if (aSurface.GetType()==GeomAbs_Plane)
1690 gp_Pln aPlane = aSurface.Plane();
1691 // It rotates a half turn round the axis of rotation
1692 aPlane.Rotate(aRotAxis , M_PI/2);
1694 Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPlane);
1695 // constructed aGeomPlane parallel to a plane containing the edge (center mid-edge)
1696 gp_Pnt aMiddle ((Aa.X()+Ab.X() )/2 ,(Aa.Y()+Ab.Y() )/2 ,(Aa.Z()+Ab.Z() )/2 );
1697 Handle(AIS_Plane) anAISPlane = new AIS_Plane (aGeomPlane, aMiddle);
1698 GetMapOfAIS().Bind (anAISPlane, aName);
1699 TheAISContext()->Display (anAISPlane, Standard_True);
1703 Message::SendFail ("Error: surface is not Plane");
1711 //===============================================================================================
1712 //function : VChangePlane
1714 //===============================================================================================
1715 static int VChangePlane (Draw_Interpretor& /*theDi*/, Standard_Integer theArgsNb, const char** theArgVec)
1717 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
1718 if (aContextAIS.IsNull())
1720 Message::SendFail ("Error: no active viewer.");
1724 if (theArgsNb < 3 || theArgsNb > 11)
1726 Message::SendFail ("Syntax error: wrong number of arguments.");
1730 TCollection_AsciiString aName (theArgVec[1]);
1732 Handle(AIS_Plane) aPlane = GetMapOfAIS().IsBound2(aName)
1733 ? Handle(AIS_Plane)::DownCast (GetMapOfAIS().Find2 (aName))
1736 if ( aPlane.IsNull() )
1738 Message::SendFail() << "Syntax error: there is no interactive plane with the given name '" << aName << "'.";
1742 Standard_Real aCenterX = aPlane->Center().X();
1743 Standard_Real aCenterY = aPlane->Center().Y();
1744 Standard_Real aCenterZ = aPlane->Center().Z();
1746 Standard_Real aDirX = aPlane->Component()->Axis().Direction().X();
1747 Standard_Real aDirY = aPlane->Component()->Axis().Direction().Y();
1748 Standard_Real aDirZ = aPlane->Component()->Axis().Direction().Z();
1750 Standard_Real aSizeX = 0.0;
1751 Standard_Real aSizeY = 0.0;
1752 aPlane->Size (aSizeX, aSizeY);
1753 Standard_Boolean isUpdate = Standard_True;
1755 TCollection_AsciiString aPName, aPValue;
1756 for (Standard_Integer anArgIt = 1; anArgIt < theArgsNb; ++anArgIt)
1758 const TCollection_AsciiString anArg = theArgVec[anArgIt];
1759 TCollection_AsciiString anArgCase = anArg;
1760 anArgCase.UpperCase();
1761 if (ViewerTest::SplitParameter (anArg, aPName, aPValue))
1764 if (aPName.IsEqual ("X"))
1766 aCenterX = aPValue.RealValue();
1768 else if (aPName.IsEqual ("Y"))
1770 aCenterY = aPValue.RealValue();
1772 else if (aPName.IsEqual ("Z"))
1774 aCenterZ = aPValue.RealValue();
1776 else if (aPName.IsEqual ("DX"))
1778 aDirX = aPValue.RealValue();
1780 else if (aPName.IsEqual ("DY"))
1782 aDirY = aPValue.RealValue();
1784 else if (aPName.IsEqual ("DZ"))
1786 aDirZ = aPValue.RealValue();
1788 else if (aPName.IsEqual ("SX"))
1790 aSizeX = aPValue.RealValue();
1792 else if (aPName.IsEqual ("SY"))
1794 aSizeY = aPValue.RealValue();
1797 else if (anArg.IsEqual ("NOUPDATE"))
1799 isUpdate = Standard_False;
1803 gp_Dir aDirection (aDirX, aDirY, aDirZ);
1804 gp_Pnt aCenterPnt (aCenterX, aCenterY, aCenterZ);
1805 aPlane->SetCenter (aCenterPnt);
1806 aPlane->SetComponent (new Geom_Plane (aCenterPnt, aDirection));
1807 aPlane->SetSize (aSizeX, aSizeY);
1809 aContextAIS->Update (aPlane, isUpdate);
1814 //==============================================================================
1816 // --------------- Uniquement par parametre. Pas de selection dans le viewer.
1817 //==============================================================================
1819 //==============================================================================
1820 //function : VLineBuilder
1821 //purpose : Build an AIS_Line
1822 //Draw arg : vline LineName [AIS_PointName] [AIS_PointName]
1823 // [Xa] [Ya] [Za] [Xb] [Yb] [Zb]
1824 //==============================================================================
1825 #include <Geom_CartesianPoint.hxx>
1826 #include <AIS_Line.hxx>
1829 static int VLineBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1832 if (argc!=4 && argc!=8 && argc!=2 ) {di<<"vline error: number of arguments not correct \n";return 1; }
1834 // On recupere les parametres
1835 Handle(AIS_InteractiveObject) theShapeA;
1836 Handle(AIS_InteractiveObject) theShapeB;
1838 // Parametres: AIS_Point AIS_Point
1839 // ===============================
1841 GetMapOfAIS().Find2 (argv[2], theShapeA);
1842 // On verifie que c'est bien une AIS_Point
1843 if (!theShapeA.IsNull() &&
1844 theShapeA->Type()==AIS_KOI_Datum && theShapeA->Signature()==1) {
1845 // on recupere le deuxieme AIS_Point
1846 GetMapOfAIS().Find2 (argv[3], theShapeB);
1847 if (theShapeB.IsNull() ||
1848 (!(theShapeB->Type()==AIS_KOI_Datum && theShapeB->Signature()==1)))
1850 di <<"vline error: wrong type of 2de argument.\n";
1854 else {di <<"vline error: wrong type of 1st argument.\n";return 1; }
1855 // Les deux parametres sont du bon type. On verifie que les points ne sont pas confondus
1856 Handle(AIS_Point) theAISPointA= Handle(AIS_Point)::DownCast (theShapeA);
1857 Handle(AIS_Point) theAISPointB= Handle(AIS_Point)::DownCast (theShapeB);
1859 Handle(Geom_Point ) myGeomPointBA= theAISPointA->Component();
1860 Handle(Geom_CartesianPoint ) myCartPointA= Handle(Geom_CartesianPoint)::DownCast (myGeomPointBA);
1861 // Handle(Geom_CartesianPoint ) myCartPointA= *(Handle(Geom_CartesianPoint)*)& (theAISPointA->Component() ) ;
1863 Handle(Geom_Point ) myGeomPointB= theAISPointB->Component();
1864 Handle(Geom_CartesianPoint ) myCartPointB= Handle(Geom_CartesianPoint)::DownCast (myGeomPointB);
1865 // Handle(Geom_CartesianPoint ) myCartPointB= *(Handle(Geom_CartesianPoint)*)& (theAISPointB->Component() ) ;
1867 if (myCartPointB->X()==myCartPointA->X() && myCartPointB->Y()==myCartPointA->Y() && myCartPointB->Z()==myCartPointA->Z() ) {
1869 di<<"vline error: same points\n";return 1;
1871 // Les deux points sont OK...Construction de l'AIS_Line (en faite, le segment AB)
1872 Handle(AIS_Line) theAISLine= new AIS_Line(myCartPointA,myCartPointB );
1873 GetMapOfAIS().Bind(theAISLine,argv[1] );
1874 TheAISContext()->Display (theAISLine, Standard_True);
1878 // Parametres 6 Reals
1879 // ==================
1882 // On verifie que les deux points ne sont pas confondus
1884 Standard_Real coord[6];
1885 for(Standard_Integer i=0;i<=2;i++){
1886 coord[i]=Draw::Atof(argv[2+i]);
1887 coord[i+3]=Draw::Atof(argv[5+i]);
1890 Handle(Geom_CartesianPoint ) myCartPointA=new Geom_CartesianPoint (coord[0],coord[1],coord[2] );
1891 Handle(Geom_CartesianPoint ) myCartPointB=new Geom_CartesianPoint (coord[3],coord[4],coord[5] );
1893 Handle(AIS_Line) theAISLine= new AIS_Line(myCartPointA,myCartPointB );
1894 GetMapOfAIS().Bind(theAISLine,argv[1] );
1895 TheAISContext()->Display (theAISLine, Standard_True);
1899 // Pas de parametres: Selection dans le viewer.
1900 // ============================================
1904 TopTools_ListOfShape aShapes;
1905 ViewerTest::GetSelectedShapes (aShapes);
1906 if (aShapes.Extent() != 2)
1908 Message::SendFail ("Error: wrong number of selected shapes.");
1912 const TopoDS_Shape& aShapeA = aShapes.First();
1913 const TopoDS_Shape& aShapeB = aShapes.Last();
1915 if (!(aShapeA.ShapeType() == TopAbs_VERTEX
1916 && aShapeB.ShapeType() == TopAbs_VERTEX))
1918 Message::SendFail ("Error: you should select two different vertex.");
1922 // Construction de la line
1923 gp_Pnt A = BRep_Tool::Pnt (TopoDS::Vertex (aShapeA));
1924 gp_Pnt B = BRep_Tool::Pnt (TopoDS::Vertex (aShapeB));
1926 Handle(Geom_CartesianPoint ) myCartPointA=new Geom_CartesianPoint(A);
1927 Handle(Geom_CartesianPoint ) myCartPointB=new Geom_CartesianPoint(B);
1929 Handle(AIS_Line) theAISLine= new AIS_Line(myCartPointA,myCartPointB );
1930 GetMapOfAIS().Bind(theAISLine,argv[1] );
1931 TheAISContext()->Display (theAISLine, Standard_True);
1937 //==============================================================================
1938 // class : FilledCircle
1939 // purpose : creates filled circle based on AIS_InteractiveObject
1941 // This class is used to check method Matches() of class
1942 // Select3D_SensitiveCircle with member myFillStatus = Standard_True,
1943 // because none of AIS classes provides creation of
1944 // Select3D_SensitiveCircle with member myFillStatus = Standard_True
1945 // (look method ComputeSelection() )
1946 //==============================================================================
1948 Handle(Geom_Circle) CreateCircle(gp_Pnt theCenter, Standard_Real theRadius)
1950 gp_Ax2 anAxes(theCenter, gp_Dir(gp_Vec(0., 0., 1.)));
1951 gp_Circ aCirc(anAxes, theRadius);
1952 Handle(Geom_Circle) aCircle = new Geom_Circle(aCirc);
1956 class FilledCircle : public AIS_InteractiveObject
1960 DEFINE_STANDARD_RTTI_INLINE(FilledCircle,AIS_InteractiveObject);
1962 FilledCircle(gp_Pnt theCenter, Standard_Real theRadius);
1963 FilledCircle(Handle(Geom_Circle) theCircle);
1966 TopoDS_Face ComputeFace();
1968 // Virtual methods implementation
1969 void Compute ( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
1970 const Handle(Prs3d_Presentation)& thePresentation,
1971 const Standard_Integer theMode) Standard_OVERRIDE;
1973 void ComputeSelection ( const Handle(SelectMgr_Selection)& theSelection,
1974 const Standard_Integer theMode) Standard_OVERRIDE;
1977 Handle(Geom_Circle) myCircle;
1978 Standard_Boolean myFilledStatus;
1983 FilledCircle::FilledCircle(gp_Pnt theCenter, Standard_Real theRadius)
1985 myCircle = CreateCircle(theCenter, theRadius);
1986 myFilledStatus = Standard_True;
1989 FilledCircle::FilledCircle(Handle(Geom_Circle) theCircle)
1991 myCircle = theCircle;
1992 myFilledStatus = Standard_True;
1995 TopoDS_Face FilledCircle::ComputeFace()
1997 // Create edge from myCircle
1998 BRepBuilderAPI_MakeEdge anEdgeMaker(myCircle->Circ());
1999 TopoDS_Edge anEdge = anEdgeMaker.Edge();
2001 // Create wire from anEdge
2002 BRepBuilderAPI_MakeWire aWireMaker(anEdge);
2003 TopoDS_Wire aWire = aWireMaker.Wire();
2005 // Create face from aWire
2006 BRepBuilderAPI_MakeFace aFaceMaker(aWire);
2007 TopoDS_Face aFace = aFaceMaker.Face();
2012 void FilledCircle::Compute(const Handle(PrsMgr_PresentationManager3d) &/*thePresentationManager*/,
2013 const Handle(Prs3d_Presentation) &thePresentation,
2014 const Standard_Integer theMode)
2016 thePresentation->Clear();
2018 TopoDS_Face aFace = ComputeFace();
2020 if (aFace.IsNull()) return;
2021 if (theMode != 0) return;
2023 StdPrs_ShadedShape::Add(thePresentation, aFace, myDrawer);
2026 void FilledCircle::ComputeSelection(const Handle(SelectMgr_Selection) &theSelection,
2027 const Standard_Integer /*theMode*/)
2029 Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this);
2030 Handle(Select3D_SensitiveCircle) aSensitiveCircle = new Select3D_SensitiveCircle (anEntityOwner, myCircle->Circ(), myFilledStatus);
2031 theSelection->Add(aSensitiveCircle);
2034 //==============================================================================
2036 // ----------------- Uniquement par parametre. Pas de selection dans le viewer.
2037 //==============================================================================
2039 //==============================================================================
2040 //function : VCircleBuilder
2041 //purpose : Build an AIS_Circle
2042 //Draw arg : vcircle CircleName PlaneName PointName Radius IsFilled
2043 // PointName PointName PointName IsFilled
2044 //==============================================================================
2046 void DisplayCircle (Handle (Geom_Circle) theGeomCircle,
2047 TCollection_AsciiString theName,
2048 Standard_Boolean isFilled)
2050 Handle(AIS_InteractiveObject) aCircle;
2053 aCircle = new FilledCircle(theGeomCircle);
2057 aCircle = new AIS_Circle(theGeomCircle);
2058 Handle(AIS_Circle)::DownCast (aCircle)->SetFilledCircleSens (Standard_False);
2061 // Check if there is an object with given name
2062 // and remove it from context
2063 if (GetMapOfAIS().IsBound2(theName))
2065 Handle(AIS_InteractiveObject) anInterObj = GetMapOfAIS().Find2(theName);
2066 TheAISContext()->Remove(anInterObj, Standard_False);
2067 GetMapOfAIS().UnBind2(theName);
2070 // Bind the circle to its name
2071 GetMapOfAIS().Bind(aCircle, theName);
2073 // Display the circle
2074 TheAISContext()->Display (aCircle, Standard_True);
2078 static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const char** argv)
2080 // Verification of the arguments
2081 if (argc>6 || argc<2)
2083 Message::SendFail ("Syntax error: wrong number of arguments");
2087 // There are all arguments
2091 TCollection_AsciiString aName(argv[1]);
2092 Standard_Boolean isFilled = Draw::Atoi(argv[5]) != 0;
2094 Handle(AIS_InteractiveObject) theShapeA, theShapeB;
2095 GetMapOfAIS().Find2 (argv[2], theShapeA);
2096 GetMapOfAIS().Find2 (argv[3], theShapeB);
2098 // Arguments: AIS_Point AIS_Point AIS_Point
2099 // ========================================
2100 if (!theShapeA.IsNull() && !theShapeB.IsNull() &&
2101 theShapeA->Type()==AIS_KOI_Datum && theShapeA->Signature()==1)
2103 if (theShapeB->Type()!=AIS_KOI_Datum || theShapeB->Signature()!=1 )
2105 Message::SendFail ("Error: 2d argument is unexpected to be a point");
2108 // The third object must be a point
2109 Handle(AIS_InteractiveObject) theShapeC;
2110 GetMapOfAIS().Find2 (argv[4], theShapeC);
2111 if (theShapeC.IsNull() ||
2112 theShapeC->Type()!=AIS_KOI_Datum || theShapeC->Signature()!=1 )
2114 Message::SendFail ("Error: 3d argument is unexpected to be a point");
2118 // Verify that the three points are different
2119 Handle(AIS_Point) theAISPointA = Handle(AIS_Point)::DownCast(theShapeA);
2120 Handle(AIS_Point) theAISPointB = Handle(AIS_Point)::DownCast(theShapeB);
2121 Handle(AIS_Point) theAISPointC = Handle(AIS_Point)::DownCast(theShapeC);
2123 Handle(Geom_Point) myGeomPointA = theAISPointA->Component();
2124 Handle(Geom_CartesianPoint) myCartPointA =
2125 Handle(Geom_CartesianPoint)::DownCast(myGeomPointA);
2127 Handle(Geom_Point) myGeomPointB = theAISPointB->Component();
2128 Handle(Geom_CartesianPoint) myCartPointB =
2129 Handle(Geom_CartesianPoint)::DownCast(myGeomPointB);
2131 Handle(Geom_Point) myGeomPointC = theAISPointC->Component();
2132 Handle(Geom_CartesianPoint) myCartPointC =
2133 Handle(Geom_CartesianPoint)::DownCast(myGeomPointC);
2136 if (Abs(myCartPointA->X()-myCartPointB->X()) <= Precision::Confusion() &&
2137 Abs(myCartPointA->Y()-myCartPointB->Y()) <= Precision::Confusion() &&
2138 Abs(myCartPointA->Z()-myCartPointB->Z()) <= Precision::Confusion() )
2140 Message::SendFail ("Error: Same points");
2144 if (Abs(myCartPointA->X()-myCartPointC->X()) <= Precision::Confusion() &&
2145 Abs(myCartPointA->Y()-myCartPointC->Y()) <= Precision::Confusion() &&
2146 Abs(myCartPointA->Z()-myCartPointC->Z()) <= Precision::Confusion() )
2148 Message::SendFail ("Error: Same points");
2152 if (Abs(myCartPointB->X()-myCartPointC->X()) <= Precision::Confusion() &&
2153 Abs(myCartPointB->Y()-myCartPointC->Y()) <= Precision::Confusion() &&
2154 Abs(myCartPointB->Z()-myCartPointC->Z()) <= Precision::Confusion() )
2156 Message::SendFail ("Error: Same points");
2159 // Construction of the circle
2160 GC_MakeCircle Cir = GC_MakeCircle (myCartPointA->Pnt(),
2161 myCartPointB->Pnt(), myCartPointC->Pnt() );
2162 Handle (Geom_Circle) theGeomCircle;
2165 theGeomCircle = Cir.Value();
2167 catch (StdFail_NotDone const&)
2169 Message::SendFail ("Error: can't create circle");
2173 DisplayCircle(theGeomCircle, aName, isFilled);
2176 // Arguments: AIS_Plane AIS_Point Real
2177 // ===================================
2178 else if (theShapeA->Type() == AIS_KOI_Datum &&
2179 theShapeA->Signature() == 7 )
2181 if (theShapeB->Type() != AIS_KOI_Datum ||
2182 theShapeB->Signature() != 1 )
2184 Message::SendFail ("Error: 2d element is a unexpected to be a point");
2187 // Check that the radius is >= 0
2188 if (Draw::Atof(argv[4]) <= 0 )
2190 Message::SendFail ("Syntax error: the radius must be >=0");
2194 // Recover the normal to the plane
2195 Handle(AIS_Plane) theAISPlane = Handle(AIS_Plane)::DownCast(theShapeA);
2196 Handle(AIS_Point) theAISPointB = Handle(AIS_Point)::DownCast(theShapeB);
2198 Handle(Geom_Plane) myGeomPlane = theAISPlane->Component();
2199 Handle(Geom_Point) myGeomPointB = theAISPointB->Component();
2200 Handle(Geom_CartesianPoint) myCartPointB =
2201 Handle(Geom_CartesianPoint)::DownCast(myGeomPointB);
2203 gp_Pln mygpPlane = myGeomPlane->Pln();
2204 gp_Ax1 thegpAxe = mygpPlane.Axis();
2205 gp_Dir theDir = thegpAxe.Direction();
2206 gp_Pnt theCenter = myCartPointB->Pnt();
2207 Standard_Real TheR = Draw::Atof(argv[4]);
2208 GC_MakeCircle Cir = GC_MakeCircle (theCenter, theDir ,TheR);
2209 Handle (Geom_Circle) theGeomCircle;
2212 theGeomCircle = Cir.Value();
2214 catch (StdFail_NotDone const&)
2216 Message::SendFail ("Error: can't create circle");
2220 DisplayCircle(theGeomCircle, aName, isFilled);
2227 Message::SendFail ("Error: 1st argument has an unexpected type");
2232 // No arguments: selection in the viewer
2233 // =========================================
2236 // Get the name of the circle
2237 TCollection_AsciiString aName(argv[1]);
2239 TopTools_ListOfShape aShapes;
2240 ViewerTest::GetSelectedShapes (aShapes);
2241 if (aShapes.Extent() != 3 && aShapes.Extent() != 2)
2243 Message::SendFail ("Error: Wrong number of selected shapes.");
2247 const TopoDS_Shape& aShapeA = aShapes.First();
2248 if (aShapeA.ShapeType() == TopAbs_VERTEX )
2250 if (aShapes.Extent() != 3)
2252 Message::SendFail ("Error: wrong number of selected shapes.");
2256 TopTools_ListOfShape::Iterator anIter (aShapes);
2259 const TopoDS_Shape& aShapeB = anIter.Value();
2262 const TopoDS_Shape& aShapeC = anIter.Value();
2265 Standard_Boolean isFilled;
2266 std::cout << "Enter filled status (0 or 1)\n";
2267 std::cin >> isFilled;
2269 // Construction of the circle
2270 gp_Pnt A = BRep_Tool::Pnt (TopoDS::Vertex (aShapeA));
2271 gp_Pnt B = BRep_Tool::Pnt (TopoDS::Vertex (aShapeB));
2272 gp_Pnt C = BRep_Tool::Pnt (TopoDS::Vertex (aShapeC));
2274 GC_MakeCircle Cir = GC_MakeCircle (A, B, C);
2275 Handle (Geom_Circle) theGeomCircle;
2278 theGeomCircle = Cir.Value();
2280 catch (StdFail_NotDone const&)
2282 Message::SendFail ("Error: can't create circle");
2286 DisplayCircle(theGeomCircle, aName, isFilled);
2289 else if (aShapeA.ShapeType() == TopAbs_FACE)
2291 const TopoDS_Shape& aShapeB = aShapes.Last();
2293 // Recover the radius
2294 Standard_Real theRad;
2297 std::cout << " Enter the value of the radius:\n";
2299 } while (theRad <= 0);
2301 // Get filled status
2302 Standard_Boolean isFilled;
2303 std::cout << "Enter filled status (0 or 1)\n";
2304 std::cin >> isFilled;
2306 // Recover the normal to the plane. tag
2307 TopoDS_Face myFace = TopoDS::Face(aShapeA);
2308 BRepAdaptor_Surface mySurface (myFace, Standard_False);
2309 gp_Pln myPlane = mySurface.Plane();
2310 Handle(Geom_Plane) theGeomPlane = new Geom_Plane (myPlane);
2311 gp_Pln mygpPlane = theGeomPlane->Pln();
2312 gp_Ax1 thegpAxe = mygpPlane.Axis();
2313 gp_Dir theDir = thegpAxe.Direction();
2315 // Recover the center
2316 gp_Pnt theCenter = BRep_Tool::Pnt (TopoDS::Vertex (aShapeB));
2318 // Construct the circle
2319 GC_MakeCircle Cir = GC_MakeCircle (theCenter, theDir ,theRad);
2320 Handle (Geom_Circle) theGeomCircle;
2323 theGeomCircle = Cir.Value();
2325 catch (StdFail_NotDone const&)
2327 Message::SendFail ("Error: can't create circle");
2331 DisplayCircle(theGeomCircle, aName, isFilled);
2335 Message::SendFail ("Error: You should select face and vertex or three vertices.");
2343 //=======================================================================
2344 //function : VDrawText
2346 //=======================================================================
2347 static int VDrawText (Draw_Interpretor& theDI,
2348 Standard_Integer theArgsNb,
2349 const char** theArgVec)
2351 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
2354 Message::SendFail ("Syntax error: wrong number of arguments. See usage:");
2355 theDI.PrintHelp (theArgVec[0]);
2358 else if (aContext.IsNull())
2360 Message::SendFail ("Error: no active viewer");
2364 Standard_Integer anArgIt = 1;
2365 TCollection_ExtendedString aName (theArgVec[anArgIt++], Standard_True);
2366 TCollection_ExtendedString aText (theArgVec[anArgIt++], Standard_True);
2367 Handle(AIS_TextLabel) aTextPrs;
2368 ViewerTest_AutoUpdater anAutoUpdater (aContext, ViewerTest::CurrentView());
2370 Standard_Boolean isNewPrs = Standard_False;
2371 if (GetMapOfAIS().IsBound2 (aName))
2373 aTextPrs = Handle(AIS_TextLabel)::DownCast (GetMapOfAIS().Find2 (aName));
2376 if (aTextPrs.IsNull())
2378 isNewPrs = Standard_True;
2379 aTextPrs = new AIS_TextLabel();
2380 aTextPrs->SetFont ("Courier");
2383 aTextPrs->SetText (aText);
2385 Handle(Graphic3d_TransformPers) aTrsfPers;
2386 Aspect_TypeOfDisplayText aDisplayType = Aspect_TODT_NORMAL;
2388 Standard_Boolean aHasPlane = Standard_False;
2393 for (; anArgIt < theArgsNb; ++anArgIt)
2395 TCollection_AsciiString aParam (theArgVec[anArgIt]);
2398 if (anAutoUpdater.parseRedrawMode (aParam))
2402 else if (aParam == "-pos"
2403 || aParam == "-position")
2405 if (anArgIt + 3 >= theArgsNb)
2407 Message::SendFail() << "Error: wrong number of values for parameter '" << aParam << "'";
2411 aPos.SetX (Draw::Atof (theArgVec[++anArgIt]));
2412 aPos.SetY (Draw::Atof (theArgVec[++anArgIt]));
2413 aPos.SetZ (Draw::Atof (theArgVec[++anArgIt]));
2414 aTextPrs->SetPosition (aPos);
2416 else if (aParam == "-color")
2418 Quantity_Color aColor;
2419 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgsNb - anArgIt - 1,
2420 theArgVec + anArgIt + 1,
2424 Message::SendFail() << "Syntax error at '" << aParam << "'";
2427 anArgIt += aNbParsed;
2428 aTextPrs->SetColor (aColor);
2430 else if (aParam == "-halign")
2432 if (++anArgIt >= theArgsNb)
2434 Message::SendFail() << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'";
2438 TCollection_AsciiString aType (theArgVec[anArgIt]);
2440 if (aType == "left")
2442 aTextPrs->SetHJustification (Graphic3d_HTA_LEFT);
2444 else if (aType == "center")
2446 aTextPrs->SetHJustification (Graphic3d_HTA_CENTER);
2448 else if (aType == "right")
2450 aTextPrs->SetHJustification (Graphic3d_HTA_RIGHT);
2454 Message::SendFail() << "Syntax error at '" << aParam << "'";
2458 else if (aParam == "-valign")
2460 if (++anArgIt >= theArgsNb)
2462 Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
2466 TCollection_AsciiString aType (theArgVec[anArgIt]);
2470 aTextPrs->SetVJustification (Graphic3d_VTA_TOP);
2472 else if (aType == "center")
2474 aTextPrs->SetVJustification (Graphic3d_VTA_CENTER);
2476 else if (aType == "bottom")
2478 aTextPrs->SetVJustification (Graphic3d_VTA_BOTTOM);
2480 else if (aType == "topfirstline")
2482 aTextPrs->SetVJustification (Graphic3d_VTA_TOPFIRSTLINE);
2486 Message::SendFail() << "Syntax error at '" << aParam << "'";
2490 else if (aParam == "-angle")
2492 if (++anArgIt >= theArgsNb)
2494 Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
2498 aTextPrs->SetAngle (Draw::Atof (theArgVec[anArgIt]) * (M_PI / 180.0));
2500 else if (aParam == "-zoom")
2502 if (++anArgIt >= theArgsNb)
2504 Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
2508 aTextPrs->SetZoomable (Draw::Atoi (theArgVec[anArgIt]) == 1);
2510 else if (aParam == "-height")
2512 if (++anArgIt >= theArgsNb)
2514 Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
2518 aTextPrs->SetHeight (Draw::Atof(theArgVec[anArgIt]));
2520 else if (aParam == "-aspect")
2522 if (++anArgIt >= theArgsNb)
2524 Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
2528 TCollection_AsciiString anOption (theArgVec[anArgIt]);
2529 anOption.LowerCase();
2530 Font_FontAspect aFontAspect = Font_FA_Undefined;
2531 if (!parseFontStyle (anOption, aFontAspect))
2533 Message::SendFail() << "Syntax error: unknown font aspect '" << anOption << "'";
2536 aTextPrs->SetFontAspect (aFontAspect);
2538 else if (aParam == "-font")
2540 if (++anArgIt >= theArgsNb)
2542 Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
2546 aTextPrs->SetFont (theArgVec[anArgIt]);
2548 else if (aParam == "-plane")
2550 if (anArgIt + 6 >= theArgsNb)
2552 Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
2556 Standard_Real aX = Draw::Atof (theArgVec[++anArgIt]);
2557 Standard_Real aY = Draw::Atof (theArgVec[++anArgIt]);
2558 Standard_Real aZ = Draw::Atof (theArgVec[++anArgIt]);
2559 aNormal.SetCoord (aX, aY, aZ);
2561 aX = Draw::Atof (theArgVec[++anArgIt]);
2562 aY = Draw::Atof (theArgVec[++anArgIt]);
2563 aZ = Draw::Atof (theArgVec[++anArgIt]);
2564 aDirection.SetCoord (aX, aY, aZ);
2566 aHasPlane = Standard_True;
2568 else if (aParam == "-flipping")
2570 aTextPrs->SetFlipping (Standard_True);
2572 else if (aParam == "-ownanchor")
2574 if (++anArgIt >= theArgsNb)
2576 std::cout << "Error: wrong number of values for parameter '" << aParam.ToCString() << "'.\n";
2579 aTextPrs->SetOwnAnchorPoint (Draw::Atoi (theArgVec[anArgIt]) == 1);
2581 else if (aParam == "-disptype"
2582 || aParam == "-displaytype")
2584 if (++anArgIt >= theArgsNb)
2586 Message::SendFail() << "Syntax error: wrong number of values for parameter '" << aParam << "'";
2589 TCollection_AsciiString aType (theArgVec[anArgIt]);
2591 if (aType == "subtitle")
2592 aDisplayType = Aspect_TODT_SUBTITLE;
2593 else if (aType == "decal")
2594 aDisplayType = Aspect_TODT_DEKALE;
2595 else if (aType == "blend")
2596 aDisplayType = Aspect_TODT_BLEND;
2597 else if (aType == "dimension")
2598 aDisplayType = Aspect_TODT_DIMENSION;
2599 else if (aType == "normal")
2600 aDisplayType = Aspect_TODT_NORMAL;
2601 else if (aType == "shadow")
2602 aDisplayType = Aspect_TODT_SHADOW;
2605 Message::SendFail() << "Syntax error: wrong display type '" << aType << "'";
2609 else if (aParam == "-subcolor"
2610 || aParam == "-subtitlecolor")
2612 Quantity_Color aColor;
2613 Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgsNb - anArgIt - 1,
2614 theArgVec + anArgIt + 1,
2618 Message::SendFail() << "Syntax error at '" << aParam << "'";
2621 anArgIt += aNbParsed;
2622 aTextPrs->SetColorSubTitle (aColor);
2624 else if (aParam == "-2d")
2626 aTrsfPers = new Graphic3d_TransformPers (Graphic3d_TMF_2d);
2628 else if (aParam == "-trsfperspos"
2629 || aParam == "-perspos")
2631 if (anArgIt + 2 >= theArgsNb)
2633 Message::SendFail() << "Error: wrong number of values for parameter '" << aParam << "'.";
2637 TCollection_AsciiString aX (theArgVec[++anArgIt]);
2638 TCollection_AsciiString aY (theArgVec[++anArgIt]);
2639 TCollection_AsciiString aZ = "0";
2640 if (!aX.IsIntegerValue()
2641 || !aY.IsIntegerValue())
2643 Message::SendFail() << "Error: wrong syntax at '" << aParam << "'.";
2646 if (anArgIt + 1 < theArgsNb)
2648 TCollection_AsciiString aTemp = theArgVec[anArgIt + 1];
2649 if (aTemp.IsIntegerValue())
2656 aTrsfPers = Graphic3d_TransformPers::FromDeprecatedParams (Graphic3d_TMF_2d, gp_Pnt (aX.IntegerValue(), aY.IntegerValue(), aZ.IntegerValue()));
2660 Message::SendFail() << "Syntax error: unknown argument '" << aParam << "'";
2667 aTextPrs->SetOrientation3D (gp_Ax2 (aPos, aNormal, aDirection));
2670 aTextPrs->SetDisplayType (aDisplayType);
2672 if (!aTrsfPers.IsNull())
2674 aContext->SetTransformPersistence (aTextPrs, aTrsfPers);
2675 aTextPrs->SetZLayer(Graphic3d_ZLayerId_TopOSD);
2676 if (aTextPrs->Position().Z() != 0)
2678 aTextPrs->SetPosition (gp_Pnt(aTextPrs->Position().X(), aTextPrs->Position().Y(), 0));
2681 else if (!aTextPrs->TransformPersistence().IsNull())
2683 aContext->SetTransformPersistence (aTextPrs, Handle(Graphic3d_TransformPers)());
2688 ViewerTest::Display (aName, aTextPrs, Standard_False);
2692 aContext->Redisplay (aTextPrs, Standard_False, Standard_True);
2698 #include <gp_Pnt.hxx>
2699 #include <Graphic3d_ArrayOfPoints.hxx>
2700 #include <Graphic3d_ArrayOfPrimitives.hxx>
2701 #include <Graphic3d_ArrayOfTriangles.hxx>
2702 #include <Poly_Array1OfTriangle.hxx>
2703 #include <Poly_Triangle.hxx>
2704 #include <Poly_Triangulation.hxx>
2705 #include <TColgp_Array1OfPnt.hxx>
2706 #include <TShort_Array1OfShortReal.hxx>
2707 #include <TShort_HArray1OfShortReal.hxx>
2709 #include <AIS_Triangulation.hxx>
2710 #include <StdPrs_ToolTriangulatedShape.hxx>
2711 #include <Poly_Connect.hxx>
2712 #include <TColgp_Array1OfDir.hxx>
2713 #include <Graphic3d_GraphicDriver.hxx>
2715 #include <TColStd_Array1OfInteger.hxx>
2716 #include <TColStd_HArray1OfInteger.hxx>
2717 #include <Prs3d_ShadingAspect.hxx>
2718 #include <Graphic3d_MaterialAspect.hxx>
2719 #include <Graphic3d_AspectFillArea3d.hxx>
2721 #include <BRepPrimAPI_MakeCylinder.hxx>
2722 #include <TopoDS_Shape.hxx>
2723 #include <TopExp_Explorer.hxx>
2724 #include <TopAbs.hxx>
2725 #include <AIS_InteractiveObject.hxx>
2728 //===============================================================================================
2729 //function : CalculationOfSphere
2731 //purpose : Create a Sphere
2732 //===============================================================================================
2734 Handle( Poly_Triangulation ) CalculationOfSphere( double X , double Y , double Z ,
2737 double mRadius = Radius;
2738 double mCenter[3] = {X,Y,Z};
2739 int mThetaResolution;
2741 double mStartTheta = 0;//StartTheta;
2742 double mEndTheta = 360;//EndTheta;
2743 double mStartPhi = 0;//StartPhi;
2744 double mEndPhi = 180;//EndPhi;
2745 res = res < 4 ? 4 : res;
2747 mThetaResolution = res;
2748 mPhiResolution = res;
2751 int jStart, jEnd, numOffset;
2752 double x[3], n[3], deltaPhi, deltaTheta, phi, theta, radius;
2753 double startTheta, endTheta, startPhi, endPhi;
2754 int base, numPoles=0, thetaResolution, phiResolution;
2759 if ( numPieces > mThetaResolution ) {
2760 numPieces = mThetaResolution;
2763 int localThetaResolution = mThetaResolution;
2764 double localStartTheta = mStartTheta;
2765 double localEndTheta = mEndTheta;
2767 while ( localEndTheta < localStartTheta ) {
2768 localEndTheta += 360.0;
2771 deltaTheta = (localEndTheta - localStartTheta) / localThetaResolution;
2773 // Change the ivars based on pieces.
2775 start = piece * localThetaResolution / numPieces;
2776 end = (piece+1) * localThetaResolution / numPieces;
2777 localEndTheta = localStartTheta + (double)(end) * deltaTheta;
2778 localStartTheta = localStartTheta + (double)(start) * deltaTheta;
2779 localThetaResolution = end - start;
2781 // Create north pole if needed
2782 int number_point = 0;
2783 int number_pointArray = 0;
2785 if ( mStartPhi <= 0.0 ) {
2786 number_pointArray++;
2789 if ( mEndPhi >= 180.0 ) {
2790 number_pointArray++;
2794 // Check data, determine increments, and convert to radians
2795 startTheta = (localStartTheta < localEndTheta ? localStartTheta : localEndTheta);
2796 startTheta *= M_PI / 180.0;
2797 endTheta = (localEndTheta > localStartTheta ? localEndTheta : localStartTheta);
2798 endTheta *= M_PI / 180.0;
2801 startPhi = ( mStartPhi < mEndPhi ? mStartPhi : mEndPhi);
2802 startPhi *= M_PI / 180.0;
2803 endPhi = ( mEndPhi > mStartPhi ? mEndPhi : mStartPhi);
2804 endPhi *= M_PI / 180.0;
2806 phiResolution = mPhiResolution - numPoles;
2807 deltaPhi = (endPhi - startPhi) / ( mPhiResolution - 1);
2808 thetaResolution = localThetaResolution;
2809 if ( fabs(localStartTheta - localEndTheta) < 360.0 ) {
2810 ++localThetaResolution;
2812 deltaTheta = (endTheta - startTheta) / thetaResolution;
2814 jStart = ( mStartPhi <= 0.0 ? 1 : 0);
2815 jEnd = ( mEndPhi >= 180.0 ? mPhiResolution - 1 : mPhiResolution);
2817 // Create intermediate points
2818 for ( i = 0; i < localThetaResolution; i++ ) {
2819 for ( j = jStart; j < jEnd; j++ ) {
2820 number_pointArray++;
2824 //Generate mesh connectivity
2825 base = phiResolution * localThetaResolution;
2827 int number_triangle = 0 ;
2828 if ( mStartPhi <= 0.0 ) { // around north pole
2829 number_triangle += localThetaResolution;
2832 if ( mEndPhi >= 180.0 ) { // around south pole
2833 number_triangle += localThetaResolution;
2836 // bands in-between poles
2837 for ( i=0; i < localThetaResolution; i++){
2838 for ( j=0; j < (phiResolution-1); j++){
2839 number_triangle +=2;
2843 Handle( Poly_Triangulation ) polyTriangulation = new Poly_Triangulation(number_pointArray, number_triangle, false);
2844 TColgp_Array1OfPnt& PointsOfArray = polyTriangulation->ChangeNodes();
2845 Poly_Array1OfTriangle& pArrayTriangle = polyTriangulation->ChangeTriangles();
2847 if ( mStartPhi <= 0.0 ){
2850 x[2] = mCenter[2] + mRadius;
2851 PointsOfArray.SetValue(1,gp_Pnt(x[0],x[1],x[2]));
2854 // Create south pole if needed
2855 if ( mEndPhi >= 180.0 ){
2858 x[2] = mCenter[2] - mRadius;
2859 PointsOfArray.SetValue(2,gp_Pnt(x[0],x[1],x[2]));
2863 for ( i=0; i < localThetaResolution; i++){
2864 theta = localStartTheta * M_PI / 180.0 + i*deltaTheta;
2865 for ( j = jStart; j < jEnd; j++){
2866 phi = startPhi + j*deltaPhi;
2867 radius = mRadius * sin((double)phi);
2868 n[0] = radius * cos((double)theta);
2869 n[1] = radius * sin((double)theta);
2870 n[2] = mRadius * cos((double)phi);
2871 x[0] = n[0] + mCenter[0];
2872 x[1] = n[1] + mCenter[1];
2873 x[2] = n[2] + mCenter[2];
2874 PointsOfArray.SetValue(number_point,gp_Pnt(x[0],x[1],x[2]));
2880 number_triangle = 1;
2881 if ( mStartPhi <= 0.0 ){// around north pole
2882 for (i=0; i < localThetaResolution; i++){
2883 pts[0] = phiResolution*i + numPoles;
2884 pts[1] = (phiResolution*(i+1) % base) + numPoles;
2886 pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
2891 if ( mEndPhi >= 180.0 ){ // around south pole
2892 numOffset = phiResolution - 1 + numPoles;
2893 for (i=0; i < localThetaResolution; i++){
2894 pts[0] = phiResolution*i + numOffset;
2895 pts[2] = ((phiResolution*(i+1)) % base) + numOffset;
2896 pts[1] = numPoles - 1;
2897 pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
2902 // bands in-between poles
2904 for (i=0; i < localThetaResolution; i++){
2905 for (j=0; j < (phiResolution-1); j++){
2906 pts[0] = phiResolution*i + j + numPoles;
2907 pts[1] = pts[0] + 1;
2908 pts[2] = ((phiResolution*(i+1)+j) % base) + numPoles + 1;
2909 pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
2912 pts[2] = pts[1] - 1;
2913 pArrayTriangle.SetValue(number_triangle,Poly_Triangle(pts[0],pts[1],pts[2]));
2918 Poly_Connect* pc = new Poly_Connect(polyTriangulation);
2920 Handle(TShort_HArray1OfShortReal) Normals = new TShort_HArray1OfShortReal(1, polyTriangulation->NbNodes() * 3);
2922 Standard_Integer index[3];
2923 Standard_Real Tol = Precision::Confusion();
2926 for (i = PointsOfArray.Lower(); i <= PointsOfArray.Upper(); i++) {
2927 gp_XYZ eqPlan(0, 0, 0);
2928 for ( pc->Initialize(i); pc->More(); pc->Next()) {
2929 pArrayTriangle(pc->Value()).Get(index[0], index[1], index[2]);
2930 gp_XYZ v1(PointsOfArray(index[1]).Coord()-PointsOfArray(index[0]).Coord());
2931 gp_XYZ v2(PointsOfArray(index[2]).Coord()-PointsOfArray(index[1]).Coord());
2933 Standard_Real mod = vv.Modulus();
2934 if(mod < Tol) continue;
2938 Standard_Real modmax = eqPlan.Modulus();
2941 Nor = gp_Dir(eqPlan);
2943 Nor = gp_Dir(0., 0., 1.);
2945 Standard_Integer k = (i - PointsOfArray.Lower()) * 3;
2946 Normals->SetValue(k + 1, (Standard_ShortReal)Nor.X());
2947 Normals->SetValue(k + 2, (Standard_ShortReal)Nor.Y());
2948 Normals->SetValue(k + 3, (Standard_ShortReal)Nor.Z());
2952 polyTriangulation->SetNormals(Normals);
2954 return polyTriangulation;
2957 //===============================================================================================
2958 //function : VDrawSphere
2960 //purpose : Create an AIS shape.
2961 //===============================================================================================
2962 static int VDrawSphere (Draw_Interpretor& /*di*/, Standard_Integer argc, const char** argv)
2965 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
2966 if (aContextAIS.IsNull())
2968 Message::SendFail ("Error: no active viewer");
2973 Message::SendFail() << "Syntax error: wrong number of arguments.\n"
2974 << "Use: " << argv[0] << " shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToShowEdges=0]";
2978 // read the arguments
2979 TCollection_AsciiString aShapeName (argv[1]);
2980 Standard_Integer aResolution = Draw::Atoi (argv[2]);
2981 Standard_Real aCenterX = (argc > 5) ? Draw::Atof (argv[3]) : 0.0;
2982 Standard_Real aCenterY = (argc > 5) ? Draw::Atof (argv[4]) : 0.0;
2983 Standard_Real aCenterZ = (argc > 5) ? Draw::Atof (argv[5]) : 0.0;
2984 Standard_Real aRadius = (argc > 6) ? Draw::Atof (argv[6]) : 100.0;
2985 Standard_Boolean toShowEdges = (argc > 7) ? Draw::Atoi (argv[7]) == 1 : Standard_False;
2986 Standard_Boolean toPrintInfo = (argc > 8) ? Draw::Atoi (argv[8]) == 1 : Standard_True;
2988 // remove AIS object with given name from map
2989 VDisplayAISObject (aShapeName, Handle(AIS_InteractiveObject)());
2992 std::cout << "Compute Triangulation...\n";
2993 Handle(AIS_Triangulation) aShape
2994 = new AIS_Triangulation (CalculationOfSphere (aCenterX, aCenterY, aCenterZ,
2997 Standard_Integer aNumberPoints = aShape->GetTriangulation()->Nodes().Length();
2998 Standard_Integer aNumberTriangles = aShape->GetTriangulation()->Triangles().Length();
3000 // stupid initialization of Green color in RGBA space as integer
3001 // probably wrong for big-endian CPUs
3002 const Graphic3d_Vec4ub aColor (0, 255, 0, 0);
3004 // setup colors array per vertex
3005 Handle(TColStd_HArray1OfInteger) aColorArray = new TColStd_HArray1OfInteger (1, aNumberPoints);
3006 for (Standard_Integer aNodeId = 1; aNodeId <= aNumberPoints; ++aNodeId)
3008 aColorArray->SetValue (aNodeId, *reinterpret_cast<const Standard_Integer*> (aColor.GetData()));
3010 aShape->SetColors (aColorArray);
3013 Standard_Integer aPointsSize = aNumberPoints * 3 * sizeof(float); // 3x GLfloat
3014 Standard_Integer aNormalsSize = aNumberPoints * 3 * sizeof(float); // 3x GLfloat
3015 Standard_Integer aColorsSize = aNumberPoints * 3 * sizeof(float); // 3x GLfloat without alpha
3016 Standard_Integer aTrianglesSize = aNumberTriangles * 3 * sizeof(int); // 3x GLint
3017 Standard_Integer aPolyConnectSize = aNumberPoints * 4 + aNumberTriangles * 6 * 4;
3018 Standard_Integer aTotalSize = aPointsSize + aNormalsSize + aColorsSize + aTrianglesSize;
3019 aTotalSize >>= 20; //MB
3020 aNormalsSize >>= 20;
3022 aTrianglesSize >>= 20;
3023 aPolyConnectSize >>= 20;
3026 std::cout << "NumberOfPoints: " << aNumberPoints << "\n"
3027 << "NumberOfTriangles: " << aNumberTriangles << "\n"
3028 << "Amount of memory required for PolyTriangulation without Normals: " << (aTotalSize - aNormalsSize) << " Mb\n"
3029 << "Amount of memory for colors: " << aColorsSize << " Mb\n"
3030 << "Amount of memory for PolyConnect: " << aPolyConnectSize << " Mb\n"
3031 << "Amount of graphic card memory required: " << aTotalSize << " Mb\n";
3034 // Setting material properties, very important for desirable visual result!
3035 Graphic3d_MaterialAspect aMat (Graphic3d_NOM_PLASTIC);
3036 aMat.SetAmbientColor (Quantity_Color (Graphic3d_Vec3 (0.04f)));
3037 aMat.SetSpecularColor(Quantity_Color (Graphic3d_Vec3 (0.50f)));
3038 Handle(Graphic3d_AspectFillArea3d) anAspect
3039 = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID,
3041 Quantity_NOC_YELLOW,
3046 Handle(Prs3d_ShadingAspect) aShAsp = new Prs3d_ShadingAspect();
3047 anAspect->SetDrawEdges (toShowEdges);
3048 aShAsp->SetAspect (anAspect);
3049 aShape->Attributes()->SetShadingAspect (aShAsp);
3051 VDisplayAISObject (aShapeName, aShape);
3055 //=============================================================================
3056 //function : VComputeHLR
3058 //=============================================================================
3060 static int VComputeHLR (Draw_Interpretor& ,
3061 Standard_Integer theArgNb,
3062 const char** theArgVec)
3064 TCollection_AsciiString aShapeName, aHlrName;
3069 bool hasViewDirArg = false;
3070 Prs3d_TypeOfHLR anAlgoType = Prs3d_TOH_PolyAlgo;
3071 bool toShowCNEdges = false, toShowHiddenEdges = false;
3072 int aNbIsolines = 0;
3073 if (Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext())
3076 Handle(V3d_View) aView = ViewerTest::CurrentView();
3077 Standard_Integer aWidth, aHeight;
3078 Standard_Real aCentX, aCentY, aCentZ, aDirX, aDirY, aDirZ;
3079 Standard_Real aRightX, aRightY, aRightZ;
3080 aView->Window()->Size (aWidth, aHeight);
3082 aView->ConvertWithProj (aWidth, aHeight/2,
3083 aRightX, aRightY, aRightZ,
3084 aDirX, aDirY, aDirZ);
3085 aView->ConvertWithProj (aWidth/2, aHeight/2,
3086 aCentX, aCentY, aCentZ,
3087 aDirX, aDirY, aDirZ);
3089 anEye.SetCoord (-aCentX, -aCentY, -aCentZ);
3090 aDir.SetCoord (-aDirX, -aDirY, -aDirZ);
3091 aRight.SetCoord (aRightX - aCentX, aRightY - aCentY, aRightZ - aCentZ);
3092 aProjAx.SetLocation (anEye);
3093 aProjAx.SetDirection (aDir);
3094 aProjAx.SetXDirection (aRight);
3096 for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
3098 TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
3099 anArgCase.LowerCase();
3100 if (anArgIter + 1 < theArgNb
3101 && (anArgCase == "-algotype"
3102 || anArgCase == "-algo"
3103 || anArgCase == "-type"))
3105 TCollection_AsciiString anArgNext (theArgVec[++anArgIter]);
3106 anArgNext.LowerCase();
3107 if (anArgNext == "polyalgo")
3109 anAlgoType = Prs3d_TOH_PolyAlgo;
3111 else if (anArgNext == "algo")
3113 anAlgoType = Prs3d_TOH_Algo;
3117 Message::SendFail() << "Syntax error: unknown algo type '" << anArgNext << "'";
3121 else if (anArgCase == "-showhiddenedges"
3122 || anArgCase == "-hiddenedges"
3123 || anArgCase == "-hidden")
3125 toShowHiddenEdges = true;
3126 if (anArgIter + 1 < theArgNb
3127 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toShowHiddenEdges))
3132 else if (anArgCase == "-showtangentedges"
3133 || anArgCase == "-tangentedges"
3134 || anArgCase == "-tangent")
3136 toShowCNEdges = true;
3137 if (anArgIter + 1 < theArgNb
3138 && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toShowCNEdges))
3143 else if (anArgIter + 1 < theArgNb
3144 && (anArgCase == "-nbiso"
3145 || anArgCase == "-nbisolines"))
3147 aNbIsolines = Draw::Atoi (theArgVec[++anArgIter]);
3149 else if (aSh.IsNull())
3151 aSh = DBRep::Get (theArgVec[anArgIter]);
3152 aShapeName = theArgVec[anArgIter];
3155 BRep_Builder aBrepBuilder;
3156 BRepTools::Read (aSh, theArgVec[anArgIter], aBrepBuilder);
3159 Message::SendFail() << "Syntax error: no shape with name " << theArgVec[anArgIter] << " found";
3164 else if (aHlrName.IsEmpty())
3166 aHlrName = theArgVec[anArgIter];
3168 else if (!hasViewDirArg
3169 && anArgIter + 8 < theArgNb)
3171 hasViewDirArg = true;
3173 anEye.SetCoord (Draw::Atof (theArgVec[anArgIter + 0]), Draw::Atof (theArgVec[anArgIter + 1]), Draw::Atof (theArgVec[anArgIter + 2]));
3174 aDir .SetCoord (Draw::Atof (theArgVec[anArgIter + 3]), Draw::Atof (theArgVec[anArgIter + 4]), Draw::Atof (theArgVec[anArgIter + 5]));
3175 anUp .SetCoord (Draw::Atof (theArgVec[anArgIter + 6]), Draw::Atof (theArgVec[anArgIter + 7]), Draw::Atof (theArgVec[anArgIter + 8]));
3176 aProjAx.SetLocation (anEye);
3177 aProjAx.SetDirection (aDir);
3178 aProjAx.SetYDirection (anUp);
3183 Message::SendFail() << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'";
3188 if (aHlrName.IsEmpty() || aSh.IsNull()
3189 || (ViewerTest::GetAISContext().IsNull() && hasViewDirArg))
3191 Message::SendFail ("Syntax error: wrong number of arguments");
3195 HLRAlgo_Projector aProjector (aProjAx);
3196 TopoDS_Shape aVisible[6];
3197 TopoDS_Shape aHidden[6];
3198 if (anAlgoType == Prs3d_TOH_PolyAlgo)
3200 Handle(HLRBRep_PolyAlgo) aPolyAlgo = new HLRBRep_PolyAlgo();
3201 aPolyAlgo->Projector (aProjector);
3202 aPolyAlgo->Load (aSh);
3203 aPolyAlgo->Update();
3205 HLRBRep_PolyHLRToShape aHLRToShape;
3206 aHLRToShape.Update (aPolyAlgo);
3208 aVisible[HLRBRep_Sharp] = aHLRToShape.VCompound();
3209 aVisible[HLRBRep_OutLine] = aHLRToShape.OutLineVCompound(); // extract visible outlines
3210 aVisible[HLRBRep_Rg1Line] = aHLRToShape.Rg1LineVCompound();
3213 aVisible[HLRBRep_RgNLine] = aHLRToShape.RgNLineVCompound();
3215 if (toShowHiddenEdges)
3217 aHidden[HLRBRep_Sharp] = aHLRToShape.HCompound();
3218 aHidden[HLRBRep_OutLine] = aHLRToShape.OutLineHCompound();
3219 aHidden[HLRBRep_Rg1Line] = aHLRToShape.Rg1LineHCompound();
3222 aHidden[HLRBRep_RgNLine] = aHLRToShape.RgNLineHCompound();
3228 Handle(HLRBRep_Algo) aHlrAlgo = new HLRBRep_Algo();
3229 aHlrAlgo->Add (aSh, aNbIsolines);
3230 aHlrAlgo->Projector (aProjector);
3234 HLRBRep_HLRToShape aHLRToShape (aHlrAlgo);
3235 aVisible[HLRBRep_Sharp] = aHLRToShape.VCompound();
3236 aVisible[HLRBRep_OutLine] = aHLRToShape.OutLineVCompound();
3237 aVisible[HLRBRep_Rg1Line] = aHLRToShape.Rg1LineVCompound();
3240 aVisible[HLRBRep_RgNLine] = aHLRToShape.RgNLineVCompound();
3242 aVisible[HLRBRep_IsoLine] = aHLRToShape.IsoLineVCompound();
3244 if (toShowHiddenEdges)
3246 aHidden[HLRBRep_Sharp] = aHLRToShape.HCompound();
3247 aHidden[HLRBRep_OutLine] = aHLRToShape.OutLineHCompound();
3248 aHidden[HLRBRep_Rg1Line] = aHLRToShape.Rg1LineHCompound();
3251 aHidden[HLRBRep_RgNLine] = aHLRToShape.RgNLineHCompound();
3253 aHidden[HLRBRep_IsoLine] = aHLRToShape.IsoLineHCompound();
3256 //aVisible[HLRBRep_Sharp] = aHLRToShape.CompoundOfEdges (HLRBRep_Sharp, Standard_True, Standard_True);
3257 //aVisible[HLRBRep_OutLine] = aHLRToShape.OutLineVCompound3d();
3260 TopoDS_Compound aCompRes, aCompVis, aCompHid;
3261 BRep_Builder aBuilder;
3262 aBuilder.MakeCompound (aCompVis);
3263 aBuilder.MakeCompound (aCompHid);
3264 aBuilder.MakeCompound (aCompRes);
3265 for (int aTypeIter = 0; aTypeIter < 6; ++aTypeIter)
3267 if (!aVisible[aTypeIter].IsNull())
3269 aBuilder.Add (aCompVis, aVisible[aTypeIter]);
3271 if (!aHidden[aTypeIter].IsNull())
3273 aBuilder.Add (aCompHid, aHidden[aTypeIter]);
3276 aBuilder.Add (aCompRes, aCompVis);
3277 aBuilder.Add (aCompRes, aCompHid);
3279 // create an AIS shape and display it
3280 if (!ViewerTest::GetAISContext().IsNull())
3282 Handle(AIS_ColoredShape) anObject = new AIS_ColoredShape (aCompRes);
3283 if (toShowHiddenEdges)
3285 Handle(Prs3d_LineAspect) aLineAspect = new Prs3d_LineAspect (Quantity_Color (Quantity_NOC_RED), Aspect_TOL_DASH, 1.0f);
3286 for (int aTypeIter = 0; aTypeIter < 6; ++aTypeIter)
3288 if (!aHidden[aTypeIter].IsNull())
3290 Handle(AIS_ColoredDrawer) aDrawer = anObject->CustomAspects (aHidden[aTypeIter]);
3291 aDrawer->SetLineAspect (aLineAspect);
3292 aDrawer->SetWireAspect (aLineAspect);
3293 aDrawer->SetFreeBoundaryAspect (aLineAspect);
3294 aDrawer->SetUnFreeBoundaryAspect (aLineAspect);
3298 ViewerTest::Display (aHlrName, anObject, true);
3301 DBRep::Set (aHlrName.ToCString(), aCompRes);
3305 // This class is a wrap for Graphic3d_ArrayOfPrimitives; it is used for
3306 // manipulating and displaying such an array with AIS context
3308 class MyPArrayObject : public AIS_InteractiveObject
3313 MyPArrayObject (const Handle(Graphic3d_ArrayOfPrimitives)& thePArray) : myPArray (thePArray) {}
3315 MyPArrayObject (Graphic3d_TypeOfPrimitiveArray thePrimType,
3316 const Handle(TColStd_HArray1OfAsciiString)& theDesc,
3317 const Handle(Graphic3d_AspectMarker3d)& theMarkerAspect)
3319 Init (thePrimType, theDesc, theMarkerAspect, Standard_False);
3322 //! Initialize the array from specified description.
3323 Standard_Boolean Init (Graphic3d_TypeOfPrimitiveArray thePrimType,
3324 const Handle(TColStd_HArray1OfAsciiString)& theDesc,
3325 const Handle(Graphic3d_AspectMarker3d)& theMarkerAspect,
3326 Standard_Boolean theToPatch);
3328 DEFINE_STANDARD_RTTI_INLINE(MyPArrayObject,AIS_InteractiveObject);
3330 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
3332 //! Sets color to this interactive object
3333 //! @param theColor the color to be set
3334 virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
3338 void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
3339 const Handle(Prs3d_Presentation)& aPresentation,
3340 const Standard_Integer aMode) Standard_OVERRIDE;
3342 void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
3343 const Standard_Integer /*theMode*/) Standard_OVERRIDE;
3345 bool CheckInputCommand (const TCollection_AsciiString theCommand,
3346 const Handle(TColStd_HArray1OfAsciiString)& theArgsArray,
3347 Standard_Integer &theArgIndex,
3348 Standard_Integer theArgCount,
3349 Standard_Integer theMaxArgs);
3351 //! Sets color for the shading aspect of the drawer used in this interactive object
3352 //! @param theColor the color to be set
3353 void setColorForShadingAspect(const Quantity_Color& theColor);
3355 //! Replaces shading aspect from myDrawer->Link() with the own shading aspect of myDrawer for this interactive object
3356 void replaceShadingAspect();
3360 Handle(Graphic3d_AspectMarker3d) myMarkerAspect;
3361 Handle(Graphic3d_ArrayOfPrimitives) myPArray;
3365 void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
3366 const Handle(Prs3d_Presentation)& thePrs,
3367 const Standard_Integer theMode)
3369 if (myPArray.IsNull() || theMode != 0)
3374 Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
3375 if (!myMarkerAspect.IsNull())
3377 aGroup->SetGroupPrimitivesAspect (myMarkerAspect);
3381 aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
3383 aGroup->AddPrimitiveArray (myPArray);
3386 Standard_Boolean MyPArrayObject::Init (Graphic3d_TypeOfPrimitiveArray thePrimType,
3387 const Handle(TColStd_HArray1OfAsciiString)& theDesc,
3388 const Handle(Graphic3d_AspectMarker3d)& theMarkerAspect,
3389 Standard_Boolean theToPatch)
3391 myMarkerAspect = theMarkerAspect;
3397 // Parsing array description
3398 Standard_Integer aVertexNum = 0, aBoundNum = 0, aEdgeNum = 0;
3399 Graphic3d_ArrayFlags anArrayFlags = Graphic3d_ArrayFlags_None;
3401 const Standard_Integer anArgsCount = theDesc->Length();
3402 TCollection_AsciiString aCommand;
3403 for (Standard_Integer anArgIndex = theDesc->Lower(); anArgIndex <= theDesc->Upper(); )
3405 aCommand = theDesc->Value (anArgIndex);
3406 aCommand.LowerCase();
3408 if (CheckInputCommand ("-deinterleaved", theDesc, anArgIndex, 0, anArgsCount))
3410 anArrayFlags |= Graphic3d_ArrayFlags_AttribsDeinterleaved;
3412 else if (CheckInputCommand ("-mutable", theDesc, anArgIndex, 0, anArgsCount))
3414 anArrayFlags |= Graphic3d_ArrayFlags_AttribsMutable;