mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0022302: BRepMesh_IncrimentalMesh calls for each face of shape on vdisplay
This commit is contained in:
parent
f10018adfe
commit
3c34883cdc
@ -87,10 +87,10 @@ Standard_Real AIS_Shape::GetDeflection(const TopoDS_Shape& aShape,
|
||||
const Handle(Prs3d_Drawer)& aDrawer)
|
||||
{
|
||||
// WARNING: this same piece of code appears several times in Prs3d classes
|
||||
Standard_Real aDeflection;
|
||||
Standard_Real aDeflection = aDrawer->MaximalChordialDeviation();
|
||||
if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
|
||||
Bnd_Box B;
|
||||
BRepBndLib::Add(aShape, B);
|
||||
BRepBndLib::Add(aShape, B, Standard_False);
|
||||
if ( ! B.IsVoid() )
|
||||
{
|
||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||
@ -98,11 +98,7 @@ Standard_Real AIS_Shape::GetDeflection(const TopoDS_Shape& aShape,
|
||||
aDeflection = Max( aXmax-aXmin, Max(aYmax-aYmin, aZmax-aZmin)) *
|
||||
aDrawer->DeviationCoefficient() * 4;
|
||||
}
|
||||
else
|
||||
aDeflection = aDrawer->MaximalChordialDeviation();
|
||||
}
|
||||
else
|
||||
aDeflection = aDrawer->MaximalChordialDeviation();
|
||||
return aDeflection;
|
||||
}
|
||||
|
||||
@ -496,20 +492,7 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
|
||||
|
||||
// POP protection against crash in low layers
|
||||
|
||||
Standard_Real aDeflection = myDrawer->MaximalChordialDeviation();
|
||||
if (myDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
|
||||
{
|
||||
// Vector is calculated depending on global min max of the part:
|
||||
Bnd_Box aBndBox; //= BoundingBox(); ?
|
||||
BRepBndLib::Add (shape, aBndBox);
|
||||
if (!aBndBox.IsVoid())
|
||||
{
|
||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||
aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||
aDeflection = Max (aXmax - aXmin, Max (aYmax - aYmin, aZmax - aZmin)) * myDrawer->DeviationCoefficient();
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Real aDeflection = GetDeflection(shape, myDrawer);
|
||||
Standard_Boolean autoTriangulation = Standard_True;
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
@ -518,7 +501,7 @@ void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
|
||||
shape,
|
||||
TypOfSel,
|
||||
aDeflection,
|
||||
myDrawer->DeviationAngle(),
|
||||
myDrawer->HLRAngle(),
|
||||
autoTriangulation);
|
||||
} catch ( Standard_Failure ) {
|
||||
// cout << "a Shape should be incorrect : A Selection on the Bnd is activated "<<endl;
|
||||
@ -1178,5 +1161,4 @@ Standard_Boolean AIS_Shape::OwnHLRDeviationAngle ( Standard_Real & anAngle,
|
||||
anAngle = myDrawer->HLRAngle();
|
||||
aPreviousAngle = myDrawer->PreviousHLRDeviationAngle ();
|
||||
return myDrawer->IsOwnHLRDeviationAngle();
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,9 @@ is
|
||||
-- Package methods for shapes
|
||||
--
|
||||
|
||||
Add(S : Shape from TopoDS; B : in out Box from Bnd);
|
||||
Add(S : Shape from TopoDS;
|
||||
B : in out Box from Bnd;
|
||||
useTriangulation: Boolean from Standard = Standard_True);
|
||||
---Purpose:Adds the shape S to the bounding box B.
|
||||
-- More precisely are successively added to B:
|
||||
-- - each face of S; the triangulation of the face is used if it exists,
|
||||
|
@ -26,12 +26,11 @@
|
||||
//purpose : Add a shape bounding to a box
|
||||
//=======================================================================
|
||||
|
||||
void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B)
|
||||
void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B, Standard_Boolean useTriangulation)
|
||||
{
|
||||
TopExp_Explorer ex;
|
||||
|
||||
// Add the faces
|
||||
|
||||
BRepAdaptor_Surface BS;
|
||||
Handle(Geom_Surface) GS;
|
||||
Handle(Poly_Triangulation) T;
|
||||
@ -42,7 +41,8 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B)
|
||||
for (ex.Init(S,TopAbs_FACE); ex.More(); ex.Next()) {
|
||||
const TopoDS_Face& F = TopoDS::Face(ex.Current());
|
||||
T = BRep_Tool::Triangulation(F, l);
|
||||
if (!T.IsNull()) {
|
||||
if (useTriangulation && !T.IsNull())
|
||||
{
|
||||
nbNodes = T->NbNodes();
|
||||
const TColgp_Array1OfPnt& Nodes = T->Nodes();
|
||||
for (i = 1; i <= nbNodes; i++) {
|
||||
@ -51,8 +51,8 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B)
|
||||
}
|
||||
// B.Enlarge(T->Deflection());
|
||||
B.Enlarge(T->Deflection() + BRep_Tool::Tolerance(F));
|
||||
}
|
||||
else {
|
||||
} else
|
||||
{
|
||||
GS = BRep_Tool::Surface(F, l);
|
||||
if (!GS.IsNull()) {
|
||||
BS.Initialize(F, Standard_False);
|
||||
@ -80,31 +80,35 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B)
|
||||
}
|
||||
|
||||
// Add the edges not in faces
|
||||
|
||||
|
||||
Handle(TColStd_HArray1OfInteger) HIndices;
|
||||
Handle(Poly_PolygonOnTriangulation) Poly;
|
||||
|
||||
for (ex.Init(S,TopAbs_EDGE,TopAbs_FACE); ex.More(); ex.Next()) {
|
||||
for (ex.Init(S,TopAbs_EDGE,TopAbs_FACE); ex.More(); ex.Next())
|
||||
{
|
||||
const TopoDS_Edge& E = TopoDS::Edge(ex.Current());
|
||||
Handle(Poly_Polygon3D) P3d = BRep_Tool::Polygon3D(E, l);
|
||||
if (!P3d.IsNull()) {
|
||||
if (!P3d.IsNull())
|
||||
{
|
||||
const TColgp_Array1OfPnt& Nodes = P3d->Nodes();
|
||||
nbNodes = P3d->NbNodes();
|
||||
for (i = 1; i <= nbNodes; i++) {
|
||||
for (i = 1; i <= nbNodes; i++)
|
||||
{
|
||||
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));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
BRep_Tool::PolygonOnTriangulation(E, Poly, T, l);
|
||||
if (!Poly.IsNull()) {
|
||||
if (useTriangulation && !Poly.IsNull())
|
||||
{
|
||||
const TColStd_Array1OfInteger& Indices = Poly->Nodes();
|
||||
const TColgp_Array1OfPnt& Nodes = T->Nodes();
|
||||
nbNodes = Indices.Length();
|
||||
for (i = 1; i <= nbNodes; i++) {
|
||||
for (i = 1; i <= nbNodes; i++)
|
||||
{
|
||||
if (l.IsIdentity()) B.Add(Nodes(Indices(i)));
|
||||
else B.Add(Nodes(Indices(i)).Transformed(l));
|
||||
}
|
||||
@ -112,7 +116,8 @@ void BRepBndLib::Add(const TopoDS_Shape& S, Bnd_Box& B)
|
||||
B.Enlarge(Poly->Deflection() + BRep_Tool::Tolerance(E));
|
||||
}
|
||||
else {
|
||||
if (BRep_Tool::IsGeometric(E)) {
|
||||
if (BRep_Tool::IsGeometric(E))
|
||||
{
|
||||
BC.Initialize(E);
|
||||
BndLib_Add3dCurve::Add(BC, BRep_Tool::Tolerance(E), B);
|
||||
}
|
||||
|
@ -54,10 +54,10 @@
|
||||
static Standard_Real GetDeflection(const anyShape& aShape,
|
||||
const Handle(Prs3d_Drawer)& aDrawer)
|
||||
{
|
||||
Standard_Real aDeflection;
|
||||
Standard_Real aDeflection = aDrawer->MaximalChordialDeviation();
|
||||
if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
|
||||
Bnd_Box B;
|
||||
BRepBndLib::Add(aShape, B);
|
||||
BRepBndLib::Add(aShape, B, Standard_False);
|
||||
if ( ! B.IsVoid() )
|
||||
{
|
||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||
@ -65,12 +65,7 @@ static Standard_Real GetDeflection(const anyShape& aShape,
|
||||
aDeflection = MAX3( aXmax-aXmin , aYmax-aYmin , aZmax-aZmin)
|
||||
* aDrawer->DeviationCoefficient()*4;
|
||||
}
|
||||
else
|
||||
aDeflection = aDrawer->MaximalChordialDeviation();
|
||||
}
|
||||
else
|
||||
aDeflection = aDrawer->MaximalChordialDeviation();
|
||||
|
||||
return aDeflection;
|
||||
}
|
||||
|
||||
@ -81,7 +76,6 @@ static Standard_Boolean ShadeFromShape(const anyShape& aShape
|
||||
const Handle (Prs3d_Presentation)& aPresentation,
|
||||
const Handle (Prs3d_Drawer)& aDrawer)
|
||||
{
|
||||
|
||||
anyShadedShapeTool SST;
|
||||
Handle(Poly_Triangulation) T;
|
||||
TopLoc_Location loc;
|
||||
@ -187,7 +181,6 @@ static Standard_Boolean ShadeFromShape(const anyShape& aShape
|
||||
const anyTopFace& F = SST.CurrentFace();
|
||||
T = SST.Triangulation(F, loc);
|
||||
if (!T.IsNull()) {
|
||||
|
||||
nnn = T->NbTriangles();
|
||||
const TColgp_Array1OfPnt& Nodes = T->Nodes();
|
||||
const Poly_Array1OfTriangle& triangles = T->Triangles();
|
||||
@ -324,14 +317,18 @@ void Prs3d_ShadedShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
|
||||
}
|
||||
Standard_Real aDeflection = GetDeflection(aShape, aDrawer);
|
||||
//using of plugin
|
||||
// Check if it is possible to avoid unnecessary recomputation
|
||||
// of shape triangulation
|
||||
if( !BRepTools::Triangulation(aShape, aDeflection) )
|
||||
{
|
||||
BRepTools::Clean(aShape);
|
||||
|
||||
BRepMesh_PDiscretRoot pAlgo;
|
||||
pAlgo=BRepMesh_DiscretFactory::Get().Discret(aShape,
|
||||
aDeflection,
|
||||
aDrawer->HLRAngle());
|
||||
if (pAlgo)
|
||||
pAlgo->Perform();
|
||||
|
||||
}
|
||||
ShadeFromShape(aShape, aDeflection, Standard_True, aPresentation, aDrawer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -94,7 +94,7 @@ Matches (const Standard_Real XMin,
|
||||
Bnd_Box2d BoundBox;
|
||||
BoundBox.Update(XMin-aTol,YMin-aTol,XMax+aTol,YMax+aTol);
|
||||
|
||||
for(Standard_Integer j=0; j<mynbpoints-1; j++)
|
||||
for(Standard_Integer j=0; j<mynbpoints; j++)
|
||||
{
|
||||
if(BoundBox.IsOut(((Select3D_Pnt2d*)mypolyg2d)[j])) return Standard_False;
|
||||
}
|
||||
|
@ -67,6 +67,12 @@ void StdSelect_BRepSelectionTool
|
||||
const Standard_Real theMaxParam)
|
||||
{
|
||||
Standard_Integer aPriority = (thePriority == -1) ? GetStandardPriority (theShape, theType) : thePriority;
|
||||
|
||||
if( isAutoTriangulation && !BRepTools::Triangulation (theShape, Precision::Infinite()) )
|
||||
{
|
||||
BRepMesh_IncrementalMesh(theShape, theDeflection, Standard_False, theDeviationAngle);
|
||||
}
|
||||
|
||||
Handle(StdSelect_BRepOwner) aBrepOwner;
|
||||
switch (theType)
|
||||
{
|
||||
@ -586,13 +592,7 @@ Standard_Boolean StdSelect_BRepSelectionTool
|
||||
// check if there is triangulation of the face...
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (theFace, aLoc);
|
||||
if (aTriangulation.IsNull() && theAutoTriangulation)
|
||||
{
|
||||
Standard_Real aDefaultDefl = 0.2;
|
||||
Standard_Real aDefaultAng = 30 * PI / 180.0;
|
||||
BRepMesh_IncrementalMesh (theFace, aDefaultDefl, Standard_True, aDefaultAng);
|
||||
aTriangulation = BRep_Tool::Triangulation (theFace, aLoc);
|
||||
}
|
||||
|
||||
if (!aTriangulation.IsNull())
|
||||
{
|
||||
Handle(Select3D_SensitiveTriangulation) STG = new Select3D_SensitiveTriangulation (theOwner, aTriangulation, aLoc, theInteriorFlag);
|
||||
|
Loading…
x
Reference in New Issue
Block a user