/*!\file:  TriMeshProcessRifts.cpp
 * \brief split a mesh where a rift (or fault) is present
 */ 

#include "./TriMeshProcessRifts.h"

void TriMeshProcessRiftsUsage(void){/*{{{*/
	_printLine_("");
	_printLine_("   usage: [index2,x2,y2,segments2,segmentmarkers2,rifts2]=TriMeshProcessrifts(index1,x1,y1,segments1,segmentmarkers1) ");
	_printLine_("      where: (index1,x1,y1,segments1,segmentmarkers1) is an initial triangulation.");
	_printLine_("      index2,x2,y2,segments2,segmentmarkers2,rifts2 is the resulting triangulation where rifts have been processed.");
}/*}}}*/
WRAPPER(TriMeshProcessRifts){

	/* returned quantities: */
	RiftStruct *riftstruct = NULL;

	/* input: */
	int     nel,nods;
	double *index          = NULL;
	double *x              = NULL;
	double *y              = NULL;
	double *segments       = NULL;
	double *segmentmarkers = NULL;
	int     num_seg;

	/*Boot module*/
	MODULEBOOT();

	/*checks on arguments on the matlab side: */
	CHECKARGUMENTS(NLHS,NRHS,&TriMeshProcessRiftsUsage);

	/*Fetch data */
	FetchData(&index,&nel,NULL,INDEXIN);
	FetchData(&x,&nods,XIN);
	FetchData(&y,NULL,YIN);
	FetchData(&segments,&num_seg,NULL,SEGMENTSIN);
	FetchData(&segmentmarkers,NULL,SEGMENTMARKERSIN);

	/*call x layer*/
	TriMeshProcessRiftsx(&index,&nel,&x,&y,&nods,&segments,&segmentmarkers,&num_seg,&riftstruct);

	/*Output : */
	WriteData(INDEXOUT,index,nel,3);
	WriteData(XOUT,x,nods,1);
	WriteData(YOUT,y,nods,1);
	WriteData(SEGMENTSOUT,segments,num_seg,3);
	WriteData(SEGMENTMARKERSOUT,segmentmarkers,num_seg,1);
	WriteData(RIFTSTRUCT,riftstruct);

	/*end module: */
	MODULEEND();
}
