]> Creatis software - creaMaracasVisu.git/commitdiff
#3502 Modify middle point in patch
authorPablo Garzon <garzon@ei-pfe-706.creatis.insa-lyon.fr>
Thu, 30 Mar 2023 12:41:36 +0000 (14:41 +0200)
committerPablo Garzon <garzon@ei-pfe-706.creatis.insa-lyon.fr>
Thu, 30 Mar 2023 12:41:36 +0000 (14:41 +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
lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h

index 04ed010a068a6ede9137f8b58b560be3801e6923..112a484df9019c362f6e6e1dad750af644513615 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
@@ -72,7 +72,7 @@ COMPLEX_PORT
 meshmanagermodel
 -150.374274:130.740991:-900.000000
 FIN_COMPLEX_PORT
-BOXES:75
+BOXES:81
 BOX
 creaMaracasVisu:ShowNPoints:showNpoints
 ISEXEC:FALSE
@@ -94,8 +94,8 @@ FIN_BOX
 BOX
 creaMaracasVisu:ManualContourModel_Box:Box06
 ISEXEC:FALSE
-29.075845:30.364799:-900.000000
-53.595845:27.864799:-900.000000
+35.216468:30.364799:-900.000000
+59.736468:27.864799:-900.000000
 PORT
 DoubleContour:"1"
 PORT
@@ -132,8 +132,8 @@ FIN_BOX
 BOX
 std:MultipleInputs:Box31
 ISEXEC:FALSE
-21.957727:-67.075176:-900.000000
-43.927727:-69.575176:-900.000000
+18.992085:-64.219001:-900.000000
+40.962085:-66.719001:-900.000000
 FIN_BOX
 BOX
 creaMaracasVisu:ManualContourModel_Box:Box29
@@ -516,8 +516,8 @@ FIN_BOX
 BOX
 creaVtk:LinearExtrusionFilter:Box96
 ISEXEC:FALSE
-126.330445:-29.439611:-900.000000
-148.840445:-31.939611:-900.000000
+126.138551:-32.318028:-900.000000
+148.648551:-34.818028:-900.000000
 FIN_BOX
 BOX
 creaMaracasVisu:PolyDataToActor_Widget:Box98
@@ -691,7 +691,59 @@ ISEXEC:FALSE
 PORT
 In0:"Auto Add Points (Start/Stop)"
 FIN_BOX
-CONNECTIONS:154
+BOX
+creaMaracasVisu:ShowNPoints_Tools:Box120
+ISEXEC:FALSE
+-380.000207:-26.721711:-900.000000
+-357.455207:-29.221711:-900.000000
+PORT
+BoxProcessMode:"Manual"
+PORT
+Type:"220"
+FIN_BOX
+BOX
+wx:CommandButton:Box121
+ISEXEC:FALSE
+-390.668472:-8.967632:-900.000000
+-368.283472:-11.467632:-900.000000
+PORT
+Label:"+"
+FIN_BOX
+BOX
+wx:CommandButton:Box127
+ISEXEC:FALSE
+-322.149651:-11.922729:-900.000000
+-299.764651:-14.422729:-900.000000
+PORT
+Label:"-"
+FIN_BOX
+BOX
+creaMaracasVisu:ShowNPoints_Tools:Box128
+ISEXEC:FALSE
+-328.813882:-27.476919:-900.000000
+-306.268882:-29.976919:-900.000000
+PORT
+BoxProcessMode:"Manual"
+PORT
+Type:"220"
+FIN_BOX
+BOX
+std:ConcatStrings:Box130
+ISEXEC:FALSE
+-378.800018:37.000233:-900.000000
+-356.040018:34.500233:-900.000000
+PORT
+In2:"  1"
+FIN_BOX
+BOX
+std:ConcatStrings:Box131
+ISEXEC:FALSE
+-344.138161:36.747302:-900.000000
+-321.378161:34.247302:-900.000000
+PORT
+In2:"  -1"
+FIN_BOX
+CONNECTIONS:168
 CONNECTION
 Box06:LstContourPointsX:Box04:LstX
 NumberOfControlPoints:0
@@ -1154,4 +1206,46 @@ NumberOfControlPoints:0
 CONNECTION
 Box119:Out:Box58:StringVector
 NumberOfControlPoints:0
+CONNECTION
+Box68:Spacing:Box120:Spacing
+NumberOfControlPoints:0
+CONNECTION
+showNpoints:WidgetShowNPoints:Box120:WidgetShowNPoints
+NumberOfControlPoints:0
+CONNECTION
+Box121:BoxChange:Box120:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box121:Widget:Box101:Widget5
+NumberOfControlPoints:0
+CONNECTION
+Box127:BoxChange:Box128:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box127:Widget:Box101:Widget6
+NumberOfControlPoints:0
+CONNECTION
+Box68:Spacing:Box128:Spacing
+NumberOfControlPoints:0
+CONNECTION
+showNpoints:WidgetShowNPoints:Box128:WidgetShowNPoints
+NumberOfControlPoints:0
+CONNECTION
+Box60:Out:Box130:In1
+NumberOfControlPoints:0
+CONNECTION
+Box60:Out:Box131:In1
+NumberOfControlPoints:0
+CONNECTION
+Box130:Out:Box120:Params
+NumberOfControlPoints:0
+CONNECTION
+Box131:Out:Box128:Params
+NumberOfControlPoints:0
+CONNECTION
+Box120:BoxChange:Box31:In3
+NumberOfControlPoints:0
+CONNECTION
+Box128:BoxChange:Box31:In5
+NumberOfControlPoints:0
 APP_END
index 8bad5a3046f496d1250691ccb6c09885dd8001a2..031783008c20f4ffbf552c186fdae66fab68c371 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
@@ -252,6 +252,26 @@ new wx:Slider Box118
 new std:AddStringToVector Box119
   set Box119.In0 "Auto Add Points (Start/Stop)"
 
+new creaMaracasVisu:ShowNPoints_Tools Box120
+  set Box120.BoxProcessMode "Manual"
+  set Box120.Type "220"
+
+new wx:CommandButton Box121
+  set Box121.Label "+"
+
+new wx:CommandButton Box127
+  set Box127.Label "-"
+
+new creaMaracasVisu:ShowNPoints_Tools Box128
+  set Box128.BoxProcessMode "Manual"
+  set Box128.Type "220"
+
+new std:ConcatStrings Box130
+  set Box130.In2 "  1"
+
+new std:ConcatStrings Box131
+  set Box131.In2 "  -1"
+
 
 connect Box06.LstContourPointsX Box04.LstX
 connect showNpoints.lstIndexs Box06.LstIndexsIn
@@ -392,6 +412,20 @@ connect Box118.Widget Box101.Widget1
 connect Box118.Out Box96.ScalarFactor
 connect Box118.BoxChange Box103.In3
 connect Box119.Out Box58.StringVector
+connect Box68.Spacing Box120.Spacing
+connect showNpoints.WidgetShowNPoints Box120.WidgetShowNPoints
+connect Box121.BoxChange Box120.BoxExecute
+connect Box121.Widget Box101.Widget5
+connect Box127.BoxChange Box128.BoxExecute
+connect Box127.Widget Box101.Widget6
+connect Box68.Spacing Box128.Spacing
+connect showNpoints.WidgetShowNPoints Box128.WidgetShowNPoints
+connect Box60.Out Box130.In1
+connect Box60.Out Box131.In1
+connect Box130.Out Box120.Params
+connect Box131.Out Box128.Params
+connect Box120.BoxChange Box31.In3
+connect Box128.BoxChange Box31.In5
 
 # Complex input ports
 input point showNpoints.In " "
index c258512c0472f6ed80afa84d61717dc9e69f9c70..275a66d2e753a4a9892a3a7d1c276256185943ec 100644 (file)
@@ -30,7 +30,7 @@ void ShowNPoints_Tools::NearestPointToMesh( vtkPoints *points,vtkStaticPointLoca
 
 void ShowNPoints_Tools::CreatePatch_3points()
 {
-       printf("PG ShowNPoints_Tools::CreatePatch_3points  Entered patch 3 points !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+       //printf("PG ShowNPoints_Tools::CreatePatch_3points  Entered patch 3 points !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
        WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
        wsp->StopAutoAddPoints();
     wsp->StopTrackPoint();
@@ -106,11 +106,11 @@ void ShowNPoints_Tools::CreatePatch_3points()
                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");
+               //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");
+               //printf("PG ShowNPoints_Tools::CreatePatch_3points  Warning patch not apply. Need only one group of 3 points\n");
        }
 }
 
@@ -305,15 +305,53 @@ void ShowNPoints_Tools::CreatePatch_Points(std::vector<int> lstX, std::vector<in
 //        4. Si el angulo es major de 90 Invertir las normales de la superficie actual
     if (angle<90)
     {
+       vtkMath::MultiplyScalar(n2, -1);
         wsp->InvertLstPoints_();
     } // if angle
+    std::vector<double> normalOut(n2, n2 + 3);
+    double norm = vtkMath::Norm(n2);
+    normalOut[0] = normalOut[0]/norm;
+       normalOut[1] = normalOut[1]/norm;
+       normalOut[2] = normalOut[2]/norm;
+    bbSetOutputOut(normalOut);
     
     // --- Finish ---
     wsp->SetOutputBox();
     wsp->UndoRedo_SaveCollection();
 }
 
+void ShowNPoints_Tools::MovePatchCenter()
+{      
+       std::vector<double> params = bbGetInputParams();
+       if(params.size() == 4)
+       {
+               if(params[3] != 1 && params[3] != -1)
+               {
+                       printf("PG ShowNPoints_Tools::MovePatchCenter()  Warning params are wrong. direction of movement should be 1 or -1\n");
+                       return;
+               }
+               
+               double centerPoint[3];
+               std::vector<double> normal, modPoint;
+               
+               normal.push_back(params[0]);
+               normal.push_back(params[1]);
+               normal.push_back(params[2]);
 
+               int direction = -params[3];
+               
+               WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
+               wsp->GetCollectionPoint(1,1, centerPoint);
+               modPoint.push_back(centerPoint[0] + direction*normal[0]);
+               modPoint.push_back(centerPoint[1] + direction*normal[1]);
+               modPoint.push_back(centerPoint[2] + direction*normal[2]);
+
+               wsp->SetCollectionPoint(1, 1, modPoint);
+               wsp->GetViewShowNPoints()->RefreshPoints();
+       }else{
+               printf("PG ShowNPoints_Tools::MovePatchCenter()  Warning params are wrong. Need 4: normal x y z and direction of movement (1 or -1)\n");
+       }
+}
 
 //=====
 // 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)
@@ -391,6 +429,10 @@ void ShowNPoints_Tools::Process()
         {
             bbGetInputWidgetShowNPoints()->OnInvertLstPoints_();
         } // if Type
+        if(bbGetInputType()==220)
+        {
+               MovePatchCenter();
+        } // if Type
     } // if bbGetInputWidgetShowNPoints
 }
 //===== 
