From: Pablo Garzon Date: Thu, 15 Jun 2023 11:25:07 +0000 (+0200) Subject: #3516 Join points tool X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9b4a68ab477d31540270afbc77a1ae5661a03eed;p=creaMaracasVisu.git #3516 Join points tool --- diff --git a/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg b/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg index 298832c..6993ce1 100644 --- a/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg +++ b/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg @@ -1,6 +1,6 @@ # ---------------------------------- # - BBTKGEditor v 1.5 BBG BlackBox Diagram file -# - /Users/davila/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg +# - /home/garzon/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg # ---------------------------------- APP_START @@ -523,9 +523,9 @@ ISEXEC:FALSE -265.790737:67.872984:-900.000000 -237.750737:65.372984:-900.000000 PORT -In0:"0 1 2 3 4 5 6 7 8 9 10 11" +In0:"0 1 2 3 4 5 6 7 8 9 10 11 12" PORT -In1:"1 5 10 20 30 40 50 0 100 110 205 210" +In1:"1 5 10 20 30 40 50 0 100 110 205 210 240" PORT Type:"2" FIN_BOX @@ -646,6 +646,8 @@ ISEXEC:FALSE -278.644612:87.294401:-900.000000 PORT In0:"Tool - Inverse Normals" +PORT +In1:"Tool - Join start and end points to current spline" FIN_BOX BOX creaMaracasVisu:ShowNPoints_Tools:Box116 diff --git a/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs b/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs index f92d158..bbfe251 100644 --- a/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs +++ b/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs @@ -1,6 +1,6 @@ # ---------------------------------- # - BBTKGEditor v 1.5 BBS BlackBox Script (Complex Box) -# - /Users/davila/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs +# - /home/garzon/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs # ---------------------------------- include std @@ -185,8 +185,8 @@ new std:AddStringToVector Box99 set Box99.In0 "Auto Add Points (Start/Stop)" new std:VectorFilterString Box100 - set Box100.In0 "0 1 2 3 4 5 6 7 8 9 10 11" - set Box100.In1 "1 5 10 20 30 40 50 0 100 110 205 210" + set Box100.In0 "0 1 2 3 4 5 6 7 8 9 10 11 12" + set Box100.In1 "1 5 10 20 30 40 50 0 100 110 205 210 240" set Box100.Type "2" new std:ConcatStrings Box101 @@ -234,6 +234,7 @@ new wx:LayoutLine Box114 new std:AddStringToVector Box115 set Box115.In0 "Tool - Inverse Normals" + set Box115.In1 "Tool - Join start and end points to current spline" new creaMaracasVisu:ShowNPoints_Tools Box116 set Box116.BoxProcessMode "Manual" diff --git a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx index 1d8215e..968542a 100644 --- a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx +++ b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx @@ -762,6 +762,32 @@ void ShowNPoints_Tools::MovePointInNormal() } } + +void ShowNPoints_Tools::JoinPoints() +{ + WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints(); + wsp->StopAutoAddPoints(); + wsp->StopTrackPoint(); + if((wsp->GetLstModelShowNPointsSize()>=2) + && (wsp->GetModelShowNPoints()->GetLstPointsSize()>0)) + { + int numberOfSplines = wsp->GetLstModelShowNPointsSize(); + double x, y, z; + int sizeCurrentSpline, i; + wsp->GetModelShowNPoints()->GetIdPoint(0, &x, &y, &z); + std::vector pointStart = {x, y, z}; + sizeCurrentSpline = wsp->GetModelShowNPoints()->GetLstPointsX().size(); + wsp->GetModelShowNPoints()->GetIdPoint(sizeCurrentSpline-1, &x, &y, &z); + std::vector pointEnd = {x, y, z}; + for(i = 0; i < numberOfSplines; i++){ + sizeCurrentSpline = wsp->GetModelShowNPoints(i)->GetLstPointsX().size(); + wsp->SetCollectionPoint(i, 0, pointStart); + wsp->SetCollectionPoint(i, sizeCurrentSpline-1, pointEnd); + } + wsp->SetOutputBox(); + wsp->UndoRedo_SaveCollection(); + } +} //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== @@ -846,6 +872,10 @@ void ShowNPoints_Tools::Process() { MovePointInNormal(); } // if Type + if(bbGetInputType()==240) + { + JoinPoints(); + } // if Type if(bbGetInputType()==300) { CreateExpandedSurface(); diff --git a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h index fda64b0..0b5f0c1 100644 --- a/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h +++ b/bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h @@ -48,6 +48,7 @@ class bbcreaMaracasVisu_EXPORT ShowNPoints_Tools void WidenSurface(); void ExpandPatch(); void MovePointInNormal(); + void JoinPoints(); //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) @@ -62,7 +63,7 @@ BBTK_CATEGORY("empty"); BBTK_INPUT(ShowNPoints_Tools,WidgetShowNPoints,"WidgetShowNPoints",WidgetShowNPoints*,""); BBTK_INPUT(ShowNPoints_Tools,Spacing,"(default [1,1,1] )Spacing",std::vector,""); BBTK_INPUT(ShowNPoints_Tools,Mesh,"Mesh en format vtkPolyData ",vtkPolyData*,""); - BBTK_INPUT(ShowNPoints_Tools,Type,"(default 0) 0:Nothing 1:Auto add poits 5:Add Point 10:Insert Point 20:TrackPoint 30:Set nearest point 40:Erase point 50:Deleta all points 100:Insert group after 110:Delete group 120:Reset colletion 200:Tool 3 or 4 points to patch surface - Create Mesh (based on 1 group and 3 or 4 points) 205:Tool 3 or 4 points to volume surface - Create Mesh (based on 1 group and 3 or 4 points) 210: Invert points 220: Move patch center 300: Create expanded surface 310: Create wide expanded surface 320: Expand Surface, 330: Widen surface, 340: Expand patch",int,""); + BBTK_INPUT(ShowNPoints_Tools,Type,"(default 0) 0:Nothing 1:Auto add poits 5:Add Point 10:Insert Point 20:TrackPoint 30:Set nearest point 40:Erase point 50:Deleta all points 100:Insert group after 110:Delete group 120:Reset colletion 200:Tool 3 or 4 points to patch surface - Create Mesh (based on 1 group and 3 or 4 points) 205:Tool 3 or 4 points to volume surface - Create Mesh (based on 1 group and 3 or 4 points) 210: Invert points 220: Move patch center 230: Move point in normal of surface 240: Join all start-end points to the start-end points on selected spline 300: Create expanded surface 310: Create wide expanded surface 320: Expand Surface, 330: Widen surface, 340: Expand patch",int,""); BBTK_INPUT(ShowNPoints_Tools, Params,"Optional params for the tools, required for 200: normal and direction, 320: centroid and direction, 330: normal and direction, 340: centroid and direction", std::vector,""); BBTK_OUTPUT(ShowNPoints_Tools, Out, "Output", std::vector, ""); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx index 44e9c87..d2dc044 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx @@ -356,6 +356,15 @@ ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints() return lstModelShowNPoints[ mActualCollection ]; } +//------------------------------------------------------------------------ +ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints(int id) +{ + if(id >= 0 && id < lstModelShowNPoints.size()) + { + return lstModelShowNPoints[ id ]; + } +} + // EED 2022-05-19 //------------------------------------------------------------------------ ViewShowNPoints* WidgetShowNPoints::GetViewShowNPoints() diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h index 2ab28bb..30c3863 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h @@ -101,6 +101,7 @@ class WidgetShowNPoints : public wxPanel int GetLstModelShowNPointsSize(); ModelShowNPoints* GetModelShowNPoints(); + ModelShowNPoints* GetModelShowNPoints(int id); ViewShowNPoints* GetViewShowNPoints(); void SetInitLstPoints( std::vector initLstPointsX, std::vector initLstPointsY, std::vector initLstPointsZ, std::vector initLstLabels, std::vector initLstIndexs );