It avoids degenrated edges using in the Group control.
ModuleBase_FilterLinearEdge.h
ModuleBase_FilterMulti.h
ModuleBase_FilterNoConsructionSubShapes.h
+ ModuleBase_FilterNoDegeneratedEdge.h
ModuleBase_FilterShapeType.h
ModuleBase_Tools.h
ModuleBase_IModule.h
ModuleBase_FilterLinearEdge.cpp
ModuleBase_FilterMulti.cpp
ModuleBase_FilterNoConsructionSubShapes.cpp
+ ModuleBase_FilterNoDegeneratedEdge.cpp
ModuleBase_FilterShapeType.cpp
ModuleBase_Tools.cpp
ModuleBase_IModule.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_ViewerFilters.cpp
+// Created: 10 Feb 2015
+// Author: Natalia ERMOLAEVA
+
+
+#include "ModuleBase_FilterNoDegeneratedEdge.h"
+
+#include <StdSelect_BRepOwner.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <BRep_Tool.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(ModuleBase_FilterNoDegeneratedEdge, StdSelect_EdgeFilter);
+IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterNoDegeneratedEdge, StdSelect_EdgeFilter);
+
+ModuleBase_FilterNoDegeneratedEdge::ModuleBase_FilterNoDegeneratedEdge()
+: StdSelect_EdgeFilter(StdSelect_AnyEdge)
+{
+}
+
+Standard_Boolean ModuleBase_FilterNoDegeneratedEdge::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
+{
+ bool isEdge = StdSelect_EdgeFilter::IsOk(theOwner);
+ if (isEdge) {
+ Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
+ if (!anOwner.IsNull() && anOwner->HasShape()) {
+ const TopoDS_Shape& aShape = anOwner->Shape();
+ if (BRep_Tool::Degenerated(TopoDS::Edge(aShape)))
+ return Standard_False;
+ }
+ }
+ return isEdge;
+}
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_ViewerFilters.h
+// Created: 10 Feb 2015
+// Author: Natalia ERMOLAEVA
+
+
+#ifndef ModuleBase_FilterNoDegeneratedEdge_H
+#define ModuleBase_FilterNoDegeneratedEdge_H
+
+#include <QStringList>
+
+#include <StdSelect_EdgeFilter.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+/**
+* \ingroup GUI
+* \class ModuleBase_FilterNoDegeneratedEdge
+* An edge filter, which additionally filters degenerative edges.
+*/
+DEFINE_STANDARD_HANDLE(ModuleBase_FilterNoDegeneratedEdge, StdSelect_EdgeFilter);
+class ModuleBase_FilterNoDegeneratedEdge: public StdSelect_EdgeFilter
+{
+public:
+ /// Constructor
+ Standard_EXPORT ModuleBase_FilterNoDegeneratedEdge();
+
+ /**
+ * Returns true if the owner is computed from decomposition(it is global selection, not the sub-shapes)
+ * of if the selected result is a construction and the result feature is composite and has sub-elements.
+ * \param theOwner the result of selection
+ * \return whether the owner is selectable in the viewer
+ */
+ Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
+
+ DEFINE_STANDARD_RTTI(ModuleBase_FilterNoDegeneratedEdge)
+
+protected:
+};
+
+#endif
\ No newline at end of file
#include <ModuleBase_WidgetMultiSelector.h>
#include <ModuleBase_WidgetShapeSelector.h>
+#include <ModuleBase_FilterNoDegeneratedEdge.h>
#include <ModuleBase_ISelection.h>
#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_IViewer.h>
#include <ModuleBase_Tools.h>
#include <ModelAPI_Data.h>
} else {
disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
myWorkshop->deactivateSubShapesSelection();
+
+ myWorkshop->viewer()->removeSelectionFilter(myEdgesTypeFilter);
}
}
QIntList aList;
aList.append(ModuleBase_WidgetShapeSelector::shapeType(aNewType));
myWorkshop->activateSubShapesSelection(aList);
+
+ // it is necessary to filter the selected edges to be non-degenerated
+ // it is not possible to build naming name for such edges
+ if (aNewType == "Edges") {
+ myEdgesTypeFilter = new ModuleBase_FilterNoDegeneratedEdge();
+ ModuleBase_IViewer* aViewer = myWorkshop->viewer();
+ aViewer->addSelectionFilter(myEdgesTypeFilter);
+ }
+ else {
+ myWorkshop->viewer()->removeSelectionFilter(myEdgesTypeFilter);
+ }
}
//********************************************************************
#include <ModuleBase.h>
#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_FilterNoDegeneratedEdge.h>
#include <GeomAPI_Shape.h>
#include <ModelAPI_Result.h>
/// An action for pop-up menu in a list control
QAction* myCopyAction;
+
+ /// A filter for the Edges type, which avoid the generated edges selection
+ Handle(ModuleBase_FilterNoDegeneratedEdge) myEdgesTypeFilter;
};
#endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */