| 1 | // Created by: CKY / Contract Toubro-Larsen |
| 2 | // Copyright (c) 1993-1999 Matra Datavision |
| 3 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
| 4 | // |
| 5 | // This file is part of Open CASCADE Technology software library. |
| 6 | // |
| 7 | // This library is free software; you can redistribute it and/or modify it under |
| 8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
| 9 | // by the Free Software Foundation, with special exception defined in the file |
| 10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
| 11 | // distribution for complete text of the license and disclaimer of any warranty. |
| 12 | // |
| 13 | // Alternatively, this file may be used under the terms of Open CASCADE |
| 14 | // commercial license or contractual agreement. |
| 15 | |
| 16 | //-------------------------------------------------------------------- |
| 17 | //-------------------------------------------------------------------- |
| 18 | |
| 19 | #include <IGESAppli_LineWidening.hxx> |
| 20 | #include <IGESAppli_ToolLineWidening.hxx> |
| 21 | #include <IGESData_DirChecker.hxx> |
| 22 | #include <IGESData_IGESDumper.hxx> |
| 23 | #include <IGESData_IGESReaderData.hxx> |
| 24 | #include <IGESData_IGESWriter.hxx> |
| 25 | #include <IGESData_LevelListEntity.hxx> |
| 26 | #include <IGESData_ParamCursor.hxx> |
| 27 | #include <IGESData_ParamReader.hxx> |
| 28 | #include <Interface_Check.hxx> |
| 29 | #include <Interface_CopyTool.hxx> |
| 30 | #include <Interface_EntityIterator.hxx> |
| 31 | #include <Interface_ShareTool.hxx> |
| 32 | #include <Message_Messenger.hxx> |
| 33 | #include <Standard_DomainError.hxx> |
| 34 | |
| 35 | IGESAppli_ToolLineWidening::IGESAppli_ToolLineWidening () { } |
| 36 | |
| 37 | |
| 38 | void IGESAppli_ToolLineWidening::ReadOwnParams |
| 39 | (const Handle(IGESAppli_LineWidening)& ent, |
| 40 | const Handle(IGESData_IGESReaderData)& /*IR*/, IGESData_ParamReader& PR) const |
| 41 | { |
| 42 | Standard_Integer tempNbPropertyValues; |
| 43 | Standard_Real tempWidth; |
| 44 | Standard_Integer tempCorneringCode; |
| 45 | Standard_Integer tempExtensionFlag; |
| 46 | Standard_Integer tempJustificationFlag; |
| 47 | Standard_Real tempExtensionValue = 0.; |
| 48 | //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed |
| 49 | |
| 50 | //szv#4:S4163:12Mar99 `st=` not needed |
| 51 | PR.ReadInteger(PR.Current(),"No. of Property values",tempNbPropertyValues); |
| 52 | PR.ReadReal(PR.Current(),"Width of metalization",tempWidth); |
| 53 | PR.ReadInteger(PR.Current(),"Cornering code",tempCorneringCode); |
| 54 | PR.ReadInteger(PR.Current(),"Extension Flag",tempExtensionFlag); |
| 55 | PR.ReadInteger(PR.Current(),"Justification Flag",tempJustificationFlag); |
| 56 | if (PR.IsParamDefined(PR.CurrentNumber())) |
| 57 | PR.ReadReal(PR.Current(),"Extension value",tempExtensionValue); |
| 58 | else if (tempExtensionFlag == 2) |
| 59 | PR.AddFail("Extension Value not defined while Extension Flag = 2"); |
| 60 | |
| 61 | DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent); |
| 62 | ent->Init(tempNbPropertyValues,tempWidth,tempCorneringCode,tempExtensionFlag, |
| 63 | tempJustificationFlag,tempExtensionValue); |
| 64 | } |
| 65 | |
| 66 | void IGESAppli_ToolLineWidening::WriteOwnParams |
| 67 | (const Handle(IGESAppli_LineWidening)& ent, IGESData_IGESWriter& IW) const |
| 68 | { |
| 69 | IW.Send(ent->NbPropertyValues()); |
| 70 | IW.Send(ent->WidthOfMetalization()); |
| 71 | IW.Send(ent->CorneringCode()); |
| 72 | IW.Send(ent->ExtensionFlag()); |
| 73 | IW.Send(ent->JustificationFlag()); |
| 74 | IW.Send(ent->ExtensionValue()); |
| 75 | } |
| 76 | |
| 77 | void IGESAppli_ToolLineWidening::OwnShared |
| 78 | (const Handle(IGESAppli_LineWidening)& /*ent*/, Interface_EntityIterator& /*iter*/) const |
| 79 | { |
| 80 | } |
| 81 | |
| 82 | void IGESAppli_ToolLineWidening::OwnCopy |
| 83 | (const Handle(IGESAppli_LineWidening)& another, |
| 84 | const Handle(IGESAppli_LineWidening)& ent, Interface_CopyTool& /*TC*/) const |
| 85 | { |
| 86 | ent->Init |
| 87 | (5,another->WidthOfMetalization(),another->CorneringCode(), |
| 88 | another->ExtensionFlag(),another->JustificationFlag(), |
| 89 | another->ExtensionValue()); |
| 90 | } |
| 91 | |
| 92 | Standard_Boolean IGESAppli_ToolLineWidening::OwnCorrect |
| 93 | (const Handle(IGESAppli_LineWidening)& ent) const |
| 94 | { |
| 95 | Standard_Boolean res = (ent->NbPropertyValues() != 5); |
| 96 | if (res) ent->Init |
| 97 | (5,ent->WidthOfMetalization(),ent->CorneringCode(),ent->ExtensionFlag(), |
| 98 | ent->JustificationFlag(),ent->ExtensionValue()); |
| 99 | if (ent->SubordinateStatus() != 0) { |
| 100 | Handle(IGESData_LevelListEntity) nulevel; |
| 101 | ent->InitLevel(nulevel,0); |
| 102 | res = Standard_True; |
| 103 | } |
| 104 | return res; // nbpropertyvalues = 5 + RAZ level selon subordinate |
| 105 | } |
| 106 | |
| 107 | IGESData_DirChecker IGESAppli_ToolLineWidening::DirChecker |
| 108 | (const Handle(IGESAppli_LineWidening)& /*ent*/ ) const |
| 109 | { |
| 110 | IGESData_DirChecker DC(406,5); //Form no = 5 & Type = 406 |
| 111 | DC.Structure(IGESData_DefVoid); |
| 112 | DC.GraphicsIgnored(); |
| 113 | DC.BlankStatusIgnored(); |
| 114 | DC.UseFlagIgnored(); |
| 115 | DC.HierarchyStatusIgnored(); |
| 116 | return DC; |
| 117 | } |
| 118 | |
| 119 | void IGESAppli_ToolLineWidening::OwnCheck |
| 120 | (const Handle(IGESAppli_LineWidening)& ent, |
| 121 | const Interface_ShareTool& , Handle(Interface_Check)& ach) const |
| 122 | { |
| 123 | if (ent->SubordinateStatus() != 0) |
| 124 | if (ent->DefLevel() == IGESData_DefOne || |
| 125 | ent->DefLevel() == IGESData_DefSeveral) |
| 126 | ach->AddWarning("Level type: defined while ignored"); |
| 127 | if (ent->NbPropertyValues() != 5) |
| 128 | ach->AddFail("Number of Property Values != 5"); |
| 129 | if (ent->CorneringCode() != 0 && ent->CorneringCode() != 1) |
| 130 | ach->AddFail("Cornering Code incorrect"); |
| 131 | if (ent->ExtensionFlag() < 0 || ent->ExtensionFlag() > 2) |
| 132 | ach->AddFail("Extension Flag value incorrect"); |
| 133 | if (ent->JustificationFlag() < 0 || ent->JustificationFlag() > 2) |
| 134 | ach->AddFail("Justification Flag value incorrect"); |
| 135 | } |
| 136 | |
| 137 | void IGESAppli_ToolLineWidening::OwnDump |
| 138 | (const Handle(IGESAppli_LineWidening)& ent, const IGESData_IGESDumper& /*dumper*/, |
| 139 | const Handle(Message_Messenger)& S, const Standard_Integer /*level*/) const |
| 140 | { |
| 141 | S << "IGESAppli_LineWidening" << endl; |
| 142 | |
| 143 | S << "Number of property values : " << ent->NbPropertyValues() << endl; |
| 144 | S << "Width of metalization : " << ent->WidthOfMetalization() << endl; |
| 145 | S << "Cornering Code : " ; |
| 146 | if (ent->CorneringCode() == 0) S << "0 (rounded)" << endl; |
| 147 | else if (ent->CorneringCode() == 1) S << "1 (squared)" << endl; |
| 148 | else S << "incorrect value" << endl; |
| 149 | |
| 150 | S << "Extension Flag : " ; |
| 151 | if (ent->ExtensionFlag() == 0) S << "0 (No Extension)" << endl; |
| 152 | else if (ent->ExtensionFlag() == 1) S << "1 (One-half width extension)" << endl; |
| 153 | else if (ent->ExtensionFlag() == 2) S << "2 (Extension set by ExtensionValue)" << endl; |
| 154 | else S << "incorrect value" << endl; |
| 155 | |
| 156 | S << "Justification Flag : " ; |
| 157 | if (ent->JustificationFlag() == 0) |
| 158 | S << "0 (Centre justified)" << endl; |
| 159 | else if (ent->JustificationFlag() == 1) |
| 160 | S << "1 (left justified)" << endl; |
| 161 | else if (ent->JustificationFlag() == 2) |
| 162 | S << "2 (right justified)" << endl; |
| 163 | else |
| 164 | S << "incorrect value" << endl; |
| 165 | |
| 166 | if (ent->ExtensionFlag() == 2) |
| 167 | S << "Extension Value : " << ent->ExtensionValue() << endl; |
| 168 | else |
| 169 | S << "No Extension Value (Extension Flag != 2)" << endl; |
| 170 | } |
| 171 | |