b311480e |
1 | // Created on: 1997-09-03 |
2 | // Created by: Yves FRICAUD |
3 | // Copyright (c) 1997-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | #include <TNaming_Naming.ixx> |
24 | |
25 | #include <TNaming_Builder.hxx> |
26 | #include <TNaming_Tool.hxx> |
27 | #include <TNaming_ListIteratorOfListOfNamedShape.hxx> |
28 | #include <TNaming_Iterator.hxx> |
7fd59977 |
29 | #include <TNaming_Scope.hxx> |
30 | #include <TNaming_NamingTool.hxx> |
31 | #include <TNaming_Name.hxx> |
32 | #include <TNaming_Identifier.hxx> |
33 | #include <TNaming_Localizer.hxx> |
34 | #include <TNaming_NewShapeIterator.hxx> |
35 | #include <TNaming_OldShapeIterator.hxx> |
36 | #include <TNaming_Selector.hxx> |
37 | #include <TNaming.hxx> |
7fd59977 |
38 | #include <TDF_ChildIterator.hxx> |
39 | #include <TDF_LabelList.hxx> |
40 | #include <TDF_Data.hxx> |
41 | #include <TDF_LabelMap.hxx> |
42 | #include <TDF_TagSource.hxx> |
43 | #include <TopoDS_Iterator.hxx> |
44 | #include <TopTools_MapOfShape.hxx> |
45 | #include <TopExp.hxx> |
46 | #include <TopExp_Explorer.hxx> |
47 | #include <TopTools_MapIteratorOfMapOfShape.hxx> |
48 | #include <Standard_DomainError.hxx> |
49 | #include <TopTools_ListOfShape.hxx> |
50 | #include <TopTools_ListIteratorOfListOfShape.hxx> |
51 | #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> |
52 | #include <TColStd_MapOfInteger.hxx> |
53 | #include <TColStd_MapIteratorOfMapOfInteger.hxx> |
54 | #include <TopTools_MapIteratorOfMapOfOrientedShape.hxx> |
55 | #include <TopTools_HArray1OfShape.hxx> |
1ec8a59e |
56 | #include <BRepTools.hxx> |
7fd59977 |
57 | #include <BRep_Tool.hxx> |
58 | #include <TopoDS.hxx> |
1ec8a59e |
59 | #include <TopoDS_Wire.hxx> |
60 | #include <TopoDS_Face.hxx> |
61 | #include <TopoDS_Shell.hxx> |
62 | #include <TopoDS_Solid.hxx> |
7fd59977 |
63 | // #include <TNaming_NCollections.hxx> |
64 | #include <NCollection_Map.hxx> |
65 | #include <NCollection_DataMap.hxx> |
66 | typedef NCollection_Map<TopoDS_Shape> TNaming_MapOfShape; |
67 | typedef TNaming_MapOfShape::Iterator TNaming_MapIteratorOfMapOfShape; |
68 | typedef NCollection_DataMap<TopoDS_Shape, TNaming_MapOfShape> TNaming_DataMapOfShapeMapOfShape; |
69 | typedef TNaming_DataMapOfShapeMapOfShape::Iterator TNaming_DataMapIteratorOfDataMapOfShapeMapOfShape; |
70 | // The bug concerns access to a null object in the method Filter(): |
71 | #define BUC60847 |
72 | |
73 | #define OCC273 |
74 | #define OCC350 |
75 | #define OCC352 |
76 | #define ALLOW_CHILD_NBS |
77 | //#define MDTV_DEB_CC |
78 | //#define MDTV_DEB_OR |
79 | //#define MDTV_DEB_MOD |
80 | //#define MDTV_OR |
81 | //#define MDTV_DEB_INNS |
82 | //#define MDTV_DEB_NBS |
83 | //#define MDTV_DEB_71 |
84 | //#define MDTV_DEB_WIN |
85 | #ifdef MDTV_DEB |
86 | #include <TDF_MapIteratorOfLabelMap.hxx> |
87 | #include <TCollection_AsciiString.hxx> |
88 | #include <TDF_Tool.hxx> |
89 | #include <BRepTools.hxx> |
90 | #include <TNaming_Tool.hxx> |
91 | #include <DbgTools.hxx> |
92 | #endif |
93 | #ifdef DEB |
94 | #include <TDF_Tool.hxx> |
95 | #include <TDF_MapIteratorOfLabelMap.hxx> |
96 | |
97 | #include <TCollection_AsciiString.hxx> |
98 | #include <BRepTools.hxx> |
99 | void Print_Entry(const TDF_Label& label) |
100 | { |
101 | TCollection_AsciiString entry; |
102 | TDF_Tool::Entry(label, entry); |
103 | cout << "LabelEntry = "<< entry << endl; |
104 | } |
105 | static void Write(const TopoDS_Shape& shape, |
106 | const Standard_CString filename) |
107 | { |
108 | char buf[256]; |
109 | if(strlen(filename) > 256) return; |
110 | strcpy (buf, filename); |
111 | char* p = buf; |
112 | while (*p) { |
113 | if(*p == ':') |
114 | *p = '-'; |
115 | p++; |
116 | } |
117 | ofstream save (buf); |
118 | if(!save) |
119 | cout << "File " << buf << " was not created: rdstate = " << save.rdstate() << endl; |
120 | save << "DBRep_DrawableShape" << endl << endl; |
121 | if(!shape.IsNull()) BRepTools::Write(shape, save); |
122 | save.close(); |
123 | } |
124 | void WriteNSOnLabel(const Handle(TNaming_NamedShape) & NS, const TCollection_AsciiString& Nam) |
125 | { |
126 | if (!NS.IsNull()) { |
127 | TCollection_AsciiString entry; |
128 | TDF_Tool::Entry(NS->Label(), entry); |
129 | TopoDS_Shape Sh = TNaming_Tool::GetShape (NS); |
130 | if(!Sh.IsNull()) { |
131 | TCollection_AsciiString Entry = Nam + entry + ".brep"; |
132 | Write(Sh, Entry.ToCString()); |
133 | } |
134 | else |
135 | cout << "WriteNSOnLabel>>> TopoDS_Shape IS NULL on Entry = "<< entry << endl; |
136 | } |
137 | else |
138 | cout << "WriteNSOnLabel >>> NamedShape IS NULL" << endl; |
139 | } |
7fd59977 |
140 | #endif |
141 | |
142 | //========================================================================================== |
143 | static Handle(TNaming_NamedShape) BuildName (const TDF_Label& F, |
144 | TNaming_Scope& MDF, |
145 | const TopoDS_Shape& S, |
146 | const TopoDS_Shape& Context, |
147 | const Handle(TNaming_NamedShape)& Stop, |
148 | const Standard_Boolean Geometry); |
149 | |
150 | //======================================================================= |
151 | static Standard_Integer RepeatabilityInContext(const TopoDS_Shape& Selection, |
152 | const TopoDS_Shape& Context); |
153 | //======================================================================= |
154 | extern Standard_Boolean IsEqual (const TopoDS_Shape& S1, const TopoDS_Shape& S2); |
155 | |
156 | //======================================================================= |
157 | //function : Solve |
158 | //purpose : voir avec YFR comment retrouver le bon resulat et le mettre |
159 | // : dans le NamedShape de L |
160 | //======================================================================= |
161 | Standard_Boolean TNaming_Naming::Solve (TDF_LabelMap& Valid) |
162 | { |
163 | Handle(TNaming_Naming) subname; |
164 | for (TDF_ChildIterator it (Label(),Standard_False); it.More(); it.Next()) { |
165 | #ifdef MDTV_DEB_NBS |
166 | TCollection_AsciiString anEntry; |
167 | TDF_Tool::Entry(it.Value(), anEntry); |
168 | cout << "TNaming_Naming::Solve: Label to be solved = " << anEntry << endl; |
169 | #endif |
170 | if (it.Value().FindAttribute(TNaming_Naming::GetID(),subname)) { |
171 | if (!subname->Solve (Valid)) { |
172 | return Standard_False; // not necessary to continue |
173 | } |
174 | } |
175 | } |
176 | #ifdef MDTV_DEB_CC |
177 | TDF_MapIteratorOfLabelMap anItr(Valid); |
178 | cout << "TNaming_Naming::Solve:: Valid label Map" << endl; |
179 | for (; anItr.More(); anItr.Next()) { |
180 | const TDF_Label& aLabel = anItr.Key(); |
181 | TCollection_AsciiString anEntry; |
182 | TDF_Tool::Entry(aLabel, anEntry); |
183 | cout << "Label = " << anEntry << endl; |
184 | } |
185 | #endif |
186 | if (Regenerate(Valid)) { |
187 | if (!Valid.IsEmpty()) Valid.Add(Label()); |
188 | return Standard_True; |
189 | } |
190 | return Standard_False; |
191 | } |
192 | |
193 | |
194 | //======================================================================= |
195 | //function : GetID |
196 | //purpose : |
197 | //======================================================================= |
198 | |
199 | const Standard_GUID& TNaming_Naming::GetID () |
200 | { |
201 | static Standard_GUID TNaming_NamingID("c0a19201-5b78-11d1-8940-080009dc3333"); |
202 | return TNaming_NamingID; |
203 | } |
204 | |
205 | //======================================================================= |
206 | //function : Insert |
207 | //purpose : |
208 | //======================================================================= |
209 | |
210 | Handle(TNaming_Naming) TNaming_Naming::Insert (const TDF_Label& under) |
211 | { |
212 | Handle(TNaming_Naming) N; |
213 | TDF_Label child = TDF_TagSource::NewChild(under); |
214 | N = new TNaming_Naming (); |
215 | child.AddAttribute (N); |
216 | return N; |
217 | } |
218 | |
219 | //======================================================================= |
220 | //function : BuildNS |
221 | //purpose : returns a new NamedShape, which is built as selection: |
222 | // : TNaming_Builder::Select("S","S") at the new child label of the label <F>. |
223 | //======================================================================= |
224 | |
225 | static Handle(TNaming_NamedShape) BuildNS (const TDF_Label& F, |
226 | const TopoDS_Shape& S, |
227 | const TNaming_NameType& Name) |
228 | { |
229 | Handle (TNaming_Naming) Naming = TNaming_Naming::Insert (F); |
230 | |
231 | TNaming_Name& theName = Naming->ChangeName(); |
232 | theName.ShapeType(S.ShapeType()); |
233 | theName.Shape(S); |
7dcac1df |
234 | theName.Orientation(S.Orientation()); |
7fd59977 |
235 | theName.Type(Name); |
236 | TNaming_Builder B(Naming->Label()); |
237 | B.Select(S,S); |
238 | return B.NamedShape(); |
239 | } |
240 | |
241 | //======================================================================= |
242 | //function : FindIndex |
243 | //purpose : |
244 | //======================================================================= |
245 | |
246 | static Standard_Integer FindIndex(const Handle(TNaming_NamedShape)& NS, |
247 | const TopoDS_Shape& S) |
248 | { |
249 | TDF_LabelList Labels; |
250 | TopoDS_Shape IS = TNaming_Tool::InitialShape(S,NS->Label(),Labels); |
251 | Standard_Integer Index = 1; |
252 | for (TNaming_Iterator itNS(NS); itNS.More(); itNS.Next(),Index++) { |
253 | if (IS.IsSame(itNS.NewShape())) break; |
254 | } |
255 | return Index; |
256 | } |
257 | |
258 | |
259 | //======================================================================= |
260 | //function : CompareInGeneration |
261 | //purpose : returns true, only if the specified NS contains only <S> in |
262 | // : the "new shapes" set. |
263 | //======================================================================= |
264 | |
265 | static Standard_Boolean CompareInGeneration (const Handle(TNaming_NamedShape)& NS, |
266 | const TopoDS_Shape& S) |
267 | { |
268 | for (TNaming_Iterator it(NS); it.More(); it.Next()) { |
269 | if (!it.NewShape().IsSame(S)) return 0; |
270 | } |
271 | return 1; |
272 | } |
273 | |
274 | #ifdef OCC350 |
275 | |
276 | //======================================================================= |
277 | //function : GetShapeEvolutions |
278 | //purpose : returns Standard_True, if target has parent in source; list contains inheritance chain |
279 | //======================================================================= |
280 | static Standard_Boolean GetShapeEvolutions(const TopoDS_Shape& theTarget, // this is changed in recursion |
281 | const Handle(TNaming_NamedShape)& theSource, |
282 | TopTools_ListOfShape& aList) // returns list in the backward order |
283 | { |
284 | Handle(TNaming_NamedShape) aTarget = TNaming_Tool::NamedShape(theTarget,theSource->Label()); |
285 | if (!aTarget.IsNull()) { |
286 | #ifdef MDTV_DEB_71 |
287 | cout <<"GetShapeEvolutions: target NS = "; |
288 | Print_Entry(aTarget->Label()); |
289 | cout <<"GetShapeEvolutions: Source NS = "; |
290 | Print_Entry(theSource->Label()); |
291 | TCollection_AsciiString aNam("GetShapeEvolutions"); |
292 | WriteNSOnLabel(aTarget,aNam); |
293 | #endif |
294 | if (aTarget->Label() == theSource->Label()) return Standard_True; // check if target is in the source |
295 | } else return Standard_False; |
296 | |
297 | TNaming_Iterator anIter(aTarget); |
298 | for(;anIter.More();anIter.Next()) { // check all appropriate old shapes of target |
299 | #ifdef MDTV_DEB_71 |
300 | if(!anIter.OldShape().IsNull()) { |
301 | Write(anIter.OldShape(), "Target_OldS.brep"); |
302 | cout <<"Target OldS TS =" <<anIter.OldShape().TShape()->This() <<endl; |
303 | } |
304 | if(!anIter.NewShape().IsNull()) { |
305 | Write(anIter.NewShape(), "Target_NewS.brep"); |
306 | cout <<"Target NewS TS =" <<anIter.NewShape().TShape()->This() <<endl; |
307 | } |
308 | #endif |
309 | if (anIter.OldShape().IsNull() || anIter.NewShape().IsNull()) continue; |
310 | if (!anIter.NewShape().IsSame(theTarget)) continue; |
311 | if (GetShapeEvolutions(anIter.OldShape(),theSource,aList)) { // recursion: now target is old shape |
312 | aList.Append(theTarget); // if oldshape has the source as parent (or belongs to it) , fill the list |
313 | return Standard_True; |
314 | } |
315 | } |
316 | return Standard_False; |
317 | } |
318 | |
319 | //======================================================================= |
320 | //function : CompareInModification |
321 | //purpose : returns empty named shape if naming is already done |
322 | //======================================================================= |
323 | |
324 | static Handle(TNaming_NamedShape) CompareInModification (const Handle(TNaming_NamedShape)& NS, // parent |
325 | const TopoDS_Shape& S) // target |
326 | { |
327 | Handle(TNaming_NamedShape) aResult; |
328 | if (S.IsNull() || NS.IsNull()) return aResult; |
329 | #ifdef MDTV_DEB_71 |
330 | cout <<"CompareInModification: parent NS = "; |
331 | Print_Entry(NS->Label()); |
332 | Write(S, "CompareInM_S.brep"); |
333 | TCollection_AsciiString aNam("CompareInM"); |
334 | WriteNSOnLabel(NS,aNam); |
335 | #endif |
336 | Handle(TNaming_NamedShape) aSource; // parent NamedShape, which can be found by TopoDS shape |
337 | TNaming_Iterator anIt(NS); |
338 | for(;anIt.More() && aSource.IsNull();anIt.Next()) { |
339 | if (!anIt.NewShape().IsNull()) { |
340 | aSource = TNaming_Tool::NamedShape(anIt.NewShape(),NS->Label()); |
341 | #ifdef MDTV_DEB_71 |
342 | TCollection_AsciiString aNam("CompareInM_Source"); |
343 | WriteNSOnLabel(aSource,aNam); |
344 | #endif |
345 | } |
346 | } |
347 | // searching for 1:n to the same label modifications (in this case current naming is insufficient) |
348 | TopTools_ListOfShape aList; |
349 | if (GetShapeEvolutions(S,aSource,aList) && aList.Extent() > 0) { |
350 | TopTools_ListIteratorOfListOfShape anIter(aList); |
351 | for(;anIter.More();anIter.Next()) { |
352 | aResult = TNaming_Tool::NamedShape(anIter.Value(),NS->Label()); |
353 | if (aResult->Evolution()!=TNaming_MODIFY) { // evolution must be modify, otherwise everything is OK |
354 | aResult.Nullify(); |
355 | return aResult; |
356 | } |
357 | TopTools_MapOfShape aMap; // collection of the old shapes of the shape from list |
358 | TNaming_Iterator aNIter1(aResult); |
359 | |
360 | for(;aNIter1.More();aNIter1.Next()) { |
361 | if (aNIter1.NewShape().IsSame(anIter.Value())) {// if isSame |
362 | aMap.Add(aNIter1.OldShape()); |
363 | } |
364 | } |
365 | TNaming_Iterator aNIter2(aResult); // if some another shapes has oldshape from map, return namedshape with this oldshape |
366 | |
367 | for(;aNIter2.More();aNIter2.Next()) { |
368 | if (aNIter2.NewShape().IsSame(anIter.Value())) continue; |
369 | if (aMap.Contains(aNIter2.OldShape())) { // if one shape was modified to the two at the shared label, return this one |
370 | aResult = TNaming_Tool::NamedShape(aNIter2.OldShape(),NS->Label()); |
371 | if (!aResult.IsNull()) return aResult; |
372 | } |
373 | } |
374 | } |
375 | aResult.Nullify(); |
376 | } |
377 | return aResult; |
378 | } |
379 | #endif |
380 | |
381 | //======================================================================= |
382 | static Standard_Boolean FillSMap(const TopoDS_Shape& S, TopTools_MapOfShape& MS) |
383 | { |
384 | if(S.IsNull()) return Standard_False; |
385 | Standard_Boolean isHomogen(Standard_True); |
386 | TopAbs_ShapeEnum aPrevType(TopAbs_SHAPE); |
387 | TopoDS_Iterator it(S); |
388 | for (; it.More(); it.Next()) { |
389 | const TopAbs_ShapeEnum aType = it.Value().ShapeType(); |
390 | #ifdef MDTV_DEB_CC |
391 | cout <<"TestSolution_FillMap: S_Type = :" << it.Value().ShapeType() <<" TShape = " << it.Value().TShape()->This() <<endl; |
392 | #endif |
393 | if(aType > TopAbs_COMPSOLID) { |
394 | MS.Add(it.Value()); |
395 | if(aPrevType == TopAbs_SHAPE) |
396 | aPrevType = aType; |
397 | else if(aPrevType != aType) |
398 | isHomogen = Standard_False; |
399 | } |
400 | else |
401 | if(!FillSMap(it.Value(), MS)) |
402 | isHomogen = Standard_False; |
403 | } |
404 | return isHomogen; |
405 | } |
406 | //======================================================================= |
407 | //function : Compare |
408 | //purpose : checks naming of the shape <S> in the NamedShape <NS>. |
409 | // : Returns true, if it's correct. Details ==> |
410 | // : The method takes all modifications of the "NS" (see CurrentShape method), |
411 | // : which are in the "MDF" (if it's not empty) before <Stop> shape and check them. |
412 | // : whether these modifications contain only "S". If yes then the method |
413 | // : returns true, otherwise it returns false. |
414 | //======================================================================= |
415 | |
416 | static Standard_Boolean Compare (const Handle(TNaming_NamedShape)& NS, |
417 | const TNaming_Scope& MDF, |
418 | const Handle(TNaming_NamedShape)& Stop, |
419 | const TopoDS_Shape& S) |
420 | { |
421 | TDF_LabelMap Forbiden; |
422 | TopTools_MapOfShape MS; |
423 | if (!Stop.IsNull()) TNaming_NamingTool::BuildDescendants(Stop,Forbiden); |
424 | TNaming_NamingTool::CurrentShape(MDF.GetValid(),Forbiden,NS,MS); |
425 | #ifdef MDTV_DEB_NBS |
426 | Write(S, "Compare_S.brep"); |
427 | cout << "S: TShape = " <<S.TShape()->This() <<endl; |
428 | Standard_Integer i =1; |
429 | TopTools_MapIteratorOfMapOfShape it(MS); |
430 | TCollection_AsciiString aNam("Compare_MS_"); |
431 | TCollection_AsciiString ext(".brep"); |
432 | for(;it.More();it.Next(), i++) { |
433 | TCollection_AsciiString aName = aNam + i + ext; |
434 | Write(it.Key(), aName.ToCString()) ; |
435 | cout << aName.ToCString()<< ": TShape = " <<it.Key().TShape()->This() <<endl; |
436 | } |
437 | #endif |
438 | return (MS.Contains(S) && MS.Extent() == 1); |
439 | } |
440 | //======================================================================= |
441 | //function : TestSolution |
442 | //purpose : returns true, if last modification of shape from "NS" is equal to "S": |
443 | // : If shape "S" has atomic type (TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX), |
444 | // : then returns S.IsSame(shape from "NS"). |
445 | // : Otherwise the result of exploration of these shapes must be same. |
446 | //======================================================================= |
447 | |
448 | static Standard_Boolean TestSolution(const TNaming_Scope& MDF, |
449 | const Handle(TNaming_NamedShape)& NS, |
450 | const TopoDS_Shape& S) |
451 | { |
452 | |
453 | if (NS.IsNull()) return Standard_False; |
454 | TopoDS_Shape Res = MDF.CurrentShape(NS);// last modification of NS taken into account Valid map |
455 | if(S.IsNull() || Res.IsNull()) return Standard_False; |
456 | #ifdef MDTV_DEB_CC |
457 | Write(S, "TSol_S.brep"); |
458 | Write(Res, "TSol_Res.brep"); |
459 | #endif |
460 | #ifdef OCC352 |
461 | |
462 | if ((S.ShapeType() == TopAbs_FACE || |
463 | S.ShapeType() == TopAbs_EDGE || |
464 | S.ShapeType() == TopAbs_VERTEX ) && |
465 | Res.ShapeType() != TopAbs_COMPOUND) { |
466 | return (Res.IsSame(S)); |
467 | } else if (S.ShapeType() == TopAbs_SOLID || |
468 | S.ShapeType() == TopAbs_COMPSOLID) { |
469 | TopTools_MapOfShape aMS; |
470 | TopExp_Explorer exp; |
471 | for (exp.Init(S,TopAbs_FACE) ; exp.More(); exp.Next()) { |
472 | aMS.Add(exp.Current()); |
473 | } |
474 | for (exp.Init(Res,TopAbs_FACE) ; exp.More(); exp.Next()) { //content of MS and Res should be the same |
475 | if (aMS.Contains(exp.Current())) { |
476 | aMS.Remove(exp.Current()); |
477 | } |
478 | else return 0; |
479 | } |
480 | return aMS.IsEmpty(); |
481 | } else { |
482 | |
483 | #else |
484 | |
485 | if (S.ShapeType() == TopAbs_SOLID || |
486 | S.ShapeType() == TopAbs_FACE || |
487 | S.ShapeType() == TopAbs_EDGE || |
488 | S.ShapeType() == TopAbs_VERTEX ) { |
489 | return (Res.IsSame(S)); |
490 | } |
491 | else { |
492 | |
493 | #endif |
494 | |
495 | TopTools_MapOfShape MS; |
496 | Standard_Boolean isHom = FillSMap(S, MS); |
497 | TopAbs_ShapeEnum aType(TopAbs_SHAPE); |
498 | TColStd_MapOfInteger aView; |
499 | TopTools_MapIteratorOfMapOfShape itm(MS); |
500 | for(;itm.More();itm.Next()) { |
501 | aType = itm.Key().ShapeType(); |
502 | if(isHom) |
503 | break; |
504 | else |
505 | aView.Add(itm.Key().ShapeType()); |
506 | } |
507 | |
508 | if (MS.Contains(Res)) { |
509 | MS.Remove(Res); |
510 | if (MS.IsEmpty()) return 1; |
511 | } |
512 | if (Res.ShapeType() == TopAbs_SOLID || |
513 | Res.ShapeType() == TopAbs_COMPSOLID || |
514 | Res.ShapeType() == TopAbs_COMPOUND) |
515 | { |
516 | TopExp_Explorer exp; |
517 | if(isHom) |
518 | for (exp.Init(Res,aType) ; exp.More(); exp.Next()) { |
519 | if (MS.Contains(exp.Current())) { |
520 | MS.Remove(exp.Current()); |
521 | } |
522 | } else { |
523 | TColStd_MapIteratorOfMapOfInteger itm(aView); |
524 | for(;itm.More();itm.Next()) { |
525 | TopAbs_ShapeEnum aType = (TopAbs_ShapeEnum)itm.Key(); |
526 | for (exp.Init(Res,aType) ; exp.More(); exp.Next()) { |
527 | if (MS.Contains(exp.Current())) { |
528 | MS.Remove(exp.Current()); |
529 | } |
530 | } |
531 | } |
532 | } |
533 | } else { |
534 | if(S.IsSame(Res)) |
535 | return Standard_True; |
536 | TopoDS_Iterator it(Res); |
537 | for (; it.More(); it.Next()) { //content of MS and Res should be the same |
538 | if (MS.Contains(it.Value())) { |
539 | MS.Remove(it.Value()); |
540 | } |
541 | else return 0; |
542 | } |
543 | } |
544 | return MS.IsEmpty(); |
545 | } |
546 | } |
547 | |
548 | //======================================================================= |
549 | //function : FindNewShapeInFather |
550 | //purpose : |
551 | //======================================================================= |
552 | |
553 | static void FindNewShapeInFather (const Handle(TNaming_NamedShape)& NS, |
554 | TopoDS_Shape& SC) |
555 | { |
b2197f93 |
556 | const TDF_Label& Father = NS->Label().Father(); |
7fd59977 |
557 | TNaming_Iterator itLab(Father); |
b2197f93 |
558 | if(itLab.More()) |
559 | SC = itLab.NewShape(); |
7fd59977 |
560 | } |
561 | |
562 | //======================================================================= |
563 | //function : NextModif |
564 | //purpose : |
565 | //======================================================================= |
566 | |
567 | static Handle(TNaming_NamedShape) NextModif(const Handle(TNaming_NamedShape)& NS) |
568 | { |
569 | Handle (TNaming_NamedShape) Next; |
570 | if (!NS.IsNull()) { |
571 | TNaming_NewShapeIterator it(NS); |
572 | if (it.More()&& it.IsModification()) Next = it.NamedShape(); |
573 | } |
574 | return Next; |
575 | } |
576 | //======================================================================= |
577 | // C1 - cand shape of the father, C2 - shape of rebuild child Naming attr. |
578 | // (to be Compound of elementary shapes) |
579 | //======================================================================= |
580 | static Standard_Boolean IsContSame(const TopoDS_Shape& C1, const TopoDS_Shape& C2) |
581 | { |
582 | Standard_Boolean aRes(Standard_False); |
583 | if(!C1.IsNull() && !C2.IsNull()) { |
584 | TopTools_MapOfShape aMap; |
585 | if(FillSMap(C1, aMap)) { |
586 | aRes = Standard_True; |
587 | TopoDS_Iterator it(C2); |
588 | for(;it.More();it.Next()) { |
589 | if(!aMap.Contains(it.Value())) { |
590 | aRes = Standard_False; |
591 | break; |
592 | } |
593 | } |
594 | } |
595 | } |
596 | return aRes; |
597 | } |
598 | |
599 | //======================================================================= |
600 | // Identifies the case when Filter haven't sense because of multiplicity |
601 | //======================================================================= |
602 | static Standard_Boolean IsMultipleCase(const TopoDS_Shape& S, |
603 | const TopoDS_Shape& Context, |
604 | const TopTools_MapOfShape& Neighbourgs) { |
605 | |
606 | TopTools_IndexedDataMapOfShapeListOfShape aDM; |
607 | TNaming_MapOfShape aM; |
608 | TopTools_MapOfShape aNbs; |
609 | aNbs.Assign(Neighbourgs); |
610 | aNbs.Add(S); |
611 | TNaming_DataMapOfShapeMapOfShape aDMM; |
612 | TopExp::MapShapesAndAncestors (Context, TopAbs_EDGE, TopAbs_FACE, aDM); |
613 | TopTools_MapIteratorOfMapOfShape it(aNbs); |
614 | for(;it.More();it.Next()) { |
615 | if(aDM.Contains(it.Key())) { |
616 | TNaming_MapOfShape aMS; |
617 | const TopTools_ListOfShape& aL = aDM.FindFromKey(it.Key()); |
618 | TopTools_ListIteratorOfListOfShape lit(aL); |
619 | for(;lit.More();lit.Next()) { |
620 | aM.Add(lit.Value()); |
621 | aMS.Add(lit.Value()); |
622 | } |
623 | if(aMS.Extent()) |
624 | aDMM.Bind(it.Key(), aMS); |
625 | } else { |
626 | #ifdef DEB |
627 | cout << "Key is not BOUND!" <<endl; |
628 | #endif |
629 | return Standard_False; |
630 | } |
631 | } |
632 | |
633 | Standard_Boolean isCommon(Standard_True); |
634 | TNaming_MapIteratorOfMapOfShape itm(aM); |
635 | for(;itm.More();itm.Next()) { |
636 | isCommon = Standard_True; // statement: this shape (itm.Key()) is common (to be checked below) |
637 | TNaming_DataMapIteratorOfDataMapOfShapeMapOfShape itdm(aDMM); |
638 | for (;itdm.More();itdm.Next()) { |
7fd59977 |
639 | const TNaming_MapOfShape& aMap = itdm.Value(); |
640 | if(!aMap.Contains(itm.Key())) { |
641 | isCommon = Standard_False; |
642 | break; |
643 | } |
644 | } |
645 | if(isCommon) break; // common single face found |
646 | } |
647 | if(isCommon && aM.Extent() < aNbs.Extent()) {// number of unique faces (to have single solution) |
648 | //should be at least no less than (Nb of Neighbourgs) +1 |
649 | return Standard_True; |
650 | } |
651 | return Standard_False; |
652 | } |
653 | //======================================================================= |
654 | //function : Filter |
655 | //purpose : sets the name with type "FILTERBYNEIGHBOURGS" and returns true, |
656 | // : if it was correctly done. |
657 | // : |
658 | // : |
659 | //======================================================================= |
660 | |
661 | static Standard_Boolean Filter (const TDF_Label& F, |
662 | TNaming_Scope& MDF, |
663 | const TopoDS_Shape& S, |
664 | const TopoDS_Shape& Context, |
665 | TNaming_Localizer& Localizer, |
666 | Handle(TNaming_NamedShape)& NS, |
667 | const Standard_Integer Lev) |
668 | { |
669 | // 1. Localizer.FindNeighbourg("Context", "S", "Neighbourg") - looks for neighbourgs of "S" with the same shape type in the "Context" |
670 | // shape and adds them to the "Neighbourg" map; |
671 | // 2. If "Neighbourg" map is empty, tries to do the same with the new context shape: shape from the father label of the "S" named shape; |
672 | // 3. If "Neighbourg" map is still empty, returns false; |
673 | // 4. Adds to the new child of label "L" new TNaming_Naming attribute with the next properties name: shape type is shape type of the "S", |
674 | // type is TNaming_FILTERBYNEIGHBOURGS, stop shape ( "Until" ) is "Context" of corresponding NamedShape; |
675 | // first argument of name is "NS" NamedShape. |
676 | // 5. Adds to the Name all shapes from "Neighbourg" map: build it with the BuildName( new generated TNaming_Naming attribute, MDF, |
677 | // argument shape from "Neighbourg", "Context", NextModif( "Until" ), true ) method. |
678 | // 6. Creates resulting NamedShape with the "Regenerate" ( it just calls TName::Solve method ) method from TNaming_Naming class. |
679 | // 7. If Compare( result NamedShape, MDF, stop, "S" ) returns true, "Filter" method returns true, else returns false. |
680 | |
681 | //------------------------------ |
682 | // Construction des voisins ==> of neighbors. |
683 | //------------------------------ |
684 | Standard_Integer aLev(Lev); |
685 | TopTools_MapOfShape Neighbourg; |
686 | Localizer.FindNeighbourg (Context,S,Neighbourg); |
687 | #ifdef MDTV_DEB_NBS |
688 | //DbgTools::DisplayShape(Context, F, Quantity_NOC_GREEN); |
689 | //DbgTools::DisplayShape(S, F, Quantity_NOC_BLUE1); |
690 | Write(Context, "FNBS_Context.brep"); |
691 | Write(S, "FNBS_S.brep"); |
efd4b232 |
692 | Write(Neighbourg, "NBS"); |
7fd59977 |
693 | #endif |
694 | #ifdef OCC273 |
695 | // mpv : NS and shape must be the same |
696 | Standard_Boolean isIn = Standard_False; |
697 | TNaming_Iterator anIter(NS); |
698 | for(;anIter.More();anIter.Next()) { |
699 | #ifdef MDTV_DEB |
700 | //DbgTools::DisplayShape(anIter.NewShape(), F, Quantity_NOC_RED); |
701 | #endif |
702 | if (anIter.NewShape().IsSame(S)) { |
703 | isIn = Standard_True; |
704 | break; |
705 | } |
706 | } |
707 | if (!isIn) if (!TNaming_Tool::NamedShape(S,F).IsNull()) NS = TNaming_Tool::NamedShape(S,F); |
708 | // if (!TNaming_Tool::NamedShape(S,F).IsNull()) NS = TNaming_Tool::NamedShape(S,F); |
709 | #endif |
710 | |
711 | if (Neighbourg.IsEmpty()) { |
712 | // Recherche du vrai context. (Research of context truth) |
713 | Handle(TNaming_NamedShape) GenS = TNaming_Tool::NamedShape(S,NS->Label()); |
714 | #ifdef BUC60847 |
715 | if (GenS.IsNull()) return Standard_False; |
716 | #endif |
717 | TDF_Label Father = (GenS->Label()).Father(); |
718 | Father.FindAttribute(TNaming_NamedShape::GetID(),GenS); |
719 | TopoDS_Shape GoodContext = TNaming_Tool::GetShape(GenS); |
720 | Localizer.FindNeighbourg (GoodContext,S,Neighbourg); |
721 | } |
722 | |
723 | |
724 | if (Neighbourg.IsEmpty()) { |
725 | #ifdef DEB |
726 | cout <<"FindNeighbourg: impossible"<<endl; |
727 | #endif |
728 | return 0; |
729 | } else { |
730 | #ifdef MDTV_DEB_NBS |
731 | Write(Neighbourg, "Neighbourgs"); |
732 | #endif |
733 | aLev++; |
734 | //cout <<"Filter: Lev = " << aLev << endl; |
735 | } |
736 | if(aLev > 3) return 0; |
737 | #ifdef ALLOW_CHILD_NBS |
738 | Handle(TNaming_Naming) aFNaming; |
739 | TopoDS_Shape aFatherCandSh; |
740 | F.FindAttribute(TNaming_Naming::GetID(), aFNaming); |
741 | if(!aFNaming.IsNull()) { |
742 | const TNaming_Name& aName = aFNaming->GetName(); |
743 | if (aName.Type() == TNaming_FILTERBYNEIGHBOURGS) { |
744 | aFatherCandSh = aName.Arguments().First()->Get(); |
745 | } |
746 | } |
747 | if(S.ShapeType() == TopAbs_EDGE && aFatherCandSh.IsNull()) { |
748 | //check the applicability |
749 | if(!NS.IsNull() && !NS->Get().IsNull() && NS->Get().ShapeType() == TopAbs_COMPOUND) |
750 | if(IsMultipleCase(S, Context, Neighbourg)) { |
751 | //cout << "Filter: ==> MultipleCase!" << endl; |
752 | NS->Label().FindAttribute(TNaming_Naming::GetID(), aFNaming); |
753 | if(!aFNaming.IsNull()) { |
754 | TNaming_Name& aName = aFNaming->ChangeName(); |
755 | if (aName.Type() == TNaming_INTERSECTION) { |
756 | Standard_Integer ij(1); |
757 | TNaming_ListIteratorOfListOfNamedShape itA(aName.Arguments()); |
758 | for (; itA.More(); itA.Next(), ij++) { |
759 | const TopoDS_Shape& aFace = TNaming_Tool::CurrentShape(itA.Value()); |
760 | #ifdef MDTV_DEB_MOD |
761 | Write(aFace, "First_Face.brep"); |
762 | cout <<"Selection TS = " << S.TShape()->This() <<endl; |
763 | #endif |
764 | Standard_Integer i(1), indxW(0),indxE(0),nbW(0),nbE(0), indxF(0); |
765 | Standard_Boolean isFound(Standard_False); |
766 | TopoDS_Iterator it(aFace); |
767 | for (;it.More();it.Next(),i++) { |
768 | nbW++; |
769 | #ifdef MDTV_DEB_MOD |
770 | Write(it.Value(), "First_Wire.brep"); |
771 | #endif |
772 | if(!isFound) { |
773 | Standard_Integer j(1); |
774 | TopoDS_Iterator it2(it.Value()); |
775 | for (;it2.More();it2.Next(),j++) { |
776 | nbE++; |
777 | #ifdef MDTV_DEB_MOD |
778 | Write(it2.Value(), "First_Wire.brep"); |
779 | cout <<"Edge TS = " << it2.Value().TShape()->This() <<endl; |
780 | #endif |
781 | if(S.IsEqual(it2.Value())) { |
782 | indxE = j; |
783 | indxW = i; |
784 | indxF = ij; |
785 | isFound = Standard_True; |
786 | } |
787 | } |
788 | } |
789 | } |
790 | if(isFound) { |
791 | Standard_Integer Index = indxE & 0x000000FF; |
792 | Index = Index | (nbE << 8); |
793 | Index = Index | (indxW << 16); |
794 | Index = Index | (nbW << 20); |
795 | Index = Index | (indxF << 24); |
796 | aName.Index(Index); |
797 | //------------------------------ |
798 | // Compute the TNaming_NamedShape |
799 | //------------------------------ |
800 | aFNaming->Regenerate(MDF.ChangeValid()); |
801 | aFNaming->Label().FindAttribute(TNaming_NamedShape::GetID(),NS); |
802 | Handle (TNaming_NamedShape) Until = TNaming_Tool::NamedShape(Context,NS->Label()); |
803 | Handle (TNaming_NamedShape) Stop = NextModif(Until); |
804 | if (Compare (NS,MDF,Stop,S)) return 1; |
805 | break; |
806 | } |
807 | } |
808 | } |
809 | } |
810 | return 0; |
811 | } |
812 | } |
813 | #endif |
814 | |
815 | //----------------------------------------------------- |
816 | // Construction function de naming. et insertion sous F |
817 | //----------------------------------------------------- |
818 | Handle (TNaming_Naming) NF = TNaming_Naming::Insert (F); |
819 | |
820 | Handle (TNaming_NamedShape) Until = TNaming_Tool::NamedShape(Context,NS->Label()); |
821 | Handle (TNaming_NamedShape) Stop = NextModif(Until); |
822 | TNaming_Name& theName = NF->ChangeName(); |
823 | theName.ShapeType(S.ShapeType()); |
824 | theName.Shape(S); |
7dcac1df |
825 | theName.Orientation(S.Orientation()); |
7fd59977 |
826 | theName.Type(TNaming_FILTERBYNEIGHBOURGS); |
827 | theName.Append(NS); |
828 | theName.StopNamedShape (Until); |
829 | #ifdef MDTV_DEB_NBS |
830 | cout << "FilterByNBS: "; |
831 | Print_Entry(NF->Label()); |
efd4b232 |
832 | cout <<"AppendNS = " ; |
833 | Print_Entry(NS->Label()); |
7fd59977 |
834 | #endif |
835 | //--------------------- |
836 | // Naming des voisins. |
837 | //--------------------- |
838 | |
839 | TopTools_MapIteratorOfMapOfShape itN(Neighbourg); |
840 | for (; itN.More(); itN.Next()) { |
841 | #ifdef ALLOW_CHILD_NBS |
842 | const TopoDS_Shape& aS = itN.Key(); |
843 | Handle (TNaming_NamedShape) aNS = |
844 | BuildName(NF->Label(), MDF, aS, Context, Stop, 1); |
845 | #ifdef MDTV_DEB_NBS |
846 | const TopoDS_Shape& aS2 = aNS->Get(); |
847 | if(!aS.IsNull()) |
848 | cout << "Shape arg type = " << aS.ShapeType() <<" TSH = " << aS.TShape()->This()<<endl; |
efd4b232 |
849 | if(!aS2.IsNull()) { |
7fd59977 |
850 | cout << "Build shape type = " << aS2.ShapeType() <<" TSH = " << aS2.TShape()->This()<<endl; |
efd4b232 |
851 | Write (aS2, "NBS_BuildShape.brep"); |
852 | } |
853 | if(aNS.IsNull()) { |
854 | cout <<"AppendNS = " ; |
855 | Print_Entry(aNS->Label()); |
856 | } |
7fd59977 |
857 | #endif |
858 | |
859 | const TopoDS_Shape aSNS = aNS->Get(); //allow child level |
860 | Standard_Boolean allowChild(Standard_True); |
861 | if(!aSNS.IsNull() && aSNS.ShapeType() == TopAbs_COMPOUND && !aFatherCandSh.IsNull()) |
862 | allowChild = !IsContSame(aFatherCandSh, aSNS); |
863 | if(allowChild && !aSNS.IsNull() && aS.ShapeType() != aSNS.ShapeType() && |
864 | aSNS.ShapeType() == TopAbs_COMPOUND) |
865 | { // aLev < 3 |
866 | #ifdef MDTV_DEB_NBS |
867 | cout <<"Father label = "; |
868 | Print_Entry(aNS->Label().Father()); |
869 | Write(aS,"SelectionS.brep"); |
870 | Write(aSNS,"SelectionSNS.brep"); |
871 | #endif |
872 | Handle(TNaming_Naming) aNaming; |
873 | Standard_Boolean StandardFilter(Standard_True); |
874 | aNS->FindAttribute(TNaming_Naming::GetID(), aNaming); |
875 | if(!aNaming.IsNull()) { |
876 | const TNaming_Name& aName = aNaming->GetName(); |
877 | if (aName.Type() == TNaming_GENERATION) |
878 | StandardFilter = Standard_False; |
879 | if(StandardFilter) |
880 | if (!Compare (aNS,MDF,Stop,aS)) { |
881 | TNaming_Localizer aLocalizer; |
882 | Filter (NF->Label(), MDF,aS,Context, aLocalizer,aNS, aLev); |
883 | } |
884 | } |
885 | } |
886 | theName.Append(aNS); |
887 | #else |
888 | theName.Append(BuildName(NF->Label(), MDF, itN.Key(), Context, Stop, 1)); |
889 | #endif |
890 | } |
891 | //------------------------------ |
892 | // Compute the TNaming_NamedShape |
893 | //------------------------------ |
894 | NF->Regenerate(MDF.ChangeValid()); |
895 | NF->Label().FindAttribute(TNaming_NamedShape::GetID(),NS); |
896 | |
897 | //----------------- |
898 | // Check du filtre. |
899 | //----------------- |
900 | if (Compare (NS,MDF,Stop,S)) return 1; |
901 | #ifdef MDTV_DEB |
902 | cout <<"TNaming_Naming::Name Filter insufficient"<<endl; |
903 | #endif |
904 | return 0; |
905 | } |
906 | |
907 | |
908 | //======================================================================= |
909 | //function : BuildNameInNS |
910 | //purpose : Calls BuildName method, but with new context and new stop shape. |
911 | // : Context is searched at the father label of the "Context" label : |
912 | // : old shapes from the NamedShape at the defined father label. |
913 | // : If it's impossible, then "S" set as context. |
914 | // : If "S" is in new context, then stop shape is named shape, |
915 | // : which belongs to the father label of the "Context" named shape. |
916 | // : For example, face (F2) of prism (P) is generated from the edge (E) |
917 | // : of primitive face (F1) of box (B). F2 is named as GENERATION from E. |
918 | // : Naming of E is done with help BuildNameInNS function: |
919 | // : with context B and stop shape P. |
920 | //======================================================================= |
921 | static Handle(TNaming_NamedShape) BuildNameInNS (const TDF_Label& F, |
922 | TNaming_Scope& MDF, |
923 | const TopoDS_Shape& S, |
924 | const Handle(TNaming_NamedShape)& Context, |
925 | const Handle(TNaming_NamedShape)& Stop, |
926 | const Standard_Boolean Geometry) |
927 | |
928 | { |
929 | // il faut determiner un nouveau context et un nouveau Stop. |
1ec8a59e |
930 | // it is necessary to determine a new context and a new Stop |
7fd59977 |
931 | TopoDS_Shape SC; |
932 | Handle(TNaming_NamedShape) NewStop = Stop; |
933 | |
934 | TNaming_Localizer::FindShapeContext (Context,S,SC); |
935 | |
936 | if(!SC.IsNull()){ |
937 | // <Context> is Ident.NamedShapeOfGeneration() == |
938 | TDF_Label Father = Context->Label().Father(); |
939 | Father.FindAttribute(TNaming_NamedShape::GetID(),NewStop); |
940 | #ifdef MDTV_DEB_INNS |
941 | if(!Stop.IsNull()) |
942 | {cout <<" Stop NS : "; Print_Entry( Stop->Label());} |
943 | if(!NewStop.IsNull()) |
944 | {cout <<" NewStop : "; Print_Entry( NewStop->Label());} |
945 | cout <<"ContextLabel: "; Print_Entry( Context->Label()); |
946 | cout <<"Father : "; Print_Entry( Father); |
947 | #endif |
948 | } |
949 | #ifdef MDTV_DEB_INNS |
950 | if(NewStop.IsNull()) |
951 | cout <<"BuildNameInNS:: NewStop shape is NULL" << endl; |
952 | #endif |
953 | return BuildName (F,MDF,S,SC,NewStop,Geometry); |
954 | } |
955 | |
956 | //======================================================================= |
957 | //function : |
958 | //purpose : |
959 | //======================================================================= |
960 | |
961 | static Handle(TNaming_NamedShape) BuildName (const TDF_Label& F, |
962 | TNaming_Scope& MDF, |
963 | const TopoDS_Shape& Selection, |
964 | const TopoDS_Shape& Context, |
965 | const Handle(TNaming_NamedShape)& Stop, |
966 | const Standard_Boolean Geom) |
967 | { |
968 | |
969 | |
970 | |
971 | // Create an identifier |
972 | Standard_Boolean OnlyOne = !Geom; |
973 | Standard_Boolean IsGeneration = Standard_False; |
974 | #ifdef MDTV_DEB_MOD |
975 | cout <<"BuildName: F => "; |
976 | Print_Entry(F); |
977 | cout <<" Selection type = " << Selection.ShapeType() << " TS = " << Selection.TShape()->This() << endl; |
978 | Write(Selection, "BName_Selection.brep"); |
979 | Write(Context, "BName_Context.brep"); |
980 | #endif |
981 | TNaming_Identifier Ident(F, Selection, Context,OnlyOne); |
982 | |
983 | Handle (TNaming_Naming) Naming; |
984 | Handle (TNaming_NamedShape) NS; |
985 | |
986 | if (!Ident.IsDone()) { |
987 | return BuildNS (F,Selection, TNaming_UNKNOWN); |
988 | } |
989 | if (Ident.IsFeature() && Stop.IsNull()) { |
990 | //------------- |
991 | // Deja Nomme |
992 | //------------- |
993 | if (!OnlyOne) return Ident.FeatureArg(); |
994 | else NS = Ident.FeatureArg(); |
995 | } |
996 | else { |
997 | //--------------------------------------------- |
998 | // Construction de la fonction d identification. |
999 | //--------------------------------------------- |
1000 | //Standard_Boolean NotOnlyOne = 0; |
1001 | |
1002 | Naming = TNaming_Naming::Insert(F); |
1003 | |
1004 | TNaming_Name& theName = Naming->ChangeName(); |
1005 | theName.ShapeType(Selection.ShapeType()); |
1006 | theName.Shape(Selection); |
7dcac1df |
1007 | theName.Orientation(Selection.Orientation()); |
7fd59977 |
1008 | theName.Type(Ident.Type()); |
1009 | #ifdef MDTV_DEB_MOD |
1010 | cout <<"BuildName: Inserted Naming Att at "; |
1011 | Print_Entry(Naming->Label()); |
1012 | cout <<" NameType = " << theName.Type() <<endl; |
1013 | #endif |
1014 | if (Ident.IsFeature()) { |
1015 | theName.Append(Ident.FeatureArg()); |
1016 | } |
1017 | if (theName.Type() == TNaming_GENERATION) { |
1018 | theName.Append(Ident.NamedShapeOfGeneration()); |
1019 | IsGeneration = Standard_True; |
1020 | } |
1021 | if (theName.Type() == TNaming_CONSTSHAPE) { |
1022 | theName.Index(FindIndex(Ident.FeatureArg(),Selection)); |
1023 | } |
1024 | //------------------------------------ |
1025 | // Renseignement du NamedShape d arret. |
1026 | //------------------------------------ |
1027 | theName.StopNamedShape (Stop); |
1028 | #ifdef MDTV_DEB_MOD |
1029 | if(!Stop.IsNull()) { |
1030 | TCollection_AsciiString Es; |
1031 | TDF_Tool::Entry(Stop->Label(), Es); |
1032 | cout <<"StopNS at Label = "<< Es << endl; |
1033 | } |
1034 | #endif |
1035 | //--------------------------------- |
1036 | // Identification des arguments. |
1037 | //--------------------------------- |
1038 | |
1039 | for (Ident.InitArgs(); Ident.MoreArgs(); Ident.NextArg()) { |
1040 | if (Ident.ArgIsFeature()) { |
1041 | theName.Append(Ident.FeatureArg()); |
1042 | #ifdef MDTV_DEB_MOD |
1043 | if(!Ident.FeatureArg().IsNull()) { |
1044 | TCollection_AsciiString E; |
1045 | TDF_Tool::Entry(Ident.FeatureArg()->Label(), E); |
1046 | cout <<"Added argument NS from Label = "<< E << endl; |
1047 | } |
1048 | #endif |
1049 | } |
1050 | else { |
1051 | #ifdef MDTV_DEB_MOD |
1052 | cout <<"BuildName: NameType = " <<theName.Type() << " NS "; |
1053 | Print_Entry(Naming->Label()); |
1054 | cout <<"Ident.ShapeArg() type = " << Ident.ShapeArg().ShapeType() << " TS = " << Ident.ShapeArg().TShape()->This() << endl; |
1055 | Write(Ident.ShapeArg(), "BName_ShapeArg.brep"); |
1056 | #endif |
1057 | if (theName.Type() == TNaming_GENERATION) |
1058 | theName.Append(BuildNameInNS(Naming->Label(),MDF,Ident.ShapeArg(),Ident.NamedShapeOfGeneration(),Stop,Geom)); |
1059 | else |
1060 | theName.Append(BuildName(Naming->Label(),MDF,Ident.ShapeArg(),Context,Stop,Geom)); |
1061 | } |
1062 | } |
1063 | |
1064 | //------------------------ |
1065 | // Reconstruction of Name |
1066 | //------------------------ |
1067 | Naming->Regenerate(MDF.ChangeValid()); |
1068 | #ifdef MDTV_DEB_MOD |
1069 | TCollection_AsciiString E2; |
1070 | TDF_Tool::Entry(Naming->Label(), E2); |
1071 | cout <<"Regenerated Naming Att at Label = "<< E2 << endl; |
1072 | #endif |
1073 | Naming->Label().FindAttribute(TNaming_NamedShape::GetID(),NS); |
1074 | if(NS.IsNull()) return NS; |
1075 | if (MDF.WithValid()) MDF.Valid(NS->Label()); |
1076 | #ifdef MDTV_DEB_MOD |
1077 | if(!NS.IsNull()) { |
1078 | TCollection_AsciiString E; |
1079 | TDF_Tool::Entry(NS->Label(), E); |
1080 | cout <<"Regenerated NS at Label = "<< E << endl; |
1081 | } |
1082 | #endif |
1083 | } |
1084 | |
1085 | if (OnlyOne) { |
1086 | //------------------------------------------------- |
1087 | // Filtre par les voisins |
1088 | // pour construire le nom correspondant a S. |
1089 | //------------------------------------------------- |
1090 | |
1091 | #ifdef OCC273 |
1092 | if(NS.IsNull()) return NS; |
1093 | #endif |
1094 | |
1095 | TNaming_Localizer Localizer; |
1096 | TNaming_Iterator itNS(NS); |
1097 | if (itNS.More()) { |
1098 | //---------------- |
1099 | // Check + Filtre |
1100 | //---------------- |
1101 | |
1102 | #ifdef OCC350 |
1103 | |
1104 | Standard_Boolean StandardFilter = !IsGeneration; |
1105 | if (IsGeneration) { |
1106 | if (!CompareInGeneration (NS,Selection)) { |
1107 | |
1108 | TopoDS_Shape NewContext; |
1109 | Handle(TNaming_NamedShape) NewStop; |
1110 | FindNewShapeInFather (Ident.NamedShapeOfGeneration(),NewContext); |
1111 | Filter (F,MDF,Selection,NewContext,Localizer,NS,0); |
1112 | } |
1113 | } else if (Ident.Type() == TNaming_MODIFUNTIL || |
1114 | (Ident.Type() == TNaming_INTERSECTION && Naming->ChangeName().Arguments().Extent() == 1)) { |
1115 | #ifdef MDTV_DEB_MOD |
1116 | cout <<"BuildName(CompareInModification): NameType = " <<Ident.Type() << " NS "; |
1117 | Print_Entry(Ident.Type() == TNaming_MODIFUNTIL ? NS->Label() : Naming->ChangeName().Arguments().First()->Label()); |
1118 | cout <<"Selection type = " << Selection.ShapeType() << " TS = " << Selection.TShape()->This() << endl; |
1119 | #endif |
1120 | Handle(TNaming_NamedShape) NewNS = |
1121 | CompareInModification(Ident.Type() == TNaming_MODIFUNTIL ? NS : Naming->ChangeName().Arguments().First(), Selection); |
1122 | if (!NewNS.IsNull()) { // there is need to describe name in detail: modification with type 1:n in the same label |
1123 | StandardFilter = Standard_False; |
1124 | if (Ident.IsFeature()) { // for MODIFUNTIL: change it to the GENERATION |
1125 | Naming = TNaming_Naming::Insert(F); |
1126 | TNaming_Name& theName = Naming->ChangeName(); |
1127 | theName.ShapeType(Selection.ShapeType()); |
7dcac1df |
1128 | theName.Shape(Selection); |
1129 | theName.Orientation(Selection.Orientation()); |
7fd59977 |
1130 | theName.Type(TNaming_GENERATION); |
1131 | theName.Append(TNaming_Tool::NamedShape(Selection,F)); |
1132 | theName.Append(NewNS); |
1133 | Naming->Regenerate(MDF.ChangeValid()); |
1134 | Naming->Label().FindAttribute(TNaming_NamedShape::GetID(),NS); |
1135 | |
1136 | } |
1137 | Filter (F,MDF,Selection,Context,Localizer,NS,0); |
1138 | } |
1139 | } |
1140 | if (StandardFilter) if (!Compare (NS,MDF,Stop,Selection)) { |
1141 | Filter (F,MDF,Selection,Context,Localizer,NS,0); |
1142 | } |
1143 | |
1144 | #else |
1145 | |
1146 | if (IsGeneration) { |
1147 | if (!CompareInGeneration (NS,Selection)) { |
1148 | TopoDS_Shape NewContext; |
1149 | Handle(TNaming_NamedShape) NewStop; |
1150 | FindNewShapeInFather (Ident.NamedShapeOfGeneration(),NewContext); |
1151 | Filter (F,MDF,Selection,NewContext,Localizer,NS,0); |
1152 | } |
1153 | } |
1154 | else { |
1155 | if (!Compare (NS,MDF,Stop,Selection)) |
1156 | Filter (F,MDF,Selection,Context,Localizer,NS,0); |
1157 | } |
1158 | |
1159 | #endif |
1160 | |
1161 | } |
1162 | } |
1163 | if (MDF.WithValid()) MDF.Valid(NS->Label()); |
1164 | #ifdef MDTV_DEB_MOD |
1165 | if(!NS.IsNull()) { |
1166 | TCollection_AsciiString E; |
1167 | TDF_Tool::Entry(NS->Label(), E); |
1168 | cout <<"Returned NS from Label = "<< E << endl; |
1169 | } |
1170 | #endif |
1171 | return NS; |
1172 | } |
1173 | |
1174 | //======================================================================= |
1175 | //function : Validate |
1176 | //purpose : |
1177 | //======================================================================= |
1178 | |
1179 | static void Validate(TNaming_Scope& MDF, |
1180 | TNaming_OldShapeIterator& it) |
1181 | { |
1182 | MDF.Valid(it.Label()); |
1183 | MDF.ValidChildren(it.Label()); |
1184 | |
1185 | TNaming_OldShapeIterator it2(it); |
1186 | for (; it2.More(); it2.Next()) { |
1187 | Validate (MDF,it2); |
1188 | } |
1189 | } |
1190 | |
1191 | //======================================================================= |
1192 | //function : UnValidate |
1193 | //purpose : |
1194 | //======================================================================= |
1195 | |
1196 | static void UnValidate(TNaming_Scope& MDF, |
1197 | TNaming_NewShapeIterator& it) |
1198 | { |
1199 | MDF.Unvalid(it.Label()); |
1200 | MDF.UnvalidChildren(it.Label()); |
1201 | |
1202 | TNaming_NewShapeIterator it2(it); |
1203 | for (; it2.More(); it2.Next()) { |
1204 | UnValidate (MDF,it2); |
1205 | } |
1206 | } |
1207 | |
1208 | //======================================================================= |
1209 | //function : BuildScope |
1210 | //purpose : adds to the MDF the label of <Context> NamedShape, |
1211 | // : its children, all its oldShapes and its children. |
1212 | // : unvalidates all newShapes and it's children. |
1213 | // : If <Context> is null or next modification has an empty newShape |
1214 | // : ( this shape was deleted ), then MDF.WithValid(Standard_False) |
1215 | // : and nothing is added to the scope. |
1216 | //======================================================================= |
1217 | |
1218 | static void BuildScope (TNaming_Scope& MDF, |
1219 | const TopoDS_Shape& Context, |
1220 | const TDF_Label& Acces) |
1221 | { |
1222 | if (Context.IsNull()) { |
1223 | MDF.WithValid(Standard_False); |
1224 | return; |
1225 | } |
1226 | |
1227 | //---------------------------------------------------- |
1228 | // Is context the current state |
1229 | //---------------------------------------------------- |
1230 | Handle(TNaming_NamedShape) NS = TNaming_Tool::NamedShape(Context,Acces); |
1231 | Handle(TNaming_NamedShape) Next = NextModif(NS); // if NS has subsequent evolution = MODIFY, return it |
1232 | if (Next.IsNull()) { |
1233 | MDF.WithValid(Standard_False); |
1234 | return; |
1235 | } |
1236 | //----------------------------- |
1237 | // a posteriori naming |
1238 | //----------------------------- |
1239 | MDF.WithValid(Standard_True); |
1240 | MDF.Valid(NS->Label()); |
1241 | MDF.ValidChildren(NS->Label()); |
1242 | TNaming_OldShapeIterator it(Context,Acces); |
1243 | |
1244 | for (; it.More(); it.Next()) { |
1245 | Validate(MDF,it); |
1246 | } |
1247 | |
1248 | TNaming_NewShapeIterator it2(Context,Acces); |
1249 | for (;it2.More(); it2.Next()) { |
1250 | UnValidate (MDF,it2); |
1251 | } |
1252 | } |
1253 | |
1ec8a59e |
1254 | //======================================================================= |
1255 | //function : HasAncFace |
1256 | //purpose : Returns True & <Face> if ancestor face is found |
7fd59977 |
1257 | //======================================================================= |
1258 | static Standard_Boolean HasAncFace(const TopoDS_Shape& Context, |
1ec8a59e |
1259 | const TopoDS_Shape& W, TopoDS_Shape& Face, Standard_Boolean& isOuter) |
7fd59977 |
1260 | { |
1261 | Standard_Boolean hasFace(Standard_False); |
1262 | if(W.ShapeType() != TopAbs_WIRE) |
1263 | return hasFace; |
1264 | TopExp_Explorer exp(Context, TopAbs_FACE); |
1265 | for(;exp.More(); exp.Next()) { |
1266 | for (TopoDS_Iterator it(exp.Current()) ; it.More(); it.Next()) { |
1267 | if(it.Value().IsEqual(W)) {// is the Wire ? |
1ec8a59e |
1268 | Face = exp.Current(); |
1269 | if(!Face.IsNull()) { |
1270 | hasFace = Standard_True; |
1271 | // cout << "HasAncFace: TS = " <<theFace.TShape()->This() <<endl; |
1272 | const TopoDS_Face aFace(TopoDS::Face(Face)); |
1273 | TopoDS_Wire anOuterW; |
1274 | if(TNaming::OuterWire(aFace, anOuterW)) { |
1275 | if(!anOuterW.IsNull() && anOuterW.IsEqual(W)) |
1276 | isOuter = Standard_True; |
1277 | else |
1278 | isOuter = Standard_False; |
1279 | } |
1280 | break; |
1281 | } |
1282 | } |
1283 | } |
7fd59977 |
1284 | if(hasFace) break; |
1285 | } |
1286 | return hasFace; |
1287 | } |
1288 | |
1289 | //======================================================================= |
1290 | //function : BuildNameWire |
1291 | //purpose : Names Wire |
1292 | //======================================================================= |
1293 | |
1294 | static Handle(TNaming_NamedShape) BuildNameWire (const TDF_Label& F, |
1295 | TNaming_Scope& MDF, |
1296 | const TopoDS_Shape& Selection, |
1297 | const TopoDS_Shape& Context, |
1298 | const Handle(TNaming_NamedShape)& Stop, |
1299 | const Standard_Boolean Geom) |
1300 | { |
1301 | Handle (TNaming_NamedShape) NS; |
1302 | Standard_Boolean found(Standard_False); |
1303 | Handle (TNaming_Naming) Naming; |
1304 | if(!F.FindAttribute(TNaming_Naming::GetID(), Naming)) { |
1305 | Naming = new TNaming_Naming (); |
1306 | F.AddAttribute (Naming); |
1307 | TNaming_Name& theName = Naming->ChangeName(); |
1308 | theName.ShapeType(Selection.ShapeType()); |
7dcac1df |
1309 | theName.Shape(Selection); |
1310 | theName.Orientation(Selection.Orientation()); |
7fd59977 |
1311 | } |
1312 | |
1313 | TNaming_Name& theName = Naming->ChangeName(); |
1314 | TopoDS_Shape aFace; |
1ec8a59e |
1315 | Standard_Boolean isOuter(Standard_False); |
1316 | Standard_Boolean hasFace = HasAncFace(Context, Selection, aFace, isOuter); |
1317 | if(hasFace && Selection.ShapeType() > Context.ShapeType()) { |
7fd59977 |
1318 | theName.Type(TNaming_WIREIN); |
1ec8a59e |
1319 | if(Context.ShapeType() == TopAbs_FACE) { |
1320 | for (TopoDS_Iterator it(Context) ; it.More(); it.Next()) { |
1321 | if(it.Value().IsEqual(Selection)) { |
1322 | if (TNaming_Selector::IsIdentified (F, Context, NS, Geom)) { |
1323 | theName.Append(NS); |
1324 | found = Standard_True; |
1325 | break; |
1326 | } |
1327 | } |
7fd59977 |
1328 | } |
1ec8a59e |
1329 | if(found) { |
1330 | theName.Append(BuildName (Naming->Label(),MDF,aFace,Context,Stop,Geom)); |
1331 | if(isOuter) { |
1332 | theName.Index(1); |
1333 | } else { |
1334 | theName.Index(-1); |
1335 | for (TopExp_Explorer exp(Selection,TopAbs_EDGE) ; exp.More(); exp.Next()) { |
1336 | if(exp.Current().IsNull()) continue; |
1337 | if (BRep_Tool::Degenerated(TopoDS::Edge(exp.Current()))) continue; |
1338 | theName.Append(TNaming_Naming::Name(Naming->Label(),exp.Current(),Context, Geom, 1, 0)); |
1339 | } |
1340 | } |
1341 | } else |
1342 | return BuildNS (F,Selection, TNaming_UNKNOWN); |
1343 | |
1344 | } else { // context is not Face |
1345 | theName.Append(BuildName (Naming->Label(),MDF,aFace,Context,Stop,Geom)); |
1346 | if(isOuter) { |
1347 | theName.Index(1); |
1348 | } else { |
1349 | for (TopExp_Explorer exp(Selection,TopAbs_EDGE) ; exp.More(); exp.Next()) { |
1350 | if(exp.Current().IsNull()) continue; |
1351 | if (BRep_Tool::Degenerated(TopoDS::Edge(exp.Current()))) continue; |
1352 | theName.Append(TNaming_Naming::Name(Naming->Label(),exp.Current(),Context, Geom, 1, 0)); |
1353 | } |
1354 | } |
1355 | }// |
1356 | } |
1357 | else { // => no Face |
7fd59977 |
1358 | theName.Type(TNaming_UNION); |
1359 | for (TopExp_Explorer exp(Selection,TopAbs_EDGE) ; exp.More(); exp.Next()) { |
1ec8a59e |
1360 | if(exp.Current().IsNull()) continue; |
1361 | if (BRep_Tool::Degenerated(TopoDS::Edge(exp.Current()))) continue; |
7fd59977 |
1362 | theName.Append(BuildName (Naming->Label(),MDF,exp.Current(),Context,Stop,Geom)); |
1363 | } |
1364 | } |
1365 | //Naming->GetName().Solve(Naming->Label(),MDF.GetValid()); |
1366 | Naming->Label().FindAttribute(TNaming_NamedShape::GetID(),NS); |
1367 | return NS; |
1368 | } |
1369 | |
1370 | //======================================================================= |
1371 | static Standard_Boolean IsOneIn (const TopoDS_Shape& S, const TopoDS_Shape& Context) |
1372 | { |
1373 | Standard_Boolean found(Standard_False); |
1374 | if(S.IsNull() || Context.IsNull()) return found; |
1375 | for (TopExp_Explorer exp(Context,S.ShapeType()); exp.More(); exp.Next()) { |
1376 | if (exp.Current().IsEqual(S)) { |
1377 | found = Standard_True; |
1378 | break; |
1379 | } |
1380 | } |
1381 | return found; |
1382 | } |
1383 | |
1384 | //======================================================================= |
1385 | static Standard_Boolean IsAllIn (const TopoDS_Shape& S, const TopoDS_Shape& Context) |
1386 | { |
1387 | #ifdef MDTV_DEB_CC |
1388 | Write(S, "IsAllIn_Sel.brep"); |
1389 | #endif |
1390 | Standard_Boolean found(Standard_False); |
1391 | if(S.IsNull() || Context.IsNull()) return found; |
1392 | Standard_Integer num1(0), num2(0); |
1393 | for(TopoDS_Iterator it(S);it.More();it.Next(),num1++) { |
1394 | #ifdef MDTV_DEB_CC |
1395 | cout <<"S sub-shape type = " << it.Value().ShapeType() <<endl; |
1396 | Write (it.Value(), "Sel_ItValue.brep"); |
1397 | #endif |
1398 | if(it.Value().ShapeType() != TopAbs_COMPOUND) |
1399 | for (TopExp_Explorer exp(Context,it.Value().ShapeType()); exp.More(); exp.Next()) { |
1400 | #ifdef MDTV_DEB_CC |
1401 | cout <<"Context sub-shape type = " << exp.Current().ShapeType() <<endl; |
1402 | Write(exp.Current(), "Contex_Curnt.brep"); |
1403 | #endif |
1404 | if (exp.Current().IsEqual(it.Value())) { |
1405 | num2++; |
1406 | break; |
1407 | } |
1408 | } else { |
1409 | Standard_Boolean isAll = IsAllIn(it.Value(), Context); |
1410 | if(isAll) |
1411 | num2++; |
1412 | } |
1413 | } |
1414 | if(num1 == num2) |
1415 | found = Standard_True; |
1416 | #ifdef MDTV_DEB_CC |
1417 | else |
1418 | cout <<"Compound case : selected num1 = " << num1 << " context contains num2 = " << num2 << endl; |
1419 | #endif |
1420 | return found; |
1421 | } |
1422 | //======================================================================= |
1423 | //function : RepeatabilityInContext |
1424 | //purpose : |
1425 | //======================================================================= |
1426 | static Standard_Integer RepeatabilityInContext(const TopoDS_Shape& Selection, |
1427 | const TopoDS_Shape& Context) |
1428 | { |
1429 | Standard_Integer aNum(0); |
1430 | if (!Context.IsNull() && !Selection.IsNull()) { |
1431 | // Write(Selection, "Repeat_Selection.brep"); |
1432 | // Write(Context, "Repeat_Context.brep"); |
1433 | if (Context.ShapeType() < Selection.ShapeType()) { |
1ec8a59e |
1434 | if(Selection.ShapeType() != TopAbs_SHELL) { |
1435 | for (TopExp_Explorer exp(Context,Selection.ShapeType()); exp.More(); exp.Next()) { |
1436 | if (exp.Current().IsSame(Selection)) |
1437 | aNum++; |
1438 | } |
1439 | } |
1440 | } |
7fd59977 |
1441 | else if(Selection.ShapeType() == TopAbs_COMPOUND) { |
1442 | TopoDS_Iterator it(Selection); |
1443 | for(;it.More();it.Next()) { |
1444 | Standard_Integer n(0); |
1445 | for (TopExp_Explorer exp(Context,it.Value().ShapeType()); exp.More(); exp.Next()) { |
1446 | if (exp.Current().IsSame(it.Value())) { |
1447 | n++; |
1448 | } |
1449 | } |
1450 | if(n > aNum) aNum = n; |
1451 | } |
1452 | } |
1453 | } |
1454 | #ifdef MDTV_DEB_OR |
1455 | cout <<"RepeatabilityInContext: = " <<aNum <<endl; |
1456 | #endif |
1457 | return aNum; |
1458 | } |
1ec8a59e |
1459 | |
1460 | //======================================================================= |
1461 | //function : HasAncSolid |
1462 | //purpose : Returns true if Sh has ancestor solid in this context |
1463 | //======================================================================= |
1464 | static Standard_Boolean HasAncSolid(const TopoDS_Shape& Context, |
1465 | const TopoDS_Shape& Sh, TopoDS_Shape& Solid, |
1466 | Standard_Boolean& isOuter) |
1467 | { |
1468 | Standard_Boolean hasSolid(Standard_False); |
1469 | if(Sh.ShapeType() != TopAbs_SHELL) |
1470 | return hasSolid; |
1471 | TopExp_Explorer exp(Context, TopAbs_SOLID); |
1472 | for(;exp.More(); exp.Next()) { |
1473 | for (TopoDS_Iterator it(exp.Current()) ; it.More(); it.Next()) { |
1474 | if(it.Value().IsEqual(Sh)) {// is the Solid ? |
1475 | Solid = exp.Current(); |
1476 | if(!Solid.IsNull()) { |
1477 | hasSolid = Standard_True; |
1478 | TopoDS_Shell anOuterShell; |
1479 | if(TNaming::OuterShell(TopoDS::Solid(Solid), anOuterShell)) { |
1480 | #ifdef MDTV_DEB_TSOL |
1481 | Write(anOuterShell, "OuterShell.brep"); |
1482 | #endif |
1483 | if(!anOuterShell.IsNull() && anOuterShell.IsEqual(Sh)) |
1484 | isOuter = Standard_True; |
1485 | else |
1486 | isOuter = Standard_False; |
1487 | } |
1488 | break; |
1489 | } |
1490 | } |
1491 | } |
1492 | if(hasSolid) break; |
1493 | } |
1494 | return hasSolid; |
1495 | } |
1496 | //======================================================================= |
1497 | //function : BuildNameShell |
1498 | //purpose : Names Shell |
1499 | //======================================================================= |
1500 | |
1501 | static Handle(TNaming_NamedShape) BuildNameShell (const TDF_Label& F, |
1502 | TNaming_Scope& MDF, |
1503 | const TopoDS_Shape& Selection, |
1504 | const TopoDS_Shape& Context, |
1505 | const Handle(TNaming_NamedShape)& Stop, |
1506 | const Standard_Boolean Geom) |
1507 | { |
1508 | Handle (TNaming_NamedShape) NS; |
1509 | Standard_Boolean found(Standard_False); |
1510 | Handle (TNaming_Naming) Naming; |
1511 | if(!F.FindAttribute(TNaming_Naming::GetID(), Naming)) { |
1512 | Naming = new TNaming_Naming (); |
1513 | F.AddAttribute (Naming); |
1514 | TNaming_Name& theName = Naming->ChangeName(); |
1515 | theName.ShapeType(Selection.ShapeType()); |
7dcac1df |
1516 | theName.Shape(Selection); |
1517 | theName.Orientation(Selection.Orientation()); |
1ec8a59e |
1518 | } |
1519 | |
1520 | TNaming_Name& theName = Naming->ChangeName(); |
1521 | TopoDS_Shape aSolid; |
1522 | Standard_Boolean isOuter(Standard_False); |
1523 | Standard_Boolean hasSolid = HasAncSolid(Context, Selection, aSolid, isOuter); |
1524 | if(hasSolid && Selection.ShapeType() > Context.ShapeType()) { |
1525 | theName.Type(TNaming_SHELLIN);// SHELLIN |
1526 | |
1527 | if(Context.ShapeType() == TopAbs_SOLID) { |
1528 | for (TopoDS_Iterator it(Context) ; it.More(); it.Next()) { |
1529 | #ifdef MDTV_DEB_TSOL |
1530 | Write(it.Value(), "Shell_inSo.brep"); |
1531 | #endif |
1532 | if(it.Value().IsEqual(Selection)) { |
1533 | found = Standard_True; |
1534 | break; |
1535 | } |
1536 | } |
1537 | if(found) { |
1538 | // solid => aSolid which is also a context |
1539 | Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(Context,F); |
1540 | if(!aNS.IsNull()) |
1541 | theName.ContextLabel(aNS->Label()); |
1542 | theName.Append(aNS); |
1543 | if(isOuter) { |
1544 | theName.Index(1); |
1545 | } else { //not OuterShell |
1546 | theName.Index(-1); |
1547 | for (TopExp_Explorer exp(Selection,TopAbs_FACE) ; exp.More(); exp.Next()) { |
1548 | if(exp.Current().IsNull()) continue; |
1549 | theName.Append(BuildName (Naming->Label(),MDF,exp.Current(),Context,Stop,Geom)); |
1550 | } |
1551 | } |
1552 | } else |
1553 | return BuildNS (F,Selection, TNaming_UNKNOWN); |
1554 | } else { |
1555 | // context is not SOLID |
1556 | //theName.Append(BuildName (Naming->Label(),MDF,aSolid,Context,Stop,Geom));//########### |
1557 | if(isOuter) { |
1558 | #ifdef MDTV_DEB_TSOL |
1559 | Write(aSolid, "foundSolid.brep"); |
1560 | #endif |
1561 | theName.Index(1); |
1562 | Handle (TNaming_Naming) NamingSo = TNaming_Naming::Insert(F); |
1563 | TNaming_Name& theNameSo = NamingSo->ChangeName(); |
1564 | theNameSo.ShapeType(aSolid.ShapeType()); |
1565 | theNameSo.Shape(aSolid); |
1566 | theNameSo.Type(TNaming_UNION); |
1567 | Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(Context,F); |
1568 | if(!aNS.IsNull()) |
1569 | theNameSo.ContextLabel(aNS->Label()); |
1570 | for (TopExp_Explorer exp(aSolid,TopAbs_FACE) ; exp.More(); exp.Next()) |
1571 | theNameSo.Append(BuildName (NamingSo->Label(),MDF,exp.Current(),Context,Stop,Geom)); |
1572 | NamingSo->GetName().Solve(NamingSo->Label(),MDF.GetValid()); |
1573 | aNS.Nullify(); |
1574 | NamingSo->Label().FindAttribute(TNaming_NamedShape::GetID(),aNS); |
1575 | theName.Append(aNS); |
1576 | } else { |
1577 | theName.Index(-1); |
1578 | // - name Solid: theName.Append(BuildName (Naming->Label(),MDF, aSolid,Context,Stop,Geom)); |
1579 | Handle (TNaming_Naming) NamingSo = TNaming_Naming::Insert(F); |
1580 | TNaming_Name& theNameSo = NamingSo->ChangeName(); |
1581 | theNameSo.ShapeType(aSolid.ShapeType()); |
1582 | theNameSo.Shape(aSolid); |
1583 | theNameSo.Type(TNaming_UNION); |
1584 | Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(Context,F); |
1585 | if(!aNS.IsNull()) |
1586 | theNameSo.ContextLabel(aNS->Label()); |
1587 | for (TopExp_Explorer exp(aSolid,TopAbs_FACE) ; exp.More(); exp.Next()) |
1588 | theNameSo.Append(BuildName (NamingSo->Label(),MDF,exp.Current(),Context,Stop,Geom)); |
1589 | NamingSo->GetName().Solve(NamingSo->Label(),MDF.GetValid()); |
1590 | aNS.Nullify(); |
1591 | NamingSo->Label().FindAttribute(TNaming_NamedShape::GetID(),aNS); |
1592 | theName.Append(aNS); |
1593 | |
1594 | for (TopExp_Explorer exp(Selection,TopAbs_FACE) ; exp.More(); exp.Next()) { |
1595 | if(exp.Current().IsNull()) continue; |
1596 | theName.Append(BuildName (Naming->Label(),MDF,exp.Current(),Context,Stop,Geom)); |
1597 | } |
1598 | } |
1599 | }// |
1600 | } |
1601 | else { // => no Solid |
1602 | theName.Type(TNaming_UNION); |
1603 | Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(Context,F); |
1604 | if(!aNS.IsNull()) |
1605 | theName.ContextLabel(aNS->Label()); |
1606 | for (TopExp_Explorer exp(Selection,TopAbs_FACE) ; exp.More(); exp.Next()) { |
1607 | if(exp.Current().IsNull()) continue; |
1608 | theName.Append(BuildName (Naming->Label(),MDF,exp.Current(),Context,Stop,Geom)); |
1609 | } |
1610 | } |
1611 | //Naming->GetName().Solve(Naming->Label(),MDF.GetValid()); |
1612 | Naming->Label().FindAttribute(TNaming_NamedShape::GetID(),NS); |
1613 | return NS; |
1614 | } |
1615 | |
7fd59977 |
1616 | //======================================================================= |
1617 | //function : BuildAggregationNam |
1618 | //purpose : |
1619 | //======================================================================= |
1620 | static void BuildAggregationName (const TDF_Label& F, |
1621 | TNaming_Scope& MDF, |
1622 | const TopoDS_Shape& S, |
1623 | const TopoDS_Shape& Context, |
1624 | const Handle(TNaming_NamedShape)& Stop, |
1625 | const Standard_Boolean Geom) |
1626 | { |
1627 | const Standard_Boolean found2 = IsAllIn(S, Context); |
1628 | Handle (TNaming_Naming) Naming; |
1629 | if(!F.FindAttribute(TNaming_Naming::GetID(), Naming)) { |
1630 | Naming = new TNaming_Naming (); |
1631 | F.AddAttribute (Naming); |
1632 | TNaming_Name& theName = Naming->ChangeName(); |
1633 | theName.ShapeType(S.ShapeType()); |
1634 | theName.Shape(S); |
7dcac1df |
1635 | theName.Orientation(S.Orientation()); |
7fd59977 |
1636 | } |
1637 | #ifdef MDTV_DEB_CC |
1638 | cout <<"BuildAggregationName ==> "; |
1639 | Print_Entry(Naming->Label()); |
1640 | #endif |
1641 | TNaming_Name& theName = Naming->ChangeName(); |
1642 | for (TopoDS_Iterator itc(S) ; itc.More(); itc.Next()) { |
1643 | const TopoDS_Shape& aS = itc.Value(); |
1644 | if ((aS.ShapeType() == TopAbs_SOLID && !TNaming_Tool::NamedShape(aS,Naming->Label()).IsNull()) || |
1645 | aS.ShapeType() == TopAbs_FACE || |
1646 | aS.ShapeType() == TopAbs_EDGE || |
1647 | aS.ShapeType() == TopAbs_VERTEX ) { |
1648 | theName.Append(BuildName (F, MDF, aS,Context,Stop,Geom)); |
1649 | } else { // ==> union of union || union of wires |
1650 | TopAbs_ShapeEnum atomTyp; |
1651 | switch (aS.ShapeType()) |
1652 | { |
1653 | case TopAbs_SOLID: |
1654 | case TopAbs_SHELL: |
1655 | atomTyp = TopAbs_FACE; |
1656 | break; |
1657 | case TopAbs_WIRE: |
1658 | atomTyp = TopAbs_EDGE; |
1659 | break; |
1660 | default: |
1661 | atomTyp = TopAbs_SHAPE; |
1662 | } |
1663 | |
1664 | Handle(TNaming_NamedShape) aNS; |
1665 | Handle (TNaming_Naming) aNaming = TNaming_Naming::Insert(F); |
1666 | TNaming_Name& aName = aNaming->ChangeName(); |
1667 | aName.ShapeType(aS.ShapeType()); |
7dcac1df |
1668 | aName.Shape(aS); |
1669 | theName.Orientation(aS.Orientation()); |
7fd59977 |
1670 | aName.Type(TNaming_UNION); |
1671 | |
1672 | if (atomTyp != TopAbs_SHAPE) { |
1673 | if(aS.ShapeType() == TopAbs_WIRE) { |
1674 | aNS = BuildNameWire (aNaming->Label(), MDF, aS, Context,Stop,Geom); |
1675 | } |
1ec8a59e |
1676 | else if(aS.ShapeType() == TopAbs_SHELL) |
1677 | aNS = BuildNameShell (aNaming->Label(), MDF, aS, Context,Stop,Geom); |
7fd59977 |
1678 | else { |
1679 | for (TopExp_Explorer exp(aS,atomTyp) ; exp.More(); exp.Next()) { |
1680 | aName.Append(BuildName (aNaming->Label(),MDF,exp.Current(),Context,Stop,Geom)); |
1681 | } |
1682 | } |
1683 | } else { |
1684 | #ifdef MDTV_DEB_CC |
1685 | cout << "atomic type is NOT defined ... ==> Aggregation" <<endl; |
1686 | #endif |
1687 | BuildAggregationName(aNaming->Label(),MDF, aS, Context,Stop,Geom); |
1688 | } |
1689 | if(found2) { |
1690 | aNS = TNaming_Tool::NamedShape(Context, F); |
1691 | if(!aNS.IsNull()) |
1692 | aNaming->ChangeName().ContextLabel(aNS->Label()); |
1693 | } |
1694 | |
1695 | aNaming->GetName().Solve(aNaming->Label(),MDF.GetValid()); |
1696 | if(aNaming->Label().FindAttribute(TNaming_NamedShape::GetID(),aNS)) |
1697 | if (!Geom && TestSolution(MDF,aNS,aS)) { |
1698 | theName.Append(aNS); |
1699 | } |
1700 | } |
1701 | } |
1702 | } |
1703 | |
1704 | |
1705 | //======================================================================= |
1706 | //function : Name |
1707 | //purpose : |
1708 | //======================================================================= |
1709 | |
1710 | Handle(TNaming_NamedShape) TNaming_Naming::Name (const TDF_Label& F, |
1711 | const TopoDS_Shape& S, |
1712 | const TopoDS_Shape& Context, |
1713 | const Standard_Boolean Geom, |
1714 | const Standard_Boolean KeepOrientation, |
1715 | const Standard_Boolean BNProblem) |
1716 | |
1717 | { |
1718 | Handle(TNaming_NamedShape) NS; |
1719 | if (KeepOrientation) { |
1720 | #ifdef MDTV_DEB_INNS |
1721 | cout <<"KeepOR = 1: "; Print_Entry(F); |
1722 | #endif |
1723 | Standard_Integer aNum = RepeatabilityInContext(S, Context); |
1724 | |
1725 | Standard_Boolean aBNproblem = (BNProblem) ? (aNum /*== 1*/ && S != Context) : Standard_False; |
1726 | |
1727 | if (aNum > 1 || aBNproblem) { |
1728 | TopoDS_Shape UC = TNaming::FindUniqueContext(S, Context); |
1729 | Handle(TopTools_HArray1OfShape) Arr; |
1730 | if (UC.IsNull() && S.ShapeType() == TopAbs_COMPOUND) { |
1731 | UC = TNaming::FindUniqueContextSet(S, Context, Arr); |
1732 | #ifdef MDTV_DEB_CC |
1733 | Write(UC, "UniqueContextSet.brep"); |
1734 | Write(S, "InitialSelection.brep"); |
1735 | if(S.ShapeType()==TopAbs_COMPOUND) { |
1736 | TCollection_AsciiString aNam("S_"); |
1737 | TopoDS_Iterator it(S); |
1738 | for(int i=1;it.More();it.Next(),i++) { |
1739 | TCollection_AsciiString aName = aNam + i + ".brep"; |
1740 | Write(it.Value(), aName.ToCString()); |
1741 | } |
1742 | } |
1743 | #endif |
1744 | } |
1745 | if(!UC.IsNull()) { |
1746 | Handle (TNaming_Naming) Naming = TNaming_Naming::Insert(F); |
1747 | TNaming_Name& theName = Naming->ChangeName(); |
1748 | theName.ShapeType(S.ShapeType()); |
1749 | theName.Shape(S); |
1750 | theName.Type(TNaming_ORIENTATION); |
7dcac1df |
1751 | theName.Orientation(S.Orientation()); |
7fd59977 |
1752 | |
1753 | if (!TNaming_Selector::IsIdentified (F, S, NS, Geom)) |
1754 | NS = TNaming_Naming::Name(Naming->Label(),S,Context,Geom,0); |
1755 | theName.Append (NS); |
1756 | #ifdef MDTV_OR |
1757 | cout << " Sel Label ==> "; Print_Entry(NS->Label()); |
1758 | #endif |
1759 | //szy 21.10.2009 |
1760 | if(S.ShapeType() == TopAbs_EDGE && UC.ShapeType() == TopAbs_FACE) { |
1761 | if(RepeatabilityInContext(S, UC) == 2) { //sim. edge |
1762 | TopoDS_Iterator itw(UC); |
1763 | for(;itw.More();itw.Next()) { |
1764 | Standard_Boolean found(Standard_False); |
1765 | TopoDS_Iterator it(itw.Value()); |
1766 | for(int i=1;it.More();it.Next(),i++) { |
1767 | if(it.Value().IsEqual(S)) { |
1ec8a59e |
1768 | theName.Index(i);//We use this field to save a Seam Shape Index; Before this field was used for GENERATED only |
7fd59977 |
1769 | found = Standard_True; |
1770 | #ifdef MDTV_OR |
1771 | cout << "ORDER = " << i <<endl; |
1772 | #endif |
1773 | break; |
1774 | } |
1775 | } |
1776 | if(found) break; |
1777 | } |
1778 | } |
1779 | } |
1780 | // |
1781 | if(S.ShapeType() == TopAbs_COMPOUND && Arr->Length() > 1) { |
1782 | // N arguments: to be optimized to avoid duplication of the same Context shape |
1783 | for(Standard_Integer i = Arr->Lower(); i <= Arr->Upper(); i++) { |
1784 | NS = TNaming_Naming::Name(Naming->Label(), Arr->Value(i), Context, Geom, 1, aBNproblem); |
1785 | theName.Append (NS); |
1786 | } |
1787 | } else { |
1788 | NS = TNaming_Naming::Name(Naming->Label(),UC,Context, Geom, 1, aBNproblem); |
1789 | theName.Append (NS); |
1790 | #ifdef MDTV_OR |
1791 | cout << " Cont Label ==> "; Print_Entry(NS->Label()); |
1792 | #endif |
1793 | } |
1794 | //Naming->Update(); |
1795 | TNaming_Scope MDF; |
1796 | BuildScope (MDF,Context,F); |
1797 | Naming->GetName().Solve(Naming->Label(),MDF.GetValid()); |
1798 | Naming->Label().FindAttribute(TNaming_NamedShape::GetID(),NS); |
1799 | theName.ContextLabel(NS->Label()); |
1800 | if (Geom) return NS; |
1801 | if(NS.IsNull()) { |
1802 | cout <<" %%% WARNING: TNaming_Naming::Name: FAILED"<<endl; |
1803 | return BuildNS (F,S, TNaming_UNKNOWN); |
1804 | } |
1805 | |
1806 | if (!Geom && TestSolution(MDF,NS,S)) return NS; |
1807 | cout <<" %%% WARNING: TNaming_Naming::Name: FAILED"<<endl; |
1808 | |
1809 | // Naming n is unsatisfactory |
1810 | return BuildNS (F,S, TNaming_UNKNOWN); |
1811 | } |
1812 | } else |
1813 | if (TNaming_Selector::IsIdentified (F, S, NS, Geom)) |
1814 | return NS; |
1815 | } |
1816 | |
1817 | //------------------------------------------------------------ |
1818 | // Construction du MDF tel que <Context> soit le dernier etat |
1819 | // valide, |
1820 | // Ceci pour les localisation a posteriori par exemple. |
1821 | //------------------------------------------------------------ |
1822 | |
1823 | TNaming_Scope MDF; |
1824 | BuildScope (MDF,Context,F); |
1825 | Handle(TNaming_NamedShape) Stop; |
1826 | |
1827 | #ifdef OCC352 |
1828 | |
1829 | if ((S.ShapeType() == TopAbs_SOLID && !TNaming_Tool::NamedShape(S,F).IsNull()) || |
1830 | |
1831 | #else |
1832 | |
1833 | if (S.ShapeType() == TopAbs_SOLID || |
1834 | |
1835 | #endif |
1836 | |
1837 | S.ShapeType() == TopAbs_FACE || |
1838 | S.ShapeType() == TopAbs_EDGE || |
1839 | S.ShapeType() == TopAbs_VERTEX ) { |
1840 | //--------------------------------------- |
1841 | // Localisation de S comme element simple. |
1842 | //--------------------------------------- |
1843 | Handle(TNaming_NamedShape) NS = BuildName (F,MDF,S,Context,Stop,Geom); |
1844 | if (Geom) return NS; |
1845 | if (!Geom && TestSolution(MDF,NS,S)) return NS; |
1846 | } |
1847 | else { |
1848 | //---------------------------------------------------- |
1849 | // Localisation de S comme ensemble d elements simples. |
1850 | //----------------------------------------------------- |
1851 | Handle(TNaming_NamedShape) NS; |
1852 | Handle (TNaming_Naming) Naming = TNaming_Naming::Insert(F); |
1853 | TNaming_Name& theName = Naming->ChangeName(); |
1854 | |
1855 | theName.ShapeType(S.ShapeType());// modified by vro 05.09.00 |
1856 | theName.Shape(S); |
7dcac1df |
1857 | theName.Orientation(S.Orientation()); |
7fd59977 |
1858 | if(S.ShapeType() != TopAbs_WIRE) |
1859 | theName.Type(TNaming_UNION); |
1860 | |
1861 | #ifdef OCC352 |
1862 | TopAbs_ShapeEnum atomType; |
1863 | switch (S.ShapeType()) { |
1864 | case TopAbs_COMPSOLID: |
1865 | case TopAbs_SOLID: |
1866 | case TopAbs_SHELL: |
1867 | atomType = TopAbs_FACE; |
1868 | break; |
1869 | case TopAbs_WIRE: |
1870 | atomType = TopAbs_EDGE; |
1871 | break; |
1872 | default: |
1873 | atomType = TopAbs_SHAPE; |
1874 | } |
1875 | Standard_Boolean found(Standard_False); |
1876 | if (!Context.IsNull()) { |
1877 | if (Context.ShapeType() < S.ShapeType()) |
1878 | found = IsOneIn(S, Context); |
1879 | if(found) { |
1880 | NS = TNaming_Tool::NamedShape(Context, F); |
1881 | if(!NS.IsNull()) |
1882 | theName.ContextLabel(NS->Label()); |
1883 | } |
1884 | } |
1885 | if (atomType == TopAbs_SHAPE) { |
1886 | if(S.ShapeType() == TopAbs_COMPOUND) { |
1887 | BuildAggregationName(Naming->Label(),MDF, S, Context,Stop,Geom); |
1888 | } else { |
1889 | for (TopoDS_Iterator it(S) ; it.More(); it.Next()) { |
1890 | theName.Append(BuildName (Naming->Label(),MDF,it.Value(),Context,Stop,Geom)); |
1891 | } |
1892 | } |
1893 | } else { |
1894 | if(S.ShapeType() == TopAbs_WIRE) |
1ec8a59e |
1895 | NS = BuildNameWire (Naming->Label(), MDF, S, Context,Stop,Geom); |
1896 | else if(S.ShapeType() == TopAbs_SHELL) { |
1897 | NS = BuildNameShell (Naming->Label(), MDF, S, Context,Stop,Geom); |
1898 | } |
1899 | else { |
1900 | theName.Type(TNaming_UNION); |
1901 | for (TopExp_Explorer exp(S,atomType) ; exp.More(); exp.Next()) { |
1902 | theName.Append(BuildName (Naming->Label(),MDF,exp.Current(),Context,Stop,Geom)); |
1903 | } |
1904 | } |
7fd59977 |
1905 | } |
1906 | #else |
1907 | for (TopoDS_Iterator it(S) ; it.More(); it.Next()) { |
1908 | theName.Append(BuildName (Naming->Label(),MDF,it.Value(),Context,Stop,Geom)); |
1909 | } |
1910 | #endif |
1911 | |
1912 | //Naming->Update(); |
1913 | Naming->GetName().Solve(Naming->Label(),MDF.GetValid()); |
1914 | Naming->Label().FindAttribute(TNaming_NamedShape::GetID(),NS); |
1915 | if (Geom) return NS; |
1916 | |
1917 | #ifdef OCC273 |
1918 | if(NS.IsNull()) return BuildNS (F,S, TNaming_UNKNOWN); |
1919 | #endif |
1920 | |
1921 | if (!Geom && TestSolution(MDF,NS,S)) return NS; |
1922 | } |
1923 | |
1924 | cout <<" %%% WARNING: TNaming_Naming::Name: FAILED"<<endl; |
1925 | |
1926 | // Naming n is not satisfactory |
1927 | return BuildNS (F,S, TNaming_UNKNOWN); |
1928 | } |
1929 | |
1930 | |
1931 | //======================================================================= |
1932 | //function : TNaming_Naming |
1933 | //purpose : |
1934 | //======================================================================= |
1935 | |
1936 | TNaming_Naming::TNaming_Naming() {} |
1937 | |
1938 | //======================================================================= |
1939 | //function : ID |
1940 | //purpose : |
1941 | //======================================================================= |
1942 | |
1943 | const Standard_GUID& TNaming_Naming::ID () const |
1944 | { |
1945 | return GetID(); |
1946 | } |
1947 | |
1948 | |
1949 | //======================================================================= |
1950 | //function : IsDefined |
1951 | //purpose : |
1952 | //======================================================================= |
1953 | |
1954 | Standard_Boolean TNaming_Naming::IsDefined() const |
1955 | { |
1956 | return (myName.Type() != TNaming_UNKNOWN); |
1957 | } |
1958 | |
1959 | //======================================================================= |
1960 | //function : GetName |
1961 | //purpose : |
1962 | //======================================================================= |
1963 | |
1964 | const TNaming_Name& TNaming_Naming::GetName() const |
1965 | { |
1966 | return myName; |
1967 | } |
1968 | |
1969 | //======================================================================= |
1970 | //function : ChangeName |
1971 | //purpose : |
1972 | //======================================================================= |
1973 | |
1974 | TNaming_Name& TNaming_Naming::ChangeName() |
1975 | { |
1976 | return myName; |
1977 | } |
1978 | |
1979 | //======================================================================= |
1980 | //function : Regenerate |
1981 | //purpose : idem designer |
1982 | //======================================================================= |
1983 | |
1984 | Standard_Boolean TNaming_Naming::Regenerate (TDF_LabelMap& MDF) |
1985 | |
1986 | { |
1987 | return myName.Solve(Label(),MDF); |
1988 | } |
1989 | |
1990 | |
1991 | //======================================================================= |
1992 | //function : NewEmpty |
1993 | //purpose : |
1994 | //======================================================================= |
1995 | |
1996 | Handle(TDF_Attribute) TNaming_Naming::NewEmpty () const |
1997 | { |
1998 | return new TNaming_Naming (); |
1999 | } |
2000 | |
2001 | |
2002 | //======================================================================= |
2003 | //function : Restore |
2004 | //purpose : |
2005 | //======================================================================= |
2006 | |
2007 | void TNaming_Naming::Restore(const Handle(TDF_Attribute)& other) |
2008 | { |
2009 | Handle(TNaming_Naming) OtherNaming = Handle(TNaming_Naming)::DownCast(other); |
2010 | myName = OtherNaming->ChangeName(); |
2011 | } |
2012 | |
2013 | //======================================================================= |
2014 | //function : Paste |
2015 | //purpose : |
2016 | //======================================================================= |
2017 | |
2018 | void TNaming_Naming::Paste (const Handle(TDF_Attribute)& into, |
2019 | const Handle(TDF_RelocationTable)& RT) const |
2020 | { |
2021 | Handle(TNaming_Naming) NewNaming = Handle(TNaming_Naming)::DownCast(into); |
2022 | myName.Paste(NewNaming->ChangeName(),RT); |
2023 | } |
2024 | |
2025 | //======================================================================= |
2026 | //function : References |
2027 | //purpose : Redefined from TDF_Attribute |
2028 | //======================================================================= |
2029 | |
2030 | void TNaming_Naming::References(const Handle(TDF_DataSet)& DataSet) const |
2031 | { |
2032 | // Iteration on NamedShape of the name |
2033 | TNaming_ListIteratorOfListOfNamedShape it(myName.Arguments()); |
2034 | for (;it.More();it.Next()) DataSet->AddAttribute(it.Value()); |
2035 | if (!myName.StopNamedShape().IsNull()) DataSet->AddAttribute(myName.StopNamedShape()); |
2036 | } |
2037 | //======================================================================= |
2038 | //function : Dump |
2039 | //purpose : |
2040 | //======================================================================= |
2041 | |
2042 | Standard_OStream& TNaming_Naming::Dump (Standard_OStream& anOS) const |
2043 | { |
2044 | anOS << "TNaming_Naming"; |
2045 | return anOS; |
2046 | } |
2047 | |
2048 | |
2049 | //======================================================================= |
2050 | //function :ExtendedDump |
2051 | //purpose : |
2052 | //======================================================================= |
2053 | |
2054 | void TNaming_Naming::ExtendedDump(Standard_OStream& anOS, |
2055 | const TDF_IDFilter& /*aFilter*/, |
2056 | TDF_AttributeIndexedMap& /*aMap*/) const |
2057 | { |
2058 | anOS << "TNaming_Naming ExtendedDump "; |
2059 | //anOS<<"myContext: #" <<aMap.Add(myContext)<<endl; |
2060 | } |
2061 | |