From fb2e38d5862b79562851f49aef6fc525ad99e6ea Mon Sep 17 00:00:00 2001 From: DUC ANH HOANG Date: Thu, 20 Jun 2024 16:07:52 +0200 Subject: [PATCH] last clean --- src/SPV3D/SPV3D_Prs.cxx | 84 ++++++---------------------------- src/SPV3D/SPV3D_Prs.h | 17 +++---- src/SPV3D/SPV3D_ViewModel.cxx | 5 +- src/SPV3D/SPV3D_ViewWindow.cxx | 28 +----------- src/SPV3D/SPV3D_ViewWindow.h | 2 - 5 files changed, 24 insertions(+), 112 deletions(-) diff --git a/src/SPV3D/SPV3D_Prs.cxx b/src/SPV3D/SPV3D_Prs.cxx index d6fd8c6fe..210d89a50 100644 --- a/src/SPV3D/SPV3D_Prs.cxx +++ b/src/SPV3D/SPV3D_Prs.cxx @@ -23,6 +23,7 @@ #include "SPV3D_Prs.h" #include "SPV3D_ViewWindow.h" +#include #include "vtkActor.h" #include "vtkPolyData.h" #include "vtkCellData.h" @@ -36,24 +37,18 @@ #include "vtkPVTrivialProducer.h" #include -#include +#include vtkIdType SPV3D_Prs::cellid = 0; vtkIdType SPV3D_Prs::nbsolid = 0; -//std::map SPV3D_Prs::vtkIdToEntry; -//vtkSmartPointer SPV3D_Prs::multiGEOMData = vtkSmartPointer::New(); SPV3D_EXPORTSPV3DData::SPV3D_EXPORTSPV3DData() { nbsolid = 0; _multiGEOMData = vtkSmartPointer::New(); - std::cout << "DDDDDDDDDDDDDDDDDDDDDD" << std::endl; pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:"))); - std::cout << "AAAAAAAAAAAAAAAAAAAAAa" << std::endl; pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); - std::cout << "BBBBBBBBBBBBBBBBBBBBBB" << std::endl; _sourceProducer = builder->createSource("sources","PVTrivialProducer",serv); - std::cout << "CCCCCCCCCCCCCCCCCCCCC" << std::endl; } void SPV3D_EXPORTSPV3DData::SetPolyData(vtkPolyData* ds) { @@ -69,7 +64,7 @@ void SPV3D_EXPORTSPV3DData::SetPrs(vtkPolyData* ds, const char* entry) auto nbCells( ds->GetNumberOfCells() ); vtkNew solidIdArray; - std::cout << "nb of cells: " <SetNumberOfComponents(1); solidIdArray->SetNumberOfTuples( nbCells ); solidIdArray->SetName("Solid id"); @@ -81,7 +76,6 @@ void SPV3D_EXPORTSPV3DData::SetPrs(vtkPolyData* ds, const char* entry) vtkIdType *pt( solidIdArray->GetPointer(0) ); vtkIdType solidid = SPV3D_Prs::FromEntryToVtkId(entry); - std::cout <<"Presolidid_from_src: " <GetPointer(0); // std::for_each(pt,pt+nbCells,[](vtkIdType& elt) { elt = SPV3D_Prs::cellid;SPV3D_Prs::cellid++; }); @@ -97,26 +91,25 @@ void SPV3D_EXPORTSPV3DData::RemovePrs(const char* entry) unsigned int id; if (!havePrs(entry, id)) { - std::cout << "Can not find solid " << entry<< std::endl; + qWarning() << "Can not find solid with entry: " << entry; return; } _multiGEOMData->RemoveBlock(id); updateSource_for_display(); - //Hide_list.erase(SPV3D_Prs::FromEntryToVtkId(entry)); } void SPV3D_EXPORTSPV3DData::updateSource_for_display() { vtkNew appendFilter; nbsolid = _multiGEOMData->GetNumberOfBlocks(); - std::cout <<"number of block: " << nbsolid<GetBlock(i)); if (polyData) { vtkIdTypeArray* retrievedArray = vtkIdTypeArray::SafeDownCast(polyData->GetCellData()->GetArray("Solid id")); - if (retrievedArray && Hide_list.find(retrievedArray->GetValue(0)) == Hide_list.end()) + if (retrievedArray) appendFilter->AddInputData(polyData); } } @@ -144,13 +137,6 @@ bool SPV3D_EXPORTSPV3DData::IsVisible() const return GetRepresentation()->isVisible(); } -bool SPV3D_EXPORTSPV3DData::SolidIsVisible(vtkIdType solid_id) const -{ - if( Hide_list.find(solid_id) != Hide_list.end() ) - return false; - return true; -} - bool SPV3D_EXPORTSPV3DData::havePrs(const char* entry, unsigned int & id) { vtkIdType solid_id = SPV3D_Prs::FromEntryToVtkId(entry); @@ -167,34 +153,7 @@ bool SPV3D_EXPORTSPV3DData::havePrs(const char* entry, unsigned int & id) id++; } - if (id < _multiGEOMData->GetNumberOfBlocks()) - return true; - else - return false; -} - -void SPV3D_EXPORTSPV3DData::HideSolid(vtkIdType solid_id) -{ - //auto ret = Hide_list.emplace(solid_id); - //if (!ret.second) - // std::cout << SPV3D_Prs::FromVtkIdToEntry(solid_id) << " already exists in Hide_list\n" << std::endl; - const char* entry = SPV3D_Prs::FromVtkIdToEntry(solid_id); - std::cout << "entry from vtkidtoentry: "<< entry << std::endl; - RemovePrs(entry); - updateSource_for_display(); -} - -void SPV3D_EXPORTSPV3DData::DisplaySolid(vtkIdType solid_id) -{ - if (SolidIsVisible(solid_id)) - { - Hide_list.erase(solid_id); - } - else - { - std::cout << SPV3D_Prs::FromVtkIdToEntry(solid_id) << " is not in Hide_list\n" << std::endl; - } - updateSource_for_display(); + return id < _multiGEOMData->GetNumberOfBlocks(); } void SPV3D_EXPORTSPV3DData::Hide() const @@ -260,48 +219,33 @@ void SPV3D_Prs::DisplayIn( SALOME_View* v ) const SALOME_PV3DPrs::DisplayIn(v); } -void SPV3D_Prs::CopyInfo(SPV3D_EXPORTSPV3DData *info) const -{ - if(!_pvRendInfo || !info) - return ; - if(_pvRendInfo == info) - return ; - *_pvRendInfo = *info; -} - bool SPV3D_Prs::IsNull() const { if(_pvRendInfo) - return _pvRendInfo->IsNull(); + { + unsigned int id; + return !_pvRendInfo->havePrs(GetEntry(),id); + } return true; } - - - - void SPV3D_Prs::FillUsingActor(vtkActor *actor) const { std::cout << "Hello FillUsingActor"<isEntryAlreadyExist( GetEntry() ); if(id == -1) // not exist { - std::cout << "FillUsingActor111111111111111"<GetMapper()->Update(); vtkDataObject *ds = actor->GetMapper()->GetInput(); vtkPolyData *ds2 = vtkPolyData::SafeDownCast(ds); if(ds2) { - std::cout << "FillUsingActor2222222222222222éé"<ExportToSPV3D(ds2, GetEntry()); } } - else //exist but hide + else { - std::cout << "FillUsingActor33333333333333é"<DisplayObj_withEntry( GetEntry() ); + qWarning() << "Geometry Object is already in viewer window"; } -} \ No newline at end of file +} diff --git a/src/SPV3D/SPV3D_Prs.h b/src/SPV3D/SPV3D_Prs.h index a320387d8..191fd556b 100644 --- a/src/SPV3D/SPV3D_Prs.h +++ b/src/SPV3D/SPV3D_Prs.h @@ -40,7 +40,10 @@ public: void SetPrs(vtkPolyData* ds, const char* entry); void SetPolyData(vtkPolyData* ds); void RemovePrs(const char* entry); - void SetSourceProducer(pqPipelineSource *sourceProducer) const { _sourceProducer = sourceProducer; } + + // the source producer is initialized in the instantiation of SPV3D_EXPORTSPV3DData + // Normaly, we shouldn't copy another src in SPV3D_EXPORTSPV3DData + //void SetSourceProducer(pqPipelineSource *sourceProducer) const { _sourceProducer = sourceProducer; } pqPipelineSource *GetSourceProducer() const { return _sourceProducer; } void SetRepresentation(pqDataRepresentation *repr) const { _repr = repr; } @@ -52,16 +55,12 @@ public: bool IsVisible() const; bool havePrs(const char* entry, unsigned int & id); void Hide() const; - void HideSolid(vtkIdType solid_id); - void DisplaySolid(vtkIdType solid_id); - bool SolidIsVisible(vtkIdType solid_id) const; private: SPV3D_EXPORTSPV3DData(const SPV3D_EXPORTSPV3DData& other) = default; private: vtkSmartPointer _multiGEOMData; vtkIdType nbsolid; - std::set Hide_list; mutable pqPipelineSource *_sourceProducer = nullptr; mutable pqDataRepresentation *_repr = nullptr; }; @@ -82,11 +81,11 @@ public: void DisplayIn( SALOME_View* v ) const override; - void CopyInfo(SPV3D_EXPORTSPV3DData *info) const; - void SetPVRenderInfo(SPV3D_EXPORTSPV3DData *pvRendInfo) { _pvRendInfo = pvRendInfo; } - void SetSourceProducer(pqPipelineSource *sourceProducer) const { if(_pvRendInfo) _pvRendInfo->SetSourceProducer(sourceProducer); } + // the source producer is initialized in the instantiation of SPV3D_EXPORTSPV3DData + // Normaly, we shouldn't copy another src in SPV3D_EXPORTSPV3DData + //void SetSourceProducer(pqPipelineSource *sourceProducer) const { if(_pvRendInfo) _pvRendInfo->SetSourceProducer(sourceProducer); } pqPipelineSource *GetSourceProducer() const { if(_pvRendInfo) return _pvRendInfo->GetSourceProducer(); return nullptr; } void SetRepresentation(pqDataRepresentation *repr) const { if(_pvRendInfo) _pvRendInfo->SetRepresentation(repr); } @@ -112,7 +111,5 @@ private: std::string _name; static vtkIdType cellid; static vtkIdType nbsolid; - //static std::map vtkIdToEntry; - //static vtkSmartPointer multiGEOMData; }; diff --git a/src/SPV3D/SPV3D_ViewModel.cxx b/src/SPV3D/SPV3D_ViewModel.cxx index 8471c2663..90cae0b6a 100644 --- a/src/SPV3D/SPV3D_ViewModel.cxx +++ b/src/SPV3D/SPV3D_ViewModel.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -205,7 +206,6 @@ void SPV3D_ViewModel::updatePVPrsPipeline(const SPV3D_Prs* aPrs) pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); pqActiveObjects::instance().setActiveView(getView()); pqPipelineSource *mySourceProducer = aPrs->GetSourceProducer(); - aPrs->SetSourceProducer( mySourceProducer ); pqDataRepresentation* myRepr(builder->createDataRepresentation(mySourceProducer->getOutputPort(0),getView(),"CADRepresentation"));//"GeometryRepresentation" vtkSMViewProxy::RepresentationVisibilityChanged(myRepr->getViewProxy(), myRepr->getProxy(), true); aPrs->SetRepresentation(myRepr); @@ -224,7 +224,6 @@ void SPV3D_ViewModel::updatePVPrsPipeline(const SPV3D_Prs* aPrs) */ void SPV3D_ViewModel::Display( const SALOME_PV3DPrs* prs ) { - std::cout << "SPV3D_ViewModel::Display" << std::endl; if(const SPV3D_Prs* aPrs = dynamic_cast( prs )) { updatePVPrsPipeline(aPrs); @@ -233,7 +232,7 @@ void SPV3D_ViewModel::Display( const SALOME_PV3DPrs* prs ) } else { - std::cout<< "Can't update PV presentation pipeline"<< std::endl; + qWarning()<< "SPV3D_ViewModel::Display: Something wrong"; } } diff --git a/src/SPV3D/SPV3D_ViewWindow.cxx b/src/SPV3D/SPV3D_ViewWindow.cxx index 7f4f30243..b4e04f9b5 100644 --- a/src/SPV3D/SPV3D_ViewWindow.cxx +++ b/src/SPV3D/SPV3D_ViewWindow.cxx @@ -244,13 +244,6 @@ SPV3D_Prs *SPV3D_ViewWindow::findOrCreatePrs( const char* entry ) unsigned int SPV3D_ViewWindow::isEntryAlreadyExist( const char* entry ) const { - //std::string entryCpp( entry ); - //for(const auto& prs : myPrs) - //{ - // if(entryCpp == prs.first) - // return prs.second.get(); - //} - //return nullptr; unsigned int id; if(myPrs->havePrs(entry, id)) return id; @@ -273,15 +266,10 @@ SPV3D_ViewWindow::~SPV3D_ViewWindow() bool SPV3D_ViewWindow::isVisible(const Handle(SALOME_InteractiveObject)& theIObject) { auto entry = theIObject->getEntry(); - //for(auto& prs : myPrs) - //{ - // if(entryCpp == prs.first ) - // return prs.second->IsVisible(); - //} unsigned int id; if (myPrs->havePrs(entry, id)) { - return myPrs->SolidIsVisible(SPV3D_Prs::FromEntryToVtkId(entry)); + return true; } return false; } @@ -327,10 +315,6 @@ void SPV3D_ViewWindow::DisplayAll() */ void SPV3D_ViewWindow::EraseAll() { - //for(auto& prs : myPrs) - //{ - // prs.second->Hide(); - //} myPrs->Hide(); if(myModel) myModel->render(); @@ -416,13 +400,3 @@ void SPV3D_ViewWindow::hideEvent( QHideEvent * theEvent ) { emit Hide( theEvent ); } - -void SPV3D_ViewWindow::DisplayObj_withEntry(const char* entry) -{ - myPrs->DisplaySolid(SPV3D_Prs::FromEntryToVtkId(entry)); -} - -void SPV3D_ViewWindow::HideObj_withEntry(const char* entry) -{ - myPrs->HideSolid(SPV3D_Prs::FromEntryToVtkId(entry)); -} \ No newline at end of file diff --git a/src/SPV3D/SPV3D_ViewWindow.h b/src/SPV3D/SPV3D_ViewWindow.h index a0d20b514..fb546dc78 100644 --- a/src/SPV3D/SPV3D_ViewWindow.h +++ b/src/SPV3D/SPV3D_ViewWindow.h @@ -60,8 +60,6 @@ class SPV3D_EXPORT SPV3D_ViewWindow : public PV3DViewer_ViewWindow /* display */ //---------------------------------------------------------------------------- - void DisplayObj_withEntry(const char* entry); - void HideObj_withEntry(const char* entry); //! Redirect the request to #SPV3D_View::Display (to support old code) virtual void Display(const Handle(SALOME_InteractiveObject)& theIObject, bool theImmediatly = true); -- 2.39.2