0027104: DownCast() cannot return null for mismatched handle
[occt.git] / src / IGESSelect / IGESSelect_SignLevelNumber.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
42cf5bc1 14
7fd59977 15#include <IGESData_IGESEntity.hxx>
16#include <IGESGraph_DefinitionLevel.hxx>
42cf5bc1 17#include <IGESSelect_SignLevelNumber.hxx>
18#include <Interface_InterfaceModel.hxx>
7fd59977 19#include <Interface_Macros.hxx>
42cf5bc1 20#include <Standard_Transient.hxx>
21#include <Standard_Type.hxx>
22#include <TCollection_AsciiString.hxx>
7fd59977 23
42cf5bc1 24#include <stdio.h>
92efcf78 25IMPLEMENT_STANDARD_RTTIEXT(IGESSelect_SignLevelNumber,IFSelect_Signature)
26
7fd59977 27static TCollection_AsciiString laval;
28
29
30 IGESSelect_SignLevelNumber::IGESSelect_SignLevelNumber
31 (const Standard_Boolean countmode)
32 : IFSelect_Signature ("Level Number") ,
33 thecountmode (countmode) { }
34
35 Standard_CString IGESSelect_SignLevelNumber::Value
36 (const Handle(Standard_Transient)& ent,
37 const Handle(Interface_InterfaceModel)& /* model */) const
38{
39 char carlev[20];
40 DeclareAndCast(IGESData_IGESEntity,igesent,ent);
41//JR/Hp
42 if (igesent.IsNull()) {
43 Standard_CString astr ;
44 astr = (Standard_CString ) (thecountmode ? " NO LEVEL" : "/0/");
45 return astr ;
46 }
47// if (igesent.IsNull()) return (thecountmode ? " NO LEVEL" : "/0/");
48 DeclareAndCast(IGESGraph_DefinitionLevel,levelist,igesent->LevelList());
49 Standard_Integer level = igesent->Level();
50
51 if (levelist.IsNull()) {
52//JR/Hp
53 if (level < 0) {
54 Standard_CString astr ;
55 astr = (Standard_CString ) (thecountmode ? " NO LEVEL" : "/0/") ;
56 return astr ;
57 }
58// if (level < 0) return (thecountmode ? " NO LEVEL" : "/0/");
59 laval.Clear();
60 if (thecountmode) sprintf (carlev,"%7d",level);
61 else sprintf (carlev,"/%d/",level);
62 laval.AssignCat (carlev);
63 }
64 else if (thecountmode) return "LEVEL LIST";
65 else {
66 Standard_Integer i, nblev = levelist->NbLevelNumbers();
67 laval.Clear();
68 laval.AssignCat("LIST:/");
69 for (i = 1; i <= nblev; i ++) {
70 sprintf(carlev,"%d/",levelist->LevelNumber(i));
71 laval.AssignCat(carlev);
72 }
73 }
74 return laval.ToCString();
75}