Salome HOME
Revert "Synchronize adm files"
[plugins/hexoticplugin.git] / src / HexoticPlugin / HexoticPlugin_Hexotic.hxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // ---
21 // File   : HexoticPlugin_Hexotic.hxx
22 // Author : Lioka RAZAFINDRAZAKA (CEA)
23 // ---
24 //
25 #ifndef _HexoticPlugin_Hexotic_HXX_
26 #define _HexoticPlugin_Hexotic_HXX_
27
28 #include "HexoticPlugin_Defs.hxx"
29 #include "HexoticPlugin_Hypothesis.hxx"
30
31 #include "SMESH_Algo.hxx"
32 #include "SMESH_Mesh.hxx"
33 #include "Utils_SALOME_Exception.hxx"
34
35 #ifdef WITH_BLSURFPLUGIN
36 #include "BLSURFPlugin_Hypothesis.hxx"
37 #endif
38
39 #include <string>
40
41 #include "DriverGMF_Read.hxx"
42 #include "DriverGMF_Write.hxx"
43
44 #include <SALOMEconfig.h>
45 #include CORBA_CLIENT_HEADER(GEOM_Gen)
46 #include <SMESH_Gen_i.hxx>
47
48 class SMESH_Mesh;
49 class HexoticPlugin_Hypothesis;
50 class TCollection_AsciiString;
51 class gp_Pnt;
52
53 class HEXOTICPLUGIN_EXPORT HexoticPlugin_Hexotic: public SMESH_3D_Algo
54 {
55 public:
56   HexoticPlugin_Hexotic(int hypId, int studyId, SMESH_Gen* gen);
57   virtual ~HexoticPlugin_Hexotic();
58
59 #ifdef WITH_BLSURFPLUGIN
60   bool CheckBLSURFHypothesis(SMESH_Mesh&         aMesh,
61                              const TopoDS_Shape& aShape);
62 #endif
63
64   virtual bool CheckHypothesis(SMESH_Mesh&                          aMesh,
65                                const TopoDS_Shape&                  aShape,
66                                SMESH_Hypothesis::Hypothesis_Status& aStatus);
67
68   void SetParameters(const HexoticPlugin_Hypothesis* hyp);
69
70   virtual bool Compute(SMESH_Mesh& aMesh,  const TopoDS_Shape& aShape);
71
72   virtual bool Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper);
73
74     virtual void CancelCompute();
75     bool computeCanceled() { return _compute_canceled;};
76
77   virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
78                         MapShapeNbElems& aResMap);
79
80 protected:
81   const HexoticPlugin_Hypothesis* _hypothesis;
82
83 private:
84
85   std::string getHexoticCommand(const TCollection_AsciiString& Hexotic_In,
86                                 const TCollection_AsciiString& Hexotic_Out,
87                                 const TCollection_AsciiString& Hexotic_Sol) const;
88   
89   GEOM::GEOM_Object_var entryToGeomObj(std::string entry);
90   TopoDS_Shape     entryToShape(std::string entry);
91
92   std::vector<std::string> writeSizeMapFile(std::string fileName);
93   
94   // Functions to get sample point from shapes
95   void createControlPoints( const TopoDS_Shape& theShape, 
96                             const double& theSize, 
97                             std::vector< Control_Pnt >& thePoints );
98   void createPointsSampleFromEdge( const TopoDS_Shape& aShape, 
99                                    const double& theSize, 
100                                    std::vector<Control_Pnt>& thePoints );
101   void createPointsSampleFromFace( const TopoDS_Shape& aShape, 
102                                    const double& theSize, 
103                                    std::vector<Control_Pnt>& thePoints );
104   void createPointsSampleFromSolid( const TopoDS_Shape& aShape, 
105                                     const double& theSize, 
106                                     std::vector<Control_Pnt>& thePoints );
107   
108   // Some functions for surface sampling
109   void subdivideTriangle( const gp_Pnt& p1, 
110                           const gp_Pnt& p2, 
111                           const gp_Pnt& p3, 
112                           const double& theSize, 
113                           std::vector<Control_Pnt>& thePoints );
114   
115   std::vector<gp_Pnt> computePointsForSplitting( const gp_Pnt& p1, 
116                                                  const gp_Pnt& p2, 
117                                                  const gp_Pnt& p3 );
118   gp_Pnt tangencyPoint(const gp_Pnt& p1, 
119                        const gp_Pnt& p2, 
120                        const gp_Pnt& Center);
121   
122
123   int  _iShape;
124   int  _nbShape;
125   int  _hexesMinLevel;
126   int  _hexesMaxLevel;
127   double _hexesMinSize;
128   double _hexesMaxSize;
129   bool _hexoticIgnoreRidges;
130   bool _hexoticInvalidElements;
131   bool _hexoticFilesKept;
132   int  _hexoticSharpAngleThreshold;
133   int  _hexoticNbProc;
134   std::string  _hexoticWorkingDirectory;
135   int _hexoticVerbosity;
136   int _hexoticMaxMemory;
137   int _hexoticSdMode;
138   HexoticPlugin_Hypothesis::THexoticSizeMaps _sizeMaps;
139   SMDS_MeshNode** _tabNode;
140   
141 #ifdef WITH_BLSURFPLUGIN
142   const BLSURFPlugin_Hypothesis* _blsurfHypo;
143 #endif
144
145
146   volatile bool _compute_canceled;
147   
148   SALOMEDS::Study_var myStudy;
149   SMESH_Gen_i*        smeshGen_i;
150
151 };
152
153 #endif