+//=============================================================================
+/*!
+ * \brief Split a diagonal of a quadrangle formed by two adjacent triangles
+ * so that four new triangles appear in place of the two triangles
+ */
+//=============================================================================
+
+void SMESH_MeshEditor_i::AddNodeOnSegment(SMESH::smIdType nodeID1,
+ SMESH::smIdType nodeID2,
+ CORBA::Double position)
+{
+ SMESH_TRY;
+ initData();
+
+ const SMDS_MeshNode * n1 = getMeshDS()->FindNode( nodeID1 );
+ const SMDS_MeshNode * n2 = getMeshDS()->FindNode( nodeID2 );
+ if ( !n1 )
+ THROW_SALOME_CORBA_EXCEPTION( SMESH_Comment( "Invalid node ID: ") << nodeID1,
+ SALOME::BAD_PARAM);
+ if ( !n2 )
+ THROW_SALOME_CORBA_EXCEPTION( SMESH_Comment( "Invalid node ID: ") << nodeID2,
+ SALOME::BAD_PARAM);
+
+ if ( myIsPreviewMode ) // make preview data
+ {
+ TPreviewMesh* tmpMesh = getPreviewMesh();
+ TIDSortedElemSet elemSet, avoidSet;
+ TopoDS_Shape shape;
+ while ( const SMDS_MeshElement* face = SMESH_MeshAlgos::FindFaceInSet( n1, n2,
+ elemSet, avoidSet ))
+ {
+ if ( avoidSet.empty() )
+ {
+ shape = getMeshDS()->IndexToShape( face->GetShapeID() );
+ if ( !shape.IsNull() )
+ {
+ tmpMesh->ShapeToMesh( TopoDS_Shape() );
+ tmpMesh->ShapeToMesh( shape );
+ }
+ }
+ SMDS_MeshElement* faceCopy = tmpMesh->Copy ( face );
+ avoidSet.insert( face );
+
+ if ( !shape.IsNull() )
+ tmpMesh->GetMeshDS()->SetMeshElementOnShape( faceCopy, shape );
+ }
+ n1 = tmpMesh->GetMeshDS()->FindNode( nodeID1 );
+ n2 = tmpMesh->GetMeshDS()->FindNode( nodeID2 );
+
+ if ( !shape.IsNull() )
+ {
+ tmpMesh->GetMeshDS()->SetMeshElementOnShape( n1, shape );
+ tmpMesh->GetMeshDS()->SetMeshElementOnShape( n2, shape );
+ }
+ }
+
+ getEditor().SplitEdge( n1, n2, position );
+
+ if ( !myIsPreviewMode )
+ {
+ // Update Python script
+ TPythonDump() << this << ".AddNodeOnSegment( "
+ << nodeID1 << ", " << nodeID2 << ", " << position << " )";
+
+ declareMeshModified( /*isReComputeSafe=*/true );
+ }
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+}
+
+//=============================================================================
+/*!
+ * \brief Split a face into triangles by adding a new node onto the face
+ * and connecting the new node with face nodes
+ */
+//=============================================================================
+
+void SMESH_MeshEditor_i::AddNodeOnFace(SMESH::smIdType theFaceID,
+ CORBA::Double theX,
+ CORBA::Double theY,
+ CORBA::Double theZ)
+{
+ SMESH_TRY;
+ initData();
+
+ const SMDS_MeshElement * face = getMeshDS()->FindElement( theFaceID );
+ if ( !face )
+ THROW_SALOME_CORBA_EXCEPTION( SMESH_Comment( "Invalid face ID: ") << theFaceID,
+ SALOME::BAD_PARAM);
+ if ( face->GetType() != SMDSAbs_Face )
+ THROW_SALOME_CORBA_EXCEPTION( "The element is not a face ", SALOME::BAD_PARAM );
+
+ if ( myIsPreviewMode ) // make preview data
+ {
+ TPreviewMesh* tmpMesh = getPreviewMesh();
+ face = tmpMesh->Copy ( face );
+ }
+
+ getEditor().SplitFace( face, theX, theY, theZ );
+
+ if ( !myIsPreviewMode )
+ {
+ // Update Python script
+ TPythonDump() << this << ".AddNodeOnFace( "
+ << theFaceID << ", "
+ << theX << ", "
+ << theY << ", "
+ << theZ << " )";
+
+ declareMeshModified( /*isReComputeSafe=*/true );
+ }
+
+ SMESH_CATCH( SMESH::throwCorbaException );
+}
+