Version: 8.3.0
StdMeshers_ProjectionUtils.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, 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 calsses
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 
35 #include <TopTools_DataMapOfShapeShape.hxx>
36 #include <TopTools_IndexedMapOfShape.hxx>
37 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
38 #include <TopoDS_Edge.hxx>
39 #include <TopoDS_Face.hxx>
40 #include <TopoDS_Vertex.hxx>
41 #include <gp_GTrsf.hxx>
42 #include <gp_GTrsf2d.hxx>
43 
44 #include <list>
45 #include <map>
46 
47 class SMDS_MeshNode;
48 class SMESH_Algo;
49 class SMESH_Hypothesis;
50 class SMESH_Mesh;
51 class SMESH_subMesh;
52 class TopoDS_Shape;
53 
59 {
60  TopTools_DataMapOfShapeShape _map1to2, _map2to1;
61 
62  enum EAssocType {
65 
66  // convention: s1 - target, s2 - source
67  bool Bind( const TopoDS_Shape& s1, const TopoDS_Shape& s2 )
68  { _map1to2.Bind( s1, s2 ); return _map2to1.Bind( s2, s1 ); }
69  bool IsBound( const TopoDS_Shape& s, const bool isShape2=false ) const
70  { return (isShape2 ? _map2to1 : _map1to2).IsBound( s ); }
71  bool IsEmpty() const { return _map1to2.IsEmpty(); }
72  int Extent() const { return _map1to2.Extent(); }
73  void Clear() { _map1to2.Clear(); _map2to1.Clear(); }
74  const TopoDS_Shape& operator()( const TopoDS_Shape& s, const bool isShape2=false ) const
75  { // if we get a Standard_NoSuchObject here, it means that the calling code
76  // passes incorrect isShape2
77  return (isShape2 ? _map2to1 : _map1to2)( s );
78  }
80  void SetAssocType( EAssocType type ) { if ( _assocType == UNDEF ) _assocType = type; }
81 };
82 
86 namespace StdMeshers_ProjectionUtils
87 {
89  typedef TopTools_IndexedDataMapOfShapeListOfShape TAncestorMap;
90  typedef std::map<const SMDS_MeshNode*, const SMDS_MeshNode*,
92 
93 
99  {
100  gp_GTrsf2d _trsf;
101  gp_XY _srcOrig;
102  public:
104 
105  void Set( const gp_GTrsf2d& t ) { _trsf = t; } // it's an alternative to Solve()
106 
107  bool Solve( const std::vector< gp_XY >& srcPnts,
108  const std::vector< gp_XY >& tgtPnts );
109 
110  gp_XY Transform( const gp_Pnt2d& srcUV ) const;
111 
112  bool IsIdentity() const { return ( _trsf.Form() == gp_Identity ); }
113  };
119  {
120  gp_GTrsf _trsf;
121  gp_XYZ _srcOrig;
122  public:
123  TrsfFinder3D(): _srcOrig(0,0,0) {}
124 
125  void Set( const gp_GTrsf& t ) { _trsf = t; } // it's an alternative to Solve()
126 
127  bool Solve( const std::vector< gp_XYZ > & srcPnts,
128  const std::vector< gp_XYZ > & tgtPnts );
129 
130  gp_XYZ Transform( const gp_Pnt& srcP ) const;
131 
132  gp_XYZ TransformVec( const gp_Vec& v ) const;
133 
134  bool IsIdentity() const { return ( _trsf.Form() == gp_Identity ); }
135 
136  bool Invert();
137  };
138 
149  bool FindSubShapeAssociation(const TopoDS_Shape& theShape1,
150  SMESH_Mesh* theMesh1,
151  const TopoDS_Shape& theShape2,
152  SMESH_Mesh* theMesh2,
153  TShapeShapeMap & theAssociationMap);
154 
166  int FindFaceAssociation(const TopoDS_Face& face1,
167  TopoDS_Vertex VV1[2],
168  const TopoDS_Face& face2,
169  TopoDS_Vertex VV2[2],
170  std::list< TopoDS_Edge > & edges1,
171  std::list< TopoDS_Edge > & edges2,
172  const bool isClosenessAssoc=false);
173 
180  void InitVertexAssociation( const SMESH_Hypothesis* theHyp,
181  TShapeShapeMap & theAssociationMap);
182 
191  bool InsertAssociation( const TopoDS_Shape& theShape1, // target
192  const TopoDS_Shape& theShape2, // source
193  TShapeShapeMap & theAssociationMap);
194 
198  TopoDS_Edge GetEdgeByVertices( SMESH_Mesh* aMesh,
199  const TopoDS_Vertex& V1,
200  const TopoDS_Vertex& V2);
201 
206  TopoDS_Face GetNextFace( const TAncestorMap& edgeToFaces,
207  const TopoDS_Edge& edge,
208  const TopoDS_Face& face);
212  TopoDS_Vertex GetNextVertex(const TopoDS_Edge& edge,
213  const TopoDS_Vertex& vertex);
214 
223  std::pair<int,TopoDS_Edge> GetPropagationEdge( SMESH_Mesh* aMesh,
224  const TopoDS_Edge& anEdge,
225  const TopoDS_Edge& fromEdge,
226  TopTools_IndexedMapOfShape* chain=0);
227 
238  bool FindMatchingNodesOnFaces( const TopoDS_Face& face1,
239  SMESH_Mesh* mesh1,
240  const TopoDS_Face& face2,
241  SMESH_Mesh* mesh2,
242  const TShapeShapeMap & assocMap,
243  TNodeNodeMap & nodeIn2OutMap);
250  TopoDS_Shape OuterShape( const TopoDS_Face& face,
251  TopAbs_ShapeEnum type);
252 
259  bool MakeComputed(SMESH_subMesh * sm, const int iterationNb = 0);
260 
264  std::string SourceNotComputedError( SMESH_subMesh * sm = 0,
265  SMESH_Algo* projAlgo=0);
266 
273  void SetEventListener(SMESH_subMesh* subMesh,
274  TopoDS_Shape srcShape,
275  SMESH_Mesh* srcMesh);
276 
280  TopoDS_Edge GetBoundaryEdge(const TopoDS_Shape& edgeContainer,
281  const SMESH_Mesh& mesh,
282  std::list< TopoDS_Edge >* allBndEdges = 0 );
283 };
284 
285 #endif