mttCountObjects.m 689 B

1234567891011121314151617181920212223
  1. function model = mttCountObjects(model)
  2. object_names = mttGetFieldNames(model,'obj') ;
  3. number_of_objects = length(object_names) ;
  4. model.count.obj = number_of_objects ;
  5. model.count.cr = 0 ;
  6. for i = 1:number_of_objects
  7. object_name = object_names{i} ;
  8. object = getfield(model,'obj',object_name) ;
  9. if ~isempty(object.cr)
  10. model.count.cr = model.count.cr + 1 ;
  11. end
  12. if isfield(object,'obj')
  13. next = mttCountObjects(object) ;
  14. model.count.obj = model.count.obj + next.count.obj ;
  15. model.count.cr = model.count.cr + next.count.cr ;
  16. end
  17. end