Commit | Line | Data |
---|---|---|
973c2be1 | 1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 2 | // |
973c2be1 | 3 | // This file is part of Open CASCADE Technology software library. |
b311480e | 4 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 10 | // |
973c2be1 | 11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. | |
b311480e | 13 | |
7fd59977 | 14 | |
42cf5bc1 | 15 | #include <Interface_Check.hxx> |
7fd59977 | 16 | #include <Interface_CopyTool.hxx> |
42cf5bc1 | 17 | #include <Interface_EntityIterator.hxx> |
7fd59977 | 18 | #include <Interface_GeneralLib.hxx> |
7fd59977 | 19 | #include <Interface_GeneralModule.hxx> |
42cf5bc1 | 20 | #include <Interface_InterfaceModel.hxx> |
7fd59977 | 21 | #include <Interface_Macros.hxx> |
42cf5bc1 | 22 | #include <Interface_ShareTool.hxx> |
23 | #include <Message_Messenger.hxx> | |
24 | #include <Standard_NoSuchObject.hxx> | |
25 | #include <Standard_Transient.hxx> | |
26 | #include <Standard_Type.hxx> | |
27 | #include <StepData.hxx> | |
28 | #include <StepData_Protocol.hxx> | |
29 | #include <StepData_StepModel.hxx> | |
30 | #include <StepData_StepWriter.hxx> | |
31 | #include <TCollection_HAsciiString.hxx> | |
7fd59977 | 32 | |
42cf5bc1 | 33 | #include <stdio.h> |
92efcf78 | 34 | IMPLEMENT_STANDARD_RTTIEXT(StepData_StepModel,Interface_InterfaceModel) |
35 | ||
7fd59977 | 36 | // Entete de fichier : liste d entites |
bc650d41 | 37 | StepData_StepModel::StepData_StepModel () { } |
7fd59977 | 38 | |
7fd59977 | 39 | |
bc650d41 G |
40 | Handle(Standard_Transient) StepData_StepModel::Entity |
41 | (const Standard_Integer num) const | |
42 | { return Value(num); } // nom plus joli | |
7fd59977 | 43 | |
bc650d41 G |
44 | void StepData_StepModel::GetFromAnother |
45 | (const Handle(Interface_InterfaceModel)& other) | |
7fd59977 | 46 | { |
47 | theheader.Clear(); | |
48 | DeclareAndCast(StepData_StepModel,another,other); | |
49 | if (another.IsNull()) return; | |
50 | Interface_EntityIterator iter = another->Header(); | |
bc650d41 | 51 | // recopier le header. Attention, header distinct du contenu ... |
7fd59977 | 52 | Interface_CopyTool TC (this,StepData::HeaderProtocol()); |
53 | for (; iter.More(); iter.Next()) { | |
54 | Handle(Standard_Transient) newhead; | |
55 | if (!TC.Copy(iter.Value(),newhead,Standard_False,Standard_False)) continue; | |
56 | if (!newhead.IsNull()) theheader.Append(newhead); | |
57 | } | |
58 | } | |
59 | ||
bc650d41 G |
60 | Handle(Interface_InterfaceModel) StepData_StepModel::NewEmptyModel () const |
61 | { return new StepData_StepModel; } | |
7fd59977 | 62 | |
63 | ||
bc650d41 | 64 | Interface_EntityIterator StepData_StepModel::Header () const |
7fd59977 | 65 | { |
66 | Interface_EntityIterator iter; | |
67 | theheader.FillIterator(iter); | |
68 | return iter; | |
69 | } | |
70 | ||
bc650d41 G |
71 | Standard_Boolean StepData_StepModel::HasHeaderEntity |
72 | (const Handle(Standard_Type)& atype) const | |
73 | { return (theheader.NbTypedEntities(atype) == 1); } | |
7fd59977 | 74 | |
bc650d41 G |
75 | Handle(Standard_Transient) StepData_StepModel::HeaderEntity |
76 | (const Handle(Standard_Type)& atype) const | |
77 | { return theheader.TypedEntity(atype); } | |
7fd59977 | 78 | |
79 | ||
80 | // Remplissage du Header | |
81 | ||
bc650d41 G |
82 | void StepData_StepModel::ClearHeader () |
83 | { theheader.Clear(); } | |
7fd59977 | 84 | |
85 | ||
bc650d41 G |
86 | void StepData_StepModel::AddHeaderEntity |
87 | (const Handle(Standard_Transient)& ent) | |
88 | { theheader.Append(ent); } | |
7fd59977 | 89 | |
90 | ||
91 | void StepData_StepModel::VerifyCheck(Handle(Interface_Check)& ach) const | |
92 | { | |
93 | Interface_GeneralLib lib(StepData::HeaderProtocol()); | |
543a9964 | 94 | Handle(StepData_StepModel) me (this); |
95 | Handle(Interface_Protocol) aHP = StepData::HeaderProtocol(); | |
96 | Interface_ShareTool sh(me,aHP); | |
7fd59977 | 97 | Handle(Interface_GeneralModule) module; Standard_Integer CN; |
98 | for (Interface_EntityIterator iter = Header(); iter.More(); iter.Next()) { | |
99 | Handle(Standard_Transient) head = iter.Value(); | |
100 | if (!lib.Select(head,module,CN)) continue; | |
101 | module->CheckCase(CN,head,sh,ach); | |
102 | } | |
103 | } | |
104 | ||
105 | ||
bc650d41 G |
106 | void StepData_StepModel::DumpHeader |
107 | (const Handle(Message_Messenger)& S, const Standard_Integer /*level*/) const | |
7fd59977 | 108 | { |
bc650d41 | 109 | // NB : level n est pas utilise |
7fd59977 | 110 | |
111 | Handle(StepData_Protocol) stepro = StepData::HeaderProtocol(); | |
112 | Standard_Boolean iapro = !stepro.IsNull(); | |
113 | if (!iapro) S<<" -- WARNING : StepModel DumpHeader, Protocol not defined\n"; | |
114 | ||
115 | Interface_EntityIterator iter = Header(); | |
116 | Standard_Integer nb = iter.NbEntities(); | |
117 | S << " -- Step Model Header : " <<iter.NbEntities() << " Entities :\n"; | |
118 | for (iter.Start(); iter.More(); iter.Next()) { | |
119 | S << " " << iter.Value()->DynamicType()->Name() << "\n"; | |
120 | } | |
121 | if (!iapro || nb == 0) return; | |
122 | S << " -- -- STEP MODEL HEADER CONTENT -- --" << endl; | |
123 | S << " -- Dumped with Protocol : " << stepro->DynamicType()->Name() | |
124 | << " --"<<endl; | |
125 | ||
126 | Standard_SStream aSStream; | |
543a9964 | 127 | Handle(StepData_StepModel) me (this); |
128 | StepData_StepWriter SW(me); | |
7fd59977 | 129 | SW.SendModel(stepro,Standard_True); // envoi HEADER seul |
130 | SW.Print(aSStream); | |
131 | S << aSStream.str().c_str(); | |
132 | } | |
133 | ||
134 | ||
bc650d41 G |
135 | void StepData_StepModel::ClearLabels () |
136 | { theidnums.Nullify(); } | |
7fd59977 | 137 | |
bc650d41 G |
138 | void StepData_StepModel::SetIdentLabel |
139 | (const Handle(Standard_Transient)& ent, const Standard_Integer ident) | |
7fd59977 | 140 | { |
bc650d41 G |
141 | Standard_Integer num = Number(ent); |
142 | if (!num) | |
143 | return; | |
144 | if(theidnums.IsNull()) | |
145 | { | |
146 | theidnums = new TColStd_HArray1OfInteger(1, NbEntities()); | |
147 | theidnums->Init(0); | |
148 | } | |
149 | theidnums->SetValue(num,ident); | |
7fd59977 | 150 | |
7fd59977 | 151 | } |
152 | ||
bc650d41 G |
153 | Standard_Integer StepData_StepModel::IdentLabel |
154 | (const Handle(Standard_Transient)& ent) const | |
7fd59977 | 155 | { |
bc650d41 G |
156 | if(theidnums.IsNull()) |
157 | return 0; | |
158 | Standard_Integer num = Number(ent); | |
159 | return (!num ? 0 : theidnums->Value(num)); | |
160 | } | |
161 | ||
162 | void StepData_StepModel::PrintLabel | |
163 | (const Handle(Standard_Transient)& ent, const Handle(Message_Messenger)& S) const | |
164 | { | |
165 | Standard_Integer num = (theidnums.IsNull() ? 0 : Number(ent)); | |
166 | Standard_Integer nid = (!num ? 0 : theidnums->Value(num)); | |
7fd59977 | 167 | if (nid > 0) S<<"#"<<nid; |
168 | else if (num > 0) S<<"(#"<<num<<")"; | |
169 | else S<<"(#0..)"; | |
170 | } | |
171 | ||
bc650d41 G |
172 | Handle(TCollection_HAsciiString) StepData_StepModel::StringLabel |
173 | (const Handle(Standard_Transient)& ent) const | |
7fd59977 | 174 | { |
175 | Handle(TCollection_HAsciiString) label; | |
176 | char text[20]; | |
bc650d41 G |
177 | Standard_Integer num = (theidnums.IsNull() ? 0 : Number(ent)); |
178 | Standard_Integer nid = (!num ? 0 : theidnums->Value(num)); | |
7fd59977 | 179 | |
180 | if (nid > 0) sprintf (text, "#%d",nid); | |
181 | else if (num > 0) sprintf (text, "(#%d)",num); | |
182 | else sprintf (text, "(#0..)"); | |
183 | ||
184 | label = new TCollection_HAsciiString(text); | |
185 | return label; | |
186 | } |