]> Creatis software - creaMaracasVisu.git/commitdiff
#3485 ShowNPionts for Multiple Groups
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Tue, 12 Jul 2022 09:38:56 +0000 (11:38 +0200)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Tue, 12 Jul 2022 09:38:56 +0000 (11:38 +0200)
bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx
bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/WidgetShowNPoints.h

index 5f16750f664b285cdf66bce33b89b642fa9a3a75..01ab191170908674bbabc1b465400e7a4dded003 100644 (file)
 //===== 
 #include "bbcreaMaracasVisuShowNPoints_Tools.h"
 #include "bbcreaMaracasVisuPackage.h"
+
+
 namespace bbcreaMaracasVisu
 {
 
 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ShowNPoints_Tools)
 BBTK_BLACK_BOX_IMPLEMENTATION(ShowNPoints_Tools,bbtk::AtomicBlackBox);
 
+
+
+void ShowNPoints_Tools::NearestPointToMesh( vtkPoints *points,vtkStaticPointLocator *pointLocator,double *spc,double *p,double *pM)
+{
+    
+    p[0] = p[0] * spc[0];
+    p[1] = p[1] * spc[1];
+    p[2] = p[2] * spc[2];
+    points->GetPoint( pointLocator->FindClosestPoint(p) , pM );
+    pM[0] = pM[0] / spc[0];
+    pM[1] = pM[1] / spc[1];
+    pM[2] = pM[2] / spc[2];
+}
+
 void ShowNPoints_Tools::CreatePatch01()
 {
-    bbGetInputWidgetShowNPoints()->CreatePatch01(  );
+    WidgetShowNPoints* wsp = bbGetInputWidgetShowNPoints();
+    if ( (wsp->GetLstModelShowNPointsSize()==1) &&
+         (wsp->GetModelShowNPoints()->GetLstPointsSize()==4) &&
+         (bbGetInputMesh()!=NULL ) )
+    {
+        double                  spc[3];
+                                spc[0]          = bbGetInputSpacing()[0];
+                                spc[1]          = bbGetInputSpacing()[1];
+                                spc[2]          = bbGetInputSpacing()[2];
+        vtkPoints               *points         = bbGetInputMesh()->GetPoints();
+        vtkStaticPointLocator   *pointLocator   = vtkStaticPointLocator::New();
+        pointLocator->SetDataSet( bbGetInputMesh() );
+        pointLocator->BuildLocator();
+
+        wsp->StopTrackPoint();
+        double p[3],pM[3];
+        double dx,dy,dz,s;
+        std::vector<int> lstX = wsp->GetModelShowNPoints()->GetLstPointsX();
+        std::vector<int> lstY = wsp->GetModelShowNPoints()->GetLstPointsY();
+        std::vector<int> lstZ = wsp->GetModelShowNPoints()->GetLstPointsZ();
+        
+        // --- Group 0 ---
+        wsp->ErasePoint( 2 );
+        wsp->ErasePoint( 2 );
+        dx = lstX[1]-lstX[0];
+        dy = lstY[1]-lstY[0];
+        dz = lstZ[1]-lstZ[0];
+        s=0.33333;
+        p[0] = lstX[0] + dx*s;
+        p[1] = lstY[0] + dy*s;
+        p[2] = lstZ[0] + dz*s;
+        NearestPointToMesh(points, pointLocator, spc, p,pM);
+        wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
+        s=s*2;
+        p[0] = lstX[0] + dx*s;
+        p[1] = lstY[0] + dy*s;
+        p[2] = lstZ[0] + dz*s;
+        NearestPointToMesh(points, pointLocator, spc, p,pM);
+        wsp->InsertPoint(pM[0],pM[1], pM[2],"");
+
+        // --- Group 1 ---
+        wsp->OnInsertCollectionAfter_();
+          p[0] = (lstX[0]+lstX[3])/2;
+          p[1] = (lstY[0]+lstY[3])/2;
+          p[2] = (lstZ[0]+lstZ[3])/2;
+          NearestPointToMesh(points, pointLocator, spc, p,pM);
+          wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
+          p[0] = (lstX[1]+lstX[2])/2;
+          p[1] = (lstY[1]+lstY[2])/2;
+          p[2] = (lstZ[1]+lstZ[2])/2;
+          NearestPointToMesh(points, pointLocator, spc, p,pM);
+          wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
+          p[0] = (lstX[0]+lstX[1]+lstX[2]+lstX[3])/4;          p[1] = (lstY[0]+lstY[1]+lstY[2]+lstY[3])/4;          p[2] = (lstZ[0]+lstZ[1]+lstZ[2]+lstZ[3])/4;
+          wsp->InsertPoint(p[0] ,p[1], p[2],"");
+
+        // --- Group 2 ---
+        wsp->OnInsertCollectionAfter_();
+          p[0] = lstX[3];
+          p[1] = lstY[3];
+          p[2] = lstZ[3];
+          wsp->InsertPoint(p[0] ,p[1], p[2],"");
+          p[0] = lstX[2];
+          p[1] = lstY[2];
+          p[2] = lstZ[2];
+          wsp->InsertPoint(p[0] ,p[1], p[2],"");
+          dx = lstX[2]-lstX[3];
+          dy = lstY[2]-lstY[3];
+          dz = lstZ[2]-lstZ[3];
+          s=0.33333;
+          p[0] = lstX[3] + dx*s;
+          p[1] = lstY[3] + dy*s;
+          p[2] = lstZ[3] + dz*s;
+          NearestPointToMesh(points, pointLocator, spc, p,pM);
+          wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
+          s=s*2;
+          p[0] = lstX[3] + dx*s;
+          p[1] = lstY[3] + dy*s;
+          p[2] = lstZ[3] + dz*s;
+          NearestPointToMesh(points, pointLocator, spc, p,pM);
+          wsp->InsertPoint(pM[0] ,pM[1], pM[2],"");
+
+        wsp->SetOutputBox();
+        pointLocator->Delete();
+    } else {
+            printf("EED ShowNPoints_Tools::CreatePatch01  Warning patch not apply. Need juste one group with four points\n");
+    } // if
 }
 
