mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: invalid pointer reference for optional coordinate system lookup
- code remnant from separate lookup + construct of coordinateSystem
(7b2bcfda0b).
Apply consistent use of coordinateSystem::NewIfPresent to avoid
these types of coding mishaps
This commit is contained in:
@ -60,34 +60,21 @@ Foam::plane Foam::sampledCuttingPlane::definePlane
|
||||
{
|
||||
plane pln(dict);
|
||||
|
||||
bool adjust = false;
|
||||
const dictionary* dictptr = nullptr;
|
||||
coordSystem::cartesian cs;
|
||||
// Optional (cartesian) coordinate transform.
|
||||
// - with registry to allow lookup from globally defined systems
|
||||
|
||||
// Create with registry to allow lookup from globally defined
|
||||
// coordinate systems.
|
||||
auto csysPtr = coordinateSystem::NewIfPresent(mesh, dict);
|
||||
|
||||
auto csPtr = coordinateSystem::NewIfPresent(mesh, *dictptr);
|
||||
|
||||
if (csPtr)
|
||||
if (!csysPtr)
|
||||
{
|
||||
adjust = true;
|
||||
cs = csPtr();
|
||||
csysPtr = coordinateSystem::NewIfPresent(dict, "transform");
|
||||
}
|
||||
else if
|
||||
(
|
||||
(dictptr = dict.findDict("transform", keyType::LITERAL)) != nullptr
|
||||
)
|
||||
{
|
||||
// 'origin' (READ_IF_PRESENT)
|
||||
adjust = true;
|
||||
cs = coordSystem::cartesian(*dictptr, IOobjectOption::READ_IF_PRESENT);
|
||||
}
|
||||
|
||||
|
||||
// Make plane relative to the Cartesian coordinate system
|
||||
if (adjust)
|
||||
if (csysPtr)
|
||||
{
|
||||
coordSystem::cartesian cs(csysPtr());
|
||||
|
||||
const point orig = cs.globalPosition(pln.origin());
|
||||
const vector norm = cs.globalVector(pln.normal());
|
||||
|
||||
|
||||
@ -58,34 +58,21 @@ Foam::plane Foam::sampledPlane::definePlane
|
||||
{
|
||||
plane pln(dict);
|
||||
|
||||
bool adjust = false;
|
||||
const dictionary* dictptr = nullptr;
|
||||
coordSystem::cartesian cs;
|
||||
// Optional (cartesian) coordinate transform.
|
||||
// - with registry to allow lookup from globally defined systems
|
||||
|
||||
// Create with registry to allow lookup from globally defined
|
||||
// coordinate systems.
|
||||
auto csysPtr = coordinateSystem::NewIfPresent(mesh, dict);
|
||||
|
||||
auto csPtr = coordinateSystem::NewIfPresent(mesh, dict);
|
||||
|
||||
if (csPtr)
|
||||
if (!csysPtr)
|
||||
{
|
||||
adjust = true;
|
||||
cs = csPtr();
|
||||
csysPtr = coordinateSystem::NewIfPresent(dict, "transform");
|
||||
}
|
||||
else if
|
||||
(
|
||||
(dictptr = dict.findDict("transform", keyType::LITERAL)) != nullptr
|
||||
)
|
||||
{
|
||||
// 'origin' (READ_IF_PRESENT)
|
||||
adjust = true;
|
||||
cs = coordSystem::cartesian(*dictptr, IOobjectOption::READ_IF_PRESENT);
|
||||
}
|
||||
|
||||
|
||||
// Make plane relative to the Cartesian coordinate system
|
||||
if (adjust)
|
||||
if (csysPtr)
|
||||
{
|
||||
coordSystem::cartesian cs(csysPtr());
|
||||
|
||||
const point orig = cs.globalPosition(pln.origin());
|
||||
const vector norm = cs.globalVector(pln.normal());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user