From: Eduardo Davila Date: Mon, 27 Jul 2009 15:06:08 +0000 (+0000) Subject: no message X-Git-Tag: EED.02Oct2009~12 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=61dfb8201f2762bceabe938f978e6ada6f9d0873;p=creaMaracasVisu.git no message --- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx index 4e32b1e..4604878 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx @@ -22,10 +22,10 @@ ContourExtractData::ContourExtractData( bool okImagesResults) //---------------------------------------------------------------------- void ContourExtractData::SetImage( vtkImageData* imagedata) { - this->imagedata = imagedata; - if (this->okImagesResults==true){ - InitVtkImagesResult(); - } + this->imagedata = imagedata; + + // init vtk image result : valuesImage maskImage + if (this->okImagesResults==true){ InitVtkImagesResult(); } } //---------------------------------------------------------------------- void ContourExtractData::SetZtoBeAnalys( int z ) @@ -88,8 +88,8 @@ void ContourExtractData::GetMinMaxPoint_Of_LstManConMod( int *minPoint, GetMinMaxPoint(minPoint,maxPoint,lstManConMod[i]); } } -//------------------------------------------------------------------------ +//------------------------------------------------------------------------ int ContourExtractData::AnalisisContourInside(int x, int y, manualContourModel *manualcontourmodel @@ -129,11 +129,12 @@ int ContourExtractData::AnalisisContourInside(int x, manualcontourmodel->GetSpline_i_Point(i,&x2,&y2,&z2); x2=x2+0.5; y2=y2+0.5; //------------------------------------------------------------------------------------------------------ - + //by triangle similarity - if ( ((y1=y1)&&(yy2)&&(y<=y1)&&(y>y2)) ) + if ( ((y1=y1)&&(yy2)&&(y>=y2)&&(y=x1) && (x<=x2)) { inBorder=true; } + if ( ((int)y1==(int)y2) && ((int)y1==y) && (x2=x2) && (x<=x1)) { inBorder=true; } + + if (inBorder==true){ i=nps; } x1=x2; y1=y2; z1=z2; @@ -166,9 +168,99 @@ int ContourExtractData::AnalisisContourInside(int x, return result; } + //------------------------------------------------------------------------ +int ContourExtractData::AnalisisContourInsideV2(int x, int y, int iContour ) +{ + bool inBorder=false; + int result = 0; + int i; + int nps=_lstlstlstVecX1[iContour][y].size(); + + double x1,y1,x2,y2; + double borderX, borderY; + double xx1, yy1,xx2, yy2; + double xx=x, yy=y; + double d; + for (i=0; i=yy1)&&(yy<=yy2) ) + { + + //by triangle similarity + d = ( fabs(xx2-xx1)*(yy-yy1) ) / (yy2-yy1) ; + if ( (xx1xx2)&&(x<(xx1-d)) ) { result++; } + + if ( (yy2-yy1)/difxx2xx1 >= 1.0) + { + if (xx1<=xx2) + { + borderX = xx1+d; + borderY = y; + } else { + borderX = xx1-d; + borderY = y; + } + } + } // if point inside y + + + // Finding border looking in vertical direction + if ( ((xx1<=xx2)&&(xx>=xx1)&&(xxxx2)&&(xx>=xx2)&&(xx=x1) && (x<=x2)) { inBorder=true; } + if ( ((int)y1==(int)y2) && ((int)y1==y) && (x2=x2) && (x<=x1)) { inBorder=true; } + + if (inBorder==true){ i=nps; } + } // for i + + + if (inBorder==true) { result=1; } + + return result; +} + + + +//------------------------------------------------------------------------ bool ContourExtractData::isInside(int x, int y, int typeOperation) { bool result = false; @@ -186,7 +278,8 @@ bool ContourExtractData::isInside(int x, int y, int typeOperation) { for (i=0;i *pLstValue, maxPoint[1] = -999999; GetMinMaxPoint_Of_LstManConMod(minPoint,maxPoint); - + InitLstContoursLinesYPoints(); for (j=minPoint[1]; j<=maxPoint[1]; j++) { @@ -447,7 +533,6 @@ vtkImageData *ContourExtractData::GetVtkImageMaskResult() // ------------------------------------------------------------------------ void ContourExtractData::InitVtkImagesResult() { - printf("EED ContourExtractData::InitVtkImagesResult\n"); int ext[6]; int newDim[3]; double spc[3]; @@ -481,7 +566,6 @@ void ContourExtractData::InitVtkImagesResult() imagedataMaskResult->SetSpacing(spc); imagedataMaskResult->SetDimensions( newDim ); imagedataMaskResult->AllocateScalars(); - printf("EED ContourExtractData::InitVtkImagesResult %p %p\n", imagedataValueResult, imagedataMaskResult); } @@ -600,3 +684,69 @@ void ContourExtractData::SetTypeOperation(int type) { _typeOperation=type; } + +//------------------------------------------------------------------------ +void ContourExtractData::Fill_lstlstlstVecXY(int iContour, int sizeY) +{ + int i,y; + double x1,y1,z1,x2,y2,z2; + manualContourModel *manualcontourmodel= lstManConMod[iContour]; + int nps = manualcontourmodel->GetNumberOfPointsSpline(); // number of points in the spline + manualcontourmodel->UpdateSpline(); + //------------------------------------------------------------------------------------------------------ + + for (y=0;yGetSpline_i_Point(0,&x1,&y1,&z1); + x1=x1+0.5; y1=y1+0.5; + for (i=1; i<=nps; i++) + { + manualcontourmodel->GetSpline_i_Point(i,&x2,&y2,&z2); + x2=x2+0.5; y2=y2+0.5; + if ( ((y1=y1)&&(y<=y2)) || ((y1>y2)&&(y>=y2)&&(y<=y1)) || ((int)y1==y) || ((int)y2==y) ) + { + _lstlstlstVecX1[iContour][y].push_back(x1); + _lstlstlstVecY1[iContour][y].push_back(y1); + _lstlstlstVecX2[iContour][y].push_back(x2); + _lstlstlstVecY2[iContour][y].push_back(y2); + } + x1=x2; y1=y2; z1=z2; + } // for i Points in spline + } // y + +} + +void ContourExtractData::InitLstContoursLinesYPoints() +{ + // init InInside Optimisation + int i; + + _lstlstlstVecX1.clear(); + _lstlstlstVecY1.clear(); + _lstlstlstVecX2.clear(); + _lstlstlstVecY2.clear(); + + int ext[6]; + this->imagedata->GetWholeExtent(ext); + int sizeY = ext[3]-ext[2]+1; + std::vector vecDouble; + std::vector< std::vector > vecVecDouble; + for ( i=0 ; i > > _lstlstlstVecX1; + std::vector< std::vector< std::vector > > _lstlstlstVecY1; + std::vector< std::vector< std::vector > > _lstlstlstVecX2; + std::vector< std::vector< std::vector > > _lstlstlstVecY2; + void Fill_lstlstlstVecXY(int iContour, int sizeY); + void InitLstContoursLinesYPoints(); + }; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx index 693b7d8..4f4e5b5 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx @@ -4,11 +4,8 @@ * \brief Class bbtk::ThresholdImageView . */ - #include "ThresholdImageView.h" - - //========================================================================= ThresholdImageView::ThresholdImageView( ) { @@ -36,7 +33,6 @@ //---------------------------------------------------------------------------- void ThresholdImageView::SetImage(vtkImageData* image) { - printf("ThresholdImageView::SetImage %p\n", image); _image = image; } @@ -78,15 +74,12 @@ void ThresholdImageView::onThreshold() range[1]=255; } - int minTot = floor (range[0]); int maxTot = ceil (range[1]); - int minVal = floor (_minValue); int maxVal = floor (_maxValue); - if (!_actorPresent) { if (_imageReslicer==NULL) @@ -163,7 +156,6 @@ void ThresholdImageView::onThreshold() baseView->GetRenderer()->AddActor( _thresholdActor ); _actorPresent = true; } - else { _imageReslicer->SetResliceAxesOrigin(0,0,z); @@ -192,7 +184,6 @@ void ThresholdImageView::onThreshold() _thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent } } - _thresholdTable->Build( ); _thresholdMapper->SetLookupTable( _thresholdTable ); _thresholdMapper->SetInput( img ); @@ -219,13 +210,10 @@ void ThresholdImageView::onThresholdInterpolation(bool interpolate) { _thresholdActor->InterpolateOn( ); } - else { _thresholdActor->InterpolateOff( ); - } - -//EED _theViewPanel->RefreshInterface(); + } } } @@ -236,8 +224,6 @@ void ThresholdImageView::onThresholdChangeOpacity (int opacity) { _thresholdActor->SetOpacity(opacity*0.1); } - -//EED _theViewPanel->RefreshInterface(); } //---------------------------------------------------------------------------- @@ -248,9 +234,7 @@ void ThresholdImageView::onThresholdRemove() wxVtkBaseView * baseView = _baseView; baseView->GetRenderer()->RemoveActor( _thresholdActor ); _actorPresent = false; - } - -//EED _theViewPanel->RefreshInterface(); + } }