1 // File: BRepTest_ChamferCommands.cxx
2 // Created: Mon Sep 25 14:07:55 1995
3 // Author: Stagiaire Flore Lautheanne
10 #include <Draw_Interpretor.hxx>
11 #include <BRepTest.hxx>
13 #include <BRepFilletAPI_MakeChamfer.hxx>
14 #include <TopAbs_ShapeEnum.hxx>
16 #include <TopoDS_Face.hxx>
17 #include <TopoDS_Edge.hxx>
18 #include <TopoDS_Vertex.hxx>
19 #include <TopoDS_Shape.hxx>
21 #include <Precision.hxx>
28 //=========================================================================
30 // purpose : command to construct chamfers on several edges
31 // Here the chamfer is propagated on tangential edges to the
33 //=========================================================================
35 static Standard_Integer chamfer(Draw_Interpretor& di,
36 Standard_Integer narg,
40 // check the argument number of the command
42 //cout <<" help for chamf : "<< endl;
43 //cout <<" Construction by equal distances from edge : chamf newname shape edge face S dist"<< endl;
44 //cout <<" Construction by two distances from edge : chamf newname shape edge face dist1 dist2"<< endl;
45 //cout <<" Construction by distance from edge and given angle : chamf newname shape edge face A dist angle"<< endl;
46 di <<" help for chamf : "<< "\n";
47 di <<" Construction by equal distances from edge : chamf newname shape edge face S dist"<< "\n";
48 di <<" Construction by two distances from edge : chamf newname shape edge face dist1 dist2"<< "\n";
49 di <<" Construction by distance from edge and given angle : chamf newname shape edge face A dist angle"<< "\n";
52 if (narg < 7) return 1;
54 TopoDS_Shape S = DBRep::Get(a[2]);
55 if (S.IsNull()) return 1;
59 Standard_Real d1,d2, angle;
60 Standard_Integer i = 3;
61 Standard_Integer Method = 1;
62 Standard_Integer NbArg = 3;
64 BRepFilletAPI_MakeChamfer aMCh(S);
66 if (!strcasecmp(a[i + 2], "S") ) Method = 0;
69 if (!strcasecmp(a[i + 2], "A")) {
75 while (i + NbArg < narg) {
76 TopoDS_Shape aLocalEdge(DBRep::Get(a[i], TopAbs_EDGE));
77 E = TopoDS::Edge(aLocalEdge);
78 TopoDS_Shape aLocalFace(DBRep::Get(a[i + 1], TopAbs_FACE));
79 F = TopoDS::Face(aLocalFace);
80 // E = TopoDS::Edge(DBRep::Get(a[i], TopAbs_EDGE));
81 // F = TopoDS::Face(DBRep::Get(a[i + 1], TopAbs_FACE));
83 if (!E.IsNull() && !F.IsNull() && (aMCh.Contour(E) == 0) ) {
86 if ( d1 > Precision::Confusion())
91 else if (Method == 1) {
92 if (!E.IsNull() && !F.IsNull() && (aMCh.Contour(E) == 0) ) {
96 if ( (d1 > Precision::Confusion())
97 && (d2 > Precision::Confusion()) )
103 if (!E.IsNull() && !F.IsNull() && (aMCh.Contour(E) == 0) ) {
105 angle = atof(a[i + 4]);
108 if ( (d1 > Precision::Confusion())
109 && (angle > Precision::Confusion())
110 && (PI / 2.- angle > Precision::Confusion()) )
111 aMCh.AddDA(d1, angle, E, F);
119 if (!strcasecmp(a[i + 2], "S") ) Method = 0;
122 if (!strcasecmp(a[i + 2], "A")) {
131 // compute the chamfer and display the result
132 if (aMCh.NbContours() == 0 )
134 //cout<<"No suitable edges to chamfer"<<endl;
135 di<<"No suitable edges to chamfer"<<"\n";
141 DBRep::Set(a[1],aMCh);
145 //cout<<"compute of chamfer failed"<<endl;
146 di<<"compute of chamfer failed"<<"\n";
156 //=======================================================================
157 //function : ChamferCommands
159 //=======================================================================
161 void BRepTest::ChamferCommands(Draw_Interpretor& theCommands)
163 static Standard_Boolean done = Standard_False;
165 done = Standard_True;
167 DBRep::BasicCommands(theCommands);
169 const char* g = "TOPOLOGY Fillet construction commands";
171 // theCommands.Add("chamf",
172 // "chamf newname shape edge1 face1 dist1_1 dist1_2 edge2 face2 dist2_1 dist2_2 ... ",__FILE__,chamfer,g);
174 theCommands.Add("chamf",
175 "for help call chamf without arguments",__FILE__,chamfer,g);