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
21 // File : BLSURFPlugin_BLSURF.hxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #ifndef _BLSURFPlugin_BLSURF_HXX_
28 #define _BLSURFPlugin_BLSURF_HXX_
31 #include <TopoDS_Vertex.hxx>
32 #include <TopoDS_Edge.hxx>
33 #include <TopoDS_Wire.hxx>
34 #include <TopoDS_Face.hxx>
35 #include <TopoDS_Shape.hxx>
38 #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
40 // rnv: avoid compilation warning on Linux : "_POSIX_C_SOURCE" and "_XOPEN_SOURCE" are redefined
41 #ifdef _POSIX_C_SOURCE
42 #undef _POSIX_C_SOURCE
50 #include <SMESH_Algo.hxx>
51 #include <SMESH_Mesh.hxx>
52 #include <SMESHDS_Mesh.hxx>
53 #include <SMDS_MeshElement.hxx>
54 #include <SMDS_MeshNode.hxx>
55 #include <SMESH_Gen_i.hxx>
56 #include <StdMeshers_ViscousLayers2D.hxx>
57 #include <SALOMEconfig.h>
58 #include CORBA_CLIENT_HEADER(SALOMEDS)
59 #include CORBA_CLIENT_HEADER(GEOM_Gen)
60 #include "Utils_SALOME_Exception.hxx"
63 #include <meshgems/meshgems.h>
64 #include <meshgems/cadsurf.h>
67 #include <BRepClass_FaceClassifier.hxx>
68 #include <BRepAdaptor_Surface.hxx>
69 #include <BRepTools.hxx>
70 #include <BRepAdaptor_HSurface.hxx>
72 #include "BLSURFPlugin_Hypothesis.hxx"
76 class BLSURFPlugin_BLSURF: public SMESH_2D_Algo
79 BLSURFPlugin_BLSURF(int hypId, SMESH_Gen* gen, bool theHasGEOM);
81 virtual ~BLSURFPlugin_BLSURF();
83 virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
84 const TopoDS_Shape& aShape,
85 SMESH_Hypothesis::Hypothesis_Status& aStatus);
87 void SetParameters(const BLSURFPlugin_Hypothesis* hyp, cadsurf_session_t *css, const TopoDS_Shape& shape);
89 virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
90 virtual bool Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper);
92 virtual void CancelCompute();
93 bool computeCanceled() { return _compute_canceled; }
95 virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
96 MapShapeNbElems& aResMap);
98 static void FillEntryToShape( const BLSURFPlugin_Hypothesis* hyp,
99 std::map< std::string, TopoDS_Shape > & s2eMap );
101 virtual void SetEventListener(SMESH_subMesh* subMesh) override;
102 virtual void SubmeshRestored(SMESH_subMesh* subMesh) override;
107 typedef std::vector<int> TListOfIDs;
109 // PreCad Edges periodicity
110 struct TPreCadPeriodicityIDs {
111 TListOfIDs shape1IDs;
112 TListOfIDs shape2IDs;
113 std::vector<double> theSourceVerticesCoords;
114 std::vector<double> theTargetVerticesCoords;
118 struct TEdgePeriodicityIDs {
123 int edge_orientation;
126 // Vertex periodicity
127 struct TVertexPeriodicityIDs {
134 // Vector of pairs of ids
135 typedef std::vector< TPreCadPeriodicityIDs > TPreCadIDsPeriodicityVector;
136 typedef std::vector< std::pair<int, int> > TShapesIDsPeriodicityVector;
137 typedef std::vector< TEdgePeriodicityIDs > TEdgesIDsPeriodicityVector;
138 typedef std::vector< TVertexPeriodicityIDs > TVerticesIDsPeriodicityVector;
140 // Point projection on FACE
147 static projectionPoint getProjectionPoint(TopoDS_Face& theFace,
148 const gp_Pnt& thePoint,
149 const bool theAllowStateON=false);
153 const BLSURFPlugin_Hypothesis* _hypothesis;
154 bool _haveViscousLayers;
156 TPreCadIDsPeriodicityVector _preCadFacesIDsPeriodicityVector;
157 TPreCadIDsPeriodicityVector _preCadEdgesIDsPeriodicityVector;
160 bool compute(SMESH_Mesh& aMesh,
161 const TopoDS_Shape& aShape,
162 bool allowSubMeshClearing);
164 void set_param(cadsurf_session_t *css,
165 const char * option_name,
166 const char * option_value);
168 TopoDS_Shape entryToShape(std::string entry);
169 void addCoordsFromVertices(const std::vector<std::string> &theVerticesEntries, std::vector<double> &theVerticesCoords);
170 void addCoordsFromVertex(BLSURFPlugin_Hypothesis::TEntry theVertexEntry, std::vector<double> &theVerticesCoords);
171 void createEnforcedVertexOnFace(TopoDS_Shape FaceShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList);
172 void createPreCadFacesPeriodicity(TopoDS_Shape theGeomShape, const BLSURFPlugin_Hypothesis::TPreCadPeriodicity &preCadPeriodicity);
173 void createPreCadEdgesPeriodicity(TopoDS_Shape theGeomShape, const BLSURFPlugin_Hypothesis::TPreCadPeriodicity &preCadPeriodicity);
174 void Set_NodeOnEdge(SMESHDS_Mesh* meshDS, const SMDS_MeshNode* node, const TopoDS_Shape& ed);
175 void BRepClass_FaceClassifierPerform(BRepClass_FaceClassifier* fc, const TopoDS_Face& face, const gp_Pnt& P, const Standard_Real Tol);
179 PyObject * main_dict;
181 volatile bool _compute_canceled;