Jumping into vtk.js

pload ALL
pload VIS
ivtkinit
ivtkdisplay <shape>
ivtksetdispmode <shape> 1
ivtksetselmode <shape> 4 on
Render OpenCascade shapes with VTK on desktop.
void IVtkDraw::Commands (Draw_Interpretor& theCommands)
{
...

// Add this:
theCommands.Add("ivtkdumpvtp",
"ivtkdumpvtp name filename",
__FILE__, VtkDumpVtp, group);

...
}
#include <vtkXMLPolyDataWriter.h>

static int VtkDumpVtp(Draw_Interpretor&,
int argc,
const char** argv)
{
if ( !GetInteractor() || !GetInteractor()->IsEnabled() )
{
std::cout << "Error: call ivtkinit before." << std::endl;
return 1;
}

// Get the actor in question.
vtkSmartPointer<vtkActor> actor;
if ( !GetMapOfActors().Find2(argv[1], actor) )
{
std::cout << "Cannot find actor with name '" << argv[1] << "'." << std::endl;
return 1; // Error.
}

// Update mapper to actualize the state of data set.
actor->GetMapper()->Update();

// Get data from mapper.
vtkPolyData* pData = vtkPolyData::SafeDownCast( actor->GetMapper()->GetInput() );

// Dump to file.
vtkSmartPointer<vtkXMLPolyDataWriter>
writer = vtkSmartPointer<vtkXMLPolyDataWriter>::New();
//
writer->SetFileName(argv[2]);
writer->SetInputData(pData);
writer->Write();

return 0;
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store