1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0032078: Visualization, Poly_Triangulation - add cached bounding box.

1) Add empty constructor for Poly_Triangulation(),
2) Add Poly_Triangulation::HasGeometry() method to check that triangulation has any geometry.
3) Add possibility to cache bounding box in Poly_Triangulation and use it later in case of empty triangulation.
4) Add Poly_Triangulation::MinMax() to extends input box with bounding box of triangulation.
5) Add Poly_Triangulation::UpdateCachedMinMax() to cache min - max range of this triangulation with bounding box of nodal data.
6) Add virtual Poly_Triangulation::computeBoundingBox() to calculate bounding box of nodal data.
7) Update BRepBndLib::Add/AddOptimal/AddOBB algorithms to check empty triangulation and use cached box in this case.
8) Update BRepGProp::roughBary/surfaceProperties/volumeProperties to skip empty triangulation.
9) Remove additional myBox from RWGltf_GltfLatePrimitiveArray and some hack to save this box as nodes of base Poly_Triangulation.
10) Cache min-max range from JT file during its parsing
This commit is contained in:
osa
2021-01-22 17:56:45 +03:00
committed by bugmaster
parent a46ab511c5
commit 538ab5dd8a
9 changed files with 232 additions and 104 deletions

View File

@@ -88,16 +88,10 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTria
const TopoDS_Face& F = TopoDS::Face(ex.Current());
const Handle(Poly_Triangulation)& T = BRep_Tool::Triangulation(F, l);
const Handle(Geom_Surface)& GS = BRep_Tool::Surface (F, aDummyLoc);
if ((useTriangulation || GS.IsNull()) && !T.IsNull())
if ((useTriangulation || GS.IsNull()) && !T.IsNull() && T->MinMax (B, l))
{
nbNodes = T->NbNodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
for (i = 1; i <= nbNodes; i++) {
if (l.IsIdentity()) B.Add(Nodes(i));
else B.Add(Nodes(i).Transformed(l));
}
// B.Enlarge(T->Deflection());
B.Enlarge(T->Deflection() + BRep_Tool::Tolerance(F));
B.Enlarge (T->Deflection() + BRep_Tool::Tolerance (F));
} else
{
if (!GS.IsNull()) {
@@ -137,14 +131,14 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTria
{
const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
Handle(Poly_Polygon3D) P3d = BRep_Tool::Polygon3D(E, l);
if (!P3d.IsNull())
if (!P3d.IsNull() && P3d->NbNodes() > 0)
{
const TColgp_Array1OfPnt& Nodes = P3d->Nodes();
nbNodes = P3d->NbNodes();
for (i = 1; i <= nbNodes; i++)
{
if (l.IsIdentity()) B.Add(Nodes(i));
else B.Add(Nodes(i).Transformed(l));
if (l.IsIdentity()) B.Add(Nodes[i]);
else B.Add(Nodes[i].Transformed(l));
}
// B.Enlarge(P3d->Deflection());
B.Enlarge(P3d->Deflection() + BRep_Tool::Tolerance(E));
@@ -152,15 +146,24 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTria
else
{
BRep_Tool::PolygonOnTriangulation(E, Poly, T, l);
if (useTriangulation && !Poly.IsNull())
if (useTriangulation && !Poly.IsNull() && !T.IsNull() && T->NbNodes() > 0)
{
const TColStd_Array1OfInteger& Indices = Poly->Nodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
nbNodes = Indices.Length();
for (i = 1; i <= nbNodes; i++)
if (l.IsIdentity())
{
if (l.IsIdentity()) B.Add(Nodes(Indices(i)));
else B.Add(Nodes(Indices(i)).Transformed(l));
for (i = 1; i <= nbNodes; i++)
{
B.Add(Nodes(Indices[i]));
}
}
else
{
for (i = 1; i <= nbNodes; i++)
{
B.Add(Nodes(Indices[i]).Transformed(l));
}
}
// B.Enlarge(T->Deflection());
B.Enlarge(Poly->Deflection() + BRep_Tool::Tolerance(E));
@@ -237,20 +240,14 @@ void BRepBndLib::AddOptimal(const TopoDS_Shape& S, Bnd_Box& B,
const TopoDS_Face& F = TopoDS::Face(ex.Current());
T = BRep_Tool::Triangulation(F, l);
Bnd_Box aLocBox;
if (useTriangulation && !T.IsNull())
if (useTriangulation && !T.IsNull() && T->MinMax (aLocBox, l))
{
nbNodes = T->NbNodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
for (i = 1; i <= nbNodes; i++) {
if (l.IsIdentity()) aLocBox.Add(Nodes(i));
else aLocBox.Add(Nodes(i).Transformed(l));
}
// B.Enlarge(T->Deflection());
aLocBox.Enlarge(T->Deflection() + BRep_Tool::Tolerance(F));
Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
aLocBox.Get(xmin, ymin, zmin, xmax, ymax, zmax);
B.Update(xmin, ymin, zmin, xmax, ymax, zmax);
}
}
else
{
const Handle(Geom_Surface)& GS = BRep_Tool::Surface(F, l);
@@ -326,14 +323,14 @@ void BRepBndLib::AddOptimal(const TopoDS_Shape& S, Bnd_Box& B,
const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
Bnd_Box aLocBox;
Handle(Poly_Polygon3D) P3d = BRep_Tool::Polygon3D(E, l);
if (useTriangulation && (!P3d.IsNull()))
if (useTriangulation && !P3d.IsNull() && P3d->NbNodes() > 0)
{
const TColgp_Array1OfPnt& Nodes = P3d->Nodes();
nbNodes = P3d->NbNodes();
for (i = 1; i <= nbNodes; i++)
{
if (l.IsIdentity()) aLocBox.Add(Nodes(i));
else aLocBox.Add(Nodes(i).Transformed(l));
if (l.IsIdentity()) aLocBox.Add(Nodes[i]);
else aLocBox.Add(Nodes[i].Transformed(l));
}
Standard_Real Tol = useShapeTolerance? BRep_Tool::Tolerance(E) : 0.;
aLocBox.Enlarge(P3d->Deflection() + Tol);
@@ -341,15 +338,15 @@ void BRepBndLib::AddOptimal(const TopoDS_Shape& S, Bnd_Box& B,
else
{
BRep_Tool::PolygonOnTriangulation(E, Poly, T, l);
if (useTriangulation && !Poly.IsNull())
if (useTriangulation && !Poly.IsNull() && !T.IsNull() && T->NbNodes() > 0)
{
const TColStd_Array1OfInteger& Indices = Poly->Nodes();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
nbNodes = Indices.Length();
for (i = 1; i <= nbNodes; i++)
{
if (l.IsIdentity()) aLocBox.Add(Nodes(Indices(i)));
else aLocBox.Add(Nodes(Indices(i)).Transformed(l));
if (l.IsIdentity()) aLocBox.Add(Nodes(Indices[i]));
else aLocBox.Add(Nodes(Indices[i]).Transformed(l));
}
Standard_Real Tol = useShapeTolerance? BRep_Tool::Tolerance(E) : 0.;
aLocBox.Enlarge(Poly->Deflection() + Tol);

View File

@@ -196,8 +196,8 @@ static Standard_Integer PointsForOBB(const TopoDS_Shape& theS,
{
if (thePts)
{
const gp_Pnt aP = aLoc.IsIdentity() ? aNodesArr(i) :
aNodesArr(i).Transformed(aLoc);
const gp_Pnt aP = aLoc.IsIdentity() ? aNodesArr[i] :
aNodesArr[i].Transformed(aLoc);
(*thePts)(aRetVal) = aP;
}
@@ -239,8 +239,8 @@ static Standard_Integer PointsForOBB(const TopoDS_Shape& theS,
{
if (thePts)
{
const gp_Pnt aP = aLoc.IsIdentity() ? aNodesArr(i) :
aNodesArr(i).Transformed(aLoc);
const gp_Pnt aP = aLoc.IsIdentity() ? aNodesArr[i] :
aNodesArr[i].Transformed(aLoc);
(*thePts)(aRetVal) = aP;
}