]> Creatis software - creaMaracasVisu.git/commitdiff
#3577 Automatic close contour in manualConctour creation
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Sun, 9 Feb 2025 13:24:25 +0000 (14:24 +0100)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Sun, 9 Feb 2025 13:24:25 +0000 (14:24 +0100)
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.h

index cf4c32e93c68b3ba6fbcad3528ef8a5252ef5dbd..fd9ec40aca04eeb9269ee0150930627bd1cfb320 100644 (file)
@@ -168,7 +168,11 @@ void manualContourControler::MouseMove(int x, int y) // virtual
         GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
     }
        GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
-       if (GetState()==1){     SetPoint( _bakIdPoint , x , y ,z); }
+       if (GetState()==1)
+    {  
+        SetPoint( _bakIdPoint , x , y ,z);
+        GetManualViewBaseContour()->AutomaticOpenCloseContour();
+    }
        if (GetState()==5){     SetPoint( _bakIdPoint , x , y ,z); }
     if (GetState()==9){ GetManualViewBaseContour()->SetNewPositionGroupSelectedPoints( x,y,z );  }
        if ( GetState()==6 && !IsEditable() && GetPosibleToMove() &&IsMoving() )
index 043b6d5980de4478fcf6a449d9551e5c7eebc872..cf42458b80f5f2cbf8fde08c76dd4bf94102a5ea 100644 (file)
@@ -1116,6 +1116,10 @@ void manualViewBaseContour::SetNewPositionGroupSelectedPoints(  int x , int y ,i
 }
 
 //-------------------------------------------------------------------
-int manualViewBaseContour::GetNumberOfPointsGroupSelectedPoints()
+int manualViewBaseContour::GetNumberOfPointsGroupSelectedPoints()   // virtual
+{
+}
+
+void manualViewBaseContour::AutomaticOpenCloseContour()    // virtual
 {
 }
index 529f6daf00124c1abd15f1aa5ff1a5aea33b69ee..83726938aa5cec7d4656c3a5ec7c4867dacb117c 100644 (file)
@@ -184,7 +184,8 @@ public:
     virtual void                    InitGroupSelectionPointsToBeMove(int id);
     virtual void                    SetNewPositionGroupSelectedPoints( int x , int y ,int z);
     virtual int                     GetNumberOfPointsGroupSelectedPoints();
-    
+    virtual void                    AutomaticOpenCloseContour();
+
 //---------------------------------------------------
 // PRIVATE METHODS & ATTS
 //---------------------------------------------------
index a297b5ff3f45040a7df55a0ce7cb86a16567dbac..43ef14a183bb076dc6cff18d71110ab54ca7aced 100644 (file)
@@ -543,3 +543,55 @@ void manualViewContour::SetNewPositionGroupSelectedPoints(  int x , int y , int
         UpdateViewPoint(id);
     } // for i
 }
+
+void manualViewContour::AutomaticOpenCloseContour()
+{
+    int i, manualPointsSZ = _manContModel->GetSizeLstPoints();
+    if (manualPointsSZ>=3){
+        double minX,minY,minZ;
+        double maxX,maxY,maxZ;
+        double cX,cY,cZ;
+        manualPoint *mp;
+        double v1X,v1Y,v1Z;
+        double v2X,v2Y,v2Z;
+        double ang;
+        for ( i=0; i<manualPointsSZ; i++ )
+        {
+            mp = _manContModel->GetManualPoint( i );
+            if (i==0)
+            {
+                minX = mp->GetX();
+                maxX = mp->GetX();
+                minY = mp->GetY();
+                maxY = mp->GetY();
+                minZ = mp->GetZ();
+                maxZ = mp->GetZ();
+            }
+            if (minX>mp->GetX()) { minX=mp->GetX(); }
+            if (maxX<mp->GetX()) { maxX=mp->GetX(); }
+            if (minY>mp->GetY()) { minY=mp->GetY(); }
+            if (maxY<mp->GetY()) { maxY=mp->GetY(); }
+            if (minZ>mp->GetZ()) { minZ=mp->GetZ(); }
+            if (maxZ<mp->GetZ()) { maxZ=mp->GetZ(); }
+        } // for
+        cX = (minX+maxX)/2;
+        cY = (minY+maxY)/2;
+        cZ = (minZ+maxZ)/2;
+        mp=_manContModel->GetManualPoint(0);
+        v1X=mp->GetX() - cX;
+        v1Y=mp->GetY() - cY;
+        v1Z=mp->GetZ() - cZ;
+        mp=_manContModel->GetManualPoint( manualPointsSZ-1 );
+        v2X=mp->GetX() - cX;
+        v2Y=mp->GetY() - cY;
+        v2Z=mp->GetZ() - cZ;
+        ang = abs( atan2(v1Y,v1X) - atan2(v2Y,v2X) );
+        if (ang<0.785398)  //  PI/4  45 degre
+        {
+            _manContModel->SetCloseContour(true);
+        }else{ // if 45 degre
+            _manContModel->SetCloseContour(false);
+        }
+    } // if manualPointsSZ >=3
+    
+}
index 4713b8f4ce097ee8dd9357cdc23993645842a330..b019cf84a1ebaf1d73bbd941cc0b63b2831256a5 100644 (file)
@@ -55,7 +55,8 @@ public:
     virtual void    InitGroupSelectionPointsToBeMove(int id);
     virtual void    SetNewPositionGroupSelectedPoints( int x , int y ,int z);
     virtual int     GetNumberOfPointsGroupSelectedPoints();
-
+    virtual void    AutomaticOpenCloseContour();
+    
 private:
        std::vector< std::vector<double> >  _initialMovingPoints;
        manualContourModel                  *_initialConoturModel;
@@ -67,7 +68,6 @@ protected:
        double _maxX;
        double _maxY;
        double _maxZ;
-
     //2024-10-25
     std::vector<double> lstPointsGroupSelectedToMoveId;
     std::vector<double> lstPointsGroupSelectedToMoveX;