Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1993-06-01 |
2 | // Created by: Didier PIFFAULT | |
3 | // Copyright (c) 1993-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
973c2be1 | 8 | // This library is free software; you can redistribute it and / or modify it |
9 | // under the terms of the GNU Lesser General Public 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. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
0d88155b O |
16 | |
17 | #include <BRepMesh_SelectorOfDataStructureOfDelaun.ixx> | |
18 | #include <BRepMesh_PairOfIndex.hxx> | |
19 | ||
20 | //======================================================================= | |
21 | //function : BRepMesh_SelectorOfDataStructureOfDelaun | |
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 | BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDelaun(const Handle(BRepMesh_DataStructureOfDelaun)& theMesh) | |
33 | : myMesh(theMesh), | |
34 | myNodes(10, myMesh->Allocator()), | |
35 | myLinks(10, myMesh->Allocator()), | |
36 | myElements(10, myMesh->Allocator()), | |
37 | myFrontier(10, myMesh->Allocator()) | |
38 | {} | |
39 | ||
40 | void BRepMesh_SelectorOfDataStructureOfDelaun::Initialize(const Handle(BRepMesh_DataStructureOfDelaun)& theMesh) | |
41 | { | |
42 | myMesh=theMesh; | |
43 | myNodes.Clear(); | |
44 | myLinks.Clear(); | |
45 | myElements.Clear(); | |
46 | myFrontier.Clear(); | |
47 | } | |
48 | ||
49 | //======================================================================= | |
50 | //function : NeighboursOfNode | |
51 | //purpose : | |
52 | //======================================================================= | |
53 | void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Vertex& theNode) | |
54 | { | |
55 | NeighboursOfNode(myMesh->IndexOf(theNode)); | |
56 | } | |
57 | ||
58 | void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfNode(const Standard_Integer indexNode) | |
59 | { | |
60 | BRepMesh_ListOfInteger::Iterator itL(myMesh->LinkNeighboursOf(indexNode)); | |
61 | ||
62 | for (; itL.More(); itL.Next()) { | |
63 | const BRepMesh_PairOfIndex& aPair = myMesh->ElemConnectedTo(itL.Value()); | |
64 | for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++) | |
65 | myElements.Add(aPair.Index(j)); | |
66 | } | |
67 | } | |
68 | ||
69 | //======================================================================= | |
70 | //function : NeighboursOfLink | |
71 | //purpose : | |
72 | //======================================================================= | |
73 | void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Edge& theLink) | |
74 | { | |
75 | NeighboursOfNode(theLink.FirstNode()); | |
76 | NeighboursOfNode(theLink.LastNode()); | |
77 | } | |
78 | ||
79 | void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfLink(const Standard_Integer indexLink) | |
80 | { | |
81 | NeighboursOf(myMesh->GetLink(indexLink)); | |
82 | } | |
83 | ||
84 | //======================================================================= | |
85 | //function : NeighboursOfElement | |
86 | //purpose : by edge and by vertices | |
87 | //======================================================================= | |
88 | void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Triangle& theElem) | |
89 | { | |
90 | Standard_Integer v1, v2, v3, ev; | |
91 | Standard_Boolean o1, o2, o3; | |
92 | theElem.Edges(v1, v3, ev, o1, o2, o3); | |
93 | v2=myMesh->GetLink(v1).LastNode(); | |
94 | v1=myMesh->GetLink(v1).FirstNode(); | |
95 | ev=myMesh->GetLink(v3).LastNode(); | |
96 | if (v1!=ev && v2!=ev) v3=ev; | |
97 | else v3=myMesh->GetLink(v3).FirstNode(); | |
98 | NeighboursOfNode(v1); | |
99 | NeighboursOfNode(v2); | |
100 | NeighboursOfNode(v3); | |
101 | } | |
102 | ||
103 | void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfElement(const Standard_Integer indexElem) | |
104 | { | |
105 | NeighboursOf(myMesh->GetElement(indexElem)); | |
106 | } | |
107 | ||
108 | //======================================================================= | |
109 | //function : NeighboursByEdgeOf | |
110 | //purpose : Neighbours Of an element only by edge | |
111 | //======================================================================= | |
112 | void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursByEdgeOf(const BRepMesh_Triangle& theElem) | |
113 | { | |
114 | Standard_Integer e[3], iEd; | |
115 | Standard_Boolean o1, o2, o3; | |
116 | theElem.Edges(e[0], e[1], e[2], o1, o2, o3); | |
117 | ||
118 | for (iEd=0; iEd<3; iEd++) { | |
119 | const BRepMesh_PairOfIndex& aPair = myMesh->ElemConnectedTo(e[iEd]); | |
120 | for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++) | |
121 | myElements.Add(aPair.Index(j)); | |
122 | } | |
123 | } | |
124 | ||
125 | ||
126 | //======================================================================= | |
127 | //function : NeighboursOfSelector | |
128 | //purpose : | |
129 | //======================================================================= | |
130 | void BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_SelectorOfDataStructureOfDelaun& /*theSelector*/) | |
131 | {} | |
132 | ||
133 | //======================================================================= | |
134 | //function : AddNeighbours | |
135 | //purpose : | |
136 | //======================================================================= | |
137 | void BRepMesh_SelectorOfDataStructureOfDelaun::AddNeighbours() | |
138 | {} | |
139 | ||
140 | //======================================================================= | |
141 | //function : Nodes | |
142 | //purpose : | |
143 | //======================================================================= | |
144 | const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::Nodes()const | |
145 | {return myNodes;} | |
146 | ||
147 | //======================================================================= | |
148 | //function : Links | |
149 | //purpose : | |
150 | //======================================================================= | |
151 | const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::Links()const | |
152 | {return myLinks;} | |
153 | ||
154 | //======================================================================= | |
155 | //function : Elements | |
156 | //purpose : | |
157 | //======================================================================= | |
158 | const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::Elements()const | |
159 | {return myElements;} | |
160 | ||
161 | //======================================================================= | |
162 | //function : FrontierLinks | |
163 | //purpose : | |
164 | //======================================================================= | |
165 | const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::FrontierLinks()const | |
166 | {return myFrontier;} | |
167 |