]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Implement PAL7218: Sweep mesh elements along discretized curve
authorvsr <vsr@opencascade.com>
Mon, 17 Jan 2005 12:54:44 +0000 (12:54 +0000)
committervsr <vsr@opencascade.com>
Mon, 17 Jan 2005 12:54:44 +0000 (12:54 +0000)
src/SMESH_I/SMESH_MeshEditor_i.cxx
src/SMESH_I/SMESH_MeshEditor_i.hxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx

index 34072c00f3ff067d8c6e5edfd488a337cac1453c..f27cc396e78dff14f7ad4ce9ccab84e7950c2cd2 100644 (file)
@@ -533,6 +533,75 @@ void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObjec
   ExtrusionSweep(anElementsId, theStepVector, theNbOfSteps);
 }
 
+//=======================================================================
+//function : ExtrusionAlongPath
+//purpose  : 
+//=======================================================================
+
+void SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array &   theIDsOfElements,
+                                           SMESH::SMESH_Mesh_ptr       thePathMesh,
+                                           GEOM::GEOM_Object_ptr       thePathShape,
+                                           CORBA::Long                 theNodeStart,
+                                           CORBA::Boolean              theHasAngles,
+                                           const SMESH::double_array & theAngles,
+                                           CORBA::Boolean              theHasRefPoint,
+                                           const SMESH::PointStruct &  theRefPoint)
+{
+  SMESHDS_Mesh*  aMesh = GetMeshDS();
+
+  if ( thePathMesh->_is_nil() || thePathShape->_is_nil() )
+    return;
+
+  SMESH_Mesh_i* aMeshImp = dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( thePathMesh ).in() );
+  TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( thePathShape );
+  SMESH_subMesh* aSubMesh = aMeshImp->GetImpl().GetSubMesh( aShape );
+
+  if ( !aSubMesh )
+    return;
+
+  SMDS_MeshNode* nodeStart = (SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(theNodeStart);
+  if ( !nodeStart )
+    return;
+
+  set<const SMDS_MeshElement*> elements;
+  for (int i = 0; i < theIDsOfElements.length(); i++)
+  {
+    CORBA::Long index = theIDsOfElements[i];
+    const SMDS_MeshElement * elem = aMesh->FindElement(index);
+    if ( elem )
+      elements.insert( elem );
+  }
+
+  list<double> angles;
+  for (int i = 0; i < theAngles.length(); i++)
+  {
+    angles.push_back( theAngles[i] );
+  }
+
+  gp_Pnt refPnt( theRefPoint.x, theRefPoint.y, theRefPoint.z );
+
+  ::SMESH_MeshEditor anEditor( _myMesh );
+  int res = anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart, theHasAngles, angles, theHasRefPoint, refPnt );
+}
+
+//=======================================================================
+//function : ExtrusionAlongPathObject
+//purpose  : 
+//=======================================================================
+
+void SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr   theObject,
+                                                 SMESH::SMESH_Mesh_ptr       thePathMesh,
+                                                 GEOM::GEOM_Object_ptr       thePathShape,
+                                                 CORBA::Long                 theNodeStart,
+                                                 CORBA::Boolean              theHasAngles,
+                                                 const SMESH::double_array & theAngles,
+                                                 CORBA::Boolean              theHasRefPoint,
+                                                 const SMESH::PointStruct &  theRefPoint)
+{
+  SMESH::long_array_var anElementsId = theObject->GetIDs();
+  ExtrusionAlongPath( anElementsId, thePathMesh, thePathShape, theNodeStart, theHasAngles, theAngles, theHasRefPoint, theRefPoint );
+}
+
 //=======================================================================
 //function : Mirror
 //purpose  : 
index 2923617bda2885a3ef90264a72282759544e23ee..3677d13425ceb11851af05aa2500a7028d3cfb14 100644 (file)
@@ -105,6 +105,24 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
                            const SMESH::DirStruct &  StepVector,
                            CORBA::Long               NbOfSteps);
   
