Salome HOME
Merge remote-tracking branch 'remotes/origin/HighLevelDump'
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintSplit.h
index 5e7bae5b553a20554c564642c12eb183ad475468..2167a71c32761d33d63febd0b2fd2d5275d3f699 100755 (executable)
@@ -13,6 +13,9 @@
 
 class GeomDataAPI_Point2D;
 class ModelAPI_Feature;
+class ModelAPI_Result;
+
+typedef std::pair<std::string, std::shared_ptr<GeomDataAPI_Point2D> > IdToPointPair;
 
 /** \class SketchPlugin_ConstraintSplit
  *  \ingroup Plugins
@@ -53,10 +56,6 @@ class SketchPlugin_ConstraintSplit : public SketchPlugin_ConstraintBase
   /// \brief Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
-  /// Called on change of any argument-attribute of this object
-  /// \param theID identifier of changed attribute
-  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
-
   /// Returns the AIS preview
   //SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
 
@@ -64,6 +63,10 @@ class SketchPlugin_ConstraintSplit : public SketchPlugin_ConstraintBase
   /// \returns true
   SKETCHPLUGIN_EXPORT virtual bool isMacro() const;
 
+  /// Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false.
+  /// This is necessary to perform execute only by apply the feature
+  SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; }
+
   /// \brief Use plugin manager for features creation
   SketchPlugin_ConstraintSplit();
 
@@ -73,10 +76,12 @@ class SketchPlugin_ConstraintSplit : public SketchPlugin_ConstraintBase
   //};
 
 private:
-  /// Returns geom point attribute of the feature
-  /// \param theStartPoint
-  /// \return geometical point
-  std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(const bool& theStartPoint);
+  /// Returns geom point attribute of the feature bounds. It processes line or arc.
+  /// For circle feature, the result attributes are null
+  /// \param theStartPointAttr an out attribute to start point
+  /// \param theStartPointAttr an out attribute to end point
+  void getFeaturePoints(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
   /// \param theAttribute an attribute
@@ -86,10 +91,94 @@ private:
   /// Creates a new feature in the base shape type with bounding points given in parameters
   /// \param theStartPointAttr an attribute of the start point
   /// \param theEndPointAttr an attribute of the end point
-  std::shared_ptr<ModelAPI_Feature> FeaturePtr SketchPlugin_ConstraintSplit::createFeature(
-                                    const std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
-                                    const std::shared_ptr<GeomDataAPI_Point2D>& theEndPointAttr);
-
+  //std::shared_ptr<ModelAPI_Feature> createFeature(
+  //                                  const std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
+  //                                  const std::shared_ptr<GeomDataAPI_Point2D>& theEndPointAttr);
+
+  /// 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 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);
+
+  /// Obtains those constraints of the feature that should be modified
+  /// \param theSplitFeature a result split feature
+  /// \param theBaseFeature a modified base feature
+  /// \param theAfterFeature an additional created feature if source segement contain three parts
+  /// \param theFeaturesToDelete [out] constrains that will be deleted 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 setConstraints(const FeaturePtr& theSplitFeature,
+                      const FeaturePtr& theBaseFeature,
+                      const FeaturePtr& theAfterFeature,
+    const std::set<std::shared_ptr<ModelAPI_Feature>>& theFeaturesToDelete,
+    const std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theTangentFeatures,
+    const std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToFeature,
+    const std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToPoint);*/
+
+  /// Make the base object is splitted by the point attributes
+  /// \param theSplitFeature a result split feature
+  /// \param theBeforeFeature a feature between start point and the 1st point of split feature
+  /// \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
+  void splitArc(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);
+
+  /// 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 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 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);
+
+  /// 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
+  /// \param theSourceAttribute an attribute of GeomDataAPI_Point2D to obtain data
+  void fillAttribute(const AttributePtr& theModifiedAttribute,
+                     const AttributePtr& theSourceAttribute);
+
+  /// Creates an arc feature filled by center of base feature and given points
+  /// \param theBaseFeature another arc feature
+  /// \param theFirstAttribute an attribute with coordinates for the start point
+  /// \param theSecondAttribute an attribute with coordinates for the end point
+  FeaturePtr createArcFeature(const FeaturePtr& theBaseFeature,
+                              const AttributePtr& theFirstPointAttr,
+                              const AttributePtr& theSecondPointAttr);
+
+  /// Add feature coincidence constraint between given attributes
+  /// \param theConstraintId a constraint index
+  /// \param theFirstAttribute an attribute of further coincidence
+  /// \param theSecondAttribute an attribute of further coincidence
+  void createConstraint(const std::string& theConstraintId,
+                        const std::shared_ptr<ModelAPI_Attribute>& theFirstAttribute,
+                        const std::shared_ptr<ModelAPI_Attribute>& theSecondAttribute);
+
+  /// Add feature coincidence constraint between given attributes
+  /// \param theConstraintId a constraint index
+  /// \param theFirstAttribute an attribute of further coincidence
+  /// \param theFirstAttribute an attribute of further coincidence
+  void createConstraintForObjects(const std::string& theConstraintId,
+                        const std::shared_ptr<ModelAPI_Object>& theFirstObject,
+                        const std::shared_ptr<ModelAPI_Object>& theSecondObject);
+
+  /// Result result of the feature to build constraint with. For arc, circle it is an edge result.
+  /// \param theFeature a feature
+  /// \return result object
+  std::shared_ptr<ModelAPI_Result> getFeatureResult(
+                                    const std::shared_ptr<ModelAPI_Feature>& theFeature);
 private:
   //std::set<AttributePtr> myNewPoints; ///< set of new points
   //std::map<AttributePtr, FilletFeatures> myPointFeaturesMap; ///< map of point and features for fillet