2018-08-27 03:55:25 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2018- Equinor ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2018-08-27 03:55:25 -05:00
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2018-08-27 03:55:25 -05:00
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-08-27 03:55:25 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "cvfVector3.h"
|
2018-08-27 07:27:33 -05:00
|
|
|
#include <vector>
|
2018-08-27 03:55:25 -05:00
|
|
|
|
|
|
|
namespace cvf
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
class Part;
|
|
|
|
class Object;
|
|
|
|
class HitItem;
|
|
|
|
class HitItemCollection;
|
|
|
|
class Ray;
|
|
|
|
} // namespace cvf
|
2018-08-27 03:55:25 -05:00
|
|
|
|
|
|
|
class RiuPickItemInfo
|
|
|
|
{
|
|
|
|
public:
|
2019-09-06 03:40:57 -05:00
|
|
|
RiuPickItemInfo()
|
|
|
|
: m_distanceAlongRay( std::numeric_limits<double>::infinity() )
|
|
|
|
, m_pickedPart( nullptr )
|
|
|
|
, m_globalPickedPoint( cvf::Vec3d::UNDEFINED )
|
|
|
|
, m_localPickedPoint( cvf::Vec3d::UNDEFINED )
|
|
|
|
, m_globalRayOrigin( cvf::Vec3d::UNDEFINED )
|
|
|
|
, m_sourceInfo( nullptr )
|
|
|
|
, m_faceIdx( -1 )
|
|
|
|
{
|
|
|
|
}
|
2018-08-27 03:55:25 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
explicit RiuPickItemInfo( const cvf::HitItem* hitItem, const cvf::Vec3d& globalRayOrigin )
|
|
|
|
: m_pickedPart( nullptr )
|
|
|
|
, m_globalPickedPoint( cvf::Vec3d::UNDEFINED )
|
|
|
|
, m_localPickedPoint( cvf::Vec3d::UNDEFINED )
|
|
|
|
, m_globalRayOrigin( cvf::Vec3d::UNDEFINED )
|
|
|
|
, m_sourceInfo( nullptr )
|
|
|
|
, m_faceIdx( -1 )
|
2018-08-27 03:55:25 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
*this = extractPickItemInfo( hitItem );
|
2019-01-31 08:49:12 -06:00
|
|
|
m_globalRayOrigin = globalRayOrigin;
|
2018-08-27 03:55:25 -05:00
|
|
|
}
|
|
|
|
|
2020-02-12 04:13:38 -06:00
|
|
|
const cvf::Part* pickedPart() const { return m_pickedPart; }
|
|
|
|
cvf::Vec3d globalPickedPoint() const { return m_globalPickedPoint; }
|
|
|
|
cvf::Vec3d localPickedPoint() const { return m_localPickedPoint; }
|
|
|
|
const cvf::Object* sourceInfo() const { return m_sourceInfo; }
|
|
|
|
cvf::uint faceIdx() const { return m_faceIdx; }
|
|
|
|
double distanceAlongRay() const { return m_distanceAlongRay; }
|
|
|
|
cvf::Vec3d globalRayOrigin() const { return m_globalRayOrigin; }
|
2018-08-27 03:55:25 -05:00
|
|
|
|
2020-01-28 03:21:37 -06:00
|
|
|
float polygonOffsetUnit() const;
|
|
|
|
|
|
|
|
bool operator<( const RiuPickItemInfo& other ) const;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
static RiuPickItemInfo extractPickItemInfo( const cvf::HitItem* hitItem );
|
|
|
|
static std::vector<RiuPickItemInfo> convertToPickItemInfos( const cvf::HitItemCollection& hitItems,
|
2020-01-28 03:21:37 -06:00
|
|
|
const cvf::Vec3d& globalRayOrigin,
|
2023-02-26 03:48:40 -06:00
|
|
|
double coincidentRayDistanceTolerance = 1e-3 );
|
2018-08-27 03:55:25 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
double m_distanceAlongRay;
|
|
|
|
const cvf::Part* m_pickedPart;
|
|
|
|
cvf::Vec3d m_globalPickedPoint;
|
|
|
|
cvf::Vec3d m_localPickedPoint;
|
2019-01-31 08:49:12 -06:00
|
|
|
cvf::Vec3d m_globalRayOrigin;
|
2018-08-27 03:55:25 -05:00
|
|
|
const cvf::Object* m_sourceInfo;
|
|
|
|
cvf::uint m_faceIdx;
|
2020-01-28 03:21:37 -06:00
|
|
|
|
|
|
|
static double sm_rayDistanceTolerance;
|
2018-08-27 03:55:25 -05:00
|
|
|
};
|