mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
consistency update
- OSspecific: chmod() -> chMod(), even although it's not used anywhere - ListOps get subset() and inplaceSubset() templated on BoolListType - added UList<bool>::operator[](..) const specialization. Returns false (actually pTraits<bool>::zero) for out-of-range elements. This lets us use List<bool> with lazy evaluation and no noticeable change in performance. - use rcIndex() and fcIndex() wherever possible. Could check if branching or modulus is faster for fcIndex(). - UList and FixedList get 'const T* cdata() const' and 'T* data()' members. Similar to the STL front() and std::string::data() methods, they return a pointer to the first element without needing to write '&myList[0]', recast begin() or violate const-ness.
This commit is contained in:
@ -77,14 +77,22 @@ int main(int argc, char *argv[])
|
|||||||
const PackedList<3>& constLst = list1;
|
const PackedList<3>& constLst = list1;
|
||||||
Info<< "\ntest operator[] const with out-of-range index\n";
|
Info<< "\ntest operator[] const with out-of-range index\n";
|
||||||
constLst.print(Info);
|
constLst.print(Info);
|
||||||
if (!constLst[20])
|
if (constLst[20])
|
||||||
|
{
|
||||||
|
Info<< "[20] is true (unexpected)\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Info<< "[20] is false (expected) list size should be unchanged (const)\n";
|
Info<< "[20] is false (expected) list size should be unchanged (const)\n";
|
||||||
}
|
}
|
||||||
constLst.print(Info);
|
constLst.print(Info);
|
||||||
|
|
||||||
Info<< "\ntest operator[] non-const with out-of-range index\n";
|
Info<< "\ntest operator[] non-const with out-of-range index\n";
|
||||||
if (!list1[20])
|
if (list1[20])
|
||||||
|
{
|
||||||
|
Info<< "[20] is true (unexpected)\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Info<< "[20] is false (expected) but list was resized?? (non-const)\n";
|
Info<< "[20] is false (expected) but list was resized?? (non-const)\n";
|
||||||
}
|
}
|
||||||
@ -268,6 +276,23 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "removed final value: " << list3.remove() << endl;
|
Info<< "removed final value: " << list3.remove() << endl;
|
||||||
list3.print(Info);
|
list3.print(Info);
|
||||||
|
|
||||||
|
|
||||||
|
List<bool> list4(4, true);
|
||||||
|
{
|
||||||
|
const List<bool>& constLst = list4;
|
||||||
|
Info<< "\ntest operator[] const with out-of-range index\n";
|
||||||
|
Info<< constLst << endl;
|
||||||
|
if (constLst[20])
|
||||||
|
{
|
||||||
|
Info<< "[20] is true (unexpected)\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "[20] is false (expected) list size should be unchanged (const)\n";
|
||||||
|
}
|
||||||
|
Info<< constLst << endl;
|
||||||
|
}
|
||||||
|
|
||||||
Info<< "\n\nDone.\n";
|
Info<< "\n\nDone.\n";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -69,7 +69,7 @@ void checkFaceEdges
|
|||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
label fp1 = (fp + 1) % f.size();
|
label fp1 = f.fcIndex(fp);
|
||||||
|
|
||||||
if (edges[myEdges[fp]] != edge(f[fp], f[fp1]))
|
if (edges[myEdges[fp]] != edge(f[fp], f[fp1]))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -74,20 +74,17 @@ labelList getSortedEdges
|
|||||||
const edge& e = edges[edgeI];
|
const edge& e = edges[edgeI];
|
||||||
|
|
||||||
label fp = findIndex(f, e[0]);
|
label fp = findIndex(f, e[0]);
|
||||||
|
label fp1 = f.fcIndex(fp);
|
||||||
label fp1 = (fp+1) % f.size();
|
|
||||||
|
|
||||||
if (f[fp1] == e[1])
|
if (f[fp1] == e[1])
|
||||||
{
|
{
|
||||||
// Edgei in fp-fp1 order
|
// EdgeI between fp -> fp1
|
||||||
faceEdges[fp] = edgeI;
|
faceEdges[fp] = edgeI;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Edgei between fp-1 and fp
|
// EdgeI between fp-1 -> fp
|
||||||
label fpMin1 = (fp == 0 ? f.size()-1 : fp-1);
|
faceEdges[f.rcIndex(fp)] = edgeI;
|
||||||
|
|
||||||
faceEdges[fpMin1] = edgeI;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -211,7 +211,7 @@ void Foam::cellSplitter::setRefinement
|
|||||||
|
|
||||||
// Add other pyramids
|
// Add other pyramids
|
||||||
for (label i = 1; i < cFaces.size(); i++)
|
for (label i = 1; i < cFaces.size(); i++)
|
||||||
{
|
{
|
||||||
label addedCellI =
|
label addedCellI =
|
||||||
meshMod.setAction
|
meshMod.setAction
|
||||||
(
|
(
|
||||||
@ -277,7 +277,7 @@ void Foam::cellSplitter::setRefinement
|
|||||||
|
|
||||||
label index = findIndex(f0, e[0]);
|
label index = findIndex(f0, e[0]);
|
||||||
|
|
||||||
bool edgeInFaceOrder = (f0[(index+1) % f0.size()] == e[1]);
|
bool edgeInFaceOrder = (f0[f0.fcIndex(index)] == e[1]);
|
||||||
|
|
||||||
// Check if cellI is the face owner
|
// Check if cellI is the face owner
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ void Foam::cellSplitter::setRefinement
|
|||||||
|
|
||||||
label index = findIndex(f1, e[0]);
|
label index = findIndex(f1, e[0]);
|
||||||
|
|
||||||
bool edgeInFaceOrder = (f1[(index+1) % f1.size()] == e[1]);
|
bool edgeInFaceOrder = (f1[f1.fcIndex(index)] == e[1]);
|
||||||
|
|
||||||
// Check if cellI is the face owner
|
// Check if cellI is the face owner
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ void Foam::cellSplitter::setRefinement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Update all existing faces for split owner or neighbour.
|
// Update all existing faces for split owner or neighbour.
|
||||||
@ -441,7 +441,7 @@ void Foam::cellSplitter::setRefinement
|
|||||||
|
|
||||||
label patchID, zoneID, zoneFlip;
|
label patchID, zoneID, zoneFlip;
|
||||||
getFaceInfo(faceI, patchID, zoneID, zoneFlip);
|
getFaceInfo(faceI, patchID, zoneID, zoneFlip);
|
||||||
|
|
||||||
meshMod.setAction
|
meshMod.setAction
|
||||||
(
|
(
|
||||||
polyModifyFace
|
polyModifyFace
|
||||||
@ -458,7 +458,7 @@ void Foam::cellSplitter::setRefinement
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
faceUpToDate[faceI] = true;
|
faceUpToDate[faceI] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,7 +156,7 @@ class vtkPV3Foam
|
|||||||
|
|
||||||
bool empty() const
|
bool empty() const
|
||||||
{
|
{
|
||||||
return (size_ == 0);
|
return !size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset()
|
void reset()
|
||||||
|
|||||||
@ -351,7 +351,7 @@ label otherEdge
|
|||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Starting from startPoint on startEdge on startFace walk along border
|
// Starting from startPoint on startEdge on startFace walk along border
|
||||||
// and insert faces along the way. Walk keeps always one point or one edge
|
// and insert faces along the way. Walk keeps always one point or one edge
|
||||||
@ -461,18 +461,8 @@ label sharedFace
|
|||||||
|
|
||||||
label startIndex = findIndex(f, e.start());
|
label startIndex = findIndex(f, e.start());
|
||||||
|
|
||||||
bool edgeOrder;
|
// points in face in same order as edge
|
||||||
|
bool edgeOrder = (f[f.fcIndex(startIndex)] == e.end());
|
||||||
if (f[(startIndex + 1) % f.size()] == e.end())
|
|
||||||
{
|
|
||||||
// points in face in same order as edge
|
|
||||||
edgeOrder = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// points in face in reverse order as edge
|
|
||||||
edgeOrder = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get faces using edge in sorted order. (sorted such that walking
|
// Get faces using edge in sorted order. (sorted such that walking
|
||||||
// around them in anti-clockwise order corresponds to edge vector
|
// around them in anti-clockwise order corresponds to edge vector
|
||||||
@ -485,25 +475,18 @@ label sharedFace
|
|||||||
if (edgeOrder)
|
if (edgeOrder)
|
||||||
{
|
{
|
||||||
// Get face before firstFaceI
|
// Get face before firstFaceI
|
||||||
if (faceIndex == 0)
|
return eFaces[eFaces.rcIndex(faceIndex)];
|
||||||
{
|
|
||||||
return eFaces[eFaces.size() - 1];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return eFaces[faceIndex - 1];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Get face after firstFaceI
|
// Get face after firstFaceI
|
||||||
return eFaces[(faceIndex+1) % eFaces.size()];
|
return eFaces[eFaces.fcIndex(faceIndex)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Calculate (inward pointing) normals on edges shared by faces in faceToEdge and
|
// Calculate (inward pointing) normals on edges shared by faces in faceToEdge and
|
||||||
// averages them to pointNormals.
|
// averages them to pointNormals.
|
||||||
void calcPointVecs
|
void calcPointVecs
|
||||||
(
|
(
|
||||||
const triSurface& surf,
|
const triSurface& surf,
|
||||||
@ -602,7 +585,7 @@ void calcPointVecs
|
|||||||
}
|
}
|
||||||
|
|
||||||
scalar magMidVec = mag(midVec);
|
scalar magMidVec = mag(midVec);
|
||||||
|
|
||||||
if (magMidVec > SMALL)
|
if (magMidVec > SMALL)
|
||||||
{
|
{
|
||||||
midVec /= magMidVec;
|
midVec /= magMidVec;
|
||||||
@ -925,7 +908,7 @@ int main(int argc, char *argv[])
|
|||||||
newPoints[newPointI] = newPoints[pointI] + 0.1 * minLen * n;
|
newPoints[newPointI] = newPoints[pointI] + 0.1 * minLen * n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Renumber all faces in connectedFaces
|
// Renumber all faces in connectedFaces
|
||||||
|
|||||||
@ -432,7 +432,7 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
|||||||
|
|
||||||
|
|
||||||
// Set the file mode
|
// Set the file mode
|
||||||
bool Foam::chmod(const fileName& name, const mode_t m)
|
bool Foam::chMod(const fileName& name, const mode_t m)
|
||||||
{
|
{
|
||||||
return ::chmod(name.c_str(), m) == 0;
|
return ::chmod(name.c_str(), m) == 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -226,7 +226,7 @@ bool Foam::HashTable<T, Key, Hash>::set
|
|||||||
const bool protect
|
const bool protect
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (tableSize_ == 0)
|
if (!tableSize_)
|
||||||
{
|
{
|
||||||
resize(2);
|
resize(2);
|
||||||
}
|
}
|
||||||
@ -556,7 +556,7 @@ void Foam::HashTable<T, Key, Hash>::operator=
|
|||||||
}
|
}
|
||||||
|
|
||||||
// could be zero-sized from a previous transfer()
|
// could be zero-sized from a previous transfer()
|
||||||
if (tableSize_ == 0)
|
if (!tableSize_)
|
||||||
{
|
{
|
||||||
resize(rhs.tableSize_);
|
resize(rhs.tableSize_);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,7 +54,7 @@ inline Foam::label Foam::HashTable<T, Key, Hash>::size() const
|
|||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
inline bool Foam::HashTable<T, Key, Hash>::empty() const
|
inline bool Foam::HashTable<T, Key, Hash>::empty() const
|
||||||
{
|
{
|
||||||
return (nElmts_ == 0);
|
return !nElmts_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ inline Foam::label Foam::StaticHashTable<T, Key, Hash>::size() const
|
|||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
inline bool Foam::StaticHashTable<T, Key, Hash>::empty() const
|
inline bool Foam::StaticHashTable<T, Key, Hash>::empty() const
|
||||||
{
|
{
|
||||||
return (nElmts_ == 0);
|
return !nElmts_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -83,7 +83,7 @@ inline Foam::label Foam::DLListBase::size() const
|
|||||||
|
|
||||||
inline bool Foam::DLListBase::empty() const
|
inline bool Foam::DLListBase::empty() const
|
||||||
{
|
{
|
||||||
return (nElmts_ == 0);
|
return !nElmts_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -73,7 +73,7 @@ inline Foam::label Foam::SLListBase::size() const
|
|||||||
|
|
||||||
inline bool Foam::SLListBase::empty() const
|
inline bool Foam::SLListBase::empty() const
|
||||||
{
|
{
|
||||||
return (nElmts_ == 0);
|
return !nElmts_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -135,10 +135,21 @@ public:
|
|||||||
inline label fcIndex(const label i) const;
|
inline label fcIndex(const label i) const;
|
||||||
|
|
||||||
//- Return the reverse circular index, i.e. the previous index
|
//- Return the reverse circular index, i.e. the previous index
|
||||||
// which returns to the last at the begining of the list
|
// which returns to the last at the beginning of the list
|
||||||
inline label rcIndex(const label i) const;
|
inline label rcIndex(const label i) const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Return a const pointer to the first data element,
|
||||||
|
// similar to the STL front() method and the string::data() method
|
||||||
|
// This can be used (with caution) when interfacing with C code.
|
||||||
|
inline const T* cdata() const;
|
||||||
|
|
||||||
|
//- Return a pointer to the first data element,
|
||||||
|
// similar to the STL front() method and the string::data() method
|
||||||
|
// This can be used (with caution) when interfacing with C code.
|
||||||
|
inline T* data();
|
||||||
|
|
||||||
|
|
||||||
// Check
|
// Check
|
||||||
|
|
||||||
//- Check start is within valid range (0 ... size-1).
|
//- Check start is within valid range (0 ... size-1).
|
||||||
@ -174,10 +185,10 @@ public:
|
|||||||
|
|
||||||
// Member operators
|
// Member operators
|
||||||
|
|
||||||
//- Return subscript-checked element of FixedList.
|
//- Return element of FixedList.
|
||||||
inline T& operator[](const label);
|
inline T& operator[](const label);
|
||||||
|
|
||||||
//- Return subscript-checked element of constant FixedList.
|
//- Return element of constant FixedList.
|
||||||
inline const T& operator[](const label) const;
|
inline const T& operator[](const label) const;
|
||||||
|
|
||||||
//- Assignment from array operator. Takes linear time.
|
//- Assignment from array operator. Takes linear time.
|
||||||
@ -282,7 +293,7 @@ public:
|
|||||||
//- Return size of the largest possible FixedList.
|
//- Return size of the largest possible FixedList.
|
||||||
inline label max_size() const;
|
inline label max_size() const;
|
||||||
|
|
||||||
//- Return true if the FixedList is empty (i.e., if size() == 0).
|
//- Return true if the FixedList is empty (ie, size() is zero).
|
||||||
inline bool empty() const;
|
inline bool empty() const;
|
||||||
|
|
||||||
//- Swap two FixedLists of the same type in constant time.
|
//- Swap two FixedLists of the same type in constant time.
|
||||||
|
|||||||
@ -121,7 +121,7 @@ inline Foam::label Foam::FixedList<T, Size>::fcIndex(const label i) const
|
|||||||
template<class T, Foam::label Size>
|
template<class T, Foam::label Size>
|
||||||
inline Foam::label Foam::FixedList<T, Size>::rcIndex(const label i) const
|
inline Foam::label Foam::FixedList<T, Size>::rcIndex(const label i) const
|
||||||
{
|
{
|
||||||
return (i == 0 ? Size-1 : i-1);
|
return (i ? i-1 : Size-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -195,9 +195,26 @@ inline void Foam::FixedList<T, Size>::transfer(const FixedList<T, Size>& lst)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, Foam::label Size>
|
||||||
|
inline const T*
|
||||||
|
Foam::FixedList<T, Size>::cdata() const
|
||||||
|
{
|
||||||
|
return v_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, Foam::label Size>
|
||||||
|
inline T*
|
||||||
|
Foam::FixedList<T, Size>::data()
|
||||||
|
{
|
||||||
|
return v_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Return subscript-checked element access
|
// element access
|
||||||
template<class T, Foam::label Size>
|
template<class T, Foam::label Size>
|
||||||
inline T& Foam::FixedList<T, Size>::operator[](const label i)
|
inline T& Foam::FixedList<T, Size>::operator[](const label i)
|
||||||
{
|
{
|
||||||
@ -208,7 +225,7 @@ inline T& Foam::FixedList<T, Size>::operator[](const label i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return subscript-checked const element access
|
// const element access
|
||||||
template<class T, Foam::label Size>
|
template<class T, Foam::label Size>
|
||||||
inline const T& Foam::FixedList<T, Size>::operator[](const label i) const
|
inline const T& Foam::FixedList<T, Size>::operator[](const label i) const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -119,7 +119,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& L)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
is.read(reinterpret_cast<char*>(L.begin()), Size*sizeof(T));
|
is.read(reinterpret_cast<char*>(L.data()), Size*sizeof(T));
|
||||||
|
|
||||||
is.fatalCheck
|
is.fatalCheck
|
||||||
(
|
(
|
||||||
@ -231,7 +231,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const FixedList<T, Size>& L)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
os.write(reinterpret_cast<const char*>(L.v_), Size*sizeof(T));
|
os.write(reinterpret_cast<const char*>(L.cdata()), Size*sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check state of IOstream
|
// Check state of IOstream
|
||||||
|
|||||||
@ -117,7 +117,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
|
|||||||
{
|
{
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
is.read(reinterpret_cast<char*>(L.begin()), s*sizeof(T));
|
is.read(reinterpret_cast<char*>(L.data()), s*sizeof(T));
|
||||||
|
|
||||||
is.fatalCheck
|
is.fatalCheck
|
||||||
(
|
(
|
||||||
|
|||||||
@ -90,17 +90,31 @@ void duplicateOrder(const UList<T>&, labelList& order);
|
|||||||
template<class T>
|
template<class T>
|
||||||
void uniqueOrder(const UList<T>&, labelList& order);
|
void uniqueOrder(const UList<T>&, labelList& order);
|
||||||
|
|
||||||
//- Extract elements of List whose region is certain value.
|
//- Extract elements of List when select is a certain value.
|
||||||
// Use e.g. to extract all selected elements:
|
// eg, to extract all selected elements:
|
||||||
// subset<boolList, labelList>(selectedElems, true, lst);
|
// subset<bool, labelList>(selectedElems, true, lst);
|
||||||
template<class T, class ListType>
|
template<class T, class ListType>
|
||||||
ListType subset(const UList<T>& regions, const T& region, const ListType&);
|
ListType subset(const UList<T>& select, const T& value, const ListType&);
|
||||||
|
|
||||||
//- Inplace extract elements of List whose region is certain value. Use e.g.
|
//- Inplace extract elements of List when select is a certain value.
|
||||||
// to extract all selected elements:
|
// eg, to extract all selected elements:
|
||||||
// inplaceSubset<boolList, labelList>(selectedElems, true, lst);
|
// inplaceSubset<bool, labelList>(selectedElems, true, lst);
|
||||||
template<class T, class ListType>
|
template<class T, class ListType>
|
||||||
void inplaceSubset(const UList<T>& regions, const T& region, ListType&);
|
void inplaceSubset(const UList<T>& select, const T& value, ListType&);
|
||||||
|
|
||||||
|
//- Extract elements of List when select is true
|
||||||
|
// eg, to extract all selected elements:
|
||||||
|
// subset<boolList, labelList>(selectedElems, lst);
|
||||||
|
// Note a labelHashSet could also be used for the bool-list
|
||||||
|
template<class BoolListType, class ListType>
|
||||||
|
ListType subset(const BoolListType& select, const ListType&);
|
||||||
|
|
||||||
|
//- Inplace extract elements of List when select is true
|
||||||
|
// eg, to extract all selected elements:
|
||||||
|
// inplaceSubset<boolList, labelList>(selectedElems, lst);
|
||||||
|
// Note a labelHashSet could also be used for the bool-list
|
||||||
|
template<class BoolListType, class ListType>
|
||||||
|
void inplaceSubset(const BoolListType& select, ListType&);
|
||||||
|
|
||||||
//- Invert one-to-one map. Unmapped elements will be -1.
|
//- Invert one-to-one map. Unmapped elements will be -1.
|
||||||
labelList invert(const label len, const UList<label>&);
|
labelList invert(const label len, const UList<label>&);
|
||||||
@ -108,8 +122,9 @@ labelList invert(const label len, const UList<label>&);
|
|||||||
//- Invert one-to-many map. Unmapped elements will be size 0.
|
//- Invert one-to-many map. Unmapped elements will be size 0.
|
||||||
labelListList invertOneToMany(const label len, const UList<label>&);
|
labelListList invertOneToMany(const label len, const UList<label>&);
|
||||||
|
|
||||||
//- Invert many-to-many. Input and output types need to be inherited
|
//- Invert many-to-many.
|
||||||
// from List. E.g. faces to pointFaces.
|
// Input and output types need to be inherited from List.
|
||||||
|
// eg, faces to pointFaces.
|
||||||
template<class InList, class OutList>
|
template<class InList, class OutList>
|
||||||
void invertManyToMany(const label len, const UList<InList>&, List<OutList>&);
|
void invertManyToMany(const label len, const UList<InList>&, List<OutList>&);
|
||||||
|
|
||||||
|
|||||||
@ -243,16 +243,17 @@ void Foam::uniqueOrder
|
|||||||
template<class T, class ListType>
|
template<class T, class ListType>
|
||||||
ListType Foam::subset
|
ListType Foam::subset
|
||||||
(
|
(
|
||||||
const UList<T>& regions,
|
const UList<T>& select,
|
||||||
const T& region,
|
const T& value,
|
||||||
const ListType& lst
|
const ListType& lst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (regions.size() < lst.size())
|
// select must at least cover the list range
|
||||||
|
if (select.size() < lst.size())
|
||||||
{
|
{
|
||||||
FatalErrorIn("subset(const UList<T>&, const T&, const ListType&)")
|
FatalErrorIn("subset(const UList<T>&, const T&, const ListType&)")
|
||||||
<< "Regions is of size " << regions.size()
|
<< "select is of size " << select.size()
|
||||||
<< "; list it is supposed to index is of size " << lst.size()
|
<< "; but it must index a list of size " << lst.size()
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +262,7 @@ ListType Foam::subset
|
|||||||
label nElem = 0;
|
label nElem = 0;
|
||||||
forAll(lst, elemI)
|
forAll(lst, elemI)
|
||||||
{
|
{
|
||||||
if (regions[elemI] == region)
|
if (select[elemI] == value)
|
||||||
{
|
{
|
||||||
newLst[nElem++] = lst[elemI];
|
newLst[nElem++] = lst[elemI];
|
||||||
}
|
}
|
||||||
@ -275,23 +276,77 @@ ListType Foam::subset
|
|||||||
template<class T, class ListType>
|
template<class T, class ListType>
|
||||||
void Foam::inplaceSubset
|
void Foam::inplaceSubset
|
||||||
(
|
(
|
||||||
const UList<T>& regions,
|
const UList<T>& select,
|
||||||
const T& region,
|
const T& value,
|
||||||
ListType& lst
|
ListType& lst
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (regions.size() < lst.size())
|
// select must at least cover the list range
|
||||||
|
if (select.size() < lst.size())
|
||||||
{
|
{
|
||||||
FatalErrorIn("inplaceSubset(const UList<T>&, const T&, ListType&)")
|
FatalErrorIn("inplaceSubset(const UList<T>&, const T&, ListType&)")
|
||||||
<< "Regions is of size " << regions.size()
|
<< "select is of size " << select.size()
|
||||||
<< "; list it is supposed to index is of size " << lst.size()
|
<< "; but it must index a list of size " << lst.size()
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
label nElem = 0;
|
label nElem = 0;
|
||||||
forAll(lst, elemI)
|
forAll(lst, elemI)
|
||||||
{
|
{
|
||||||
if (regions[elemI] == region)
|
if (select[elemI] == value)
|
||||||
|
{
|
||||||
|
if (nElem != elemI)
|
||||||
|
{
|
||||||
|
lst[nElem] = lst[elemI];
|
||||||
|
}
|
||||||
|
++nElem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lst.setSize(nElem);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class BoolListType, class ListType>
|
||||||
|
ListType Foam::subset
|
||||||
|
(
|
||||||
|
const BoolListType& select,
|
||||||
|
const ListType& lst
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// select can have a different size
|
||||||
|
// eg, when it is a PackedBoolList or a labelHashSet
|
||||||
|
|
||||||
|
ListType newLst(lst.size());
|
||||||
|
|
||||||
|
label nElem = 0;
|
||||||
|
forAll(lst, elemI)
|
||||||
|
{
|
||||||
|
if (select[elemI])
|
||||||
|
{
|
||||||
|
newLst[nElem++] = lst[elemI];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newLst.setSize(nElem);
|
||||||
|
|
||||||
|
return newLst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class BoolListType, class ListType>
|
||||||
|
void Foam::inplaceSubset
|
||||||
|
(
|
||||||
|
const BoolListType& select,
|
||||||
|
ListType& lst
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// select can have a different size
|
||||||
|
// eg, when it is a PackedBoolList or a labelHashSet
|
||||||
|
|
||||||
|
label nElem = 0;
|
||||||
|
forAll(lst, elemI)
|
||||||
|
{
|
||||||
|
if (select[elemI])
|
||||||
{
|
{
|
||||||
if (nElem != elemI)
|
if (nElem != elemI)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -185,7 +185,7 @@ public:
|
|||||||
//- Number of entries.
|
//- Number of entries.
|
||||||
inline label size() const;
|
inline label size() const;
|
||||||
|
|
||||||
//- Return true if the list is empty (i.e., size() == 0).
|
//- Return true if the list is empty (ie, size() is zero).
|
||||||
inline bool empty() const;
|
inline bool empty() const;
|
||||||
|
|
||||||
//- Get value at index I.
|
//- Get value at index I.
|
||||||
|
|||||||
@ -158,7 +158,7 @@ public:
|
|||||||
//- Return the number of elements in the PtrList
|
//- Return the number of elements in the PtrList
|
||||||
inline label size() const;
|
inline label size() const;
|
||||||
|
|
||||||
//- Return true if the PtrList is empty (i.e., if size() == 0).
|
//- Return true if the PtrList is empty (ie, size() is zero).
|
||||||
inline bool empty() const;
|
inline bool empty() const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ Class
|
|||||||
|
|
||||||
Description
|
Description
|
||||||
A 1D vector of objects of type \<T\>, where the size of the vector is
|
A 1D vector of objects of type \<T\>, where the size of the vector is
|
||||||
known and used for subscript bounds checking, etc.
|
known and can be used for subscript bounds checking, etc.
|
||||||
|
|
||||||
Storage is not allocated during construction or use but is supplied to
|
Storage is not allocated during construction or use but is supplied to
|
||||||
the constructor as an argument. This type of list is particularly useful
|
the constructor as an argument. This type of list is particularly useful
|
||||||
@ -140,6 +140,17 @@ public:
|
|||||||
label byteSize() const;
|
label byteSize() const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Return a const pointer to the first data element,
|
||||||
|
// similar to the STL front() method and the string::data() method
|
||||||
|
// This can be used (with caution) when interfacing with C code.
|
||||||
|
inline const T* cdata() const;
|
||||||
|
|
||||||
|
//- Return a pointer to the first data element,
|
||||||
|
// similar to the STL front() method and the string::data() method
|
||||||
|
// This can be used (with caution) when interfacing with C code.
|
||||||
|
inline T* data();
|
||||||
|
|
||||||
|
|
||||||
// Check
|
// Check
|
||||||
|
|
||||||
//- Check start is within valid range (0 ... size-1).
|
//- Check start is within valid range (0 ... size-1).
|
||||||
@ -164,10 +175,12 @@ public:
|
|||||||
|
|
||||||
// Member operators
|
// Member operators
|
||||||
|
|
||||||
//- Return subscript-checked element of UList.
|
//- Return element of UList.
|
||||||
inline T& operator[](const label);
|
inline T& operator[](const label);
|
||||||
|
|
||||||
//- Return subscript-checked element of constant UList.
|
//- Return element of constant UList.
|
||||||
|
// Note that the bool specialization adds lazy evaluation so reading
|
||||||
|
// an out-of-range element returns false without any ill-effects
|
||||||
inline const T& operator[](const label) const;
|
inline const T& operator[](const label) const;
|
||||||
|
|
||||||
//- Allow cast to a const List<T>&
|
//- Allow cast to a const List<T>&
|
||||||
@ -266,7 +279,7 @@ public:
|
|||||||
//- Return size of the largest possible UList.
|
//- Return size of the largest possible UList.
|
||||||
inline label max_size() const;
|
inline label max_size() const;
|
||||||
|
|
||||||
//- Return true if the UList is empty (i.e., if size() == 0).
|
//- Return true if the UList is empty (ie, size() is zero).
|
||||||
inline bool empty() const;
|
inline bool empty() const;
|
||||||
|
|
||||||
//- Swap two ULists of the same type in constant time.
|
//- Swap two ULists of the same type in constant time.
|
||||||
|
|||||||
@ -25,6 +25,7 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
#include "error.H"
|
||||||
|
#include "pTraits.H"
|
||||||
#include "Swap.H"
|
#include "Swap.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
@ -64,7 +65,7 @@ inline Foam::label Foam::UList<T>::fcIndex(const label i) const
|
|||||||
template<class T>
|
template<class T>
|
||||||
inline Foam::label Foam::UList<T>::rcIndex(const label i) const
|
inline Foam::label Foam::UList<T>::rcIndex(const label i) const
|
||||||
{
|
{
|
||||||
return (i == 0 ? size()-1 : i-1);
|
return (i ? i-1 : size()-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -113,9 +114,24 @@ inline void Foam::UList<T>::checkIndex(const label i) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline const T* Foam::UList<T>::cdata() const
|
||||||
|
{
|
||||||
|
return v_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline T* Foam::UList<T>::data()
|
||||||
|
{
|
||||||
|
return v_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Return subscript-checked element access
|
|
||||||
|
// element access
|
||||||
template<class T>
|
template<class T>
|
||||||
inline T& Foam::UList<T>::operator[](const label i)
|
inline T& Foam::UList<T>::operator[](const label i)
|
||||||
{
|
{
|
||||||
@ -126,7 +142,28 @@ inline T& Foam::UList<T>::operator[](const label i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return subscript-checked const element access
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Template specialization for bool
|
||||||
|
template<>
|
||||||
|
inline const bool& Foam::UList<bool>::operator[](const label i) const
|
||||||
|
{
|
||||||
|
// lazy evaluation - return false for out-of-range
|
||||||
|
if (i < size_)
|
||||||
|
{
|
||||||
|
return v_[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Foam::pTraits<bool>::zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end of namespace Foam
|
||||||
|
|
||||||
|
|
||||||
|
// const element access
|
||||||
template<class T>
|
template<class T>
|
||||||
inline const T& Foam::UList<T>::operator[](const label i) const
|
inline const T& Foam::UList<T>::operator[](const label i) const
|
||||||
{
|
{
|
||||||
@ -248,7 +285,7 @@ inline Foam::label Foam::UList<T>::max_size() const
|
|||||||
template<class T>
|
template<class T>
|
||||||
inline bool Foam::UList<T>::empty() const
|
inline bool Foam::UList<T>::empty() const
|
||||||
{
|
{
|
||||||
return (size_ == 0);
|
return !size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -124,7 +124,7 @@ public:
|
|||||||
//- Return the number of elements in the UPtrList
|
//- Return the number of elements in the UPtrList
|
||||||
inline label size() const;
|
inline label size() const;
|
||||||
|
|
||||||
//- Return true if the UPtrList is empty (i.e., if size() == 0).
|
//- Return true if the UPtrList is empty (ie, size() is zero).
|
||||||
inline bool empty() const;
|
inline bool empty() const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -31,11 +31,7 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
defineTypeNameAndDebug(Foam::Time, 0);
|
||||||
{
|
|
||||||
defineTypeNameAndDebug(Time, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
const char* Foam::NamedEnum<Foam::Time::stopAtControls, 4>::names[] =
|
const char* Foam::NamedEnum<Foam::Time::stopAtControls, 4>::names[] =
|
||||||
@ -100,9 +96,11 @@ void Foam::Time::adjustDeltaT()
|
|||||||
void Foam::Time::setControls()
|
void Foam::Time::setControls()
|
||||||
{
|
{
|
||||||
// default is to resume calculation from "latestTime"
|
// default is to resume calculation from "latestTime"
|
||||||
word startFrom("latestTime");
|
word startFrom = controlDict_.lookupOrDefault<word>
|
||||||
|
(
|
||||||
controlDict_.readIfPresent("startFrom", startFrom);
|
"startFrom",
|
||||||
|
"latestTime"
|
||||||
|
);
|
||||||
|
|
||||||
if (startFrom == "startTime")
|
if (startFrom == "startTime")
|
||||||
{
|
{
|
||||||
@ -421,7 +419,7 @@ Foam::instant Foam::Time::findClosestTime(const scalar t) const
|
|||||||
label nearestIndex = -1;
|
label nearestIndex = -1;
|
||||||
scalar deltaT = GREAT;
|
scalar deltaT = GREAT;
|
||||||
|
|
||||||
for (label i=1; i<times.size(); i++)
|
for (label i=1; i < times.size(); i++)
|
||||||
{
|
{
|
||||||
scalar diff = mag(times[i].value() - t);
|
scalar diff = mag(times[i].value() - t);
|
||||||
if (diff < deltaT)
|
if (diff < deltaT)
|
||||||
|
|||||||
@ -103,7 +103,7 @@ Foam::List<Foam::instant> Foam::timeSelector::select
|
|||||||
const List<instant>& Times
|
const List<instant>& Times
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return subset(selected(Times), true, Times);
|
return subset(selected(Times), Times);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ void Foam::timeSelector::inplaceSelect
|
|||||||
List<instant>& Times
|
List<instant>& Times
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
inplaceSubset(selected(Times), true, Times);
|
inplaceSubset(selected(Times), Times);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ Foam::List<Foam::instant> Foam::timeSelector::select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return subset(selectTimes, true, timeDirs);
|
return subset(selectTimes, timeDirs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -123,7 +123,7 @@ Foam::List<Foam::scalar> Foam::scalarRanges::select
|
|||||||
const List<scalar>& values
|
const List<scalar>& values
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return subset(selected(values), true, values);
|
return subset(selected(values), values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ void Foam::scalarRanges::inplaceSelect
|
|||||||
List<scalar>& values
|
List<scalar>& values
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
inplaceSubset(selected(values), true, values);
|
inplaceSubset(selected(values), values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -110,7 +110,7 @@ fileName findEtcFile(const fileName&, bool mandatory=false);
|
|||||||
bool mkDir(const fileName&, mode_t=0777);
|
bool mkDir(const fileName&, mode_t=0777);
|
||||||
|
|
||||||
//- Set the file mode
|
//- Set the file mode
|
||||||
bool chmod(const fileName&, const mode_t);
|
bool chMod(const fileName&, const mode_t);
|
||||||
|
|
||||||
//- Return the file mode
|
//- Return the file mode
|
||||||
mode_t mode(const fileName&);
|
mode_t mode(const fileName&);
|
||||||
|
|||||||
@ -44,7 +44,7 @@ void Foam::interpolationTable<Type>::readTable()
|
|||||||
// Check that the data are okay
|
// Check that the data are okay
|
||||||
check();
|
check();
|
||||||
|
|
||||||
if (this->size() == 0)
|
if (this->empty())
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
|
|||||||
@ -82,7 +82,7 @@ public:
|
|||||||
//- Return true if the reference count is zero
|
//- Return true if the reference count is zero
|
||||||
bool okToDelete() const
|
bool okToDelete() const
|
||||||
{
|
{
|
||||||
return (count_ == 0);
|
return !count_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ inline Foam::label Foam::face::right(const label i) const
|
|||||||
// Edge to the left of face vertex i
|
// Edge to the left of face vertex i
|
||||||
inline Foam::label Foam::face::left(const label i) const
|
inline Foam::label Foam::face::left(const label i) const
|
||||||
{
|
{
|
||||||
return i == 0 ? size() - 1 : (i - 1);
|
return i ? i-1 : size()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -867,7 +867,7 @@ bool primitiveMesh::checkFaceAngles
|
|||||||
forAll(f, fp0)
|
forAll(f, fp0)
|
||||||
{
|
{
|
||||||
// Get vertex after fp
|
// Get vertex after fp
|
||||||
label fp1 = (fp0 + 1) % f.size();
|
label fp1 = f.fcIndex(fp0);
|
||||||
|
|
||||||
// Normalized vector between two consecutive points
|
// Normalized vector between two consecutive points
|
||||||
vector e10(p[f[fp1]] - p[f[fp0]]);
|
vector e10(p[f[fp1]] - p[f[fp0]]);
|
||||||
@ -1636,12 +1636,12 @@ bool primitiveMesh::checkCommonOrder
|
|||||||
|
|
||||||
|
|
||||||
// Vertices before and after on curFace
|
// Vertices before and after on curFace
|
||||||
label fpPlus1 = (fp+1) % curFace.size();
|
label fpPlus1 = curFace.fcIndex(fp);
|
||||||
label fpMin1 = (fp == 0 ? curFace.size()-1 : fp-1);
|
label fpMin1 = curFace.rcIndex(fp);
|
||||||
|
|
||||||
// Vertices before and after on nbFace
|
// Vertices before and after on nbFace
|
||||||
label nbPlus1 = (nb+1) % nbFace.size();
|
label nbPlus1 = nbFace.fcIndex(nb);
|
||||||
label nbMin1 = (nb == 0 ? nbFace.size()-1 : nb-1);
|
label nbMin1 = nbFace.rcIndex(nb);
|
||||||
|
|
||||||
// Find order of walking by comparing next points on both
|
// Find order of walking by comparing next points on both
|
||||||
// faces.
|
// faces.
|
||||||
|
|||||||
@ -155,20 +155,10 @@ void Foam::walkPatch::faceToFace
|
|||||||
|
|
||||||
indexInFace_.append(fp);
|
indexInFace_.append(fp);
|
||||||
|
|
||||||
|
|
||||||
// Visit neighbouring faces in order, starting at fp.
|
// Visit neighbouring faces in order, starting at fp.
|
||||||
for (label i = 0; i < f.size(); i++)
|
for (label i = 0; i < f.size(); i++)
|
||||||
{
|
{
|
||||||
label fp1;
|
label fp1 = reverse_ ? f.rcIndex(fp) : f.fcIndex(fp);
|
||||||
if (reverse_)
|
|
||||||
{
|
|
||||||
fp1 = (fp == 0 ? f.size()-1 : fp-1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fp1 = (fp + 1) % f.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
label nbr = getNeighbour(faceI, fp, f[fp], f[fp1]);
|
label nbr = getNeighbour(faceI, fp, f[fp], f[fp1]);
|
||||||
|
|
||||||
if
|
if
|
||||||
|
|||||||
@ -340,8 +340,8 @@ Foam::label Foam::octreeDataFaceList::getSampleType
|
|||||||
// Face intersection point lies on edge between two face triangles
|
// Face intersection point lies on edge between two face triangles
|
||||||
|
|
||||||
// Calculate edge normal as average of the two triangle normals
|
// Calculate edge normal as average of the two triangle normals
|
||||||
label fpPrev = (fp == 0 ? f.size()-1 : fp-1);
|
label fpPrev = f.rcIndex(fp);
|
||||||
label fpNext = (fp + 1) % f.size();
|
label fpNext = f.fcIndex(fp);
|
||||||
|
|
||||||
vector e = points[f[fp]] - ctr;
|
vector e = points[f[fp]] - ctr;
|
||||||
vector ePrev = points[f[fpPrev]] - ctr;
|
vector ePrev = points[f[fpPrev]] - ctr;
|
||||||
@ -434,7 +434,7 @@ bool Foam::octreeDataFaceList::intersects
|
|||||||
// Disable picking up intersections behind us.
|
// Disable picking up intersections behind us.
|
||||||
scalar oldTol = intersection::setPlanarTol(0.0);
|
scalar oldTol = intersection::setPlanarTol(0.0);
|
||||||
|
|
||||||
pointHit inter =
|
pointHit inter =
|
||||||
f.ray
|
f.ray
|
||||||
(
|
(
|
||||||
start,
|
start,
|
||||||
@ -486,7 +486,7 @@ bool Foam::octreeDataFaceList::findTightest
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Construct bb around sample and myFar
|
// Construct bb around sample and myFar
|
||||||
const point dist2(fabs(dist.x()), fabs(dist.y()), fabs(dist.z()));
|
const point dist2(fabs(dist.x()), fabs(dist.y()), fabs(dist.z()));
|
||||||
|
|
||||||
tightest.min() = sample - dist2;
|
tightest.min() = sample - dist2;
|
||||||
tightest.max() = sample + dist2;
|
tightest.max() = sample + dist2;
|
||||||
@ -558,7 +558,7 @@ Foam::scalar Foam::octreeDataFaceList::calcNearest
|
|||||||
}
|
}
|
||||||
return nearHit.distance();
|
return nearHit.distance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::octreeDataFaceList::write
|
void Foam::octreeDataFaceList::write
|
||||||
(
|
(
|
||||||
|
|||||||
@ -374,7 +374,7 @@ void Foam::cellCuts::calcFaceCuts() const
|
|||||||
label cutI = 0;
|
label cutI = 0;
|
||||||
|
|
||||||
// Do point-edge-point walk over face and collect all cuts.
|
// Do point-edge-point walk over face and collect all cuts.
|
||||||
// Problem is that we want to start from one of the endpoints of a
|
// Problem is that we want to start from one of the endpoints of a
|
||||||
// string of connected cuts; we don't want to start somewhere in the
|
// string of connected cuts; we don't want to start somewhere in the
|
||||||
// middle.
|
// middle.
|
||||||
|
|
||||||
@ -387,17 +387,16 @@ void Foam::cellCuts::calcFaceCuts() const
|
|||||||
|
|
||||||
if (pointIsCut_[v0])
|
if (pointIsCut_[v0])
|
||||||
{
|
{
|
||||||
label fpMin1 = (fp == 0 ? f.size()-1 : fp-1);
|
label vMin1 = f[f.rcIndex(fp)];
|
||||||
label vMin1 = f[fpMin1];
|
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
!pointIsCut_[vMin1]
|
!pointIsCut_[vMin1]
|
||||||
&& !edgeIsCut_[findEdge(faceI, v0, vMin1)]
|
&& !edgeIsCut_[findEdge(faceI, v0, vMin1)]
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
cuts[cutI++] = vertToEVert(v0);
|
cuts[cutI++] = vertToEVert(v0);
|
||||||
startFp = (fp+1) % f.size();
|
startFp = f.fcIndex(fp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -408,7 +407,7 @@ void Foam::cellCuts::calcFaceCuts() const
|
|||||||
{
|
{
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
label fp1 = (fp+1) % f.size();
|
label fp1 = f.fcIndex(fp);
|
||||||
|
|
||||||
label v0 = f[fp];
|
label v0 = f[fp];
|
||||||
label v1 = f[fp1];
|
label v1 = f[fp1];
|
||||||
@ -438,7 +437,7 @@ void Foam::cellCuts::calcFaceCuts() const
|
|||||||
|
|
||||||
forAll(f, i)
|
forAll(f, i)
|
||||||
{
|
{
|
||||||
label fp1 = (fp+1) % f.size();
|
label fp1 = f.fcIndex(fp);
|
||||||
|
|
||||||
// Get the three items: current vertex, next vertex and edge
|
// Get the three items: current vertex, next vertex and edge
|
||||||
// inbetween
|
// inbetween
|
||||||
@ -659,7 +658,7 @@ bool Foam::cellCuts::crossEdge
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// No success. Restore state (i.e. backtrack)
|
// No success. Restore state (i.e. backtrack)
|
||||||
nVisited = oldNVisited;
|
nVisited = oldNVisited;
|
||||||
|
|
||||||
@ -794,7 +793,7 @@ bool Foam::cellCuts::walkFace
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Walk across cuts (cut edges or cut vertices) of cell. Stops when hit cut
|
// Walk across cuts (cut edges or cut vertices) of cell. Stops when hit cut
|
||||||
// already visited. Returns true when loop of 3 or more vertices found.
|
// already visited. Returns true when loop of 3 or more vertices found.
|
||||||
bool Foam::cellCuts::walkCell
|
bool Foam::cellCuts::walkCell
|
||||||
(
|
(
|
||||||
@ -1202,7 +1201,7 @@ Foam::labelList Foam::cellCuts::nonAnchorPoints
|
|||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
findIndex(anchorPoints, pointI) == -1
|
findIndex(anchorPoints, pointI) == -1
|
||||||
&& findIndex(loop, vertToEVert(pointI)) == -1
|
&& findIndex(loop, vertToEVert(pointI)) == -1
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -1556,7 +1555,7 @@ bool Foam::cellCuts::calcAnchors
|
|||||||
}
|
}
|
||||||
prevStat = eStat;
|
prevStat = eStat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2135,7 +2134,7 @@ bool Foam::cellCuts::setFromCellLoop
|
|||||||
// Storage for points on one side of cell
|
// Storage for points on one side of cell
|
||||||
labelList anchorPoints;
|
labelList anchorPoints;
|
||||||
|
|
||||||
okLoop =
|
okLoop =
|
||||||
validLoop(cellI, loop, loopWeights, faceSplitCuts, anchorPoints);
|
validLoop(cellI, loop, loopWeights, faceSplitCuts, anchorPoints);
|
||||||
|
|
||||||
if (okLoop)
|
if (okLoop)
|
||||||
@ -3007,7 +3006,7 @@ void Foam::cellCuts::flip(const label cellI)
|
|||||||
mesh().cellPoints()[cellI],
|
mesh().cellPoints()[cellI],
|
||||||
cellAnchorPoints_[cellI],
|
cellAnchorPoints_[cellI],
|
||||||
loop
|
loop
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,6 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
|
|
||||||
defineTypeNameAndDebug(geomCellLooper, 0);
|
defineTypeNameAndDebug(geomCellLooper, 0);
|
||||||
|
|
||||||
addToRunTimeSelectionTable(cellLooper, geomCellLooper, word);
|
addToRunTimeSelectionTable(cellLooper, geomCellLooper, word);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -187,8 +186,8 @@ bool Foam::geomCellLooper::edgeEndsCut
|
|||||||
|
|
||||||
const edge& e = mesh().edges()[edgeI];
|
const edge& e = mesh().edges()[edgeI];
|
||||||
|
|
||||||
label prevCut = loop[(index == 0 ? loop.size()-1 : index-1)];
|
const label prevCut = loop[loop.rcIndex(index)];
|
||||||
label nextCut = loop[(index == loop.size()-1 ? 0 : index+1)];
|
const label nextCut = loop[loop.fcIndex(index)];
|
||||||
|
|
||||||
if (!isEdge(prevCut) && !isEdge(nextCut))
|
if (!isEdge(prevCut) && !isEdge(nextCut))
|
||||||
{
|
{
|
||||||
@ -360,7 +359,7 @@ bool Foam::geomCellLooper::cut
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Cut through edge end point. Might be duplicate
|
// Cut through edge end point. Might be duplicate
|
||||||
// since connected edge might also be snapped to same
|
// since connected edge might also be snapped to same
|
||||||
// endpoint so only insert if unique.
|
// endpoint so only insert if unique.
|
||||||
label cut = vertToEVert(cutVertI);
|
label cut = vertToEVert(cutVertI);
|
||||||
|
|||||||
@ -76,24 +76,11 @@ bool Foam::meshCutAndRemove::isIn
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
label nextIndex = (index + 1) % cuts.size();
|
return
|
||||||
|
(
|
||||||
if (cuts[nextIndex] == twoCuts[1])
|
cuts[cuts.fcIndex(index)] == twoCuts[1]
|
||||||
{
|
|| cuts[cuts.rcIndex(index)] == twoCuts[1]
|
||||||
return true;
|
);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
label prevIndex = (index == 0 ? cuts.size()-1 : index - 1);
|
|
||||||
|
|
||||||
if (cuts[prevIndex] == twoCuts[1])
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -502,11 +489,11 @@ Foam::face Foam::meshCutAndRemove::addEdgeCutsToFace(const label faceI) const
|
|||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
// Duplicate face vertex .
|
// Duplicate face vertex.
|
||||||
newFace[newFp++] = f[fp];
|
newFace[newFp++] = f[fp];
|
||||||
|
|
||||||
// Check if edge has been cut.
|
// Check if edge has been cut.
|
||||||
label fp1 = (fp + 1) % f.size();
|
label fp1 = f.fcIndex(fp);
|
||||||
|
|
||||||
HashTable<label, edge, Hash<edge> >::const_iterator fnd =
|
HashTable<label, edge, Hash<edge> >::const_iterator fnd =
|
||||||
addedPoints_.find(edge(f[fp], f[fp1]));
|
addedPoints_.find(edge(f[fp], f[fp1]));
|
||||||
@ -558,7 +545,7 @@ Foam::face Foam::meshCutAndRemove::loopToFace
|
|||||||
|
|
||||||
newFace[newFaceI++] = vertI;
|
newFace[newFaceI++] = vertI;
|
||||||
|
|
||||||
label nextCut = loop[(fp+1) % loop.size()];
|
label nextCut = loop[loop.fcIndex(fp)];
|
||||||
|
|
||||||
if (!isEdge(nextCut))
|
if (!isEdge(nextCut))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -72,24 +72,11 @@ bool Foam::meshCutter::isIn
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
label nextIndex = (index + 1) % cuts.size();
|
return
|
||||||
|
(
|
||||||
if (cuts[nextIndex] == twoCuts[1])
|
cuts[cuts.fcIndex(index)] == twoCuts[1]
|
||||||
{
|
|| cuts[cuts.rcIndex(index)] == twoCuts[1]
|
||||||
return true;
|
);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
label prevIndex = (index == 0 ? cuts.size()-1 : index - 1);
|
|
||||||
|
|
||||||
if (cuts[prevIndex] == twoCuts[1])
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -459,7 +446,7 @@ Foam::face Foam::meshCutter::addEdgeCutsToFace(const label faceI) const
|
|||||||
newFace[newFp++] = f[fp];
|
newFace[newFp++] = f[fp];
|
||||||
|
|
||||||
// Check if edge has been cut.
|
// Check if edge has been cut.
|
||||||
label fp1 = (fp + 1) % f.size();
|
label fp1 = f.fcIndex(fp);
|
||||||
|
|
||||||
HashTable<label, edge, Hash<edge> >::const_iterator fnd =
|
HashTable<label, edge, Hash<edge> >::const_iterator fnd =
|
||||||
addedPoints_.find(edge(f[fp], f[fp1]));
|
addedPoints_.find(edge(f[fp], f[fp1]));
|
||||||
@ -511,7 +498,7 @@ Foam::face Foam::meshCutter::loopToFace
|
|||||||
|
|
||||||
newFace[newFaceI++] = vertI;
|
newFace[newFaceI++] = vertI;
|
||||||
|
|
||||||
label nextCut = loop[(fp+1) % loop.size()];
|
label nextCut = loop[loop.fcIndex(fp)];
|
||||||
|
|
||||||
if (!isEdge(nextCut))
|
if (!isEdge(nextCut))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1284,7 +1284,7 @@ bool Foam::polyMeshGeometry::checkFaceAngles
|
|||||||
forAll(f, fp0)
|
forAll(f, fp0)
|
||||||
{
|
{
|
||||||
// Get vertex after fp
|
// Get vertex after fp
|
||||||
label fp1 = (fp0 + 1) % f.size();
|
label fp1 = f.fcIndex(fp0);
|
||||||
|
|
||||||
// Normalized vector between two consecutive points
|
// Normalized vector between two consecutive points
|
||||||
vector e10(p[f[fp1]] - p[f[fp0]]);
|
vector e10(p[f[fp1]] - p[f[fp0]]);
|
||||||
|
|||||||
@ -69,7 +69,7 @@ bool Foam::combineFaces::convexFace
|
|||||||
forAll(f, fp0)
|
forAll(f, fp0)
|
||||||
{
|
{
|
||||||
// Get vertex after fp
|
// Get vertex after fp
|
||||||
label fp1 = (fp0 + 1) % f.size();
|
label fp1 = f.fcIndex(fp0);
|
||||||
|
|
||||||
// Normalized vector between two consecutive points
|
// Normalized vector between two consecutive points
|
||||||
vector e10(points[f[fp1]] - points[f[fp0]]);
|
vector e10(points[f[fp1]] - points[f[fp0]]);
|
||||||
@ -730,7 +730,7 @@ void Foam::combineFaces::setRefinement
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Count removed points
|
// Count removed points
|
||||||
label n = 0;
|
label n = 0;
|
||||||
forAll(nPointFaces, pointI)
|
forAll(nPointFaces, pointI)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -71,7 +71,7 @@ Foam::label Foam::faceCollapser::findEdge
|
|||||||
label edgeI = edgeLabels[i];
|
label edgeI = edgeLabels[i];
|
||||||
|
|
||||||
const edge& e = edges[edgeI];
|
const edge& e = edges[edgeI];
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
(e[0] == v0 && e[1] == v1)
|
(e[0] == v0 && e[1] == v1)
|
||||||
@ -113,7 +113,7 @@ void Foam::faceCollapser::filterFace
|
|||||||
newFace.append(v0);
|
newFace.append(v0);
|
||||||
|
|
||||||
// Look ahead one to get edge.
|
// Look ahead one to get edge.
|
||||||
label fp1 = (fp + 1) % f.size();
|
label fp1 = f.fcIndex(fp);
|
||||||
|
|
||||||
label v1 = f[fp1];
|
label v1 = f[fp1];
|
||||||
|
|
||||||
@ -410,7 +410,7 @@ void Foam::faceCollapser::setRefinement
|
|||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
label fp1 = (fp + 1) % f.size();
|
label fp1 = f.fcIndex(fp);
|
||||||
|
|
||||||
// Get index in sorted list
|
// Get index in sorted list
|
||||||
label sorted0 = sortedFp[fp];
|
label sorted0 = sortedFp[fp];
|
||||||
|
|||||||
@ -50,7 +50,7 @@ bool Foam::cellFeatures::faceAlignedEdge(const label faceI, const label edgeI)
|
|||||||
{
|
{
|
||||||
if (f[fp] == e.start())
|
if (f[fp] == e.start())
|
||||||
{
|
{
|
||||||
label fp1 = (fp + 1) % f.size();
|
label fp1 = f.fcIndex(fp);
|
||||||
|
|
||||||
return f[fp1] == e.end();
|
return f[fp1] == e.end();
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ Foam::label Foam::cellFeatures::nextEdge
|
|||||||
<< thisEdgeI << " at vertex " << thisVertI << endl
|
<< thisEdgeI << " at vertex " << thisVertI << endl
|
||||||
<< "This might mean that the externalEdges do not form a closed loop"
|
<< "This might mean that the externalEdges do not form a closed loop"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,12 +146,12 @@ bool Foam::cellFeatures::isCellFeatureEdge
|
|||||||
const face& f0 = mesh_.faces()[face0];
|
const face& f0 = mesh_.faces()[face0];
|
||||||
|
|
||||||
label face0Start = findIndex(f0, e.start());
|
label face0Start = findIndex(f0, e.start());
|
||||||
label face0End = (face0Start + 1) % f0.size();
|
label face0End = f0.fcIndex(face0Start);
|
||||||
|
|
||||||
const face& f1 = mesh_.faces()[face1];
|
const face& f1 = mesh_.faces()[face1];
|
||||||
|
|
||||||
label face1Start = findIndex(f1, e.start());
|
label face1Start = findIndex(f1, e.start());
|
||||||
label face1End = (face1Start + 1) % f1.size();
|
label face1End = f1.fcIndex(face1Start);
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -268,7 +268,7 @@ void Foam::cellFeatures::calcSuperFaces() const
|
|||||||
{
|
{
|
||||||
faceMap_[superI].shrink();
|
faceMap_[superI].shrink();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Construct superFaces
|
// Construct superFaces
|
||||||
|
|
||||||
|
|||||||
@ -440,8 +440,8 @@ Foam::label Foam::octreeDataFace::getSampleType
|
|||||||
// Face intersection point lies on edge between two face triangles
|
// Face intersection point lies on edge between two face triangles
|
||||||
|
|
||||||
// Calculate edge normal as average of the two triangle normals
|
// Calculate edge normal as average of the two triangle normals
|
||||||
label fpPrev = (fp == 0 ? f.size()-1 : fp-1);
|
const label fpPrev = f.rcIndex(fp);
|
||||||
label fpNext = (fp + 1) % f.size();
|
const label fpNext = f.fcIndex(fp);
|
||||||
|
|
||||||
vector e = points[f[fp]] - mesh_.faceCentres()[faceI];
|
vector e = points[f[fp]] - mesh_.faceCentres()[faceI];
|
||||||
vector ePrev = points[f[fpPrev]] - mesh_.faceCentres()[faceI];
|
vector ePrev = points[f[fpPrev]] - mesh_.faceCentres()[faceI];
|
||||||
@ -530,7 +530,7 @@ bool Foam::octreeDataFace::overlaps
|
|||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
label fp1 = (fp == f.size()-1 ? 0 : fp+1);
|
const label fp1 = f.fcIndex(fp);
|
||||||
|
|
||||||
bool triIntersects = triangleFuncs::intersectBb
|
bool triIntersects = triangleFuncs::intersectBb
|
||||||
(
|
(
|
||||||
|
|||||||
@ -808,7 +808,7 @@ bool Foam::primitiveMeshGeometry::checkFaceAngles
|
|||||||
forAll(f, fp0)
|
forAll(f, fp0)
|
||||||
{
|
{
|
||||||
// Get vertex after fp
|
// Get vertex after fp
|
||||||
label fp1 = (fp0 + 1) % f.size();
|
label fp1 = f.fcIndex(fp0);
|
||||||
|
|
||||||
// Normalized vector between two consecutive points
|
// Normalized vector between two consecutive points
|
||||||
vector e10(p[f[fp1]] - p[f[fp0]]);
|
vector e10(p[f[fp1]] - p[f[fp0]]);
|
||||||
|
|||||||
@ -241,14 +241,14 @@ void Foam::booleanSurface::propagateEdgeSide
|
|||||||
{
|
{
|
||||||
// Edge (and hence eFaces) in same order as prevVert0.
|
// Edge (and hence eFaces) in same order as prevVert0.
|
||||||
// Take next face from sorted list
|
// Take next face from sorted list
|
||||||
nextInd = (ind + 1) % eFaces.size();
|
nextInd = eFaces.fcIndex(ind);
|
||||||
prevInd = (ind > 0 ? ind - 1 : eFaces.size()-1);
|
prevInd = eFaces.rcIndex(ind);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Take previous face from sorted neighbours
|
// Take previous face from sorted neighbours
|
||||||
nextInd = (ind > 0 ? ind - 1 : eFaces.size()-1);
|
nextInd = eFaces.rcIndex(ind);
|
||||||
prevInd = (ind + 1) % eFaces.size();
|
prevInd = eFaces.fcIndex(ind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -222,11 +222,11 @@ bool Foam::intersectedSurface::sameEdgeOrder
|
|||||||
{
|
{
|
||||||
// Get prev/next vertex on fA
|
// Get prev/next vertex on fA
|
||||||
label vA1 = fA[(fpA + 1) % 3];
|
label vA1 = fA[(fpA + 1) % 3];
|
||||||
label vAMin1 = fA[fpA == 0 ? 2 : fpA-1];
|
label vAMin1 = fA[fpA ? fpA-1 : 2];
|
||||||
|
|
||||||
// Get prev/next vertex on fB
|
// Get prev/next vertex on fB
|
||||||
label vB1 = fB[(fpB + 1) % 3];
|
label vB1 = fB[(fpB + 1) % 3];
|
||||||
label vBMin1 = fB[fpB == 0 ? 2 : fpB-1];
|
label vBMin1 = fB[fpB ? fpB-1 : 2];
|
||||||
|
|
||||||
if (vA1 == vB1 || vAMin1 == vBMin1)
|
if (vA1 == vB1 || vAMin1 == vBMin1)
|
||||||
{
|
{
|
||||||
@ -1308,14 +1308,14 @@ Foam::intersectedSurface::intersectedSurface
|
|||||||
// Construct mapping back into original surface
|
// Construct mapping back into original surface
|
||||||
faceMap_.setSize(size());
|
faceMap_.setSize(size());
|
||||||
|
|
||||||
for(label faceI = 0; faceI < surf.size()-1; faceI++)
|
for (label faceI = 0; faceI < surf.size()-1; faceI++)
|
||||||
{
|
{
|
||||||
for(label triI = startTriI[faceI]; triI < startTriI[faceI+1]; triI++)
|
for (label triI = startTriI[faceI]; triI < startTriI[faceI+1]; triI++)
|
||||||
{
|
{
|
||||||
faceMap_[triI] = faceI;
|
faceMap_[triI] = faceI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(label triI = startTriI[surf.size()-1]; triI < size(); triI++)
|
for (label triI = startTriI[surf.size()-1]; triI < size(); triI++)
|
||||||
{
|
{
|
||||||
faceMap_[triI] = surf.size()-1;
|
faceMap_[triI] = surf.size()-1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -473,7 +473,7 @@ Foam::label Foam::BasicMeshedSurface<Face>::triangulate
|
|||||||
|
|
||||||
for (label fp = 1; fp < f.size() - 1; ++fp)
|
for (label fp = 1; fp < f.size() - 1; ++fp)
|
||||||
{
|
{
|
||||||
label fp1 = (fp + 1) % f.size();
|
label fp1 = f.fcIndex(fp);
|
||||||
|
|
||||||
newFaces[newFaceI] = triFace(f[0], f[fp], f[fp1]);
|
newFaces[newFaceI] = triFace(f[0], f[fp], f[fp1]);
|
||||||
faceMap[newFaceI] = faceI;
|
faceMap[newFaceI] = faceI;
|
||||||
|
|||||||
@ -269,6 +269,22 @@ void Foam::surfMesh::transfer
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::Xfer< Foam::MeshedSurface<Foam::face> >
|
||||||
|
Foam::surfMesh::xfer()
|
||||||
|
{
|
||||||
|
Xfer< MeshedSurface<face> > xf;
|
||||||
|
|
||||||
|
xf().storedPoints().transfer(storedPoints_);
|
||||||
|
xf().storedFaces().transfer(storedFaces_);
|
||||||
|
xf().storedZones().transfer(surfZones_);
|
||||||
|
|
||||||
|
// Clear addressing.
|
||||||
|
MeshReference::clearGeom();
|
||||||
|
|
||||||
|
return xf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::surfMesh::rename(const word& newName)
|
void Foam::surfMesh::rename(const word& newName)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
|
|||||||
@ -315,6 +315,9 @@ public:
|
|||||||
|
|
||||||
// Storage management
|
// Storage management
|
||||||
|
|
||||||
|
//- Transfer contents to the Xfer container as a MeshedSurface
|
||||||
|
Xfer< MeshedSurface<face> > xfer();
|
||||||
|
|
||||||
//- Clear geometry
|
//- Clear geometry
|
||||||
void clearGeom();
|
void clearGeom();
|
||||||
|
|
||||||
|
|||||||
@ -227,7 +227,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
|||||||
// points may be incomplete
|
// points may be incomplete
|
||||||
for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
|
for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
|
||||||
{
|
{
|
||||||
label fp2 = (fp1 + 1) % f.size();
|
label fp2 = f.fcIndex(fp1);
|
||||||
|
|
||||||
dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
|
dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
|
||||||
sizes[zoneI]++;
|
sizes[zoneI]++;
|
||||||
|
|||||||
@ -182,7 +182,7 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
|||||||
// points may be incomplete
|
// points may be incomplete
|
||||||
for (label fp1 = 1; fp1 < f.size() - 1; fp1++)
|
for (label fp1 = 1; fp1 < f.size() - 1; fp1++)
|
||||||
{
|
{
|
||||||
label fp2 = (fp1 + 1) % f.size();
|
label fp2 = f.fcIndex(fp1);
|
||||||
|
|
||||||
dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
|
dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
|
||||||
dynZones.append(zoneI);
|
dynZones.append(zoneI);
|
||||||
|
|||||||
@ -130,7 +130,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
|
|||||||
// cannot use face::triangulation (points may be incomplete)
|
// cannot use face::triangulation (points may be incomplete)
|
||||||
for (label fp1 = 1; fp1 < f.size() - 1; fp1++)
|
for (label fp1 = 1; fp1 < f.size() - 1; fp1++)
|
||||||
{
|
{
|
||||||
label fp2 = (fp1 + 1) % f.size();
|
label fp2 = f.fcIndex(fp1);
|
||||||
|
|
||||||
dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
|
dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,7 +54,7 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
|
|||||||
const point& p0 = pointLst[f[0]];
|
const point& p0 = pointLst[f[0]];
|
||||||
for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
|
for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
|
||||||
{
|
{
|
||||||
label fp2 = (fp1 + 1) % f.size();
|
label fp2 = f.fcIndex(fp1);
|
||||||
|
|
||||||
const point& p1 = pointLst[f[fp1]];
|
const point& p1 = pointLst[f[fp1]];
|
||||||
const point& p2 = pointLst[f[fp2]];
|
const point& p2 = pointLst[f[fp2]];
|
||||||
@ -95,7 +95,7 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
|
|||||||
const point& p0 = pointLst[f[0]];
|
const point& p0 = pointLst[f[0]];
|
||||||
for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
|
for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
|
||||||
{
|
{
|
||||||
label fp2 = (fp1 + 1) % f.size();
|
label fp2 = f.fcIndex(fp1);
|
||||||
|
|
||||||
STLtriangle stlTri
|
STLtriangle stlTri
|
||||||
(
|
(
|
||||||
|
|||||||
@ -45,7 +45,7 @@ inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
|
|||||||
const point& p0 = pointLst[f[0]];
|
const point& p0 = pointLst[f[0]];
|
||||||
for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
|
for (label fp1 = 1; fp1 < f.size() - 1; ++fp1)
|
||||||
{
|
{
|
||||||
label fp2 = (fp1 + 1) % f.size();
|
label fp2 = f.fcIndex(fp1);
|
||||||
|
|
||||||
const point& p1 = pointLst[f[fp1]];
|
const point& p1 = pointLst[f[fp1]];
|
||||||
const point& p2 = pointLst[f[fp2]];
|
const point& p2 = pointLst[f[fp2]];
|
||||||
|
|||||||
@ -33,17 +33,17 @@ License
|
|||||||
const Foam::scalar Foam::faceTriangulation::edgeRelTol = 1E-6;
|
const Foam::scalar Foam::faceTriangulation::edgeRelTol = 1E-6;
|
||||||
|
|
||||||
|
|
||||||
//- Edge to the right of face vertex i
|
// Edge to the right of face vertex i
|
||||||
Foam::label Foam::faceTriangulation::right(const label, label i)
|
Foam::label Foam::faceTriangulation::right(const label, label i)
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Edge to the left of face vertex i
|
// Edge to the left of face vertex i
|
||||||
Foam::label Foam::faceTriangulation::left(const label size, label i)
|
Foam::label Foam::faceTriangulation::left(const label size, label i)
|
||||||
{
|
{
|
||||||
return i == 0 ? size - 1 : (i - 1);
|
return i ? i-1 : size-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -60,10 +60,8 @@ Foam::tmp<Foam::vectorField> Foam::faceTriangulation::calcEdges
|
|||||||
|
|
||||||
forAll(f, i)
|
forAll(f, i)
|
||||||
{
|
{
|
||||||
label ni = f.fcIndex(i);
|
|
||||||
|
|
||||||
point thisPt = points[f[i]];
|
point thisPt = points[f[i]];
|
||||||
point nextPt = points[f[ni]];
|
point nextPt = points[f[f.fcIndex(i)]];
|
||||||
|
|
||||||
vector vec(nextPt - thisPt);
|
vector vec(nextPt - thisPt);
|
||||||
vec /= mag(vec) + VSMALL;
|
vec /= mag(vec) + VSMALL;
|
||||||
@ -109,7 +107,7 @@ void Foam::faceTriangulation::calcHalfAngle
|
|||||||
// Return true and intersection point if intersection between p1 and p2.
|
// Return true and intersection point if intersection between p1 and p2.
|
||||||
Foam::pointHit Foam::faceTriangulation::rayEdgeIntersect
|
Foam::pointHit Foam::faceTriangulation::rayEdgeIntersect
|
||||||
(
|
(
|
||||||
const vector& normal,
|
const vector& normal,
|
||||||
const point& rayOrigin,
|
const point& rayOrigin,
|
||||||
const vector& rayDir,
|
const vector& rayDir,
|
||||||
const point& p1,
|
const point& p1,
|
||||||
@ -225,10 +223,10 @@ void Foam::faceTriangulation::findDiagonal
|
|||||||
label minIndex = -1;
|
label minIndex = -1;
|
||||||
scalar minPosOnEdge = GREAT;
|
scalar minPosOnEdge = GREAT;
|
||||||
|
|
||||||
for(label i = 0; i < f.size() - 2; i++)
|
for (label i = 0; i < f.size() - 2; i++)
|
||||||
{
|
{
|
||||||
scalar posOnEdge;
|
scalar posOnEdge;
|
||||||
pointHit inter =
|
pointHit inter =
|
||||||
rayEdgeIntersect
|
rayEdgeIntersect
|
||||||
(
|
(
|
||||||
normal,
|
normal,
|
||||||
@ -258,7 +256,7 @@ void Foam::faceTriangulation::findDiagonal
|
|||||||
|
|
||||||
index1 = -1;
|
index1 = -1;
|
||||||
index2 = -1;
|
index2 = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const label leftIndex = minIndex;
|
const label leftIndex = minIndex;
|
||||||
@ -299,7 +297,7 @@ void Foam::faceTriangulation::findDiagonal
|
|||||||
|
|
||||||
// all vertices except for startIndex and ones to left and right of it.
|
// all vertices except for startIndex and ones to left and right of it.
|
||||||
faceVertI = f.fcIndex(f.fcIndex(startIndex));
|
faceVertI = f.fcIndex(f.fcIndex(startIndex));
|
||||||
for(label i = 0; i < f.size() - 3; i++)
|
for (label i = 0; i < f.size() - 3; i++)
|
||||||
{
|
{
|
||||||
const point& pt = points[f[faceVertI]];
|
const point& pt = points[f[faceVertI]];
|
||||||
|
|
||||||
@ -400,7 +398,7 @@ Foam::label Foam::faceTriangulation::findStart
|
|||||||
|
|
||||||
return minIndex;
|
return minIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -153,7 +153,7 @@ bool triSurface::readOBJ(const fileName& OBJfileName)
|
|||||||
// Cannot use face::triangulation since no complete points yet.
|
// Cannot use face::triangulation since no complete points yet.
|
||||||
for (label fp = 1; fp < verts.size() - 1; fp++)
|
for (label fp = 1; fp < verts.size() - 1; fp++)
|
||||||
{
|
{
|
||||||
label fp1 = (fp + 1) % verts.size();
|
label fp1 = verts.fcIndex(fp);
|
||||||
|
|
||||||
labelledTri tri(verts[0], verts[fp], verts[fp1], groupID);
|
labelledTri tri(verts[0], verts[fp], verts[fp1], groupID);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user