-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathvtkTEMPLATE.cxx
executable file
·37 lines (28 loc) · 1.51 KB
/
vtkTEMPLATE.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "structToVtk.h"
#include "vtkToStruct.h"
/* MATLAB entry function
* nlhs/nrhs contain the number of left/right-hand-side arguments to this function
* plhs/prhs are arrays of pointers to the arguments in MATLAB data format */
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
///// Parse inputs /////
const std::string syntax = "outStruct = vtkTEMPLATE(inStruct)";
if(nrhs < 1)
mexErrMsgTxt(("Not enough input arguments. Syntax: " + syntax).c_str());
if(nrhs > 1)
mexErrMsgTxt(("Too many input arguments. Syntax: " + syntax).c_str());
if(nlhs > 1)
mexErrMsgTxt(("Too many output arguments. Syntax: " + syntax).c_str());
///// Convert MATLAB struct into vtkPointSet /////
vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
vtkSmartPointer<vtkUnstructuredGrid> unstructuredGrid = vtkSmartPointer<vtkUnstructuredGrid>::New();
vtkPointSet* pointSet = structToVtk(prhs[0], polyData, unstructuredGrid, false);
///// Apply operations to pointSet /////
// if(pointSet->GetDataObjectType() != VTK_POLY_DATA)
// mexErrMsgTxt("vtkLinearSubdivisionFilter requires poly data as input. Incompatible cell(s) found.");
// vtkSmartPointer<vtkTEMPLATE> TEMPLATE = vtkSmartPointer<vtkTEMPLATE>::New();
// TEMPLATE->SetInputData(pointSet);
// TEMPLATE->Update();
///// Convert vtkPointSet into MATLAB struct /////
plhs[0] = vtkToStruct(TEMPLATE->GetOutput(), false);
}