1 // Created on: 1998-11-12
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <ViewerTest.hxx>
28 #include <AIS_AngleDimension.hxx>
29 #include <AIS_Circle.hxx>
30 #include <AIS_DiameterDimension.hxx>
31 #include <AIS_DisplayMode.hxx>
32 #include <AIS_InteractiveContext.hxx>
33 #include <AIS_LengthDimension.hxx>
34 #include <AIS_ListIteratorOfListOfInteractive.hxx>
35 #include <AIS_ListOfInteractive.hxx>
36 #include <AIS_MapOfInteractive.hxx>
37 #include <AIS_Point.hxx>
38 #include <AIS_RadiusDimension.hxx>
39 #include <AIS_Relation.hxx>
40 #include <AIS_Shape.hxx>
41 #include <BRepAdaptor_Curve.hxx>
42 #include <BRep_Builder.hxx>
43 #include <BRep_Tool.hxx>
44 #include <BRepTools.hxx>
45 #include <Draw_Interpretor.hxx>
47 #include <Draw_Appli.hxx>
48 #include <Draw_Window.hxx>
51 #include <GC_MakePlane.hxx>
52 #include <Geom_CartesianPoint.hxx>
53 #include <Geom_Circle.hxx>
54 #include <Geom_Plane.hxx>
55 #include <gp_Circ.hxx>
57 #include <IntAna_IntConicQuad.hxx>
58 #include <IntAna_Quadric.hxx>
59 #include <Precision.hxx>
60 #include <Select3D_Projector.hxx>
61 #include <StdSelect.hxx>
63 #include <TCollection_AsciiString.hxx>
64 #include <TCollection_ExtendedString.hxx>
65 #include <TColStd_MapOfInteger.hxx>
67 #include <TopAbs_ShapeEnum.hxx>
70 #include <TopoDS_Face.hxx>
71 #include <TopoDS_Solid.hxx>
72 #include <TopoDS_Vertex.hxx>
73 #include <V3d_Viewer.hxx>
74 #include <V3d_View.hxx>
76 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
77 #include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
78 #include <ViewerTest_EventManager.hxx>
80 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
81 extern int ViewerMainLoop(Standard_Integer argc, const char** argv);
82 extern Handle(AIS_InteractiveContext)& TheAISContext ();
88 #define VertexMask 0x01
92 static Standard_Boolean ComputeIntersection(const gp_Lin& L,const gp_Pln& ThePl, gp_Pnt& TheInter)
94 static IntAna_Quadric TheQuad;
95 TheQuad.SetQuadric(ThePl);
96 static IntAna_IntConicQuad QQ;
97 QQ.Perform(L,TheQuad);
100 TheInter = QQ.Point(1);
101 return Standard_True;
104 return Standard_False;
107 //=======================================================================
108 //function : Get3DPointAtMousePosition
109 //purpose : calcul du point 3D correspondant a la position souris dans le plan de
111 //=======================================================================
113 static gp_Pnt Get3DPointAtMousePosition ()
115 Handle(V3d_View) aview = ViewerTest::CurrentView();
116 static Select3D_Projector prj;
119 // le plan de la vue...
120 Standard_Real xv,yv,zv;
121 aview->Proj(xv,yv,zv);
122 Standard_Real xat,yat,zat;
123 aview->At(xat,yat,zat);
124 gp_Pln ThePl(gp_Pnt(xat,yat,zat),gp_Dir(xv,yv,zv));
125 Standard_Integer xpix,ypix;
127 ViewerTest::GetMousePosition(xpix,ypix);
128 aview->Convert(xpix,ypix,x,y); // espace reel 2D de la vue...
129 gp_Lin L = prj.Shoot(x,y);
132 ComputeIntersection(L,ThePl,P);
136 //=======================================================================
137 //function : ComputeNewPlaneForDim
139 //=======================================================================
141 static void ComputeNewPlaneForDim (const Handle(AIS_Relation)& R,
154 TopoDS_Shape S1 = R->FirstShape();
155 TopoDS_Shape S2 = R->SecondShape();
156 TopAbs_ShapeEnum Typ1 = S1.ShapeType();
157 TopAbs_ShapeEnum Typ2 = S2.ShapeType();
160 thepoint[0] = Get3DPointAtMousePosition();
162 // on met l'objet le plus petit en 1...
163 if((Standard_Integer)Typ2>(Standard_Integer)Typ1){
165 TopoDS_Shape tmpS = S1;
166 TopAbs_ShapeEnum tmpT = Typ1;
175 thepoint[0] = BRep_Tool::Pnt(S1);
176 if(Typ2==TopAbs_VERTEX)
177 thepoint[1] = BRep_Tool::Pnt(S2);
178 else if(Typ2==TopAbs_EDGE){
180 TopExp::Vertices(S2,Va,Vb);
181 thepoint[1] = BRep_Tool::Pnt(Va);
183 else if(Typ2==TopAbs_FACE){
192 //=======================================================================
193 //function : VDimBuilder
194 //purpose : Command for building dimension presentations: angle,
195 // length, radius, diameter
196 //=======================================================================
197 static int VDimBuilder(Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgs)
201 std::cerr << theArgs[0] << ": command argument is required. Type help for more information.\n";
206 TCollection_AsciiString aDimType(theArgs[1]);
207 AIS_KindOfDimension aKindOfDimension;
208 if (aDimType == "length")
210 aKindOfDimension = AIS_KOD_LENGTH;
212 else if (aDimType == "angle")
214 aKindOfDimension = AIS_KOD_PLANEANGLE;
216 else if (aDimType == "radius")
218 aKindOfDimension = AIS_KOD_RADIUS;
220 else if (aDimType == "diameter" || aDimType == "diam")
222 aKindOfDimension = AIS_KOD_DIAMETER;
226 std::cerr << theArgs[0] << ": wrong type of dimension. Type help for more information.\n";
229 NCollection_List<Handle(AIS_InteractiveObject)> aShapes;
230 Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect;
231 Standard_Boolean isPlaneCustom = Standard_False;
232 TCollection_AsciiString aName;
233 gp_Pln aWorkingPlane;
234 Standard_Boolean isCustomFlyout = Standard_False;
235 Standard_Real aCustomFlyout = 0.0;
237 for (Standard_Integer anIt = 2; anIt < theArgsNb; ++anIt)
239 TCollection_AsciiString anArgString = theArgs[anIt];
240 TCollection_AsciiString aParamName;
241 TCollection_AsciiString aParamValue;
242 if (ViewerTest::SplitParameter (anArgString, aParamName, aParamValue))
244 aParamName.LowerCase();
245 aParamValue.LowerCase();
247 if (aParamName == "text")
249 anAspect->MakeText3d (aParamValue == "3d");
251 else if (aParamName == "name")
253 if (aParamValue.IsEmpty())
255 std::cerr << theArgs[0] << ": no name for dimension.\n";
261 else if (aParamName == "plane")
263 if (aParamValue == "xoy")
265 aWorkingPlane = gp_Pln (gp_Ax3 (gp::XOY()));
267 else if (aParamValue == "zox")
269 aWorkingPlane = gp_Pln (gp_Ax3 (gp::ZOX()));
271 else if (aParamValue == "yoz")
273 aWorkingPlane = gp_Pln (gp_Ax3 (gp::YOZ()));
277 std::cerr << theArgs[0] << ": wrong plane.\n";
281 isPlaneCustom = Standard_True;
283 else if (aParamName == "label")
285 NCollection_List<TCollection_AsciiString> aListOfLabelVals;
286 while (aParamValue.Length() > 0)
288 TCollection_AsciiString aValue = aParamValue;
290 Standard_Integer aSeparatorPos = aParamValue.Search (",");
291 if (aSeparatorPos >= 0)
293 aValue.Trunc (aSeparatorPos - 1);
294 aParamValue.Remove (aSeparatorPos, 1);
297 aListOfLabelVals.Append (aValue);
299 aParamValue.Remove (1, aValue.Length());
302 NCollection_List<TCollection_AsciiString>::Iterator aLabelValueIt (aListOfLabelVals);
303 for ( ; aLabelValueIt.More(); aLabelValueIt.Next())
305 aParamValue = aLabelValueIt.Value();
307 if (aParamValue == "left")
309 anAspect->SetTextHorizontalPosition (Prs3d_DTHP_Left);
311 else if (aParamValue == "right")
313 anAspect->SetTextHorizontalPosition (Prs3d_DTHP_Right);
315 else if (aParamValue == "hcenter")
317 anAspect->SetTextHorizontalPosition (Prs3d_DTHP_Center);
319 else if (aParamValue == "hfit")
321 anAspect->SetTextHorizontalPosition (Prs3d_DTHP_Fit);
323 else if (aParamValue == "above")
325 anAspect->SetTextVerticalPosition (Prs3d_DTVP_Above);
327 else if (aParamValue == "below")
329 anAspect->SetTextVerticalPosition (Prs3d_DTVP_Below);
331 else if (aParamValue == "vcenter")
333 anAspect->SetTextVerticalPosition (Prs3d_DTVP_Center);
337 std::cerr << theArgs[0] << ": invalid label position: \"" << aParamValue << "\".\n";
342 else if (aParamName == "flyout")
344 if (!aParamValue.IsRealValue())
346 std::cerr << theArgs[0] << ": numeric value expected for flyout.\n";
350 aCustomFlyout = aParamValue.RealValue();
352 isCustomFlyout = Standard_True;
354 else if (aParamName == "arrows")
356 if (aParamValue == "external")
358 anAspect->SetArrowOrientation (Prs3d_DAO_External);
360 else if (aParamValue == "internal")
362 anAspect->SetArrowOrientation (Prs3d_DAO_Internal);
364 else if (aParamValue == "fit")
366 anAspect->SetArrowOrientation (Prs3d_DAO_Fit);
371 std::cerr << theArgs[0] << ": unknow parameter: \"" << aParamName << "\".\n";
377 if (!GetMapOfAIS().IsBound2 (anArgString))
379 std::cerr << theArgs[0] << ": wrong name of shape. May be here is a wrong parameter.\n";
383 Handle(AIS_InteractiveObject) aShape = Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2 (anArgString));
386 std::cerr << theArgs[0] << ": wrong name of shape. Not a shape.\n";
390 aShapes.Append (aShape);
396 std::cerr << theArgs[0] << ": no name for dimension.\n";
401 Handle(AIS_Dimension) aDim;
402 switch (aKindOfDimension)
408 std::cerr << theArgs[0] << ": can not build dimension without working plane.\n";
411 if (aShapes.Extent() == 1)
413 if (aShapes.First()->Type() == AIS_KOI_Shape
414 && (Handle(AIS_Shape)::DownCast(aShapes.First()))->Shape().ShapeType() != TopAbs_EDGE)
416 std::cerr << theArgs[0] << ": wrong shape type.\n";
419 aDim = new AIS_LengthDimension (TopoDS::Edge ((Handle(AIS_Shape)::DownCast(aShapes.First()))->Shape()), aWorkingPlane);
421 else if (aShapes.Extent() == 2)
423 if (aShapes.First()->Type() == AIS_KOI_Shape && aShapes.Last()->Type() == AIS_KOI_Shape)
424 aDim = new AIS_LengthDimension ((Handle(AIS_Shape)::DownCast(aShapes.First ()))->Shape(),
425 (Handle(AIS_Shape)::DownCast(aShapes.Last ()))->Shape(),
429 Handle(AIS_Point) aPoint1 = Handle(AIS_Point)::DownCast(aShapes.First ());
430 Handle(AIS_Point) aPoint2 = Handle(AIS_Point)::DownCast(aShapes.Last ());
431 aDim = new AIS_LengthDimension (aPoint1->Component()->Pnt(),
432 aPoint2->Component()->Pnt(),
438 std::cerr << theArgs[0] << ": wrong number of shapes to build dimension.\n";
445 case AIS_KOD_PLANEANGLE:
447 if (aShapes.Extent() == 1 && aShapes.First()->Type()==AIS_KOI_Shape)
449 Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aShapes.First());
450 if (aShape->Shape().ShapeType() == TopAbs_FACE)
451 aDim = new AIS_AngleDimension (TopoDS::Face(aShape->Shape()));
453 if (aShapes.Extent() == 2)
455 Handle(AIS_Shape) aShape1 = Handle(AIS_Shape)::DownCast(aShapes.First());
456 Handle(AIS_Shape) aShape2 = Handle(AIS_Shape)::DownCast(aShapes.Last());
457 if (!aShape1.IsNull() && !aShape2.IsNull()
458 && aShape1->Shape().ShapeType() == TopAbs_EDGE
459 && aShape2->Shape().ShapeType() == TopAbs_EDGE)
460 aDim = new AIS_AngleDimension (TopoDS::Edge(aShape1->Shape()),TopoDS::Edge(aShape2->Shape()));
463 std::cerr << theArgs[0] << ": wrong shapes for angle dimension.\n";
467 else if (aShapes.Extent() == 3)
469 gp_Pnt aP1, aP2, aP3;
470 Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast (aShapes.First());
473 aP1 = aPoint->Component()->Pnt();
474 aShapes.RemoveFirst();
475 aPoint = Handle(AIS_Point)::DownCast (aShapes.First());
478 aP2 = aPoint->Component()->Pnt();
479 aShapes.RemoveFirst();
480 aPoint = Handle(AIS_Point)::DownCast (aShapes.First());
483 aP3 = aPoint->Component()->Pnt();
484 aDim = new AIS_AngleDimension (aP1, aP2, aP3);
488 std::cerr << theArgs[0] << ": wrong number of shapes to build dimension.\n";
495 case AIS_KOD_RADIUS: // radius of the circle
497 if (aShapes.Extent() == 1)
499 Handle(AIS_Circle) aShape = Handle(AIS_Circle)::DownCast (aShapes.First());
500 gp_Circ aCircle = aShape->Circle()->Circ();
501 aDim = new AIS_RadiusDimension (aCircle);
505 std::cerr << theArgs[0] << ": wrong number of shapes to build dimension.\n";
512 case AIS_KOD_DIAMETER:
514 if (aShapes.Extent() == 1)
516 Handle(AIS_Circle) aShape = Handle(AIS_Circle)::DownCast (aShapes.First());
517 gp_Circ aCircle = aShape->Circle()->Circ();
518 aDim = new AIS_DiameterDimension (aCircle);
522 std::cerr << theArgs[0] << ": wrong number of shapes to build dimension.\n";
531 std::cerr << theArgs[0] << ": wrong type of dimension. Type help for more information.\n";
536 aDim->SetDimensionAspect (anAspect);
540 aDim->SetFlyout (aCustomFlyout);
543 if (GetMapOfAIS().IsBound2(aName))
545 theDi << theArgs[0] << ": shape with name " << aName.ToCString ()<< " already exists. It will be replaced\n";
546 Handle(AIS_InteractiveObject) anObj =
547 Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(aName));
548 TheAISContext()->Remove(anObj, Standard_False);
549 GetMapOfAIS().UnBind2(aName);
552 GetMapOfAIS().Bind (aDim,aName);
557 //=======================================================================
558 //function : VAngleDimBuilder
560 //=======================================================================
562 static int VAngleDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
564 Standard_Integer myCurrentIndex;
565 if (argc!=2) {di<<" vangledim error."<<"\n";return 1;}
566 TheAISContext()->CloseAllContexts();
567 TheAISContext()->OpenLocalContext();
568 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
569 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
570 di<<" Select two edges coplanar or not."<<"\n";
571 Standard_Integer argcc = 5;
572 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
573 const char **argvv = (const char **) buff;
574 while (ViewerMainLoop( argcc, argvv) ) { }
577 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
578 ShapeA = TheAISContext()->SelectedShape();
580 // Si ShapeA est un Edge.
581 if (ShapeA.ShapeType()== TopAbs_EDGE ) {
583 // Boucle d'attente waitpick.
584 Standard_Integer argccc = 5;
585 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
586 const char **argvvv = (const char **) bufff;
587 while (ViewerMainLoop( argccc, argvvv) ) { }
591 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
592 ShapeB = TheAISContext()->SelectedShape();
594 // ShapeB doit etre un Edge
595 if (ShapeB.ShapeType()!= TopAbs_EDGE ) {
596 di<<" vangledim error: you shoud have selected an edge."<<"\n";return 1;
599 // on recupere les vertexes de edgeA
601 TopExp::Vertices(TopoDS::Edge(ShapeA),Va ,Vb );
602 // Recuperation des points.
603 gp_Pnt A=BRep_Tool::Pnt(Va);
604 gp_Pnt B=BRep_Tool::Pnt(Vb);
605 gp_Pnt C(A.X()+5 ,A.Y()+5 ,A.Z()+5 );
608 // Construction du plane. Methode pas orthodoxe!
609 GC_MakePlane MkPlane(A ,B ,C );
610 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
612 // Construction du texte.
613 TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString( 90 ) );
615 // Fermeture du context local.
616 TheAISContext()->CloseLocalContext(myCurrentIndex);
618 // Construction de l'AIS dimension
619 Handle (AIS_AngleDimension) myAISDim= new AIS_AngleDimension (TopoDS::Edge(ShapeA) ,TopoDS::Edge(ShapeB) ,theGeomPlane->Pln());
620 GetMapOfAIS().Bind (myAISDim,argv[1]);
621 TheAISContext()->Display(myAISDim );
625 di<<" vangledim error: you must select 2 edges."<<"\n";return 1;
632 //==============================================================================
633 //function : VDiameterDim
634 //purpose : Display the diameter dimension of a face or an edge.
635 //Draw arg : vdiameterdim Name
636 //==============================================================================
638 static int VDiameterDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
641 Standard_Integer myCurrentIndex;
642 Standard_Real theRadius;
645 if (argc!=2) {di<<" vdiameterdim error"<<"\n";return 1;}
646 // Fermeture des contextes locaux
647 TheAISContext()->CloseAllContexts();
648 // Ouverture d'un contexte local et recuperation de son index.
649 TheAISContext()->OpenLocalContext();
650 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
652 // On active les modes de selections Edges et Faces.
653 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
654 di<<" Select an circled edge."<<"\n";
656 // Boucle d'attente waitpick.
657 Standard_Integer argcc = 5;
658 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
659 const char **argvv = (const char **) buff;
660 while (ViewerMainLoop( argcc, argvv) ) { }
664 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
665 ShapeA = TheAISContext()->SelectedShape();
667 if (ShapeA.ShapeType()==TopAbs_EDGE ) {
669 // Recuperation du rayon
670 BRepAdaptor_Curve theCurve(TopoDS::Edge(ShapeA));
671 if (theCurve.GetType()!=GeomAbs_Circle ) {di<<"vdiameterdim error: the edge is not a circular one."<<"\n";return 1;}
673 gp_Circ theGpCircle=theCurve.Circle();
674 theRadius=2.*theGpCircle.Radius();
677 // Construction du texte.
678 TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theRadius ) );
679 // Construction de L'AIS_AngleDimension.
680 TheAISContext()->CloseLocalContext(myCurrentIndex);
682 Handle (AIS_DiameterDimension) myDiamDim= new AIS_DiameterDimension(ShapeA);
683 GetMapOfAIS().Bind (myDiamDim,argv[1]);
684 TheAISContext()->Display(myDiamDim );
689 di<<" vdiameterdim error: the selection of a face or an edge was expected."<<"\n";return 1;
697 //==============================================================================
698 // Fonction vconcentric
699 // ----------------- Uniquement par selection dans le viewer.
700 //==============================================================================
702 //==============================================================================
703 //function : VConcentric
704 //purpose : Display the concentric relation between two surfaces.
705 //Draw arg : vconcentric Name
706 //==============================================================================
707 #include <AIS_ConcentricRelation.hxx>
708 #include <Geom_Plane.hxx>
709 #include <gp_Pln.hxx>
710 #include <GC_MakePlane.hxx>
711 #include <BRepAdaptor_Curve.hxx>
712 #include <TopExp_Explorer.hxx>
715 static int VConcentricBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
718 Standard_Integer myCurrentIndex;
721 if (argc!=2) {di<<"vconcentric error."<<"\n";return 1;}
722 // Fermeture des contextes locaux
723 TheAISContext()->CloseAllContexts();
724 // Ouverture d'un contexte local et recuperation de son index.
725 TheAISContext()->OpenLocalContext();
726 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
728 // On active les modes de selections Edges et Faces.
729 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
730 di<<" Select a circled edge."<<"\n";
732 // Boucle d'attente waitpick.
733 Standard_Integer argcc = 5;
734 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
735 const char **argvv = (const char **) buff;
736 while (ViewerMainLoop( argcc, argvv) ) { }
740 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
741 ShapeA = TheAISContext()->SelectedShape();
743 // ShapeA est un edge
744 // ==================
745 if (ShapeA.ShapeType()==TopAbs_EDGE ) {
746 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) );
747 di<<" Select an edge."<<"\n";
749 // Boucle d'attente waitpick.
750 Standard_Integer argccc = 5;
751 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
752 const char **argvvv = (const char **) bufff;
753 while (ViewerMainLoop( argccc, argvvv) ) { }
757 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
758 ShapeB = TheAISContext()->SelectedShape();
760 if (ShapeB.ShapeType()!=TopAbs_EDGE ) {
761 di<<" vconcentric error: select an edge."<<"\n";return 1;
764 // Construction du plane.
765 // On recupere le centre du cercle A.
766 BRepAdaptor_Curve theCurveA(TopoDS::Edge(ShapeA) );
767 gp_Circ theCircleA=theCurveA.Circle();
768 gp_Pnt theCenterA=theCircleA.Location();
769 // On recupere deux points sur le cercle A
770 gp_Pnt B= theCurveA.Value(0.25);
771 gp_Pnt C= theCurveA.Value(0.75);
772 // Construction du plane.
773 GC_MakePlane MkPlane(theCenterA ,B ,C );
774 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
776 // Fermeture du context local
777 TheAISContext()->CloseLocalContext(myCurrentIndex);
779 Handle (AIS_ConcentricRelation) myConcentry= new AIS_ConcentricRelation(ShapeA, ShapeB, theGeomPlane );
780 TheAISContext()->Display(myConcentry );
781 GetMapOfAIS().Bind (myConcentry,argv[1]);
786 di<<" vconcentric error: the selection of a face or an edge was expected."<<"\n";return 1;
796 //==============================================================================
797 //function : VEqualDistRelation
799 //Draw arg : vdiameterdim Name DiameterValue
800 //==============================================================================
801 #include <AIS_EqualDistanceRelation.hxx>
802 #include <BRepExtrema_ExtCC.hxx>
803 #include <GC_MakePlane.hxx>
806 static int VEqualDistRelation(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
809 Standard_Integer myCurrentIndex;
812 if (argc!=2) {di<<" vequaldistrelation error: no arguments allowed."<<"\n";return 1;}
814 // Fermeture des contextes locaux
815 TheAISContext()->CloseAllContexts();
817 // Ouverture d'un contexte local et recuperation de son index.
818 TheAISContext()->OpenLocalContext();
819 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
821 // On active les modes de selections Edges et Vertexes.
822 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
823 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
824 di<<" Select an edge or a vertex"<<"\n";
826 // Boucle d'attente waitpick.
827 Standard_Integer argc1 = 5;
828 const char *buf1[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
829 const char **argv1 = (const char **) buf1;
830 while (ViewerMainLoop( argc1, argv1) ) { }
834 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
835 ShapeA = TheAISContext()->SelectedShape();
838 di<<" Select an edge or a vertex"<<"\n";
839 // Boucle d'attente waitpick.
840 Standard_Integer argc2 = 5;
841 const char *buf2[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
842 const char **argv2 = (const char **) buf2;
843 while (ViewerMainLoop( argc2, argv2) ) { }
847 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
848 ShapeB = TheAISContext()->SelectedShape();
851 // Verification des resultats.
852 if (ShapeA.ShapeType()==TopAbs_EDGE && ShapeB.ShapeType()==TopAbs_EDGE ) {
853 // A et B sont des edges ils doivent etre paralleles
854 BRepExtrema_ExtCC myDeltaEdge (TopoDS::Edge(ShapeA) ,TopoDS::Edge(ShapeB) );
855 // on verifie qu'ils sont pas paralleles.
856 if (!myDeltaEdge.IsParallel() ) {di<<"vequaldist error: non parallel edges."<<"\n";return 1; }
861 di<<" Select an edge or a vertex"<<"\n";
862 // Boucle d'attente waitpick.
863 Standard_Integer argc3 = 5;
864 const char *buf3[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
865 const char **argv3 = (const char **) buf3;
866 while (ViewerMainLoop( argc3, argv3) ) { }
870 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
871 ShapeC = TheAISContext()->SelectedShape();
874 di<<" Select an edge or a vertex"<<"\n";
875 // Boucle d'attente waitpick.
876 Standard_Integer argc4 = 5;
877 const char *buf4[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
878 const char **argv4 = (const char **) buf4;
879 while (ViewerMainLoop( argc4, argv4) ) { }
883 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
884 ShapeD = TheAISContext()->SelectedShape();
886 // Verification des resultats.
887 if (ShapeC.ShapeType()==TopAbs_EDGE && ShapeD.ShapeType()==TopAbs_EDGE ) {
888 // C et D sont des edges ils doivent etre paralleles
889 BRepExtrema_ExtCC myDeltaEdge2 (TopoDS::Edge(ShapeC) ,TopoDS::Edge(ShapeD) );
890 // on verifie qu'ils sont pas paralleles.
891 if (!myDeltaEdge2.IsParallel() ) {di<<"vequaldist error: non parallel edges."<<"\n";return 1; }
895 // Creation du plan porteur de la contrainte.Methode lourde!
897 if (ShapeA.ShapeType()==TopAbs_EDGE) {
900 TopExp::Vertices (TopoDS::Edge(ShapeA) ,Va ,Vb );
901 A=BRep_Tool::Pnt(Va);
902 B=BRep_Tool::Pnt(Vb);
904 if (ShapeB.ShapeType()==TopAbs_EDGE) {
905 // B est un edge aussi
907 TopExp::Vertices (TopoDS::Edge(ShapeB) ,Vc ,Vd );
908 // besoin que de 1 point.
909 C=BRep_Tool::Pnt(Vc);
914 C=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) );
919 A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA) );
921 if (ShapeB.ShapeType()==TopAbs_EDGE ) {
924 TopExp::Vertices (TopoDS::Edge(ShapeB) ,Vb ,Vc );
925 // besoin que de 2 points.
926 B=BRep_Tool::Pnt(Vb);
927 C=BRep_Tool::Pnt(Vc);
932 B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) );
940 // Fermeture du context local.
941 TheAISContext()->CloseLocalContext(myCurrentIndex);
943 // construction du plane
944 GC_MakePlane MkPlane(A ,B ,C );
945 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
947 // Construction de l'AIS_EqualDistanceRelation
948 Handle (AIS_EqualDistanceRelation ) myRelation= new AIS_EqualDistanceRelation (ShapeA, ShapeB, ShapeC ,ShapeD , theGeomPlane );
949 TheAISContext()->Display(myRelation );
950 GetMapOfAIS().Bind (myRelation,argv[1]);
958 //==============================================================================
959 //function : VEqualRadiusRelation
961 //Draw arg : vdiameterdim Name DiameterValue
962 //==============================================================================
963 #include <AIS_EqualRadiusRelation.hxx>
964 #include <GC_MakePlane.hxx>
965 #include <BRepAdaptor_Curve.hxx>
968 static int VEqualRadiusRelation(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
971 Standard_Integer myCurrentIndex;
974 if (argc!=2) {di<<" vequalrad error: no arguments allowed."<<"\n";return 1;}
976 // Fermeture des contextes locaux
977 TheAISContext()->CloseAllContexts();
979 // Ouverture d'un contexte local et recuperation de son index.
980 TheAISContext()->OpenLocalContext();
981 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
983 // On active les modes de selections Edges.
984 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
985 di<<" Select an circled edge "<<"\n";
987 // Boucle d'attente waitpick.
988 Standard_Integer argc1 = 5;
989 const char *buf1[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
990 const char **argv1 = (const char **) buf1;
991 while (ViewerMainLoop( argc1, argv1) ) { }
995 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
996 ShapeA = TheAISContext()->SelectedShape();
999 di<<" Select the last circled edge."<<"\n";
1000 // Boucle d'attente waitpick.
1001 Standard_Integer argc2 = 5;
1002 const char *buf2[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1003 const char **argv2 = (const char **) buf2;
1004 while (ViewerMainLoop( argc2, argv2) ) { }
1007 TopoDS_Shape ShapeB;
1008 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
1009 ShapeB = TheAISContext()->SelectedShape();
1011 // creation du plan qui contient la contrainte.
1012 TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA);
1013 TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB);
1014 BRepAdaptor_Curve theCurveA(EdgeA);
1015 // On recupere 3 points A,B,C de la curve.
1016 gp_Pnt A=theCurveA.Value(0.1);
1017 gp_Pnt B=theCurveA.Value(0.5);
1018 gp_Pnt C=theCurveA.Value(0.9);
1020 // fermeture du contexte local.
1021 TheAISContext()->CloseLocalContext(myCurrentIndex);
1023 // Creation du plane.
1024 GC_MakePlane MkPlane (A ,B ,C );
1025 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
1026 // Construction de l'AIS_EqualRadiusRelation
1027 Handle (AIS_EqualRadiusRelation ) myRelation= new AIS_EqualRadiusRelation (EdgeA,EdgeB, theGeomPlane );
1028 TheAISContext()->Display(myRelation );
1029 GetMapOfAIS().Bind (myRelation,argv[1]);
1036 //==============================================================================
1037 //function : VFixRelation
1039 //Draw arg : vdiameterdim Name DiameterValue
1040 //==============================================================================
1041 #include <AIS_FixRelation.hxx>
1042 #include <GC_MakePlane.hxx>
1043 #include <BRepAdaptor_Curve.hxx>
1045 static int VFixRelation(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1048 Standard_Integer myCurrentIndex;
1051 if (argc!=2) {di<<" vfix error: no arguments allowed."<<"\n";return 1;}
1053 // Fermeture des contextes locaux
1054 TheAISContext()->CloseAllContexts();
1056 // Ouverture d'un contexte local et recuperation de son index.
1057 TheAISContext()->OpenLocalContext();
1058 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
1060 // On active les modes de selections edge.
1061 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
1062 di<<" Select an edge. "<<"\n";
1064 // Boucle d'attente waitpick.
1065 Standard_Integer argc1 = 5;
1066 const char *buf1[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1067 const char **argv1 = (const char **) buf1;
1068 while (ViewerMainLoop( argc1, argv1) ) { }
1071 TopoDS_Shape ShapeA;
1072 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
1073 ShapeA = TheAISContext()->SelectedShape();
1076 // creation du plan qui contient la contrainte.
1077 TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA);
1078 BRepAdaptor_Curve theCurveA(EdgeA);
1079 // On recupere 3 points A,B,C de la curve.
1080 gp_Pnt A=theCurveA.Value(0.1);
1081 gp_Pnt B=theCurveA.Value(0.5);
1082 gp_Pnt D=theCurveA.Value(0.9);
1083 gp_Pnt C(B.X()+5,B.Y()+5,B.Z()+5);
1085 // fermeture du contexte local.
1086 TheAISContext()->CloseLocalContext(myCurrentIndex);
1088 // Creation du plane.
1089 GC_MakePlane MkPlane (A ,D ,C );
1090 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
1091 // Construction de l'AIS_EqualRadiusRelation
1092 Handle (AIS_FixRelation) myRelation= new AIS_FixRelation (EdgeA,theGeomPlane );
1093 TheAISContext()->Display(myRelation );
1094 GetMapOfAIS().Bind (myRelation,argv[1]);
1101 //==============================================================================
1102 //function : VIdenticRelation
1104 //Draw arg : vdiameterdim Name DiameterValue
1105 //==============================================================================
1106 #include <AIS_IdenticRelation.hxx>
1107 #include <BRepAdaptor_Curve.hxx>
1108 #include <TopExp_Explorer.hxx>
1111 static int VIdenticRelation(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1114 Standard_Integer myCurrentIndex;
1117 if (argc!=2) {di<<" videntity error: no arguments allowed."<<"\n";return 1;}
1119 // Fermeture des contextes locaux
1120 TheAISContext()->CloseAllContexts();
1122 // Ouverture d'un contexte local et recuperation de son index.
1123 TheAISContext()->OpenLocalContext();
1124 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
1126 // On active les modes de selections vertex et face.
1127 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
1128 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
1129 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
1130 di<<" Select an edge, a face or a vertex. "<<"\n";
1132 // Boucle d'attente waitpick.
1133 Standard_Integer argc1 = 5;
1134 const char *buf1[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1135 const char **argv1 = (const char **) buf1;
1136 while (ViewerMainLoop( argc1, argv1) ) { }
1139 TopoDS_Shape ShapeA;
1140 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
1141 ShapeA = TheAISContext()->SelectedShape();
1144 di<<" Select an edge, a face or a vertex. "<<"\n";
1145 // Boucle d'attente waitpick.
1146 Standard_Integer argc2 = 5;
1147 const char *buf2[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1148 const char **argv2 = (const char **) buf2;
1149 while (ViewerMainLoop( argc2, argv2) ) { }
1152 TopoDS_Shape ShapeB;
1153 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
1154 ShapeB = TheAISContext()->SelectedShape();
1157 // Recuperation de points pour construir le Geom_Plnae.
1159 if (ShapeA.ShapeType()==TopAbs_EDGE) {
1160 // A est un edge; on peut supposer qu'il sera element d'une face ou possesseur d'un vertex ou identic a un autre edge.
1161 // on recupere deux points sur l'edge (il peut etre rectiligne)
1162 TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA);
1163 BRepAdaptor_Curve theCurveA(EdgeA);
1164 // Creation des 3 points.
1165 A=theCurveA.Value(0.1);
1166 B=theCurveA.Value(0.9);
1171 else if (ShapeA.ShapeType()==TopAbs_VERTEX ) {
1172 // SahpeA est un Vertex
1173 // On va utiliser ShapeB
1174 if (ShapeB.ShapeType()==TopAbs_EDGE) {
1176 TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB);
1177 BRepAdaptor_Curve theCurveB(EdgeB);
1178 // Creation des 3 points.
1179 A=theCurveB.Value(0.1);
1180 B=theCurveB.Value(0.9);
1186 else if (ShapeB.ShapeType()==TopAbs_FACE ) {
1187 // Shape B est une face
1188 TopoDS_Face FaceB=TopoDS::Face(ShapeB);
1189 // On recupere 1 edge de FaceB(la face n'a pas forcement de vertex) (l'element A est forcement dans B).
1190 TopExp_Explorer FaceExp(FaceB,TopAbs_EDGE);
1191 TopoDS_Edge EdgeFromB=TopoDS::Edge(FaceExp.Current() );
1192 // On recupere les 3 points de l'edge de face B
1193 BRepAdaptor_Curve theCurveB(EdgeFromB);
1194 // On recupere 3 points A,B,C de la curve.
1195 A=theCurveB.Value(0.1);
1196 B=theCurveB.Value(0.5);
1197 C=theCurveB.Value(0.9);
1201 // B ets un vetex aussi
1202 A=BRep_Tool::Pnt(TopoDS::Vertex(ShapeA) );
1203 B=BRep_Tool::Pnt(TopoDS::Vertex(ShapeB) );
1213 TopoDS_Face FaceA=TopoDS::Face(ShapeA);
1214 // On recupere 1 edge de FaceA
1215 TopExp_Explorer FaceExp(FaceA,TopAbs_EDGE);
1216 TopoDS_Edge EdgeFromA=TopoDS::Edge(FaceExp.Current() );
1217 // On recupere les 3 points de l'edge
1218 BRepAdaptor_Curve theCurveA(EdgeFromA);
1219 // On recupere 3 points A,B,C de la curve.
1220 A=theCurveA.Value(0.1);
1221 B=theCurveA.Value(0.5);
1222 C=theCurveA.Value(0.9);
1226 // Fermeture du context local.
1227 TheAISContext()->CloseLocalContext(myCurrentIndex);
1228 // On construit le plane
1229 GC_MakePlane MkPlane (A ,B ,C );
1230 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
1232 // Construction de l'AIS_IdenticRelation
1233 Handle ( AIS_IdenticRelation ) myRelation= new AIS_IdenticRelation (ShapeA ,ShapeB, theGeomPlane );
1234 TheAISContext()->Display(myRelation );
1235 GetMapOfAIS().Bind (myRelation,argv[1]);
1242 //==============================================================================
1243 //function : VLengthDimension
1244 //purpose : Display the diameter dimension of a face or an edge.
1245 //Draw arg : vdiameterdim Name DiameterValue
1246 //==============================================================================
1247 #include <AIS_LengthDimension.hxx>
1248 #include <BRepExtrema_ExtCC.hxx>
1249 #include <BRepExtrema_ExtPC.hxx>
1250 #include <BRepExtrema_ExtCF.hxx>
1251 #include <BRepExtrema_ExtPF.hxx>
1252 #include <BRepExtrema_ExtFF.hxx>
1253 #include <TCollection_ExtendedString.hxx>
1254 #include <BRepExtrema_DistShapeShape.hxx>
1255 #include <GC_MakePlane.hxx>
1256 #include <TopExp_Explorer.hxx>
1257 #include <BRepBuilderAPI_MakeVertex.hxx>
1258 static int VLenghtDimension(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1261 Standard_Integer myCurrentIndex;
1262 Standard_Real theDist;
1265 if (argc!=2) {di<<" videntity error: no arguments allowed."<<"\n";return 1;}
1267 // Fermeture des contextes locaux
1268 TheAISContext()->CloseAllContexts();
1270 // Ouverture d'un contexte local et recuperation de son index.
1271 myCurrentIndex = TheAISContext()->OpenLocalContext();
1272 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
1273 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
1274 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
1275 di<<" Select an edge, a face or a vertex. "<<"\n";
1277 // Boucle d'attente waitpick.
1278 Standard_Integer argc1 = 5;
1279 const char *buf1[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1280 const char **argv1 = (const char **) buf1;
1281 while (ViewerMainLoop( argc1, argv1) ) { }
1284 TopoDS_Shape ShapeA;
1285 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
1286 ShapeA = TheAISContext()->SelectedShape();
1288 di<<" Select an edge, a face or a vertex. "<<"\n";
1289 // Boucle d'attente waitpick.
1290 Standard_Integer argc2 = 5;
1291 const char *buf2[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1292 const char **argv2 = (const char **) buf2;
1293 while (ViewerMainLoop( argc2, argv2) ) { }
1296 TopoDS_Shape ShapeB;
1297 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
1298 ShapeB = TheAISContext()->SelectedShape();
1300 // ShapeA est un edge.
1301 // ===================
1302 if (ShapeA.ShapeType()==TopAbs_EDGE ) {
1303 TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA);
1305 // Si ShapeB est un edge
1306 if (ShapeB.ShapeType()==TopAbs_EDGE ) {
1307 TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB);
1308 BRepExtrema_ExtCC myDeltaEdge (EdgeA ,EdgeB );
1309 // on verifie qu'ils ne sont pas paralleles.
1310 if (!myDeltaEdge.IsParallel() ) {di<<"vlenghtdim error: non parallel edges."<<"\n";return 1; }
1312 // On saisit la distance et on l'arrondit!
1313 theDist=Round (sqrt(myDeltaEdge.SquareDistance(1))*10. )/10.;
1315 // On recupere 3 Points des edges pour construire un plane.
1316 TopoDS_Vertex Va,Vb,Vc,Vd;
1317 TopExp::Vertices(EdgeA,Va,Vb);
1318 TopExp::Vertices(EdgeB,Vc,Vd);
1319 gp_Pnt A=BRep_Tool::Pnt(Va);
1320 gp_Pnt B=BRep_Tool::Pnt(Vb);
1321 gp_Pnt C=BRep_Tool::Pnt(Vc);
1323 // Creation du Plane contenant la relation.
1324 GC_MakePlane MkPlane(A,B,C);
1325 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
1327 TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) );
1329 // On ferme le contexte local.
1330 TheAISContext()->CloseLocalContext(myCurrentIndex);
1332 // on construit l'AISLenghtDimension.
1333 Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (EdgeA,EdgeB,theGeomPlane->Pln());
1334 TheAISContext()->Display(myLenghtDim );
1335 GetMapOfAIS().Bind (myLenghtDim ,argv[1]);
1338 // Si ShapeB est un vertex.
1339 else if (ShapeB.ShapeType()==TopAbs_VERTEX ) {
1341 TopoDS_Vertex VertexB=TopoDS::Vertex(ShapeB);
1342 BRepExtrema_ExtPC myDeltaEdgeVertex (VertexB ,EdgeA );
1344 // On saisit la distance et on l'arrondit!
1345 theDist=Round (sqrt (myDeltaEdgeVertex.SquareDistance(1))*10. )/10.;
1347 // On recupere 2 Points de EdgeA pour construire un plane.
1348 TopoDS_Vertex Va,Vb;
1349 TopExp::Vertices(EdgeA,Va,Vb);
1350 gp_Pnt A=BRep_Tool::Pnt(Va);
1351 gp_Pnt B=BRep_Tool::Pnt(Vb);
1352 gp_Pnt C=BRep_Tool::Pnt(VertexB);
1354 GC_MakePlane MkPlane(A,B,C);
1355 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
1357 TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) );
1358 TheAISContext()->CloseLocalContext(myCurrentIndex);
1359 Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (EdgeA,VertexB,theGeomPlane->Pln());
1360 TheAISContext()->Display(myLenghtDim );
1361 GetMapOfAIS().Bind (myLenghtDim ,argv[1]);
1366 // Si ShapeB est une Face
1369 TopoDS_Face FaceB=TopoDS::Face(ShapeB);
1370 BRepExtrema_ExtCF myDeltaEdgeFace (EdgeA,FaceB );
1371 // On verifie que l'edge est bien parallele a la face.
1372 if (!myDeltaEdgeFace.IsParallel() ) {di<<"vdistdim error: the edge isn't parallel to the face;can't compute the distance. "<<"\n";return 1; }
1374 // on construit l'AISLenghtDimension.
1375 Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (FaceB,EdgeA);
1376 TheAISContext()->Display(myLenghtDim );
1377 GetMapOfAIS().Bind (myLenghtDim ,argv[1]);
1381 // ShapeA est un vertex
1382 // ====================
1383 if (ShapeA.ShapeType()==TopAbs_VERTEX ) {
1384 TopoDS_Vertex VertexA=TopoDS::Vertex(ShapeA);
1386 // Si ShapeB est un edge.
1387 if (ShapeB.ShapeType()==TopAbs_EDGE ) {
1388 TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB);
1389 BRepExtrema_ExtPC myDeltaEdgeVertex (VertexA ,EdgeB );
1390 // On saisit la distance et on l'arrondit!
1391 theDist=Round (sqrt (myDeltaEdgeVertex.SquareDistance(1))*10. )/10.;
1393 // On recupere 2 Points de EdgeB pour construire un plane.
1394 TopoDS_Vertex Va,Vb;
1395 TopExp::Vertices(EdgeB,Va,Vb);
1396 gp_Pnt A=BRep_Tool::Pnt(Va);
1397 gp_Pnt B=BRep_Tool::Pnt(Vb);
1398 gp_Pnt C=BRep_Tool::Pnt(VertexA);
1400 // Creation du Plane contenant la relation.
1401 GC_MakePlane MkPlane(A,B,C);
1402 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
1404 // Fermeture du contexte local.
1405 TheAISContext()->CloseLocalContext(myCurrentIndex);
1406 // Construction du texte.
1407 TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) );
1409 // on construit l'AISLenghtDimension.
1410 Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (EdgeB,VertexA,theGeomPlane->Pln());
1411 TheAISContext()->Display(myLenghtDim );
1412 GetMapOfAIS().Bind (myLenghtDim ,argv[1]);
1416 // Si ShapeB est un vertex.
1417 else if (ShapeB.ShapeType()==TopAbs_VERTEX ) {
1418 TopoDS_Vertex VertexB=TopoDS::Vertex(ShapeB);
1419 BRepExtrema_DistShapeShape myDeltaVertexVertex (VertexA ,VertexB );
1420 // On saisit la distance et on l'arrondit!
1421 theDist=Round (myDeltaVertexVertex.Value()*10. )/10.;
1423 // Les deux premiers points.
1424 gp_Pnt A=BRep_Tool::Pnt(VertexA);
1425 gp_Pnt B=BRep_Tool::Pnt(VertexB);
1426 gp_Pnt C(B.X()+10,B.Y()+10,B.Z()+10);
1428 GC_MakePlane MkPlane(A,B,C);
1429 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
1431 // Fermeture du contexte local.
1432 TheAISContext()->CloseLocalContext(myCurrentIndex);
1433 // Construction du texte.
1434 TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) );
1436 // on construit l'AISLenghtDimension.
1437 Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (VertexA,VertexB,theGeomPlane->Pln());
1438 TheAISContext()->Display(myLenghtDim );
1439 GetMapOfAIS().Bind (myLenghtDim ,argv[1]);
1446 // Si ShapeB est une Face
1449 TopoDS_Face FaceB=TopoDS::Face(ShapeB);
1450 BRepExtrema_ExtPF myDeltaVertexFace (VertexA ,FaceB );
1451 // On saisit la distance et on l'arrondit!
1452 theDist=Round (sqrt (myDeltaVertexFace.SquareDistance(1))*10. )/10.;
1455 gp_Pnt A=BRep_Tool::Pnt(VertexA);
1457 // On recupere 1 edge de FaceB.
1458 TopExp_Explorer FaceExp(FaceB,TopAbs_EDGE);
1459 TopoDS_Edge EdFromB=TopoDS::Edge(FaceExp.Current() );
1460 // On recupere les deux vertexes extremites de l'edge de face B
1461 TopoDS_Vertex Vb,Vc;
1462 TopExp::Vertices(EdFromB,Vb,Vc);
1467 gp_Pnt C=BRep_Tool::Pnt(Vc);
1469 // On projette le point B sur la Face car il
1470 // n'existe pas de constructeurs AIS_LD PointFace
1471 // on est donc oblige de creer un nouveau TopoDS_Vertex.
1472 gp_Pnt theProjA=myDeltaVertexFace.Point(1);
1473 BRepBuilderAPI_MakeVertex theVertexMaker(theProjA);
1474 TopoDS_Vertex VertexAproj=theVertexMaker.Vertex();
1475 // Creation du Plane contenant la relation.
1476 GC_MakePlane MkPlane(A,theProjA,C);
1477 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
1479 // Fermeture du contexte local.
1480 TheAISContext()->CloseLocalContext(myCurrentIndex);
1481 // Construction du texte.
1482 TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) );
1484 // on construit l'AISLenghtDimension.
1485 Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (VertexA,VertexAproj,theGeomPlane->Pln());
1486 TheAISContext()->Display(myLenghtDim );
1487 GetMapOfAIS().Bind (myLenghtDim ,argv[1]);
1495 // ShapeA est une Face
1496 // ===================
1498 TopoDS_Face FaceA=TopoDS::Face(ShapeA);
1499 // Si ShapeB est un edge.
1500 if (ShapeB.ShapeType()==TopAbs_EDGE ) {
1501 TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB);
1502 BRepExtrema_ExtCF myDeltaEdgeFace (EdgeB,FaceA );
1503 // On verifie que l'edge est bien parallele a la face.
1504 if (!myDeltaEdgeFace.IsParallel() ) {di<<"vdistdim error: the edge isn't parallel to the face;can't compute the distance. "<<"\n";return 1; }
1506 // On saisit la distance et on l'arrondit!
1507 theDist=Round (sqrt (myDeltaEdgeFace.SquareDistance(1))*10. )/10.;
1509 // Construction du texte.
1510 TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) );
1512 // on construit l'AISLenghtDimension.
1513 Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (FaceA,EdgeB);
1514 TheAISContext()->Display(myLenghtDim );
1515 GetMapOfAIS().Bind (myLenghtDim ,argv[1]);
1519 // Si ShapeB est un vertex.
1520 else if (ShapeB.ShapeType()==TopAbs_VERTEX ) {
1522 TopoDS_Vertex VertexB=TopoDS::Vertex(ShapeB);
1523 BRepExtrema_ExtPF myDeltaVertexFace (VertexB ,FaceA );
1524 // On saisit la distance et on l'arrondit!
1525 theDist=Round (sqrt (myDeltaVertexFace.SquareDistance(1))*10. )/10.;
1528 gp_Pnt B=BRep_Tool::Pnt(VertexB);
1530 // On recupere 1 edge de FaceA.
1531 TopExp_Explorer FaceExp(FaceA,TopAbs_EDGE);
1532 TopoDS_Edge EdFromA=TopoDS::Edge(FaceExp.Current() );
1533 // On recupere les deux vertexes extremites de l'edge de face A
1534 TopoDS_Vertex Va,Vc;
1535 TopExp::Vertices(EdFromA,Va,Vc);
1536 gp_Pnt A=BRep_Tool::Pnt(Va);
1542 // On projette le point B sur la Face car il
1543 // n'existe pas de constructeurs AIS_LD PointFace
1544 // on est donc oblige de creer un nouveau TopoDS_Vertex.
1545 gp_Pnt theProjB=myDeltaVertexFace.Point(1);
1546 BRepBuilderAPI_MakeVertex theVertexMaker(theProjB);
1547 TopoDS_Vertex VertexBproj=theVertexMaker.Vertex();
1548 // Creation du Plane contenant la relation.
1549 GC_MakePlane MkPlane(A,B,theProjB);
1550 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
1552 // Fermeture du contexte local.
1553 TheAISContext()->CloseLocalContext(myCurrentIndex);
1554 // Construction du texte.
1555 TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) );
1557 // on construit l'AISLenghtDimension mais en utilisant le constructeur Vertex Vertex.
1558 Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (VertexB,VertexBproj,theGeomPlane->Pln());
1559 TheAISContext()->Display(myLenghtDim );
1560 GetMapOfAIS().Bind (myLenghtDim ,argv[1]);
1564 // Si ShapeB est une Face
1567 TopoDS_Face FaceB=TopoDS::Face(ShapeB);
1568 BRepExtrema_ExtFF myDeltaFaceFace (FaceA ,FaceB );
1569 // On verifie que les deux faces sont bien parelles.
1570 if (!myDeltaFaceFace.IsParallel() ) {di<<"vdistdim error: the faces are not parallel. "<<"\n";return 1; }
1572 // On saisit la distance et on l'arrondit!
1573 theDist=Round (sqrt (myDeltaFaceFace.SquareDistance(1))*10. )/10.;
1574 // Fermeture du contexte local.
1575 TheAISContext()->CloseLocalContext(myCurrentIndex);
1576 // Construction du texte.
1577 TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("d=")+TCollection_ExtendedString(theDist ) );
1579 // on construit l'AISLenghtDimension.
1580 Handle(AIS_LengthDimension ) myLenghtDim=new AIS_LengthDimension (FaceA,FaceB);
1581 TheAISContext()->Display(myLenghtDim );
1582 GetMapOfAIS().Bind (myLenghtDim ,argv[1]);
1595 //==============================================================================
1596 //function : VRadiusDim
1597 //purpose : Display the radius dimension of a face or an edge.
1598 //Draw arg : vradiusdim Name
1599 //==============================================================================
1600 #include <AIS_RadiusDimension.hxx>
1601 #include <TCollection_ExtendedString.hxx>
1602 #include <BRepAdaptor_Curve.hxx>
1603 #include <gp_Circ.hxx>
1606 static int VRadiusDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1609 Standard_Integer myCurrentIndex;
1610 Standard_Real theRadius;
1613 if (argc!=2) {di<<" vradiusdim error"<<"\n";return 1;}
1615 // Fermeture des contextes locaux
1616 TheAISContext()->CloseAllContexts();
1618 // Ouverture d'un contexte local et recuperation de son index.
1619 TheAISContext()->OpenLocalContext();
1620 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
1622 // On active les modes de selections Edges et Faces.
1623 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
1624 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
1625 di<<" Select an circled edge or face."<<"\n";
1627 // Boucle d'attente waitpick.
1628 Standard_Integer argcc = 5;
1629 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1630 const char **argvv = (const char **) buff;
1631 while (ViewerMainLoop( argcc, argvv) ) { }
1634 TopoDS_Shape ShapeA;
1635 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
1636 ShapeA = TheAISContext()->SelectedShape();
1639 // Shape A est un edge.
1640 if (ShapeA.ShapeType()==TopAbs_EDGE ) {
1642 TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA);
1643 // Recuperation du rayon
1644 BRepAdaptor_Curve theCurve(TopoDS::Edge(ShapeA));
1645 if (theCurve.GetType()!=GeomAbs_Circle ) {di<<"vradiusdim error: the edge is not a circular one."<<"\n";return 1;}
1647 gp_Circ theGpCircle=theCurve.Circle();
1648 theRadius=theGpCircle.Radius();
1649 // On arrondit le rayon
1650 theRadius=Round (theRadius*10. )/10.;
1653 // Construction du texte.
1654 TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("r=")+TCollection_ExtendedString(theRadius ) );
1656 // Fermeture du contexte.
1657 TheAISContext()->CloseLocalContext(myCurrentIndex);
1659 // Construction de L'AIS_RadiusDimension.
1660 Handle (AIS_RadiusDimension) myRadDim= new AIS_RadiusDimension(ShapeA);
1661 GetMapOfAIS().Bind (myRadDim,argv[1]);
1662 TheAISContext()->Display(myRadDim );
1667 // Shape A est une face
1668 else if (ShapeA.ShapeType()==TopAbs_FACE ) {
1670 // on recupere un edge de la face.
1671 TopoDS_Face FaceA=TopoDS::Face(ShapeA);
1673 TopExp_Explorer FaceExp(FaceA,TopAbs_EDGE);
1674 TopoDS_Edge EdgeFromA=TopoDS::Edge(FaceExp.Current() );
1676 // Recuperation du rayon
1677 BRepAdaptor_Curve theCurve(EdgeFromA );
1678 if (theCurve.GetType()!=GeomAbs_Circle ) {di<<"vradiusdim error: the face is not a circular one."<<"\n";return 1;}
1680 gp_Circ theGpCircle=theCurve.Circle();
1681 theRadius=theGpCircle.Radius();
1682 // On arrondit le rayon
1683 theRadius=Round (theRadius*10. )/10.;
1686 // Construction du texte.
1687 TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("r=")+TCollection_ExtendedString(theRadius ) );
1689 // Fermeture du contexte.
1690 TheAISContext()->CloseLocalContext(myCurrentIndex);
1692 // Construction de L'AIS_RadiusDimension.
1693 Handle (AIS_RadiusDimension) myRadDim= new AIS_RadiusDimension(ShapeA);
1694 GetMapOfAIS().Bind (myRadDim,argv[1]);
1695 TheAISContext()->Display(myRadDim );
1701 di<<" vradiusdim error: the selection of a face or an edge was expected."<<"\n";return 1;
1710 //==============================================================================
1711 //function : VOffsetDim
1712 //purpose : Display the offset dimension
1713 //Draw arg : voffsetdim Name
1714 //==============================================================================
1715 #include <AIS_OffsetDimension.hxx>
1716 #include <TCollection_ExtendedString.hxx>
1717 #include <BRepExtrema_ExtFF.hxx>
1720 static int VOffsetDimBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1723 Standard_Integer myCurrentIndex;
1724 Standard_Real theDist;
1727 if (argc!=2) {di<<" voffsetdim error"<<"\n";return 1;}
1729 // Fermeture des contextes locaux
1730 TheAISContext()->CloseAllContexts();
1732 // Ouverture d'un contexte local et recuperation de son index.
1733 TheAISContext()->OpenLocalContext();
1734 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
1736 // On active les modes de selections Faces.
1737 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
1738 di<<" Select a face."<<"\n";
1740 // Boucle d'attente waitpick.
1741 Standard_Integer argcc = 5;
1742 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1743 const char **argvv = (const char **) buff;
1744 while (ViewerMainLoop( argcc, argvv) ) { }
1747 TopoDS_Shape ShapeA;
1748 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
1749 ShapeA = TheAISContext()->SelectedShape();
1752 di<<" Select a face."<<"\n";
1753 // Boucle d'attente waitpick.
1754 Standard_Integer argccc = 5;
1755 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1756 const char **argvvv = (const char **) bufff;
1757 while (ViewerMainLoop( argccc, argvvv) ) { }
1760 TopoDS_Shape ShapeB;
1761 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
1762 ShapeB = TheAISContext()->SelectedShape();
1766 // Shape A et B est une face
1767 if (ShapeA.ShapeType()==TopAbs_FACE && ShapeB.ShapeType()==TopAbs_FACE ) {
1769 TopoDS_Face FaceA=TopoDS::Face(ShapeA);
1770 TopoDS_Face FaceB=TopoDS::Face(ShapeB);
1772 BRepExtrema_ExtFF myDeltaFaceFace (FaceA ,FaceB );
1773 // On verifie que les deux faces sont bien parelles.
1774 if (!myDeltaFaceFace.IsParallel() ) {di<<"vdistdim error: the faces are not parallel. "<<"\n";return 1; }
1776 // On saisit la distance et on l'arrondit!
1777 theDist=Round (sqrt (myDeltaFaceFace.SquareDistance(1))*10. )/10.;
1778 // Fermeture du contexte local.
1779 TheAISContext()->CloseLocalContext(myCurrentIndex);
1780 // Construction du texte.
1781 TCollection_ExtendedString TheMessage_Str(TCollection_ExtendedString("offset=")+TCollection_ExtendedString(theDist ) );
1783 // on construit l'AIS_OffsetDimension
1784 Handle(AIS_OffsetDimension) myOffsetDim=new AIS_OffsetDimension (FaceA,FaceB,theDist,TheMessage_Str );
1785 TheAISContext()->Display(myOffsetDim );
1786 GetMapOfAIS().Bind (myOffsetDim ,argv[1]);
1793 di<<" voffsetdim error: the selection of a face was expected."<<"\n";return 1;
1803 //==============================================================================
1804 //function : VParallel
1805 //purpose : Display the parallel relation
1806 //Draw arg : vparallel Name
1807 //==============================================================================
1808 #include <AIS_ParallelRelation.hxx>
1809 #include <TCollection_ExtendedString.hxx>
1810 #include <BRepExtrema_ExtFF.hxx>
1811 #include <BRepExtrema_ExtCC.hxx>
1812 #include <GC_MakePlane.hxx>
1813 #include <BRepAdaptor_Curve.hxx>
1814 #include <TopExp_Explorer.hxx>
1817 static int VParallelBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1820 Standard_Integer myCurrentIndex;
1823 if (argc!=2) {di<<" vparallel error"<<"\n";return 1;}
1825 // Fermeture des contextes locaux
1826 TheAISContext()->CloseAllContexts();
1828 // Ouverture d'un contexte local et recuperation de son index.
1829 TheAISContext()->OpenLocalContext();
1830 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
1832 // On active les modes de selections Edges.
1833 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
1834 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
1835 di<<" Select an edge or a face "<<"\n";
1837 // Boucle d'attente waitpick.
1838 Standard_Integer argcc = 5;
1839 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1840 const char **argvv = (const char **) buff;
1841 while (ViewerMainLoop( argcc, argvv) ) { }
1844 TopoDS_Shape ShapeA;
1845 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
1846 ShapeA = TheAISContext()->SelectedShape();
1849 // SahpeA est un edge.
1850 // ===================
1851 if (ShapeA.ShapeType()==TopAbs_EDGE ) {
1853 // desactivation du mode face
1854 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) );
1855 di<<" Select a second edge"<<"\n";
1856 // Boucle d'attente waitpick.
1857 Standard_Integer argccc = 5;
1858 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1859 const char **argvvv = (const char **) bufff;
1860 while (ViewerMainLoop( argccc, argvvv) ) { }
1863 TopoDS_Shape ShapeB;
1864 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
1865 ShapeB = TheAISContext()->SelectedShape();
1868 // recuperation des edges.
1869 TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA);
1870 TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB);
1871 BRepExtrema_ExtCC myDeltaEdge (EdgeA ,EdgeB );
1872 // on verifie qu'ils ne sont pas paralleles.
1873 if (!myDeltaEdge.IsParallel() ) {di<<"vparallel error: non parallel edges."<<"\n";return 1; }
1876 // On recupere les vertexes extremites des edge A et B.
1877 BRepAdaptor_Curve theCurveA(EdgeA);
1878 BRepAdaptor_Curve theCurveB(EdgeB);
1879 // On recupere 3 points A,B,C des curves.
1880 gp_Pnt A=theCurveA.Value(0.1);
1881 gp_Pnt B=theCurveA.Value(0.9);
1882 gp_Pnt C=theCurveB.Value(0.5);
1884 // Construction du Geom_Plane
1885 GC_MakePlane MkPlane(A,B,C);
1886 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
1887 // Fermeture du contexte local.
1888 TheAISContext()->CloseLocalContext(myCurrentIndex);
1889 // Construction de l'AIS_ParallelRelation
1890 Handle(AIS_ParallelRelation) myParaRelation= new AIS_ParallelRelation(EdgeA ,EdgeB ,theGeomPlane );
1891 TheAISContext()->Display(myParaRelation );
1892 GetMapOfAIS().Bind (myParaRelation ,argv[1]);
1897 // Shape A est une face
1898 // ====================
1901 // desactivation du mode edge
1902 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2) );
1903 di<<" Select a second edge"<<"\n";
1904 // Boucle d'attente waitpick.
1905 Standard_Integer argccc = 5;
1906 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1907 const char **argvvv = (const char **) bufff;
1908 while (ViewerMainLoop( argccc, argvvv) ) { }
1911 TopoDS_Shape ShapeB;
1912 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
1913 ShapeB = TheAISContext()->SelectedShape();
1916 TopoDS_Face FaceA=TopoDS::Face(ShapeA);
1917 TopoDS_Face FaceB=TopoDS::Face(ShapeB);
1919 BRepExtrema_ExtFF myDeltaFaceFace (FaceA ,FaceB );
1920 // On verifie que les deux faces sont bien parelles.
1921 if (!myDeltaFaceFace.IsParallel() ) {di<<"vdistdim error: the faces are not parallel. "<<"\n";return 1; }
1923 // recuperation des edges des faces.
1924 TopExp_Explorer FaceExpA(FaceA,TopAbs_EDGE);
1925 TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE);
1927 TopoDS_Edge EdgeA=TopoDS::Edge(FaceExpA.Current() );
1928 TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() );
1930 // On recupere les vertexes extremites des edge A et B.
1931 BRepAdaptor_Curve theCurveA(EdgeA);
1932 BRepAdaptor_Curve theCurveB(EdgeB);
1933 // On recupere 3 points A,B,C des curves.
1934 gp_Pnt A=theCurveA.Value(0.1);
1935 gp_Pnt B=theCurveA.Value(0.9);
1936 gp_Pnt C=theCurveB.Value(0.5);
1938 // Construction du Geom_Plane
1939 GC_MakePlane MkPlane(A,B,C);
1940 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
1941 // Fermeture du contexte local.
1942 TheAISContext()->CloseLocalContext(myCurrentIndex);
1943 // Construction de l'AIS_ParallelRelation
1944 Handle(AIS_ParallelRelation) myParaRelation= new AIS_ParallelRelation(FaceA ,FaceB ,theGeomPlane );
1945 TheAISContext()->Display(myParaRelation );
1946 GetMapOfAIS().Bind (myParaRelation ,argv[1]);
1960 //==============================================================================
1961 //function : VPerpendicularRelation
1962 //purpose : Display the Perpendicular Relation
1963 //Draw arg : vperpendicular Name
1964 //==============================================================================
1965 #include <AIS_PerpendicularRelation.hxx>
1966 #include <TCollection_ExtendedString.hxx>
1967 #include <GC_MakePlane.hxx>
1968 #include <BRepAdaptor_Curve.hxx>
1969 #include <TopExp_Explorer.hxx>
1973 static int VPerpendicularBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1976 Standard_Integer myCurrentIndex;
1979 if (argc!=2) {di<<" vortho error"<<"\n";return 1;}
1981 // Fermeture des contextes locaux
1982 TheAISContext()->CloseAllContexts();
1984 // Ouverture d'un contexte local et recuperation de son index.
1985 TheAISContext()->OpenLocalContext();
1986 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
1988 // On active les modes de selections Edges.
1989 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
1990 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
1991 di<<" Select an edge or a face "<<"\n";
1993 // Boucle d'attente waitpick.
1994 Standard_Integer argcc = 5;
1995 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
1996 const char **argvv = (const char **) buff;
1997 while (ViewerMainLoop( argcc, argvv) ) { }
2000 TopoDS_Shape ShapeA;
2001 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
2002 ShapeA = TheAISContext()->SelectedShape();
2005 // ShapeA est un edge.
2006 // ===================
2007 if (ShapeA.ShapeType()==TopAbs_EDGE ) {
2009 // desactivation du mode face
2010 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) );
2011 di<<" Select a second edge"<<"\n";
2012 // Boucle d'attente waitpick.
2013 Standard_Integer argccc = 5;
2014 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2015 const char **argvvv = (const char **) bufff;
2016 while (ViewerMainLoop( argccc, argvvv) ) { }
2019 TopoDS_Shape ShapeB;
2020 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
2021 ShapeB = TheAISContext()->SelectedShape();
2024 // recuperation des edges.
2025 TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA);
2026 TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB);
2028 // On recupere les curves
2029 BRepAdaptor_Curve theCurveA(EdgeA);
2030 BRepAdaptor_Curve theCurveB(EdgeB);
2031 // on verifie si les edges sont orthogonaux.
2032 //gp_Lin theLineA=theCurveA.Line();
2033 //gp_Lin theLineB=theCurveB.Line();
2034 //if (abs(theLineA.Angle(theLineB) ) != M_PI/2 ) {cout<<"vperpendicular error: Edges are not othogonals."<<endl;return 1;}
2036 // On recupere 3 points A,B,C des curves.
2037 gp_Pnt A=theCurveA.Value(0.1);
2038 gp_Pnt B=theCurveA.Value(0.9);
2039 gp_Pnt C=theCurveB.Value(0.5);
2040 // Construction du Geom_Plane
2041 GC_MakePlane MkPlane(A,B,C);
2042 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
2043 // Fermeture du contexte local.
2044 TheAISContext()->CloseLocalContext(myCurrentIndex);
2045 // Construction de l'AIS_ParallelRelation
2046 Handle(AIS_PerpendicularRelation) myOrthoRelation= new AIS_PerpendicularRelation (EdgeA ,EdgeB ,theGeomPlane );
2047 TheAISContext()->Display(myOrthoRelation );
2048 GetMapOfAIS().Bind (myOrthoRelation ,argv[1]);
2053 // Shape A est une face
2054 // ====================
2057 // desactivation du mode edge
2058 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2) );
2059 di<<" Select a second edge"<<"\n";
2060 // Boucle d'attente waitpick.
2061 Standard_Integer argccc = 5;
2062 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2063 const char **argvvv = (const char **) bufff;
2064 while (ViewerMainLoop( argccc, argvvv) ) { }
2067 TopoDS_Shape ShapeB;
2068 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
2069 ShapeB = TheAISContext()->SelectedShape();
2072 // pas de verification d'orthogonalite.
2073 TopoDS_Face FaceA=TopoDS::Face(ShapeA);
2074 TopoDS_Face FaceB=TopoDS::Face(ShapeB);
2076 // recuperation des edges des faces.
2077 TopExp_Explorer FaceExpA(FaceA,TopAbs_EDGE);
2078 TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE);
2080 TopoDS_Edge EdgeA=TopoDS::Edge(FaceExpA.Current() );
2081 TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() );
2083 // On recupere les vertexes extremites des edge A et B.
2084 BRepAdaptor_Curve theCurveA(EdgeA);
2085 BRepAdaptor_Curve theCurveB(EdgeB);
2086 // On recupere 3 points A,B,C des curves.
2087 gp_Pnt A=theCurveA.Value(0.1);
2088 gp_Pnt B=theCurveA.Value(0.9);
2089 gp_Pnt C=theCurveB.Value(0.5);
2090 // Construction du Geom_Plane
2091 GC_MakePlane MkPlane(A,B,C);
2092 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
2093 // Fermeture du contexte local.
2094 TheAISContext()->CloseLocalContext(myCurrentIndex);
2095 // Construction de l'AIS_PerpendicularRelation
2096 Handle(AIS_PerpendicularRelation) myOrthoRelation= new AIS_PerpendicularRelation(FaceA ,FaceB );
2097 TheAISContext()->Display(myOrthoRelation );
2098 GetMapOfAIS().Bind (myOrthoRelation ,argv[1]);
2110 //==============================================================================
2111 //function : VTangentRelation
2112 //purpose : Display the tangent Relation
2113 //Draw arg : vtangent Name
2114 //==============================================================================
2115 #include <AIS_TangentRelation.hxx>
2118 static int VTangentBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2121 Standard_Integer myCurrentIndex;
2124 if (argc!=2) {di<<" vtangent error"<<"\n";return 1;}
2126 // Fermeture des contextes locaux
2127 TheAISContext()->CloseAllContexts();
2129 // Ouverture d'un contexte local et recuperation de son index.
2130 TheAISContext()->OpenLocalContext();
2131 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
2133 // On active les modes de selections Edges.
2134 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
2135 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(4) );
2136 di<<" Select two coplanar edges(First the circular edge then the tangent edge) or two faces "<<"\n";
2138 // Boucle d'attente waitpick.
2139 Standard_Integer argcc = 5;
2140 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2141 const char **argvv = (const char **) buff;
2142 while (ViewerMainLoop( argcc, argvv) ) { }
2145 TopoDS_Shape ShapeA;
2146 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
2147 ShapeA = TheAISContext()->SelectedShape();
2150 // ShapeA est un edge.
2151 // ===================
2152 if (ShapeA.ShapeType()==TopAbs_EDGE ) {
2154 // desactivation du mode face
2155 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(4) );
2156 di<<" Select a second edge"<<"\n";
2157 // Boucle d'attente waitpick.
2158 Standard_Integer argccc = 5;
2159 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2160 const char **argvvv = (const char **) bufff;
2161 while (ViewerMainLoop( argccc, argvvv) ) { }
2164 TopoDS_Shape ShapeB;
2165 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
2166 ShapeB = TheAISContext()->SelectedShape();
2169 // recuperation des edges.
2170 TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA);
2171 TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB);
2173 // On recupere les curves
2174 BRepAdaptor_Curve theCurveA(EdgeA);
2175 BRepAdaptor_Curve theCurveB(EdgeB);
2177 // On recupere 3 points A,B,C des curves.
2178 gp_Pnt A=theCurveA.Value(0.1);
2179 gp_Pnt B=theCurveA.Value(0.9);
2180 gp_Pnt C=theCurveB.Value(0.5);
2182 // Construction du Geom_Plane
2183 GC_MakePlane MkPlane(A,B,C);
2184 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
2185 // Fermeture du contexte local.
2186 TheAISContext()->CloseLocalContext(myCurrentIndex);
2187 // Construction de l'AIS_TangentRelation
2188 Handle(AIS_TangentRelation) myTanRelation= new AIS_TangentRelation (EdgeA ,EdgeB ,theGeomPlane );
2189 TheAISContext()->Display(myTanRelation );
2190 GetMapOfAIS().Bind (myTanRelation ,argv[1]);
2195 // Shape A est une face
2196 // ====================
2199 // desactivation du mode edge
2200 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2) );
2201 di<<" Select a second edge"<<"\n";
2202 // Boucle d'attente waitpick.
2203 Standard_Integer argccc = 5;
2204 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2205 const char **argvvv = (const char **) bufff;
2206 while (ViewerMainLoop( argccc, argvvv) ) { }
2209 TopoDS_Shape ShapeB;
2210 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
2211 ShapeB = TheAISContext()->SelectedShape();
2214 TopoDS_Face FaceA=TopoDS::Face(ShapeA);
2215 TopoDS_Face FaceB=TopoDS::Face(ShapeB);
2217 // recuperation des edges des faces.
2218 TopExp_Explorer FaceExpA(FaceA,TopAbs_EDGE);
2219 TopExp_Explorer FaceExpB(FaceB,TopAbs_EDGE);
2221 TopoDS_Edge EdgeA=TopoDS::Edge(FaceExpA.Current() );
2222 TopoDS_Edge EdgeB=TopoDS::Edge(FaceExpB.Current() );
2224 // On recupere les vertexes extremites des edge A et B.
2225 BRepAdaptor_Curve theCurveA(EdgeA);
2226 BRepAdaptor_Curve theCurveB(EdgeB);
2227 // On recupere 3 points A,B,C des curves.
2228 gp_Pnt A=theCurveA.Value(0.1);
2229 gp_Pnt B=theCurveA.Value(0.9);
2230 gp_Pnt C=theCurveB.Value(0.5);
2232 // Construction du Geom_Plane
2233 GC_MakePlane MkPlane(A,B,C);
2234 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
2235 // Fermeture du contexte local.
2236 TheAISContext()->CloseLocalContext(myCurrentIndex);
2237 // Construction de l'AIS_PerpendicularRelation
2238 Handle(AIS_TangentRelation) myTanRelation= new AIS_TangentRelation(FaceA ,FaceB,theGeomPlane );
2239 TheAISContext()->Display(myTanRelation );
2240 GetMapOfAIS().Bind (myTanRelation ,argv[1]);
2251 //==============================================================================
2252 //function : VSymetricalRelation
2253 //purpose : Display the Symetrical Relation
2254 //Draw arg : vsymetric Name
2255 //==============================================================================
2256 #include <AIS_SymmetricRelation.hxx>
2259 static int VSymmetricBuilder(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2262 Standard_Integer myCurrentIndex;
2265 if (argc!=2) {di<<" vSymmetric error"<<"\n";return 1;}
2267 // Fermeture des contextes locaux
2268 TheAISContext()->CloseAllContexts();
2270 // Ouverture d'un contexte local et recuperation de son index.
2271 TheAISContext()->OpenLocalContext();
2272 myCurrentIndex=TheAISContext()->IndexOfCurrentLocal();
2274 // On active les modes de selections
2275 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
2276 di<<" Select an edge:the axis of symetry "<<"\n";
2278 // Boucle d'attente waitpick.
2279 Standard_Integer argcc = 5;
2280 const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2281 const char **argvv = (const char **) buff;
2282 while (ViewerMainLoop( argcc, argvv) ) { }
2285 TopoDS_Shape ShapeA;
2286 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
2287 ShapeA = TheAISContext()->SelectedShape();
2289 // recuperation des edges.
2290 TopoDS_Edge EdgeA=TopoDS::Edge(ShapeA);
2292 // On active les modes de selections
2293 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(2) );
2294 TheAISContext()->ActivateStandardMode (AIS_Shape::SelectionType(1) );
2295 di<<" Select two edges or two vertices. "<<"\n";
2297 // Boucle d'attente waitpick.
2298 Standard_Integer argcc2 = 5;
2299 // const char *buff2[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2300 const char **argvv2 = (const char **) buff;
2301 while (ViewerMainLoop( argcc2, argvv2) ) { }
2304 TopoDS_Shape ShapeB;
2305 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
2306 ShapeB = TheAISContext()->SelectedShape();
2313 // ShapeB est un edge.
2314 // ===================
2315 if (ShapeB.ShapeType()==TopAbs_EDGE ) {
2317 // desactivation du mode vertex
2318 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(1) );
2319 di<<" Select a second edge"<<"\n";
2320 // Boucle d'attente waitpick.
2321 Standard_Integer argccc = 5;
2322 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2323 const char **argvvv = (const char **) bufff;
2324 while (ViewerMainLoop( argccc, argvvv) ) { }
2327 TopoDS_Shape ShapeC;
2328 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
2329 ShapeC = TheAISContext()->SelectedShape();
2332 // recuperation des edges.
2333 TopoDS_Edge EdgeB=TopoDS::Edge(ShapeB);
2334 TopoDS_Edge EdgeC=TopoDS::Edge(ShapeC);
2335 // on verifie que les edges sont paralleles
2336 BRepExtrema_ExtCC myDeltaEdgeAB (EdgeA ,EdgeB );
2337 BRepExtrema_ExtCC myDeltaEdgeAC (EdgeA ,EdgeC );
2338 // on verifie qu'ils sont paralleles.
2339 if (!myDeltaEdgeAB.IsParallel() ) {di<<"vsymetric error: non parallel edges."<<"\n";return 1; }
2340 if (!myDeltaEdgeAC.IsParallel() ) {di<<"vsymetric error: non parallel edges."<<"\n";return 1; }
2341 // on recupere les vertexs
2342 TopoDS_Vertex Va,Vb,Vc,Vd;
2343 TopExp::Vertices(EdgeB,Va,Vb );
2344 TopExp::Vertices(EdgeC,Vc,Vd );
2345 gp_Pnt A=BRep_Tool::Pnt(Va);
2346 gp_Pnt B=BRep_Tool::Pnt(Vc);
2347 gp_Pnt C = Get3DPointAtMousePosition();
2349 // gp_Pnt C=BRep_Tool::Pnt(Vc);
2350 // Construction du Geom_Plane
2351 GC_MakePlane MkPlane(A,B,C);
2352 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
2353 // Fermeture du contexte local.
2354 TheAISContext()->CloseLocalContext(myCurrentIndex);
2355 // Construction de l'AIS_SymmetricRelation
2356 Handle(AIS_SymmetricRelation) mySymRelation= new AIS_SymmetricRelation (EdgeA ,EdgeB ,EdgeC, theGeomPlane );
2357 TheAISContext()->Display(mySymRelation );
2358 GetMapOfAIS().Bind (mySymRelation ,argv[1]);
2363 // Shape B est un vertex
2364 // =====================
2367 // desactivation du mode edge
2368 TheAISContext()->DeactivateStandardMode (AIS_Shape::SelectionType(2) );
2369 di<<" Select a second edge"<<"\n";
2370 // Boucle d'attente waitpick.
2371 Standard_Integer argccc = 5;
2372 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2373 const char **argvvv = (const char **) bufff;
2374 while (ViewerMainLoop( argccc, argvvv) ) { }
2377 TopoDS_Shape ShapeC;
2378 for(TheAISContext()->InitSelected() ;TheAISContext()->MoreSelected() ;TheAISContext()->NextSelected() ) {
2379 ShapeC = TheAISContext()->SelectedShape();
2382 // recuperation des Vertex
2383 TopoDS_Vertex VertexB=TopoDS::Vertex(ShapeB);
2384 TopoDS_Vertex VertexC=TopoDS::Vertex(ShapeC);
2385 // transfo en gp_Pnt
2386 gp_Pnt B=BRep_Tool::Pnt(VertexB);
2387 gp_Pnt C=BRep_Tool::Pnt(VertexC);
2389 // on recupere les vertexes de l'axe de sym
2390 TopoDS_Vertex Va,Vb;
2391 TopExp::Vertices(EdgeA,Va,Vb );
2392 gp_Pnt A=BRep_Tool::Pnt(Va);
2393 // Construction du Geom_Plane
2394 GC_MakePlane MkPlane(A,B,C);
2395 Handle(Geom_Plane) theGeomPlane=MkPlane.Value();
2396 // Fermeture du contexte local.
2397 TheAISContext()->CloseLocalContext(myCurrentIndex);
2398 // Construction de l'AIS_SymmetricRelation
2399 Handle(AIS_SymmetricRelation) mySymRelation= new AIS_SymmetricRelation (EdgeA ,VertexB ,VertexC, theGeomPlane );
2400 TheAISContext()->Display(mySymRelation );
2401 GetMapOfAIS().Bind (mySymRelation ,argv[1]);
2411 //=======================================================================
2412 //function : VMoveDim
2414 //=======================================================================
2415 static int VMoveDim(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2417 if(argc>2) return 1;
2419 const Handle(V3d_View) aview = ViewerTest::CurrentView();
2420 Handle(AIS_InteractiveObject) pickedobj;
2422 pickedobj = TheAISContext()->FirstCurrentObject();
2423 if(pickedobj.IsNull() || pickedobj->Type()!=AIS_KOI_Relation)
2424 pickedobj = ViewerTest::PickObject(AIS_KOI_Relation);
2427 // reperage dans le viewer...
2428 if(!strcasecmp(argv[1],".")){
2429 pickedobj = ViewerTest::PickObject(AIS_KOI_Relation);
2432 else if(GetMapOfAIS().IsBound2(argv[1]))
2433 pickedobj = Handle(AIS_InteractiveObject)::DownCast
2434 (GetMapOfAIS().Find2(argv[1]));
2437 if(pickedobj.IsNull()){
2438 di<<"Bad Type Object"<<"\n";
2441 if(pickedobj->Type() != AIS_KOI_Relation)
2443 Standard_Integer argccc = 5;
2445 const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" };
2446 const char **argvvv = (const char **) bufff;
2448 Handle(AIS_Relation) R = *((Handle(AIS_Relation)*)&pickedobj);
2449 Handle(Geom_Plane) ThePl;
2450 // Standard_Real x,y,z,xv,yv,zv;
2451 Standard_Real x,y,xv,yv,zv;
2452 static Standard_Real last_xv(0),last_yv(0),last_zv(0);
2453 Standard_Integer xpix,ypix;
2454 // Standard_Boolean SameAsLast(Standard_False);
2455 Select3D_Projector prj(aview);
2458 while (ViewerMainLoop( argccc, argvvv) ) {
2459 //....... la ligne de tir
2460 ViewerTest::GetMousePosition(xpix,ypix);
2461 aview->Convert(xpix,ypix,x,y); // espace reel 2D de la vue...
2462 gp_Lin L = prj.Shoot(x,y);
2466 // ....... le plan de la vue...
2467 aview->Proj(xv,yv,zv);
2468 static Standard_Boolean haschanged(Standard_False);
2469 if(Abs(last_xv-xv)>Precision::Confusion() ||
2470 Abs(last_yv-yv)>Precision::Confusion() ||
2471 Abs(last_zv-zv)>Precision::Confusion() ){
2475 Standard_Real xat,yat,zat;
2476 aview->At(xat,yat,zat);
2477 ThePl = new Geom_Plane(gp_Pnt(xat,yat,zat),gp_Dir(xv,yv,zv));
2478 haschanged = Standard_True;
2479 di <<"changement de plan"<<"\n";
2483 // Standard_Integer xpix,ypix;
2484 // Standard_Real x,y;
2488 ComputeNewPlaneForDim(R,NewPlane,GoodPoint);
2489 haschanged = Standard_False;
2492 if(ComputeIntersection(L,ThePl->Pln(),GoodPoint)){
2493 R->SetPosition(GoodPoint);
2495 TheAISContext()->Redisplay(R);
2502 //=======================================================================
2503 //function : RelationsCommands
2505 //=======================================================================
2508 void ViewerTest::RelationCommands(Draw_Interpretor& theCommands)
2510 const char *group = "AISRelations";
2512 theCommands.Add("vdimension",
2513 "vdimension {angle|length|radius|diameter} name={Dim_Name} shape1 [shape2 [shape3]]\n"
2514 " [text={2d|3d}] [plane={xoy|yoz|zox}]\n"
2515 " [label={left|right|hcenter|hfit},{above|below|vcenter}]\n"
2516 " [flyout=value] [arrows={external|internal|fit}]\n"
2517 " -Builds angle, length, radius and diameter dimensions.\n"
2518 __FILE__,VDimBuilder,group);
2520 theCommands.Add("vangledim",
2521 "vangledim Name:Selection in the viewer only ",
2522 __FILE__,VAngleDimBuilder,group);
2524 theCommands.Add("vdiameterdim",
2525 "vdiameterdim Name : Selection in the viewer only ",
2526 __FILE__,VDiameterDimBuilder,group);
2528 theCommands.Add("vconcentric",
2529 "vconcentric Name : Selection in the viewer only ",
2530 __FILE__,VConcentricBuilder,group);
2532 theCommands.Add("vequaldist",
2533 "vequaldist Name Selection in the viewer only ",
2534 __FILE__,VEqualDistRelation ,group);
2536 theCommands.Add("vequalrad",
2537 "vequalrad Name Selection in the viewer only ",
2538 __FILE__,VEqualRadiusRelation ,group);
2540 theCommands.Add("vfix",
2541 "vfix Name Selection in the viewer only ",
2542 __FILE__,VFixRelation ,group);
2544 theCommands.Add("videntity",
2545 "videntity Name Selection in the viewer only ",
2546 __FILE__,VIdenticRelation ,group);
2548 theCommands.Add("vdistdim",
2549 "vdistdim Name Selection in the viewer only ",
2550 __FILE__,VLenghtDimension ,group);
2552 theCommands.Add("vradiusdim",
2553 "vradiusdim Name Selection in the viewer only ",
2554 __FILE__,VRadiusDimBuilder ,group);
2556 theCommands.Add("voffsetdim",
2557 "voffsetdim Name Selection in the viewer only ",
2558 __FILE__,VOffsetDimBuilder ,group);
2560 theCommands.Add("vparallel",
2561 "vparallel Name Selection in the viewer only ",
2562 __FILE__,VParallelBuilder ,group);
2564 theCommands.Add("vortho",
2565 "vortho Name Selection in the viewer only ",
2566 __FILE__,VPerpendicularBuilder ,group);
2568 theCommands.Add("vtangent",
2569 "vtangent Name Selection in the viewer only ",
2570 __FILE__,VTangentBuilder ,group);
2573 theCommands.Add("vsymetric",
2574 "vsymetric Name Selection in the viewer only ",
2575 __FILE__,VSymmetricBuilder ,group);
2577 theCommands.Add("vmovedim",
2578 "vmovedim [name] : move Mouse in the viewer; click MB1 to stop motion...",
2579 __FILE__,VMoveDim,group);