Salome HOME
#1404 Random crash with Shaper: AIS presentations: correction for symbol presentations.
authornds <nds@opencascade.com>
Thu, 21 Apr 2016 11:35:19 +0000 (14:35 +0300)
committernds <nds@opencascade.com>
Thu, 21 Apr 2016 12:54:34 +0000 (15:54 +0300)
23 files changed:
src/SketcherPrs/SketcherPrs_Collinear.cpp
src/SketcherPrs/SketcherPrs_Collinear.h
src/SketcherPrs/SketcherPrs_Equal.cpp
src/SketcherPrs/SketcherPrs_Equal.h
src/SketcherPrs/SketcherPrs_HVDirection.cpp
src/SketcherPrs/SketcherPrs_HVDirection.h
src/SketcherPrs/SketcherPrs_Middle.cpp
src/SketcherPrs/SketcherPrs_Middle.h
src/SketcherPrs/SketcherPrs_Mirror.cpp
src/SketcherPrs/SketcherPrs_Mirror.h
src/SketcherPrs/SketcherPrs_Parallel.cpp
src/SketcherPrs/SketcherPrs_Parallel.h
src/SketcherPrs/SketcherPrs_Perpendicular.cpp
src/SketcherPrs/SketcherPrs_Perpendicular.h
src/SketcherPrs/SketcherPrs_Rigid.cpp
src/SketcherPrs/SketcherPrs_Rigid.h
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.h
src/SketcherPrs/SketcherPrs_Tangent.cpp
src/SketcherPrs/SketcherPrs_Tangent.h
src/SketcherPrs/SketcherPrs_Tools.cpp
src/SketcherPrs/SketcherPrs_Transformation.cpp
src/SketcherPrs/SketcherPrs_Transformation.h

index 64e027394b0269b4bf915715f3698a68d922ee80..36c68a41def93f79f5dd30d24a4feb07c0cf38ad 100755 (executable)
@@ -44,7 +44,7 @@ bool SketcherPrs_Collinear::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
   return aReadyToDisplay;
 }
 
-bool SketcherPrs_Collinear::updatePoints(double theStep) const
+bool SketcherPrs_Collinear::updateIfReadyToDisplay(double theStep) const
 {
   if (!IsReadyToDisplay(myConstraint, myPlane))
     return false;
index e43fdac89aa4423b445ab2d5fb941340dc85ab7c..61f55c0b0f22e4375d36d1a63b0ff2c61b235c40 100755 (executable)
@@ -41,7 +41,7 @@ protected:
 
   /// Update myPntArray according to presentation positions
   /// \return true in case of success
-  virtual bool updatePoints(double theStep) const;
+  virtual bool updateIfReadyToDisplay(double theStep) const;
 };
 
 #endif
\ No newline at end of file
index 1a808f93587436409adcb27708e48097aa5f7b25..4423ca592888c07774a96dd0eaf13bca751e84b0 100644 (file)
@@ -44,7 +44,7 @@ bool SketcherPrs_Equal::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
   return aReadyToDisplay;
 }
 
-bool SketcherPrs_Equal::updatePoints(double theStep) const
+bool SketcherPrs_Equal::updateIfReadyToDisplay(double theStep) const
 {
   if (!IsReadyToDisplay(myConstraint, myPlane))
     return false;
index bba05f150c44b9da3177fd912fe5d8a8dc5db7a8..0e0dd3130a2189e1daee02b3cda0be374ea08f68 100644 (file)
@@ -41,7 +41,7 @@ protected:
 
   /// Update myPntArray according to presentation positions
   /// \return true in case of success
-  virtual bool updatePoints(double theStep) const;
+  virtual bool updateIfReadyToDisplay(double theStep) const;
 };
 
 #endif
\ No newline at end of file
index bc93712401620094cc956d2e6a5fe3af0c8401d2..23f68b7b1768e1b1c3212f47f531aece5cc8363c 100644 (file)
@@ -40,7 +40,7 @@ bool SketcherPrs_HVDirection::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
   return aReadyToDisplay;
 }
 
