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 <IGESGeom_Direction.hxx>
26 #include <IGESGeom_Point.hxx>
27 #include <IGESSolid_CylindricalSurface.hxx>
28 #include <IGESSolid_ToolCylindricalSurface.hxx>
29 #include <Interface_Check.hxx>
30 #include <Interface_CopyTool.hxx>
31 #include <Interface_EntityIterator.hxx>
32 #include <Interface_Macros.hxx>
33 #include <Interface_ShareTool.hxx>
34 #include <Message_Messenger.hxx>
35 #include <Standard_DomainError.hxx>
37 IGESSolid_ToolCylindricalSurface::IGESSolid_ToolCylindricalSurface () { }
40 void IGESSolid_ToolCylindricalSurface::ReadOwnParams
41 (const Handle(IGESSolid_CylindricalSurface)& ent,
42 const Handle(IGESData_IGESReaderData)& IR, IGESData_ParamReader& PR) const
44 Handle(IGESGeom_Point) tempLocation;
45 Handle(IGESGeom_Direction) tempAxis;
46 Handle(IGESGeom_Direction) tempRefdir; // default Unparametrised
47 Standard_Real tempRadius;
48 //Standard_Boolean st; //szv#4:S4163:12Mar99 not needed
50 PR.ReadEntity(IR, PR.Current(), "Point on axis",
51 STANDARD_TYPE(IGESGeom_Point), tempLocation); //szv#4:S4163:12Mar99 `st=` not needed
53 PR.ReadEntity(IR, PR.Current(), "Axis direction",
54 STANDARD_TYPE(IGESGeom_Direction), tempAxis); //szv#4:S4163:12Mar99 `st=` not needed
56 PR.ReadReal(PR.Current(), "Radius", tempRadius); //szv#4:S4163:12Mar99 `st=` not needed
58 if (ent->FormNumber() == 1) // Parametrised surface
59 PR.ReadEntity(IR, PR.Current(), "Reference direction",
60 STANDARD_TYPE(IGESGeom_Direction), tempRefdir); //szv#4:S4163:12Mar99 `st=` not needed
62 DirChecker(ent).CheckTypeAndForm(PR.CCheck(),ent);
63 ent->Init (tempLocation, tempAxis, tempRadius, tempRefdir);
66 void IGESSolid_ToolCylindricalSurface::WriteOwnParams
67 (const Handle(IGESSolid_CylindricalSurface)& ent, IGESData_IGESWriter& IW) const
69 IW.Send(ent->LocationPoint());
71 IW.Send(ent->Radius());
72 if (ent->IsParametrised()) IW.Send(ent->ReferenceDir());
75 void IGESSolid_ToolCylindricalSurface::OwnShared
76 (const Handle(IGESSolid_CylindricalSurface)& ent, Interface_EntityIterator& iter) const
78 iter.GetOneItem(ent->LocationPoint());
79 iter.GetOneItem(ent->Axis());
80 iter.GetOneItem(ent->ReferenceDir());
83 void IGESSolid_ToolCylindricalSurface::OwnCopy
84 (const Handle(IGESSolid_CylindricalSurface)& another,
85 const Handle(IGESSolid_CylindricalSurface)& ent, Interface_CopyTool& TC) const
87 Standard_Real tempRadius;
89 DeclareAndCast(IGESGeom_Point, tempLocation,
90 TC.Transferred(another->LocationPoint()));
91 DeclareAndCast(IGESGeom_Direction, tempAxis,
92 TC.Transferred(another->Axis()));
93 tempRadius = another->Radius();
94 if (another->IsParametrised())
96 DeclareAndCast(IGESGeom_Direction, tempRefdir,
97 TC.Transferred(another->ReferenceDir()));
98 ent->Init (tempLocation, tempAxis, tempRadius, tempRefdir);
102 Handle(IGESGeom_Direction) tempRefdir;
103 ent->Init (tempLocation, tempAxis, tempRadius, tempRefdir);
108 IGESData_DirChecker IGESSolid_ToolCylindricalSurface::DirChecker
109 (const Handle(IGESSolid_CylindricalSurface)& /*ent*/) const
111 IGESData_DirChecker DC(192, 0, 1);
113 DC.Structure (IGESData_DefVoid);
114 DC.LineFont (IGESData_DefAny);
115 DC.Color (IGESData_DefAny);
117 DC.BlankStatusIgnored ();
118 DC.SubordinateStatusRequired (1);
119 DC.HierarchyStatusIgnored ();
123 void IGESSolid_ToolCylindricalSurface::OwnCheck
124 (const Handle(IGESSolid_CylindricalSurface)& ent,
125 const Interface_ShareTool& , Handle(Interface_Check)& ach) const
127 if (ent->Radius() <= 0.0)
128 ach->AddFail("Radius : Value <= 0.0");
129 Standard_Integer fn = 0;
130 if (ent->IsParametrised()) fn = 1;
131 if (fn != ent->FormNumber()) ach->AddFail
132 ("Parametrised Status Mismatches with Form Number");
135 void IGESSolid_ToolCylindricalSurface::OwnDump
136 (const Handle(IGESSolid_CylindricalSurface)& ent, const IGESData_IGESDumper& dumper,
137 const Handle(Message_Messenger)& S, const Standard_Integer level) const
139 S << "IGESSolid_CylindricalSurface" << Message_EndLine;
141 Standard_Integer sublevel = (level <= 4) ? 0 : 1;
142 S << "Point on axis : ";
143 dumper.Dump(ent->LocationPoint(),S, sublevel);
144 S << Message_EndLine;
145 S << "Axis direction : ";
146 dumper.Dump(ent->Axis(),S, sublevel);
147 S << Message_EndLine;
148 S << "Radius : " << ent->Radius() << Message_EndLine;
149 if (ent->IsParametrised())
151 S << "Surface is Parametrised - Reference direction : ";
152 dumper.Dump(ent->ReferenceDir(),S, sublevel);
153 S << Message_EndLine;
155 else S << "Surface is UnParametrised" << Message_EndLine;