44 #include "opt_octree.h"
78 point p(pt.x(), pt.y(), pt.z());
92 const Level min_level_;
141 data_access(max_level_,iso_val_),
142 min_level_(min_level),
143 geometryToConformTo_(geometryToConformTo),
144 converter_(converter)
149 virtual ~distanceCalc() =
default;
155 virtual bool need_refine(
const Cube &
c )
159 if ( l >= _max_level )
return false;
160 if ( l < min_level_ )
return true;
194 if (geometry[surfaces[i]].overlaps(bb))
358 virtual real value_at(
const Cube &
c )
360 return signedDistance(converter_.toGlobal(
c)) - _iso_val;
367 int main(
int argc,
char *argv[])
371 "Re-sample surfaces used in foamyHexMesh operation"
383 Info<<
"Reading surfaces as specified in the foamyHexMeshDict and"
384 <<
" writing a re-sampled surface to " << exportName
406 "cvSearchableSurfaces",
413 foamyHexMeshDict.subDict(
"geometry"),
414 foamyHexMeshDict.getOrDefault(
"singleRegionName",
true)
417 Info<<
"Geometry read in = "
418 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
428 foamyHexMeshDict.subDict(
"surfaceConformation")
431 Info<<
"Set up geometry in = "
432 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
436 const labelList& surfaces = geometryToConformTo.surfaces();
439 const label minLevel = 2;
443 const scalar maxSize = 1.0 / (1 << minLevel);
444 const scalar halfMaxSize = 0.5*maxSize;
450 scalar wantedRange = 1.0-maxSize;
452 const treeBoundBox bb = geometryToConformTo.globalBounds();
456 point(wantedRange, wantedRange, wantedRange),
462 point(halfMaxSize, halfMaxSize, halfMaxSize),
485 octree.set_impl(&
ref);
487 Info<<
"Calculated octree in = "
488 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
490 MarchingCubes& mc = octree.mc();
493 octree.build_isosurface(&
ref) ;
495 Info<<
"Constructed iso surface of distance in = "
496 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
501 Triangle* triangles = mc.triangles();
502 label nTris = mc.ntrigs();
504 for (label triI = 0; triI < nTris; ++triI)
506 const Triangle& t = triangles[triI];
507 if (t.v1 != t.v2 && t.v1 != t.v3 && t.v2 != t.v3)
528 points[pointi] = converter.toGlobal(v);
533 labelList regionOffsets(surfaces.size());
537 const wordList& regions = geometry[surfaces[i]].regions();
538 regionOffsets[i] = nRegions;
539 nRegions += regions.size();
547 const wordList& regions = geometry[surfaces[i]].regions();
553 geometry[surfaces[i]].
name() +
"_" + regions[regionI],
564 Info<<
"Extracted triSurface in = "
565 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
572 geometryToConformTo.findSurfaceNearest
591 if (hitSurfaces[triI] == surfI)
593 surfInfo.append(hitInfo[triI]);
594 surfIndices.append(triI);
600 geometry[surfaces[surfI]].getRegion(surfInfo, region);
604 label triI = surfIndices[i];
605 s[triI].region() = regionOffsets[surfI]+region[i];
610 Info<<
"Re-patched surface in = "
611 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;
628 Info<<
"writing surfMesh:\n "
629 << smesh.searchableSurface::objectPath() <<
nl <<
endl;
630 smesh.searchableSurface::write();
632 Info<<
"Written surface in = "
633 <<
timer.cpuTimeIncrement() <<
" s." <<
nl <<
endl;