7fd59977 |
1 | // File: MeshDS_Selector.gxx |
2 | // Created: Tue Jun 1 11:20:51 1993 |
3 | // Author: Didier PIFFAULT |
4 | // <dpf@zerox> |
5 | |
6 | #include <MeshDS_PairOfIndex.hxx> |
7 | |
8 | //======================================================================= |
9 | //function : MeshDS_Selector |
10 | //purpose : |
11 | //======================================================================= |
12 | MeshDS_Selector::MeshDS_Selector() |
13 | : myNodes(10, new NCollection_IncAllocator), |
14 | myLinks(10, new NCollection_IncAllocator), |
15 | myElements(10, new NCollection_IncAllocator), |
16 | myFrontier(10, new NCollection_IncAllocator) |
17 | |
18 | {} |
19 | |
20 | MeshDS_Selector::MeshDS_Selector(const Handle(MeshDS_Mesh2d)& theMesh) |
21 | : myMesh(theMesh), |
22 | myNodes(10, myMesh->Allocator()), |
23 | myLinks(10, myMesh->Allocator()), |
24 | myElements(10, myMesh->Allocator()), |
25 | myFrontier(10, myMesh->Allocator()) |
26 | {} |
27 | |
28 | void MeshDS_Selector::Initialize(const Handle(MeshDS_Mesh2d)& theMesh) |
29 | { |
30 | myMesh=theMesh; |
31 | myNodes.Clear(); |
32 | myLinks.Clear(); |
33 | myElements.Clear(); |
34 | myFrontier.Clear(); |
35 | } |
36 | |
37 | //======================================================================= |
38 | //function : NeighboursOfNode |
39 | //purpose : |
40 | //======================================================================= |
41 | void MeshDS_Selector::NeighboursOf(const Node& theNode) |
42 | { |
43 | NeighboursOfNode(myMesh->IndexOf(theNode)); |
44 | } |
45 | |
46 | void MeshDS_Selector::NeighboursOfNode(const Standard_Integer indexNode) |
47 | { |
48 | MeshDS_ListOfInteger::Iterator itL(myMesh->LinkNeighboursOf(indexNode)); |
49 | |
50 | for (; itL.More(); itL.Next()) { |
51 | const MeshDS_PairOfIndex& aPair = myMesh->ElemConnectedTo(itL.Value()); |
52 | for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++) |
53 | myElements.Add(aPair.Index(j)); |
54 | } |
55 | } |
56 | |
57 | //======================================================================= |
58 | //function : NeighboursOfLink |
59 | //purpose : |
60 | //======================================================================= |
61 | void MeshDS_Selector::NeighboursOf(const Link& theLink) |
62 | { |
63 | NeighboursOfNode(theLink.FirstNode()); |
64 | NeighboursOfNode(theLink.LastNode()); |
65 | } |
66 | |
67 | void MeshDS_Selector::NeighboursOfLink(const Standard_Integer indexLink) |
68 | { |
69 | NeighboursOf(myMesh->GetLink(indexLink)); |
70 | } |
71 | |
72 | //======================================================================= |
73 | //function : NeighboursOfElement |
74 | //purpose : by edge and by vertices |
75 | //======================================================================= |
76 | void MeshDS_Selector::NeighboursOf(const Element& theElem) |
77 | { |
78 | Standard_Integer v1, v2, v3, ev; |
79 | Standard_Boolean o1, o2, o3; |
80 | theElem.Edges(v1, v3, ev, o1, o2, o3); |
81 | v2=myMesh->GetLink(v1).LastNode(); |
82 | v1=myMesh->GetLink(v1).FirstNode(); |
83 | ev=myMesh->GetLink(v3).LastNode(); |
84 | if (v1!=ev && v2!=ev) v3=ev; |
85 | else v3=myMesh->GetLink(v3).FirstNode(); |
86 | NeighboursOfNode(v1); |
87 | NeighboursOfNode(v2); |
88 | NeighboursOfNode(v3); |
89 | } |
90 | |
91 | void MeshDS_Selector::NeighboursOfElement(const Standard_Integer indexElem) |
92 | { |
93 | NeighboursOf(myMesh->GetElement(indexElem)); |
94 | } |
95 | |
96 | //======================================================================= |
97 | //function : NeighboursByEdgeOf |
98 | //purpose : Neighbours Of an element only by edge |
99 | //======================================================================= |
100 | void MeshDS_Selector::NeighboursByEdgeOf(const Element& theElem) |
101 | { |
102 | Standard_Integer e[3], iEd; |
103 | Standard_Boolean o1, o2, o3; |
104 | theElem.Edges(e[0], e[1], e[2], o1, o2, o3); |
105 | |
106 | for (iEd=0; iEd<3; iEd++) { |
107 | const MeshDS_PairOfIndex& aPair = myMesh->ElemConnectedTo(e[iEd]); |
108 | for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++) |
109 | myElements.Add(aPair.Index(j)); |
110 | } |
111 | } |
112 | |
113 | |
114 | //======================================================================= |
115 | //function : NeighboursOfSelector |
116 | //purpose : |
117 | //======================================================================= |
118 | void MeshDS_Selector::NeighboursOf(const MeshDS_Selector& /*theSelector*/) |
119 | {} |
120 | |
121 | //======================================================================= |
122 | //function : AddNeighbours |
123 | //purpose : |
124 | //======================================================================= |
125 | void MeshDS_Selector::AddNeighbours() |
126 | {} |
127 | |
128 | //======================================================================= |
129 | //function : Nodes |
130 | //purpose : |
131 | //======================================================================= |
132 | const MeshDS_MapOfInteger& MeshDS_Selector::Nodes()const |
133 | {return myNodes;} |
134 | |
135 | //======================================================================= |
136 | //function : Links |
137 | //purpose : |
138 | //======================================================================= |
139 | const MeshDS_MapOfInteger& MeshDS_Selector::Links()const |
140 | {return myLinks;} |
141 | |
142 | //======================================================================= |
143 | //function : Elements |
144 | //purpose : |
145 | //======================================================================= |
146 | const MeshDS_MapOfInteger& MeshDS_Selector::Elements()const |
147 | {return myElements;} |
148 | |
149 | //======================================================================= |
150 | //function : FrontierLinks |
151 | //purpose : |
152 | //======================================================================= |
153 | const MeshDS_MapOfInteger& MeshDS_Selector::FrontierLinks()const |
154 | {return myFrontier;} |
155 | |