1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 //svv#1 11.01.00 : porting on DEC
16 //svv#2 21.02.00 : porting on SIL
17 //smh#14 17.03.2000 : FRA62479 Clearing of gtool.
19 #include <Dico_DictionaryOfTransient.hxx>
20 #include <Dico_IteratorOfDictionaryOfTransient.hxx>
21 #include <Interface_Check.hxx>
22 #include <Interface_CheckIterator.hxx>
23 #include <Interface_EntityIterator.hxx>
24 #include <Interface_GeneralLib.hxx>
25 #include <Interface_GeneralModule.hxx>
26 #include <Interface_GTool.hxx>
27 #include <Interface_InterfaceMismatch.hxx>
28 #include <Interface_InterfaceModel.hxx>
29 #include <Interface_Protocol.hxx>
30 #include <Interface_ReportEntity.hxx>
31 #include <Interface_SignType.hxx>
32 #include <Message_Messenger.hxx>
33 #include <Standard_NoSuchObject.hxx>
34 #include <Standard_OutOfRange.hxx>
35 #include <Standard_Transient.hxx>
36 #include <Standard_Type.hxx>
37 #include <TCollection_HAsciiString.hxx>
38 #include <TColStd_Array1OfInteger.hxx>
39 #include <TColStd_Array1OfTransient.hxx>
40 #include <TColStd_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
42 IMPLEMENT_STANDARD_RTTIEXT(Interface_InterfaceModel,MMgt_TShared)
44 // Un Modele d`Interface est un ensemble ferme d`Entites d`interface : chacune
45 // est dans un seul modele a la fois; elle y a un numero (Number) qui permet de
46 // verifier qu`une entite est bien dans un seul modele, de definir des Map tres
47 // performantes, de fournir un identifieur numerique
48 // Il est a meme d`etre utilise dans des traitements de Graphe
49 // STATICS : les TEMPLATES
50 static const Handle(Dico_DictionaryOfTransient)& templates()
52 static Handle(Dico_DictionaryOfTransient) atemp;
53 if (atemp.IsNull()) atemp = new Dico_DictionaryOfTransient;
58 static const Handle(Standard_Type)& typerep()
60 static Handle(Standard_Type) tr = STANDARD_TYPE(Interface_ReportEntity);
65 static const Handle(Interface_Check)& nulch()
67 static Handle(Interface_Check) anulch = new Interface_Check;
72 //=======================================================================
73 //function : Interface_InterfaceModel
75 //=======================================================================
77 Interface_InterfaceModel::Interface_InterfaceModel ()
78 : haschecksem (Standard_False), isdispatch (Standard_False)
80 thecheckstx = new Interface_Check;
81 thechecksem = new Interface_Check;
85 //=======================================================================
88 //=======================================================================
90 void Interface_InterfaceModel::Destroy () // on fait un mimumum
92 // Moins que Clear que, lui, est adapte a chaque norme
96 thecategory.Nullify();
100 //=======================================================================
101 //function : SetProtocol
103 //=======================================================================
105 void Interface_InterfaceModel::SetProtocol(const Handle(Interface_Protocol)& proto)
107 thegtool = new Interface_GTool(proto);
111 //=======================================================================
112 //function : Protocol
114 //=======================================================================
116 Handle(Interface_Protocol) Interface_InterfaceModel::Protocol () const
118 Handle(Interface_Protocol) proto;
119 if (!thegtool.IsNull()) return thegtool->Protocol();
124 //=======================================================================
125 //function : SetGTool
127 //=======================================================================
129 void Interface_InterfaceModel::SetGTool(const Handle(Interface_GTool)& gtool)
135 //=======================================================================
138 //=======================================================================
140 Handle(Interface_GTool) Interface_InterfaceModel::GTool () const
146 //=======================================================================
149 //=======================================================================
151 void Interface_InterfaceModel::Clear ()
154 thecheckstx->Clear();
155 thechecksem->Clear();
158 thecategory.Nullify();
162 //=======================================================================
163 //function : DispatchStatus
165 //=======================================================================
167 Standard_Boolean& Interface_InterfaceModel::DispatchStatus ()
173 //=======================================================================
174 //function : ClearEntities
176 //=======================================================================
178 void Interface_InterfaceModel::ClearEntities ()
182 haschecksem = Standard_False;
184 if (!thegtool.IsNull()) {
185 // WhenDeleteCase is not applicable
186 /* Handle(Interface_GeneralModule) module; Standard_Integer CN;
187 Standard_Integer nb = NbEntities();
188 for (Standard_Integer i = 1; i <= nb ; i ++) {
189 Handle(Standard_Transient) anent = Value(i);
190 if (thegtool->Select (anent,module,CN))
191 module->WhenDeleteCase (CN,anent,isdispatch);
193 thegtool->ClearEntities(); //smh#14 FRA62479
195 isdispatch = Standard_False;
200 // .... ACCES AUX ENTITES ....
203 //=======================================================================
204 //function : NbEntities
206 //=======================================================================
208 Standard_Integer Interface_InterfaceModel::NbEntities () const
210 return theentities.Extent();
214 //=======================================================================
215 //function : Contains
217 //=======================================================================
219 Standard_Boolean Interface_InterfaceModel::Contains
220 (const Handle(Standard_Transient)& anentity) const
222 if (theentities.Contains(anentity)) return Standard_True;
223 Handle(Interface_ReportEntity) rep =
224 Handle(Interface_ReportEntity)::DownCast(anentity);
225 if (!rep.IsNull()) return Contains(rep->Concerned());
226 return Standard_False;
230 //=======================================================================
233 //=======================================================================
235 Standard_Integer Interface_InterfaceModel::Number
236 (const Handle(Standard_Transient)& anentity) const
238 if (anentity.IsNull()) return 0;
239 Standard_Integer num = theentities.FindIndex(anentity);
240 if (num > 0) return num;
241 if (anentity->IsKind(typerep())) {
242 Handle(Interface_ReportEntity) rep =
243 Handle(Interface_ReportEntity)::DownCast(anentity);
244 if (!rep.IsNull()) return Number(rep->Concerned());
250 Standard_Integer Interface_InterfaceModel::DENumber
251 (const Handle(Standard_Transient)& anentity) const
253 if (anentity.IsNull()) return 0;
254 Standard_Integer num = theentities.FindIndex(anentity);
255 if (num > 0) return (2*num-1);
256 if (anentity->IsKind(typerep())) {
257 Handle(Interface_ReportEntity) rep =
258 Handle(Interface_ReportEntity)::DownCast(anentity);
259 if (!rep.IsNull()) return (Number(rep->Concerned())*2-1);
265 // .. Acces Speciaux (Report, etc...) ..
268 //=======================================================================
271 //=======================================================================
273 const Handle(Standard_Transient)& Interface_InterfaceModel::Value
274 (const Standard_Integer num) const
276 return theentities.FindKey(num);
280 //=======================================================================
283 //=======================================================================
285 Standard_Integer Interface_InterfaceModel::NbTypes
286 (const Handle(Standard_Transient)& ent) const
288 if (Protocol().IsNull()) return 1;
289 return Protocol()->NbTypes(ent);
293 //=======================================================================
296 //=======================================================================
298 Handle(Standard_Type) Interface_InterfaceModel::Type
299 (const Handle(Standard_Transient)& ent, const Standard_Integer nt) const
301 if (Protocol().IsNull()) return ent->DynamicType();
302 return Protocol()->Type(ent,nt);
306 //=======================================================================
307 //function : TypeName
309 //=======================================================================
311 Standard_CString Interface_InterfaceModel::TypeName
312 (const Handle(Standard_Transient)& ent, const Standard_Boolean complet) const
314 if (!thegtool.IsNull()) return thegtool->SignValue (ent,this);
315 Standard_CString tn = ent->DynamicType()->Name();
316 if (complet) return tn;
317 return Interface_InterfaceModel::ClassName(tn);
321 //=======================================================================
322 //function : ClassName
324 //=======================================================================
326 Standard_CString Interface_InterfaceModel::ClassName(const Standard_CString typnam)
328 return Interface_SignType::ClassName (typnam);
332 //=======================================================================
333 //function : EntityState
335 //=======================================================================
337 Interface_DataState Interface_InterfaceModel::EntityState
338 (const Standard_Integer num) const
340 Handle(Interface_ReportEntity) rep;
341 if (!thereports.IsBound(num)) {
342 if (!therepch.IsBound(num)) return Interface_StateOK;
343 rep = Handle(Interface_ReportEntity)::DownCast(therepch.Find(num));
344 if (rep->IsError()) return Interface_DataFail;
345 return Interface_DataWarning;
347 rep = Handle(Interface_ReportEntity)::DownCast(thereports.Find(num));
348 if (rep.IsNull()) return Interface_StateUnknown;
349 if (rep->IsUnknown()) return Interface_StateUnknown;
350 if (rep->HasNewContent()) return Interface_StateUnloaded;
351 if (rep->IsError()) return Interface_LoadFail;
353 if (!therepch.IsBound(num)) return Interface_LoadWarning;
354 rep = Handle(Interface_ReportEntity)::DownCast(therepch.Find(num));
355 if (rep->IsError()) return Interface_DataFail;
356 return Interface_DataWarning;
360 //=======================================================================
361 //function : IsReportEntity
363 //=======================================================================
365 Standard_Boolean Interface_InterfaceModel::IsReportEntity
366 (const Standard_Integer num, const Standard_Boolean semantic) const
368 return (semantic ? therepch.IsBound(num) : thereports.IsBound(num));
372 //=======================================================================
373 //function : ReportEntity
375 //=======================================================================
377 Handle(Interface_ReportEntity) Interface_InterfaceModel::ReportEntity
378 (const Standard_Integer num, const Standard_Boolean semantic) const
380 Handle(Interface_ReportEntity) rep;
381 if (!IsReportEntity(num,semantic)) return rep;
382 if (semantic) rep = Handle(Interface_ReportEntity)::DownCast(therepch.Find(num));
383 else rep = Handle(Interface_ReportEntity)::DownCast(thereports.Find(num));
388 //=======================================================================
389 //function : IsErrorEntity
391 //=======================================================================
393 Standard_Boolean Interface_InterfaceModel::IsErrorEntity
394 (const Standard_Integer num) const
396 Handle(Interface_ReportEntity) rep = ReportEntity(num);
397 if (rep.IsNull()) return Standard_False;
398 return rep->IsError();
402 //=======================================================================
403 //function : IsRedefinedContent
405 //=======================================================================
407 Standard_Boolean Interface_InterfaceModel::IsRedefinedContent
408 (const Standard_Integer num) const
410 Handle(Interface_ReportEntity) rep = ReportEntity(num);
411 if (rep.IsNull()) return Standard_False;
412 return rep->HasNewContent();
416 //=======================================================================
417 //function : ClearReportEntity
419 //=======================================================================
421 Standard_Boolean Interface_InterfaceModel::ClearReportEntity
422 (const Standard_Integer num)
424 if (!thereports.IsBound(num)) return Standard_False;
425 thereports.UnBind (num);
426 return Standard_True;
430 //=======================================================================
431 //function : SetReportEntity
433 //=======================================================================
435 Standard_Boolean Interface_InterfaceModel::SetReportEntity
436 (const Standard_Integer num, const Handle(Interface_ReportEntity)& rep)
438 Standard_Integer nm = num;
439 Handle(Standard_Transient) ent;
442 if (! (ent == rep->Concerned()) ) Interface_InterfaceMismatch::Raise
443 ("InterfaceModel : SetReportEntity");
444 } else if (num < 0) {
447 if (! (ent == rep->Concerned()) ) Interface_InterfaceMismatch::Raise
448 ("InterfaceModel : SetReportEntity");
450 ent = rep->Concerned();
452 if (nm == 0) Interface_InterfaceMismatch::Raise
453 ("InterfaceModel : SetReportEntity");
455 if (!thereports.IsBound(nm)) {
456 Standard_Integer maxrep = thereports.NbBuckets();
457 if (thereports.Extent() > maxrep - 10) thereports.ReSize(maxrep*3/2);
459 if (nm <= 0) return Standard_False;
460 return thereports.Bind (nm,rep);
464 //=======================================================================
465 //function : AddReportEntity
467 //=======================================================================
469 Standard_Boolean Interface_InterfaceModel::AddReportEntity
470 (const Handle(Interface_ReportEntity)& rep, const Standard_Boolean semantic)
472 if (rep.IsNull()) return Standard_False;
473 Handle(Standard_Transient) ent = rep->Concerned();
474 if (ent.IsNull()) return Standard_False;
475 Standard_Integer num = Number(ent);
476 if (num == 0) return Standard_False;
477 if (semantic) return thereports.Bind (num,rep);
478 else return therepch.Bind (num,rep);
482 //=======================================================================
483 //function : IsUnknownEntity
485 //=======================================================================
487 Standard_Boolean Interface_InterfaceModel::IsUnknownEntity
488 (const Standard_Integer num) const
490 Handle(Interface_ReportEntity) rep = ReportEntity(num);
491 if (rep.IsNull()) return Standard_False;
492 return rep->IsUnknown();
496 // .... Checks semantiques .... //
499 //=======================================================================
500 //function : FillSemanticChecks
502 //=======================================================================
504 void Interface_InterfaceModel::FillSemanticChecks
505 (const Interface_CheckIterator& checks, const Standard_Boolean clear)
507 if (!checks.Model().IsNull()) {
508 Handle(Standard_Transient) t1 = checks.Model();
509 Handle(Standard_Transient) t2 = this;
510 if (t2 != t1) return;
512 if (clear) { therepch.Clear(); thechecksem->Clear(); }
513 Standard_Integer nb = 0;
514 for (checks.Start(); checks.More(); checks.Next()) nb ++;
515 therepch.ReSize (therepch.Extent() + nb + 2);
516 for (checks.Start(); checks.More(); checks.Next()) {
517 const Handle(Interface_Check) ach = checks.Value();
518 Standard_Integer num = checks.Number();
519 // global check : ok si MEME MODELE
520 if (num == 0) thechecksem->GetMessages(ach);
522 Handle(Standard_Transient) ent = Value(num);
523 Handle(Interface_ReportEntity) rep = new Interface_ReportEntity(ach,ent);
524 therepch.Bind (num,rep);
527 haschecksem = Standard_True;
531 //=======================================================================
532 //function : HasSemanticChecks
534 //=======================================================================
536 Standard_Boolean Interface_InterfaceModel::HasSemanticChecks () const
542 //=======================================================================
545 //=======================================================================
547 const Handle(Interface_Check)& Interface_InterfaceModel::Check
548 (const Standard_Integer num, const Standard_Boolean syntactic) const
551 if (syntactic) return thecheckstx;
552 else return thechecksem;
554 if (! (syntactic ? thereports.IsBound(num) : therepch.IsBound(num)) )
556 Handle(Standard_Transient) trep;
557 if (syntactic) trep = thereports.Find(num);
558 else trep = therepch.Find(num);
559 Handle(Interface_ReportEntity) rep = Handle(Interface_ReportEntity)::DownCast(trep);
560 if (rep.IsNull()) return nulch();
565 // .... Chargement des donnees du Modele .... //
568 //=======================================================================
569 //function : Reservate
571 //=======================================================================
573 void Interface_InterfaceModel::Reservate (const Standard_Integer nbent)
575 if (nbent > theentities.NbBuckets()) theentities.ReSize (nbent);
576 if (nbent < -thereports.NbBuckets()) thereports.ReSize (-nbent);
580 //=======================================================================
581 //function : AddEntity
583 //=======================================================================
585 void Interface_InterfaceModel::AddEntity(const Handle(Standard_Transient)& anentity)
587 //Standard_Integer newnum; svv #2
588 if (!anentity->IsKind(typerep())) theentities.Add(anentity);
589 // Report : Ajouter Concerned, mais noter presence Report et sa valeur
591 Handle(Interface_ReportEntity) rep =
592 Handle(Interface_ReportEntity)::DownCast(anentity);
593 AddEntity(rep->Concerned());
594 Standard_Integer maxrep = thereports.NbBuckets();
595 if (thereports.Extent() > maxrep - 10) thereports.ReSize(maxrep*3/2);
596 thereports.Bind (Number(rep->Concerned()),rep);
601 // AddWithRefs itere sur les Entities referencees pour charger une Entite
602 // au complet, avec tout ce dont elle a besoin
605 //=======================================================================
606 //function : AddWithRefs
608 //=======================================================================
610 void Interface_InterfaceModel::AddWithRefs(const Handle(Standard_Transient)& anent,
611 const Handle(Interface_Protocol)& proto,
612 const Standard_Integer level,
613 const Standard_Boolean listall)
615 if (anent.IsNull()) return;
616 if (theentities.FindIndex(anent) != 0) {
617 if (!listall) return;
619 Interface_GeneralLib lib(proto);
620 AddWithRefs (anent,lib,level,listall);
621 if (Protocol().IsNull() && !proto.IsNull()) SetProtocol(proto);
625 //=======================================================================
626 //function : AddWithRefs
628 //=======================================================================
630 void Interface_InterfaceModel::AddWithRefs(const Handle(Standard_Transient)& anent,
631 const Standard_Integer level,
632 const Standard_Boolean listall)
634 Handle(Interface_Protocol) proto = Protocol();
635 if (proto.IsNull()) Interface_InterfaceMismatch::Raise
636 ("InterfaceModel : AddWithRefs");
637 AddWithRefs (anent,proto,level,listall);
641 //=======================================================================
642 //function : AddWithRefs
644 //=======================================================================
646 void Interface_InterfaceModel::AddWithRefs(const Handle(Standard_Transient)& anent,
647 const Interface_GeneralLib& lib,
648 const Standard_Integer level,
649 const Standard_Boolean listall)
651 if (anent.IsNull()) return;
652 if (theentities.FindIndex(anent) != 0) {
653 if (!listall) return;
655 else AddEntity(anent);
657 Interface_EntityIterator iter;
658 Handle(Interface_GeneralModule) module; Standard_Integer CN;
659 if (lib.Select (anent,module,CN)) {
660 module->FillSharedCase (CN,anent,iter);
661 // FillShared tout court : supposerait que le modele soit deja pret
662 // or justement, on est en train de le construire ...
663 module->ListImpliedCase (CN,anent,iter);
665 Standard_Integer lev1 = level-1;
666 if (lev1 == 0) return; // level = 0 -> tous niveaux; sinon encore n-1
667 for (iter.Start(); iter.More(); iter.Next())
668 AddWithRefs(iter.Value(),lib,lev1,listall);
672 //=======================================================================
673 //function : ReplaceEntity
675 //=======================================================================
677 void Interface_InterfaceModel::ReplaceEntity(const Standard_Integer nument,
678 const Handle(Standard_Transient)& anent)
680 theentities.Substitute(nument,anent);
683 // ReverseOrders permet de mieux controler la numeration des Entites :
684 // Souvent, les fichiers mettent les racines en fin, tandis que AddWithRefs
688 //=======================================================================
689 //function : ReverseOrders
691 //=======================================================================
693 void Interface_InterfaceModel::ReverseOrders (const Standard_Integer after)
695 Standard_Integer nb = NbEntities(); //Standard_Integer num; svv #2
696 if (nb < 2 || after >= nb) return;
697 TColStd_Array1OfTransient ents(1,nb);
698 Standard_Integer i; // svv #1
699 for (i = 1; i <= nb; i ++)
700 ents.SetValue (i, theentities.FindKey(i));
701 // On va vider la Map, puis la recharger : dans l ordre jusqua after
702 // en ordre inverse apres
705 for (i = 1; i <= after; i ++) theentities.Add (ents(i));// svv #2
706 for (i = nb; i > after; i --) theentities.Add (ents(i));
707 // Faudra aussi s occuper des Reports
708 for (i = nb; i > after; i --) {
709 Standard_Integer i2 = nb+after-i;
710 Handle(Standard_Transient) rep1,rep2;
711 if (thereports.IsBound(i)) rep1 = thereports.Find(i);
712 if (thereports.IsBound(i2)) rep2 = thereports.Find(i2);
713 if (!rep1.IsNull()) thereports.Bind (i2,rep1);
714 else thereports.UnBind (i2);
715 if (!rep2.IsNull()) thereports.Bind (i,rep2);
716 else thereports.UnBind (i);
721 //=======================================================================
722 //function : ChangeOrder
724 //=======================================================================
726 void Interface_InterfaceModel::ChangeOrder(const Standard_Integer oldnum,
727 const Standard_Integer newnum,
728 const Standard_Integer cnt) //szv#4:S4163:12Mar99 `count` hid one from this
730 Standard_Integer nb = NbEntities(); Standard_Integer i; //, num; svv #2
731 if (nb < 2 || newnum >= nb || cnt<= 0) return;
732 TColStd_Array1OfTransient ents(1,nb);
733 // On va preparer le changement
734 Standard_Integer minum = (oldnum > newnum ? newnum : oldnum);
735 Standard_Integer mxnum = (oldnum < newnum ? newnum : oldnum);
736 Standard_Integer kount = (oldnum > newnum ? cnt : -cnt);
737 if (cnt <= 0 || cnt > mxnum - minum) Interface_InterfaceMismatch::Raise
738 ("InterfaceModel : ChangeOrder, Overlap");
739 for (i = 1; i < minum; i ++) ents.SetValue (i,theentities.FindKey(i));
740 for (i = mxnum+cnt; i <= nb; i ++) ents.SetValue (i,theentities.FindKey(i));
741 for (i = minum; i < mxnum; i ++)
742 ents.SetValue( i + kount, theentities.FindKey(i) );
743 for (i = oldnum; i < oldnum+cnt; i ++)
744 ents.SetValue( i + (newnum-oldnum), theentities.FindKey(i) );
748 for (i = 1; i <= nb; i ++) theentities.Add (ents(i)); // svv #2
750 Standard_Integer difnum = mxnum - minum;
751 for (i = minum; i < minum+cnt; i ++) {
752 Handle(Standard_Transient) rep1, rep2;
753 if (thereports.IsBound(i)) rep1 = thereports.Find(i);
754 if (thereports.IsBound(i+difnum)) rep1 = thereports.Find(i+difnum);
755 if (!rep1.IsNull()) thereports.Bind (i+difnum,rep1);
756 else thereports.UnBind (i+difnum);
757 if (!rep2.IsNull()) thereports.Bind (i,rep2);
758 else thereports.UnBind (i);
763 // GetFromTransfer permet de recuperer un resultat prepare par ailleurs
764 // Le Modele demarre a zero. Les entites doivent etre libres (cf AddEntity)
767 //=======================================================================
768 //function : GetFromTransfer
770 //=======================================================================
772 void Interface_InterfaceModel::GetFromTransfer
773 (const Interface_EntityIterator& aniter)
775 theentities.Clear(); theentities.ReSize (aniter.NbEntities());
776 for (aniter.Start(); aniter.More(); aniter.Next()) {
777 Handle(Standard_Transient) ent = aniter.Value(); AddEntity(ent);
782 // .... Interrogations .... //
785 //=======================================================================
786 //function : SetCategoryNumber
788 //=======================================================================
790 Standard_Boolean Interface_InterfaceModel::SetCategoryNumber
791 (const Standard_Integer num, const Standard_Integer val)
793 Standard_Integer i,nb = NbEntities();
794 if (num < 1 || num > nb) return Standard_False;
795 if (thecategory.IsNull()) thecategory = new TCollection_HAsciiString(nb,' ');
796 else if (thecategory->Length() < nb) {
797 Handle(TCollection_HAsciiString) c = new TCollection_HAsciiString(nb,' ');
798 for (i = thecategory->Length(); i > 0; i --)
799 c->SetValue(i,thecategory->Value(i));
802 Standard_Character cval = (Standard_Character)(val + 32);
803 thecategory->SetValue(num,cval);
804 return Standard_True;
808 //=======================================================================
809 //function : CategoryNumber
811 //=======================================================================
813 Standard_Integer Interface_InterfaceModel::CategoryNumber
814 (const Standard_Integer num) const
816 if (thecategory.IsNull()) return 0;
817 if (num < 1 || num > thecategory->Length()) return 0;
818 Standard_Integer val = thecategory->Value(num);
823 //=======================================================================
824 //function : FillIterator
826 //=======================================================================
828 void Interface_InterfaceModel::FillIterator(Interface_EntityIterator& iter) const
830 Standard_Integer nb = NbEntities();
831 for (Standard_Integer i = 1; i <= nb; i ++)
832 iter.GetOneItem (theentities.FindKey(i));
836 //=======================================================================
837 //function : Entities
839 //=======================================================================
841 Interface_EntityIterator Interface_InterfaceModel::Entities () const
843 Interface_EntityIterator iter;
849 //=======================================================================
852 //=======================================================================
854 Interface_EntityIterator Interface_InterfaceModel::Reports
855 (const Standard_Boolean semantic) const
857 Interface_EntityIterator iter;
859 TColStd_DataMapIteratorOfDataMapOfIntegerTransient itmap (therepch);
860 for (; itmap.More(); itmap.Next()) iter.AddItem (itmap.Value());
862 TColStd_DataMapIteratorOfDataMapOfIntegerTransient itmap (thereports);
863 for (; itmap.More(); itmap.Next()) iter.AddItem (itmap.Value());
869 //=======================================================================
870 //function : Redefineds
872 //=======================================================================
874 Interface_EntityIterator Interface_InterfaceModel::Redefineds () const
876 Interface_EntityIterator iter;
877 TColStd_DataMapIteratorOfDataMapOfIntegerTransient itmap (thereports);
878 for (; itmap.More(); itmap.Next()) {
879 Handle(Interface_ReportEntity) rep =
880 Handle(Interface_ReportEntity)::DownCast(itmap.Value());
881 if (rep.IsNull()) continue;
882 if (!rep->HasNewContent()) continue;
888 //#include <limits.h>
889 //#include <TColStd_MapTransientHasher.hxx>
892 //=======================================================================
893 //function : GlobalCheck
895 //=======================================================================
897 const Handle(Interface_Check)& Interface_InterfaceModel::GlobalCheck
898 (const Standard_Boolean syntactic) const
900 if (syntactic) return thecheckstx;
901 else return thechecksem;
905 //=======================================================================
906 //function : SetGlobalCheck
908 //=======================================================================
910 void Interface_InterfaceModel::SetGlobalCheck(const Handle(Interface_Check)& ach)
916 //=======================================================================
917 //function : VerifyCheck
919 //=======================================================================
921 void Interface_InterfaceModel::VerifyCheck (Handle(Interface_Check)& /*ach*/) const
926 //=======================================================================
929 //=======================================================================
931 void Interface_InterfaceModel::Print(const Handle(Standard_Transient)& ent,
932 const Handle(Message_Messenger)& S,
933 const Standard_Integer mode) const
935 if (ent.IsNull()) { S<<"NULL"; return; }
936 Standard_Integer num = Number(ent);
937 if (mode <= 0) S<<num;
938 if (mode == 0) S<<":";
942 // PrintLabel (ent,S);
948 //=======================================================================
949 //function : PrintToLog
951 //=======================================================================
953 void Interface_InterfaceModel::PrintToLog(const Handle(Standard_Transient)& ent,
954 const Handle(Message_Messenger)& S) const
960 // .... TEMPLATES .... //
963 //=======================================================================
964 //function : NextNumberForLabel
966 //=======================================================================
968 Standard_Integer Interface_InterfaceModel::NextNumberForLabel
969 (const Standard_CString label, const Standard_Integer fromnum,
970 const Standard_Boolean exact) const
972 Standard_Integer n = NbEntities();
973 Handle(TCollection_HAsciiString) labs = new TCollection_HAsciiString(label);
974 Standard_Integer lnb = labs->Length();
977 Standard_Integer i; // svv #1
978 for (i = fromnum+1; i <= n; i ++) {
979 Handle(TCollection_HAsciiString) lab = StringLabel (Value(i));
980 if (lab.IsNull()) continue;
982 if (lab->IsSameString(labs,Standard_False)) return i;
984 if (lab->Length() < lnb) continue;
986 if (lab->SearchFromEnd(labs) == lab->Length() - lnb + 1) return i;
990 // En "non exact", on admet de recevoir le numero entre 1 et n
993 if (labs->IsIntegerValue()) i = atoi (labs->ToCString());
994 if (i <= 0 || i > n) i = 0;
999 //=======================================================================
1000 //function : HasTemplate
1002 //=======================================================================
1004 Standard_Boolean Interface_InterfaceModel::HasTemplate
1005 (const Standard_CString name)
1007 return templates()->HasItem(name);
1011 //=======================================================================
1012 //function : Template
1014 //=======================================================================
1016 Handle(Interface_InterfaceModel) Interface_InterfaceModel::Template
1017 (const Standard_CString name)
1019 Handle(Interface_InterfaceModel) model,newmod;
1020 if (!HasTemplate(name)) return model;
1021 model = Handle(Interface_InterfaceModel)::DownCast(templates()->Item(name));
1022 newmod = model->NewEmptyModel();
1023 newmod->GetFromAnother (model);
1028 //=======================================================================
1029 //function : SetTemplate
1031 //=======================================================================
1033 Standard_Boolean Interface_InterfaceModel::SetTemplate
1034 (const Standard_CString name, const Handle(Interface_InterfaceModel)& model)
1036 Standard_Boolean deja;
1037 Handle(Standard_Transient)& newmod = templates()->NewItem(name,deja);
1043 //=======================================================================
1044 //function : ListTemplates
1046 //=======================================================================
1048 Handle(TColStd_HSequenceOfHAsciiString) Interface_InterfaceModel::ListTemplates ()
1050 Handle(TColStd_HSequenceOfHAsciiString) list = new
1051 TColStd_HSequenceOfHAsciiString();
1052 if (templates().IsNull()) return list;
1053 for (Dico_IteratorOfDictionaryOfTransient iter(templates());
1054 iter.More(); iter.Next()) {
1055 list->Append (new TCollection_HAsciiString (iter.Name()) );