Salome HOME
Distributed Geom, Smesh. Modifications by Anthony GEAY.
[modules/smesh.git] / src / SMESH_I / SMESH_MeshEditor_i.hxx
index 9aba3bb4fe9871f3bb699759417644a35498977d..52ba2d7766592675b0dfadb2499657a995964dc5 100644 (file)
@@ -1,23 +1,23 @@
 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
 //
 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
 #ifndef _SMESH_MESHEDITOR_I_HXX_
 #define _SMESH_MESHEDIOTR_I_HXX_
 
+#include "SMESH.hxx"
+
 #include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SMESH_Mesh)
+#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
 
 #include "SMESH_Mesh.hxx"
 
-class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
+class SMESH_MeshEditor;
+
+class SMESH_I_EXPORT SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
 {
  public:
-  SMESH_MeshEditor_i(SMESH_Mesh * theMesh);
+  SMESH_MeshEditor_i(SMESH_Mesh * theMesh, bool isPreview);
 
-  virtual ~ SMESH_MeshEditor_i()
-  {
-  };
+  virtual ~ SMESH_MeshEditor_i();
 
   // --- CORBA
   CORBA::Boolean RemoveElements(const SMESH::long_array & IDsOfElements);
   CORBA::Boolean RemoveNodes(const SMESH::long_array & IDsOfNodes);
 
-  CORBA::Boolean AddNode(CORBA::Double x, CORBA::Double y, CORBA::Double z);
-  CORBA::Boolean AddEdge(const SMESH::long_array & IDsOfNodes);
-  CORBA::Boolean AddFace(const SMESH::long_array & IDsOfNodes);
-  CORBA::Boolean AddVolume(const SMESH::long_array & IDsOfNodes);
-
-  CORBA::Boolean AddPolyhedralVolume(const SMESH::long_array & IDsOfNodes,
-                                     const SMESH::long_array & Quantities);
-  CORBA::Boolean AddPolyhedralVolumeByFaces(const SMESH::long_array & IdsOfFaces);
+  /*!
+   * Methods for creation new elements.
+   * Returns ID of created element or 0 if element not created
+   */
+  CORBA::Long AddNode(CORBA::Double x, CORBA::Double y, CORBA::Double z);
+  CORBA::Long AddEdge(const SMESH::long_array & IDsOfNodes);
+  CORBA::Long AddFace(const SMESH::long_array & IDsOfNodes);
+  CORBA::Long AddPolygonalFace(const SMESH::long_array & IDsOfNodes);
+  CORBA::Long AddVolume(const SMESH::long_array & IDsOfNodes);
+  CORBA::Long AddPolyhedralVolume(const SMESH::long_array & IDsOfNodes,
+                                  const SMESH::long_array & Quantities);
+  CORBA::Long AddPolyhedralVolumeByFaces(const SMESH::long_array & IdsOfFaces);
 
   CORBA::Boolean MoveNode(CORBA::Long NodeID,
                           CORBA::Double x, CORBA::Double y, CORBA::Double z);
@@ -64,18 +70,23 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
   CORBA::Boolean Reorient(const SMESH::long_array & IDsOfElements);
   CORBA::Boolean ReorientObject(SMESH::SMESH_IDSource_ptr theObject);
 
-  CORBA::Boolean TriToQuad(const SMESH::long_array &   IDsOfElements,
-                           SMESH::NumericalFunctor_ptr Criterion,
-                           CORBA::Double               MaxAngle);
-  CORBA::Boolean TriToQuadObject(SMESH::SMESH_IDSource_ptr theObject,
-                                SMESH::NumericalFunctor_ptr Criterion,
-                                CORBA::Double               MaxAngle);
-  CORBA::Boolean QuadToTri(const SMESH::long_array &   IDsOfElements,
-                           SMESH::NumericalFunctor_ptr Criterion);
-  CORBA::Boolean SplitQuad(const SMESH::long_array & IDsOfElements,
-                           CORBA::Boolean            Diag13);
-  CORBA::Boolean SplitQuadObject(SMESH::SMESH_IDSource_ptr theObject,
-                                CORBA::Boolean            Diag13);
+  // Split/Join faces
+  CORBA::Boolean TriToQuad       (const SMESH::long_array &   IDsOfElements,
+                                  SMESH::NumericalFunctor_ptr Criterion,
+                                  CORBA::Double               MaxAngle);
+  CORBA::Boolean TriToQuadObject (SMESH::SMESH_IDSource_ptr   theObject,
+                                  SMESH::NumericalFunctor_ptr Criterion,
+                                  CORBA::Double               MaxAngle);
+  CORBA::Boolean QuadToTri       (const SMESH::long_array &   IDsOfElements,
+                                  SMESH::NumericalFunctor_ptr Criterion);
+  CORBA::Boolean QuadToTriObject (SMESH::SMESH_IDSource_ptr   theObject,
+                                  SMESH::NumericalFunctor_ptr Criterion);
+  CORBA::Boolean SplitQuad       (const SMESH::long_array &   IDsOfElements,
+                                  CORBA::Boolean              Diag13);
+  CORBA::Boolean SplitQuadObject (SMESH::SMESH_IDSource_ptr   theObject,
+                                  CORBA::Boolean              Diag13);
+  CORBA::Long    BestSplit       (CORBA::Long                 IDOfQuad,
+                                  SMESH::NumericalFunctor_ptr Criterion);
 
   CORBA::Boolean Smooth(const SMESH::long_array &              IDsOfElements,
                         const SMESH::long_array &              IDsOfFixedNodes,
@@ -110,6 +121,10 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
                              SMESH::SMESH_MeshEditor::Smooth_Method Method,
                               bool                                   IsParametric);
 
+
+  void ConvertToQuadratic(CORBA::Boolean Force3d);
+  CORBA::Boolean ConvertFromQuadratic();
+
   void RenumberNodes();
   void RenumberElements();
 
@@ -136,7 +151,12 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
   void ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
                               const SMESH::DirStruct &  StepVector,
                               CORBA::Long               NbOfSteps);
