/***********************************************************************/ /* Open Visualization Data Explorer */ /* (C) Copyright IBM Corp. 1989,1999 */ /* ALL RIGHTS RESERVED */ /* This code licensed under the */ /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */ /***********************************************************************/ #include #include #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #ifndef MAXDIMS #define MAXDIMS 32 #endif /* * A table of depComp (dependent component) structures is use to * allow these components to be changed to reflect the changes in * the postions component upon which they depend. */ typedef struct depComp { char *name; Array newA; Pointer new_data; Array oldA; Pointer old_data; int iSize; } depComp; typedef struct argblck { Object inField; Object outField; float scale; } argblck; static Object DoIsolate(Object o,float scale); static Error Isolate_Field(Pointer p); Error m_Isolate(Object *in, Object *out) { Object o = NULL; float scale; /* Check for required input object */ if(!in[0]) { DXSetError(ERROR_BAD_PARAMETER,"missing input"); goto error; } /* Typecheck scale input or set to default (.5) */ if(!in[1]) scale = .5; else if (!DXExtractFloat(in[1],&scale)){ DXSetError(ERROR_BAD_PARAMETER,"scale must be a scalar value"); goto error; } if ((scale<0) || (scale>1)) { DXSetError(ERROR_BAD_PARAMETER,"scale must be between 0 and 1"); goto error; } if (scale==0) DXWarning("scale value for isolate is zero."); /* Copy input object and call DoIsolate on the copy */ DXCreateTaskGroup(); o = DoIsolate(in[0],1-scale); if (! o) goto error; if (!DXExecuteTaskGroup()) goto error; if(!o) goto error; /* o is now our output */ out[0] = o; return OK; /* Handle errors */ error: if (o != in[0]) DXDelete((Object)o); out[0] = NULL; return ERROR; } static Object DoIsolate(Object o,float scale) { Object oo,subo,subo2; int fixed,z; Matrix m; int i,newi; char *name; struct argblck arg; switch (DXGetObjectClass(o)) { case CLASS_FIELD: if (DXEmptyField((Field)o)) return o; oo = DXCopy(o,COPY_STRUCTURE); if(!oo) goto error; arg.inField = o; arg.outField = oo; arg.scale = scale; if(!DXAddTask(Isolate_Field,&arg,sizeof(arg),0.0)) goto error; return oo; break; case CLASS_GROUP: { Group g = (Group)DXCopy(o, COPY_HEADER); if (! g) return NULL; for (i=0; oo= DXGetEnumeratedMember((Group)o,i,&name); i++) { if(!(oo = DoIsolate(oo,scale))) goto error; name ? DXSetMember(g,name,oo) : DXSetEnumeratedMember(g,i,oo); } return (Object)g; break; } case CLASS_XFORM: { Xform x = (Xform)DXCopy(o,COPY_HEADER); DXGetXformInfo((Xform)o,&subo,&m); if(!(oo = DoIsolate(subo,scale))) goto error; DXSetXformObject(x,oo); return (Object)x; break; } case CLASS_CLIPPED: { Clipped c = (Clipped)DXCopy(o,COPY_HEADER); DXGetClippedInfo((Clipped)o,&subo,&subo2); if(!(oo = DoIsolate(subo,scale))) goto error; DXSetClippedObjects(c,oo,subo2); return (Object)c; break; } case CLASS_SCREEN: { Screen s = (Screen)DXCopy(o,COPY_HEADER); DXGetScreenInfo((Screen)o,&subo,&fixed, &z); if(!(oo = DoIsolate(subo,scale))) goto error; DXSetScreenObject(s,oo); return (Object)s; break; } default: DXSetError(ERROR_BAD_PARAMETER,"object must be a field or group"); goto error; } return o; error: /* Delete anything we might have lying around */ return ERROR; } static Error Isolate_Field(Pointer p) { Object attr; Array old_pA,new_pA,old_cA,new_cA,old_dA,new_dA; Array compArray; ArrayHandle old_cHandle = NULL,old_pHandle = NULL; InvalidComponentHandle old_invPHandle = NULL,new_invPHandle = NULL; /* The following fixes a bizarre compiler optimizer bug on hp700 */ #ifdef hp700 volatile #endif Point point[8],delta,centroid; depComp *depPCompA = NULL; /* posns dependant component table */ char *eType,*name,*str; float *old_postions,*new_positions; int *old_connections,*new_connections; int i,j,k; int nVperE,nElements,pDim; int ndepPComps = 0; int has_invalid_posns = FALSE; int newIndex = 0; Field inField,outField; float scale; int shape[MAXDIMS]; int rank; struct argblck *arg = (struct argblck *)p; inField = (Field)arg->inField; outField = (Field)arg->outField; scale = arg->scale; /* Check that input has connections */ old_cA = (Array)DXGetComponentValue(inField,"connections"); if(!old_cA) { DXSetError(ERROR_MISSING_DATA,"input has no connections"); goto error; } old_pA = (Array)DXGetComponentValue(inField,"positions"); if(!old_pA){ DXSetError(ERROR_MISSING_DATA,"field has no positions"); goto error; } /* get dimensionality of positions array */ DXGetArrayInfo(old_pA,NULL,NULL,NULL,&rank,shape); for (i=0, pDim=1;i