]> Creatis software - creaMaracasVisu.git/commitdiff
#3474 Refresh optimization DrawAxisTree3D Box
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Mon, 15 Nov 2021 08:39:42 +0000 (09:39 +0100)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Mon, 15 Nov 2021 08:39:42 +0000 (09:39 +0100)
bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx

index 9a4b8789d04e87d28b9b5d0cf5bbf1dcda1a3262..bae9e276b0ae2e7c62b32cad69896d698d83da76 100644 (file)
@@ -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<double> lstX =bbGetInputlstPointX();
+        std::vector<double> lstY =bbGetInputlstPointY();
+        std::vector<double> lstZ =bbGetInputlstPointZ();
                for (i=iGeneral;i<size;i++)
                {
                        //multiplicar ver parametros spacing, en maracas cuando se toca la imagen y se ve dycom
                        //hay parĀ·metro dycom, vtkImagedata valor spacing y esos datos hay que multiplicar al polydata
-                       allPoints->InsertNextPoint( 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<vtkVertex> vertex = vtkSmartPointer<vtkVertex>::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<vtkVertex> vertex = vtkSmartPointer<vtkVertex>::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<double> 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; iPoint<pointSize; iPoint++)
                {
-                       r = bbGetInputColour()[0+iPoint*3]*255.0;
-                       g = bbGetInputColour()[1+iPoint*3]*255.0;
-                       b = bbGetInputColour()[2+iPoint*3]*255.0;
-                       //colors->SetTuple3(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 ; iActor<sizeActors; iActor++)
@@ -202,7 +191,6 @@ void DrawAxisTree3D::Process()
        vecVtkPolyData.clear();
        vecVtkPolyDataMaper.clear();
        vecVtkActors.clear();
-
        // Adding actors
        if (bbGetInputActive()==true)
        {
@@ -233,7 +221,6 @@ void DrawAxisTree3D::Process()
                        printf("\nDrawAxisTree3D .ERROR.  size of vectors lstPointX.size=%d lstPointY.size=%d lstPointZ.size=%d are not coherent \n\n",bbGetInputlstPointX().size(), bbGetInputlstPointY().size(), bbGetInputlstPointZ().size() );
                }// size X Y Z
        } // if Active
-
 }
 
 void DrawAxisTree3D::bbUserSetDefaultValues()
index 618488f93713d78c071fbc30f56c31c3806c83cb..42b8651bc6ebbdc11f01436c6df7ae6d04269f05 100644 (file)
@@ -97,7 +97,6 @@ void wxVtk2DBaseView::TransformCoordinate_spacing_ModelToView(double &X,double &
 //-------------------------------------------------------------------
 void wxVtk2DBaseView::ResetView()
 {
-       printf("EED wxVtk2DBaseView::ResetView Start\n");
        double spx = 0,spy = 0,spz = 0;
        int x1 = 1,x2 = 1,y1 = 1,y2 = 1,z1 = 1,z2 = 1;
        wxVtkBaseView::Configure();
@@ -117,7 +116,6 @@ void wxVtk2DBaseView::ResetView()
                imageData->GetSpacing (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");
 }
 
 //-------------------------------------------------------------------