function varargout=Rigidite(Th,varargin)
  assert(fc_simesh.is_siMesh(Th))
  p = inputParser;
  p.addParamValue('local', false, @islogical ); 
  p.addParamValue('labels', [] );
  p.addParamValue('d', Th.d ); % kind of elementary mesh ( d-simplicial)
  p.parse(varargin{:});
  d=p.Results.d;assert( ismember(d,1:Th.d) ) 
  if isempty(p.Results.labels)
    [idx,labels]=Th.find(d);
  else
    labs=p.Results.labels;
    [idx,labels]=Th.find(d,labs);
    if length(labels)<length(labs)
      LD=setdiff(labs,labels);
      error('siMesh.Rigidite: %d-simplex labels not found %s',d,num2str(LD))
    end
  end
  n=length(labels);
  if p.Results.local
    A=cell(1,n);
    for i=1:n
      A{i}=siMeshElt.Rigidite(Th.sTh{idx(i)},'local',true);
    end
    if n==1,A=A{1};end
  else
    A=sparse(Th.nq,Th.nq);
    for i=1:n
      A=A+siMeshElt.Rigidite(Th.sTh{idx(i)},'local',false);
    end
  end
  varargout{1}=A;
  if nargout>=2,varargout{2}=idx;end
  if nargout==3,varargout{3}=labels;end
end
