static void adjustAngle(ConstraintWrapperPtr theConstraint);
/// \brief Update mirror points
static void adjustMirror(ConstraintWrapperPtr theConstraint);
+/// \brief Update a sign of the point-line distance constraint
+static void adjustPtLineDistance(ConstraintWrapperPtr theConstraint);
/// \brief Transform points to be symmetric regarding to the mirror line
static void makeMirrorPoints(EntityWrapperPtr theOriginal,
GCS_PARAMETER_WRAPPER(anIntermediate));
break;
case CONSTRAINT_TANGENT_ARC_LINE:
+ case CONSTRAINT_TANGENT_CIRCLE_LINE:
case CONSTRAINT_TANGENT_ARC_ARC:
aResult = createConstraintTangent(theConstraint, theGroupID, theType,
GCS_ENTITY_WRAPPER(theEntity1), GCS_ENTITY_WRAPPER(theEntity2));
// Update flags and parameters in constraints
if (aType == CONSTRAINT_ANGLE)
adjustAngle(theConstraint);
+ else if (aType == CONSTRAINT_PT_LINE_DISTANCE)
+ adjustPtLineDistance(theConstraint);
}
EntityWrapperPtr PlaneGCSSolver_Builder::createFeature(
std::shared_ptr<PlaneGCSSolver_EntityWrapper> theEntity2)
{
GCSConstraintPtr aNewConstr;
- if (theType == CONSTRAINT_TANGENT_ARC_LINE) {
+ if (theType == CONSTRAINT_TANGENT_ARC_LINE || theType == CONSTRAINT_TANGENT_CIRCLE_LINE) {
std::shared_ptr<GCS::Circle> aCirc = std::dynamic_pointer_cast<GCS::Circle>(theEntity1->entity());
std::shared_ptr<GCS::Line> aLine = std::dynamic_pointer_cast<GCS::Line>(theEntity2->entity());
}
}
+void adjustPtLineDistance(ConstraintWrapperPtr theConstraint)
+{
+ BuilderPtr aBuilder = PlaneGCSSolver_Builder::getInstance();
+
+ std::shared_ptr<GeomAPI_Pnt2d> aPoint;
+ std::shared_ptr<GeomAPI_Lin2d> aLine;
+ std::list<EntityWrapperPtr> aSubs = theConstraint->entities();
+ std::list<EntityWrapperPtr>::const_iterator aSIt = aSubs.begin();
+ for (; aSIt != aSubs.end(); ++aSIt) {
+ if ((*aSIt)->type() == ENTITY_POINT)
+ aPoint = aBuilder->point(*aSIt);
+ else if ((*aSIt)->type() == ENTITY_LINE)
+ aLine = aBuilder->line(*aSIt);
+ }
+
+ std::shared_ptr<GeomAPI_XY> aLineVec = aLine->direction()->xy();
+ std::shared_ptr<GeomAPI_XY> aPtLineVec = aPoint->xy()->decreased(aLine->location()->xy());
+ if (aPtLineVec->cross(aLineVec) * theConstraint->value() < 0.0)
+ theConstraint->setValue(theConstraint->value() * (-1.0));
+}
+