1 // Created on: 1998-11-20
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
26 #include <ViewerTest.hxx>
28 #include <BRepTest.hxx>
29 #include <TColgp_Array1OfPnt2d.hxx>
31 #include <Draw_Interpretor.hxx>
32 #include <Draw_Appli.hxx>
33 #include <BRepFilletAPI_MakeFillet.hxx>
34 //#include <BRepAlgo_BooleanOperation.hxx>
35 //#include <BRepAlgo_Fuse.hxx>
36 //#include <BRepAlgo_Cut.hxx>
37 #include <BiTgte_Blend.hxx>
38 #include <TopOpeBRepBuild_HBuilder.hxx>
39 #include <TopTools_ListIteratorOfListOfShape.hxx>
40 #include <TopAbs_ShapeEnum.hxx>
41 #include <TopoDS_Shape.hxx>
42 #include <TopoDS_Compound.hxx>
43 #include <TopoDS_Edge.hxx>
44 #include <TopoDS_Vertex.hxx>
47 #include <TopExp_Explorer.hxx>
49 #include <FilletSurf_Builder.hxx>
50 #include <ChFi3d_FilletShape.hxx>
51 #include <Geom_TrimmedCurve.hxx>
52 #include <TopTools_ListOfShape.hxx>
53 #include <FilletSurf_StatusType.hxx>
54 #include <FilletSurf_ErrorTypeStatus.hxx>
56 #include <DrawTrSurf.hxx>
57 #include <TopTools_HArray1OfShape.hxx>
59 #include <AIS_InteractiveContext.hxx>
60 #include <AIS_InteractiveObject.hxx>
61 #include <AIS_Shape.hxx>
67 //#define strcasecmp strcmp Already defined in Standard
71 extern Handle(AIS_Shape) GetAISShapeFromName(const char* name);
74 static Standard_Real t3d = 1.e-4;
75 static Standard_Real t2d = 1.e-5;
76 static Standard_Real ta = 1.e-2;
77 static Standard_Real fl = 1.e-3;
78 static Standard_Real tapp_angle = 1.e-2;
79 static GeomAbs_Shape blend_cont = GeomAbs_C1;
81 static BRepFilletAPI_MakeFillet* Rakk = 0;
83 static BRepFilletAPI_MakeFillet* Rake = 0;
84 static char name[100];
88 static void printtolblend(Draw_Interpretor& di)
90 di<<"tolerance ang : "<<ta<<"\n";
91 di<<"tolerance 3d : "<<t3d<<"\n";
92 di<<"tolerance 2d : "<<t2d<<"\n";
93 di<<"fleche : "<<fl<<"\n";
95 di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n";
100 static Standard_Integer tolblend(Draw_Interpretor& di, Standard_Integer narg, const char** a)
107 ta = Draw::Atof(a[1]);
108 t3d = Draw::Atof(a[2]);
109 t2d = Draw::Atof(a[3]);
110 fl = Draw::Atof(a[4]);
117 static Standard_Integer VBLEND(Draw_Interpretor& di, Standard_Integer narg, const char** a)
119 if(Rakk != 0) {delete Rakk; Rakk = 0;}
121 if (narg<5) return 1;
123 Standard_Integer NbToPick = (narg -4)/2;
124 Handle(TopTools_HArray1OfShape) arr = new TopTools_HArray1OfShape(1,NbToPick);
125 if(ViewerTest::PickShapes(TopAbs_EDGE,arr)){
126 for(Standard_Integer i=1;i<=NbToPick;i++){
127 TopoDS_Shape PickSh = arr->Value(i);
128 if(!PickSh.IsNull()){
129 DBRep::Set(a[(2*i+2)],PickSh);
134 TopoDS_Shape V = DBRep::Get(a[2]);
135 if(V.IsNull()) return 1;
136 ChFi3d_FilletShape FSh = ChFi3d_Rational;
138 if (!strcasecmp(a[narg-1], "Q")) {
139 FSh = ChFi3d_QuasiAngular;
141 else if (!strcasecmp(a[narg-1], "P")) {
142 FSh = ChFi3d_Polynomial;
145 Rakk = new BRepFilletAPI_MakeFillet(V,FSh);
146 Rakk->SetParams(ta,t3d,t2d,t3d,t2d,fl);
147 Rakk->SetContinuity(blend_cont, tapp_angle);
150 Standard_Integer nbedge = 0;
151 for (Standard_Integer ii = 1; ii < (narg-1)/2; ii++){
152 Rad = Draw::Atof(a[2*ii + 1]);
153 TopoDS_Shape aLocalShape = DBRep::Get(a[(2*ii+2)],TopAbs_EDGE);
154 E = TopoDS::Edge(aLocalShape);
155 // E = TopoDS::Edge(DBRep::Get(a[(2*ii+2)],TopAbs_EDGE));
161 if(!nbedge) return 1;
163 if(!Rakk->IsDone()) return 1;
164 TopoDS_Shape res = Rakk->Shape();
165 DBRep::Set(a[1],res);
169 Handle(AIS_Shape) AS = GetAISShapeFromName(a[1]);
170 Handle(AIS_Shape) Start = GetAISShapeFromName(a[2]);
171 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
172 Ctx->Erase(Start,Standard_False);
173 if(Ctx->IsDisplayed(AS))
183 void ViewerTest::FilletCommands(Draw_Interpretor& theCommands)
185 const char* g = "Viewer Fillet construction commands";
186 theCommands.Add("vblend",
187 "vblend result object rad1 ed1 rad2 ed2 ... [R/Q/P]",__FILE__,