1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
19 #include <IGESData_DirChecker.hxx>
20 #include <IGESData_IGESDumper.hxx>
21 #include <IGESData_IGESReaderData.hxx>
22 #include <IGESData_IGESWriter.hxx>
23 #include <IGESData_ParamCursor.hxx>
24 #include <IGESData_ParamReader.hxx>
25 #include <IGESDimen_GeneralNote.hxx>
26 #include <IGESDimen_LeaderArrow.hxx>
27 #include <IGESDimen_OrdinateDimension.hxx>
28 #include <IGESDimen_ToolOrdinateDimension.hxx>
29 #include <IGESDimen_WitnessLine.hxx>
30 #include <Interface_Check.hxx>
31 #include <Interface_CopyTool.hxx>
32 #include <Interface_EntityIterator.hxx>
33 #include <Interface_Macros.hxx>
34 #include <Interface_ShareTool.hxx>
35 #include <Message_Messenger.hxx>
36 #include <Standard_DomainError.hxx>
38 IGESDimen_ToolOrdinateDimension::IGESDimen_ToolOrdinateDimension () { }
41 void IGESDimen_ToolOrdinateDimension::ReadOwnParams
42 (const Handle(IGESDimen_OrdinateDimension)& theEnt,
43 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
45 Handle(IGESDimen_GeneralNote) tempNote;
46 Handle(IGESDimen_WitnessLine) witLine;
47 Handle(IGESDimen_LeaderArrow) leadArr;
48 Standard_Boolean isLine=Standard_False;
50 PR.ReadEntity(IR,PR.Current(),"General Note",
51 STANDARD_TYPE(IGESDimen_GeneralNote),tempNote);
53 if (theEnt->FormNumber() == 0)
55 Handle(IGESData_IGESEntity) ent;
56 if (!PR.ReadEntity(IR,PR.Current(),"Line or Leader", ent)) { } // WARNING : Two possible Types allowed :
57 else if (ent->IsKind(STANDARD_TYPE(IGESDimen_WitnessLine)))
59 witLine = GetCasted(IGESDimen_WitnessLine,ent);
60 isLine = Standard_True;
62 else if (ent->IsKind(STANDARD_TYPE(IGESDimen_LeaderArrow)))
64 leadArr = GetCasted(IGESDimen_LeaderArrow,ent);
65 isLine = Standard_False;
67 else PR.AddFail("Line or Leader : Type is incorrect");
71 PR.ReadEntity(IR, PR.Current(), "Line",
72 STANDARD_TYPE(IGESDimen_WitnessLine), witLine);
73 PR.ReadEntity(IR, PR.Current(), "Leader",
74 STANDARD_TYPE(IGESDimen_LeaderArrow), leadArr);
77 DirChecker(theEnt).CheckTypeAndForm(PR.CCheck(), theEnt);
78 theEnt->Init ( tempNote, isLine, witLine, leadArr);
81 void IGESDimen_ToolOrdinateDimension::WriteOwnParams
82 (const Handle(IGESDimen_OrdinateDimension)& ent, IGESData_IGESWriter& IW) const
85 if (ent->FormNumber() == 0) // either WitnessLine or LeaderArrow
88 IW.Send(ent->WitnessLine());
90 IW.Send(ent->Leader());
92 else // both WitnessLine and LeaderArrow
94 IW.Send(ent->WitnessLine());
95 IW.Send(ent->Leader());
99 void IGESDimen_ToolOrdinateDimension::OwnShared
100 (const Handle(IGESDimen_OrdinateDimension)& ent, Interface_EntityIterator& iter) const
102 iter.GetOneItem(ent->Note());
103 iter.GetOneItem(ent->WitnessLine());
104 iter.GetOneItem(ent->Leader());
107 void IGESDimen_ToolOrdinateDimension::OwnCopy
108 (const Handle(IGESDimen_OrdinateDimension)& another,
109 const Handle(IGESDimen_OrdinateDimension)& ent, Interface_CopyTool& TC) const
111 DeclareAndCast(IGESDimen_GeneralNote, tempNote,
112 TC.Transferred(another->Note()));
113 DeclareAndCast(IGESDimen_WitnessLine, witLine,
114 TC.Transferred(another->WitnessLine()));
115 DeclareAndCast(IGESDimen_LeaderArrow, leadArr,
116 TC.Transferred(another->Leader()));
117 ent->Init(tempNote, another->IsLine(), witLine, leadArr);
120 IGESData_DirChecker IGESDimen_ToolOrdinateDimension::DirChecker
121 (const Handle(IGESDimen_OrdinateDimension)& /*ent*/) const
123 IGESData_DirChecker DC(218, 0, 1);
124 DC.Structure(IGESData_DefVoid);
125 DC.LineFont(IGESData_DefAny);
126 DC.LineWeight(IGESData_DefValue);
127 DC.Color(IGESData_DefAny);
129 DC.UseFlagRequired (1);
134 void IGESDimen_ToolOrdinateDimension::OwnCheck
135 (const Handle(IGESDimen_OrdinateDimension)& ent,
136 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
138 Standard_Boolean nowitnes = ent->WitnessLine().IsNull();
139 Standard_Boolean noleader = ent->Leader().IsNull();
140 if (nowitnes && noleader) ach->AddFail
141 ("Neither WitnessLine nor LeaderArrow is defined");
142 else if (ent->FormNumber() == 0) {
143 if (!nowitnes && !noleader) ach->AddFail
144 ("Form 0 cannot afford both WitnessLine and LeaderArrow");
147 if (nowitnes || noleader) ach->AddFail
148 ("Form 1 requires both WtnessLine and LeaderArrow");
152 void IGESDimen_ToolOrdinateDimension::OwnDump
153 (const Handle(IGESDimen_OrdinateDimension)& ent, const IGESData_IGESDumper& dumper,
154 const Handle(Message_Messenger)& S, const Standard_Integer level) const
156 S << "IGESDimen_OrdinateDimension" << endl;
157 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
159 S << "General Note : ";
160 dumper.Dump(ent->Note(),S, sublevel);
162 Handle(IGESDimen_WitnessLine) witLine = ent->WitnessLine();
163 Handle(IGESDimen_LeaderArrow) leadArr = ent->Leader();
164 if (!witLine.IsNull()) {
165 S << "Witness line : ";
166 dumper.Dump(witLine,S, sublevel);
169 if (!leadArr.IsNull()) {
170 S << "Leader arrow :";
171 dumper.Dump(leadArr,S, sublevel);