Implement PAL7218: Sweep mesh elements along discretized curve

This commit is contained in:
vsr 2005-01-17 12:54:44 +00:00
parent d590247c64
commit 76e859fd8d
4 changed files with 205 additions and 0 deletions

View 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 :

View 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,

View 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();
}

View 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