Salome HOME
Issue #2024: Redesign of circle and arc of circle
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintSplit.h
index bd602854c6100c6b7bdddcbddaba84f51ffb03ad..e4e1bc7705eb816b4abd8994ea553c445326d6b5 100755 (executable)
@@ -26,7 +26,7 @@ typedef std::pair<std::string, std::shared_ptr<GeomDataAPI_Point2D> > IdToPointP
  *
  * The following constraints will be applied after split to keep the divided segments geometry:
  * - Coincident constraints for both parts of created segments in the point of splitting
- * - For linear segments parallel, for circles \96 tangent constraint, for arc \96 tangent and equal
+ * - For linear segments parallel, for circles - tangent constraint, for arc - tangent and equal
  *   constraints. In case of three segments in result two couple of constraints are created
  *    - parallel and equal constraints: the first is between 1st and middle entity, the second is
  *      between 1st and 3rd.
@@ -80,17 +80,17 @@ class SketchPlugin_ConstraintSplit : public SketchPlugin_ConstraintBase
   /// \brief Use plugin manager for features creation
   SketchPlugin_ConstraintSplit();
 
-  /// \return map of base points and features;
-  //SKETCHPLUGIN_EXPORT const std::map<AttributePtr, FilletFeatures> pointsFeaturesMap() const {
-  //  return myPointFeaturesMap;
-  //};
+  /// Returns the AIS preview
+  SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
 
 private:
   /// Returns geom point attribute of the feature bounds. It processes line or arc.
   /// For circle feature, the result attributes are null
+  /// \param theFeature a source feature
   /// \param theStartPointAttr an out attribute to start point
   /// \param theStartPointAttr an out attribute to end point
-  void getFeaturePoints(std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
+  void getFeaturePoints(const FeaturePtr& theFeature,
+                        std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
                         std::shared_ptr<GeomDataAPI_Point2D>& theEndPointAttr);
 
   /// Returns cast of attribute to geometrical point if the attribute is a ref attr attribute
@@ -101,32 +101,50 @@ private:
   /// Obtains those constraints of the feature that should be modified. output maps contain
   /// point of coincidence and attribute id to be modified after split
   /// \param theFeaturesToDelete [out] constrains that will be deleted after split
+  /// \param theFeaturesToUpdate [out] constrains that will be updated after split
   /// \param theTangentFeatures  [out] tangent feature to be connected to new feature
   /// \param theCoincidenceToFeature [out] coincidence to feature to be connected to new feature
   /// \param theCoincidenceToPoint [out] coincidence to point be connected to new feature
   void getConstraints(std::set<std::shared_ptr<ModelAPI_Feature>>& theFeaturesToDelete,
-              std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theTangentFeatures,
-              std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToFeature,
-              std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToPoint);
+              std::set<std::shared_ptr<ModelAPI_Feature>>& theFeaturesToUpdate,
+              std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToFeature);
 
+  /// Obtains references to feature point attributes and to feature,
+  /// e.g. for feature line: 1st container is
+  ///             <1st line point, list<entity_a in distance, entity_b in parallel> >
+  ///             <2nd line point, list<> >
+  ///      for feature circle 2nd container is <entity_a in Radius, entity_b in equal, ...>
+  /// \param theFeature an investigated feature
+  /// \param theRefs a container of list of referenced attributes
   void getRefAttributes(const FeaturePtr& theFeature,
-                        std::map<AttributePtr, std::list<AttributePtr> >& theRefs);
+                        std::map<AttributePtr, std::list<AttributePtr> >& theRefs,
+                        std::list<AttributePtr>& theRefsToFeature);
 
   /// Move coincidence constraint from feature to point if it is found
   /// \param theCoincidenceToFeature coincidence to feature to be connected to new feature
   /// \param theFurtherCoincidences a list of points where coincidences will be build
-  /// \paramv theFeatureResults created results after split where constaint might be connected
+  /// \param theFeatureResults created results after split where constaint might be connected
+  /// \param theSplitFeature feature created by split, new coincidences to points should be created
+  /// if theCoincidenceToFeature contains equal points
   void updateCoincidenceConstraintsToFeature(
-              const std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToFeature,
-              const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theFurtherCoincidences,
-              const std::set<ResultPtr>& theFeatureResults);
+      const std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToFeature,
+      const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theFurtherCoincidences,
+      const std::set<ResultPtr>& theFeatureResults,
+      const FeaturePtr& theSplitFeature);
+
+  /// Move constraints from base feature to given feature
+  /// \param theFeature a base feature
+  /// \param theRefsToFeature list of attributes referenced to base feature
+  void updateRefFeatureConstraints(const std::shared_ptr<ModelAPI_Result>& theFeatureBaseResult,
+                                   const std::list<AttributePtr>& theRefsToFeature);
 
-  /// Move tangency constraint to the nearest split feature that has a coincidence to the tangent
-  /// \param theTangentFeatures tangencies to feature to be connected to nearest feature
-  /// \param theFurtherCoincidences a list of points where coincidences is built
-  void updateTangentConstraintsToFeature(
-              const std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theTangentFeatures,
-              const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theFurtherCoincidences);
+  /// Move constraints from attribute of base feature to attribute after modification
+  /// \param theBaseRefAttributes container of references to the attributes of base feature
+  /// \param theModifiedAttributes container of attributes placed instead of base attributes
+  /// at the same place
+  void updateRefAttConstraints(
+               const std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes,
+               const std::set<std::pair<AttributePtr, AttributePtr> >& theModifiedAttributes);
 
   /// Make the base object is splitted by the point attributes
   /// \param theSplitFeature a result split feature
