1 // Modified: Tue Oct 15 10:12:02 1996
2 // Author: Joelle CHAUVET
4 // Add ChFi2d_TangencyError (PRO3529)
5 // Modified: Fri Sep 25 09:38:04 1998
6 // Author: Joelle CHAUVET
8 // status = ChFi2d_NotAuthorized if edges are not
9 // lines or circles (BUC60288) + partial_result
12 #include <TColgp_Array1OfPnt2d.hxx>
13 #include <BRepTest.hxx>
15 #include <Draw_Interpretor.hxx>
16 #include <Draw_Appli.hxx>
17 #include <BRepFilletAPI_MakeFillet2d.hxx>
18 #include <TopAbs_ShapeEnum.hxx>
19 #include <TopoDS_Shape.hxx>
20 #include <TopoDS_Edge.hxx>
21 #include <TopoDS_Vertex.hxx>
25 //=======================================================================
27 //purpose : 2d fillets and chamfers
28 //=======================================================================
30 static Standard_Integer chfi2d(Draw_Interpretor& di, Standard_Integer n, const char** a)
33 di << "chfi2d : not enough args";
37 // set up the algorithm
38 TopoDS_Shape F = DBRep::Get(a[2],TopAbs_FACE);
40 di << "chfi2d : "<< a[2] << " not a face";
44 BRepFilletAPI_MakeFillet2d MF(TopoDS::Face(F));
45 if (MF.Status() == ChFi2d_NotPlanar) {
46 di << "chfi2d : not a planar face";
51 Standard_Boolean partial_result = Standard_False;
52 Standard_Integer i = 3;
55 TopoDS_Shape aLocalEdge(DBRep::Get(a[i],TopAbs_EDGE));
56 TopoDS_Edge E1 = TopoDS::Edge(aLocalEdge);
57 aLocalEdge = DBRep::Get(a[i+1],TopAbs_EDGE);
58 TopoDS_Edge E2 = TopoDS::Edge(aLocalEdge);
59 // TopoDS_Edge E1 = TopoDS::Edge(DBRep::Get(a[i],TopAbs_EDGE));
60 // TopoDS_Edge E2 = TopoDS::Edge(DBRep::Get(a[i+1],TopAbs_EDGE));
62 if (E1.IsNull() || E2.IsNull()) {
63 di << "chfi2d : " << a[i] << " or " << a[i+1] << " not an edge";
65 di <<" WARNING : this is a partial result ";
72 if (!TopExp::CommonVertex(E1,E2,V)) {
73 di << "chfi2d " << a[i] << " and " << a[i+1] << " does not share a vertex";
75 di <<" WARNING : this is a partial result ";
83 di << "chfi2d : not enough args";
85 di <<" WARNING : this is a partial result ";
91 Standard_Real p1 = atof(a[i+1]);
97 di << "chfi2d : not enough args";
99 di <<" WARNING : this is a partial result ";
100 DBRep::Set(a[1],res);
104 Standard_Real p2 = atof(a[i+2]);
105 if (a[i][2] == 'D') {
106 MF.AddChamfer(E1,E2,p1,p2);
109 MF.AddChamfer(E1,V,p1,p2 * (M_PI / 180.0));
113 if (MF.Status() == ChFi2d_TangencyError) {
114 di << "chfi2d : " << a[i-2] << " and " << a[i-1] << " are tangent ";
115 if (partial_result) {
116 di <<" WARNING : this is a partial result ";
117 DBRep::Set(a[1],res);
122 if (MF.Status() == ChFi2d_NotAuthorized) {
123 di << "chfi2d : " << a[i-2] << " or " << a[i-1] << " is not a line or a circle ";
124 if (partial_result) {
125 di <<" WARNING : this is a partial result ";
126 DBRep::Set(a[1],res);
131 if (MF.Status() != ChFi2d_IsDone) {
132 di << "chfi2d : operation failed on " << a[i-2];
133 if (partial_result) {
134 di <<" WARNING : this is a partial result ";
135 DBRep::Set(a[1],res);
140 partial_result = Standard_True;
159 //=======================================================================
160 //function : Fillet2DCommands
162 //=======================================================================
164 void BRepTest::Fillet2DCommands(Draw_Interpretor& theCommands)
166 static Standard_Boolean done = Standard_False;
168 done = Standard_True;
170 DBRep::BasicCommands(theCommands);
172 const char* g = "TOPOLOGY Fillet2D construction commands";
174 theCommands.Add("chfi2d","chfi2d result face [edge1 edge2 (F radius/CDD d1 d2/CDA d ang) ....]",__FILE__,chfi2d,g);