+  void ExtrusionAlongPath(const SMESH::long_array &   IDsOfElements,
+                          SMESH::SMESH_Mesh_ptr       PathMesh,
+                          GEOM::GEOM_Object_ptr       PathShape,
+                          CORBA::Long                 NodeStart,
+                          CORBA::Boolean              HasAngles,
+                          const SMESH::double_array & Angles,
+                          CORBA::Boolean              HasRefPoint,
+                          const SMESH::PointStruct &  RefPoint);
+
+  void ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr   theObject,
+                                SMESH::SMESH_Mesh_ptr       PathMesh,
+                                GEOM::GEOM_Object_ptr       PathShape,
+                                CORBA::Long                 NodeStart,
+                                CORBA::Boolean              HasAngles,
+                                const SMESH::double_array & Angles,
+                                CORBA::Boolean              HasRefPoint,
+                                const SMESH::PointStruct &  RefPoint);
+
   void Mirror(const SMESH::long_array &           IDsOfElements,
               const SMESH::AxisStruct &           Axis,
               SMESH::SMESH_MeshEditor::MirrorType MirrorType,
index 5673c9bd45038a12e756cc2bf6ab01aac804a726..408b9d2f28b24362841cc8e8506f6d179a4cb5af 100644 (file)
@@ -1126,6 +1126,17 @@ CORBA::Long SMESH_Mesh_i::NbNodes()throw(SALOME::SALOME_Exception)
   return _impl->NbNodes();
 }
 
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+CORBA::Long SMESH_Mesh_i::NbElements()throw (SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  return NbEdges() + NbFaces() + NbVolumes();
+}
+  
 //=============================================================================
 /*!
  *  
@@ -1237,3 +1248,98 @@ SMESH::long_array* SMESH_Mesh_i::GetIDs()
   
   return aResult._retn();
 }
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+  
+SMESH::long_array* SMESH_Mesh_i::GetElementsId()
+     throw (SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE("SMESH_Mesh_i::GetElementsId");
+  SMESH::long_array_var aResult = new SMESH::long_array();
+  SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+
+  if ( aSMESHDS_Mesh == NULL )
+    return aResult._retn();
+
+  long nbElements = NbElements();
+  aResult->length( nbElements );
+  SMDS_ElemIteratorPtr anIt = aSMESHDS_Mesh->elementsIterator();
+  for ( int i = 0, n = nbElements; i < n && anIt->more(); i++ )
+    aResult[i] = anIt->next()->GetID();
+
+  return aResult._retn();
+}
+
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+
+SMESH::long_array* SMESH_Mesh_i::GetElementsByType( SMESH::ElementType theElemType )
+    throw (SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE("SMESH_subMesh_i::GetElementsByType");
+  SMESH::long_array_var aResult = new SMESH::long_array();
+  SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+
+  if ( aSMESHDS_Mesh == NULL )
+    return aResult._retn();
+
+  long nbElements = NbElements();
+
+  // No sense in returning ids of elements along with ids of nodes:
+  // when theElemType == SMESH::ALL, return node ids only if
+  // there are no elements
+  if ( theElemType == SMESH::NODE || theElemType == SMESH::ALL && nbElements == 0 )
+    return GetNodesId();
+
+  aResult->length( nbElements );
+
+  int i = 0;
+
+  SMDS_ElemIteratorPtr anIt = aSMESHDS_Mesh->elementsIterator();
+  while ( i < nbElements && anIt->more() ) {
+    const SMDS_MeshElement* anElem = anIt->next();
+    if ( theElemType == SMESH::ALL || anElem->GetType() == (SMDSAbs_ElementType)theElemType )
+      aResult[i++] = anElem->GetID();
+  }
+
+  aResult->length( i );
+
+  return aResult._retn();
+}
+
+//=============================================================================
+/*!
+ *  
+ */
+//=============================================================================
+  
+SMESH::long_array* SMESH_Mesh_i::GetNodesId()
+  throw (SALOME::SALOME_Exception)
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE("SMESH_subMesh_i::GetNodesId");
+  SMESH::long_array_var aResult = new SMESH::long_array();
+  SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
+
+  if ( aSMESHDS_Mesh == NULL )
+    return aResult._retn();
+
+  long nbNodes = NbNodes();
+  aResult->length( nbNodes );
+  SMDS_NodeIteratorPtr anIt = aSMESHDS_Mesh->nodesIterator();
+  for ( int i = 0, n = nbNodes; i < n && anIt->more(); i++ )
+    aResult[i] = anIt->next()->GetID();
+
+  return aResult._retn();
+}
+
index 0b010c474cfe1cf5c2adcf16511467a0acd8ad20..2e46328908a6f52a48c5b892266602a9f847047a 100644 (file)
@@ -165,6 +165,9 @@ public:
   CORBA::Long NbNodes()
     throw (SALOME::SALOME_Exception);
   
+  CORBA::Long NbElements()
+    throw (SALOME::SALOME_Exception);
+  
   CORBA::Long NbEdges()
     throw (SALOME::SALOME_Exception);
   
@@ -195,6 +198,15 @@ public:
   CORBA::Long NbSubMesh()
     throw (SALOME::SALOME_Exception);
 
+  SMESH::long_array* GetElementsId()
+    throw (SALOME::SALOME_Exception);
+
+  SMESH::long_array* GetElementsByType( SMESH::ElementType theElemType )
+    throw (SALOME::SALOME_Exception);
+  
+  SMESH::long_array* GetNodesId()
+    throw (SALOME::SALOME_Exception);
+  
   char* Dump();
   
   // Internal methods not available through CORBA