#include "vtkPVTrivialProducer.h"
#include <pqDataRepresentation.h>
+#include <vtkAppendPolyData.h>
+
+vtkIdType SPV3D_Prs::cellid = 0;
+vtkIdType SPV3D_Prs::solidid = 0;
+vtkSmartPointer<vtkMultiBlockDataSet> SPV3D_Prs::multiGEOMData = vtkSmartPointer<vtkMultiBlockDataSet>::New();
+
+static vtkIdType SPV3D_Prs::FromEntryToVtkId (const char* entry)
+{
+ char *str = new char[strlen(entry)+1];
+ strcpy(str, entry);
+
+ const char delimiter[2] = ":";
+
+ char* token;
+ token = strtok(str, delimiter);
+
+ std::uint32_t ret(0);
+
+ while (token != NULL) {
+ ret |= atoi(token);
+ token = strtok(NULL, delimiter);
+ }
+
+ return static_cast<vtkIdType> (ret);
+}
+
+
bool SPV3D_EXPORTSPV3DData::IsVisible() const
{
if( IsNull() )
void SPV3D_Prs::FillUsingActor(vtkActor *actor) const
{
+ std::cout << "Hello FillUsingActor"<<std::endl;
+
SPV3D_EXPORTSPV3DData *alreadyExistingSrc = nullptr;
alreadyExistingSrc = _view->isEntryAlreadyExist( GetEntry() );
+ std::cout <<"ENtry: " <<GetEntry() << std::endl;
+ std::cout <<"solid_id from entry: "<< SPV3D_Prs::FromEntryToVtkId(GetEntry());
if(alreadyExistingSrc && !alreadyExistingSrc->GetSourceProducer())
{
actor->GetMapper()->Update();
if(ds3)
{
ds4->ShallowCopy( ds3 );
- vtkNew<vtkIdTypeArray> solidIdArray;
auto nbCells( ds4->GetNumberOfCells() );
+
+ vtkNew<vtkIdTypeArray> solidIdArray;
+ std::cout << "nb of cells: " <<nbCells <<std::endl;
solidIdArray->SetNumberOfComponents(1);
solidIdArray->SetNumberOfTuples( nbCells );
solidIdArray->SetName("Solid id");
+
+ // vtkNew<vtkIdTypeArray> cellIdArray;
+ // cellIdArray->SetNumberOfComponents(1);
+ // cellIdArray->SetNumberOfTuples( nbCells );
+ // cellIdArray->SetName("Edge id");
+
vtkIdType *pt( solidIdArray->GetPointer(0) );
- std::for_each(pt,pt+nbCells,[](vtkIdType& elt) { elt = 0; });
+ std::for_each(pt,pt+nbCells,[](vtkIdType& elt) { elt = SPV3D_Prs::solidid;});
+ // pt = cellIdArray->GetPointer(0);
+ // std::for_each(pt,pt+nbCells,[](vtkIdType& elt) { elt = SPV3D_Prs::cellid;SPV3D_Prs::cellid++; });
+
ds4->GetCellData()->AddArray( solidIdArray );
+ // ds4->GetCellData()->AddArray( cellIdArray );
+ ////Add dataset to multiblock
+//
+ SPV3D_Prs::multiGEOMData->SetBlock(SPV3D_Prs::solidid, ds4);
+//
+ SPV3D_Prs::solidid++;
+ }
+
+ vtkNew<vtkAppendPolyData> appendFilter;
+ std::cout <<"number of block" << SPV3D_Prs::multiGEOMData->GetNumberOfBlocks()<<std::endl;
+ for (unsigned int i = 0; i < SPV3D_Prs::multiGEOMData->GetNumberOfBlocks(); ++i)
+ {
+ vtkPolyData* polyData = vtkPolyData::SafeDownCast(SPV3D_Prs::multiGEOMData->GetBlock(i));
+ if (polyData)
+ {
+ appendFilter->AddInputData(polyData);
+ }
}
- //
+ appendFilter->Update();
+ vtkNew<vtkPolyData> ds5;
+ ds5->ShallowCopy(appendFilter->GetOutput());
+
pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:")));
pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder());
pqPipelineSource *mySourceProducer(builder->createSource("sources","PVTrivialProducer",serv));
- vtkSMProxy *producerBase = mySourceProducer->getProxy();
+ vtkSMProxy* producerBase = mySourceProducer->getProxy();
vtkSMSourceProxy *producer(vtkSMSourceProxy::SafeDownCast(producerBase));
+ //producer->SetInput(ds4, 0);
vtkObjectBase *clientSideObject(producer->GetClientSideObject());
vtkPVTrivialProducer *clientSideObjectCast = vtkPVTrivialProducer::SafeDownCast(clientSideObject);
- clientSideObjectCast->SetOutput(ds4);
+ clientSideObjectCast->SetOutput(ds5);
mySourceProducer->updatePipeline();
pqProxy *producerBase2( getPQProxy(producerBase) );
if(producerBase2 && !_name.empty())
#include "SPV3D.h"
#include "SALOME_Prs.h"
+#include "vtkPolyData.h"
+#include "vtkCellData.h"
+#include <vtkMultiBlockDataSet.h>
+#include <vtkSmartPointer.h>
class vtkActor;
class pqPipelineSource;
class pqDataRepresentation;
pqDataRepresentation *GetRepresentation() const { if(_pvRendInfo) return _pvRendInfo->GetRepresentation(); return nullptr; }
bool IsNull() const override;
+ static vtkIdType FromEntryToVtkId (const char*);
+ // static const char* FromVtkIdToEntry (vtkIdType);
private:
SPV3D_ViewWindow *_view = nullptr;
//! Name attached to the displayable object in the study
std::string _name;
+ static vtkIdType cellid;
+ static vtkIdType solidid;
+ static vtkSmartPointer<vtkMultiBlockDataSet> multiGEOMData;
+
};