30 template<
class FaceEdges>
31 void Foam::star::cross
35 const UList<FaceEdges>& faceEdges
39 starFaceFaces_.
append(facei);
40 faceStarFaces_[facei] = starFaceFaces_.
size() - 1;
44 const label starEdgei = edgeStarEdges_[faceEdges[facei][faceEdgei]];
45 const label starEdgei0 = starEdgeEdges_[starEdgei].starEdgei0_;
46 const label starEdgei1 = starEdgeEdges_[starEdgei].starEdgei1_;
47 edgeStarEdges_[starEdgeEdges_[starEdgei].edgei_] = -1;
48 starEdgeEdges_[starEdgei] = {-1, -1, -1};
52 label faceEdgeiR = faceEdgei, starEdgeiR1 = starEdgei1;
55 const label faceEdgeiRR = faceEdges[facei].rcIndex(faceEdgeiR);
56 const label edgeiRR = faceEdges[facei][faceEdgeiRR];
57 const label starEdgeiRR = edgeStarEdges_[edgeiRR];
58 if (starEdgeiRR == -1 || starEdgeiRR != starEdgeiR1)
break;
59 faceEdgeiR = faceEdgeiRR;
60 starEdgeiR1 = starEdgeEdges_[starEdgeiRR].starEdgei1_;
61 edgeStarEdges_[starEdgeEdges_[starEdgeiRR].edgei_] = -1;
62 starEdgeEdges_[starEdgeiRR] = {-1, -1, -1};
64 label faceEdgeiF = faceEdgei, starEdgeiF0 = starEdgei0;
67 const label faceEdgeiFF = faceEdges[facei].fcIndex(faceEdgeiF);
68 const label edgeiFF = faceEdges[facei][faceEdgeiFF];
69 const label starEdgeiFF = edgeStarEdges_[edgeiFF];
70 if (starEdgeiFF == -1 || starEdgeiFF != starEdgeiF0)
break;
71 faceEdgeiF = faceEdgeiFF;
72 starEdgeiF0 = starEdgeEdges_[starEdgeiFF].starEdgei0_;
73 edgeStarEdges_[starEdgeEdges_[starEdgeiFF].edgei_] = -1;
74 starEdgeEdges_[starEdgeiFF] = {-1, -1, -1};
78 label faceEdgej = faceEdges[facei].fcIndex(faceEdgeiF);
82 if (faceEdgej == faceEdgeiR)
84 starEdgeEdges_[starEdgeiF0].starEdgei1_ = starEdgeiR1;
85 starEdgeEdges_[starEdgeiR1].starEdgei0_ = starEdgeiF0;
90 while (faceEdgej != faceEdgeiR)
93 faceEdgej == faceEdges[facei].fcIndex(faceEdgeiF);
95 faceEdgej == faceEdges[facei].rcIndex(faceEdgeiR);
97 const label starEdgej0 =
98 isFirst ? starEdgeiF0 : starEdgeEdges_.size() - 1;
99 const label starEdgej = starEdgeEdges_.size();
100 const label starEdgej1 =
101 isLast ? starEdgeiR1 : starEdgeEdges_.size() + 1;
103 const label edgej = faceEdges[facei][faceEdgej];
105 if (isFirst && starEdgeiF0 != -1)
107 starEdgeEdges_[starEdgeiF0].starEdgei1_ = starEdgej;
110 starEdgeEdges_.append({starEdgej0, edgej, starEdgej1});
111 edgeStarEdges_[edgej] = starEdgej;
113 if (isLast && starEdgeiR1 != -1)
115 starEdgeEdges_[starEdgeiR1].starEdgei0_ = starEdgej;
118 faceEdgej = faceEdges[facei].
fcIndex(faceEdgej);
126 template<
class CanCross,
class FaceEdges>
129 const label faceOrEdgei,
134 const label maxIterations
138 faceStarFaces_.resize(faceEdges.
size(), -1);
139 edgeStarEdges_.resize(edgeFaces.
size(), -1);
145 const label edgei = faceEdges[faceOrEdgei][0];
146 starEdgeEdges_.append({-1, edgei, -1});
147 edgeStarEdges_[edgei] = 0;
148 cross(edgei, faceOrEdgei, faceEdges);
152 const label starEdgei0 = starEdgeEdges_.size() - 1;
153 const label starEdgei1 = 1;
154 starEdgeEdges_[0] = {starEdgei0, edgei, starEdgei1};
155 edgeStarEdges_[edgei] = 0;
156 starEdgeEdges_[starEdgei0].starEdgei1_ = 0;
157 starEdgeEdges_[starEdgei1].starEdgei0_ = 0;
164 forAll(edgeFaces[faceOrEdgei], edgeFacei)
166 const label facei = edgeFaces[faceOrEdgei][edgeFacei];
167 if (facei == -1)
continue;
172 starEdgeEdges_.append({-1, faceOrEdgei, -1});
173 edgeStarEdges_[faceOrEdgei] = 0;
181 const label starEdgei0 = starEdgeEdges_.
size() - 1;
182 const label starEdgei1 = 1;
183 starEdgeEdges_[0] = {starEdgei0, faceOrEdgei, starEdgei1};
184 edgeStarEdges_[faceOrEdgei] = 0;
185 starEdgeEdges_[starEdgei0].starEdgei1_ = 0;
186 starEdgeEdges_[starEdgei1].starEdgei0_ = 0;
190 cross(faceOrEdgei, facei, faceEdges);
195 label iterations = 0;
196 forAll(starEdgeEdges_, starEdgei)
198 if (iterations == maxIterations)
break;
201 const label edgei = starEdgeEdges_[starEdgei].edgei_;
202 if (edgei == -1)
continue;
206 forAll(edgeFaces[edgei], edgeFacei)
208 facei = edgeFaces[edgei][edgeFacei];
209 if (facei != -1 && faceStarFaces_[facei] == -1)
217 if (facei != -1 && canCross(edgei, facei))
219 cross(edgei, facei, faceEdges);
224 forAll(starEdgeEdges_, starEdgei)
226 label starEdgei0 = starEdgei;
227 label starEdgei1 = starEdgeEdges_[starEdgei0].starEdgei1_;
229 if (starEdgei1 == -1)
continue;
231 label edgei0 = starEdgeEdges_[starEdgei0].edgei_;
232 label edgei1 = starEdgeEdges_[starEdgei1].edgei_;
234 while (edgei0 != -1 && edgei1 != -1 && edgei0 == edgei1)
236 const label starEdgei00 = starEdgeEdges_[starEdgei0].starEdgei0_;
237 const label starEdgei11 = starEdgeEdges_[starEdgei1].starEdgei1_;
239 edgeStarEdges_[edgei0] = -1;
240 starEdgeEdges_[starEdgei0] = {-1, -1, -1};
241 edgeStarEdges_[edgei1] = -1;
242 starEdgeEdges_[starEdgei1] = {-1, -1, -1};
244 if (starEdgei00 != -1)
246 starEdgeEdges_[starEdgei00].starEdgei1_ = starEdgei11;
247 starEdgei0 = starEdgei00;
248 edgei0 = starEdgeEdges_[starEdgei00].edgei_;
252 starEdgei0 = edgei0 = -1;
255 if (starEdgei11 != -1)
257 starEdgeEdges_[starEdgei11].starEdgei0_ = starEdgei00;
258 starEdgei1 = starEdgei11;
259 edgei1 = starEdgeEdges_[starEdgei11].edgei_;
263 starEdgei1 = edgei0 = -1;
270 oldStarEdgeNewStarEdges.
resize(starEdgeEdges_.size());
271 oldStarEdgeNewStarEdges = -1;
275 forAll(starEdgeEdges_, starEdgej)
277 if (starEdgeEdges_[starEdgej].edgei_ != -1)
279 oldStarEdgeNewStarEdges[starEdgej] = starEdgei;
280 starEdgeEdges_[starEdgei] = starEdgeEdges_[starEdgej];
284 starEdgeEdges_.
resize(starEdgei);
287 forAll(starEdgeEdges_, starEdgei)
289 label& starEdgei0 = starEdgeEdges_[starEdgei].starEdgei0_;
290 if (starEdgei0 != -1)
292 starEdgei0 = oldStarEdgeNewStarEdges[starEdgei0];
294 label& starEdgei1 = starEdgeEdges_[starEdgei].starEdgei1_;
295 if (starEdgei1 != -1)
297 starEdgei1 = oldStarEdgeNewStarEdges[starEdgei1];
311 forAll(starEdgeEdges_, starEdgei)
313 if (starEdgeEdges_[starEdgei].starEdgei0_ == -1)
315 swapStarEdges(starEdgei, 0);
#define forAll(list, i)
Loop across all elements in list.
void resize(const label)
Alter the addressed list size.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
void size(const label)
Override size to be inconsistent with allocated storage.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
label size() const
Return the number of elements in the UList.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
Context class. Returned by populate and resets the star when it.
context populate(const label faceOrEdgei, const bool isFace, CanCross canCross, const UList< FaceEdges > &faceEdges, const UList< labelPair > &edgeFaces, const label maxIterations=labelMax)
Populate the star given a seed face or edge, a function.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
labelList first(const UList< labelPair > &p)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)