]> Creatis software - creaMaracasVisu.git/commitdiff
#3504 Integer to double ShowNpoints
authorPablo Garzon <garzon@ei-pfe-706.creatis.insa-lyon.fr>
Tue, 4 Apr 2023 12:26:03 +0000 (14:26 +0200)
committerPablo Garzon <garzon@ei-pfe-706.creatis.insa-lyon.fr>
Tue, 4 Apr 2023 12:26:03 +0000 (14:26 +0200)
bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbg
bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbs
bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx
bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h
bbtk/src/bbmaracasvisuShowNPoints.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/ViewShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h

index ddc0a77572c5c30ea56120782518b8dc4cded78d..b75e4201b5745950269a33a392ab04db71a1bcd4 100644 (file)
@@ -1,6 +1,6 @@
 # ----------------------------------
 # - BBTKGEditor v 1.5 BBG BlackBox Diagram file
-# - /Users/davila/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbg
+# - /home/garzon/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbg
 # ----------------------------------
 
 APP_START
@@ -179,7 +179,7 @@ In7:"+>  Insert group after"
 PORT
 In8:"-  Delete group"
 PORT
-In9:"Tool - 3 points to surface"
+In9:"Tool - 3 or 4 points to surface"
 FIN_BOX
 BOX
 creaMaracasVisu:ShowNPoints_Tools:Box60
@@ -623,9 +623,7 @@ ISEXEC:FALSE
 -301.046687:92.535608:-900.000000
 -276.526687:90.035608:-900.000000
 PORT
-In0:"Tool - 4 points to surface"
-PORT
-In1:"Tool - Inverse Normals"
+In0:"Tool - Inverse Normals"
 FIN_BOX
 BOX
 std:VectorFilterString:Box112
@@ -633,9 +631,9 @@ ISEXEC:FALSE
 -276.139970:71.814693:-900.000000
 -248.099970:69.314693:-900.000000
 PORT
-In0:"0 1    2   3   4   5   6   7   8       9     10     11     12"
+In0:"0 1    2   3   4   5   6   7   8       9     10     11"
 PORT
-In1:"1  5  10 20 30 40 50 0  100   110  190   200   210"
+In1:"1  5  10 20 30 40 50 0  100   110   200   210"
 PORT
 Type:"2"
 FIN_BOX
@@ -1083,9 +1081,6 @@ CONNECTION
 Box100:Out:Box95:Param
 NumberOfControlPoints:0
 CONNECTION
-Box99:Widget:Box101:Widget4
-NumberOfControlPoints:0
-CONNECTION
 Box99:BoxChange:Box103:In4
 NumberOfControlPoints:0
 CONNECTION
@@ -1206,9 +1201,6 @@ CONNECTION
 Box117:Widget:Box44:Widget3
 NumberOfControlPoints:0
 CONNECTION
-Box118:Widget:Box101:Widget1
-NumberOfControlPoints:0
-CONNECTION
 Box118:Out:Box96:ScalarFactor
 NumberOfControlPoints:0
 CONNECTION
@@ -1269,9 +1261,15 @@ CONNECTION
 Box127:Widget:Box129:Widget4
 NumberOfControlPoints:0
 CONNECTION
-Box129:Widget:Box101:Widget7
+Box121:Widget:Box129:Widget6
 NumberOfControlPoints:0
 CONNECTION
-Box121:Widget:Box129:Widget6
+Box99:Widget:Box101:Widget7
+NumberOfControlPoints:0
+CONNECTION
+Box118:Widget:Box101:Widget4
+NumberOfControlPoints:0
+CONNECTION
+Box129:Widget:Box101:Widget1
 NumberOfControlPoints:0
 APP_END
index 482b97cdbbe1f7e4bed3a2b8f0f87d9426ddee23..1ca503f8942d030451f9f7ef61a1d004ad76e2e7 100644 (file)
@@ -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_ApplyPatch.bbs
+# - /home/garzon/Creatis/C23/creatools_source/creaMaracasVisu/bbtk/bbs/boxes/Mesh_tool_ApplyPatch.bbs
 # ----------------------------------
 
 include std
@@ -60,7 +60,7 @@ new std:AddStringToVector Box58
   set Box58.In6 "----------------------"
   set Box58.In7 "+>  Insert group after"
   set Box58.In8 "-  Delete group"
-  set Box58.In9 "Tool - 3 points to surface"
+  set Box58.In9 "Tool - 3 or 4 points to surface"
 
 new creaMaracasVisu:ShowNPoints_Tools Box60
 
@@ -224,12 +224,11 @@ new creaVtk:MeshReduction_QuadricDecimation Box110
   set Box110.TargetReduction "0.5"
 
 new std:AddStringToVector Box111
-  set Box111.In0 "Tool - 4 points to surface"
-  set Box111.In1 "Tool - Inverse Normals"
+  set Box111.In0 "Tool - Inverse Normals"
 
 new std:VectorFilterString Box112
-  set Box112.In0 "0 1    2   3   4   5   6   7   8       9     10     11     12"
-  set Box112.In1 "1  5  10 20 30 40 50 0  100   110  190   200   210"
+  set Box112.In0 "0 1    2   3   4   5   6   7   8       9     10     11"
+  set Box112.In1 "1  5  10 20 30 40 50 0  100   110   200   210"
   set Box112.Type "2"
 
 new std:ConcatStrings Box114
