From: ika Date: Tue, 14 May 2024 14:26:59 +0000 (+0100) Subject: * 0033273: Data Exchange, GDT - Getting number of multiple elements with the same... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=8573cc5994ba80489b3a6073454216bad002e0be;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 4ad3778ed6..ca43e4a557 100644 --- a/src/XCAFDoc/XCAFDoc_DimTolTool.cxx +++ b/src/XCAFDoc/XCAFDoc_DimTolTool.cxx @@ -13,6 +13,8 @@ #include +#include +#include #include #include #include @@ -1058,6 +1060,51 @@ void XCAFDoc_DimTolTool::SetGDTPresentations(NCollection_IndexedDataMap 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 : DumpJson //purpose : diff --git a/src/XCAFDoc/XCAFDoc_DimTolTool.hxx b/src/XCAFDoc/XCAFDoc_DimTolTool.hxx index ea4b34436f..40e0e08181 100644 --- a/src/XCAFDoc/XCAFDoc_DimTolTool.hxx +++ b/src/XCAFDoc/XCAFDoc_DimTolTool.hxx @@ -229,6 +229,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;