X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSketchPlugin%2FSketchPlugin_Split.h;h=05c33c38c648f71b63ca8ff1d4745e5238d440b6;hb=4d139bda8e931e65bf1a63b12e6b13d26ae9b205;hp=4a37a3f0a17e807c36bd68868f340e4aa84c41e4;hpb=87b6a30a3afb8fb32e7e43ade8d9c947d9eb1684;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Split.h b/src/SketchPlugin/SketchPlugin_Split.h index 4a37a3f0a..05c33c38c 100644 --- a/src/SketchPlugin/SketchPlugin_Split.h +++ b/src/SketchPlugin/SketchPlugin_Split.h @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,18 +12,18 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef SketchPlugin_Split_H_ #define SketchPlugin_Split_H_ #include "SketchPlugin.h" +#include "SketchPlugin_Tools.h" -#include "GeomAPI_IPresentable.h" +#include #include #include @@ -38,13 +38,14 @@ typedef std::pair > IdToPointP * \ingroup Plugins * \brief Feature for creation of a new constraint splitting object. Entities for split: * - Linear segment by point(s) on this line - * - Arc by point(s) on this arc - * - Circle by at least 2 split-points on this circle + * - Circular/elliptic arc by point(s) on this arc + * - Circle/ellipse by at least 2 split-points on it * * 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 - tangent constraint, for arc - tangent and equal - * constraints. In case of three segments in result two couple of constraints are created + * - For linear segments parallel, for circles/ellipses - 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. * - tangency constraints: the first between 1st and 2nd, the second between 2nd and 3rd. @@ -58,11 +59,6 @@ typedef std::pair > IdToPointP * start point of arc/line. * - Replication constraint used split feature will be deleted in the same way as it is deleted * by any of entity delete in sketch which is used in this constraint. - * - * This constraint has three attributes: - * SketchPlugin_Constraint::VALUE() contains reference object to be splitted - * SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B() for the points of split; - * */ class SketchPlugin_Split : public SketchPlugin_Feature, public GeomAPI_IPresentable, public ModelAPI_IReentrant @@ -128,35 +124,10 @@ class SketchPlugin_Split : public SketchPlugin_Feature, public GeomAPI_IPresenta /// Returns the AIS preview SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious); - /// Moves the feature : Empty - SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {}; - /// Apply information of the message to current object. It fills selected point and object virtual std::string processEvent(const std::shared_ptr& theMessage); private: - /// Fulfill an internal container by shapes obtained from the parameter object - /// Shapes are result of split operation by points coincident to shape of the object - /// \param theObject a source object (will be splitted) - /// \param theSketch a sketch object - void fillObjectShapes(const ObjectPtr& theObject, const ObjectPtr& theSketch); - - GeomShapePtr getSubShape(const std::string& theObjectAttributeId, - const std::string& thePointAttributeId); - /// 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(const FeaturePtr& theFeature, - std::shared_ptr& theStartPointAttr, - std::shared_ptr& theEndPointAttr); - - /// Returns cast of attribute to geometrical point if the attribute is a ref attr attribute - /// \param theAttribute an attribute - /// \param geom point 2D or NULL - std::shared_ptr getPointOfRefAttr(const AttributePtr& theAttribute); - /// 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 @@ -168,28 +139,20 @@ private: std::set>& theFeaturesToUpdate, std::map, IdToPointPair>& theCoincidenceToFeature); - /// Obtains references to feature point attributes and to feature, - /// e.g. for feature line: 1st container is - /// <1st line point, list > - /// <2nd line point, list<> > - /// for feature circle 2nd container is - /// \param theFeature an investigated feature - /// \param theRefs a container of list of referenced attributes - void getRefAttributes(const FeaturePtr& theFeature, - std::map >& theRefs, - std::list& 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 /// \param theFeatureResults created results after split where constaint might be connected /// \param theSplitFeature feature created by split, new coincidences to points should be created + /// \param theFeaturesToDelete the list of removed features (will be updated here by + /// the coincidences to be removed) /// if theCoincidenceToFeature contains equal points void updateCoincidenceConstraintsToFeature( const std::map, IdToPointPair>& theCoincidenceToFeature, const std::set >& theFurtherCoincidences, const std::set& theFeatureResults, - const FeaturePtr& theSplitFeature); + const FeaturePtr& theSplitFeature, + std::set& theFeaturesToDelete); /// Move constraints from base feature to given feature /// \param theFeature a base feature @@ -197,14 +160,6 @@ private: void updateRefFeatureConstraints(const std::shared_ptr& theFeatureBaseResult, const std::list& theRefsToFeature); - /// 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 >& theBaseRefAttributes, - const std::set >& theModifiedAttributes); - /// 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 @@ -235,6 +190,20 @@ private: std::set>& theCreatedFeatures, std::set>& theModifiedAttributes); + /// 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 + /// \param theCreatedFeatures a container of created features + /// \return new elliptic arc if it was created + FeaturePtr splitEllipticArc(std::shared_ptr& theSplitFeature, + std::shared_ptr& theBeforeFeature, + std::shared_ptr& theAfterFeature, + std::set >& thePoints, + std::set>& theCreatedFeatures, + std::set>& theModifiedAttributes); + /// 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 @@ -242,7 +211,7 @@ private: /// \param thePoints a list of points where coincidences will be build /// \param theCreatedFeatures a container of created features /// \return new arc if it was created - FeaturePtr splitCircle(std::shared_ptr& theSplitFeature, + FeaturePtr splitClosed(std::shared_ptr& theSplitFeature, std::shared_ptr& theBeforeFeature, std::shared_ptr& theAfterFeature, std::set >& thePoints, @@ -281,48 +250,6 @@ private: void fillAttribute(const AttributePtr& theModifiedAttribute, const AttributePtr& theSourceAttribute); - /// Creates a line 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 createLineFeature(const FeaturePtr& theBaseFeature, - const AttributePtr& theFirstPointAttr, - const AttributePtr& theSecondPointAttr); - - /// 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 - std::shared_ptr createConstraint(const std::string& theConstraintId, - const std::shared_ptr& theFirstAttribute, - const std::shared_ptr& 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 - std::shared_ptr createConstraintForObjects(const std::string& theConstraintId, - const std::shared_ptr& theFirstObject, - const std::shared_ptr& theSecondObject); - - /// Add feature coincidence constraint between given attributes - /// \param theFeaturesToUpdate a constraint index - void updateFeaturesAfterSplit(const std::set& 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 - std::shared_ptr getFeatureResult( - const std::shared_ptr& theFeature); - /// Returns attributes of the feature, used in edge build, for arc it is end and start points /// \param theFeature a feature /// \return container of attributes @@ -342,11 +269,10 @@ private: const bool isUseAttributesInfo = true); #endif private: - typedef std::map, - std::shared_ptr > PntToAttributesMap; std::map, std::set > myCashedShapes; - std::map, PntToAttributesMap> myCashedReferences; + std::map, + GeomAlgoAPI_ShapeTools::PointToRefsMap> myCashedReferences; }; #endif