1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
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>
35 #include <TopoDS_Shape.hxx>
36 #include <SWDRAW_ToVRML.hxx>
37 //#72 rln 09.03.99 Packaging of SWDRAW
39 #include <ShapeProcess_OperLibrary.hxx>
40 #include <BRepTools.hxx>
41 #include <Draw_Window.hxx>
42 #include <BRep_Builder.hxx>
43 #include <gp_Trsf.hxx>
45 // for NSPApply -- CKY 12 JUL 2001
47 #include <XSAlgo_AlgoContainer.hxx>
49 #include <Draw_ProgressIndicator.hxx>
51 static int dejadraw = 0;
53 //#72 rln 09.03.99 Packaging of SWDRAW
55 //=======================================================================
58 //=======================================================================
60 static Standard_Integer tovrml(Draw_Interpretor& /*di*/, Standard_Integer n, const char** a)
64 TopoDS_Shape sh = DBRep::Get (a[1]);
65 const char* filename = a[2];
66 if (!avrml.Write (sh,filename)) return 1;
70 //=======================================================================
73 //=======================================================================
75 static Standard_Integer LocSet (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
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";
85 TopoDS_Shape a = DBRep::Get ( argv[1] );
87 di << "No shape named \"" << argv[1] << "\" found" << "\n";
92 TopoDS_Shape b = DBRep::Get ( argv[2] );
94 di << "No shape named \"" << argv[2] << "\" found" << "\n";
98 TopoDS_Shape c = DBRep::Get ( argv[3] );
100 di << "No shape named \"" << argv[3] << "\" found" << "\n";
103 L = b.Location().Multiplied ( c.Location().Inverted() );
105 else L = b.Location();
108 DBRep::Set ( argv[1], a );
113 //=======================================================================
116 //=======================================================================
118 static Standard_Integer LocDump (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
121 di << argv[0] << "LocDump a: dump location of shape \"a\"" << "\n";
125 TopoDS_Shape a = DBRep::Get ( argv[1] );
127 di << "No shape named \"" << argv[1] << "\" found" << "\n";
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 );
145 //=======================================================================
146 //function : NSPApply
147 //purpose : CKY , 12 JUL 2001
148 //=======================================================================
150 static Standard_Integer NSPApply (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
153 di<<"NSPApply result(new shape) shape(initial shape) rscfile sequence tol [maxtol, default=1]"<<"\n";
156 TopoDS_Shape shape = DBRep::Get ( argv[2] );
157 if (shape.IsNull()) {
158 di << "No shape named \"" << argv[1] << "\" found" << "\n";
161 TopoDS_Shape newshape;
162 Standard_Real tol = Draw::Atof(argv[5]);
163 Standard_Real maxtol = 1.;
164 if (argc > 6) maxtol = Draw::Atof(argv[6]);
166 XSAlgo::AlgoContainer()->PrepareForTransfer();
167 Handle(Standard_Transient) info; // reserved for special uses
168 Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di, 1);
169 newshape = XSAlgo::AlgoContainer()->ProcessShape
170 ( shape, tol, maxtol, argv[3] , argv[4] , info, aProgress);
171 // WHAT IS MISSING HERE IS MERGING with starting transfer map
173 if (newshape.IsNull()) {
174 di<<"No result produced"<<"\n";
177 DBRep::Set ( argv[1], newshape );
181 //=======================================================================
184 //=======================================================================
186 void SWDRAW::Init (Draw_Interpretor& theCommands)
190 // DBRep::BasicCommands(theCommands);
191 // CKY 4-AOUT-1998 : pb avec GeomFill
192 // GeometryTest::AllCommands(theCommands);
193 // BRepTest::AllCommands(theCommands);
194 // MeshTest::Commands(theCommands);
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);
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");
213 theCommands.Add("tovrml", "shape filename",__FILE__, tovrml, "essai");
215 // register operators for ShapeProcessing
216 ShapeProcess_OperLibrary::Init();
218 // new shape processing
219 theCommands.Add ("NSPApply","NSPApply result shape rscfilename sequence tol [maxtol, default=1]",
220 __FILE__,NSPApply,"essai");
223 //=======================================================================
224 //function : GroupName
226 //=======================================================================
228 Standard_CString SWDRAW::GroupName()
230 return "Shape Healing";