void DataManager::CopyLookupTable(vtkSmartPointer<vtkLookupTable> from, vtkSmartPointer<vtkLookupTable> to) const
{
  // copyTo exists and i don't want to do just a DeepCopy that could release memory, i just want to copy the colors
  double rgba[4];

  to->Allocate();
  to->SetNumberOfTableValues(from->GetNumberOfTableValues());

  for (int index = 0; index != from->GetNumberOfTableValues(); index++)
  {
    from->GetTableValue(index, rgba);
    to->SetTableValue(index, rgba);
  }

  to->SetTableRange(0, from->GetNumberOfTableValues() - 1);
}
Ejemplo n.º 2
0
void
ExporterVTK<MeshType,N>::saveMesh( mesh_ptrtype mesh, vtkSmartPointer<vtkout_type> out ) const
{
    /* get local elements */
    //auto r = markedelements(step->mesh(), markerid, EntityProcessType::LOCAL_ONLY );
    auto r = elements(mesh);
    auto elt_it = r.template get<1>();
    auto elt_en = r.template get<2>();

    /* Gather points and elements into vectors + info about data */
    Feel::detail::MeshPoints<float> mp( mesh.get(), this->worldComm(), elt_it, elt_en, false, true, true, 0 );

    /* Add points to data structure */
    vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
    points->SetDataTypeToFloat();
    points->SetNumberOfPoints(mp.ids.size());

    float * coords = mp.coords.data();
    for ( int i = 0; i < mp.ids.size() ; i++ )
    {
        points->SetPoint( (vtkIdType)(mp.ids[i]), coords + i * 3 );
    }

    out->SetPoints(points);

    /* Add cells to data structure */
    int nbElem = mp.elem.size() / mesh_type::element_type::numPoints;
    out->Allocate(nbElem, nbElem);

    vtkSmartPointer<vtkelement_type> cell = vtkSmartPointer<vtkelement_type>::New();

    for( int i = 0; i < mp.elem.size(); i+=mesh_type::element_type::numPoints )
    {
        for( int p=0; p < mesh_type::element_type::numPoints; ++p )
        {
            cell->GetPointIds()->SetId(p, mp.elem[i + p]);
        }
        out->InsertNextCell(cell->GetCellType(), cell->GetPointIds());
    }
}
Ejemplo n.º 3
0
void TransferFunction::toBWVtkLookupTable(
         double rangeMin,
         double rangeMax,
         vtkSmartPointer<vtkLookupTable> lt,
         unsigned int size )
{
    SLM_TRACE_FUNC();

    // Configures basic parameters
    lt->Allocate( size, size );
    lt->SetScaleToLinear();

    lt->SetRampToLinear();
    lt->SetTableRange( rangeMin, rangeMax );
    lt->SetAlphaRange( 1.0, 1.0 );
    lt->SetHueRange( 0.0, 0.0 );
    lt->SetSaturationRange( 0.0, 0.0 );
    lt->SetValueRange( 0.0, 1.0 );

    lt->Build();

    lt->Modified();
}