I 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, related post: The Interfaces In VTK Can’t Be Used With Webassembly. After reading the source code of vtkOrientedGlyphContourRepresentation::vtkOrientedGlyphContourRepresentation(), we know that LinesMapper, ActiveMapper, and Mapper had SetResolveCoincidentTopologyToPolygonOffset. So we have to create a child class of vtkOrientedGlyphContourRepresentation to change these mappers’ properties.

#define vSP vtkSmartPointer    
#define vSPNew(Var, Type)    vSP<Type> Var = vSP<Type>::New();

int myOrientedGlyphContourRepresentation::RenderOpaqueGeometry(vtkViewport *viewport)
//...
    //if (this->ShowSelectedNodes && this->SelectedNodesActor &&
    //    this->SelectedNodesActor->GetVisibility())
    //{
    //    count += this->SelectedNodesActor->RenderOpaqueGeometry(viewport);
    //}
     return count;
}

myOrientedGlyphContourRepresentation::BuildRepresentation()
//...
#ifndef __EMSCRIPTEN__
    //...
    this->ActiveMapper->SetRelativeCoincidentTopologyPolygonOffsetParameters(0, -66000);
    this->ActiveMapper->SetRelativeCoincidentTopologyPointOffsetParameter(-66000);
#else
    this->LinesMapper->SetResolveCoincidentTopologyToOff();
    this->ActiveMapper->SetResolveCoincidentTopologyToOff();
    this->Mapper->SetResolveCoincidentTopologyToOff();
    this->SelectedNodesMapper->SetResolveCoincidentTopologyToOff();
#endif

To make the widget’s line wider, we can use tube filter to process the data.

void myOrientedGlyphContourRepresentation::BuildRepresentation()
{
//...
    vSPNew( tubeFilter, vtkTubeFilter );
    tubeFilter->SetInputData( this->Lines );
    tubeFilter->SetRadius(0.5);
    tubeFilter->SetNumberOfSides(50);
    tubeFilter->Update();
    vSPNew( data, vtkPolyData );
    data->DeepCopy( tubeFilter->GetOutput() );
    this->LinesMapper->SetInputData( data );
Categories: VTK

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

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

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