コード例 #1
0
ファイル: WlzBndFunction.c プロジェクト: dscho/Woolz
const char	*WlzGetPropName(WlzObject *obj)
{
  WlzErrorNum errNum = WLZ_ERR_NONE;
  WlzProperty prop;
  const char *name = NULL;
  char *dst = NULL;

  if(obj->plist)
  {
    prop = WlzGetProperty(obj->plist->list, WLZ_PROPERTY_NAME, &errNum);
    if(prop.core && (errNum == WLZ_ERR_NONE))
    {
      switch(prop.core->type)
      {
	case WLZ_PROPERTY_NAME:
	  dst = prop.name->name;
	  break;
	case WLZ_PROPERTY_GREY:
	  dst = prop.greyV->name;
	  break;
	default:
	  errNum = WLZ_ERR_PROPERTY_TYPE;
	  break;
      }
    }
  }
  name = AlcStrDup((const char *) dst);
  return(name);
}
コード例 #2
0
ファイル: WlzBndFunction.c プロジェクト: ma-tech/Woolz
/*!
* \return	Property name string.
* \ingroup	LibWlzBnd
* \brief	Get's an object's property name string.
* \param	obj			Given object.
* \param	dstErr			Destination error pointer, may be NULL.
*/
const char	*WlzGetPropName(WlzObject *obj, WlzErrorNum *dstErr)
{
  const char *name = NULL;
  char *dst = NULL;
  WlzErrorNum errNum = WLZ_ERR_NONE;

  if(obj == NULL)
  {
    errNum = WLZ_ERR_OBJECT_NULL;
  }
  else if(obj->plist)
  {
    WlzProperty prop;

    prop = WlzGetProperty(obj->plist->list, WLZ_PROPERTY_NAME, &errNum);
    if((errNum == WLZ_ERR_NONE) && prop.core)
    {
      switch(prop.core->type)
      {
	case WLZ_PROPERTY_NAME:
	  dst = prop.name->name;
	  break;
	case WLZ_PROPERTY_GREY:
	  dst = prop.greyV->name;
	  break;
	default:
	  errNum = WLZ_ERR_PROPERTY_TYPE;
	  break;
      }
      name = AlcStrDup((const char *)dst);
    }
  }
  if(dstErr)
  {
    *dstErr = errNum;
  }
  return(name);
}
コード例 #3
0
ファイル: WlzChangeEMAPProperty.c プロジェクト: dscho/Woolz
int main(int	argc,
         char	**argv)
{

    WlzObject	*obj;
    FILE		*inFile;
    char 		optList[] = "a:e:E:c:C:f:F:l:m:M:n:rs:S:t:T:V:hv";
    int		option;
    WlzEMAPPropertyType	emapType=WLZ_EMAP_PROPERTY_DOMAIN_OTHER;
    int		emapTypeFlg=0;
    char		*modelUID=NULL;
    char		*anatomyUID=NULL;
    char		*targetUID=NULL;
    char		*targetVersion=NULL;
    char		*stage=NULL, *subStage=NULL;
    char		*modelName=NULL;
    char		*version=NULL;
    char		*fileName=NULL;
    time_t	creationTime;
    int		cTimeFlg=0;
    char		*creationAuthor=NULL;
    char		*creationMachineName=NULL;
    time_t	modificationTime;
    int		mTimeFlg=0;
    char		*modificationAuthor=NULL;
    char		*comment=NULL;
    int		removeFlg=0;
    WlzProperty	property;
    struct tm	tm;
    WlzErrorNum	errNum;

    /* read the argument list and check for an input file */
    opterr = 0;
    while( (option = getopt(argc, argv, optList)) != EOF ) {
        switch( option ) {

        case 'a':
            anatomyUID = optarg;
            break;

        case 'e':
            modelUID = optarg;
            break;

        case 'E':
            targetUID = optarg;
            break;

        case 'c':
            if(sscanf(optarg, "%d/%d/%d",
                      &(tm.tm_mday), &(tm.tm_mon), &(tm.tm_year)) == 3) {
                tm.tm_sec = 0;
                tm.tm_min = 0;
                tm.tm_hour = 0;
                if( tm.tm_year > 1900 ) {
                    tm.tm_year -= 1900;
                }
                creationTime = mktime(&tm);
                cTimeFlg = 1;
            }
            else {
                usage(argv[0]);
                return( 1 );
            }
            break;

        case 'C':
            creationAuthor = optarg;
            break;

        case 'f':
            fileName = optarg;
            break;

        case 'F':
            targetVersion = optarg;
            break;

        case 'l':
            creationMachineName = optarg;
            break;

        case 'm':
            if(sscanf(optarg, "%d/%d/%d",
                      &(tm.tm_mday), &(tm.tm_mon), &(tm.tm_year)) == 3) {
                tm.tm_sec = 0;
                tm.tm_min = 0;
                tm.tm_hour = 0;
                if( tm.tm_year > 1900 ) {
                    tm.tm_year -= 1900;
                }
                modificationTime = mktime(&tm);
                mTimeFlg = 1;
            }
            else {
                usage(argv[0]);
                return( 1 );
            }
            break;

        case 'M':
            modificationAuthor = optarg;
            break;

        case 'n':
            modelName = optarg;
            break;

        case 'r':
            removeFlg = 1;
            break;

        case 's':
            stage = optarg;
            break;

        case 'S':
            subStage = optarg;
            break;

        case 't':
            switch( emapType = (WlzEMAPPropertyType) atoi(optarg) ) {

            case WLZ_EMAP_PROPERTY_GREY_MODEL:
            case WLZ_EMAP_PROPERTY_GREY_OTHER:
            case WLZ_EMAP_PROPERTY_DOMAIN_ANATOMY:
            case WLZ_EMAP_PROPERTY_DOMAIN_OTHER:
            case WLZ_EMAP_PROPERTY_TRANSFORM:
                break;

            default:
                fprintf(stderr, "%s: EMAP property type = %d is invalid\n",
                        argv[0], emapType );
                usage(argv[0]);
                return 1;

            }
            emapTypeFlg=1;
            break;

        case 'T':
            comment = optarg;
            break;

        case 'V':
            version = optarg;
            break;

        case 'h':
        default:
            usage(argv[0]);
            return( 1 );

        }
    }

    inFile = stdin;
    if( optind < argc ) {
        if( (inFile = fopen(*(argv+optind), "r")) == NULL ) {
            fprintf(stderr, "%s: can't open file %s\n", argv[0], *(argv+optind));
            usage(argv[0]);
            return 1;
        }
    }

    /* read objects and convert if possible */
    while( (obj = WlzReadObj(inFile, NULL)) != NULL ) {
        switch( obj->type ) {
        case WLZ_2D_DOMAINOBJ:
        case WLZ_3D_DOMAINOBJ:
        case WLZ_TRANS_OBJ:
        case WLZ_3D_WARP_TRANS:
        case WLZ_PROPERTY_OBJ:
            /* get the EMAP property, if absent add one */
            if( obj->plist == NULL ) {
                obj->plist = WlzMakePropertyList(NULL);
            }
            if( obj->plist ) {
                property = WlzGetProperty(obj->plist->list, WLZ_PROPERTY_EMAP, NULL);
                if( property.core == NULL ) {
                    property.emap = WlzMakeEMAPProperty(WLZ_EMAP_PROPERTY_GREY_MODEL,
                                                        NULL, NULL, NULL, NULL, NULL,
                                                        NULL, NULL, NULL, NULL, NULL,
                                                        &errNum);
                    WlzAssignProperty(property, NULL);
                    AlcDLPListEntryAppend(obj->plist->list, NULL, (void *) property.emap,
                                          WlzFreePropertyListEntry);
                }
            }
            if( removeFlg ) {
                WlzRemoveProperty(obj->plist->list, property);
            }
            else {
                if( !emapTypeFlg ) {
                    emapType = property.emap->emapType;
                }
                WlzChangeEMAPProperty(property.emap, emapType, modelUID,
                                      anatomyUID, targetUID, targetVersion, stage,
                                      subStage, modelName, version, fileName, comment);
                if( cTimeFlg ) {
                    property.emap->creationTime = creationTime;
                }
                if( creationAuthor ) {
                    strcpy(property.emap->creationAuthor, creationAuthor);
                }
                if( creationMachineName ) {
                    strcpy(property.emap->creationMachineName, creationMachineName);
                }
                if( mTimeFlg ) {
                    property.emap->modificationTime = modificationTime;
                }
                if( modificationAuthor ) {
                    strcpy(property.emap->modificationAuthor, modificationAuthor);
                }
            }
            break;

        case WLZ_COMPOUND_ARR_1:
        case WLZ_COMPOUND_ARR_2:
            break;

        default:
            break;
        }

        (void )WlzWriteObj(stdout, obj);
        WlzFreeObj(obj);
    }

    return WLZ_ERR_NONE;
}