]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewBaseContour.cpp
#3058 creaMaracasVisu Feature New Normal - optimizing of manualContourView of a...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualViewBaseContour.cpp
index 1e765740c51f3cc035f42b6b24d34d0fb312e66b..91f1c1bb14a24c7f80c6167217f5a82daa53a6a8 100644 (file)
@@ -113,7 +113,9 @@ void manualViewBaseContour :: AddCompleteContourActor(  bool ifControlPoints )
 
         //Adding each control point
         if( ifControlPoints )
+        {
                AddControlPoints();
+        }
         RefreshContour();
         Refresh();
 }
@@ -275,7 +277,8 @@ void manualViewBaseContour::ConstructVTKObjects()
        DeleteVtkObjects();
        _pts = vtkPoints::New();
        _pts->SetNumberOfPoints(nps);
-       for (i=0 ; i<nps ; i++){
+       for (i=0 ; i<nps ; i++)
+       {
                _pts->SetPoint(i,       0       , 0     , 0 );
        }
        // This is for the boundaring inicialisation
@@ -286,15 +289,25 @@ void manualViewBaseContour::ConstructVTKObjects()
        _pts->SetPoint(0,       -1000   , -1000 , -1000 );
        _pts->SetPoint(1,       1000    , 1000  , 1000  );
 
-       vtkCellArray *lines = vtkCellArray::New();
-       lines->InsertNextCell( nps /* +1 */ );
-       for ( i=0 ; i<nps+1 ; i++ ){
-               lines->InsertCellPoint(i % nps );
+       // This is the structure for the spline
+       _splineCell = vtkCellArray::New();
+       _splineCell->InsertNextCell( nps /* +1 */ );
+       for ( i=0 ; i<nps+1 ; i++ )
+       {
+               _splineCell->InsertCellPoint(i % nps );
        }
+
+       // This is the structure for the spline justo to points (line)
+       // This will be use in the refresh part, in case the spline have only 2 points
+       _lineCell = vtkCellArray::New();
+       _lineCell->InsertNextCell(2);
+       _lineCell->InsertCellPoint(0);
+       _lineCell->InsertCellPoint(1);
+
        _pd = vtkPolyData::New();
        _pd->SetPoints( _pts );
-       _pd->SetLines( lines );
-       lines->Delete();  //do not delete lines ??
+       _pd->SetLines( _splineCell );
+       // lines->Delete();  //do not delete lines ??
 
        _contourVtkActor        =       vtkActor::New();
     _bboxMapper                        =       vtkPolyDataMapper::New();
@@ -312,6 +325,16 @@ void manualViewBaseContour::ConstructVTKObjects()
        InitTextActor();
 }
 
+void manualViewBaseContour::SetCellArray(bool type)
+{
+       if (type==true)
+       {
+               _pd->SetLines( _splineCell );
+       } else {
+               _pd->SetLines( _lineCell );
+       }// if type
+}
+
 // ----------------------------------------------------------------------------
 void manualViewBaseContour::InitTextActor()
 {
@@ -653,7 +676,8 @@ double* manualViewBaseContour::GetVectorPointsZManualContour()
 // ----------------------------------------------------------------------------
 void manualViewBaseContour::Refresh() // virtual
 {
-       if (_contourVtkActor!=NULL){
+       if (_contourVtkActor!=NULL)
+       {
                RefreshContour();
        }
        int i,size=_lstViewPoints.size();