1 // Created on: 2002-10-24
2 // Created by: Michael KUZMITCHEV
3 // Copyright (c) 2002-2012 OPEN CASCADE SAS
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.
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.
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.
24 #include <Draw_Interpretor.hxx>
26 #include <DrawTrSurf.hxx>
27 #include <AIS_InteractiveContext.hxx>
28 #include <ViewerTest.hxx>
29 #include <AIS_Shape.hxx>
30 #include <TopoDS_Shape.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 //=======================================================================
47 //=======================================================================
48 static Standard_Integer OCC895 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
50 if (argc < 2 || argc > 5)
52 di << "Usage : " << argv[0] << " result [angle [reverse [order]]]" << "\n";
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;
61 // Make a wire from the first arc for ThruSections.
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())
70 axis1.Rotate(gp_Ax1(center1, gp::DZ()), angle*M_PI/180.0);
72 gce_MakeCirc makeCirc1(axis1, rad);
73 if(!makeCirc1.IsDone()) return 1;
74 gp_Circ circ1 = makeCirc1.Value();
75 GC_MakeArcOfCircle makeArc1(circ1, 0, M_PI/2, Standard_True);
76 if(!makeArc1.IsDone()) return 1;
77 Handle_Geom_TrimmedCurve arc1 = makeArc1.Value();
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;
85 if(!makeWire1.IsDone()) return 1;
86 TopoDS_Wire wire1 = makeWire1.Wire();
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());
92 gce_MakeCirc makeCirc2(axis2, rad);
93 if(!makeCirc2.IsDone()) return 1;
94 gp_Circ circ2 = makeCirc2.Value();
95 GC_MakeArcOfCircle makeArc2(circ2, 0, M_PI/2, Standard_True);
96 if(!makeArc2.IsDone()) return 1;
97 Handle_Geom_TrimmedCurve arc2 = makeArc2.Value();
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();
108 BRepOffsetAPI_ThruSections thruSect(Standard_False,Standard_True);
111 thruSect.AddWire(wire1);
112 thruSect.AddWire(wire2);
116 thruSect.AddWire(wire2);
117 thruSect.AddWire(wire1);
120 if(!thruSect.IsDone()) return 1;
121 TopoDS_Shape myShape = thruSect.Shape();
123 DBRep::Set(argv[1],myShape);
128 void QABugs::Commands_12(Draw_Interpretor& theCommands) {
129 char *group = "QABugs";
131 theCommands.Add ("OCC895", "OCC895 result [angle [reverse [order]]]", __FILE__, OCC895, group);