-bool SketcherPrs_HVDirection::updatePoints(double theStep) const 
+bool SketcherPrs_HVDirection::updateIfReadyToDisplay(double theStep) const 
 {
   if (!IsReadyToDisplay(myConstraint, myPlane))
     return false;
index 0f6bf64d3330bd76c225be7f5892319218b53799..39bd961a95082f4997ae5a1dcb8c8ab59a450555 100644 (file)
@@ -48,7 +48,7 @@ protected:
 
   /// Update myPntArray according to presentation positions
   /// \return true in case of success
-  virtual bool updatePoints(double theStep) const;
+  virtual bool updateIfReadyToDisplay(double theStep) const;
 
 private:
   bool myIsHorisontal;
index eaba7173302f9d565768f65e4a18acec4ea4cebf..4d4a00e15e7466b41045aa2e0937bd6d6fb5d280 100755 (executable)
@@ -45,7 +45,7 @@ bool SketcherPrs_Middle::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
   return aReadyToDisplay;
 }
 
-bool SketcherPrs_Middle::updatePoints(double theStep) const
+bool SketcherPrs_Middle::updateIfReadyToDisplay(double theStep) const
 {
   if (!IsReadyToDisplay(myConstraint, myPlane))
     return false;
index 10d22ba868d476c8c413fdda266cf75150b6887c..0ba22c9f9d39753ebd16068c390f017f4be57110 100755 (executable)
@@ -41,7 +41,7 @@ protected:
 
   /// Update myPntArray according to presentation positions
   /// \return true in case of success
-  virtual bool updatePoints(double theStep) const;
+  virtual bool updateIfReadyToDisplay(double theStep) const;
 
   /// Draw shape of the object. Find shape result if the object is feature
   void drawLine(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor,
index a1fea6f4d3d91fde3a20f69c68ffbaeac95a1fbe..30bbc6ec33ceba0d29740ace179e984cf1bf37bf 100644 (file)
@@ -57,7 +57,7 @@ bool SketcherPrs_Mirror::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
   return aReadyToDisplay;
 }
 
-bool SketcherPrs_Mirror::updatePoints(double theStep) const
+bool SketcherPrs_Mirror::updateIfReadyToDisplay(double theStep) const
 {
   if (!IsReadyToDisplay(myConstraint, myPlane))
     return false;
index 35d5c146cf1cd9496744630a440b1805dd865af6..3d3d311e89aee290f61fc45afaf0fc8d98045d39 100644 (file)
@@ -40,7 +40,7 @@ protected:
 
   /// Update myPntArray according to presentation positions
   /// \return true in case of success
-  virtual bool updatePoints(double theStep) const;
+  virtual bool updateIfReadyToDisplay(double theStep) const;
 };
 
 #endif
\ No newline at end of file
index 3a4d3be35020711da35aa3eaab395d64afa8075b..431c396b0e963cf83bc01735b5e8eaf0e1c9f3cb 100644 (file)
@@ -43,7 +43,7 @@ bool SketcherPrs_Parallel::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
   return aReadyToDisplay;
 }
 
-bool SketcherPrs_Parallel::updatePoints(double theStep) const
+bool SketcherPrs_Parallel::updateIfReadyToDisplay(double theStep) const
 {
   if (!IsReadyToDisplay(myConstraint, myPlane))
     return false;
index e2d415fb700732666fc8b77e6e24678492e7385e..cdadd05600617add43674eedde43cf23d4b785fe 100644 (file)
@@ -41,7 +41,7 @@ protected:
 
   /// Update myPntArray according to presentation positions
   /// \return true in case of success
-  virtual bool updatePoints(double theStep) const;
+  virtual bool updateIfReadyToDisplay(double theStep) const;
 };
 
 #endif
\ No newline at end of file
index cb5302eefa0311e098ee4ec3e694628fed478507..58a7cdec88a6c0ca8a9e7a5b502b2300be2b67f5 100644 (file)
@@ -43,7 +43,7 @@ bool SketcherPrs_Perpendicular::IsReadyToDisplay(ModelAPI_Feature* theConstraint
   return aReadyToDisplay;
 }
 
-bool SketcherPrs_Perpendicular::updatePoints(double theStep) const
+bool SketcherPrs_Perpendicular::updateIfReadyToDisplay(double theStep) const
 {
   if (!IsReadyToDisplay(myConstraint, myPlane))
     return false;
index 42bcf79538922e39b5a131fcdaafd58d99734438..33a6f7495d659675f4bd7ed1fe56095f4d7b50e6 100644 (file)
@@ -46,7 +46,7 @@ protected:
 
   /// Update myPntArray according to presentation positions
   /// \return true in case of success
-  virtual bool updatePoints(double theStep) const;
+  virtual bool updateIfReadyToDisplay(double theStep) const;
 };
 
 #endif
