-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
SMDS_MeshElement::Filter & filter = *aFilter;
if ( aType == SMDSAbs_Node )
- for (int i=0; i<IDs.length(); i++) {
+ for ( CORBA::ULong i = 0; i < IDs.length(); i++ ) {
const SMDS_MeshElement * elem = aMesh->FindNode( IDs[i] );
if ( filter( elem ))
aMap.insert( aMap.end(), elem );
}
else
- for (int i=0; i<IDs.length(); i++) {
+ for ( CORBA::ULong i = 0; i<IDs.length(); i++) {
const SMDS_MeshElement * elem = aMesh->FindElement( IDs[i] );
if ( filter( elem ))
aMap.insert( aMap.end(), elem );
SMESH::long_array_var aElementsId = theObject->GetIDs();
if ( types->length() == 1 && types[0] == SMESH::NODE)
{
- for(int i = 0; i < aElementsId->length(); i++)
+ for ( CORBA::ULong i = 0; i < aElementsId->length(); i++ )
if ( const SMDS_MeshNode * n = theMeshDS->FindNode( aElementsId[i] ))
theNodeSet.insert( theNodeSet.end(), n);
}
{
SMDS_NodeIteratorPtr nIt = theMeshDS->nodesIterator();
while ( nIt->more( ))
- if( const SMDS_MeshElement * elem = nIt->next() )
+ if ( const SMDS_MeshElement * elem = nIt->next() )
theNodeSet.insert( elem->begin_nodes(), elem->end_nodes());
}
else
{
- for(int i = 0; i < aElementsId->length(); i++)
- if( const SMDS_MeshElement * elem = theMeshDS->FindElement( aElementsId[i] ))
+ for ( CORBA::ULong i = 0; i < aElementsId->length(); i++ )
+ if ( const SMDS_MeshElement * elem = theMeshDS->FindElement( aElementsId[i] ))
theNodeSet.insert( elem->begin_nodes(), elem->end_nodes());
}
}
SMDSAbs_ElementType elemType = (*theElements.begin())->GetType();
bool sameElemType = ( elemType == (*theElements.rbegin())->GetType() );
if ( sameElemType &&
- theMeshDS->GetMeshInfo().NbElements( elemType ) == theElements.size() )
+ theMeshDS->GetMeshInfo().NbElements( elemType ) == (int) theElements.size() )
return; // all the elements are in theElements
if ( !sameElemType )
list< int > IdList;
- for (int i = 0; i < IDsOfElements.length(); i++)
+ for ( CORBA::ULong i = 0; i < IDsOfElements.length(); i++ )
IdList.push_back( IDsOfElements[i] );
// Update Python script
initData();
list< int > IdList;
- for (int i = 0; i < IDsOfNodes.length(); i++)
+ for ( CORBA::ULong i = 0; i < IDsOfNodes.length(); i++)
IdList.push_back( IDsOfNodes[i] );
// Update Python script
SMESH::Controls::Filter::GetElementsId( getMeshDS(), predicate, seq );
// remove orphan nodes (if there are any)
- list< int > IdList;
- for ( int i = 0; i < seq.size(); i++ )
- IdList.push_back( seq[i] );
+ list< int > IdList( seq.begin(), seq.end() );
int nbNodesBefore = myMesh->NbNodes();
getEditor().Remove( IdList, true );
*/
//=============================================================================
-CORBA::Long SMESH_MeshEditor_i::Add0DElement(CORBA::Long IDOfNode)
+CORBA::Long SMESH_MeshEditor_i::Add0DElement(CORBA::Long IDOfNode,
+ CORBA::Boolean DuplicateElements)
throw (SALOME::SALOME_Exception)
{
SMESH_TRY;
initData();
const SMDS_MeshNode* aNode = getMeshDS()->FindNode(IDOfNode);
- SMDS_MeshElement* elem = getMeshDS()->Add0DElement(aNode);
+ SMDS_ElemIteratorPtr it0D = aNode->GetInverseElementIterator( SMDSAbs_0DElement );
+
+ SMDS_MeshElement* elem = 0;
+ if ( DuplicateElements || !it0D->more() )
+ elem = getMeshDS()->Add0DElement(aNode);
// Update Python script
TPythonDump() << "elem0d = " << this << ".Add0DElement( " << IDOfNode <<" )";
//=============================================================================
//
-// \brief Create 0D elements on all nodes of the given object except those
-// nodes on which a 0D element already exists.
+// \brief Create 0D elements on all nodes of the given object.
// \param theObject object on whose nodes 0D elements will be created.
// \param theGroupName optional name of a group to add 0D elements created
// and/or found on nodes of \a theObject.
+// \param DuplicateElements to add one more 0D element to a node or not.
// \return an object (a new group or a temporary SMESH_IDSource) holding
// ids of new and/or found 0D elements.
//
SMESH::SMESH_IDSource_ptr
SMESH_MeshEditor_i::Create0DElementsOnAllNodes(SMESH::SMESH_IDSource_ptr theObject,
- const char* theGroupName)
+ const char* theGroupName,
+ CORBA::Boolean theDuplicateElements)
throw (SALOME::SALOME_Exception)
{
SMESH_TRY;
TIDSortedElemSet elements, elems0D;
if ( idSourceToSet( theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
- getEditor().Create0DElementsOnAllNodes( elements, elems0D );
+ getEditor().Create0DElementsOnAllNodes( elements, elems0D, theDuplicateElements );
SMESH::long_array_var newElems = new SMESH::long_array;
newElems->length( elems0D.size() );
SMESH_TRY;
initData();
- for (int i = 0; i < IDsOfElements.length(); i++)
+ for ( CORBA::ULong i = 0; i < IDsOfElements.length(); i++ )
{
CORBA::Long index = IDsOfElements[i];
const SMDS_MeshElement * elem = getMeshDS()->FindElement(index);
arrayToSet(IDsOfElements, aMesh, elements, SMDSAbs_Face);
set<const SMDS_MeshNode*> fixedNodes;
- for (int i = 0; i < IDsOfFixedNodes.length(); i++) {
+ for ( CORBA::ULong i = 0; i < IDsOfFixedNodes.length(); i++) {
CORBA::Long index = IDsOfFixedNodes[i];
const SMDS_MeshNode * node = aMesh->FindNode(index);
if ( node )
bool myIsExtrusionByNormal;
static int makeFlags( CORBA::Boolean MakeGroups,
+ CORBA::Boolean LinearVariation = false,
CORBA::Boolean ByAverageNormal = false,
CORBA::Boolean UseInputElemsOnly = false,
CORBA::Long Flags = 0,
if ( MakeGroups ) Flags |= ::SMESH_MeshEditor::EXTRUSION_FLAG_GROUPS;
if ( ByAverageNormal ) Flags |= ::SMESH_MeshEditor::EXTRUSION_FLAG_BY_AVG_NORMAL;
if ( UseInputElemsOnly) Flags |= ::SMESH_MeshEditor::EXTRUSION_FLAG_USE_INPUT_ELEMS_ONLY;
+ if ( LinearVariation ) Flags |= ::SMESH_MeshEditor::EXTRUSION_FLAG_SCALE_LINEAR_VARIATION;
if ( MakeBoundary ) Flags |= ::SMESH_MeshEditor::EXTRUSION_FLAG_BOUNDARY;
return Flags;
}
// standard params
- ExtrusionParams(const SMESH::DirStruct & theDir,
- CORBA::Long theNbOfSteps,
- CORBA::Boolean theMakeGroups):
+ ExtrusionParams(const SMESH::DirStruct & theDir,
+ CORBA::Long theNbOfSteps,
+ const SMESH::double_array & theScaleFactors,
+ CORBA::Boolean theLinearVariation,
+ const SMESH::double_array & theBasePoint,
+ CORBA::Boolean theMakeGroups):
::SMESH_MeshEditor::ExtrusParam ( gp_Vec( theDir.PS.x,
theDir.PS.y,
theDir.PS.z ),
theNbOfSteps,
- makeFlags( theMakeGroups )),
+ toList( theScaleFactors ),
+ TBasePoint( theBasePoint ),
+ makeFlags( theMakeGroups, theLinearVariation )),
myIsExtrusionByNormal( false )
{
}
theDir.PS.y,
theDir.PS.z ),
theNbOfSteps,
- makeFlags( theMakeGroups, false, false,
+ std::list<double>(),
+ 0,
+ makeFlags( theMakeGroups, false, false, false,
theExtrFlags, false ),
theSewTolerance ),
myIsExtrusionByNormal( false )
CORBA::Boolean theMakeGroups ):
::SMESH_MeshEditor::ExtrusParam ( theStepSize,
theNbOfSteps,
- makeFlags( theMakeGroups,
+ makeFlags( theMakeGroups, false,
theByAverageNormal, theUseInputElemsOnly ),
theDim),
myIsExtrusionByNormal( true )
{
Flags() &= ~(::SMESH_MeshEditor::EXTRUSION_FLAG_GROUPS);
}
+
+ private:
+
+ static std::list<double> toList( const SMESH::double_array & theScaleFactors )
+ {
+ std::list<double> scales;
+ for ( CORBA::ULong i = 0; i < theScaleFactors.length(); ++i )
+ scales.push_back( theScaleFactors[i] );
+ return scales;
+ }
+
+ // structure used to convert SMESH::double_array to gp_XYZ*
+ struct TBasePoint
+ {
+ gp_XYZ *pp, p;
+ TBasePoint( const SMESH::double_array & theBasePoint )
+ {
+ pp = 0;
+ if ( theBasePoint.length() == 3 )
+ {
+ p.SetCoord( theBasePoint[0], theBasePoint[1], theBasePoint[2] );
+ pp = &p;
+ }
+ }
+ operator const gp_XYZ*() const { return pp; }
+ };
};
}
const SMESH::ListOfIDSources & theFaces,
const SMESH::DirStruct & theStepVector,
CORBA::Long theNbOfSteps,
+ const SMESH::double_array & theScaleFactors,
+ CORBA::Boolean theLinearVariation,
+ const SMESH::double_array & theBasePoint,
CORBA::Boolean theToMakeGroups)
throw (SALOME::SALOME_Exception)
{
SMESH_TRY;
initData();
- ExtrusionParams params( theStepVector, theNbOfSteps, theToMakeGroups );
+ ExtrusionParams params( theStepVector, theNbOfSteps, theScaleFactors,
+ theLinearVariation, theBasePoint, theToMakeGroups );
TIDSortedElemSet elemsNodes[2];
for ( int i = 0, nb = theNodes.length(); i < nb; ++i ) {
idSourceToSet( theFaces[i], getMeshDS(), elemsNodes[0], SMDSAbs_Face );
list<double> angles;
- for (int i = 0; i < theAngles.length(); i++) {
+ for ( CORBA::ULong i = 0; i < theAngles.length(); i++ ) {
angles.push_back( theAngles[i] );
}
}
if ( !myIsPreviewMode ) {
- aPythonDump << "(" << aGroups << ", error) = "
- << this << ".ExtrusionAlongPathObjects( "
+ if ( aGroups->length() > 0 ) aPythonDump << "(" << aGroups << ", error) = ";
+ else aPythonDump << "(_noGroups, error) = ";
+ aPythonDump << this << ".ExtrusionAlongPathObjects( "
<< theNodes << ", "
<< theEdges << ", "
<< theFaces << ", "
<< thePathShape << ", "
<< theNodeStart << ", "
<< theHasAngles << ", "
- << theAngles << ", "
+ << TVar( theAngles ) << ", "
<< theLinearVariation << ", "
<< theHasRefPoint << ", "
<< "SMESH.PointStruct( "
- << ( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
- << ( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
- << ( theHasRefPoint ? theRefPoint.z : 0 ) << " ), "
+ << TVar( theHasRefPoint ? theRefPoint.x : 0 ) << ", "
+ << TVar( theHasRefPoint ? theRefPoint.y : 0 ) << ", "
+ << TVar( theHasRefPoint ? theRefPoint.z : 0 ) << " ), "
<< theMakeGroups << " )";
}
else
TIDSortedNodeSet nodes;
idSourceToNodeSet( theObject, getMeshDS(), nodes );
- for ( int i = 0; i < theExceptSubMeshOrGroups.length(); ++i )
+ for ( CORBA::ULong i = 0; i < theExceptSubMeshOrGroups.length(); ++i )
{
SMDS_ElemIteratorPtr nodeIt = myMesh_i->GetElements( theExceptSubMeshOrGroups[i],
SMESH::NODE );
aTPythonDump << this << ".MergeNodes([";
TIDSortedNodeSet setOfNodesToKeep;
- for ( int i = 0; i < NodesToKeep.length(); ++i )
+ for ( CORBA::ULong i = 0; i < NodesToKeep.length(); ++i )
{
prepareIdSource( NodesToKeep[i] );
SMDS_ElemIteratorPtr nodeIt = myMesh_i->GetElements( NodesToKeep[i], SMESH::NODE );
}
::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes;
- for (int i = 0; i < GroupsOfNodes.length(); i++)
+ for ( CORBA::ULong i = 0; i < GroupsOfNodes.length(); i++ )
{
const SMESH::long_array& aNodeGroup = GroupsOfNodes[ i ];
aListOfListOfNodes.push_back( list< const SMDS_MeshNode* >() );
list< const SMDS_MeshNode* >& aListOfNodes = aListOfListOfNodes.back();
- for ( int j = 0; j < aNodeGroup.length(); j++ )
+ for ( CORBA::ULong j = 0; j < aNodeGroup.length(); j++ )
{
CORBA::Long index = aNodeGroup[ j ];
if ( const SMDS_MeshNode * node = aMesh->FindNode( index ))
::SMESH_MeshEditor::TListOfListOfElementsID aListOfListOfElementsID;
- for (int i = 0; i < GroupsOfElementsID.length(); i++) {
+ for ( CORBA::ULong i = 0; i < GroupsOfElementsID.length(); i++ ) {
const SMESH::long_array& anElemsIDGroup = GroupsOfElementsID[ i ];
aListOfListOfElementsID.push_back( list< int >() );
list< int >& aListOfElemsID = aListOfListOfElementsID.back();
- for ( int j = 0; j < anElemsIDGroup.length(); j++ ) {
+ for ( CORBA::ULong j = 0; j < anElemsIDGroup.length(); j++ ) {
CORBA::Long id = anElemsIDGroup[ j ];
aListOfElemsID.push_back( id );
}
SMDSAbs_ElementType( type ),
foundElems);
res->length( foundElems.size() );
- for ( int i = 0; i < foundElems.size(); ++i )
+ for ( size_t i = 0; i < foundElems.size(); ++i )
res[i] = foundElems[i]->GetID();
return res._retn();
{
SMESH_TRY;
SMESH::long_array_var res = new SMESH::long_array;
-
- SMESH::array_of_ElementType_var types = elementIDs->GetTypes();
- if ( types->length() == 1 && // a part contains only nodes or 0D elements
- ( types[0] == SMESH::NODE || types[0] == SMESH::ELEM0D || types[0] == SMESH::BALL) &&
- type != types[0] ) // but search of elements of dim > 0
- return res._retn();
+ if ( type != SMESH::NODE )
+ {
+ SMESH::array_of_ElementType_var types = elementIDs->GetTypes();
+ if ( types->length() == 1 && // a part contains only nodes or 0D elements
+ ( types[0] == SMESH::NODE || types[0] == SMESH::ELEM0D || types[0] == SMESH::BALL) &&
+ type != types[0] ) // but search of elements of dim > 0
+ return res._retn();
+ }
if ( SMESH::DownCast<SMESH_Mesh_i*>( elementIDs )) // elementIDs is the whole mesh
return FindElementsByPoint( x,y,z, type );
SMESHDS_Mesh* meshDS = SMESH::DownCast<SMESH_Mesh_i*>( mesh )->GetImpl().GetMeshDS();
if ( !idSourceToSet( elementIDs, meshDS, elements,
- SMDSAbs_ElementType(type), /*emptyIfIsMesh=*/true))
+ ( type == SMESH::NODE ? SMDSAbs_All : (SMDSAbs_ElementType) type ),
+ /*emptyIfIsMesh=*/true))
return res._retn();
typedef SMDS_SetIterator<const SMDS_MeshElement*, TIDSortedElemSet::const_iterator > TIter;
SMDSAbs_ElementType( type ),
foundElems);
res->length( foundElems.size() );
- for ( int i = 0; i < foundElems.size(); ++i )
+ for ( size_t i = 0; i < foundElems.size(); ++i )
res[i] = foundElems[i]->GetID();
return res._retn();
RETCASE( SEW_TOPO_DIFF_SETS_OF_ELEMENTS );
RETCASE( SEW_BAD_SIDE1_NODES );
RETCASE( SEW_BAD_SIDE2_NODES );
+ RETCASE( SEW_INTERNAL_ERROR );
}
return SMESH::SMESH_MeshEditor::SEW_OK;
}
for ( CORBA::ULong iP = 0; iP < aGRP.length(); ++iP )
{
const SMESH::FreeBorderPart& aPART = aGRP[ iP ];
- if ( aPART.border < 0 || aPART.border >= freeBorders.borders.length() )
+ if ( aPART.border < 0 || aPART.border >= (int) freeBorders.borders.length() )
THROW_SALOME_CORBA_EXCEPTION("Invalid FreeBorderPart::border index", SALOME::BAD_PARAM);
const SMESH::FreeBorder& aBRD = freeBorders.borders[ aPART.border ];
- if ( aPART.node1 < 0 || aPART.node1 > aBRD.nodeIDs.length() )
+ if ( aPART.node1 < 0 || aPART.node1 > (int) aBRD.nodeIDs.length() )
THROW_SALOME_CORBA_EXCEPTION("Invalid FreeBorderPart::node1", SALOME::BAD_PARAM);
- if ( aPART.node2 < 0 || aPART.node2 > aBRD.nodeIDs.length() )
+ if ( aPART.node2 < 0 || aPART.node2 > (int) aBRD.nodeIDs.length() )
THROW_SALOME_CORBA_EXCEPTION("Invalid FreeBorderPart::node2", SALOME::BAD_PARAM);
- if ( aPART.nodeLast < 0 || aPART.nodeLast > aBRD.nodeIDs.length() )
+ if ( aPART.nodeLast < 0 || aPART.nodeLast > (int) aBRD.nodeIDs.length() )
THROW_SALOME_CORBA_EXCEPTION("Invalid FreeBorderPart::nodeLast", SALOME::BAD_PARAM);
// do not keep these nodes for further sewing as nodes can be removed by the sewing
*/
//================================================================================
-string SMESH_MeshEditor_i::generateGroupName(const string& thePrefix)
+std::string SMESH_MeshEditor_i::generateGroupName(const std::string& thePrefix)
{
SMESH::ListOfGroups_var groups = myMesh_i->GetGroups();
- set<string> groupNames;
+ set<std::string> groupNames;
// Get existing group names
for (int i = 0, nbGroups = groups->length(); i < nbGroups; i++ ) {
}
// Find new name
- string name = thePrefix;
+ std::string name = thePrefix;
int index = 0;
while (!groupNames.insert(name).second)
{
if ( error ) *error = IDSource_OK;
- if ( CORBA::is_nil( theIDSource ) )
+ if ( CORBA::is_nil( theIDSource ))
{
if ( error ) *error = IDSource_INVALID;
return false;
// Create group with newly created nodes
SMESH::long_array_var anIds = GetLastCreatedNodes();
if (anIds->length() > 0) {
- string anUnindexedName (theNodes->GetName());
- string aNewName = generateGroupName(anUnindexedName + "_double");
+ std::string anUnindexedName (theNodes->GetName());
+ std::string aNewName = generateGroupName(anUnindexedName + "_double");
aNewGroup = myMesh_i->CreateGroup(SMESH::NODE, aNewName.c_str());
aNewGroup->Add(anIds);
pyDump << aNewGroup << " = ";
// 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");
+ std::string anUnindexedName (theNodes[0]->GetName());
+ std::string aNewName = generateGroupName(anUnindexedName + "_double");
aNewGroup = myMesh_i->CreateGroup(SMESH::NODE, aNewName.c_str());
aNewGroup->Add(anIds);
pyDump << aNewGroup << " = ";
{
// Create group with newly created elements
CORBA::String_var elemGroupName = theElems->GetName();
- string aNewName = generateGroupName( string(elemGroupName.in()) + "_double");
+ std::string aNewName = generateGroupName( std::string(elemGroupName.in()) + "_double");
if ( !getEditor().GetLastCreatedElems().IsEmpty() && theElemGroupNeeded )
{
SMESH::long_array_var anIds = GetLastCreatedElems();
{
// Create group with newly created elements
CORBA::String_var elemGroupName = theElems[0]->GetName();
- string aNewName = generateGroupName( string(elemGroupName.in()) + "_double");
+ std::string aNewName = generateGroupName( std::string(elemGroupName.in()) + "_double");
if ( !getEditor().GetLastCreatedElems().IsEmpty() && theElemGroupNeeded )
{
SMESH::long_array_var anIds = GetLastCreatedElems();
theNodeSearcher = SMESH_MeshAlgos::GetNodeSearcher( *getMeshDS() );
vector<double> nodesCoords;
- for (int i = 0; i < theNodesCoords.length(); i++)
+ for ( CORBA::ULong i = 0; i < theNodesCoords.length(); i++)
{
nodesCoords.push_back( theNodesCoords[i] );
}
groupsOfThisMesh ->length( groups.length() );
groupsOfOtherMesh->length( groups.length() );
int nbGroups = 0, nbGroupsOfOtherMesh = 0;
- for ( int i = 0; i < groups.length(); ++i )
+ for ( CORBA::ULong i = 0; i < groups.length(); ++i )
{
SMESH::SMESH_Mesh_var m = groups[i]->GetMesh();
if ( myMesh_i != SMESH::DownCast<SMESH_Mesh_i*>( m ))