1 // Created on: 1998-11-20
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <ViewerTest.hxx>
18 #include <BRepTest.hxx>
19 #include <TColgp_Array1OfPnt2d.hxx>
21 #include <Draw_Interpretor.hxx>
22 #include <Draw_Appli.hxx>
23 #include <BRepFilletAPI_MakeFillet.hxx>
24 #include <BiTgte_Blend.hxx>
25 #include <TopTools_ListIteratorOfListOfShape.hxx>
26 #include <TopAbs_ShapeEnum.hxx>
27 #include <TopoDS_Shape.hxx>
28 #include <TopoDS_Compound.hxx>
29 #include <TopoDS_Edge.hxx>
30 #include <TopoDS_Vertex.hxx>
33 #include <TopExp_Explorer.hxx>
35 #include <FilletSurf_Builder.hxx>
36 #include <ChFi3d_FilletShape.hxx>
37 #include <Geom_TrimmedCurve.hxx>
38 #include <TopTools_ListOfShape.hxx>
39 #include <FilletSurf_StatusType.hxx>
40 #include <FilletSurf_ErrorTypeStatus.hxx>
42 #include <DrawTrSurf.hxx>
43 #include <TopTools_HArray1OfShape.hxx>
45 #include <AIS_InteractiveContext.hxx>
46 #include <AIS_InteractiveObject.hxx>
47 #include <AIS_Shape.hxx>
50 //#define strcasecmp strcmp Already defined in Standard
54 static Standard_Real t3d = 1.e-4;
55 static Standard_Real t2d = 1.e-5;
56 static Standard_Real ta = 1.e-2;
57 static Standard_Real fl = 1.e-3;
58 static Standard_Real tapp_angle = 1.e-2;
59 static GeomAbs_Shape blend_cont = GeomAbs_C1;
61 static BRepFilletAPI_MakeFillet* Rakk = 0;
64 static void printtolblend(Draw_Interpretor& di)
66 di<<"tolerance ang : "<<ta<<"\n";
67 di<<"tolerance 3d : "<<t3d<<"\n";
68 di<<"tolerance 2d : "<<t2d<<"\n";
69 di<<"fleche : "<<fl<<"\n";
71 di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n";
74 static Standard_Integer VBLEND(Draw_Interpretor& di, Standard_Integer narg, const char** a)
76 if(Rakk != 0) {delete Rakk; Rakk = 0;}
80 Standard_Integer NbToPick = (narg -4)/2;
81 Handle(TopTools_HArray1OfShape) arr = new TopTools_HArray1OfShape(1,NbToPick);
82 if(ViewerTest::PickShapes(TopAbs_EDGE,arr)){
83 for(Standard_Integer i=1;i<=NbToPick;i++){
84 TopoDS_Shape PickSh = arr->Value(i);
86 DBRep::Set(a[(2*i+2)],PickSh);
91 TopoDS_Shape V = DBRep::Get(a[2]);
92 if(V.IsNull()) return 1;
93 ChFi3d_FilletShape FSh = ChFi3d_Rational;
95 if (!strcasecmp(a[narg-1], "Q")) {
96 FSh = ChFi3d_QuasiAngular;
98 else if (!strcasecmp(a[narg-1], "P")) {
99 FSh = ChFi3d_Polynomial;
102 Rakk = new BRepFilletAPI_MakeFillet(V,FSh);
103 Rakk->SetParams(ta,t3d,t2d,t3d,t2d,fl);
104 Rakk->SetContinuity(blend_cont, tapp_angle);
107 Standard_Integer nbedge = 0;
108 for (Standard_Integer ii = 1; ii < (narg-1)/2; ii++){
109 Rad = Draw::Atof(a[2*ii + 1]);
110 TopoDS_Shape aLocalShape = DBRep::Get(a[(2*ii+2)],TopAbs_EDGE);
111 E = TopoDS::Edge(aLocalShape);
112 // E = TopoDS::Edge(DBRep::Get(a[(2*ii+2)],TopAbs_EDGE));
118 if(!nbedge) return 1;
120 if(!Rakk->IsDone()) return 1;
121 TopoDS_Shape res = Rakk->Shape();
122 DBRep::Set(a[1],res);
125 ViewerTest::Display (a[2], Handle(AIS_InteractiveObject)(), false);
126 ViewerTest::Display (a[1], new AIS_Shape (res), true);
133 void ViewerTest::FilletCommands(Draw_Interpretor& theCommands)
135 const char* g = "Viewer Fillet construction commands";
136 theCommands.Add("vblend",
137 "vblend result object rad1 ed1 rad2 ed2 ... [R/Q/P]",__FILE__,