diff --git a/src/Gui/SoFCDB.cpp b/src/Gui/SoFCDB.cpp index 4671657fd..becfb5473 100644 --- a/src/Gui/SoFCDB.cpp +++ b/src/Gui/SoFCDB.cpp @@ -90,6 +90,7 @@ void Gui::SoFCDB::init() SoFCVectorizeU3DAction ::initClass(); SoHighlightElementAction ::initClass(); SoSelectionElementAction ::initClass(); + SoVRMLAction ::initClass(); SoSkipBoundingGroup ::initClass(); SoTextLabel ::initClass(); SoStringLabel ::initClass(); diff --git a/src/Gui/SoFCUnifiedSelection.cpp b/src/Gui/SoFCUnifiedSelection.cpp index 335f7e054..8c109ee9c 100644 --- a/src/Gui/SoFCUnifiedSelection.cpp +++ b/src/Gui/SoFCUnifiedSelection.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +59,8 @@ #include #include #include +#include +#include #include #include @@ -682,3 +685,43 @@ const SoDetail* SoSelectionElementAction::getElement() const { return this->_det; } + +// --------------------------------------------------------------- + +SO_ACTION_SOURCE(SoVRMLAction); + +void SoVRMLAction::initClass() +{ + SO_ACTION_INIT_CLASS(SoVRMLAction,SoAction); + + SO_ENABLE(SoVRMLAction, SoSwitchElement); + + SO_ACTION_ADD_METHOD(SoNode,nullAction); + + SO_ENABLE(SoVRMLAction, SoCoordinateElement); + SO_ENABLE(SoVRMLAction, SoMaterialBindingElement); + SO_ENABLE(SoVRMLAction, SoLazyElement); + SO_ENABLE(SoVRMLAction, SoShapeStyleElement); + + SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction); + SO_ACTION_ADD_METHOD(SoMaterialBinding,callDoAction); + SO_ACTION_ADD_METHOD(SoMaterial,callDoAction); + SO_ACTION_ADD_METHOD(SoGroup,callDoAction); + SO_ACTION_ADD_METHOD(SoIndexedLineSet,callDoAction); + SO_ACTION_ADD_METHOD(SoIndexedFaceSet,callDoAction); + SO_ACTION_ADD_METHOD(SoPointSet,callDoAction); +} + +SoVRMLAction::SoVRMLAction() +{ + SO_ACTION_CONSTRUCTOR(SoVRMLAction); +} + +SoVRMLAction::~SoVRMLAction() +{ +} + +void SoVRMLAction::callDoAction(SoAction *action,SoNode *node) +{ + node->doAction(action); +} diff --git a/src/Gui/SoFCUnifiedSelection.h b/src/Gui/SoFCUnifiedSelection.h index 445a6a3e6..9c7635566 100644 --- a/src/Gui/SoFCUnifiedSelection.h +++ b/src/Gui/SoFCUnifiedSelection.h @@ -177,6 +177,24 @@ private: const SoDetail* _det; }; +/** + * @author Werner Mayer + */ +class GuiExport SoVRMLAction : public SoAction +{ + SO_ACTION_HEADER(SoVRMLAction); + +public: + SoVRMLAction(); + ~SoVRMLAction(); + + static void initClass(); + +private: + static void callDoAction(SoAction *action,SoNode *node); + +}; + } // namespace Gui diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index bd067273a..76ec7d92a 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -1041,6 +1041,8 @@ bool View3DInventorViewer::dumpToFile(const char* filename, bool binary) const if (fi.hasExtension("wrz")) binary = true; + SoVRMLAction vrml2; + vrml2.apply(pcViewProviderRoot); SoToVRML2Action tovrml2; tovrml2.apply(pcViewProviderRoot); SoVRMLGroup* vrmlRoot = tovrml2.getVRML2SceneGraph(); diff --git a/src/Mod/Part/Gui/SoBrepFaceSet.cpp b/src/Mod/Part/Gui/SoBrepFaceSet.cpp index 2005343de..0cbfeb5f1 100644 --- a/src/Mod/Part/Gui/SoBrepFaceSet.cpp +++ b/src/Mod/Part/Gui/SoBrepFaceSet.cpp @@ -44,6 +44,7 @@ # include # include # include +# include # include # include # include @@ -148,6 +149,35 @@ void SoBrepFaceSet::doAction(SoAction* action) } } } + else if (action->getTypeId() == Gui::SoVRMLAction::getClassTypeId()) { + // update the materialIndex field to match with the number of triangles if needed + SoState * state = action->getState(); + Binding mbind = this->findMaterialBinding(state); + if (mbind == PER_PART) { + const SoLazyElement* mat = SoLazyElement::getInstance(state); + int numColor = 1; + int numParts = partIndex.getNum(); + if (mat) { + numColor = mat->getNumDiffuse(); + if (numColor == numParts) { + int count = 0; + const int32_t * indices = this->partIndex.getValues(0); + for (int i=0; imaterialIndex.setNum(count); + int32_t * matind = this->materialIndex.startEditing(); + int32_t k = 0; + for (int i=0; imaterialIndex.finishEditing(); + } + } + } + } inherited::doAction(action); }