I can’t display vtkContourWidget object on web page by wasm file.
The following code snippet is very simple, create a circle and show it, we can modify it by vtkContourWidget object.
The example works in CPlusCPlus program.
VTK version: 9.0.2.

    vSP<vtkContourWidget> m_ContourWidget = vSP<vtkContourWidget>::New();

    // ...

    // Override the default representation for the contour widget to customize its look
    vtkSmartPointer<vtkOrientedGlyphContourRepresentation> contourRepresentation =
        vtkSmartPointer<vtkOrientedGlyphContourRepresentation>::New();
    contourRepresentation->GetLinesProperty()->SetColor(1, 0, 0); // Set color to red
    m_ContourWidget->SetRepresentation(contourRepresentation);

    // Generate a set of points arranged in a circle
    int numPts = 10;
    vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
    int offset = numPts / 4;
    for (int i = 0; i < numPts; i++)
    {
        // Create numPts points evenly spread around a circumference of radius 0.1
        const double angle = 2.0*vtkMath::Pi()*(i - offset)/numPts;
        points->InsertPoint(static_cast<vtkIdType>(i), 0.1*cos(angle), 0.1*sin(angle), 0.0 );
    }

    // Create a cell array to connect the points into meaningful geometry
    vtkIdType* vertexIndices = new vtkIdType[numPts];
    for (int i = 0; i < numPts; i++) { vertexIndices[i] = static_cast<vtkIdType>(i); }

    vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
    lines->InsertNextCell(numPts, vertexIndices);

    // Create polydata to hold the geometry just created, and populate it
    vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
    polydata->SetPoints(points);
    polydata->SetLines(lines);
    polydata->Modified();

    LOG( INFO, "polyData cells: ", polydata->GetNumberOfCells() );

    // Set up the contour widget within the visualization pipeline just assembled
    m_ContourWidget->SetInteractor( Getm_RenderWindow()->GetInteractor() );
    m_ContourWidget->On(); // Turn on the interactor observer
    m_ContourWidget->Initialize(polydata);

But it will crash on our web page.

Output:

ERROR: In /work/vtk/Rendering/OpenGL2/vtkShaderProgram.cxx, line 453 UDataModel.js:2612:16
vtkShaderProgram (0x77818c0): ERROR: 0:113: '/' : wrong operand types - no operation '/' exists that takes a left-hand operand of type 'highp float' and a right operand of type 'const int' (or there is no acceptable conversion) UDataModel.js:2612:16
<empty string> 2 UDataModel.js:2612:16
exception thrown: RuntimeError: index out of bounds,vtkOpenGLPolyDataMapper::UpdateShaders(vtkOpenGLHelper&, vtkRenderer*, vtkActor*)@http://localhost:4000/UDataModel.wasm:wasm-function[9523]:0x4f7d9c
vtkOpenGLPolyDataMapper::RenderPieceDraw(vtkRenderer*, vtkActor*)@http://localhost:4000/UDataModel.wasm:wasm-function[9531]:0x4fac50
vtkOpenGLPolyDataMapper::RenderPiece(vtkRenderer*, vtkActor*)@http://localhost:4000/UDataModel.wasm:wasm-function[9533]:0x4fafdc
vtkPolyDataMapper::Render(vtkRenderer*, vtkActor*)@http://localhost:4000/UDataModel.wasm:wasm-function[7361]:0x47d4aa
vtkOpenGLActor::Render(vtkRenderer*, vtkMapper*)@http://localhost:4000/UDataModel.wasm:wasm-function[8925]:0x4b7eeb
vtkActor::RenderOpaqueGeometry(vtkViewport*)@http://localhost:4000/UDataModel.wasm:wasm-function[6853]:0x45d8f6
vtkOrientedGlyphContourRepresentation::RenderOpaqueGeometry(vtkViewport*)@http://localhost:4000/UDataModel.wasm:wasm-function[15628]:0x6becc6
vtkProp::RenderFilteredOpaqueGeometry(vtkViewport*, vtkInformation*)@http://localhost:4000/UDataModel.wasm:wasm-function[7440]:0x47f7ea
vtkDefaultPass::RenderFilteredOpaqueGeometry(vtkRenderState const*)@http://localhost:4000/UDataModel.wasm:wasm-function[8902]:0x4b795a
vtkOpaquePass::Render(vtkRenderState const*)@http://localhost:4000/UDataModel.wasm:wasm-function[8917]:0x4b7c83
vtkSequencePass::Render(vtkRenderState const*)@http://localhost:4000/UDataModel.wasm:wasm-function[10331]:0x535961
vtkCameraPass::Render(vtkRenderState const*)@http://localhost:4000/UDataModel.wasm:wasm-function[8874]:0x4b69a7
vtkImageProcessingPass::RenderDelegate(vtkRenderState const*, int, int, int, int, vtkOpenGLFramebufferObject*, vtkTextureObject*)@http://localhost:4000/UDataModel.wasm:wasm-function[10298]:0x5335ed
vtkToneMappingPass::Render(vtkRenderState const*)@http://localhost:4000/UDataModel.wasm:wasm-function[10494]:0x53f8d6
vtkOpenGLRenderer::DeviceRender()@http://localhost:4000/UDataModel.wasm:wasm-function[9754]:0x50c586
vtkRenderer::Render()@http://localhost:4000/UDataModel.wasm:wasm-function[7983]:0x48dbb1
vtkRendererCollection::Render()@http://localhost:4000/UDataModel.wasm:wasm-function[8167]:0x493407
vtkRenderWindow::DoStereoRender()@http://localhost:4000/UDataModel.wasm:wasm-function[7662]:0x484d25
vtkRenderWindow::Render()@http://localhost:4000/UDataModel.wasm:wasm-function[7661]:0x484c00
vtkOpenGLRenderWindow::Render()@http://localhost:4000/UDataModel.wasm:wasm-function[9714]:0x509f63

