1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

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.
This commit is contained in:
dpasukhi 2022-12-16 12:03:23 +00:00
parent 706b94cc6d
commit 5485309a4a
2 changed files with 51 additions and 0 deletions

View File

@ -13,6 +13,8 @@
#include <XCAFDoc_DimTolTool.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
#include <Precision.hxx>
#include <Standard_GUID.hxx>
#include <Standard_Type.hxx>
@ -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<Bnd_Box> 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<Bnd_Box> 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 :

View File

@ -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;