0022898: IGES import fails in german environment
[occt.git] / src / SWDRAW / SWDRAW.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18#include <SWDRAW.ixx>
19
91322f44 20#include <Draw.hxx>
7fd59977 21#include <DBRep.hxx>
7fd59977 22
23#include <SWDRAW_ShapeTool.hxx>
24#include <SWDRAW_ShapeAnalysis.hxx>
25#include <SWDRAW_ShapeBuild.hxx>
26#include <SWDRAW_ShapeConstruct.hxx>
27#include <SWDRAW_ShapeCustom.hxx>
28#include <SWDRAW_ShapeExtend.hxx>
29#include <SWDRAW_ShapeFix.hxx>
30#include <SWDRAW_ShapeUpgrade.hxx>
31#include <SWDRAW_ShapeProcess.hxx>
32#include <SWDRAW_ShapeProcessAPI.hxx>
33
34// tovrml
35#include <TopoDS_Shape.hxx>
36#include <SWDRAW_ToVRML.hxx>
37//#72 rln 09.03.99 Packaging of SWDRAW
38
39#include <ShapeProcess_OperLibrary.hxx>
40#include <BRepTools.hxx>
41#include <Draw_Window.hxx>
42#include <BRep_Builder.hxx>
43#include <gp_Trsf.hxx>
b311480e 44
7fd59977 45// for NSPApply -- CKY 12 JUL 2001
46#include <XSAlgo.hxx>
47#include <XSAlgo_AlgoContainer.hxx>
48
b485ee79
KD
49#include <Draw_ProgressIndicator.hxx>
50
7fd59977 51static int dejadraw = 0;
52
7fd59977 53//#72 rln 09.03.99 Packaging of SWDRAW
54
55//=======================================================================
56//function : tovrml
57//purpose :
58//=======================================================================
59
60static Standard_Integer tovrml(Draw_Interpretor& /*di*/, Standard_Integer n, const char** a)
61{
62 if (n < 3) return 1;
63 SWDRAW_ToVRML avrml;
64 TopoDS_Shape sh = DBRep::Get (a[1]);
65 const char* filename = a[2];
66 if (!avrml.Write (sh,filename)) return 1;
67 return 0;
68}
69
70//=======================================================================
71//function : LocSet
72//purpose :
73//=======================================================================
74
75static Standard_Integer LocSet (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
76{
77 if (argc < 2) {
78 di << argv[0] << "LocSet a [b [c]]: set location for shape \"a\":" << "\n";
79 di << "- to Null if one argument is given" << "\n";
80 di << "- to location of shape b if two arguments are given" << "\n";
81 di << "- to difference of locations of shapes b and c if three arguments are given" << "\n";
82 return 1;
83 }
84
85 TopoDS_Shape a = DBRep::Get ( argv[1] );
86 if ( a.IsNull() ) {
87 di << "No shape named \"" << argv[1] << "\" found" << "\n";
88 return 1;
89 }
90 TopLoc_Location L;
91 if ( argc >2 ) {
92 TopoDS_Shape b = DBRep::Get ( argv[2] );
93 if ( b.IsNull() ) {
94 di << "No shape named \"" << argv[2] << "\" found" << "\n";
95 return 1;
96 }
97 if ( argc >3 ) {
98 TopoDS_Shape c = DBRep::Get ( argv[3] );
99 if ( c.IsNull() ) {
100 di << "No shape named \"" << argv[3] << "\" found" << "\n";
101 return 1;
102 }
103 L = b.Location().Multiplied ( c.Location().Inverted() );
104 }
105 else L = b.Location();
106 }
107 a.Location ( L );
108 DBRep::Set ( argv[1], a );
109
110 return 0;
111}
112
113//=======================================================================
114//function : LocDump
115//purpose :
116//=======================================================================
117
118static Standard_Integer LocDump (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
119{
120 if (argc < 2) {
121 di << argv[0] << "LocDump a: dump location of shape \"a\"" << "\n";
122 return 1;
123 }
124
125 TopoDS_Shape a = DBRep::Get ( argv[1] );
126 if ( a.IsNull() ) {
127 di << "No shape named \"" << argv[1] << "\" found" << "\n";
128 return 1;
129 }
130
131 TopLoc_Location L = a.Location();
132 di << "Location of shape " << argv[1] << ":" << "\n";
133// L.ShallowDump ( di );
134 di << "Results in:" << "\n";
135 gp_Trsf T = L.Transformation();
136 TopLoc_Location l ( T );
137 //l.ShallowDump ( di );
138 Standard_SStream aSStream;
139 l.ShallowDump ( aSStream );
140 di << aSStream;
141
142 return 0;
143}
144
145//=======================================================================
146//function : NSPApply
147//purpose : CKY , 12 JUL 2001
148//=======================================================================
149
150static Standard_Integer NSPApply (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
151{
152 if ( argc < 6) {
153 di<<"NSPApply result(new shape) shape(initial shape) rscfile sequence tol [maxtol, default=1]"<<"\n";
154 return 1;
155 }
156 TopoDS_Shape shape = DBRep::Get ( argv[2] );
157 if (shape.IsNull()) {
158 di << "No shape named \"" << argv[1] << "\" found" << "\n";
159 return 1;
160 }
161 TopoDS_Shape newshape;
91322f44 162 Standard_Real tol = Draw::Atof(argv[5]);
7fd59977 163 Standard_Real maxtol = 1.;
91322f44 164 if (argc > 6) maxtol = Draw::Atof(argv[6]);
7fd59977 165
166 XSAlgo::AlgoContainer()->PrepareForTransfer();
167 Handle(Standard_Transient) info; // reserved for special uses
b485ee79 168 Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di, 1);
7fd59977 169 newshape = XSAlgo::AlgoContainer()->ProcessShape
b485ee79 170 ( shape, tol, maxtol, argv[3] , argv[4] , info, aProgress);
7fd59977 171// WHAT IS MISSING HERE IS MERGING with starting transfer map
172
173 if (newshape.IsNull()) {
174 di<<"No result produced"<<"\n";
175 }
176 else
177 DBRep::Set ( argv[1], newshape );
178 return 0;
179}
180
181//=======================================================================
182//function : Init
183//purpose :
184//=======================================================================
185
186void SWDRAW::Init (Draw_Interpretor& theCommands)
187{
188 if (!dejadraw) {
189 dejadraw = 1;
190// DBRep::BasicCommands(theCommands);
191// CKY 4-AOUT-1998 : pb avec GeomFill
192// GeometryTest::AllCommands(theCommands);
193// BRepTest::AllCommands(theCommands);
194// MeshTest::Commands(theCommands);
195 }
196
197 SWDRAW_ShapeTool::InitCommands (theCommands);
198 SWDRAW_ShapeAnalysis::InitCommands (theCommands);
199 SWDRAW_ShapeBuild::InitCommands (theCommands);
200 SWDRAW_ShapeConstruct::InitCommands (theCommands);
201 SWDRAW_ShapeCustom::InitCommands (theCommands);
202 SWDRAW_ShapeExtend::InitCommands (theCommands);
203 SWDRAW_ShapeFix::InitCommands (theCommands);
204 SWDRAW_ShapeUpgrade::InitCommands (theCommands);
205 SWDRAW_ShapeProcess::InitCommands (theCommands);
206 SWDRAW_ShapeProcessAPI::InitCommands (theCommands);
207
7fd59977 208 // locations
209 theCommands.Add("LocSet", "a [b [c]]: set loc b->a; use no args to get help",__FILE__,LocSet,"essai");
210 theCommands.Add("LocDump", "a: dump location of a",__FILE__,LocDump,"essai");
211
212 //tovrml
213 theCommands.Add("tovrml", "shape filename",__FILE__, tovrml, "essai");
214
215 // register operators for ShapeProcessing
216 ShapeProcess_OperLibrary::Init();
217
218 // new shape processing
219 theCommands.Add ("NSPApply","NSPApply result shape rscfilename sequence tol [maxtol, default=1]",
220 __FILE__,NSPApply,"essai");
221}
222
223//=======================================================================
224//function : GroupName
225//purpose :
226//=======================================================================
227
228Standard_CString SWDRAW::GroupName()
229{
230 return "Shape Healing";
231}