From: vsv Date: Mon, 13 Apr 2015 09:21:23 +0000 (+0300) Subject: Fix of errors under Linux X-Git-Tag: V_1.1.0~40 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ab7fe1f045e12be9de203d93d2d645dd6c291013;p=modules%2Fshaper.git Fix of errors under Linux --- diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index 3ee3e65ea..591536e01 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -82,19 +82,19 @@ bool SketchPlugin_ConstraintDistance::compute(const std::string& theAttributeId) aPnt_A = aPoint_A->pnt(); aPnt_B = aPoint_B->pnt(); } else if (!aPoint_A && aPoint_B) { - //std::shared_ptr aLine = SketcherPrs_Tools::getFeatureLine( - // aData, SketchPlugin_Constraint::ENTITY_A()); - //if (aLine) { - // aPnt_B = aPoint_B->pnt(); - // aPnt_A = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_B); - //} + FeaturePtr aLine = SketcherPrs_Tools::getFeatureLine( + aData, SketchPlugin_Constraint::ENTITY_A()); + if (aLine) { + aPnt_B = aPoint_B->pnt(); + aPnt_A = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_B); + } } else if (aPoint_A && !aPoint_B) { - //std::shared_ptr aLine = SketcherPrs_Tools::getFeatureLine( - // aData, SketchPlugin_Constraint::ENTITY_B()); - //if (aLine) { - // aPnt_A = aPoint_A->pnt(); - // aPnt_B = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_A); - //} + FeaturePtr aLine = SketcherPrs_Tools::getFeatureLine( + aData, SketchPlugin_Constraint::ENTITY_B()); + if (aLine) { + aPnt_A = aPoint_A->pnt(); + aPnt_B = SketcherPrs_Tools::getProjectionPoint(aLine, aPnt_A); + } } if (!aPnt_A || !aPnt_B) return false; @@ -159,19 +159,21 @@ double SketchPlugin_ConstraintDistance::calculateCurrentDistance() const if (aPointA && aPointB) { // both points aDistance = aPointA->pnt()->distance(aPointB->pnt()); } else { -// if (!aPointA && aPointB) { //Line and point -// std::shared_ptr aLine = -// SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A()); -// if (aLine) { -// aDistance = aLine->distanceToPoint(aPointB->pnt()); -// } -// } else if (aPointA && !aPointB) { // Point and line -// std::shared_ptr aLine = -// SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B()); -// if (aLine) { -// aDistance = aLine->distanceToPoint(aPointA->pnt()); -// } -// } + if (!aPointA && aPointB) { //Line and point + FeaturePtr aLineFeature = + SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A()); + std::shared_ptr aLine = std::dynamic_pointer_cast(aLineFeature); + if (aLine) { + aDistance = aLine->distanceToPoint(aPointB->pnt()); + } + } else if (aPointA && !aPointB) { // Point and line + FeaturePtr aLineFeasture = + SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B()); + std::shared_ptr aLine = std::dynamic_pointer_cast(aLineFeasture); + if (aLine) { + aDistance = aLine->distanceToPoint(aPointA->pnt()); + } + } } return aDistance; }