// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
#include <sstream>
+typedef map<const SMDS_MeshElement*,
+ list<const SMDS_MeshElement*> > TElemOfElemListMap;
+
using namespace std;
//=======================================================================
//function : addAxis
-//purpose :
+//purpose :
//=======================================================================
static TCollection_AsciiString& addAxis(TCollection_AsciiString& theStr,
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
#ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"AddVolume: \", isDone" );
#endif
-
+
return true;
};
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
const SMDS_MeshNode * node = GetMeshDS()->FindNode( NodeID );
if ( !node )
return false;
-
+
GetMeshDS()->MoveNode(node, x, y, z);
// Update Python script
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
-
-CORBA::Boolean
- SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfElements,
- SMESH::NumericalFunctor_ptr Criterion,
- CORBA::Double MaxAngle)
+CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfElements,
+ SMESH::NumericalFunctor_ptr Criterion,
+ CORBA::Double MaxAngle)
{
set<const SMDS_MeshElement*> faces;
for (int i = 0; i < IDsOfElements.length(); i++)
if ( elem && elem->GetType() == SMDSAbs_Face)
faces.insert( elem );
}
- SMESH::NumericalFunctor_i* aNumericalFunctor =
+ SMESH::NumericalFunctor_i* aNumericalFunctor =
dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
SMESH::Controls::NumericalFunctorPtr aCrit;
if ( !aNumericalFunctor )
// Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.TriToQuad(");
SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", None, ";
- str += (Standard_Real) MaxAngle;
- SMESH_Gen_i::AddToCurrentPyScript( str + ")" );
+ str += TCollection_AsciiString((Standard_Real) MaxAngle) + ")";
+ SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"TriToQuad: \", isDone" );
#endif
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
-
-CORBA::Boolean
- SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject,
- SMESH::NumericalFunctor_ptr Criterion,
- CORBA::Double MaxAngle)
+CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject,
+ SMESH::NumericalFunctor_ptr Criterion,
+ CORBA::Double MaxAngle)
{
SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
// Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.TriToQuadObject(");
SMESH_Gen_i::AddObject( str, theObject ) += ", None, ";
- str += (Standard_Real) MaxAngle;
- SMESH_Gen_i::AddToCurrentPyScript( str + ")" );
+ str += TCollection_AsciiString((Standard_Real) MaxAngle) + ")";
+ SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"TriToQuadObject: \", isDone" );
#endif
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
-
-CORBA::Boolean
- SMESH_MeshEditor_i::QuadToTri(const SMESH::long_array & IDsOfElements,
- SMESH::NumericalFunctor_ptr Criterion)
+CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfElements,
+ SMESH::NumericalFunctor_ptr Criterion)
{
set<const SMDS_MeshElement*> faces;
for (int i = 0; i < IDsOfElements.length(); i++)
if ( elem && elem->GetType() == SMDSAbs_Face)
faces.insert( elem );
}
- SMESH::NumericalFunctor_i* aNumericalFunctor =
+ SMESH::NumericalFunctor_i* aNumericalFunctor =
dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
SMESH::Controls::NumericalFunctorPtr aCrit;
if ( !aNumericalFunctor )
// Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.QuadToTri(");
- SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", None ), ";
+ SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", None )";
SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"QuadToTri: \", isDone" );
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
+CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr theObject,
+ SMESH::NumericalFunctor_ptr Criterion)
+{
+ SMESH::long_array_var anElementsId = theObject->GetIDs();
+ CORBA::Boolean isDone = QuadToTri(anElementsId, Criterion);
-CORBA::Boolean
- SMESH_MeshEditor_i::SplitQuad(const SMESH::long_array & IDsOfElements,
- CORBA::Boolean Diag13)
+ // Clear python line(s), created by QuadToTri()
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
+#ifdef _DEBUG_
+ aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
+#endif
+
+ // Update Python script
+ TCollection_AsciiString str ("isDone = mesh_editor.QuadToTriObject(");
+ SMESH_Gen_i::AddObject( str, theObject ) += ", None )";
+ SMESH_Gen_i::AddToCurrentPyScript( str );
+#ifdef _DEBUG_
+ SMESH_Gen_i::AddToCurrentPyScript( "print \"QuadToTriObject: \", isDone" );
+#endif
+
+ return isDone;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfElements,
+ CORBA::Boolean Diag13)
{
set<const SMDS_MeshElement*> faces;
for (int i = 0; i < IDsOfElements.length(); i++)
// Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.SplitQuad(");
SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", ";
- str += TCollection_AsciiString( Diag13 );
- SMESH_Gen_i::AddToCurrentPyScript( str + ")" );
+ str += TCollection_AsciiString( Diag13 ) + ")";
+ SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"SplitQuad: \", isDone" );
#endif
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
-
-CORBA::Boolean
- SMESH_MeshEditor_i::SplitQuadObject(SMESH::SMESH_IDSource_ptr theObject,
- CORBA::Boolean Diag13)
+CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
+ CORBA::Boolean Diag13)
{
SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = SplitQuad(anElementsId, Diag13);
return isDone;
}
+//=============================================================================
+/*!
+ * BestSplit
+ */
+//=============================================================================
+CORBA::Long SMESH_MeshEditor_i::BestSplit (CORBA::Long IDOfQuad,
+ SMESH::NumericalFunctor_ptr Criterion)
+{
+ const SMDS_MeshElement* quad = GetMeshDS()->FindElement(IDOfQuad);
+ if (quad && quad->GetType() == SMDSAbs_Face && quad->NbNodes() == 4)
+ {
+ SMESH::NumericalFunctor_i* aNumericalFunctor =
+ dynamic_cast<SMESH::NumericalFunctor_i*>(SMESH_Gen_i::GetServant(Criterion).in());
+ SMESH::Controls::NumericalFunctorPtr aCrit;
+ if (aNumericalFunctor)
+ aCrit = aNumericalFunctor->GetNumericalFunctor();
+ else
+ aCrit.reset(new SMESH::Controls::AspectRatio());
+
+ ::SMESH_MeshEditor anEditor (_myMesh);
+ return anEditor.BestSplit(quad, aCrit);
+ }
+ return -1;
+}
+
//=======================================================================
//function : Smooth
-//purpose :
+//purpose :
//=======================================================================
CORBA::Boolean
//=======================================================================
//function : SmoothParametric
-//purpose :
+//purpose :
//=======================================================================
CORBA::Boolean
//=======================================================================
//function : SmoothObject
-//purpose :
+//purpose :
//=======================================================================
CORBA::Boolean
//=======================================================================
//function : SmoothParametricObject
-//purpose :
+//purpose :
//=======================================================================
CORBA::Boolean
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
str += (Standard_Integer) MaxNbOfIterations;
str += ", ";
str += (Standard_Real) MaxAspectRatio;
- if ( Method == ::SMESH_MeshEditor::CENTROIDAL )
+ if ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH )
str += ", SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH, ";
else
str += ", SMESH.SMESH_MeshEditor.LAPLACIAN_SMOOTH, ";
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=============================================================================
/*!
- *
+ *
*/
//=============================================================================
//=======================================================================
//function : RotationSweep
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElements,
//=======================================================================
//function : RotationSweepObject
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject,
//=======================================================================
//function : ExtrusionSweep
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements,
gp_Vec stepVec( P->x, P->y, P->z );
::SMESH_MeshEditor anEditor( _myMesh );
- anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
+ //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
+ TElemOfElemListMap aHystory;
+ anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
// Update Python script
TCollection_AsciiString str = "stepVector = SMESH.DirStruct( SMESH.PointStruct ( ";
//=======================================================================
//function : ExtrusionSweepObject
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject,
str += TCollection_AsciiString((int)theNbOfSteps) + " )";
SMESH_Gen_i::AddToCurrentPyScript( str );
}
+
//=======================================================================
//function : ExtrusionSweepObject1D
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::ExtrusionSweepObject1D(SMESH::SMESH_IDSource_ptr theObject,
gp_Vec stepVec( P->x, P->y, P->z );
::SMESH_MeshEditor anEditor( _myMesh );
- anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
+ //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
+ TElemOfElemListMap aHystory;
+ anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
}
//=======================================================================
//function : ExtrusionSweepObject2D
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::ExtrusionSweepObject2D(SMESH::SMESH_IDSource_ptr theObject,
gp_Vec stepVec( P->x, P->y, P->z );
::SMESH_MeshEditor anEditor( _myMesh );
- anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
+ //anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps);
+ TElemOfElemListMap aHystory;
+ anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
}
+
+//=======================================================================
+//function : AdvancedExtrusion
+//purpose :
+//=======================================================================
+
+void SMESH_MeshEditor_i::AdvancedExtrusion(const SMESH::long_array & theIDsOfElements,
+ const SMESH::DirStruct & theStepVector,
+ CORBA::Long theNbOfSteps,
+ CORBA::Long theExtrFlags,
+ CORBA::Double theSewTolerance)
+{
+ SMESHDS_Mesh* aMesh = GetMeshDS();
+
+ 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 );
+ }
+ const SMESH::PointStruct * P = &theStepVector.PS;
+ gp_Vec stepVec( P->x, P->y, P->z );
+
+ ::SMESH_MeshEditor anEditor( _myMesh );
+ TElemOfElemListMap aHystory;
+ anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory,
+ theExtrFlags, theSewTolerance);
+
+ // Update Python script
+ TCollection_AsciiString str = "stepVector = SMESH.DirStruct( SMESH.PointStruct ( ";
+ str += (TCollection_AsciiString) stepVec.X() + ", ";
+ str += (TCollection_AsciiString) stepVec.Y() + ", ";
+ str += (TCollection_AsciiString) stepVec.Z() + " ))";
+ SMESH_Gen_i::AddToCurrentPyScript( str );
+ str = ("mesh_editor.AdvancedExtrusion(");
+ SMESH_Gen_i::AddArray( str, theIDsOfElements ) += ", stepVector, ";
+ str += TCollection_AsciiString((int)theNbOfSteps) + ",";
+ str += TCollection_AsciiString((int)theExtrFlags) + ", ";
+ str += TCollection_AsciiString((double)theSewTolerance) + " )";
+ SMESH_Gen_i::AddToCurrentPyScript( str );
+}
+
+
#define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
static SMESH::SMESH_MeshEditor::Extrusion_Error convExtrError( const::SMESH_MeshEditor::Extrusion_Error e )
//=======================================================================
//function : ExtrusionAlongPath
-//purpose :
+//purpose :
//=======================================================================
SMESH::SMESH_MeshEditor::Extrusion_Error
//=======================================================================
//function : ExtrusionAlongPathObject
-//purpose :
+//purpose :
//=======================================================================
SMESH::SMESH_MeshEditor::Extrusion_Error
//=======================================================================
//function : Mirror
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElements,
//=======================================================================
//function : MirrorObject
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObject,
//=======================================================================
//function : Translate
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements,
//=======================================================================
//function : TranslateObject
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject,
//=======================================================================
//function : Rotate
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements,
gp_Trsf aTrsf;
aTrsf.SetRotation( gp_Ax1( P, V ), theAngle);
-
+
::SMESH_MeshEditor anEditor( _myMesh );
anEditor.Transform (elements, aTrsf, theCopy);
//=======================================================================
//function : RotateObject
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject,
//=======================================================================
//function : FindCoincidentNodes
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double Tolerance,
//=======================================================================
//function : MergeNodes
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes)
//=======================================================================
//function : MergeEqualElements
-//purpose :
+//purpose :
//=======================================================================
void SMESH_MeshEditor_i::MergeEqualElements()
//=======================================================================
//function : operator
-//purpose :
+//purpose :
//=======================================================================
#define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm;
//=======================================================================
//function : SewFreeBorders
-//purpose :
+//purpose :
//=======================================================================
SMESH::SMESH_MeshEditor::Sew_Error
//=======================================================================
//function : SewConformFreeBorders
-//purpose :
+//purpose :
//=======================================================================
SMESH::SMESH_MeshEditor::Sew_Error
//=======================================================================
//function : SewBorderToSide
-//purpose :
+//purpose :
//=======================================================================
SMESH::SMESH_MeshEditor::Sew_Error
//=======================================================================
//function : SewSideElements
-//purpose :
+//purpose :
//=======================================================================
SMESH::SMESH_MeshEditor::Sew_Error