@@ -371,7 +370,6 @@ connect Box04.Out Box95.In
 connect Box95.Out Box96.In
 connect Box99.Out Box100.In1
 connect Box100.Out Box95.Param
-connect Box99.Widget Box101.Widget4
 connect Box99.BoxChange Box103.In4
 connect Box103.BoxChange Box98.boxexecute
 connect Box71.Out Box105.wxVtkBaseView
@@ -412,7 +410,6 @@ connect Box43.Widget Box44.Widget1
 connect Box78.Widget Box117.Widget2
 connect Box80.Widget Box117.Widget4
 connect Box117.Widget Box44.Widget3
-connect Box118.Widget Box101.Widget1
 connect Box118.Out Box96.ScalarFactor
 connect Box118.BoxChange Box103.In3
 connect Box119.Out Box58.StringVector
@@ -433,8 +430,10 @@ connect Box128.BoxChange Box126.In2
 connect Box120.BoxChange Box126.In1
 connect Box126.BoxChange Box31.BoxExecute
 connect Box127.Widget Box129.Widget4
-connect Box129.Widget Box101.Widget7
 connect Box121.Widget Box129.Widget6
+connect Box99.Widget Box101.Widget7
+connect Box118.Widget Box101.Widget4
+connect Box129.Widget Box101.Widget1
 
 # Complex input ports
 input point showNpoints.In " "
index 84435b2ab3567d5a051c55fe4173ebf72e38652e..254ad790f2df48bc73ee89c30dbf0f06aca01016 100644 (file)
@@ -32,107 +32,112 @@ void ShowNPoints_Tools::CreatePatch_3points()
 {
        //printf("PG ShowNPoints_Tools::CreatePatch_3points  Entered patch 3 points !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
        WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
-       wsp->StopAutoAddPoints();
-    wsp->StopTrackPoint();
-       if ( (wsp->GetLstModelShowNPointsSize()==1) &&
-         (wsp->GetModelShowNPoints()->GetLstPointsSize()==3) &&
-         (bbGetInputMesh()!=NULL ) )
-    {
-               std::vector<int> lstX = wsp->GetModelShowNPoints()->GetLstPointsX();
-               std::vector<int> lstY = wsp->GetModelShowNPoints()->GetLstPointsY();
-               std::vector<int> lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ();
-               
-               double pA[3];
-        pA[0] = lstX[0];
-        pA[1] = lstY[0];
-        pA[2] = lstZ[0];
-        double pB[3];
-        pB[0] = lstX[1];
-        pB[1] = lstY[1];
-        pB[2] = lstZ[1];
-        double pC[3];
-        pC[0] = lstX[2];
-        pC[1] = lstY[2];
-        pC[2] = lstZ[2];
+       
+       std::vector<double> lstX = wsp->GetModelShowNPoints()->GetLstPointsX();
+       std::vector<double> lstY = wsp->GetModelShowNPoints()->GetLstPointsY();
+       std::vector<double> lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ();
+       
+       double pA[3];
+    pA[0] = lstX[0];
+    pA[1] = lstY[0];
+    pA[2] = lstZ[0];
+    double pB[3];
+    pB[0] = lstX[1];
+    pB[1] = lstY[1];
+    pB[2] = lstZ[1];
+    double pC[3];
+    pC[0] = lstX[2];
+    pC[1] = lstY[2];
+    pC[2] = lstZ[2];
 
-               double v[3];
-               double u[3];
-               vtkMath::Subtract(pC,pA,v);
-               vtkMath::Subtract(pB,pA,u);
-               
-               /**point in AC closest to B.
-               *formula t=(V)dot(U)/(V)dot(V)
-               */
-               double t = vtkMath::Dot(v,u)/vtkMath::Dot(v,v);
-               /**nP found point
-               *formula A+t(C-A) -> A+tV
-               */
-               vtkMath::MultiplyScalar(v, t);
-               double nP[3];
-               vtkMath::Add(pA, v, nP);
-               
-               //calculate direction vector from found point to B
-               double dirVector[3];
-               vtkMath::Subtract(pB, nP, dirVector);
-               
-               double pointAdd[3];
-               double pointSub[3];
-               
-               //Add and subtract direction vector to A and C to find the 4 points to create the patch,
-               
-               std::vector<int> resListX;
-               std::vector<int> resListY;
-               std::vector<int> resListZ;
-               
-               vtkMath::Add(pA, dirVector, pointAdd);
-               vtkMath::Subtract(pA, dirVector, pointSub);
-               
-               resListX.push_back(pointSub[0]);
-               resListY.push_back(pointSub[1]);
-               resListZ.push_back(pointSub[2]);
+       double v[3];
+       double u[3];
+       vtkMath::Subtract(pC,pA,v);
+       vtkMath::Subtract(pB,pA,u);
+       
+       /**point in AC closest to B.
+       *formula t=(V)dot(U)/(V)dot(V)
+       */
+       double t = vtkMath::Dot(v,u)/vtkMath::Dot(v,v);
+       /**nP found point
+       *formula A+t(C-A) -> A+tV
+       */
+       vtkMath::MultiplyScalar(v, t);
+       double nP[3];
+       vtkMath::Add(pA, v, nP);
+       
+       //calculate direction vector from found point to B
+       double dirVector[3];
+       vtkMath::Subtract(pB, nP, dirVector);
+       
+       double pointAdd[3];
+       double pointSub[3];
+       
+       //Add and subtract direction vector to A and C to find the 4 points to create the patch,
+       
+       std::vector<double> resListX;
+       std::vector<double> resListY;
+       std::vector<double> resListZ;
+       
+       vtkMath::Add(pA, dirVector, pointAdd);
+       vtkMath::Subtract(pA, dirVector, pointSub);
+       
+       resListX.push_back(pointSub[0]);
+       resListY.push_back(pointSub[1]);
+       resListZ.push_back(pointSub[2]);
 
-               resListX.push_back(pointAdd[0]);
-               resListY.push_back(pointAdd[1]);
-               resListZ.push_back(pointAdd[2]);
-               
-               
-               vtkMath::Add(pC, dirVector, pointAdd);
-               vtkMath::Subtract(pC, dirVector, pointSub);
-               
-               resListX.push_back(pointAdd[0]);
-               resListY.push_back(pointAdd[1]);
-               resListZ.push_back(pointAdd[2]);
-               
-               resListX.push_back(pointSub[0]);
-               resListY.push_back(pointSub[1]);
-               resListZ.push_back(pointSub[2]);
-               //printf("PG ShowNPoints_Tools::CreatePatch_3points  Calls CreatePatch_Points !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
-               //Create patch given the previously calculated points (4 points)
-               CreatePatch_Points(resListX, resListY, resListZ);
-       }else{
-               //printf("PG ShowNPoints_Tools::CreatePatch_3points  Warning patch not apply. Need only one group of 3 points\n");
-       }
+       resListX.push_back(pointAdd[0]);
+       resListY.push_back(pointAdd[1]);
+       resListZ.push_back(pointAdd[2]);
+       
+       
+       vtkMath::Add(pC, dirVector, pointAdd);
+       vtkMath::Subtract(pC, dirVector, pointSub);
+       
+       resListX.push_back(pointAdd[0]);
+       resListY.push_back(pointAdd[1]);
+       resListZ.push_back(pointAdd[2]);
+       
+       resListX.push_back(pointSub[0]);
+       resListY.push_back(pointSub[1]);
+       resListZ.push_back(pointSub[2]);
+
+       //Create patch given the previously calculated points (4 points)
+       CreatePatch_Points(resListX, resListY, resListZ);
 }
 
 void ShowNPoints_Tools::CreatePatch_4points()
