mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-11 07:56:08 -06:00
#3249 Refactoring: Remove the old extractintersectionData.
Replace it with a separate find method. Use RiuPickItemInfo in the RicViewerEventObject
This commit is contained in:
parent
714ba1e605
commit
ad9864240c
@ -24,6 +24,7 @@
|
|||||||
#include "cvfBase.h"
|
#include "cvfBase.h"
|
||||||
#include "cvfObject.h"
|
#include "cvfObject.h"
|
||||||
#include "cvfVector3.h"
|
#include "cvfVector3.h"
|
||||||
|
#include "RiuPickItemInfo.h"
|
||||||
|
|
||||||
namespace cvf {
|
namespace cvf {
|
||||||
class Part;
|
class Part;
|
||||||
@ -37,17 +38,14 @@ class Rim3dView;
|
|||||||
class RicViewerEventObject
|
class RicViewerEventObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RicViewerEventObject(cvf::Vec3d globalIntersectionPoint,
|
RicViewerEventObject(const std::vector<RiuPickItemInfo>& partAndTriangleIndexPairs,
|
||||||
const std::vector<std::pair<const cvf::Part*,
|
Rim3dView* view)
|
||||||
cvf::uint>>& partAndTriangleIndexPairs, Rim3dView* view)
|
: m_partAndTriangleIndexPairs(partAndTriangleIndexPairs)
|
||||||
: m_globalIntersectionPoint(globalIntersectionPoint)
|
|
||||||
, m_partAndTriangleIndexPairs(partAndTriangleIndexPairs)
|
|
||||||
, m_view(view)
|
, m_view(view)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
cvf::Vec3d m_globalIntersectionPoint;
|
std::vector<RiuPickItemInfo> m_partAndTriangleIndexPairs;
|
||||||
std::vector<std::pair<const cvf::Part*, cvf::uint>> m_partAndTriangleIndexPairs;
|
|
||||||
Rim3dView* m_view;
|
Rim3dView* m_view;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ bool Ric3dWellLogCurveViewerEventHandler::handleEvent(const RicViewerEventObject
|
|||||||
cvf::uint triangleIndex = cvf::UNDEFINED_UINT;
|
cvf::uint triangleIndex = cvf::UNDEFINED_UINT;
|
||||||
|
|
||||||
const auto& partAndTriangleIndexPair = eventObject.m_partAndTriangleIndexPairs.front();
|
const auto& partAndTriangleIndexPair = eventObject.m_partAndTriangleIndexPairs.front();
|
||||||
const cvf::Part* part = partAndTriangleIndexPair.first;
|
const cvf::Part* part = partAndTriangleIndexPair.pickedPart();
|
||||||
|
|
||||||
const RivObjectSourceInfo* sourceInfo = dynamic_cast<const RivObjectSourceInfo*>(part->sourceInfo());
|
const RivObjectSourceInfo* sourceInfo = dynamic_cast<const RivObjectSourceInfo*>(part->sourceInfo());
|
||||||
if (sourceInfo)
|
if (sourceInfo)
|
||||||
@ -60,8 +60,10 @@ bool Ric3dWellLogCurveViewerEventHandler::handleEvent(const RicViewerEventObject
|
|||||||
cvf::Vec3d closestPoint;
|
cvf::Vec3d closestPoint;
|
||||||
double measuredDepthAtPoint;
|
double measuredDepthAtPoint;
|
||||||
double valueAtPoint;
|
double valueAtPoint;
|
||||||
Rim3dWellLogCurve* curve = curveCollection->checkForCurveIntersection(
|
Rim3dWellLogCurve* curve = curveCollection->checkForCurveIntersection( eventObject.m_partAndTriangleIndexPairs.front().globalPickedPoint(),
|
||||||
eventObject.m_globalIntersectionPoint, &closestPoint, &measuredDepthAtPoint, &valueAtPoint);
|
&closestPoint,
|
||||||
|
&measuredDepthAtPoint,
|
||||||
|
&valueAtPoint);
|
||||||
if (curve)
|
if (curve)
|
||||||
{
|
{
|
||||||
RiuMainWindow::instance()->selectAsCurrentItem(curve);
|
RiuMainWindow::instance()->selectAsCurrentItem(curve);
|
||||||
|
@ -52,7 +52,7 @@ bool RicIntersectionViewerEventHandler::handleEvent(const RicViewerEventObject&
|
|||||||
CVF_ASSERT(rimView);
|
CVF_ASSERT(rimView);
|
||||||
|
|
||||||
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
|
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
|
||||||
cvf::Vec3d domainCoord = transForm->transformToDomainCoord(eventObject.m_globalIntersectionPoint);
|
cvf::Vec3d domainCoord = transForm->transformToDomainCoord(eventObject.m_partAndTriangleIndexPairs.front().globalPickedPoint());
|
||||||
|
|
||||||
if (intersection->inputPolyLineFromViewerEnabled())
|
if (intersection->inputPolyLineFromViewerEnabled())
|
||||||
{
|
{
|
||||||
|
@ -62,7 +62,7 @@ bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& even
|
|||||||
if(!eventObject.m_partAndTriangleIndexPairs.empty())
|
if(!eventObject.m_partAndTriangleIndexPairs.empty())
|
||||||
{
|
{
|
||||||
const auto & partAndTriangleIndexPair = eventObject.m_partAndTriangleIndexPairs.front();
|
const auto & partAndTriangleIndexPair = eventObject.m_partAndTriangleIndexPairs.front();
|
||||||
const cvf::Part* part = partAndTriangleIndexPair.first;
|
const cvf::Part* part = partAndTriangleIndexPair.pickedPart();
|
||||||
|
|
||||||
if (part)
|
if (part)
|
||||||
{
|
{
|
||||||
@ -76,7 +76,7 @@ bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& even
|
|||||||
if (eventObject.m_partAndTriangleIndexPairs.size() > 1)
|
if (eventObject.m_partAndTriangleIndexPairs.size() > 1)
|
||||||
{
|
{
|
||||||
const auto& secondPair = eventObject.m_partAndTriangleIndexPairs[1];
|
const auto& secondPair = eventObject.m_partAndTriangleIndexPairs[1];
|
||||||
const cvf::Part* secondPickedPart = secondPair.first;
|
const cvf::Part* secondPickedPart = secondPair.pickedPart();
|
||||||
if (secondPickedPart)
|
if (secondPickedPart)
|
||||||
{
|
{
|
||||||
auto wellPathSourceCandidate =
|
auto wellPathSourceCandidate =
|
||||||
@ -89,7 +89,7 @@ bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& even
|
|||||||
{
|
{
|
||||||
wellPathSourceInfo =
|
wellPathSourceInfo =
|
||||||
dynamic_cast<const RivWellPathSourceInfo*>(secondPickedPart->sourceInfo());
|
dynamic_cast<const RivWellPathSourceInfo*>(secondPickedPart->sourceInfo());
|
||||||
wellPathTriangleIndex = secondPair.second;
|
wellPathTriangleIndex = secondPair.faceIdx();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& even
|
|||||||
if (dynamic_cast<const RivWellPathSourceInfo*>(part->sourceInfo()))
|
if (dynamic_cast<const RivWellPathSourceInfo*>(part->sourceInfo()))
|
||||||
{
|
{
|
||||||
wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(part->sourceInfo());
|
wellPathSourceInfo = dynamic_cast<const RivWellPathSourceInfo*>(part->sourceInfo());
|
||||||
wellPathTriangleIndex = partAndTriangleIndexPair.second;
|
wellPathTriangleIndex = partAndTriangleIndexPair.faceIdx();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& even
|
|||||||
if (!rimView) return false;
|
if (!rimView) return false;
|
||||||
|
|
||||||
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
|
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
|
||||||
cvf::Vec3d pickedPositionInUTM = transForm->transformToDomainCoord(eventObject.m_globalIntersectionPoint);
|
cvf::Vec3d pickedPositionInUTM = transForm->transformToDomainCoord(eventObject.m_partAndTriangleIndexPairs.front().globalPickedPoint());
|
||||||
|
|
||||||
if (auto intersectionView = dynamic_cast<Rim2dIntersectionView*>(rimView))
|
if (auto intersectionView = dynamic_cast<Rim2dIntersectionView*>(rimView))
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "cvfPart.h"
|
#include "cvfPart.h"
|
||||||
#include "cvfDrawableGeo.h"
|
#include "cvfDrawableGeo.h"
|
||||||
#include "cvfTransform.h"
|
#include "cvfTransform.h"
|
||||||
|
#include "cvfHitItemCollection.h"
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -48,3 +49,17 @@ RiuPickItemInfo RiuPickItemInfo::extractPickItemInfo(const cvf::HitItem* hitItem
|
|||||||
|
|
||||||
return pickInfo;
|
return pickInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<RiuPickItemInfo> RiuPickItemInfo::convertToPickItemInfos( const cvf::HitItemCollection &hitItems)
|
||||||
|
{
|
||||||
|
std::vector<RiuPickItemInfo> pickItemInfos;
|
||||||
|
pickItemInfos.reserve(hitItems.count());
|
||||||
|
for ( size_t i = 0; i < hitItems.count(); i++ )
|
||||||
|
{
|
||||||
|
pickItemInfos.emplace_back(RiuPickItemInfo(hitItems.item(i)));
|
||||||
|
}
|
||||||
|
return pickItemInfos;
|
||||||
|
}
|
||||||
|
@ -20,12 +20,14 @@
|
|||||||
|
|
||||||
#include "cvfBase.h"
|
#include "cvfBase.h"
|
||||||
#include "cvfVector3.h"
|
#include "cvfVector3.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace cvf
|
namespace cvf
|
||||||
{
|
{
|
||||||
class Part;
|
class Part;
|
||||||
class Object;
|
class Object;
|
||||||
class HitItem;
|
class HitItem;
|
||||||
|
class HitItemCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -59,6 +61,7 @@ public:
|
|||||||
double distanceAlongRay() const { return m_distanceAlongRay;}
|
double distanceAlongRay() const { return m_distanceAlongRay;}
|
||||||
|
|
||||||
static RiuPickItemInfo extractPickItemInfo(const cvf::HitItem* hitItem);
|
static RiuPickItemInfo extractPickItemInfo(const cvf::HitItem* hitItem);
|
||||||
|
static std::vector<RiuPickItemInfo> convertToPickItemInfos(const cvf::HitItemCollection &hitItems);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_distanceAlongRay;
|
double m_distanceAlongRay;
|
||||||
|
@ -148,6 +148,7 @@ void RiuViewerCommands::setOwnerView(Rim3dView * owner)
|
|||||||
m_reservoirView = owner;
|
m_reservoirView = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -162,41 +163,43 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
|||||||
QMenu menu;
|
QMenu menu;
|
||||||
caf::CmdFeatureMenuBuilder menuBuilder;
|
caf::CmdFeatureMenuBuilder menuBuilder;
|
||||||
|
|
||||||
uint firstPartTriangleIndex = cvf::UNDEFINED_UINT;
|
|
||||||
cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO);
|
|
||||||
cvf::Vec3d globalIntersectionPoint(cvf::Vec3d::ZERO);
|
|
||||||
|
|
||||||
const cvf::Part* firstHitPart = nullptr;
|
const cvf::Part* firstHitPart = nullptr;
|
||||||
|
uint firstPartTriangleIndex = cvf::UNDEFINED_UINT;
|
||||||
m_currentPickPositionInDomainCoords = cvf::Vec3d::UNDEFINED;
|
m_currentPickPositionInDomainCoords = cvf::Vec3d::UNDEFINED;
|
||||||
|
|
||||||
// Check type of view
|
|
||||||
RimGridView* gridView = dynamic_cast<RimGridView*>(m_reservoirView.p());
|
|
||||||
Rim2dIntersectionView* int2dView = dynamic_cast<Rim2dIntersectionView*>(m_reservoirView.p());
|
|
||||||
|
|
||||||
cvf::HitItemCollection hitItems;
|
cvf::HitItemCollection hitItems;
|
||||||
if (m_viewer->rayPick(winPosX, winPosY, &hitItems))
|
if (m_viewer->rayPick(winPosX, winPosY, &hitItems))
|
||||||
{
|
{
|
||||||
std::vector<std::pair<const cvf::Part*, cvf::uint>> partAndTriangleIndexPairs;
|
std::vector<RiuPickItemInfo> pickItemInfos = RiuPickItemInfo::convertToPickItemInfos(hitItems);
|
||||||
extractIntersectionData(hitItems, &localIntersectionPoint, &globalIntersectionPoint,
|
|
||||||
&partAndTriangleIndexPairs, nullptr, nullptr);
|
|
||||||
|
|
||||||
for (const auto& partTringleIndex : partAndTriangleIndexPairs)
|
cvf::Vec3d globalIntersectionPoint(cvf::Vec3d::ZERO);
|
||||||
|
|
||||||
|
if ( pickItemInfos.size() )
|
||||||
{
|
{
|
||||||
if (!firstHitPart)
|
globalIntersectionPoint = pickItemInfos[0].globalPickedPoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& pickItem : pickItemInfos)
|
||||||
{
|
{
|
||||||
auto part = partTringleIndex.first;
|
const RivObjectSourceInfo* objectSourceInfo = dynamic_cast<const RivObjectSourceInfo*>(pickItem.sourceInfo());
|
||||||
const RivObjectSourceInfo* objectSourceInfo = dynamic_cast<const RivObjectSourceInfo*>(part->sourceInfo());
|
if ( objectSourceInfo && dynamic_cast<RimPerforationInterval*>(objectSourceInfo->object()) )
|
||||||
if (objectSourceInfo && dynamic_cast<RimPerforationInterval*>(objectSourceInfo->object()))
|
|
||||||
{
|
{
|
||||||
// Skip picking on perforation interval, display well path context menu
|
// Skip picking on perforation interval, display well path context menu
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
firstHitPart = part;
|
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(pickItem.sourceInfo());
|
||||||
firstPartTriangleIndex = partTringleIndex.second;
|
if ( rivSourceInfo && rivSourceInfo->hasNNCIndices())
|
||||||
break;
|
{
|
||||||
|
// Skip picking on nnc-s
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
firstHitPart = pickItem.pickedPart();
|
||||||
|
firstPartTriangleIndex = pickItem.faceIdx();
|
||||||
|
globalIntersectionPoint = pickItem.globalPickedPoint();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cvf::Vec3d displayModelOffset = cvf::Vec3d::ZERO;
|
cvf::Vec3d displayModelOffset = cvf::Vec3d::ZERO;
|
||||||
@ -209,6 +212,11 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check type of view
|
||||||
|
|
||||||
|
RimGridView* gridView = dynamic_cast<RimGridView*>(m_reservoirView.p());
|
||||||
|
Rim2dIntersectionView* int2dView = dynamic_cast<Rim2dIntersectionView*>(m_reservoirView.p());
|
||||||
|
|
||||||
if (firstHitPart && firstPartTriangleIndex != cvf::UNDEFINED_UINT)
|
if (firstHitPart && firstPartTriangleIndex != cvf::UNDEFINED_UINT)
|
||||||
{
|
{
|
||||||
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
|
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(firstHitPart->sourceInfo());
|
||||||
@ -518,19 +526,13 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
|
|||||||
cvf::HitItemCollection hitItems;
|
cvf::HitItemCollection hitItems;
|
||||||
if (m_viewer->rayPick(winPosX, winPosY, &hitItems))
|
if (m_viewer->rayPick(winPosX, winPosY, &hitItems))
|
||||||
{
|
{
|
||||||
std::vector<std::pair<const cvf::Part*, cvf::uint>> partAndTriangleIndexPairs;
|
if (hitItems.count())
|
||||||
extractIntersectionData(hitItems,
|
|
||||||
&localIntersectionPoint,
|
|
||||||
&globalIntersectionPoint,
|
|
||||||
&partAndTriangleIndexPairs,
|
|
||||||
&firstNncHitPart,
|
|
||||||
&nncPartTriangleIndex);
|
|
||||||
|
|
||||||
if (!partAndTriangleIndexPairs.empty())
|
|
||||||
{
|
{
|
||||||
RicViewerEventObject viewerEventObject(globalIntersectionPoint,
|
std::vector<RiuPickItemInfo> pickItemInfos = RiuPickItemInfo::convertToPickItemInfos(hitItems);
|
||||||
partAndTriangleIndexPairs,
|
|
||||||
|
RicViewerEventObject viewerEventObject(pickItemInfos,
|
||||||
m_reservoirView);
|
m_reservoirView);
|
||||||
|
|
||||||
for (size_t i = 0; i < m_viewerEventHandlers.size(); i++)
|
for (size_t i = 0; i < m_viewerEventHandlers.size(); i++)
|
||||||
{
|
{
|
||||||
if (m_viewerEventHandlers[i]->handleEvent(viewerEventObject))
|
if (m_viewerEventHandlers[i]->handleEvent(viewerEventObject))
|
||||||
@ -539,8 +541,24 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
firstHitPart = partAndTriangleIndexPairs.front().first;
|
size_t indexToFirstNoneNncItem = -1;
|
||||||
firstPartTriangleIndex = partAndTriangleIndexPairs.front().second;
|
size_t indexToNncItemNearFirstItem = -1;
|
||||||
|
|
||||||
|
findFirstItems(pickItemInfos, &indexToFirstNoneNncItem, &indexToNncItemNearFirstItem);
|
||||||
|
|
||||||
|
if ( indexToFirstNoneNncItem != -1 )
|
||||||
|
{
|
||||||
|
localIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].localPickedPoint();
|
||||||
|
globalIntersectionPoint = pickItemInfos[indexToFirstNoneNncItem].globalPickedPoint();
|
||||||
|
firstHitPart = pickItemInfos[indexToFirstNoneNncItem].pickedPart();
|
||||||
|
firstPartTriangleIndex = pickItemInfos[indexToFirstNoneNncItem].faceIdx();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (indexToNncItemNearFirstItem != -1)
|
||||||
|
{
|
||||||
|
firstNncHitPart = pickItemInfos[indexToNncItemNearFirstItem].pickedPart();
|
||||||
|
nncPartTriangleIndex = pickItemInfos[indexToNncItemNearFirstItem].faceIdx();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -903,8 +921,76 @@ void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionBoxSourceInfo*
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuViewerCommands::findFirstItems(const std::vector<RiuPickItemInfo> & pickItemInfos,
|
||||||
|
size_t* indexToFirstNoneNncItem,
|
||||||
|
size_t* indexToNncItemNearFirsItem)
|
||||||
|
{
|
||||||
|
CVF_ASSERT(pickItemInfos.size() > 0);
|
||||||
|
CVF_ASSERT(indexToFirstNoneNncItem);
|
||||||
|
CVF_ASSERT(indexToNncItemNearFirsItem);
|
||||||
|
|
||||||
|
double pickDepthThresholdSquared = 0.05 *0.05;
|
||||||
|
{
|
||||||
|
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(m_reservoirView.p());
|
||||||
|
|
||||||
|
if (eclipseView && eclipseView->mainGrid())
|
||||||
|
{
|
||||||
|
double characteristicCellSize = eclipseView->mainGrid()->characteristicIJCellSize();
|
||||||
|
pickDepthThresholdSquared = characteristicCellSize / 100.0;
|
||||||
|
pickDepthThresholdSquared = pickDepthThresholdSquared * pickDepthThresholdSquared;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t firstNonNncHitIndex = cvf::UNDEFINED_SIZE_T;
|
||||||
|
size_t nncNearFirstItemIndex = cvf::UNDEFINED_SIZE_T;
|
||||||
|
cvf::Vec3d firstOrFirstNonNncIntersectionPoint = pickItemInfos[0].globalPickedPoint();
|
||||||
|
|
||||||
|
// Find first nnc part, and store as a separate thing if the nnc is first or close behind the first hit item.
|
||||||
|
// Find index to first ordinary (non-nnc) part
|
||||||
|
|
||||||
|
for (size_t i = 0; i < pickItemInfos.size(); i++)
|
||||||
|
{
|
||||||
|
// If hit item is nnc and is close to first (none-nnc) hit, store nncpart and face id
|
||||||
|
|
||||||
|
bool canFindRelvantNNC = true;
|
||||||
|
|
||||||
|
const RivSourceInfo* rivSourceInfo = dynamic_cast<const RivSourceInfo*>(pickItemInfos[i].sourceInfo());
|
||||||
|
if ( rivSourceInfo && rivSourceInfo->hasNNCIndices() )
|
||||||
|
{
|
||||||
|
if ( nncNearFirstItemIndex == cvf::UNDEFINED_SIZE_T && canFindRelvantNNC)
|
||||||
|
{
|
||||||
|
cvf::Vec3d distFirstNonNNCToCandidate = firstOrFirstNonNncIntersectionPoint - pickItemInfos[i].globalPickedPoint();
|
||||||
|
|
||||||
|
// This candidate is an NNC hit
|
||||||
|
if ( distFirstNonNNCToCandidate.lengthSquared() < pickDepthThresholdSquared )
|
||||||
|
{
|
||||||
|
nncNearFirstItemIndex = i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
canFindRelvantNNC = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( firstNonNncHitIndex == cvf::UNDEFINED_SIZE_T )
|
||||||
|
{
|
||||||
|
firstNonNncHitIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstNonNncHitIndex != cvf::UNDEFINED_SIZE_T && (nncNearFirstItemIndex != cvf::UNDEFINED_SIZE_T || !canFindRelvantNNC) )
|
||||||
|
{
|
||||||
|
break; // Found what can be found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(*indexToFirstNoneNncItem) = firstNonNncHitIndex;
|
||||||
|
(*indexToNncItemNearFirsItem) = nncNearFirstItemIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// If there is an nnc-item within a depth-tolerance distance from the first hit-item
|
/// If there is an nnc-item within a depth-tolerance distance from the first hit-item
|
||||||
/// return this as nncPart and nncPartFaceHit
|
/// return this as nncPart and nncPartFaceHit
|
||||||
@ -917,7 +1003,9 @@ void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hi
|
|||||||
std::vector<std::pair<const cvf::Part*, cvf::uint>>* partAndTriangleIndexPairs,
|
std::vector<std::pair<const cvf::Part*, cvf::uint>>* partAndTriangleIndexPairs,
|
||||||
const cvf::Part** nncPart, uint* nncPartFaceHit)
|
const cvf::Part** nncPart, uint* nncPartFaceHit)
|
||||||
{
|
{
|
||||||
|
|
||||||
CVF_ASSERT(hitItems.count() > 0);
|
CVF_ASSERT(hitItems.count() > 0);
|
||||||
|
std::vector<RiuPickItemInfo> pickItemInfos = convertToPickItemInfos(hitItems);
|
||||||
|
|
||||||
double pickDepthThresholdSquared = 0.05 *0.05;
|
double pickDepthThresholdSquared = 0.05 *0.05;
|
||||||
{
|
{
|
||||||
@ -933,14 +1021,8 @@ void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hi
|
|||||||
|
|
||||||
size_t firstNonNncHitIndex = cvf::UNDEFINED_SIZE_T;
|
size_t firstNonNncHitIndex = cvf::UNDEFINED_SIZE_T;
|
||||||
size_t nncHitIndex = cvf::UNDEFINED_SIZE_T;
|
size_t nncHitIndex = cvf::UNDEFINED_SIZE_T;
|
||||||
cvf::Vec3d firstOrFirstNonNncIntersectionPoint = hitItems.item(0)->intersectionPoint();
|
cvf::Vec3d firstOrFirstNonNncIntersectionPoint = pickItemInfos[0].globalPickedPoint();
|
||||||
|
|
||||||
std::vector<RiuPickItemInfo> pickItemInfos;
|
|
||||||
pickItemInfos.reserve(hitItems.count());
|
|
||||||
for (size_t i = 0; i < hitItems.count(); i++)
|
|
||||||
{
|
|
||||||
pickItemInfos.emplace_back(RiuPickItemInfo(hitItems.item(i)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find first nnc part, and store as a separate thing if the nnc is first or close behind the first hit item.
|
// Find first nnc part, and store as a separate thing if the nnc is first or close behind the first hit item.
|
||||||
// Find index to first ordinary (non-nnc) part
|
// Find index to first ordinary (non-nnc) part
|
||||||
@ -1006,6 +1088,7 @@ void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -33,6 +33,7 @@ class Rim3dView;
|
|||||||
class RiuViewer;
|
class RiuViewer;
|
||||||
class RivIntersectionBoxSourceInfo;
|
class RivIntersectionBoxSourceInfo;
|
||||||
class RivIntersectionSourceInfo;
|
class RivIntersectionSourceInfo;
|
||||||
|
class RiuPickItemInfo;
|
||||||
|
|
||||||
class QMouseEvent;
|
class QMouseEvent;
|
||||||
|
|
||||||
@ -64,12 +65,10 @@ private:
|
|||||||
void findCellAndGridIndex(const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo, cvf::uint firstPartTriangleIndex, size_t* cellIndex, size_t* gridIndex);
|
void findCellAndGridIndex(const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo, cvf::uint firstPartTriangleIndex, size_t* cellIndex, size_t* gridIndex);
|
||||||
|
|
||||||
void ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k);
|
void ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k);
|
||||||
void extractIntersectionData(const cvf::HitItemCollection& hitItems,
|
|
||||||
cvf::Vec3d* localIntersectionPoint,
|
void findFirstItems(const std::vector<RiuPickItemInfo> & pickItemInfos,
|
||||||
cvf::Vec3d* globalIntersectionPoint,
|
size_t* indexToFirstNoneNncItem,
|
||||||
std::vector<std::pair<const cvf::Part*, cvf::uint>>* partAndTriangleIndexPairs,
|
size_t* indexToNncItemNearFirsItem);
|
||||||
const cvf::Part** nncPart,
|
|
||||||
uint* nncPartFaceHit);
|
|
||||||
|
|
||||||
bool handleOverlayItemPicking(int winPosX, int winPosY);
|
bool handleOverlayItemPicking(int winPosX, int winPosY);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user