#include "SPV3D_Prs.h"
#include "SPV3D_ViewWindow.h"
+#include <vtkAppendPolyData.h>
#include "vtkActor.h"
#include "vtkPolyData.h"
#include "vtkCellData.h"
#include "vtkPVTrivialProducer.h"
#include <pqDataRepresentation.h>
-#include <vtkAppendPolyData.h>
+#include <QDebug>
vtkIdType SPV3D_Prs::cellid = 0;
vtkIdType SPV3D_Prs::nbsolid = 0;
-//std::map<vtkIdType, const char*> SPV3D_Prs::vtkIdToEntry;
-//vtkSmartPointer<vtkMultiBlockDataSet> SPV3D_Prs::multiGEOMData = vtkSmartPointer<vtkMultiBlockDataSet>::New();
SPV3D_EXPORTSPV3DData::SPV3D_EXPORTSPV3DData()
{
nbsolid = 0;
_multiGEOMData = vtkSmartPointer<vtkMultiBlockDataSet>::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)
{
auto nbCells( ds->GetNumberOfCells() );
vtkNew<vtkIdTypeArray> solidIdArray;
- std::cout << "nb of cells: " <<nbCells <<std::endl;
+ qInfo() << "nb of cells: " << nbCells;
solidIdArray->SetNumberOfComponents(1);
solidIdArray->SetNumberOfTuples( nbCells );
solidIdArray->SetName("Solid id");
vtkIdType *pt( solidIdArray->GetPointer(0) );
vtkIdType solidid = SPV3D_Prs::FromEntryToVtkId(entry);
- std::cout <<"Presolidid_from_src: " <<solidid << std::endl;
std::for_each(pt,pt+nbCells,[solidid](vtkIdType& elt) { elt = solidid;});
// pt = cellIdArray->GetPointer(0);
// std::for_each(pt,pt+nbCells,[](vtkIdType& elt) { elt = SPV3D_Prs::cellid;SPV3D_Prs::cellid++; });
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<vtkAppendPolyData> appendFilter;
nbsolid = _multiGEOMData->GetNumberOfBlocks();
- std::cout <<"number of block: " << nbsolid<<std::endl;
+ qInfo() <<"number of block: " << nbsolid;
for (unsigned int i = 0; i < nbsolid; ++i)
{
vtkPolyData* polyData = vtkPolyData::SafeDownCast(_multiGEOMData->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);
}
}
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);
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
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"<<std::endl;
- std::cout << "entry: " <<GetEntry()<< std::endl;
- //SPV3D_EXPORTSPV3DData *alreadyExistingSrc = nullptr;
int id = _view->isEntryAlreadyExist( GetEntry() );
if(id == -1) // not exist
{
- std::cout << "FillUsingActor111111111111111"<<std::endl;
actor->GetMapper()->Update();
vtkDataObject *ds = actor->GetMapper()->GetInput();
vtkPolyData *ds2 = vtkPolyData::SafeDownCast(ds);
if(ds2)
{
- std::cout << "FillUsingActor2222222222222222éé"<<std::endl;
_view->ExportToSPV3D(ds2, GetEntry());
}
}
- else //exist but hide
+ else
{
- std::cout << "FillUsingActor33333333333333é"<<std::endl;
- _view->DisplayObj_withEntry( GetEntry() );
+ qWarning() << "Geometry Object is already in viewer window";
}
-}
\ No newline at end of file
+}
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; }
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<vtkMultiBlockDataSet> _multiGEOMData;
vtkIdType nbsolid;
- std::set<vtkIdType> Hide_list;
mutable pqPipelineSource *_sourceProducer = nullptr;
mutable pqDataRepresentation *_repr = nullptr;
};
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); }
std::string _name;
static vtkIdType cellid;
static vtkIdType nbsolid;
- //static std::map<vtkIdType,const char*> vtkIdToEntry;
- //static vtkSmartPointer<vtkMultiBlockDataSet> multiGEOMData;
};
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;
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;
}
*/
void SPV3D_ViewWindow::EraseAll()
{
- //for(auto& prs : myPrs)
- //{
- // prs.second->Hide();
- //}
myPrs->Hide();
if(myModel)
myModel->render();
{
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