1 // Copyright (C) 2007-2021 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 // SMESH SMESH : implementation of SMESH idl descriptions
24 // File : StdMeshers_BlockRenumber.hxx
25 // Author : Edward AGAPOV, OCC
28 #ifndef _SMESH_BlockRenumber_HXX_
29 #define _SMESH_BlockRenumber_HXX_
31 #include "SMESH_StdMeshers.hxx"
33 #include "SMESH_ComputeError.hxx"
34 #include "SMESH_Hypothesis.hxx"
35 #include "SMESH_MeshEditor.hxx"
37 #include <NCollection_DataMap.hxx>
38 #include <TopTools_MapOfShape.hxx>
39 #include <TopoDS_Vertex.hxx>
41 #include <boost/serialization/vector.hpp>
49 // =========================================================
50 struct StdMeshers_BlockCS // Local coordinate system of a block
53 std::string _vertex000;
54 std::string _vertex001;
56 bool operator==( const StdMeshers_BlockCS& other ) const
58 return ( _solid == other._solid &&
59 _vertex000 == other._vertex000 &&
60 _vertex001 == other._vertex001 );
64 // =========================================================
66 * \class 3D Hypothesis used by Hexahedron(ijk) algorithm
67 * to renumber mesh of a block to be structured-like
69 // =========================================================
71 class STDMESHERS_EXPORT StdMeshers_BlockRenumber : public SMESH_Hypothesis
74 StdMeshers_BlockRenumber(int hypId, SMESH_Gen * gen);
76 void SetBlocksOrientation( std::vector< StdMeshers_BlockCS > & blockCS );
78 const std::vector< StdMeshers_BlockCS > & GetBlocksOrientation() const { return _blockCS; }
80 virtual std::ostream & SaveTo(std::ostream & save) override;
81 virtual std::istream & LoadFrom(std::istream & load) override;
84 * \brief Initialize Fineness by the mesh built on the geometry
85 * \param theMesh - the built mesh
86 * \param theShape - the geometry of interest
87 * \retval bool - true if parameter values have been successfully defined
89 bool SetParametersByMesh(const SMESH_Mesh* /*mesh*/, const TopoDS_Shape& /*shape*/) override
93 * \brief Initialize my parameter values by default parameters.
94 * \retval bool - true if parameter values have been successfully defined
96 bool SetParametersByDefaults(const TDefaults& /*dflts*/, const SMESH_Mesh* /*mesh*/=0) override
102 * \brief Check validity of parameter
104 SMESH_ComputeErrorPtr CheckHypothesis(SMESH_Mesh& theMesh, const TopoDS_Shape& theShape) const;
107 * \brief Return true and vertices if block orientation is defined for a given solid
109 bool IsSolidIncluded( SMESH_Mesh& mesh,
110 const TopoDS_Shape& solid,
111 TopoDS_Vertex& vertex000,
112 TopoDS_Vertex& vertex001 ) const;
116 // Persistence: define both input and output at once
117 friend class boost::serialization::access;
118 template<class Archive> void serialize( Archive & ar, const unsigned int /*version*/ )
125 std::vector< StdMeshers_BlockCS > _blockCS;
127 typedef NCollection_DataMap< TopoDS_Shape, std::pair< TopoDS_Vertex, TopoDS_Vertex > > TSolid2VV;
128 TSolid2VV _solids2vertices; // shapes defined by _blockCS, non-persistent
131 // =========================================================
133 * \brief Help in using StdMeshers_BlockRenumber
135 class StdMeshers_RenumberHelper
139 StdMeshers_RenumberHelper( SMESH_Mesh& mesh,
140 const StdMeshers_BlockRenumber* hyp);
142 * \brief Find default vertex at (0,0,0) local position
144 static TopoDS_Vertex GetVertex000( const TopTools_MapOfShape& cornerVertices );
147 * \brief Find a vertex of a solid located at the given point
149 static TopoDS_Vertex GetVertexAtPoint( const TopoDS_Shape& solid, const TopoDS_Shape& point );
152 * \brief Create a copy of an old node and remember this couple of nodes for replacement
154 void AddReplacingNode( const SMDS_MeshNode* & oldNode );
157 * \brief Replace old nodes by new ones
159 void DoReplaceNodes();
164 const StdMeshers_BlockRenumber* _hyp;
166 SMESH_MeshEditor::TListOfListOfNodes _nodesToMerge;
167 std::list< const SMDS_MeshNode* > _newOldNodes;