index 28b8e65b627411f829fd3ea8ca9ab3c132cb3661..d0abad840e0b5f1c2979edff5f651ed7190af920 100644 (file)
@@ -29,6 +29,8 @@ class bbcreaMaracasVisu_EXPORT ShowNPoints_Tools
     BBTK_DECLARE_INPUT(Spacing,std::vector<double>);
     BBTK_DECLARE_INPUT(Mesh,vtkPolyData*);
     BBTK_DECLARE_INPUT(Type,int);
+    BBTK_DECLARE_INPUT(Params, std::vector<double>);
+    BBTK_DECLARE_OUTPUT(Out, std::vector<double>);
 //  BBTK_DECLARE_OUTPUT(Out,double);
   BBTK_PROCESS(Process);
   void Process();
@@ -37,6 +39,7 @@ class bbcreaMaracasVisu_EXPORT ShowNPoints_Tools
     void CreatePatch_4points();
     void CreatePatch_Points(std::vector<int> lstX, std::vector<int> lstY, std::vector<int> lstZ);
     void NearestPointToMesh( vtkPoints *points, vtkStaticPointLocator   *pointLocator, double *spc , double *p , double *pM   );
+    void MovePatchCenter();
 
 //===== 
 // 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)
@@ -51,7 +54,10 @@ 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)",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  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_OUTPUT(ShowNPoints_Tools, Out, "Output", std::vector<double>, "");
 //  BBTK_OUTPUT(ShowNPoints_Tools,Out,"First output",double,"");
 BBTK_END_DESCRIBE_BLACK_BOX(ShowNPoints_Tools);
 //===== 
