1 // Created on: 2002-10-24
2 // Created by: Michael KUZMITCHEV
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
19 #include <Draw_Interpretor.hxx>
21 #include <DrawTrSurf.hxx>
22 #include <AIS_InteractiveContext.hxx>
23 #include <ViewerTest.hxx>
24 #include <AIS_Shape.hxx>
25 #include <TopoDS_Shape.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 //=======================================================================
42 //=======================================================================
43 static Standard_Integer OCC895 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
45 if (argc < 2 || argc > 5)
47 di << "Usage : " << argv[0] << " result [angle [reverse [order]]]\n";
51 const Standard_Real rad = 1.0;
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;
56 // Make a wire from the first arc for ThruSections.
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())
65 axis1.Rotate(gp_Ax1(center1, gp::DZ()), angle*M_PI/180.0);
67 gce_MakeCirc makeCirc1(axis1, rad);
68 if(!makeCirc1.IsDone()) return 1;
69 gp_Circ circ1 = makeCirc1.Value();
70 GC_MakeArcOfCircle makeArc1(circ1, 0, M_PI/2, Standard_True);
71 if(!makeArc1.IsDone()) return 1;
72 Handle(Geom_TrimmedCurve) arc1 = makeArc1.Value();
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;
80 if(!makeWire1.IsDone()) return 1;
81 TopoDS_Wire wire1 = makeWire1.Wire();
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());
87 gce_MakeCirc makeCirc2(axis2, rad);
88 if(!makeCirc2.IsDone()) return 1;
89 gp_Circ circ2 = makeCirc2.Value();
90 GC_MakeArcOfCircle makeArc2(circ2, 0, M_PI/2, Standard_True);
91 if(!makeArc2.IsDone()) return 1;
92 Handle(Geom_TrimmedCurve) arc2 = makeArc2.Value();
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;
100 if(!makeWire2.IsDone()) return 1;
101 TopoDS_Wire wire2 = makeWire2.Wire();
103 BRepOffsetAPI_ThruSections thruSect(Standard_False,Standard_True);
106 thruSect.AddWire(wire1);
107 thruSect.AddWire(wire2);
111 thruSect.AddWire(wire2);
112 thruSect.AddWire(wire1);
115 if(!thruSect.IsDone()) return 1;
116 TopoDS_Shape myShape = thruSect.Shape();
118 DBRep::Set(argv[1],myShape);
123 void QABugs::Commands_12(Draw_Interpretor& theCommands) {
124 const char *group = "QABugs";
126 theCommands.Add ("OCC895", "OCC895 result [angle [reverse [order]]]", __FILE__, OCC895, group);