\ No newline at end of file
index 71122d431a4e0df0030e417815e0cf9bd60c23c8..5875d6c2954375b001ff07b238658178713c7f0f 100644 (file)
@@ -68,7 +68,7 @@ bool SketcherPrs_Rigid::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
   return aReadyToDisplay;
 }
 
-bool SketcherPrs_Rigid::updatePoints(double theStep) const 
+bool SketcherPrs_Rigid::updateIfReadyToDisplay(double theStep) const 
 {
   if (!IsReadyToDisplay(myConstraint, myPlane))
     return false;
index cf9d5042709ad139f9e9a80d35bf7e53250ad059..1bb7b4a613b26a7845c4819de2c6b63da9e577f9 100644 (file)
@@ -47,7 +47,7 @@ protected:
 
   /// Update myPntArray according to presentation positions
   /// \return true in case of success
-  virtual bool updatePoints(double theStep) const;
+  virtual bool updateIfReadyToDisplay(double theStep) const;
 
 };
 
index 2d42f57a568f39160cb31d29760ed9d5137c4458..33c02b37cd78ead80a7fb65d33ef13e634a05db5 100644 (file)
@@ -362,10 +362,10 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)&
   }
 
   // Update points with default shift value
-  if (!updatePoints(20)) {
-    Events_Error::throwException("An empty AIS presentation: SketcherPrs_SymbolPrs");
-    return;
-  }
+  // it updates array of points if the presentation is ready to display, or the array of points
+  // contains the previous values
+  
+  bool aReadyToDisplay = updateIfReadyToDisplay(20);
 
   int aNbVertex = myPntArray->VertexNumber();
   if (myOwner.IsNull()) {
@@ -397,6 +397,10 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)&
   // Disable frustum culling for this object by marking it as mutable
   aGroup->Structure()->SetMutable(true);
   //aGroup->AddPrimitiveArray(myPntArray);
+
+  if (!aReadyToDisplay)
+    SketcherPrs_Tools::sendEmptyPresentationError(myConstraint,
+                          "An empty AIS presentation: SketcherPrs_LengthDimension");
 }
 
 
@@ -448,8 +452,8 @@ void SketcherPrs_SymbolPrs::Render(const Handle(OpenGl_Workspace)& theWorkspace)
   // ShaperModification:start
   double aScale = aView->Camera()->Scale();
   // Update points coordinate taking the viewer scale into account
-  if (!updatePoints(MyDist * aScale))
-    return;
+  updateIfReadyToDisplay(MyDist * aScale);
+
   // ShaperModification:end
 
   Handle(Graphic3d_Buffer) aAttribs = myPntArray->Attributes();
index fb51129275e1b8ef28031c286b3efd082dc39235..458f860a74cb34fc97c5ca8a6cbe46aea4b4f80e 100644 (file)
@@ -116,7 +116,7 @@ protected:
 
   /// Update myPntArray according to presentation positions
   /// \return true in case of success
-  virtual bool updatePoints(double theStep) const { return true; }
+  virtual bool updateIfReadyToDisplay(double theStep) const { return true; }
 
   /// Draw a shape into the given presentation scene
   /// \param theShape the shape to draw
index cb86910fcee24a63618b5e199144a3f504823023..09fa6810969a7673009619641eac5509701e2d34 100644 (file)
@@ -47,7 +47,7 @@ bool SketcherPrs_Tangent::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
   return aReadyToDisplay;
 }
 
-bool SketcherPrs_Tangent::updatePoints(double theStep) const
+bool SketcherPrs_Tangent::updateIfReadyToDisplay(double theStep) const
 {
   if (!IsReadyToDisplay(myConstraint, myPlane))
     return false;
index baed8cf7d988478b8582d447de568a58ba72867b..a3cf98bbdeaa08a66d33a965a440c2b40160e837 100644 (file)
@@ -43,7 +43,7 @@ protected:
 
   /// Update myPntArray according to presentation positions
   /// \return true in case of success
-  virtual bool updatePoints(double theStep) const;
+  virtual bool updateIfReadyToDisplay(double theStep) const;
 };
 
 #endif
