]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Mouseover fix
authorDUC ANH HOANG <dh77501n@dsp1043837>
Tue, 4 Jun 2024 12:08:35 +0000 (14:08 +0200)
committerDUC ANH HOANG <dh77501n@dsp1043837>
Tue, 4 Jun 2024 12:08:35 +0000 (14:08 +0200)
src/SPV3D/SPV3D_Prs.cxx
src/SPV3D/SPV3D_Prs.h

index 8e8637cc5d9a03a2e370ffe6652aa68305e7d37b..a3b1db7f4f62f28b09b62485476f25e8301ec847 100644 (file)
 #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() )
@@ -67,8 +94,12 @@ pqProxy *getPQProxy(vtkSMProxy *proxy)
 
 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();
@@ -78,24 +109,56 @@ void SPV3D_Prs::FillUsingActor(vtkActor *actor) const
     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();
+    vtkSMProxyproducerBase = 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())
index 2cba496a03867a265d3316c5a1044fe3f4806f94..1f7fcaae5071c5f209cea7d92bf3e69000e51f76 100644 (file)
 #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;
@@ -75,6 +79,8 @@ public:
   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:
 
@@ -90,4 +96,8 @@ 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;
+
 };