From: Anthony Geay Date: Fri, 14 Apr 2023 09:42:45 +0000 (+0200) Subject: Basics for selection in PV3D viewer X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7b785bee40d5c47e830c1aafe0692a0511fe8bd6;p=modules%2Fgui.git Basics for selection in PV3D viewer --- diff --git a/src/LightApp/LightApp_PV3DSelector.cxx b/src/LightApp/LightApp_PV3DSelector.cxx index 961cf8b41..ff1ca466e 100644 --- a/src/LightApp/LightApp_PV3DSelector.cxx +++ b/src/LightApp/LightApp_PV3DSelector.cxx @@ -91,7 +91,7 @@ void LightApp_PV3DSelector::onSelectionChanged() /*! Gets list of selected data owners.(output \a aList). */ -void LightApp_PV3DSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const +void LightApp_PV3DSelector::getSelection( SUIT_DataOwnerPtrList& /*aList*/ ) const { DBG_FUN(); @@ -126,8 +126,10 @@ void LightApp_PV3DSelector::setSelection( const SUIT_DataOwnerPtrList& theList ) DBG_FUN(); if ( myViewer && ( theList.isEmpty() || myViewer->isSelectionEnabled() )) { - if(SUIT_ViewManager* aViewMgr = myViewer->getViewManager()){ - if(SPV3D_ViewWindow* aView = dynamic_cast(aViewMgr->getActiveView())){ + //if(SUIT_ViewManager* aViewMgr = myViewer->getViewManager()) + { + // if(SPV3D_ViewWindow* aView = dynamic_cast(aViewMgr->getActiveView())) + { // if(PV3DViewer_Selector* aSelector = aView->GetSelector()){ // SALOME_ListIO anAppendList; // const SALOME_ListIO& aStoredList = aSelector->StoredIObjects(); diff --git a/src/LightApp/LightApp_PV3DSelector.h b/src/LightApp/LightApp_PV3DSelector.h index 69f883ea1..4586b8520 100644 --- a/src/LightApp/LightApp_PV3DSelector.h +++ b/src/LightApp/LightApp_PV3DSelector.h @@ -1,7 +1,4 @@ -// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2023 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public diff --git a/src/SPV3D/CMakeLists.txt b/src/SPV3D/CMakeLists.txt index 4dbbd264a..7d476458d 100644 --- a/src/SPV3D/CMakeLists.txt +++ b/src/SPV3D/CMakeLists.txt @@ -19,8 +19,6 @@ INCLUDE(UseQtExt) -#add_subdirectory(plugins) - # --- options --- # additional include directories @@ -60,6 +58,7 @@ SET(_moc_HEADERS SPV3D_ViewManager.h SPV3D_ViewModel.h SPV3D_ViewWindow.h + SPV3D_CADSelection.h ) # header files / no moc processing @@ -82,6 +81,7 @@ SET(_other_SOURCES SPV3D_ViewManager.cxx SPV3D_ViewModel.cxx SPV3D_ViewWindow.cxx + SPV3D_CADSelection.cxx ) # sources / to compile diff --git a/src/SPV3D/SPV3D_CADSelection.cxx b/src/SPV3D/SPV3D_CADSelection.cxx new file mode 100644 index 000000000..34331783c --- /dev/null +++ b/src/SPV3D/SPV3D_CADSelection.cxx @@ -0,0 +1,443 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "SPV3D_CADSelection.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//----------------------------------------------------------------------------- +SPV3D_CADSelection::SPV3D_CADSelection(QObject *parent, + pqRenderView* view, SelectionMode mode):QObject(parent) +{ + this->View = view; + this->Mode = mode; + this->PreviousRenderViewMode = -1; + this->MousePosition[0] = 0; + this->MousePosition[1] = 0; + //this->selectionComboBox = comboBox; + + for (size_t i = 0; i < sizeof(this->ObserverIds) / sizeof(this->ObserverIds[0]); ++i) + { + this->ObserverIds[i] = 0; + } + + //QObject::connect(button, SIGNAL(toggled(bool)), this, SLOT(actionTriggered(bool))); + + // if view == nullptr, we track the active view. + if (view == nullptr) + { + QObject::connect( + &pqActiveObjects::instance(), SIGNAL(viewChanged(pqView*)), this, SLOT(setView(pqView*))); + // this ensure that the enabled-state is set correctly. + this->setView(nullptr); + } + + this->setRepresentation(nullptr); + QObject::connect(&pqActiveObjects::instance(), + SIGNAL(representationChanged(pqDataRepresentation*)), this, + SLOT(setRepresentation(pqDataRepresentation*))); + + vtkPVRenderViewSettings::GetInstance()->SetEnableFastPreselection(true); + + this->updateEnableState(); +} + +//----------------------------------------------------------------------------- +SPV3D_CADSelection::~SPV3D_CADSelection() +{ + this->cleanupObservers(); +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::SetMode(const SPV3D_CADSelection::SelectionMode mode) +{ + this->Mode = mode; +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::updateEnableState() +{ + this->endSelection(); + + //auto paction = this->parentAction(); + //bool state = false; + if (this->Representation) + { + vtkSMProxy* proxy = this->Representation->getProxy(); + vtkSMStringVectorProperty* prop = + vtkSMStringVectorProperty::SafeDownCast(proxy->GetProperty("ColorArrayName")); + if (prop) + { + int association = std::atoi(prop->GetElement(3)); + const char* arrayName = prop->GetElement(4); + + vtkPVDataInformation* dataInfo = this->Representation->getInputDataInformation(); + + vtkPVDataSetAttributesInformation* info = nullptr; + if (association == vtkDataObject::CELL && + this->Mode == SELECT_FACES) + { + info = dataInfo->GetCellDataInformation(); + } + if (association == vtkDataObject::POINT && + this->Mode == SELECT_VERTICES) + { + info = dataInfo->GetPointDataInformation(); + } + + if (info) + { + /*vtkPVArrayInformation* arrayInfo = */info->GetArrayInformation(arrayName); + //state = arrayInfo && arrayInfo->GetDataType() == VTK_ID_TYPE; + } + } + } + //paction->setEnabled(state); +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::actionTriggered(bool val) +{ + if (val) + { + this->beginSelection(); + } + else + { + this->endSelection(); + } +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::setView(pqView* view) +{ + if (this->View != view) + { + // if we were currently in selection, finish that before changing the view. + this->endSelection(); + } + + this->View = qobject_cast(view); + + // update enable state. + //this->parentAction()->setEnabled(this->View != nullptr); +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::setRepresentation(pqDataRepresentation* representation) +{ + if (this->Representation != representation) + { + // if we are currently in selection, finish that before changing the representation. + this->endSelection(); + + if (this->Representation != nullptr) + { + QObject::disconnect(this->RepresentationConnection); + } + + this->Representation = representation; + + if (this->Representation != nullptr) + { + this->RepresentationConnection = this->connect( + this->Representation, SIGNAL(colorArrayNameModified()), SLOT(updateEnableState())); + } + + // update enable state. + this->updateEnableState(); + } +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::beginSelection() +{ + if (!this->View) + { + return; + } + + //QAction* actn = this->parentAction(); + //if (actn->isCheckable()) + { + //this->selectionComboBox->setEnabled(false); + + vtkSMRenderViewProxy* rmp = this->View->getRenderViewProxy(); + vtkSMPropertyHelper(rmp, "InteractionMode").Get(&this->PreviousRenderViewMode); + + //QString currentPrimitive = this->selectionComboBox->currentText(); + pqCoreUtilities::promptUser("SPV3D_CADSelection", QMessageBox::Information, + "Interactive Selection Information", + "You are entering interactive selection mode to highlight.\n" + "Move the mouse point over the dataset to interactively highlight elements.\n\n" + "Press Ctrl + click to add the currently highlighted element.\n" + "Press Shift + click to remove the element.\n\n" + "Click on Select button to exit this mode.", + QMessageBox::Ok | QMessageBox::Save); + this->View->setCursor(Qt::CrossCursor); + vtkSMPropertyHelper(rmp, "InteractionMode").Set(vtkPVRenderView::INTERACTION_MODE_SELECTION); + + rmp->UpdateVTKObjects(); + + // Setup observer. + assert(this->ObserverIds[0] == 0 && this->ObservedObject == nullptr && this->ObserverIds[1] == 0); + this->ObservedObject = rmp->GetInteractor(); + this->ObserverIds[0] = this->ObservedObject->AddObserver( + vtkCommand::MouseMoveEvent, this, &SPV3D_CADSelection::onMouseMove); + this->ObserverIds[1] = this->ObservedObject->AddObserver(vtkCommand::LeftButtonReleaseEvent, + this, &SPV3D_CADSelection::onLeftButtonRelease); + this->ObserverIds[2] = this->ObservedObject->AddObserver(vtkCommand::RightButtonPressEvent, + this, &SPV3D_CADSelection::onRightButtonPress); + this->ObserverIds[3] = this->ObservedObject->AddObserver(vtkCommand::RightButtonReleaseEvent, + this, &SPV3D_CADSelection::onRightButtonRelease); + + //this->parentAction()->setChecked(true); + } +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::endSelection() +{ + if (!this->View) + { + return; + } + + if (this->PreviousRenderViewMode == -1) + { + return; + } + + //QAction* actn = this->parentAction(); + //if (actn->isCheckable()) + { + vtkSMRenderViewProxy* rmp = this->View->getRenderViewProxy(); + vtkSMPropertyHelper(rmp, "InteractionMode").Set(this->PreviousRenderViewMode); + this->PreviousRenderViewMode = -1; + rmp->UpdateVTKObjects(); + this->View->setCursor(QCursor()); + this->cleanupObservers(); + //this->parentAction()->setChecked(false); + + if (this->CurrentRepresentation != nullptr) + { + vtkSMSessionProxyManager* pxm = rmp->GetSessionProxyManager(); + vtkSMProxy* emptySel = pxm->NewProxy("sources", "IDSelectionSource"); + + this->CurrentRepresentation->UpdateVTKObjects(); + this->CurrentRepresentation = nullptr; + emptySel->Delete(); + + rmp->StillRender(); + } + + //this->selectionComboBox->setEnabled(true); + } +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::onMouseMove() +{ + if (!this->DisablePreSelection && vtkPVRenderViewSettings::GetInstance()->GetEnableFastPreselection()) + { + this->fastSelection(true); + } +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::onLeftButtonRelease() +{ + if (vtkPVRenderViewSettings::GetInstance()->GetEnableFastPreselection()) + { + this->fastSelection(); + } +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::onRightButtonPress() +{ + this->DisablePreSelection = true; +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::onRightButtonRelease() +{ + this->DisablePreSelection = false; +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::fastSelection(bool presel) +{ + vtkSMRenderViewProxy* rmp = this->View->getRenderViewProxy(); + assert(rmp != nullptr); + + int x = rmp->GetInteractor()->GetEventPosition()[0]; + int y = rmp->GetInteractor()->GetEventPosition()[1]; + this->MousePosition[0] = x; + this->MousePosition[1] = y; + + int region[4] = { x, y, x, y }; + + vtkNew selectedRepresentations; + vtkNew selectionSources; + bool status = false; + // Do the selection on the current region + switch (this->Mode) + { + case SELECT_SOLIDS: + status = rmp->SelectSurfaceCells(region, selectedRepresentations, selectionSources, false, 0, false, "Solid id"); + break; + case SELECT_FACES: + status = rmp->SelectSurfaceCells(region, selectedRepresentations, selectionSources, false, 0, false, "Face id"); + break; + case SELECT_EDGES: + status = rmp->SelectSurfaceCells(region, selectedRepresentations, selectionSources, false, 0, false, "Edge id"); + break; + case SELECT_VERTICES: + status = rmp->SelectSurfaceCells(region, selectedRepresentations, selectionSources, false, 0, false, "Vertex id"); + break; + default: + qCritical("Invalid call to SPV3D_CADSelection::fastSelection"); + return; + } + + vtkSMRepresentationProxy* repr = + vtkSMRepresentationProxy::SafeDownCast(selectedRepresentations->GetItemAsObject(0)); + + if (repr && !presel) + { + repr->InvokeCommand("BeginSelect"); + } + + // If something has been preselected or selected + if (status) + { + vtkSMRepresentationProxy* repr = + vtkSMRepresentationProxy::SafeDownCast(selectedRepresentations->GetItemAsObject(0)); + + // If the selection occurs on a new represention, clean the selection on the + // current representation before continuing + if (this->CurrentRepresentation != nullptr && repr != this->CurrentRepresentation) + { + vtkSMSessionProxyManager* pxm = repr->GetSessionProxyManager(); + vtkSMProxy* emptySel = pxm->NewProxy("sources", "IDSelectionSource"); + + vtkSMPropertyHelper(this->CurrentRepresentation, "Selection").Set(emptySel); + this->CurrentRepresentation->UpdateVTKObjects(); + emptySel->Delete(); + } + + this->CurrentRepresentation = repr; + + // Set the selection (selection source) to the current representation + vtkSMSourceProxy* sel = vtkSMSourceProxy::SafeDownCast(selectionSources->GetItemAsObject(0)); + vtkSMPropertyHelper(repr, "Selection").Set(sel); + repr->UpdateVTKObjects(); + } + // If nothing has been selected then clean current representation + // with an "empty" selection source + else if (this->CurrentRepresentation != nullptr) + { + vtkSMSessionProxyManager* pxm = rmp->GetSessionProxyManager(); + vtkSMProxy* emptySel = pxm->NewProxy("sources", "IDSelectionSource"); + + vtkSMPropertyHelper(this->CurrentRepresentation, "Selection").Set(emptySel); + this->CurrentRepresentation->UpdateVTKObjects(); + this->CurrentRepresentation = nullptr; + emptySel->Delete(); + } + + this->View->forceRender(); + this->View->forceRender(); + // TODO improve this to avoid double render + + if (repr && !presel) + { + repr->InvokeCommand("EndSelect"); + } +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::selectionChanged(vtkObject*, unsigned long, void* calldata) +{ + BEGIN_UNDO_EXCLUDE(); + + int selectionModifier = this->getSelectionModifier(); + int* region = reinterpret_cast(calldata); +// Simple version check to change once 5.10 support is dropped + this->View->selectCellsOnSurface(region, selectionModifier); + //this->View->selectOnSurface(region, selectionModifier); + END_UNDO_EXCLUDE(); + + this->endSelection(); +} + +//----------------------------------------------------------------------------- +int SPV3D_CADSelection::getSelectionModifier() +{ + int selectionModifier = pqView::PV_SELECTION_DEFAULT;//this->Superclass::getSelectionModifier(); + + vtkSMRenderViewProxy* rmp = this->View->getRenderViewProxy(); + assert(rmp != nullptr); + + bool ctrl = rmp->GetInteractor()->GetControlKey() == 1; + bool shift = rmp->GetInteractor()->GetShiftKey() == 1; + selectionModifier = pqView::PV_SELECTION_TOGGLE; + + if (ctrl) + { + selectionModifier = pqView::PV_SELECTION_ADDITION; + } + else if (shift) + { + selectionModifier = pqView::PV_SELECTION_SUBTRACTION; + } + return selectionModifier; +} + +//----------------------------------------------------------------------------- +void SPV3D_CADSelection::cleanupObservers() +{ + for (size_t i = 0; i < sizeof(this->ObserverIds) / sizeof(this->ObserverIds[0]); ++i) + { + if (this->ObservedObject != nullptr && this->ObserverIds[i] > 0) + { + this->ObservedObject->RemoveObserver(this->ObserverIds[i]); + } + this->ObserverIds[i] = 0; + } + this->ObservedObject = nullptr; +} diff --git a/src/SPV3D/SPV3D_CADSelection.h b/src/SPV3D/SPV3D_CADSelection.h new file mode 100644 index 000000000..b73fa7d92 --- /dev/null +++ b/src/SPV3D/SPV3D_CADSelection.h @@ -0,0 +1,160 @@ +// Copyright (C) 2023 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#pragma once + +#include + +#include +#include + +#include +#include +#include +#include +#include + +class vtkObject; +class pqView; +class pqRenderView; +class vtkIntArray; +class pqDataRepresentation; +class vtkSMRepresentationProxy; +class vtkSMSourceProxy; + +/** + * SPV3D_CADSelection handles various selection modes available on + * RenderViews. Simply create multiple instances of + * SPV3D_CADSelection to handle selection modes for that RenderView. + * SPV3D_CADSelection uses internal static members to ensure that + * at most 1 view (and 1 type of selection) is in selection-mode at any given + * time. + */ +class SPV3D_CADSelection : public QObject +{ + Q_OBJECT + +public: + enum SelectionMode + { + SELECT_SOLIDS, + SELECT_FACES, + SELECT_EDGES, + SELECT_VERTICES + }; + + /** + * If \c view is nullptr, this reaction will track the active-view maintained by + * pqActiveObjects. + */ + SPV3D_CADSelection(QObject *parent, pqRenderView* view, SelectionMode mode); + + ~SPV3D_CADSelection() override; + + /** + * Set the selectionMode + */ + void SetMode(const SPV3D_CADSelection::SelectionMode mode); + +public Q_SLOTS: + /** + * For checkable actions, this calls this->beginSelection() or + * this->endSelection() is val is true or false, respectively. For + * non-checkable actions, this call this->beginSelection() and + * this->endSelection() in that order. + */ + virtual void actionTriggered(bool val); + +private Q_SLOTS: + /** + * Called when this object was created with nullptr as the view and the active + * view changes. + */ + void setView(pqView* view); + + /** + * Called when the active representation changes. + */ + void setRepresentation(pqDataRepresentation* representation); + + /** + * starts the selection i.e. setup render view in selection mode. + */ + void beginSelection(); + + /** + * finishes the selection. Doesn't cause the selection, just returns the + * render view to previous interaction mode. + */ + void endSelection(); + + void updateEnableState(); + + ///@{ + /** + * Disable preselection during rotation using the right button. + */ + void onRightButtonPress(); + void onRightButtonRelease(); + ///@} + +private: + + /** + * callback called when the vtkPVRenderView is done with selection. + */ + void selectionChanged(vtkObject*, unsigned long, void* calldata); + + /** + * callback called for mouse move events when in 'interactive selection' + * modes. + */ + void onMouseMove(); + + /** + * callback called for click events when in 'interactive selection' modes. + */ + void onLeftButtonRelease(); + + // Get the current state of selection modifier + int getSelectionModifier(); + + /** + * makes fast selection. + */ + void fastSelection(bool presel = false); + + /** + * cleans up observers. + */ + void cleanupObservers(); + + Q_DISABLE_COPY(SPV3D_CADSelection) + QPointer View; + QPointer Representation; + QMetaObject::Connection RepresentationConnection; + vtkSMRepresentationProxy* CurrentRepresentation = nullptr; + SelectionMode Mode; + int PreviousRenderViewMode; + vtkWeakPointer ObservedObject; + unsigned long ObserverIds[4]; + int MousePosition[2]; + QComboBox* selectionComboBox; + bool DisablePreSelection = false; +}; diff --git a/src/SPV3D/SPV3D_Prs.cxx b/src/SPV3D/SPV3D_Prs.cxx index d10efd876..f06108fef 100644 --- a/src/SPV3D/SPV3D_Prs.cxx +++ b/src/SPV3D/SPV3D_Prs.cxx @@ -1,7 +1,4 @@ -// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2023 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -27,7 +24,8 @@ #include "SPV3D_ViewWindow.h" #include "vtkActor.h" -#include "vtkDataSet.h" +#include "vtkPolyData.h" +#include "vtkCellData.h" #include "vtkMapper.h" #include "pqServer.h" #include "pqApplicationCore.h" @@ -38,6 +36,7 @@ #include "vtkPVTrivialProducer.h" #include + //--------------------------------------------------------- #define USE_DEBUG #define MBCLASSNAME "SPV3D_Prs" @@ -80,8 +79,21 @@ void SPV3D_Prs::FillUsingActor(vtkActor *actor) const if(alreadyExistingSrc && !alreadyExistingSrc->GetSourceProducer()) { actor->GetMapper()->Update(); - vtkDataObject *ds = actor->GetMapper()->GetInput();//GetOutputDataObject(0); - vtkDataSet *ds2 = vtkDataSet::SafeDownCast(ds); + vtkDataObject *ds = actor->GetMapper()->GetInput(); + vtkPolyData *ds3 = vtkPolyData::SafeDownCast(ds); + vtkNew ds4; + if(ds3) + { + ds4->ShallowCopy( ds3 ); + vtkNew solidIdArray; + auto nbCells( ds4->GetNumberOfCells() ); + solidIdArray->SetNumberOfComponents(1); + solidIdArray->SetNumberOfTuples( nbCells ); + solidIdArray->SetName("Solid id"); + vtkIdType *pt( solidIdArray->GetPointer(0) ); + std::for_each(pt,pt+nbCells,[](vtkIdType& elt) { elt = 0; }); + ds4->GetCellData()->AddArray( solidIdArray ); + } // pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:"))); pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); @@ -90,7 +102,7 @@ void SPV3D_Prs::FillUsingActor(vtkActor *actor) const vtkSMSourceProxy *producer(vtkSMSourceProxy::SafeDownCast(producerBase)); vtkObjectBase *clientSideObject(producer->GetClientSideObject()); vtkPVTrivialProducer *clientSideObjectCast = vtkPVTrivialProducer::SafeDownCast(clientSideObject); - clientSideObjectCast->SetOutput(ds2); + clientSideObjectCast->SetOutput(ds4); mySourceProducer->updatePipeline(); pqProxy *producerBase2( getPQProxy(producerBase) ); if(producerBase2 && !_name.empty()) diff --git a/src/SPV3D/SPV3D_ViewModel.cxx b/src/SPV3D/SPV3D_ViewModel.cxx index 1c761d508..2e084f496 100644 --- a/src/SPV3D/SPV3D_ViewModel.cxx +++ b/src/SPV3D/SPV3D_ViewModel.cxx @@ -1,7 +1,4 @@ -// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2023 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -152,7 +149,7 @@ void SPV3D_ViewModel::setViewManager(SUIT_ViewManager* theViewManager) /*! Builds popup for vtk viewer */ -void SPV3D_ViewModel::contextMenuPopup( QMenu* thePopup ) +void SPV3D_ViewModel::contextMenuPopup( QMenu */*thePopup*/ ) { DBG_FUN(); @@ -187,7 +184,6 @@ void SPV3D_ViewModel::enableSelection(bool isEnabled) ARG(isEnabled); mySelectionEnabled = isEnabled; //!! To be done for view windows - if (SUIT_ViewManager* aViewManager = getViewManager()) { QVector aViews = aViewManager->getViews(); for ( int i = 0; i < aViews.count(); i++ ) @@ -200,11 +196,11 @@ void SPV3D_ViewModel::enableSelection(bool isEnabled) if(!isEnabled) { //clear current selection in the viewer bool blocked = blockSignals( true ); - if ( SUIT_ViewManager* aViewMgr = getViewManager() ) { + /*if ( SUIT_ViewManager* aViewMgr = getViewManager() ) { if( SPV3D_ViewWindow* aViewWindow = dynamic_cast( aViewMgr->getActiveView() ) ){ //NYI } - } + }*/ blockSignals( blocked ); } @@ -231,16 +227,19 @@ void SPV3D_ViewModel::Display( const SALOME_PV3DPrs* prs ) pqActiveObjects::instance().setActiveView(getView()); pqPipelineSource *mySourceProducer = aPrs->GetSourceProducer(); aPrs->SetSourceProducer( mySourceProducer ); - pqDataRepresentation* myRepr(builder->createDataRepresentation(mySourceProducer->getOutputPort(0),getView(),"GeometryRepresentation")); + pqDataRepresentation* myRepr(builder->createDataRepresentation(mySourceProducer->getOutputPort(0),getView(),"CADRepresentation"));//"GeometryRepresentation" vtkSMViewProxy::RepresentationVisibilityChanged(myRepr->getViewProxy(), myRepr->getProxy(), true); aPrs->SetRepresentation(myRepr); } pqDataRepresentation* myRepr = aPrs->GetRepresentation(); myRepr->setVisible(1); vtkSMPVRepresentationProxy* proxy(dynamic_cast(myRepr->getProxy())); - vtkSMPropertyHelper inputHelper(proxy, "Input"); - vtkSMSourceProxy* input = vtkSMSourceProxy::SafeDownCast(inputHelper.GetAsProxy()); - input->UpdatePipeline(); + if(proxy) + { + vtkSMPropertyHelper inputHelper(proxy, "Input"); + vtkSMSourceProxy* input = vtkSMSourceProxy::SafeDownCast(inputHelper.GetAsProxy()); + input->UpdatePipeline(); + } getView()->resetDisplay(); getView()->render(); } @@ -251,7 +250,7 @@ void SPV3D_ViewModel::Display( const SALOME_PV3DPrs* prs ) \param prs - presentation \param forced - removes object from view */ -void SPV3D_ViewModel::Erase( const SALOME_PV3DPrs* prs, const bool forced ) +void SPV3D_ViewModel::Erase( const SALOME_PV3DPrs* prs, const bool /*forced*/ ) { DBG_FUN(); @@ -311,7 +310,7 @@ bool SPV3D_ViewModel::isVisible( const Handle(SALOME_InteractiveObject)& io ) \Collect objects visible in viewer \param theList - visible objects collection */ -void SPV3D_ViewModel::GetVisible( SALOME_ListIO& theList ) +void SPV3D_ViewModel::GetVisible( SALOME_ListIO &/*theList*/ ) { // NYI } @@ -327,7 +326,7 @@ void SPV3D_ViewModel::Repaint() } -void SPV3D_ViewModel::onViewCreated( SUIT_ViewWindow* view) { +void SPV3D_ViewModel::onViewCreated( SUIT_ViewWindow */*view*/) { DBG_FUN(); #ifdef VGL_WORKAROUND if ( SPV3D_ViewWindow* svw = dynamic_cast( view ) ) @@ -335,8 +334,6 @@ void SPV3D_ViewModel::onViewCreated( SUIT_ViewWindow* view) { #endif } - - //----------------------------------------------------------------------------- void SPV3D_ViewModel::onSourceCreated(pqPipelineSource* source) { diff --git a/src/SPV3D/SPV3D_ViewModel.h b/src/SPV3D/SPV3D_ViewModel.h index 1c9c9469b..b9690501f 100644 --- a/src/SPV3D/SPV3D_ViewModel.h +++ b/src/SPV3D/SPV3D_ViewModel.h @@ -1,7 +1,4 @@ -// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2023 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -20,32 +17,19 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef SPV3D_VIEWMODEL_H -#define SPV3D_VIEWMODEL_H +#pragma once #include "SPV3D.h" #include "PV3DViewer_ViewModel.h" -#include "Qtx.h" - #include #include #include -#include -#include - class QMouseEvent; - -class SPV3D_ViewWindow; -class PV3DViewer_Actor; - class pqPipelineSource; -class pqCADSelection; -class pqCADGroupModel; class pqView; - //! Extends two interfaces #SPV3D_ViewModelBase and #SALOME_View class SPV3D_EXPORT SPV3D_ViewModel : public PV3DViewer_ViewModel, public SALOME_View { @@ -117,13 +101,6 @@ protected: pqPipelineSource* MeshSource = nullptr; private: - pqCADSelection* selection; - pqCADGroupModel* GroupModel; - int GroupCounter = 0; - -private: - bool mySelectionEnabled; + bool mySelectionEnabled; pqView *_view = nullptr; }; - -#endif diff --git a/src/SPV3D/SPV3D_ViewWindow.cxx b/src/SPV3D/SPV3D_ViewWindow.cxx index 036b9fc2d..b8f00272a 100644 --- a/src/SPV3D/SPV3D_ViewWindow.cxx +++ b/src/SPV3D/SPV3D_ViewWindow.cxx @@ -80,6 +80,7 @@ SPV3D_ViewWindow::SPV3D_ViewWindow(SUIT_Desktop* theDesktop, SPV3D_ViewModel* th } #include +#include #include #include #include @@ -88,6 +89,8 @@ SPV3D_ViewWindow::SPV3D_ViewWindow(SUIT_Desktop* theDesktop, SPV3D_ViewModel* th #include #include +#include "SPV3D_CADSelection.h" + void SPV3D_ViewWindow::init() { pqView *view(myModel->getView()); @@ -96,6 +99,7 @@ void SPV3D_ViewWindow::init() wid->setParent( this ); setCentralWidget( wid ); // + this-> myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), // title (language-dependant) QString( "PV3DViewerViewOperations" ), // name (language-independant) false ); @@ -116,6 +120,37 @@ void SPV3D_ViewWindow::init() QObject::connect(selectionReaction, QOverload::of(&pqRenderViewSelectionReaction::selectedCustomBox), this, &SPV3D_ViewWindow::pickCenterOfRotation); + // + mySelection = new SPV3D_CADSelection(this,renderView,SPV3D_CADSelection::SELECT_SOLIDS); + QAction *selectionAction = toolMgr()->toolBar(myToolBar)->addAction(SUIT_Session::session()->resourceMgr()->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_STANDARD" ) ), tr( "MNU_SVTK_PRESELECTION_STANDARD" ) ); + selectionAction->setCheckable(true); + QObject::connect(selectionAction, &QAction::toggled, this, &SPV3D_ViewWindow::goSelect); +} + +void SPV3D_ViewWindow::goSelect(bool val) +{ + if(val) + { + pqView* activeView(myModel->getView()); + if (!activeView) + { + return; + } + for(const auto& elt : myPrs) + { + pqPipelineSource *geometrySource = elt.second->GetSourceProducer(); + if(geometrySource) + { + vtkSMProxy* repr = activeView->getViewProxy()->FindRepresentation( + geometrySource->getSourceProxy(), 0); + repr->InvokeCommand("Reset"); + } + } + activeView->forceRender(); + activeView->render(); + activeView->resetDisplay(); + } + mySelection->actionTriggered(val); } //----------------------------------------------------------------------------- @@ -264,12 +299,10 @@ bool SPV3D_ViewWindow::isVisible(const Handle(SALOME_InteractiveObject)& theIObj \param theIO - object \param theImmediatly - update viewer */ -void SPV3D_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO, - bool theImmediatly) +void SPV3D_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& /*theIO*/, + bool /*theImmediatly*/) { DBG_FUN(); - - // NYI } /*! @@ -277,8 +310,8 @@ void SPV3D_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO, \param theIO - object \param theImmediatly - update viewer */ -void SPV3D_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO, - bool theImmediatly) +void SPV3D_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& /*theIO*/, + bool /*theImmediatly*/) { DBG_FUN(); } @@ -287,10 +320,9 @@ void SPV3D_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO, Display only passed object \param theIO - object */ -void SPV3D_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO) +void SPV3D_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& /*theIO*/) { DBG_FUN(); - // NYI } @@ -300,7 +332,6 @@ void SPV3D_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO void SPV3D_ViewWindow::DisplayAll() { DBG_FUN(); - // NYI } /*! @@ -322,7 +353,6 @@ void SPV3D_ViewWindow::EraseAll() */ void SPV3D_ViewWindow::Repaint(bool )//(bool theUpdateTrihedron) { - // NYI if(myModel) myModel->render(); } @@ -331,10 +361,9 @@ void SPV3D_ViewWindow::Repaint(bool )//(bool theUpdateTrihedron) Enables/disables selection. \param theEnable if true - selection will be enabled */ -void SPV3D_ViewWindow::SetSelectionEnabled( bool theEnable ) +void SPV3D_ViewWindow::SetSelectionEnabled( bool /*theEnable*/ ) { DBG_FUN(); - // NYI } /*! diff --git a/src/SPV3D/SPV3D_ViewWindow.h b/src/SPV3D/SPV3D_ViewWindow.h index 505ddb9a4..b3cc7f08c 100644 --- a/src/SPV3D/SPV3D_ViewWindow.h +++ b/src/SPV3D/SPV3D_ViewWindow.h @@ -20,8 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef SPV3D_VIEWWINDOW_H -#define SPV3D_VIEWWINDOW_H +#pragma once #ifdef WIN32 #pragma warning( disable:4251 ) @@ -35,53 +34,14 @@ #include "SALOME_InteractiveObject.hxx" #include "SALOME_ListIO.hxx" -#include -#include - #include #include -class SUIT_Desktop; -class SUIT_ResourceMgr; - -class PV3DViewer_Actor; -class PV3DViewer_Trihedron; - class SPV3D_ViewModel; -class SPV3D_Selector; -class SPV3D_View; - -class SPV3D_CubeAxesActor2D; - -class vtkRenderer; -class vtkRenderWindow; -class vtkRenderWindowInteractor; -class vtkInteractorStyle; -class vtkCallbackCommand; - -class SPV3D_RenderWindowInteractor; -class SPV3D_Renderer; -class SPV3D_NonIsometricDlg; -class SPV3D_UpdateRateDlg; -class SPV3D_CubeAxesDlg; -class SPV3D_SetRotationPointDlg; -class SPV3D_InteractorStyle; -class SPV3D_KeyFreeInteractorStyle; -class SPV3D_ViewParameterDlg; -class SPV3D_Recorder; -class SPV3D_Prs; - -namespace salomevtk -{ - class vtkPVAxesWidget; -} - -class vtkObject; -class QtxAction; - +class SPV3D_CADSelection; //! Define a container for SALOME PV3D view window -class SPV3D_EXPORT SPV3D_ViewWindow : public PV3DViewer_ViewWindow //SUIT_ViewWindow +class SPV3D_EXPORT SPV3D_ViewWindow : public PV3DViewer_ViewWindow { Q_OBJECT @@ -133,6 +93,7 @@ public slots: virtual void hideEvent( QHideEvent * ); void showCenterAxes(bool); void pickCenterOfRotation(int posx, int posy); + void goSelect(bool val); protected slots: void onKeyPressed(QKeyEvent* event); @@ -143,6 +104,7 @@ protected slots: void onMouseMoving(QMouseEvent* event); protected: + SPV3D_CADSelection *mySelection = nullptr; int myToolBar = -1; SPV3D_ViewModel* myModel; std::list< std::pair > > myPrs; @@ -151,5 +113,3 @@ protected: #ifdef WIN32 #pragma warning( default:4251 ) #endif - -#endif diff --git a/src/SPV3D/plugins/CMakeLists.txt b/src/SPV3D/plugins/CMakeLists.txt deleted file mode 100644 index 72c37840f..000000000 --- a/src/SPV3D/plugins/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -option(BUILD_SHARED_LIBS "Build shared libraries" ON) - -paraview_plugin_scan( - PLUGIN_FILES - cadSources/paraview.plugin - cadRepresentations/paraview.plugin - PROVIDES_PLUGINS plugins - ENABLE_BY_DEFAULT ON - HIDE_PLUGINS_FROM_CACHE ON) - -paraview_plugin_build( - RUNTIME_DESTINATION "${CMAKE_INSTALL_BINDIR}" - LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}" - LIBRARY_SUBDIRECTORY "${PARAVIEW_PLUGIN_SUBDIR}" - PLUGINS_FILE_NAME "salome.xml" - INSTALL_EXPORT SPV3DParaViewPlugins - CMAKE_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SPV3D - LIBRARY_SUBDIRECTORY "salome" - PLUGINS ${plugins} - TARGET salome_paraview_plugins) diff --git a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/CADRepresentation.xml b/src/SPV3D/plugins/cadRepresentations/CADRepresentations/CADRepresentation.xml deleted file mode 100644 index b79338f24..000000000 --- a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/CADRepresentation.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - CAD Representation. - - - - Set the input to the representation. Must be a vtkPolyData producer. - - - - - - - - - - Set the selection. - - - - - Set the visibility for this representation. - - - - - Set the group to show in Group Mode. - - - - - Set the opacity of the given group. - - - - - - Enable or disable the Group Mode. - - - - - - - - - diff --git a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/CMakeLists.txt b/src/SPV3D/plugins/cadRepresentations/CADRepresentations/CMakeLists.txt deleted file mode 100644 index b8961707b..000000000 --- a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -set(classes - vtkCADMapper - vtkCADRepresentation) - -vtk_module_add_module(CADRepresentations - FORCE_STATIC - CLASSES ${classes}) - -paraview_add_server_manager_xmls( - XMLS CADRepresentation.xml) diff --git a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/MBDebug.h b/src/SPV3D/plugins/cadRepresentations/CADRepresentations/MBDebug.h deleted file mode 100644 index 53f42ed1c..000000000 --- a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/MBDebug.h +++ /dev/null @@ -1,243 +0,0 @@ -#ifndef MBDebug_HeaderFile -#define MBDebug_HeaderFile - -//--------------------------------------------------------------- -// Usage of the logging facilities: -// -// (1) At the beginning of each class file to be debugged, there -// should be a static string variable defined with the name -// of the class. Then, include the "MBDebug.h" header file. -// -// //--------------------------------------------------------- -// #define USE_DEBUG -// static const char *dbg_class = "ClassName"; -// #include "MBDebug.h" -// //--------------------------------------------------------- -// -// (2) At the beginning of each class method, call the DBG_FUN -// macro. -// -// int ClassName::MyMethod(int x) -// { -// DBG_FUN(); -// ... -// } -// -// NOTE: For static methods, call the DBG_FUNC() macro!! -//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// This debugging/logging class is a "header-only" solution and -// does NOT require any additional implementation (.cpp) file! -//--------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef MB_IGNORE_QT -# include -#endif - -//--------------------------------------------------------------- -// Set the debug flags dependent on the preprocessor definitions -//--------------------------------------------------------------- -#ifdef USE_DEBUG -# define MBS_DEBUG_FLAG MBDebug::DF_DEBUG -#else -# define MBS_DEBUG_FLAG 0 -#endif /*DEBUG*/ - -#define MBS_DBG_FLAGS (MBS_DEBUG_FLAG) - - -//--------------------------------------------------------------- -// Define the global debug macros -//--------------------------------------------------------------- -#define DLOG MBDebug::LogPrint() -#define RETURN(var) { RET(var); return (var); } - -#ifdef USE_DEBUG - -# define DBG_FUN() MBDebug _dbg(dbg_class, __FUNCTION__, MBS_DBG_FLAGS, (void*)this) -# define DBG_FUNC() MBDebug _dbg(dbg_class, __FUNCTION__, MBS_DBG_FLAGS) -# define DBG_FUNB(blk) MBDebug _dbg(dbg_class, blk, MBS_DBG_FLAGS) -# define MSGEL(txt) MBDebug::LogPrint() << txt << std::endl -# define PRINT(txt) MBDebug::LogPrint() << txt -# define SHOW2(var,typ) DumpVar(#var,(typ)(var)) -# define SHOW(var) DumpVar(#var,var) -# define ARG(var) do { PRINT("in:"); DumpVar(#var,var); } while (0) -# define ARG2(var,typ) do { PRINT("in:"); DumpVar(#var,(typ)(var)); } while (0) -# define RET(var) do { PRINT("out:"); DumpVar(#var,var); } while (0) -# define MSG(txt) MBDebug::LogPrint() << txt - -#else /*!USE_DEBUG*/ - -# define DBG_FUN() -# define DBG_FUNC() -# define DBG_FUNB(blk) -# define MSGEL(txt) -# define PRINT(txt) -# define SHOW2(var,typ) -# define SHOW(var) -# define ARG(var) -# define ARG2(var,typ) -# define RET(var) -# define MSG(txt) - -#endif /*USE_DEBUG*/ - - -//--------------------------------------------------------------- -// Declare the debugging and profiling class -//--------------------------------------------------------------- -class MBDebug -{ -public: - enum { - DF_NONE = 0x00, // no debug - DF_DEBUG = 0x01 // debug a function - }; - - MBDebug(const char* aClassName, const char* aFuncName, const short aFlag, void* aThis=NULL) - :mClassName(aClassName),mFuncName(aFuncName),mThis(aThis),mFlags((unsigned char)aFlag) - { - if (mFlags & (DF_DEBUG)) - { - std::cout << "{ENTER: " << mClassName + "::" + mFuncName; - if (mThis) std::cout << "(this=" << mThis << ")"; - std::cout << std::endl; - } - } - virtual ~MBDebug() - { - if (mFlags & (DF_DEBUG)) - std::cout << "}LEAVE: " << mClassName << "::" << mFuncName << std::endl; - } - - // Log file output management - static std::ostream& LogPrint() { return std::cout; } - -private: - std::string mClassName; // Name of class to be debugged - std::string mFuncName; // Name of function to be debugged - void* mThis; // The "this" pointer to the class being debugged - unsigned char mFlags; // Debug mode flags -}; - - - -#define YesNo(b) (b ? "Yes" : "No") - - - -inline std::string w2s(std::wstring ws) -{ - using convert_typeX = std::codecvt_utf8; - std::wstring_convert converterX; - return(converterX.to_bytes(ws)); -} - -// Primitive types -inline void DumpVar(const char *szName, char value) -{ - DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; -} - -inline void DumpVar(const char *szName, bool value) -{ - DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; -} - -inline void DumpVar(const char *szName, short value) -{ - DLOG << "[shrt]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, int value) -{ - DLOG << "[int]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, long value) -{ - DLOG << "[long]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, double value) -{ - DLOG << "[dbl]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, unsigned char value) -{ - DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned short value) -{ - DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned int value) -{ - DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned long value) -{ - DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, const char* value) -{ - DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const std::string &value) -{ - DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const std::wstring &value) -{ - DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; -} - -#ifndef MB_IGNORE_QT -inline void DumpVar(const char *szName, const QString &value) -{ - DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; -} -#endif - -inline void DumpVar(const char *szName, const void* value) -{ - DLOG << "[ptr]: " << szName << "=" << value << std::endl; -} - - -// Collection of primitive types -inline void DumpVar(const char *szName, const std::set &values) -{ - DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) - DLOG << (bFirst ? "" : ",") << *it; - DLOG << "]" << std::endl; -} - -inline void DumpVar(const char *szName, const std::list& values) -{ - DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) - DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); - DLOG << "]" << std::endl; -} - - -#endif // MBDebug_HeaderFile - diff --git a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtk.module b/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtk.module deleted file mode 100644 index 515f266e4..000000000 --- a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtk.module +++ /dev/null @@ -1,9 +0,0 @@ -NAME - CADRepresentations -DEPENDS - ParaView::RemotingViews - VTK::RenderingOpenGL2 - VTK::CommonDataModel - VTK::glew -PRIVATE_DEPENDS - VTK::CommonCore diff --git a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtkCADMapper.cxx b/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtkCADMapper.cxx deleted file mode 100644 index df91e282b..000000000 --- a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtkCADMapper.cxx +++ /dev/null @@ -1,495 +0,0 @@ -#include "vtkCADMapper.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//--------------------------------------------------------- -#define USE_DEBUG -#define MB_IGNORE_QT -static const char *dbg_class = "vtkCADMapper"; -#include "MBDebug.h" -//--------------------------------------------------------- - - -vtkStandardNewMacro(vtkCADMapper); - -//----------------------------------------------------------------------------- -void vtkCADMapper::SetOpacity(vtkIdType cellId, unsigned char opacity) -{ - DBG_FUN(); - ARG2(cellId, long); - ARG2(opacity, int); - - if(this->PrimColors.empty()) - { - return; - } - - for (vtkIdType primId : this->CellToPrimMap[cellId]) - { - this->PrimColors[4 * primId + 3] = opacity; - } -} - -//----------------------------------------------------------------------------- -void vtkCADMapper::ToggleResetColor(vtkIdType cellId) -{ - DBG_FUN(); - ARG2(cellId, long); - - if(this->PrimColors.empty()) - { - return; - } - - const int opacity = this->GroupModeEnabled ? 0 : 255; - - // Retrieve "default" colors - unsigned char color[4]; - this->Colors->GetTypedTuple(cellId, color); - - for (vtkIdType primId : this->CellToPrimMap[cellId]) - { - this->PrimColors[4 * primId] = color[0]; - this->PrimColors[4 * primId + 1] = color[1]; - this->PrimColors[4 * primId + 2] = color[2]; - this->PrimColors[4 * primId + 3] = opacity; - } -} - -//----------------------------------------------------------------------------- -void vtkCADMapper::ToggleSelectColor(vtkIdType cellId) -{ - DBG_FUN(); - ARG2(cellId, long); - - if(this->PrimColors.empty()) - { - return; - } - - auto* selectionColors = - this->GroupModeEnabled ? this->GroupSelectionColor : this->SelectionColor; - - const int opacity = this->GroupModeEnabled ? this->SavedCellOpacities[cellId] : 255; - - for (vtkIdType primId : this->CellToPrimMap[cellId]) - { - this->PrimColors[4 * primId] = selectionColors[0]; - this->PrimColors[4 * primId + 1] = selectionColors[1]; - this->PrimColors[4 * primId + 2] = selectionColors[2]; - this->PrimColors[4 * primId + 3] = opacity; - } -} - -//----------------------------------------------------------------------------- -void vtkCADMapper::TogglePreselectColor(vtkIdType cellId) -{ - // DBG_FUN(); - // ARG2(cellId, long); - - if(this->PrimColors.empty()) - { - return; - } - - for (vtkIdType primId : this->CellToPrimMap[cellId]) - { - this->PrimColors[4 * primId] = this->PreselectionColor[0]; - this->PrimColors[4 * primId + 1] = this->PreselectionColor[1]; - this->PrimColors[4 * primId + 2] = this->PreselectionColor[2]; - this->PrimColors[4 * primId + 3] = 255; - } -} - -//----------------------------------------------------------------------------- -void vtkCADMapper::ForceUpdate() -{ - DBG_FUN(); - - this->Modified(); - this->NeedUpdate = true; -} - -//----------------------------------------------------------------------------- -void vtkCADMapper::BuildCellTextures(vtkRenderer* ren, vtkActor* vtkNotUsed(actor), - vtkCellArray* vtkNotUsed(prims)[4], int vtkNotUsed(representation)) -{ - DBG_FUN(); - - if (!this->NeedUpdate) - { - return; - } - - // Add the preselection - for (vtkIdType idx : - this->SelectionCache[std::make_tuple(0, 0, this->PreselectedCellId)]) - { - this->TogglePreselectColor(idx); - } - - // Fill OpenGL related buffers - if (!this->CellScalarTexture) - { - this->CellScalarTexture = vtkTextureObject::New(); - this->CellScalarBuffer = vtkOpenGLBufferObject::New(); - this->CellScalarBuffer->SetType(vtkOpenGLBufferObject::TextureBuffer); - } - this->CellScalarTexture->SetContext(static_cast(ren->GetVTKWindow())); - this->CellScalarBuffer->Upload(this->PrimColors, vtkOpenGLBufferObject::TextureBuffer); - this->CellScalarTexture->CreateTextureBuffer( - static_cast(this->PrimColors.size() / 4), 4, VTK_UNSIGNED_CHAR, - this->CellScalarBuffer); - - // Reset preselection - for (vtkIdType idx : - this->SelectionCache[std::make_tuple(0, 0, this->PreselectedCellId)]) - { - this->ToggleResetColor(idx); - } - - this->NeedUpdate = false; -} - -//----------------------------------------------------------------------------- -void vtkCADMapper::BeginSelect() -{ - DBG_FUN(); - MSGEL("...vtkMapper::BeginSelect()"); - - this->Selecting = true; -} - -//----------------------------------------------------------------------------- -void vtkCADMapper::EndSelect() -{ - DBG_FUN(); - MSGEL("...vtkMapper::EndSelect()"); - - this->Selecting = false; -} - -//----------------------------------------------------------------------------- -void vtkCADMapper::CreateGroup() -{ - DBG_FUN(); - - this->SavedGroups.emplace_back(std::make_pair(this->SelectedIds, this->CurrentArrayName)); - this->SavedGroupVisibilities.emplace_back(false); - this->ResetSelection(); -} - -//----------------------------------------------------------------------------- -void vtkCADMapper::SetGroupVisibility(int groupIdx, bool visibility) -{ - DBG_FUN(); - ARG(groupIdx); - ARG(visibility); - - if(!this->GroupModeEnabled) - { - return; - } - - // Reconstruct the cache if needed (if a different array for selection by value is choosen) - this->BuildSelectionCache(this->SavedGroups[groupIdx].second.c_str(), 0, this->CurrentInput); - - // Save the group visibility - this->SavedGroupVisibilities[groupIdx] = visibility; - - // Show the selected group - for (vtkIdType id : this->SavedGroups[groupIdx].first) - { - for (vtkIdType idx : this->SelectionCache[std::make_tuple(0, 0, id)]) - { - if (visibility) - { - this->ToggleSelectColor(idx); - } - else - { - this->ToggleResetColor(idx); - } - } - this->SelectedIds.emplace(id); - } - this->ForceUpdate(); -} - -//----------------------------------------------------------------------------- -void vtkCADMapper::SetGroupOpacity(int groupIdx, unsigned char opacity) -{ - DBG_FUN(); - ARG(groupIdx); - ARG2(opacity, int); - - if(!this->GroupModeEnabled) - { - return; - } - - // Reconstruct the cache if needed (if a different array for selection by value is choosen) - this->BuildSelectionCache(this->SavedGroups[groupIdx].second.c_str(), 0, this->CurrentInput); - - // Save the opacity of the selected group and update it directly if currently visible - for (vtkIdType id : this->SavedGroups[groupIdx].first) - { - for (vtkIdType idx : this->SelectionCache[std::make_tuple(0, 0, id)]) - { - this->SavedCellOpacities[idx] = opacity; - if(this->SavedGroupVisibilities[groupIdx]) - { - this->SetOpacity(idx, opacity); - } - } - } - this->ForceUpdate(); -} - -//----------------------------------------------------------------------------- -void vtkCADMapper::SetGroupModeEnabled(bool enabled) -{ - DBG_FUN(); - ARG(enabled); - - this->GroupModeEnabled = enabled; - - // Set the group mode colors and opacity and clear the selections - this->InitializePrimColors(); - this->SelectedIds.clear(); - this->PreselectedCellId = -1; - - // Show all visible groups - for (vtkIdType groupId = 0; groupId < this->SavedGroups.size(); groupId++) - { - if (this->SavedGroupVisibilities[groupId]) - { - this->SetGroupVisibility(groupId, true); - } - } - - this->ForceUpdate(); -} - -//----------------------------------------------------------------------------- -void vtkCADMapper::ResetSelection() -{ - DBG_FUN(); - - for (vtkIdType id : this->SelectedIds) - { - for (vtkIdType idx : this->SelectionCache[std::make_tuple(0, 0, id)]) - { - this->ToggleResetColor(idx); - } - } - - this->SelectedIds.clear(); - this->PreselectedCellId = -1; - this->ForceUpdate(); -} - -//----------------------------------------------------------------------------- -void vtkCADMapper::Initialize() -{ - DBG_FUN(); - - vtkPolyData* input = vtkPolyData::SafeDownCast(this->GetInput()); - if(!input) - { - vtkErrorMacro("Unable to retrieve input polydata."); - return; - } - - vtkCellArray* prims[4]; - - prims[0] = input->GetVerts(); - prims[1] = input->GetLines(); - prims[2] = input->GetPolys(); - prims[3] = input->GetStrips(); - - vtkIdType nbVerts = input->GetNumberOfVerts(); - vtkIdType nbLines = input->GetNumberOfLines(); - vtkIdType nbPolys = input->GetNumberOfPolys(); - SHOW2(nbVerts, long); - SHOW2(nbLines, long); - SHOW2(nbPolys, long); - - // Store the mapping from OpenGL primitives to VTK cells - this->CellCellMap->BuildCellSupportArrays(prims, VTK_SURFACE, input->GetPoints()); - - // Create the mapping from VTK cells to OpenGL primitives (inverse of CellCellMap) - this->CellToPrimMap.clear(); - this->CellToPrimMap.resize(nbVerts + nbLines + nbPolys); - for (auto& v : this->CellToPrimMap) - { - // heuristic : for performances, we assume that we will have at most 10 primitives per cell - // it's just a reserve, the algorithm will still works if there is more primitives - v.reserve(10); - } - - for (size_t i = 0; i < this->CellCellMap->GetSize(); i++) - { - this->CellToPrimMap[this->CellCellMap->GetValue(i)].push_back(i); - } - - // Reset the default colors for all VTK cells - if (vtkUnsignedCharArray::SafeDownCast(input->GetCellData()->GetArray("RGB"))) - { - input->GetCellData()->RemoveArray("RGB"); - } - - vtkNew colorArray; - colorArray->SetNumberOfComponents(3); - colorArray->SetNumberOfTuples(nbVerts + nbLines + nbPolys); - colorArray->SetName("RGB"); - - input->GetCellData()->SetScalars(colorArray); - - for (int i = 0; i < nbVerts; i++) - { - colorArray->SetTypedTuple(i, this->VertexColor); - } - - for (int i = 0; i < nbLines; i++) - { - colorArray->SetTypedTuple(nbVerts + i, this->EdgeColor); - } - - for (int i = 0; i < nbPolys; i++) - { - colorArray->SetTypedTuple(nbVerts + nbLines + i, this->FaceColor); - } - - // Initialize the primitive colors from the created color array - this->InitializePrimColors(); - - // Clear saved group visibilities - this->SavedGroupVisibilities.clear(); - - // Initialize saved cell opacities - this->SavedCellOpacities.clear(); - this->SavedCellOpacities.resize(nbVerts + nbLines + nbPolys, 255); - - // Reset texture and selection - if (this->CellScalarTexture) - { - this->CellScalarTexture->Delete(); - this->CellScalarTexture = nullptr; - } - - if (this->CellScalarBuffer) - { - this->CellScalarBuffer->Delete(); - this->CellScalarBuffer = nullptr; - } - - this->SelectedIds.clear(); - this->PreselectedCellId = -1; - this->ForceUpdate(); -} - -//---------------------------------------------------------------------------- -void vtkCADMapper::InitializePrimColors() -{ - DBG_FUN(); - - vtkPolyData* input = vtkPolyData::SafeDownCast(this->GetInput()); - if(!input) - { - vtkErrorMacro("Unable to retrieve input polydata."); - return; - } - - vtkUnsignedCharArray* colorArray = vtkUnsignedCharArray::SafeDownCast(input->GetCellData()->GetAbstractArray("RGB")); - if(!colorArray) - { - vtkErrorMacro("Unable to retrieve the input color array."); - return; - } - - // Map the VTK cell color values to the OpenGL primitives color values - unsigned char* colorPtr = colorArray->GetPointer(0); - const int opacity = this->GroupModeEnabled ? 0 : 255; - - this->PrimColors.clear(); - this->PrimColors.reserve(4 * this->CellCellMap->GetSize()); - for (size_t i = 0; i < this->CellCellMap->GetSize(); i++) - { - for (int j = 0; j < 3; j++) - { - this->PrimColors.push_back(colorPtr[this->CellCellMap->GetValue(i) * 3 + j]); - } - this->PrimColors.push_back(opacity); - } -} - -//---------------------------------------------------------------------------- -void vtkCADMapper::PrintSelf(ostream& os, vtkIndent indent) -{ - DBG_FUN(); - - this->Superclass::PrintSelf(os, indent); -} - -//---------------------------------------------------------------------------- -void vtkCADMapper::AddCellIdsToSelectionPrimitives(vtkPolyData* poly, const char* arrayName, - unsigned int processId, unsigned int compositeIndex, vtkIdType selectedId) -{ - MSGEL("...vtkCADMapper::AddCellIdsToSelectionPrimitives(array=" << (arrayName ? arrayName : "") << ", procId=" << processId << ", compIdx=" << compositeIndex << ", selId=" << (int)selectedId << ")"); - // DBG_FUN(); - // ARG(arrayName); - // ARG(processId); - // ARG(compositeIndex); - // ARG2(selectedId, long); - - this->BuildSelectionCache(arrayName, false, poly); - this->CurrentArrayName = arrayName; - - // If we are selecting an already selected cell, remove it - auto idIterator = this->SelectedIds.find(selectedId); - if (idIterator != this->SelectedIds.end()) - { - if (!this->Selecting) - { - return; - } - for (vtkIdType idx : - this->SelectionCache[std::make_tuple(processId, compositeIndex, selectedId)]) - { - this->ToggleResetColor(idx); - } - this->SelectedIds.erase(idIterator); - return; - } - - if (!this->Selecting) - { - if (this->PreselectedCellId == selectedId) - { - return; - } - this->PreselectedCellId = selectedId; - this->ForceUpdate(); - } - else - { - this->PreselectedCellId = -1; - for (vtkIdType idx : - this->SelectionCache[std::make_tuple(processId, compositeIndex, selectedId)]) - { - this->ToggleSelectColor(idx); - } - this->SelectedIds.emplace(selectedId); - this->ForceUpdate(); - } -} diff --git a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtkCADMapper.h b/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtkCADMapper.h deleted file mode 100644 index 214878071..000000000 --- a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtkCADMapper.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef vtkCADMapper_h -#define vtkCADMapper_h - -#include "CADRepresentationsModule.h" // for export macro - -#include - -#include -#include - -class CADREPRESENTATIONS_EXPORT vtkCADMapper : public vtkOpenGLPolyDataMapper -{ -public: - static vtkCADMapper* New(); - vtkTypeMacro(vtkCADMapper, vtkOpenGLPolyDataMapper); - void PrintSelf(ostream& os, vtkIndent indent) override; - - /** - * Set the opacity value for the given VTK cell. - */ - void SetOpacity(vtkIdType id, unsigned char opacity); - - /** - * Set the reset color value for the given VTK cell. - */ - void ToggleResetColor(vtkIdType id); - - - /** - * Set the select color value for the given VTK cell. - */ - void ToggleSelectColor(vtkIdType id); - - - /** - * Set the preselect color value for the given VTK cell. - */ - void TogglePreselectColor(vtkIdType id); - - /** - * Initialize the map between the VTK cells and OpenGL primitives. - * Initialize also the colors of the primitives using this map - * and the defined colors (Face/Vertex/Edge colors) - */ - void Initialize(); - - /** - * Force BuildCellTextures to execute for the next rendering step. - */ - void ForceUpdate(); - - ///@{ - /** - * Mark the begining and the end of the selection. - */ - void BeginSelect(); - void EndSelect(); - ///@} - - /** - * Create a new selection group, and reset the selection. - */ - void CreateGroup(); - - /** - * If in group mode, set the visibility of the given selection group. - */ - void SetGroupVisibility(int groupIdx, bool visibility); - - /** - * If in group mode, set the opacity of the given selection group. - */ - void SetGroupOpacity(int groupIdx, unsigned char opacity); - - /** - * Enable/disable the Group Mode. In this mode, you visualize - * groups you saved (with the CreateGroup function). Only one - * group can be displayed at a time. - */ - void SetGroupModeEnabled(bool enabled); - - /** - * Reset the current selection. - */ - void ResetSelection(); - -protected: - vtkCADMapper() = default; - ~vtkCADMapper() = default; - - /** - * Called each time a render pass is done. Pushes the primitive colors (PrimColors) - * on the OpenGL side. - */ - void BuildCellTextures( - vtkRenderer* ren, vtkActor* actor, vtkCellArray* prims[4], int representation) override; - -private: - vtkCADMapper(const vtkCADMapper&) = delete; - void operator=(const vtkCADMapper&) = delete; - - /** - * Called during the render pass if the mapper's selection (vtkSelection) changed. - * - Save the preselected id in order to render pre-selection when BuildCellTextures is called - * - If a new selected id is furnished, add it to the SelectedId cache and toggle - * the selection color for the corresponding vtkCell ids using the SelectionCache map. - * - * Selected / preselected ids are values of the data array (arrayName), which allow to - * map geometry elements to their vtkCell counterparts. This mapping is stored in the - * SelectionCache map. - */ - void AddCellIdsToSelectionPrimitives(vtkPolyData* poly, const char* arrayName, - unsigned int processId, unsigned int compositeIndex, vtkIdType selectedId) override; - - /** - * Initialise the primitive colors using color array stored in the input polydata. - * Also initialize the opacity values (depending on current mode). - */ - void InitializePrimColors(); - - // VTK cells to OpenGL primitives map - std::vector> CellToPrimMap; - // Store the currenly selected ids (array values) - std::set SelectedIds; - // Store all the saved selection groups and their respective array name - // (type of cell to select) - std::vector, std::string>> SavedGroups; - // OpenGL primitives color, used in the BuildCellTextures method. - std::vector PrimColors; - // Store the current preselected id (array value) - vtkIdType PreselectedCellId = -1; - bool NeedUpdate = false; - bool Selecting = false; - std::string CurrentArrayName; - bool GroupModeEnabled = false; - - std::vector SavedGroupVisibilities; - std::vector SavedCellOpacities; - - const unsigned char FaceColor[3] = { 255, 255, 255 }; - const unsigned char EdgeColor[3] = { 0, 255, 0 }; - const unsigned char VertexColor[3] = { 255, 128, 0 }; - const unsigned char PreselectionColor[3] = { 0, 0, 255 }; - const unsigned char SelectionColor[3] = { 255, 0, 0 }; - const unsigned char GroupSelectionColor[3] = { 0, 255, 255 }; -}; - -#endif diff --git a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtkCADRepresentation.cxx b/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtkCADRepresentation.cxx deleted file mode 100644 index d1e879d9d..000000000 --- a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtkCADRepresentation.cxx +++ /dev/null @@ -1,319 +0,0 @@ -#include "vtkCADMapper.h" -#include "vtkCADRepresentation.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -//--------------------------------------------------------- -#define USE_DEBUG -#define MB_IGNORE_QT -static const char *dbg_class = "vtkCADRepresentation"; -#include "MBDebug.h" -//--------------------------------------------------------- - - -vtkStandardNewMacro(vtkCADRepresentation); - -//---------------------------------------------------------------------------- -vtkCADRepresentation::vtkCADRepresentation() -{ - DBG_FUN(); - - this->Actor->SetMapper(this->Mapper); - - vtkNew sel; - this->Mapper->SetSelection(sel); - - this->SetArrayIdNames(nullptr, nullptr); -} - -//---------------------------------------------------------------------------- -int vtkCADRepresentation::ProcessViewRequest(vtkInformationRequestKey* request_type, vtkInformation* inInfo, - vtkInformation* outInfo) -{ - DBG_FUN(); - - if (!this->Superclass::ProcessViewRequest(request_type, inInfo, outInfo)) - { - return 0; - } - - if (request_type == vtkPVView::REQUEST_UPDATE()) - { - MSGEL("....vtkCADRepresentation::ProcessViewRequest(REQUEST_UPDATE)"); - vtkPVRenderView::SetPiece(inInfo, this, this->PolyData); - vtkPVRenderView::SetGeometryBounds(inInfo, this, this->PolyData->GetBounds()); - } - else if (request_type == vtkPVView::REQUEST_RENDER()) - { - MSGEL("....vtkCADRepresentation::ProcessViewRequest(REQUEST_RENDER)"); - vtkAlgorithmOutput* producerPort = vtkPVRenderView::GetPieceProducer(inInfo, this); - this->Mapper->SetInputConnection(producerPort); - - if(!this->IsInitialized) - { - this->Mapper->Initialize(); - this->IsInitialized = true; - } - } - - return 1; -} - -//------------------------------------------------------------------------------ -void vtkCADRepresentation::SetVisibility(bool value) -{ - DBG_FUN(); - ARG(value); - - this->Superclass::SetVisibility(value); - this->Actor->SetVisibility(value); -} - -//---------------------------------------------------------------------------- -void vtkCADRepresentation::BeginSelect() -{ - DBG_FUN(); - - if(this->IsInitialized) - { - this->Mapper->BeginSelect(); - } -} - -//---------------------------------------------------------------------------- -void vtkCADRepresentation::EndSelect() -{ - DBG_FUN(); - - if(this->IsInitialized) - { - this->Mapper->EndSelect(); - } -} - -//---------------------------------------------------------------------------- -void vtkCADRepresentation::CreateGroup() -{ - DBG_FUN(); - - if(this->IsInitialized) - { - this->Mapper->CreateGroup(); - } -} - -//---------------------------------------------------------------------------- -void vtkCADRepresentation::SetGroupVisibility(int groupIdx, bool visibility) -{ - DBG_FUN(); - ARG(groupIdx); - ARG(visibility); - - if(this->IsInitialized) - { - this->Mapper->SetGroupVisibility(groupIdx, visibility); - } -} - -//---------------------------------------------------------------------------- -void vtkCADRepresentation::SetGroupOpacity(int groupIdx, unsigned char opacity) -{ - DBG_FUN(); - ARG(groupIdx); - ARG2(opacity, int); - - if(this->IsInitialized) - { - this->Mapper->SetGroupOpacity(groupIdx, opacity); - } -} - -//---------------------------------------------------------------------------- -void vtkCADRepresentation::SetGroupModeEnabled(bool enabled) -{ - DBG_FUN(); - ARG(enabled); - - if(this->IsInitialized) - { - this->Mapper->SetGroupModeEnabled(enabled); - } -} - -//---------------------------------------------------------------------------- -void vtkCADRepresentation::Reset() -{ - DBG_FUN(); - - if(this->IsInitialized) - { - this->Mapper->ResetSelection(); - } -} - -//------------------------------------------------------------------------------ -int vtkCADRepresentation::FillInputPortInformation(int vtkNotUsed(port), vtkInformation* info) -{ - DBG_FUN(); - - info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData"); - - // Saying INPUT_IS_OPTIONAL() is essential, since representations don't have - // any inputs on client-side (in client-server, client-render-server mode) and - // render-server-side (in client-render-server mode). - info->Set(vtkAlgorithm::INPUT_IS_OPTIONAL(), 1); - - return 1; -} - -//------------------------------------------------------------------------------ -int vtkCADRepresentation::RequestData( - vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector) -{ - DBG_FUN(); - - if (inputVector[0]->GetNumberOfInformationObjects() == 1) - { - MSGEL("....for a SINGLE info object"); - vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); - vtkPolyData* polyData = vtkPolyData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); - this->PolyData->ShallowCopy(polyData); - } - else - { - this->PolyData->Initialize(); - } - - return this->Superclass::RequestData(request, inputVector, outputVector); -} - -//------------------------------------------------------------------------------ -bool vtkCADRepresentation::AddToView(vtkView* view) -{ - DBG_FUN(); - - vtkPVRenderView* rview = vtkPVRenderView::SafeDownCast(view); - if (rview) - { - MSGEL("....Renderer->AddActor()"); - rview->GetRenderer()->AddActor(this->Actor); - - // Indicate that this is prop that we are rendering when hardware selection - // is enabled. - rview->RegisterPropForHardwareSelection(this, this->Actor); - return this->Superclass::AddToView(view); - } - return false; -} - -//------------------------------------------------------------------------------ -bool vtkCADRepresentation::RemoveFromView(vtkView* view) -{ - DBG_FUN(); - - vtkPVRenderView* rview = vtkPVRenderView::SafeDownCast(view); - if (rview) - { - rview->GetRenderer()->RemoveActor(this->Actor); - rview->UnRegisterPropForHardwareSelection(this, this->Actor); - return this->Superclass::RemoveFromView(view); - } - return false; -} - -//---------------------------------------------------------------------------- -void vtkCADRepresentation::PrintSelf(ostream& os, vtkIndent indent) -{ - DBG_FUN(); - - this->Superclass::PrintSelf(os, indent); -} - -//---------------------------------------------------------------------------- -void vtkCADRepresentation::SetSelectionConnection(vtkAlgorithmOutput* input) -{ - DBG_FUN(); - - // Copied from vtkCompositeRepresentation - if (!input) - { - return; - } - - vtkMultiProcessController* controller = vtkMultiProcessController::GetGlobalController(); - int numPiece = controller->GetNumberOfProcesses(); - int piece = controller->GetLocalProcessId(); - input->GetProducer()->UpdatePiece(piece, numPiece, 0); - - vtkSmartPointer sel; - int actualNbPieces = numPiece; - - vtkSMSession* session = - vtkSMSession::SafeDownCast(vtkProcessModule::GetProcessModule()->GetSession()); - if (session) - { - actualNbPieces = session->GetNumberOfProcesses(vtkPVSession::DATA_SERVER); - } - - // in order to handle the case where we are connected to a parallel server using - // local rendering, we have to compare the number of processes here - if (numPiece < actualNbPieces && piece == 0) - { - vtkSelection* localSel = - vtkSelection::SafeDownCast(input->GetProducer()->GetOutputDataObject(0)); - sel = vtkSmartPointer::New(); - sel->ShallowCopy(localSel); - - for (int i = 1; i < actualNbPieces; i++) - { - input->GetProducer()->UpdatePiece(i, actualNbPieces, 0); - localSel = vtkSelection::SafeDownCast(input->GetProducer()->GetOutputDataObject(0)); - if (localSel->GetNumberOfNodes() > 1) - { - vtkWarningMacro("Only the first node of a selection will be considered."); - } - vtkSelectionNode* node = localSel->GetNode(0); - node->GetProperties()->Set(vtkSelectionNode::PROCESS_ID(), i); - sel->AddNode(localSel->GetNode(0)); - } - } - else - { - sel = vtkSelection::SafeDownCast(input->GetProducer()->GetOutputDataObject(0)); - if (sel->GetNumberOfNodes() > 1) - { - vtkWarningMacro("Only the first node of a selection will be considered."); - } - sel->GetNode(0)->GetProperties()->Set(vtkSelectionNode::PROCESS_ID(), piece); - } - - this->Mapper->GetSelection()->ShallowCopy(sel); -} - -//---------------------------------------------------------------------------- -void vtkCADRepresentation::SetArrayIdNames(const char* pointArray, const char* cellArray) -{ - DBG_FUN(); - ARG(pointArray); - ARG(cellArray); - - vtkCADMapper* mapper = vtkCADMapper::SafeDownCast(this->Mapper); - mapper->SetPointIdArrayName(pointArray ? pointArray : "vtkOriginalPointIds"); - mapper->SetCellIdArrayName(cellArray ? cellArray : "vtkOriginalCellIds"); -} diff --git a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtkCADRepresentation.h b/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtkCADRepresentation.h deleted file mode 100644 index e3a277b22..000000000 --- a/src/SPV3D/plugins/cadRepresentations/CADRepresentations/vtkCADRepresentation.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef vtkCADRepresentation_h -#define vtkCADRepresentation_h - -#include "CADRepresentationsModule.h" // for export macro - -#include - -#include -#include -#include -#include - -class vtkActor; -class vtkCADMapper; - -enum SelectionType : unsigned char -{ - GeometrySolids = 0, - GeometryVertices, - GeometryEdges, - GeometryFaces, - SelectionTypeCount -}; -class CADREPRESENTATIONS_EXPORT vtkCADRepresentation - : public vtkPVDataRepresentation -{ -public: - static vtkCADRepresentation* New(); - vtkTypeMacro(vtkCADRepresentation, vtkPVDataRepresentation); - void PrintSelf(ostream& os, vtkIndent indent) override; - - int ProcessViewRequest(vtkInformationRequestKey* request_type, vtkInformation* inInfo, - vtkInformation* outInfo) override; - - /** - * Set the pre-configured selection source for making the selection. - * The vtkSelection is obtained internally and forwarded to the mapper - */ - void SetSelectionConnection(vtkAlgorithmOutput* input); - - /** - * Set the visibility of the rendered actor. - */ - void SetVisibility(bool val) override; - - void Reset(); - void BeginSelect(); - void EndSelect(); - - /** - * Create a new selection group, and reset the selection. - * Forwarded to the mapper. - */ - void CreateGroup(); - - /** - * If in group mode, set the visibility of the given selection group. - * Forwarded to the mapper. - */ - void SetGroupVisibility(int groupIdx, bool visibility); - - /** - * If in group mode, set the opacity of the given selection group. - * Forwarded to the mapper. - */ - void SetGroupOpacity(int groupIdx, unsigned char opacity); - - /** - * Enable/disable the Group Mode. In this mode, you visualize - * groups you saved (with the CreateGroup function). Only one - * group can be displayed at a time. - * Forwarded to the mapper. - */ - void SetGroupModeEnabled(bool enabled); - - /** - * Add a shape to the list of selected shapes that will - * be modified by setOpacity / toggleColor functions - * (for debugging purposes). - */ - void AddShape(vtkIdType groupId, vtkIdType cellId); - - void SetArrayIdNames(const char* pointArray, const char* cellArray) override; -protected: - vtkCADRepresentation(); - ~vtkCADRepresentation() = default; - - int FillInputPortInformation(int port, vtkInformation* info) override; - int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; - bool AddToView(vtkView* view) override; - bool RemoveFromView(vtkView* view) override; - - bool IsInitialized = false; - vtkNew Actor; - vtkNew Mapper; - vtkNew PolyData; - -private: - vtkCADRepresentation(const vtkCADRepresentation&) = delete; - void operator=(const vtkCADRepresentation&) = delete; -}; - -#endif // vtkCADRepresentation_h diff --git a/src/SPV3D/plugins/cadRepresentations/CMakeLists.txt b/src/SPV3D/plugins/cadRepresentations/CMakeLists.txt deleted file mode 100644 index 57849acd4..000000000 --- a/src/SPV3D/plugins/cadRepresentations/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -paraview_add_plugin(CADRepresentation - VERSION "1.0" - MODULES CADRepresentations - MODULE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/CADRepresentations/vtk.module" - XML_DOCUMENTATION OFF) diff --git a/src/SPV3D/plugins/cadRepresentations/paraview.plugin b/src/SPV3D/plugins/cadRepresentations/paraview.plugin deleted file mode 100644 index 239ebf13e..000000000 --- a/src/SPV3D/plugins/cadRepresentations/paraview.plugin +++ /dev/null @@ -1,9 +0,0 @@ -NAME - CADRepresentation -DESCRIPTION - CADViewer plugin providing representations. -REQUIRES_MODULES - ParaView::RemotingViews - VTK::CommonCore - VTK::CommonDataModel - VTK::RenderingOpenGL2 diff --git a/src/SPV3D/plugins/cadSources/CADSources/CADSource.xml b/src/SPV3D/plugins/cadSources/CADSources/CADSource.xml deleted file mode 100644 index 5911cac4a..000000000 --- a/src/SPV3D/plugins/cadSources/CADSources/CADSource.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - diff --git a/src/SPV3D/plugins/cadSources/CADSources/CMakeLists.txt b/src/SPV3D/plugins/cadSources/CADSources/CMakeLists.txt deleted file mode 100644 index 224a42b07..000000000 --- a/src/SPV3D/plugins/cadSources/CADSources/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -set(classes - vtkGeometryGenerator - vtkMeshGenerator) - -vtk_module_add_module(CADSources - FORCE_STATIC - CLASSES ${classes}) - -paraview_add_server_manager_xmls( - XMLS CADSource.xml) diff --git a/src/SPV3D/plugins/cadSources/CADSources/MBDebug.h b/src/SPV3D/plugins/cadSources/CADSources/MBDebug.h deleted file mode 100644 index bb701152f..000000000 --- a/src/SPV3D/plugins/cadSources/CADSources/MBDebug.h +++ /dev/null @@ -1,243 +0,0 @@ -#ifndef MBDebug_HeaderFile -#define MBDebug_HeaderFile - -//--------------------------------------------------------------- -// Usage of the logging facilities: -// -// (1) At the beginning of each class file to be debugged, there -// should be a static string variable defined with the name -// of the class. Then, include the "MBDebug.h" header file. -// -// //--------------------------------------------------------- -// #define USE_DEBUG -// //#define MB_IGNORE_QT -// #define MB_CLASSNAME "ClassName" -// #include "MBDebug.h" -// //--------------------------------------------------------- -// -// (2) At the beginning of each class method, call the DBG_FUN -// macro. -// -// int ClassName::MyMethod(int x) -// { -// DBG_FUN(); -// ... -// } -// -// NOTE: For static methods, call the DBG_FUNC() macro!! -//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// This debugging/logging class is a "header-only" solution and -// does NOT require any additional implementation (.cpp) file! -//--------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef MB_IGNORE_QT -# include -#endif - -//--------------------------------------------------------------- -// Set the debug flags dependent on the preprocessor definitions -//--------------------------------------------------------------- -#ifdef USE_DEBUG -# define MBS_DEBUG_FLAG MBDebug::DF_DEBUG -#else -# define MBS_DEBUG_FLAG 0 -#endif /*DEBUG*/ - -#define MBS_DBG_FLAGS (MBS_DEBUG_FLAG) - - -//--------------------------------------------------------------- -// Define the global debug macros -//--------------------------------------------------------------- -#define DLOG MBDebug::LogPrint() -#define RETURN(var) { RET(var); return (var); } - -#ifdef USE_DEBUG - -# define DBG_FUN() MBDebug _dbg(MB_CLASSNAME, __FUNCTION__, MBS_DBG_FLAGS, (void*)this) -# define DBG_FUNC() MBDebug _dbg(MB_CLASSNAME, __FUNCTION__, MBS_DBG_FLAGS) -# define DBG_FUNB(blk) MBDebug _dbg(MB_CLASSNAME, blk, MBS_DBG_FLAGS) -# define MSGEL(txt) MBDebug::LogPrint() << txt << std::endl -# define PRINT(txt) MBDebug::LogPrint() << txt -# define SHOW2(var,typ) DumpVar(#var,(typ)(var)) -# define SHOW(var) DumpVar(#var,var) -# define ARG(var) do { PRINT("in:"); DumpVar(#var,var); } while (0) -# define ARG2(var,typ) do { PRINT("in:"); DumpVar(#var,(typ)(var)); } while (0) -# define RET(var) do { PRINT("out:"); DumpVar(#var,var); } while (0) -# define MSG(txt) MBDebug::LogPrint() << txt - -#else /*!USE_DEBUG*/ - -# define DBG_FUN() -# define DBG_FUNC() -# define DBG_FUNB(blk) -# define MSGEL(txt) -# define PRINT(txt) -# define SHOW2(var,typ) -# define SHOW(var) -# define ARG(var) -# define ARG2(var,typ) -# define RET(var) -# define MSG(txt) - -#endif /*USE_DEBUG*/ - - -//--------------------------------------------------------------- -// Declare the debugging and profiling class -//--------------------------------------------------------------- -class MBDebug -{ -public: - enum { - DF_NONE = 0x00, // no debug - DF_DEBUG = 0x01 // debug a function - }; - - MBDebug(const char* aClassName, const char* aFuncName, const short aFlag, void* aThis=NULL) - :mClassName(aClassName),mFuncName(aFuncName),mThis(aThis),mFlags((unsigned char)aFlag) - { - if (mFlags & (DF_DEBUG)) - { - std::cout << "{ENTER: " << mClassName + "::" + mFuncName; - if (mThis) std::cout << "(this=" << mThis << ")"; - std::cout << std::endl; - } - } - virtual ~MBDebug() - { - if (mFlags & (DF_DEBUG)) - std::cout << "}LEAVE: " << mClassName << "::" << mFuncName << std::endl; - } - - // Log file output management - static std::ostream& LogPrint() { return std::cout; } - -private: - std::string mClassName; // Name of class to be debugged - std::string mFuncName; // Name of function to be debugged - void* mThis; // The "this" pointer to the class being debugged - unsigned char mFlags; // Debug mode flags -}; - - - -#define YesNo(b) (b ? "Yes" : "No") - - - -inline std::string w2s(std::wstring ws) -{ - using convert_typeX = std::codecvt_utf8; - std::wstring_convert converterX; - return(converterX.to_bytes(ws)); -} - -// Primitive types -inline void DumpVar(const char *szName, char value) -{ - DLOG << "[chr]: " << szName << "='" << value << "'" << std::endl; -} - -inline void DumpVar(const char *szName, bool value) -{ - DLOG << "[bool]: " << szName << "=" << (value ? "true" : "false") << std::endl; -} - -inline void DumpVar(const char *szName, short value) -{ - DLOG << "[shrt]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, int value) -{ - DLOG << "[int]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, long value) -{ - DLOG << "[long]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, double value) -{ - DLOG << "[dbl]: " << szName << "=" << value << std::endl; -} - -inline void DumpVar(const char *szName, unsigned char value) -{ - DLOG << "[byte]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned short value) -{ - DLOG << "[word]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned int value) -{ - DLOG << "[uint]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, unsigned long value) -{ - DLOG << "[dword]: " << szName << "=0x" << std::hex << value << std::dec << std::endl; -} - -inline void DumpVar(const char *szName, const char* value) -{ - DLOG << "[str]: " << szName << "=\"" << (value ? value : "") << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const std::string &value) -{ - DLOG << "[Str]: " << szName << "=\"" << value << "\"" << std::endl; -} - -inline void DumpVar(const char *szName, const std::wstring &value) -{ - DLOG << "[WStr]: " << szName << "=\"" << w2s(value) << "\"" << std::endl; -} - -#ifndef MB_IGNORE_QT -inline void DumpVar(const char *szName, const QString &value) -{ - DLOG << "[QStr]: " << szName << "=\"" << value.toStdString() << "\"" << std::endl; -} -#endif - -inline void DumpVar(const char *szName, const void* value) -{ - DLOG << "[ptr]: " << szName << "=" << value << std::endl; -} - - -// Collection of primitive types -inline void DumpVar(const char *szName, const std::set &values) -{ - DLOG << "[intSet]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) - DLOG << (bFirst ? "" : ",") << *it; - DLOG << "]" << std::endl; -} - -inline void DumpVar(const char *szName, const std::list& values) -{ - DLOG << "[boolList]: " << szName << "={" << values.size() << "}["; - bool bFirst = true; - for (auto it=values.cbegin(); it!=values.cend(); ++it) - DLOG << (bFirst ? "" : ",") << (*it ? "Y" : "N"); - DLOG << "]" << std::endl; -} - - -#endif // MBDebug_HeaderFile diff --git a/src/SPV3D/plugins/cadSources/CADSources/vtk.module b/src/SPV3D/plugins/cadSources/CADSources/vtk.module deleted file mode 100644 index 612a21139..000000000 --- a/src/SPV3D/plugins/cadSources/CADSources/vtk.module +++ /dev/null @@ -1,7 +0,0 @@ -NAME - CADSources -DEPENDS - VTK::FiltersCore -PRIVATE_DEPENDS - VTK::CommonCore - VTK::CommonExecutionModel diff --git a/src/SPV3D/plugins/cadSources/CADSources/vtkGeometryGenerator.cxx b/src/SPV3D/plugins/cadSources/CADSources/vtkGeometryGenerator.cxx deleted file mode 100644 index 540d7bff5..000000000 --- a/src/SPV3D/plugins/cadSources/CADSources/vtkGeometryGenerator.cxx +++ /dev/null @@ -1,301 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGeometryGenerator.cxx - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -#include "vtkGeometryGenerator.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -//--------------------------------------------------------- -#define USE_DEBUG -#define MB_IGNORE_QT -#define MB_CLASSNAME "vtkGeometryGenerator" -#include "MBDebug.h" -//--------------------------------------------------------- - - -vtkStandardNewMacro(vtkGeometryGenerator); - -//---------------------------------------------------------------------------- -vtkGeometryGenerator::vtkGeometryGenerator() -{ - DBG_FUN(); - this->SetNumberOfInputPorts(0); -} - -//---------------------------------------------------------------------------- -void vtkGeometryGenerator::PrintSelf(ostream& os, vtkIndent indent) -{ - DBG_FUN(); - this->Superclass::PrintSelf(os, indent); -} - -//---------------------------------------------------------------------------- -int vtkGeometryGenerator::RequestData(vtkInformation* vtkNotUsed(request), - vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector) -{ - DBG_FUN(); - // get the output - vtkPolyData* output = vtkPolyData::GetData(outputVector); - - unsigned int nbPoints = 8 // cube points - + 12 * (this->EdgeSubdivision - 1) // additional points on edges - + 6 * (this->EdgeSubdivision - 1) * (this->EdgeSubdivision - 1) // additional points on faces - ; - - unsigned int nbLines = 12; - unsigned int nbPointsPerLine = this->EdgeSubdivision + 1; - unsigned int sizeLines = nbLines * (nbPointsPerLine + 1); - - unsigned int nbQuads = 6 * this->EdgeSubdivision * this->EdgeSubdivision; - unsigned int sizeQuads = nbQuads * 5; - SHOW2(nbPoints, int); SHOW2(nbLines, int); SHOW2(nbQuads, int); - - vtkNew points; - points->Allocate(this->NumberOfSolids * nbPoints); - - vtkNew vertices; - vertices->Allocate(this->NumberOfSolids * 8 * 2); - - vtkNew lines; - lines->Allocate(this->NumberOfSolids * sizeLines); - - vtkNew quads; - quads->Allocate(this->NumberOfSolids * sizeQuads); - - unsigned int totalCells = this->NumberOfSolids * (8 + 12 + nbQuads); - - vtkNew solidIdArray; - solidIdArray->SetName("Solid id"); - solidIdArray->SetNumberOfComponents(1); - solidIdArray->Allocate(totalCells); - - vtkNew faceIdArray; - faceIdArray->SetName("Face id"); - faceIdArray->SetNumberOfComponents(1); - faceIdArray->Allocate(totalCells); - - vtkNew edgeIdArray; - edgeIdArray->SetName("Edge id"); - edgeIdArray->SetNumberOfComponents(1); - edgeIdArray->Allocate(totalCells); - - vtkNew vertexIdArray; - vertexIdArray->SetName("Vertex id"); - vertexIdArray->SetNumberOfComponents(1); - vertexIdArray->Allocate(totalCells); - - int sizeRow; - int save_round = std::fegetround(); - std::fesetround(FE_UPWARD); - sizeRow = std::lrint(std::cbrt(this->NumberOfSolids) - 1e-10); - std::fesetround(save_round); - - // edge ids - std::array, 12> edgesIds; - for (std::vector& v : edgesIds) - { - v.resize(this->EdgeSubdivision + 1); - } - - // quads ids - std::array, 6> quadsIds; - for (std::vector& v : quadsIds) - { - v.resize((this->EdgeSubdivision + 1) * (this->EdgeSubdivision + 1)); - } - - // cube creation - const double cubeLen = 0.5; - const double cubeSpacing = 1.0; - const double edgeLen = cubeLen / static_cast(this->EdgeSubdivision); - unsigned int currentIndex = 0; - for (unsigned int i = 0; i < this->NumberOfSolids; i++) - { - double x = cubeSpacing * (i % sizeRow); - double y = cubeSpacing * ((i / sizeRow) % sizeRow); - double z = cubeSpacing * (i / (sizeRow * sizeRow)); - - // create vertices - std::array verticesIds; - - auto addPoint = [&](int id, double px, double py, double pz) { - verticesIds[id] = points->InsertNextPoint(px, py, pz); - vertices->InsertNextCell(1, &verticesIds[id]); - }; - - addPoint(0, x, y, z); - addPoint(1, x + cubeLen, y, z); - addPoint(2, x, y + cubeLen, z); - addPoint(3, x + cubeLen, y + cubeLen, z); - addPoint(4, x, y, z + cubeLen); - addPoint(5, x + cubeLen, y, z + cubeLen); - addPoint(6, x, y + cubeLen, z + cubeLen); - addPoint(7, x + cubeLen, y + cubeLen, z + cubeLen); - - // create edges - - auto addEdge = [&](int id, unsigned int vId1, unsigned int vId2, int comp) { - edgesIds[id][0] = verticesIds[vId1]; - edgesIds[id][this->EdgeSubdivision] = verticesIds[vId2]; - double p[3]; // position of starting point - points->GetPoint(verticesIds[vId1], p); - for (unsigned int j = 1; j < this->EdgeSubdivision; j++) - { - p[comp] += edgeLen; - edgesIds[id][j] = points->InsertNextPoint(p); - } - lines->InsertNextCell(this->EdgeSubdivision + 1, edgesIds[id].data()); - }; - - addEdge(0, 0, 1, 0); - addEdge(1, 1, 3, 1); - addEdge(2, 2, 3, 0); - addEdge(3, 0, 2, 1); - addEdge(4, 4, 5, 0); - addEdge(5, 4, 6, 1); - addEdge(6, 6, 7, 0); - addEdge(7, 5, 7, 1); - addEdge(8, 0, 4, 2); - addEdge(9, 1, 5, 2); - addEdge(10, 3, 7, 2); - addEdge(11, 2, 6, 2); - - // create faces - auto addFace = [&](int id, unsigned int eId1, unsigned int eId2, unsigned int eId3, - unsigned int eId4, int compU, int compV, bool orientU, bool orientV) { - for (unsigned int j = 0; j < this->EdgeSubdivision + 1; j++) - { - // vertices will be written two times (for each edges) but it should be the same - int uid = orientU ? j : this->EdgeSubdivision - j; - int vid = orientV ? j : this->EdgeSubdivision - j; - quadsIds[id][j] = edgesIds[eId1][uid]; - quadsIds[id][j + this->EdgeSubdivision * (this->EdgeSubdivision + 1)] = edgesIds[eId2][uid]; - quadsIds[id][j * (this->EdgeSubdivision + 1)] = edgesIds[eId3][vid]; - quadsIds[id][(j + 1) * (this->EdgeSubdivision + 1) - 1] = edgesIds[eId4][vid]; - } - - // create internal points - double p[3]; // position of starting corner - points->GetPoint(edgesIds[eId1][orientU ? 0 : this->EdgeSubdivision], p); - - double v = p[compV]; - for (unsigned int j = 1; j < this->EdgeSubdivision; j++) - { - p[compU] += orientV ? edgeLen : -edgeLen; - p[compV] = v; - for (unsigned int k = 1; k < this->EdgeSubdivision; k++) - { - p[compV] += orientU ? edgeLen : -edgeLen; - quadsIds[id][j * (this->EdgeSubdivision + 1) + k] = points->InsertNextPoint(p); - } - } - - // link internal points - for (unsigned int j = 0; j < this->EdgeSubdivision; j++) - { - for (unsigned int k = 0; k < this->EdgeSubdivision; k++) - { - vtkIdType q[4] = { quadsIds[id][j * (this->EdgeSubdivision + 1) + k], - quadsIds[id][(j + 1) * (this->EdgeSubdivision + 1) + k], - quadsIds[id][(j + 1) * (this->EdgeSubdivision + 1) + k + 1], - quadsIds[id][j * (this->EdgeSubdivision + 1) + k + 1] }; - quads->InsertNextCell(4, q); - } - } - }; - - addFace(0, 0, 2, 3, 1, 1, 0, true, true); - addFace(1, 9, 10, 1, 7, 1, 2, true, true); - addFace(2, 4, 6, 7, 5, 1, 0, false, true); - addFace(3, 8, 11, 5, 3, 1, 2, false, true); - addFace(4, 4, 0, 8, 9, 2, 0, true, false); - addFace(5, 2, 6, 11, 10, 2, 0, true, true); - } - - // noId indicates that no specific ID is assigned. - // -2 is used to avoid conflict with existing IDs as well as with preselection - vtkIdType noId = -2; - - // add vertex ids - for (unsigned int i = 0; i < this->NumberOfSolids; i++) - { - vtkIdType sId = i + 1; - for (unsigned int j = 0; j < 8; j++) - { - vtkIdType id = 8 * i + j + 1; - solidIdArray->InsertNextTypedTuple(&sId); - faceIdArray->InsertNextTypedTuple(&noId); - edgeIdArray->InsertNextTypedTuple(&noId); - vertexIdArray->InsertNextTypedTuple(&id); - } - } - - // add edges ids - for (unsigned int i = 0; i < this->NumberOfSolids; i++) - { - vtkIdType sId = i + 1; - for (unsigned int j = 0; j < 12; j++) - { - vtkIdType id = 12 * i + j + 1; - solidIdArray->InsertNextTypedTuple(&sId); - faceIdArray->InsertNextTypedTuple(&noId); - edgeIdArray->InsertNextTypedTuple(&id); - vertexIdArray->InsertNextTypedTuple(&noId); - } - } - - // add faces ids - for (unsigned int i = 0; i < this->NumberOfSolids; i++) - { - vtkIdType sId = i + 1; - for (unsigned int j = 0; j < 6; j++) - { - vtkIdType id = 6 * i + j + 1; - for (unsigned int k = 0; k < this->EdgeSubdivision * this->EdgeSubdivision; k++) - { - solidIdArray->InsertNextTypedTuple(&sId); - faceIdArray->InsertNextTypedTuple(&id); - edgeIdArray->InsertNextTypedTuple(&noId); - vertexIdArray->InsertNextTypedTuple(&noId); - } - } - } - - SHOW2(points->GetNumberOfPoints(), long); - SHOW2(vertices->GetNumberOfCells(), long); - SHOW2(lines->GetNumberOfCells(), long); - SHOW2(quads->GetNumberOfCells(), long); - output->SetPoints(points); - output->SetVerts(vertices); - output->SetLines(lines); - output->SetPolys(quads); - - output->GetCellData()->AddArray(solidIdArray); - output->GetCellData()->AddArray(faceIdArray); - output->GetCellData()->AddArray(edgeIdArray); - output->GetCellData()->AddArray(vertexIdArray); - - return 1; -} diff --git a/src/SPV3D/plugins/cadSources/CADSources/vtkGeometryGenerator.h b/src/SPV3D/plugins/cadSources/CADSources/vtkGeometryGenerator.h deleted file mode 100644 index c435271a0..000000000 --- a/src/SPV3D/plugins/cadSources/CADSources/vtkGeometryGenerator.h +++ /dev/null @@ -1,64 +0,0 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: vtkGeometryGenerator.h - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ -/** - * @class vtkGeometryGenerator - * @brief create a polygonal mesh with BRep mapping - */ - -#ifndef vtkGeometryGenerator_h -#define vtkGeometryGenerator_h - -#include "CADSourcesModule.h" - -#include - -class CADSOURCES_EXPORT vtkGeometryGenerator : public vtkPolyDataAlgorithm -{ -public: - vtkTypeMacro(vtkGeometryGenerator, vtkPolyDataAlgorithm); - void PrintSelf(ostream& os, vtkIndent indent) override; - static vtkGeometryGenerator* New(); - - //@{ - /** - * Set/Get the number of subdivision of each edges of one cube. - */ - vtkSetMacro(EdgeSubdivision, unsigned int); - vtkGetMacro(EdgeSubdivision, unsigned int); - //@} - - //@{ - /** - * Set/Get the number of solids (cubes) generated. - */ - vtkSetMacro(NumberOfSolids, unsigned int); - vtkGetMacro(NumberOfSolids, unsigned int); - //@} - -protected: - vtkGeometryGenerator(); - ~vtkGeometryGenerator() override = default; - - int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; - - unsigned int EdgeSubdivision = 10; - unsigned int NumberOfSolids = 5000; - -private: - vtkGeometryGenerator(const vtkGeometryGenerator&) = delete; - void operator=(const vtkGeometryGenerator&) = delete; -}; - -#endif diff --git a/src/SPV3D/plugins/cadSources/CADSources/vtkMeshGenerator.cxx b/src/SPV3D/plugins/cadSources/CADSources/vtkMeshGenerator.cxx deleted file mode 100644 index 0c8118283..000000000 --- a/src/SPV3D/plugins/cadSources/CADSources/vtkMeshGenerator.cxx +++ /dev/null @@ -1,66 +0,0 @@ -#include "vtkMeshGenerator.h" - -#include -#include -#include -#include -#include - -#include -#include - -//--------------------------------------------------------- -#define USE_DEBUG -#define MB_IGNORE_QT -#define MB_CLASSNAME "vtkMeshGenerator" -#include "MBDebug.h" -//--------------------------------------------------------- - - -vtkStandardNewMacro(vtkMeshGenerator); - -//---------------------------------------------------------------------------- -void vtkMeshGenerator::PrintSelf(ostream& os, vtkIndent indent) -{ - DBG_FUN(); - - this->Superclass::PrintSelf(os, indent); -} - -//------------------------------------------------------------------------------ -int vtkMeshGenerator::FillInputPortInformation(int port, vtkInformation* info) -{ - DBG_FUN(); - ARG(port); - - if (port == 0) - { - info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData"); - return 1; - } - return 0; -} - -//---------------------------------------------------------------------------- -int vtkMeshGenerator::RequestData(vtkInformation* request, - vtkInformationVector** inputVector, vtkInformationVector* outputVector) -{ - DBG_FUN(); - - vtkPolyData* input = vtkPolyData::GetData(inputVector[0]); - vtkUnstructuredGrid* output = vtkUnstructuredGrid::GetData(outputVector); - if (!input || !output) - { - return 0; - } - - MSGEL("....applying Delaunay3D filter"); - vtkNew delaunay; - delaunay->SetInputData(input); - delaunay->Update(); - - output->ShallowCopy(delaunay->GetOutput()); - - return 1; -} - diff --git a/src/SPV3D/plugins/cadSources/CADSources/vtkMeshGenerator.h b/src/SPV3D/plugins/cadSources/CADSources/vtkMeshGenerator.h deleted file mode 100644 index ef5c1b3d2..000000000 --- a/src/SPV3D/plugins/cadSources/CADSources/vtkMeshGenerator.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef vtkMeshGenerator_h -#define vtkMeshGenerator_h - -#include "CADSourcesModule.h" - -#include - -/** - * @class vtkMeshGenerator - * @brief create a mesh using a 3D Delaunay filter on a vtkPolyData - */ -class CADSOURCES_EXPORT vtkMeshGenerator : public vtkUnstructuredGridAlgorithm -{ -public: - - vtkTypeMacro(vtkMeshGenerator, vtkUnstructuredGridAlgorithm); - void PrintSelf(ostream& os, vtkIndent indent) override; - static vtkMeshGenerator* New(); - -protected: - vtkMeshGenerator() = default; - ~vtkMeshGenerator() override = default; - - int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; - int FillInputPortInformation(int, vtkInformation*) override; - -private: - vtkMeshGenerator(const vtkMeshGenerator&) = delete; - void operator=(const vtkMeshGenerator&) = delete; -}; - -#endif diff --git a/src/SPV3D/plugins/cadSources/CMakeLists.txt b/src/SPV3D/plugins/cadSources/CMakeLists.txt deleted file mode 100644 index be0a7a297..000000000 --- a/src/SPV3D/plugins/cadSources/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -paraview_add_plugin(CADSource - VERSION "1.0" - MODULES CADSources - SOURCES ${sources} - MODULE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/CADSources/vtk.module") - diff --git a/src/SPV3D/plugins/cadSources/paraview.plugin b/src/SPV3D/plugins/cadSources/paraview.plugin deleted file mode 100644 index b25a87169..000000000 --- a/src/SPV3D/plugins/cadSources/paraview.plugin +++ /dev/null @@ -1,6 +0,0 @@ -NAME - CADSource -DESCRIPTION - CADViewer plugin providing sources -REQUIRES_MODULES - VTK::CommonCore