69 label fp0 =
f.find(
e[0]);
70 label fp1 =
f.fcIndex(fp0);
71 label fp2 =
f.fcIndex(fp1);
156void createBoundaryEdgeTrees
168 treeBoundaryEdges[surfI] =
189 treeBoundaryEdges[surfI]
201class findNearestOpSubset
203 const indexedOctree<treeDataEdge>& tree_;
205 DynamicList<label>& shapeMask_;
211 const indexedOctree<treeDataEdge>&
tree,
212 DynamicList<label>& shapeMask
216 shapeMask_(shapeMask)
224 scalar& nearestDistSqr,
229 const treeDataEdge& shape = tree_.
shapes();
231 for (
const label index : indices)
235 if (shapeMask_.
found(edgeIndex))
247 if (distSqr < nearestDistSqr)
249 nearestDistSqr = distSqr;
251 nearestPoint = nearHit.
point();
261int main(
int argc,
char *argv[])
265 "Hook surfaces to other surfaces by moving and retriangulating their"
266 " boundary edges to match other surface boundary edges"
275 "Maximum number of iterations (default: 100)"
288 const scalar dist(
args.get<scalar>(1));
289 const scalar matchTolerance(
Foam::max(1
e-6*dist, SMALL));
290 const label
maxIters =
args.getOrDefault<label>(
"maxIters", 100);
292 Info<<
"Hooking distance = " << dist <<
nl
314 const wordList& regions = surfs[surfI].regions();
315 forAll(regions, surfRegionI)
327 List<DynamicList<labelledTri>> newFaces(surfs.
size());
328 List<DynamicList<point>> newPoints(surfs.
size());
329 List<bitSet> visitedFace(surfs.
size());
344 "hookedSurface_" + surfs.names()[surfI],
359 Info<<
nl <<
"Iteration = " << nIters++ <<
endl;
362 createBoundaryEdgeTrees(newSurfaces, bEdgeTrees, treeBoundaryEdges);
364 forAll(newSurfaces, surfI)
366 const triSurface& newSurf = newSurfaces[surfI];
370 visitedFace[surfI] = bitSet(newSurf.
size(),
false);
373 forAll(newSurfaces, surfI)
382 forAll(bPointsTobEdges, bPointi)
389 const labelList& pEdges = pointEdges[pointi];
401 bEdgeTree.findNearest
426 nearestHit = currentHit;
427 bPointsHitTree[bPointi] = treeI;
431 if (nearestHit.
hit())
451 forAll(bPointsTobEdges, bPointi)
457 const label hitSurfI = bPointsHitTree[bPointi];
458 const triSurface& hitSurf = newSurfaces[hitSurfI];
461 treeBoundaryEdges[hitSurfI][eHit.
index()];
468 if (eFaces.
size() != 1)
471 <<
"Edge is attached to " << eFaces.
size()
472 <<
" faces." <<
endl;
477 const label facei = eFaces[0];
479 if (visitedFace[hitSurfI][facei])
508 if (hitSurfI == surfI)
514 newPoints[hitSurfI].append(newPoints[surfI][pointi]);
515 newPointi = newPoints[hitSurfI].size() - 1;
528 visitedFace[hitSurfI].set(facei);
530 forAll(newFacesFromSplit, newFacei)
532 const labelledTri& fN = newFacesFromSplit[newFacei];
536 newFaces[hitSurfI][facei] = fN;
540 newFaces[hitSurfI].
append(fN);
547 Info<<
" Number of edges split = " << nChanged <<
endl;
549 forAll(newSurfaces, surfI)
558 "hookedSurface_" + surfs.names()[surfI],
573 }
while (nChanged > 0 && nIters <=
maxIters);
577 forAll(newSurfaces, surfI)
581 Info<<
"Writing hooked surface " << newSurf.searchableSurface::name()
584 newSurf.searchableSurface::write();
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
scalar distance() const noexcept
Return distance to hit.
bool hit() const noexcept
Is there a hit.
const point_type & point() const noexcept
Return the point, no checks.
label index() const noexcept
Return the hit index.
void setMiss() noexcept
Set the hit status off.
bool hit() const noexcept
Is there a hit?
const point_type & point() const noexcept
Return point, no checks.
label nBoundaryEdges() const
Number of boundary edges == (nEdges() - nInternalEdges()).
const labelListList & pointEdges() const
Return point-edge addressing.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
label nInternalEdges() const
Number of internal edges.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
const labelList & boundaryPoints() const
Return list of boundary points, address into LOCAL point list.
const labelListList & edgeFaces() const
Return edge-face addressing.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
bool found(const T &val, label pos=0) const
Same as contains().
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
The number of entries in the list.
scalar distSqr(const Vector< Cmpt > &v2) const
The L2-norm distance squared from another vector. The magSqr() of the difference.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
static void noParallel()
Remove the parallel options.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
static void addNote(const string ¬e)
Add extra notes for the usage information.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Non-pointer based hierarchical recursive searching.
const Type & shapes() const noexcept
Reference to shape.
A triFace with additional (region) index.
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Standard boundBox with extra functionality for use in octree.
treeBoundBox extend(Random &rndGen, const scalar s) const
Return slightly wider bounding box.
Holds data for octree to work on an edges subset.
const linePointRef line(const label index) const
Geometric line for edge at specified shape index. Frequently used.
label objectIndex(const label index) const
Map from shape index to original (non-subset) edge label.
IOoject and searching on triSurface.
Triangulated surface description with patch information.
A class for handling words, derived from Foam::string.
const polyBoundaryMesh & patches
const word dictName("faMeshDefinition")
#define WarningInFunction
Report a warning using Foam::Warning.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
List< word > wordList
List of word.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< labelList > labelListList
List of labelList.
PointHit< point > pointHit
A PointHit with a 3D point.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & indent(Ostream &os)
Indent stream.
static constexpr int maxIters
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
vector point
Point is a vector.
vectorField pointField
pointField is a vectorField.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
UList< label > labelUList
A UList of labels.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
constexpr char nl
The newline '\n' character (0x0a).
Tree tree(triangles.begin(), triangles.end())
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
Unit conversion functions.