0025154: Collections in BRepMesh package are named in non-conformant manner
[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-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <BRepMesh_SelectorOfDataStructureOfDelaun.hxx>
18 #include <BRepMesh_PairOfIndex.hxx>
19
20 //=======================================================================
21 //function : Default constructor
22 //purpose  : 
23 //=======================================================================
24 BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDelaun()
25 : myNodes   (10, new NCollection_IncAllocator),
26   myLinks   (10, new NCollection_IncAllocator),
27   myElements(10, new NCollection_IncAllocator),
28   myFrontier(10, new NCollection_IncAllocator)
29 {
30 }
31
32 //=======================================================================
33 //function : Constructor
34 //purpose  : 
35 //=======================================================================
36 BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDelaun(
37   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
46 //=======================================================================
47 //function : Initialize
48 //purpose  : 
49 //=======================================================================
50 void BRepMesh_SelectorOfDataStructureOfDelaun::Initialize(
51   const Handle(BRepMesh_DataStructureOfDelaun)& theMesh)
52 {
53   myMesh = theMesh;
54   myNodes.Clear();
55   myLinks.Clear();
56   myElements.Clear();
57   myFrontier.Clear();
58 }
59
60 //=======================================================================
61 //function : NeighboursOf(Node)
62 //purpose  : 
63 //=======================================================================
64 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(
65   const BRepMesh_Vertex& theNode)
66 {
67   NeighboursOfNode(myMesh->IndexOf(theNode));
68 }
69
70 //=======================================================================
71 //function : NeighboursOfNode(NodeIndex)
72 //purpose  : 
73 //=======================================================================
74 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfNode(
75   const Standard_Integer theNodeIndex)
76 {
77   BRepMesh::ListOfInteger::Iterator aLinkIt(
78     myMesh->LinksConnectedTo(theNodeIndex));
79
80   for (; aLinkIt.More(); aLinkIt.Next())
81     elementsOfLink(aLinkIt.Value());
82 }
83
84 //=======================================================================
85 //function : NeighboursOf(Link)
86 //purpose  : 
87 //=======================================================================
88 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(
89   const BRepMesh_Edge& theLink)
90 {
91   NeighboursOfNode(theLink.FirstNode());
92   NeighboursOfNode(theLink.LastNode());
93 }
94
95 //=======================================================================
96 //function : NeighboursOfLink(LinkIndex)
97 //purpose  : 
98 //=======================================================================
99 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfLink(
100   const Standard_Integer theLinkIndex)
101 {
102   NeighboursOf(myMesh->GetLink(theLinkIndex));
103 }
104
105 //=======================================================================
106 //function : NeighboursOf(Element)
107 //purpose  :
108 //=======================================================================
109 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(
110   const BRepMesh_Triangle& theElement)
111 {
112   Standard_Integer v[3];
113   myMesh->ElementNodes(theElement, v);
114
115   for (Standard_Integer i = 0; i < 3; ++i)
116     NeighboursOfNode(v[i]);
117 }
118
119 //=======================================================================
120 //function : NeighboursOfElement(ElementIndex)
121 //purpose  :
122 //=======================================================================
123 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfElement(
124   const Standard_Integer theElementIndex)
125 {
126   NeighboursOf(myMesh->GetElement(theElementIndex));
127 }
128
129 //=======================================================================
130 //function : NeighboursByEdgeOf(Element)
131 //purpose  : 
132 //=======================================================================
133 void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursByEdgeOf(
134   const BRepMesh_Triangle& theElement)
135 {
136   Standard_Integer e[3];
137   Standard_Boolean o[3];
138   theElement.Edges(e, o);
139
140   for (Standard_Integer i = 0; i < 3; ++i)
141     elementsOfLink(e[i]);
142 }
143
144 //=======================================================================
145 //function : elementsOfLink
146 //purpose  : 
147 //=======================================================================
148 void BRepMesh_SelectorOfDataStructureOfDelaun::elementsOfLink(
149   const Standard_Integer theIndex)
150 {
151   const BRepMesh_PairOfIndex& aPair = myMesh->ElementsConnectedTo(theIndex);
152   for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; ++j)
153     myElements.Add(aPair.Index(j));
154 }