From 1b4ae09d7ff99ffeb0c64656122aba6266ace686 Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Tue, 3 Jul 2012 11:48:08 +0000 Subject: [PATCH] BUG - 1399 Optimisation of ifTouchContour in manualViewContour (Boundaring) - 1449 ManaulPaint incorrect default parameters --- .../manualContour/manualView3VContour.cpp | 70 +++++++++++++------ .../manualContour/manualViewBullEyeSector.cpp | 29 +++++++- .../manualContour/manualViewContour.cpp | 7 +- .../widgets/manualContour/manualViewContour.h | 2 + .../manualPaint/wxManualPaintPanel.cpp | 16 ++--- 5 files changed, 89 insertions(+), 35 deletions(-) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualView3VContour.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualView3VContour.cpp index c7a1d75..f8fadff 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualView3VContour.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualView3VContour.cpp @@ -62,6 +62,17 @@ void manualView3VContour::RefreshContour() // virtula { manualViewContour::RefreshContour(); int i; + + //EED 27 Juin 2012 + //Boundaring box + _minX=99999; + _minY=99999; + _minZ=99999; + _maxX=-99999; + _maxY=-99999; + _maxZ=-99999; + + double pp[3]; // JSTG 25-02-08 ---------------------------------------- //int nps = GetNumberOfPointsSpline(); @@ -74,7 +85,18 @@ void manualView3VContour::RefreshContour() // virtula //EED 27 sep 2006 _pts->SetPoint( i, pp[0] , pp[1] ,pp[2] ); - } + + + //EED 27 Juin 2012 + //Boundaring box + if (pp[0] < _minX) { _minX = pp[0]; } + if (pp[1] < _minY) { _minY = pp[1]; } + if (pp[2] < _minZ) { _minZ = pp[2]; } + if (pp[0] > _maxX) { _maxX = pp[0]; } + if (pp[1] > _maxY) { _maxY = pp[1]; } + if (pp[2] > _maxZ) { _maxY = pp[2]; } + + }// for } @@ -122,28 +144,30 @@ bool manualView3VContour::ifTouchContour(int x,int y,int z){ // virtual yy = yy * _spc[1]; zz = zz * _spc[2]; - unsigned int i, nps,nps_t; - nps = _sizePointsContour; - if (this->_manContModel->IfCloseContour()==true) - { - nps_t = nps; - } else { - nps_t = nps-1; - } - FilterCordinateXYZ(xx,yy,zz); - - for( i = 0; i < nps_t; i++ ) { - _pts->GetPoint(i%nps, ppA); - _pts->GetPoint((i+1)%nps, ppB); - FilterCordinateXYZ(ppA[0],ppA[1],ppA[2]); - FilterCordinateXYZ(ppB[0],ppB[1],ppB[2]); - d1= sqrt( (ppA[0]-xx)*(ppA[0]-xx) + (ppA[1]-yy)*(ppA[1]-yy) + (ppA[2]-zz)*(ppA[2]-zz)); - d2= sqrt( (ppB[0]-xx)*(ppB[0]-xx) + (ppB[1]-yy)*(ppB[1]-yy) + (ppB[2]-zz)*(ppB[2]-zz)); - d3= sqrt( (ppB[0]-ppA[0])*(ppB[0]-ppA[0]) + (ppB[1]-ppA[1])*(ppB[1]-ppA[1]) + (ppB[2]-ppA[2])*(ppB[2]-ppA[2])); - if ( ((d1+d2)>=d3) && ((d1+d2)<=d3*1.3) ) { - result=true; - i=nps; + if ( (xx>=_minX) && (yy>=_minY) && (xx<=_maxX) && (yy<=_maxY)) { // boundaring box + unsigned int i, nps,nps_t; + nps = _sizePointsContour; + if (this->_manContModel->IfCloseContour()==true) + { + nps_t = nps; + } else { + nps_t = nps-1; } - } + FilterCordinateXYZ(xx,yy,zz); + + for( i = 0; i < nps_t; i++ ) { + _pts->GetPoint(i%nps, ppA); + _pts->GetPoint((i+1)%nps, ppB); + FilterCordinateXYZ(ppA[0],ppA[1],ppA[2]); + FilterCordinateXYZ(ppB[0],ppB[1],ppB[2]); + d1= sqrt( (ppA[0]-xx)*(ppA[0]-xx) + (ppA[1]-yy)*(ppA[1]-yy) + (ppA[2]-zz)*(ppA[2]-zz)); + d2= sqrt( (ppB[0]-xx)*(ppB[0]-xx) + (ppB[1]-yy)*(ppB[1]-yy) + (ppB[2]-zz)*(ppB[2]-zz)); + d3= sqrt( (ppB[0]-ppA[0])*(ppB[0]-ppA[0]) + (ppB[1]-ppA[1])*(ppB[1]-ppA[1]) + (ppB[2]-ppA[2])*(ppB[2]-ppA[2])); + if ( ((d1+d2)>=d3) && ((d1+d2)<=d3*1.3) ) { + result=true; + i=nps; + } // if d1 d2 d3 + }// for i + } // boundaring box return result; } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBullEyeSector.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBullEyeSector.cpp index 7f666de..e3800a1 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBullEyeSector.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBullEyeSector.cpp @@ -13,8 +13,18 @@ void manualViewBullEyeSector::RefreshContour() //EED004 int i,nps; double x,y,z; + double xx,yy,zz; //---------------------------------- + //EED 27 Juin 2012 + //Boundaring box + _minX=99999; + _minY=99999; + _minZ=99999; + _maxX=-99999; + _maxY=-99999; + _maxZ=-99999; + _manContModel->UpdateSpline(); nps = _manContModel->GetNumberOfPointsSpline(); @@ -23,8 +33,23 @@ void manualViewBullEyeSector::RefreshContour() for( i = 0; i < nps; i++ ) { _manContModel->GetSpline_i_Point(i,&x,&y,&z); - _pts->SetPoint(i , x*_spc[0] , y*_spc[1] , z*_spc[2] ); + xx = x*_spc[0]; + yy = y*_spc[1]; + zz = z*_spc[2]; + _pts->SetPoint(i , xx , yy , zz ); + + //EED 27 Juin 2012 + //Boundaring box + if (xx < _minX) { _minX = xx; } + if (yy < _minY) { _minY = yy; } + if (zz < _minZ) { _minZ = zz; } + if (xx > _maxX) { _maxX = xx; } + if (yy > _maxY) { _maxY = yy; } + if (zz > _maxZ) { _maxY = zz; } + + }// for - } + + } // if _pts } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp index 3a42953..bff37c3 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.cpp @@ -78,6 +78,8 @@ void manualViewContour::RefreshContour() // virtual nps = _manContModel->GetNumberOfPointsSpline(); //delta=( double ) ( np ) / ( double ) ( nps-1 ); //JSTG 25-02-08 + //EED 27 Juin 2012 + //Boundaring box _minX=99999; _minY=99999; _maxX=-99999; @@ -101,7 +103,8 @@ void manualViewContour::RefreshContour() // virtual zz=z*_spc[2]; _pts->SetPoint(i,xx,yy,zz ); -//EED 27 Juin 2012 + //EED 27 Juin 2012 + //Boundaring box if (xx < _minX) { _minX = xx; } if (yy < _minY) { _minY = yy; } if (xx > _maxX) { _maxX = xx; } @@ -210,7 +213,7 @@ bool manualViewContour::ifTouchContour(int x,int y,int z) yy = yy * _spc[1]; zz = zz * _spc[2]; - if ( (xx>=_minX) && (yy>=_minY) && (xx<=_maxX) && (yy<=_maxY)) { + if ( (xx>=_minX) && (yy>=_minY) && (xx<=_maxX) && (yy<=_maxY)) { // inside the boundaring box unsigned int i, nps,nps_t; nps = _sizePointsContour; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.h index 3acc8fa..6f3b752 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewContour.h @@ -38,8 +38,10 @@ private: protected: double _minX; double _minY; + double _minZ; double _maxX; double _maxY; + double _maxZ; }; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp index 2ae9cf5..58054ea 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualPaint/wxManualPaintPanel.cpp @@ -173,22 +173,22 @@ void wxManualPaintPanel::ConfigureGrayLevelSld( ) { _txtGrayLevel = new wxStaticText( this, -1, wxString( _T(" Gray Level ") ) ); - _sldGrayLevel = new wxSlider( this, -1, 0, 0, 50, wxDefaultPosition, + _sldGrayLevel = new wxSlider( this, -1, 0, 0, 255, wxDefaultPosition, wxDefaultSize, wxSL_LABELS ); _sldGrayLevel->SetMinSize( wxSize( 200, -1 ) ); _sldGrayLevel->SetMaxSize( wxSize( 200, -1 ) ); _graylevelCtrl = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, - wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 50, 0 ); + wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 65535, 0 ); } //-------------------------------------------------------------------------- void wxManualPaintPanel::ConfigureBrushSizeSld( ) { _txtBrushSize = new wxStaticText( this, -1, wxString( _T(" Brush size ") ) ); - _sldBrushSize = new wxSlider( this, -1, 1, 1, 20, wxDefaultPosition, + _sldBrushSize = new wxSlider( this, -1, 1, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS ); _BrushSizeCtrl = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, - wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 20, 0 ); + wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 65535, 0 ); _sldBrushSize->SetMinSize( wxSize( 200, -1 ) ); _sldBrushSize->SetMaxSize( wxSize( 200, -1 ) ); } @@ -197,12 +197,12 @@ void wxManualPaintPanel::ConfigureDistanceFillSld( ) { _txtDistanceFill = new wxStaticText( this, -1, wxString( _T(" Distance fill ") ) ); - _sldDistanceFill = new wxSlider( this, -1, 500, 1, 500, wxDefaultPosition, + _sldDistanceFill = new wxSlider( this, -1, 50, 1, 500, wxDefaultPosition, wxDefaultSize, wxSL_LABELS ); _sldDistanceFill->SetMinSize( wxSize( 200, -1 ) ); _sldDistanceFill->SetMaxSize( wxSize( 200, -1 ) ); _distancefillCtrl = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, - wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 500, 500 ); + wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 500, 50 ); _txtDistanceFill->Disable( ); _sldDistanceFill->Disable( ); _distancefillCtrl->Disable( ); @@ -212,12 +212,12 @@ void wxManualPaintPanel::ConfigureTolFillSld( ) { _txtToleranceFill = new wxStaticText( this, -1, wxString( _T(" Tolerance fill ") ) ); - _sldToleranceFill = new wxSlider( this, -1, 50, 0, 50, wxDefaultPosition, + _sldToleranceFill = new wxSlider( this, -1, 125, 0, 255, wxDefaultPosition, wxDefaultSize, wxSL_LABELS ); _sldToleranceFill->SetMinSize( wxSize( 200, -1 ) ); _sldToleranceFill->SetMaxSize( wxSize( 200, -1 ) ); _tolerancefillCtrl = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, - wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 50, 50 ); + wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 65535, 50 ); _txtToleranceFill->Disable( ); _sldToleranceFill->Disable( ); _tolerancefillCtrl->Disable( ); -- 2.47.1