mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-13 02:00:34 +05:00
PAL0023627: [IMACS] ASERIS: project point to the mesh
This commit is contained in:
parent
db0762b147
commit
858b4bff64
@ -773,6 +773,20 @@ module SMESH
|
|||||||
in ElementType type)
|
in ElementType type)
|
||||||
raises (SALOME::SALOME_Exception);
|
raises (SALOME::SALOME_Exception);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Project a point to a mesh object.
|
||||||
|
* Return ID of an element of given type where the given point is projected
|
||||||
|
* and coordinates of the projection point.
|
||||||
|
* In the case if nothing found, return -1 and []
|
||||||
|
*/
|
||||||
|
long ProjectPoint(in double x,
|
||||||
|
in double y,
|
||||||
|
in double z,
|
||||||
|
in SMESH_IDSource meshObject,
|
||||||
|
in ElementType type,
|
||||||
|
out double_array projecton)
|
||||||
|
raises (SALOME::SALOME_Exception);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
|
* Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
|
||||||
* TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
|
* TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
|
||||||
|
@ -1243,11 +1243,11 @@ gp_XYZ SMESH_ElementSearcherImpl::Project(const gp_Pnt& point,
|
|||||||
|
|
||||||
ElementBndBoxTree*& ebbTree = _ebbTree[ _elementType ];
|
ElementBndBoxTree*& ebbTree = _ebbTree[ _elementType ];
|
||||||
if ( !ebbTree )
|
if ( !ebbTree )
|
||||||
ebbTree = new ElementBndBoxTree( *_mesh, _elementType );
|
ebbTree = new ElementBndBoxTree( *_mesh, _elementType, _meshPartIt );
|
||||||
|
|
||||||
gp_XYZ p = point.XYZ();
|
gp_XYZ p = point.XYZ();
|
||||||
ElementBndBoxTree* ebbLeaf = ebbTree->getLeafAtPoint( p );
|
ElementBndBoxTree* ebbLeaf = ebbTree->getLeafAtPoint( p );
|
||||||
const Bnd_B3d* box = ebbLeaf->getBox();
|
const Bnd_B3d* box = ebbLeaf ? ebbLeaf->getBox() : ebbTree->getBox();
|
||||||
double radius = ( box->CornerMax() - box->CornerMin() ).Modulus();
|
double radius = ( box->CornerMax() - box->CornerMin() ).Modulus();
|
||||||
|
|
||||||
ElementBndBoxTree::TElemSeq elems;
|
ElementBndBoxTree::TElemSeq elems;
|
||||||
|
@ -178,7 +178,7 @@ namespace MeshEditor_I {
|
|||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
* \brief Deleter of theNodeSearcher at any compute event occurred
|
* \brief Deleter of theNodeSearcher and theElementSearcher at any compute event occurred
|
||||||
*/
|
*/
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ namespace MeshEditor_I {
|
|||||||
*/
|
*/
|
||||||
//================================================================================
|
//================================================================================
|
||||||
|
|
||||||
string getPartIOR( SMESH::SMESH_IDSource_ptr theMeshPart, SMESH::ElementType type)
|
string getPartIOR( SMESH::SMESH_IDSource_ptr theMeshPart, SMESH::ElementType type = SMESH::ALL )
|
||||||
{
|
{
|
||||||
string partIOR = SMESH_Gen_i::GetORB()->object_to_string( theMeshPart );
|
string partIOR = SMESH_Gen_i::GetORB()->object_to_string( theMeshPart );
|
||||||
if ( SMESH_Group_i* group_i = SMESH::DownCast<SMESH_Group_i*>( theMeshPart ))
|
if ( SMESH_Group_i* group_i = SMESH::DownCast<SMESH_Group_i*>( theMeshPart ))
|
||||||
@ -4652,6 +4652,68 @@ SMESH_MeshEditor_i::FindAmongElementsByPoint(SMESH::SMESH_IDSource_ptr elementID
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : ProjectPoint
|
||||||
|
//purpose : Project a point to a mesh object.
|
||||||
|
// Return ID of an element of given type where the given point is projected
|
||||||
|
// and coordinates of the projection point.
|
||||||
|
// In the case if nothing found, return -1 and []
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
CORBA::Long SMESH_MeshEditor_i::ProjectPoint(CORBA::Double x,
|
||||||
|
CORBA::Double y,
|
||||||
|
CORBA::Double z,
|
||||||
|
SMESH::SMESH_IDSource_ptr meshObject,
|
||||||
|
SMESH::ElementType type,
|
||||||
|
SMESH::double_array_out projecton)
|
||||||
|
throw (SALOME::SALOME_Exception)
|
||||||
|
{
|
||||||
|
if ( CORBA::is_nil( meshObject ))
|
||||||
|
THROW_SALOME_CORBA_EXCEPTION("NULL meshObject", SALOME::BAD_PARAM);
|
||||||
|
|
||||||
|
SMESH_TRY;
|
||||||
|
|
||||||
|
SMESH::SMESH_Mesh_var mesh = meshObject->GetMesh();
|
||||||
|
SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
|
||||||
|
if ( mesh_i != myMesh_i )
|
||||||
|
{
|
||||||
|
SMESH::SMESH_MeshEditor_var editor=
|
||||||
|
myIsPreviewMode ? mesh_i->GetMeshEditPreviewer() : mesh_i->GetMeshEditor();
|
||||||
|
return editor->ProjectPoint( x,y,z, meshObject, type, projecton );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
theSearchersDeleter.Set( myMesh, getPartIOR( meshObject ));
|
||||||
|
if ( !theElementSearcher )
|
||||||
|
{
|
||||||
|
// create a searcher from meshObject
|
||||||
|
|
||||||
|
SMDS_ElemIteratorPtr elemIt;
|
||||||
|
if ( ! SMESH::DownCast<SMESH_Mesh_i*>( meshObject ))
|
||||||
|
elemIt = myMesh_i->GetElements( meshObject, type );
|
||||||
|
|
||||||
|
theElementSearcher = SMESH_MeshAlgos::GetElementSearcher( *getMeshDS(), elemIt );
|
||||||
|
}
|
||||||
|
|
||||||
|
const SMDS_MeshElement* elem = 0;
|
||||||
|
gp_XYZ pProj = theElementSearcher->Project( gp_Pnt( x,y,z ),
|
||||||
|
SMDSAbs_ElementType( type ),
|
||||||
|
&elem );
|
||||||
|
|
||||||
|
projecton = new SMESH::double_array();
|
||||||
|
if ( elem && !elem->IsNull() )
|
||||||
|
{
|
||||||
|
projecton->length( 3 );
|
||||||
|
projecton[0] = pProj.X();
|
||||||
|
projecton[1] = pProj.Y();
|
||||||
|
projecton[2] = pProj.Z();
|
||||||
|
return elem->GetID();
|
||||||
|
}
|
||||||
|
|
||||||
|
SMESH_CATCH( SMESH::throwCorbaException );
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : GetPointState
|
//function : GetPointState
|
||||||
//purpose : Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
|
//purpose : Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
|
||||||
|
@ -546,6 +546,20 @@ public:
|
|||||||
SMESH::ElementType type)
|
SMESH::ElementType type)
|
||||||
throw (SALOME::SALOME_Exception);
|
throw (SALOME::SALOME_Exception);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Project a point to a mesh object.
|
||||||
|
* Return ID of an element of given type where the given point is projected
|
||||||
|
* and coordinates of the projection point.
|
||||||
|
* In the case if nothing found, return -1 and []
|
||||||
|
*/
|
||||||
|
CORBA::Long ProjectPoint(CORBA::Double x,
|
||||||
|
CORBA::Double y,
|
||||||
|
CORBA::Double z,
|
||||||
|
SMESH::SMESH_IDSource_ptr meshObject,
|
||||||
|
SMESH::ElementType type,
|
||||||
|
SMESH::double_array_out projecton)
|
||||||
|
throw (SALOME::SALOME_Exception);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
|
* Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
|
||||||
* TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
|
* TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
|
||||||
|
@ -4228,6 +4228,17 @@ class Mesh(metaclass = MeshMeta):
|
|||||||
else:
|
else:
|
||||||
return self.editor.FindElementsByPoint(x, y, z, elementType)
|
return self.editor.FindElementsByPoint(x, y, z, elementType)
|
||||||
|
|
||||||
|
def ProjectPoint(self, x,y,z, meshObject, elementType):
|
||||||
|
"""
|
||||||
|
Project a point to a mesh object.
|
||||||
|
Return ID of an element of given type where the given point is projected
|
||||||
|
and coordinates of the projection point.
|
||||||
|
In the case if nothing found, return -1 and []
|
||||||
|
"""
|
||||||
|
if ( isinstance( meshObject, Mesh )):
|
||||||
|
meshObject = meshObject.GetMesh()
|
||||||
|
return self.editor.ProjectPoint( x,y,z, meshObject, elementType )
|
||||||
|
|
||||||
def GetPointState(self, x, y, z):
|
def GetPointState(self, x, y, z):
|
||||||
"""
|
"""
|
||||||
Return point state in a closed 2D mesh in terms of TopAbs_State enumeration:
|
Return point state in a closed 2D mesh in terms of TopAbs_State enumeration:
|
||||||
|
Loading…
Reference in New Issue
Block a user