]> Creatis software - creaMaracasVisu.git/commitdiff
#3518 ShowNPoints propose new points in new Collection (group)
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Mon, 19 Jun 2023 13:12:44 +0000 (15:12 +0200)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Mon, 19 Jun 2023 13:12:44 +0000 (15:12 +0200)
bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbg
bbtk/bbs/boxes/Mesh_tool_ApplySurface.bbs
bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx
bbtk/src/bbcreaMaracasVisuShowNPoints_Tools.cxx
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 48bb2ddf680b8f54ea7d5f22aa48e03d4062c760..4d2b9acbaf36394b9d63b7ea68bf43d03cfe1bf2 100644 (file)
@@ -72,7 +72,7 @@ COMPLEX_PORT
 meshmanagermodel
 -150.374274:130.740991:-900.000000
 FIN_COMPLEX_PORT
-BOXES:86
+BOXES:84
 BOX
 creaMaracasVisu:ShowNPoints:showNpoints
 ISEXEC:FALSE
@@ -764,18 +764,6 @@ PORT
 Orientation:"H"
 FIN_BOX
 BOX
-wx:OutputText:Box128
-ISEXEC:FALSE
-120.937187:-68.167658:-900.000000
-142.717187:-70.667658:-900.000000
-FIN_BOX
-BOX
-wx:OutputText:Box129
-ISEXEC:FALSE
-125.385650:-72.286605:-900.000000
-147.165650:-74.786605:-900.000000
-FIN_BOX
-BOX
 wx:LayoutLine:Box130
 ISEXEC:FALSE
 108.922083:-61.432768:-900.000000
@@ -789,7 +777,7 @@ ISEXEC:FALSE
 -17.624192:-45.101554:-900.000000
 4.155808:-47.601554:-900.000000
 FIN_BOX
-CONNECTIONS:171
+CONNECTIONS:169
 CONNECTION
 Box06:LstContourPointsX:Box04:LstX
 NumberOfControlPoints:0
@@ -1280,12 +1268,6 @@ CONNECTION
 Box127:Widget:Box50:Widget6
 NumberOfControlPoints:0
 CONNECTION
-Box118:Widget:Box130:Widget2
-NumberOfControlPoints:0
-CONNECTION
-Box124:Widget:Box130:Widget4
-NumberOfControlPoints:0
-CONNECTION
 Box130:Widget:Box121:Widget3
 NumberOfControlPoints:0
 CONNECTION
@@ -1298,9 +1280,9 @@ CONNECTION
 Box131:Widget:Box50:Widget9
 NumberOfControlPoints:0
 CONNECTION
-Box129:Widget:Box121:Widget9
+Box124:Widget:Box130:Widget1
 NumberOfControlPoints:0
 CONNECTION
-Box128:Widget:Box121:Widget8
+Box118:Widget:Box130:Widget3
 NumberOfControlPoints:0
 APP_END
index 9548fea9300cb189ff5a63196d71be9aa2d5b82d..f6ed0d677ed7bdb5cb7e8e4ed5c7228f7dd93ee1 100644 (file)
@@ -281,10 +281,6 @@ new creaMaracasVisu:ShowNPoints_Tools Box126
 new wx:LayoutLine Box127
   set Box127.Orientation "H"
 
-new wx:OutputText Box128
-
-new wx:OutputText Box129
-
 new wx:LayoutLine Box130
   set Box130.Orientation "V"
 
@@ -439,14 +435,12 @@ connect showNpoints.WidgetShowNPoints Box122.WidgetShowNPoints
 connect showNpoints.WidgetShowNPoints Box126.WidgetShowNPoints
 connect Box108.Widget Box127.Widget2
 connect Box127.Widget Box50.Widget6
-connect Box118.Widget Box130.Widget2
-connect Box124.Widget Box130.Widget4
 connect Box130.Widget Box121.Widget3
 connect Box106.Widget Box127.Widget5
 connect Box103.Widget Box50.Widget7
 connect Box131.Widget Box50.Widget9
-connect Box129.Widget Box121.Widget9
-connect Box128.Widget Box121.Widget8
+connect Box124.Widget Box130.Widget1
+connect Box118.Widget Box130.Widget3
 
 # Complex input ports
 input point showNpoints.In " "
index 41b98dc8c8c94fec227f3341bb939e8bea46948c..3a8922e5a170622c7f8f3d4877365569b4161234 100644 (file)
@@ -6,7 +6,6 @@
 
 #include <creaContoursFactory.h>
 
