0022980: Fixed Standard_Atomic.hxx
[occt.git] / src / QABugs / QABugs_12.cxx
CommitLineData
b311480e 1// Created on: 2002-10-24
2// Created by: Michael KUZMITCHEV
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
21
1cd84fee 22#include <QABugs.hxx>
7fd59977 23
24#include <Draw_Interpretor.hxx>
25#include <DBRep.hxx>
26#include <DrawTrSurf.hxx>
27#include <AIS_InteractiveContext.hxx>
28#include <ViewerTest.hxx>
29#include <AIS_Shape.hxx>
30#include <TopoDS_Shape.hxx>
31
32#include <gp_Pnt.hxx>
33#include <gp_Ax2.hxx>
34#include <gp.hxx>
35#include <gp_Ax1.hxx>
36#include <gce_MakeCirc.hxx>
37#include <gp_Circ.hxx>
38#include <GC_MakeArcOfCircle.hxx>
39#include <BRepBuilderAPI_MakeEdge.hxx>
40#include <TopoDS_Edge.hxx>
41#include <BRepBuilderAPI_MakeWire.hxx>
42#include <TopoDS_Wire.hxx>
43#include <Geom_TrimmedCurve.hxx>
44#include <BRepOffsetAPI_ThruSections.hxx>
45//=======================================================================
46// OCC895
47//=======================================================================
48static Standard_Integer OCC895 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
49{
50 if (argc < 2 || argc > 5)
51 {
52 di << "Usage : " << argv[0] << " result [angle [reverse [order]]]" << "\n";
53 return 1;
54 }
55
56 const Standard_Real rad = 1.0;
57 const Standard_Real angle = (argc > 2)? atof(argv[2]) : 0.0;
58 const Standard_Integer reverse = (argc > 3)? atoi(argv[3]) : 0;
59 const Standard_Integer order = (argc > 4)? atoi(argv[4]) : 0;
60
61 // Make a wire from the first arc for ThruSections.
62 //
63 // This arc is rotated 5 degrees about the Z axis.
64 // I don't know why, but if we don't rotate it,
65 // the final shell is not twisted.
66 gp_Pnt center1(0,10,0);
67 gp_Ax2 axis1 = reverse?
68 gp_Ax2(center1, gp::DY(), gp::DZ()) : gp_Ax2(center1, -gp::DY(), gp::DX());
69 if (Abs(angle) > gp::Resolution())
c6541a0c 70 axis1.Rotate(gp_Ax1(center1, gp::DZ()), angle*M_PI/180.0);
7fd59977 71
72 gce_MakeCirc makeCirc1(axis1, rad);
73 if(!makeCirc1.IsDone()) return 1;
74 gp_Circ circ1 = makeCirc1.Value();
c6541a0c 75 GC_MakeArcOfCircle makeArc1(circ1, 0, M_PI/2, Standard_True);
7fd59977 76 if(!makeArc1.IsDone()) return 1;
77 Handle_Geom_TrimmedCurve arc1 = makeArc1.Value();
78
79 // Create wire 1
80 BRepBuilderAPI_MakeEdge makeEdge1(arc1, arc1->StartPoint(), arc1->EndPoint());
81 if(!makeEdge1.IsDone()) return 1;
82 TopoDS_Edge edge1 = makeEdge1.Edge();
83 BRepBuilderAPI_MakeWire makeWire1;
84 makeWire1.Add(edge1);
85 if(!makeWire1.IsDone()) return 1;
86 TopoDS_Wire wire1 = makeWire1.Wire();
87
88 // Make a wire from the second arc for ThruSections.
89 gp_Pnt center2(10,0,0);
90 gp_Ax2 axis2(center2, -gp::DX(), gp::DZ());
91
92 gce_MakeCirc makeCirc2(axis2, rad);
93 if(!makeCirc2.IsDone()) return 1;
94 gp_Circ circ2 = makeCirc2.Value();
c6541a0c 95 GC_MakeArcOfCircle makeArc2(circ2, 0, M_PI/2, Standard_True);
7fd59977 96 if(!makeArc2.IsDone()) return 1;
97 Handle_Geom_TrimmedCurve arc2 = makeArc2.Value();
98
99 // Create wire 2
100 BRepBuilderAPI_MakeEdge makeEdge2(arc2, arc2->StartPoint(), arc2->EndPoint());
101 if(!makeEdge2.IsDone()) return 1;
102 TopoDS_Edge edge2 = makeEdge2.Edge();
103 BRepBuilderAPI_MakeWire makeWire2;
104 makeWire2.Add(edge2);
105 if(!makeWire2.IsDone()) return 1;
106 TopoDS_Wire wire2 = makeWire2.Wire();
107
108 BRepOffsetAPI_ThruSections thruSect(Standard_False,Standard_True);
109 if (order)
110 {
111 thruSect.AddWire(wire1);
112 thruSect.AddWire(wire2);
113 }
114 else
115 {
116 thruSect.AddWire(wire2);
117 thruSect.AddWire(wire1);
118 }
119 thruSect.Build();
120 if(!thruSect.IsDone()) return 1;
121 TopoDS_Shape myShape = thruSect.Shape();
122
123 DBRep::Set(argv[1],myShape);
124
125 return 0;
126}
127
1cd84fee 128void QABugs::Commands_12(Draw_Interpretor& theCommands) {
1365140b 129 const char *group = "QABugs";
7fd59977 130
131 theCommands.Add ("OCC895", "OCC895 result [angle [reverse [order]]]", __FILE__, OCC895, group);
132
133 return;
134}