Builder/Builder/Common/plyfile.c
/******************************************************************************
Specify that we want the "other" properties of an element to be tucked
away within the user's structure.  The user needn't be concerned for how
these properties are stored.

Entry:
  plyfile   - file identifier
  elem_name - name of element that we want to store other_props in
  offset    - offset to where other_props will be stored inside user's structure

Exit:
  returns pointer to structure containing description of other_props
******************************************************************************/
Specify that we want the "other" properties of an element to be tucked
away within the user's structure.  The user needn't be concerned for how
these properties are stored.

plyfile   - file identifier
elem_name - name of element that we want to store other_props in
offset    - offset to where other_props will be stored inside user's structure

returns pointer to structure containing description of other_props
Specify that we want the " other " properties of an element to be tucked away within the user ' s structure . The user needn ' t be concerned for how these properties are stored . plyfile - file identifier elem_name - name of element that we want to store other_props in offset - offset to where other_props will be stored inside user ' s structure returns pointer to structure containing description of other_props
PlyOtherProp *ply_get_other_properties(
  PlyFile *plyfile,
  char *elem_name,
  int offset
)
{
  int i;
  PlyElement *elem;
  PlyOtherProp *other;
  PlyProperty *prop;
  int nprops;
  elem = find_element (plyfile, elem_name);
  if (elem == NULL) {
    fprintf (stderr, "ply_get_other_properties: Can't find element '%s'\n",
             elem_name);
    return (NULL);
  }
  plyfile->which_elem = elem;
  elem->other_offset = offset;
  setup_other_props (elem);
  other = (PlyOtherProp *) myalloc (sizeof (PlyOtherProp));
  other->name = _strdup (elem_name);
#if 0
  if (elem->other_offset == NO_OTHER_PROPS) {
    other->size = 0;
    other->props = NULL;
    other->nprops = 0;
    return (other);
  }
#endif
  other->size = elem->other_size;
  other->props = (PlyProperty **) myalloc (sizeof(PlyProperty) * elem->nprops);
  nprops = 0;
  for (i = 0; i < elem->nprops; i++) {
    if (elem->store_prop[i])
      continue;
    prop = (PlyProperty *) myalloc (sizeof (PlyProperty));
    copy_property (prop, elem->props[i]);
    other->props[nprops] = prop;
    nprops++;
  }
  other->nprops = nprops;
#if 1
  if (other->nprops == 0) {
    elem->other_offset = NO_OTHER_PROPS;
  }
#endif
  return (other);
}
PlyOtherProp * ply_get_other_properties ( PlyFile * plyfile , char * elem_name , int offset ) { int i ; PlyElement * elem ; PlyOtherProp * other ; PlyProperty * prop ; int nprops ; elem = find_element ( plyfile , elem_name ) ; if ( elem == NULL ) { fprintf ( stderr , " \n " , elem_name ) ; return ( NULL ) ; } plyfile -> which_elem = elem ; elem -> other_offset = offset ; setup_other_props ( elem ) ; other = ( PlyOtherProp * ) myalloc ( sizeof ( PlyOtherProp ) ) ; other -> name = _strdup ( elem_name ) ; #if 0 if ( elem -> other_offset == NO_OTHER_PROPS ) { other -> size = 0 ; other -> props = NULL ; other -> nprops = 0 ; return ( other ) ; } #endif other -> size = elem -> other_size ; other -> props = ( PlyProperty * * ) myalloc ( sizeof ( PlyProperty ) * elem -> nprops ) ; nprops = 0 ; for ( i = 0 ; i < elem -> nprops ; i ++ ) { if ( elem -> store_prop [ i ] ) continue ; prop = ( PlyProperty * ) myalloc ( sizeof ( PlyProperty ) ) ; copy_property ( prop , elem -> props [ i ] ) ; other -> props [ nprops ] = prop ; nprops ++ ; } other -> nprops = nprops ; #if 1 if ( other -> nprops == 0 ) { elem -> other_offset = NO_OTHER_PROPS ; } #endif return ( other ) ; }
Specify that we want the "other" properties of an element to be tucked
away within the user's structure.
Specify that we want the " other " properties of an element to be tucked away within the user ' s structure .
/* find information about the element */ /* remember that this is the "current" element */ /* save the offset to where to store the other_props */ /* place the appropriate pointers, etc. in the element's property list */ /* create structure for describing other_props */ /* save descriptions of each "other" property */ /* set other_offset pointer appropriately if there are NO other properties */ /* return structure */