54 const label newPointi,
152 void createBoundaryEdgeTrees
164 treeBoundaryEdges[surfI] =
190 treeBoundaryEdges[surfI]
202 class findNearestOpSubset
217 shapeMask_(shapeMask)
225 scalar& nearestDistSqr,
234 const label index = indices[i];
240 &&
findIndex(shapeMask_, edgeIndex) != -1
246 const edge& e = shape.
edges()[edgeIndex];
255 if (distSqr < nearestDistSqr)
257 nearestDistSqr = distSqr;
269 int main(
int argc,
char *argv[])
273 "hook surfaces to other surfaces by moving and retriangulating their" 274 "boundary edges to match other surface boundary edges" 287 const scalar matchTolerance(
max(1e-6*dist, small));
288 const label maxIters = 100;
290 Info<<
"Hooking distance = " << dist <<
endl;
311 const wordList& regions = surfs[surfI].regions();
312 forAll(regions, surfRegionI)
332 refCast<const triSurfaceMesh>(surfs[surfI]);
341 "hookedSurface_" + surfs.names()[surfI],
356 Info<<
nl <<
"Iteration = " << nIters++ <<
endl;
359 createBoundaryEdgeTrees(newSurfaces, bEdgeTrees, treeBoundaryEdges);
361 forAll(newSurfaces, surfI)
363 const triSurface& newSurf = newSurfaces[surfI];
370 forAll(newSurfaces, surfI)
379 forAll(bPointsTobEdges, bPointi)
386 const labelList& pEdges = pointEdges[pointi];
398 bEdgeTree.findNearest
423 nearestHit = currentHit;
424 bPointsHitTree[bPointi] = treeI;
430 if (nearestHit.
hit())
448 forAll(bPointsTobEdges, bPointi)
454 const label hitSurfI = bPointsHitTree[bPointi];
455 const triSurface& hitSurf = newSurfaces[hitSurfI];
458 treeBoundaryEdges[hitSurfI][eHit.
index()];
465 if (eFaces.
size() != 1)
468 <<
"Edge is attached to " << eFaces.
size()
469 <<
" faces." <<
endl;
474 const label facei = eFaces[0];
476 if (visitedFace[hitSurfI][facei])
502 label newPointi = -1;
505 if (hitSurfI == surfI)
511 newPoints[hitSurfI].append(newPoints[surfI][pointi]);
512 newPointi = newPoints[hitSurfI].size() - 1;
525 visitedFace[hitSurfI][facei] =
true;
527 forAll(newFacesFromSplit, newFacei)
529 const labelledTri& fN = newFacesFromSplit[newFacei];
533 newFaces[hitSurfI][facei] = fN;
537 newFaces[hitSurfI].
append(fN);
544 Info<<
" Number of edges split = " << nChanged <<
endl;
546 forAll(newSurfaces, surfI)
555 "hookedSurface_" + surfs.names()[surfI],
570 }
while (nChanged > 0 && nIters <= maxIters);
574 forAll(newSurfaces, surfI)
578 Info<<
"Writing hooked surface " << newSurf.searchableSurface::name()
581 newSurf.searchableSurface::write();
const fvPatchList & patches
const labelListList & pointEdges() const
Return point-edge addressing.
#define forAll(list, i)
Loop across all elements in list.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Ostream & indent(Ostream &os)
Indent stream.
const pointField & points() const
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Unit conversion functions.
void size(const label)
Override size to be inconsistent with allocated storage.
const labelList & boundaryPoints() const
Return list of boundary points,.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Holds data for octree to work on an edges subset.
label nInternalEdges() const
Number of internal edges.
static void noParallel()
Remove the parallel options.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
const Field< PointType > & localPoints() const
Return pointField of points in patch.
IOdictionary systemDict(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion)
A surface geometry formed of discrete facets, e.g. triangles and/or quadrilaterals, defined in a file using formats such as Wavefront OBJ, or stereolithography STL.
const Point & hitPoint() const
Return hit point.
label region() const
Return region label.
linePointRef line(const pointField &) const
Return edge line.
vectorField pointField
pointField is a vectorField.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
static const word & geometryDir()
Return the geometry directory name.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
bool hit() const
Is there a hit.
Container for searchableSurfaces.
const Type & shapes() const
Reference to shape.
const labelListList & edgeFaces() const
Return edge-face addressing.
bool hit() const
Is there a hit.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
List< label > labelList
A List of labels.
Triangle with additional region number.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
const Point & rawPoint() const
Return point with no checking.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
const Point & rawPoint() const
Return point with no checking.
label nEdges() const
Return number of edges in patch.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
label size() const
Return the number of elements in the UPtrList.
const edgeList & edges() const
Non-pointer based hierarchical recursive searching.
#define WarningInFunction
Report a warning using Foam::Warning.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
label end() const
Return end vertex label.
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
T argRead(const label index) const
Read a value from the argument at index.
Standard boundBox + extra functionality for use in octree.
scalar distance() const
Return distance to hit.
static void addNote(const string &)
Add extra notes for the usage information.
Triangulated surface description with patch information.
Foam::argList args(argc, argv)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
label index() const
Return index.
const labelList & edgeLabels() const
label start() const
Return start vertex label.
treeBoundBox extend(const scalar s) const
Return asymetrically extended bounding box, with guaranteed.