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";
130 Flag = Draw::Atoi(a[9*ii+7]) != 0;
131 Angle = Draw::Atof(a[9*ii+8])*M_PI/180.;
132 Pax.SetCoord(Draw::Atof(a[9*ii+9]),Draw::Atof(a[9*ii+10]),Draw::Atof(a[9*ii+11]));
133 Dax.SetCoord(Draw::Atof(a[9*ii+12]),Draw::Atof(a[9*ii+13]),Draw::Atof(a[9*ii+14]));
134 drft.Add(F,Dirextract,Angle,gp_Pln(Pax,Dax), Flag);
135 if (!drft.AddDone()) {
140 if (!drft.AddDone()) {
141 DBRep::Set("bugdep",drft.ProblematicShape());
142 theCommands << "Bad shape in variable bugdep ";
143 Print(theCommands,drft.Status());
148 DBRep::Set(a[1],drft);
151 DBRep::Set("bugdep",drft.ProblematicShape());
152 theCommands << "Problem encountered during the reconstruction : ";
153 theCommands << "bad shape in variable bugdep; ";
154 Print(theCommands,drft.Status());
158 static Standard_Integer draft (Draw_Interpretor& di,
159 Standard_Integer n, const char** a)
161 Standard_Integer Inside = -1;
162 Standard_Boolean Internal = Standard_False;
165 Standard_Real x, y ,z, teta;
166 TopoDS_Shape SInit = DBRep::Get(a[2]);//shape d'arret
168 x = Draw::Atof(a[3]);
169 y = Draw::Atof(a[4]); // direction de depouille
170 z = Draw::Atof(a[5]);
171 teta = Draw::Atof(a[6]); //angle de depouille (teta)
177 BRepOffsetAPI_MakeDraft MkDraft(SInit, D, teta);
180 Standard_Integer cur = 8;
181 if (!strcmp(a[cur],"-IN")) {
185 else if (!strcmp(a[cur],"-OUT")) {
191 if (!strcmp(a[cur],"-Ri")) {
192 MkDraft.SetOptions(BRepBuilderAPI_RightCorner);
195 else if (!strcmp(a[cur],"-Ro")) {
196 MkDraft.SetOptions(BRepBuilderAPI_RoundCorner);
201 if (!strcmp(a[cur],"-Internal")) {
202 Internal = Standard_True;
209 MkDraft.SetDraft(Internal);
210 di << "Internal Draft : \n";
211 //cout << "Internal Draft : " << endl;
214 di << "External Draft : \n";
215 //cout << "External Draft : " << endl;
217 TopoDS_Shape Stop = DBRep::Get(a[7]);//shape d'arret
218 if (!Stop.IsNull()) {
219 Standard_Boolean KeepOutside = Standard_True;
220 if (Inside==0) KeepOutside = Standard_False;
221 MkDraft.Perform(Stop, KeepOutside);
224 Handle(Geom_Surface) Surf = DrawTrSurf::GetSurface(a[7]);
225 if (! Surf.IsNull()) { // surface d'arret
226 Standard_Boolean KeepInside = Standard_True;
227 if (Inside==1) KeepInside = Standard_False;
228 MkDraft.Perform(Surf, KeepInside);
231 Standard_Real L = Draw::Atof(a[7]);
239 DBRep::Set(a[1], MkDraft.Shape());
240 DBRep::Set("DraftShell", MkDraft.Shell());
246 //=======================================================================
247 //function : DraftAngleCommands
249 //=======================================================================
251 void BRepTest::DraftAngleCommands(Draw_Interpretor& theCommands)
253 static Standard_Boolean done = Standard_False;
255 done = Standard_True;
257 DBRep::BasicCommands(theCommands);
259 const char* g = "Draft angle modification commands";
261 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);
263 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);
265 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]",