From 15112ae15da4222831b0e8e7c9be87daf9e99a1c Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Mon, 15 Nov 2021 09:39:42 +0100 Subject: [PATCH] #3474 Refresh optimization DrawAxisTree3D Box --- bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx | 93 ++++++++----------- .../wxWindows/widgets/wxVtk2DBaseView.cxx | 11 --- 2 files changed, 40 insertions(+), 64 deletions(-) diff --git a/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx b/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx index 9a4b878..bae9e27 100644 --- a/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx +++ b/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx @@ -77,69 +77,63 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis) vtkPolyLine *polyline = vtkPolyLine::New(); vtkCellArray* allTopology = vtkCellArray::New( ); // allTopology->InsertNextCell( numPoints ); - - size=iGeneral+numPoints; - + std::vector lstX =bbGetInputlstPointX(); + std::vector lstY =bbGetInputlstPointY(); + std::vector lstZ =bbGetInputlstPointZ(); for (i=iGeneral;iInsertNextPoint( bbGetInputlstPointX()[i]*spc[0], - bbGetInputlstPointY()[i]*spc[1], - bbGetInputlstPointZ()[i]*spc[2] ); -// printf("DrawAxisTree3D::DrawOneAxis point %d -> %f, %f, %f \n", i, bbGetInputlstPointX()[i], bbGetInputlstPointY()[i], bbGetInputlstPointZ()[i] ); - -polyline->GetPointIds()->InsertNextId(i-iGeneral); + allPoints->InsertNextPoint( lstX[i], + lstY[i], + lstZ[i] ); +// printf("DrawAxisTree3D::DrawOneAxis point %d -> %f, %f, %f \n", i, bbGetInputlstPointX()[i], bbGetInputlstPointY()[i], bbGetInputlstPointZ()[i] ); + polyline->GetPointIds()->InsertNextId(i-iGeneral); // allTopology->InsertCellPoint( i-iGeneral ); } // rof - - allTopology->InsertNextCell(polyline); + allTopology->InsertNextCell(polyline); // create cell array for edges - vtkCellArray *edges = vtkCellArray::New(); + vtkCellArray *edges = vtkCellArray::New(); // connect edge's and vertexes point ids - for(vtkIdType i = iGeneral; i < size-1; i++) - { - vtkLine *edge = vtkLine::New(); - edge->GetPointIds()->SetId(0, i-iGeneral); - edge->GetPointIds()->SetId(1, (i-iGeneral+1) ); - edges->InsertNextCell(edge); - edge->Delete(); - // vtkSmartPointer vertex = vtkSmartPointer::New(); - // vertex->GetPointIds()->SetId(0, i); - // vertexes->InsertNextCell(vertex); - } - polydata->SetPoints( allPoints ); - polydata->SetLines(edges); -// polydata->SetLines( allTopology ); - - - // polydata->SetPolys( allTopology ); - - edges->Delete(); - allPoints->Delete(); - allTopology->Delete(); - } - + for(vtkIdType i = iGeneral; i < size-1; i++) + { + vtkLine *edge = vtkLine::New(); + edge->GetPointIds()->SetId(0, i-iGeneral); + edge->GetPointIds()->SetId(1, (i-iGeneral+1) ); + edges->InsertNextCell(edge); + edge->Delete(); + // vtkSmartPointer vertex = vtkSmartPointer::New(); + // vertex->GetPointIds()->SetId(0, i); + // vertexes->InsertNextCell(vertex); + } // for i + polydata->SetPoints( allPoints ); + polydata->SetLines(edges); + // polydata->SetLines( allTopology ); + // polydata->SetPolys( allTopology ); + edges->Delete(); + allPoints->Delete(); + allTopology->Delete(); + } // if lstpointsXsize + // color double r,g,b; - + std::vector lstColor = bbGetInputColour(); if (bbGetInputColourLaw()==1) // the same color for all { - r = bbGetInputColour()[0]; - g = bbGetInputColour()[1]; - b = bbGetInputColour()[2]; + r = lstColor[0]; + g = lstColor[1]; + b = lstColor[2]; vtkactor->GetProperty()->SetColor( r,g,b ); } // Law 1 color for all - if (bbGetInputColourLaw()==2) // different colors for each segment { if ( (iAxis*3+1) < (int)(bbGetInputColour().size()) ) { - r = bbGetInputColour()[0+iAxis*3]; - g = bbGetInputColour()[1+iAxis*3]; - b = bbGetInputColour()[2+iAxis*3]; + r = lstColor[0+iAxis*3]; + g = lstColor[1+iAxis*3]; + b = lstColor[2+iAxis*3]; } else { r = (rand() % 100) / 100.0; g = (rand() % 100) / 100.0; @@ -147,7 +141,6 @@ polyline->GetPointIds()->InsertNextId(i-iGeneral); } vtkactor->GetProperty()->SetColor( r,g,b ); } // Law 2 color for each segment - if (bbGetInputColourLaw()==3) // color for each point { // Setup the colors array @@ -158,20 +151,17 @@ polyline->GetPointIds()->InsertNextId(i-iGeneral); int iPoint,pointSize=iGeneral+numPoints; for (iPoint=iGeneral; iPointSetTuple3(iPoint,r,g,b); + r = lstColor[0+iPoint*3]*255.0; + g = lstColor[1+iPoint*3]*255.0; + b = lstColor[2+iPoint*3]*255.0; colors->InsertNextTuple3(r,g,b); } polydata->GetCellData()->SetScalars(colors); polydata->Modified(); - } // Law 3 color for each point vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() ); vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() ); - if ( bbGetInputTransform()!=NULL ) { vtkactor->SetUserTransform( bbGetInputTransform() ); @@ -186,7 +176,6 @@ polyline->GetPointIds()->InsertNextId(i-iGeneral); void DrawAxisTree3D::Process() { - // Removing actors int iActor,sizeActors = vecVtkActors.size(); for (iActor=0 ; iActorGetSpacing (spx,spy,spz); imageData->GetExtent (x1,x2,y1,y2,z1,z2); } -printf("//EED wxVtk2DBaseView::ResetView %d %d %d %d %d %d \n",x1,x2,y1,y2,z1,z2); _imageViewer2XYZ -> SetExtentDimension(x1,x2,y1,y2,z1,z2); _imageViewer2XYZ -> GetVtkImageViewer2()->SetupInteractor ( iren ); @@ -144,14 +142,7 @@ printf("//EED wxVtk2DBaseView::ResetView %d %d %d %d %d %d \n",x1,x2,y1,y vtkInteractorZoomCamera *_vtkInteractorZoomCamera = new vtkInteractorZoomCamera(); style2D->SetInteractorZoomCamera(_vtkInteractorZoomCamera); - - SetInteractorStyleImage( style2D ); - - // RaC - ////////////// - printf("EED wxVtk2DBaseView::ResetView End\n"); - } //------------------------------------------------------------------- @@ -335,7 +326,6 @@ void wxVtk2DBaseView::UpdateCameraParallelScale() //------------------------------------------------------------------- void wxVtk2DBaseView::Refresh() { -printf("EED wxVtk2DBaseView::Refresh Start\n"); int z = (int)(GetVtkBaseData()->GetZ()); _imageViewer2XYZ->SetZSlice( z ); //EED 2016/02/19 @@ -345,7 +335,6 @@ printf("EED wxVtk2DBaseView::Refresh Start\n"); UpdateColorWindowLevel(); UpdateCameraParallelScale(); wxVtkBaseView::Refresh(); -printf("EED wxVtk2DBaseView::Refresh End\n"); } //------------------------------------------------------------------- -- 2.47.1