-
 namespace bbcreaMaracasVisu
 {
 
index 27ebbf9e9358ee3765560bdc09f39cf8f841beb6..f7f1a48f981398f8d8e27eb45596547bca4f0fe1 100644 (file)
@@ -193,17 +193,11 @@ void ShowNPoints_Tools::InitCreateVolumeSurface_Points()
         pointEnd.push_back( pC3[1] );
         pointEnd.push_back( pC3[2] );
 
-        printf("EED ShowNPoints_Tools::InitCreateVolumeSurface_Points 1\n");
         wsp->SetActualCollection(0);
-        printf("EED ShowNPoints_Tools::InitCreateVolumeSurface_Points 2\n");
         wsp->SetReferencePoint(pointStart);
-        printf("EED ShowNPoints_Tools::InitCreateVolumeSurface_Points 3\n");
         wsp->OnInsertPoint_();
-        printf("EED ShowNPoints_Tools::InitCreateVolumeSurface_Points 4\n");
         wsp->SetReferencePoint(pointEnd);
-        printf("EED ShowNPoints_Tools::InitCreateVolumeSurface_Points 5\n");
         wsp->OnInsertPoint_();
-        printf("EED ShowNPoints_Tools::InitCreateVolumeSurface_Points 6\n");
 
         wsp->SetActualCollection(2);
         wsp->SetReferencePoint(pointStart);
index 61e53d98c61121261f7a097d8829bba1895eb26a..b4ba379963e38cee8124ace5da22e20ca395dd54 100644 (file)
@@ -81,7 +81,6 @@ void ViewShowNPoints::AddVtkPoint()
     vtkActor *sphereActor    = vtkActor::New();
     sphereActor->SetMapper(sphereMapper);
     sphereActor->SetOrigin(0, 0, 0);
-
     lstActorsSphere.push_back(sphereActor);
     
     if(renderer==NULL){
index 43c15a0cefe8651b60d517b70622565ea9b19f61..a7a08401f8967e042f0ffb4eeb3d18ba36f29b5c 100644 (file)
@@ -11,6 +11,8 @@
 
 #include "WidgetShowNPoints.h"
 
+#include <creaContoursFactory.h>
+
 //----------------------------------------------------------------------
 //----------------------------------------------------------------------
 //----------------------------------------------------------------------
@@ -517,11 +519,14 @@ void WidgetShowNPoints::AddVtkPoint()
 //------------------------------------------------------------------------
 void WidgetShowNPoints::AddPoint(double x, double y, double z, std::string label)
 {
+    printf("WidgetShowNPoints::AddPoint 0  model=%p\n", GetModelShowNPoints() );
        GetModelShowNPoints()->AddPoint(x,y,z, label );
     // EED 2022-05-19
     //AddVtkPoint();
     //RefreshPoint(lstActorsSphere.size()-1);
+    printf("WidgetShowNPoints::AddPoint 1   view=%p\n", GetViewShowNPoints() );
     GetViewShowNPoints()->AddPoint();
+    printf("WidgetShowNPoints::AddPoint 2\n");
 }
 
 //------------------------------------------------------------------------
@@ -1114,15 +1119,15 @@ void WidgetShowNPoints::InsertCollection()
 {
     ModelShowNPoints*   model   = new ModelShowNPoints();
     ViewShowNPoints*    view    = new ViewShowNPoints( model );
+    view->mopacity              = lstViewShowNPoints[0]->mopacity;
+    view->renderer              = lstViewShowNPoints[0]->renderer;
     model->SetImage( lstModelShowNPoints[0]->GetImage() );
-    view->mopacity = lstViewShowNPoints[0]->mopacity;
-    view->renderer = lstViewShowNPoints[0]->renderer;
     lstModelShowNPoints.insert( lstModelShowNPoints.begin()+mActualCollection , model );
     lstViewShowNPoints.insert( lstViewShowNPoints.begin()+mActualCollection , view );
 }
 
 //------------------------------------------------------------------------
-void WidgetShowNPoints::InsertCollectionBefore_()
+void WidgetShowNPoints::InsertCollectionBefore_()  
 {
     InsertCollection();
     RefreshCollectionText();
@@ -1134,6 +1139,7 @@ void WidgetShowNPoints::InsertCollectionBefore_()
 void WidgetShowNPoints::OnInsertCollectionBefore_()
 {
     InsertCollectionBefore_();
+    CreatePointsIntoNewCollection();
     UndoRedo_SaveCollection();
 }
 
@@ -1155,10 +1161,12 @@ void WidgetShowNPoints::InsertCollectionAfter_()
     StopTrackPoint();
 }
 
+
 //------------------------------------------------------------------------
 void WidgetShowNPoints::OnInsertCollectionAfter_()
 {
     InsertCollectionAfter_();
+    CreatePointsIntoNewCollection();
     UndoRedo_SaveCollection();
 }
 
@@ -1168,6 +1176,90 @@ void WidgetShowNPoints::OnInsertCollectionAfter(wxCommandEvent &event)
     OnInsertCollectionAfter_();
 }
 
+//------------------------------------------------------------------------
+void WidgetShowNPoints::CreatePointsIntoNewCollection()
+{
+    //   ---------------------------------------------
+    printf("\nWidgetShowNPoints::InsertCollection mActualCollection=%d\n",mActualCollection);
+    int c1 = mActualCollection-1;
+    int c2 = mActualCollection+1;
+    if (c2==lstModelShowNPoints.size()) { c2=0; }
+    if ((c1>=0) && (c1!=c2) )
+    {
+        std::vector<double> c1LstX = lstModelShowNPoints[c1]->GetLstPointsX();
+        std::vector<double> c1LstY = lstModelShowNPoints[c1]->GetLstPointsY();
+        std::vector<double> c1LstZ = lstModelShowNPoints[c1]->GetLstPointsZ();
+        std::vector<double> c2LstX = lstModelShowNPoints[c2]->GetLstPointsX();
+        std::vector<double> c2LstY = lstModelShowNPoints[c2]->GetLstPointsY();
+        std::vector<double> c2LstZ = lstModelShowNPoints[c2]->GetLstPointsZ();
+        std::vector<double> c1LstXX;
+        std::vector<double> c1LstYY;
+        std::vector<double> c1LstZZ;
+        std::vector<double> c2LstXX;
+        std::vector<double> c2LstYY;
+        std::vector<double> c2LstZZ;
+        creaContoursFactory     f;
+        manualContourModel      *m;
+        double                  x,y,z;
+        int                     i,size;
+        int                     sc; // sizeContour
+        
+        if ( (c1LstX.size()!=0) && (c2LstX.size()!=0) )
+        {
+            // ----------------- Spline 1 --------------------
+            sc          = 100;
+            size        = c1LstX.size();
+            m           = (manualContourModel*)f.getContourModel( 1 );  // Spline
+            //        m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
+            m->SetNumberOfPointsSpline( sc );
+            m->SetCloseContour( false );
+            for (i=0;i<size;i++)
+            {
+                m->AddPoint( c1LstX[i] , c1LstY[i] , c1LstZ[i] );
+            } // for
+            m->UpdateSpline();
+            for (i=0;i<sc;i++)
+            {
+                m->GetSpline_i_Point(i,&x,&y,&z);
+                c1LstXX.push_back(x);
+                c1LstYY.push_back(y);
+                c1LstZZ.push_back(z);
+            } // for
+            delete m;
+            // ----------------- Spline 2 --------------------
+            size        = c2LstX.size();
+            m           = (manualContourModel*)f.getContourModel( 1 );  // Spline
+            //        m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
+            m->SetNumberOfPointsSpline( sc );
+            m->SetCloseContour( false );
+            for (i=0;i<size;i++)
+            {
+                m->AddPoint( c2LstX[i] , c2LstY[i] , c2LstZ[i] );
+            } // for
+            m->UpdateSpline();
+            for (i=0;i<sc;i++)
+            {
+                m->GetSpline_i_Point(i,&x,&y,&z);
+                c2LstXX.push_back(x);
+                c2LstYY.push_back(y);
+                c2LstZZ.push_back(z);
+            } // for
+            delete m;
+            // ----------------- Add new Points --------------------
+            i=0;   x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
+//            i=33;  x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
+//            i=66;  x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
+            i=25;  x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
+            i=50;  x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
+            i=75;  x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
+            i=sc-1;x=(c1LstXX[i]+c2LstXX[i])/2; y=(c1LstYY[i]+c2LstYY[i])/2; z=(c1LstZZ[i]+c2LstZZ[i])/2; AddPoint(x,y,z,"");
+        } // if size of c1LstX c2LstX
+    }  // if c1 && c2
+
+}
+
+
+
 //------------------------------------------------------------------------
 void WidgetShowNPoints::DeleteCollection_()
 {
index 9a6ab0d1bb21107a499c4a0654b45c826b5b30a9..193f287ea1700bad888ce65dc36283394e975333 100644 (file)
@@ -56,6 +56,7 @@ class WidgetShowNPoints : public wxPanel
       void InsertCollectionAfter_();
       void OnInsertCollectionAfter_();
       void OnInsertCollectionAfter(wxCommandEvent &event);
+      void CreatePointsIntoNewCollection();
       void OnDeleteCollection_();
       void OnDeleteCollection(wxCommandEvent &event);
       void DeleteCollection_();