#3035 Consolidate duplicate code

This commit is contained in:
Magne Sjaastad 2018-06-25 08:19:29 +02:00
parent b317ea9e9e
commit 1575a6564a
2 changed files with 55 additions and 74 deletions

View File

@ -153,32 +153,9 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod
{ {
cvf::Vec3d partTranslation = distanceToCenterLine * cvf::Vec3d(fractureMatrix.col(2)); cvf::Vec3d partTranslation = distanceToCenterLine * cvf::Vec3d(fractureMatrix.col(2));
for (auto& part : parts)
{ {
cvf::Mat4d m = cvf::Mat4d::fromTranslation(partTranslation); RivWellFracturePartMgr::addPartAtPositiveAndNegativeTranslation(model, part.p(), partTranslation);
cvf::ref<cvf::Transform> partTransform = new cvf::Transform;
partTransform->setLocalTransform(m);
for (auto& part : parts)
{
part->setTransform(partTransform.p());
model->addPart(part.p());
}
}
{
cvf::Mat4d m = cvf::Mat4d::fromTranslation(-partTranslation);
cvf::ref<cvf::Transform> partTransform = new cvf::Transform;
partTransform->setLocalTransform(m);
for (const auto& originalPart : parts)
{
auto part = originalPart->shallowCopy();
part->setTransform(partTransform.p());
model->addPart(part.p());
}
} }
} }
else else
@ -194,36 +171,19 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod
// Position the containment mask outside the fracture parts // Position the containment mask outside the fracture parts
// Always duplicate the containment mask parts // Always duplicate the containment mask parts
auto maskOfFractureAreasOutsideGrid = createOutsideReservoirMaskPart(eclView);
if (maskOfFractureAreasOutsideGrid.notNull())
{ {
double scaleFactor = 0.03; auto maskOfFractureAreasOutsideGrid = createMaskOfFractureOutsideGrid(eclView);
if (m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) if (maskOfFractureAreasOutsideGrid.notNull())
{ {
scaleFactor = 2 * distanceToCenterLine; double scaleFactor = 0.03;
} if (m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH)
{
scaleFactor = 2 * distanceToCenterLine;
}
cvf::Vec3d partTranslation = scaleFactor * cvf::Vec3d(fractureMatrix.col(2)); cvf::Vec3d partTranslation = scaleFactor * cvf::Vec3d(fractureMatrix.col(2));
{ RivWellFracturePartMgr::addPartAtPositiveAndNegativeTranslation(model, maskOfFractureAreasOutsideGrid.p(), partTranslation);
cvf::Mat4d m = cvf::Mat4d::fromTranslation(partTranslation);
cvf::ref<cvf::Transform> partTransform = new cvf::Transform;
partTransform->setLocalTransform(m);
maskOfFractureAreasOutsideGrid->setTransform(partTransform.p());
model->addPart(maskOfFractureAreasOutsideGrid.p());
}
{
cvf::Mat4d m = cvf::Mat4d::fromTranslation(-partTranslation);
cvf::ref<cvf::Transform> partTransform = new cvf::Transform;
partTransform->setLocalTransform(m);
auto copy = maskOfFractureAreasOutsideGrid->shallowCopy();
copy->setTransform(partTransform.p());
model->addPart(copy.p());
} }
} }
@ -243,29 +203,9 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod
cvf::Vec3d partTranslation = scaleFactor * cvf::Vec3d(fractureMatrix.col(2)); cvf::Vec3d partTranslation = scaleFactor * cvf::Vec3d(fractureMatrix.col(2));
{ RivWellFracturePartMgr::addPartAtPositiveAndNegativeTranslation(model, containmentMask.p(), partTranslation);
cvf::Mat4d m = cvf::Mat4d::fromTranslation(partTranslation);
cvf::ref<cvf::Transform> partTransform = new cvf::Transform;
partTransform->setLocalTransform(m);
containmentMask->setTransform(partTransform.p());
model->addPart(containmentMask.p());
}
{
cvf::Mat4d m = cvf::Mat4d::fromTranslation(-partTranslation);
cvf::ref<cvf::Transform> partTransform = new cvf::Transform;
partTransform->setLocalTransform(m);
auto copy = containmentMask->shallowCopy();
copy->setTransform(partTransform.p());
model->addPart(copy.p());
}
} }
} }
} }
appendFracturePerforationLengthParts(eclView, model); appendFracturePerforationLengthParts(eclView, model);
@ -801,7 +741,7 @@ cvf::ref<cvf::Part> RivWellFracturePartMgr::createContainmentMaskPart(const RimE
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// Create mask for the parts outside the grid cells of the reservoir /// Create mask for the parts outside the grid cells of the reservoir
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> RivWellFracturePartMgr::createOutsideReservoirMaskPart(const RimEclipseView& activeView) cvf::ref<cvf::Part> RivWellFracturePartMgr::createMaskOfFractureOutsideGrid(const RimEclipseView& activeView)
{ {
cvf::Mat4d frMx = m_rimFracture->transformMatrix(); cvf::Mat4d frMx = m_rimFracture->transformMatrix();
@ -1190,3 +1130,40 @@ cvf::ref<cvf::DrawableGeo> RivWellFracturePartMgr::buildDrawableGeoFromTriangles
return geo; return geo;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Transform> RivWellFracturePartMgr::createLocalTransformFromTranslation(const cvf::Vec3d& translation)
{
cvf::Mat4d m = cvf::Mat4d::fromTranslation(translation);
cvf::ref<cvf::Transform> partTransform = new cvf::Transform;
partTransform->setLocalTransform(m);
return partTransform;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivWellFracturePartMgr::addPartAtPositiveAndNegativeTranslation(cvf::ModelBasicList* model, cvf::Part* part, const cvf::Vec3d& translation)
{
{
cvf::ref<cvf::Transform> partTransform = RivWellFracturePartMgr::createLocalTransformFromTranslation(translation);
part->setTransform(partTransform.p());
model->addPart(part);
}
{
// Create a copy of the part to be able to assign a transformation matrix representing the translation in the opposite
// direction
cvf::ref<cvf::Transform> partTransform = RivWellFracturePartMgr::createLocalTransformFromTranslation(-translation);
auto copy = part->shallowCopy();
copy->setTransform(partTransform.p());
model->addPart(copy.p());
}
}

View File

@ -35,6 +35,7 @@ namespace cvf
class Part; class Part;
class Color3f; class Color3f;
class ScalarMapper; class ScalarMapper;
class Transform;
} }
namespace caf namespace caf
@ -72,7 +73,7 @@ private:
cvf::ref<cvf::Part> createStimPlanElementColorSurfacePart(const RimEclipseView& activeView); cvf::ref<cvf::Part> createStimPlanElementColorSurfacePart(const RimEclipseView& activeView);
cvf::ref<cvf::Part> createContainmentMaskPart(const RimEclipseView& activeView); cvf::ref<cvf::Part> createContainmentMaskPart(const RimEclipseView& activeView);
cvf::ref<cvf::Part> createOutsideReservoirMaskPart(const RimEclipseView& activeView); cvf::ref<cvf::Part> createMaskOfFractureOutsideGrid(const RimEclipseView& activeView);
void appendFracturePerforationLengthParts(const RimEclipseView& activeView, cvf::ModelBasicList* model); void appendFracturePerforationLengthParts(const RimEclipseView& activeView, cvf::ModelBasicList* model);
@ -88,6 +89,9 @@ private:
const caf::DisplayCoordTransform& displayCoordTransform); const caf::DisplayCoordTransform& displayCoordTransform);
static cvf::ref<cvf::DrawableGeo> buildDrawableGeoFromTriangles(const std::vector<cvf::uint>& triangleIndices, const std::vector<cvf::Vec3f>& nodeCoords); static cvf::ref<cvf::DrawableGeo> buildDrawableGeoFromTriangles(const std::vector<cvf::uint>& triangleIndices, const std::vector<cvf::Vec3f>& nodeCoords);
static cvf::ref<cvf::Transform> createLocalTransformFromTranslation(const cvf::Vec3d& translation);
static void addPartAtPositiveAndNegativeTranslation(cvf::ModelBasicList* model, cvf::Part* part, const cvf::Vec3d& translation);
private: private:
caf::PdmPointer<RimFracture> m_rimFracture; caf::PdmPointer<RimFracture> m_rimFracture;