]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix of errors under Linux
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 13 Apr 2015 09:21:23 +0000 (12:21 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 13 Apr 2015 09:21:23 +0000 (12:21 +0300)
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp

index 3ee3e65ead27b6677f80a7f2e8537a300cc62b72..591536e0118358ff3cbd033b67aaff1e42d9057d 100644 (file)
@@ -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<SketchPlugin_Line> 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<SketchPlugin_Line> 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<SketchPlugin_Line> 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<SketchPlugin_Line> 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<SketchPlugin_Line> aLine = std::dynamic_pointer_cast<SketchPlugin_Line>(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<SketchPlugin_Line> aLine = std::dynamic_pointer_cast<SketchPlugin_Line>(aLineFeasture);
+      if (aLine) {
+        aDistance = aLine->distanceToPoint(aPointA->pnt());
+      }
+    }
   }
   return aDistance;
 }