+{
+       WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
+            
+       std::vector<double> lstX = wsp->GetModelShowNPoints()->GetLstPointsX();
+       std::vector<double> lstY = wsp->GetModelShowNPoints()->GetLstPointsY();
+       std::vector<double> lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ();
+       CreatePatch_Points(lstX, lstY, lstZ);
+}
+
+void ShowNPoints_Tools::InitCreatePatch_Points()
 {
        WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
        wsp->StopAutoAddPoints();
     wsp->StopTrackPoint();
-       if ( (wsp->GetLstModelShowNPointsSize()==1) &&
-         (wsp->GetModelShowNPoints()->GetLstPointsSize()==4) &&
-         (bbGetInputMesh()!=NULL ) )
-    {               
-               std::vector<int> lstX = wsp->GetModelShowNPoints()->GetLstPointsX();
-               std::vector<int> lstY = wsp->GetModelShowNPoints()->GetLstPointsY();
-               std::vector<int> lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ();
-               CreatePatch_Points(lstX, lstY, lstZ);
-    }else{
-               printf("PG ShowNPoints_Tools::CreatePatch_4points  Warning patch not apply. Need only one group of 4 points\n");
+       if((wsp->GetLstModelShowNPointsSize()==1) && (bbGetInputMesh()!=NULL )){
+               if(wsp->GetModelShowNPoints()->GetLstPointsSize()==4){
+                       CreatePatch_4points();
+               }
+               else if(wsp->GetModelShowNPoints()->GetLstPointsSize()==3){
+                       CreatePatch_3points();
+               }
+               else{
+                       printf("PG ShowNPoints_Tools::CreatePatch_Npoints  Warning patch not apply. Number of points is invalid. Group should have 3 or 4 points\n");
+               }
+       }
+       else{
+               printf("PG ShowNPoints_Tools::CreatePatch_Npoints  Warning patch not apply. groups or mesh invalid. Need 1 group of 3 or 4 points, and a mesh\n");
        }
 }
 
-void ShowNPoints_Tools::CreatePatch_Points(std::vector<int> lstX, std::vector<int> lstY, std::vector<int> lstZ)
+void ShowNPoints_Tools::CreatePatch_Points(std::vector<double> lstX, std::vector<double> lstY, std::vector<double> lstZ)
 {
     WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
     std::vector<long int>   lstIdNormalSurface;
@@ -347,7 +352,6 @@ void ShowNPoints_Tools::MovePatchCenter()
                modPoint.push_back(centerPoint[2] + direction * normal[2]);
 
                wsp->SetCollectionPoint(1, 1, modPoint);
-               wsp->GetViewShowNPoints()->RefreshPoints();
         
         // --- Finish ---
         wsp->SetOutputBox();
@@ -421,13 +425,9 @@ void ShowNPoints_Tools::Process()
         {
             bbGetInputWidgetShowNPoints()->OnResetCollections_();
         } // if Type
-        if (bbGetInputType()==190)
-        {
-            CreatePatch_3points();
-        } // if Type
         if (bbGetInputType()==200)
         {
-            CreatePatch_4points();
+            InitCreatePatch_Points();
         } // if Type
         if (bbGetInputType()==210)
         {
index d0abad840e0b5f1c2979edff5f651ed7190af920..2f510b4e73cf57ff73878bc8ae78241b60b2b789 100644 (file)
@@ -37,7 +37,8 @@ class bbcreaMaracasVisu_EXPORT ShowNPoints_Tools
     
     void CreatePatch_3points();
     void CreatePatch_4points();
-    void CreatePatch_Points(std::vector<int> lstX, std::vector<int> lstY, std::vector<int> lstZ);
+    void InitCreatePatch_Points();
+    void CreatePatch_Points(std::vector<double> lstX, std::vector<double> lstY, std::vector<double> lstZ);
     void NearestPointToMesh( vtkPoints *points, vtkStaticPointLocator   *pointLocator, double *spc , double *p , double *pM   );
     void MovePatchCenter();
 
@@ -54,8 +55,8 @@ BBTK_CATEGORY("empty");
   BBTK_INPUT(ShowNPoints_Tools,WidgetShowNPoints,"WidgetShowNPoints",WidgetShowNPoints*,"");
   BBTK_INPUT(ShowNPoints_Tools,Spacing,"(default [1,1,1] )Spacing",std::vector<double>,"");
   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  190:Tool 3 points to surface - Create Mesh (based with one group and 3 points)   200:Tool 4 points to surface - Create Mesh (based with one group and 4 points)         210: Invert points      220: Move patch center",int,"");
-  BBTK_INPUT(ShowNPoints_Tools, Params,"Optional params for the tools,         required for 200: Normal and direction", std::vector<double>,"");
+  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 surface - Create Mesh (based on one group and 3 or 4 points)  210: Invert points      220: Move patch center",int,"");
+  BBTK_INPUT(ShowNPoints_Tools, Params,"Optional params for the tools, required 200: Normal and direction", std::vector<double>,"");
   
   BBTK_OUTPUT(ShowNPoints_Tools, Out, "Output", std::vector<double>, "");
 //  BBTK_OUTPUT(ShowNPoints_Tools,Out,"First output",double,"");
index 2312b2e5871216b738df82c6388df2f9950c78a6..5c6a56a172301c52ba49c508822798f4cf93b8ee 100644 (file)
@@ -64,22 +64,22 @@ class /*BBTK_EXPORT*/ ShowNPoints
    public bbtk::WxBlackBox
 {
   BBTK_BLACK_BOX_INTERFACE(ShowNPoints,bbtk::WxBlackBox);
-  BBTK_DECLARE_INPUT(In, std::vector<int> );
+  BBTK_DECLARE_INPUT(In, std::vector<double> );
   BBTK_DECLARE_INPUT(Renderer, vtkRenderer* );
   BBTK_DECLARE_INPUT(Image, vtkImageData* );
   BBTK_DECLARE_INPUT(Colour, std::vector<double> );
   BBTK_DECLARE_INPUT(Opacity, double );
   BBTK_DECLARE_INPUT(Radio, double );
-  BBTK_DECLARE_INPUT(InitLstPointsX , std::vector<int> );
-  BBTK_DECLARE_INPUT(InitLstPointsY , std::vector<int> );
-  BBTK_DECLARE_INPUT(InitLstPointsZ , std::vector<int> );
+  BBTK_DECLARE_INPUT(InitLstPointsX , std::vector<double> );
+  BBTK_DECLARE_INPUT(InitLstPointsY , std::vector<double> );
+  BBTK_DECLARE_INPUT(InitLstPointsZ , std::vector<double> );
   BBTK_DECLARE_INPUT(InitLstLabels  , std::vector<std::string> );
   BBTK_DECLARE_INPUT(InitLstIndexs  , std::vector<int> );
   BBTK_DECLARE_INPUT(Type, int );
 
-  BBTK_DECLARE_OUTPUT( lstPointsX   , std::vector<int> );
-  BBTK_DECLARE_OUTPUT( lstPointsY   , std::vector<int> );
-  BBTK_DECLARE_OUTPUT( lstPointsZ   , std::vector<int> );
+  BBTK_DECLARE_OUTPUT( lstPointsX   , std::vector<double> );
+  BBTK_DECLARE_OUTPUT( lstPointsY   , std::vector<double> );
+  BBTK_DECLARE_OUTPUT( lstPointsZ   , std::vector<double> );
   BBTK_DECLARE_OUTPUT( lstLabels    ,  std::vector<std::string> );
   BBTK_DECLARE_OUTPUT( WidgetShowNPoints,  WidgetShowNPoints*);
   BBTK_DECLARE_OUTPUT( lstIndexs    , std::vector<int> );
@@ -98,22 +98,22 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ShowNPoints,bbtk::WxBlackBox);
   BBTK_DESCRIPTION("widget that shows N moints in 3D (vtkActors)");
   BBTK_CATEGORY("widgetVtk");
 
-  BBTK_INPUT(ShowNPoints,In,"One Point",std::vector<int>,"");
+  BBTK_INPUT(ShowNPoints,In,"One Point",std::vector<double>,"");
   BBTK_INPUT(ShowNPoints,Renderer,"Renderer",vtkRenderer*,"");
   BBTK_INPUT(ShowNPoints,Image,"vktkImageData",vtkImageData*,"");
   BBTK_INPUT(ShowNPoints,Colour,"Colour of the actor",std::vector<double>,"colour");
   BBTK_INPUT(ShowNPoints,Opacity,"Opacity of the actor 0..1 (default 1)",double,"");
   BBTK_INPUT(ShowNPoints,Radio,"Radio of the spheres 1..50 (default 10)",double,"");
-  BBTK_INPUT(ShowNPoints,InitLstPointsX,"Initial lst of points X",std::vector<int>,"");
-  BBTK_INPUT(ShowNPoints,InitLstPointsY,"Initial lst of points Y",std::vector<int>,"");
-  BBTK_INPUT(ShowNPoints,InitLstPointsZ,"Initial lst of points Z",std::vector<int>,"");
+  BBTK_INPUT(ShowNPoints,InitLstPointsX,"Initial lst of points X",std::vector<double>,"");
+  BBTK_INPUT(ShowNPoints,InitLstPointsY,"Initial lst of points Y",std::vector<double>,"");
+  BBTK_INPUT(ShowNPoints,InitLstPointsZ,"Initial lst of points Z",std::vector<double>,"");
   BBTK_INPUT(ShowNPoints,InitLstLabels,"Initial lst of labels",std::vector<std::string>,"");
   BBTK_INPUT(ShowNPoints,InitLstIndexs,"Initial lst of indexs sizes",std::vector<int>,"");
   BBTK_INPUT(ShowNPoints,Type,"Type of the widget. 0(default): N-points, 1:Just one point, 2:Add/DeleteAll points, 3:As 0 with out save/load option, 4 Multiple NPoints",int,"");
 
-  BBTK_OUTPUT(ShowNPoints , lstPointsX , " list of points X ", std::vector<int> ,"");
-  BBTK_OUTPUT(ShowNPoints , lstPointsY , " list of points Y ", std::vector<int> ,"");
-  BBTK_OUTPUT(ShowNPoints , lstPointsZ , " list of points Z ", std::vector<int> ,"");
+  BBTK_OUTPUT(ShowNPoints , lstPointsX , " list of points X ", std::vector<double> ,"");
+  BBTK_OUTPUT(ShowNPoints , lstPointsY , " list of points Y ", std::vector<double> ,"");
+  BBTK_OUTPUT(ShowNPoints , lstPointsZ , " list of points Z ", std::vector<double> ,"");
   BBTK_OUTPUT(ShowNPoints , lstLabels , " list of labels ", std::vector<std::string> ,"");
   BBTK_OUTPUT(ShowNPoints , lstIndexs , " list of index sizes ", std::vector<int> ,"");
   BBTK_OUTPUT(ShowNPoints , WidgetShowNPoints , " WidgetShowNPoints ", WidgetShowNPoints* ,"");
index ea3616a7113830e4af1a7e5fff2bb0a3078b478f..a66c92d6be55c1fa9316a09aa42dfb007c4a72eb 100644 (file)
@@ -28,19 +28,19 @@ double ModelShowNPoints::GetRadio()
 }
 
 //------------------------------------------------------------------------
-std::vector<int> ModelShowNPoints::GetLstPointsX()
+std::vector<double> ModelShowNPoints::GetLstPointsX()
 {
        return lstPointsX;
 }
 
 //------------------------------------------------------------------------
-std::vector<int> ModelShowNPoints::GetLstPointsY()
+std::vector<double> ModelShowNPoints::GetLstPointsY()
 {
        return lstPointsY;
 }
 
 //------------------------------------------------------------------------
-std::vector<int> ModelShowNPoints::GetLstPointsZ()
+std::vector<double> ModelShowNPoints::GetLstPointsZ()
 {
        return lstPointsZ;
 }
@@ -65,13 +65,13 @@ std::vector<std::string> ModelShowNPoints::GetLstLabels()
 }
 
 //------------------------------------------------------------------------
-void ModelShowNPoints::SetReferencePoint(std::vector<int> ppoint)
+void ModelShowNPoints::SetReferencePoint(std::vector<double> ppoint)
 {
        mReferencePoint = ppoint;
 }
 
 //------------------------------------------------------------------------
-std::vector<int> ModelShowNPoints::GetReferencePoint()
+std::vector<double> ModelShowNPoints::GetReferencePoint()
 {
        return mReferencePoint;
 }
@@ -95,7 +95,7 @@ std::string ModelShowNPoints::CleanSpaces(std::string ss)
 }
 
 //------------------------------------------------------------------------
