1 // Copyright (C) 2007-2016 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
34 #include <Geom_Surface.hxx>
35 #include <ShapeAnalysis_Surface.hxx>
36 #include <TopoDS_Face.hxx>
37 #include <TopoDS_Shape.hxx>
38 #include <gp_Pnt2d.hxx>
43 class GeomAPI_ProjectPointOnCurve;
44 class GeomAPI_ProjectPointOnSurf;
46 class SMESHDS_Hypothesis;
48 class SMESH_ProxyMesh;
50 typedef std::map<SMESH_TLink, const SMDS_MeshNode*> TLinkNodeMap;
51 typedef std::map<SMESH_TLink, const SMDS_MeshNode*>::iterator ItTLinkNode;
53 typedef SMDS_Iterator<const TopoDS_Shape*> PShapeIterator;
54 typedef boost::shared_ptr< PShapeIterator > PShapeIteratorPtr;
56 typedef std::vector<const SMDS_MeshNode* > TNodeColumn;
57 typedef std::map< double, TNodeColumn > TParam2ColumnMap;
59 typedef gp_XY (*xyFunPtr)(const gp_XY& uv1, const gp_XY& uv2);
61 //=======================================================================
63 * \brief It helps meshers to add elements and provides other utilities
65 * - It allows meshers not to care about creation of medium nodes
66 * when filling a quadratic mesh. Helper does it itself.
67 * It defines order of elements to create when IsQuadraticSubMesh()
69 * - It provides information on a shape it is initialized with:
70 * periodicity, presence of singularities etc.
73 //=======================================================================
75 class SMESH_EXPORT SMESH_MesherHelper
78 // ---------- PUBLIC UTILITIES ----------
81 * \brief Returns true if all elements of a sub-mesh are of same shape
82 * \param smDS - sub-mesh to check elements of
83 * \param shape - expected shape of elements
84 * \param nullSubMeshRes - result value for the case of smDS == NULL
85 * \retval bool - check result
87 static bool IsSameElemGeometry(const SMESHDS_SubMesh* smDS,
88 SMDSAbs_GeometryType shape,
89 const bool nullSubMeshRes = true);
92 * \brief Load nodes bound to face into a map of node columns
93 * \param theParam2ColumnMap - map of node columns to fill
94 * \param theFace - the face on which nodes are searched for
95 * \param theBaseSide - the edges holding nodes on which columns' bases
96 * \param theMesh - the mesh containing nodes
97 * \retval bool - false if something is wrong
99 * The key of the map is a normalized parameter of each
100 * base node on theBaseSide. Edges in theBaseSide must be sequenced.
101 * This method works in supposition that nodes on the face
102 * forms a structured grid and elements can be quardrangles or triangles
104 static bool LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap,
105 const TopoDS_Face& theFace,
106 const std::list<TopoDS_Edge>& theBaseSide,
107 SMESHDS_Mesh* theMesh,
108 SMESH_ProxyMesh* theProxyMesh=0);
110 * \brief Variant of LoadNodeColumns() above with theBaseSide given by one edge
112 static bool LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap,
113 const TopoDS_Face& theFace,
114 const TopoDS_Edge& theBaseEdge,
115 SMESHDS_Mesh* theMesh,
116 SMESH_ProxyMesh* theProxyMesh=0);
118 * \brief Return true if 2D mesh on FACE is structured
120 static bool IsStructured( SMESH_subMesh* faceSM );
123 * \brief Return true if 2D mesh on FACE is distored
125 static bool IsDistorted2D( SMESH_subMesh* faceSM,
126 bool checkUV = false,
127 SMESH_MesherHelper* faceHelper = NULL);
130 * \brief Returns true if given node is medium
131 * \param n - node to check
132 * \param typeToCheck - type of elements containing the node to ask about node status
133 * \retval bool - check result
135 static bool IsMedium(const SMDS_MeshNode* node,
136 const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
138 * \brief Return support shape of a node
139 * \param node - the node
140 * \param meshDS - mesh DS
141 * \retval TopoDS_Shape - found support shape
142 * \sa SMESH_Algo::VertexNode( const TopoDS_Vertex&, SMESHDS_Mesh* )
144 static TopoDS_Shape GetSubShapeByNode(const SMDS_MeshNode* node,
145 const SMESHDS_Mesh* meshDS);
148 * \brief Return a valid node index, fixing the given one if necessary
149 * \param ind - node index
150 * \param nbNodes - total nb of nodes
151 * \retval int - valid node index
153 static inline int WrapIndex(int ind, const int nbNodes) {
154 return (( ind %= nbNodes ) < 0 ) ? ind + nbNodes : ind;
158 * \brief Return UV of a point inside a quadrilateral FACE by it's
159 * normalized parameters within a unit quadrangle and the
160 * corresponding projections on sub-shapes of the real-world FACE.
161 * The used calculation method is called Trans-Finite Interpolation (TFI).
162 * \param x,y - normalized parameters that should be in range [0,1]
163 * \param a0,a1,a2,a3 - UV of VERTEXes of the FACE == projections on VERTEXes
164 * \param p0,p1,p2,p3 - UV of the point projections on EDGEs of the FACE
165 * \return gp_XY - UV of the point on the FACE
167 * Y ^ Order of those UV in the FACE is as follows.
175 * o---x-----o ----> X
178 inline static gp_XY calcTFI(double x, double y,
179 const gp_XY& a0,const gp_XY& a1,const gp_XY& a2,const gp_XY& a3,
180 const gp_XY& p0,const gp_XY& p1,const gp_XY& p2,const gp_XY& p3);
183 * \brief Same as "gp_XY calcTFI(...)" but in 3D
185 inline static gp_XYZ calcTFI(double x, double y,
186 const gp_XYZ& a0,const gp_XYZ& a1,const gp_XYZ& a2,const gp_XYZ& a3,
187 const gp_XYZ& p0,const gp_XYZ& p1,const gp_XYZ& p2,const gp_XYZ& p3);
189 * \brief Count nb of sub-shapes
190 * \param shape - the shape
191 * \param type - the type of sub-shapes to count
192 * \param ignoreSame - if true, use map not to count same shapes, else use explorer
193 * \retval int - the calculated number
195 static int Count(const TopoDS_Shape& shape,
196 const TopAbs_ShapeEnum type,
197 const bool ignoreSame);
200 * \brief Return number of unique ancestors of the shape
202 static int NbAncestors(const TopoDS_Shape& shape,
203 const SMESH_Mesh& mesh,
204 TopAbs_ShapeEnum ancestorType=TopAbs_SHAPE);
206 * \brief Return iterator on ancestors of the given type, included into a container shape
208 static PShapeIteratorPtr GetAncestors(const TopoDS_Shape& shape,
209 const SMESH_Mesh& mesh,
210 TopAbs_ShapeEnum ancestorType,
211 const TopoDS_Shape* container = 0);
213 * \brief Find a common ancestor, of the given type, of two shapes
215 static TopoDS_Shape GetCommonAncestor(const TopoDS_Shape& shape1,
216 const TopoDS_Shape& shape2,
217 const SMESH_Mesh& mesh,
218 TopAbs_ShapeEnum ancestorType);
220 * \brief Return orientation of sub-shape in the main shape
222 static TopAbs_Orientation GetSubShapeOri(const TopoDS_Shape& shape,
223 const TopoDS_Shape& subShape);
225 static bool IsSubShape( const TopoDS_Shape& shape, const TopoDS_Shape& mainShape );
227 static bool IsSubShape( const TopoDS_Shape& shape, SMESH_Mesh* aMesh );
229 static bool IsBlock( const TopoDS_Shape& shape );
231 static double MaxTolerance( const TopoDS_Shape& shape );
233 static double GetAngle( const TopoDS_Edge & E1, const TopoDS_Edge & E2,
234 const TopoDS_Face & F, const TopoDS_Vertex & V,
235 gp_Vec* faceNormal=0);
237 static bool IsClosedEdge( const TopoDS_Edge& anEdge );
239 static TopoDS_Vertex IthVertex( const bool is2nd, TopoDS_Edge anEdge, const bool CumOri=true );
241 static TopAbs_ShapeEnum GetGroupType(const TopoDS_Shape& group,
242 const bool avoidCompound=false);
244 static TopoDS_Shape GetShapeOfHypothesis( const SMESHDS_Hypothesis * hyp,
245 const TopoDS_Shape& shape,
250 // ---------- PUBLIC INSTANCE METHODS ----------
253 SMESH_MesherHelper(SMESH_Mesh& theMesh);
255 SMESH_Gen* GetGen() const;
257 SMESH_Mesh* GetMesh() const { return myMesh; }
259 SMESHDS_Mesh* GetMeshDS() const;
262 * Check submesh for given shape: if all elements on this shape are quadratic,
263 * quadratic elements will be created. Also fill myTLinkNodeMap
265 bool IsQuadraticSubMesh(const TopoDS_Shape& theShape);
268 * \brief Set order of elements to create without calling IsQuadraticSubMesh()
270 void SetIsQuadratic(const bool theBuildQuadratic)
271 { myCreateQuadratic = theBuildQuadratic; }
274 * \brief Set myCreateBiQuadratic flag
276 void SetIsBiQuadratic(const bool theBuildBiQuadratic)
277 { myCreateBiQuadratic = theBuildBiQuadratic; }
280 * \brief Return myCreateQuadratic flag
282 bool GetIsQuadratic() const { return myCreateQuadratic; }
285 * \brief Find out elements orientation on a geometrical face
287 bool IsReversedSubMesh (const TopoDS_Face& theFace);
290 * \brief Return myCreateBiQuadratic flag
292 bool GetIsBiQuadratic() const { return myCreateBiQuadratic; }
295 * \brief Move medium nodes of faces and volumes to fix distorted elements
296 * \param error - container of fixed distorted elements
297 * \param volumeOnly - fix nodes on geom faces or not if the shape is solid
299 void FixQuadraticElements(SMESH_ComputeErrorPtr& error, bool volumeOnly=true);
302 * \brief To set created elements on the shape set by IsQuadraticSubMesh()
303 * or the next methods. By defaul elements are set on the shape if
304 * a mesh has no shape to be meshed
306 bool SetElementsOnShape(bool toSet)
307 { bool res = mySetElemOnShape; mySetElemOnShape = toSet; return res; }
310 * \brief Set shape to make elements on without calling IsQuadraticSubMesh()
312 void SetSubShape(const int subShapeID);//!==SMESHDS_Mesh::ShapeToIndex(shape)
313 void SetSubShape(const TopoDS_Shape& subShape);
315 * \brief Return ID of the shape set by IsQuadraticSubMesh() or SetSubShape()
316 * \retval int - shape index in SMESHDS
318 int GetSubShapeID() const { return myShapeID; }
320 * \brief Return the shape set by IsQuadraticSubMesh() or SetSubShape()
322 const TopoDS_Shape& GetSubShape() const { return myShape; }
324 * \brief Copy shape information from another helper to improve performance
325 * since SetSubShape() can be time consuming if there are many edges
327 void CopySubShapeInfo(const SMESH_MesherHelper& other);
331 * \brief Convert a shape to its index in the SMESHDS_Mesh
333 int ShapeToIndex( const TopoDS_Shape& S ) const;
336 * Creates a node (!Note ID before u=0.,v0.)
338 SMDS_MeshNode* AddNode(double x, double y, double z, int ID = 0, double u=0., double v=0.);
340 * Creates quadratic or linear edge
342 SMDS_MeshEdge* AddEdge(const SMDS_MeshNode* n1,
343 const SMDS_MeshNode* n2,
345 const bool force3d = true);
347 * Creates quadratic or linear triangle
349 SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
350 const SMDS_MeshNode* n2,
351 const SMDS_MeshNode* n3,
353 const bool force3d = false);
355 * Creates bi-quadratic, quadratic or linear quadrangle
357 SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
358 const SMDS_MeshNode* n2,
359 const SMDS_MeshNode* n3,
360 const SMDS_MeshNode* n4,
362 const bool force3d = false);
364 * Creates polygon, with additional nodes in quadratic mesh
366 SMDS_MeshFace* AddPolygonalFace (const std::vector<const SMDS_MeshNode*>& nodes,
368 const bool force3d = false);
370 * Creates quadratic or linear tetrahedron
372 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
373 const SMDS_MeshNode* n2,
374 const SMDS_MeshNode* n3,
375 const SMDS_MeshNode* n4,
377 const bool force3d = true);
379 * Creates quadratic or linear pyramid
381 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
382 const SMDS_MeshNode* n2,
383 const SMDS_MeshNode* n3,
384 const SMDS_MeshNode* n4,
385 const SMDS_MeshNode* n5,
387 const bool force3d = true);
389 * Creates quadratic or linear pentahedron
391 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
392 const SMDS_MeshNode* n2,
393 const SMDS_MeshNode* n3,
394 const SMDS_MeshNode* n4,
395 const SMDS_MeshNode* n5,
396 const SMDS_MeshNode* n6,
398 const bool force3d = true);
400 * Creates bi-quadratic, quadratic or linear hexahedron
402 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
403 const SMDS_MeshNode* n2,
404 const SMDS_MeshNode* n3,
405 const SMDS_MeshNode* n4,
406 const SMDS_MeshNode* n5,
407 const SMDS_MeshNode* n6,
408 const SMDS_MeshNode* n7,
409 const SMDS_MeshNode* n8,
411 bool force3d = true);
414 * Creates LINEAR!!!!!!!!! octahedron
416 SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
417 const SMDS_MeshNode* n2,
418 const SMDS_MeshNode* n3,
419 const SMDS_MeshNode* n4,
420 const SMDS_MeshNode* n5,
421 const SMDS_MeshNode* n6,
422 const SMDS_MeshNode* n7,
423 const SMDS_MeshNode* n8,
424 const SMDS_MeshNode* n9,
425 const SMDS_MeshNode* n10,
426 const SMDS_MeshNode* n11,
427 const SMDS_MeshNode* n12,
429 bool force3d = true);
432 * Creates polyhedron. In quadratic mesh, adds medium nodes
434 SMDS_MeshVolume* AddPolyhedralVolume (const std::vector<const SMDS_MeshNode*>& nodes,
435 const std::vector<int>& quantities,
437 const bool force3d = true);
439 * \brief Enables fixing node parameters on EDGEs and FACEs by
440 * GetNodeU(...,check=true), GetNodeUV(...,check=true), CheckNodeUV() and
441 * CheckNodeU() in case if a node lies on a shape set via SetSubShape().
444 void ToFixNodeParameters(bool toFix);
447 * \brief Return U of the given node on the edge
449 double GetNodeU(const TopoDS_Edge& theEdge,
450 const SMDS_MeshNode* theNode,
451 const SMDS_MeshNode* inEdgeNode=0,
452 bool* check=0) const;
454 * \brief Return node UV on face
455 * \param inFaceNode - a node of element being created located inside a face
456 * \param check - if provided, returns result of UV check that it enforces
458 gp_XY GetNodeUV(const TopoDS_Face& F,
459 const SMDS_MeshNode* n,
460 const SMDS_MeshNode* inFaceNode=0,
461 bool* check=0) const;
463 * \brief Check and fix node UV on a face
464 * \param force - check even if checks of other nodes on this face passed OK
465 * \param distXYZ - returns result distance and point coordinates
466 * \retval bool - false if UV is bad and could not be fixed
468 bool CheckNodeUV(const TopoDS_Face& F,
469 const SMDS_MeshNode* n,
472 const bool force=false,
473 double distXYZ[4]=0) const;
475 * \brief Check and fix node U on an edge
476 * \param force - check even if checks of other nodes on this edge passed OK
477 * \param distXYZ - returns result distance and point coordinates
478 * \retval bool - false if U is bad and could not be fixed
480 bool CheckNodeU(const TopoDS_Edge& E,
481 const SMDS_MeshNode* n,
484 const bool force=false,
485 double distXYZ[4]=0) const;
487 * \brief Return middle UV taking in account surface period
489 static gp_XY GetMiddleUV(const Handle(Geom_Surface)& surface,
493 * \brief Return UV for the central node of a biquadratic triangle
495 static gp_XY GetCenterUV(const gp_XY& uv1,
503 * \brief Define a pointer to wrapper over a function of gp_XY class,
504 * suitable to pass as xyFunPtr to ApplyIn2D().
505 * For exaple gp_XY_FunPtr(Added) defines pointer gp_XY_Added to function
506 * calling gp_XY::Added(gp_XY), which is to be used like following
507 * ApplyIn2D(surf, uv1, uv2, gp_XY_Added)
509 #define gp_XY_FunPtr(meth) \
510 static gp_XY __gpXY_##meth (const gp_XY& uv1, const gp_XY& uv2) { return uv1.meth( uv2 ); } \
511 static xyFunPtr gp_XY_##meth = & __gpXY_##meth
514 * \brief Perform given operation on two 2d points in parameric space of given surface.
515 * It takes into account period of the surface. Use gp_XY_FunPtr macro
516 * to easily define pointer to function of gp_XY class.
518 static gp_XY ApplyIn2D(Handle(Geom_Surface) surface,
522 const bool resultInPeriod=true);
525 * \brief Move node positions on a FACE within surface period
526 * \param [in] face - the FACE
527 * \param [inout] uv - node positions to adjust
528 * \param [in] nbUV - nb of \a uv
530 void AdjustByPeriod( const TopoDS_Face& face, gp_XY uv[], const int nbUV );
533 * \brief Check if inFaceNode argument is necessary for call GetNodeUV(F,..)
534 * \retval bool - return true if the face is periodic
536 * If F is Null, answer about subshape set through IsQuadraticSubMesh() or
539 bool GetNodeUVneedInFaceNode(const TopoDS_Face& F = TopoDS_Face()) const;
542 * \brief Return projector intitialized by given face without location, which is returned
544 GeomAPI_ProjectPointOnSurf& GetProjector(const TopoDS_Face& F,
545 TopLoc_Location& loc,
546 double tol=0 ) const;
548 * \brief Return a cached ShapeAnalysis_Surface of a FACE
550 Handle(ShapeAnalysis_Surface) GetSurface(const TopoDS_Face& F ) const;
553 * \brief Check if shape is a degenerated edge or it's vertex
554 * \param subShape - edge or vertex index in SMESHDS
555 * \retval bool - true if subShape is a degenerated shape
557 * It works only if IsQuadraticSubMesh() or SetSubShape() has been called
559 bool IsDegenShape(const int subShape) const
560 { return myDegenShapeIds.find( subShape ) != myDegenShapeIds.end(); }
562 * \brief Check if the shape set through IsQuadraticSubMesh() or SetSubShape()
563 * has a degenerated edges
564 * \retval bool - true if it has
566 bool HasDegeneratedEdges() const { return !myDegenShapeIds.empty(); }
569 * \brief Check if shape is a seam edge or it's vertex
570 * \param subShape - edge or vertex index in SMESHDS
571 * \retval bool - true if subShape is a seam shape
573 * It works only if IsQuadraticSubMesh() or SetSubShape() has been called.
574 * Seam shape has two 2D alternative represenations on the face
576 bool IsSeamShape(const int subShape) const
577 { return mySeamShapeIds.find( subShape ) != mySeamShapeIds.end(); }
579 * \brief Check if shape is a seam edge or it's vertex
580 * \param subShape - edge or vertex
581 * \retval bool - true if subShape is a seam shape
583 * It works only if IsQuadraticSubMesh() or SetSubShape() has been called.
584 * Seam shape has two 2D alternative represenations on the face
586 bool IsSeamShape(const TopoDS_Shape& subShape) const
587 { return IsSeamShape( ShapeToIndex( subShape )); }
589 * \brief Return true if an edge or a vertex encounters twice in face wire
590 * \param subShape - Id of edge or vertex
592 bool IsRealSeam(const int subShape) const
593 { return mySeamShapeIds.find( -subShape ) != mySeamShapeIds.end(); }
595 * \brief Return true if an edge or a vertex encounters twice in face wire
596 * \param subShape - edge or vertex
598 bool IsRealSeam(const TopoDS_Shape& subShape) const
599 { return IsRealSeam( ShapeToIndex( subShape )); }
601 * \brief Check if the shape set through IsQuadraticSubMesh() or SetSubShape()
602 * has a seam edge, i.e. an edge that has two parametric representations
604 * \retval bool - true if it has
606 bool HasSeam() const { return !mySeamShapeIds.empty(); }
608 * \brief Check if the shape set through IsQuadraticSubMesh() or SetSubShape()
609 * has a seam edge that encounters twice in a wire
610 * \retval bool - true if it has
612 bool HasRealSeam() const { return HasSeam() && ( *mySeamShapeIds.begin() < 0 ); }
614 * \brief Return index of periodic parametric direction of a closed face
615 * \retval int - 1 for U, 2 for V direction
617 int GetPeriodicIndex() const { return myParIndex; }
619 * \brief Return an alternative parameter for a node on seam
621 double GetOtherParam(const double param) const;
623 * \brief Check if UV is on seam. Return 0 if not, 1 for U seam, 2 for V seam
625 int IsOnSeam(const gp_XY& uv) const;
628 * \brief Return existing or create new medium nodes between given ones
629 * \param force3d - true means node creation at the middle between the
630 * two given nodes, else node position is found on its
631 * supporting geometrical shape, if any.
632 * \param expectedSupport - shape type corresponding to element being created
633 * , e.g TopAbs_EDGE if SMDSAbs_Edge is created
634 * basing on \a n1 and \a n2
636 const SMDS_MeshNode* GetMediumNode(const SMDS_MeshNode* n1,
637 const SMDS_MeshNode* n2,
639 TopAbs_ShapeEnum expectedSupport=TopAbs_SHAPE);
641 * \brief Return existing or create a new central node for a quardilateral
642 * quadratic face given its 8 nodes.
643 * \param force3d - true means node creation in between the given nodes,
644 * else node position is found on a geometrical face if any.
646 const SMDS_MeshNode* GetCentralNode(const SMDS_MeshNode* n1,
647 const SMDS_MeshNode* n2,
648 const SMDS_MeshNode* n3,
649 const SMDS_MeshNode* n4,
650 const SMDS_MeshNode* n12,
651 const SMDS_MeshNode* n23,
652 const SMDS_MeshNode* n34,
653 const SMDS_MeshNode* n41,
656 * \brief Return existing or create a new central node for a
657 * quadratic triangle given its 6 nodes.
658 * \param force3d - true means node creation in between the given nodes,
659 * else node position is found on a geometrical face if any.
661 const SMDS_MeshNode* GetCentralNode(const SMDS_MeshNode* n1,
662 const SMDS_MeshNode* n2,
663 const SMDS_MeshNode* n3,
664 const SMDS_MeshNode* n12,
665 const SMDS_MeshNode* n23,
666 const SMDS_MeshNode* n31,
669 * \brief Return index and type of the shape (EDGE or FACE only) to set a medium node on
671 std::pair<int, TopAbs_ShapeEnum> GetMediumPos(const SMDS_MeshNode* n1,
672 const SMDS_MeshNode* n2,
673 const bool useCurSubShape=false,
674 TopAbs_ShapeEnum expectedSupport=TopAbs_SHAPE);
676 * \brief Add a link in my data structure
678 void AddTLinkNode(const SMDS_MeshNode* n1,
679 const SMDS_MeshNode* n2,
680 const SMDS_MeshNode* n12);
682 * \brief Add many links in my data structure
684 void AddTLinkNodeMap(const TLinkNodeMap& aMap)
685 { myTLinkNodeMap.insert(aMap.begin(), aMap.end()); }
687 bool AddTLinks(const SMDS_MeshEdge* edge);
688 bool AddTLinks(const SMDS_MeshFace* face);
689 bool AddTLinks(const SMDS_MeshVolume* vol);
692 * Returns myTLinkNodeMap
694 const TLinkNodeMap& GetTLinkNodeMap() const { return myTLinkNodeMap; }
697 * Check mesh without geometry for: if all elements on this shape are quadratic,
698 * quadratic elements will be created.
699 * Used then generated 3D mesh without geometry.
701 enum MType{ LINEAR, QUADRATIC, COMP };
702 MType IsQuadraticMesh();
704 virtual ~SMESH_MesherHelper();
706 static void WriteShape(const TopoDS_Shape& s);
712 * \brief Select UV on either of 2 pcurves of a seam edge, closest to the given UV
713 * \param uv1 - UV on the seam
714 * \param uv2 - UV within a face
715 * \retval gp_Pnt2d - selected UV
717 gp_Pnt2d getUVOnSeam( const gp_Pnt2d& uv1, const gp_Pnt2d& uv2 ) const;
719 const SMDS_MeshNode* getMediumNodeOnComposedWire(const SMDS_MeshNode* n1,
720 const SMDS_MeshNode* n2,
723 double getFaceMaxTol( const TopoDS_Shape& face ) const;
728 // forbidden copy constructor
729 SMESH_MesherHelper (const SMESH_MesherHelper& theOther);
731 // key of a map of bi-quadratic face to it's central node
732 struct TBiQuad: public std::pair<int, std::pair<int, int> >
734 TBiQuad(const SMDS_MeshNode* n1,
735 const SMDS_MeshNode* n2,
736 const SMDS_MeshNode* n3,
737 const SMDS_MeshNode* n4=0)
743 if ( n4 ) s.insert(n4);
744 TIDSortedNodeSet::iterator n = s.begin();
745 first = (*n++)->GetID();
746 second.first = (*n++)->GetID();
747 second.second = (*n++)->GetID();
751 // maps used during creation of quadratic elements
752 TLinkNodeMap myTLinkNodeMap; // medium nodes on links
753 std::map< TBiQuad, const SMDS_MeshNode* > myMapWithCentralNode; // central nodes of faces
755 std::set< int > myDegenShapeIds;
756 std::set< int > mySeamShapeIds;
757 double myPar1[2], myPar2[2]; // U and V bounds of a closed periodic surface
758 int myParIndex; // bounds' index (1-U, 2-V, 3-both)
760 std::map< int, double > myFaceMaxTol;
762 typedef std::map< int, Handle(ShapeAnalysis_Surface)> TID2Surface;
763 typedef std::map< int, GeomAPI_ProjectPointOnSurf* > TID2ProjectorOnSurf;
764 typedef std::map< int, GeomAPI_ProjectPointOnCurve* > TID2ProjectorOnCurve;
765 mutable TID2Surface myFace2Surface;
766 TID2ProjectorOnSurf myFace2Projector;
767 TID2ProjectorOnCurve myEdge2Projector;
769 TopoDS_Shape myShape;
773 bool myCreateQuadratic;
774 bool myCreateBiQuadratic;
775 bool mySetElemOnShape;
776 bool myFixNodeParameters;
778 std::map< int,bool > myNodePosShapesValidity;
779 bool toCheckPosOnShape(int shapeID ) const;
780 void setPosOnShapeValidity(int shapeID, bool ok ) const;
783 //=======================================================================
785 SMESH_MesherHelper::calcTFI(double x, double y,
786 const gp_XY& a0,const gp_XY& a1,const gp_XY& a2,const gp_XY& a3,
787 const gp_XY& p0,const gp_XY& p1,const gp_XY& p2,const gp_XY& p3)
790 ((1 - y) * p0 + x * p1 + y * p2 + (1 - x) * p3 ) -
791 ((1 - x) * (1 - y) * a0 + x * (1 - y) * a1 + x * y * a2 + (1 - x) * y * a3);
793 //=======================================================================
795 SMESH_MesherHelper::calcTFI(double x, double y,
796 const gp_XYZ& a0,const gp_XYZ& a1,const gp_XYZ& a2,const gp_XYZ& a3,
797 const gp_XYZ& p0,const gp_XYZ& p1,const gp_XYZ& p2,const gp_XYZ& p3)
800 ((1 - y) * p0 + x * p1 + y * p2 + (1 - x) * p3 ) -
801 ((1 - x) * (1 - y) * a0 + x * (1 - y) * a1 + x * y * a2 + (1 - x) * y * a3);
803 //=======================================================================