1 // File: ViewerTest_FilletCommands.cxx
2 // Created: Fri Nov 20 16:58:22 1998
3 // Author: Robert COUBLANC
4 // <rob@robox.paris1.matra-dtv.fr>
10 #include <ViewerTest.hxx>
12 #include <BRepTest.hxx>
13 #include <TColgp_Array1OfPnt2d.hxx>
15 #include <Draw_Interpretor.hxx>
16 #include <Draw_Appli.hxx>
17 #include <BRepFilletAPI_MakeFillet.hxx>
18 //#include <BRepAlgo_BooleanOperation.hxx>
19 //#include <BRepAlgo_Fuse.hxx>
20 //#include <BRepAlgo_Cut.hxx>
21 #include <BiTgte_Blend.hxx>
22 #include <TopOpeBRepBuild_HBuilder.hxx>
23 #include <TopTools_ListIteratorOfListOfShape.hxx>
24 #include <TopAbs_ShapeEnum.hxx>
25 #include <TopoDS_Shape.hxx>
26 #include <TopoDS_Compound.hxx>
27 #include <TopoDS_Edge.hxx>
28 #include <TopoDS_Vertex.hxx>
31 #include <TopExp_Explorer.hxx>
33 #include <FilletSurf_Builder.hxx>
34 #include <ChFi3d_FilletShape.hxx>
35 #include <Geom_TrimmedCurve.hxx>
36 #include <TopTools_ListOfShape.hxx>
37 #include <FilletSurf_StatusType.hxx>
38 #include <FilletSurf_ErrorTypeStatus.hxx>
40 #include <DrawTrSurf.hxx>
41 #include <TopTools_HArray1OfShape.hxx>
43 #include <AIS_InteractiveContext.hxx>
44 #include <AIS_InteractiveObject.hxx>
45 #include <AIS_Shape.hxx>
51 //#define strcasecmp strcmp Already defined in Standard
55 extern Handle(AIS_Shape) GetAISShapeFromName(const char* name);
58 static Standard_Real t3d = 1.e-4;
59 static Standard_Real t2d = 1.e-5;
60 static Standard_Real ta = 1.e-2;
61 static Standard_Real fl = 1.e-3;
62 static Standard_Real tapp_angle = 1.e-2;
63 static GeomAbs_Shape blend_cont = GeomAbs_C1;
65 static BRepFilletAPI_MakeFillet* Rakk = 0;
67 static BRepFilletAPI_MakeFillet* Rake = 0;
68 static char name[100];
72 static void printtolblend(Draw_Interpretor& di)
74 di<<"tolerance ang : "<<ta<<"\n";
75 di<<"tolerance 3d : "<<t3d<<"\n";
76 di<<"tolerance 2d : "<<t2d<<"\n";
77 di<<"fleche : "<<fl<<"\n";
79 di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n";
84 static Standard_Integer tolblend(Draw_Interpretor& di, Standard_Integer narg, const char** a)
101 static Standard_Integer VBLEND(Draw_Interpretor& di, Standard_Integer narg, const char** a)
103 if(Rakk != 0) {delete Rakk; Rakk = 0;}
105 if (narg<5) return 1;
107 Standard_Integer NbToPick = (narg -4)/2;
109 Standard_Boolean autonaming = !strcasecmp(a[3],".");
111 Handle(TopTools_HArray1OfShape) arr = new TopTools_HArray1OfShape(1,NbToPick);
112 if(ViewerTest::PickShapes(TopAbs_EDGE,arr)){
113 for(Standard_Integer i=1;i<=NbToPick;i++){
114 TopoDS_Shape PickSh = arr->Value(i);
115 if(!PickSh.IsNull()){
116 DBRep::Set(a[(2*i+2)],PickSh);
121 TopoDS_Shape V = DBRep::Get(a[2]);
122 if(V.IsNull()) return 1;
123 ChFi3d_FilletShape FSh = ChFi3d_Rational;
125 if (!strcasecmp(a[narg-1], "Q")) {
126 FSh = ChFi3d_QuasiAngular;
128 else if (!strcasecmp(a[narg-1], "P")) {
129 FSh = ChFi3d_Polynomial;
132 Rakk = new BRepFilletAPI_MakeFillet(V,FSh);
133 Rakk->SetParams(ta,t3d,t2d,t3d,t2d,fl);
134 Rakk->SetContinuity(blend_cont, tapp_angle);
137 Standard_Integer nbedge = 0;
138 for (Standard_Integer ii = 1; ii < (narg-1)/2; ii++){
139 Rad = atof(a[2*ii + 1]);
140 TopoDS_Shape aLocalShape = DBRep::Get(a[(2*ii+2)],TopAbs_EDGE);
141 E = TopoDS::Edge(aLocalShape);
142 // E = TopoDS::Edge(DBRep::Get(a[(2*ii+2)],TopAbs_EDGE));
148 if(!nbedge) return 1;
150 if(!Rakk->IsDone()) return 1;
151 TopoDS_Shape res = Rakk->Shape();
152 DBRep::Set(a[1],res);
156 Handle(AIS_Shape) AS = GetAISShapeFromName(a[1]);
157 Handle(AIS_Shape) Start = GetAISShapeFromName(a[2]);
158 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
159 Ctx->Erase(Start,Standard_False);
160 if(Ctx->IsDisplayed(AS))
170 void ViewerTest::FilletCommands(Draw_Interpretor& theCommands)
172 const char* g = "Viewer Fillet construction commands";
173 theCommands.Add("vblend",
174 "vblend result object rad1 ed1 rad2 ed2 ... [R/Q/P]",__FILE__,