1 // Copyright (C) 2007-2022 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 // Add a vertex on EDGE
61 void AddVertexOnEdge( const double* xyz );
63 // Return EDGEs resulted from division of FACE boundary by enforced segments
64 bool GetSplitsOfEdge( const TopoDS_Edge& edge,
65 std::vector< TopoDS_Edge > & splits,
66 TopTools_IndexedMapOfShape & edgeTags );
68 // Return true if there are enforced segments on a FACE. Start iteration on segments
69 bool HasSegmentsOnFace( const TopoDS_Face& face );
71 // Data of an enforced segment to provide MG-CADSurf with
75 Handle(Geom2d_Curve) _pcurve;
84 // Return next segment on the FACE. Iteration starts upon calling HasSegmentsOnFace()
85 bool NextSegment( Segmemnt & seg, TopTools_IndexedMapOfShape & vertexTags );
87 // Return enforced node by tag
88 const SMDS_MeshNode* GetNodeByTag( int tag, const TopTools_IndexedMapOfShape & vertexTags );
90 // Return true if a tad corresponds to an enforced segment
91 bool IsSegmentTag( int tag ) const;
93 // Return tag of EDGE by tags of its splits
94 int GetTagOfSplitEdge( int splitTag ) const;
96 typedef std::map< const SMDS_MeshElement* , std::vector< const SMDS_MeshNode* > > TNodesOnSeg;
100 void copyEnforcedMesh( const BLSURFPlugin_Hypothesis::EnforcedMesh& theEnfMesh,
101 const BLSURFPlugin_Hypothesis* theHyp,
102 const TopoDS_Shape& theShape);
104 const SMDS_MeshNode* copyEnforcedNode( const SMDS_MeshNode* enfNode );
106 void setupPredicates( const TopoDS_Shape& shape );
108 void splitSegmentOnSeveralShapes( const SMDS_MeshElement* segment );
110 void splitSelfIntersectingSegments( const TopoDS_Shape & face );
112 void findIntersectionWithSeamEdge( const TopoDS_Face & face, TNodesOnSeg & segInternalNodes );
114 bool intersectSegments( const SMDS_MeshElement* seg1, const SMDS_MeshElement* seg2,
115 const TopoDS_Face& face, gp_Pnt& intPnt, gp_Pnt2d& inUV ) const;
117 gp_Pnt getEdgeIntersection( const TopoDS_Shape& faceOrEdge,
118 const gp_XYZ& xyz0, const gp_XYZ& xyz1,
119 TopoDS_Edge & edge, double & paramOnEdge );
121 void splitEdgeByNodes( TopoDS_Edge edge, const std::vector< const SMDS_MeshNode* >& nodes);
123 SMDS_MeshGroup* getGroup( const std::string& groupName );
125 const SMDS_MeshNode* findNodeOnEdge( const gp_Pnt& p, const TopoDS_Edge& edge );
126 void addNodeOnEdge( const SMDS_MeshNode*node , const TopoDS_Edge& edge, const double u = 0. );
131 SMESH_MesherHelper _helper;
133 std::map< std::string, SMDS_MeshGroup* > _name2Group;
135 TopTools_IndexedMapOfShape _faces;
137 // segments whose nodes are on different FACEs;
138 // such segments will be split into segments lying each on own FACE
139 std::vector< const SMDS_MeshElement* > _segmentsOnSeveralShapes;
141 // nodes projected on EDGEs; EDGEs will be divided by them
142 typedef NCollection_DataMap< TopoDS_Edge,
143 std::vector< const SMDS_MeshNode* >,
144 TopTools_ShapeMapHasher> TEdge2Nodes;
145 typedef NCollection_DataMap< TopoDS_Edge,
146 std::vector< TopoDS_Edge >,
147 TopTools_ShapeMapHasher> TEdge2Edges;
148 TEdge2Nodes _nodesOnEdge;
149 TEdge2Edges _edgeSplitsOfEdge; // result of EDGE division by nodes
150 std::map< int, int > _splitTags2EdgeTag;
151 std::map< const SMDS_MeshNode* , TopoDS_Vertex > _nOnE2Vertex; // VERTEXes on _nodesOnEdge
153 typedef SMESH::Controls::ElementsOnShape TPredicate;
154 typedef SMESH::Controls::ElementsOnShapePtr TPredicatePtr;
155 TPredicatePtr _onVertexPredicate;
156 TPredicatePtr _onEdgePredicate;
158 // for iteration of segments of FACE
160 SMDS_ElemIteratorPtr _segIterator;
161 TopoDS_Face _currentFace;
165 typedef NCollection_IndexedMap< const SMDS_MeshNode* > TNodeIndMap;
166 TNodeIndMap _nodeTags;
169 // nodes not projected to geometry; they are reused during next projection to geometry
170 std::vector< const SMDS_MeshNode* > _freeNodes;