From: dpasukhi Date: Fri, 16 Dec 2022 12:03:23 +0000 (+0000) Subject: 0033273: Data Exchange, GDT - Getting number of multiple elements with the same measure X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=5485309a4ad00fa3ed0c57b0079137145b67726d;p=occt.git 0033273: Data Exchange, GDT - Getting number of multiple elements with the same measure Updated DimTolTool API to get number of multiple elements with the same measure. --- diff --git a/src/XCAFDoc/XCAFDoc_DimTolTool.cxx b/src/XCAFDoc/XCAFDoc_DimTolTool.cxx index 8a5da13d17..a6a16c527a 100644 --- a/src/XCAFDoc/XCAFDoc_DimTolTool.cxx +++ b/src/XCAFDoc/XCAFDoc_DimTolTool.cxx @@ -13,6 +13,8 @@ #include +#include +#include #include #include #include @@ -617,6 +619,51 @@ Standard_Boolean XCAFDoc_DimTolTool::GetRefDatumLabel(const TDF_Label& theShapeL return Standard_True; } +//======================================================================= +//function : GetNumberOfPlaces +//purpose : +//======================================================================= +Standard_Integer XCAFDoc_DimTolTool::GetNumberOfPlaces(const TDF_Label& theLabel) +{ + TDF_LabelSequence aFirstShapes, aSecondShapes; + GetRefShapeLabel(theLabel, aFirstShapes, aSecondShapes); + + NCollection_Sequence aBoxes; + for (Standard_Integer anI = 1; anI <= aFirstShapes.Size(); anI++) + { + Bnd_Box aBox; + BRepBndLib::Add(ShapeTool()->GetShape(aFirstShapes(anI)), aBox, Standard_True); + aBoxes.Append(aBox); + } + + // Fill bounded boxes of number of places - this will exclude duplications + NCollection_Sequence aPlaces; + for (Standard_Integer anI = 1; anI <= aBoxes.Size(); anI++) + { + Standard_Boolean toAddPlace = Standard_True; + Standard_Integer aBoxesIndex = 1; + for (Standard_Integer aJ = 1; aJ <= aPlaces.Size(); aJ++) + { + if (!aPlaces(aJ).IsOut(aBoxes(anI))) + { + toAddPlace = Standard_False; + aBoxesIndex = aJ; + break; + } + } + + if (toAddPlace) + { + aPlaces.Append(aBoxes(anI)); + } + else + { + aPlaces.ChangeValue(aBoxesIndex).Add(aBoxes(anI)); + } + } + return aPlaces.Size(); +} + //======================================================================= //function : GetDimTol //purpose : diff --git a/src/XCAFDoc/XCAFDoc_DimTolTool.hxx b/src/XCAFDoc/XCAFDoc_DimTolTool.hxx index ae511ab318..e6de6f96ed 100644 --- a/src/XCAFDoc/XCAFDoc_DimTolTool.hxx +++ b/src/XCAFDoc/XCAFDoc_DimTolTool.hxx @@ -232,6 +232,10 @@ public: Standard_EXPORT Standard_Boolean GetRefDatumLabel (const TDF_Label& theShapeL, TDF_LabelSequence& theDatum) const; + //! @param theLabel [in] geometrical tolerance TDF label. + //! @return Number Of Places corresponding to the Geometrical Tolerance or Dimensional Tolerance TDF label. + Standard_EXPORT Standard_Integer GetNumberOfPlaces (const TDF_Label& theLabel); + //! Returns true if the given GDT is marked as locked. Standard_EXPORT Standard_Boolean IsLocked(const TDF_Label& theViewL) const;