Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
44d1ed3e
Commit
44d1ed3e
authored
Dec 12, 2012
by
laurence
Browse files
ENH: boundBox: Change distanceFromBoxSqr to nearest()
Returns the nearest point instead of a distance
parent
ec634a89
Changes
3
Hide whitespace changes
Inline
Side-by-side
applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C
View file @
44d1ed3e
...
...
@@ -791,15 +791,19 @@ Foam::DistributedDelaunayMesh<Triangulation>::rangeInsertReferredWithInfo
label
count
=
0
;
for
(
PointIterator
it
=
begin
;
it
!=
end
;
++
it
)
{
const
scalar
distFromBbSqr
=
bb
.
distanceFromBoxSqr
(
topoint
(
it
->
point
())
);
const
pointFromPoint
samplePoint
=
topoint
(
it
->
point
());
pointsBbDistSqr
.
append
(
std
::
make_pair
(
distFromBbSqr
,
count
++
)
);
if
(
!
bb
.
contains
(
samplePoint
))
{
const
Foam
::
point
nearestPoint
=
bb
.
nearest
(
samplePoint
);
const
scalar
distFromBbSqr
=
magSqr
(
nearestPoint
-
samplePoint
);
pointsBbDistSqr
.
append
(
std
::
make_pair
(
distFromBbSqr
,
count
++
)
);
}
}
std
::
random_shuffle
(
pointsBbDistSqr
.
begin
(),
pointsBbDistSqr
.
end
());
...
...
src/OpenFOAM/meshes/boundBox/boundBox.C
View file @
44d1ed3e
...
...
@@ -300,21 +300,14 @@ bool Foam::boundBox::containsAny
}
Foam
::
scalar
Foam
::
boundBox
::
distanceFromBoxSqr
(
const
point
&
pt
)
const
Foam
::
point
Foam
::
boundBox
::
nearest
(
const
point
&
pt
)
const
{
if
(
contains
(
pt
))
{
return
0
;
}
// Clip the point to the range of the bounding box
const
scalar
surfPtx
=
Foam
::
max
(
Foam
::
min
(
pt
.
x
(),
max_
.
x
()),
min_
.
x
());
const
scalar
surfPty
=
Foam
::
max
(
Foam
::
min
(
pt
.
y
(),
max_
.
y
()),
min_
.
y
());
const
scalar
surfPtz
=
Foam
::
max
(
Foam
::
min
(
pt
.
z
(),
max_
.
z
()),
min_
.
z
());
const
point
surfacePt
(
surfPtx
,
surfPty
,
surfPtz
);
return
magSqr
(
pt
-
surfacePt
);
return
point
(
surfPtx
,
surfPty
,
surfPtz
);
}
...
...
src/OpenFOAM/meshes/boundBox/boundBox.H
View file @
44d1ed3e
...
...
@@ -225,9 +225,10 @@ public:
const
FixedList
<
label
,
Size
>&
indices
)
const
;
//- Distance of a point from the box.
// Return 0 if inside.
scalar
distanceFromBoxSqr
(
const
point
&
)
const
;
//- Return the nearest point on the boundBox to the supplied point.
// If point is inside the boundBox then the point is returned
// unchanged.
point
nearest
(
const
point
&
)
const
;
// Friend Operators
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment