0024171: Eliminate CLang compiler warning -Wreorder
[occt.git] / src / BRepMesh / BRepMesh_SelectorOfDataStructureOfDelaun.cxx
1 // Created on: 1993-06-01
2 // Created by: Didier PIFFAULT
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 #include <BRepMesh_SelectorOfDataStructureOfDelaun.ixx>
23 #include <BRepMesh_PairOfIndex.hxx>
24
25 //=======================================================================
26 //function : BRepMesh_SelectorOfDataStructureOfDelaun
27 //purpose  : 
28 //=======================================================================
29 BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDelaun()
30 : myNodes(10, new NCollection_IncAllocator),
31 myLinks(10, new NCollection_IncAllocator),
32 myElements(10, new NCollection_IncAllocator),
33 myFrontier(10, new NCollection_IncAllocator)
34
35 {}
36
37 BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDelaun(const Handle(BRepMesh_DataStructureOfDelaun)& theMesh)
38 : myMesh(theMesh),
39 myNodes(10, myMesh->Allocator()),
40 myLinks(10, myMesh->Allocator()),
41 myElements(10, myMesh->Allocator()),
42 myFrontier(10, myMesh->Allocator())
43 {}
44
45 void  BRepMesh_SelectorOfDataStructureOfDelaun::Initialize(const Handle(BRepMesh_DataStructureOfDelaun)& theMesh)
46 {
47   myMesh=theMesh;
48   myNodes.Clear();
49   myLinks.Clear();
50   myElements.Clear();
51   myFrontier.Clear();
52 }
53
54 //=======================================================================
55 //function : NeighboursOfNode
56 //purpose  : 
57 //=======================================================================
58 void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Vertex& theNode)
59 {
60   NeighboursOfNode(myMesh->IndexOf(theNode));
61 }
62
63 void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfNode(const Standard_Integer indexNode)
64 {
65   BRepMesh_ListOfInteger::Iterator itL(myMesh->LinkNeighboursOf(indexNode));
66
67   for (; itL.More(); itL.Next()) {
68     const BRepMesh_PairOfIndex& aPair = myMesh->ElemConnectedTo(itL.Value());
69     for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++)
70       myElements.Add(aPair.Index(j));
71   }
72 }
73
74 //=======================================================================
75 //function : NeighboursOfLink
76 //purpose  : 
77 //=======================================================================
78 void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Edge& theLink)
79 {
80   NeighboursOfNode(theLink.FirstNode());
81   NeighboursOfNode(theLink.LastNode());
82 }
83
84 void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfLink(const Standard_Integer indexLink)
85 {
86   NeighboursOf(myMesh->GetLink(indexLink));
87 }
88
89 //=======================================================================
90 //function : NeighboursOfElement
91 //purpose  : by edge and by vertices
92 //=======================================================================
93 void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Triangle& theElem)
94 {
95   Standard_Integer v1, v2, v3, ev;
96   Standard_Boolean o1, o2, o3;
97   theElem.Edges(v1, v3, ev, o1, o2, o3);
98   v2=myMesh->GetLink(v1).LastNode();
99   v1=myMesh->GetLink(v1).FirstNode();
100   ev=myMesh->GetLink(v3).LastNode();
101   if (v1!=ev && v2!=ev) v3=ev;
102   else v3=myMesh->GetLink(v3).FirstNode();
103   NeighboursOfNode(v1);
104   NeighboursOfNode(v2);
105   NeighboursOfNode(v3);
106 }
107
108 void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfElement(const Standard_Integer indexElem)
109 {
110   NeighboursOf(myMesh->GetElement(indexElem));
111 }
112
113 //=======================================================================
114 //function : NeighboursByEdgeOf
115 //purpose  : Neighbours Of an element only by edge
116 //=======================================================================
117 void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursByEdgeOf(const BRepMesh_Triangle& theElem)
118 {
119   Standard_Integer e[3], iEd;
120   Standard_Boolean o1, o2, o3;
121   theElem.Edges(e[0], e[1], e[2], o1, o2, o3);
122
123   for (iEd=0; iEd<3; iEd++) {
124     const BRepMesh_PairOfIndex& aPair = myMesh->ElemConnectedTo(e[iEd]);
125     for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++)
126       myElements.Add(aPair.Index(j));
127   }
128 }
129
130
131 //=======================================================================
132 //function : NeighboursOfSelector
133 //purpose  : 
134 //=======================================================================
135 void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_SelectorOfDataStructureOfDelaun& /*theSelector*/)
136 {}
137
138 //=======================================================================
139 //function : AddNeighbours
140 //purpose  : 
141 //=======================================================================
142 void  BRepMesh_SelectorOfDataStructureOfDelaun::AddNeighbours()
143 {}
144
145 //=======================================================================
146 //function : Nodes
147 //purpose  : 
148 //=======================================================================
149 const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::Nodes()const
150 {return myNodes;}
151
152 //=======================================================================
153 //function : Links
154 //purpose  : 
155 //=======================================================================
156 const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::Links()const
157 {return myLinks;}
158
159 //=======================================================================
160 //function : Elements
161 //purpose  : 
162 //=======================================================================
163 const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::Elements()const
164 {return myElements;}
165
166 //=======================================================================
167 //function : FrontierLinks
168 //purpose  : 
169 //=======================================================================
170 const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::FrontierLinks()const
171 {return myFrontier;}
172