// Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #include #include #include #include #include #include #include #include #include #include IMPLEMENT_STANDARD_RTTIEXT(IFSelect_SignatureList,MMgt_TShared) IFSelect_SignatureList::IFSelect_SignatureList (const Standard_Boolean withlist) { thesignonly = Standard_False; thelistat = withlist; thenbnuls = 0; SetName("..."); } void IFSelect_SignatureList::SetList (const Standard_Boolean withlist) { thelistat = withlist; } Standard_Boolean& IFSelect_SignatureList::ModeSignOnly () { return thesignonly; } void IFSelect_SignatureList::Clear () { thelastval.Clear(); thenbnuls = 0; thedicount.Clear(); thediclist.Clear(); } void IFSelect_SignatureList::Add (const Handle(Standard_Transient)& ent, const Standard_CString sign) { if (thesignonly) { thelastval.Clear(); thelastval.AssignCat (sign); return; } if (sign[0] == '\0') { thenbnuls ++; return; } if (thedicount.Contains(sign)) thedicount.ChangeFromKey(sign)++; else thedicount.Add(sign, 1); if (thelistat) { Handle(TColStd_HSequenceOfTransient) alist; if (thediclist.Contains(sign)) alist = Handle(TColStd_HSequenceOfTransient)::DownCast(thediclist.FindFromKey(sign)); else { alist = new TColStd_HSequenceOfTransient(); thediclist.Add(sign, alist); } alist->Append(ent); } } Standard_CString IFSelect_SignatureList::LastValue () const { return thelastval.ToCString(); } void IFSelect_SignatureList::Init (const Standard_CString name, const NCollection_IndexedDataMap& theCount, const NCollection_IndexedDataMap& list, const Standard_Integer nbnuls) { thelastval.Clear(); thename = new TCollection_HAsciiString (name); thedicount = theCount; thediclist = list; thenbnuls = nbnuls; if (thediclist.IsEmpty()) thelistat = Standard_False; } Handle(TColStd_HSequenceOfHAsciiString) IFSelect_SignatureList::List (const Standard_CString root) const { Handle(TColStd_HSequenceOfHAsciiString) list = new TColStd_HSequenceOfHAsciiString(); NCollection_IndexedDataMap::Iterator iter(thedicount); for (; iter.More(); iter.Next()) { if (!iter.Key().StartsWith(root)) continue; Handle(TCollection_HAsciiString) sign = new TCollection_HAsciiString (iter.Key()); list->Append(sign); } return list; } Standard_Boolean IFSelect_SignatureList::HasEntities () const { return thelistat; } Standard_Integer IFSelect_SignatureList::NbNulls () const { return thenbnuls; } Standard_Integer IFSelect_SignatureList::NbTimes (const Standard_CString sign) const { Standard_Integer nb = 0; thedicount.FindFromKey(sign, nb); return nb; } Handle(TColStd_HSequenceOfTransient) IFSelect_SignatureList::Entities (const Standard_CString sign) const { Handle(TColStd_HSequenceOfTransient) list; Handle(Standard_Transient) aTList; if (!thelistat) return list; if (thediclist.FindFromKey(sign, aTList)) list = Handle(TColStd_HSequenceOfTransient)::DownCast(aTList); else list = new TColStd_HSequenceOfTransient(); return list; } void IFSelect_SignatureList::SetName (const Standard_CString name) { thename = new TCollection_HAsciiString (name); } Standard_CString IFSelect_SignatureList::Name () const { return thename->ToCString(); } void IFSelect_SignatureList::PrintCount (const Handle(Message_Messenger)& S) const { Standard_Integer nbtot = 0, nbsign = 0; NCollection_IndexedDataMap::Iterator iter(thedicount); S << " Count "<ToCString()<<"\n ----- -----------"< 0) S << thename->ToCString()<< " Nul : " << thenbnuls<::Iterator iter(thediclist); for (; iter.More(); iter.Next()) { DeclareAndCast(TColStd_HSequenceOfTransient,list,iter.Value()); S<Length(); S<<" - Nb: "< 5 && mod == IFSelect_ShortByItem) nc = 5; for (Standard_Integer i = 1; i <= nc; i ++) { if (list->Value(i).IsNull()) { S<<" 0"; if (mod == IFSelect_EntitiesByItem) S<<":(Global)"; continue; } Standard_Integer num = model->Number(list->Value(i)); if (num == IFSelect_ShortByItem) { S<<" ??"; continue; } S<<" "<PrintLabel(list->Value(i),S); } } if (nc < nb) S<<" .. etc"; S<::Iterator iter(thedicount); S << " Summary "<ToCString()<<"\n ----- -----------"< maxent) maxent = nbent; TCollection_AsciiString name = iter.Key(); // if (!name.IsIntegerValue()) continue; pas bien fiable Standard_Integer ic, nc = name.Length(); Standard_Boolean iaint = Standard_True; for (ic = 1; ic <= nc; ic ++) { char unc = name.Value(ic); if (ic == 1 && (unc == ' ' || unc == '+' || unc == '-')) continue; if (unc >= '0' && unc <= '9') continue; iaint = Standard_False; break; } if (!iaint) continue; Standard_Integer val = name.IntegerValue(); if (nbval == 0) { minval = maxval = val; } if (minval > val) minval = val; if (maxval < val) maxval = val; nbval ++; nbve += nbent; totval += (val*nbent); } S << " Nb Total:"< 0) { S<<" Summary on Integer Values"<