X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvLandmarks.cxx;h=dc38cd228f69b27981960e24b220bf3fafa5c4eb;hb=7615e289788483e21028050638195e29c4e34321;hp=fed697ebc2a218943ac125b4676e15ac1f3afd70;hpb=cf891024f9fed4d9ee3eabf13f2114a1d724df43;p=clitk.git diff --git a/vv/vvLandmarks.cxx b/vv/vvLandmarks.cxx index fed697e..dc38cd2 100644 --- a/vv/vvLandmarks.cxx +++ b/vv/vvLandmarks.cxx @@ -23,6 +23,7 @@ #include #include +#include #include "vtkPolyData.h" #include "vtkPoints.h" #include "vtkFloatArray.h" @@ -117,6 +118,41 @@ void vvLandmarks::RemoveLastLandmark() //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +void vvLandmarks::RemoveLandmarkWithLabel(vtkStdString label, int time) +{ + if (label != "P1" && label != "P2") + return; + // erase a vtkPoint by shifiting the array . + // not a problem here because there are no + // pologyons linking the points + int t = time;//mLandmarks[index].coordinates[3]; + int npoints = mPoints[t]->GetNumberOfPoints(); + + //search of the index corresponding to the label + int index(0); + while (mLabels[t]->GetValue(index) != label) + ++index; + + for (int i = index; i < npoints - 1; i++) { + mPoints[t]->InsertPoint(i, mPoints[t]->GetPoint(i+1)); + std::string str_i; // string which will contain the result + std::ostringstream convert; // stream used for the conversion + convert << i; // insert the textual representation of 'i' in the characters in the stream + str_i = convert.str(); // set 'str_i' to the contents of the stream + mLabels[t]->SetValue(i,mLabels[t]->GetValue(i+1)); + } + mPoints[t]->SetNumberOfPoints(npoints-1); + mLabels[t]->SetNumberOfValues(npoints-1); + mLabels[t]->Modified(); + mPolyData->Modified(); + + mLandmarks[t].erase(mLandmarks[t].begin() + index); + mIds[t]->RemoveLastTuple(); +} +//-------------------------------------------------------------------- + + //-------------------------------------------------------------------- void vvLandmarks::RemoveLandmark(int index) { @@ -451,7 +487,11 @@ void vvLandmarks::SetTime(int time) mPolyData->GetPointData()->SetScalars(mIds[time]); mPolyData->GetPointData()->AddArray(mLabels[time]); mPolyData->Modified(); +#if VTK_MAJOR_VERSION <= 5 mPolyData->Update(); +#else + //mPolyData->Update(); +#endif mTime = time; } }