From 88000c43d09de22761bb0ca9e19995e72dc2ebce Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Mon, 27 Apr 2020 10:39:15 +0200 Subject: [PATCH] #3413 creaMaracasVisu Feature New Normal - openmp and Transparent mechanism in wxVtk3DBaseView --- .../bbcreaMaracasVisuManualPaint_Model.cxx | 150 +++++++++-- bbtk/src/bbcreaMaracasVisuManualPaint_Model.h | 2 +- bbtk/src/bbmaracasvisuAxeVolume.cxx | 234 ++++++++++-------- .../wxWindows/widgets/wxVtk3DBaseView.cxx | 9 +- 4 files changed, 274 insertions(+), 121 deletions(-) diff --git a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx index 58df16c..7167f6c 100644 --- a/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx +++ b/bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx @@ -16,24 +16,123 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ManualPaint_Model,bbtk::AtomicBlackBox); // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== +//-- Alternativa con openmp -- +void ManualPaint_Model::LstPointOMPAnalice() +{ +//-- Alternativa con openmp -- +// A. Create copie of index original list => lst1 +// B. if list1 es not empty do.. +// B.1. Create copy of lst1 to lst2 +// B.2. For each element of lst2 (incrimental) check the distance of the rest of the list (decremental) and take it out +// B.3. openmp sobre la La lst2 que queda (PaintImage) +// B.4. Quitar los elementos de lst2 en lst1 y recomenzar desde el punto B; + + double distMin,dist2Min; + if (bbGetInputTool()==0) + { + distMin=bbGetInputBrushSize(); + } else { + distMin=bbGetInputDistanceFill(); + } + dist2Min=distMin*distMin*1.2; + +// A. Create copie of index original list => lst1 + std::vector lst1; + int i1,size1 = bbGetInputByLstPointsX().size(); + for (i1=0;i1 lst2; + for (i1=0;i1i2 ; i3-- ) + { + dx = bbGetInputByLstPointsX()[ lst2[i2] ]-bbGetInputByLstPointsX()[ lst2[i3] ]; + dy = bbGetInputByLstPointsY()[ lst2[i2] ]-bbGetInputByLstPointsY()[ lst2[i3] ]; + dz = bbGetInputByLstPointsZ()[ lst2[i2] ]-bbGetInputByLstPointsZ()[ lst2[i3] ]; + dist2 = dx*dx +dy*dy + dz*dz ; + if (dist2PaintImage( bbGetInputByLstPointsX()[ lst2[i2] ] , + bbGetInputByLstPointsY()[ lst2[i2] ] , + bbGetInputByLstPointsZ()[ lst2[i2] ] ); + } // for i2 + +// B.4. Quitar los elementos de lst2 en lst1 y recomenzar desde el punto B; + for (i2=0;i2Delete(); - } - - int ext[6]; - bbGetInputIn()->GetExtent(ext); - int sizeX=ext[1]-ext[0]+1; - int sizeY=ext[3]-ext[2]+1; - int sizeZ=ext[5]-ext[4]+1; - - double spc[3]; - bbGetInputIn()->GetSpacing(spc); - double invSpc[3]; - invSpc[0] = 1/spc[0]; - invSpc[1] = 1/spc[1]; - invSpc[2] = 1/spc[2]; - - int outputformat = GetTypeFormat( bbGetInputOutputFormat() , bbGetInputIn() ); - - mimage = vtkImageData::New(); - mimage->SetSpacing(bbGetInputIn()->GetSpacing()); - mimage->SetDimensions(bbGetInputIn()->GetDimensions()); - mimage->SetExtent(bbGetInputIn()->GetExtent()); - mimage->SetOrigin(bbGetInputIn()->GetOrigin()); -//EED 2017-01-01 Migration VTK7 -#if VTK_MAJOR_VERSION <= 5 - mimage->SetScalarType( outputformat ); - mimage->AllocateScalars(); -#else - mimage->AllocateScalars( outputformat , 1); -#endif - - int sizeLstPointR = bbGetInputlstPointR().size(); - int iAxe,sizeAxe = bbGetInputlstPointX().size(); - int ii; - int sizeImage = sizeX*sizeY*sizeZ; - unsigned short *p; - - // Clean image - p = (unsigned short*)mimage->GetScalarPointer (0, 0, 0); - for ( ii=0 ; ii=1) + mimage->Delete(); + } + + int ext[6]; + bbGetInputIn()->GetExtent(ext); + int sizeX=ext[1]-ext[0]+1; + int sizeY=ext[3]-ext[2]+1; + int sizeZ=ext[5]-ext[4]+1; + + double spc[3]; + bbGetInputIn()->GetSpacing(spc); + double invSpc[3]; + invSpc[0] = 1/spc[0]; + invSpc[1] = 1/spc[1]; + invSpc[2] = 1/spc[2]; + + int outputformat = GetTypeFormat( bbGetInputOutputFormat() , bbGetInputIn() ); + + mimage = vtkImageData::New(); + mimage->SetSpacing(bbGetInputIn()->GetSpacing()); + mimage->SetDimensions(bbGetInputIn()->GetDimensions()); + mimage->SetExtent(bbGetInputIn()->GetExtent()); + mimage->SetOrigin(bbGetInputIn()->GetOrigin()); + //EED 2017-01-01 Migration VTK7 + #if VTK_MAJOR_VERSION <= 5 + mimage->SetScalarType( outputformat ); + mimage->AllocateScalars(); + #else + mimage->AllocateScalars( outputformat , 1); + #endif + + int sizeLstPointR = bbGetInputlstPointR().size(); + int iAxe,sizeAxe = bbGetInputlstPointX().size(); + int ii; + int sizeImage = sizeX*sizeY*sizeZ; + // unsigned short *p; + + // Clean image + memset( (char*)mimage->GetScalarPointer(0,0,0) , 0, sizeImage*(mimage->GetScalarSize()) ); + + // p = (unsigned short*)mimage->GetScalarPointer (0, 0, 0); + // for ( ii=0 ; ii=1) + { + r = bbGetInputlstPointR()[ bbGetInputlstPointR().size()-1 ] * invSpc[0]; + } else { + r = 1; + } + } // if iAxe sizeLstPointR + px = bbGetInputlstPointX()[iAxe] * invSpc[0]; + py = bbGetInputlstPointY()[iAxe] * invSpc[1]; + pz = bbGetInputlstPointZ()[iAxe] * invSpc[2]; + px1 = px - r; + py1 = py - r; + pz1 = pz - r; + px2 = px + r; + py2 = py + r; + pz2 = pz + r; + rr=r*r; + + long int index; + for ( i=px1 ; i<=px2 ; i++ ) { - ry = j - py; - ry = ry*ry; - for ( k=pz1 ; k=0) && (i=0) && (j=0) && (kGetScalarPointer (i, j, k); -// if (*p==0) - if ( mimage->GetScalarComponentAsDouble(i,j,k,0)==0 ) + if ( (i>=0) && (i=0) && (j=0) && (kGetScalarPointer (i, j, k); + // if (*p==0) + index=i+j*sizeX+k*sizeX*sizeY; + GETVALUE2_VTK_CREA(vItmpOMP,pI,stI,index) + // EED2020-04-25 if ( mimage->GetScalarComponentAsDouble(i,j,k,0)==0 ) + if ( vI==0 ) { -// *p=255; - mimage->SetScalarComponentFromDouble (i,j,k,0, bbGetInputValue() ); - } - } // *p==0 - } // if inside point - } //for k - } //for j - } //for i - } // for iAxe - bbSetOutputOut( mimage ); + rz = k - pz; + rz = rz*rz; + if ( rx + ry + rz <= rr ) + { + // *p=255; + vItmpOMP=bbGetInputValue(); + SETVALUE2_VTK_CREA(vItmpOMP,pI,stI,index) + // EED2020-04-25 mimage->SetScalarComponentFromDouble (i,j,k,0, bbGetInputValue() ); + } + } // *p==0 + } // if inside point + } //for k + } //for j + } //for i + } // for iAxe + bbSetOutputOut( mimage ); + } else { + printf("\n"); + printf("EED Warnning!! AxeVolume::Process The Input In is not set.\n"); + printf("\n"); + }// if bbGetInputIn() } diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.cxx index d9c3339..4bf3d9b 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk3DBaseView.cxx @@ -208,7 +208,14 @@ void wxVtk3DBaseView::Configure() GetCamera()->Yaw(180+30); GetCamera()->Pitch(-22); - } + //https://stackoverflow.com/questions/47528086/problems-with-rendering-transparent-objects-in-vtk + //https://itk.org/Wiki/VTK/Depth_Peeling + _aRenderer->SetUseDepthPeeling(1); + _aRenderer->SetOcclusionRatio(0.1); + _aRenderer->SetMaximumNumberOfPeels(100); + _renWin->SetMultiSamples(0); + _renWin->SetAlphaBitPlanes(1); + } // if _configure } //------------------------------------------------------------------- -- 2.47.1