-void ModelShowNPoints::GetIdPoint(int id, int *x, int *y, int *z)
+void ModelShowNPoints::GetIdPoint(int id, double *x, double *y, double *z)
 {
        *x = lstPointsX[id];
        *y = lstPointsY[id];
@@ -115,7 +115,7 @@ vtkImageData *ModelShowNPoints::GetImage()
 }
 
 //------------------------------------------------------------------------
-void ModelShowNPoints::AddPoint(int x, int y, int z, std::string label)
+void ModelShowNPoints::AddPoint(double x, double y, double z, std::string label)
 {
        lstPointsX.push_back( x );
        lstPointsY.push_back( y );
@@ -132,11 +132,11 @@ double ModelShowNPoints::DistanceSQ(double dX0, double dY0, double dZ0, double d
 }
 
 //------------------------------------------------------------------------
-int ModelShowNPoints::InsertPoint(int x, int y, int z, std::string label)
+int ModelShowNPoints::InsertPoint(double x, double y, double z, std::string label)
 {
        if(lstPointsX.size()>1)
        {
-               std::vector<int> dTotal;
+               std::vector<double> dTotal;
                int pos = 1;
                double a,b,c,res;
         int i,j;
@@ -149,7 +149,7 @@ int ModelShowNPoints::InsertPoint(int x, int y, int z, std::string label)
                                dTotal.push_back (res);         
                }
                //Gets the smallest distance 
-               int smallTMP = dTotal[0];
+               double smallTMP = dTotal[0];
                for (j = 0; j < (int) dTotal.size(); j++)
                {
                          if(dTotal[j]<smallTMP)
@@ -209,7 +209,7 @@ int ModelShowNPoints::InsertPoint(int x, int y, int z, std::string label)
         //  *************** Open contour case End *******************
 
         
-               std::vector<int>::iterator it;
+               std::vector<double>::iterator it;
                //Insert the point in the list of points
                it = lstPointsX.begin();
                lstPointsX.insert( it+pos, x );
@@ -239,21 +239,21 @@ void ModelShowNPoints::SavePoints_(FILE* ff)
         int i , size = (int) (lstPointsX.size());
         fprintf(ff,"NumberOfPoints %d \n",size);
         fprintf(ff," X\tY\tZ\tvalue\tLabel\n");
-        int x, y, z;
+        double x, y, z;
         double value;
         for (i=0; i<size; i++)
         {
             x       = lstPointsX[i];
             y       = lstPointsY[i];
             z       = lstPointsZ[i];
-            value   = mimage->GetScalarComponentAsDouble(x,y,z,0);
+            value   = mimage->GetScalarComponentAsDouble(std::round(x),std::round(y),std::round(z),0);
             if (lstLabels[i]!="")
             {
                 tmpLabel=lstLabels[i];
             } else{
                 tmpLabel="<_VOID_>";
             }
-            fprintf(ff,"%d\t%d\t%d\t%f\t%s\n", x , y , z , value  , tmpLabel.c_str());
+            fprintf(ff,"%f\t%f\t%f\t%f\t%s\n", x , y , z , value  , tmpLabel.c_str());
         } // for
 }
 
@@ -279,11 +279,12 @@ int ModelShowNPoints::ReadPoints_(FILE* ff)
     fscanf(ff," %s %s %s %s %s",chartmp, chartmp,chartmp,chartmp,chartmp );
 
     float value;
-    int x,y,z;
+    double x,y,z;
     for (i=0; i<size; i++)
     {
-        fscanf(ff,"%d%d%d%f%s",&x,&y,&z,&value,chartmp );  // x,y,z,value,label
+        fscanf(ff,"%lf%lf%lf%f%s",&x,&y,&z,&value,chartmp );  // x,y,z,value,label
         if (strcmp(chartmp,"<_VOID_>")==0) { strcpy(chartmp,""); }
+        cout << x << " " << y << " " << z << " " << value << endl;
         AddPoint(x,y,z, chartmp );
     }
     return size;
index fce61074bbd09cb09198e7b6d7ce364bf7485c23..b809c2a602c5e91a332bd02591b104b9d6c50a2a 100644 (file)
@@ -13,47 +13,47 @@ class ModelShowNPoints
        public:
          ModelShowNPoints();
          ~ModelShowNPoints(); 
-         std::vector<int>                      GetLstPointsX();
-         std::vector<int>                      GetLstPointsY();
-         std::vector<int>                      GetLstPointsZ();
-         void                                          GetIdPoint(int id, int *x, int *y, int *z);
-         std::string                           GetIdLabel(int id);
-         std::vector<std::string>      GetLstLabels();
-         void                                          AddPoint(int x, int y, int z, std::string label);
-         double                                        DistanceSQ(double dX0, double dY0, double dZ0, double dX1, double dY1, double dZ1);
-         int                                           InsertPoint(int x, int y, int z, std::string label);
-         void                                          SavePoints(std::string filename);
-      void                      SavePoints_(FILE* ff);
+         std::vector<double>                   GetLstPointsX();
+         std::vector<double>                   GetLstPointsY();
+         std::vector<double>                   GetLstPointsZ();
+         void                                                  GetIdPoint(int id, double *x, double *y, double *z);
+         std::string                                   GetIdLabel(int id);
+         std::vector<std::string>              GetLstLabels();
+         void                                                  AddPoint(double x, double y, double z, std::string label);
+         double                                                DistanceSQ(double dX0, double dY0, double dZ0, double dX1, double dY1, double dZ1);
+         int                                                   InsertPoint(double x, double y, double z, std::string label);
+         void                                                  SavePoints(std::string filename);
+      void                             SavePoints_(FILE* ff);
 
-      int                                              ReadPoints(std::string filename);
-      int                       ReadPoints_(FILE* ff);
-         int                                           GetNearestPoint();
+      int                                                      ReadPoints(std::string filename);
+      int                              ReadPoints_(FILE* ff);
+         int                                                   GetNearestPoint();
 
-         int                                           GetLstPointsSize();
-         void                                          SetPointId_mReferencePoint(int id);
-         int                                           IdInsidePoint();
+         int                                                   GetLstPointsSize();
+         void                                                  SetPointId_mReferencePoint(int id);
+         int                                                   IdInsidePoint();
 
-         void                                          SetPointById(int id, std::vector<double> point);
+         void                                                  SetPointById(int id, std::vector<double> point);
 
-         void                                          SetReferencePoint(std::vector<int> ppoint);
-         std::vector<int>                      GetReferencePoint();
-         void                                          SetImage(vtkImageData *image);
-         std::string                           CleanSpaces(std::string ss);
-         vtkImageData*                         GetImage();
-         void                                          SetRadio(double radio);
-         double                                        GetRadio();
-         int                                           RenamePoint(std::string label);
-         void                                          ErasePoint(int id);
-         void                                          SetFirstTime(bool value);
-         bool                                          GetFirstTime();
-      void                      InversLstPoints();
+         void                                                  SetReferencePoint(std::vector<double> ppoint);
+         std::vector<double>                   GetReferencePoint();
+         void                                                  SetImage(vtkImageData *image);
+         std::string                                   CleanSpaces(std::string ss);
+         vtkImageData*                                 GetImage();
+         void                                                  SetRadio(double radio);
+         double                                                GetRadio();
+         int                                                   RenamePoint(std::string label);
+         void                                                  ErasePoint(int id);
+         void                                                  SetFirstTime(bool value);
+         bool                                                  GetFirstTime();
+      void                             InversLstPoints();
       
        private:
-         std::vector<int>              lstPointsX;
-         std::vector<int>              lstPointsY;
-         std::vector<int>              lstPointsZ;
+         std::vector<double>           lstPointsX;
+         std::vector<double>           lstPointsY;
+         std::vector<double>           lstPointsZ;
          std::vector<std::string>      lstLabels;
-         std::vector<int>                      mReferencePoint;
+         std::vector<double>                   mReferencePoint;
          double                                mradio;
          vtkImageData                          *mimage;
          bool                                                  firsttime;
index 0af0e4532675941e3d3489f350d35164bbe0557a..008f5cf8cac887c8c36b1d2cf052bd6bceaab47f 100644 (file)
@@ -21,7 +21,7 @@ ViewShowNPoints::~ViewShowNPoints()
 void ViewShowNPoints::RefreshPoint(int id)
 {
     double spc[3];
-    int x,y,z;
+    double x,y,z;
     GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
     GetModelShowNPoints()->GetImage()->GetSpacing(spc);
     std::string label     = GetModelShowNPoints()->GetIdLabel(id);
index 7aba88abfcd0005e85584e704f8cb52c075c1048..1ae46a5f5126fa414c434fd2df7674e10dd22c88 100644 (file)
@@ -506,7 +506,7 @@ void WidgetShowNPoints::AddVtkPoint()
 
 
 //------------------------------------------------------------------------
-void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
+void WidgetShowNPoints::AddPoint(double x, double y, double z, std::string label)
 {
        GetModelShowNPoints()->AddPoint(x,y,z, label );
     // EED 2022-05-19
@@ -516,7 +516,7 @@ void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
 }
 
 //------------------------------------------------------------------------
-void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT
+void WidgetShowNPoints::InsertPoint(double x, double y, double z, std::string label)//CFT
 {
     // EED 2022-05-19
        //if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
@@ -547,7 +547,7 @@ void WidgetShowNPoints::OnInsertPoint_()
     {
         return;
     }
-    std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
+    std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
     if (point.size()==3)
     {
         InsertPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
@@ -573,7 +573,7 @@ void WidgetShowNPoints::OnAddPoint__()
        {
                return;
        }
-       std::vector<int> point = GetModelShowNPoints()->GetReferencePoint();
+       std::vector<double> point = GetModelShowNPoints()->GetReferencePoint();
        if (point.size()==3)
        {
                AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
@@ -954,7 +954,7 @@ void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
 }
 
 //------------------------------------------------------------------------
-void  WidgetShowNPoints::SetReferencePoint(std::vector<int> point)
+void  WidgetShowNPoints::SetReferencePoint(std::vector<double> point)
 {
        GetModelShowNPoints()->SetReferencePoint(point);
     int i,size=lstModelShowNPoints.size();
@@ -965,7 +965,7 @@ void  WidgetShowNPoints::SetReferencePoint(std::vector<int> point)
 }
 
 //------------------------------------------------------------------------
-void  WidgetShowNPoints::SetInitLstPoints( std::vector<int> initLstPointsX,  std::vector<int> initLstPointsY, std::vector<int> initLstPointsZ, std::vector<std::string> initLstLabels )
+void  WidgetShowNPoints::SetInitLstPoints( std::vector<double> initLstPointsX,  std::vector<double> initLstPointsY, std::vector<double> initLstPointsZ, std::vector<std::string> initLstLabels )
 {
     // EED 2022-05-19
        //if (this->renderer==NULL)
@@ -978,7 +978,7 @@ void  WidgetShowNPoints::SetInitLstPoints( std::vector<int> initLstPointsX,  std
        sizeY = (int)initLstPointsY.size();
        sizeZ = (int)initLstPointsZ.size();
        sizeLabels = (int)initLstLabels.size();
-       int x,y,z;
+       double x,y,z;
        std::string label;
        if ( (sizeX==sizeY) && (sizeX==sizeZ) )
        {
@@ -1363,7 +1363,7 @@ void WidgetShowNPoints::OnLoadCollections(wxCommandEvent &event)
 //------------------------------------------------------------------------
 void WidgetShowNPoints::GetCollectionPoint(int idCol,int idPoint, double *pPoint)
 {
-    int x,y,z;
+    double x,y,z;
     lstModelShowNPoints[idCol]->GetIdPoint(idPoint,&x,&y,&z);
     pPoint[0] = x;
     pPoint[1] = y;
@@ -1373,24 +1373,27 @@ void WidgetShowNPoints::GetCollectionPoint(int idCol,int idPoint, double *pPoint
 void WidgetShowNPoints::SetCollectionPoint(int idCol, int idPoint, std::vector<double> modPoint)
 {
        if(idCol >= 0 && idCol < lstModelShowNPoints.size())
+       {
                lstModelShowNPoints[idCol]->SetPointById(idPoint, modPoint);
+               lstViewShowNPoints[idCol]->RefreshPoint(idPoint);
+       }
        else{
                printf("WidgetShowNPoints::SetCollectionPoint  ...Error... Invalid collection, out of range");
        }
 }
 //------------------------------------------------------------------------
-std::vector<int> WidgetShowNPoints::GetLstPointsX()
+std::vector<double> WidgetShowNPoints::GetLstPointsX()
 {
     if (mtype!=4)
     {
         return GetModelShowNPoints()->GetLstPointsX();
     } else {
-        std::vector<int> lst;
+        std::vector<double> lst;
         int iP,s;
         int iG,sG=lstModelShowNPoints.size();
         for (iG=0 ; iG<sG ; iG++)
         {
-            std::vector<int> lstTmp = lstModelShowNPoints[iG]->GetLstPointsX();
+            std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsX();
             s = lstTmp.size();
             for (iP=0 ; iP<s ; iP++)
             {
@@ -1402,18 +1405,18 @@ std::vector<int> WidgetShowNPoints::GetLstPointsX()
 }
 
 //------------------------------------------------------------------------
-std::vector<int> WidgetShowNPoints::GetLstPointsY()
+std::vector<double> WidgetShowNPoints::GetLstPointsY()
 {
     if (mtype!=4)
     {
         return GetModelShowNPoints()->GetLstPointsY();
     } else {
-        std::vector<int> lst;
+        std::vector<double> lst;
         int iP,s;
         int iG,sG=lstModelShowNPoints.size();
         for (iG=0 ; iG<sG ; iG++)
         {
-            std::vector<int> lstTmp = lstModelShowNPoints[iG]->GetLstPointsY();
+            std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsY();
             s = lstTmp.size();
             for (iP=0 ; iP<s ; iP++)
             {
@@ -1425,18 +1428,18 @@ std::vector<int> WidgetShowNPoints::GetLstPointsY()
 }
 
 //------------------------------------------------------------------------
-std::vector<int> WidgetShowNPoints::GetLstPointsZ()
+std::vector<double> WidgetShowNPoints::GetLstPointsZ()
 {
     if (mtype!=4)
     {
         return GetModelShowNPoints()->GetLstPointsZ();
     } else {
-        std::vector<int> lst;
+        std::vector<double> lst;
         int iP,s;
         int iG,sG=lstModelShowNPoints.size();
         for (iG=0 ; iG<sG ; iG++)
         {
-            std::vector<int> lstTmp = lstModelShowNPoints[iG]->GetLstPointsZ();
+            std::vector<double> lstTmp = lstModelShowNPoints[iG]->GetLstPointsZ();
             s = lstTmp.size();
             for (iP=0 ; iP<s ; iP++)
             {
index 54d77e0a1e97adae66a9bf14dcda4e95e1b460cf..f4531493ef56572a95c5b013666c981bd324bc72 100644 (file)
@@ -93,16 +93,16 @@ class WidgetShowNPoints : public wxPanel
          void SetRadio(double radio);
          void SetImage(vtkImageData *image);
          void SetRenderer(vtkRenderer *renderer);
-         void SetReferencePoint(std::vector<int> point);
+         void SetReferencePoint(std::vector<double> point);
 
-         void AddPoint(int x, int y, int z, std::string label);
+         void AddPoint(double x, double y, double z, std::string label);
       void OnInsertPoint_();
-         void InsertPoint(int x, int y, int z, std::string label);//CFT
+         void InsertPoint(double x, double y, double z, std::string label);//CFT
 
       int GetLstModelShowNPointsSize();
          ModelShowNPoints* GetModelShowNPoints();
       ViewShowNPoints* GetViewShowNPoints();
-         void SetInitLstPoints( std::vector<int> initLstPointsX,  std::vector<int> initLstPointsY, std::vector<int> initLstPointsZ, std::vector<std::string> initLstLabels );
+         void SetInitLstPoints( std::vector<double> initLstPointsX,  std::vector<double> initLstPointsY, std::vector<double> initLstPointsZ, std::vector<std::string> initLstLabels );
 
       void          SetType(int type);
       int           GetType();
@@ -111,9 +111,9 @@ class WidgetShowNPoints : public wxPanel
       virtual void  SetOutputBox();
       void          ErasePoint(int id);
 
-      std::vector<int> GetLstPointsX();
-      std::vector<int> GetLstPointsY();
-      std::vector<int> GetLstPointsZ();
+      std::vector<double> GetLstPointsX();
+      std::vector<double> GetLstPointsY();
+      std::vector<double> GetLstPointsZ();
       std::vector<std::string> GetLstLabels();
       std::vector<int> GetLstIndexs();