From: vsr Date: Mon, 17 Jan 2005 12:54:44 +0000 (+0000) Subject: Implement PAL7218: Sweep mesh elements along discretized curve X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=76e859fd8db64bec866e61c70b286910cdc185d9;p=modules%2Fsmesh.git Implement PAL7218: Sweep mesh elements along discretized curve --- diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 34072c00f..f27cc396e 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -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_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 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 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 : diff --git a/src/SMESH_I/SMESH_MeshEditor_i.hxx b/src/SMESH_I/SMESH_MeshEditor_i.hxx index 2923617bd..3677d1342 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.hxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.hxx @@ -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, diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 5673c9bd4..408b9d2f2 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -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(); +} + diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index 0b010c474..2e4632890 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -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