+ /*!
+ * Flags of extrusion.
+ * BOUNDARY: create or not boundary for result of extrusion
+ * SEW: try to use existing nodes or create new nodes in any case
+ * GROUPS: to create groups
+ * BY_AVG_NORMAL: step size is measured along average normal to elements,
+ * else step size is measured along average normal of any element
+ * USE_INPUT_ELEMS_ONLY: to use only input elements to compute extrusion direction
+ * for ExtrusionByNormal()
+ * SCALE_LINEAR_VARIATION: to make linear variation of scale factors
+ * ANGLE_LINEAR_VARIATION: to make linear variation of angles
+ */
+ enum ExtrusionFlags {
+ EXTRUSION_FLAG_BOUNDARY = 0x01,
+ EXTRUSION_FLAG_SEW = 0x02,
+ EXTRUSION_FLAG_GROUPS = 0x04,
+ EXTRUSION_FLAG_BY_AVG_NORMAL = 0x08,
+ EXTRUSION_FLAG_USE_INPUT_ELEMS_ONLY = 0x10,
+ EXTRUSION_FLAG_SCALE_LINEAR_VARIATION = 0x20,
+ EXTRUSION_FLAG_ANGLE_LINEAR_VARIATION = 0x40
+ };
+
+ /*!
+ * Generator of nodes for extrusion functionality
+ */
+ class SMESH_EXPORT ExtrusParam
+ {
+ public:
+ //! Point on extrusion path
+ struct PathPoint
+ {
+ gp_Pnt myPnt;
+ gp_Dir myTgt;
+ double myAngle, myScale;
+ PathPoint(): myPnt(99., 99., 99.), myTgt(1.,0.,0.), myAngle(0), myScale(0) {}
+ };
+
+ ExtrusParam( const gp_Vec& theStep,
+ const int theNbSteps,
+ const std::list<double>& theScales,
+ const std::list<double>& theAngles,
+ const gp_XYZ* theBaseP,
+ const int theFlags = 0,
+ const double theTolerance = 1e-6);
+ ExtrusParam( const gp_Dir& theDir,
+ Handle(TColStd_HSequenceOfReal) theSteps,
+ const int theFlags = 0,
+ const double theTolerance = 1e-6);
+ ExtrusParam( const double theStep,
+ const int theNbSteps,
+ const int theFlags,
+ const int theDim); // for extrusion by normal
+ ExtrusParam( const std::vector< PathPoint >& thePoints,
+ const gp_Pnt* theBaseP,
+ const std::list<double>& theScales,
+ const bool theMakeGroups); // for extrusion along path
+
+ SMESH_SequenceOfNode& ChangeNodes() { return myNodes; }
+ int& Flags() { return myFlags; }
+ bool ToMakeBoundary() const { return myFlags & EXTRUSION_FLAG_BOUNDARY; }
+ bool ToMakeGroups() const { return myFlags & EXTRUSION_FLAG_GROUPS; }
+ bool ToUseInpElemsOnly() const { return myFlags & EXTRUSION_FLAG_USE_INPUT_ELEMS_ONLY; }
+ bool IsScaleVariation() const { return myFlags & EXTRUSION_FLAG_SCALE_LINEAR_VARIATION; }
+ bool IsAngleVariation() const { return myFlags & EXTRUSION_FLAG_ANGLE_LINEAR_VARIATION; }
+ int NbSteps() const {
+ return mySteps.IsNull() ? myPathPoints.size() - 1: mySteps->Length();
+ }
+ // stores elements to use for extrusion by normal, depending on
+ // state of EXTRUSION_FLAG_USE_INPUT_ELEMS_ONLY flag;
+ // define myBaseP for scaling
+ void SetElementsToUse( const TIDSortedElemSet& elems, const TIDSortedElemSet& nodes );
+
+ // creates nodes and returns number of nodes added in \a newNodes
+ int MakeNodes( SMESHDS_Mesh* mesh,
+ const SMDS_MeshNode* srcNode,
+ std::list<const SMDS_MeshNode*> & newNodes,
+ const bool makeMediumNodes)
+ {
+ return (this->*myMakeNodesFun)( mesh, srcNode, newNodes, makeMediumNodes );
+ }
+ private:
+
+ gp_Dir myDir; // direction of extrusion
+ Handle(TColStd_HSequenceOfReal) mySteps; // magnitudes for each step
+ std::vector<double> myScales;// scale factors
+ std::vector<double> myAngles;// angles
+ gp_XYZ myBaseP; // scaling/rotation center
+ SMESH_SequenceOfNode myNodes; // nodes for using in sewing
+ int myFlags; // see ExtrusionFlags
+ double myTolerance; // tolerance for sewing nodes
+ const TIDSortedElemSet* myElemsToUse; // elements to use for extrusion by normal
+ std::vector< PathPoint > myPathPoints; // points along a path
+ int (ExtrusParam::* myMakeNodesFun)(SMESHDS_Mesh*, // function of extrusion method
+ const SMDS_MeshNode*,
+ std::list<const SMDS_MeshNode*> &,
+ const bool);
+ int makeNodesByDir( SMESHDS_Mesh* mesh,
+ const SMDS_MeshNode* srcNode,
+ std::list<const SMDS_MeshNode*> & newNodes,
+ const bool makeMediumNodes);
+ int makeNodesByDirAndSew( SMESHDS_Mesh* mesh,
+ const SMDS_MeshNode* srcNode,
+ std::list<const SMDS_MeshNode*> & newNodes,
+ const bool makeMediumNodes);
+ int makeNodesByNormal2D( SMESHDS_Mesh* mesh,
+ const SMDS_MeshNode* srcNode,
+ std::list<const SMDS_MeshNode*> & newNodes,
+ const bool makeMediumNodes);
+ int makeNodesByNormal1D( SMESHDS_Mesh* mesh,
+ const SMDS_MeshNode* srcNode,
+ std::list<const SMDS_MeshNode*> & newNodes,
+ const bool makeMediumNodes);
+ int makeNodesAlongTrack( SMESHDS_Mesh* mesh,
+ const SMDS_MeshNode* srcNode,
+ std::list<const SMDS_MeshNode*> & newNodes,
+ const bool makeMediumNodes);
+ // step iteration
+ void beginStepIter( bool withMediumNodes );
+ bool moreSteps();
+ double nextStep();
+ std::vector< double > myCurSteps;
+ bool myWithMediumNodes;
+ int myNextStep;
+ };
+
+ /*!
+ * Generate new elements by extrusion of theElements
+ * It is a method used in .idl file. All functionality
+ * is implemented in the next method (see below) which
+ * is used in the current method.
+ * @param theElems - list of elements for extrusion
+ * @param newElemsMap returns history of extrusion
+ * @param theFlags set flags for performing extrusion (see description
+ * of enum ExtrusionFlags for additional information)
+ * @param theTolerance - uses for comparing locations of nodes if flag
+ * EXTRUSION_FLAG_SEW is set
+ */
+ PGroupIDs ExtrusionSweep (TIDSortedElemSet theElems[2],
+ const gp_Vec& theStep,
+ const int theNbSteps,
+ TTElemOfElemListMap& newElemsMap,
+ const int theFlags,
+ const double theTolerance = 1.e-6);
+
+ /*!
+ * Generate new elements by extrusion of theElements
+ * @param theElems - list of elements for extrusion
+ * @param newElemsMap returns history of extrusion
+ * @param theFlags set flags for performing extrusion (see description
+ * of enum ExtrusionFlags for additional information)
+ * @param theTolerance - uses for comparing locations of nodes if flag
+ * EXTRUSION_FLAG_SEW is set
+ * @param theParams - special structure for manage of extrusion
+ */
+ PGroupIDs ExtrusionSweep (TIDSortedElemSet theElems[2],
+ ExtrusParam& theParams,
+ TTElemOfElemListMap& newElemsMap);
+
+