#1274 - pre-proto - Fix in which cells that is shown.

This commit is contained in:
astridkbjorke
2017-03-16 14:53:44 +01:00
parent 654bbb38e3
commit f8b246bdf3
2 changed files with 47 additions and 3 deletions

View File

@@ -292,12 +292,20 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri
std::vector<double> depthCoords;
for (int i = 0; i < depthCoordsAtNodes.size() - 1; i++) depthCoords.push_back((depthCoordsAtNodes[i] + depthCoordsAtNodes[i + 1]) / 1);
float polygonXmin;
float polygonXmax;
float polygonYmin;
float polygonYmax;
getPolygonBB(polygonXmin, polygonXmax, polygonYmin, polygonYmax);
std::vector<cvf::Vec3f> stimPlanMeshVertices;
for (int i = 0; i < xCoords.size() - 1; i++)
{
for (int j = 0; j < depthCoords.size() - 1; j++)
{
if (stimPlanCellTouchesPolygon(xCoords[i], xCoords[i + 1], depthCoords[j], depthCoords[j + 1]))
if (stimPlanCellTouchesPolygon(xCoords[i], xCoords[i + 1], depthCoords[j], depthCoords[j + 1], polygonXmin, polygonXmax, polygonYmin, polygonYmax))
{
stimPlanMeshVertices.push_back(cvf::Vec3f(static_cast<float>(xCoords[i]), static_cast<float>(depthCoords[j]), 0.0f));
stimPlanMeshVertices.push_back(cvf::Vec3f(static_cast<float>(xCoords[i + 1]), static_cast<float>(depthCoords[j]), 0.0f));
@@ -325,6 +333,30 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri
return stimPlanMeshGeo;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::getPolygonBB(float &polygonXmin, float &polygonXmax, float &polygonYmin, float &polygonYmax)
{
std::vector<cvf::Vec3f> polygon = m_rimFracture->attachedFractureDefinition()->fracturePolygon(m_rimFracture->fractureUnit);
if (polygon.size() > 1)
{
polygonXmin = polygon[0].x();
polygonXmax = polygon[0].x();
polygonYmin = polygon[0].y();
polygonYmax = polygon[0].y();
}
for (cvf::Vec3f v : polygon)
{
if (v.x() < polygonXmin) polygonXmin = v.x();
if (v.x() > polygonXmax) polygonXmax = v.x();
if (v.y() < polygonYmin) polygonYmin = v.y();
if (v.y() > polygonYmax) polygonYmax = v.y();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -473,8 +505,17 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::createGeo(const std::vector<c
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RivWellFracturePartMgr::stimPlanCellTouchesPolygon(double xMin, double xMax, double yMin, double yMax)
bool RivWellFracturePartMgr::stimPlanCellTouchesPolygon(double xMin, double xMax, double yMin, double yMax, float polygonXmin, float polygonXmax, float polygonYmin, float polygonYmax)
{
if (static_cast<float>(xMin) > polygonXmin && static_cast<float>(xMax) < polygonXmax)
{
if (static_cast<float>(yMin) > polygonYmin && static_cast<float>(yMax) < polygonYmax)
{
return true;
}
}
std::vector<cvf::Vec3f> polygon = m_rimFracture->attachedFractureDefinition()->fracturePolygon(m_rimFracture->fractureUnit);
for (cvf::Vec3f v : polygon)

View File

@@ -63,8 +63,11 @@ private:
cvf::ref<cvf::DrawableGeo> createPolygonDrawable(caf::DisplayCoordTransform* displayCoordTransform);
cvf::ref<cvf::DrawableGeo> createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, caf::DisplayCoordTransform* displayCoordTransform);
void getPolygonBB(float &polygonXmin, float &polygonXmax, float &polygonYmin, float &polygonYmax);
std::vector<cvf::Vec3f> transfromToFractureDisplayCoords(std::vector<cvf::Vec3f> polygon, cvf::Mat4f m, caf::DisplayCoordTransform* displayCoordTransform);
bool stimPlanCellTouchesPolygon(double xMin, double xMax, double yMin, double yMax);
bool stimPlanCellTouchesPolygon(double xMin, double xMax, double yMin, double yMax, float polygonXmin, float polygonXmax, float polygonYmin, float polygonYmax);
std::vector<double> mirrorDataAtSingleDepth(std::vector<double> depthData);
static cvf::ref<cvf::DrawableGeo> createGeo(const std::vector<cvf::uint>& triangleIndices, const std::vector<cvf::Vec3f>& nodeCoords);