{
}
+//=================================================================================================
+GeomAPI_Circ::GeomAPI_Circ(const GeomCurvePtr& theCurve)
+{
+ Handle(Geom_Curve) aCurve = theCurve->impl<Handle(Geom_Curve)>();
+ Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast(aCurve);
+ if (aCirc.IsNull())
+ throw Standard_ConstructionError("GeomAPI_Circ: Curve is not a circle");
+ setImpl(new gp_Circ(aCirc->Circ()));
+}
+
//=================================================================================================
const std::shared_ptr<GeomAPI_Pnt> GeomAPI_Circ::center() const
{
#define GeomAPI_Circ_H_
#include <GeomAPI_Interface.h>
+#include <GeomAPI_Curve.h>
#include <memory>
class GeomAPI_Ax2;
GEOMAPI_EXPORT GeomAPI_Circ(const std::shared_ptr<GeomAPI_Pnt>& theCenter,
const std::shared_ptr<GeomAPI_Dir>& theDir, double theRadius);
+ /// Creation of circle defined by a curve
+ GEOMAPI_EXPORT GeomAPI_Circ(const GeomCurvePtr& theCurve);
+
/// Return center of the circle
GEOMAPI_EXPORT const std::shared_ptr<GeomAPI_Pnt> center() const;
bool isCoplanar(const std::shared_ptr<GeomAPI_Lin> theLin) const;
};
+//! Pointer on the object
+typedef std::shared_ptr<GeomAPI_Lin> GeomLinePtr;
+
#endif
#include <Graphic3d_AspectLine3d.hxx>
#include <Prs3d_Root.hxx>
+#include <GeomAPI_Curve.h>
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Lin.h>
IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs);
ObjectPtr aObj2 =
SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+ GeomShapePtr aShp1 = SketcherPrs_Tools::getShape(aObj1);
+ GeomShapePtr aShp2 = SketcherPrs_Tools::getShape(aObj2);
+
+ GeomEdgePtr aEdge1(new GeomAPI_Edge(aShp1));
+ GeomEdgePtr aEdge2(new GeomAPI_Edge(aShp2));
+
+ std::shared_ptr<GeomAPI_Lin> aLin1 = aEdge1->line();
+ std::shared_ptr<GeomAPI_Lin> aLin2 = aEdge2->line();
+
+ std::shared_ptr<GeomAPI_Pnt> aPnt = aLin1->intersect(aLin2);
+
// Compute position of symbols
SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
- gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep);
- gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep);
- myPntArray = new Graphic3d_ArrayOfPoints(2, withColor);
+ gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep, aPnt);
+ //gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep);
+ myPntArray = new Graphic3d_ArrayOfPoints(1, withColor);
myPntArray->AddVertex(aP1);
- myPntArray->AddVertex(aP2);
+ //myPntArray->AddVertex(aP2);
return true;
}
gp_Pnt aP; // Central point
if (thePnt.get()) {
- aP = thePnt->impl<gp_Pnt>();
+ return getPointPosition(theShape, thePrs, theStep, thePnt);
} else {
if (aShape->isEdge()) {
std::shared_ptr<GeomAPI_Curve> aCurve =
// Compute shifting vector for a one symbol
gp_Vec aShift = aVec1.Crossed(thePrs->plane()->normal()->impl<gp_Dir>());
aShift.Normalize();
- // For point based symbols step = 1.2, for line based = 0.8
- aShift.Multiply(theStep * (thePnt.get()? 1.2 : 0.8));
+ aShift.Multiply(theStep * 0.8);
// Shift the position coordinate according to position index
int aPos = getPositionIndex(theShape, thePrs);
return aP;
}
+gp_Pnt SketcherPrs_PositionMgr::getPointPosition(
+ ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs,
+ double theStep, GeomPointPtr thePnt)
+{
+ gp_Pnt aP = thePnt->impl<gp_Pnt>();
+ gp_Vec aVec1 = getVector(theLine, thePrs->plane()->dirX(), aP);
+
+ // Compute shifting vector for a one symbol
+ gp_Vec aShift = aVec1.Crossed(thePrs->plane()->normal()->impl<gp_Dir>());
+ aShift.Normalize();
+ aShift.Multiply(theStep * 1.5);
+ aP.Translate(aShift);
+ return aP;
+}
+
+
void SketcherPrs_PositionMgr::deleteConstraint(const SketcherPrs_SymbolPrs* thePrs)
{
std::map<ObjectPtr, PositionsMap>::iterator aIt;
/// \param thePrs a presentation of constraint
int getPositionIndex(ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs);
+ gp_Pnt getPointPosition(ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs,
+ double theStep, GeomPointPtr thePnt);
+
private:
typedef std::map<const SketcherPrs_SymbolPrs*, int> PositionsMap;
#include "SketcherPrs_PositionMgr.h"
#include <GeomAPI_Curve.h>
+#include <GeomAPI_Circ.h>
+#include <GeomAPI_Lin.h>
#include <SketchPlugin_Constraint.h>
GeomCurvePtr aCurv1 = std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShp1));
GeomCurvePtr aCurv2 = std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShp2));
- GeomPointPtr aPnt1_1 = aCurv1->getPoint(aCurv1->startParam());
- GeomPointPtr aPnt1_2 = aCurv1->getPoint(aCurv1->endParam());
-
- GeomPointPtr aPnt2_1 = aCurv2->getPoint(aCurv2->startParam());
- GeomPointPtr aPnt2_2 = aCurv2->getPoint(aCurv2->endParam());
-
+ GeomCurvePtr aLine;
+ GeomCirclePtr aCircle;
+ if (aCurv1->isLine()) {
+ aLine = aCurv1;
+ aCircle = GeomCirclePtr(new GeomAPI_Circ(aCurv2));
+ } else {
+ aLine = aCurv2;
+ aCircle = GeomCirclePtr(new GeomAPI_Circ(aCurv1));
+ }
+
+ GeomPointPtr aPnt1 = aLine->getPoint(aLine->startParam());
+ GeomPointPtr aPnt2 = aLine->getPoint(aLine->endParam());
+ double aParam;
GeomPointPtr aPnt;
- if (aPnt1_1->isEqual(aPnt2_1) || aPnt1_1->isEqual(aPnt2_2))
- aPnt = aPnt1_1;
- else if (aPnt1_2->isEqual(aPnt2_1) || aPnt1_2->isEqual(aPnt2_2))
- aPnt = aPnt1_2;
+ if (aCircle->parameter(aPnt1, 1.e-4, aParam))
+ aPnt = aPnt1;
+ else
+ aPnt = aPnt2;
// Compute points coordinates
SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();