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"
37 #include "SMESH_ComputeError.hxx"
39 #include <utilities.h>
41 #include <TColStd_HSequenceOfReal.hxx>
53 class SMESH_MesherHelper;
56 //=======================================================================
58 * \brief Searcher for the node closest to point
60 //=======================================================================
61 struct SMESH_NodeSearcher
63 virtual const SMDS_MeshNode* FindClosestTo( const gp_Pnt& pnt ) = 0;
64 virtual void MoveNode( const SMDS_MeshNode* node, const gp_Pnt& toPnt ) = 0;
67 //=======================================================================
69 * \brief Searcher for elements
71 //=======================================================================
73 struct SMESH_ElementSearcher
76 * \brief Find elements of given type where the given point is IN or ON.
77 * Returns nb of found elements and elements them-selves.
79 * 'ALL' type means elements of any type excluding nodes and 0D elements
81 virtual int FindElementsByPoint(const gp_Pnt& point,
82 SMDSAbs_ElementType type,
83 std::vector< const SMDS_MeshElement* >& foundElems)=0;
85 * \brief Return an element most close to the given point
87 virtual const SMDS_MeshElement* FindClosestTo( const gp_Pnt& point,
88 SMDSAbs_ElementType type) = 0;
90 * \brief Return elements possibly intersecting the line
92 virtual void GetElementsNearLine( const gp_Ax1& line,
93 SMDSAbs_ElementType type,
94 std::vector< const SMDS_MeshElement* >& foundElems)=0;
96 * \brief Find out if the given point is out of closed 2D mesh.
98 virtual TopAbs_State GetPointState(const gp_Pnt& point) = 0;
102 // ============================================================
104 * \brief Editor of a mesh
106 // ============================================================
108 class SMESH_EXPORT SMESH_MeshEditor
112 SMESH_MeshEditor( SMESH_Mesh* theMesh );
114 SMESH_Mesh * GetMesh() { return myMesh; }
115 SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); }
117 const SMESH_SequenceOfElemPtr& GetLastCreatedNodes() const { return myLastCreatedNodes; }
118 const SMESH_SequenceOfElemPtr& GetLastCreatedElems() const { return myLastCreatedElems; }
120 SMESH_ComputeErrorPtr & GetError() { return myError; }
125 SMDS_MeshElement* AddElement(const std::vector<const SMDS_MeshNode*> & nodes,
126 const SMDSAbs_ElementType type,
129 const double ballDiameter=0.);
133 SMDS_MeshElement* AddElement(const std::vector<int> & nodeIDs,
134 const SMDSAbs_ElementType type,
138 int Remove (const std::list< int >& theElemIDs, const bool isNodes);
139 // Remove a node or an element.
140 // Modify a compute state of sub-meshes which become empty
142 bool InverseDiag (const SMDS_MeshElement * theTria1,
143 const SMDS_MeshElement * theTria2 );
144 // Replace two neighbour triangles with ones built on the same 4 nodes
145 // but having other common link.
146 // Return False if args are improper
148 bool InverseDiag (const SMDS_MeshNode * theNode1,
149 const SMDS_MeshNode * theNode2 );
150 // Replace two neighbour triangles sharing theNode1-theNode2 link
151 // with ones built on the same 4 nodes but having other common link.
152 // Return false if proper faces not found
154 bool DeleteDiag (const SMDS_MeshNode * theNode1,
155 const SMDS_MeshNode * theNode2 );
156 // Replace two neighbour triangles sharing theNode1-theNode2 link
157 // with a quadrangle built on the same 4 nodes.
158 // Return false if proper faces not found
160 bool Reorient (const SMDS_MeshElement * theElement);
161 // Reverse theElement orientation
163 int Reorient2D (TIDSortedElemSet & theFaces,
164 const gp_Dir& theDirection,
165 const SMDS_MeshElement * theFace);
166 // Reverse theFaces whose orientation to be same as that of theFace
167 // oriented according to theDirection. Return nb of reoriented faces
170 * \brief Fuse neighbour triangles into quadrangles.
171 * \param theElems - The triangles to be fused.
172 * \param theCriterion - Is used to choose a neighbour to fuse with.
173 * \param theMaxAngle - Is a max angle between element normals at which fusion
174 * is still performed; theMaxAngle is mesured in radians.
175 * \return bool - Success or not.
177 bool TriToQuad (TIDSortedElemSet & theElems,
178 SMESH::Controls::NumericalFunctorPtr theCriterion,
179 const double theMaxAngle);
182 * \brief Split quadrangles into triangles.
183 * \param theElems - The faces to be splitted.
184 * \param theCriterion - Is used to choose a diagonal for splitting.
185 * \return bool - Success or not.
187 bool QuadToTri (TIDSortedElemSet & theElems,
188 SMESH::Controls::NumericalFunctorPtr theCriterion);
191 * \brief Split quadrangles into triangles.
192 * \param theElems - The faces to be splitted.
193 * \param the13Diag - Is used to choose a diagonal for splitting.
194 * \return bool - Success or not.
196 bool QuadToTri (TIDSortedElemSet & theElems,
197 const bool the13Diag);
200 * \brief Find better diagonal for splitting.
201 * \param theQuad - The face to find better splitting of.
202 * \param theCriterion - Is used to choose a diagonal for splitting.
203 * \return int - 1 for 1-3 diagonal, 2 for 2-4, -1 - for errors.
205 int BestSplit (const SMDS_MeshElement* theQuad,
206 SMESH::Controls::NumericalFunctorPtr theCriterion);
209 enum SplitVolumToTetraFlags { HEXA_TO_5 = 1, HEXA_TO_6 = 2, HEXA_TO_24 = 3 };//!<arg of SplitVolumesIntoTetra()
211 * \brief Split volumic elements into tetrahedra.
213 void SplitVolumesIntoTetra (const TIDSortedElemSet & theElems, const int theMethodFlags);
216 enum SmoothMethod { LAPLACIAN = 0, CENTROIDAL };
218 void Smooth (TIDSortedElemSet & theElements,
219 std::set<const SMDS_MeshNode*> & theFixedNodes,
220 const SmoothMethod theSmoothMethod,
221 const int theNbIterations,
222 double theTgtAspectRatio = 1.0,
223 const bool the2D = true);
224 // Smooth theElements using theSmoothMethod during theNbIterations
225 // or until a worst element has aspect ratio <= theTgtAspectRatio.
226 // Aspect Ratio varies in range [1.0, inf].
227 // If theElements is empty, the whole mesh is smoothed.
228 // theFixedNodes contains additionally fixed nodes. Nodes built
229 // on edges and boundary nodes are always fixed.
230 // If the2D, smoothing is performed using UV parameters of nodes
231 // on geometrical faces
233 typedef std::auto_ptr< std::list<int> > PGroupIDs;
235 PGroupIDs RotationSweep (TIDSortedElemSet & theElements,
236 const gp_Ax1& theAxis,
237 const double theAngle,
238 const int theNbSteps,
239 const double theToler,
240 const bool theMakeGroups,
241 const bool theMakeWalls=true);
242 // Generate new elements by rotation of theElements around theAxis
243 // by theAngle by theNbSteps
246 * Auxilary flag for advanced extrusion.
247 * BOUNDARY: create or not boundary for result of extrusion
248 * SEW: try to use existing nodes or create new nodes in any case
250 enum ExtrusionFlags {
251 EXTRUSION_FLAG_BOUNDARY = 0x01,
252 EXTRUSION_FLAG_SEW = 0x02
256 * special structure for control of extrusion functionality
259 gp_Dir myDir; // direction of extrusion
260 Handle(TColStd_HSequenceOfReal) mySteps; // magnitudes for each step
261 SMESH_SequenceOfNode myNodes; // nodes for using in sewing
265 * Create new node in the mesh with given coordinates
266 * (auxiliary for advanced extrusion)
268 const SMDS_MeshNode* CreateNode(const double x,
271 const double tolnode,
272 SMESH_SequenceOfNode& aNodes);
275 * Generate new elements by extrusion of theElements
276 * It is a method used in .idl file. All functionality
277 * is implemented in the next method (see below) which
278 * is used in the current method.
279 * @param theElems - list of elements for extrusion
280 * @param newElemsMap returns history of extrusion
281 * @param theFlags set flags for performing extrusion (see description
282 * of enum ExtrusionFlags for additional information)
283 * @param theTolerance - uses for comparing locations of nodes if flag
284 * EXTRUSION_FLAG_SEW is set
286 PGroupIDs ExtrusionSweep (TIDSortedElemSet & theElems,
287 const gp_Vec& theStep,
288 const int theNbSteps,
289 TElemOfElemListMap& newElemsMap,
290 const bool theMakeGroups,
291 const int theFlags = EXTRUSION_FLAG_BOUNDARY,
292 const double theTolerance = 1.e-6);
295 * Generate new elements by extrusion of theElements
296 * @param theElems - list of elements for extrusion
297 * @param newElemsMap returns history of extrusion
298 * @param theFlags set flags for performing extrusion (see description
299 * of enum ExtrusionFlags for additional information)
300 * @param theTolerance - uses for comparing locations of nodes if flag
301 * EXTRUSION_FLAG_SEW is set
302 * @param theParams - special structure for manage of extrusion
304 PGroupIDs ExtrusionSweep (TIDSortedElemSet & theElems,
305 ExtrusParam& theParams,
306 TElemOfElemListMap& newElemsMap,
307 const bool theMakeGroups,
309 const double theTolerance);
312 // Generate new elements by extrusion of theElements
313 // by theStep by theNbSteps
315 enum Extrusion_Error {
320 EXTR_BAD_STARTING_NODE,
321 EXTR_BAD_ANGLES_NUMBER,
322 EXTR_CANT_GET_TANGENT
325 Extrusion_Error ExtrusionAlongTrack (TIDSortedElemSet & theElements,
326 SMESH_subMesh* 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 Extrusion_Error ExtrusionAlongTrack (TIDSortedElemSet & theElements,
335 SMESH_Mesh* theTrackPattern,
336 const SMDS_MeshNode* theNodeStart,
337 const bool theHasAngles,
338 std::list<double>& theAngles,
339 const bool theLinearVariation,
340 const bool theHasRefPoint,
341 const gp_Pnt& theRefPoint,
342 const bool theMakeGroups);
343 // Generate new elements by extrusion of theElements along path given by theTrackPattern,
344 // theHasAngles are the rotation angles, base point can be given by theRefPoint
346 PGroupIDs Transform (TIDSortedElemSet & theElements,
347 const gp_Trsf& theTrsf,
349 const bool theMakeGroups,
350 SMESH_Mesh* theTargetMesh=0);
351 // Move or copy theElements applying theTrsf to their nodes
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 typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes;
366 void FindCoincidentNodes (TIDSortedNodeSet & theNodes,
367 const double theTolerance,
368 TListOfListOfNodes & theGroupsOfNodes);
369 // Return list of group of nodes close to each other within theTolerance.
370 // Search among theNodes or in the whole mesh if theNodes is empty.
372 void MergeNodes (TListOfListOfNodes & theNodeGroups);
373 // In each group, the cdr of nodes are substituted by the first one
376 typedef std::list< std::list< int > > TListOfListOfElementsID;
378 void FindEqualElements(TIDSortedElemSet & theElements,
379 TListOfListOfElementsID & theGroupsOfElementsID);
380 // Return list of group of elements build on the same nodes.
381 // Search among theElements or in the whole mesh if theElements is empty.
383 void MergeElements(TListOfListOfElementsID & theGroupsOfElementsID);
384 // In each group remove all but first of elements.
386 void MergeEqualElements();
387 // Remove all but one of elements built on the same nodes.
388 // Return nb of successfully merged groups.
391 * \brief Return true if the point is IN or ON of the element
393 static bool IsOut( const SMDS_MeshElement* element, const gp_Pnt& point, double tol );
395 static double GetDistance( const SMDS_MeshFace* face, const gp_Pnt& point );
397 int SimplifyFace (const std::vector<const SMDS_MeshNode *> faceNodes,
398 std::vector<const SMDS_MeshNode *>& poly_nodes,
399 std::vector<int>& quantities) const;
400 // Split face, defined by <faceNodes>, into several faces by repeating nodes.
401 // Is used by MergeNodes()
403 static bool CheckFreeBorderNodes(const SMDS_MeshNode* theNode1,
404 const SMDS_MeshNode* theNode2,
405 const SMDS_MeshNode* theNode3 = 0);
406 // Return true if the three nodes are on a free border
408 static bool FindFreeBorder (const SMDS_MeshNode* theFirstNode,
409 const SMDS_MeshNode* theSecondNode,
410 const SMDS_MeshNode* theLastNode,
411 std::list< const SMDS_MeshNode* > & theNodes,
412 std::list< const SMDS_MeshElement* >& theFaces);
413 // Return nodes and faces of a free border if found
417 // for SewFreeBorder()
418 SEW_BORDER1_NOT_FOUND,
419 SEW_BORDER2_NOT_FOUND,
420 SEW_BOTH_BORDERS_NOT_FOUND,
422 SEW_VOLUMES_TO_SPLIT,
423 // for SewSideElements()
424 SEW_DIFF_NB_OF_ELEMENTS,
425 SEW_TOPO_DIFF_SETS_OF_ELEMENTS,
432 Sew_Error SewFreeBorder (const SMDS_MeshNode* theBorderFirstNode,
433 const SMDS_MeshNode* theBorderSecondNode,
434 const SMDS_MeshNode* theBorderLastNode,
435 const SMDS_MeshNode* theSide2FirstNode,
436 const SMDS_MeshNode* theSide2SecondNode,
437 const SMDS_MeshNode* theSide2ThirdNode = 0,
438 const bool theSide2IsFreeBorder = true,
439 const bool toCreatePolygons = false,
440 const bool toCreatePolyedrs = false);
441 // Sew the free border to the side2 by replacing nodes in
442 // elements on the free border with nodes of the elements
443 // of the side 2. If nb of links in the free border and
444 // between theSide2FirstNode and theSide2LastNode are different,
445 // additional nodes are inserted on a link provided that no
446 // volume elements share the splitted link.
447 // The side 2 is a free border if theSide2IsFreeBorder == true.
448 // Sewing is peformed between the given first, second and last
449 // nodes on the sides.
450 // theBorderFirstNode is merged with theSide2FirstNode.
451 // if (!theSide2IsFreeBorder) then theSide2SecondNode gives
452 // the last node on the side 2, which will be merged with
453 // theBorderLastNode.
454 // if (theSide2IsFreeBorder) then theSide2SecondNode will
455 // be merged with theBorderSecondNode.
456 // if (theSide2IsFreeBorder && theSide2ThirdNode == 0) then
457 // the 2 free borders are sewn link by link and no additional
458 // nodes are inserted.
459 // Return false, if sewing failed.
461 Sew_Error SewSideElements (TIDSortedElemSet& theSide1,
462 TIDSortedElemSet& theSide2,
463 const SMDS_MeshNode* theFirstNode1ToMerge,
464 const SMDS_MeshNode* theFirstNode2ToMerge,
465 const SMDS_MeshNode* theSecondNode1ToMerge,
466 const SMDS_MeshNode* theSecondNode2ToMerge);
467 // Sew two sides of a mesh. Nodes belonging to theSide1 are
468 // merged with nodes of elements of theSide2.
469 // Number of elements in theSide1 and in theSide2 must be
470 // equal and they should have similar node connectivity.
471 // The nodes to merge should belong to side s borders and
472 // the first node should be linked to the second.
474 void InsertNodesIntoLink(const SMDS_MeshElement* theFace,
475 const SMDS_MeshNode* theBetweenNode1,
476 const SMDS_MeshNode* theBetweenNode2,
477 std::list<const SMDS_MeshNode*>& theNodesToInsert,
478 const bool toCreatePoly = false);
479 // insert theNodesToInsert into theFace between theBetweenNode1 and theBetweenNode2.
480 // If toCreatePoly is true, replace theFace by polygon, else split theFace.
482 void UpdateVolumes (const SMDS_MeshNode* theBetweenNode1,
483 const SMDS_MeshNode* theBetweenNode2,
484 std::list<const SMDS_MeshNode*>& theNodesToInsert);
485 // insert theNodesToInsert into all volumes, containing link
486 // theBetweenNode1 - theBetweenNode2, between theBetweenNode1 and theBetweenNode2.
488 void ConvertToQuadratic(const bool theForce3d);
489 void ConvertToQuadratic(const bool theForce3d, TIDSortedElemSet& theElements);
490 // Converts all mesh to quadratic one, deletes old elements, replacing
491 // them with quadratic ones with the same id.
492 // If theForce3d = 1; this results in the medium node lying at the
493 // middle of the line segments connecting start and end node of a mesh
495 // If theForce3d = 0; this results in the medium node lying at the
496 // geometrical edge from which the mesh element is built
498 bool ConvertFromQuadratic();
499 void ConvertFromQuadratic(TIDSortedElemSet& theElements);
500 // Converts all mesh from quadratic to ordinary ones, deletes old quadratic elements, replacing
501 // them with ordinary mesh elements with the same id.
502 // Returns true in case of success, false otherwise.
504 static void AddToSameGroups (const SMDS_MeshElement* elemToAdd,
505 const SMDS_MeshElement* elemInGroups,
506 SMESHDS_Mesh * aMesh);
507 // Add elemToAdd to the all groups the elemInGroups belongs to
509 static void RemoveElemFromGroups (const SMDS_MeshElement* element,
510 SMESHDS_Mesh * aMesh);
511 // remove element from the all groups
513 static void ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
514 const SMDS_MeshElement* elemToAdd,
515 SMESHDS_Mesh * aMesh);
516 // replace elemToRm by elemToAdd in the all groups
518 static void ReplaceElemInGroups (const SMDS_MeshElement* elemToRm,
519 const std::vector<const SMDS_MeshElement*>& elemToAdd,
520 SMESHDS_Mesh * aMesh);
521 // replace elemToRm by elemToAdd in the all groups
524 * \brief Return nodes linked to the given one in elements of the type
526 static void GetLinkedNodes( const SMDS_MeshNode* node,
527 TIDSortedElemSet & linkedNodes,
528 SMDSAbs_ElementType type = SMDSAbs_All );
530 static const SMDS_MeshElement* FindFaceInSet(const SMDS_MeshNode* n1,
531 const SMDS_MeshNode* n2,
532 const TIDSortedElemSet& elemSet,
533 const TIDSortedElemSet& avoidSet,
536 // Return a face having linked nodes n1 and n2 and which is
537 // - not in avoidSet,
538 // - in elemSet provided that !elemSet.empty()
539 // i1 and i2 optionally returns indices of n1 and n2
542 * \brief Find corresponding nodes in two sets of faces
543 * \param theSide1 - first face set
544 * \param theSide2 - second first face
545 * \param theFirstNode1 - a boundary node of set 1
546 * \param theFirstNode2 - a node of set 2 corresponding to theFirstNode1
547 * \param theSecondNode1 - a boundary node of set 1 linked with theFirstNode1
548 * \param theSecondNode2 - a node of set 2 corresponding to theSecondNode1
549 * \param nReplaceMap - output map of corresponding nodes
550 * \return Sew_Error - is a success or not
552 static Sew_Error FindMatchingNodes(std::set<const SMDS_MeshElement*>& theSide1,
553 std::set<const SMDS_MeshElement*>& theSide2,
554 const SMDS_MeshNode* theFirstNode1,
555 const SMDS_MeshNode* theFirstNode2,
556 const SMDS_MeshNode* theSecondNode1,
557 const SMDS_MeshNode* theSecondNode2,
558 TNodeNodeMap & theNodeReplaceMap);
561 * \brief Returns true if given node is medium
562 * \param n - node to check
563 * \param typeToCheck - type of elements containing the node to ask about node status
564 * \return bool - check result
566 static bool IsMedium(const SMDS_MeshNode* node,
567 const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
569 int FindShape (const SMDS_MeshElement * theElem);
570 // Return an index of the shape theElem is on
571 // or zero if a shape not found
573 bool DoubleNodes( const std::list< int >& theListOfNodes,
574 const std::list< int >& theListOfModifiedElems );
576 bool DoubleNodes( const TIDSortedElemSet& theElems,
577 const TIDSortedElemSet& theNodesNot,
578 const TIDSortedElemSet& theAffectedElems );
580 bool AffectedElemGroupsInRegion( const TIDSortedElemSet& theElems,
581 const TIDSortedElemSet& theNodesNot,
582 const TopoDS_Shape& theShape,
583 TIDSortedElemSet& theAffectedElems);
585 bool DoubleNodesInRegion( const TIDSortedElemSet& theElems,
586 const TIDSortedElemSet& theNodesNot,
587 const TopoDS_Shape& theShape );
589 double OrientedAngle(const gp_Pnt& p0, const gp_Pnt& p1, const gp_Pnt& g1, const gp_Pnt& g2);
591 bool DoubleNodesOnGroupBoundaries( const std::vector<TIDSortedElemSet>& theElems,
592 bool createJointElems);
594 bool CreateFlatElementsOnFacesGroups( const std::vector<TIDSortedElemSet>& theElems );
596 void CreateHoleSkin(double radius,
597 const TopoDS_Shape& theShape,
598 SMESH_NodeSearcher* theNodeSearcher,
599 const char* groupName,
600 std::vector<double>& nodesCoords,
601 std::vector<std::vector<int> >& listOfListOfNodes);
604 * \brief Generated skin mesh (containing 2D cells) from 3D mesh
605 * The created 2D mesh elements based on nodes of free faces of boundary volumes
606 * \return TRUE if operation has been completed successfully, FALSE otherwise
608 bool Make2DMeshFrom3D();
610 enum Bnd_Dimension { BND_2DFROM3D, BND_1DFROM3D, BND_1DFROM2D };
612 int MakeBoundaryMesh(const TIDSortedElemSet& elements,
613 Bnd_Dimension dimension,
614 SMESH_Group* group = 0,
615 SMESH_Mesh* targetMesh = 0,
616 bool toCopyElements = false,
617 bool toCopyExistingBondary = false,
618 bool toAddExistingBondary = false,
619 bool aroundElements = false);
625 * \brief Convert elements contained in a submesh to quadratic
626 * \return int - nb of checked elements
628 int convertElemToQuadratic(SMESHDS_SubMesh * theSm,
629 SMESH_MesherHelper& theHelper,
630 const bool theForce3d);
633 * \brief Convert quadratic elements to linear ones and remove quadratic nodes
634 * \return nb of checked elements
636 int removeQuadElem( SMESHDS_SubMesh * theSm,
637 SMDS_ElemIteratorPtr theItr,
638 const int theShapeID);
640 * \brief Create groups of elements made during transformation
641 * \param nodeGens - nodes making corresponding myLastCreatedNodes
642 * \param elemGens - elements making corresponding myLastCreatedElems
643 * \param postfix - to append to names of new groups
645 PGroupIDs generateGroups(const SMESH_SequenceOfElemPtr& nodeGens,
646 const SMESH_SequenceOfElemPtr& elemGens,
647 const std::string& postfix,
648 SMESH_Mesh* targetMesh=0);
651 typedef std::map<const SMDS_MeshNode*, std::list<const SMDS_MeshNode*> > TNodeOfNodeListMap;
652 typedef TNodeOfNodeListMap::iterator TNodeOfNodeListMapItr;
653 typedef std::vector<TNodeOfNodeListMapItr> TVecOfNnlmiMap;
654 typedef std::map<const SMDS_MeshElement*, TVecOfNnlmiMap > TElemOfVecOfNnlmiMap;
657 * \brief Create elements by sweeping an element
658 * \param elem - element to sweep
659 * \param newNodesItVec - nodes generated from each node of the element
660 * \param newElems - generated elements
661 * \param nbSteps - number of sweeping steps
662 * \param srcElements - to append elem for each generated element
664 void sweepElement(const SMDS_MeshElement* elem,
665 const std::vector<TNodeOfNodeListMapItr> & newNodesItVec,
666 std::list<const SMDS_MeshElement*>& newElems,
668 SMESH_SequenceOfElemPtr& srcElements);
671 * \brief Create 1D and 2D elements around swept elements
672 * \param mapNewNodes - source nodes and ones generated from them
673 * \param newElemsMap - source elements and ones generated from them
674 * \param elemNewNodesMap - nodes generated from each node of each element
675 * \param elemSet - all swept elements
676 * \param nbSteps - number of sweeping steps
677 * \param srcElements - to append elem for each generated element
679 void makeWalls (TNodeOfNodeListMap & mapNewNodes,
680 TElemOfElemListMap & newElemsMap,
681 TElemOfVecOfNnlmiMap & elemNewNodesMap,
682 TIDSortedElemSet& elemSet,
684 SMESH_SequenceOfElemPtr& srcElements);
686 struct SMESH_MeshEditor_PathPoint
690 double myAngle, myPrm;
692 SMESH_MeshEditor_PathPoint(): myPnt(99., 99., 99.), myTgt(1.,0.,0.), myAngle(0), myPrm(0) {}
693 void SetPnt (const gp_Pnt& aP3D) { myPnt =aP3D; }
694 void SetTangent (const gp_Dir& aTgt) { myTgt =aTgt; }
695 void SetAngle (const double& aBeta) { myAngle=aBeta; }
696 void SetParameter(const double& aPrm) { myPrm =aPrm; }
697 const gp_Pnt& Pnt ()const { return myPnt; }
698 const gp_Dir& Tangent ()const { return myTgt; }
699 double Angle ()const { return myAngle; }
700 double Parameter ()const { return myPrm; }
702 Extrusion_Error MakeEdgePathPoints(std::list<double>& aPrms,
703 const TopoDS_Edge& aTrackEdge,
705 std::list<SMESH_MeshEditor_PathPoint>& aLPP);
706 Extrusion_Error MakeExtrElements(TIDSortedElemSet& theElements,
707 std::list<SMESH_MeshEditor_PathPoint>& theFullList,
708 const bool theHasAngles,
709 std::list<double>& theAngles,
710 const bool theLinearVariation,
711 const bool theHasRefPoint,
712 const gp_Pnt& theRefPoint,
713 const bool theMakeGroups);
714 void LinearAngleVariation(const int NbSteps,
715 list<double>& theAngles);
717 bool doubleNodes( SMESHDS_Mesh* theMeshDS,
718 const TIDSortedElemSet& theElems,
719 const TIDSortedElemSet& theNodesNot,
720 std::map< const SMDS_MeshNode*, const SMDS_MeshNode* >& theNodeNodeMap,
721 const bool theIsDoubleElem );
727 // Nodes and elements created during last operation
728 SMESH_SequenceOfElemPtr myLastCreatedNodes, myLastCreatedElems;
730 // Description of error/warning occured during last operation
731 SMESH_ComputeErrorPtr myError;