X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=bbtk%2Fsrc%2FbbmaracasvisuDrawAxisTree3D.cxx;h=45ec0b7d52bf1de570da9ba36a9a9a416a08b0c8;hb=39ac649f6a07b1646505a9d8c418f72bd76fc64e;hp=cdabc926eb9d63c2f1f361366b2e452b1a8d9350;hpb=273a38f26a7d720f1282f96b33e48781cce3baad;p=creaMaracasVisu.git diff --git a/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx b/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx index cdabc92..45ec0b7 100644 --- a/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx +++ b/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx @@ -27,6 +27,13 @@ #include "bbcreaMaracasVisuPackage.h" #include "vtkLinearTransform.h" +#include "vtkUnsignedCharArray.h" +#include "vtkCellData.h" +#include "vtkPolyLine.h" +#include "vtkLine.h" + + + namespace bbcreaMaracasVisu { @@ -41,7 +48,14 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis) vtkPolyDataMapper *polydatamapper = vtkPolyDataMapper::New(); vtkActor *vtkactor = vtkActor::New(); +// polydatamapper->ScalarVisibilityOff(); +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 polydatamapper->SetInput(polydata); +#else + polydatamapper->SetInputData(polydata); + polydatamapper->Update(); +#endif vtkactor->SetMapper(polydatamapper); vecVtkPolyData.push_back( polydata ); @@ -60,8 +74,9 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis) if( lstpointsXsize>0 ){ vtkPoints* allPoints = vtkPoints::New( ); +vtkPolyLine *polyline = vtkPolyLine::New(); vtkCellArray* allTopology = vtkCellArray::New( ); - allTopology->InsertNextCell( numPoints ); +// allTopology->InsertNextCell( numPoints ); size=iGeneral+numPoints; for (i=iGeneral;i %f, %f, %f \n", i, bbGetInputlstPointX()[i], bbGetInputlstPointY()[i], bbGetInputlstPointZ()[i] ); - allTopology->InsertCellPoint( i-iGeneral ); + +polyline->GetPointIds()->InsertNextId(i-iGeneral); + +// allTopology->InsertCellPoint( i-iGeneral ); } // rof + allTopology->InsertNextCell(polyline); + + // create cell array for edges + 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( allTopology ); + polydata->SetLines(edges); +// polydata->SetLines( allTopology ); + + + // polydata->SetPolys( allTopology ); + + edges->Delete(); allPoints->Delete(); allTopology->Delete(); } @@ -83,18 +125,52 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis) // color double r,g,b; - if ( (iAxis*3+1) < (int)(bbGetInputColour().size()) ) + if (bbGetInputColourLaw()==1) // the same color for all + { + r = bbGetInputColour()[0]; + g = bbGetInputColour()[1]; + b = bbGetInputColour()[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]; - } else { + } else { r = (rand() % 100) / 100.0; g = (rand() % 100) / 100.0; b = (rand() % 100) / 100.0; - } + } + vtkactor->GetProperty()->SetColor( r,g,b ); + } // Law 2 color for each segment + + if (bbGetInputColourLaw()==3) // color for each point + { + // Setup the colors array + vtkUnsignedCharArray *colors = vtkUnsignedCharArray::New(); + colors->SetNumberOfComponents(3); + colors->SetName("Colors"); +// colors->SetName("vertex color"); + int iPoint,pointSize=iGeneral+numPoints; + + + for (iPoint=iGeneral; iPointSetTuple3(iPoint,r,g,b); + colors->InsertNextTuple3(r,g,b); + } + polydata->GetCellData()->SetScalars(colors); + polydata->Modified(); + + } // Law 3 color for each point - vtkactor->GetProperty()->SetColor( r,g,b ); vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() ); vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() ); @@ -108,21 +184,27 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis) { bbGetInputRenderer()->AddActor( vtkactor ); } + } void DrawAxisTree3D::Process() { - printf("EED DrawAxisTree3D::Process start \n"); int iGeneral=0; - int iAxis,sizeLstAxis=bbGetInputlstIndexs().size(); + std::vector lstIndexs = bbGetInputlstIndexs(); + if ( bbGetInputlstIndexs().size()==0 ) + { + lstIndexs.push_back( bbGetInputlstPointX().size() ); + } // if + int iAxis,sizeLstAxis=lstIndexs.size(); int iActor,sizeActors = vecVtkActors.size(); int numPoints; - if (oldLstSize!=sizeLstAxis) - { - oldLstSize=sizeLstAxis; + +// if (oldLstSize!=sizeLstAxis) +// { +// oldLstSize=sizeLstAxis; for (iActor=0 ; iActorDelete(); vecVtkPolyDataMaper[iActor]->Delete(); vecVtkActors[iActor]->Delete(); - } - } + } // if + } // for iActor vecVtkPolyData.clear(); vecVtkPolyDataMaper.clear(); vecVtkActors.clear(); + for ( iAxis=0 ; iAxisGetProperty()->SetOpacity( bbGetInputOpacity() ); + vecVtkActors[iActor]->GetProperty()->SetLineWidth( bbGetInputLineWidth() ); } - } - - printf("EED DrawAxisTree3D::Process end \n"); +// } // if oldLstSize } @@ -203,6 +286,7 @@ void DrawAxisTree3D::bbUserSetDefaultValues() bbSetInputOpacity(1); bbSetInputLineWidth(0.5); bbSetInputColourLaw(1); + bbSetInputTransform(NULL); }