X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvLandmarks.cxx;h=dc38cd228f69b27981960e24b220bf3fafa5c4eb;hb=2d5b3631dbb64aaf5868d90ac9b1006dd7f4dcef;hp=0b5f98a264886c6b11bad1e6a0a488d1557511cd;hpb=8410a88a08678a4b2e026b5bc2c61adaef763c05;p=clitk.git diff --git a/vv/vvLandmarks.cxx b/vv/vvLandmarks.cxx index 0b5f98a..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) { @@ -143,6 +179,17 @@ void vvLandmarks::RemoveLandmark(int index) } //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +void vvLandmarks::RemoveAll() +{ + for (unsigned int i = 0; i < mLandmarks.size(); i++) { + mLandmarks[i].clear(); + mPoints[i]->SetNumberOfPoints(0); + mLabels[i]->SetNumberOfValues(0); + mIds[i]->SetNumberOfValues(0); + } +} +//-------------------------------------------------------------------- //-------------------------------------------------------------------- void vvLandmarks::ChangeComments(int index, std::string comments) @@ -440,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; } }