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

Function IntersectWithCell

Common/DataModel/Testing/Cxx/quadraticIntersection.cxx:76–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76void IntersectWithCell(unsigned nTest, vtkMinimalStandardRandomSequence* sequence,
77 bool threeDimensional, double radius, double* offset, vtkCell* cell,
78 vtkSmartPointer<vtkRenderWindow> renderWindow)
79{
80 double p[2][3];
81 p[0][2] = p[1][2] = 0.;
82 double tol = 1.e-7;
83 double t;
84 double intersect[3];
85 double pcoords[3];
86 int subId;
87
88 auto points = vtkSmartPointer<vtkPoints>::New();
89 auto vertices = vtkSmartPointer<vtkCellArray>::New();
90
91 for (unsigned i = 0; i < nTest; i++)
92 {
93 if (threeDimensional)
94 {
95 RandomSphere(sequence, radius, offset, p[0]);
96 RandomSphere(sequence, radius, offset, p[1]);
97 }
98 else
99 {
100 RandomCircle(sequence, radius, offset, p[0]);
101 RandomCircle(sequence, radius, offset, p[1]);
102 }
103
104 if (cell->IntersectWithLine(p[0], p[1], tol, t, intersect, pcoords, subId))
105 {
106 vtkIdType pid = points->InsertNextPoint(intersect);
107 vertices->InsertNextCell(1, &pid);
108 }
109 }
110
111 auto camera = vtkSmartPointer<vtkCamera>::New();
112 camera->SetPosition(2, 2, 2);
113 camera->SetFocalPoint(offset[0], offset[1], offset[2]);
114
115 auto renderer = vtkSmartPointer<vtkRenderer>::New();
116 renderer->SetActiveCamera(camera);
117 renderWindow->AddRenderer(renderer);
118 double dim[4];
119 static int testNum = 0;
120 ViewportRange(testNum++, dim);
121 renderer->SetViewport(dim[0], dim[2], dim[1], dim[3]);
122
123 auto point = vtkSmartPointer<vtkPolyData>::New();
124
125 point->SetPoints(points);
126 point->SetVerts(vertices);
127
128 auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
129 mapper->SetInputData(point);
130
131 auto actor = vtkSmartPointer<vtkActor>::New();
132 actor->SetMapper(mapper);
133 renderer->AddActor(actor);

Callers 1

TestIntersectWithLineFunction · 0.70

Calls 15

SetActiveCameraMethod · 0.80
SetVertsMethod · 0.80
RandomSphereFunction · 0.70
RandomCircleFunction · 0.70
ViewportRangeFunction · 0.70
RenderMethod · 0.65
NewFunction · 0.50
IntersectWithLineMethod · 0.45
InsertNextPointMethod · 0.45
InsertNextCellMethod · 0.45
SetPositionMethod · 0.45
SetFocalPointMethod · 0.45

Tested by 1

TestIntersectWithLineFunction · 0.56