]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
23179: EDF 11603 - Problem with extrusion when path is not well oriented
authoreap <eap@opencascade.com>
Wed, 7 Oct 2015 15:06:26 +0000 (18:06 +0300)
committereap <eap@opencascade.com>
Wed, 7 Oct 2015 15:06:26 +0000 (18:06 +0300)
IPAL52909: TC7.7.0: edges selection provides incorrect nodes IDs
IPAL52895: TC7.7.0: Incorrect behaviour of the "Move Node" dialog.
IPAL52910: TC7.7.0: mesh is not updated at Apply click in Smoothing dialog

src/OBJECT/SMESH_Object.cxx
src/SMESH/SMESH_MeshEditor.cxx
src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx
src/SMESHGUI/SMESHGUI_GroupDlg.cxx
src/SMESHGUI/SMESHGUI_MakeNodeAtPointDlg.cxx
src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx
src/SMESHUtils/SMESH_MAT2d.cxx
src/SMESHUtils/SMESH_MAT2d.hxx
src/StdMeshers/StdMeshers_QuadFromMedialAxis_1D2D.cxx

index a8d9f780e927a6c0dcf55422111bf5a944422d8a..44d70da65188d8ad8cef4bc91a923efda8ed5eef 100644 (file)
@@ -539,7 +539,7 @@ void SMESH_VisualObjDef::buildElemPrs()
 
 //=================================================================================
 // function : GetEdgeNodes
-// purpose  : Retrieve ids of nodes from edge of elements ( edge is numbered from 1 )
+// purpose  : Retrieve ids of nodes from edge of elements ( edge is numbered from 0 )
 //=================================================================================
 bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId,
                                        const int theEdgeNum,
@@ -556,11 +556,13 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId,
     
   int nbNodes = anElem->NbCornerNodes();
 
-  if ( theEdgeNum < 0 || theEdgeNum > 3 || (nbNodes != 3 && nbNodes != 4) || theEdgeNum > nbNodes )
+  if (( theEdgeNum < 0 || theEdgeNum > 3 ) ||
+      ( nbNodes != 3 && nbNodes != 4 ) ||
+      ( theEdgeNum >= nbNodes ))
     return false;
 
-  theNodeId1 = anElem->GetNode( theEdgeNum - 1       )->GetID();
-  theNodeId2 = anElem->GetNode( theEdgeNum % nbNodes )->GetID();
+  theNodeId1 = anElem->GetNode(  theEdgeNum                 )->GetID();
+  theNodeId2 = anElem->GetNode(( theEdgeNum + 1 ) % nbNodes )->GetID();
 
   return true;
 }
