Example #1
0
void
reduce_v(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[])
{
	dd_ErrorType err;
	dd_MatrixPtr V,V1;
	dd_rowset red;
	
	if (nrhs  == 1 && nlhs >= 1 && nlhs <= 2 && mxIsStruct(prhs[0])) {
		dd_set_global_constants();  /* First, this must be called. */
		V = FT_get_V_MatrixPtr(prhs[0]);		
		red = dd_RedundantRows(V, &err); /* find redundant rows */
		if (err == dd_NoError) {
			/* remove the red rows */
			V1 = dd_MatrixSubmatrix(V, red);
			plhs[0] = FT_set_V_MatrixPtr(V1);
			dd_FreeMatrix(V1);
			if (nlhs == 2) {
				plhs[1] = FT_set_Set(red);
			}
		} else {
    			dd_WriteErrorMessages(stdout,err);
    			mexErrMsgTxt("CDD returned an error, see above(!) for details");
  		}
		dd_FreeMatrix(V);
		set_free(red);
  		return;
	} else {
		mexErrMsgTxt("reduce_v expects an V input struct and produces a V output struct and an optional vector of removed vertices");
	}
}
Example #2
0
void
adj_extreme(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[])
{
	dd_PolyhedraPtr P;
	dd_ErrorType err;
	dd_MatrixPtr H,V;
	dd_SetFamilyPtr A;
	
	if (nrhs  == 1 && nlhs == 2 && mxIsStruct(prhs[0])) {
		dd_set_global_constants();  /* First, this must be called. */
		H = FT_get_H_MatrixPtr(prhs[0]);		

		P = dd_DDMatrix2Poly(H, &err); /* compute the second representation */
		if (err == dd_NoError) {
			V = dd_CopyGenerators(P);
			A = dd_CopyAdjacency(P);
			plhs[0] = FT_set_V_MatrixPtr(V);
			plhs[1] = FT_set_SetFamilyPtr(A);
			dd_FreeMatrix(V);
			dd_FreeSetFamily(A);
		} else {
    			dd_WriteErrorMessages(stdout,err);
    			mexErrMsgTxt("CDD returned an error, see above(!) for details");    			
  		}
		dd_FreeMatrix(H);
  		dd_FreePolyhedra(P);
  		return;
	} else {
		mexErrMsgTxt("adj_extreme expects an H input struct and produces a V output struct and the adjacency struct");
	}
}
Example #3
0
void 
file_ine(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[])
/* Ine file input, V output, similar to extreme */
{
    dd_PolyhedraPtr poly;
    dd_MatrixPtr M;
    dd_ErrorType err;
    char *inputfile;
    FILE *reading=NULL;
    dd_MatrixPtr A, G;
    dd_SetFamilyPtr GI,GA;
    int buflen, status;
    
    dd_set_global_constants();  /* First, this must be called. */
    if (nrhs  == 1 && nlhs <=2 && mxIsChar(prhs[0])) {
        /*  dd_SetInputFile(&reading,inputfile, &err); */
        buflen = mxGetN(prhs[0]) + 1;
        inputfile= mxCalloc(buflen, sizeof(char));
        status = mxGetString(prhs[0], inputfile, buflen);
        if ( (reading = fopen(inputfile,"r") )== NULL) {
            mxErrMsgTxt("Input file not found\n");
            return;
        }
        printf(" Input file opened. \n");    
        M=dd_PolyFile2Matrix(reading, &err);
        
        if (err==dd_NoError) {
            poly=dd_DDMatrix2Poly(M, &err); /* compute the second representation */
            if (err!=dd_NoError) {
                dd_WriteErrorMessages(stdout,err);
                mxErrMsgTxt("CDD internal error\n");
                return;
            }
            A=dd_CopyInequalities(poly);
            G=dd_CopyGenerators(poly);
            GI=dd_CopyInputIncidence(poly);
            GA=dd_CopyAdjacency(poly);
            plhs[0] = FT_set_V_MatrixPtr(G);
            plhs[1] = ZH_set_Vlist(GI,GA);
            dd_FreePolyhedra(poly);
            dd_FreeMatrix(M);
            return;
        }
    }
    else {
        mexErrMsgTxt("file-ine expects an file input");
    }
    return;
}
Example #4
0
void
copy_v(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[])
{
	dd_MatrixPtr V;
	
	if (nrhs  == 1 && nlhs == 1 && mxIsStruct(prhs[0])) {
		dd_set_global_constants();  /* First, this must be called. */
		V = FT_get_V_MatrixPtr(prhs[0]);		
		plhs[0] = FT_set_V_MatrixPtr(V);
		dd_FreeMatrix(V);
  		return;
	} else {
		mexErrMsgTxt("copy_v expects a V input struct and produces a V output struct");
	}
}
Example #5
0
void
v_hull_extreme(int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[])
{
	dd_PolyhedraPtr P,P1;
	dd_ErrorType err;
	dd_MatrixPtr H,V,V1;

	
	if (nrhs  == 1 && nlhs == 1 && mxIsStruct(prhs[0])) {
		V = FT_get_V_MatrixPtr(prhs[0]);		
		dd_set_global_constants();  /* First, this must be called. */

		P = dd_DDMatrix2Poly(V, &err); /* compute the second representation */
		if (err == dd_NoError) {
			H = dd_CopyInequalities(P);
			P1 = dd_DDMatrix2Poly(H, &err); /* compute the second representation */


			if (err == dd_NoError) {
				V1 = dd_CopyGenerators(P1);
				plhs[0] = FT_set_V_MatrixPtr(V1);
				dd_FreeMatrix(V1);
			} else {
    				dd_WriteErrorMessages(stdout,err);
    				mexErrMsgTxt("CDD returned an error, see above(!) for details");    			
  			}
			dd_FreePolyhedra(P1);
			dd_FreeMatrix(H);
		} else {
    			dd_WriteErrorMessages(stdout,err);
    			mexErrMsgTxt("CDD returned an error, see above(!) for details");
  		}
		dd_FreeMatrix(V);
  		dd_FreePolyhedra(P);
  		return;
	} else {
		mexErrMsgTxt("v_hull_extreme expects a V input struct and produces a V output struct");
	}
}