-  
+  void AdvancedExtrusion(const SMESH::long_array & theIDsOfElements,
+                        const SMESH::DirStruct &  theStepVector,
+                        CORBA::Long               theNbOfSteps,
+                        CORBA::Long               theExtrFlags,
+                        CORBA::Double             theSewTolerance);
+
   SMESH::SMESH_MeshEditor::Extrusion_Error
     ExtrusionAlongPath(const SMESH::long_array &   IDsOfElements,
                        SMESH::SMESH_Mesh_ptr       PathMesh,
@@ -146,7 +166,7 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
                        const SMESH::double_array & Angles,
                        CORBA::Boolean              HasRefPoint,
                        const SMESH::PointStruct &  RefPoint);
-  
+
   SMESH::SMESH_MeshEditor::Extrusion_Error
     ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr   theObject,
                              SMESH::SMESH_Mesh_ptr       PathMesh,
@@ -157,6 +177,10 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
                              CORBA::Boolean              HasRefPoint,
                              const SMESH::PointStruct &  RefPoint);
 
+  SMESH::double_array* LinearAnglesVariation(SMESH::SMESH_Mesh_ptr       PathMesh,
+                                             GEOM::GEOM_Object_ptr       PathShape,
+                                             const SMESH::double_array & Angles);
+
   void Mirror(const SMESH::long_array &           IDsOfElements,
               const SMESH::AxisStruct &           Axis,
               SMESH::SMESH_MeshEditor::MirrorType MirrorType,
@@ -182,8 +206,20 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
 
   void FindCoincidentNodes (CORBA::Double                  Tolerance,
                             SMESH::array_of_long_array_out GroupsOfNodes);
+  void FindCoincidentNodesOnPart(SMESH::SMESH_IDSource_ptr      theObject,
+                                 CORBA::Double                  Tolerance,
+                                 SMESH::array_of_long_array_out GroupsOfNodes);
   void MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes);
+  void FindEqualElements(SMESH::SMESH_IDSource_ptr      theObject,
+                        SMESH::array_of_long_array_out GroupsOfElementsID);
+  void MergeElements(const SMESH::array_of_long_array& GroupsOfElementsID);
   void MergeEqualElements();
+  CORBA::Long MoveClosestNodeToPoint(CORBA::Double x,
+                                     CORBA::Double y,
+                                     CORBA::Double z,
+                                     CORBA::Long   nodeID);
+
+
 
   SMESH::SMESH_MeshEditor::Sew_Error
     SewFreeBorders(CORBA::Long FirstNodeID1,
@@ -216,9 +252,60 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
                     CORBA::Long NodeID2OfSide1ToMerge,
                     CORBA::Long NodeID2OfSide2ToMerge);
 
+  /*!
+   * Set new nodes for given element.
+   * If number of nodes is not corresponded to type of
+   * element - returns false
+   */
+  CORBA::Boolean ChangeElemNodes(CORBA::Long ide, const SMESH::long_array& newIDs);
+  
+  /*!
+   * Return data of mesh edition preview
+   */
+  SMESH::MeshPreviewStruct* GetPreviewData();
+
+  /*!
+   * If during last operation of MeshEditor some nodes were
+   * created this method returns list of it's IDs, if new nodes
+   * not creared - returns empty list
+   */
+  SMESH::long_array* GetLastCreatedNodes();
+
+  /*!
+   * If during last operation of MeshEditor some elements were
+   * created this method returns list of it's IDs, if new elements
+   * not creared - returns empty list
+   */
+  SMESH::long_array* GetLastCreatedElems();
+
+  //
+  // Internal methods
+  //
+
+  /*!
+   * \brief Update myLastCreated* or myPreviewData
+    * \param anEditor - it contains edition results
+   */
+  void StoreResult(::SMESH_MeshEditor& anEditor);
+
+  /*!
+   * \brief Return edited mesh ID
+    * \retval int - mesh ID
+   */
+  int GetMeshId() const { return myMesh->GetId(); }
+
  private:
-  SMESHDS_Mesh * GetMeshDS() { return _myMesh->GetMeshDS(); }
-  SMESH_Mesh   *_myMesh;
+
+  SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); }
+  void initData();
+
+  SMESH_Mesh *          myMesh;
+
+  SMESH::long_array_var myLastCreatedElems;
+  SMESH::long_array_var myLastCreatedNodes;
+
+  SMESH::MeshPreviewStruct_var myPreviewData;
+  bool                         myPreviewMode;
 };
 
 #endif