Restoring test cases removed by last commit.
[occt.git] / src / QABugs / QABugs_19.cxx
CommitLineData
b311480e 1// Created on: 2002-05-21
2// Created by: QA Admin
3// Copyright (c) 2002-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20
1cd84fee 21#include <QABugs.hxx>
7fd59977 22
23#include <Draw_Interpretor.hxx>
24#include <DBRep.hxx>
25#include <DrawTrSurf.hxx>
26#include <AIS_InteractiveContext.hxx>
27#include <ViewerTest.hxx>
28#include <AIS_Shape.hxx>
29#include <TopoDS_Shape.hxx>
30
31#include <gp_Pnt2d.hxx>
f6f03db9 32#include <gp_Ax1.hxx>
7fd59977 33#include <GCE2d_MakeSegment.hxx>
34#include <Geom2d_TrimmedCurve.hxx>
35#include <DrawTrSurf.hxx>
36
f6f03db9 37#include <Precision.hxx>
38
7fd59977 39#include <PCollection_HAsciiString.hxx>
40
c2ae831c 41#include <cstdio>
42#include <cmath>
43#include <iostream>
44#include <OSD_PerfMeter.hxx>
45#include <OSD_Timer.hxx>
46#include <BRepPrimAPI_MakeBox.hxx>
47#include <BRepPrimAPI_MakeSphere.hxx>
48#include <BRepAlgo_Cut.hxx>
49
7fd59977 50//static Standard_Integer OCC230 (Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char ** /*argv*/)
51static Standard_Integer OCC230 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
52{
53 if ( argc != 4) {
54 di << "ERROR OCC230: Usage : " << argv[0] << " TrimmedCurve Pnt2d Pnt2d" << "\n";
55 return 1;
56 }
57
58 gp_Pnt2d P1, P2;
59 if ( !DrawTrSurf::GetPoint2d(argv[2],P1)) {
60 di << "ERROR OCC230: " << argv[2] << " is not Pnt2d" << "\n";
61 return 1;
62 }
63 if ( !DrawTrSurf::GetPoint2d(argv[3],P2)) {
64 di << "ERROR OCC230: " << argv[3] << " is not Pnt2d" << "\n";
65 return 1;
66 }
67
68 GCE2d_MakeSegment MakeSegment(P1,P2);
69 Handle(Geom2d_TrimmedCurve) TrimmedCurve = MakeSegment.Value();
70 DrawTrSurf::Set(argv[1], TrimmedCurve);
71 return 0;
72}
73
74static Standard_Integer OCC142 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
75{
76 for(Standard_Integer i= 0;i <= 20;i++){
77 Handle(PCollection_HAsciiString) pstr = new PCollection_HAsciiString("TEST");
78 pstr->Clear();
79 }
80 di << "OCC142: OK" << "\n";
81 return 0;
82}
83
f6f03db9 84static Standard_Integer OCC23361 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/)
85{
86 gp_Pnt p(0, 0, 2);
87
88 gp_Trsf t1, t2;
89 t1.SetRotation(gp_Ax1(p, gp_Dir(0, 1, 0)), -0.49328285294022267);
90 t2.SetRotation(gp_Ax1(p, gp_Dir(0, 0, 1)), 0.87538474718473880);
91
92 gp_Trsf tComp = t2 * t1;
93
94 gp_Pnt p1(10, 3, 4);
95 gp_Pnt p2 = p1.Transformed(tComp);
96 gp_Pnt p3 = p1.Transformed(t1);
97 p3.Transform(t2);
98
99 // points must be equal
100 if ( ! p2.IsEqual(p3, Precision::Confusion()) )
101 di << "ERROR OCC23361: equivalent transformations does not produce equal points" << "\n";
102 else
103 di << "OCC23361: OK" << "\n";
104
105 return 0;
106}
107
c2ae831c 108static Standard_Integer OCC23237 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
109{
110 OSD_PerfMeter aPM("TestMeter",0);
111 OSD_Timer aTM;
112
113 // run some operation in cycle for about 2 seconds to have good values of times to compare
114 int count = 0;
115 printf("OSD_PerfMeter test.\nRunning Boolean operation on solids in loop.\n");
116 for (; aTM.ElapsedTime() < 2.; count++)
117 {
118 aPM.Start();
119 aTM.Start();
120
121 // do some operation that will take considerable time compared with time or starting / stopping timers
122 BRepPrimAPI_MakeBox aBox (10., 10., 10.);
123 BRepPrimAPI_MakeSphere aSphere (10.);
124 BRepAlgo_Cut (aBox.Shape(), aSphere.Shape());
125
126 aTM.Stop();
127 aPM.Stop();
128 }
129
130 int aNbEnters = 0;
131 Standard_Real aPerfMeter_CPUtime = 0., aTimer_ElapsedTime = aTM.ElapsedTime();
132
133 perf_get_meter("TestMeter", &aNbEnters, &aPerfMeter_CPUtime);
134
135 Standard_Real aTimeDiff = (fabs(aTimer_ElapsedTime - aPerfMeter_CPUtime) / aTimer_ElapsedTime);
136
137 printf("\nMeasurement results (%d cycles):\n", count);
138 printf("\nOSD_PerfMeter CPU time: %lf\nOSD_Timer elapsed time: %lf\n", aPerfMeter_CPUtime, aTimer_ElapsedTime);
139 printf("Time delta is: %.3lf %%\n", aTimeDiff * 100);
140
141 if (aTimeDiff > 0.2)
142 di << "OCC23237: Error: too much difference between CPU and elapsed times";
143 else if (aNbEnters != count)
144 di << "OCC23237: Error: counter reported by PerfMeter (" << aNbEnters << ") does not correspond to actual number of cycles";
145 else
146 di << "OCC23237: OK";
147
148 return 0;
149}
150
1cd84fee 151void QABugs::Commands_19(Draw_Interpretor& theCommands) {
152 char *group = "QABugs";
7fd59977 153
154 theCommands.Add ("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group);
155 theCommands.Add ("OCC142", "OCC142", __FILE__, OCC142, group);
f6f03db9 156 theCommands.Add ("OCC23361", "OCC23361", __FILE__, OCC23361, group);
c2ae831c 157 theCommands.Add("OCC23237", "OCC23237", __FILE__, OCC23237, group);
7fd59977 158
159 return;
160}