]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/GEOM_I/GEOM_IShapesOperations_i.cc
Salome HOME
0022686: [CEA 1268] Explode a shape into edges sorted in a row from a starting point
[modules/geom.git] / src / GEOM_I / GEOM_IShapesOperations_i.cc
index cee18553c219adff6e803018108942e7c1232153..e7f4c7b903c52f837607f7713ffa29ca67178141 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  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
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -831,6 +831,49 @@ CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
   return anID;
 }
 
+//=============================================================================
+/*!
+ *  GetSubShapesIndices
+ */
+//=============================================================================
+GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSubShapesIndices
+  (GEOM::GEOM_Object_ptr theMainShape, const GEOM::ListOfGO& theSubShapes)
+{
+  GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
+  
+  //Get the reference main shape
+  Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape); 
+  if (aMainShapeRef.IsNull()) return aSeq._retn();
+      
+  //Get the subshapes
+  std::list<Handle(GEOM_Object)> aShapes;
+  int aLen = theSubShapes.length();
+  for (int ind = 0; ind < aLen; ind++) {
+    Handle(GEOM_Object) aSh = GetObjectImpl(theSubShapes[ind]);
+    if (aSh.IsNull())
+    {
+      MESSAGE("NULL shape")
+      return aSeq._retn();
+    }
+    aShapes.push_back(aSh);
+  }
+
+  //Get the IDs of <theSubShapes> inside <theMainShape>
+  Handle(TColStd_HSequenceOfInteger) aHSeq = 
+  GetOperations()->GetSubShapesIndices(aMainShapeRef, aShapes);
+  
+  if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
+
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  
+  for (Standard_Integer i = 1; i <= aLength; i++)
+    aSeq[i-1] = aHSeq->Value(i);
+
+  return aSeq._retn();
+}
+
+
 //=============================================================================
 /*!
  *  GetTopologyIndex
@@ -1863,3 +1906,44 @@ GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSameIDs
 
   return aSeq._retn();
 }
+
+//=============================================================================
+/*!
+ *  GetSubShapeEdgeSorted
+ */
+//=============================================================================
+GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSubShapeEdgeSorted
+                                        (GEOM::GEOM_Object_ptr theShape,
+                                         GEOM::GEOM_Object_ptr theStartPoint)
+{
+  GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference objects
+  Handle(GEOM_Object) aShape      = GetObjectImpl(theShape);
+  Handle(GEOM_Object) aStartPoint = GetObjectImpl(theStartPoint);
+
+  if (aShape.IsNull() || aStartPoint.IsNull()) {
+    return aSeq._retn();
+  }
+
+  //Get Shapes On Shape
+  Handle(TColStd_HSequenceOfTransient) aHSeq =
+      GetOperations()->GetSubShapeEdgeSorted(aShape, aStartPoint);
+
+  if (!GetOperations()->IsDone() || aHSeq.IsNull())
+    return aSeq._retn();
+
+  const Standard_Integer aLength = aHSeq->Length();
+  Standard_Integer       i;
+
+  aSeq->length(aLength);
+
+  for (i = 1; i <= aLength; i++) {
+    aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
+  }
+
+  return aSeq._retn();
+}