icon=":icons/sketch.png"
tooltip="Select a face for extrusion"
activate="true"
- shape_types="face wire edge"
+ shape_types="face"
use_subshapes="true"
/>
- <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="0" icon=":icons/dimension_v.png" tooltip="Set size of extrusion">
+ <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="1" icon=":icons/dimension_v.png" tooltip="Set size of extrusion">
<validator id="GeomValidators_Positive"/>
</doublevalue>
<boolvalue id="extrusion_reverse" label="Reverse" default="false" tooltip="Reverse default direction"/>
#ifndef GEOMAPI_WIRE_H_
#define GEOMAPI_WIRE_H_
-#include <GeomAPI.h>
-#include <GeomAPI_Edge.h>
+#include "GeomAPI.h"
+#include "GeomAPI_Edge.h"
+#include "GeomAPI_Pnt.h"
+#include "GeomAPI_Dir.h"
#include <boost/smart_ptr/shared_ptr.hpp>
void addEdge(boost::shared_ptr<GeomAPI_Shape> theEdge);
std::list<boost::shared_ptr<GeomAPI_Shape> > getEdges();
+ /// Returns True if the wire is defined in a plane
+ bool hasPlane() const { return myOrigin && myNorm && myDirX && myDirY; }
+
+ /// Set/Get origin point
+ void setOrigin(const boost::shared_ptr<GeomAPI_Pnt>& theOrigin) { myOrigin = theOrigin; }
+ boost::shared_ptr<GeomAPI_Pnt> origin() const { return myOrigin; }
+
+ /// Set/Get X direction vector
+ void setDirX(const boost::shared_ptr<GeomAPI_Dir>& theDirX) { myDirX = theDirX; }
+ boost::shared_ptr<GeomAPI_Dir> dirX() const { return myDirX; }
+
+ /// Set/Get Y direction vector
+ void setDirY(const boost::shared_ptr<GeomAPI_Dir>& theDirY) { myDirY = theDirY; }
+ boost::shared_ptr<GeomAPI_Dir> dirY() const { return myDirY; }
+
+ /// Set/Get Normal direction vector
+ void setNorm(const boost::shared_ptr<GeomAPI_Dir>& theNorm) { myNorm = theNorm; }
+ boost::shared_ptr<GeomAPI_Dir> norm() const { return myNorm; }
+
+private:
+ boost::shared_ptr<GeomAPI_Pnt> myOrigin;
+ boost::shared_ptr<GeomAPI_Dir> myDirX;
+ boost::shared_ptr<GeomAPI_Dir> myDirY;
+ boost::shared_ptr<GeomAPI_Dir> myNorm;
};
#endif
ModuleBase_WidgetLineEdit.h
ModuleBase_WidgetMultiSelector.h
ModuleBase_ViewerFilters.h
+ ModuleBase_ResultPrs.h
)
SET(PROJECT_SOURCES
ModuleBase_WidgetLineEdit.cpp
ModuleBase_WidgetMultiSelector.cpp
ModuleBase_ViewerFilters.cpp
+ ModuleBase_ResultPrs.cpp
)
SET(PROJECT_LIBRARIES
Config
ModelAPI
GeomAPI
+ GeomAlgoAPI
${QT_LIBRARIES}
${CAS_VIEWER}
${CAS_KERNEL}
${CMAKE_SOURCE_DIR}/src/ModelAPI
${CMAKE_SOURCE_DIR}/src/GeomDataAPI
${CMAKE_SOURCE_DIR}/src/GeomAPI
+ ${CMAKE_SOURCE_DIR}/src/GeomAlgoAPI
)
ADD_DEFINITIONS(-DMODULEBASE_EXPORTS ${CAS_DEFINITIONS})
--- /dev/null
+// File: ModuleBase_ResultPrs.cpp
+// Created: 21 October 2014
+// Author: Vitaly SMETANNIKOV
+
+#include "ModuleBase_ResultPrs.h"
+
+#include <ModelAPI_Tools.h>
+#include <GeomAPI_Wire.h>
+#include <GeomAlgoAPI_SketchBuilder.h>
+
+#include <BRep_Builder.hxx>
+#include <AIS_Drawer.hxx>
+#include <Prs3d_IsoAspect.hxx>
+
+IMPLEMENT_STANDARD_HANDLE(ModuleBase_ResultPrs, AIS_Shape);
+IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ResultPrs, AIS_Shape);
+
+ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
+ : AIS_Shape(TopoDS_Shape()), myResult(theResult), myIsSketchMode(false)
+{
+ boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
+ boost::shared_ptr<GeomAPI_Wire> aWirePtr =
+ boost::dynamic_pointer_cast<GeomAPI_Wire>(aShapePtr);
+ if (aWirePtr) {
+ if (aWirePtr->hasPlane() ) {
+ // If this is a wire with plane defined thin it is a sketch-like object
+ // It must have invisible faces
+ std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
+ GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(),
+ aWirePtr->dirY(), aWirePtr->norm(), aWirePtr, aFaces);
+
+ BRep_Builder aBuilder;
+ TopoDS_Shape aShape = aWirePtr->impl<TopoDS_Shape>();
+ std::list<boost::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
+ for (aIt = aFaces.cbegin(); aIt != aFaces.cend(); ++aIt) {
+ TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
+ aBuilder.Add(aShape, aFace);
+ }
+ Set(aShape);
+ myIsSketchMode = true;
+ // Define number of ISO lines
+ //Handle(AIS_Drawer) aDrawer = Attributes();
+ //Attributes()->SetIsoOnPlane(Standard_False);
+ //SetAttributes(aDrawer);
+ } else {
+ Set(aWirePtr->impl<TopoDS_Shape>());
+ }
+ } else {
+ Set(aShapePtr->impl<TopoDS_Shape>());
+ }
+}
+
+
+Standard_Boolean ModuleBase_ResultPrs::AcceptDisplayMode(const Standard_Integer theMode) const
+{
+ if (myIsSketchMode) {
+ return theMode == 0;
+ }
+ return AIS_Shape::AcceptDisplayMode(theMode);
+}
+
+void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode)
+{
+ if (myIsSketchMode) {
+ Handle(AIS_Drawer) aDrawer = Attributes();
+ aDrawer->SetIsoOnPlane(Standard_False);
+ aDrawer->UIsoAspect()->SetNumber(0);
+ aDrawer->VIsoAspect()->SetNumber(0);
+ SetAttributes(aDrawer);
+ }
+ AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
+}
--- /dev/null
+// File: ModuleBase_ResultPrs.h
+// Created: 21 October 2014
+// Author: Vitaly SMETANNIKOV
+
+#ifndef ModuleBase_ResultPrs_H
+#define ModuleBase_ResultPrs_H
+
+#include "ModuleBase.h"
+
+#include <ModelAPI_Result.h>
+
+#include <AIS_Shape.hxx>
+#include <Standard_DefineHandle.hxx>
+
+DEFINE_STANDARD_HANDLE(ModuleBase_ResultPrs, AIS_Shape)
+
+class ModuleBase_ResultPrs: public AIS_Shape
+{
+public:
+ Standard_EXPORT ModuleBase_ResultPrs(ResultPtr theResult);
+
+ Standard_EXPORT ResultPtr getResult() const { return myResult; }
+
+ Standard_EXPORT virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const;
+
+ DEFINE_STANDARD_RTTI(ModuleBase_ResultPrs)
+protected:
+ void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
+
+private:
+ ResultPtr myResult;
+
+ bool myIsSketchMode;
+};
+
+
+#endif
\ No newline at end of file
for (; aShapeIt != aFeaturesPreview.end(); ++aShapeIt) {
aBigWire->addEdge(*aShapeIt);
}
+ aBigWire->setOrigin(anOrigin->pnt());
+ aBigWire->setDirX(aDirX->dir());
+ aBigWire->setDirY(aDirY->dir());
+ aBigWire->setNorm(aNorm->dir());
+
// GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(),
// aFeaturesPreview, aLoops, aWires);
boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
#include <ModelAPI_Object.h>
#include <ModelAPI_Tools.h>
+#include <ModuleBase_ResultPrs.h>
+
#include <GeomAPI_Shape.h>
#include <GeomAPI_IPresentable.h>
boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
if (aShapePtr) {
anAIS = AISObjectPtr(new GeomAPI_AISObject());
- anAIS->createShape(aShapePtr);
+ anAIS->setImpl(new Handle(AIS_InteractiveObject)(new ModuleBase_ResultPrs(aResult)));
+ //anAIS->createShape(aShapePtr);
isShading = true;
}
}