@@ -134,11 +152,14 @@ private:
   /// \param theAfterFeature a feature between last point of split feature and the end point
   /// \param thePoints a list of points where coincidences will be build
   /// \param theCreatedFeatures a container of created features
+  /// \param theModifiedAttributes a container of attribute on base
+  /// feature to attribute on new feature
   void splitLine(std::shared_ptr<ModelAPI_Feature>& theSplitFeature,
                  std::shared_ptr<ModelAPI_Feature>& theBeforeFeature,
                  std::shared_ptr<ModelAPI_Feature>& theAfterFeature,
                  std::set<std::shared_ptr<GeomDataAPI_Point2D> >& thePoints,
-                 std::set<std::shared_ptr<ModelAPI_Feature>>& theCreatedFeatures);
+                 std::set<std::shared_ptr<ModelAPI_Feature>>& theCreatedFeatures,
+                 std::set<std::pair<AttributePtr, AttributePtr>>& theModifiedAttributes);
 
   /// Make the base object is splitted by the point attributes
   /// \param theSplitFeature a result split feature
@@ -150,7 +171,8 @@ private:
                 std::shared_ptr<ModelAPI_Feature>& theBeforeFeature,
                 std::shared_ptr<ModelAPI_Feature>& theAfterFeature,
                 std::set<std::shared_ptr<GeomDataAPI_Point2D> >& thePoints,
-                std::set<std::shared_ptr<ModelAPI_Feature>>& theCreatedFeatures);
+                std::set<std::shared_ptr<ModelAPI_Feature>>& theCreatedFeatures,
+                std::set<std::pair<AttributePtr, AttributePtr>>& theModifiedAttributes);
 
   /// Make the base object is splitted by the point attributes
   /// \param theSplitFeature a result split feature
@@ -162,7 +184,8 @@ private:
                    std::shared_ptr<ModelAPI_Feature>& theBeforeFeature,
                    std::shared_ptr<ModelAPI_Feature>& theAfterFeature,
                    std::set<std::shared_ptr<GeomDataAPI_Point2D> >& thePoints,
-                   std::set<std::shared_ptr<ModelAPI_Feature>>& theCreatedFeatures);
+                   std::set<std::shared_ptr<ModelAPI_Feature>>& theCreatedFeatures,
+                   std::set<std::pair<AttributePtr, AttributePtr>>& theModifiedAttributes);
 
   /// Correct the first and the second point to provide condition that the first is closer to
   /// the start point and the second point - to the last end of current segment. To rearrange
@@ -171,10 +194,24 @@ private:
   /// \param theEndPointAttr an end point of a segment
   /// \param theFirstPointAttr a start point of a segment
   /// \param theSecondPointAttr an end point of a segment
-  void arrangePoints(const std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
-                     const std::shared_ptr<GeomDataAPI_Point2D>& theEndPointAttr,
-                     std::shared_ptr<GeomDataAPI_Point2D>& theFirstPointAttr,
-                     std::shared_ptr<GeomDataAPI_Point2D>& theSecondPointAttr);
+  void arrangePointsOnLine(const std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
+                           const std::shared_ptr<GeomDataAPI_Point2D>& theEndPointAttr,
+                           std::shared_ptr<GeomDataAPI_Point2D>& theFirstPointAttr,
+                           std::shared_ptr<GeomDataAPI_Point2D>& theSecondPointAttr) const;
+
+  /// Correct the first and the second point to provide condition that the first is closer to
+  /// the start point and the second point - to the last end of current segment. To rearrange
+  /// them if this condition is not satisfied.
+  /// \param theArc an arc to be split
+  /// \param theStartPointAttr a start point of a segment
+  /// \param theEndPointAttr an end point of a segment
+  /// \param theFirstPointAttr a start point of a segment
+  /// \param theSecondPointAttr an end point of a segment
+  void arrangePointsOnArc(const FeaturePtr& theArc,
+                          const std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
+                          const std::shared_ptr<GeomDataAPI_Point2D>& theEndPointAttr,
+                          std::shared_ptr<GeomDataAPI_Point2D>& theFirstPointAttr,
+                          std::shared_ptr<GeomDataAPI_Point2D>& theSecondPointAttr) const;
 
   /// Fill attribute by value of another attribute. It processes only Point 2D attributes.
   /// \param theModifiedAttribute an attribute of GeomDataAPI_Point2D on feature to be modified
@@ -214,6 +251,10 @@ private:
                         const std::shared_ptr<ModelAPI_Object>& theFirstObject,
                         const std::shared_ptr<ModelAPI_Object>& theSecondObject);
 
+  /// Add feature coincidence constraint between given attributes
+  /// \param theFeaturesToUpdate a constraint index
+  void updateFeaturesAfterSplit(const std::set<FeaturePtr>& theFeaturesToUpdate);
+
   /// Result result of the feature to build constraint with. For arc, circle it is an edge result.
   /// \param theFeature a feature
   /// \return result object
@@ -226,11 +267,13 @@ private:
   std::set<std::shared_ptr<ModelAPI_Attribute> > getEdgeAttributes(
                                     const std::shared_ptr<ModelAPI_Feature>& theFeature);
 
+#ifdef _DEBUG
   /// Return feature name, kind, point attribute values united in a string
   /// \param theFeature an investigated feature
   /// \return string value
   std::string getFeatureInfo(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                              const bool isUseAttributesInfo = true);
+#endif
 };
 
 #endif