Version: 9.16.0
StdMeshers_ProjectionUtils.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5//
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.
10//
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.
15//
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
19//
20// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21//
22
23// SMESH SMESH : idl implementation based on 'SMESH' unit's classes
24// File : StdMeshers_ProjectionUtils.hxx
25// Created : Thu Oct 26 15:37:24 2006
26// Author : Edward AGAPOV (eap)
27//
28#ifndef StdMeshers_ProjectionUtils_HeaderFile
29#define StdMeshers_ProjectionUtils_HeaderFile
30
31#include "SMESH_StdMeshers.hxx"
32
33#include "SMDS_MeshElement.hxx"
34#include "SMESH_Delaunay.hxx"
36
37#include <ShapeAnalysis_Surface.hxx>
38#include <TopTools_DataMapOfShapeShape.hxx>
39#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
40#include <TopTools_IndexedMapOfShape.hxx>
41#include <TopoDS_Edge.hxx>
42#include <TopoDS_Face.hxx>
43#include <TopoDS_Vertex.hxx>
44#include <gp_GTrsf.hxx>
45#include <gp_GTrsf2d.hxx>
46
47#include <list>
48#include <map>
49
50class SMDS_MeshNode;
51class SMESH_Algo;
53class SMESH_Mesh;
54class SMESH_subMesh;
55class TopoDS_Shape;
56
57//-----------------------------------------------------------------------------------------
63{
64 TopTools_DataMapOfShapeShape _map1to2, _map2to1;
65
69
70 // convention: s1 - target, s2 - source
71 bool Bind( const TopoDS_Shape& s1, const TopoDS_Shape& s2 )
72 { _map1to2.Bind( s1, s2 ); return _map2to1.Bind( s2, s1 ); }
73 bool IsBound( const TopoDS_Shape& s, const bool isShape2=false ) const
74 { return (isShape2 ? _map2to1 : _map1to2).IsBound( s ); }
75 bool IsEmpty() const { return _map1to2.IsEmpty(); }
76 int Extent() const { return _map1to2.Extent(); }
77 void Clear() { _map1to2.Clear(); _map2to1.Clear(); }
78 const TopoDS_Shape& operator()( const TopoDS_Shape& s, const bool isShape2=false ) const
79 { // if we get a Standard_NoSuchObject here, it means that the calling code
80 // passes incorrect isShape2
81 return (isShape2 ? _map2to1 : _map1to2)( s );
82 }
84 void SetAssocType( EAssocType type ) { if ( _assocType == UNDEF ) _assocType = type; }
85};
86
91{
93 typedef TopTools_IndexedDataMapOfShapeListOfShape TAncestorMap;
94 typedef std::map<const SMDS_MeshNode*, const SMDS_MeshNode*,
96
97
98 //-----------------------------------------------------------------------------------------
104 {
105 gp_GTrsf2d _trsf;
106 gp_XY _srcOrig;
107 public:
109
110 void Set( const gp_GTrsf2d& t ) { _trsf = t; } // it's an alternative to Solve()
111
112 bool Solve( const std::vector< gp_XY >& srcPnts,
113 const std::vector< gp_XY >& tgtPnts );
114
115 gp_XY Transform( const gp_Pnt2d& srcUV ) const;
116
117 bool IsIdentity() const { return ( _trsf.Form() == gp_Identity ); }
118 };
119 //-----------------------------------------------------------------------------------------
125 {
126 gp_GTrsf _trsf;
127 gp_XYZ _srcOrig;
128 public:
130
131 void Set( const gp_GTrsf& t ) { _trsf = t; } // it's an alternative to Solve()
132
133 bool Solve( const std::vector< gp_XYZ > & srcPnts,
134 const std::vector< gp_XYZ > & tgtPnts );
135
136 gp_XYZ Transform( const gp_Pnt& srcP ) const;
137
138 gp_XYZ TransformVec( const gp_Vec& v ) const;
139
140 bool IsIdentity() const { return ( _trsf.Form() == gp_Identity ); }
141
142 bool Invert();
143 };
144
145 //-----------------------------------------------------------------------------------------
156 {
157 public:
158
159 Delaunay( const TSideVector& wires, bool checkUV = false );
160
161 Delaunay( const std::vector< const UVPtStructVec* > & boundaryNodes,
162 SMESH_MesherHelper& faceHelper,
163 bool checkUV = false);
164
165 protected:
166 virtual gp_XY getNodeUV( const TopoDS_Face& face, const SMDS_MeshNode* node ) const;
167
168 private:
172 };
173 typedef boost::shared_ptr< Delaunay > DelaunayPtr;
174
175 //-----------------------------------------------------------------------------------------
179 class Morph
180 {
183 public:
184
185 Morph(const TSideVector& srcWires);
186
187 bool Perform(SMESH_MesherHelper& tgtHelper,
188 const TSideVector& tgtWires,
189 Handle(ShapeAnalysis_Surface) tgtSurface,
190 const TNodeNodeMap& src2tgtNodes,
191 const bool moveAll);
192 };
193
194 //-----------------------------------------------------------------------------------------
205 bool FindSubShapeAssociation(const TopoDS_Shape& theShape1,
206 SMESH_Mesh* theMesh1,
207 const TopoDS_Shape& theShape2,
208 SMESH_Mesh* theMesh2,
209 TShapeShapeMap & theAssociationMap);
210
222 int FindFaceAssociation(const TopoDS_Face& face1,
223 TopoDS_Vertex VV1[2],
224 const TopoDS_Face& face2,
225 TopoDS_Vertex VV2[2],
226 std::list< TopoDS_Edge > & edges1,
227 std::list< TopoDS_Edge > & edges2,
228 const bool isClosenessAssoc=false);
229
236 void InitVertexAssociation( const SMESH_Hypothesis* theHyp,
237 TShapeShapeMap & theAssociationMap);
238
247 bool InsertAssociation( const TopoDS_Shape& theShape1, // target
248 const TopoDS_Shape& theShape2, // source
249 TShapeShapeMap & theAssociationMap);
250
254 TopoDS_Edge GetEdgeByVertices( SMESH_Mesh* aMesh,
255 const TopoDS_Vertex& V1,
256 const TopoDS_Vertex& V2);
257
262 TopoDS_Face GetNextFace( const TAncestorMap& edgeToFaces,
263 const TopoDS_Edge& edge,
264 const TopoDS_Face& face);
268 TopoDS_Vertex GetNextVertex(const TopoDS_Edge& edge,
269 const TopoDS_Vertex& vertex);
270
279 std::pair<int,TopoDS_Edge> GetPropagationEdge( SMESH_Mesh* aMesh,
280 const TopoDS_Edge& anEdge,
281 const TopoDS_Edge& fromEdge,
282 TopTools_IndexedMapOfShape* chain=0);
283
294 bool FindMatchingNodesOnFaces( const TopoDS_Face& face1,
295 SMESH_Mesh* mesh1,
296 const TopoDS_Face& face2,
297 SMESH_Mesh* mesh2,
298 const TShapeShapeMap & assocMap,
299 TNodeNodeMap & nodeIn2OutMap);
306 TopoDS_Shape OuterShape( const TopoDS_Face& face,
307 TopAbs_ShapeEnum type);
308
315 bool MakeComputed(SMESH_subMesh * sm, const int iterationNb = 0);
316
320 std::string SourceNotComputedError( SMESH_subMesh * sm = 0,
321 SMESH_Algo* projAlgo=0);
322
330 TopoDS_Shape srcShape,
331 SMESH_Mesh* srcMesh);
332
336 TopoDS_Edge GetBoundaryEdge(const TopoDS_Shape& edgeContainer,
337 const SMESH_Mesh& mesh,
338 std::list< TopoDS_Edge >* allBndEdges = 0 );
339}
340
341#endif
Handle(SALOME_InteractiveObject) GeomSelectionTools
Return the first selected Salome Interactive Object (Handle(Salome_InteractiveObject))
Definition: GeomSelectionTools.cxx:97
#define STDMESHERS_EXPORT
Definition: SMESH_StdMeshers.hxx:38
std::vector< StdMeshers_FaceSidePtr > TSideVector
Definition: StdMeshers_FaceSide.hxx:57
boost::shared_ptr< StdMeshers_FaceSide > StdMeshers_FaceSidePtr
Definition: StdMeshers_FaceSide.hxx:56
Definition: SMDS_MeshNode.hxx:36
Root of all algorithms.
Definition: SMESH_Algo.hxx:79
Create a Delaunay triangulation of nodes on a face boundary and provide exploration of nodes shared b...
Definition: SMESH_Delaunay.hxx:46
Definition: SMESH_Hypothesis.hxx:48
Definition: SMESH_Mesh.hxx:80
It helps meshers to add elements and provides other utilities.
Definition: SMESH_MesherHelper.hxx:84
Definition: SMESH_subMesh.hxx:61
Create a Delaunay triangulation of nodes on a face boundary and provide exploration of nodes shared b...
Definition: StdMeshers_ProjectionUtils.hxx:156
virtual gp_XY getNodeUV(const TopoDS_Face &face, const SMDS_MeshNode *node) const
Definition: StdMeshers_ProjectionUtils.cxx:2964
bool _checkUV
Definition: StdMeshers_ProjectionUtils.hxx:171
Delaunay(const TSideVector &wires, bool checkUV=false)
Definition: StdMeshers_ProjectionUtils.cxx:2933
SMESH_MesherHelper * _helper
Definition: StdMeshers_ProjectionUtils.hxx:169
bool * _checkUVPtr
Definition: StdMeshers_ProjectionUtils.hxx:171
StdMeshers_FaceSidePtr _wire
Definition: StdMeshers_ProjectionUtils.hxx:170
Morph mesh on the target FACE to lie within FACE boundary w/o distortion.
Definition: StdMeshers_ProjectionUtils.hxx:180
bool Perform(SMESH_MesherHelper &tgtHelper, const TSideVector &tgtWires, Handle(ShapeAnalysis_Surface) tgtSurface, const TNodeNodeMap &src2tgtNodes, const bool moveAll)
Move non-marked target nodes.
Definition: StdMeshers_ProjectionUtils.cxx:2855
Morph(const TSideVector &srcWires)
triangulate the srcFace in 2D
Definition: StdMeshers_ProjectionUtils.cxx:2837
Delaunay _delaunay
Definition: StdMeshers_ProjectionUtils.hxx:181
SMESH_subMesh * _srcSubMesh
Definition: StdMeshers_ProjectionUtils.hxx:182
Finds transformation between two sets of 2D points using a least square approximation.
Definition: StdMeshers_ProjectionUtils.hxx:104
bool Solve(const std::vector< gp_XY > &srcPnts, const std::vector< gp_XY > &tgtPnts)
Computes transformation between two sets of 2D points using a least square approximation.
Definition: StdMeshers_ProjectionUtils.cxx:2618
gp_XY Transform(const gp_Pnt2d &srcUV) const
Transforms a 2D points using a found transformation.
Definition: StdMeshers_ProjectionUtils.cxx:2684
gp_XY _srcOrig
Definition: StdMeshers_ProjectionUtils.hxx:106
TrsfFinder2D()
Definition: StdMeshers_ProjectionUtils.hxx:108
bool IsIdentity() const
Definition: StdMeshers_ProjectionUtils.hxx:117
gp_GTrsf2d _trsf
Definition: StdMeshers_ProjectionUtils.hxx:105
void Set(const gp_GTrsf2d &t)
Definition: StdMeshers_ProjectionUtils.hxx:110
Finds transformation between two sets of 3D points using a least square approximation.
Definition: StdMeshers_ProjectionUtils.hxx:125
bool Solve(const std::vector< gp_XYZ > &srcPnts, const std::vector< gp_XYZ > &tgtPnts)
Computes transformation between two sets of 3D points using a least square approximation.
Definition: StdMeshers_ProjectionUtils.cxx:2701
TrsfFinder3D()
Definition: StdMeshers_ProjectionUtils.hxx:129
bool Invert()
Inversion.
Definition: StdMeshers_ProjectionUtils.cxx:2801
void Set(const gp_GTrsf &t)
Definition: StdMeshers_ProjectionUtils.hxx:131
gp_XYZ Transform(const gp_Pnt &srcP) const
Transforms a 3D point using a found transformation.
Definition: StdMeshers_ProjectionUtils.cxx:2778
bool IsIdentity() const
Definition: StdMeshers_ProjectionUtils.hxx:140
gp_GTrsf _trsf
Definition: StdMeshers_ProjectionUtils.hxx:126
gp_XYZ _srcOrig
Definition: StdMeshers_ProjectionUtils.hxx:127
gp_XYZ TransformVec(const gp_Vec &v) const
Transforms a 3D vector using a found transformation.
Definition: StdMeshers_ProjectionUtils.cxx:2791
Methods common to Projection algorithms.
Definition: StdMeshers_ProjectionUtils.cxx:2606
bool MakeComputed(SMESH_subMesh *sm, const int iterationNb=0)
Check that submeshis is computed and try to compute it if is not.
Definition: StdMeshers_ProjectionUtils.cxx:2304
TopoDS_Vertex GetNextVertex(const TopoDS_Edge &edge, const TopoDS_Vertex &vertex)
Return other vertex of an edge.
Definition: StdMeshers_ProjectionUtils.cxx:1832
bool FindMatchingNodesOnFaces(const TopoDS_Face &face1, SMESH_Mesh *mesh1, const TopoDS_Face &face2, SMESH_Mesh *mesh2, const TShapeShapeMap &assocMap, TNodeNodeMap &nodeIn2OutMap)
Find corresponding nodes on two faces.
Definition: StdMeshers_ProjectionUtils.cxx:1948
std::map< const SMDS_MeshNode *, const SMDS_MeshNode *, TIDCompare > TNodeNodeMap
Definition: StdMeshers_ProjectionUtils.hxx:95
StdMeshers_ShapeShapeBiDirectionMap TShapeShapeMap
Definition: StdMeshers_ProjectionUtils.hxx:92
TopoDS_Shape OuterShape(const TopoDS_Face &face, TopAbs_ShapeEnum type)
Return any sub-shape of a face belonging to the outer wire.
Definition: StdMeshers_ProjectionUtils.cxx:2286
int FindFaceAssociation(const TopoDS_Face &face1, TopoDS_Vertex VV1[2], const TopoDS_Face &face2, TopoDS_Vertex VV2[2], std::list< TopoDS_Edge > &edges1, std::list< TopoDS_Edge > &edges2, const bool isClosenessAssoc=false)
Find association of edges of faces.
Definition: StdMeshers_ProjectionUtils.cxx:1411
std::pair< int, TopoDS_Edge > GetPropagationEdge(SMESH_Mesh *aMesh, const TopoDS_Edge &anEdge, const TopoDS_Edge &fromEdge, TopTools_IndexedMapOfShape *chain=0)
Return an oriented propagation edge.
Definition: StdMeshers_ProjectionUtils.cxx:1856
TopoDS_Face GetNextFace(const TAncestorMap &edgeToFaces, const TopoDS_Edge &edge, const TopoDS_Face &face)
Return another face sharing an edge.
Definition: StdMeshers_ProjectionUtils.cxx:1810
bool FindSubShapeAssociation(const TopoDS_Shape &theShape1, SMESH_Mesh *theMesh1, const TopoDS_Shape &theShape2, SMESH_Mesh *theMesh2, TShapeShapeMap &theAssociationMap)
Looks for association of all sub-shapes of two shapes.
Definition: StdMeshers_ProjectionUtils.cxx:526
void InitVertexAssociation(const SMESH_Hypothesis *theHyp, TShapeShapeMap &theAssociationMap)
Insert vertex association defined by a hypothesis into a map.
Definition: StdMeshers_ProjectionUtils.cxx:1718
std::string SourceNotComputedError(SMESH_subMesh *sm=0, SMESH_Algo *projAlgo=0)
Returns an error message to show in case if MakeComputed( sm ) fails.
Definition: StdMeshers_ProjectionUtils.cxx:2420
bool InsertAssociation(const TopoDS_Shape &theShape1, const TopoDS_Shape &theShape2, TShapeShapeMap &theAssociationMap)
Inserts association theShape1 <-> theShape2 to TShapeShapeMap.
Definition: StdMeshers_ProjectionUtils.cxx:1756
TopTools_IndexedDataMapOfShapeListOfShape TAncestorMap
Definition: StdMeshers_ProjectionUtils.hxx:93
boost::shared_ptr< Delaunay > DelaunayPtr
Definition: StdMeshers_ProjectionUtils.hxx:173
TopoDS_Edge GetBoundaryEdge(const TopoDS_Shape &edgeContainer, const SMESH_Mesh &mesh, std::list< TopoDS_Edge > *allBndEdges=0)
Return a boundary EDGE (or all boundary EDGEs) of edgeContainer.
Definition: StdMeshers_ProjectionUtils.cxx:2456
TopoDS_Edge GetEdgeByVertices(SMESH_Mesh *aMesh, const TopoDS_Vertex &V1, const TopoDS_Vertex &V2)
Finds an edge by its vertices in a main shape of the mesh.
Definition: StdMeshers_ProjectionUtils.cxx:1782
void SetEventListener(SMESH_subMesh *subMesh, TopoDS_Shape srcShape, SMESH_Mesh *srcMesh)
Set event listeners to submesh with projection algo.
Definition: StdMeshers_ProjectionUtils.cxx:2546
Struct used instead of a sole TopTools_DataMapOfShapeShape to avoid problems with bidirectional bindi...
Definition: StdMeshers_ProjectionUtils.hxx:63
EAssocType _assocType
Definition: StdMeshers_ProjectionUtils.hxx:68
bool IsBound(const TopoDS_Shape &s, const bool isShape2=false) const
Definition: StdMeshers_ProjectionUtils.hxx:73
TopTools_DataMapOfShapeShape _map1to2
Definition: StdMeshers_ProjectionUtils.hxx:64
void Clear()
Definition: StdMeshers_ProjectionUtils.hxx:77
int Extent() const
Definition: StdMeshers_ProjectionUtils.hxx:76
TopTools_DataMapOfShapeShape _map2to1
Definition: StdMeshers_ProjectionUtils.hxx:64
const TopoDS_Shape & operator()(const TopoDS_Shape &s, const bool isShape2=false) const
Definition: StdMeshers_ProjectionUtils.hxx:78
StdMeshers_ShapeShapeBiDirectionMap()
Definition: StdMeshers_ProjectionUtils.hxx:83
bool Bind(const TopoDS_Shape &s1, const TopoDS_Shape &s2)
Definition: StdMeshers_ProjectionUtils.hxx:71
void SetAssocType(EAssocType type)
Definition: StdMeshers_ProjectionUtils.hxx:84
bool IsEmpty() const
Definition: StdMeshers_ProjectionUtils.hxx:75
EAssocType
Definition: StdMeshers_ProjectionUtils.hxx:66
@ PARTNER
Definition: StdMeshers_ProjectionUtils.hxx:67
@ CLOSE_VERTEX
Definition: StdMeshers_ProjectionUtils.hxx:67
@ UNDEF
Definition: StdMeshers_ProjectionUtils.hxx:67
@ FEW_EF
Definition: StdMeshers_ProjectionUtils.hxx:67
@ COMMON_VERTEX
Definition: StdMeshers_ProjectionUtils.hxx:67
@ INIT_VERTEX
Definition: StdMeshers_ProjectionUtils.hxx:67
@ PROPAGATION
Definition: StdMeshers_ProjectionUtils.hxx:67
Definition: SMDS_MeshElement.hxx:209