Commit a4fdc6e1 authored by Sreekanth Arikatla's avatar Sreekanth Arikatla
Browse files

Merge branch 'clearBugDbgRenderLines' into 'master'

BUG: Use vtkPolyData instead of vtkPolyLine for VTKdbgLinesRenderDelegate

See merge request iMSTK/iMSTK!325
parents 4ece7524 114d5624
Pipeline #139790 passed with stage
in 0 seconds
...@@ -64,11 +64,17 @@ int main() ...@@ -64,11 +64,17 @@ int main()
scene->addDebugGeometry(debugTriangleGeo); scene->addDebugGeometry(debugTriangleGeo);
// Create debug Lines // Create debug Lines
auto debugLinesGeo = std::make_shared<DebugRenderLines>("debugLines", 2); auto debugLinesGeo = std::make_shared<DebugRenderLines>("debugLines");
StdVectorOfVec3d linesVerts; StdVectorOfVec3d linesVerts;
linesVerts.push_back(Vec3d(0, 0, 0)); linesVerts.push_back(Vec3d(15, 0, 0));
linesVerts.push_back(Vec3d(100, 100, 100)); linesVerts.push_back(Vec3d(100, 0, 0));
linesVerts.push_back(Vec3d(0, 15, 0));
linesVerts.push_back(Vec3d(0, 100, 0));
linesVerts.push_back(Vec3d(0, 0, 15));
linesVerts.push_back(Vec3d(0, 0, 100));
debugLinesGeo->setVertexData(linesVerts); debugLinesGeo->setVertexData(linesVerts);
......
...@@ -30,10 +30,10 @@ limitations under the License. ...@@ -30,10 +30,10 @@ limitations under the License.
#include <vtkCellArray.h> #include <vtkCellArray.h>
#include <vtkFloatArray.h> #include <vtkFloatArray.h>
#include <vtkPointData.h> #include <vtkPointData.h>
#include <vtkPolyLine.h>
#include <vtkProperty.h> #include <vtkProperty.h>
#include <vtkOpenGLPolyDataMapper.h> #include <vtkOpenGLPolyDataMapper.h>
#include <vtkTrivialProducer.h> #include <vtkTrivialProducer.h>
#include <vtkLine.h>
namespace imstk namespace imstk
{ {
...@@ -47,29 +47,30 @@ VTKdbgLinesRenderDelegate::VTKdbgLinesRenderDelegate(std::shared_ptr<DebugRender ...@@ -47,29 +47,30 @@ VTKdbgLinesRenderDelegate::VTKdbgLinesRenderDelegate(std::shared_ptr<DebugRender
double* vertData = reinterpret_cast<double*>(triVertData.data()); double* vertData = reinterpret_cast<double*>(triVertData.data());
m_mappedVertexArray->SetArray(vertData, triVertData.size() * 3, 1); m_mappedVertexArray->SetArray(vertData, triVertData.size() * 3, 1);
// Create lines polydata
auto linesPolyData = vtkSmartPointer<vtkPolyData>::New();
// Create points // Create points
auto points = vtkSmartPointer<vtkPoints>::New(); auto points = vtkSmartPointer<vtkPoints>::New();
points->SetNumberOfPoints(triVertData.size()); points->SetNumberOfPoints(triVertData.size());
points->SetData(m_mappedVertexArray); points->SetData(m_mappedVertexArray);
linesPolyData->SetPoints(points);
// Create cells // Create cells
auto polyLine = vtkSmartPointer<vtkPolyLine>::New(); auto lines = vtkSmartPointer<vtkCellArray>::New();
polyLine->GetPointIds()->SetNumberOfIds(triVertData.size()); for (unsigned int i = 0; i < triVertData.size() - 1; i += 2)
for (unsigned int i = 0; i < triVertData.size(); ++i)
{ {
polyLine->GetPointIds()->SetId(i, i); auto l = vtkSmartPointer<vtkLine>::New();
} l->GetPointIds()->SetId(0, i);
auto cells = vtkSmartPointer<vtkCellArray>::New(); l->GetPointIds()->SetId(1, i + 1);
cells->InsertNextCell(polyLine);
// Create PolyData lines->InsertNextCell(l);
auto polydata = vtkSmartPointer<vtkPolyData>::New(); }
polydata->SetPoints(points); linesPolyData->SetLines(lines);
polydata->SetLines(cells);
// Create connection source // Create connection source
auto source = vtkSmartPointer<vtkTrivialProducer>::New(); auto source = vtkSmartPointer<vtkTrivialProducer>::New();
source->SetOutput(polydata); source->SetOutput(linesPolyData);
m_Lines->setDataModifiedFlag(false); m_Lines->setDataModifiedFlag(false);
// Update Transform, Render Properties // Update Transform, Render Properties
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment