mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-05-10 09:30:48 +08:00
Modeling Algorithms - Replace HLRAlgo_PolyData::Box with Bnd_Box (#923)
Replace custom HLRAlgo_PolyData::Box struct with standard Bnd_Box class to leverage its built-in update functionality and reduce code duplication. Changes: - Remove HLRAlgo_PolyData::Box struct definition - Update UpdateGlobalMinMax methods to use Bnd_Box::Update() - Simplify bounding box computation logic using Bnd_Box methods - Use C++17 structured bindings with Bnd_Box::Get()
This commit is contained in:
@@ -67,7 +67,7 @@ void HLRAlgo_PolyAlgo::Update()
|
||||
Standard_Real xSegmnMin, ySegmnMin, zSegmnMin;
|
||||
Standard_Real xSegmnMax, ySegmnMax, zSegmnMax;
|
||||
constexpr Standard_Real Big = Precision::Infinite();
|
||||
HLRAlgo_PolyData::Box aBox(Big, Big, Big, -Big, -Big, -Big);
|
||||
Bnd_Box aBox;
|
||||
|
||||
myNbrShell = myHShell.Size();
|
||||
for (Standard_Integer aShellIter = myHShell.Lower(); aShellIter <= myHShell.Upper(); ++aShellIter)
|
||||
@@ -76,10 +76,11 @@ void HLRAlgo_PolyAlgo::Update()
|
||||
aPsd->UpdateGlobalMinMax(aBox);
|
||||
}
|
||||
|
||||
Standard_Real dx = aBox.XMax - aBox.XMin;
|
||||
Standard_Real dy = aBox.YMax - aBox.YMin;
|
||||
Standard_Real dz = aBox.ZMax - aBox.ZMin;
|
||||
Standard_Real precad = dx;
|
||||
const auto [aXMin, aXMax, aYMin, aYMax, aZMin, aZMax] = aBox.Get();
|
||||
Standard_Real dx = aXMax - aXMin;
|
||||
Standard_Real dy = aYMax - aYMin;
|
||||
Standard_Real dz = aZMax - aZMin;
|
||||
Standard_Real precad = dx;
|
||||
if (precad < dy)
|
||||
precad = dy;
|
||||
if (precad < dz)
|
||||
@@ -90,9 +91,9 @@ void HLRAlgo_PolyAlgo::Update()
|
||||
Standard_Real SurDY = 1020 / (dy + precad);
|
||||
Standard_Real SurDZ = 508 / (dz + precad);
|
||||
precad = precad * 0.5;
|
||||
Standard_Real DecaX = -aBox.XMin + precad;
|
||||
Standard_Real DecaY = -aBox.YMin + precad;
|
||||
Standard_Real DecaZ = -aBox.ZMin + precad;
|
||||
Standard_Real DecaX = -aXMin + precad;
|
||||
Standard_Real DecaY = -aYMin + precad;
|
||||
Standard_Real DecaZ = -aZMin + precad;
|
||||
|
||||
for (Standard_Integer aShellIter = myHShell.Lower(); aShellIter <= myHShell.Upper(); ++aShellIter)
|
||||
{
|
||||
|
||||
@@ -53,69 +53,24 @@ void HLRAlgo_PolyData::HPHDat(const Handle(HLRAlgo_HArray1OfPHDat)& HPHDat)
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void HLRAlgo_PolyData::UpdateGlobalMinMax(Box& theBox)
|
||||
void HLRAlgo_PolyData::UpdateGlobalMinMax(Bnd_Box& theBox)
|
||||
{
|
||||
Standard_Integer i;
|
||||
Standard_Real X1, X2, X3, Y1, Y2, Y3, Z1, Z2, Z3;
|
||||
const TColgp_Array1OfXYZ& Nodes = myHNodes->Array1();
|
||||
HLRAlgo_Array1OfTData& TData = myHTData->ChangeArray1();
|
||||
Standard_Integer nbT = TData.Upper();
|
||||
HLRAlgo_TriangleData* TD = &(TData.ChangeValue(1));
|
||||
const TColgp_Array1OfXYZ& Nodes = myHNodes->Array1();
|
||||
const HLRAlgo_Array1OfTData& TData = myHTData->Array1();
|
||||
const Standard_Integer nbT = TData.Upper();
|
||||
|
||||
for (i = 1; i <= nbT; i++)
|
||||
for (Standard_Integer i = 1; i <= nbT; i++)
|
||||
{
|
||||
if (TD->Flags & HLRAlgo_PolyMask_FMskHiding)
|
||||
const HLRAlgo_TriangleData& TD = TData.Value(i);
|
||||
if (TD.Flags & HLRAlgo_PolyMask_FMskHiding)
|
||||
{
|
||||
const gp_XYZ& P1 = Nodes(TD->Node1);
|
||||
const gp_XYZ& P2 = Nodes(TD->Node2);
|
||||
const gp_XYZ& P3 = Nodes(TD->Node3);
|
||||
X1 = P1.X();
|
||||
Y1 = P1.Y();
|
||||
Z1 = P1.Z();
|
||||
X2 = P2.X();
|
||||
Y2 = P2.Y();
|
||||
Z2 = P2.Z();
|
||||
X3 = P3.X();
|
||||
Y3 = P3.Y();
|
||||
Z3 = P3.Z();
|
||||
if (theBox.XMin > X1)
|
||||
theBox.XMin = X1;
|
||||
else if (theBox.XMax < X1)
|
||||
theBox.XMax = X1;
|
||||
if (theBox.YMin > Y1)
|
||||
theBox.YMin = Y1;
|
||||
else if (theBox.YMax < Y1)
|
||||
theBox.YMax = Y1;
|
||||
if (theBox.ZMin > Z1)
|
||||
theBox.ZMin = Z1;
|
||||
else if (theBox.ZMax < Z1)
|
||||
theBox.ZMax = Z1;
|
||||
if (theBox.XMin > X2)
|
||||
theBox.XMin = X2;
|
||||
else if (theBox.XMax < X2)
|
||||
theBox.XMax = X2;
|
||||
if (theBox.YMin > Y2)
|
||||
theBox.YMin = Y2;
|
||||
else if (theBox.YMax < Y2)
|
||||
theBox.YMax = Y2;
|
||||
if (theBox.ZMin > Z2)
|
||||
theBox.ZMin = Z2;
|
||||
else if (theBox.ZMax < Z2)
|
||||
theBox.ZMax = Z2;
|
||||
if (theBox.XMin > X3)
|
||||
theBox.XMin = X3;
|
||||
else if (theBox.XMax < X3)
|
||||
theBox.XMax = X3;
|
||||
if (theBox.YMin > Y3)
|
||||
theBox.YMin = Y3;
|
||||
else if (theBox.YMax < Y3)
|
||||
theBox.YMax = Y3;
|
||||
if (theBox.ZMin > Z3)
|
||||
theBox.ZMin = Z3;
|
||||
else if (theBox.ZMax < Z3)
|
||||
theBox.ZMax = Z3;
|
||||
const gp_XYZ& P1 = Nodes(TD.Node1);
|
||||
const gp_XYZ& P2 = Nodes(TD.Node2);
|
||||
const gp_XYZ& P3 = Nodes(TD.Node3);
|
||||
theBox.Update(P1.X(), P1.Y(), P1.Z());
|
||||
theBox.Update(P2.X(), P2.Y(), P2.Z());
|
||||
theBox.Update(P3.X(), P3.Y(), P3.Z());
|
||||
}
|
||||
TD++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
#ifndef _HLRAlgo_PolyData_HeaderFile
|
||||
#define _HLRAlgo_PolyData_HeaderFile
|
||||
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <HLRAlgo_BiPoint.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <TColgp_HArray1OfXYZ.hxx>
|
||||
#include <HLRAlgo_HArray1OfTData.hxx>
|
||||
#include <HLRAlgo_HArray1OfPHDat.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <HLRAlgo_HArray1OfTData.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TColgp_HArray1OfXYZ.hxx>
|
||||
|
||||
class HLRAlgo_EdgeStatus;
|
||||
|
||||
@@ -57,38 +57,6 @@ public:
|
||||
Standard_Real Param, TolParam, TolAng, Tolerance;
|
||||
};
|
||||
|
||||
struct Box
|
||||
{
|
||||
Standard_Real XMin, YMin, ZMin, XMax, YMax, ZMax;
|
||||
|
||||
//! The default constructor.
|
||||
Box()
|
||||
: XMin(0.0),
|
||||
YMin(0.0),
|
||||
ZMin(0.0),
|
||||
XMax(0.0),
|
||||
YMax(0.0),
|
||||
ZMax(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
//! The initializing constructor.
|
||||
Box(const Standard_Real& theXMin,
|
||||
const Standard_Real& theYMin,
|
||||
const Standard_Real& theZMin,
|
||||
const Standard_Real& theXMax,
|
||||
const Standard_Real& theYMax,
|
||||
const Standard_Real& theZMax)
|
||||
: XMin(theXMin),
|
||||
YMin(theYMin),
|
||||
ZMin(theZMin),
|
||||
XMax(theXMax),
|
||||
YMax(theYMax),
|
||||
ZMax(theZMax)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
Standard_EXPORT HLRAlgo_PolyData();
|
||||
|
||||
Standard_EXPORT void HNodes(const Handle(TColgp_HArray1OfXYZ)& HNodes);
|
||||
@@ -107,7 +75,7 @@ public:
|
||||
|
||||
HLRAlgo_Array1OfPHDat& PHDat() const;
|
||||
|
||||
Standard_EXPORT void UpdateGlobalMinMax(Box& theBox);
|
||||
Standard_EXPORT void UpdateGlobalMinMax(Bnd_Box& theBox);
|
||||
|
||||
Standard_Boolean Hiding() const;
|
||||
|
||||
|
||||
@@ -30,56 +30,13 @@ HLRAlgo_PolyShellData::HLRAlgo_PolyShellData(const Standard_Integer nbFace)
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void HLRAlgo_PolyShellData::UpdateGlobalMinMax(HLRAlgo_PolyData::Box& theBox)
|
||||
void HLRAlgo_PolyShellData::UpdateGlobalMinMax(Bnd_Box& theBox)
|
||||
{
|
||||
HLRAlgo_ListIteratorOfListOfBPoint it;
|
||||
|
||||
for (it.Initialize(mySegList); it.More(); it.Next())
|
||||
for (HLRAlgo_ListIteratorOfListOfBPoint it(mySegList); it.More(); it.Next())
|
||||
{
|
||||
HLRAlgo_BiPoint& BP = it.ChangeValue();
|
||||
HLRAlgo_BiPoint::PointsT& aPoints = BP.Points();
|
||||
if (aPoints.PntP1.X() < aPoints.PntP2.X())
|
||||
{
|
||||
if (theBox.XMin > aPoints.PntP1.X())
|
||||
theBox.XMin = aPoints.PntP1.X();
|
||||
else if (theBox.XMax < aPoints.PntP2.X())
|
||||
theBox.XMax = aPoints.PntP2.X();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (theBox.XMin > aPoints.PntP2.X())
|
||||
theBox.XMin = aPoints.PntP2.X();
|
||||
else if (theBox.XMax < aPoints.PntP1.X())
|
||||
theBox.XMax = aPoints.PntP1.X();
|
||||
}
|
||||
if (aPoints.PntP1.Y() < aPoints.PntP2.Y())
|
||||
{
|
||||
if (theBox.YMin > aPoints.PntP1.Y())
|
||||
theBox.YMin = aPoints.PntP1.Y();
|
||||
else if (theBox.YMax < aPoints.PntP2.Y())
|
||||
theBox.YMax = aPoints.PntP2.Y();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (theBox.YMin > aPoints.PntP2.Y())
|
||||
theBox.YMin = aPoints.PntP2.Y();
|
||||
else if (theBox.YMax < aPoints.PntP1.Y())
|
||||
theBox.YMax = aPoints.PntP1.Y();
|
||||
}
|
||||
if (aPoints.PntP1.Z() < aPoints.PntP2.Z())
|
||||
{
|
||||
if (theBox.ZMin > aPoints.PntP1.Z())
|
||||
theBox.ZMin = aPoints.PntP1.Z();
|
||||
else if (theBox.ZMax < aPoints.PntP2.Z())
|
||||
theBox.ZMax = aPoints.PntP2.Z();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (theBox.ZMin > aPoints.PntP2.Z())
|
||||
theBox.ZMin = aPoints.PntP2.Z();
|
||||
else if (theBox.ZMax < aPoints.PntP1.Z())
|
||||
theBox.ZMax = aPoints.PntP1.Z();
|
||||
}
|
||||
const HLRAlgo_BiPoint::PointsT& aPoints = it.Value().Points();
|
||||
theBox.Update(aPoints.PntP1.X(), aPoints.PntP1.Y(), aPoints.PntP1.Z());
|
||||
theBox.Update(aPoints.PntP2.X(), aPoints.PntP2.Y(), aPoints.PntP2.Z());
|
||||
}
|
||||
for (Standard_Integer i = myPolyg.Lower(); i <= myPolyg.Upper(); i++)
|
||||
{
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
#ifndef _HLRAlgo_PolyShellData_HeaderFile
|
||||
#define _HLRAlgo_PolyShellData_HeaderFile
|
||||
|
||||
#include <Standard_Type.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <HLRAlgo_ListOfBPoint.hxx>
|
||||
#include <HLRAlgo_PolyData.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
class HLRAlgo_PolyShellData;
|
||||
DEFINE_STANDARD_HANDLE(HLRAlgo_PolyShellData, Standard_Transient)
|
||||
@@ -37,7 +38,7 @@ public:
|
||||
|
||||
Standard_EXPORT HLRAlgo_PolyShellData(const Standard_Integer nbFace);
|
||||
|
||||
Standard_EXPORT void UpdateGlobalMinMax(HLRAlgo_PolyData::Box& theBox);
|
||||
Standard_EXPORT void UpdateGlobalMinMax(Bnd_Box& theBox);
|
||||
|
||||
Standard_EXPORT void UpdateHiding(const Standard_Integer nbHiding);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user