0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / IGESData / IGESData.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #include <IGESData.hxx>
15 #include <IGESData_DefaultGeneral.hxx>
16 #include <IGESData_DefaultSpecific.hxx>
17 #include <IGESData_GlobalSection.hxx>
18 #include <IGESData_IGESModel.hxx>
19 #include <IGESData_Protocol.hxx>
20 #include <Interface_InterfaceModel.hxx>
21 #include <Interface_Static.hxx>
22 #include <Interface_Version.hxx>
23 #include <Message_MsgFile.hxx>
24 #include <OSD_Process.hxx>
25 #include <Quantity_Date.hxx>
26 #include <Standard_Integer.hxx>
27 #include <Standard_Real.hxx>
28 #include <TCollection_HAsciiString.hxx>
29
30 #include <stdio.h>
31 static Handle(IGESData_Protocol) proto;
32
33 static Handle(IGESData_DefaultGeneral)    stmod;
34 static Handle(IGESData_DefaultSpecific)   speci;
35
36
37     void  IGESData::Init ()
38 {
39   if (proto.IsNull()) proto = new IGESData_Protocol;
40   if (stmod.IsNull()) stmod = new IGESData_DefaultGeneral;
41   if (speci.IsNull()) speci = new IGESData_DefaultSpecific;
42 //  et modele template "iges"
43   if (Interface_InterfaceModel::HasTemplate("iges")) return;
44
45   OSD_Process process;
46
47   // Static Parameters - see also Static Standards
48   // -----------------
49   Interface_Static::Standards();
50
51   Interface_Static::Init ("XSTEP","read.iges.bspline.approxd1.mode",'e',"");
52   Interface_Static::Init ("XSTEP","read.iges.bspline.approxd1.mode",'&',"ematch 0");
53   Interface_Static::Init ("XSTEP","read.iges.bspline.approxd1.mode",'&',"eval Off");
54   Interface_Static::Init ("XSTEP","read.iges.bspline.approxd1.mode",'&',"eval On");
55   Interface_Static::SetIVal ("read.iges.bspline.approxd1.mode",0);
56
57   Interface_Static::Init ("XSTEP","read.iges.bspline.continuity",'i',"1");
58   Interface_Static::Init ("XSTEP","read.iges.bspline.continuity",'&',"imin 0");
59   Interface_Static::Init ("XSTEP","read.iges.bspline.continuity",'&',"imax 2");
60
61   //#58 rln Interface_Static::Init ("XSTEP","write.iges.header.product" ,'t',"");
62   Interface_Static::Init ("XSTEP","write.iges.header.receiver",'t',"");//58 rln Unknown
63   Interface_Static::Init ("XSTEP","write.iges.header.author"  ,'t',process.UserName().ToCString());
64   Interface_Static::Init ("XSTEP","write.iges.header.company" ,'t',"");//58 rln Matra Datavision
65
66   Interface_Static::Init ("XSTEP","write.iges.unit",'e',"");
67   Interface_Static::Init ("XSTEP","write.iges.unit",'&',"enum 1");
68   Interface_Static::Init ("XSTEP","write.iges.unit",'&',"eval INCH");  // 1
69   Interface_Static::Init ("XSTEP","write.iges.unit",'&',"eval MM");    // 2
70   Interface_Static::Init ("XSTEP","write.iges.unit",'&',"eval ??");    // 3
71   Interface_Static::Init ("XSTEP","write.iges.unit",'&',"eval FT");    // 4
72   Interface_Static::Init ("XSTEP","write.iges.unit",'&',"eval MI");    // 5
73   Interface_Static::Init ("XSTEP","write.iges.unit",'&',"eval M");     // 6
74   Interface_Static::Init ("XSTEP","write.iges.unit",'&',"eval KM");    // 7
75   Interface_Static::Init ("XSTEP","write.iges.unit",'&',"eval MIL");   // 8
76   Interface_Static::Init ("XSTEP","write.iges.unit",'&',"eval UM");    // 9
77   Interface_Static::Init ("XSTEP","write.iges.unit",'&',"eval CM");    //10
78   Interface_Static::Init ("XSTEP","write.iges.unit",'&',"eval UIN");   //11
79   Interface_Static::SetCVal ("write.iges.unit","MM");
80
81   Interface_Static::Init ("XSTEP","write.iges.brep.mode",'e',"");
82   Interface_Static::Init ("XSTEP","write.iges.brep.mode",'&',"ematch 0");
83   Interface_Static::Init ("XSTEP","write.iges.brep.mode",'&',"eval Faces");
84   Interface_Static::Init ("XSTEP","write.iges.brep.mode",'&',"eval BRep");
85   Interface_Static::SetIVal ("write.iges.brep.mode",0);
86
87   //S4181 pdn 23.04.99: adding new parameter handling writing of elementary surfaces
88   Interface_Static::Init ("XSTEP","write.convertsurface.mode",'e',"");
89   Interface_Static::Init ("XSTEP","write.convertsurface.mode",'&',"ematch 0");
90   Interface_Static::Init ("XSTEP","write.convertsurface.mode",'&',"eval Off");
91   Interface_Static::Init ("XSTEP","write.convertsurface.mode",'&',"eval On");
92   Interface_Static::SetIVal ("write.convertsurface.mode",0);
93
94   // abv 15.11.00: ShapeProcessing
95   Interface_Static::Init ("XSTEP","write.iges.resource.name",'t',"IGES");
96   Interface_Static::Init ("XSTEP","read.iges.resource.name",'t',"IGES");
97   Interface_Static::Init ("XSTEP","write.iges.sequence",'t',"ToIGES");
98   Interface_Static::Init ("XSTEP","read.iges.sequence",'t',"FromIGES");
99   
100   // sln 11.06.2002 OCC448 : Initialize "read.onlyvisible" parameter  to control transfering 
101   // invisiable sub entities which logicaly depend on the grouping entities
102   Interface_Static::Init ("XSTEP","read.iges.onlyvisible",'e',"");
103   Interface_Static::Init ("XSTEP","read.iges.onlyvisible",'&',"ematch 0");
104   Interface_Static::Init ("XSTEP","read.iges.onlyvisible",'&',"eval Off");
105   Interface_Static::Init ("XSTEP","read.iges.onlyvisible",'&',"eval On");
106   Interface_Static::SetIVal ("read.iges.onlyvisible",0);
107
108   //gka added parameter for reading failed entities. 19.07
109   Interface_Static::Init ("XSTEP","read.iges.faulty.entities",'e',"");
110   Interface_Static::Init ("XSTEP","read.iges.faulty.entities",'&',"ematch 0");
111   Interface_Static::Init ("XSTEP","read.iges.faulty.entities",'&',"eval Off");
112   Interface_Static::Init ("XSTEP","read.iges.faulty.entities",'&',"eval On");
113   Interface_Static::SetIVal ("read.iges.faulty.entities",0);
114
115   //ika added parameter for writing planes mode 2.11.2012 
116   Interface_Static::Init ("XSTEP","write.iges.plane.mode",'e',"");
117   Interface_Static::Init ("XSTEP","write.iges.plane.mode",'&',"ematch 0");
118   Interface_Static::Init ("XSTEP","write.iges.plane.mode",'&',"eval Plane");
119   Interface_Static::Init ("XSTEP","write.iges.plane.mode",'&',"eval BSpline");
120   Interface_Static::SetIVal ("write.iges.plane.mode",0);
121
122    //ika added parameter for writing offset curves like BSplines 12.04.2013 
123   Interface_Static::Init ("XSTEP","write.iges.offset.mode",'e',"");
124   Interface_Static::Init ("XSTEP","write.iges.offset.mode",'&',"ematch 0");
125   Interface_Static::Init ("XSTEP","write.iges.offset.mode",'&',"eval On");
126   Interface_Static::Init ("XSTEP","write.iges.offset.mode",'&',"eval Off");
127   Interface_Static::SetIVal ("write.iges.offset.mode",0);
128
129   // Creating the Global Section
130   //----------------------------
131
132   IGESData_GlobalSection GS;
133   //#58 rln 28.12.98 changing default values for Global Section
134   char procver[80];
135   sprintf (procver, XSTEP_PROCESSOR_VERSION, "IGES");
136   Handle(TCollection_HAsciiString) gsys = new TCollection_HAsciiString (procver);
137   Interface_Static::Init ("XSTEP","write.iges.header.product" ,'t',procver);
138   
139 /*  Handle(TCollection_HAsciiString) gsys = new TCollection_HAsciiString
140     (XSTEP_VERSION);
141   gsys->AssignCat(" on ");
142   gsys->AssignCat
143 #ifdef HPUX
144     ("HP-UX");
145   std::cout<<"--  OSD_Path::SystemVersion, does not work well on HP-UX"<<std::endl;
146 #endif
147 #ifndef HPUX
148     (host.SystemVersion().ToCString());
149 #endif
150
151 //  SendName : nom significatif de la piece transmise par exemple
152 //  SystemId : c est MDTV etc
153 //  InterfaceVersion : la version en cours de XSTEP; incluant la plateforme
154
155   char nomsys[100]; int istat; long lstat;
156   struct utsname infosy;
157   istat = uname (&infosy);
158   lstat = sysinfo (SI_HW_PROVIDER,nomsys,99);
159   Handle(TCollection_HAsciiString) gsys = new TCollection_HAsciiString(nomsys);
160   gsys->AssignCat(" ");
161   lstat = sysinfo (SI_ARCHITECTURE,nomsys,99);
162   gsys->AssignCat(nomsys);
163   gsys->AssignCat("/");
164   gsys->AssignCat(infosy.sysname);
165   gsys->AssignCat(" ");
166   gsys->AssignCat(infosy.release);
167 */
168   Standard_Integer year;                                //gka 19.01.99
169   OSD_Process system;
170   Quantity_Date ladate = system.SystemDate(); 
171   year = ladate.Year();
172   Handle(TCollection_HAsciiString) datestr;
173   if( year < 2000 )
174     //#65 rln 12.02.99 S4151 (explicitly force YYMMDD.HHMMSS before Y2000)
175     datestr = GS.NewDateString(0,0,0,0,0,0,0);
176   else 
177     //#65 rln 12.02.99 S4151 (explicitly force YYYYMMDD.HHMMSS after Y2000)
178     datestr = GS.NewDateString(0,0,0,0,0,0,-1);
179   GS.SetSeparator (',');
180   GS.SetEndMark   (';');
181   GS.SetSendName (new TCollection_HAsciiString(Interface_Static::CVal("write.iges.header.product")));
182   GS.SetFileName (new TCollection_HAsciiString("Filename.iges"));
183   GS.SetSystemId (new TCollection_HAsciiString(XSTEP_SYSTEM_VERSION));//#58 rln "MATRA-DATAVISION EUCLID-QUANTUM"
184   GS.SetInterfaceVersion (gsys);
185   GS.SetIntegerBits      ( IntegerSize() );
186   GS.SetMaxPower10Single ( RealLast10Exp() );
187   GS.SetMaxDigitsSingle  ( RealDigits() );
188   GS.SetMaxPower10Double ( RealLast10Exp() );
189   GS.SetMaxDigitsDouble  ( RealDigits() );
190   GS.SetReceiveName (Interface_Static::Static("write.iges.header.receiver")->HStringValue());
191 // new TCollection_HAsciiString("Unknown");
192   GS.SetScale       (1.0);
193   GS.SetUnitFlag    (Interface_Static::IVal("write.iges.unit"));
194   GS.SetUnitName    (new TCollection_HAsciiString(Interface_Static::CVal("write.iges.unit")));
195   GS.SetLineWeightGrad (1);
196   GS.SetMaxLineWeight  (0.01);
197   GS.SetDate        (datestr);
198   GS.SetResolution  (0.0001);
199   GS.SetMaxCoord    (0.0 /*1000.0*/);//22.10.98 rln BUC60081
200   GS.SetAuthorName  (Interface_Static::Static("write.iges.header.author")->HStringValue());
201 //  new TCollection_HAsciiString (process.UserName());
202   GS.SetCompanyName (Interface_Static::Static("write.iges.header.company")->HStringValue());
203 //  new TCollection_HAsciiString("Matra Datavision");
204   GS.SetIGESVersion (11);         // pour IGES-5.3 //gka 19.01.99
205   GS.SetDraftingStandard (0);
206   GS.SetLastChangeDate  (datestr);
207   GS.SetApplicationProtocol(new TCollection_HAsciiString("")); //gka 19.01.99
208
209 //  Interface_Check check;
210 //  GS.Init(params, check);
211
212   // Creating the Model
213   //-------------------
214
215   Handle(IGESData_IGESModel) model = new IGESData_IGESModel;
216   model->SetGlobalSection(GS);
217   Interface_InterfaceModel::SetTemplate ("iges", model);
218 }
219
220     Handle(IGESData_Protocol) IGESData::Protocol ()
221 {
222   return proto;
223 }