mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
NNC: Prioritize NNC parts when picking in 3D scene
This commit is contained in:
parent
59eeb0894f
commit
1c80a9dbe8
@ -250,7 +250,9 @@ void RivFaultPartMgr::generatePartGeometry()
|
||||
part->setDrawable(geo.p());
|
||||
|
||||
// Set mapping from triangle face index to cell index
|
||||
part->setSourceInfo(RivSourceInfo::fromCellIndices(m_nativeFaultGenerator->triangleToSourceGridCellMap().p()).p());
|
||||
cvf::ref<RivSourceInfo> si = new RivSourceInfo;
|
||||
si->m_cellIndices = m_nativeFaultGenerator->triangleToSourceGridCellMap().p();
|
||||
part->setSourceInfo(si.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
part->setEnableMask(faultBit);
|
||||
@ -301,7 +303,9 @@ void RivFaultPartMgr::generatePartGeometry()
|
||||
part->setDrawable(geo.p());
|
||||
|
||||
// Set mapping from triangle face index to cell index
|
||||
part->setSourceInfo(RivSourceInfo::fromCellIndices(m_oppositeFaultGenerator->triangleToSourceGridCellMap().p()).p());
|
||||
cvf::ref<RivSourceInfo> si = new RivSourceInfo;
|
||||
si->m_cellIndices = m_oppositeFaultGenerator->triangleToSourceGridCellMap().p();
|
||||
part->setSourceInfo(si.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
part->setEnableMask(faultBit);
|
||||
@ -350,7 +354,9 @@ void RivFaultPartMgr::generatePartGeometry()
|
||||
part->setDrawable(geo.p());
|
||||
|
||||
// Set mapping from triangle face index to cell index
|
||||
part->setSourceInfo(RivSourceInfo::fromNNCIndices(m_NNCGenerator->triangleToNNCIndex().p()).p());
|
||||
cvf::ref<RivSourceInfo> si = new RivSourceInfo;
|
||||
si->m_NNCIndices = m_NNCGenerator->triangleToNNCIndex().p();
|
||||
part->setSourceInfo(si.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
part->setEnableMask(faultBit);
|
||||
|
@ -115,7 +115,9 @@ void RivGridPartMgr::generatePartGeometry(cvf::StructGridGeometryGenerator& geoB
|
||||
part->setTransform(m_scaleTransform.p());
|
||||
|
||||
// Set mapping from triangle face index to cell index
|
||||
part->setSourceInfo(RivSourceInfo::fromCellIndices(geoBuilder.triangleToSourceGridCellMap().p()).p());
|
||||
cvf::ref<RivSourceInfo> si = new RivSourceInfo;
|
||||
si->m_cellIndices = geoBuilder.triangleToSourceGridCellMap().p();
|
||||
part->setSourceInfo(si.p());
|
||||
|
||||
part->updateBoundingBox();
|
||||
|
||||
|
@ -22,27 +22,15 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RivSourceInfo> RivSourceInfo::fromCellIndices(cvf::Array<size_t>* cellIndices)
|
||||
bool RivSourceInfo::hasCellIndices() const
|
||||
{
|
||||
CVF_ASSERT(cellIndices);
|
||||
|
||||
cvf::ref<RivSourceInfo> si = new RivSourceInfo;
|
||||
|
||||
si->m_cellIndices = cellIndices;
|
||||
|
||||
return si;
|
||||
return m_cellIndices.notNull();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RivSourceInfo> RivSourceInfo::fromNNCIndices(cvf::Array<size_t>* nncIndices)
|
||||
bool RivSourceInfo::hasNNCIndices() const
|
||||
{
|
||||
CVF_ASSERT(nncIndices);
|
||||
|
||||
cvf::ref<RivSourceInfo> si = new RivSourceInfo;
|
||||
|
||||
si->m_NNCIndices = nncIndices;
|
||||
|
||||
return si;
|
||||
return m_NNCIndices.notNull();
|
||||
}
|
||||
|
@ -25,8 +25,8 @@
|
||||
class RivSourceInfo : public cvf::Object
|
||||
{
|
||||
public:
|
||||
static cvf::ref<RivSourceInfo> fromCellIndices(cvf::Array<size_t>* cellIndices);
|
||||
static cvf::ref<RivSourceInfo> fromNNCIndices(cvf::Array<size_t>* nncIndices);
|
||||
bool hasCellIndices() const;
|
||||
bool hasNNCIndices() const;
|
||||
|
||||
public:
|
||||
cvf::ref<cvf::Array<size_t> > m_cellIndices;
|
||||
|
@ -274,7 +274,7 @@ void RiuViewer::mouseReleaseEvent(QMouseEvent* event)
|
||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
|
||||
if (rivSourceInfo)
|
||||
{
|
||||
if (rivSourceInfo->m_cellIndices->size() > 0)
|
||||
if (rivSourceInfo->hasCellIndices())
|
||||
{
|
||||
m_currentGridIdx = firstHitPart->id();
|
||||
m_currentCellIndex = rivSourceInfo->m_cellIndices->get(faceIndex);
|
||||
@ -437,7 +437,7 @@ void RiuViewer::handlePickAction(int winPosX, int winPosY)
|
||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
|
||||
if (rivSourceInfo)
|
||||
{
|
||||
if (rivSourceInfo->m_cellIndices.notNull())
|
||||
if (rivSourceInfo->hasCellIndices())
|
||||
{
|
||||
cellIndex = rivSourceInfo->m_cellIndices->get(faceIndex);
|
||||
|
||||
@ -546,18 +546,46 @@ cvf::Part* RiuViewer::pickPointAndFace(int winPosX, int winPosY, uint* faceHit,
|
||||
{
|
||||
CVF_ASSERT(faceHit);
|
||||
|
||||
cvf::HitItemCollection pPoints;
|
||||
bool isSomethingHit = rayPick(winPosX, winPosY, &pPoints);
|
||||
cvf::HitItemCollection hitItems;
|
||||
bool isSomethingHit = rayPick(winPosX, winPosY, &hitItems);
|
||||
|
||||
if (isSomethingHit)
|
||||
{
|
||||
CVF_ASSERT(pPoints.count() > 0);
|
||||
cvf::HitItem* firstItem = pPoints.firstItem();
|
||||
const cvf::Part* pickedPart = firstItem->part();
|
||||
CVF_ASSERT(hitItems.count() > 0);
|
||||
|
||||
double characteristicCellSize = m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->characteristicIJCellSize();
|
||||
double pickDepthThresholdSquared = characteristicCellSize / 10.0;
|
||||
pickDepthThresholdSquared = pickDepthThresholdSquared * pickDepthThresholdSquared;
|
||||
|
||||
cvf::HitItem* hitItem = hitItems.firstItem();
|
||||
cvf::Vec3d firstItemIntersectionPoint = hitItem->intersectionPoint();
|
||||
|
||||
// Check if we have a close hit item with NNC data
|
||||
for (size_t i = 0; i < hitItems.count(); i++)
|
||||
{
|
||||
cvf::HitItem* hitItemCandidate = hitItems.item(i);
|
||||
cvf::Vec3d diff = firstItemIntersectionPoint - hitItemCandidate->intersectionPoint();
|
||||
|
||||
// Hit items are ordered by distance from eye
|
||||
if (diff.lengthSquared() > pickDepthThresholdSquared) break;
|
||||
|
||||
const cvf::Part* pickedPartCandidate = hitItemCandidate->part();
|
||||
if (pickedPartCandidate && pickedPartCandidate->sourceInfo())
|
||||
{
|
||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(pickedPartCandidate->sourceInfo());
|
||||
if (rivSourceInfo && rivSourceInfo->hasNNCIndices())
|
||||
{
|
||||
hitItem = hitItemCandidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const cvf::Part* pickedPart = hitItem->part();
|
||||
CVF_ASSERT(pickedPart);
|
||||
|
||||
const cvf::Transform* xf = pickedPart->transform();
|
||||
cvf::Vec3d globalPickedPoint = firstItem->intersectionPoint();
|
||||
cvf::Vec3d globalPickedPoint = hitItem->intersectionPoint();
|
||||
|
||||
if(localIntersectionPoint)
|
||||
{
|
||||
@ -574,7 +602,7 @@ cvf::Part* RiuViewer::pickPointAndFace(int winPosX, int winPosY, uint* faceHit,
|
||||
if (faceHit)
|
||||
{
|
||||
|
||||
const cvf::HitDetailDrawableGeo* detail = dynamic_cast<const cvf::HitDetailDrawableGeo*>(firstItem->detail());
|
||||
const cvf::HitDetailDrawableGeo* detail = dynamic_cast<const cvf::HitDetailDrawableGeo*>(hitItem->detail());
|
||||
if (detail)
|
||||
{
|
||||
*faceHit = detail->faceIndex();
|
||||
|
Loading…
Reference in New Issue
Block a user