#include <AIS_ColoredDrawer.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Selection.hxx>
+#include <BOPTools_AlgoTools3D.hxx>
#include <BRep_Builder.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Prs3d_Drawer.hxx>
if (!myHiddenSubShapes.Contains(theShape))
aNbOfHiddenSubShapes++; // the shape to be hidden later
- TopExp_Explorer anExp(myOriginalShape, TopAbs_FACE);
- bool aHasVisibleShape = false;
- for(TopExp_Explorer anExp(myOriginalShape, TopAbs_FACE); anExp.More() && !aHasVisibleShape;
- anExp.Next())
- {
- aNbOfHiddenSubShapes--;
- if (aNbOfHiddenSubShapes < 0)
- aHasVisibleShape = true;
- }
- return aHasVisibleShape;
+ //const TopoDS_Shape aCurrentShape = Shape();
+ NCollection_List<TopoDS_Shape> aHiddenSubShapes = myHiddenSubShapes;
+ aHiddenSubShapes.Append(theShape);
+
+ TopoDS_Compound aCompound;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound (aCompound);
+ collectSubShapes(aBuilder, aCompound, myOriginalShape, aHiddenSubShapes);
+ return !BOPTools_AlgoTools3D::IsEmptyShape(aCompound);
}
//********************************************************************
Set(myOriginalShape);
}
else { // convert shape into SHELL
- TopoDS_Shell aShell;
- BRep_Builder aShellBuilder;
- aShellBuilder.MakeShell(aShell);
- bool isEmptyShape = true;
- for(TopExp_Explorer anExp(myOriginalShape, TopAbs_FACE); anExp.More(); anExp.Next()) {
- if (myHiddenSubShapes.Contains(anExp.Current()))
- continue;
- aShellBuilder.Add(aShell, anExp.Current());
- isEmptyShape = false;
- }
- Set(aShell);
+ TopoDS_Compound aCompound;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound (aCompound);
+ collectSubShapes(aBuilder, aCompound, myOriginalShape, myHiddenSubShapes);
+ bool isEmptyShape = BOPTools_AlgoTools3D::IsEmptyShape(aCompound);
+ Set(aCompound);
if (isEmptyShape)
aReadyToDisplay = false;
}
}
}
+//********************************************************************
+void ModuleBase_ResultPrs::collectSubShapes(BRep_Builder& theBuilder,
+ TopoDS_Shape& theCompound, const TopoDS_Shape& theShape,
+ const NCollection_List<TopoDS_Shape>& theHiddenSubShapes)
+{
+ switch (theShape.ShapeType()) {
+ case TopAbs_COMPOUND: {
+ for (TopoDS_Iterator aChildIter (theShape); aChildIter.More(); aChildIter.Next())
+ collectSubShapes(theBuilder, theCompound, aChildIter.Value(), theHiddenSubShapes);
+ }
+ break;
+ case TopAbs_SOLID:
+ case TopAbs_SHELL: {
+ for (TopExp_Explorer anExp (theShape, TopAbs_FACE); anExp.More(); anExp.Next()) {
+ collectSubShapes(theBuilder, theCompound, anExp.Current(), theHiddenSubShapes);
+ }
+ }
+ break;
+ case TopAbs_WIRE: {
+ for (TopExp_Explorer anExp (theShape, TopAbs_EDGE); anExp.More(); anExp.Next()) {
+ collectSubShapes(theBuilder, theCompound, anExp.Current(), theHiddenSubShapes);
+ }
+ }
+ break;
+ case TopAbs_FACE: {
+ if (theHiddenSubShapes.Contains(theShape))
+ return; // remove hidden shape
+ theBuilder.Add(theCompound, theShape);
+ }
+ break;
+ case TopAbs_EDGE:
+ case TopAbs_VERTEX: {
+ theBuilder.Add(theCompound, theShape);
+ }
+ default:
+ break;
+ }
+}
+
//********************************************************************
void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer theMode)
#include <ModelAPI_Result.h>
+#include <BRep_Builder.hxx>
#include <NCollection_List.hxx>
#include <ViewerData_AISShape.hxx>
#include <Standard_DefineHandle.hxx>
bool appendVertexSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer theMode);
+ /// Creates compound of vertices, edges and faces.
+ /// If the shape is COMPOUND, iterate by sub-shapes.
+ /// If the shape is SOLID/SHEL, explore shape by FACES,
+ /// If the shape is WIRE, explore shape by EDGES
+ /// \param theBuilder result compound builder
+ /// \param theCompound the result shape
+ /// \param theShape the processed shape
+ /// \param theHiddenSubShapes container of shapes to be skipped (faces)
+ void collectSubShapes(BRep_Builder& theBuilder, TopoDS_Shape& theCompound,
+ const TopoDS_Shape& theShape, const NCollection_List<TopoDS_Shape>& theHiddenSubShapes);
+
+private:
/// Reference to result object
ResultPtr myResult;