mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-14 01:13:52 -06:00
RigCell: Added faceIndices and faceNormal methods
This commit is contained in:
parent
df411efe3f
commit
81176258bc
@ -229,10 +229,12 @@ cvf::Vec3d RigCell::faceCenter(cvf::StructGridInterface::FaceType face) const
|
|||||||
cvf::ubyte faceVertexIndices[4];
|
cvf::ubyte faceVertexIndices[4];
|
||||||
cvf::StructGridInterface::cellFaceVertexIndices(face, faceVertexIndices);
|
cvf::StructGridInterface::cellFaceVertexIndices(face, faceVertexIndices);
|
||||||
|
|
||||||
|
const std::vector<cvf::Vec3d>& nodeCoords = m_hostGrid->mainGrid()->nodes();
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
avg += m_hostGrid->mainGrid()->nodes()[m_cornerIndices[faceVertexIndices[i]]];
|
avg += nodeCoords[m_cornerIndices[faceVertexIndices[i]]];
|
||||||
}
|
}
|
||||||
|
|
||||||
avg /= 4.0;
|
avg /= 4.0;
|
||||||
@ -240,6 +242,19 @@ cvf::Vec3d RigCell::faceCenter(cvf::StructGridInterface::FaceType face) const
|
|||||||
return avg;
|
return avg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
cvf::Vec3d RigCell::faceNormal(cvf::StructGridInterface::FaceType face) const
|
||||||
|
{
|
||||||
|
cvf::ubyte faceVertexIndices[4];
|
||||||
|
cvf::StructGridInterface::cellFaceVertexIndices(face, faceVertexIndices);
|
||||||
|
const std::vector<cvf::Vec3d>& nodeCoords = m_hostGrid->mainGrid()->nodes();
|
||||||
|
|
||||||
|
return ( nodeCoords[m_cornerIndices[faceVertexIndices[2]]] - nodeCoords[m_cornerIndices[faceVertexIndices[0]]]) ^
|
||||||
|
( nodeCoords[m_cornerIndices[faceVertexIndices[3]]] - nodeCoords[m_cornerIndices[faceVertexIndices[1]]]);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Find the intersection between the cell and the ray. The point closest to the ray origin is returned
|
/// Find the intersection between the cell and the ray. The point closest to the ray origin is returned
|
||||||
/// in \a intersectionPoint, while the return value is the total number of intersections with the 24 triangles
|
/// in \a intersectionPoint, while the return value is the total number of intersections with the 24 triangles
|
||||||
@ -291,3 +306,17 @@ int RigCell::firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersectio
|
|||||||
return intersectionCount;
|
return intersectionCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RigCell::faceIndices(cvf::StructGridInterface::FaceType face, caf::SizeTArray4* indices) const
|
||||||
|
{
|
||||||
|
cvf::ubyte faceVertexIndices[4];
|
||||||
|
cvf::StructGridInterface::cellFaceVertexIndices(face, faceVertexIndices);
|
||||||
|
|
||||||
|
(*indices)[0] = m_cornerIndices[faceVertexIndices[0]];
|
||||||
|
(*indices)[1] = m_cornerIndices[faceVertexIndices[1]];
|
||||||
|
(*indices)[2] = m_cornerIndices[faceVertexIndices[2]];
|
||||||
|
(*indices)[3] = m_cornerIndices[faceVertexIndices[3]];
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ public:
|
|||||||
|
|
||||||
caf::SizeTArray8& cornerIndices() { return m_cornerIndices;}
|
caf::SizeTArray8& cornerIndices() { return m_cornerIndices;}
|
||||||
const caf::SizeTArray8& cornerIndices() const { return m_cornerIndices;}
|
const caf::SizeTArray8& cornerIndices() const { return m_cornerIndices;}
|
||||||
|
void faceIndices(cvf::StructGridInterface::FaceType face, caf::SizeTArray4 * faceIndices) const ;
|
||||||
|
|
||||||
bool isInvalid() const { return m_isInvalid; }
|
bool isInvalid() const { return m_isInvalid; }
|
||||||
void setInvalid( bool val ) { m_isInvalid = val; }
|
void setInvalid( bool val ) { m_isInvalid = val; }
|
||||||
@ -62,6 +63,8 @@ public:
|
|||||||
|
|
||||||
cvf::Vec3d center() const;
|
cvf::Vec3d center() const;
|
||||||
cvf::Vec3d faceCenter(cvf::StructGridInterface::FaceType face) const;
|
cvf::Vec3d faceCenter(cvf::StructGridInterface::FaceType face) const;
|
||||||
|
cvf::Vec3d faceNormal(cvf::StructGridInterface::FaceType face) const;
|
||||||
|
|
||||||
int firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersectionPoint) const;
|
int firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersectionPoint) const;
|
||||||
bool isLongPyramidCell(double maxHeightFactor = 5, double nodeNearTolerance = 1e-3 ) const;
|
bool isLongPyramidCell(double maxHeightFactor = 5, double nodeNearTolerance = 1e-3 ) const;
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user