1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
19 //svv#1 11.01.00 : porting on DEC
20 //svv#2 21.02.00 : porting on SIL
21 //smh#14 17.03.2000 : FRA62479 Clearing of gtool.
22 #include <Interface_InterfaceModel.ixx>
23 #include <Interface_GeneralModule.hxx>
24 #include <TColStd_Array1OfTransient.hxx>
25 #include <TColStd_Array1OfInteger.hxx>
26 #include <Interface_InterfaceMismatch.hxx>
27 #include <Dico_DictionaryOfTransient.hxx>
28 #include <Dico_IteratorOfDictionaryOfTransient.hxx>
29 #include <TColStd_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
30 #include <Standard_OutOfRange.hxx>
31 #include <Interface_SignType.hxx>
32 #include <Message_Messenger.hxx>
34 // Un Modele d`Interface est un ensemble ferme d`Entites d`interface : chacune
35 // est dans un seul modele a la fois; elle y a un numero (Number) qui permet de
36 // verifier qu`une entite est bien dans un seul modele, de definir des Map tres
37 // performantes, de fournir un identifieur numerique
39 // Il est a meme d`etre utilise dans des traitements de Graphe
41 // STATICS : les TEMPLATES
44 static const Handle(Dico_DictionaryOfTransient)& templates()
46 static Handle(Dico_DictionaryOfTransient) atemp;
47 if (atemp.IsNull()) atemp = new Dico_DictionaryOfTransient;
52 static const Handle(Standard_Type)& typerep()
54 static Handle(Standard_Type) tr = STANDARD_TYPE(Interface_ReportEntity);
59 static const Handle(Interface_Check)& nulch()
61 static Handle(Interface_Check) anulch = new Interface_Check;
66 //=======================================================================
67 //function : Interface_InterfaceModel
69 //=======================================================================
71 Interface_InterfaceModel::Interface_InterfaceModel ()
72 : haschecksem (Standard_False), isdispatch (Standard_False)
74 thecheckstx = new Interface_Check;
75 thechecksem = new Interface_Check;
79 //=======================================================================
82 //=======================================================================
84 void Interface_InterfaceModel::Destroy () // on fait un mimumum
86 // Moins que Clear que, lui, est adapte a chaque norme
90 thecategory.Nullify();
94 //=======================================================================
95 //function : SetProtocol
97 //=======================================================================
99 void Interface_InterfaceModel::SetProtocol(const Handle(Interface_Protocol)& proto)
101 thegtool = new Interface_GTool(proto);
105 //=======================================================================
106 //function : Protocol
108 //=======================================================================
110 Handle(Interface_Protocol) Interface_InterfaceModel::Protocol () const
112 Handle(Interface_Protocol) proto;
113 if (!thegtool.IsNull()) return thegtool->Protocol();
118 //=======================================================================
119 //function : SetGTool
121 //=======================================================================
123 void Interface_InterfaceModel::SetGTool(const Handle(Interface_GTool)& gtool)
129 //=======================================================================
132 //=======================================================================
134 Handle(Interface_GTool) Interface_InterfaceModel::GTool () const
140 //=======================================================================
143 //=======================================================================
145 void Interface_InterfaceModel::Clear ()
148 thecheckstx->Clear();
149 thechecksem->Clear();
152 thecategory.Nullify();
156 //=======================================================================
157 //function : DispatchStatus
159 //=======================================================================
161 Standard_Boolean& Interface_InterfaceModel::DispatchStatus ()
167 //=======================================================================
168 //function : ClearEntities
170 //=======================================================================
172 void Interface_InterfaceModel::ClearEntities ()
176 haschecksem = Standard_False;
178 if (!thegtool.IsNull()) {
179 // WhenDeleteCase is not applicable
180 /* Handle(Interface_GeneralModule) module; Standard_Integer CN;
181 Standard_Integer nb = NbEntities();
182 for (Standard_Integer i = 1; i <= nb ; i ++) {
183 Handle(Standard_Transient) anent = Value(i);
184 if (thegtool->Select (anent,module,CN))
185 module->WhenDeleteCase (CN,anent,isdispatch);
187 thegtool->ClearEntities(); //smh#14 FRA62479
189 isdispatch = Standard_False;
194 // .... ACCES AUX ENTITES ....
197 //=======================================================================
198 //function : NbEntities
200 //=======================================================================
202 Standard_Integer Interface_InterfaceModel::NbEntities () const
204 return theentities.Extent();
208 //=======================================================================
209 //function : Contains
211 //=======================================================================
213 Standard_Boolean Interface_InterfaceModel::Contains
214 (const Handle(Standard_Transient)& anentity) const
216 if (theentities.Contains(anentity)) return Standard_True;
217 Handle(Interface_ReportEntity) rep =
218 Handle(Interface_ReportEntity)::DownCast(anentity);
219 if (!rep.IsNull()) return Contains(rep->Concerned());
220 return Standard_False;
224 //=======================================================================
227 //=======================================================================
229 Standard_Integer Interface_InterfaceModel::Number
230 (const Handle(Standard_Transient)& anentity) const
232 if (anentity.IsNull()) return 0;
233 Standard_Integer num = theentities.FindIndex(anentity);
234 if (num > 0) return num;
235 if (anentity->IsKind(typerep())) {
236 Handle(Interface_ReportEntity) rep =
237 Handle(Interface_ReportEntity)::DownCast(anentity);
238 if (!rep.IsNull()) return Number(rep->Concerned());
244 Standard_Integer Interface_InterfaceModel::DENumber
245 (const Handle(Standard_Transient)& anentity) const
247 if (anentity.IsNull()) return 0;
248 Standard_Integer num = theentities.FindIndex(anentity);
249 if (num > 0) return (2*num-1);
250 if (anentity->IsKind(typerep())) {
251 Handle(Interface_ReportEntity) rep =
252 Handle(Interface_ReportEntity)::DownCast(anentity);
253 if (!rep.IsNull()) return (Number(rep->Concerned())*2-1);
259 // .. Acces Speciaux (Report, etc...) ..
262 //=======================================================================
265 //=======================================================================
267 const Handle(Standard_Transient)& Interface_InterfaceModel::Value
268 (const Standard_Integer num) const
270 return theentities.FindKey(num);
274 //=======================================================================
277 //=======================================================================
279 Standard_Integer Interface_InterfaceModel::NbTypes
280 (const Handle(Standard_Transient)& ent) const
282 if (Protocol().IsNull()) return 1;
283 return Protocol()->NbTypes(ent);
287 //=======================================================================
290 //=======================================================================
292 Handle(Standard_Type) Interface_InterfaceModel::Type
293 (const Handle(Standard_Transient)& ent, const Standard_Integer nt) const
295 if (Protocol().IsNull()) return ent->DynamicType();
296 return Protocol()->Type(ent,nt);
300 //=======================================================================
301 //function : TypeName
303 //=======================================================================
305 Standard_CString Interface_InterfaceModel::TypeName
306 (const Handle(Standard_Transient)& ent, const Standard_Boolean complet) const
308 if (!thegtool.IsNull()) return thegtool->SignValue (ent,this);
309 Standard_CString tn = ent->DynamicType()->Name();
310 if (complet) return tn;
311 return Interface_InterfaceModel::ClassName(tn);
315 //=======================================================================
316 //function : ClassName
318 //=======================================================================
320 Standard_CString Interface_InterfaceModel::ClassName(const Standard_CString typnam)
322 return Interface_SignType::ClassName (typnam);
326 //=======================================================================
327 //function : EntityState
329 //=======================================================================
331 Interface_DataState Interface_InterfaceModel::EntityState
332 (const Standard_Integer num) const
334 Handle(Interface_ReportEntity) rep;
335 if (!thereports.IsBound(num)) {
336 if (!therepch.IsBound(num)) return Interface_StateOK;
337 rep = Handle(Interface_ReportEntity)::DownCast(therepch.Find(num));
338 if (rep->IsError()) return Interface_DataFail;
339 return Interface_DataWarning;
341 rep = Handle(Interface_ReportEntity)::DownCast(thereports.Find(num));
342 if (rep.IsNull()) return Interface_StateUnknown;
343 if (rep->IsUnknown()) return Interface_StateUnknown;
344 if (rep->HasNewContent()) return Interface_StateUnloaded;
345 if (rep->IsError()) return Interface_LoadFail;
347 if (!therepch.IsBound(num)) return Interface_LoadWarning;
348 rep = Handle(Interface_ReportEntity)::DownCast(therepch.Find(num));
349 if (rep->IsError()) return Interface_DataFail;
350 return Interface_DataWarning;
354 //=======================================================================
355 //function : IsReportEntity
357 //=======================================================================
359 Standard_Boolean Interface_InterfaceModel::IsReportEntity
360 (const Standard_Integer num, const Standard_Boolean semantic) const
362 return (semantic ? therepch.IsBound(num) : thereports.IsBound(num));
366 //=======================================================================
367 //function : ReportEntity
369 //=======================================================================
371 Handle(Interface_ReportEntity) Interface_InterfaceModel::ReportEntity
372 (const Standard_Integer num, const Standard_Boolean semantic) const
374 Handle(Interface_ReportEntity) rep;
375 if (!IsReportEntity(num,semantic)) return rep;
376 if (semantic) rep = Handle(Interface_ReportEntity)::DownCast(therepch.Find(num));
377 else rep = Handle(Interface_ReportEntity)::DownCast(thereports.Find(num));
382 //=======================================================================
383 //function : IsErrorEntity
385 //=======================================================================
387 Standard_Boolean Interface_InterfaceModel::IsErrorEntity
388 (const Standard_Integer num) const
390 Handle(Interface_ReportEntity) rep = ReportEntity(num);
391 if (rep.IsNull()) return Standard_False;
392 return rep->IsError();
396 //=======================================================================
397 //function : IsRedefinedContent
399 //=======================================================================
401 Standard_Boolean Interface_InterfaceModel::IsRedefinedContent
402 (const Standard_Integer num) const
404 Handle(Interface_ReportEntity) rep = ReportEntity(num);
405 if (rep.IsNull()) return Standard_False;
406 return rep->HasNewContent();
410 //=======================================================================
411 //function : ClearReportEntity
413 //=======================================================================
415 Standard_Boolean Interface_InterfaceModel::ClearReportEntity
416 (const Standard_Integer num)
418 if (!thereports.IsBound(num)) return Standard_False;
419 thereports.UnBind (num);
420 return Standard_True;
424 //=======================================================================
425 //function : SetReportEntity
427 //=======================================================================
429 Standard_Boolean Interface_InterfaceModel::SetReportEntity
430 (const Standard_Integer num, const Handle(Interface_ReportEntity)& rep)
432 Standard_Integer nm = num;
433 Handle(Standard_Transient) ent;
436 if (! (ent == rep->Concerned()) ) Interface_InterfaceMismatch::Raise
437 ("InterfaceModel : SetReportEntity");
438 } else if (num < 0) {
441 if (! (ent == rep->Concerned()) ) Interface_InterfaceMismatch::Raise
442 ("InterfaceModel : SetReportEntity");
444 ent = rep->Concerned();
446 if (nm == 0) Interface_InterfaceMismatch::Raise
447 ("InterfaceModel : SetReportEntity");
449 if (!thereports.IsBound(nm)) {
450 Standard_Integer maxrep = thereports.NbBuckets();
451 if (thereports.Extent() > maxrep - 10) thereports.ReSize(maxrep*3/2);
453 if (nm <= 0) return Standard_False;
454 return thereports.Bind (nm,rep);
458 //=======================================================================
459 //function : AddReportEntity
461 //=======================================================================
463 Standard_Boolean Interface_InterfaceModel::AddReportEntity
464 (const Handle(Interface_ReportEntity)& rep, const Standard_Boolean semantic)
466 if (rep.IsNull()) return Standard_False;
467 Handle(Standard_Transient) ent = rep->Concerned();
468 if (ent.IsNull()) return Standard_False;
469 Standard_Integer num = Number(ent);
470 if (num == 0) return Standard_False;
471 if (semantic) return thereports.Bind (num,rep);
472 else return therepch.Bind (num,rep);
476 //=======================================================================
477 //function : IsUnknownEntity
479 //=======================================================================
481 Standard_Boolean Interface_InterfaceModel::IsUnknownEntity
482 (const Standard_Integer num) const
484 Handle(Interface_ReportEntity) rep = ReportEntity(num);
485 if (rep.IsNull()) return Standard_False;
486 return rep->IsUnknown();
490 // .... Checks semantiques .... //
493 //=======================================================================
494 //function : FillSemanticChecks
496 //=======================================================================
498 void Interface_InterfaceModel::FillSemanticChecks
499 (const Interface_CheckIterator& checks, const Standard_Boolean clear)
501 if (!checks.Model().IsNull()) {
502 Handle(Standard_Transient) t1 = checks.Model();
503 Handle(Standard_Transient) t2 = this;
504 if (t2 != t1) return;
506 if (clear) { therepch.Clear(); thechecksem->Clear(); }
507 Standard_Integer nb = 0;
508 for (checks.Start(); checks.More(); checks.Next()) nb ++;
509 therepch.ReSize (therepch.Extent() + nb + 2);
510 for (checks.Start(); checks.More(); checks.Next()) {
511 const Handle(Interface_Check) ach = checks.Value();
512 Standard_Integer num = checks.Number();
513 // global check : ok si MEME MODELE
514 if (num == 0) thechecksem->GetMessages(ach);
516 Handle(Standard_Transient) ent = Value(num);
517 Handle(Interface_ReportEntity) rep = new Interface_ReportEntity(ach,ent);
518 therepch.Bind (num,rep);
521 haschecksem = Standard_True;
525 //=======================================================================
526 //function : HasSemanticChecks
528 //=======================================================================
530 Standard_Boolean Interface_InterfaceModel::HasSemanticChecks () const
536 //=======================================================================
539 //=======================================================================
541 const Handle(Interface_Check)& Interface_InterfaceModel::Check
542 (const Standard_Integer num, const Standard_Boolean syntactic) const
545 if (syntactic) return thecheckstx;
546 else return thechecksem;
548 if (! (syntactic ? thereports.IsBound(num) : therepch.IsBound(num)) )
550 Handle(Standard_Transient) trep;
551 if (syntactic) trep = thereports.Find(num);
552 else trep = therepch.Find(num);
553 Handle(Interface_ReportEntity) rep = Handle(Interface_ReportEntity)::DownCast(trep);
554 if (rep.IsNull()) return nulch();
559 // .... Chargement des donnees du Modele .... //
562 //=======================================================================
563 //function : Reservate
565 //=======================================================================
567 void Interface_InterfaceModel::Reservate (const Standard_Integer nbent)
569 if (nbent > theentities.NbBuckets()) theentities.ReSize (nbent);
570 if (nbent < -thereports.NbBuckets()) thereports.ReSize (-nbent);
574 //=======================================================================
575 //function : AddEntity
577 //=======================================================================
579 void Interface_InterfaceModel::AddEntity(const Handle(Standard_Transient)& anentity)
581 //Standard_Integer newnum; svv #2
582 if (!anentity->IsKind(typerep())) theentities.Add(anentity);
583 // Report : Ajouter Concerned, mais noter presence Report et sa valeur
585 Handle(Interface_ReportEntity) rep =
586 Handle(Interface_ReportEntity)::DownCast(anentity);
587 AddEntity(rep->Concerned());
588 Standard_Integer maxrep = thereports.NbBuckets();
589 if (thereports.Extent() > maxrep - 10) thereports.ReSize(maxrep*3/2);
590 thereports.Bind (Number(rep->Concerned()),rep);
595 // AddWithRefs itere sur les Entities referencees pour charger une Entite
596 // au complet, avec tout ce dont elle a besoin
599 //=======================================================================
600 //function : AddWithRefs
602 //=======================================================================
604 void Interface_InterfaceModel::AddWithRefs(const Handle(Standard_Transient)& anent,
605 const Handle(Interface_Protocol)& proto,
606 const Standard_Integer level,
607 const Standard_Boolean listall)
609 if (anent.IsNull()) return;
610 if (theentities.FindIndex(anent) != 0) {
611 if (!listall) return;
613 Interface_GeneralLib lib(proto);
614 AddWithRefs (anent,lib,level,listall);
615 if (Protocol().IsNull() && !proto.IsNull()) SetProtocol(proto);
619 //=======================================================================
620 //function : AddWithRefs
622 //=======================================================================
624 void Interface_InterfaceModel::AddWithRefs(const Handle(Standard_Transient)& anent,
625 const Standard_Integer level,
626 const Standard_Boolean listall)
628 Handle(Interface_Protocol) proto = Protocol();
629 if (proto.IsNull()) Interface_InterfaceMismatch::Raise
630 ("InterfaceModel : AddWithRefs");
631 AddWithRefs (anent,proto,level,listall);
635 //=======================================================================
636 //function : AddWithRefs
638 //=======================================================================
640 void Interface_InterfaceModel::AddWithRefs(const Handle(Standard_Transient)& anent,
641 const Interface_GeneralLib& lib,
642 const Standard_Integer level,
643 const Standard_Boolean listall)
645 if (anent.IsNull()) return;
646 if (theentities.FindIndex(anent) != 0) {
647 if (!listall) return;
649 else AddEntity(anent);
651 Interface_EntityIterator iter;
652 Handle(Interface_GeneralModule) module; Standard_Integer CN;
653 if (lib.Select (anent,module,CN)) {
654 module->FillSharedCase (CN,anent,iter);
655 // FillShared tout court : supposerait que le modele soit deja pret
656 // or justement, on est en train de le construire ...
657 module->ListImpliedCase (CN,anent,iter);
659 Standard_Integer lev1 = level-1;
660 if (lev1 == 0) return; // level = 0 -> tous niveaux; sinon encore n-1
661 for (iter.Start(); iter.More(); iter.Next())
662 AddWithRefs(iter.Value(),lib,lev1,listall);
666 //=======================================================================
667 //function : ReplaceEntity
669 //=======================================================================
671 void Interface_InterfaceModel::ReplaceEntity(const Standard_Integer nument,
672 const Handle(Standard_Transient)& anent)
674 theentities.Substitute(nument,anent);
677 // ReverseOrders permet de mieux controler la numeration des Entites :
678 // Souvent, les fichiers mettent les racines en fin, tandis que AddWithRefs
682 //=======================================================================
683 //function : ReverseOrders
685 //=======================================================================
687 void Interface_InterfaceModel::ReverseOrders (const Standard_Integer after)
689 Standard_Integer nb = NbEntities(); //Standard_Integer num; svv #2
690 if (nb < 2 || after >= nb) return;
691 TColStd_Array1OfTransient ents(1,nb);
692 Standard_Integer i; // svv #1
693 for (i = 1; i <= nb; i ++)
694 ents.SetValue (i, theentities.FindKey(i));
695 // On va vider la Map, puis la recharger : dans l ordre jusqua after
696 // en ordre inverse apres
699 for (i = 1; i <= after; i ++) theentities.Add (ents(i));// svv #2
700 for (i = nb; i > after; i --) theentities.Add (ents(i));
701 // Faudra aussi s occuper des Reports
702 for (i = nb; i > after; i --) {
703 Standard_Integer i2 = nb+after-i;
704 Handle(Standard_Transient) rep1,rep2;
705 if (thereports.IsBound(i)) rep1 = thereports.Find(i);
706 if (thereports.IsBound(i2)) rep2 = thereports.Find(i2);
707 if (!rep1.IsNull()) thereports.Bind (i2,rep1);
708 else thereports.UnBind (i2);
709 if (!rep2.IsNull()) thereports.Bind (i,rep2);
710 else thereports.UnBind (i);
715 //=======================================================================
716 //function : ChangeOrder
718 //=======================================================================
720 void Interface_InterfaceModel::ChangeOrder(const Standard_Integer oldnum,
721 const Standard_Integer newnum,
722 const Standard_Integer cnt) //szv#4:S4163:12Mar99 `count` hid one from this
724 Standard_Integer nb = NbEntities(); Standard_Integer i; //, num; svv #2
725 if (nb < 2 || newnum >= nb || cnt<= 0) return;
726 TColStd_Array1OfTransient ents(1,nb);
727 // On va preparer le changement
728 Standard_Integer minum = (oldnum > newnum ? newnum : oldnum);
729 Standard_Integer mxnum = (oldnum < newnum ? newnum : oldnum);
730 Standard_Integer kount = (oldnum > newnum ? cnt : -cnt);
731 if (cnt <= 0 || cnt > mxnum - minum) Interface_InterfaceMismatch::Raise
732 ("InterfaceModel : ChangeOrder, Overlap");
733 for (i = 1; i < minum; i ++) ents.SetValue (i,theentities.FindKey(i));
734 for (i = mxnum+cnt; i <= nb; i ++) ents.SetValue (i,theentities.FindKey(i));
735 for (i = minum; i < mxnum; i ++)
736 ents.SetValue( i + kount, theentities.FindKey(i) );
737 for (i = oldnum; i < oldnum+cnt; i ++)
738 ents.SetValue( i + (newnum-oldnum), theentities.FindKey(i) );
742 for (i = 1; i <= nb; i ++) theentities.Add (ents(i)); // svv #2
744 Standard_Integer difnum = mxnum - minum;
745 for (i = minum; i < minum+cnt; i ++) {
746 Handle(Standard_Transient) rep1, rep2;
747 if (thereports.IsBound(i)) rep1 = thereports.Find(i);
748 if (thereports.IsBound(i+difnum)) rep1 = thereports.Find(i+difnum);
749 if (!rep1.IsNull()) thereports.Bind (i+difnum,rep1);
750 else thereports.UnBind (i+difnum);
751 if (!rep2.IsNull()) thereports.Bind (i,rep2);
752 else thereports.UnBind (i);
757 // GetFromTransfer permet de recuperer un resultat prepare par ailleurs
758 // Le Modele demarre a zero. Les entites doivent etre libres (cf AddEntity)
761 //=======================================================================
762 //function : GetFromTransfer
764 //=======================================================================
766 void Interface_InterfaceModel::GetFromTransfer
767 (const Interface_EntityIterator& aniter)
769 theentities.Clear(); theentities.ReSize (aniter.NbEntities());
770 for (aniter.Start(); aniter.More(); aniter.Next()) {
771 Handle(Standard_Transient) ent = aniter.Value(); AddEntity(ent);
776 // .... Interrogations .... //
779 //=======================================================================
780 //function : SetCategoryNumber
782 //=======================================================================
784 Standard_Boolean Interface_InterfaceModel::SetCategoryNumber
785 (const Standard_Integer num, const Standard_Integer val)
787 Standard_Integer i,nb = NbEntities();
788 if (num < 1 || num > nb) return Standard_False;
789 if (thecategory.IsNull()) thecategory = new TCollection_HAsciiString(nb,' ');
790 else if (thecategory->Length() < nb) {
791 Handle(TCollection_HAsciiString) c = new TCollection_HAsciiString(nb,' ');
792 for (i = thecategory->Length(); i > 0; i --)
793 c->SetValue(i,thecategory->Value(i));
796 Standard_Character cval = (Standard_Character)(val + 32);
797 thecategory->SetValue(num,cval);
798 return Standard_True;
802 //=======================================================================
803 //function : CategoryNumber
805 //=======================================================================
807 Standard_Integer Interface_InterfaceModel::CategoryNumber
808 (const Standard_Integer num) const
810 if (thecategory.IsNull()) return 0;
811 if (num < 1 || num > thecategory->Length()) return 0;
812 Standard_Integer val = thecategory->Value(num);
817 //=======================================================================
818 //function : FillIterator
820 //=======================================================================
822 void Interface_InterfaceModel::FillIterator(Interface_EntityIterator& iter) const
824 Standard_Integer nb = NbEntities();
825 for (Standard_Integer i = 1; i <= nb; i ++)
826 iter.GetOneItem (theentities.FindKey(i));
830 //=======================================================================
831 //function : Entities
833 //=======================================================================
835 Interface_EntityIterator Interface_InterfaceModel::Entities () const
837 Interface_EntityIterator iter;
843 //=======================================================================
846 //=======================================================================
848 Interface_EntityIterator Interface_InterfaceModel::Reports
849 (const Standard_Boolean semantic) const
851 Interface_EntityIterator iter;
853 TColStd_DataMapIteratorOfDataMapOfIntegerTransient itmap (therepch);
854 for (; itmap.More(); itmap.Next()) iter.AddItem (itmap.Value());
856 TColStd_DataMapIteratorOfDataMapOfIntegerTransient itmap (thereports);
857 for (; itmap.More(); itmap.Next()) iter.AddItem (itmap.Value());
863 //=======================================================================
864 //function : Redefineds
866 //=======================================================================
868 Interface_EntityIterator Interface_InterfaceModel::Redefineds () const
870 Interface_EntityIterator iter;
871 TColStd_DataMapIteratorOfDataMapOfIntegerTransient itmap (thereports);
872 for (; itmap.More(); itmap.Next()) {
873 Handle(Interface_ReportEntity) rep =
874 Handle(Interface_ReportEntity)::DownCast(itmap.Value());
875 if (rep.IsNull()) continue;
876 if (!rep->HasNewContent()) continue;
882 //#include <limits.h>
883 //#include <TColStd_MapTransientHasher.hxx>
886 //=======================================================================
887 //function : GlobalCheck
889 //=======================================================================
891 const Handle(Interface_Check)& Interface_InterfaceModel::GlobalCheck
892 (const Standard_Boolean syntactic) const
894 if (syntactic) return thecheckstx;
895 else return thechecksem;
899 //=======================================================================
900 //function : SetGlobalCheck
902 //=======================================================================
904 void Interface_InterfaceModel::SetGlobalCheck(const Handle(Interface_Check)& ach)
910 //=======================================================================
911 //function : VerifyCheck
913 //=======================================================================
915 void Interface_InterfaceModel::VerifyCheck (Handle(Interface_Check)& /*ach*/) const
920 //=======================================================================
923 //=======================================================================
925 void Interface_InterfaceModel::Print(const Handle(Standard_Transient)& ent,
926 const Handle(Message_Messenger)& S,
927 const Standard_Integer mode) const
929 if (ent.IsNull()) { S<<"NULL"; return; }
930 Standard_Integer num = Number(ent);
931 if (mode <= 0) S<<num;
932 if (mode == 0) S<<":";
936 // PrintLabel (ent,S);
942 //=======================================================================
943 //function : PrintToLog
945 //=======================================================================
947 void Interface_InterfaceModel::PrintToLog(const Handle(Standard_Transient)& ent,
948 const Handle(Message_Messenger)& S) const
954 // .... TEMPLATES .... //
957 //=======================================================================
958 //function : NextNumberForLabel
960 //=======================================================================
962 Standard_Integer Interface_InterfaceModel::NextNumberForLabel
963 (const Standard_CString label, const Standard_Integer fromnum,
964 const Standard_Boolean exact) const
966 Standard_Integer n = NbEntities();
967 Handle(TCollection_HAsciiString) labs = new TCollection_HAsciiString(label);
968 Standard_Integer lnb = labs->Length();
971 Standard_Integer i; // svv #1
972 for (i = fromnum+1; i <= n; i ++) {
973 Handle(TCollection_HAsciiString) lab = StringLabel (Value(i));
974 if (lab.IsNull()) continue;
976 if (lab->IsSameString(labs,Standard_False)) return i;
978 if (lab->Length() < lnb) continue;
980 if (lab->SearchFromEnd(labs) == lab->Length() - lnb + 1) return i;
984 // En "non exact", on admet de recevoir le numero entre 1 et n
987 if (labs->IsIntegerValue()) i = atoi (labs->ToCString());
988 if (i <= 0 || i > n) i = 0;
993 //=======================================================================
994 //function : HasTemplate
996 //=======================================================================
998 Standard_Boolean Interface_InterfaceModel::HasTemplate
999 (const Standard_CString name)
1001 return templates()->HasItem(name);
1005 //=======================================================================
1006 //function : Template
1008 //=======================================================================
1010 Handle(Interface_InterfaceModel) Interface_InterfaceModel::Template
1011 (const Standard_CString name)
1013 Handle(Interface_InterfaceModel) model,newmod;
1014 if (!HasTemplate(name)) return model;
1015 model = Handle(Interface_InterfaceModel)::DownCast(templates()->Item(name));
1016 newmod = model->NewEmptyModel();
1017 newmod->GetFromAnother (model);
1022 //=======================================================================
1023 //function : SetTemplate
1025 //=======================================================================
1027 Standard_Boolean Interface_InterfaceModel::SetTemplate
1028 (const Standard_CString name, const Handle(Interface_InterfaceModel)& model)
1030 Standard_Boolean deja;
1031 Handle(Standard_Transient)& newmod = templates()->NewItem(name,deja);
1037 //=======================================================================
1038 //function : ListTemplates
1040 //=======================================================================
1042 Handle(TColStd_HSequenceOfHAsciiString) Interface_InterfaceModel::ListTemplates ()
1044 Handle(TColStd_HSequenceOfHAsciiString) list = new
1045 TColStd_HSequenceOfHAsciiString();
1046 if (templates().IsNull()) return list;
1047 for (Dico_IteratorOfDictionaryOfTransient iter(templates());
1048 iter.More(); iter.Next()) {
1049 list->Append (new TCollection_HAsciiString (iter.Name()) );