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 <gp_Pnt2d.hxx>
21 #include <IGESData_DirChecker.hxx>
22 #include <IGESData_Dump.hxx>
23 #include <IGESData_IGESDumper.hxx>
24 #include <IGESData_IGESReaderData.hxx>
25 #include <IGESData_IGESWriter.hxx>
26 #include <IGESData_ParamCursor.hxx>
27 #include <IGESData_ParamReader.hxx>
28 #include <IGESDimen_LeaderArrow.hxx>
29 #include <IGESDimen_ToolLeaderArrow.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 <Standard_DomainError.hxx>
36 #include <TColgp_HArray1OfXY.hxx>
38 IGESDimen_ToolLeaderArrow::IGESDimen_ToolLeaderArrow () { }
41 void IGESDimen_ToolLeaderArrow::ReadOwnParams
42 (const Handle(IGESDimen_LeaderArrow)& ent,
43 const Handle(IGESData_IGESReaderData)& /* IR */, IGESData_ParamReader& PR) const
45 //Standard_Boolean st; //szv#4:S4163:12Mar99 moved down
47 Standard_Real arrowHeadHeight;
48 Standard_Real arrowHeadWidth;
51 Handle(TColgp_HArray1OfXY) segmentTails;
52 Standard_Integer nbval;
54 Standard_Boolean st = PR.ReadInteger( PR.Current(), "Count of Segments", nbval);
56 segmentTails = new TColgp_HArray1OfXY(1,nbval);
57 else PR.AddFail("Count of Segments: Not Positive");
59 //szv#4:S4163:12Mar99 `st=` not needed
60 PR.ReadReal(PR.Current(), "Arrow Head Height", arrowHeadHeight);
61 PR.ReadReal(PR.Current(), "Arrow Head Width", arrowHeadWidth);
62 PR.ReadReal(PR.Current(), "Z Depth", zDepth);
63 PR.ReadXY(PR.CurrentList(1, 2), "Arrow Head Position", arrowHead);
65 if (! segmentTails.IsNull())
67 for (Standard_Integer i = 1; i <= nbval; i++)
70 //st = PR.ReadXY(PR.CurrentList(1, 2), "Segment Co-ords.", tempXY); //szv#4:S4163:12Mar99 moved in if
71 if (PR.ReadXY(PR.CurrentList(1, 2), "Segment Co-ords.", tempXY))
72 segmentTails->SetValue(i, tempXY);
74 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
75 ent->Init (arrowHeadHeight, arrowHeadWidth, zDepth, arrowHead, segmentTails);
76 } //segmentTails.IsNull() crash in ent->Init( ...
80 void IGESDimen_ToolLeaderArrow::WriteOwnParams
81 (const Handle(IGESDimen_LeaderArrow)& ent, IGESData_IGESWriter& IW) const
83 Standard_Integer upper = ent->NbSegments();
85 IW.Send(ent->ArrowHeadHeight());
86 IW.Send(ent->ArrowHeadWidth());
87 IW.Send(ent->ZDepth());
88 IW.Send(ent->ArrowHead().X());
89 IW.Send(ent->ArrowHead().Y());
90 for (Standard_Integer i = 1; i <= upper; i++)
92 IW.Send((ent->SegmentTail(i)).X());
93 IW.Send((ent->SegmentTail(i)).Y());
97 void IGESDimen_ToolLeaderArrow::OwnShared
98 (const Handle(IGESDimen_LeaderArrow)& /* ent */, Interface_EntityIterator& /* iter */) const
102 void IGESDimen_ToolLeaderArrow::OwnCopy
103 (const Handle(IGESDimen_LeaderArrow)& another,
104 const Handle(IGESDimen_LeaderArrow)& ent, Interface_CopyTool& /* TC */) const
106 Standard_Integer nbval = another->NbSegments();
107 Standard_Real arrowHeadHeight = another->ArrowHeadHeight();
108 Standard_Real arrowHeadWidth = another->ArrowHeadWidth();
109 Standard_Real zDepth = another->ZDepth();
110 gp_XY arrowHead = another->ArrowHead().XY();
112 Handle(TColgp_HArray1OfXY) segmentTails = new TColgp_HArray1OfXY(1, nbval);
114 for (Standard_Integer i = 1; i <= nbval; i++)
116 segmentTails->SetValue(i, (another->SegmentTail(i)).XY());
119 ent->Init(arrowHeadHeight, arrowHeadWidth, zDepth, arrowHead, segmentTails);
120 ent->SetFormNumber (another->FormNumber());
123 IGESData_DirChecker IGESDimen_ToolLeaderArrow::DirChecker
124 (const Handle(IGESDimen_LeaderArrow)& /* ent */ ) const
126 IGESData_DirChecker DC (214, 1, 12);
127 DC.Structure(IGESData_DefVoid);
128 DC.LineFont(IGESData_DefAny);
129 DC.LineWeight(IGESData_DefValue);
130 DC.Color(IGESData_DefAny);
131 DC.UseFlagRequired(1);
132 DC.HierarchyStatusIgnored();
136 void IGESDimen_ToolLeaderArrow::OwnCheck
137 (const Handle(IGESDimen_LeaderArrow)& /* ent */,
138 const Interface_ShareTool& , Handle(Interface_Check)& /* ach */) const
142 void IGESDimen_ToolLeaderArrow::OwnDump
143 (const Handle(IGESDimen_LeaderArrow)& ent, const IGESData_IGESDumper& /* dumper */,
144 Standard_OStream& S, const Standard_Integer level) const
146 S << "IGESDimen_LeaderArrow\n"
147 << "Number of Segments : " << ent->NbSegments() << "\n"
148 << "Arrowhead Height : " << ent->ArrowHeadHeight() << "\n"
149 << "Arrowhead Width : " << ent->ArrowHeadWidth() << "\n"
150 << "Z depth : " << ent->ZDepth() << "\n"
151 << "Arrowhead co-ords : ";
152 IGESData_DumpXYLZ(S,level,ent->ArrowHead(),ent->Location(),ent->ZDepth());
153 S << "\nSegment Tails : ";
154 IGESData_DumpListXYLZ(S,level,1, ent->NbSegments(),ent->SegmentTail,
155 ent->Location(), ent->ZDepth());