22
33#include " polyscope/curve_network.h"
44
5+ #include " polyscope/elementary_geometry.h"
56#include " polyscope/pick.h"
67#include " polyscope/polyscope.h"
78#include " polyscope/render/engine.h"
@@ -348,17 +349,18 @@ void CurveNetwork::buildPickUI(const PickResult& rawResult) {
348349
349350 switch (result.elementType) {
350351 case CurveNetworkElement::NODE: {
351- buildNodePickUI(result.index );
352+ buildNodePickUI(result);
352353 break;
353354 }
354355 case CurveNetworkElement::EDGE: {
355- buildEdgePickUI(result.index );
356+ buildEdgePickUI(result);
356357 break;
357358 }
358359 };
359360}
360361
361- void CurveNetwork::buildNodePickUI(size_t nodeInd) {
362+ void CurveNetwork::buildNodePickUI(const CurveNetworkPickResult& result) {
363+ int32_t nodeInd = result.index;
362364
363365 ImGui::TextUnformatted((" node #" + std::to_string(nodeInd) + " " ).c_str());
364366 ImGui::SameLine();
@@ -379,12 +381,14 @@ void CurveNetwork::buildNodePickUI(size_t nodeInd) {
379381 ImGui::Indent(-20.);
380382}
381383
382- void CurveNetwork::buildEdgePickUI(size_t edgeInd) {
384+ void CurveNetwork::buildEdgePickUI(const CurveNetworkPickResult& result) {
385+ int32_t edgeInd = result.index;
386+
383387 ImGui::TextUnformatted((" edge #" + std::to_string(edgeInd) + " " ).c_str());
384388 ImGui::SameLine();
385- size_t n0 = edgeTailInds.getValue(edgeInd);
386- size_t n1 = edgeTipInds.getValue(edgeInd);
387- ImGui::TextUnformatted(( " " + std::to_string(n0) + " -- " + std::to_string(n1)).c_str() );
389+ int32_t n0 = edgeTailInds.getValue(edgeInd);
390+ int32_t n1 = edgeTipInds.getValue(edgeInd);
391+ ImGui::Text( " %d -- %d t_select = %. 4f " , n0, n1, result.tEdge );
388392
389393 ImGui::Spacing();
390394 ImGui::Spacing();
@@ -481,10 +485,10 @@ CurveNetworkPickResult CurveNetwork::interpretPickResult(const PickResult& rawRe
481485
482486 // compute the t \in [0,1] along the edge
483487 int32_t iStart = edgeTailInds.getValue (result.index );
484- int32_t iEnd= edgeTipInds.getValue (result.index );
488+ int32_t iEnd = edgeTipInds.getValue (result.index );
485489 glm::vec3 pStart = nodePositions.getValue (iStart);
486490 glm::vec3 pEnd = nodePositions.getValue (iEnd);
487-
491+ result. tEdge = computeTValAlongLine (rawResult. position , pStart, pEnd);
488492 } else {
489493 exception (" Bad pick index in curve network" );
490494 }
0 commit comments