@@ -584,10 +586,9 @@ vtkUnstructuredGrid* SMESH_VisualObjDef::GetUnstructuredGrid()
 //=================================================================================
 bool SMESH_VisualObjDef::IsValid() const
 {
-        //MESSAGE("SMESH_VisualObjDef::IsValid");
-  return ( GetNbEntities(SMDSAbs_0DElement) > 0 || 
-           GetNbEntities(SMDSAbs_Ball     ) > 0 || 
-           GetNbEntities(SMDSAbs_Edge     ) > 0 || 
+  return ( GetNbEntities(SMDSAbs_0DElement) > 0 ||
+           GetNbEntities(SMDSAbs_Ball     ) > 0 ||
+           GetNbEntities(SMDSAbs_Edge     ) > 0 ||
            GetNbEntities(SMDSAbs_Face     ) > 0 ||
            GetNbEntities(SMDSAbs_Volume   ) > 0 ||
            GetNbEntities(SMDSAbs_Node     ) > 0 );
@@ -597,59 +598,67 @@ bool SMESH_VisualObjDef::IsValid() const
 // function : updateEntitiesFlags
 // purpose  : Update entities flags
 //=================================================================================
-void SMESH_VisualObjDef::updateEntitiesFlags() {
+void SMESH_VisualObjDef::updateEntitiesFlags()
+{
+  unsigned int tmp = myEntitiesState;
+  ClearEntitiesFlags();
 
-        unsigned int tmp = myEntitiesState;
-        ClearEntitiesFlags();
+  map<SMDSAbs_ElementType,int> entities = SMESH::GetEntitiesFromObject(this);
 
-        map<SMDSAbs_ElementType,int> entities = SMESH::GetEntitiesFromObject(this);
-        
 
-        if( myEntitiesCache[SMDSAbs_0DElement] != 0 ||  myEntitiesCache[SMDSAbs_0DElement] >= entities[SMDSAbs_0DElement] )
-                myEntitiesState &= ~SMESH_Actor::e0DElements;
+  if( myEntitiesCache[SMDSAbs_0DElement] != 0 ||
+      myEntitiesCache[SMDSAbs_0DElement] >= entities[SMDSAbs_0DElement] )
+    myEntitiesState &= ~SMESH_Actor::e0DElements;
 
-        if( myEntitiesCache[SMDSAbs_Ball] != 0 ||  myEntitiesCache[SMDSAbs_Ball] >= entities[SMDSAbs_Ball] )
-                myEntitiesState &= ~SMESH_Actor::eBallElem;
+  if( myEntitiesCache[SMDSAbs_Ball] != 0 ||
+      myEntitiesCache[SMDSAbs_Ball] >= entities[SMDSAbs_Ball] )
+    myEntitiesState &= ~SMESH_Actor::eBallElem;
 
-        if( myEntitiesCache[SMDSAbs_Edge] != 0 || myEntitiesCache[SMDSAbs_Edge] >= entities[SMDSAbs_Edge] )
-                myEntitiesState &= ~SMESH_Actor::eEdges; 
+  if( myEntitiesCache[SMDSAbs_Edge] != 0 ||
+      myEntitiesCache[SMDSAbs_Edge] >= entities[SMDSAbs_Edge] )
+    myEntitiesState &= ~SMESH_Actor::eEdges;
 
-        if( myEntitiesCache[SMDSAbs_Face] != 0 || myEntitiesCache[SMDSAbs_Face] >= entities[SMDSAbs_Face] )
-                myEntitiesState &= ~SMESH_Actor::eFaces; 
+  if( myEntitiesCache[SMDSAbs_Face] != 0 ||
+      myEntitiesCache[SMDSAbs_Face] >= entities[SMDSAbs_Face] )
+    myEntitiesState &= ~SMESH_Actor::eFaces;
 
-        if( myEntitiesCache[SMDSAbs_Volume] != 0 || myEntitiesCache[SMDSAbs_Volume] >= entities[SMDSAbs_Volume] )
-                myEntitiesState &= ~SMESH_Actor::eVolumes;
+  if( myEntitiesCache[SMDSAbs_Volume] != 0 ||
+      myEntitiesCache[SMDSAbs_Volume] >= entities[SMDSAbs_Volume] )
+    myEntitiesState &= ~SMESH_Actor::eVolumes;
 
-        if( tmp != myEntitiesState ) {
-                myEntitiesFlag = true;
-        }
-        
-        myEntitiesCache = entities;
+  if( tmp != myEntitiesState ) {
+    myEntitiesFlag = true;
+  }
+
+  myEntitiesCache = entities;
 }
 
 //=================================================================================
 // function : ClearEntitiesFlags
 // purpose  : Clear the entities flags
 //=================================================================================
-void SMESH_VisualObjDef::ClearEntitiesFlags() {
-        myEntitiesState = SMESH_Actor::eAllEntity;
-        myEntitiesFlag = false;
+void SMESH_VisualObjDef::ClearEntitiesFlags()
+{
+  myEntitiesState = SMESH_Actor::eAllEntity;
+  myEntitiesFlag = false;
 }
 
 //=================================================================================
 // function : GetEntitiesFlag
 // purpose  : Return the entities flag
 //=================================================================================
-bool SMESH_VisualObjDef::GetEntitiesFlag() {
-        return myEntitiesFlag;
+bool SMESH_VisualObjDef::GetEntitiesFlag()
+{
+  return myEntitiesFlag;
 }
 
 //=================================================================================
 // function : GetEntitiesState
 // purpose  : Return the entities state
 //=================================================================================
-unsigned int SMESH_VisualObjDef::GetEntitiesState() {
-        return myEntitiesState;
+unsigned int SMESH_VisualObjDef::GetEntitiesState()
+{
+  return myEntitiesState;
 }
 
 /*
@@ -699,20 +708,20 @@ bool SMESH_MeshObj::Update( int theIsClear )
 
 bool SMESH_MeshObj::NulData()
 {
-        MESSAGE ("SMESH_MeshObj::NulData() ==================================================================================");
-        if (!myEmptyGrid)
-        {
-          myEmptyGrid = SMDS_UnstructuredGrid::New();
-          myEmptyGrid->Initialize();
-          myEmptyGrid->Allocate();
-          vtkPoints* points = vtkPoints::New();
-          points->SetNumberOfPoints(0);
-          myEmptyGrid->SetPoints( points );
-          points->Delete();
-          myEmptyGrid->BuildLinks();
-        }
-        myGrid->ShallowCopy(myEmptyGrid);
-        return true;
+  MESSAGE ("SMESH_MeshObj::NulData() ==================================================================================");
+  if (!myEmptyGrid)
+  {
+    myEmptyGrid = SMDS_UnstructuredGrid::New();
+    myEmptyGrid->Initialize();
+    myEmptyGrid->Allocate();
+    vtkPoints* points = vtkPoints::New();
+    points->SetNumberOfPoints(0);
+    myEmptyGrid->SetPoints( points );
+    points->Delete();
+    myEmptyGrid->BuildLinks();
+  }
+  myGrid->ShallowCopy(myEmptyGrid);
+  return true;
 }
 //=================================================================================
 // function : GetElemDimension
index e34ccf0a39d43620449613e87145252fdedd60d6..9cc4d2378405173a2a3360dcedcb04904bf6e047 100644 (file)
@@ -6389,7 +6389,7 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet     theElements[2],
       SMESH_MeshEditor_PathPoint PP2 = currList.front();
       gp_Dir D1 = PP1.Tangent();
       gp_Dir D2 = PP2.Tangent();
-      gp_Dir Dnew( ( D1.XYZ() + D2.XYZ() ) / 2 );
+      gp_Dir Dnew( D1.XYZ() + D2.XYZ() );
       PP1.SetTangent(Dnew);
       fullList.push_back(PP1);
       fullList.splice( fullList.end(), currList, ++currList.begin(), currList.end() );
@@ -6454,7 +6454,7 @@ SMESH_MeshEditor::MakeEdgePathPoints(std::list<double>&                aPrms,
     aL2 = aVec.SquareMagnitude();
     if ( aL2 < aTolVec2 )
       return EXTR_CANT_GET_TANGENT;
-    gp_Dir aTgt( aVec );
+    gp_Dir aTgt( FirstIsStart ? aVec : -aVec );
     aPP.SetPnt( aP3D );
     aPP.SetTangent( aTgt );
     aPP.SetParameter( aT );
@@ -6479,9 +6479,11 @@ SMESH_MeshEditor::MakeExtrElements(TIDSortedElemSet                  theElemSets
                                    const bool                        theMakeGroups)
 {
   const int aNbTP = fullList.size();
+
   // Angles
   if( theHasAngles && !theAngles.empty() && theLinearVariation )
     LinearAngleVariation(aNbTP-1, theAngles);
+
   // fill vector of path points with angles
   vector<SMESH_MeshEditor_PathPoint> aPPs;
   list<SMESH_MeshEditor_PathPoint>::iterator itPP = fullList.begin();
@@ -6511,10 +6513,10 @@ SMESH_MeshEditor::MakeExtrElements(TIDSortedElemSet                  theElemSets
     {
       TIDSortedElemSet& theElements = theElemSets[ is2ndSet ];
       itElem = theElements.begin();
-      for ( ; itElem != theElements.end(); itElem++ ) {
+      for ( ; itElem != theElements.end(); itElem++ )
+      {
         const SMDS_MeshElement* elem = *itElem;
-
-        SMDS_ElemIteratorPtr itN = elem->nodesIterator();
+        SMDS_ElemIteratorPtr     itN = elem->nodesIterator();
         while ( itN->more() ) {
           const SMDS_MeshElement* node = itN->next();
           if ( newNodes.insert( node ).second )
@@ -6528,19 +6530,15 @@ SMESH_MeshEditor::MakeExtrElements(TIDSortedElemSet                  theElemSets
 
   // 4. Processing the elements
   SMESHDS_Mesh* aMesh = GetMeshDS();
+  list<const SMDS_MeshNode*> emptyList;
 
   setElemsFirst( theElemSets );
   for ( int is2ndSet = 0; is2ndSet < 2; ++is2ndSet )
   {
     TIDSortedElemSet& theElements = theElemSets[ is2ndSet ];
-    for ( itElem = theElements.begin(); itElem != theElements.end(); itElem++ ) {
-      // check element type
+    for ( itElem = theElements.begin(); itElem != theElements.end(); itElem++ )
+    {
       const SMDS_MeshElement* elem = *itElem;
-      if ( !elem )
-        continue;
-      // SMDSAbs_ElementType aTypeE = elem->GetType();
-      // if ( aTypeE != SMDSAbs_Face && aTypeE != SMDSAbs_Edge )
-      //   continue;
 
       vector<TNodeOfNodeListMapItr> & newNodesItVec = mapElemNewNodes[ elem ];
       newNodesItVec.reserve( elem->NbNodes() );
@@ -6552,13 +6550,11 @@ SMESH_MeshEditor::MakeExtrElements(TIDSortedElemSet                  theElemSets
       {
         ++nodeIndex;
         // check if a node has been already processed
-        const SMDS_MeshNode* node =
-          static_cast<const SMDS_MeshNode*>( itN->next() );
-        TNodeOfNodeListMap::iterator nIt = mapNewNodes.find( node );
-        if ( nIt == mapNewNodes.end() ) {
-          nIt = mapNewNodes.insert( make_pair( node, list<const SMDS_MeshNode*>() )).first;
-          list<const SMDS_MeshNode*>& listNewNodes = nIt->second;
-
+        const SMDS_MeshNode* node = cast2Node( itN->next() );
+        TNodeOfNodeListMap::iterator nIt = mapNewNodes.insert( make_pair( node, emptyList )).first;
+        list<const SMDS_MeshNode*>& listNewNodes = nIt->second;
+        if ( listNewNodes.empty() )
+        {
           // make new nodes
           Standard_Real aAngle1x, aAngleT1T0, aTolAng;
           gp_Pnt aP0x, aP1x, aPN0, aPN1, aV0x, aV1x;
@@ -6573,7 +6569,6 @@ SMESH_MeshEditor::MakeExtrElements(TIDSortedElemSet                  theElemSets
           const SMESH_MeshEditor_PathPoint& aPP0 = aPPs[0];
           aP0x = aPP0.Pnt();
           aDT0x= aPP0.Tangent();
-          //cout<<"j = 0   PP: Pnt("<<aP0x.X()<<","<<aP0x.Y()<<","<<aP0x.Z()<<")"<<endl;
 
           for ( int j = 1; j < aNbTP; ++j ) {
             const SMESH_MeshEditor_PathPoint& aPP1 = aPPs[j];
@@ -6592,7 +6587,8 @@ SMESH_MeshEditor::MakeExtrElements(TIDSortedElemSet                  theElemSets
 
             // rotation 1 [ T1,T0 ]
             aAngleT1T0=-aDT1x.Angle( aDT0x );
-            if (fabs(aAngleT1T0) > aTolAng) {
+            if (fabs(aAngleT1T0) > aTolAng)
+            {
               aDT1T0=aDT1x^aDT0x;
               anAxT1T0.SetLocation( aV1x );
               anAxT1T0.SetDirection( aDT1T0 );
@@ -6611,13 +6607,11 @@ SMESH_MeshEditor::MakeExtrElements(TIDSortedElemSet                  theElemSets
             }
 
             // make new node
-            //MESSAGE("elem->IsQuadratic " << elem->IsQuadratic() << " " << elem->IsMediumNode(node));
-            if( elem->IsQuadratic() && !elem->IsMediumNode(node) ) {
+            if ( elem->IsQuadratic() && !elem->IsMediumNode(node) )
+            {
               // create additional node
-              double x = ( aPN1.X() + aPN0.X() )/2.;
-              double y = ( aPN1.Y() + aPN0.Y() )/2.;
-              double z = ( aPN1.Z() + aPN0.Z() )/2.;
-              const SMDS_MeshNode* newNode = aMesh->AddNode(x,y,z);
+              gp_XYZ midP = 0.5 * ( aPN1.XYZ() + aPN0.XYZ() );
+              const SMDS_MeshNode* newNode = aMesh->AddNode( midP.X(), midP.Y(), midP.Z() );
               myLastCreatedNodes.Append(newNode);
               srcNodes.Append( node );
               listNewNodes.push_back( newNode );
@@ -6633,42 +6627,40 @@ SMESH_MeshEditor::MakeExtrElements(TIDSortedElemSet                  theElemSets
             aDT0x = aDT1x;
           }
         }
-
-        else {
+        else if( elem->IsQuadratic() && !elem->IsMediumNode(node) )
+        {
           // if current elem is quadratic and current node is not medium
           // we have to check - may be it is needed to insert additional nodes
-          if( elem->IsQuadratic() && !elem->IsMediumNode(node) ) {
-            list< const SMDS_MeshNode* > & listNewNodes = nIt->second;
-            if(listNewNodes.size()==aNbTP-1) {
-              vector<const SMDS_MeshNode*> aNodes(2*(aNbTP-1));
-              gp_XYZ P(node->X(), node->Y(), node->Z());
-              list< const SMDS_MeshNode* >::iterator it = listNewNodes.begin();
-              int i;
-              for(i=0; i<aNbTP-1; i++) {
-                const SMDS_MeshNode* N = *it;
-                double x = ( N->X() + P.X() )/2.;
-                double y = ( N->Y() + P.Y() )/2.;
-                double z = ( N->Z() + P.Z() )/2.;
-                const SMDS_MeshNode* newN = aMesh->AddNode(x,y,z);
-                srcNodes.Append( node );
-                myLastCreatedNodes.Append(newN);
-                aNodes[2*i] = newN;
-                aNodes[2*i+1] = N;
-                P = gp_XYZ(N->X(),N->Y(),N->Z());
-              }
-              listNewNodes.clear();
-              for(i=0; i<2*(aNbTP-1); i++) {
-                listNewNodes.push_back(aNodes[i]);
-              }
+          list< const SMDS_MeshNode* > & listNewNodes = nIt->second;
+          if ( listNewNodes.size() == aNbTP-1 )
+          {
+            vector<const SMDS_MeshNode*> aNodes(2*(aNbTP-1));
+            gp_XYZ P(node->X(), node->Y(), node->Z());
+            list< const SMDS_MeshNode* >::iterator it = listNewNodes.begin();
+            int i;
+            for(i=0; i<aNbTP-1; i++) {
+              const SMDS_MeshNode* N = *it;
+              double x = ( N->X() + P.X() )/2.;
+              double y = ( N->Y() + P.Y() )/2.;
+              double z = ( N->Z() + P.Z() )/2.;
+              const SMDS_MeshNode* newN = aMesh->AddNode(x,y,z);
+              srcNodes.Append( node );
+              myLastCreatedNodes.Append(newN);
+              aNodes[2*i] = newN;
+              aNodes[2*i+1] = N;
+              P = gp_XYZ(N->X(),N->Y(),N->Z());
+            }
+            listNewNodes.clear();
+            for(i=0; i<2*(aNbTP-1); i++) {
+              listNewNodes.push_back(aNodes[i]);
             }
           }
         }
 
         newNodesItVec.push_back( nIt );
       }
+
       // make new elements
-      //sweepElement( aMesh, elem, newNodesItVec, newElemsMap[elem],
-      //              newNodesItVec[0]->second.size(), myLastCreatedElems );
       sweepElement( elem, newNodesItVec, newElemsMap[elem], aNbTP-1, srcElems );
     }
   }
index 4c6ebea19f80fb13dbc262c88ba0023942875a82..2779ce68917e4d004fd4017040187263bb5373eb 100644 (file)
@@ -826,7 +826,7 @@ void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument (QPushButton* button
     if (!myPath->_is_nil()) {
       SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
       if (aPathActor) {
-        SMESH::SetPointRepresentation(true);
+        aPathActor->SetPointRepresentation( true );
         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
           aViewWindow->SetSelectionMode(NodeSelection);
         SMESH::SetPickable(aPathActor);
index e9b683d611034dfb299a5a776089c4bb550e8092..7b1ad6ec92a35cdd376a4c38424dd473b9f45d21 100644 (file)
@@ -1827,6 +1827,8 @@ void SMESHGUI_GroupDlg::onAdd()
 
   if (aNbSel == 0 || myActorsList.count() == 0 || myMesh->_is_nil()) return;
 
+  SUIT_OverrideCursor wc;
+
   myIsBusy = true;
   int sizeBefore = myElements->count();
 
index 3b8ffef6514829c822f274c022c9d3f8eb0ea98a..89034c8a6782b23aa6d4937d66ce61c8dadbc0be 100644 (file)
@@ -326,7 +326,8 @@ void SMESHGUI_MakeNodeAtPointDlg::ConstructorsClicked (int constructorId)
       myDestDX->hide();
       myDestDY->hide();
       myDestDZ->hide();
-      if (myNodeToMoveGrp->isVisible()) {myNodeToMoveGrp->hide();}
+      if (myNodeToMoveGrp->isVisible()) myNodeToMoveGrp->hide();
+      myDestBtn->setChecked( true );
       break;
     }
   }
@@ -356,14 +357,15 @@ SMESHGUI_MakeNodeAtPointOp::SMESHGUI_MakeNodeAtPointOp()
   myDestCoordChanged = true;
 
   // connect signals and slots
-  connect(myDlg->myDestinationX, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
-  connect(myDlg->myDestinationY, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
-  connect(myDlg->myDestinationZ, SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
-  connect(myDlg->myDestDX, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged()));
-  connect(myDlg->myDestDY, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged()));
-  connect(myDlg->myDestDZ, SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged()));
-  connect(myDlg->myId,SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview()));
-  connect(myDlg->myPreviewChkBox,   SIGNAL (toggled(bool)),SLOT(redisplayPreview()));
+  connect(myDlg->myDestinationX,  SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
+  connect(myDlg->myDestinationY,  SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
+  connect(myDlg->myDestinationZ,  SIGNAL (valueChanged(double)), this, SLOT(redisplayPreview()));
+  connect(myDlg->myDestDX,        SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged()));
+  connect(myDlg->myDestDY,        SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged()));
+  connect(myDlg->myDestDZ,        SIGNAL (valueChanged(double)), this, SLOT(onDestCoordChanged()));
+  connect(myDlg->myId,            SIGNAL (textChanged(const QString&)),SLOT(redisplayPreview()));
+  connect(myDlg->myPreviewChkBox, SIGNAL (toggled(bool)),              SLOT(redisplayPreview()));
+  connect(myDlg->myButtonGroup,   SIGNAL (buttonClicked(int)),         SLOT(redisplayPreview()));
 
   // IPAL22913: TC6.5.0: selected in "Move node" dialog box node is not highlighted
   // note: this slot seems to be lost together with removed obsolete SMESHGUI_MoveNodesDlg class
@@ -440,13 +442,6 @@ void SMESHGUI_MakeNodeAtPointOp::startOperation()
   myDlg->show();
 
   onSelectionDone(); // init myMeshActor
-
-  if ( myMeshActor ) {
-//     myMeshActor->SetRepresentation( VTK_WIREFRAME );
-    myMeshActor->SetPointRepresentation(true);
-    SMESH::RepaintCurrentView();
-    redisplayPreview();
-  }
 }
 
 //=================================================================================
@@ -604,6 +599,8 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
 {
   if ( !myDlg->isVisible() || !myDlg->isEnabled() )
     return;
+
+  myNoPreview = true;
   try {
     SALOME_ListIO aList;
     selectionMgr()->selectedObjects(aList, SVTK_Viewer::Type());
@@ -612,6 +609,10 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
     Handle(SALOME_InteractiveObject) anIO = aList.First();
     SMESH_Actor* aMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
 
+    if (( myDlg->myIdBtn->isChecked() && myDlg->myIdBtn->isEnabled() ) ||
+        ( !myDlg->myNodeToMoveGrp->isVisible() ))
+      myMeshActor = aMeshActor;
+
     if (!aMeshActor) { // coord by geom
       if ( myDlg->myDestBtn->isChecked() ) {
         GEOM::GEOM_Object_var geom = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
@@ -620,63 +621,56 @@ void SMESHGUI_MakeNodeAtPointOp::onSelectionDone()
           if ( GEOMBase::GetShape(geom, aShape) &&
                aShape.ShapeType() == TopAbs_VERTEX ) {
             gp_Pnt P = BRep_Tool::Pnt(aShape);
-            myNoPreview = true;
             myDlg->myDestinationX->SetValue(P.X());
             myDlg->myDestinationY->SetValue(P.Y());
             myDlg->myDestinationZ->SetValue(P.Z());
-            myNoPreview = false;
-            redisplayPreview();
           }
         }
+        myNoPreview = false;
+        redisplayPreview();
         return;
       }
     }
 
-    if ( !myMeshActor )
-      myMeshActor = aMeshActor;
-
     QString aString;
     int nbElems = SMESH::GetNameOfSelectedElements(selector(),anIO, aString);
     if (nbElems == 1) {
       if (SMDS_Mesh* aMesh = aMeshActor->GetObject()->GetMesh()) {
         if (const SMDS_MeshNode* aNode = aMesh->FindNode(aString.toInt())) {
-          myNoPreview = true;
           if ( myDlg->myDestBtn->isChecked() ) { // set coord
             myDlg->myDestinationX->SetValue(aNode->X());
             myDlg->myDestinationY->SetValue(aNode->Y());
             myDlg->myDestinationZ->SetValue(aNode->Z());
-            myNoPreview = false;
-            redisplayPreview();
           }
           else if ( myDlg->myIdBtn->isChecked() &&
                     myDlg->myIdBtn->isEnabled() ) { // set node to move
             myDlg->myId->setText(aString);
-            myNoPreview = false;
+            myDlg->myCurrentX->SetValue( aNode->X() );
+            myDlg->myCurrentY->SetValue( aNode->Y() );
+            myDlg->myCurrentZ->SetValue( aNode->Z() );
             redisplayPreview();
           }
 
-          if (const SMDS_MeshNode* aCurrentNode = aMesh->FindNode(myDlg->myId->text().toInt())) {
-            double x = aCurrentNode->X();
-            double y = aCurrentNode->Y();
-            double z = aCurrentNode->Z();
-            double dx = myDlg->myDestinationX->GetValue() - x;
-            double dy = myDlg->myDestinationY->GetValue() - y;
-            double dz = myDlg->myDestinationZ->GetValue() - z;
-            myDlg->myCurrentX->SetValue(x);
-            myDlg->myCurrentY->SetValue(y);
-            myDlg->myCurrentZ->SetValue(z);
-            myDlg->myDestDX->SetValue(dx);
-            myDlg->myDestDY->SetValue(dy);
-            myDlg->myDestDZ->SetValue(dz);
-            myDlg->myDestDX->setReadOnly(false);
-            myDlg->myDestDY->setReadOnly(false);
-            myDlg->myDestDZ->setReadOnly(false);
-          }
+          double x = myDlg->myCurrentX->GetValue();
+          double y = myDlg->myCurrentY->GetValue();
+          double z = myDlg->myCurrentZ->GetValue();
+          double dx = myDlg->myDestinationX->GetValue() - x;
+          double dy = myDlg->myDestinationY->GetValue() - y;
+          double dz = myDlg->myDestinationZ->GetValue() - z;
+          myDlg->myDestDX->SetValue(dx);
+          myDlg->myDestDY->SetValue(dy);
+          myDlg->myDestDZ->SetValue(dz);
+          myDlg->myDestDX->setReadOnly(false);
+          myDlg->myDestDY->setReadOnly(false);
+          myDlg->myDestDZ->setReadOnly(false);
         }
       }
     }
   } catch (...) {
   }
+
+  myNoPreview = false;
+  redisplayPreview();
 }
 
 //================================================================================
@@ -696,7 +690,7 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
   bool moveShown = false;
   if ( myMeshActor)
   {
-    const bool isPreview = myDlg->myPreviewChkBox->isChecked();
+    const bool  isPreview = myDlg->myPreviewChkBox->isChecked();
     const bool isMoveNode = myDlg->myRButMoveWithoutNode->isChecked();
     QString msg;
     if ( isValid( msg ) )
@@ -725,22 +719,28 @@ void SMESHGUI_MakeNodeAtPointOp::redisplayPreview()
                 myDlg->myDestinationX->SetValue(x);
                 myDlg->myDestinationY->SetValue(y);
                 myDlg->myDestinationZ->SetValue(z);
-              }
-              if ( myDestCoordChanged ) {
-                dx = myDlg->myDestinationX->GetValue() - x;
-                dy = myDlg->myDestinationY->GetValue() - y;
-                dz = myDlg->myDestinationZ->GetValue() - z;
                 myDlg->myDestDX->SetValue(dx);
                 myDlg->myDestDY->SetValue(dy);
                 myDlg->myDestDZ->SetValue(dz);
               }
-              else {
-                dx = myDlg->myDestDX->GetValue() + x;
-                dy = myDlg->myDestDY->GetValue() + y;
-                dz = myDlg->myDestDZ->GetValue() + z;
-                myDlg->myDestinationX->SetValue(dx);
-                myDlg->myDestinationY->SetValue(dy);
-                myDlg->myDestinationZ->SetValue(dz);
+              else
+              {
+                if ( myDestCoordChanged ) {
+                  dx = myDlg->myDestinationX->GetValue() - x;
+                  dy = myDlg->myDestinationY->GetValue() - y;
+                  dz = myDlg->myDestinationZ->GetValue() - z;
+                  myDlg->myDestDX->SetValue(dx);
+                  myDlg->myDestDY->SetValue(dy);
+                  myDlg->myDestDZ->SetValue(dz);
+                }
+                else {
+                  dx = myDlg->myDestDX->GetValue() + x;
+                  dy = myDlg->myDestDY->GetValue() + y;
+                  dz = myDlg->myDestDZ->GetValue() + z;
+                  myDlg->myDestinationX->SetValue(dx);
+                  myDlg->myDestinationY->SetValue(dy);
+                  myDlg->myDestinationZ->SetValue(dz);
+                }
               }
               myDlg->myCurrentX->SetValue(x);
               myDlg->myCurrentY->SetValue(y);
@@ -878,7 +878,7 @@ void SMESHGUI_MakeNodeAtPointOp::onTextChange( const QString& theText )
 void SMESHGUI_MakeNodeAtPointOp::activateSelection()
 {
   selectionMgr()->clearFilters();
-  SMESH::SetPointRepresentation(false);
+  SMESH::SetPointRepresentation( true );
   selectionMgr()->installFilter( myFilter );
   setSelectionMode( NodeSelection );
 }
index f934288b8eea7a885364bba7da73a915337bda6e..d752a128aa14b55783e5f57f20407b43f4966511 100644 (file)
@@ -406,10 +406,11 @@ bool SMESHGUI_SmoothingDlg::ClickOnApply()
 
     if (aResult) {
       SMESH::Update(myIO, SMESH::eDisplay);
+      SMESH::RepaintCurrentView();
       SMESHGUI::Modified();
       //Init();
 
-      mySelectedObject = SMESH::SMESH_IDSource::_nil();
+      //mySelectedObject = SMESH::SMESH_IDSource::_nil();
     }
   }
 
index 1d1a5300823371f4eab4faef7ead9b3da8e7374e..d423f8be89998102df25558d8bbc1a54bf261f8c 100644 (file)
@@ -390,7 +390,8 @@ namespace
     BranchIterator(const std::vector<const TVDEdge*> & edges, int i )
       :_i( i ), _size( edges.size() ), _edges( edges )
     {
-      _closed = ( edges[0]->vertex1() == edges.back()->vertex0() ); // closed branch
+      _closed = ( edges[0]->vertex1() == edges.back()->vertex0() || // closed branch
+                  edges[0]->vertex0() == edges.back()->vertex1() );
     }
     const TVDEdge* operator++() { ++_i; return edge(); }
     const TVDEdge* operator--() { --_i; return edge(); }
@@ -1031,14 +1032,16 @@ namespace
         {
           branchID = bndSegs[i]._prev->_branchID;  // with sign
         }
-        else if ( bndSegs[i]._edge && // 1st bndSeg of a WIRE
-                  bndSegs[i]._inSeg->isConnected( bndSegs[i]._edge ))
+        else if ( bndSegs[i]._edge ) // 1st bndSeg of a WIRE
         {
           branchEdges.resize(( branchID = branchEdges.size()) + 1 );
-          if ( bndSegs[i]._inSeg->point0() == bndSegs[i]._edge->vertex1() )
-            endType.insert( make_pair( bndSegs[i]._edge->vertex1(), SMESH_MAT2d::BE_ON_VERTEX ));
-          else
-            endType.insert( make_pair( bndSegs[i]._edge->vertex0(), SMESH_MAT2d::BE_ON_VERTEX ));
+          if ( bndSegs[i]._inSeg->isConnected( bndSegs[i]._edge ))
+          {
+            if ( bndSegs[i]._inSeg->point0() == bndSegs[i]._edge->vertex1() )
+              endType.insert( make_pair( bndSegs[i]._edge->vertex1(), SMESH_MAT2d::BE_ON_VERTEX ));
+            else
+              endType.insert( make_pair( bndSegs[i]._edge->vertex0(), SMESH_MAT2d::BE_ON_VERTEX ));
+          }
         }
 
         bndSegs[i].setBranch( branchID, bndSegsPerEdge ); // set to i-th and to the opposite bndSeg
@@ -1398,6 +1401,21 @@ bool SMESH_MAT2d::Boundary::getBranchPoint( const std::size_t iEdge,
   return true;
 }
 
+//================================================================================
+/*!
+ * \brief Returns a BranchPoint corresponding to a given BoundaryPoint on a geom EDGE
+ *  \param [in] bp - the BoundaryPoint
+ *  \param [out] p - the found BranchPoint
+ *  \return bool - is OK
+ */
+//================================================================================
+
+bool SMESH_MAT2d::Boundary::getBranchPoint( const BoundaryPoint& bp,
+                                            BranchPoint&         p ) const
+{
+  return getBranchPoint( bp._edgeIndex, bp._param, p );
+}
+
 //================================================================================
 /*!
  * \brief Check if a given boundary segment is a null-length segment on a concave
index eff5c10d5e7ef733116483d36b9f1f302b701a29..618608e07e73f5072d6256b71cd21d9075d60d1f 100644 (file)
@@ -82,7 +82,8 @@ namespace SMESH_MAT2d
     std::size_t   _iEdge; // MA edge index within the branch
     double        _edgeParam; // normalized param within the MA edge
 
-    BranchPoint(): _branch(0), _iEdge(0), _edgeParam(-1) {}
+    BranchPoint( const Branch* b = 0, std::size_t e = 0, double u = -1 ):
+      _branch(b), _iEdge(e), _edgeParam(u) {}
   };
   //-------------------------------------------------------------------------------------
   /*!
@@ -180,6 +181,8 @@ namespace SMESH_MAT2d
 
     bool getBranchPoint( const std::size_t iEdge, double u, BranchPoint& p ) const;
 
+    bool getBranchPoint( const BoundaryPoint& bp, BranchPoint& p ) const;
+
     bool isConcaveSegment( std::size_t iEdge, std::size_t iSeg ) const;
 
     bool moveToClosestEdgeEnd( BoundaryPoint& bp ) const;
index d94b05aa9e0b807e3b59d533a29980db84beb431..680279e75c226a7341b0b1a2a854d059848eac09 100644 (file)
@@ -1031,6 +1031,9 @@ namespace
                         TMAPar2NPoints &                    thePointsOnE,
                         SinuousFace&                        theSinuFace)
   {
+    if ( theDivPoints.empty() )
+      return true;
+
     SMESHDS_Mesh* meshDS = theHelper.GetMeshDS();
     const vector< TopoDS_Edge >&     theSinuEdges = theSinuFace._sinuEdges;
     const vector< Handle(Geom_Curve) >& theCurves = theSinuFace._sinuCurves;
@@ -1059,12 +1062,28 @@ namespace
       findVertexAndNode( np1, theSinuEdges, meshDS );
       thePointsOnE.insert( make_pair( 1.1, make_pair( np0, np1)));
     }
+    else
+    {
+      // project a VERTEX of outer sinuous side corresponding to branch(0.)
+      // which is not included into theDivPoints
+      if ( ! ( theDivPoints[0]._iEdge     == 0 &&
+               theDivPoints[0]._edgeParam == 0. )) // recursive call
+      {
+        SMESH_MAT2d::BranchPoint brp( &branch, 0, 0 );
+        vector< SMESH_MAT2d::BranchPoint > divPoint( 1, brp );
+        vector< std::size_t > edgeIDs1(2), edgeIDs2(2);
+        edgeIDs1[0] = theEdgeIDs1.back();
+        edgeIDs1[1] = theEdgeIDs1[0];
+        edgeIDs2[0] = theEdgeIDs2.back();
+        edgeIDs2[1] = theEdgeIDs2[0];
+        projectVertices( theHelper, theMA, divPoint, edgeIDs1, edgeIDs2,
+                         theIsEdgeComputed, thePointsOnE, theSinuFace );
+      }
+    }
 
     // project theDivPoints
 
-    if ( theDivPoints.empty() )
-      return true;
-
+    TMAPar2NPoints::iterator u2NP;
     for ( size_t i = 0; i < theDivPoints.size(); ++i )
     {
       if ( !branch.getParameter( theDivPoints[i], uMA ))
@@ -1080,15 +1099,32 @@ namespace
         findVertexAndNode( np[0], theSinuEdges, meshDS, theEdgeIDs1[i], theEdgeIDs1[i+1] ),
         findVertexAndNode( np[1], theSinuEdges, meshDS, theEdgeIDs2[i], theEdgeIDs2[i+1] )
       };
+      const size_t iVert = isVertex[0] ? 0 : 1; // side with a VERTEX
+      const size_t iNode = 1 - iVert;           // opposite (meshed?) side
 
-      TMAPar2NPoints::iterator u2NP =
-        thePointsOnE.insert( make_pair( uMA, make_pair( np[0], np[1])));//.first;
+      if ( isVertex[0] != isVertex[1] ) // try to find an opposite VERTEX
+      {
+        theMA.getBoundary().moveToClosestEdgeEnd( bp[iNode] ); // EDGE -> VERTEX
+        SMESH_MAT2d::BranchPoint brp;
+        theMA.getBoundary().getBranchPoint( bp[iNode], brp );  // WIRE -> MA
+        SMESH_MAT2d::BoundaryPoint bp2[2];
+        branch.getBoundaryPoints( brp, bp2[0], bp2[1] );       // MA -> WIRE
+        NodePoint np2[2] = { NodePoint( bp2[0]), NodePoint( bp2[1]) };
+        findVertexAndNode( np2[0], theSinuEdges, meshDS );
+        findVertexAndNode( np2[1], theSinuEdges, meshDS );
+        if ( np2[ iVert ]._node == np[ iVert ]._node &&
+             np2[ iNode ]._node)
+        {
+          np[ iNode ] = np2[ iNode ];
+          isVertex[ iNode ] = true;
+        }
+      }
+
+      u2NP = thePointsOnE.insert( make_pair( uMA, make_pair( np[0], np[1])));
 
       if ( !isVertex[0] && !isVertex[1] ) return false; // error
       if ( isVertex[0] && isVertex[1] )
         continue;
-      const size_t iVert = isVertex[0] ? 0 : 1;
-      const size_t iNode = 1 - iVert;
 
       bool isOppComputed = theIsEdgeComputed[ np[ iNode ]._edgeInd ];
       if ( !isOppComputed )
@@ -1103,7 +1139,7 @@ namespace
 
       // evaluate distance to neighbor projections
       const double rShort = 0.2;
-      bool isShortPrev[2], isShortNext[2];
+      bool isShortPrev[2], isShortNext[2], isPrevCloser[2];
       TMAPar2NPoints::iterator u2NPPrev = u2NP, u2NPNext = u2NP;
       --u2NPPrev; ++u2NPNext;
       // bool hasPrev = ( u2NP     != thePointsOnE.begin() );
@@ -1121,8 +1157,9 @@ namespace
         double  distPrev = p.Distance( pPrev );
         double  distNext = p.Distance( pNext );
         double         r = distPrev / ( distPrev + distNext );
-        isShortPrev[iS] = ( r < rShort );
-        isShortNext[iS] = (( 1 - r ) > ( 1 - rShort ));
+        isShortPrev [iS] = ( r < rShort );
+        isShortNext [iS] = (( 1 - r ) > ( 1 - rShort ));
+        isPrevCloser[iS] = (( r < 0.5 ) && ( u2NPPrev->first > 0 ));
       }
       // if ( !hasPrev ) isShortPrev[0] = isShortPrev[1] = false;
       // if ( !hasNext ) isShortNext[0] = isShortNext[1] = false;
@@ -1132,14 +1169,14 @@ namespace
       if (( isShortPrev[0] && isShortPrev[1] ) || // option 2) -> remove a too close projection
           ( isShortNext[0] && isShortNext[1] ))
       {
-        u2NPClose = isShortPrev[0] ? u2NPPrev : u2NPNext;
+        u2NPClose = isPrevCloser[0] ? u2NPPrev : u2NPNext;
         NodePoint& npProj  = get( u2NP->second,      iNode ); // NP of VERTEX projection
         NodePoint npCloseN = get( u2NPClose->second, iNode ); // NP close to npProj
         NodePoint npCloseV = get( u2NPClose->second, iVert ); // NP close to VERTEX
         if ( !npCloseV._node )
         {
           npProj = npCloseN;
-          thePointsOnE.erase( isShortPrev[0] ? u2NPPrev : u2NPNext );
+          thePointsOnE.erase( isPrevCloser[0] ? u2NPPrev : u2NPNext );
           continue;
         }
         else
@@ -1149,7 +1186,7 @@ namespace
       }
       // else: option 1) - wide enough -> "duplicate" existing node
       {
-        u2NPClose = isShortPrev[ iNode ] ? u2NPPrev : u2NPNext;
+        u2NPClose = isPrevCloser[ iNode ] ? u2NPPrev : u2NPNext;
         NodePoint& npProj   = get( u2NP->second,      iNode ); // NP of VERTEX projection
         NodePoint& npCloseN = get( u2NPClose->second, iNode ); // NP close to npProj
         npProj = npCloseN;
@@ -1164,6 +1201,12 @@ namespace
         //theNodes2Merge[ npCloseN._node ].push_back( npProj._node );
       }
     }
+
+    // remove auxiliary NodePoint's of ends of theSinuEdges
+    for ( u2NP = thePointsOnE.begin(); u2NP->first < 0; )
+      thePointsOnE.erase( u2NP++ );
+    thePointsOnE.erase( 1.1 );
+
     return true;
   }
 
@@ -1198,7 +1241,8 @@ namespace
   void separateNodes( SMESH_MesherHelper&            theHelper,
                       const SMESH_MAT2d::MedialAxis& theMA,
                       TMAPar2NPoints &               thePointsOnE,
-                      SinuousFace&                   theSinuFace )
+                      SinuousFace&                   theSinuFace,
+                      const vector< bool >&          theIsComputedEdge)
   {
     if ( thePointsOnE.size() < 2 )
       return;
@@ -1287,7 +1331,7 @@ namespace
             }
 
             // distribute points and create nodes
-            double du = ( u1 - u0 ) / ( sameU2NP.size() + 1 );
+            double du = ( u1 - u0 ) / ( sameU2NP.size() + !existingNode );
             double u  = u0 + du;
             for ( size_t i = 0; i < sameU2NP.size(); ++i )
             {
@@ -1299,7 +1343,9 @@ namespace
                 gp_Pnt p = np->Point( curves );
                 np->_node = meshDS->AddNode( p.X(), p.Y(), p.Z() );
                 meshDS->SetNodeOnEdge( np->_node, theSinuEdges[ *edgeID ], np->_u  );
-                //mergeNodes.push_back( np->_node );
+
+                if ( theIsComputedEdge[ *edgeID ])
+                  mergeNodes.push_back( np->_node );
               }
             }
           }
@@ -1410,9 +1456,33 @@ namespace
       theFace._quad->side[ 0 ] = StdMeshers_FaceSide::New( uvsNew );
       theFace._quad->side[ 2 ] = theFace._quad->side[ 0 ];
 
-      // rotate the IN side if opposite nodes of IN and OUT sides don't match
-      if ( theFace._quad->side[ 1 ].GetUVPtStruct().empty() )
+      if ( theFace._quad->side[ 1 ].GetUVPtStruct().empty() ||
+           theFace._quad->side[ 3 ].GetUVPtStruct().empty() )
         return false;
+
+      // assure that the outer sinuous side starts at nOut
+      if ( theFace._sinuSide[0].size() > 1 )
+      {
+        const UVPtStructVec& uvsOut = theFace._quad->side[ 3 ].GetUVPtStruct(); // _sinuSide[0]
+        size_t i; // find UVPtStruct holding nOut
+        for ( i = 0; i < uvsOut.size(); ++i )
+          if ( nOut == uvsOut[i].node )
+            break;
+        if ( i == uvsOut.size() )
+          return false;
+
+        if ( i != 0  &&  i != uvsOut.size()-1 )
+        {
+          // create a new OUT quad side
+          uvsNew.clear();
+          uvsNew.reserve( uvsOut.size() );
+          uvsNew.insert( uvsNew.end(), uvsOut.begin() + i, uvsOut.end() );
+          uvsNew.insert( uvsNew.end(), uvsOut.begin() + 1, uvsOut.begin() + i + 1);
+          theFace._quad->side[ 3 ] = StdMeshers_FaceSide::New( uvsNew );
+        }
+      }
+
+      // rotate the IN side if opposite nodes of IN and OUT sides don't match
       const SMDS_MeshNode * nIn0 = theFace._quad->side[ 1 ].First().node;
       if ( nIn0 != nIn )
       {
@@ -1431,12 +1501,13 @@ namespace
         uvsNew.insert( uvsNew.end(), uvsIn.begin() + i, uvsIn.end() );
         uvsNew.insert( uvsNew.end(), uvsIn.begin() + 1, uvsIn.begin() + i + 1);
         theFace._quad->side[ 1 ] = StdMeshers_FaceSide::New( uvsNew );
-
-        if ( theFace._quad->side[ 1 ].NbPoints() !=
-             theFace._quad->side[ 3 ].NbPoints())
-          return false;
       }
-    } // if ( theShortEdges[0].empty() )
+
+      if ( theFace._quad->side[ 1 ].NbPoints() !=
+           theFace._quad->side[ 3 ].NbPoints())
+        return false;
+
+    } // if ( theFace.IsRing() )
 
     return true;
 
@@ -1666,7 +1737,7 @@ namespace
                            isComputed, pointsOnE, theSinuFace ))
       return false;
 
-    separateNodes( theHelper, theMA, pointsOnE, theSinuFace );
+    separateNodes( theHelper, theMA, pointsOnE, theSinuFace, isComputed );
 
     // create nodes
     TMAPar2NPoints::iterator u2np = pointsOnE.begin();