MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / getPickedPointPosition

Function getPickedPointPosition

source/MRMesh/MRPointOnObject.cpp:29–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29std::optional<Vector3f> getPickedPointPosition( const VisualObject& object, const PickedPoint& point )
30{
31 return std::visit( overloaded{
32 []( const std::monostate& ) -> std::optional<Vector3f>
33 {
34 return {};
35 },
36 [&object]( const MeshTriPoint& triPoint ) -> std::optional<Vector3f>
37 {
38 if ( auto objMesh = dynamic_cast< const ObjectMeshHolder* >( &object ) )
39 {
40 if ( const auto& mesh = objMesh->mesh() )
41 {
42 const auto & topology = mesh->topology;
43 if ( topology.hasEdge( triPoint.e ) )
44 {
45 if ( triPoint.bary.b == 0 || topology.left( triPoint.e ) )
46 return mesh->triPoint( triPoint );
47 }
48 }
49 }
50 return {};
51 },
52 [&object]( const EdgePoint& edgePoint ) -> std::optional<Vector3f>
53 {
54 if ( auto objLines = dynamic_cast< const ObjectLinesHolder* >( &object ) )
55 {
56 if ( const auto& polyline = objLines->polyline() )
57 {
58 const auto & topology = polyline->topology;
59 if ( topology.hasEdge( edgePoint.e ) )
60 return objLines->polyline()->edgePoint( edgePoint );
61 }
62 }
63 return {};
64 },
65 [&object]( VertId vertId ) -> std::optional<Vector3f>
66 {
67 if ( auto objPoints = dynamic_cast< const ObjectPointsHolder* >( &object ) )
68 {
69 if ( const auto& pointCloud = objPoints->pointCloud() )
70 {
71 if ( pointCloud->validPoints.test( vertId ) )
72 return pointCloud->points[vertId];
73 }
74 }
75 return {};
76 }
77 }, point );
78}
79
80std::optional<Vector3f> getPickedPointNormal( const VisualObject& object, const PickedPoint& point, bool interpolated )
81{

Callers 4

findCoordsFunction · 0.85
createPickWidget_Method · 0.85
pickedPointToVector3Function · 0.85
isPickedPointValidFunction · 0.85

Calls 5

leftMethod · 0.80
triPointMethod · 0.80
hasEdgeMethod · 0.45
edgePointMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected