From: ctorres Date: Fri, 13 Jun 2014 09:49:59 +0000 (+0200) Subject: Validation in the begining of funtion X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=34a9a0af17078bc3d7c5155aa72721d8248b4b71;p=creaMaracasVisu.git Validation in the begining of funtion --- diff --git a/bbtk/src/bbmaracasvisuShowNPoints.cxx b/bbtk/src/bbmaracasvisuShowNPoints.cxx index b9d212e..06f5f68 100644 --- a/bbtk/src/bbmaracasvisuShowNPoints.cxx +++ b/bbtk/src/bbmaracasvisuShowNPoints.cxx @@ -333,81 +333,86 @@ double WidgetShowNPoints::Distance(double dX0, double dY0, double dZ0, double dX void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT { std::cout<<"WidgetShowNPoints::InsertPoint begin "< dTotal; - int pos = 0; - int a,b,res; - //Calcule distance for each pair of points - for(int i = 0; i::iterator it; - //Insert the point in the list of points - it = lstPointsX.begin(); - lstPointsX.insert( it+pos, x ); - it = lstPointsY.begin(); - lstPointsY.insert( it+pos, y ); - it = lstPointsZ.begin(); - lstPointsZ.insert( it+pos, z ); - std::string strLabel = CleanSpaces( label ); + if(lstPointsX.size()>1) + { + std::vector dTotal; + int pos = 1; + int a,b,res; + + //Calcule distance for each pair of points + for(int i = 0; i::iterator it; + //Insert the point in the list of points + it = lstPointsX.begin(); + lstPointsX.insert( it+pos, x ); + it = lstPointsY.begin(); + lstPointsY.insert( it+pos, y ); + it = lstPointsZ.begin(); + lstPointsZ.insert( it+pos, z ); + + std::string strLabel = CleanSpaces( label ); - std::vector::iterator itS; - itS = lstLabels.begin(); - //Insert Label in list of labels - lstLabels.insert( itS+pos, strLabel ); - - // Sphere - vtkSphereSource *vtksphere = vtkSphereSource::New(); - vtksphere->SetThetaResolution (20); - vtksphere->SetPhiResolution (20); - vtksphere->SetRadius( mradio ); - - //NTU: For updating points - std::vector::iterator itSS; - itSS = lstSourceSphere.begin(); - lstSourceSphere.insert( itSS+pos, vtksphere); - - vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New(); - sphereMapper->SetInput( vtksphere->GetOutput() ); - vtkActor *sphereActor = vtkActor::New(); - sphereActor->SetMapper(sphereMapper); - sphereActor->SetOrigin(0, 0, 0); - - std::vector::iterator itAS; - itAS = lstActorsSphere.begin(); - lstActorsSphere.insert( itAS+pos, sphereActor); - if(renderer==NULL){ - wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR); - dialog.ShowModal(); - return; - } - renderer->AddActor( sphereActor ); + std::vector::iterator itS; + itS = lstLabels.begin(); + //Insert Label in list of labels + lstLabels.insert( itS+pos, strLabel ); + + // Sphere + vtkSphereSource *vtksphere = vtkSphereSource::New(); + vtksphere->SetThetaResolution (20); + vtksphere->SetPhiResolution (20); + vtksphere->SetRadius( mradio ); + + //NTU: For updating points + std::vector::iterator itSS; + itSS = lstSourceSphere.begin(); + lstSourceSphere.insert( itSS+pos, vtksphere); + + vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New(); + sphereMapper->SetInput( vtksphere->GetOutput() ); + vtkActor *sphereActor = vtkActor::New(); + sphereActor->SetMapper(sphereMapper); + sphereActor->SetOrigin(0, 0, 0); + + std::vector::iterator itAS; + itAS = lstActorsSphere.begin(); + lstActorsSphere.insert( itAS+pos, sphereActor); + if(renderer==NULL){ + wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR); + dialog.ShowModal(); + return; + } + renderer->AddActor( sphereActor ); - // Actor - vtkTextActor3D *textActor = vtkTextActor3D::New(); + // Actor + vtkTextActor3D *textActor = vtkTextActor3D::New(); - textActor->SetInput( strLabel.c_str() ); - renderer->AddActor( textActor ); - std::vector::iterator itTA; - itTA = lstActorsText.begin(); - lstActorsText.insert( itTA+pos , textActor); + textActor->SetInput( strLabel.c_str() ); + renderer->AddActor( textActor ); + std::vector::iterator itTA; + itTA = lstActorsText.begin(); + lstActorsText.insert( itTA+pos , textActor); - RefreshPoint(pos); + RefreshPoint(pos); + }//end if std::cout<<"WidgetShowNPoints::InsertPoint end"<