[Paraview] String block labels stripped by Extract Block?

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Fri May 2 15:38:54 EDT 2008


Here's how to name a block:

vtkMultiBlockDataSet* mb  = vtkMultiBlockDataSet::New();
...
vtkDataSet* myBlock0 = ...
mb->SetBlock(0, myBlock0);
mb->GetMetadata(0)->Set(vtkCompositeDataSet::NAME(), "MyBlock0");
...
vtkDataSet* myBlock1 = ...
mb->SetBlock(1, myBlock1);
mb->GetMetadata(1)->Set(vtkCompositeDataSet::NAME(), "MyBlock1");
...


The naming of blocks by putting the name in FieldData is no longer 
supported.

Utkarsh

Paul Edwards wrote:
> Hi,
> 
> How do you name blocks?  I was patching the ParaView code how Takuya 
> posted previously on the mailing list and putting the name as field data 
> for each block.  Unfortunately the latest changes in the CVS stop this 
> from working.
> 
> If there is a better way to do naming I'd prefer to use that.
> 
> Thanks,
> Paul
> 
> PS this was the post with the patch I was applying -
> 
> 2008/3/7 OSHIMA Takuya <oshima at eng.niigata-u.ac.jp 
> <mailto:oshima at eng.niigata-u.ac.jp>>:
> Hi,
> 
> As I play with the new composite dataset structures, I came to think
> it would indeed be nice if ParaView3 can handle datasets with string
> labels ("Porous Material," "Air," ... , rather than "DataSet 0,"
> "DataSet 1," ...). I mean, for example, VTK/IO/vtkEnsight6Reader.cxx
> has a fragment of code to assign its output a string label.
> 
>  vtkCharArray* nmArray = vtkCharArray::New();
>  nmArray->SetName("Name");
>  size_t len = strlen(name);
>  nmArray->SetNumberOfTuples
> 
>     (static_cast<vtkIdType>(len)+1);
>      char* copy = nmArray->GetPointer(0);
>      memcpy(copy, name, len);
>      copy[len] = '\0';
>      output->GetFieldData()->AddArray(nmArray);
>      nmArray->Delete();
> 
>     I can do the same thing to each member dataset in a MultiBlockDataSet,
>     but it doesn't seem there's a way to display the labels in
>     ParaView. However if I rewrite the code a bit for Information tab of
>     Object Inspector (of the CVS head)
> 
>     --- Qt/Components/pqProxyInformationWidget.cxx.orig     2008-02-20
>     08:56:03.000000000 +0900
>     +++ Qt/Components/pqProxyInformationWidget.cxx  2008-03-07
>     18:40:06.000000000 +0900
>     @@ -387,7 +387,8 @@
>      {
>       QTreeWidgetItem* node = 0;
> 
>     -  QString label = info? info->GetPrettyDataTypeString() : "NA";
>     +  QString label = info?
>     +    (parentItem? info->GetName() :
>     info->GetPrettyDataTypeString()): "NA";
>       if (parentItem)
>         {
>         node = new QTreeWidgetItem(parentItem, QStringList(label));
> 
>     or the one for Properties tab of the Extract Block filter,
> 
>     --- Qt/Components/pqSignalAdaptorCompositeTreeWidget.cxx.orig  
>     2008-03-01 10:59:23.000000000 +0900
>     +++ Qt/Components/pqSignalAdaptorCompositeTreeWidget.cxx      
>      2008-03-07 18:12:23.000000000 +0900
>     @@ -395,7 +395,15 @@
>       for (unsigned int cc=0; cc < cinfo->GetNumberOfChildren(); cc++)
>         {
>         vtkPVDataInformation* childInfo = cinfo->GetDataInformation(cc);
>     -    QString childLabel = QString("DataSet %1").arg(cc);
>     +    QString childLabel;
>     +    if(childInfo)
>     +      {
>     +      childLabel = QString("DataSet %1
>      %2").arg(cc).arg(childInfo->GetName());
>     +      }
>     +    else
>     +      {
>     +      childLabel = QString("DataSet %1").arg(cc);
>     +      }
>         bool is_leaf = true;
>         if (childInfo &&
>     childInfo->GetCompositeDataInformation()->GetDataIsComposite())
>           {
> 
>     I can see the string labels in addition to dataset numbers. Searching
>     the list archives of ParaView and VTK I found several similar
>     discussions held in the past. The modifications above are just
>     concepts, not ment to be applied to the real source, but would things
>     like this be an option?
> 
>     Takuya
> 
> 
> 
> 2008/4/30 OSHIMA Takuya <oshima at eng.niigata-u.ac.jp 
> <mailto:oshima at eng.niigata-u.ac.jp>>:
> 
>     Hi,
> 
>     I'm so happy to see the string block labeling feature has been finally
>     added to the CVS head!
> 
>     However I found a problem when I ran the Extract Block filter to a
>     vtkMultiBlockDataSet which has the block structure as shown by the
>     attached picture1.png (the Properties panel of the Extract Block
>     filter). In this case I expect to see the labels for the selected
>     blocks "roofEndWeb" and "internalField" after running the filter, but
>     in reality what I got was "roofEndWeb" and "1: Unstructured Grid" as
>     shown by picture2.png (the Information panel of the same filter). The
>     problem occurrs only when Prune Output is turned on.
> 
>     My guess is that the line 232 of vtkExtractBlock.cxx
> 
>              
>      clone->GetMetaData(index)->Copy(prunedBlock->GetMetaData(cc));
> 
>     should be
> 
>              
>      clone->GetMetaData(index)->Copy(prunedBlock->GetMetaData(static_cast
>     <unsigned int>(0)));
> 
>     ? (this worked for the case, but I'm not so sure.)
> 
>     Takuya
> 
>     _______________________________________________
>     ParaView mailing list
>     ParaView at paraview.org <mailto:ParaView at paraview.org>
>     http://www.paraview.org/mailman/listinfo/paraview
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> ParaView mailing list
> ParaView at paraview.org
> http://www.paraview.org/mailman/listinfo/paraview


More information about the ParaView mailing list