1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SMESH_MeshEditor.hxx
24 // Created : Mon Apr 12 14:56:19 2004
25 // Author : Edward AGAPOV (eap)
28 #ifndef SMESH_MeshEditor_HeaderFile
29 #define SMESH_MeshEditor_HeaderFile
31 #include "SMESH_SMESH.hxx"
33 #include "SMDS_MeshElement.hxx"
34 #include "SMESH_Controls.hxx"
35 #include "SMESH_Mesh.hxx"
36 #include "SMESH_TypeDefs.hxx"
38 #include <utilities.h>
40 #include <TColStd_HSequenceOfReal.hxx>
52 class SMESH_MesherHelper;
55 //=======================================================================
57 * \brief Searcher for the node closest to point
59 //=======================================================================
60 struct SMESH_NodeSearcher
62 virtual const SMDS_MeshNode* FindClosestTo( const gp_Pnt& pnt ) = 0;
63 virtual void MoveNode( const SMDS_MeshNode* node, const gp_Pnt& toPnt ) = 0;
66 //=======================================================================
68 * \brief Searcher for elements
70 //=======================================================================
72 struct SMESH_ElementSearcher
75 * \brief Find elements of given type where the given point is IN or ON.
76 * Returns nb of found elements and elements them-selves.
78 * 'ALL' type means elements of any type excluding nodes and 0D elements
80 virtual int FindElementsByPoint(const gp_Pnt& point,
81 SMDSAbs_ElementType type,
82 std::vector< const SMDS_MeshElement* >& foundElems)=0;
84 * \brief Return an element most close to the given point
86 virtual const SMDS_MeshElement* FindClosestTo( const gp_Pnt& point,
87 SMDSAbs_ElementType type) = 0;
89 * \brief Return elements possibly intersecting the line
91 virtual void GetElementsNearLine( const gp_Ax1& line,
92 SMDSAbs_ElementType type,
93 std::vector< const SMDS_MeshElement* >& foundElems)=0;
95 * \brief Find out if the given point is out of closed 2D mesh.
97 virtual TopAbs_State GetPointState(const gp_Pnt& point) = 0;
101 // ============================================================
103 * \brief Editor of a mesh
105 // ============================================================
107 class SMESH_EXPORT SMESH_MeshEditor
111 SMESH_MeshEditor( SMESH_Mesh* theMesh );
116 SMDS_MeshElement* AddElement(const std::vector<const SMDS_MeshNode*> & nodes,
117 const SMDSAbs_ElementType type,
120 const double ballDiameter=0.);
124 SMDS_MeshElement* AddElement(const std::vector<int> & nodeIDs,
125 const SMDSAbs_ElementType type,
129 int Remove (const std::list< int >& theElemIDs, const bool isNodes);
130 // Remove a node or an element.
131 // Modify a compute state of sub-meshes which become empty
133 bool InverseDiag (const SMDS_MeshElement * theTria1,
134 const SMDS_MeshElement * theTria2 );
135 // Replace two neighbour triangles with ones built on the same 4 nodes
136 // but having other common link.
137 // Return False if args are improper
139 bool InverseDiag (const SMDS_MeshNode * theNode1,
140 const SMDS_MeshNode * theNode2 );
141 // Replace two neighbour triangles sharing theNode1-theNode2 link
142 // with ones built on the same 4 nodes but having other common link.
143 // Return false if proper faces not found
145 bool DeleteDiag (const SMDS_MeshNode * theNode1,
146 const SMDS_MeshNode * theNode2 );
147 // Replace two neighbour triangles sharing theNode1-theNode2 link
148 // with a quadrangle built on the same 4 nodes.
149 // Return false if proper faces not found
151 bool Reorient (const SMDS_MeshElement * theElement);
152 // Reverse theElement orientation
154 int Reorient2D (TIDSortedElemSet & theFaces,
155 const gp_Dir& theDirection,
156 const SMDS_MeshElement * theFace);
157 // Reverse theFaces whose orientation to be same as that of theFace
158 // oriented according to theDirection. Return nb of reoriented faces
161 * \brief Fuse neighbour triangles into quadrangles.
162 * \param theElems - The triangles to be fused.
163 * \param theCriterion - Is used to choose a neighbour to fuse with.
164 * \param theMaxAngle - Is a max angle between element normals at which fusion
165 * is still performed; theMaxAngle is mesured in radians.
166 * \return bool - Success or not.
168 bool TriToQuad (TIDSortedElemSet & theElems,
169 SMESH::Controls::NumericalFunctorPtr theCriterion,
170 const double theMaxAngle);
173 * \brief Split quadrangles into triangles.
174 * \param theElems - The faces to be splitted.
175 * \param theCriterion - Is used to choose a diagonal for splitting.
176 * \return bool - Success or not.
178 bool QuadToTri (TIDSortedElemSet & theElems,
179 SMESH::Controls::NumericalFunctorPtr theCriterion);
182 * \brief Split quadrangles into triangles.
183 * \param theElems - The faces to be splitted.
184 * \param the13Diag - Is used to choose a diagonal for splitting.
185 * \return bool - Success or not.
187 bool QuadToTri (TIDSortedElemSet & theElems,
188 const bool the13Diag);
191 * \brief Find better diagonal for splitting.
192 * \param theQuad - The face to find better splitting of.
193 * \param theCriterion - Is used to choose a diagonal for splitting.
194 * \return int - 1 for 1-3 diagonal, 2 for 2-4, -1 - for errors.
196 int BestSplit (const SMDS_MeshElement* theQuad,
197 SMESH::Controls::NumericalFunctorPtr theCriterion);
200 enum SplitVolumToTetraFlags { HEXA_TO_5 = 1, HEXA_TO_6 = 2, HEXA_TO_24 = 3 };//!<arg of SplitVolumesIntoTetra()
202 * \brief Split volumic elements into tetrahedra.
204 void SplitVolumesIntoTetra (const TIDSortedElemSet & theElems, const int theMethodFlags);
207 enum SmoothMethod { LAPLACIAN = 0, CENTROIDAL };
209 void Smooth (TIDSortedElemSet & theElements,
210 std::set<const SMDS_MeshNode*> & theFixedNodes,
211 const SmoothMethod theSmoothMethod,
212 const int theNbIterations,
213 double theTgtAspectRatio = 1.0,
214 const bool the2D = true);
215 // Smooth theElements using theSmoothMethod during theNbIterations
216 // or until a worst element has aspect ratio <= theTgtAspectRatio.
217 // Aspect Ratio varies in range [1.0, inf].
218 // If theElements is empty, the whole mesh is smoothed.
219 // theFixedNodes contains additionally fixed nodes. Nodes built
220 // on edges and boundary nodes are always fixed.
221 // If the2D, smoothing is performed using UV parameters of nodes
222 // on geometrical faces
224 typedef std::auto_ptr< std::list<int> > PGroupIDs;
226 PGroupIDs RotationSweep (TIDSortedElemSet & theElements,
227 const gp_Ax1& theAxis,
228 const double theAngle,
229 const int theNbSteps,
230 const double theToler,
231 const bool theMakeGroups,
232 const bool theMakeWalls=true);
233 // Generate new elements by rotation of theElements around theAxis
234 // by theAngle by theNbSteps
237 * Auxilary flag for advanced extrusion.
238 * BOUNDARY: create or not boundary for result of extrusion
239 * SEW: try to use existing nodes or create new nodes in any case
241 enum ExtrusionFlags {
242 EXTRUSION_FLAG_BOUNDARY = 0x01,
243 EXTRUSION_FLAG_SEW = 0x02
247 * special structure for control of extrusion functionality
250 gp_Dir myDir; // direction of extrusion
251 Handle(TColStd_HSequenceOfReal) mySteps; // magnitudes for each step
252 SMESH_SequenceOfNode myNodes; // nodes for using in sewing
256 * Create new node in the mesh with given coordinates
257 * (auxiliary for advanced extrusion)
259 const SMDS_MeshNode* CreateNode(const double x,
262 const double tolnode,
263 SMESH_SequenceOfNode& aNodes);
266 * Generate new elements by extrusion of theElements
267 * It is a method used in .idl file. All functionality
268 * is implemented in the next method (see below) which
269 * is used in the current method.
270 * @param theElems - list of elements for extrusion
271 * @param newElemsMap returns history of extrusion
272 * @param theFlags set flags for performing extrusion (see description
273 * of enum ExtrusionFlags for additional information)
274 * @param theTolerance - uses for comparing locations of nodes if flag
275 * EXTRUSION_FLAG_SEW is set
277 PGroupIDs ExtrusionSweep (TIDSortedElemSet & theElems,
278 const gp_Vec& theStep,
279 const int theNbSteps,
280 TElemOfElemListMap& newElemsMap,
281 const bool theMakeGroups,
282 const int theFlags = EXTRUSION_FLAG_BOUNDARY,
283 const double theTolerance = 1.e-6);
286 * Generate new elements by extrusion of theElements
287 * @param theElems - list of elements for extrusion
288 * @param newElemsMap returns history of extrusion
289 * @param theFlags set flags for performing extrusion (see description
290 * of enum ExtrusionFlags for additional information)
291 * @param theTolerance - uses for comparing locations of nodes if flag
292 * EXTRUSION_FLAG_SEW is set
293 * @param theParams - special structure for manage of extrusion
295 PGroupIDs ExtrusionSweep (TIDSortedElemSet & theElems,
296 ExtrusParam& theParams,
297 TElemOfElemListMap& newElemsMap,
298 const bool theMakeGroups,
300 const double theTolerance);
303 // Generate new elements by extrusion of theElements
304 // by theStep by theNbSteps
306 enum Extrusion_Error {
311 EXTR_BAD_STARTING_NODE,
312 EXTR_BAD_ANGLES_NUMBER,
313 EXTR_CANT_GET_TANGENT
316 Extrusion_Error ExtrusionAlongTrack (TIDSortedElemSet & theElements,
317 SMESH_subMesh* theTrackPattern,
318 const SMDS_MeshNode* theNodeStart,
319 const bool theHasAngles,
320 std::list<double>& theAngles,
321 const bool theLinearVariation,
322 const bool theHasRefPoint,
323 const gp_Pnt& theRefPoint,
324 const bool theMakeGroups);
325 Extrusion_Error ExtrusionAlongTrack (TIDSortedElemSet & theElements,
326 SMESH_Mesh* theTrackPattern,
327 const SMDS_MeshNode* theNodeStart,
328 const bool theHasAngles,
329 std::list<double>& theAngles,
330 const bool theLinearVariation,
331 const bool theHasRefPoint,
332 const gp_Pnt& theRefPoint,
333 const bool theMakeGroups);
334 // Generate new elements by extrusion of theElements along path given by theTrackPattern,
335 // theHasAngles are the rotation angles, base point can be given by theRefPoint
337 PGroupIDs Transform (TIDSortedElemSet & theElements,
338 const gp_Trsf& theTrsf,
340 const bool theMakeGroups,
341 SMESH_Mesh* theTargetMesh=0);
342 // Move or copy theElements applying theTrsf to their nodes
345 typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
347 void FindCoincidentNodes (TIDSortedNodeSet & theNodes,
348 const double theTolerance,
349 TListOfListOfNodes & theGroupsOfNodes);
350 // Return list of group of nodes close to each other within theTolerance.
351 // Search among theNodes or in the whole mesh if theNodes is empty.
354 * \brief Return SMESH_NodeSearcher. The caller is responsible for deleteing it
356 SMESH_NodeSearcher* GetNodeSearcher();
359 * \brief Return SMESH_ElementSearcher. The caller is responsible for deleting it
361 SMESH_ElementSearcher* GetElementSearcher();
362 SMESH_ElementSearcher* GetElementSearcher( SMDS_ElemIteratorPtr elemIt );
364 * \brief Return true if the point is IN or ON of the element
366 static bool IsOut( const SMDS_MeshElement* element, const gp_Pnt& point, double tol );
368 static double GetDistance( const SMDS_MeshFace* face, const gp_Pnt& point );
370 int SimplifyFace (const std::vector<const SMDS_MeshNode *> faceNodes,
371 std::vector<const SMDS_MeshNode *>& poly_nodes,
372 std::vector<int>& quantities) const;
373 // Split face, defined by <faceNodes>, into several faces by repeating nodes.
374 // Is used by MergeNodes()
376 void MergeNodes (TListOfListOfNodes & theNodeGroups);
377 // In each group, the cdr of nodes are substituted by the first one
380 typedef std::list< std::list< int > > TListOfListOfElementsID;
382 void FindEqualElements(std::set<const SMDS_MeshElement*> & theElements,
383 TListOfListOfElementsID & theGroupsOfElementsID);
384 // Return list of group of elements build on the same nodes.
385 // Search among theElements or in the whole mesh if theElements is empty.
387 void MergeElements(TListOfListOfElementsID & theGroupsOfElementsID);
388 // In each group remove all but first of elements.
390 void MergeEqualElements();
391 // Remove all but one of elements built on the same nodes.
392 // Return nb of successfully merged groups.
394 static bool CheckFreeBorderNodes(const SMDS_MeshNode* theNode1,
395 const SMDS_MeshNode* theNode2,
396 const SMDS_MeshNode* theNode3 = 0);
397 // Return true if the three nodes are on a free border
399 static bool FindFreeBorder (const SMDS_MeshNode* theFirstNode,
400 const SMDS_MeshNode* theSecondNode,
401 const SMDS_MeshNode* theLastNode,
402 std::list< const SMDS_MeshNode* > & theNodes,
403 std::list< const SMDS_MeshElement* >& theFaces);
404 // Return nodes and faces of a free border if found
408 // for SewFreeBorder()
409 SEW_BORDER1_NOT_FOUND,
410 SEW_BORDER2_NOT_FOUND,
411 SEW_BOTH_BORDERS_NOT_FOUND,
413 SEW_VOLUMES_TO_SPLIT,
414 // for SewSideElements()
415 SEW_DIFF_NB_OF_ELEMENTS,
416 SEW_TOPO_DIFF_SETS_OF_ELEMENTS,
423 Sew_Error SewFreeBorder (const SMDS_MeshNode* theBorderFirstNode,
424 const SMDS_MeshNode* theBorderSecondNode,
425 const SMDS_MeshNode* theBorderLastNode,
426 const SMDS_MeshNode* theSide2FirstNode,
427 const SMDS_MeshNode* theSide2SecondNode,
428 const SMDS_MeshNode* theSide2ThirdNode = 0,
429 const bool theSide2IsFreeBorder = true,
430 const bool toCreatePolygons = false,
431 const bool toCreatePolyedrs = false);
432 // Sew the free border to the side2 by replacing nodes in
433 // elements on the free border with nodes of the elements
434 // of the side 2. If nb of links in the free border and
435 // between theSide2FirstNode and theSide2LastNode are different,
436 // additional nodes are inserted on a link provided that no
437 // volume elements share the splitted link.
438 // The side 2 is a free border if theSide2IsFreeBorder == true.
439 // Sewing is peformed between the given first, second and last
440 // nodes on the sides.
441 // theBorderFirstNode is merged with theSide2FirstNode.
442 // if (!theSide2IsFreeBorder) then theSide2SecondNode gives
443 // the last node on the side 2, which will be merged with
444 // theBorderLastNode.
445 // if (theSide2IsFreeBorder) then theSide2SecondNode will
446 // be merged with theBorderSecondNode.
447 // if (theSide2IsFreeBorder && theSide2ThirdNode == 0) then
448 // the 2 free borders are sewn link by link and no additional
449 // nodes are inserted.
450 // Return false, if sewing failed.
452 Sew_Error SewSideElements (TIDSortedElemSet& theSide1,
453 TIDSortedElemSet& theSide2,
454 const SMDS_MeshNode* theFirstNode1ToMerge,
455 const SMDS_MeshNode* theFirstNode2ToMerge,
456 const SMDS_MeshNode* theSecondNode1ToMerge,
457 const SMDS_MeshNode* theSecondNode2ToMerge);
458 // Sew two sides of a mesh. Nodes belonging to theSide1 are
459 // merged with nodes of elements of theSide2.
460 // Number of elements in theSide1 and in theSide2 must be
461 // equal and they should have similar node connectivity.
462 // The nodes to merge should belong to side s borders and
463 // the first node should be linked to the second.
465 void InsertNodesIntoLink(const SMDS_MeshElement* theFace,
466 const SMDS_MeshNode* theBetweenNode1,
467 const SMDS_MeshNode* theBetweenNode2,
468 std::list<const SMDS_MeshNode*>& theNodesToInsert,
469 const bool toCreatePoly = false);
470 // insert theNodesToInsert into theFace between theBetweenNode1 and theBetweenNode2.
471 // If toCreatePoly is true, replace theFace by polygon, else split theFace.
473 void UpdateVolumes (const SMDS_MeshNode* theBetweenNode1,
474 const SMDS_MeshNode* theBetweenNode2,
475 std::list<const SMDS_MeshNode*>& theNodesToInsert);
476 // insert theNodesToInsert into all volumes, containing link
477 // theBetweenNode1 - theBetweenNode2, between theBetweenNode1 and theBetweenNode2.
479 void ConvertToQuadratic(const bool theForce3d);
480 void ConvertToQuadratic(const bool theForce3d, TIDSortedElemSet& theElements);
481 // Converts all mesh to quadratic one, deletes old elements, replacing
482 // them with quadratic ones with the same id.
483 // If theForce3d = 1; this results in the medium node lying at the
484 // middle of the line segments connecting start and end node of a mesh
486 // If theForce3d = 0; this results in the medium node lying at the
487 // geometrical edge from which the mesh element is built
489 bool ConvertFromQuadratic();
490 void ConvertFromQuadratic(TIDSortedElemSet& theElements);
491 // Converts all mesh from quadratic to ordinary ones, deletes old quadratic elements, replacing
492 // them with ordinary mesh elements with the same id.
493 // Returns true in case of success, false otherwise.
495 static void AddToSameGroups (const SMDS_MeshElement* elemToAdd,
496 const SMDS_MeshElement* elemInGroups,
497 SMESHDS_Mesh * aMesh);
498 // Add elemToAdd to the all groups the elemInGroups belongs to
500 static void RemoveElemFromGroups (const SMDS_MeshElement* element,
501 SMESHDS_Mesh * aMesh);
502 // remove element from the all groups
504 static void ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
505 const SMDS_MeshElement* elemToAdd,
506 SMESHDS_Mesh * aMesh);
507 // replace elemToRm by elemToAdd in the all groups
509 static void ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
510 const std::vector<const SMDS_MeshElement*>& elemToAdd,
511 SMESHDS_Mesh * aMesh);
512 // replace elemToRm by elemToAdd in the all groups
515 * \brief Return nodes linked to the given one in elements of the type
517 static void GetLinkedNodes( const SMDS_MeshNode* node,
518 TIDSortedElemSet & linkedNodes,
519 SMDSAbs_ElementType type = SMDSAbs_All );
521 static const SMDS_MeshElement* FindFaceInSet(const SMDS_MeshNode* n1,
522 const SMDS_MeshNode* n2,
523 const TIDSortedElemSet& elemSet,
524 const TIDSortedElemSet& avoidSet,
527 // Return a face having linked nodes n1 and n2 and which is
528 // - not in avoidSet,
529 // - in elemSet provided that !elemSet.empty()
530 // i1 and i2 optionally returns indices of n1 and n2
533 * \brief Find corresponding nodes in two sets of faces
534 * \param theSide1 - first face set
535 * \param theSide2 - second first face
536 * \param theFirstNode1 - a boundary node of set 1
537 * \param theFirstNode2 - a node of set 2 corresponding to theFirstNode1
538 * \param theSecondNode1 - a boundary node of set 1 linked with theFirstNode1
539 * \param theSecondNode2 - a node of set 2 corresponding to theSecondNode1
540 * \param nReplaceMap - output map of corresponding nodes
541 * \return Sew_Error - is a success or not
543 static Sew_Error FindMatchingNodes(std::set<const SMDS_MeshElement*>& theSide1,
544 std::set<const SMDS_MeshElement*>& theSide2,
545 const SMDS_MeshNode* theFirstNode1,
546 const SMDS_MeshNode* theFirstNode2,
547 const SMDS_MeshNode* theSecondNode1,
548 const SMDS_MeshNode* theSecondNode2,
549 TNodeNodeMap & theNodeReplaceMap);
552 * \brief Returns true if given node is medium
553 * \param n - node to check
554 * \param typeToCheck - type of elements containing the node to ask about node status
555 * \return bool - check result
557 static bool IsMedium(const SMDS_MeshNode* node,
558 const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
560 int FindShape (const SMDS_MeshElement * theElem);
561 // Return an index of the shape theElem is on
562 // or zero if a shape not found
564 SMESH_Mesh * GetMesh() { return myMesh; }
566 SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); }
568 const SMESH_SequenceOfElemPtr& GetLastCreatedNodes() const { return myLastCreatedNodes; }
570 const SMESH_SequenceOfElemPtr& GetLastCreatedElems() const { return myLastCreatedElems; }
572 bool DoubleNodes( const std::list< int >& theListOfNodes,
573 const std::list< int >& theListOfModifiedElems );
575 bool DoubleNodes( const TIDSortedElemSet& theElems,
576 const TIDSortedElemSet& theNodesNot,
577 const TIDSortedElemSet& theAffectedElems );
579 bool AffectedElemGroupsInRegion( const TIDSortedElemSet& theElems,
580 const TIDSortedElemSet& theNodesNot,
581 const TopoDS_Shape& theShape,
582 TIDSortedElemSet& theAffectedElems);
584 bool DoubleNodesInRegion( const TIDSortedElemSet& theElems,
585 const TIDSortedElemSet& theNodesNot,
586 const TopoDS_Shape& theShape );
588 double OrientedAngle(const gp_Pnt& p0, const gp_Pnt& p1, const gp_Pnt& g1, const gp_Pnt& g2);
590 bool DoubleNodesOnGroupBoundaries( const std::vector<TIDSortedElemSet>& theElems,
591 bool createJointElems);
593 bool CreateFlatElementsOnFacesGroups( const std::vector<TIDSortedElemSet>& theElems );
595 void CreateHoleSkin(double radius,
596 const TopoDS_Shape& theShape,
597 SMESH_NodeSearcher* theNodeSearcher,
598 const char* groupName,
599 std::vector<double>& nodesCoords,
600 std::vector<std::vector<int> >& listOfListOfNodes);
603 * \brief Generated skin mesh (containing 2D cells) from 3D mesh
604 * The created 2D mesh elements based on nodes of free faces of boundary volumes
605 * \return TRUE if operation has been completed successfully, FALSE otherwise
607 bool Make2DMeshFrom3D();
609 enum Bnd_Dimension { BND_2DFROM3D, BND_1DFROM3D, BND_1DFROM2D };
611 int MakeBoundaryMesh(const TIDSortedElemSet& elements,
612 Bnd_Dimension dimension,
613 SMESH_Group* group = 0,
614 SMESH_Mesh* targetMesh = 0,
615 bool toCopyElements = false,
616 bool toCopyExistingBondary = false,
617 bool toAddExistingBondary = false,
618 bool aroundElements = false);
624 * \brief Convert elements contained in a submesh to quadratic
625 * \return int - nb of checked elements
627 int convertElemToQuadratic(SMESHDS_SubMesh * theSm,
628 SMESH_MesherHelper& theHelper,
629 const bool theForce3d);
632 * \brief Convert quadratic elements to linear ones and remove quadratic nodes
633 * \return nb of checked elements
635 int removeQuadElem( SMESHDS_SubMesh * theSm,
636 SMDS_ElemIteratorPtr theItr,
637 const int theShapeID);
639 * \brief Create groups of elements made during transformation
640 * \param nodeGens - nodes making corresponding myLastCreatedNodes
641 * \param elemGens - elements making corresponding myLastCreatedElems
642 * \param postfix - to append to names of new groups
644 PGroupIDs generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
645 const SMESH_SequenceOfElemPtr& elemGens,
646 const std::string& postfix,
647 SMESH_Mesh* targetMesh=0);
650 typedef std::map<const SMDS_MeshNode*, std::list<const SMDS_MeshNode*> > TNodeOfNodeListMap;
651 typedef TNodeOfNodeListMap::iterator TNodeOfNodeListMapItr;
652 typedef std::vector<TNodeOfNodeListMapItr> TVecOfNnlmiMap;
653 typedef std::map<const SMDS_MeshElement*, TVecOfNnlmiMap > TElemOfVecOfNnlmiMap;
656 * \brief Create elements by sweeping an element
657 * \param elem - element to sweep
658 * \param newNodesItVec - nodes generated from each node of the element
659 * \param newElems - generated elements
660 * \param nbSteps - number of sweeping steps
661 * \param srcElements - to append elem for each generated element
663 void sweepElement(const SMDS_MeshElement* elem,
664 const std::vector<TNodeOfNodeListMapItr> & newNodesItVec,
665 std::list<const SMDS_MeshElement*>& newElems,
667 SMESH_SequenceOfElemPtr& srcElements);
670 * \brief Create 1D and 2D elements around swept elements
671 * \param mapNewNodes - source nodes and ones generated from them
672 * \param newElemsMap - source elements and ones generated from them
673 * \param elemNewNodesMap - nodes generated from each node of each element
674 * \param elemSet - all swept elements
675 * \param nbSteps - number of sweeping steps
676 * \param srcElements - to append elem for each generated element
678 void makeWalls (TNodeOfNodeListMap & mapNewNodes,
679 TElemOfElemListMap & newElemsMap,
680 TElemOfVecOfNnlmiMap & elemNewNodesMap,
681 TIDSortedElemSet& elemSet,
683 SMESH_SequenceOfElemPtr& srcElements);
685 struct SMESH_MeshEditor_PathPoint
689 double myAngle, myPrm;
691 SMESH_MeshEditor_PathPoint(): myPnt(99., 99., 99.), myTgt(1.,0.,0.), myAngle(0), myPrm(0) {}
692 void SetPnt (const gp_Pnt& aP3D) { myPnt =aP3D; }
693 void SetTangent (const gp_Dir& aTgt) { myTgt =aTgt; }
694 void SetAngle (const double& aBeta) { myAngle=aBeta; }
695 void SetParameter(const double& aPrm) { myPrm =aPrm; }
696 const gp_Pnt& Pnt ()const { return myPnt; }
697 const gp_Dir& Tangent ()const { return myTgt; }
698 double Angle ()const { return myAngle; }
699 double Parameter ()const { return myPrm; }
701 Extrusion_Error MakeEdgePathPoints(std::list<double>& aPrms,
702 const TopoDS_Edge& aTrackEdge,
704 std::list<SMESH_MeshEditor_PathPoint>& aLPP);
705 Extrusion_Error MakeExtrElements(TIDSortedElemSet& theElements,
706 std::list<SMESH_MeshEditor_PathPoint>& theFullList,
707 const bool theHasAngles,
708 std::list<double>& theAngles,
709 const bool theLinearVariation,
710 const bool theHasRefPoint,
711 const gp_Pnt& theRefPoint,
712 const bool theMakeGroups);
713 void LinearAngleVariation(const int NbSteps,
714 list<double>& theAngles);
716 bool doubleNodes( SMESHDS_Mesh* theMeshDS,
717 const TIDSortedElemSet& theElems,
718 const TIDSortedElemSet& theNodesNot,
719 std::map< const SMDS_MeshNode*, const SMDS_MeshNode* >& theNodeNodeMap,
720 const bool theIsDoubleElem );
727 * Sequence for keeping nodes created during last operation
729 SMESH_SequenceOfElemPtr myLastCreatedNodes;
732 * Sequence for keeping elements created during last operation
734 SMESH_SequenceOfElemPtr myLastCreatedElems;