GeomAPI_Trsf.h
GeomAPI_Angle2d.h
GeomAPI_Wire.h
+ GeomAPI_Ellipse.h
)
SET(PROJECT_SOURCES
GeomAPI_Trsf.cpp
GeomAPI_Angle2d.cpp
GeomAPI_Wire.cpp
+ GeomAPI_Ellipse.cpp
)
SET(PROJECT_LIBRARIES
std::shared_ptr<GeomAPI_Dir> dir() const;
};
+//! Pointer on the object
+typedef std::shared_ptr<GeomAPI_Ax2> GeomAx2Ptr;
+
#endif
{
public:
- /** \brief Constructs a circle of radius Radius, where theAx2 locates the circle and defines its orientation in 3D space such that:\n
+ /** \brief Constructs a circle of radius Radius, where theAx2 locates
+ * the circle and defines its orientation in 3D space such that:\n
* - the center of the circle is the origin of theAx2;\n
* - the origin, "X Direction" and "Y Direction" of theAx2 define the plane of the circle;\n
* - theAx2 is the local coordinate system of the circle.\n
};
+//! Pointer on the object
+typedef std::shared_ptr<GeomAPI_Dir> GeomDirPtr;
+
#endif
#include<GeomAPI_Circ.h>
#include<GeomAPI_Dir.h>
#include<GeomAPI_Lin.h>
+#include<GeomAPI_Ax2.h>
+#include<GeomAPI_Ellipse.h>
#include <BRepAdaptor_Curve.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
+#include <Geom_Ellipse.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <gp_Ax1.hxx>
#include <gp_Pln.hxx>
+#include <gp_Elips.hxx>
#include <GCPnts_AbscissaPoint.hxx>
return false;
}
+bool GeomAPI_Edge::isEllipse() const
+{
+ const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
+ double aFirst, aLast;
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve((const TopoDS_Edge&)aShape, aFirst, aLast);
+ if (aCurve->IsKind(STANDARD_TYPE(Geom_Ellipse)))
+ return true;
+ return false;
+}
+
std::shared_ptr<GeomAPI_Pnt> GeomAPI_Edge::firstPoint()
{
const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aPoint.X(), aPoint.Y(), aPoint.Z()));
}
-std::shared_ptr<GeomAPI_Circ> GeomAPI_Edge::circle()
+std::shared_ptr<GeomAPI_Circ> GeomAPI_Edge::circle() const
{
const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
double aFirst, aLast;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve((const TopoDS_Edge&)aShape, aFirst, aLast);
- if (aCurve) {
+ if (!aCurve.IsNull()) {
Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast(aCurve);
- if (aCirc) {
+ if (!aCirc.IsNull()) {
gp_Pnt aLoc = aCirc->Location();
std::shared_ptr<GeomAPI_Pnt> aCenter(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
gp_Dir anAxis = aCirc->Axis().Direction();
return std::shared_ptr<GeomAPI_Circ>(); // not circle
}
-std::shared_ptr<GeomAPI_Lin> GeomAPI_Edge::line()
+std::shared_ptr<GeomAPI_Ellipse> GeomAPI_Edge::ellipse() const
+{
+ const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
+ double aFirst, aLast;
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve((const TopoDS_Edge&)aShape, aFirst, aLast);
+ if (!aCurve.IsNull()) {
+ Handle(Geom_Ellipse) aElips = Handle(Geom_Ellipse)::DownCast(aCurve);
+ if (!aElips.IsNull()) {
+ gp_Elips aGpElips = aElips->Elips();
+ std::shared_ptr<GeomAPI_Ellipse> aEllipse(new GeomAPI_Ellipse());
+ aEllipse->setImpl(new gp_Elips(aGpElips));
+ return aEllipse;
+ }
+ }
+ return std::shared_ptr<GeomAPI_Ellipse>(); // not elipse
+}
+
+std::shared_ptr<GeomAPI_Lin> GeomAPI_Edge::line() const
{
const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
double aFirst, aLast;
class GeomAPI_Pnt;
class GeomAPI_Circ;
class GeomAPI_Lin;
+class GeomAPI_Ellipse;
/**\class GeomAPI_Edge
* \ingroup DataModel
GEOMAPI_EXPORT
bool isArc() const;
+ /// Verifies that the edge is an arc of circle
+ GEOMAPI_EXPORT
+ bool isEllipse() const;
+
/// Returns the first vertex coordinates of the edge
GEOMAPI_EXPORT
std::shared_ptr<GeomAPI_Pnt> firstPoint();
/// Returns a circle if edge is based on the circle curve
GEOMAPI_EXPORT
- std::shared_ptr<GeomAPI_Circ> circle();
+ std::shared_ptr<GeomAPI_Circ> circle() const;
+
+ /// Returns an ellipse if edge is based on the ellipse curve
+ GEOMAPI_EXPORT
+ std::shared_ptr<GeomAPI_Ellipse> ellipse() const;
/// Returns a line if edge is based on the linear curve
GEOMAPI_EXPORT
- std::shared_ptr<GeomAPI_Lin> line();
+ std::shared_ptr<GeomAPI_Lin> line() const;
/// Returns true if the current edge is geometrically equal to the given edge
GEOMAPI_EXPORT
double length() const;
};
+//! Pointer on attribute object
+typedef std::shared_ptr<GeomAPI_Edge> GeomEdgePtr;
+
#endif
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAPI_Ellipse.cpp
+// Created: 25 April 2017
+// Author: Vitaly Smetannikov
+
+#include "GeomAPI_Ellipse.h"
+#include "GeomAPI_Ax2.h"
+#include "GeomAPI_Pnt.h"
+
+#include <gp_Elips.hxx>
+
+#define MY_ELIPS implPtr<gp_Elips>()
+
+GeomAPI_Ellipse::GeomAPI_Ellipse(const std::shared_ptr<GeomAPI_Ax2>& theAx2,
+ double theMajorRadius, double theMinorRadius)
+: GeomAPI_Interface(new gp_Elips(theAx2->impl<gp_Ax2>(), theMajorRadius, theMinorRadius))
+{
+}
+
+GeomPointPtr GeomAPI_Ellipse::firstFocus() const
+{
+ const gp_Pnt& aFirst = MY_ELIPS->Focus1();
+ return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aFirst.X(), aFirst.Y(), aFirst.Z()));
+}
+
+GeomPointPtr GeomAPI_Ellipse::secondFocus() const
+{
+ const gp_Pnt& aSecond = MY_ELIPS->Focus2();
+ return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSecond.X(), aSecond.Y(), aSecond.Z()));
+}
+
+double GeomAPI_Ellipse::minorRadius() const
+{
+ return MY_ELIPS->MinorRadius();
+}
+
+double GeomAPI_Ellipse::majorRadius() const
+{
+ return MY_ELIPS->MajorRadius();
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAPI_Ellipse.h
+// Created: 25 April 2017
+// Author: Vitaly Smetannikov
+
+#ifndef GeomAPI_Ellipse_H_
+#define GeomAPI_Ellipse_H_
+
+#include <GeomAPI_Interface.h>
+#include <memory>
+
+class GeomAPI_Pnt;
+class GeomAPI_Ax2;
+
+
+/**\class GeomAPI_Ellipse
+ * \ingroup DataModel
+ * \brief Ellipse in 3D
+ */
+class GeomAPI_Ellipse : public GeomAPI_Interface
+{
+public:
+
+ /// \brief Constructs an epty ellipse
+ GEOMAPI_EXPORT GeomAPI_Ellipse() : GeomAPI_Interface() {}
+
+ /** \brief Constructs an ellipse with major and minor radiuses,
+ * where theAx2 locates the ellipse and defines its orientation in 3D space such that:\n
+ * - the center of the circle is the origin of theAx2;\n
+ * - the origin, "X Direction" and "Y Direction" of theAx2 define the plane of the circle;\n
+ * - theAx2 is the local coordinate system of the circle.\n
+ * Note: It is possible to create a circle where Radius is equal to 0.0. raised if Radius < 0.
+ */
+ GEOMAPI_EXPORT GeomAPI_Ellipse(const std::shared_ptr<GeomAPI_Ax2>& theAx2,
+ double theMajorRadius, double theMinorRadius);
+
+ /// Returns first center of the ellipse
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> firstFocus() const;
+
+ /// Returns second center of the ellipse
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> secondFocus() const;
+
+ /// Returns minor radius of the ellipse
+ GEOMAPI_EXPORT double minorRadius() const;
+
+ /// Returns major radius of the ellipse
+ GEOMAPI_EXPORT double majorRadius() const;
+
+};
+
+//! Pointer on the object
+typedef std::shared_ptr<GeomAPI_Ellipse> GeomEllipsePtr;
+
+#endif
void translate(const std::shared_ptr<GeomAPI_Dir>& theDir, double theDist);
};
+//! Pointer on the object
+typedef std::shared_ptr<GeomAPI_Pnt> GeomPointPtr;
+
#endif
#include <GeomDataAPI_Dir.h>
#include <GeomAPI_XYZ.h>
#include <GeomAPI_Face.h>
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_ShapeExplorer.h>
#include <SketchPlugin_Sketch.h>
#include <SketcherPrs_Tools.h>
QIntList aModes;
std::shared_ptr<GeomAPI_Pln> aPlane = plane();
if (aPlane.get()) {
+ //QList<std::shared_ptr<ModuleBase_ViewerPrs>> aEdges = findCircularEdgesInPlane();
+ //foreach(std::shared_ptr<ModuleBase_ViewerPrs> aPrs, aEdges) {
+ //}
myWorkshop->module()->activeSelectionModes(aModes);
}
else {
aModule->onViewTransformed();
}
}
+
+
+//******************************************************
+QList<std::shared_ptr<ModuleBase_ViewerPrs>> PartSet_WidgetSketchLabel::findCircularEdgesInPlane()
+{
+ QList<std::shared_ptr<ModuleBase_ViewerPrs>> aResult;
+ XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
+ XGUI_Displayer* aDisplayer = aWorkshop->displayer();
+ QObjectPtrList aDispObjects = aDisplayer->displayedObjects();
+
+ std::shared_ptr<GeomAPI_Pln> aPlane = plane();
+ foreach(ObjectPtr aObj, aDispObjects) {
+ ResultPtr aResObj = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+ if (aResObj.get()) {
+ GeomShapePtr aShape = aResObj->shape();
+ if (aShape.get()) {
+ GeomAPI_ShapeExplorer aExplorer(aShape, GeomAPI_Shape::EDGE);
+ for(; aExplorer.more(); aExplorer.next()) {
+ GeomShapePtr aEdgeShape = aExplorer.current();
+ GeomAPI_Edge anEdge(aEdgeShape);
+ if ((anEdge.isCircle() || anEdge.isArc() || anEdge.isEllipse()) &&
+ anEdge.isInPlane(aPlane)) {
+ bool isContains = false;
+ // Check that edge is not used.
+ // It is possible that the same edge will be taken from different faces
+ foreach(std::shared_ptr<ModuleBase_ViewerPrs> aPrs, aResult) {
+ GeomAPI_Edge aUsedEdge(aPrs->shape());
+ if (aUsedEdge.isEqual(aEdgeShape)) {
+ isContains = true;
+ break;
+ }
+ }
+ if (!isContains) {
+ std::shared_ptr<ModuleBase_ViewerPrs>
+ aPrs(new ModuleBase_ViewerPrs(aResObj, aEdgeShape));
+ aResult.append(aPrs);
+ }
+ }
+ }
+ }
+ }
+ }
+ return aResult;
+}
/// \param thePlane a plane
std::shared_ptr<GeomAPI_Dir> setSketchPlane(std::shared_ptr<GeomAPI_Pln> thePlane);
+ /**
+ * Returns list of presentations which have displayed shapes with circular edges
+ * (circles, arcs) which are in pane of of the given sketch
+ * \param theSketch - the sketch
+ */
+ QList<std::shared_ptr<ModuleBase_ViewerPrs>> findCircularEdgesInPlane();
+
private:
/// class to show/hide preview planes
PartSet_PreviewPlanes* myPreviewPlanes;