b311480e |
1 | // Created on: 2002-10-24 |
2 | // Created by: Michael KUZMITCHEV |
973c2be1 |
3 | // Copyright (c) 2002-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
1cd84fee |
16 | #include <QABugs.hxx> |
7fd59977 |
17 | |
91322f44 |
18 | #include <Draw.hxx> |
7fd59977 |
19 | #include <Draw_Interpretor.hxx> |
20 | #include <DBRep.hxx> |
21 | #include <DrawTrSurf.hxx> |
22 | #include <AIS_InteractiveContext.hxx> |
23 | #include <ViewerTest.hxx> |
24 | #include <AIS_Shape.hxx> |
25 | #include <TopoDS_Shape.hxx> |
26 | |
27 | #include <gp_Pnt.hxx> |
28 | #include <gp_Ax2.hxx> |
29 | #include <gp.hxx> |
30 | #include <gp_Ax1.hxx> |
31 | #include <gce_MakeCirc.hxx> |
32 | #include <gp_Circ.hxx> |
33 | #include <GC_MakeArcOfCircle.hxx> |
34 | #include <BRepBuilderAPI_MakeEdge.hxx> |
35 | #include <TopoDS_Edge.hxx> |
36 | #include <BRepBuilderAPI_MakeWire.hxx> |
37 | #include <TopoDS_Wire.hxx> |
38 | #include <Geom_TrimmedCurve.hxx> |
39 | #include <BRepOffsetAPI_ThruSections.hxx> |
40 | //======================================================================= |
41 | // OCC895 |
42 | //======================================================================= |
43 | static Standard_Integer OCC895 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
44 | { |
45 | if (argc < 2 || argc > 5) |
46 | { |
47 | di << "Usage : " << argv[0] << " result [angle [reverse [order]]]" << "\n"; |
48 | return 1; |
49 | } |
50 | |
51 | const Standard_Real rad = 1.0; |
91322f44 |
52 | const Standard_Real angle = (argc > 2)? Draw::Atof(argv[2]) : 0.0; |
53 | const Standard_Integer reverse = (argc > 3)? Draw::Atoi(argv[3]) : 0; |
54 | const Standard_Integer order = (argc > 4)? Draw::Atoi(argv[4]) : 0; |
7fd59977 |
55 | |
56 | // Make a wire from the first arc for ThruSections. |
57 | // |
58 | // This arc is rotated 5 degrees about the Z axis. |
59 | // I don't know why, but if we don't rotate it, |
60 | // the final shell is not twisted. |
61 | gp_Pnt center1(0,10,0); |
62 | gp_Ax2 axis1 = reverse? |
63 | gp_Ax2(center1, gp::DY(), gp::DZ()) : gp_Ax2(center1, -gp::DY(), gp::DX()); |
64 | if (Abs(angle) > gp::Resolution()) |
c6541a0c |
65 | axis1.Rotate(gp_Ax1(center1, gp::DZ()), angle*M_PI/180.0); |
7fd59977 |
66 | |
67 | gce_MakeCirc makeCirc1(axis1, rad); |
68 | if(!makeCirc1.IsDone()) return 1; |
69 | gp_Circ circ1 = makeCirc1.Value(); |
c6541a0c |
70 | GC_MakeArcOfCircle makeArc1(circ1, 0, M_PI/2, Standard_True); |
7fd59977 |
71 | if(!makeArc1.IsDone()) return 1; |
857ffd5e |
72 | Handle(Geom_TrimmedCurve) arc1 = makeArc1.Value(); |
7fd59977 |
73 | |
74 | // Create wire 1 |
75 | BRepBuilderAPI_MakeEdge makeEdge1(arc1, arc1->StartPoint(), arc1->EndPoint()); |
76 | if(!makeEdge1.IsDone()) return 1; |
77 | TopoDS_Edge edge1 = makeEdge1.Edge(); |
78 | BRepBuilderAPI_MakeWire makeWire1; |
79 | makeWire1.Add(edge1); |
80 | if(!makeWire1.IsDone()) return 1; |
81 | TopoDS_Wire wire1 = makeWire1.Wire(); |
82 | |
83 | // Make a wire from the second arc for ThruSections. |
84 | gp_Pnt center2(10,0,0); |
85 | gp_Ax2 axis2(center2, -gp::DX(), gp::DZ()); |
86 | |
87 | gce_MakeCirc makeCirc2(axis2, rad); |
88 | if(!makeCirc2.IsDone()) return 1; |
89 | gp_Circ circ2 = makeCirc2.Value(); |
c6541a0c |
90 | GC_MakeArcOfCircle makeArc2(circ2, 0, M_PI/2, Standard_True); |
7fd59977 |
91 | if(!makeArc2.IsDone()) return 1; |
857ffd5e |
92 | Handle(Geom_TrimmedCurve) arc2 = makeArc2.Value(); |
7fd59977 |
93 | |
94 | // Create wire 2 |
95 | BRepBuilderAPI_MakeEdge makeEdge2(arc2, arc2->StartPoint(), arc2->EndPoint()); |
96 | if(!makeEdge2.IsDone()) return 1; |
97 | TopoDS_Edge edge2 = makeEdge2.Edge(); |
98 | BRepBuilderAPI_MakeWire makeWire2; |
99 | makeWire2.Add(edge2); |
100 | if(!makeWire2.IsDone()) return 1; |
101 | TopoDS_Wire wire2 = makeWire2.Wire(); |
102 | |
103 | BRepOffsetAPI_ThruSections thruSect(Standard_False,Standard_True); |
104 | if (order) |
105 | { |
106 | thruSect.AddWire(wire1); |
107 | thruSect.AddWire(wire2); |
108 | } |
109 | else |
110 | { |
111 | thruSect.AddWire(wire2); |
112 | thruSect.AddWire(wire1); |
113 | } |
114 | thruSect.Build(); |
115 | if(!thruSect.IsDone()) return 1; |
116 | TopoDS_Shape myShape = thruSect.Shape(); |
117 | |
118 | DBRep::Set(argv[1],myShape); |
119 | |
120 | return 0; |
121 | } |
122 | |
1cd84fee |
123 | void QABugs::Commands_12(Draw_Interpretor& theCommands) { |
1365140b |
124 | const char *group = "QABugs"; |
7fd59977 |
125 | |
126 | theCommands.Add ("OCC895", "OCC895 result [angle [reverse [order]]]", __FILE__, OCC895, group); |
127 | |
128 | return; |
129 | } |