//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
// File : SMESH_MeshEditor_i.cxx
// Author : Nicolas REJNERI
// Module : SMESH
-//
+
#ifdef WNT
#define NOMINMAX
#endif
//!< Copy a node
SMDS_MeshNode* Copy( const SMDS_MeshNode* anElemNode )
{
- return _myMeshDS->AddNodeWithID(anElemNode->X(), anElemNode->Y(), anElemNode->Z(),
+ return _myMeshDS->AddNodeWithID(anElemNode->X(), anElemNode->Y(), anElemNode->Z(),
anElemNode->GetID());
}
};// struct TPreviewMesh
for ( int i = 0; i < seq.size(); i++ )
IdList.push_back( seq[i] );
+ bool ret = anEditor.Remove( IdList, true );
+ myMesh->GetMeshDS()->Modified();
if ( IdList.size() )
myMesh->SetIsModified( true );
- return anEditor.Remove( IdList, true );
+ return ret;
}
//=============================================================================
if ( isOut ) {
#ifdef _DEBUG_
MESSAGE ( "FACE " << FaceID << " (" << u << "," << v << ") out of "
- << " u( " << surf.FirstUParameter()
- << "," << surf.LastUParameter()
- << ") v( " << surf.FirstVParameter()
+ << " u( " << surf.FirstUParameter()
+ << "," << surf.LastUParameter()
+ << ") v( " << surf.FirstVParameter()
<< "," << surf.LastVParameter() << ")" );
-#endif
+#endif
THROW_SALOME_CORBA_EXCEPTION("Invalid UV", SALOME::BAD_PARAM);
}
myMesh->GetMeshDS()->Modified();
if ( stat )
myMesh->SetIsModified( true ); // issue 0020693
-
+
storeResult(aMeshEditor);
return stat;
SMESH::long_array_var anElementsId = elems->GetIDs();
TIDSortedElemSet elemSet;
arrayToSet( anElementsId, GetMeshDS(), elemSet, SMDSAbs_Volume );
-
+
::SMESH_MeshEditor anEditor (myMesh);
anEditor.SplitVolumesIntoTetra( elemSet, int( methodFlags ));
myMesh->GetMeshDS()->Modified();
//=======================================================================
//function : rotationSweep
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
//=======================================================================
//function : RotationSweepMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
CORBA::Long theNbOfSteps,
CORBA::Double theTolerance)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::ListOfGroups *aGroups = rotationSweep(theIDsOfElements,
theAxis,
theAngleInRadians,
theNbOfSteps,
theTolerance,
true);
- if ( !myPreviewMode ) {
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
- aPythonDump<< this << ".RotationSweepMakeGroups( "
- << theIDsOfElements << ", "
- << theAxis << ", "
- << theAngleInRadians << ", "
- << theNbOfSteps << ", "
- << theTolerance << " )";
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
+ aPythonDump << this << ".RotationSweepMakeGroups( "
+ << theIDsOfElements << ", "
+ << theAxis << ", "
+ << theAngleInRadians << ", "
+ << theNbOfSteps << ", "
+ << theTolerance << " )";
}
return aGroups;
}
//=======================================================================
//function : RotationSweepObjectMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
CORBA::Long theNbOfSteps,
CORBA::Double theTolerance)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
theAxis,
theNbOfSteps,
theTolerance,
true);
- if ( !myPreviewMode ) {
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
- aPythonDump<< this << ".RotationSweepObjectMakeGroups( "
- << theObject << ", "
- << theAxis << ", "
- << theAngleInRadians << ", "
- << theNbOfSteps << ", "
- << theTolerance << " )";
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
+ aPythonDump << this << ".RotationSweepObjectMakeGroups( "
+ << theObject << ", "
+ << theAxis << ", "
+ << theAngleInRadians << ", "
+ << theNbOfSteps << ", "
+ << theTolerance << " )";
}
return aGroups;
}
//=======================================================================
//function : RotationSweepObject1DMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
CORBA::Long theNbOfSteps,
CORBA::Double theTolerance)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
theAxis,
theTolerance,
true,
SMDSAbs_Edge);
- if ( !myPreviewMode ) {
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
- aPythonDump<< this << ".RotationSweepObject1DMakeGroups( "
- << theObject << ", "
- << theAxis << ", "
- << theAngleInRadians << ", "
- << theNbOfSteps << ", "
- << theTolerance << " )";
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
+ aPythonDump << this << ".RotationSweepObject1DMakeGroups( "
+ << theObject << ", "
+ << theAxis << ", "
+ << theAngleInRadians << ", "
+ << theNbOfSteps << ", "
+ << theTolerance << " )";
}
return aGroups;
}
//=======================================================================
//function : RotationSweepObject2DMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
CORBA::Long theNbOfSteps,
CORBA::Double theTolerance)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups *aGroups = rotationSweep(anElementsId,
theAxis,
theTolerance,
true,
SMDSAbs_Face);
- if ( !myPreviewMode ) {
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
- aPythonDump<< this << ".RotationSweepObject2DMakeGroups( "
- << theObject << ", "
- << theAxis << ", "
- << theAngleInRadians << ", "
- << theNbOfSteps << ", "
- << theTolerance << " )";
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
+ aPythonDump << this << ".RotationSweepObject2DMakeGroups( "
+ << theObject << ", "
+ << theAxis << ", "
+ << theAngleInRadians << ", "
+ << theNbOfSteps << ", "
+ << theTolerance << " )";
}
return aGroups;
}
//=======================================================================
//function : extrusionSweep
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
{
initData();
- try {
+ try {
#ifdef NO_CAS_CATCH
OCC_CATCH_SIGNALS;
#endif
- TIDSortedElemSet elements;
+ TIDSortedElemSet elements, copyElements;
arrayToSet(theIDsOfElements, GetMeshDS(), elements, theElementType);
const SMESH::PointStruct * P = &theStepVector.PS;
gp_Vec stepVec( P->x, P->y, P->z );
+ TIDSortedElemSet* workElements = & elements;
+ TPreviewMesh tmpMesh( SMDSAbs_Face );
+ SMESH_Mesh* mesh = 0;
+
+ if ( myPreviewMode ) {
+ SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume;
+ tmpMesh.Copy( elements, copyElements, select, avoid );
+ mesh = &tmpMesh;
+ workElements = & copyElements;
+ }
+ else {
+ mesh = myMesh;
+ }
+
TElemOfElemListMap aHystory;
- ::SMESH_MeshEditor anEditor( myMesh );
+ ::SMESH_MeshEditor anEditor( mesh );
::SMESH_MeshEditor::PGroupIDs groupIds =
- anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory, theMakeGroups);
+ anEditor.ExtrusionSweep (*workElements, stepVec, theNbOfSteps, aHystory, theMakeGroups);
myMesh->GetMeshDS()->Modified();
storeResult(anEditor);
return theMakeGroups ? getGroups(groupIds.get()) : 0;
} catch(Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
INFOS( "SMESH_MeshEditor_i::ExtrusionSweep fails - "<< aFail->GetMessageString() );
}
return 0;
CORBA::Long theNbOfSteps)
{
extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, false );
- if ( !myPreviewMode ) {
+ if (!myPreviewMode) {
TPythonDump() << this << ".ExtrusionSweep( "
<< theIDsOfElements << ", " << theStepVector <<", " << theNbOfSteps << " )";
}
{
SMESH::long_array_var anElementsId = theObject->GetIDs();
extrusionSweep (anElementsId, theStepVector, theNbOfSteps, false );
- if ( !myPreviewMode ) {
+ if (!myPreviewMode) {
TPythonDump() << this << ".ExtrusionSweepObject( "
<< theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
}
//=======================================================================
//function : ExtrusionSweepMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
const SMESH::DirStruct& theStepVector,
CORBA::Long theNbOfSteps)
{
- SMESH::ListOfGroups* aGroups = extrusionSweep (theIDsOfElements, theStepVector, theNbOfSteps, true );
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
- if ( !myPreviewMode ) {
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
- aPythonDump << this << ".ExtrusionSweepMakeGroups( "
- << theIDsOfElements << ", " << theStepVector <<", " << theNbOfSteps << " )";
+ SMESH::ListOfGroups* aGroups = extrusionSweep(theIDsOfElements, theStepVector, theNbOfSteps, true);
+
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
+ aPythonDump << this << ".ExtrusionSweepMakeGroups( " << theIDsOfElements
+ << ", " << theStepVector <<", " << theNbOfSteps << " )";
}
return aGroups;
}
+
//=======================================================================
//function : ExtrusionSweepObjectMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
const SMESH::DirStruct& theStepVector,
CORBA::Long theNbOfSteps)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::long_array_var anElementsId = theObject->GetIDs();
- SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true );
+ SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector, theNbOfSteps, true);
- if ( !myPreviewMode ) {
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
- aPythonDump<< this << ".ExtrusionSweepObjectMakeGroups( "
- << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
+ aPythonDump << this << ".ExtrusionSweepObjectMakeGroups( " << theObject
+ << ", " << theStepVector << ", " << theNbOfSteps << " )";
}
return aGroups;
}
//=======================================================================
//function : ExtrusionSweepObject1DMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
const SMESH::DirStruct& theStepVector,
CORBA::Long theNbOfSteps)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::long_array_var anElementsId = theObject->GetIDs();
- SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Edge );
- if ( !myPreviewMode ) {
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
- aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( "
- << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
+ SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector,
+ theNbOfSteps, true, SMDSAbs_Edge);
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
+ aPythonDump << this << ".ExtrusionSweepObject1DMakeGroups( " << theObject
+ << ", " << theStepVector << ", " << theNbOfSteps << " )";
}
return aGroups;
}
//=======================================================================
//function : ExtrusionSweepObject2DMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
const SMESH::DirStruct& theStepVector,
CORBA::Long theNbOfSteps)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::long_array_var anElementsId = theObject->GetIDs();
- SMESH::ListOfGroups * aGroups = extrusionSweep (anElementsId, theStepVector, theNbOfSteps, true, SMDSAbs_Face );
- if ( !myPreviewMode ) {
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
- aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( "
- << theObject << ", " << theStepVector << ", " << theNbOfSteps << " )";
+ SMESH::ListOfGroups * aGroups = extrusionSweep(anElementsId, theStepVector,
+ theNbOfSteps, true, SMDSAbs_Face);
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
+ aPythonDump << this << ".ExtrusionSweepObject2DMakeGroups( " << theObject
+ << ", " << theStepVector << ", " << theNbOfSteps << " )";
}
return aGroups;
}
//=======================================================================
//function : advancedExtrusion
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
//=======================================================================
//function : AdvancedExtrusionMakeGroups
-//purpose :
+//purpose :
//=======================================================================
-
SMESH::ListOfGroups*
SMESH_MeshEditor_i::AdvancedExtrusionMakeGroups(const SMESH::long_array& theIDsOfElements,
const SMESH::DirStruct& theStepVector,
CORBA::Long theExtrFlags,
CORBA::Double theSewTolerance)
{
+ if (!myPreviewMode) {
+ TPythonDump() << "stepVector = " << theStepVector;
+ }
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::ListOfGroups * aGroups = advancedExtrusion( theIDsOfElements,
theStepVector,
theNbOfSteps,
theSewTolerance,
true);
- if ( !myPreviewMode ) {
- TPythonDump() << "stepVector = " << theStepVector;
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
aPythonDump << this << ".AdvancedExtrusionMakeGroups("
<< theIDsOfElements
<< ", stepVector, "
//=======================================================================
//function : extrusionAlongPath
-//purpose :
+//purpose :
//=======================================================================
-
SMESH::ListOfGroups*
SMESH_MeshEditor_i::extrusionAlongPath(const SMESH::long_array & theIDsOfElements,
SMESH::SMESH_Mesh_ptr thePathMesh,
//=======================================================================
//function : extrusionAlongPathX
-//purpose :
+//purpose :
//=======================================================================
-
SMESH::ListOfGroups*
SMESH_MeshEditor_i::extrusionAlongPathX(const SMESH::long_array & IDsOfElements,
SMESH::SMESH_IDSource_ptr Path,
return EmptyGr;
}
- TIDSortedElemSet elements;
+ TIDSortedElemSet elements, copyElements;
arrayToSet(IDsOfElements, GetMeshDS(), elements, ElementType);
- ::SMESH_MeshEditor anEditor( myMesh );
+ TIDSortedElemSet* workElements = &elements;
+ TPreviewMesh tmpMesh( SMDSAbs_Face );
+ SMESH_Mesh* mesh = 0;
+
+ if ( myPreviewMode )
+ {
+ SMDSAbs_ElementType select = SMDSAbs_All, avoid = SMDSAbs_Volume;
+ tmpMesh.Copy( elements, copyElements, select, avoid );
+ mesh = &tmpMesh;
+ workElements = & copyElements;
+ }
+ else
+ {
+ mesh = myMesh;
+ }
+
+ ::SMESH_MeshEditor anEditor( mesh );
::SMESH_MeshEditor::Extrusion_Error error;
SMESH_Mesh_i* aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( Path );
if(aMeshImp) {
// path as mesh
- SMDS_MeshNode* aNodeStart =
+ SMDS_MeshNode* aNodeStart =
(SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(NodeStart);
if ( !aNodeStart ) {
Error = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
return EmptyGr;
}
- error = anEditor.ExtrusionAlongTrack( elements, &(aMeshImp->GetImpl()), aNodeStart,
+ error = anEditor.ExtrusionAlongTrack( *workElements, &(aMeshImp->GetImpl()), aNodeStart,
HasAngles, angles, LinearVariation,
HasRefPoint, refPnt, MakeGroups );
myMesh->GetMeshDS()->Modified();
// path as submesh
SMESH::SMESH_Mesh_ptr aPathMesh = aSubMeshImp->GetFather();
aMeshImp = SMESH::DownCast<SMESH_Mesh_i*>( aPathMesh );
- SMDS_MeshNode* aNodeStart =
+ SMDS_MeshNode* aNodeStart =
(SMDS_MeshNode*)aMeshImp->GetImpl().GetMeshDS()->FindNode(NodeStart);
if ( !aNodeStart ) {
Error = SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE;
return EmptyGr;
}
- SMESH_subMesh* aSubMesh =
+ SMESH_subMesh* aSubMesh =
aMeshImp->GetImpl().GetSubMeshContaining(aSubMeshImp->GetId());
- error = anEditor.ExtrusionAlongTrack( elements, aSubMesh, aNodeStart,
+ error = anEditor.ExtrusionAlongTrack( *workElements, aSubMesh, aNodeStart,
HasAngles, angles, LinearVariation,
HasRefPoint, refPnt, MakeGroups );
myMesh->GetMeshDS()->Modified();
//function : ExtrusionAlongPath
//purpose :
//=======================================================================
-
SMESH::SMESH_MeshEditor::Extrusion_Error
SMESH_MeshEditor_i::ExtrusionAlongPath(const SMESH::long_array & theIDsOfElements,
SMESH::SMESH_Mesh_ptr thePathMesh,
//function : ExtrusionAlongPathObject
//purpose :
//=======================================================================
-
SMESH::SMESH_MeshEditor::Extrusion_Error
SMESH_MeshEditor_i::ExtrusionAlongPathObject(SMESH::SMESH_IDSource_ptr theObject,
SMESH::SMESH_Mesh_ptr thePathMesh,
//function : ExtrusionAlongPathObject1D
//purpose :
//=======================================================================
-
SMESH::SMESH_MeshEditor::Extrusion_Error
SMESH_MeshEditor_i::ExtrusionAlongPathObject1D(SMESH::SMESH_IDSource_ptr theObject,
SMESH::SMESH_Mesh_ptr thePathMesh,
//function : ExtrusionAlongPathObject2D
//purpose :
//=======================================================================
-
SMESH::SMESH_MeshEditor::Extrusion_Error
SMESH_MeshEditor_i::ExtrusionAlongPathObject2D(SMESH::SMESH_IDSource_ptr theObject,
SMESH::SMESH_Mesh_ptr thePathMesh,
//=======================================================================
//function : ExtrusionAlongPathMakeGroups
-//purpose :
+//purpose :
//=======================================================================
-
SMESH::ListOfGroups*
SMESH_MeshEditor_i::ExtrusionAlongPathMakeGroups(const SMESH::long_array& theIDsOfElements,
SMESH::SMESH_Mesh_ptr thePathMesh,
const SMESH::PointStruct& theRefPoint,
SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::ListOfGroups * aGroups = extrusionAlongPath( theIDsOfElements,
thePathMesh,
thePathShape,
theRefPoint,
true,
Error);
- if ( !myPreviewMode ) {
+ if (!myPreviewMode) {
bool isDumpGroups = aGroups && aGroups->length() > 0;
- TPythonDump aPythonDump;
- if(isDumpGroups) {
- aPythonDump << "("<<aGroups;
- }
- if(isDumpGroups)
- aPythonDump << ", error)";
+ if (isDumpGroups)
+ aPythonDump << "(" << aGroups << ", error)";
else
aPythonDump <<"error";
//=======================================================================
//function : ExtrusionAlongPathObjectMakeGroups
-//purpose :
+//purpose :
//=======================================================================
-
SMESH::ListOfGroups* SMESH_MeshEditor_i::
ExtrusionAlongPathObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
SMESH::SMESH_Mesh_ptr thePathMesh,
const SMESH::PointStruct& theRefPoint,
SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
thePathMesh,
true,
Error);
- if ( !myPreviewMode ) {
+ if (!myPreviewMode) {
bool isDumpGroups = aGroups && aGroups->length() > 0;
- TPythonDump aPythonDump;
- if(isDumpGroups) {
- aPythonDump << "("<<aGroups;
- }
- if(isDumpGroups)
- aPythonDump << ", error)";
+ if (isDumpGroups)
+ aPythonDump << "(" << aGroups << ", error)";
else
aPythonDump <<"error";
//=======================================================================
//function : ExtrusionAlongPathObject1DMakeGroups
-//purpose :
+//purpose :
//=======================================================================
-
SMESH::ListOfGroups* SMESH_MeshEditor_i::
ExtrusionAlongPathObject1DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
SMESH::SMESH_Mesh_ptr thePathMesh,
const SMESH::PointStruct& theRefPoint,
SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
thePathMesh,
Error,
SMDSAbs_Edge);
- if ( !myPreviewMode ) {
+ if (!myPreviewMode) {
bool isDumpGroups = aGroups && aGroups->length() > 0;
- TPythonDump aPythonDump;
- if(isDumpGroups) {
- aPythonDump << "("<<aGroups;
- }
- if(isDumpGroups)
- aPythonDump << ", error)";
+ if (isDumpGroups)
+ aPythonDump << "(" << aGroups << ", error)";
else
- aPythonDump <<"error";
+ aPythonDump << "error";
aPythonDump << " = " << this << ".ExtrusionAlongPathObject1DMakeGroups( "
<< theObject << ", "
//=======================================================================
//function : ExtrusionAlongPathObject2DMakeGroups
-//purpose :
+//purpose :
//=======================================================================
-
SMESH::ListOfGroups* SMESH_MeshEditor_i::
ExtrusionAlongPathObject2DMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
SMESH::SMESH_Mesh_ptr thePathMesh,
const SMESH::PointStruct& theRefPoint,
SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::long_array_var anElementsId = theObject->GetIDs();
SMESH::ListOfGroups * aGroups = extrusionAlongPath( anElementsId,
thePathMesh,
Error,
SMDSAbs_Face);
- if ( !myPreviewMode ) {
+ if (!myPreviewMode) {
bool isDumpGroups = aGroups && aGroups->length() > 0;
- TPythonDump aPythonDump;
- if(isDumpGroups) {
- aPythonDump << "("<<aGroups;
- }
- if(isDumpGroups)
- aPythonDump << ", error)";
+ if (isDumpGroups)
+ aPythonDump << "(" << aGroups << ", error)";
else
- aPythonDump <<"error";
+ aPythonDump << "error";
aPythonDump << " = " << this << ".ExtrusionAlongPathObject2DMakeGroups( "
<< theObject << ", "
//=======================================================================
//function : ExtrusionAlongPathObjX
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups* SMESH_MeshEditor_i::
ExtrusionAlongPathObjX(SMESH::SMESH_IDSource_ptr Object,
SMESH::ElementType ElemType,
SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::long_array_var anElementsId = Object->GetIDs();
SMESH::ListOfGroups * aGroups = extrusionAlongPathX(anElementsId,
Path,
(SMDSAbs_ElementType)ElemType,
Error);
- if ( !myPreviewMode ) {
+ if (!myPreviewMode) {
bool isDumpGroups = aGroups && aGroups->length() > 0;
- TPythonDump aPythonDump;
- if(isDumpGroups) {
- aPythonDump << "("<<aGroups;
- }
- if(isDumpGroups)
- aPythonDump << ", error)";
+ if (isDumpGroups)
+ aPythonDump << "(" << *aGroups << ", error)";
else
- aPythonDump <<"error";
+ aPythonDump << "error";
aPythonDump << " = " << this << ".ExtrusionAlongPathObjX( "
<< Object << ", "
//=======================================================================
//function : ExtrusionAlongPathX
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups* SMESH_MeshEditor_i::
ExtrusionAlongPathX(const SMESH::long_array& IDsOfElements,
SMESH::ElementType ElemType,
SMESH::SMESH_MeshEditor::Extrusion_Error& Error)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::ListOfGroups * aGroups = extrusionAlongPathX(IDsOfElements,
Path,
NodeStart,
(SMDSAbs_ElementType)ElemType,
Error);
- if ( !myPreviewMode ) {
+ if (!myPreviewMode) {
bool isDumpGroups = aGroups && aGroups->length() > 0;
- TPythonDump aPythonDump;
- if(isDumpGroups) {
- aPythonDump << "("<<aGroups;
- }
- if(isDumpGroups)
- aPythonDump << ", error)";
+ if (isDumpGroups)
+ aPythonDump << "(" << *aGroups << ", error)";
else
aPythonDump <<"error";
<< ( HasRefPoint ? RefPoint.x : 0 ) << ", "
<< ( HasRefPoint ? RefPoint.y : 0 ) << ", "
<< ( HasRefPoint ? RefPoint.z : 0 ) << " ), "
+ << MakeGroups << ", "
<< ElemType << " )";
}
return aGroups;
/*!
* \brief Compute rotation angles for ExtrusionAlongPath as linear variation
* of given angles along path steps
- * \param PathMesh mesh containing a 1D sub-mesh on the edge, along
+ * \param PathMesh mesh containing a 1D sub-mesh on the edge, along
* which proceeds the extrusion
- * \param PathShape is shape(edge); as the mesh can be complex, the edge
+ * \param PathShape is shape(edge); as the mesh can be complex, the edge
* is used to define the sub-mesh for the path
*/
//================================================================================
//=======================================================================
//function : mirror
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
aTrsf.SetMirror( gp_Ax2( P, V ));
}
- ::SMESH_MeshEditor anEditor( myMesh );
+ TIDSortedElemSet copyElements;
+ TPreviewMesh tmpMesh;
+ TIDSortedElemSet* workElements = 0;
+ SMESH_Mesh* mesh = 0;
+
+ if ( myPreviewMode )
+ {
+ tmpMesh.Copy( theElements, copyElements);
+ mesh = &tmpMesh;
+ workElements = & copyElements;
+ }
+ else
+ {
+ mesh = myMesh;
+ workElements = & theElements;
+ }
+
+ ::SMESH_MeshEditor anEditor( mesh );
::SMESH_MeshEditor::PGroupIDs groupIds =
- anEditor.Transform (theElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
+ anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
- if(theCopy)
+ if(theCopy || myPreviewMode)
storeResult(anEditor);
else
{
<< theCopy << " )";
}
TIDSortedElemSet elements;
- if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
+
+ bool emptyIfIsMesh = myPreviewMode ? false : true;
+
+ if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
mirror(elements, theAxis, theMirrorType, theCopy, false);
}
//=======================================================================
//function : MirrorMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
const SMESH::AxisStruct& theMirror,
SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::ListOfGroups * aGroups = 0;
if ( theIDsOfElements.length() > 0 )
{
arrayToSet(theIDsOfElements, GetMeshDS(), elements);
aGroups = mirror(elements, theMirror, theMirrorType, true, true);
}
- if ( !myPreviewMode ) {
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
aPythonDump << this << ".MirrorMakeGroups( "
<< theIDsOfElements << ", "
<< theMirror << ", "
//=======================================================================
//function : MirrorObjectMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
const SMESH::AxisStruct& theMirror,
SMESH::SMESH_MeshEditor::MirrorType theMirrorType)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::ListOfGroups * aGroups = 0;
TIDSortedElemSet elements;
if ( idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
aGroups = mirror(elements, theMirror, theMirrorType, true, true);
- if ( !myPreviewMode )
+ if (!myPreviewMode)
{
- TPythonDump aPythonDump;
DumpGroupsList(aPythonDump,aGroups);
aPythonDump << this << ".MirrorObjectMakeGroups( "
<< theObject << ", "
//=======================================================================
//function : MirrorMakeMesh
-//purpose :
+//purpose :
//=======================================================================
SMESH::SMESH_Mesh_ptr
mesh_i->CreateGroupServants();
}
- if ( !myPreviewMode ) {
+ if (!myPreviewMode) {
pydump << mesh << " = " << this << ".MirrorMakeMesh( "
<< theIDsOfElements << ", "
<< theMirror << ", "
}
//dump "GetGroups"
- if(!myPreviewMode && mesh_i)
+ if (!myPreviewMode && mesh_i)
mesh_i->GetGroups();
return mesh._retn();
//=======================================================================
//function : MirrorObjectMakeMesh
-//purpose :
+//purpose :
//=======================================================================
SMESH::SMESH_Mesh_ptr
false, theCopyGroups, & mesh_i->GetImpl());
mesh_i->CreateGroupServants();
}
- if ( !myPreviewMode ) {
+ if (!myPreviewMode) {
pydump << mesh << " = " << this << ".MirrorObjectMakeMesh( "
<< theObject << ", "
<< theMirror << ", "
}
//dump "GetGroups"
- if(!myPreviewMode && mesh_i)
+ if (!myPreviewMode && mesh_i)
mesh_i->GetGroups();
return mesh._retn();
//=======================================================================
//function : translate
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
const SMESH::PointStruct * P = &theVector.PS;
aTrsf.SetTranslation( gp_Vec( P->x, P->y, P->z ));
- ::SMESH_MeshEditor anEditor( myMesh );
+ TIDSortedElemSet copyElements;
+ TPreviewMesh tmpMesh;
+ TIDSortedElemSet* workElements = 0;
+ SMESH_Mesh* mesh = 0;
+
+ if ( myPreviewMode )
+ {
+ tmpMesh.Copy( theElements, copyElements);
+ mesh = &tmpMesh;
+ workElements = & copyElements;
+ }
+ else
+ {
+ mesh = myMesh;
+ workElements = & theElements;
+ }
+
+ ::SMESH_MeshEditor anEditor( mesh );
::SMESH_MeshEditor::PGroupIDs groupIds =
- anEditor.Transform (theElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
+ anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
- if(theCopy)
+ if(theCopy || myPreviewMode)
storeResult(anEditor);
else
{
const SMESH::DirStruct & theVector,
CORBA::Boolean theCopy)
{
- if ( !myPreviewMode ) {
+ if (!myPreviewMode) {
TPythonDump() << this << ".Translate( "
<< theIDsOfElements << ", "
<< theVector << ", "
<< theCopy << " )";
}
- if ( theIDsOfElements.length() )
- {
+ if (theIDsOfElements.length()) {
TIDSortedElemSet elements;
arrayToSet(theIDsOfElements, GetMeshDS(), elements);
- translate(elements,theVector,theCopy,false);
+ translate(elements, theVector, theCopy, false);
}
}
const SMESH::DirStruct & theVector,
CORBA::Boolean theCopy)
{
- if ( !myPreviewMode ) {
+ if (!myPreviewMode) {
TPythonDump() << this << ".TranslateObject( "
<< theObject << ", "
<< theVector << ", "
<< theCopy << " )";
}
TIDSortedElemSet elements;
- if ( idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
- translate( elements, theVector, theCopy, false);
+
+ bool emptyIfIsMesh = myPreviewMode ? false : true;
+
+ if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
+ translate(elements, theVector, theCopy, false);
}
//=======================================================================
//function : TranslateMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
SMESH_MeshEditor_i::TranslateMakeGroups(const SMESH::long_array& theIDsOfElements,
const SMESH::DirStruct& theVector)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::ListOfGroups * aGroups = 0;
- if ( theIDsOfElements.length() )
- {
+ if (theIDsOfElements.length()) {
TIDSortedElemSet elements;
arrayToSet(theIDsOfElements, GetMeshDS(), elements);
aGroups = translate(elements,theVector,true,true);
}
- if ( !myPreviewMode ) {
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
aPythonDump << this << ".TranslateMakeGroups( "
<< theIDsOfElements << ", "
<< theVector << " )";
//=======================================================================
//function : TranslateObjectMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
SMESH_MeshEditor_i::TranslateObjectMakeGroups(SMESH::SMESH_IDSource_ptr theObject,
const SMESH::DirStruct& theVector)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::ListOfGroups * aGroups = 0;
TIDSortedElemSet elements;
if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
aGroups = translate(elements, theVector, true, true);
- if ( !myPreviewMode ) {
-
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
aPythonDump << this << ".TranslateObjectMakeGroups( "
<< theObject << ", "
<< theVector << " )";
//=======================================================================
//function : TranslateMakeMesh
-//purpose :
+//purpose :
//=======================================================================
SMESH::SMESH_Mesh_ptr
}
//dump "GetGroups"
- if(!myPreviewMode && mesh_i)
+ if (!myPreviewMode && mesh_i)
mesh_i->GetGroups();
return mesh._retn();
//=======================================================================
//function : TranslateObjectMakeMesh
-//purpose :
+//purpose :
//=======================================================================
SMESH::SMESH_Mesh_ptr
}
}
- //dump "GetGroups"
- if(!myPreviewMode && mesh_i)
+ // dump "GetGroups"
+ if (!myPreviewMode && mesh_i)
mesh_i->GetGroups();
return mesh._retn();
//=======================================================================
//function : rotate
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
gp_Trsf aTrsf;
aTrsf.SetRotation( gp_Ax1( P, V ), theAngle);
- ::SMESH_MeshEditor anEditor( myMesh );
+ TIDSortedElemSet copyElements;
+ TPreviewMesh tmpMesh;
+ TIDSortedElemSet* workElements = 0;
+ SMESH_Mesh* mesh = 0;
+
+ if ( myPreviewMode ) {
+ tmpMesh.Copy( theElements, copyElements );
+ mesh = &tmpMesh;
+ workElements = ©Elements;
+ }
+ else
+ {
+ mesh = myMesh;
+ workElements=&theElements;
+ }
+
+ ::SMESH_MeshEditor anEditor( mesh );
::SMESH_MeshEditor::PGroupIDs groupIds =
- anEditor.Transform (theElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
+ anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
- if(theCopy)
+ if(theCopy || myPreviewMode)
storeResult(anEditor);
else
{
CORBA::Double theAngle,
CORBA::Boolean theCopy)
{
- if ( !myPreviewMode ) {
+ if (!myPreviewMode) {
TPythonDump() << this << ".Rotate( "
<< theIDsOfElements << ", "
<< theAxis << ", "
<< theAngle << ", "
<< theCopy << " )";
}
- if ( theIDsOfElements.length() > 0 )
+ if (theIDsOfElements.length() > 0)
{
TIDSortedElemSet elements;
arrayToSet(theIDsOfElements, GetMeshDS(), elements);
<< theCopy << " )";
}
TIDSortedElemSet elements;
- if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
+ bool emptyIfIsMesh = myPreviewMode ? false : true;
+ if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
rotate(elements,theAxis,theAngle,theCopy,false);
}
//=======================================================================
//function : RotateMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
const SMESH::AxisStruct& theAxis,
CORBA::Double theAngle)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::ListOfGroups * aGroups = 0;
- if ( theIDsOfElements.length() > 0 )
+ if (theIDsOfElements.length() > 0)
{
TIDSortedElemSet elements;
arrayToSet(theIDsOfElements, GetMeshDS(), elements);
aGroups = rotate(elements,theAxis,theAngle,true,true);
}
- if ( !myPreviewMode ) {
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
aPythonDump << this << ".RotateMakeGroups( "
<< theIDsOfElements << ", "
<< theAxis << ", "
//=======================================================================
//function : RotateObjectMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
const SMESH::AxisStruct& theAxis,
CORBA::Double theAngle)
{
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
+
SMESH::ListOfGroups * aGroups = 0;
TIDSortedElemSet elements;
- if ( idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
- aGroups = rotate(elements,theAxis,theAngle,true,true);
+ if (idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
+ aGroups = rotate(elements, theAxis, theAngle, true, true);
- if ( !myPreviewMode ) {
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
aPythonDump << this << ".RotateObjectMakeGroups( "
<< theObject << ", "
<< theAxis << ", "
//=======================================================================
//function : RotateMakeMesh
-//purpose :
+//purpose :
//=======================================================================
-SMESH::SMESH_Mesh_ptr
+SMESH::SMESH_Mesh_ptr
SMESH_MeshEditor_i::RotateMakeMesh(const SMESH::long_array& theIDsOfElements,
const SMESH::AxisStruct& theAxis,
CORBA::Double theAngleInRadians,
}
}
- //dump "GetGroups"
- if(!myPreviewMode && mesh_i && theIDsOfElements.length() > 0 )
+ // dump "GetGroups"
+ if (!myPreviewMode && mesh_i && theIDsOfElements.length() > 0 )
mesh_i->GetGroups();
return mesh._retn();
//=======================================================================
//function : RotateObjectMakeMesh
-//purpose :
+//purpose :
//=======================================================================
SMESH::SMESH_Mesh_ptr
}
}
- //dump "GetGroups"
- if(!myPreviewMode && mesh_i)
+ // dump "GetGroups"
+ if (!myPreviewMode && mesh_i)
mesh_i->GetGroups();
return mesh._retn();
//=======================================================================
//function : scale
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
THROW_SALOME_CORBA_EXCEPTION("Invalid nb of scale factors : 2", SALOME::BAD_PARAM);
TIDSortedElemSet elements;
- if ( !idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/true))
+ bool emptyIfIsMesh = myPreviewMode ? false : true;
+ if ( !idSourceToSet(theObject, GetMeshDS(), elements, SMDSAbs_All, emptyIfIsMesh))
return 0;
vector<double> S(3);
0, S[1], 0, thePoint.y * (1-S[1]),
0, 0, S[2], thePoint.z * (1-S[2]), tol, tol);
- ::SMESH_MeshEditor anEditor( myMesh );
+ TIDSortedElemSet copyElements;
+ TPreviewMesh tmpMesh;
+ TIDSortedElemSet* workElements = 0;
+ SMESH_Mesh* mesh = 0;
+
+ if ( myPreviewMode )
+ {
+ tmpMesh.Copy( elements, copyElements);
+ mesh = &tmpMesh;
+ workElements = & copyElements;
+ }
+ else
+ {
+ mesh = myMesh;
+ workElements = & elements;
+ }
+
+ ::SMESH_MeshEditor anEditor( mesh );
::SMESH_MeshEditor::PGroupIDs groupIds =
- anEditor.Transform (elements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
+ anEditor.Transform (*workElements, aTrsf, theCopy, theMakeGroups, theTargetMesh);
- if(theCopy)
+ if(theCopy || myPreviewMode )
storeResult(anEditor);
else
{
//=======================================================================
//function : ScaleMakeGroups
-//purpose :
+//purpose :
//=======================================================================
SMESH::ListOfGroups*
const SMESH::PointStruct& thePoint,
const SMESH::double_array& theScaleFact)
{
- SMESH::ListOfGroups * aGroups = scale(theObject, thePoint, theScaleFact, true, true);
- if ( !myPreviewMode ) {
+ TPythonDump aPythonDump; // it is here to prevent dump of GetGroups()
- TPythonDump aPythonDump;
- DumpGroupsList(aPythonDump,aGroups);
+ SMESH::ListOfGroups * aGroups = scale(theObject, thePoint, theScaleFact, true, true);
+ if (!myPreviewMode) {
+ DumpGroupsList(aPythonDump, aGroups);
aPythonDump << this << ".Scale("
<< theObject << ","
<< "SMESH.PointStruct(" <<thePoint.x << ","
//=======================================================================
//function : ScaleMakeMesh
-//purpose :
+//purpose :
//=======================================================================
SMESH::SMESH_Mesh_ptr
<< theMeshName << "' )";
}
- //dump "GetGroups"
- if(!myPreviewMode && mesh_i)
+ // dump "GetGroups"
+ if (!myPreviewMode && mesh_i)
mesh_i->GetGroups();
return mesh._retn();
void SMESH_MeshEditor_i::storeResult(::SMESH_MeshEditor& anEditor)
{
- if ( myPreviewMode ) { // --- MeshPreviewStruct filling ---
+ if ( myPreviewMode ) { // --- MeshPreviewStruct filling ---
list<int> aNodesConnectivity;
typedef map<int, int> TNodesMap;
SMDS_ElemIteratorPtr itElemNodes = aMeshElem->nodesIterator();
while ( itElemNodes->more() ) {
- const SMDS_MeshNode* aMeshNode =
+ const SMDS_MeshNode* aMeshNode =
static_cast<const SMDS_MeshNode*>( itElemNodes->next() );
int aNodeID = aMeshNode->GetID();
TNodesMap::iterator anIter = nodesMap.find(aNodeID);
}
{
- // add new nodes into myLastCreatedNodes
+ // append new nodes into myLastCreatedNodes
const SMESH_SequenceOfElemPtr& aSeq = anEditor.GetLastCreatedNodes();
- myLastCreatedNodes->length(aSeq.Length());
- for(int i=0; i<aSeq.Length(); i++)
- myLastCreatedNodes[i] = aSeq.Value(i+1)->GetID();
+ int j = myLastCreatedNodes->length();
+ int newLen = j + aSeq.Length();
+ myLastCreatedNodes->length( newLen );
+ for(int i=0; j<newLen; i++,j++)
+ myLastCreatedNodes[j] = aSeq.Value(i+1)->GetID();
}
{
- // add new elements into myLastCreatedElems
+ // append new elements into myLastCreatedElems
const SMESH_SequenceOfElemPtr& aSeq = anEditor.GetLastCreatedElems();
- myLastCreatedElems->length(aSeq.Length());
- for(int i=0; i<aSeq.Length(); i++)
- myLastCreatedElems[i] = aSeq.Value(i+1)->GetID();
+ int j = myLastCreatedElems->length();
+ int newLen = j + aSeq.Length();
+ myLastCreatedElems->length( newLen );
+ for(int i=0; j<newLen; i++,j++)
+ myLastCreatedElems[j] = aSeq.Value(i+1)->GetID();
}
}
//=======================================================================
//function : ConvertFromQuadratic
-//purpose :
+//purpose :
//=======================================================================
CORBA::Boolean SMESH_MeshEditor_i::ConvertFromQuadratic()
//=======================================================================
//function : makeMesh
-//purpose : create a named imported mesh
+//purpose : create a named imported mesh
//=======================================================================
SMESH::SMESH_Mesh_ptr SMESH_MeshEditor_i::makeMesh(const char* theMeshName)
//function : DumpGroupsList
//purpose :
//=======================================================================
-void SMESH_MeshEditor_i::DumpGroupsList(TPythonDump & theDumpPython,
+void SMESH_MeshEditor_i::DumpGroupsList(TPythonDump & theDumpPython,
const SMESH::ListOfGroups * theGroupList)
{
bool isDumpGroupList = theGroupList && theGroupList->length() > 0;
{
SMESH::ListOfGroups_var groups = myMesh_i->GetGroups();
set<string> groupNames;
-
+
// Get existing group names
for (int i = 0, nbGroups = groups->length(); i < nbGroups; i++ ) {
SMESH::SMESH_GroupBase_var aGroup = groups[i];
}
++index;
}
-
+
return name;
}
/*!
\brief Creates a hole in a mesh by doubling the nodes of some particular elements
\param theNodes - identifiers of nodes to be doubled
- \param theModifiedElems - identifiers of elements to be updated by the new (doubled)
- nodes. If list of element identifiers is empty then nodes are doubled but
+ \param theModifiedElems - identifiers of elements to be updated by the new (doubled)
+ nodes. If list of element identifiers is empty then nodes are doubled but
they not assigned to elements
\return TRUE if operation has been completed successfully, FALSE otherwise
\sa DoubleNode(), DoubleNodeGroup(), DoubleNodeGroups()
*/
//================================================================================
-CORBA::Boolean SMESH_MeshEditor_i::DoubleNodes( const SMESH::long_array& theNodes,
+CORBA::Boolean SMESH_MeshEditor_i::DoubleNodes( const SMESH::long_array& theNodes,
const SMESH::long_array& theModifiedElems )
{
initData();
*/
//================================================================================
-CORBA::Boolean SMESH_MeshEditor_i::DoubleNode( CORBA::Long theNodeId,
+CORBA::Boolean SMESH_MeshEditor_i::DoubleNode( CORBA::Long theNodeId,
const SMESH::long_array& theModifiedElems )
{
SMESH::long_array_var aNodes = new SMESH::long_array;
SMESH::long_array_var aModifiedElems;
if ( !CORBA::is_nil( theModifiedElems ) )
aModifiedElems = theModifiedElems->GetListOfID();
- else
+ else
{
aModifiedElems = new SMESH::long_array;
aModifiedElems->length( 0 );
{
if ( CORBA::is_nil( theNodes ) && theNodes->GetType() != SMESH::NODE )
return false;
-
+
SMESH::SMESH_Group_var aNewGroup;
// Duplicate nodes
aModifiedElems = new SMESH::long_array;
aModifiedElems->length( 0 );
}
-
+
TPythonDump pyDump; // suppress dump by the next line
bool aResult = DoubleNodes( aNodes, aModifiedElems );
aNewGroup->Add(anIds);
}
}
-
+
pyDump << "createdNodes = " << this << ".DoubleNodeGroupNew( " << theNodes << ", "
<< theModifiedElems << " )";
return aResult;
}
+//================================================================================
+/*!
+ * \brief Creates a hole in a mesh by doubling the nodes of some particular elements.
+ * Works as DoubleNodeGroups(), but returns a new group with newly created nodes.
+ * \param theNodes - group of nodes to be doubled.
+ * \param theModifiedElems - group of elements to be updated.
+ * \return a new group with newly created nodes
+ * \sa DoubleNodeGroups()
+ */
+//================================================================================
+
+SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeGroupsNew( const SMESH::ListOfGroups& theNodes,
+ const SMESH::ListOfGroups& theModifiedElems )
+{
+ SMESH::SMESH_Group_var aNewGroup;
+
+ TPythonDump pyDump; // suppress dump by the next line
+
+ bool aResult = DoubleNodeGroups( theNodes, theModifiedElems );
+
+ if ( aResult )
+ {
+ // Create group with newly created nodes
+ SMESH::long_array_var anIds = GetLastCreatedNodes();
+ if (anIds->length() > 0) {
+ string anUnindexedName (theNodes[0]->GetName());
+ string aNewName = generateGroupName(anUnindexedName + "_double");
+ aNewGroup = myMesh_i->CreateGroup(SMESH::NODE, aNewName.c_str());
+ aNewGroup->Add(anIds);
+ }
+ }
+
+ pyDump << "createdNodes = " << this << ".DoubleNodeGroupsNew( " << theNodes << ", "
+ << theModifiedElems << " )";
+
+ return aNewGroup._retn();
+}
+
+
//================================================================================
/*!
\brief Creates a hole in a mesh by doubling the nodes of some particular elements
\param theElems - the list of elements (edges or faces) to be replicated
The nodes for duplication could be found from these elements
\param theNodesNot - list of nodes to NOT replicate
- \param theAffectedElems - the list of elements (cells and edges) to which the
+ \param theAffectedElems - the list of elements (cells and edges) to which the
replicated nodes should be associated to.
\return TRUE if operation has been completed successfully, FALSE otherwise
\sa DoubleNodeGroup(), DoubleNodeGroups()
*/
//================================================================================
-CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElem( const SMESH::long_array& theElems,
+CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElem( const SMESH::long_array& theElems,
const SMESH::long_array& theNodesNot,
const SMESH::long_array& theAffectedElems )
*/
//================================================================================
-CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemInRegion ( const SMESH::long_array& theElems,
+CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemInRegion ( const SMESH::long_array& theElems,
const SMESH::long_array& theNodesNot,
GEOM::GEOM_Object_ptr theShape )
SMESHDS_Mesh* aMeshDS = GetMeshDS();
TIDSortedElemSet anElems, aNodes, anAffected;
- idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
- idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
+ idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
+ idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
idSourceToSet( theAffectedElems, aMeshDS, anAffected, SMDSAbs_All );
bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
SMESHDS_Mesh* aMeshDS = GetMeshDS();
TIDSortedElemSet anElems, aNodes, anAffected;
- idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
- idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
+ idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
+ idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
idSourceToSet( theAffectedElems, aMeshDS, anAffected, SMDSAbs_All );
-
+
bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
-
+
storeResult( aMeshEditor) ;
if ( aResult ) {
SMESHDS_Mesh* aMeshDS = GetMeshDS();
TIDSortedElemSet anElems, aNodes, anAffected;
- idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
- idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
+ idSourceToSet( theElems, aMeshDS, anElems, SMDSAbs_All );
+ idSourceToSet( theNodesNot, aMeshDS, aNodes, SMDSAbs_Node );
TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape );
bool aResult = aMeshEditor.DoubleNodesInRegion( anElems, aNodes, aShape );
\param theAffectedElems - group of elements to which the replicated nodes
should be associated to.
\return TRUE if operation has been completed successfully, FALSE otherwise
- \sa DoubleNodeGroup(), DoubleNodes()
+ \sa DoubleNodeGroup(), DoubleNodes(), DoubleNodeElemGroupsNew()
*/
//================================================================================
for ( int i = 0, n = theGrpList.length(); i < n; i++ )
{
SMESH::SMESH_GroupBase_var aGrp = theGrpList[ i ];
- if ( !CORBA::is_nil( aGrp ) && (theIsNodeGrp ? aGrp->GetType() == SMESH::NODE
+ if ( !CORBA::is_nil( aGrp ) && (theIsNodeGrp ? aGrp->GetType() == SMESH::NODE
: aGrp->GetType() != SMESH::NODE ) )
{
SMESH::long_array_var anIDs = aGrp->GetIDs();
return aResult;
}
+//================================================================================
+/*!
+ * \brief Creates a hole in a mesh by doubling the nodes of some particular elements
+ * Works as DoubleNodeElemGroups(), but returns a new group with newly created elements.
+ \param theElems - list of groups of elements (edges or faces) to be replicated
+ \param theNodesNot - list of groups of nodes not to replicated
+ \param theAffectedElems - group of elements to which the replicated nodes
+ should be associated to.
+ * \return a new group with newly created elements
+ * \sa DoubleNodeElemGroups()
+ */
+//================================================================================
+
+SMESH::SMESH_Group_ptr SMESH_MeshEditor_i::DoubleNodeElemGroupsNew(const SMESH::ListOfGroups& theElems,
+ const SMESH::ListOfGroups& theNodesNot,
+ const SMESH::ListOfGroups& theAffectedElems)
+{
+ SMESH::SMESH_Group_var aNewGroup;
+
+ initData();
+
+ ::SMESH_MeshEditor aMeshEditor( myMesh );
+
+ SMESHDS_Mesh* aMeshDS = GetMeshDS();
+ TIDSortedElemSet anElems, aNodes, anAffected;
+ listOfGroupToSet(theElems, aMeshDS, anElems, false );
+ listOfGroupToSet(theNodesNot, aMeshDS, aNodes, true );
+ listOfGroupToSet(theAffectedElems, aMeshDS, anAffected, false );
+
+ bool aResult = aMeshEditor.DoubleNodes( anElems, aNodes, anAffected );
+
+ storeResult( aMeshEditor) ;
+
+ myMesh->GetMeshDS()->Modified();
+ if ( aResult ) {
+ myMesh->SetIsModified( true );
+
+ // Create group with newly created elements
+ SMESH::long_array_var anIds = GetLastCreatedElems();
+ if (anIds->length() > 0) {
+ SMESH::ElementType aGroupType = myMesh_i->GetElementType(anIds[0], true);
+ string anUnindexedName (theElems[0]->GetName());
+ string aNewName = generateGroupName(anUnindexedName + "_double");
+ aNewGroup = myMesh_i->CreateGroup(aGroupType, aNewName.c_str());
+ aNewGroup->Add(anIds);
+ }
+ }
+
+ // Update Python script
+ TPythonDump() << "createdElems = " << this << ".DoubleNodeElemGroupsNew( " << &theElems << ", "
+ << &theNodesNot << ", " << &theAffectedElems << " )";
+ return aNewGroup._retn();
+}
+
//================================================================================
/*!
\brief Creates a hole in a mesh by doubling the nodes of some particular elements
* \param meshName - a name of new mesh to store created boundary elements in,
* "" means not to create the new mesh
* \param toCopyElements - if true, the checked elements will be copied into the new mesh
- * \param toCopyExistingBondary - if true, not only new but also pre-existing
+ * \param toCopyExistingBondary - if true, not only new but also pre-existing
* boundary elements will be copied into the new mesh
* \param group - returns the create group, if any
* \retval SMESH::SMESH_Mesh - the mesh where elements were added to
if ( dim > SMESH::BND_1DFROM2D )
THROW_SALOME_CORBA_EXCEPTION("Invalid boundary dimension", SALOME::BAD_PARAM);
-
SMESHDS_Mesh* aMeshDS = GetMeshDS();
SMESH::SMESH_Mesh_var mesh_var;
SMESH_Group* smesh_group = 0;
if ( strlen(groupName) )
{
- group_var = mesh_i->CreateGroup( SMESH::ElementType(elemType),groupName);
+ group_var = mesh_i->CreateGroup( SMESH::ElementType(int(elemType)-1),groupName);
if ( SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>( group_var ))
smesh_group = group_i->GetSmeshGroup();
}
toCopyElements,
toCopyExistingBondary);
storeResult( aMeshEditor );
+
+ if ( smesh_mesh )
+ smesh_mesh->GetMeshDS()->Modified();
}
+ const char* dimName[] = { "BND_2DFROM3D", "BND_1DFROM3D", "BND_1DFROM2D" };
+
// result of MakeBoundaryMesh() is a tuple (mesh, group)
if ( mesh_var->_is_nil() )
pyDump << myMesh_i->_this() << ", ";
pyDump << group_var << " = ";
pyDump << this << ".MakeBoundaryMesh( "
<< idSource << ", "
- << dim << ", "
- << groupName << ", "
- << meshName<< ", "
+ << "SMESH." << dimName[int(dim)] << ", "
+ << "'" << groupName << "', "
+ << "'" << meshName<< "', "
<< toCopyElements << ", "
<< toCopyExistingBondary << ")";
group = group_var._retn();
return mesh_var._retn();
}
+
+//================================================================================
+/*!
+ * \brief Creates missing boundary elements
+ * \param dimension - defines type of boundary elements to create
+ * \param groupName - a name of group to store all boundary elements in,
+ * "" means not to create the group
+ * \param meshName - a name of a new mesh, which is a copy of the initial
+ * mesh + created boundary elements; "" means not to create the new mesh
+ * \param toCopyAll - if true, the whole initial mesh will be copied into
+ * the new mesh else only boundary elements will be copied into the new mesh
+ * \param groups - optional groups of elements to make boundary around
+ * \param mesh - returns the mesh where elements were added to
+ * \param group - returns the created group, if any
+ * \retval long - number of added boundary elements
+ */
+//================================================================================
+
+CORBA::Long SMESH_MeshEditor_i::MakeBoundaryElements(SMESH::Bnd_Dimension dim,
+ const char* groupName,
+ const char* meshName,
+ CORBA::Boolean toCopyAll,
+ const SMESH::ListOfIDSources& groups,
+ SMESH::SMESH_Mesh_out mesh,
+ SMESH::SMESH_Group_out group)
+ throw (SALOME::SALOME_Exception)
+{
+ Unexpect aCatch(SALOME_SalomeException);
+
+ initData();
+
+ if ( dim > SMESH::BND_1DFROM2D )
+ THROW_SALOME_CORBA_EXCEPTION("Invalid boundary dimension", SALOME::BAD_PARAM);
+
+ // check that groups belongs to to this mesh and is not this mesh
+ const int nbGroups = groups.length();
+ for ( int i = 0; i < nbGroups; ++i )
+ {
+ SMESH::SMESH_Mesh_var m = groups[i]->GetMesh();
+ if ( myMesh_i != SMESH::DownCast<SMESH_Mesh_i*>( m ))
+ THROW_SALOME_CORBA_EXCEPTION("group does not belong to this mesh", SALOME::BAD_PARAM);
+ if ( SMESH::DownCast<SMESH_Mesh_i*>( groups[i] ))
+ THROW_SALOME_CORBA_EXCEPTION("expect a group but recieve a mesh", SALOME::BAD_PARAM);
+ }
+
+ TPythonDump pyDump;
+
+ int nbAdded = 0;
+ SMESH::SMESH_Mesh_var mesh_var;
+ SMESH::SMESH_Group_var group_var;
+
+ // get mesh to fill
+ mesh_var = SMESH::SMESH_Mesh::_duplicate( myMesh_i->_this() );
+ const bool toCopyMesh = ( strlen( meshName ) > 0 );
+ if ( toCopyMesh )
+ {
+ if ( toCopyAll )
+ mesh_var = SMESH_Gen_i::GetSMESHGen()->CopyMesh(mesh_var,
+ meshName,
+ /*toCopyGroups=*/false,
+ /*toKeepIDs=*/true);
+ else
+ mesh_var = makeMesh(meshName);
+ }
+ SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh_var );
+ SMESH_Mesh* tgtMesh = &mesh_i->GetImpl();
+
+ // source mesh
+ SMESH_Mesh* srcMesh = ( toCopyMesh && !toCopyAll ) ? myMesh : tgtMesh;
+ SMESHDS_Mesh* srcMeshDS = srcMesh->GetMeshDS();
+
+ // group of new boundary elements
+ SMESH_Group* smesh_group = 0;
+ SMDSAbs_ElementType elemType = (dim == SMESH::BND_2DFROM3D) ? SMDSAbs_Volume : SMDSAbs_Face;
+ if ( strlen(groupName) )
+ {
+ SMESH::ElementType groupType = SMESH::ElementType( int(elemType)-1 );
+ group_var = mesh_i->CreateGroup( groupType, groupName );
+ if ( SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>( group_var ))
+ smesh_group = group_i->GetSmeshGroup();
+ }
+
+ TIDSortedElemSet elements;
+
+ if ( nbGroups > 0 )
+ {
+ for ( int i = 0; i < nbGroups; ++i )
+ {
+ elements.clear();
+ if ( idSourceToSet( groups[i], srcMeshDS, elements, elemType,/*emptyIfIsMesh=*/false ))
+ {
+ SMESH::Bnd_Dimension bdim =
+ ( elemType == SMDSAbs_Volume ) ? SMESH::BND_2DFROM3D : SMESH::BND_1DFROM2D;
+ ::SMESH_MeshEditor aMeshEditor( srcMesh );
+ nbAdded += aMeshEditor.MakeBoundaryMesh( elements,
+ ::SMESH_MeshEditor::Bnd_Dimension(bdim),
+ smesh_group,
+ tgtMesh,
+ /*toCopyElements=*/false,
+ /*toCopyExistingBondary=*/srcMesh != tgtMesh,
+ /*toAddExistingBondary=*/true,
+ /*aroundElements=*/true);
+ storeResult( aMeshEditor );
+ }
+ }
+ }
+ else
+ {
+ ::SMESH_MeshEditor aMeshEditor( srcMesh );
+ nbAdded += aMeshEditor.MakeBoundaryMesh( elements,
+ ::SMESH_MeshEditor::Bnd_Dimension(dim),
+ smesh_group,
+ tgtMesh,
+ /*toCopyElements=*/false,
+ /*toCopyExistingBondary=*/srcMesh != tgtMesh,
+ /*toAddExistingBondary=*/true);
+ storeResult( aMeshEditor );
+ }
+ tgtMesh->GetMeshDS()->Modified();
+
+ const char* dimName[] = { "BND_2DFROM3D", "BND_1DFROM3D", "BND_1DFROM2D" };
+
+ // result of MakeBoundaryElements() is a tuple (nb, mesh, group)
+ pyDump << "nbAdded, ";
+ if ( mesh_var->_is_nil() )
+ pyDump << myMesh_i->_this() << ", ";
+ else
+ pyDump << mesh_var << ", ";
+ if ( group_var->_is_nil() )
+ pyDump << "_NoneGroup = "; // assignment to None is forbiden
+ else
+ pyDump << group_var << " = ";
+ pyDump << this << ".MakeBoundaryElements( "
+ << "SMESH." << dimName[int(dim)] << ", "
+ << "'" << groupName << "', "
+ << "'" << meshName<< "', "
+ << toCopyAll << ", "
+ << groups << ")";
+
+ mesh = mesh_var._retn();
+ group = group_var._retn();
+ return nbAdded;
+}