MCPcopy Create free account
hub / github.com/Kitware/VTK / InsertHandleOnLine

Method InsertHandleOnLine

Interaction/Widgets/vtkPolyLineRepresentation.cxx:292–340  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

290
291//------------------------------------------------------------------------------
292int vtkPolyLineRepresentation::InsertHandleOnLine(double* pos)
293{
294 if (this->NumberOfHandles < 2)
295 {
296 return -1;
297 }
298
299 vtkIdType id = this->LinePicker->GetCellId();
300
301 vtkNew<vtkPoints> newpoints;
302 newpoints->SetDataType(VTK_DOUBLE);
303 newpoints->SetNumberOfPoints(this->NumberOfHandles + 1);
304
305 int insert_index = -1;
306 if (id == -1)
307 {
308 // not on a line, add to the end
309 for (int i = 0; i < this->NumberOfHandles; ++i)
310 {
311 newpoints->SetPoint(i, this->PointHandles[i]->GetPosition());
312 }
313 newpoints->SetPoint(this->NumberOfHandles, pos);
314 insert_index = this->NumberOfHandles;
315 }
316 else
317 {
318 vtkIdType subid = this->LinePicker->GetSubId();
319
320 int istart = subid;
321 int istop = istart + 1;
322 int count = 0;
323 for (int i = 0; i <= istart; ++i)
324 {
325 newpoints->SetPoint(count++, this->PointHandles[i]->GetPosition());
326 }
327
328 insert_index = count;
329 newpoints->SetPoint(count++, pos);
330
331 for (int i = istop; i < this->NumberOfHandles; ++i)
332 {
333 newpoints->SetPoint(count++, this->PointHandles[i]->GetPosition());
334 }
335 }
336
337 this->InitializeHandles(newpoints);
338
339 return insert_index;
340}
341
342//------------------------------------------------------------------------------
343void vtkPolyLineRepresentation::InitializeHandles(vtkPoints* points)

Callers

nothing calls this directly

Calls 6

InitializeHandlesMethod · 0.95
GetCellIdMethod · 0.45
SetDataTypeMethod · 0.45
SetNumberOfPointsMethod · 0.45
SetPointMethod · 0.45
GetPositionMethod · 0.45

Tested by

no test coverage detected