0024510: Remove unused local variables
[occt.git] / src / ViewerTest / ViewerTest_FilletCommands.cxx
CommitLineData
b311480e 1// Created on: 1998-11-20
2// Created by: Robert COUBLANC
3// Copyright (c) 1998-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#ifdef HAVE_CONFIG_H
18# include <config.h>
19#endif
20
21#include <ViewerTest.hxx>
22#include <string.h>
23#include <BRepTest.hxx>
24#include <TColgp_Array1OfPnt2d.hxx>
25#include <DBRep.hxx>
26#include <Draw_Interpretor.hxx>
27#include <Draw_Appli.hxx>
28#include <BRepFilletAPI_MakeFillet.hxx>
29//#include <BRepAlgo_BooleanOperation.hxx>
30//#include <BRepAlgo_Fuse.hxx>
31//#include <BRepAlgo_Cut.hxx>
32#include <BiTgte_Blend.hxx>
33#include <TopOpeBRepBuild_HBuilder.hxx>
34#include <TopTools_ListIteratorOfListOfShape.hxx>
35#include <TopAbs_ShapeEnum.hxx>
36#include <TopoDS_Shape.hxx>
37#include <TopoDS_Compound.hxx>
38#include <TopoDS_Edge.hxx>
39#include <TopoDS_Vertex.hxx>
40#include <TopoDS.hxx>
41#include <TopExp.hxx>
42#include <TopExp_Explorer.hxx>
43
44#include <FilletSurf_Builder.hxx>
45#include <ChFi3d_FilletShape.hxx>
46#include <Geom_TrimmedCurve.hxx>
47#include <TopTools_ListOfShape.hxx>
48#include <FilletSurf_StatusType.hxx>
49#include <FilletSurf_ErrorTypeStatus.hxx>
50#include <TopAbs.hxx>
51#include <DrawTrSurf.hxx>
52#include <TopTools_HArray1OfShape.hxx>
53
54#include <AIS_InteractiveContext.hxx>
55#include <AIS_InteractiveObject.hxx>
56#include <AIS_Shape.hxx>
57
58#ifdef HAVE_STRINGS_H
59# include <strings.h>
60#endif
61#ifdef WNT
62//#define strcasecmp strcmp Already defined in Standard
63#include <stdio.h>
64#endif
65
66extern Handle(AIS_Shape) GetAISShapeFromName(const char* name);
67
68
69static Standard_Real t3d = 1.e-4;
70static Standard_Real t2d = 1.e-5;
71static Standard_Real ta = 1.e-2;
72static Standard_Real fl = 1.e-3;
73static Standard_Real tapp_angle = 1.e-2;
74static GeomAbs_Shape blend_cont = GeomAbs_C1;
75
76static BRepFilletAPI_MakeFillet* Rakk = 0;
7fd59977 77
78
79static void printtolblend(Draw_Interpretor& di)
80{
81 di<<"tolerance ang : "<<ta<<"\n";
82 di<<"tolerance 3d : "<<t3d<<"\n";
83 di<<"tolerance 2d : "<<t2d<<"\n";
84 di<<"fleche : "<<fl<<"\n";
85
86 di<<"tolblend "<<ta<<" "<<t3d<<" "<<t2d<<" "<<fl<<"\n";
87}
88
7fd59977 89static Standard_Integer VBLEND(Draw_Interpretor& di, Standard_Integer narg, const char** a)
90{
91 if(Rakk != 0) {delete Rakk; Rakk = 0;}
92 printtolblend(di);
93 if (narg<5) return 1;
94
95 Standard_Integer NbToPick = (narg -4)/2;
7fd59977 96 Handle(TopTools_HArray1OfShape) arr = new TopTools_HArray1OfShape(1,NbToPick);
97 if(ViewerTest::PickShapes(TopAbs_EDGE,arr)){
98 for(Standard_Integer i=1;i<=NbToPick;i++){
99 TopoDS_Shape PickSh = arr->Value(i);
100 if(!PickSh.IsNull()){
101 DBRep::Set(a[(2*i+2)],PickSh);
102 }
103 }
104 }
105
106 TopoDS_Shape V = DBRep::Get(a[2]);
107 if(V.IsNull()) return 1;
108 ChFi3d_FilletShape FSh = ChFi3d_Rational;
109 if (narg%2 == 0) {
110 if (!strcasecmp(a[narg-1], "Q")) {
111 FSh = ChFi3d_QuasiAngular;
112 }
113 else if (!strcasecmp(a[narg-1], "P")) {
114 FSh = ChFi3d_Polynomial;
115 }
116 }
117 Rakk = new BRepFilletAPI_MakeFillet(V,FSh);
118 Rakk->SetParams(ta,t3d,t2d,t3d,t2d,fl);
119 Rakk->SetContinuity(blend_cont, tapp_angle);
120 Standard_Real Rad;
121 TopoDS_Edge E;
122 Standard_Integer nbedge = 0;
123 for (Standard_Integer ii = 1; ii < (narg-1)/2; ii++){
91322f44 124 Rad = Draw::Atof(a[2*ii + 1]);
7fd59977 125 TopoDS_Shape aLocalShape = DBRep::Get(a[(2*ii+2)],TopAbs_EDGE);
126 E = TopoDS::Edge(aLocalShape);
127// E = TopoDS::Edge(DBRep::Get(a[(2*ii+2)],TopAbs_EDGE));
128 if(!E.IsNull()){
129 Rakk->Add(Rad,E);
130 nbedge++;
131 }
132 }
133 if(!nbedge) return 1;
134 Rakk->Build();
135 if(!Rakk->IsDone()) return 1;
136 TopoDS_Shape res = Rakk->Shape();
137 DBRep::Set(a[1],res);
138
139
140 // visu resultat...
141 Handle(AIS_Shape) AS = GetAISShapeFromName(a[1]);
142 Handle(AIS_Shape) Start = GetAISShapeFromName(a[2]);
143 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
144 Ctx->Erase(Start,Standard_False);
145 if(Ctx->IsDisplayed(AS))
146 Ctx->Redisplay(AS);
147 else
148 Ctx->Display(AS);
149 return 0;
150}
151
152
153
154
155void ViewerTest::FilletCommands(Draw_Interpretor& theCommands)
156{
157 const char* g = "Viewer Fillet construction commands";
158 theCommands.Add("vblend",
159 "vblend result object rad1 ed1 rad2 ed2 ... [R/Q/P]",__FILE__,
160 VBLEND,g);
161}