12 #include <boost/cstdint.hpp>
15 #include <vtkPolyData.h>
16 #include <vtkAppendPolyData.h>
17 #include <vtkConeSource.h>
18 #include <vtkCylinderSource.h>
22 #include <vtkClipPolyData.h>
33 Eigen::Array2i extent = frameSize - 1;
36 Vector3D imageSpacing(width/extent[0], depth/extent[1], 1.0);
40 retval.
setSize(QSize(frameSize[0], frameSize[1]));
53 retval->setProbeSector(probeDefinition);
54 retval->setVisible(
true);
55 retval->startTracking(30);
63 int DummyTool::mTransformCount = 0;
71 mTransformSaveFileName(
"DummyToolsAreToDumbToSaveThemselves"),
75 qRegisterMetaType<Transform3D>(
"Transform3D");
83 connect(mTimer.get(), SIGNAL(timeout()),
this, SLOT(sendTransform()));
112 mTransforms = positions;
123 mTransformSaveFileName = filename;
141 connect(mThread, SIGNAL(ping()),
this, SLOT(sendTransform()));
156 void DummyTool::stopThread()
162 disconnect(mThread, SIGNAL(ping()),
this, SLOT(sendTransform()));
167 if (mThread->isRunning())
169 mThread->terminate();
190 void DummyTool::sendTransform()
201 vtkPolyDataPtr DummyTool::createPolyData(
double h1,
double h2,
double r1,
double r2)
212 plane->SetNormal(0,0,-1);
213 plane->SetOrigin(0,0,-h2);
216 double h1_extension = h1*r2 / (r1-r2);
217 double h1_mod = h1+h1_extension;
218 cone1->SetResolution(50);
219 cone1->SetRadius(r1);
220 cone1->SetHeight(h1_mod);
221 cone1->SetDirection(0,0,1);
222 double center1 = -h1/2-h2+h1_extension/2;
223 cone1->SetCenter(
Vector3D(0,0,center1).begin());
226 clipper1->SetInputConnection(cone1->GetOutputPort());
227 clipper1->SetClipFunction(plane);
230 cone2->SetResolution(25);
231 cone2->SetRadius(r2);
232 cone2->SetHeight(h2);
233 cone2->SetDirection(0,0,1);
234 double center2 = -h2/2;
237 assembly->AddInputConnection(clipper1->GetOutputPort());
238 assembly->AddInputConnection(cone2->GetOutputPort());
241 return assembly->GetOutput();
247 unsigned N = unsigned(std::lround(((b-a).
length()/step)));
250 for (
unsigned i=0; i<N; ++i)
254 retval->push_back(T * R);
260 std::vector<Transform3D> DummyTool::createToolPositionMovement(
const DoubleBoundingBox3D& bb)
const
263 std::vector<Transform3D> retval;
283 double step = *std::max_element(range.begin(), range.end()) / steps;
289 createLinearMovement(&retval, &T, R, a, b, step);
291 for (
unsigned i=0; i<50; ++i)
295 retval.push_back(T * R);
298 createLinearMovement(&retval, &T, R, b, c, step);
300 for (
unsigned i=0; i<50; ++i)
304 retval.push_back(T * R);
307 createLinearMovement(&retval, &T, R, c, d, step);
308 createLinearMovement(&retval, &T, R, d, a, step);
310 for (
unsigned i=0; i<20; ++i)
314 retval.push_back(T * R);
324 std::vector<Transform3D> retval;
338 double step = *std::max_element(range.begin(), range.end()) / steps;
344 createLinearMovement(&retval, &T, R, a, b, step);
345 createLinearMovement(&retval, &T, R, b, c, step);
346 createLinearMovement(&retval, &T, R, c, d, step);
347 createLinearMovement(&retval, &T, R, d, a, step);
355 if(mTransformCount >=
int(mTransforms.size()))
358 return &mTransforms.at(mTransformCount++);