index 95d6e9e5a8792f44166edd4f2ea34e55285bcf9e..ea3616a7113830e4af1a7e5fff2bb0a3078b478f 100644 (file)
@@ -366,7 +366,18 @@ int ModelShowNPoints::IdInsidePoint()
                return id;
        } // if
 }
-
+//------------------------------------------------------------------------
+void ModelShowNPoints::SetPointById(int id, std::vector<double> point)
+{
+       if(id >= 0 && id < lstPointsX.size()){
+               lstPointsX[id] = point[0];
+               lstPointsY[id] = point[1];
+               lstPointsZ[id] = point[2];
+       }
+       else{
+               printf("WidgetShowNPoints::SetPointById  Invalid pointid, id is outside range\n");
+       }
+}
 //------------------------------------------------------------------------     
 int ModelShowNPoints::RenamePoint(std::string label)
 {
index 7fbbad7b5d7ed1fdbe833f6939d3f9fb2c5ddf4d..fce61074bbd09cb09198e7b6d7ce364bf7485c23 100644 (file)
@@ -33,6 +33,8 @@ class ModelShowNPoints
          void                                          SetPointId_mReferencePoint(int id);
          int                                           IdInsidePoint();
 
+         void                                          SetPointById(int id, std::vector<double> point);
+
          void                                          SetReferencePoint(std::vector<int> ppoint);
          std::vector<int>                      GetReferencePoint();
          void                                          SetImage(vtkImageData *image);
index 5574c862fe1f85ad86838ace5482cb3b172e9f10..7aba88abfcd0005e85584e704f8cb52c075c1048 100644 (file)
@@ -1369,7 +1369,15 @@ void WidgetShowNPoints::GetCollectionPoint(int idCol,int idPoint, double *pPoint
     pPoint[1] = y;
     pPoint[2] = z;
 }
-
+//------------------------------------------------------------------------
+void WidgetShowNPoints::SetCollectionPoint(int idCol, int idPoint, std::vector<double> modPoint)
+{
+       if(idCol >= 0 && idCol < lstModelShowNPoints.size())
+               lstModelShowNPoints[idCol]->SetPointById(idPoint, modPoint);
+       else{
+               printf("WidgetShowNPoints::SetCollectionPoint  ...Error... Invalid collection, out of range");
+       }
+}
 //------------------------------------------------------------------------
 std::vector<int> WidgetShowNPoints::GetLstPointsX()
 {
index 7e41319f4817938b49537ff0576452eecbbebeba..54d77e0a1e97adae66a9bf14dcda4e95e1b460cf 100644 (file)
@@ -69,6 +69,8 @@ class WidgetShowNPoints : public wxPanel
       void OnResetCollections_();
       void OnResetCollections(wxCommandEvent &event);
       void GetCollectionPoint(int idCol,int idPoint, double *pPoint);
+      
+      void SetCollectionPoint(int idCol, int idPoint, std::vector<double> modPoint);
 
       void OnUndo(wxCommandEvent &event);
       void OnRedo(wxCommandEvent &event);