1 // SMESH SMDS : implementaion of Salome mesh data structure
3 // Copyright (C) 2003 OPEN CASCADE
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.opencascade.org or email : webmaster@opencascade.org
23 // File : SMDSControl.cxx
24 // Author : Jean-Michel BOULCOURT
28 #include "SMDSControl.ixx"
29 #include "SMDS_Mesh.hxx"
30 #include "SMDS_MeshElement.hxx"
31 #include "SMDS_ListOfMeshElement.hxx"
32 #include "SMDS_ListIteratorOfListOfMeshElement.hxx"
34 //=======================================================================
35 //function : ComputeNeighborFaces
37 //=======================================================================
39 Standard_Integer SMDSControl::ComputeNeighborFaces(const Handle(SMDS_Mesh)& M,
40 const Handle(SMDS_MeshElement)& ME,
41 const Standard_Integer idnode1,
42 const Standard_Integer idnode2)
44 const Handle(SMDS_MeshElement)& node1 = M->FindNode(idnode1);
45 const Handle(SMDS_MeshElement)& node2 = M->FindNode(idnode2);
46 const SMDS_ListOfMeshElement& lstInvFaces1 = node1->InverseElements();
47 const SMDS_ListOfMeshElement& lstInvFaces2 = node2->InverseElements();
48 Standard_Integer neighbor=0;
50 SMDS_ListIteratorOfListOfMeshElement it1(lstInvFaces1);
51 for (;it1.More();it1.Next()) {
52 const Handle(SMDS_MeshElement)& face = it1.Value();
53 if (M->Contains(face) && !face->IsSame(ME)) {
54 if (face->IsNodeInElement(idnode1) && face->IsNodeInElement(idnode2)) {
64 SMDS_ListIteratorOfListOfMeshElement it2(lstInvFaces2);
65 for (;it2.More();it2.Next()) {
66 const Handle(SMDS_MeshElement)& face = it2.Value();
67 if (M->Contains(face) && !face->IsSame(ME)) {
68 if (face->IsNodeInElement(idnode1) && face->IsNodeInElement(idnode2)) {
77 //=======================================================================
78 //function : ComputeNeighborVolumes
80 //=======================================================================
82 Standard_Integer SMDSControl::ComputeNeighborVolumes(const Handle(SMDS_Mesh)& M,
83 const Handle(SMDS_MeshElement)& ME,
84 const Standard_Integer idnode1,
85 const Standard_Integer idnode2,
86 const Standard_Integer idnode3)
89 const Handle(SMDS_MeshElement)& node1 = M->FindNode(idnode1);
90 const Handle(SMDS_MeshElement)& node2 = M->FindNode(idnode2);
91 const Handle(SMDS_MeshElement)& node3 = M->FindNode(idnode3);
92 const SMDS_ListOfMeshElement& lstInvVol1 = node1->InverseElements();
93 const SMDS_ListOfMeshElement& lstInvVol2 = node2->InverseElements();
94 const SMDS_ListOfMeshElement& lstInvVol3 = node3->InverseElements();
96 Standard_Integer neighbor=0;
98 SMDS_ListIteratorOfListOfMeshElement it1(lstInvVol1);
99 for (;it1.More() && neighbor == 0;it1.Next()) {
100 const Handle(SMDS_MeshElement)& vol = it1.Value();
101 if (M->Contains(vol) && !vol->IsSame(ME)) {
102 if (vol->IsNodeInElement(idnode1)
103 && vol->IsNodeInElement(idnode2)
104 && vol->IsNodeInElement(idnode3)) {
114 SMDS_ListIteratorOfListOfMeshElement it2(lstInvVol2);
115 for (;it2.More() && neighbor == 0;it2.Next()) {
116 const Handle(SMDS_MeshElement)& vol = it2.Value();
117 if (M->Contains(vol) && !vol->IsSame(ME)) {
118 if (vol->IsNodeInElement(idnode1)
119 && vol->IsNodeInElement(idnode2)
120 && vol->IsNodeInElement(idnode3)) {
130 SMDS_ListIteratorOfListOfMeshElement it3(lstInvVol3);
131 for (;it3.More() && neighbor == 0;it3.Next()) {
132 const Handle(SMDS_MeshElement)& vol = it3.Value();
133 if (M->Contains(vol) && !vol->IsSame(ME)) {
134 if (vol->IsNodeInElement(idnode1)
135 && vol->IsNodeInElement(idnode2)
136 && vol->IsNodeInElement(idnode3)) {
146 //=======================================================================
147 //function : ComputeNeighborVolumes
149 //=======================================================================
151 Standard_Integer SMDSControl::ComputeNeighborVolumes(const Handle(SMDS_Mesh)& M,
152 const Handle(SMDS_MeshElement)& ME,
153 const Standard_Integer idnode1,
154 const Standard_Integer idnode2,
155 const Standard_Integer idnode3,
156 const Standard_Integer idnode4)
159 const Handle(SMDS_MeshElement)& node1 = M->FindNode(idnode1);
160 const Handle(SMDS_MeshElement)& node2 = M->FindNode(idnode2);
161 const Handle(SMDS_MeshElement)& node3 = M->FindNode(idnode3);
162 const Handle(SMDS_MeshElement)& node4 = M->FindNode(idnode4);
163 const SMDS_ListOfMeshElement& lstInvVol1 = node1->InverseElements();
164 const SMDS_ListOfMeshElement& lstInvVol2 = node2->InverseElements();
165 const SMDS_ListOfMeshElement& lstInvVol3 = node3->InverseElements();
166 const SMDS_ListOfMeshElement& lstInvVol4 = node4->InverseElements();
167 Standard_Integer neighbor=0;
169 SMDS_ListIteratorOfListOfMeshElement it1(lstInvVol1);
170 for (;it1.More();it1.Next()) {
171 const Handle(SMDS_MeshElement)& vol = it1.Value();
172 if (M->Contains(vol) && !vol->IsSame(ME)) {
173 if ( vol->IsNodeInElement(idnode1)
174 && vol->IsNodeInElement(idnode2)
175 && vol->IsNodeInElement(idnode3)
176 && vol->IsNodeInElement(idnode4)) {
186 SMDS_ListIteratorOfListOfMeshElement it2(lstInvVol2);
187 for (;it2.More();it2.Next()) {
188 const Handle(SMDS_MeshElement)& vol = it2.Value();
189 if (M->Contains(vol) && !vol->IsSame(ME)) {
190 if ( vol->IsNodeInElement(idnode1)
191 && vol->IsNodeInElement(idnode2)
192 && vol->IsNodeInElement(idnode3)
193 && vol->IsNodeInElement(idnode4)) {
203 SMDS_ListIteratorOfListOfMeshElement it3(lstInvVol3);
204 for (;it3.More();it3.Next()) {
205 const Handle(SMDS_MeshElement)& vol = it3.Value();
206 if (M->Contains(vol) && !vol->IsSame(ME)) {
207 if ( vol->IsNodeInElement(idnode1)
208 && vol->IsNodeInElement(idnode2)
209 && vol->IsNodeInElement(idnode3)
210 && vol->IsNodeInElement(idnode4)) {
220 SMDS_ListIteratorOfListOfMeshElement it4(lstInvVol4);
221 for (;it4.More();it4.Next()) {
222 const Handle(SMDS_MeshElement)& vol = it4.Value();
223 if (M->Contains(vol) && !vol->IsSame(ME)) {
224 if ( vol->IsNodeInElement(idnode1)
225 && vol->IsNodeInElement(idnode2)
226 && vol->IsNodeInElement(idnode3)
227 && vol->IsNodeInElement(idnode4)) {