Salome HOME
0023312: [CEA 1928] GEOM: Create group from second shape
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IShapesOperations.cxx
index 46a9c78a44e5ca1ee026c89ff5c108ea76319c4a..75b41d6e77cf20fcefaaefa4206101304b3e444d 100644 (file)
@@ -139,7 +139,7 @@ namespace
    * \brief Returns the vertex from theWhere shape that is coincident with
    * theVertex.
    *
-   * \param theWhere the shape where the coinsident vertex is searched.
+   * \param theWhere the shape where the coincident vertex is searched.
    * \param theVertex the vertex to be searched.
    * \return the coincident vertex if it is found. Otherwise null object.
    */
@@ -2644,7 +2644,7 @@ Handle(TColStd_HSequenceOfInteger)
   aFinder.SetState(theState);
   aFinder.Perform();
 
-  // Interprete results
+  // Interpret results
   Standard_Integer iErr = aFinder.ErrorStatus();
   // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
   if (iErr) {
@@ -2836,7 +2836,7 @@ Handle(TColStd_HSequenceOfInteger)
   aFinder.SetState(theState);
   aFinder.Perform();
 
-  // Interprete results
+  // Interpret results
   Standard_Integer iErr = aFinder.ErrorStatus();
   // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
   if (iErr) {
@@ -3335,7 +3335,7 @@ Handle(TColStd_HSequenceOfInteger)
 
   aFinder.Perform();
 
-  // Interprete results
+  // Interpret results
   Standard_Integer iErr = aFinder.ErrorStatus();
   // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
   if (iErr) {
@@ -4263,7 +4263,7 @@ Handle(TColStd_HSequenceOfInteger)
 
   aFinder.Perform();
 
-  // Interprete results
+  // Interpret results
   Standard_Integer iErr = aFinder.ErrorStatus();
   // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
   if (iErr) {
@@ -4715,6 +4715,42 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceByHistory
   return aResult;
 }
 
+//=======================================================================
+//function : GetInPlaceMap
+//purpose  :
+//=======================================================================
+void GEOMImpl_IShapesOperations::GetInPlaceMap (Handle(GEOM_Object) theShapeWhere,
+                                                Handle(GEOM_Object) theShapeWhat,
+                                                std::vector< std::vector< int > > & theResVec)
+{
+  SetErrorCode(KO);
+
+  if (theShapeWhere.IsNull() || theShapeWhat.IsNull()) return;
+
+  TopoDS_Shape aWhere = theShapeWhere->GetValue();
+  TopoDS_Shape aWhat  = theShapeWhat->GetValue();
+
+  if (aWhere.IsNull() || aWhat.IsNull()) return;
+
+  Handle(GEOM_Function) aWhereFunction = theShapeWhere->GetLastFunction();
+  if (aWhereFunction.IsNull()) return;
+
+  bool isFound = GEOMAlgo_GetInPlaceAPI::GetInPlaceMap( aWhereFunction, aWhat, theResVec );
+
+  if ( isFound )
+    SetErrorCode(OK);
+
+  Handle(GEOM_Function) aFunction =
+    GEOM::GetCreatedLast(theShapeWhere,theShapeWhat)->GetLastFunction();
+
+  GEOM::TPythonDump(aFunction, /*append=*/true)
+    << "resultList = geompy.GetInPlaceMap( "
+    << theShapeWhere << ", "
+    << theShapeWhat << ")";
+
+  return;
+}
+
 //=======================================================================
 //function : isSameEdge
 //purpose  : Returns True if two edges coincide
@@ -4758,6 +4794,10 @@ static bool isSameEdge(const TopoDS_Edge& theEdge1, const TopoDS_Edge& theEdge2)
   gp_Pnt P2 = C1->Value(U);     //Compute a point on two thirds of the edge's length
 
   C2 = new Geom_TrimmedCurve(C2, U21, U22);
+  // vsr 04/10/2018: 0023312 - As curve may be periodic, its parameters may be normalized
+  // so, we re-take them from trimmed curve
+  U21 = C2->FirstParameter();
+  U22 = C2->LastParameter();
 
   if(!GeomLib_Tool::Parameter(C2, P1, MAX_TOLERANCE, U) ||  U < U21 || U > U22)
     return false;