// Author : Nicolas REJNERI
// Module : SMESH
-#ifdef WNT
+#ifdef WIN32
#define NOMINMAX
#endif
#include <Utils_ExceptHandlers.hxx>
#include <Utils_CorbaException.hxx>
#include <SALOMEDS_wrap.hxx>
+#include <SALOME_GenericObj_i.hh>
#include <BRepAdaptor_Surface.hxx>
#include <BRep_Tool.hxx>
return _myMeshDS->AddNodeWithID(anElemNode->X(), anElemNode->Y(), anElemNode->Z(),
anElemNode->GetID());
}
+ void RemoveAll()
+ {
+ GetMeshDS()->ClearMesh();
+ }
};// struct TPreviewMesh
static SMESH_NodeSearcher * theNodeSearcher = 0;
}
myMesh = mesh;
myMeshPartIOR = meshPartIOR;
- if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) {
- const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn();
- TDependsOnMap::const_iterator sm;
- for (sm = subMeshes.begin(); sm != subMeshes.end(); sm++)
- sm->second->SetEventListener( this, 0, sm->second );
+ SMESH_subMesh* sm = mesh->GetSubMesh( mesh->GetShapeToMesh() );
+ SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator( /*includeSelf=*/true );
+ while ( smIt->more() )
+ {
+ sm = smIt->next();
+ sm->SetEventListener( this, 0, sm );
}
}
}
//!< delete self from all submeshes
void Unset(SMESH_Mesh* mesh)
{
- if ( SMESH_subMesh* myMainSubMesh = mesh->GetSubMeshContaining(1) ) {
- const TDependsOnMap & subMeshes = myMainSubMesh->DependsOn();
- TDependsOnMap::const_iterator sm;
- for (sm = subMeshes.begin(); sm != subMeshes.end(); sm++)
- sm->second->DeleteEventListener( this );
+ if ( SMESH_subMesh* sm = mesh->GetSubMeshContaining(1) ) {
+ SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator( /*includeSelf=*/true );
+ while ( smIt->more() )
+ smIt->next()->DeleteEventListener( this );
}
myMesh = 0;
}
void arrayToSet(const SMESH::long_array & IDs,
const SMESHDS_Mesh* aMesh,
TIDSortedElemSet& aMap,
- const SMDSAbs_ElementType aType = SMDSAbs_All )
+ const SMDSAbs_ElementType aType = SMDSAbs_All,
+ SMDS_MeshElement::Filter* aFilter = NULL)
{
SMDS_MeshElement::NonNullFilter filter1;
SMDS_MeshElement::TypeFilter filter2( aType );
- SMDS_MeshElement::Filter & filter =
- ( aType == SMDSAbs_All ) ? (SMDS_MeshElement::Filter&) filter1 : filter2;
+
+ if ( aFilter == NULL )
+ aFilter = ( aType == SMDSAbs_All ) ? (SMDS_MeshElement::Filter*) &filter1 : (SMDS_MeshElement::Filter*) &filter2;
+
+ SMDS_MeshElement::Filter & filter = *aFilter;
if ( aType == SMDSAbs_Node )
for (int i=0; i<IDs.length(); i++) {
SMESH_MeshEditor_i::~SMESH_MeshEditor_i()
{
- deleteAuxIDSources();
+ PortableServer::POA_var poa = SMESH_Gen_i::GetPOA();
+ PortableServer::ObjectId_var anObjectId = poa->servant_to_id(this);
+ poa->deactivate_object(anObjectId.in());
+
+ //deleteAuxIDSources();
delete myPreviewMesh; myPreviewMesh = 0;
delete myPreviewEditor; myPreviewEditor = 0;
}
void SMESH_MeshEditor_i::initData(bool deleteSearchers)
{
if ( myIsPreviewMode ) {
- if ( myPreviewMesh ) myPreviewMesh->Clear();
+ if ( myPreviewMesh ) myPreviewMesh->RemoveAll();
}
else {
if ( deleteSearchers )
//=======================================================================
//function : MakeIDSource
-//purpose : Wrap a sequence of ids in a SMESH_IDSource
+//purpose : Wrap a sequence of ids in a SMESH_IDSource.
+// Call UnRegister() as you fininsh using it!!
//=======================================================================
-struct SMESH_MeshEditor_i::_IDSource : public POA_SMESH::SMESH_IDSource
+struct SMESH_MeshEditor_i::_IDSource : public virtual POA_SMESH::SMESH_IDSource,
+ public virtual SALOME::GenericObj_i
{
SMESH::long_array _ids;
SMESH::ElementType _type;
SMESH::SMESH_IDSource_ptr SMESH_MeshEditor_i::MakeIDSource(const SMESH::long_array& ids,
SMESH::ElementType type)
{
- if ( myAuxIDSources.size() > 10 )
- deleteAuxIDSources();
+ // if ( myAuxIDSources.size() > 10 ) {
+ // delete myAuxIDSources.front();
+ // myAuxIDSources.pop_front();
+ // }
_IDSource* idSrc = new _IDSource;
idSrc->_mesh = myMesh_i->_this();
idSrc->_ids = ids;
idSrc->_type = type;
- myAuxIDSources.push_back( idSrc );
+ //myAuxIDSources.push_back( idSrc );
SMESH::SMESH_IDSource_var anIDSourceVar = idSrc->_this();
return 0;
}
-void SMESH_MeshEditor_i::deleteAuxIDSources()
-{
- std::list< _IDSource* >::iterator idSrcIt = myAuxIDSources.begin();
- for ( ; idSrcIt != myAuxIDSources.end(); ++idSrcIt )
- delete *idSrcIt;
- myAuxIDSources.clear();
-}
+// void SMESH_MeshEditor_i::deleteAuxIDSources()
+// {
+// std::list< _IDSource* >::iterator idSrcIt = myAuxIDSources.begin();
+// for ( ; idSrcIt != myAuxIDSources.end(); ++idSrcIt )
+// delete *idSrcIt;
+// myAuxIDSources.clear();
+// }
//=============================================================================
/*!
initData();
SMESHDS_Mesh* aMesh = getMeshDS();
- TIDSortedElemSet faces;
- arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face);
+ TIDSortedElemSet faces,copyFaces;
+ SMDS_MeshElement::GeomFilter triaFilter(SMDSGeom_TRIANGLE);
+ arrayToSet(IDsOfElements, aMesh, faces, SMDSAbs_Face, & triaFilter);
+ TIDSortedElemSet* workElements = & faces;
+
+ if ( myIsPreviewMode ) {
+ SMDSAbs_ElementType select = SMDSAbs_Face;
+ getPreviewMesh( SMDSAbs_Face )->Copy( faces, copyFaces, select );
+ workElements = & copyFaces;
+ }
SMESH::NumericalFunctor_i* aNumericalFunctor =
dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
else
aCrit = aNumericalFunctor->GetNumericalFunctor();
- // Update Python script
- TPythonDump() << "isDone = " << this << ".TriToQuad( "
- << IDsOfElements << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
-
+ if ( !myIsPreviewMode ) {
+ // Update Python script
+ TPythonDump() << "isDone = " << this << ".TriToQuad( "
+ << IDsOfElements << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
+ }
- bool stat = getEditor().TriToQuad( faces, aCrit, MaxAngle );
+ bool stat = getEditor().TriToQuad( *workElements, aCrit, MaxAngle );
declareMeshModified( /*isReComputeSafe=*/!stat );
return stat;
SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
- SMESH::NumericalFunctor_i* aNumericalFunctor =
- SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
+ if ( !myIsPreviewMode ) {
+ SMESH::NumericalFunctor_i* aNumericalFunctor =
+ SMESH::DownCast<SMESH::NumericalFunctor_i*>( Criterion );
- // Update Python script
- aTPythonDump << "isDone = " << this << ".TriToQuadObject("
- << theObject << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
+ // Update Python script
+ aTPythonDump << "isDone = " << this << ".TriToQuadObject("
+ << theObject << ", " << aNumericalFunctor << ", " << TVar( MaxAngle ) << " )";
+ }
return isDone;
int id = getEditor().BestSplit(quad, aCrit);
declareMeshModified( /*isReComputeSafe=*/ id < 1 );
+ return id;
}
SMESH_CATCH( SMESH::throwCorbaException );
theMakeGroups = false;
}
- TElemOfElemListMap aHystory;
+ ::SMESH_MeshEditor::TTElemOfElemListMap aHystory;
::SMESH_MeshEditor::PGroupIDs groupIds =
getEditor().ExtrusionSweep (*workElements, stepVec, theNbOfSteps, aHystory, theMakeGroups);
const SMESH::PointStruct * P = &theStepVector.PS;
gp_Vec stepVec( P->x, P->y, P->z );
- TElemOfElemListMap aHystory;
+ ::SMESH_MeshEditor::TTElemOfElemListMap aHystory;
::SMESH_MeshEditor::PGroupIDs groupIds =
getEditor().ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory,
theMakeGroups, theExtrFlags, theSewTolerance);