0022492: Scaled sphere (Solid with BSplineSurface) is wrongly exported in STEP.
[occt.git] / src / QAMitutoyoUS / QAMitutoyoUS.cxx
CommitLineData
7fd59977 1// File: QAMitutoyoUS.cxx
2// Created: Mon Mar 18 19:04:01 2002
3// Author: QA Admin
4// <qa@umnox.nnov.matra-dtv.fr>
5
6
7#include <QAMitutoyoUS.hxx>
8
9#include <Draw_Interpretor.hxx>
10#include <DBRep.hxx>
11#include <DrawTrSurf.hxx>
12#include <AIS_InteractiveContext.hxx>
13#include <ViewerTest.hxx>
14#include <AIS_Shape.hxx>
15#include <TopoDS_Shape.hxx>
16
17#include <gp_Ax2.hxx>
18#include <gp_Pnt.hxx>
19#include <Geom_RectangularTrimmedSurface.hxx>
20#include <BRepBuilderAPI_MakeFace.hxx>
21#include <GC_MakeTrimmedCone.hxx>
22
23static Standard_Integer BUC60857 (Draw_Interpretor& di, Standard_Integer /*argc*/,const char ** argv)
24{
25 gp_Ax2 Cone_Ax;
26 double R1=8, R2=16, H1=20, H2=40, angle;
27 gp_Pnt P0(0,0,0), P1(0,0,20), P2(0,0,45);
28 angle = 2*PI;
29
30 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
31 if(aContext.IsNull()) {
32 di << "Use vinit command before " << argv[0] << "\n";
33 return 1;
34 }
35
36 Handle(Geom_RectangularTrimmedSurface) S = GC_MakeTrimmedCone (P1, P2, R1, R2).Value();
1c72dff6 37 TopoDS_Shape myshape = BRepBuilderAPI_MakeFace(S, Precision::Confusion()).Shape();
7fd59977 38 DBRep::Set("BUC60857_BLUE",myshape);
39 Handle(AIS_Shape) ais1 = new AIS_Shape(myshape);
40 aContext->Display(ais1);
41 aContext->SetColor(ais1, Quantity_NOC_BLUE1);
42
43 Handle(Geom_RectangularTrimmedSurface) S2 = GC_MakeTrimmedCone (P1, P2, R1, 0).Value();
1c72dff6 44 TopoDS_Shape myshape2 = BRepBuilderAPI_MakeFace(S2, Precision::Confusion()).Shape();
7fd59977 45 DBRep::Set("BUC60857_RED",myshape2);
46 Handle(AIS_Shape) ais2 = new AIS_Shape(myshape2);
47 aContext->Display(ais2);
48 aContext->SetColor(ais2, Quantity_NOC_RED);
49
50 Handle(Geom_RectangularTrimmedSurface) S3 = GC_MakeTrimmedCone (P1, P2, R2, R1).Value();
1c72dff6 51 TopoDS_Shape myshape3 = BRepBuilderAPI_MakeFace(S3, Precision::Confusion()).Shape();
7fd59977 52 DBRep::Set("BUC60857_GREEN",myshape3);
53 Handle(AIS_Shape) ais3 = new AIS_Shape(myshape3);
54 aContext->Display(ais3);
55 aContext->SetColor(ais3, Quantity_NOC_GREEN);
56
57 return 0;
58}
59
60#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
61#include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
62#include <SelectMgr_Selection.hxx>
63#include <StdSelect_BRepOwner.hxx>
64#include <SelectBasics_SensitiveEntity.hxx>
65#if ! defined(WNT)
66extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
67#else
68Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
69#endif
70
71static Standard_Integer OCC137 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
72{
73 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
74 if(aContext.IsNull()) {
75 di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
76 return 1;
77 }
78 if ( argc < 2 || argc > 3) {
79 di << "ERROR : Usage : " << argv[0] << " highlight_mode [shape]" << "\n";
80 return 1;
81 }
82
83 ViewerTest_DoubleMapOfInteractiveAndName aMap ;
84 if(argc != 3) {
85 aMap.Assign(GetMapOfAIS());
86 } else {
87 ViewerTest_DoubleMapOfInteractiveAndName& aMap1 = GetMapOfAIS();
88 TCollection_AsciiString aName(argv[2]);
89 Handle(AIS_InteractiveObject) AISObj;
90 if(!aMap1.IsBound2(aName)) {
91 di << "Use 'vdisplay' before" << "\n";
92 return 1;
93 } else {
94 AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap1.Find2(aName));
95 if(AISObj.IsNull()){
96 di << argv[2] << " : No interactive object" << "\n";
97 return 1;
98 }
99 aMap.Bind(AISObj,aName);
100 }
101 }
102 ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS());
103 while ( it.More() ) {
104 Handle(AIS_InteractiveObject) AISObj = Handle(AIS_InteractiveObject)::DownCast(it.Key1());
105 AISObj->SetHilightMode(atoi(argv[1]));
106 if(AISObj->HasSelection(4)) {
107 //Handle(SelectMgr_Selection)& aSelection = AISObj->Selection(4);
108 const Handle(SelectMgr_Selection)& aSelection = AISObj->Selection(4);
109 if(!aSelection.IsNull()) {
110 for(aSelection->Init();aSelection->More();aSelection->Next()) {
111 Handle(StdSelect_BRepOwner) aO = Handle(StdSelect_BRepOwner)::DownCast(aSelection->Sensitive()->OwnerId());
112 aO->SetHilightMode(atoi(argv[1]));
113 }
114 }
115 }
116 it.Next();
117 }
118
119 return 0;
120}
121
122static Standard_Integer OCC137_z (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
123{
124 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
125 if(aContext.IsNull()) {
126 di << argv[0] << "ERROR : use 'vinit' command before " << "\n";
127 return 1;
128 }
129 if ( argc != 1 && argc != 2) {
130 di << "ERROR : Usage : " << argv[0] << " [ZDetection_mode]" << "\n";
131 return 1;
132 }
133 aContext->SetZDetection(((argc == 1 || (argc == 2 && atoi(argv[1]) == 1)) ? Standard_True : Standard_False));
134 return 0;
135}
136
137void QAMitutoyoUS::Commands(Draw_Interpretor& theCommands) {
138 char *group = "QAMitutoyoUS";
139
140 theCommands.Add ("BUC60857", "BUC60857", __FILE__, BUC60857, group);
141 theCommands.Add("OCC137","OCC137 mode [shape]",__FILE__,OCC137,group);
142 theCommands.Add("OCC137_z","OCC137_z [ZDetection_mode]",__FILE__,OCC137_z,group);
143
144 return;
145}