Salome HOME
Merge branch 'master' into gni/adaptation
[modules/smesh.git] / idl / SMESH_Gen.idl
1 // Copyright (C) 2007-2020  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 //  File   : SMESH_Gen.idl
23 //  Author : Paul RASCLE, EDF
24
25 #ifndef _SMESH_GEN_IDL_
26 #define _SMESH_GEN_IDL_
27
28 #include "SALOME_Exception.idl"
29 #include "SALOME_Component.idl"
30 #include "SALOMEDS.idl"
31
32 #include "GEOM_Gen.idl"
33
34 #include "SMESH_Mesh.idl"
35 #include "SMESH_Hypothesis.idl"
36
37 module SMESH
38 {
39   typedef sequence<SALOMEDS::SObject> sobject_list;
40   typedef sequence<GEOM::GEOM_Object> object_array;
41   typedef sequence<SMESH_Mesh>        mesh_array;
42
43   interface FilterManager;
44   interface SMESH_Pattern;
45   interface Measurements;
46   interface MG_ADAPT;
47   interface MG_ADAPT_OBJECT;
48
49   /*!
50    * Tags definition
51    */
52   // Top level
53   const long Tag_HypothesisRoot = 1; // hypotheses root
54   const long Tag_AlgorithmsRoot = 2; // algorithms root
55   const long Tag_FirstMeshRoot  = 3; // first mesh root
56   // Mesh/Submesh
57   const long Tag_RefOnShape             = 1; // references to shape
58   const long Tag_RefOnAppliedHypothesis = 2; // applied hypotheses root
59   const long Tag_RefOnAppliedAlgorithms = 3; // applied algorithms root
60   // Mesh only: sub-meshes roots by type
61   const long Tag_FirstSubMesh           =  4;
62   const long Tag_SubMeshOnVertex        =  4;
63   const long Tag_SubMeshOnEdge          =  5;
64   const long Tag_SubMeshOnWire          =  6;
65   const long Tag_SubMeshOnFace          =  7;
66   const long Tag_SubMeshOnShell         =  8;
67   const long Tag_SubMeshOnSolid         =  9;
68   const long Tag_SubMeshOnCompound      = 10;
69   const long Tag_LastSubMesh            = 10;
70   // Mesh only: group roots by type
71   const long Tag_FirstGroup             = 11;
72   const long Tag_NodeGroups             = 11;
73   const long Tag_EdgeGroups             = 12;
74   const long Tag_FaceGroups             = 13;
75   const long Tag_VolumeGroups           = 14;
76   const long Tag_0DElementsGroups       = 15;
77   const long Tag_BallElementsGroups     = 16;
78   const long Tag_LastGroup              = 16;
79
80   /*!
81    * Hypothesis definition error
82    */
83   struct AlgoStateError
84   {
85     Hypothesis_Status  state;
86     string             algoName;
87     long               algoDim;
88     boolean            isGlobalAlgo;
89   };
90   typedef sequence<AlgoStateError> algo_error_array;
91
92   /*!
93    * Mesh computation error
94    */
95   enum ComputeErrorName
96   {
97     COMPERR_OK            ,
98     COMPERR_BAD_INPUT_MESH,  // wrong mesh on lower submesh
99     COMPERR_STD_EXCEPTION ,  // some std exception raised
100     COMPERR_OCC_EXCEPTION ,  // OCC exception raised
101     COMPERR_SLM_EXCEPTION ,  // SALOME exception raised
102     COMPERR_EXCEPTION     ,  // other exception raised
103     COMPERR_MEMORY_PB     ,  // memory allocation problem
104     COMPERR_ALGO_FAILED   ,  // computation failed
105     COMPERR_BAD_SHAPE     ,  // bad geometry
106     COMPERR_WARNING       ,  // algo reports error but sub-mesh is computed anyway
107     COMPERR_CANCELED      ,  // compute canceled
108     COMPERR_NO_MESH_ON_SHAPE,// no mesh elements assigned to sub-mesh
109     COMPERR_BAD_PARMETERS    // incorrect hypotheses parameters
110   };
111   struct ComputeError
112   {
113     short   code;       // ComputeErrorName or, if negative, algo specific code
114     string  comment;    // textual problem description
115     string  algoName;
116     short   subShapeID; // id of sub-shape of a shape to mesh
117     boolean hasBadMesh; // there are elements preventing computation available for visualization
118   };
119   typedef sequence<ComputeError> compute_error_array;
120
121   /*!
122    * Way to initialize hypothesis
123    */
124   struct HypInitParams
125   {
126     short   way; // 0 - by mesh, 1 - by geometry size + preferred parameters, 2 - by averageLength
127     double  averageLength;
128     boolean quadDominated;
129   };
130
131   interface SMESH_Gen : Engines::EngineComponent, SALOMEDS::Driver
132   {
133     //GEOM::GEOM_Gen SetGeomEngine( in string containerLoc );
134     void SetGeomEngine( in GEOM::GEOM_Gen geomcompo );
135
136     FilterManager CreateFilterManager();
137
138     SMESH_Pattern GetPattern();
139
140     Measurements  CreateMeasurements();
141     /*!
142       Set the current mode
143      */
144     void SetEmbeddedMode( in boolean theMode );
145
146     /*!
147       Get the current mode
148      */
149     boolean IsEmbeddedMode();
150
151     /*!
152       Update the study
153      */
154     void UpdateStudy();
155     
156     /*!
157       Set enable publishing in the study
158      */
159     void SetEnablePublish( in boolean theIsEnablePublish );
160     
161     /*!
162       Get enable publishing in the study
163      */
164     boolean IsEnablePublish();
165
166     /*!
167      * Create a hypothesis that can be shared by different parts of the mesh.
168      * An hypothesis is either:
169      * - a method used to generate or modify a part of the mesh (algorithm).
170      * - a parameter or a law used by an algorithm.
171      * Algorithms are 1D, 2D or 3D.
172      */
173     SMESH_Hypothesis CreateHypothesis( in string theHypName,
174                                        in string theLibName )
175       raises ( SALOME::SALOME_Exception );
176
177     /*!
178      * Create a hypothesis and initialize it by average length
179      */
180     SMESH_Hypothesis CreateHypothesisByAverageLength( in string  theHypName,
181                                                       in string  theLibName,
182                                                       in double  theAverageLength,
183                                                       in boolean theQuadDominated)
184       raises ( SALOME::SALOME_Exception );
185
186     /*!
187      * Return a hypothesis holding parameter values corresponding either to the mesh
188      * existing on the given geometry or to size of the geometry.
189      * The returned hypothesis may be the one existing in a study and used
190      * to compute the mesh, or a temporary one created just to pass parameter
191      * values.
192      */
193     SMESH_Hypothesis GetHypothesisParameterValues( in string            theHypName,
194                                                    in string            theLibName,
195                                                    in SMESH_Mesh        theMesh,
196                                                    in GEOM::GEOM_Object theGeom,
197                                                    in HypInitParams     theWay)
198       raises ( SALOME::SALOME_Exception );
199
200     /*!
201      * Returns \c True if a hypothesis is assigned to a sole sub-mesh in a current Study
202      *  \param [in] theHyp - the hypothesis of interest
203      *  \param [out] theMesh - the sole mesh using \a theHyp
204      *  \param [out] theShape - the sole geometry \a theHyp is assigned to
205      *  \return boolean - \c True if \a theMesh and \a theShape are sole using \a theHyp
206      */
207     boolean GetSoleSubMeshUsingHyp( in SMESH_Hypothesis   theHyp,
208                                     out SMESH_Mesh        theMesh,
209                                     out GEOM::GEOM_Object theShape);
210
211     /*!
212      * Sets number of segments per diagonal of boundary box of geometry by which
213      * default segment length of appropriate 1D hypotheses is defined
214      */
215     void SetBoundaryBoxSegmentation( in long theNbSegments ) raises ( SALOME::SALOME_Exception );
216     /*!
217      * \brief Sets default number of segments per edge
218      */
219     void SetDefaultNbSegments( in long theNbSegments) raises ( SALOME::SALOME_Exception );
220
221     /*!
222      * Set the object name
223      */
224     void SetName( in string theObjectIOR,
225                   in string theObjectName )
226       raises ( SALOME::SALOME_Exception );
227
228     /*!
229      * Create a Mesh object, given a geometry shape.
230      * Mesh is created empty (no points, no elements).
231      * Shape is explored via GEOM_Client to create local copies.
232      * of TopoDS_Shapes and bind CORBA references of shape & subshapes
233      * with TopoDS_Shapes
234      */
235     SMESH_Mesh CreateMesh( in GEOM::GEOM_Object theObject )
236       raises ( SALOME::SALOME_Exception );
237
238     /*!
239      * Create an empty mesh object
240      */
241     SMESH_Mesh CreateEmptyMesh()
242       raises ( SALOME::SALOME_Exception );
243
244     /*!
245      * Create Mesh object importing data from given UNV file
246      * (UNV supported version is I-DEAS 10)
247      */
248     SMESH_Mesh CreateMeshesFromUNV( in string theFileName )
249       raises ( SALOME::SALOME_Exception );
250
251     /*!
252      * Create Mesh object(s) importing data from given MED file
253      */
254      mesh_array CreateMeshesFromMED( in string theFileName,
255                                      out SMESH::DriverMED_ReadStatus theStatus )
256        raises ( SALOME::SALOME_Exception );
257
258     /*!
259      * Create Mesh object(s) importing data from given MED file
260      */
261      mesh_array CreateMeshesFromSAUV( in string theFileName,
262                                       out SMESH::DriverMED_ReadStatus theStatus )
263        raises ( SALOME::SALOME_Exception );
264
265     /*!
266      * Create Mesh object importing data from given STL file
267      */
268     SMESH_Mesh CreateMeshesFromSTL( in string theFileName )
269       raises ( SALOME::SALOME_Exception );
270
271     /*!
272      * Create Mesh object(s) importing data from given CGNS file
273      */
274     mesh_array CreateMeshesFromCGNS( in string theFileName,
275                                      out SMESH::DriverMED_ReadStatus theStatus )
276       raises ( SALOME::SALOME_Exception );
277
278     /*!
279      * Create Mesh object importing data from given GMF file
280      *  \param theFileName - a name of file to import
281      *  \param theMakeRequiredGroups - if true, groups of required entities will be created
282      */
283     SMESH_Mesh CreateMeshesFromGMF( in string               theFileName,
284                                     in boolean              theMakeRequiredGroups,
285                                     out SMESH::ComputeError theError)
286       raises ( SALOME::SALOME_Exception );
287
288     /*!
289      * Create a mesh by copying a part of another mesh
290      *  \param meshPart - a part of mesh to copy
291      *  \param meshName - a name of the new mesh
292      *  \param toCopyGroups - to create in the new mesh groups
293      *                        the copied elements belongs to
294      *  \param toKeepIDs - to preserve IDs of the copied elements or not
295      */
296     SMESH_Mesh CopyMesh(in SMESH_IDSource meshPart,
297                         in string         meshName,
298                         in boolean        toCopyGroups,
299                         in boolean        toKeepIDs)
300       raises ( SALOME::SALOME_Exception );
301
302     /*!
303      * Create a mesh by copying definitions of another mesh to a given geometry
304      *  \param sourceMesh - a mesh to copy
305      *  \param newGeometry - a new geometry
306      *  \param meshName - a name of the new mesh
307      *  \param toCopyGroups - to create groups in the new mesh
308      *  \param toReuseHypotheses - if True, existing hypothesis will be used by the new mesh, 
309      *         otherwise new hypotheses with the same parameters will be created for the new mesh.
310      *  \param toCopyElements - to copy mesh elements of same sub-shapes of the two geometries
311      *  \param newMesh - return a new mesh
312      *  \param newGroups - return new groups
313      *  \param newSubmeshes - return new sub-meshes
314      *  \param newHypotheses - return new algorithms and hypotheses
315      *  \param invalidEntries - return study entries of objects whose
316      *         counterparts are not found in the newGeometry, followed by entries
317      *         of mesh sub-objects that are invalid because they depend on a not found
318      *         preceding sub-shape
319      */
320     boolean CopyMeshWithGeom( in SMESH_Mesh        sourceMesh,
321                               in GEOM::GEOM_Object newGeometry,
322                               in string            meshName,
323                               in boolean           toCopyGroups,
324                               in boolean           toReuseHypotheses,
325                               in boolean           toCopyElements,
326                               out SMESH_Mesh       newMesh,
327                               out ListOfGroups     newGroups,
328                               out submesh_array    newSubmeshes,
329                               out ListOfHypothesis newHypotheses,
330                               out string_array     invalidEntries)
331       raises ( SALOME::SALOME_Exception );
332
333     /*!
334      * Concatenate the given meshes or groups into one mesh,
335      * optionally to theMeshToAppendTo.
336      * Union groups with the same name and type if
337      * theUniteIdenticalGroups flag is true.
338      * Merge coincident nodes and elements if
339      * theMergeNodesAndElements flag is true.
340      */
341     SMESH_Mesh Concatenate(in ListOfIDSources theMeshesArray,
342                            in boolean         theUniteIdenticalGroups,
343                            in boolean         theMergeNodesAndElements,
344                            in double          theMergeTolerance,
345                            in SMESH_Mesh      theMeshToAppendTo)
346       raises ( SALOME::SALOME_Exception );
347
348     /*!
349      * Concatenate the given meshes into one mesh,
350      * optionally to theMeshToAppendTo.
351      * Union groups with the same name and type if
352      * theUniteIdenticalGroups flag is true.
353      * Merge coincident nodes and elements if
354      * theMergeNodesAndElements flag is true.
355      * Create the groups of all elements from initial meshes.
356      */
357     SMESH_Mesh ConcatenateWithGroups(in ListOfIDSources theMeshesArray,
358                                      in boolean         theUniteIdenticalGroups,
359                                      in boolean         theMergeNodesAndElements,
360                                      in double          theMergeTolerance,
361                                      in SMESH_Mesh      theMeshToAppendTo)
362       raises ( SALOME::SALOME_Exception );
363
364     /*!
365      * Mesh a subShape.
366      * First, verify list of hypothesis associated with the Sub-shape,
367      * return NOK if hypothesis are not sufficient
368      */
369     boolean Compute( in SMESH_Mesh        theMesh,
370                      in GEOM::GEOM_Object theSubObject )
371       raises ( SALOME::SALOME_Exception );
372
373     /*!
374      * Cancel a computation.
375      */
376     void CancelCompute( in SMESH_Mesh        theMesh,
377                         in GEOM::GEOM_Object theSubObject );
378
379     /*!
380      * Return true if hypotheses are defined well
381      */
382     boolean IsReadyToCompute( in SMESH_Mesh        theMesh,
383                               in GEOM::GEOM_Object theSubObject )
384       raises ( SALOME::SALOME_Exception );
385
386     /*!
387      * Evaluates size of prospective mesh on a shape
388      */
389     long_array  Evaluate(in SMESH_Mesh        theMesh,
390                          in GEOM::GEOM_Object theSubObject)
391       raises ( SALOME::SALOME_Exception );
392
393     /*!
394      * Calculate Mesh as preview till indicated dimension
395      * First, verify list of hypothesis associated with the Sub-shape.
396      * Return mesh preview structure
397      */
398     MeshPreviewStruct Precompute( in SMESH_Mesh        theMesh,
399                                   in GEOM::GEOM_Object theSubObject,
400                                   in Dimension         theDimension,
401                                   inout long_array    theShapesId )
402       raises ( SALOME::SALOME_Exception );
403
404     /*!
405      * Return errors of hypotheses definition
406      * algo_error_array is empty if everything is OK
407      */
408     algo_error_array GetAlgoState( in SMESH_Mesh        theMesh,
409                                    in GEOM::GEOM_Object theSubObject )
410       raises ( SALOME::SALOME_Exception );
411
412     /*!
413      * Return errors of mesh computation
414      * compute_error_array is empty if everything is OK
415      */
416     compute_error_array GetComputeErrors( in SMESH_Mesh        theMesh,
417                                           in GEOM::GEOM_Object theSubObject )
418       raises ( SALOME::SALOME_Exception );
419
420     /*!
421      * Return mesh elements preventing computation of a sub-shape
422      */
423     MeshPreviewStruct GetBadInputElements( in SMESH_Mesh theMesh,
424                                            in short      theSubShapeID )
425       raises ( SALOME::SALOME_Exception );
426
427     /*!
428      * Create groups of elements preventing computation of a sub-shape
429      */
430     SMESH::ListOfGroups MakeGroupsOfBadInputElements( in SMESH_Mesh theMesh,
431                                                       in short      theSubShapeID,
432                                                       in string     theGroupName)
433       raises ( SALOME::SALOME_Exception );
434
435     /*!
436      * Return indices of faces, edges and vertices of given sub-shapes
437      * within theMainObject
438      */
439     long_array GetSubShapesId( in GEOM::GEOM_Object theMainObject,
440                                in object_array      theListOfSubObjects )
441        raises ( SALOME::SALOME_Exception );
442
443     /*!
444      * Return geometrical object the given element is built on.
445      * The returned geometrical object, if not nil, is either found in the
446      * study or is published by this method with the given name
447      */
448     GEOM::GEOM_Object GetGeometryByMeshElement( in SMESH_Mesh  theMesh,
449                                                 in long        theElementID,
450                                                 in string      theGeomName)
451       raises ( SALOME::SALOME_Exception );
452
453     /*!
454      * Return geometrical object the given element is built on.
455      * The returned geometrical object not published in study by this method.
456      */
457     GEOM::GEOM_Object FindGeometryByMeshElement( in SMESH_Mesh  theMesh,
458                                                  in long        theElementID)
459       raises ( SALOME::SALOME_Exception );
460
461     /*!
462      * \brief Return id of object, registered in current study context
463      *
464      * Can be used to check if the object was created in the same container, as this engine.
465      */
466     long GetObjectId(in Object theObject);
467
468     /*!
469      * \brief Get version of MED format being used.
470      */
471     string GetMEDFileVersion();
472
473     /*!
474      * \brief Get MED version of the file by its name.
475      */
476     string GetMEDVersion(in string theFileName);
477
478     /*!
479      * \brief Check compatibility of file with MED format being used, for read only.
480      */
481     boolean CheckCompatibility(in string theFileName);
482
483     /*!
484      * \brief Check compatibility of file with MED format being used, for append on write.
485      */
486     boolean CheckWriteCompatibility(in string theFileName);
487
488     /*!
489      * \brief Get names of meshes defined in file with the specified name.
490      */
491     string_array GetMeshNames(in string theFileName);
492
493     /*!
494      * \brief Moves objects to the specified position
495      *  \param what objects being moved
496      *  \param where parent object where objects are moved to
497      *  \param row position in the parent object's children list at which objects are moved
498      *
499      * This function is used in the drag-n-drop functionality.
500      */
501     void Move( in sobject_list what,
502                in SALOMEDS::SObject where,
503                in long row );
504     /*!
505      * Returns true if algorithm can be used to mesh a given geometry
506      *  \param theAlgoType - the algorithm type
507      *  \param theLibName - a name of the Plug-in library implementing the algorithm
508      *  \param theShapeObject - the geometry to mesh
509      *  \param toCheckAll - if \c True, returns \c True if all shapes are meshable,
510      *         else, returns \c True if at least one shape is meshable
511      */
512     boolean IsApplicable( in string             theAlgoType,
513                           in string             theLibName,
514                           in GEOM::GEOM_Object  theShapeObject,
515                           in boolean            toCheckAll );
516
517
518     /*!
519      * Return indices of elements, which are located inside the sphere
520      *  \param theSource - mesh, sub-mesh or group
521      *  \param theElemType - mesh element type
522      *  \param theX - x coordinate of the center of the sphere
523      *  \param theY - y coordinate of the center of the sphere
524      *  \param theZ - y coordinate of the center of the sphere
525      *  \param theR - radius of the sphere
526      */
527     long_array GetInsideSphere( in SMESH_IDSource theSource,
528                                 in ElementType    theElemType,
529                                 in double theX, 
530                                 in double theY, 
531                                 in double theZ,
532                                 in double theR );    
533
534     /*!
535      * Return indices of elements, which are located inside the box
536      *  \param theSource - mesh, sub-mesh or group
537      *  \param theElemType - mesh element type
538      *  \param theX1 - x coordinate of the first opposite point
539      *  \param theY1 - y coordinate of the first opposite point
540      *  \param theZ1 - y coordinate of the first opposite point
541      *  \param theX2 - x coordinate of the second opposite point
542      *  \param theY2 - y coordinate of the second opposite point
543      *  \param theZ2 - y coordinate of the second opposite point
544      */
545     long_array GetInsideBox( in SMESH_IDSource theSource,
546                              in ElementType    theElemType,
547                              in double theX1, 
548                              in double theY1, 
549                              in double theZ1,
550                              in double theX2,
551                              in double theY2,
552                              in double theZ2);    
553     /*!
554      * Return indices of elements, which are located inside the box
555      *  \param theSource - mesh, sub-mesh or group
556      *  \param theElemType - mesh element type
557      *  \param theX - x coordinate of the cented of the bottom face
558      *  \param theY - y coordinate of the cented of the bottom face
559      *  \param theZ - y coordinate of the cented of the bottom face
560      *  \param theDX - x coordinate of the cented of the base vector
561      *  \param theDY - y coordinate of the cented of the base vector
562      *  \param theDZ - z coordinate of the cented of the base vector
563      *  \param theH - height of the cylinder
564      *  \param theR - radius of the cylinder
565      */
566     long_array GetInsideCylinder( in SMESH_IDSource theSource,
567                                   in ElementType    theElemType,
568                                   in double theX, 
569                                   in double theY, 
570                                   in double theZ,
571                                   in double theDX,
572                                   in double theDY,
573                                   in double theDZ,
574                                   in double theH,
575                                   in double theR );    
576     /*!
577      * Return indices of elements, which are located inside the geometry
578      *  \param theSource - mesh, sub-mesh or group
579      *  \param theElemType - mesh element type
580      *  \param theGeom - geometrical object
581      *  \param theTolerance - tolerance for selection.
582      */
583     long_array GetInside( in SMESH_IDSource theSource,
584                           in ElementType    theElemType,
585                           in GEOM::GEOM_Object theGeom,
586                           in double theTolerance );    
587
588    
589         MG_ADAPT CreateMG_ADAPT();
590         MG_ADAPT_OBJECT Adaptation(in string adaptType);
591         MG_ADAPT CreateAdaptationHypothesis();
592   };
593
594 };
595
596 #endif