1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // File : BLSURFPlugin_EnforcedMesh1D.hxx
20 // Author : Edward AGAPOV (OCC)
22 #ifndef __BLSURFPlugin_EnforcedMesh1D_HXX__
23 #define __BLSURFPlugin_EnforcedMesh1D_HXX__
25 #include "BLSURFPlugin_Hypothesis.hxx"
27 #include <SMESH_ControlsDef.hxx>
28 #include <SMESH_MesherHelper.hxx>
30 #include <Geom2d_Curve.hxx>
31 #include <NCollection_DataMap.hxx>
32 #include <NCollection_IndexedMap.hxx>
33 #include <TopTools_IndexedMapOfShape.hxx>
34 #include <TopoDS_Edge.hxx>
35 #include <TopoDS_Face.hxx>
36 #include <TopoDS_Vertex.hxx>
38 #include <gp_Pnt2d.hxx>
43 class SMDS_MeshElement;
49 * \brief Implement 1D mesh into the mesh made by MG-CADSurf
51 class BLSURFPlugin_EnforcedMesh1D
55 BLSURFPlugin_EnforcedMesh1D( SMESH_MesherHelper& helper,
56 const BLSURFPlugin_Hypothesis* hyp );
58 ~BLSURFPlugin_EnforcedMesh1D();
60 // Return EDGEs resulted from division of FACE boundary by enforced segments
61 bool GetSplitsOfEdge( const TopoDS_Edge& edge,
62 std::vector< TopoDS_Edge > & splits,
63 TopTools_IndexedMapOfShape & edgeTags );
65 // Return true if there are enforced segments on a FACE. Start iteration on segments
66 bool HasSegmentsOnFace( const TopoDS_Face& face );
68 // Data of an enforced segment to provide MG-CADSurf with
72 Handle(Geom2d_Curve) _pcurve;
81 // Return next segment on the FACE. Iteration starts upon calling HasSegmentsOnFace()
82 bool NextSegment( Segmemnt & seg, TopTools_IndexedMapOfShape & vertexTags );
84 // Return enforced node by tag
85 const SMDS_MeshNode* GetNodeByTag( int tag, const TopTools_IndexedMapOfShape & vertexTags );
87 // Return true if a tad corresponds to an enforced segment
88 bool IsSegmentTag( int tag ) const;
90 // Return tag of EDGE by tags of its splits
91 int GetTagOfSplitEdge( int splitTag ) const;
93 typedef std::map< const SMDS_MeshElement* , std::vector< const SMDS_MeshNode* > > TNodesOnSeg;
97 void copyEnforcedMesh( const BLSURFPlugin_Hypothesis::EnforcedMesh& theEnfMesh,
98 const BLSURFPlugin_Hypothesis* theHyp,
99 const TopoDS_Shape& theShape);
101 const SMDS_MeshNode* copyEnforcedNode( const SMDS_MeshNode* enfNode );
103 void setupPredicates( const TopoDS_Shape& shape );
105 void splitSegmentOnSeveralShapes( const SMDS_MeshElement* segment );
107 void splitSelfIntersectingSegments( const TopoDS_Shape & face );
109 void findIntersectionWithSeamEdge( const TopoDS_Face & face, TNodesOnSeg & segInternalNodes );
111 bool intersectSegments( const SMDS_MeshElement* seg1, const SMDS_MeshElement* seg2,
112 const TopoDS_Face& face, gp_Pnt& intPnt, gp_Pnt2d& inUV ) const;
114 gp_Pnt getEdgeIntersection( const TopoDS_Shape& faceOrEdge,
115 const gp_XYZ& xyz0, const gp_XYZ& xyz1,
116 TopoDS_Edge & edge, double & paramOnEdge );
118 void splitEdgeByNodes( TopoDS_Edge edge, const std::vector< const SMDS_MeshNode* >& nodes);
120 SMDS_MeshGroup* getGroup( const std::string& groupName );
122 const SMDS_MeshNode* findNodeOnEdge( const gp_Pnt& p, const TopoDS_Edge& edge );
123 void addNodeOnEdge( const SMDS_MeshNode*node , const TopoDS_Edge& edge, const double u = 0. );
128 SMESH_MesherHelper _helper;
130 std::map< std::string, SMDS_MeshGroup* > _name2Group;
132 TopTools_IndexedMapOfShape _faces;
134 // segments whose nodes are on different FACEs;
135 // such segments will be split into segments lying each on own FACE
136 std::vector< const SMDS_MeshElement* > _segmentsOnSeveralShapes;
138 // nodes projected on EDGEs; EDGEs will be divided by them
139 typedef NCollection_DataMap< TopoDS_Edge,
140 std::vector< const SMDS_MeshNode* >,
141 TopTools_ShapeMapHasher> TEdge2Nodes;
142 typedef NCollection_DataMap< TopoDS_Edge,
143 std::vector< TopoDS_Edge >,
144 TopTools_ShapeMapHasher> TEdge2Edges;
145 TEdge2Nodes _nodesOnEdge;
146 TEdge2Edges _edgeSplitsOfEdge; // result of EDGE division by nodes
147 std::map< int, int > _splitTags2EdgeTag;
148 std::map< const SMDS_MeshNode* , TopoDS_Vertex > _nOnE2Vertex; // VERTEXes on _nodesOnEdge
150 typedef SMESH::Controls::ElementsOnShape TPredicate;
151 typedef SMESH::Controls::ElementsOnShapePtr TPredicatePtr;
152 TPredicatePtr _onVertexPredicate;
153 TPredicatePtr _onEdgePredicate;
155 // for iteration of segments of FACE
157 SMDS_ElemIteratorPtr _segIterator;
158 TopoDS_Face _currentFace;
162 typedef NCollection_IndexedMap< const SMDS_MeshNode* > TNodeIndMap;
163 TNodeIndMap _nodeTags;
166 // nodes not projected to geometry; they are reused during next projection to geometry
167 std::vector< const SMDS_MeshNode* > _freeNodes;