+
+
 //=====
 // 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)
 //===== 
@@ -80,6 +183,12 @@ void ShowNPoints_Tools::bbUserSetDefaultValues()
    bbSetInputType(0);
    bbSetInputMesh(NULL);
    bbSetInputWidgetShowNPoints(NULL);
+    
+    std::vector<double> spc;
+    spc.push_back(1);
+    spc.push_back(1);
+    spc.push_back(1);
+    bbSetInputSpacing(spc);
 }
 //===== 
 // 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)
index d974669da2be9416b1a0fe325817339578927d3b..d83ba3ef1b6bbad2de1511c4bdef550f53a35e49 100644 (file)
@@ -9,7 +9,10 @@
 #include "iostream"
 
 #include "WidgetShowNPoints.h"
+
+
 #include "vtkPolyData.h"
+#include <vtkStaticPointLocator.h>
 
 namespace bbcreaMaracasVisu
 {
@@ -23,6 +26,7 @@ class bbcreaMaracasVisu_EXPORT ShowNPoints_Tools
 // 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)
 //===== 
     BBTK_DECLARE_INPUT(WidgetShowNPoints,WidgetShowNPoints*);
+    BBTK_DECLARE_INPUT(Spacing,std::vector<double>);
     BBTK_DECLARE_INPUT(Mesh,vtkPolyData*);
     BBTK_DECLARE_INPUT(Type,int);
 //  BBTK_DECLARE_OUTPUT(Out,double);
@@ -30,6 +34,8 @@ class bbcreaMaracasVisu_EXPORT ShowNPoints_Tools
   void Process();
     
     void CreatePatch01();
+    void NearestPointToMesh( vtkPoints *points, vtkStaticPointLocator   *pointLocator, double *spc , double *p , double *pM   );
+
 //===== 
 // 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)
 //===== 
@@ -41,6 +47,7 @@ BBTK_AUTHOR("Info-Dev");
 BBTK_DESCRIPTION("No Description.");
 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 10:Insert Point  20:TrackPoint  30:Set nearest point  40:Erase point  50:Deleta all points  100:Insert  group after   110:Delete group  200:Tool_1 - Create Mesh (based with one group and 4 points)",int,"");
 //  BBTK_OUTPUT(ShowNPoints_Tools,Out,"First output",double,"");
index 796ffb333de505f1ab5fdb137a465a110b4e2040..74d9e6f6032841ffd6d56ac87aa3a520b4e2254d 100644 (file)
@@ -1250,78 +1250,8 @@ std::vector<int> WidgetShowNPoints::GetLstIndexs()
     return lstIndexs;
 }
 
