Example #1
0
static COMMAND_FUNC( equivalence )
{
	const char *obj_name;
	Data_Obj *dp;
	Precision * prec_p;
	Dimension_Set ds1, *dsp=(&ds1);
	long ns,nf,nr,nc,nd;

	obj_name=NAMEOF("name for equivalent image");

	dp=pick_obj(PARENT_PROMPT);

	ns=(long) how_many("number of sequences");
	nf=(long) how_many("number of frames");
	nr=(long) how_many("number of rows");
	nc=(long) how_many("number of columns");
	nd=(long) how_many("number of components");

	prec_p = get_precision(SINGLE_QSP_ARG);

	if( dp==NULL ) return;
	if( prec_p == NULL ) return;

	INSIST_POSITIVE_DIM(ns,"sequence","equivalence")
	INSIST_POSITIVE_DIM(nf,"frame","equivalence")
	INSIST_POSITIVE_DIM(nr,"row","equivalence")
	INSIST_POSITIVE_DIM(nc,"column","equivalence")
	INSIST_POSITIVE_DIM(nd,"component","equivalence")

	SET_DIMENSION(dsp,4,ns);
	SET_DIMENSION(dsp,3,nf);
	SET_DIMENSION(dsp,2,nr);
	SET_DIMENSION(dsp,1,nc);
	SET_DIMENSION(dsp,0,nd);

	if( COMPLEX_PRECISION(PREC_CODE(prec_p)) ){
		if( DIMENSION(dsp,0) != 1 ){
			warn("Sorry, can only have 1 complex component");
			return;
		}
		//SET_DIMENSION(dsp,0,2);
	} else if( QUAT_PRECISION(PREC_CODE(prec_p)) ){
		if( DIMENSION(dsp,0) != 1 ){
			warn("Sorry, can only have 1 quaternion component");
			return;
		}
		//SET_DIMENSION(dsp,0,2);
	} else if( COLOR_PRECISION(PREC_CODE(prec_p)) ){
		if( DIMENSION(dsp,0) != 1 ){
			warn("Sorry, can only have 1 color triple per pixel");
			return;
		}
advise("component dim 3 for color");
		//SET_DIMENSION(dsp,0,3);
	}

	if( make_equivalence(obj_name,dp,dsp,prec_p) == NULL )
		warn("error making equivalence");
}
Example #2
0
int set_shape_flags(Shape_Info *shpp, uint32_t shape_flag)
{
	int i;

	/* if shape is unknown, the flag should already be set */
	if( UNKNOWN_SHAPE(shpp) ){
		SET_SHP_MAXDIM(shpp,0);
		SET_SHP_MINDIM(shpp,N_DIMENSIONS-1);

		// Should we initialize OBJ_RANGE_MAXDIM etc?
		SET_SHP_RANGE_MAXDIM(shpp,SHP_MAXDIM(shpp));
		SET_SHP_RANGE_MINDIM(shpp,SHP_MINDIM(shpp));

		return(0);
	}

	CLEAR_SHP_FLAG_BITS(shpp,SHAPE_DIM_MASK);

	for(i=0;i<N_DIMENSIONS;i++){
		assert( SHP_TYPE_DIM(shpp,i) > 0 );
	}

	/* BUG?  here we set the shape type based
	 * on dimension length, which makes it impossible
	 * to have a one-length vector.  This causes problems
	 * when we index a variable-length vector which
	 * can have length one.  An example of this is a camera
	 * array, when we sometimes only have one camers...
	 *
	 * Perhaps the solution is to set the shape flag when
	 * the object is created, and use that to set maxdim?
	 */

	set_minmaxdim(shpp,shape_flag);		// set_shape_flags

	if( shape_flag == AUTO_SHAPE ){
		if( SHP_SEQS(shpp) > 1 )
			SET_SHP_FLAG_BITS(shpp,DT_HYPER_SEQ);
		else if( SHP_FRAMES(shpp) > 1 )
			SET_SHP_FLAG_BITS(shpp, DT_SEQUENCE);
		else if( SHP_ROWS(shpp) > 1 ){
			if( SHP_TYPE_DIM(shpp,1)==1 )
				SET_SHP_FLAG_BITS(shpp, DT_COLVEC);
			else
				SET_SHP_FLAG_BITS(shpp, DT_IMAGE);
		}
		else {
			dimension_t nc;

			nc=SHP_COLS(shpp);

			if( nc > 1 )
				SET_SHP_FLAG_BITS(shpp, DT_ROWVEC);
			else	SET_SHP_FLAG_BITS(shpp, DT_SCALAR);
		}
	} else {
		SET_SHP_FLAG_BITS(shpp,shape_flag);
	}


	CLEAR_SHP_FLAG_BITS(shpp, SHAPE_TYPE_MASK);
	if( COMPLEX_PRECISION(SHP_PREC(shpp)) ){
		SET_SHP_FLAG_BITS(shpp, DT_COMPLEX);
	} else if( QUAT_PRECISION(SHP_PREC(shpp)) ){
		SET_SHP_FLAG_BITS(shpp, DT_QUAT);
	} else {
		if( SHP_COMPS(shpp) != 1 ){
			SET_SHP_FLAG_BITS(shpp, DT_MULTIDIM);
		}
	}

	/* BUG?  should the string bit be part of shape dim mask??? */
	if( STRING_PRECISION(SHP_PREC(shpp)) ){
		SET_SHP_FLAG_BITS(shpp, DT_STRING);
	}

	if( CHAR_PRECISION(SHP_PREC(shpp)) ){
		SET_SHP_FLAG_BITS(shpp, DT_CHAR);
	}

	if( BITMAP_PRECISION(SHP_PREC(shpp)) )
		SET_SHP_FLAG_BITS(shpp, DT_BIT);

	return(0);
} /* end set_shape_flags() */