diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 7a575eca25..3206a4d1ac 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -153,32 +153,9 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod { cvf::Vec3d partTranslation = distanceToCenterLine * cvf::Vec3d(fractureMatrix.col(2)); + for (auto& part : parts) { - cvf::Mat4d m = cvf::Mat4d::fromTranslation(partTranslation); - - cvf::ref 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 partTransform = new cvf::Transform; - partTransform->setLocalTransform(m); - - for (const auto& originalPart : parts) - { - auto part = originalPart->shallowCopy(); - - part->setTransform(partTransform.p()); - model->addPart(part.p()); - } + RivWellFracturePartMgr::addPartAtPositiveAndNegativeTranslation(model, part.p(), partTranslation); } } else @@ -194,36 +171,19 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod // Position the containment mask outside the fracture parts // Always duplicate the containment mask parts - auto maskOfFractureAreasOutsideGrid = createOutsideReservoirMaskPart(eclView); - if (maskOfFractureAreasOutsideGrid.notNull()) { - double scaleFactor = 0.03; - if (m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) + auto maskOfFractureAreasOutsideGrid = createMaskOfFractureOutsideGrid(eclView); + 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)); - { - cvf::Mat4d m = cvf::Mat4d::fromTranslation(partTranslation); - - cvf::ref partTransform = new cvf::Transform; - partTransform->setLocalTransform(m); - - maskOfFractureAreasOutsideGrid->setTransform(partTransform.p()); - model->addPart(maskOfFractureAreasOutsideGrid.p()); - } - - { - cvf::Mat4d m = cvf::Mat4d::fromTranslation(-partTranslation); - - cvf::ref partTransform = new cvf::Transform; - partTransform->setLocalTransform(m); - - auto copy = maskOfFractureAreasOutsideGrid->shallowCopy(); - copy->setTransform(partTransform.p()); - model->addPart(copy.p()); + RivWellFracturePartMgr::addPartAtPositiveAndNegativeTranslation(model, maskOfFractureAreasOutsideGrid.p(), partTranslation); } } @@ -243,29 +203,9 @@ void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* mod cvf::Vec3d partTranslation = scaleFactor * cvf::Vec3d(fractureMatrix.col(2)); - { - cvf::Mat4d m = cvf::Mat4d::fromTranslation(partTranslation); - - cvf::ref partTransform = new cvf::Transform; - partTransform->setLocalTransform(m); - - containmentMask->setTransform(partTransform.p()); - model->addPart(containmentMask.p()); - } - - { - cvf::Mat4d m = cvf::Mat4d::fromTranslation(-partTranslation); - - cvf::ref partTransform = new cvf::Transform; - partTransform->setLocalTransform(m); - - auto copy = containmentMask->shallowCopy(); - copy->setTransform(partTransform.p()); - model->addPart(copy.p()); - } + RivWellFracturePartMgr::addPartAtPositiveAndNegativeTranslation(model, containmentMask.p(), partTranslation); } } - } appendFracturePerforationLengthParts(eclView, model); @@ -801,7 +741,7 @@ cvf::ref RivWellFracturePartMgr::createContainmentMaskPart(const RimE //-------------------------------------------------------------------------------------------------- /// Create mask for the parts outside the grid cells of the reservoir //-------------------------------------------------------------------------------------------------- -cvf::ref RivWellFracturePartMgr::createOutsideReservoirMaskPart(const RimEclipseView& activeView) +cvf::ref RivWellFracturePartMgr::createMaskOfFractureOutsideGrid(const RimEclipseView& activeView) { cvf::Mat4d frMx = m_rimFracture->transformMatrix(); @@ -1190,3 +1130,40 @@ cvf::ref RivWellFracturePartMgr::buildDrawableGeoFromTriangles return geo; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivWellFracturePartMgr::createLocalTransformFromTranslation(const cvf::Vec3d& translation) +{ + cvf::Mat4d m = cvf::Mat4d::fromTranslation(translation); + + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); + + return partTransform; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellFracturePartMgr::addPartAtPositiveAndNegativeTranslation(cvf::ModelBasicList* model, cvf::Part* part, const cvf::Vec3d& translation) +{ + { + cvf::ref 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 partTransform = RivWellFracturePartMgr::createLocalTransformFromTranslation(-translation); + + auto copy = part->shallowCopy(); + copy->setTransform(partTransform.p()); + model->addPart(copy.p()); + } +} + diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h index 86e7725781..e8bb1457f9 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h @@ -35,6 +35,7 @@ namespace cvf class Part; class Color3f; class ScalarMapper; + class Transform; } namespace caf @@ -72,7 +73,7 @@ private: cvf::ref createStimPlanElementColorSurfacePart(const RimEclipseView& activeView); cvf::ref createContainmentMaskPart(const RimEclipseView& activeView); - cvf::ref createOutsideReservoirMaskPart(const RimEclipseView& activeView); + cvf::ref createMaskOfFractureOutsideGrid(const RimEclipseView& activeView); void appendFracturePerforationLengthParts(const RimEclipseView& activeView, cvf::ModelBasicList* model); @@ -88,6 +89,9 @@ private: const caf::DisplayCoordTransform& displayCoordTransform); static cvf::ref buildDrawableGeoFromTriangles(const std::vector& triangleIndices, const std::vector& nodeCoords); + + static cvf::ref createLocalTransformFromTranslation(const cvf::Vec3d& translation); + static void addPartAtPositiveAndNegativeTranslation(cvf::ModelBasicList* model, cvf::Part* part, const cvf::Vec3d& translation); private: caf::PdmPointer m_rimFracture;