-
-void WidgetShowNPoints::CreatePatch01()
+//------------------------------------------------------------------------
+int WidgetShowNPoints::GetLstModelShowNPointsSize()
 {
-    if ( (lstModelShowNPoints.size()==1) && (GetModelShowNPoints()->GetLstPointsSize()==4) )
-    {
-        StopTrackPoint();
-        double px,py,pz;
-        double dx,dy,dz,s;
-        std::vector<int> lstX = GetModelShowNPoints()->GetLstPointsX();
-        std::vector<int> lstY = GetModelShowNPoints()->GetLstPointsY();
-        std::vector<int> lstZ = GetModelShowNPoints()->GetLstPointsZ();
-        
-        // --- Group 0 ---
-        ErasePoint( 2 );
-        ErasePoint( 2 );
-        dx=lstX[1]-lstX[0];
-        dy=lstY[1]-lstY[0];
-        dz=lstZ[1]-lstZ[0];
-        s=0.33333;
-        px = lstX[0] + dx*s;
-        py = lstY[0] + dy*s;
-        pz = lstZ[0] + dz*s;
-        InsertPoint(px ,py, pz,"");
-        s=s*2;
-        px = lstX[0] + dx*s;
-        py = lstY[0] + dy*s;
-        pz = lstZ[0] + dz*s;
-        InsertPoint(px ,py, pz,"");
-
-        // --- Group 1 ---
-        OnInsertCollectionAfter_();
-          px = (lstX[0]+lstX[3])/2;
-          py = (lstY[0]+lstY[3])/2;
-          pz = (lstZ[0]+lstZ[3])/2;
-          InsertPoint(px ,py, pz,"");
-          px = (lstX[1]+lstX[2])/2;
-          py = (lstY[1]+lstY[2])/2;
-          pz = (lstZ[1]+lstZ[2])/2;
-          InsertPoint(px ,py, pz,"");
-          px = (lstX[0]+lstX[1]+lstX[2]+lstX[3])/4;
-          py = (lstY[0]+lstY[1]+lstY[2]+lstY[3])/4;
-          pz = (lstZ[0]+lstZ[1]+lstZ[2]+lstZ[3])/4;
-          InsertPoint(px ,py, pz,"");
-
-        
-        // --- Group 2 ---
-        OnInsertCollectionAfter_();
-          px = lstX[3];
-          py = lstY[3];
-          pz = lstZ[3];
-          InsertPoint(px ,py, pz,"");
-          px = lstX[2];
-          py = lstY[2];
-          pz = lstZ[2];
-          InsertPoint(px ,py, pz,"");
-          dx=lstX[2]-lstX[3];
-          dy=lstY[2]-lstY[3];
-          dz=lstZ[2]-lstZ[3];
-          s=0.33333;
-          px = lstX[3] + dx*s;
-          py = lstY[3] + dy*s;
-          pz = lstZ[3] + dz*s;
-          InsertPoint(px ,py, pz,"");
-          s=s*2;
-          px = lstX[3] + dx*s;
-          py = lstY[3] + dy*s;
-          pz = lstZ[3] + dz*s;
-          InsertPoint(px ,py, pz,"");
-
-        
-        SetOutputBox();
-    } else {
-            printf("EED WidgetShowNPoints::CreatePatch01  Warning patch not apply. Need juste one group with four points\n");
-    } // if
+    return lstModelShowNPoints.size();
 }
index 75776ad6d55e3aa8e1318613240ace58215f365d..4edd315d9cf7330dc5798467c383e3c393dd8a2e 100644 (file)
@@ -73,6 +73,7 @@ class WidgetShowNPoints : public wxPanel
          void InsertPoint(int x, int y, int z, std::string label);//CFT
          void DeleteAllPoints();
 
+      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 );
@@ -82,8 +83,11 @@ class WidgetShowNPoints : public wxPanel
 
                double GetRadio();
                double GetOpacity();
+
+    virtual void                      SetOutputBox();
+    void                              ErasePoint(int id);
+
     
-    void CreatePatch01();
     
     std::vector<int> GetLstPointsX();
     std::vector<int> GetLstPointsY();
@@ -94,10 +98,8 @@ class WidgetShowNPoints : public wxPanel
     
 
   protected:
-         virtual void                          SetOutputBox();
 
   private:
-         void                                      ErasePoint(int id);
     
       // EED 2022-05-19
       //vtkRenderer                       *renderer;