0023022: This is desirable to access OpenGl extensions and core API (1.2+) in one...
[occt.git] / src / RWStepShape / RWStepShape_RWEdgeLoop.cxx
1
2 #include <RWStepShape_RWEdgeLoop.ixx>
3
4 #include <StepShape_HArray1OfOrientedEdge.hxx>
5 #include <StepShape_OrientedEdge.hxx>
6
7 RWStepShape_RWEdgeLoop::RWStepShape_RWEdgeLoop () {}
8
9 void RWStepShape_RWEdgeLoop::ReadStep
10 (const Handle(StepData_StepReaderData)& data,
11  const Standard_Integer num,
12  Handle(Interface_Check)& ach,
13  const Handle(StepShape_EdgeLoop)& ent) const
14 {
15   
16   
17   // --- Number of Parameter Control ---
18   
19   if (!data->CheckNbParams(num,2,ach,"edge_loop")) return;
20   
21   // --- inherited field : name ---
22   
23   Handle(TCollection_HAsciiString) aName;
24   //szv#4:S4163:12Mar99 `Standard_Boolean stat0 =` not needed
25   data->ReadString (num,1,"name",ach,aName);
26   
27   // --- own field : edgeList ---
28   
29   Handle(StepShape_HArray1OfOrientedEdge) aEdgeList;
30   Handle(StepShape_OrientedEdge) anent;
31   Standard_Integer nsub1;
32   if (data->ReadSubList (num,2,"edge_list",ach,nsub1)) {
33     Standard_Integer nb1 = data->NbParams(nsub1);
34     aEdgeList = new StepShape_HArray1OfOrientedEdge (1, nb1);
35     for (Standard_Integer i1 = 1; i1 <= nb1; i1 ++) {
36       //szv#4:S4163:12Mar99 `Standard_Boolean stat1 =` not needed
37       if (data->ReadEntity (nsub1, i1,"oriented_edge", ach, STANDARD_TYPE(StepShape_OrientedEdge), anent))
38         aEdgeList->SetValue(i1, anent);
39     }
40   }
41   
42   //--- Initialisation of the read entity ---
43   
44   ent->Init(aName, aEdgeList);
45 }
46
47
48 void RWStepShape_RWEdgeLoop::WriteStep
49         (StepData_StepWriter& SW,
50          const Handle(StepShape_EdgeLoop)& ent) const
51 {
52   
53   // --- inherited field name ---
54   
55   SW.Send(ent->Name());
56   
57   // --- own field : edgeList ---
58   
59   SW.OpenSub();
60   for (Standard_Integer i1 = 1;  i1 <= ent->NbEdgeList();  i1 ++) {
61     SW.Send(ent->EdgeListValue(i1));
62   }
63   SW.CloseSub();
64 }
65
66 // ============================================================================
67 // Method : Share
68 // ============================================================================
69
70 void RWStepShape_RWEdgeLoop::Share(const Handle(StepShape_EdgeLoop)& ent, Interface_EntityIterator& iter) const
71 {
72
73         Standard_Integer nbElem1 = ent->NbEdgeList();
74         for (Standard_Integer is1=1; is1<=nbElem1; is1 ++) {
75           iter.GetOneItem(ent->EdgeListValue(is1));
76         }
77
78 }
79
80
81
82 void RWStepShape_RWEdgeLoop::Check
83   (const Handle(StepShape_EdgeLoop)& ent,
84    const Interface_ShareTool& ,
85    Handle(Interface_Check)& ach) const
86 {
87 //  cout << "------ calling CheckEdgeLoop ------" << endl;
88   Standard_Boolean headToTail = Standard_True;
89   //Standard_Boolean noIdentVtx = Standard_True; //szv#4:S4163:12Mar99 unused
90   Standard_Integer nbEdg = ent->NbEdgeList();
91   Handle(StepShape_OrientedEdge) theOE = ent->EdgeListValue(1);
92   Handle(StepShape_Vertex) theVxFrst = theOE->EdgeStart();
93   Handle(StepShape_Vertex) theVxLst  = theOE->EdgeEnd();
94   if((nbEdg == 1) && (theVxFrst != theVxLst)){
95     ach->AddFail("Edge loop composed of single Edge : Start and End Vertex of edge are not identical");
96   }
97   for(Standard_Integer i = 2; i <= nbEdg; i++)
98     {
99       theOE     = ent->EdgeListValue(i);
100       Handle(StepShape_Vertex) theVxStrt = theOE->EdgeStart();
101       if(theVxStrt != theVxLst){
102         headToTail = Standard_False;
103       }
104       theVxLst = theOE->EdgeEnd();
105       if(theVxStrt == theVxLst){
106         ach->AddWarning("One edge_curve contains identical vertices");
107       }
108     }
109   if(theVxFrst != theVxLst){
110     headToTail = Standard_False;
111   }
112   if(!headToTail) {
113     ach->AddFail("Error : Path does not head to tail");
114   }
115 }