From 4fbbac2c03d5860f986492250ce43e78af7bd54a Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Sun, 9 Feb 2025 14:24:25 +0100 Subject: [PATCH] #3577 Automatic close contour in manualConctour creation --- .../manualContour/manualContourControler.cpp | 6 ++- .../manualContour/manualViewBaseContour.cpp | 6 ++- .../manualContour/manualViewBaseContour.h | 3 +- .../manualContour/manualViewContour.cpp | 52 +++++++++++++++++++ .../widgets/manualContour/manualViewContour.h | 4 +- 5 files changed, 66 insertions(+), 5 deletions(-) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp index cf4c32e..fd9ec40 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourControler.cpp @@ -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() ) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp index 043b6d5..cf42458 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp @@ -1116,6 +1116,10 @@ void manualViewBaseContour::SetNewPositionGroupSelectedPoints( int x , int y ,i } //------------------------------------------------------------------- -int manualViewBaseContour::GetNumberOfPointsGroupSelectedPoints() +int manualViewBaseContour::GetNumberOfPointsGroupSelectedPoints() // virtual +{ +} + +void manualViewBaseContour::AutomaticOpenCloseContour() // virtual { } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h index 529f6da..8372693 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.h @@ -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 //--------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp index a297b5f..43ef14a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp @@ -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; iGetManualPoint( 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 (maxXGetX()) { maxX=mp->GetX(); } + if (minY>mp->GetY()) { minY=mp->GetY(); } + if (maxYGetY()) { maxY=mp->GetY(); } + if (minZ>mp->GetZ()) { minZ=mp->GetZ(); } + if (maxZGetZ()) { 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 + +} diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.h index 4713b8f..b019cf8 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.h @@ -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 > _initialMovingPoints; manualContourModel *_initialConoturModel; @@ -67,7 +68,6 @@ protected: double _maxX; double _maxY; double _maxZ; - //2024-10-25 std::vector lstPointsGroupSelectedToMoveId; std::vector lstPointsGroupSelectedToMoveX; -- 2.49.0