*/
long GetSubShapeIndex (in GEOM_Object theMainShape, in GEOM_Object theSubShape);
+ /*!
+ * Get global indices of \a theSubShapes in \a theMainShape.
+ * \param theMainShape Main shape.
+ * \param theSubShapes List of sub-shapes of the main shape.
+ * \return list of global indices of \a theSubShapes in \a theMainShape.
+ */
+ ListOfLong GetSubShapesIndices (in GEOM_Object theMainShape, in ListOfGO theSubShapes);
+
/*!
* \brief Get index of \a theSubShape in \a theMainShape, unique among sub-shapes of the same type.
*
TopTools_IndexedMapOfShape anIndices;
TopExp::MapShapes(aMainShape, anIndices);
- if (anIndices.Contains(aSubShape)) {
+// if (anIndices.Contains(aSubShape)) {
+// SetErrorCode(OK);
+// return anIndices.FindIndex(aSubShape);
+// }
+ int id = anIndices.FindIndex(aSubShape);
+ if (id > 0)
+ {
SetErrorCode(OK);
- return anIndices.FindIndex(aSubShape);
+ return id;
}
-
return -1;
}
+
+
+//=============================================================================
+/*!
+ * GetSubShapeIndices
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetSubShapesIndices (Handle(GEOM_Object) theMainShape,
+ std::list<Handle(GEOM_Object)> theSubShapes)
+{
+ MESSAGE("GEOMImpl_IShapesOperations::GetSubShapesIndices")
+ SetErrorCode(KO);
+
+ Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
+
+ TopoDS_Shape aMainShape = theMainShape->GetValue();
+ if (aMainShape.IsNull())
+ {
+ MESSAGE("NULL main shape")
+ return NULL;
+ }
+
+ TopTools_IndexedMapOfShape anIndices;
+ TopExp::MapShapes(aMainShape, anIndices);
+
+ std::list<Handle(GEOM_Object)>::iterator it;
+ for (it=theSubShapes.begin(); it != theSubShapes.end(); ++it)
+ {
+ TopoDS_Shape aSubShape = (*it)->GetValue();
+ if (aSubShape.IsNull())
+ {
+ MESSAGE("NULL subshape")
+ return NULL;
+ }
+ int id = anIndices.FindIndex(aSubShape);
+ aSeq->Append(id);
+ }
+
+ SetErrorCode(OK);
+ return aSeq;
+}
+
+
//=============================================================================
/*!
* GetTopologyIndex
Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
Handle(GEOM_Object) theSubShape);
+
+ Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetSubShapesIndices (Handle(GEOM_Object) theMainShape,
+ std::list<Handle(GEOM_Object)> theSubShapes);
Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
Handle(GEOM_Object) theSubShape);
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
CORBA::Long GetSubShapeIndex (GEOM::GEOM_Object_ptr theMainShape,
GEOM::GEOM_Object_ptr theSubShape);
+
+ GEOM::ListOfLong* GetSubShapesIndices (GEOM::GEOM_Object_ptr theMainShape,
+ const GEOM::ListOfGO& theSubShapes);
CORBA::Long GetTopologyIndex (GEOM::GEOM_Object_ptr theMainShape,
GEOM::GEOM_Object_ptr theSubShape);
anID = self.LocalOp.GetSubShapeIndex(aShape, aSubShape)
RaiseIfFailed("GetSubShapeIndex", self.LocalOp)
return anID
+
+ ## Obtain unique IDs of sub-shapes <VAR>aSubShapes</VAR> inside <VAR>aShape</VAR>
+ # This function is provided for performance purpose. The complexity is O(n) with n
+ # the number of subobjects of aShape
+ # @param aShape Shape to get sub-shape of.
+ # @param aSubShapes Sub-shapes of aShape.
+ # @return list of IDs of found sub-shapes.
+ #
+ # @ref swig_all_decompose "Example"
+ def GetSubShapesIDs(self, aShape, aSubShapes):
+ """
+ Obtain a list of IDs of sub-shapes aSubShapes inside aShape
+ This function is provided for performance purpose. The complexity is O(n) with n
+ the number of subobjects of aShape
+
+ Parameters:
+ aShape Shape to get sub-shape of.
+ aSubShapes Sub-shapes of aShape.
+
+ Returns:
+ List of IDs of found sub-shape.
+ """
+ # Example: see GEOM_TestAll.py
+ anIDs = self.ShapesOp.GetSubShapesIndices(aShape, aSubShapes)
+ RaiseIfFailed("GetSubShapesIndices", self.ShapesOp)
+ return anIDs
# end of l4_access
## @}