\ No newline at end of file
index 1bd65d40703a5f2d89cb4ce90c07bc4a8dbfdeab..ad33dbe9b679b8bfdec974128df93320f4a10021 100644 (file)
@@ -42,23 +42,37 @@ namespace SketcherPrs_Tools {
 
 AttributePtr getAttribute(ModelAPI_Feature* theFeature, const std::string& theAttrName)
 {
-  std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = aData->refattr(theAttrName);
-  return !anAttr->isObject() ? anAttr->attr() : AttributePtr();
+  AttributePtr anAttribute;
+  if (theFeature) {
+    std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+    if (aData.get() && aData->isValid()) { /// essential check as it is called in openGl thread
+      std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = aData->refattr(theAttrName);
+      if (!anAttr->isObject())
+        anAttribute = anAttr->attr();
+    }
+  }
+  return anAttribute;
 }
 
 ObjectPtr getResult(ModelAPI_Feature* theFeature, const std::string& theAttrName)
 {
-  std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = aData->refattr(theAttrName);
-  return anAttr->object();
+  ObjectPtr anObject;
+  if (theFeature) {
+    std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+    if (aData.get() && aData->isValid()) { /// essential check as it is called in openGl thread
+      std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = aData->refattr(theAttrName);
+      if (anAttr.get())
+        anObject = anAttr->object();
+    }
+  }
+  return anObject;
 }
 
 
 std::shared_ptr<GeomAPI_Shape> getShape(ObjectPtr theObject)
 {
   ResultConstructionPtr aRes = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theObject);
-  if (aRes.get() != NULL) {
+  if (aRes.get() != NULL && aRes->data()->isValid()) {/// essential check as it is called in openGl thread
     return aRes->shape();
   }
   return std::shared_ptr<GeomAPI_Shape>();
@@ -70,7 +84,8 @@ std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
 {
   std::shared_ptr<GeomDataAPI_Point2D> aPointAttr;
 
-  if (!theFeature->data())
+  /// essential check as it is called in openGl thread
+  if (!theFeature || !theFeature->data().get() || !theFeature->data()->isValid())
     return std::shared_ptr<GeomAPI_Pnt2d>();
 
   FeaturePtr aFeature;
@@ -144,7 +159,7 @@ std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
 {
   std::shared_ptr<GeomDataAPI_Point2D> aPointAttr;
 
-  if (!theData)
+  if (!theData.get() || !theData->isValid()) /// essential check as it is called in openGl thread
     return aPointAttr;
 
   FeaturePtr aFeature;
@@ -184,7 +199,7 @@ FeaturePtr getFeatureLine(DataPtr theData,
                           const std::string& theAttribute)
 {
   FeaturePtr aLine;
-  if (!theData)
+  if (!theData.get() || !theData->isValid()) /// essential check as it is called in openGl thread)
     return aLine;
 
   std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
@@ -203,6 +218,9 @@ std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(const FeaturePtr theLine,
                                                   const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
 {
   DataPtr aData = theLine->data();
+  if (!aData.get() || !aData->isValid())
+    return std::shared_ptr<GeomAPI_Pnt2d>();
+
   std::shared_ptr<GeomDataAPI_Point2D> aPoint1 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       aData->attribute(SketchPlugin_Line::START_ID()));
   std::shared_ptr<GeomDataAPI_Point2D> aPoint2 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
index d9dc0ab7fe38d05ef68343014733d17bfa721ee8..e4a4899ffef79ba0ba1ca34292bd270ac2d32994 100644 (file)
@@ -69,7 +69,7 @@ bool SketcherPrs_Transformation::IsReadyToDisplay(ModelAPI_Feature* theConstrain
   return aReadyToDisplay;
 }
 
-bool SketcherPrs_Transformation::updatePoints(double theStep) const 
+bool SketcherPrs_Transformation::updateIfReadyToDisplay(double theStep) const 
 {
   if (!IsReadyToDisplay(myConstraint, myPlane))
     return false;
index a41c9a0e067b45b75e5a8b919033827b75c22a63..068ac7c09b72606e41bb24c48e9303de31b51421 100644 (file)
@@ -47,7 +47,7 @@ protected:
 
   /// Update myPntArray according to presentation positions
   /// \return true in case of success
-  virtual bool updatePoints(double theStep) const;
+  virtual bool updateIfReadyToDisplay(double theStep) const;
 
 private:
   bool myIsTranslation;