Salome HOME
A fix for a problem with repeated <section, index> in the table.
authornds <nds@opencascade.com>
Fri, 20 Dec 2013 03:40:49 +0000 (03:40 +0000)
committernds <nds@opencascade.com>
Fri, 20 Dec 2013 03:40:49 +0000 (03:40 +0000)
The problem study has two polylines(opened, spline-3points, polyline-2points). The polylines begin and end concur.

src/HYDROCurveCreator/CurveCreator_Utils.cxx

index f0ee112738b60724e4f477ca71feb86dcbf73689..529115262e5d2cf02bee3330e80eb5f458dd926b 100644 (file)
@@ -180,26 +180,27 @@ void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve,
   theShape = aComp;
 }
 
-class ComparePnt
+class CompareSectionToPoint
 {
 public:
-  ComparePnt( const gp_Pnt& thePoint ) : myPoint( thePoint) {};
-  ~ComparePnt() {}
+  CompareSectionToPoint( const int theISection = -1, const int theIPoint = -1 )
+    : mySectionId( theISection ), myPointId( theIPoint ) {};
+  ~CompareSectionToPoint() {}
 
-  bool operator < ( const ComparePnt& theOtherPoint ) const
+  bool operator < ( const CompareSectionToPoint& theOther ) const
   {
-    bool isLess = myPoint.X() < theOtherPoint.myPoint.X();
-    if ( !isLess && myPoint.X() == theOtherPoint.myPoint.X() ) {
-      isLess = myPoint.Y() < theOtherPoint.myPoint.Y();
-      if ( !isLess && myPoint.Y() == theOtherPoint.myPoint.Y() )
-        isLess = myPoint.Z() < theOtherPoint.myPoint.Z();
-    }
+    bool isLess = mySectionId < theOther.mySectionId;
+    if ( !isLess && mySectionId == theOther.mySectionId )
+      isLess = myPointId < theOther.myPointId;
     return isLess;
   }
+
 private:
-  gp_Pnt myPoint;
+  int mySectionId;
+  int myPointId;
 };
 
+
 void CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theContext,
                                             const CurveCreator_ICurve* theCurve,
                                             CurveCreator_ICurve::SectionToPointList& thePoints )
@@ -208,7 +209,7 @@ void CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theCo
 
   std::list<float> aSelectedPoints;
   gp_Pnt aPnt;
-  std::map<ComparePnt, int> aPntMap;
+  std::map<CompareSectionToPoint, int> aPointsMap;
 
   CurveCreator_ICurve::SectionToPointList aPoints;
   for ( theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected() ) {
@@ -220,15 +221,19 @@ void CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theCo
     if ( aVertex.IsNull() )
       continue;
     aPnt = BRep_Tool::Pnt( aVertex );
-    if ( aPntMap.find( aPnt ) != aPntMap.end() )
-      continue;
-    aPntMap[aPnt] = 0;
 
     CurveCreator_UtilsICurve::findSectionsToPoints( theCurve, aPnt.X(), aPnt.Y(), aPoints );
     CurveCreator_ICurve::SectionToPointList::const_iterator anIt = aPoints.begin(),
                                                             aLast = aPoints.end();
-    for ( ; anIt != aLast; anIt++ )
+    CompareSectionToPoint aPoint;
+    for ( ; anIt != aLast; anIt++ ) {
+      aPoint = CompareSectionToPoint( (*anIt).first, (*anIt).second );
+      if ( aPointsMap.find( aPoint ) != aPointsMap.end() )
+        continue;
+      aPointsMap[aPoint] = 0;
+
       thePoints.push_back( *anIt );
+    }
   }
 }