1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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_MesherHelper.hxx
24 // Created: 15.02.06 14:48:09
25 // Author: Sergey KUUL
27 #ifndef SMESH_MesherHelper_HeaderFile
28 #define SMESH_MesherHelper_HeaderFile
30 #include "SMESH_SMESH.hxx"
32 #include "SMESH_MeshEditor.hxx" // needed for many meshers
33 #include <SMDS_MeshNode.hxx>
34 #include <SMDS_QuadraticEdge.hxx>
36 #include <Geom_Surface.hxx>
37 #include <TopoDS_Face.hxx>
38 #include <TopoDS_Shape.hxx>
39 #include <gp_Pnt2d.hxx>
44 class GeomAPI_ProjectPointOnSurf;
45 class GeomAPI_ProjectPointOnCurve;
46 class SMESH_ProxyMesh;
48 typedef std::map<SMESH_TLink, const SMDS_MeshNode*> TLinkNodeMap;
49 typedef std::map<SMESH_TLink, const SMDS_MeshNode*>::iterator ItTLinkNode;
51 typedef SMDS_Iterator<const TopoDS_Shape*> PShapeIterator;
52 typedef boost::shared_ptr< PShapeIterator > PShapeIteratorPtr;
54 typedef std::vector<const SMDS_MeshNode* > TNodeColumn;
55 typedef std::map< double, TNodeColumn > TParam2ColumnMap;
57 typedef gp_XY (*xyFunPtr)(const gp_XY& uv1, const gp_XY& uv2);
59 //=======================================================================
61 * \brief It helps meshers to add elements and provides other utilities
63 * - It allows meshers not to care about creation of medium nodes
64 * when filling a quadratic mesh. Helper does it itself.
65 * It defines order of elements to create when IsQuadraticSubMesh()
67 * - It provides information on a shape it is initialized with:
68 * periodicity, presence of singularities etc.
71 //=======================================================================
73 class SMESH_EXPORT SMESH_MesherHelper
76 // ---------- PUBLIC UTILITIES ----------
79 * \brief Returns true if all elements of a sub-mesh are of same shape
80 * \param smDS - sub-mesh to check elements of
81 * \param shape - expected shape of elements
82 * \param nullSubMeshRes - result value for the case of smDS == NULL
83 * \retval bool - check result
85 static bool IsSameElemGeometry(const SMESHDS_SubMesh* smDS,
86 SMDSAbs_GeometryType shape,
87 const bool nullSubMeshRes = true);
90 * \brief Load nodes bound to face into a map of node columns
91 * \param theParam2ColumnMap - map of node columns to fill
92 * \param theFace - the face on which nodes are searched for
93 * \param theBaseSide - the edges holding nodes on which columns' bases
94 * \param theMesh - the mesh containing nodes
95 * \retval bool - false if something is wrong
97 * The key of the map is a normalized parameter of each
98 * base node on theBaseSide. Edges in theBaseSide must be sequenced.
99 * This method works in supposition that nodes on the face
100 * forms a structured grid and elements can be quardrangles or triangles
102 static bool LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap,
103 const TopoDS_Face& theFace,
104 const std::list<TopoDS_Edge>& theBaseSide,
105 SMESHDS_Mesh* theMesh,
106 SMESH_ProxyMesh* theProxyMesh=0);
108 * \brief Variant of LoadNodeColumns() above with theBaseSide given by one edge
110 static bool LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap,
111 const TopoDS_Face& theFace,
112 const TopoDS_Edge& theBaseEdge,
113 SMESHDS_Mesh* theMesh,
114 SMESH_ProxyMesh* theProxyMesh=0);
116 * \brief Return true if 2D mesh on FACE is structured
118 static bool IsStructured( SMESH_subMesh* faceSM );
121 * \brief Return true if 2D mesh on FACE is distored
123 static bool IsDistorted2D( SMESH_subMesh* faceSM, bool checkUV=false );
126 * \brief Returns true if given node is medium
127 * \param n - node to check
128 * \param typeToCheck - type of elements containing the node to ask about node status
129 * \retval bool - check result
131 static bool IsMedium(const SMDS_MeshNode* node,
132 const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
134 * \brief Return support shape of a node
135 * \param node - the node
136 * \param meshDS - mesh DS
137 * \retval TopoDS_Shape - found support shape
138 * \sa SMESH_Algo::VertexNode( const TopoDS_Vertex&, SMESHDS_Mesh* )
140 static TopoDS_Shape GetSubShapeByNode(const SMDS_MeshNode* node,
141 const SMESHDS_Mesh* meshDS);
144 * \brief Return a valid node index, fixing the given one if necessary
145 * \param ind - node index
146 * \param nbNodes - total nb of nodes
147 * \retval int - valid node index
149 static inline int WrapIndex(int ind, const int nbNodes) {
150 return (( ind %= nbNodes ) < 0 ) ? ind + nbNodes : ind;
154 * \brief Return UV of a point inside a quadrilateral FACE by it's
155 * normalized parameters within a unit quadrangle and the
156 * corresponding projections on sub-shapes of the real-world FACE.
157 * The used calculation method is called Trans-Finite Interpolation (TFI).
158 * \param x,y - normalized parameters that should be in range [0,1]
159 * \param a0,a1,a2,a3 - UV of VERTEXes of the FACE == projections on VERTEXes
160 * \param p0,p1,p2,p3 - UV of the point projections on EDGEs of the FACE
161 * \return gp_XY - UV of the point on the FACE
163 * Y ^ Order of those UV in the FACE is as follows.
171 * o---x-----o ----> X
174 inline static gp_XY calcTFI(double x, double y,
175 const gp_XY& a0,const gp_XY& a1,const gp_XY& a2,const gp_XY& a3,
176 const gp_XY& p0,const gp_XY& p1,const gp_XY& p2,const gp_XY& p3);
179 * \brief Same as "gp_XY calcTFI(...)" but in 3D
181 inline static gp_XYZ calcTFI(double x, double y,
182 const gp_XYZ& a0,const gp_XYZ& a1,const gp_XYZ& a2,const gp_XYZ& a3,
183 const gp_XYZ& p0,const gp_XYZ& p1,const gp_XYZ& p2,const gp_XYZ& p3);
185 * \brief Count nb of sub-shapes
186 * \param shape - the shape
187 * \param type - the type of sub-shapes to count
188 * \param ignoreSame - if true, use map not to count same shapes, esle use explorer
189 * \retval int - the calculated number
191 static int Count(const TopoDS_Shape& shape,
192 const TopAbs_ShapeEnum type,
193 const bool ignoreSame);
196 * \brief Return number of unique ancestors of the shape
198 static int NbAncestors(const TopoDS_Shape& shape,
199 const SMESH_Mesh& mesh,
200 TopAbs_ShapeEnum ancestorType=TopAbs_SHAPE);
202 * \brief Return iterator on ancestors of the given type
204 static PShapeIteratorPtr GetAncestors(const TopoDS_Shape& shape,
205 const SMESH_Mesh& mesh,
206 TopAbs_ShapeEnum ancestorType);
208 * \brief Find a common ancestor, of the given type, of two shapes
210 static TopoDS_Shape GetCommonAncestor(const TopoDS_Shape& shape1,
211 const TopoDS_Shape& shape2,
212 const SMESH_Mesh& mesh,
213 TopAbs_ShapeEnum ancestorType);
215 * \brief Return orientation of sub-shape in the main shape
217 static TopAbs_Orientation GetSubShapeOri(const TopoDS_Shape& shape,
218 const TopoDS_Shape& subShape);
220 static bool IsSubShape( const TopoDS_Shape& shape, const TopoDS_Shape& mainShape );
222 static bool IsSubShape( const TopoDS_Shape& shape, SMESH_Mesh* aMesh );
224 static bool IsBlock( const TopoDS_Shape& shape );
226 static double MaxTolerance( const TopoDS_Shape& shape );
228 static double GetAngle( const TopoDS_Edge & E1, const TopoDS_Edge & E2,
229 const TopoDS_Face & F, const TopoDS_Vertex & V,
230 gp_Vec* faceNormal=0);
232 static bool IsClosedEdge( const TopoDS_Edge& anEdge );
234 static TopoDS_Vertex IthVertex( const bool is2nd, TopoDS_Edge anEdge, const bool CumOri=true );
236 static TopAbs_ShapeEnum GetGroupType(const TopoDS_Shape& group,
237 const bool avoidCompound=false);
239 static TopoDS_Shape GetShapeOfHypothesis( const SMESHDS_Hypothesis * hyp,
240 const TopoDS_Shape& shape,
245 // ---------- PUBLIC INSTANCE METHODS ----------
248 SMESH_MesherHelper(SMESH_Mesh& theMesh);
250 SMESH_Gen* GetGen() const { return GetMesh()->GetGen(); }
252 SMESH_Mesh* GetMesh() const { return myMesh; }
254 SMESHDS_Mesh* GetMeshDS() const { return GetMesh()->GetMeshDS(); }
257 * Check submesh for given shape: if all elements on this shape are quadratic,
258 * quadratic elements will be created. Also fill myTLinkNodeMap
260 bool IsQuadraticSubMesh(const TopoDS_Shape& theShape);
262 * \brief Set order of elements to create without calling IsQuadraticSubMesh()
266 * \brief Set myCreateQuadratic flag
268 void SetIsQuadratic(const bool theBuildQuadratic)
269 { myCreateQuadratic = theBuildQuadratic; }
272 * \brief Set myCreateBiQuadratic flag
274 void SetIsBiQuadratic(const bool theBuildBiQuadratic)
275 { myCreateBiQuadratic = theBuildBiQuadratic; }
278 * \brief Return myCreateQuadratic flag
280 bool GetIsQuadratic() const { return myCreateQuadratic; }
283 * \brief Find out elements orientation on a geometrical face
285 bool IsReversedSubMesh (const TopoDS_Face& theFace);
288 * \brief Return myCreateBiQuadratic flag
290 bool GetIsBiQuadratic() const { return myCreateBiQuadratic; }
293 * \brief Move medium nodes of faces and volumes to fix distorted elements
294 * \param error - container of fixed distorted elements
295 * \param volumeOnly - fix nodes on geom faces or not if the shape is solid
297 void FixQuadraticElements(SMESH_ComputeErrorPtr& error, bool volumeOnly=true);
300 * \brief To set created elements on the shape set by IsQuadraticSubMesh()
301 * or the next methods. By defaul elements are set on the shape if
302 * a mesh has no shape to be meshed
304 bool SetElementsOnShape(bool toSet)
305 { bool res = mySetElemOnShape; mySetElemOnShape = toSet; return res; }
308 * \brief Set shape to make elements on without calling IsQuadraticSubMesh()
310 void SetSubShape(const int subShapeID);//!==SMESHDS_Mesh::ShapeToIndex(shape)
311 void SetSubShape(const TopoDS_Shape& subShape);
313 * \brief Return ID of the shape set by IsQuadraticSubMesh() or SetSubShape()
314 * \retval int - shape index in SMESHDS
316 int GetSubShapeID() const { return myShapeID; }
318 * \brief Return the shape set by IsQuadraticSubMesh() or SetSubShape()
320 const TopoDS_Shape& GetSubShape() const { return myShape; }
323 * Creates a node (!Note ID before u=0.,v0.)
325 SMDS_MeshNode* AddNode(double x, double y, double z, int ID = 0, double u=0., double v=0.);
327 * Creates quadratic or linear edge
329 SMDS_MeshEdge* AddEdge(const SMDS_MeshNode* n1,
330 const SMDS_MeshNode* n2,
332 const bool force3d = true);
334 * Creates quadratic or linear triangle
336 SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
337 const SMDS_MeshNode* n2,
338 const SMDS_MeshNode* n3,
340 const bool force3d = false);
342 * Creates bi-quadratic, quadratic or linear quadrangle
344 SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
345 const SMDS_MeshNode* n2,
346 const SMDS_MeshNode* n3,
347 const SMDS_MeshNode* n4,
349 const bool force3d = false);
351 * Creates polygon, with additional nodes in quadratic mesh
353 SMDS_MeshFace* AddPolygonalFace (const std::vector<const SMDS_MeshNode*>& nodes,
355 const bool force3d = false);
357 * Creates quadratic or linear tetrahedron
359 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
360 const SMDS_MeshNode* n2,
361 const SMDS_MeshNode* n3,
362 const SMDS_MeshNode* n4,
364 const bool force3d = true);
366 * Creates quadratic or linear pyramid
368 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
369 const SMDS_MeshNode* n2,
370 const SMDS_MeshNode* n3,
371 const SMDS_MeshNode* n4,
372 const SMDS_MeshNode* n5,
374 const bool force3d = true);
376 * Creates quadratic or linear pentahedron
378 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
379 const SMDS_MeshNode* n2,
380 const SMDS_MeshNode* n3,
381 const SMDS_MeshNode* n4,
382 const SMDS_MeshNode* n5,
383 const SMDS_MeshNode* n6,
385 const bool force3d = true);
387 * Creates bi-quadratic, quadratic or linear hexahedron
389 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
390 const SMDS_MeshNode* n2,
391 const SMDS_MeshNode* n3,
392 const SMDS_MeshNode* n4,
393 const SMDS_MeshNode* n5,
394 const SMDS_MeshNode* n6,
395 const SMDS_MeshNode* n7,
396 const SMDS_MeshNode* n8,
398 bool force3d = true);
401 * Creates LINEAR!!!!!!!!! octahedron
403 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
404 const SMDS_MeshNode* n2,
405 const SMDS_MeshNode* n3,
406 const SMDS_MeshNode* n4,
407 const SMDS_MeshNode* n5,
408 const SMDS_MeshNode* n6,
409 const SMDS_MeshNode* n7,
410 const SMDS_MeshNode* n8,
411 const SMDS_MeshNode* n9,
412 const SMDS_MeshNode* n10,
413 const SMDS_MeshNode* n11,
414 const SMDS_MeshNode* n12,
416 bool force3d = true);
419 * Creates polyhedron. In quadratic mesh, adds medium nodes
421 SMDS_MeshVolume* AddPolyhedralVolume (const std::vector<const SMDS_MeshNode*>& nodes,
422 const std::vector<int>& quantities,
424 const bool force3d = true);
426 * \brief Enables fixing node parameters on EDGEs and FACEs by
427 * GetNodeU(...,check=true), GetNodeUV(...,check=true), CheckNodeUV() and
428 * CheckNodeU() in case if a node lies on a shape set via SetSubShape().
431 void ToFixNodeParameters(bool toFix);
434 * \brief Return U of the given node on the edge
436 double GetNodeU(const TopoDS_Edge& theEdge,
437 const SMDS_MeshNode* theNode,
438 const SMDS_MeshNode* inEdgeNode=0,
439 bool* check=0) const;
441 * \brief Return node UV on face
442 * \param inFaceNode - a node of element being created located inside a face
443 * \param check - if provided, returns result of UV check that it enforces
445 gp_XY GetNodeUV(const TopoDS_Face& F,
446 const SMDS_MeshNode* n,
447 const SMDS_MeshNode* inFaceNode=0,
448 bool* check=0) const;
450 * \brief Check and fix node UV on a face
451 * \param force - check even if checks of other nodes on this face passed OK
452 * \param distXYZ - returns result distance and point coordinates
453 * \retval bool - false if UV is bad and could not be fixed
455 bool CheckNodeUV(const TopoDS_Face& F,
456 const SMDS_MeshNode* n,
459 const bool force=false,
460 double distXYZ[4]=0) const;
462 * \brief Check and fix node U on an edge
463 * \param force - check even if checks of other nodes on this edge passed OK
464 * \param distXYZ - returns result distance and point coordinates
465 * \retval bool - false if U is bad and could not be fixed
467 bool CheckNodeU(const TopoDS_Edge& E,
468 const SMDS_MeshNode* n,
471 const bool force=false,
472 double distXYZ[4]=0) const;
474 * \brief Return middle UV taking in account surface period
476 static gp_XY GetMiddleUV(const Handle(Geom_Surface)& surface,
480 * \brief Return UV for the central node of a biquadratic triangle
482 static gp_XY GetCenterUV(const gp_XY& uv1,
490 * \brief Define a pointer to wrapper over a function of gp_XY class,
491 * suitable to pass as xyFunPtr to ApplyIn2D().
492 * For exaple gp_XY_FunPtr(Added) defines pointer gp_XY_Added to function
493 * calling gp_XY::Added(gp_XY), which is to be used like following
494 * ApplyIn2D(surf, uv1, uv2, gp_XY_Added)
496 #define gp_XY_FunPtr(meth) \
497 static gp_XY __gpXY_##meth (const gp_XY& uv1, const gp_XY& uv2) { return uv1.meth( uv2 ); } \
498 static xyFunPtr gp_XY_##meth = & __gpXY_##meth
501 * \brief Perform given operation on two 2d points in parameric space of given surface.
502 * It takes into account period of the surface. Use gp_XY_FunPtr macro
503 * to easily define pointer to function of gp_XY class.
505 static gp_XY ApplyIn2D(Handle(Geom_Surface) surface,
509 const bool resultInPeriod=true);
512 * \brief Move node positions on a FACE within surface period
513 * \param [in] face - the FACE
514 * \param [inout] uv - node positions to adjust
515 * \param [in] nbUV - nb of \a uv
517 void AdjustByPeriod( const TopoDS_Face& face, gp_XY uv[], const int nbUV );
520 * \brief Check if inFaceNode argument is necessary for call GetNodeUV(F,..)
521 * \retval bool - return true if the face is periodic
523 * If F is Null, answer about subshape set through IsQuadraticSubMesh() or
526 bool GetNodeUVneedInFaceNode(const TopoDS_Face& F = TopoDS_Face()) const;
529 * \brief Return projector intitialized by given face without location, which is returned
531 GeomAPI_ProjectPointOnSurf& GetProjector(const TopoDS_Face& F,
532 TopLoc_Location& loc,
533 double tol=0 ) const;
536 * \brief Check if shape is a degenerated edge or it's vertex
537 * \param subShape - edge or vertex index in SMESHDS
538 * \retval bool - true if subShape is a degenerated shape
540 * It works only if IsQuadraticSubMesh() or SetSubShape() has been called
542 bool IsDegenShape(const int subShape) const
543 { return myDegenShapeIds.find( subShape ) != myDegenShapeIds.end(); }
545 * \brief Check if the shape set through IsQuadraticSubMesh() or SetSubShape()
546 * has a degenerated edges
547 * \retval bool - true if it has
549 bool HasDegeneratedEdges() const { return !myDegenShapeIds.empty(); }
552 * \brief Check if shape is a seam edge or it's vertex
553 * \param subShape - edge or vertex index in SMESHDS
554 * \retval bool - true if subShape is a seam shape
556 * It works only if IsQuadraticSubMesh() or SetSubShape() has been called.
557 * Seam shape has two 2D alternative represenations on the face
559 bool IsSeamShape(const int subShape) const
560 { return mySeamShapeIds.find( subShape ) != mySeamShapeIds.end(); }
562 * \brief Check if shape is a seam edge or it's vertex
563 * \param subShape - edge or vertex
564 * \retval bool - true if subShape is a seam shape
566 * It works only if IsQuadraticSubMesh() or SetSubShape() has been called.
567 * Seam shape has two 2D alternative represenations on the face
569 bool IsSeamShape(const TopoDS_Shape& subShape) const
570 { return IsSeamShape( GetMeshDS()->ShapeToIndex( subShape )); }
572 * \brief Return true if an edge or a vertex encounters twice in face wire
573 * \param subShape - Id of edge or vertex
575 bool IsRealSeam(const int subShape) const
576 { return mySeamShapeIds.find( -subShape ) != mySeamShapeIds.end(); }
578 * \brief Return true if an edge or a vertex encounters twice in face wire
579 * \param subShape - edge or vertex
581 bool IsRealSeam(const TopoDS_Shape& subShape) const
582 { return IsRealSeam( GetMeshDS()->ShapeToIndex( subShape)); }
584 * \brief Check if the shape set through IsQuadraticSubMesh() or SetSubShape()
585 * has a seam edge, i.e. an edge that has two parametric representations
587 * \retval bool - true if it has
589 bool HasSeam() const { return !mySeamShapeIds.empty(); }
591 * \brief Check if the shape set through IsQuadraticSubMesh() or SetSubShape()
592 * has a seam edge that encounters twice in a wire
593 * \retval bool - true if it has
595 bool HasRealSeam() const { return HasSeam() && ( *mySeamShapeIds.begin() < 0 ); }
597 * \brief Return index of periodic parametric direction of a closed face
598 * \retval int - 1 for U, 2 for V direction
600 int GetPeriodicIndex() const { return myParIndex; }
602 * \brief Return an alternative parameter for a node on seam
604 double GetOtherParam(const double param) const;
607 * \brief Return existing or create new medium nodes between given ones
608 * \param force3d - true means node creation at the middle between the
609 * two given nodes, else node position is found on its
610 * supporting geometrical shape, if any.
611 * \param expectedSupport - shape type corresponding to element being created
612 * , e.g TopAbs_EDGE if SMDSAbs_Edge is created
613 * basing on \a n1 and \a n2
615 const SMDS_MeshNode* GetMediumNode(const SMDS_MeshNode* n1,
616 const SMDS_MeshNode* n2,
618 TopAbs_ShapeEnum expectedSupport=TopAbs_SHAPE);
620 * \brief Return existing or create a new central node for a quardilateral
621 * quadratic face given its 8 nodes.
622 * \param force3d - true means node creation in between the given nodes,
623 * else node position is found on a geometrical face if any.
625 const SMDS_MeshNode* GetCentralNode(const SMDS_MeshNode* n1,
626 const SMDS_MeshNode* n2,
627 const SMDS_MeshNode* n3,
628 const SMDS_MeshNode* n4,
629 const SMDS_MeshNode* n12,
630 const SMDS_MeshNode* n23,
631 const SMDS_MeshNode* n34,
632 const SMDS_MeshNode* n41,
635 * \brief Return existing or create a new central node for a
636 * quadratic triangle given its 6 nodes.
637 * \param force3d - true means node creation in between the given nodes,
638 * else node position is found on a geometrical face if any.
640 const SMDS_MeshNode* GetCentralNode(const SMDS_MeshNode* n1,
641 const SMDS_MeshNode* n2,
642 const SMDS_MeshNode* n3,
643 const SMDS_MeshNode* n12,
644 const SMDS_MeshNode* n23,
645 const SMDS_MeshNode* n31,
648 * \brief Return index and type of the shape (EDGE or FACE only) to set a medium node on
650 std::pair<int, TopAbs_ShapeEnum> GetMediumPos(const SMDS_MeshNode* n1,
651 const SMDS_MeshNode* n2,
652 const bool useCurSubShape=false,
653 TopAbs_ShapeEnum expectedSupport=TopAbs_SHAPE);
655 * \brief Add a link in my data structure
657 void AddTLinkNode(const SMDS_MeshNode* n1,
658 const SMDS_MeshNode* n2,
659 const SMDS_MeshNode* n12);
661 * \brief Add many links in my data structure
663 void AddTLinkNodeMap(const TLinkNodeMap& aMap)
664 { myTLinkNodeMap.insert(aMap.begin(), aMap.end()); }
666 bool AddTLinks(const SMDS_MeshEdge* edge);
667 bool AddTLinks(const SMDS_MeshFace* face);
668 bool AddTLinks(const SMDS_MeshVolume* vol);
671 * Returns myTLinkNodeMap
673 const TLinkNodeMap& GetTLinkNodeMap() const { return myTLinkNodeMap; }
676 * Check mesh without geometry for: if all elements on this shape are quadratic,
677 * quadratic elements will be created.
678 * Used then generated 3D mesh without geometry.
680 enum MType{ LINEAR, QUADRATIC, COMP };
681 MType IsQuadraticMesh();
683 virtual ~SMESH_MesherHelper();
688 * \brief Select UV on either of 2 pcurves of a seam edge, closest to the given UV
689 * \param uv1 - UV on the seam
690 * \param uv2 - UV within a face
691 * \retval gp_Pnt2d - selected UV
693 gp_Pnt2d getUVOnSeam( const gp_Pnt2d& uv1, const gp_Pnt2d& uv2 ) const;
695 const SMDS_MeshNode* getMediumNodeOnComposedWire(const SMDS_MeshNode* n1,
696 const SMDS_MeshNode* n2,
699 double getFaceMaxTol( const TopoDS_Shape& face ) const;
703 // Forbiden copy constructor
704 SMESH_MesherHelper (const SMESH_MesherHelper& theOther);
706 // key of a map of bi-quadratic face to it's central node
707 struct TBiQuad: public std::pair<int, std::pair<int, int> >
709 TBiQuad(const SMDS_MeshNode* n1,
710 const SMDS_MeshNode* n2,
711 const SMDS_MeshNode* n3,
712 const SMDS_MeshNode* n4=0)
718 if ( n4 ) s.insert(n4);
719 TIDSortedNodeSet::iterator n = s.begin();
720 first = (*n++)->GetID();
721 second.first = (*n++)->GetID();
722 second.second = (*n++)->GetID();
726 // maps used during creation of quadratic elements
727 TLinkNodeMap myTLinkNodeMap; // medium nodes on links
728 std::map< TBiQuad, const SMDS_MeshNode* > myMapWithCentralNode; // central nodes of faces
730 std::set< int > myDegenShapeIds;
731 std::set< int > mySeamShapeIds;
732 double myPar1[2], myPar2[2]; // U and V bounds of a closed periodic surface
733 int myParIndex; // bounds' index (1-U, 2-V, 3-both)
735 std::map< int, double > myFaceMaxTol;
737 typedef std::map< int, GeomAPI_ProjectPointOnSurf* > TID2ProjectorOnSurf;
738 typedef std::map< int, GeomAPI_ProjectPointOnCurve* > TID2ProjectorOnCurve;
739 TID2ProjectorOnSurf myFace2Projector;
740 TID2ProjectorOnCurve myEdge2Projector;
742 TopoDS_Shape myShape;
746 bool myCreateQuadratic;
747 bool myCreateBiQuadratic;
748 bool mySetElemOnShape;
749 bool myFixNodeParameters;
751 std::map< int,bool > myNodePosShapesValidity;
752 bool toCheckPosOnShape(int shapeID ) const;
753 void setPosOnShapeValidity(int shapeID, bool ok ) const;
756 //=======================================================================
758 SMESH_MesherHelper::calcTFI(double x, double y,
759 const gp_XY& a0,const gp_XY& a1,const gp_XY& a2,const gp_XY& a3,
760 const gp_XY& p0,const gp_XY& p1,const gp_XY& p2,const gp_XY& p3)
763 ((1 - y) * p0 + x * p1 + y * p2 + (1 - x) * p3 ) -
764 ((1 - x) * (1 - y) * a0 + x * (1 - y) * a1 + x * y * a2 + (1 - x) * y * a3);
766 //=======================================================================
768 SMESH_MesherHelper::calcTFI(double x, double y,
769 const gp_XYZ& a0,const gp_XYZ& a1,const gp_XYZ& a2,const gp_XYZ& a3,
770 const gp_XYZ& p0,const gp_XYZ& p1,const gp_XYZ& p2,const gp_XYZ& p3)
773 ((1 - y) * p0 + x * p1 + y * p2 + (1 - x) * p3 ) -
774 ((1 - x) * (1 - y) * a0 + x * (1 - y) * a1 + x * y * a2 + (1 - x) * y * a3);
776 //=======================================================================