MeshLib Documentation
Loading...
Searching...
No Matches
MRPointOnObject.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRPointOnFace.h"
4#include "MRMeshTriPoint.h"
5#include "MREdgePoint.h"
6#include <variant>
7
8namespace MR
9{
10
11// point located on either
12// 1. face of ObjectMesh
13// 2. line of ObjectLines
14// 3. point of ObjectPoints
16{
17 PointOnObject() {} //default ctor is required by Clang
19 Vector3f point;
21 float zBuffer{ 1.0f };
23 union
24 {
25 int primId = -1;
26 FaceId face; //for ObjectMesh
27 UndirectedEdgeId uedge; //for ObjectLines
28 VertId vert; //for ObjectPoints
29 };
30 [[nodiscard]] operator PointOnFace() const { return { .face = face, .point = point }; }
31};
32
33// For long-term storage of picked points on an object, such as point and contour widgets,
34// it is more convenient to use the local coordinates of the object rather than 3D coordinates,
35// which can change depending on the xf of the object.
36// --- MeshTriPoint for ObjectMeshHolder
37// --- EdgePoint for ObjectPointsHolder
38// --- VertId for ObjectLinesHolder (polylines)
39// --- int value (eq. -1) means not valid pick (pick in empty space).
40using PickedPoint = std::variant<MeshTriPoint, EdgePoint, VertId, int>;
41
42// Converts pickedPoint coordinates depending on the object type into a 3D Vector3
43MRMESH_API MR::Vector3f pickedPointToVector3( const VisualObject* object, const PickedPoint& point );
44
45// Converts PointOnObject coordinates depending on the object type to the PickedPoint variant
47
48// Checks that the picked point presents in the object's topology
49MRMESH_API bool isPickedPointValid( const VisualObject* object, const PickedPoint& point );
50
51} //namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Visual Object.
Definition MRVisualObject.h:131
Definition MRCameraOrientationPlugin.h:8
MRMESH_API MR::Vector3f pickedPointToVector3(const VisualObject *object, const PickedPoint &point)
MRMESH_API PickedPoint pointOnObjectToPickedPoint(const VisualObject *object, const PointOnObject &pos)
MRMESH_API bool isPickedPointValid(const VisualObject *object, const PickedPoint &point)
std::variant< MeshTriPoint, EdgePoint, VertId, int > PickedPoint
Definition MRPointOnObject.h:40
Definition MRMesh/MRPointOnFace.h:11
FaceId face
Definition MRMesh/MRPointOnFace.h:12
Definition MRPointOnObject.h:16
FaceId face
Definition MRPointOnObject.h:26
int primId
Definition MRPointOnObject.h:25
Vector3f point
3D location on the object in local coordinates
Definition MRPointOnObject.h:19
PointOnObject()
Definition MRPointOnObject.h:17
float zBuffer
z buffer value
Definition MRPointOnObject.h:21
VertId vert
Definition MRPointOnObject.h:28
UndirectedEdgeId uedge
Definition MRPointOnObject.h:27