It seems something wrong in shader logic which is in render process.
Then I tried vtkSplineWidget on web page, it also crashed.
It looks like all objects derived from vtkAbstractWidget will make web page crash.

exception thrown: RuntimeError: index out of bounds,vtkOpenGLPolyDataMapper::UpdateShaders(vtkOpenGLHelper&, vtkRenderer*, vtkActor*)@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[9532]:0x4f91d0
vtkOpenGLPolyDataMapper::RenderPieceDraw(vtkRenderer*, vtkActor*)@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[9540]:0x4fc084
vtkOpenGLPolyDataMapper::RenderPiece(vtkRenderer*, vtkActor*)@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[9542]:0x4fc410
vtkPolyDataMapper::Render(vtkRenderer*, vtkActor*)@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[7363]:0x47e0a7
vtkOpenGLActor::Render(vtkRenderer*, vtkMapper*)@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[8934]:0x4b931f
vtkActor::RenderOpaqueGeometry(vtkViewport*)@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[6854]:0x45e474
vtkProp::RenderFilteredOpaqueGeometry(vtkViewport*, vtkInformation*)@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[7442]:0x4803e7
vtkDefaultPass::RenderFilteredOpaqueGeometry(vtkRenderState const*)@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[8911]:0x4b8d8e
vtkOpaquePass::Render(vtkRenderState const*)@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[8926]:0x4b90b7
vtkSequencePass::Render(vtkRenderState const*)@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[10340]:0x536d95
vtkCameraPass::Render(vtkRenderState const*)@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[8883]:0x4b7ddb
vtkImageProcessingPass::RenderDelegate(vtkRenderState const*, int, int, int, int, vtkOpenGLFramebufferObject*, vtkTextureObject*)@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[10307]:0x534a21
vtkToneMappingPass::Render(vtkRenderState const*)@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[10503]:0x540d0a
vtkOpenGLRenderer::DeviceRender()@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[9763]:0x50d9ba
vtkRenderer::Render()@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[7985]:0x48e7ae
vtkRendererCollection::Render()@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[8169]:0x494004
vtkRenderWindow::DoStereoRender()@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[7664]:0x485922
vtkRenderWindow::Render()@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[7663]:0x4857fd
vtkOpenGLRenderWindow::Render()@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[9723]:0x50b397
vtkRenderWindowInteractor::Render()@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[7756]:0x487279
vtkSplineWidget::SetEnabled(int)@http://localhost:4000/UDesignCommonDataModel.wasm:wasm-function[16013]:0x6e2538

0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
trackback

[…] had found a crash bug when use vtkContourWidget by webassembly in the post Crash Bug About vtkOpenGLPolyDataMapper::UpdateShaders In vtkAbstractWidget. As we know, SetResolveCoincidentTopologyToPolygonOffset for mapper can make web page crash, […]

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X
1
0
Would love your thoughts, please comment.x
()
x