X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_Offset.h;h=c18efdae3c213c1d1bb5f6af865e816322e90298;hb=026f4997e7531acff5d6677877d4e948088c46ac;hp=19fff782accf8e77085ebf99c8f5c377595b38a2;hpb=0bdfa8968f3cded98aad14dc9cc475cdb59e81ce;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_Offset.h b/src/SketchPlugin/SketchPlugin_Offset.h index 19fff782a..c18efdae3 100644 --- a/src/SketchPlugin/SketchPlugin_Offset.h +++ b/src/SketchPlugin/SketchPlugin_Offset.h @@ -1,4 +1,4 @@ -// Copyright (C) 2020 CEA/DEN, EDF R&D +// Copyright (C) 2020-2021 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 @@ -21,13 +21,19 @@ #define SketchPlugin_Offset_H_ #include -#include +#include + +#include + +#include + +class GeomAlgoAPI_MakeShape; /**\class SketchPlugin_Offset * \ingroup Plugins * \brief Builds offset curves in the sketch. */ -class SketchPlugin_Offset : public SketchPlugin_SketchEntity +class SketchPlugin_Offset : public SketchPlugin_ConstraintBase { public: /// Offset macro feature kind @@ -78,11 +84,7 @@ public: /// Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); - /// Reimplemented from ModelAPI_Feature::isMacro(). - /// \returns true - SKETCHPLUGIN_EXPORT virtual bool isMacro() const { return true; } - - SKETCHPLUGIN_EXPORT virtual bool isPreviesNeeded() const { return false; } + SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return true; } /// Find edges connected by coincident boundary constraint and composing a wire with /// the already selected segments. It means that not more than 2 edges can be connected @@ -91,16 +93,53 @@ public: /// \return \c false in case the action not performed. SKETCHPLUGIN_EXPORT virtual bool customAction(const std::string& theActionId); - /// Use plugin manager for features creatio + /// Returns the AIS preview + SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious); + + /// Use plugin manager for features creation. SketchPlugin_Offset(); protected: /// \brief Initializes attributes of derived class. - virtual void initDerivedClassAttributes(); + virtual void initAttributes(); private: /// Find all wires connected with the selected edges bool findWires(); + + /// Create sketch feature for each edge of the offset result, + /// and store it in ENTITY_B(). Original edges are copied to ENTITY_A() to update + /// correctly if original selection is modified. + void addToSketch (const std::list< std::shared_ptr >& theOffsetAlgos); + + /// Create BSpline or BSplinePeriodic sketch feature from theEdge + void mkBSpline (FeaturePtr& theResult, const GeomEdgePtr& theEdge, + std::list& thePoolOfFeatures); + + /// Update existent feature by the parameters of the given edge or create a new feature. + /// \param[in] theShape a shape to be converted to sketch feature + /// \param[in,out] theFeature sketch feature to be updated or created from scratch + /// \param[in,out] thePoolOfFeatures list of features to be removed (may be used as a new feature) + void updateExistentOrCreateNew (const GeomShapePtr& theShape, FeaturePtr& theFeature, + std::list& thePoolOfFeatures); + + /// Find edges that prolongate theEdgeFeature (in a chain) at theEndPoint + /// Recursive method. + /// \param[in] theFirstEdge Start edge of wire searching + /// \param[in] theEdge Current edge + /// \param[in] theEndPoint Point of the Current edge, not belonging to a previous edge + /// \param[in/out] theEdgesSet All edges to find among. If empty, all sketch edges assumed. + /// \param[in/out] theProcessedEdgesSet Already processed (put in chains) edges. + /// \param[in/out] theChain Resulting edges + /// \param[in] isPrepend if true, push new found edges to theChain front, else to the back + /// \return \c true if the chain is closed + bool findWireOneWay (const FeaturePtr& theFirstEdge, + const FeaturePtr& theEdge, + const std::shared_ptr& theEndPoint, + std::set& theEdgesSet, + std::set& theProcessedEdgesSet, + std::list& theChain, + const bool isPrepend = false); }; #endif