-// 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
// 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
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
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();
+}