1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <Interface_Check.hxx>
16 #include <Interface_EntityIterator.hxx>
17 #include <Interface_ShareTool.hxx>
18 #include <RWStepShape_RWEdgeLoop.hxx>
19 #include <StepData_StepReaderData.hxx>
20 #include <StepData_StepWriter.hxx>
21 #include <StepShape_EdgeLoop.hxx>
22 #include <StepShape_HArray1OfOrientedEdge.hxx>
23 #include <StepShape_OrientedEdge.hxx>
25 RWStepShape_RWEdgeLoop::RWStepShape_RWEdgeLoop () {}
27 void RWStepShape_RWEdgeLoop::ReadStep
28 (const Handle(StepData_StepReaderData)& data,
29 const Standard_Integer num,
30 Handle(Interface_Check)& ach,
31 const Handle(StepShape_EdgeLoop)& ent) const
35 // --- Number of Parameter Control ---
37 if (!data->CheckNbParams(num,2,ach,"edge_loop")) return;
39 // --- inherited field : name ---
41 Handle(TCollection_HAsciiString) aName;
42 //szv#4:S4163:12Mar99 `Standard_Boolean stat0 =` not needed
43 data->ReadString (num,1,"name",ach,aName);
45 // --- own field : edgeList ---
47 Handle(StepShape_HArray1OfOrientedEdge) aEdgeList;
48 Handle(StepShape_OrientedEdge) anent;
49 Standard_Integer nsub1;
50 if (data->ReadSubList (num,2,"edge_list",ach,nsub1)) {
51 Standard_Integer nb1 = data->NbParams(nsub1);
52 aEdgeList = new StepShape_HArray1OfOrientedEdge (1, nb1);
53 for (Standard_Integer i1 = 1; i1 <= nb1; i1 ++) {
54 //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
55 if (data->ReadEntity (nsub1, i1,"oriented_edge", ach, STANDARD_TYPE(StepShape_OrientedEdge), anent))
56 aEdgeList->SetValue(i1, anent);
60 //--- Initialisation of the read entity ---
62 ent->Init(aName, aEdgeList);
66 void RWStepShape_RWEdgeLoop::WriteStep
67 (StepData_StepWriter& SW,
68 const Handle(StepShape_EdgeLoop)& ent) const
71 // --- inherited field name ---
75 // --- own field : edgeList ---
78 for (Standard_Integer i1 = 1; i1 <= ent->NbEdgeList(); i1 ++) {
79 SW.Send(ent->EdgeListValue(i1));
84 // ============================================================================
86 // ============================================================================
88 void RWStepShape_RWEdgeLoop::Share(const Handle(StepShape_EdgeLoop)& ent, Interface_EntityIterator& iter) const
91 Standard_Integer nbElem1 = ent->NbEdgeList();
92 for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) {
93 iter.GetOneItem(ent->EdgeListValue(is1));
100 void RWStepShape_RWEdgeLoop::Check
101 (const Handle(StepShape_EdgeLoop)& ent,
102 const Interface_ShareTool& ,
103 Handle(Interface_Check)& ach) const
105 // std::cout << "------ calling CheckEdgeLoop ------" << std::endl;
106 Standard_Boolean headToTail = Standard_True;
107 //Standard_Boolean noIdentVtx = Standard_True; //szv#4:S4163:12Mar99 unused
108 Standard_Integer nbEdg = ent->NbEdgeList();
109 Handle(StepShape_OrientedEdge) theOE = ent->EdgeListValue(1);
110 Handle(StepShape_Vertex) theVxFrst = theOE->EdgeStart();
111 Handle(StepShape_Vertex) theVxLst = theOE->EdgeEnd();
112 if((nbEdg == 1) && (theVxFrst != theVxLst)){
113 ach->AddFail("Edge loop composed of single Edge : Start and End Vertex of edge are not identical");
115 for(Standard_Integer i = 2; i <= nbEdg; i++)
117 theOE = ent->EdgeListValue(i);
118 Handle(StepShape_Vertex) theVxStrt = theOE->EdgeStart();
119 if(theVxStrt != theVxLst){
120 headToTail = Standard_False;
122 theVxLst = theOE->EdgeEnd();
123 if(theVxStrt == theVxLst){
124 ach->AddWarning("One edge_curve contains identical vertices");
127 if(theVxFrst != theVxLst){
128 headToTail = Standard_False;
131 ach->AddFail("Error : Path does not head to tail");