1 // Created on: 1995-02-22
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1995-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 <BRepTest.hxx>
19 #include <DrawTrSurf.hxx>
20 #include <Draw_Appli.hxx>
21 #include <Draw_Interpretor.hxx>
23 #include <BRepOffsetAPI_DraftAngle.hxx>
24 #include <BRepOffsetAPI_MakeDraft.hxx>
26 #include <TopoDS_Face.hxx>
30 static void Print(Draw_Interpretor& di,
31 const Draft_ErrorStatus St)
33 di << " Error Status : ";
39 case Draft_FaceRecomputation:
40 di << "Impossible face recomputation";
43 case Draft_EdgeRecomputation:
44 di << "Impossible edge recomputation";
47 case Draft_VertexRecomputation:
48 di << "Impossible vertex recomputation";
54 static Standard_Integer DEP(Draw_Interpretor& theCommands,
55 Standard_Integer narg, const char** a)
57 if ((narg<14)||(narg%8 != 6)) return 1;
58 TopoDS_Shape V = DBRep::Get(a[2]);
59 BRepOffsetAPI_DraftAngle drft(V);
61 gp_Dir Dirextract(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
67 for (Standard_Integer ii = 0; ii < (narg-6)/8; ii++){
68 TopoDS_Shape aLocalShape(DBRep::Get(a[8*ii+6],TopAbs_FACE));
69 F = TopoDS::Face(aLocalShape);
70 // F = TopoDS::Face(DBRep::Get(a[8*ii+6],TopAbs_FACE));
71 Angle = Draw::Atof(a[8*ii+7])*M_PI/180.;
72 Pax.SetCoord(Draw::Atof(a[8*ii+8]),Draw::Atof(a[8*ii+9]),Draw::Atof(a[8*ii+10]));
73 Dax.SetCoord(Draw::Atof(a[8*ii+11]),Draw::Atof(a[8*ii+12]),Draw::Atof(a[8*ii+13]));
74 drft.Add(F,Dirextract,Angle,gp_Pln(Pax,Dax));
75 if (!drft.AddDone()) {
80 if (!drft.AddDone()) {
81 DBRep::Set("bugdep",drft.ProblematicShape());
82 theCommands << "Bad shape in variable bugdep ";
83 Print(theCommands,drft.Status());
88 DBRep::Set(a[1],drft);
91 DBRep::Set("bugdep",drft.ProblematicShape());
92 theCommands << "Problem encountered during the reconstruction : ";
93 theCommands << "bad shape in variable bugdep; ";
94 Print(theCommands,drft.Status());
99 static Standard_Integer NDEP(Draw_Interpretor& theCommands,
100 Standard_Integer narg, const char** a)
102 if ((narg<15)||((narg)%9 != 6)) return 1;
103 TopoDS_Shape V = DBRep::Get(a[2]);
105 //cout << a[2] << " is not a Shape" << endl;
106 theCommands << a[2] << " is not a Shape\n";
110 BRepOffsetAPI_DraftAngle drft(V);
112 gp_Dir Dirextract(Draw::Atof(a[3]),Draw::Atof(a[4]),Draw::Atof(a[5]));
118 Standard_Boolean Flag;
119 for (Standard_Integer ii = 0; ii < (narg-6)/9; ii++){
120 TopoDS_Shape aLocalFace(DBRep::Get(a[9*ii+6],TopAbs_FACE));
121 F = TopoDS::Face(aLocalFace);
122 // F = TopoDS::Face(DBRep::Get(a[9*ii+6],TopAbs_FACE));
125 //cout << a[9*ii+6] << " is not a face" << endl;
126 theCommands << a[9*ii+6] << " is not a face\n";
131 // Flag = Draw::Atof(a[9*ii+7]); // BUG?? Real -> Boolean ???
133 Flag = (Standard_Boolean ) Draw::Atof(a[9*ii+7]);
135 Angle = Draw::Atof(a[9*ii+8])*M_PI/180.;
136 Pax.SetCoord(Draw::Atof(a[9*ii+9]),Draw::Atof(a[9*ii+10]),Draw::Atof(a[9*ii+11]));
137 Dax.SetCoord(Draw::Atof(a[9*ii+12]),Draw::Atof(a[9*ii+13]),Draw::Atof(a[9*ii+14]));
138 drft.Add(F,Dirextract,Angle,gp_Pln(Pax,Dax), Flag);
139 if (!drft.AddDone()) {
144 if (!drft.AddDone()) {
145 DBRep::Set("bugdep",drft.ProblematicShape());
146 theCommands << "Bad shape in variable bugdep ";
147 Print(theCommands,drft.Status());
152 DBRep::Set(a[1],drft);
155 DBRep::Set("bugdep",drft.ProblematicShape());
156 theCommands << "Problem encountered during the reconstruction : ";
157 theCommands << "bad shape in variable bugdep; ";
158 Print(theCommands,drft.Status());
162 static Standard_Integer draft (Draw_Interpretor& di,
163 Standard_Integer n, const char** a)
165 Standard_Integer Inside = -1;
166 Standard_Boolean Internal = Standard_False;
169 Standard_Real x, y ,z, teta;
170 TopoDS_Shape SInit = DBRep::Get(a[2]);//shape d'arret
172 x = Draw::Atof(a[3]);
173 y = Draw::Atof(a[4]); // direction de depouille
174 z = Draw::Atof(a[5]);
175 teta = Draw::Atof(a[6]); //angle de depouille (teta)
181 BRepOffsetAPI_MakeDraft MkDraft(SInit, D, teta);
184 Standard_Integer cur = 8;
185 if (!strcmp(a[cur],"-IN")) {
189 else if (!strcmp(a[cur],"-OUT")) {
195 if (!strcmp(a[cur],"-Ri")) {
196 MkDraft.SetOptions(BRepBuilderAPI_RightCorner);
199 else if (!strcmp(a[cur],"-Ro")) {
200 MkDraft.SetOptions(BRepBuilderAPI_RoundCorner);
205 if (!strcmp(a[cur],"-Internal")) {
206 Internal = Standard_True;
213 MkDraft.SetDraft(Internal);
214 di << "Internal Draft : \n";
215 //cout << "Internal Draft : " << endl;
218 di << "External Draft : \n";
219 //cout << "External Draft : " << endl;
221 TopoDS_Shape Stop = DBRep::Get(a[7]);//shape d'arret
222 if (!Stop.IsNull()) {
223 Standard_Boolean KeepOutside = Standard_True;
224 if (Inside==0) KeepOutside = Standard_False;
225 MkDraft.Perform(Stop, KeepOutside);
228 Handle(Geom_Surface) Surf = DrawTrSurf::GetSurface(a[7]);
229 if (! Surf.IsNull()) { // surface d'arret
230 Standard_Boolean KeepInside = Standard_True;
231 if (Inside==1) KeepInside = Standard_False;
232 MkDraft.Perform(Surf, KeepInside);
235 Standard_Real L = Draw::Atof(a[7]);
243 DBRep::Set(a[1], MkDraft.Shape());
244 DBRep::Set("DraftShell", MkDraft.Shell());
250 //=======================================================================
251 //function : DraftAngleCommands
253 //=======================================================================
255 void BRepTest::DraftAngleCommands(Draw_Interpretor& theCommands)
257 static Standard_Boolean done = Standard_False;
259 done = Standard_True;
261 DBRep::BasicCommands(theCommands);
263 const char* g = "Draft angle modification commands";
265 theCommands.Add("depouille", " Inclines faces of a shape, dep result shape dirx diry dirz face angle x y x dx dy dz [face angle...]",__FILE__,DEP,g);
267 theCommands.Add("ndepouille", " Inclines faces of a shape, dep result shape dirx diry dirz face 0/1 angle x y x dx dy dz [face 0/1 angle...]",__FILE__,NDEP,g);
269 theCommands.Add("draft"," Compute a draft surface along a shape, \n draft result shape dirx diry dirz angle shape/surf/length [-IN/-OUT] [Ri/Ro] [-Internal]",