mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0025132: Visualization - treat any TopoDS_Solid as closed volume
Advanced mechanism implemented: - BRep_Tool::IsClosed() method is used to detect non-manifold solids and open shells - Non-manifold solids are split into closed and open shells Adding message in test case
This commit is contained in:
parent
6da50d2610
commit
4769a39529
@ -257,7 +257,14 @@ namespace
|
|||||||
}
|
}
|
||||||
case TopAbs_SOLID:
|
case TopAbs_SOLID:
|
||||||
{
|
{
|
||||||
theBuilder.Add (StdPrs_ToolShadedShape::IsClosed (theShape) ? theCompoundForClosed : theCompoundForOpened, theShape);
|
for (TopoDS_Iterator anIter (theShape); anIter.More(); anIter.Next())
|
||||||
|
{
|
||||||
|
const TopoDS_Shape& aSubShape = anIter.Value();
|
||||||
|
const Standard_Boolean isClosed = aSubShape.ShapeType() == TopAbs_SHELL &&
|
||||||
|
BRep_Tool::IsClosed (aSubShape) &&
|
||||||
|
StdPrs_ToolShadedShape::IsTriangulated (aSubShape);
|
||||||
|
theBuilder.Add (isClosed ? theCompoundForClosed : theCompoundForOpened, aSubShape);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case TopAbs_SHELL:
|
case TopAbs_SHELL:
|
||||||
@ -483,12 +490,15 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
|
|||||||
// add wireframe presentation for isolated edges and vertices
|
// add wireframe presentation for isolated edges and vertices
|
||||||
wireframeFromShape (thePrs, theShape, theDrawer);
|
wireframeFromShape (thePrs, theShape, theDrawer);
|
||||||
|
|
||||||
// IsClosed also verifies triangulation completeness - perform tessellation beforehand
|
// Triangulation completeness is important for "open-closed" analysis - perform tessellation beforehand
|
||||||
Tessellate (theShape, theDrawer);
|
Tessellate (theShape, theDrawer);
|
||||||
const Standard_Boolean isClosed = StdPrs_ToolShadedShape::IsClosed (theShape);
|
|
||||||
|
// The shape types listed below need advanced analysis as potentially containing
|
||||||
|
// both closed and open parts. Solids are also included, because they might
|
||||||
|
// contain non-manifold parts inside (internal open shells)
|
||||||
if ((theShape.ShapeType() == TopAbs_COMPOUND
|
if ((theShape.ShapeType() == TopAbs_COMPOUND
|
||||||
|| theShape.ShapeType() == TopAbs_COMPSOLID)
|
|| theShape.ShapeType() == TopAbs_COMPSOLID
|
||||||
&& !isClosed
|
|| theShape.ShapeType() == TopAbs_SOLID)
|
||||||
&& theToExploreSolids)
|
&& theToExploreSolids)
|
||||||
{
|
{
|
||||||
// collect two compounds: for opened and closed (solid) sub-shapes
|
// collect two compounds: for opened and closed (solid) sub-shapes
|
||||||
@ -515,7 +525,8 @@ void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePrs,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
shadeFromShape (theShape, thePrs, theDrawer,
|
shadeFromShape (theShape, thePrs, theDrawer,
|
||||||
theHasTexels, theUVOrigin, theUVRepeat, theUVScale, isClosed);
|
theHasTexels, theUVOrigin, theUVRepeat, theUVScale,
|
||||||
|
StdPrs_ToolShadedShape::IsClosed (theShape));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theDrawer->IsFaceBoundaryDraw())
|
if (theDrawer->IsFaceBoundaryDraw())
|
||||||
|
@ -35,27 +35,23 @@
|
|||||||
#include <TopExp_Explorer.hxx>
|
#include <TopExp_Explorer.hxx>
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
|
|
||||||
namespace
|
//=======================================================================
|
||||||
|
//function : isTriangulated
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
Standard_Boolean StdPrs_ToolShadedShape::IsTriangulated (const TopoDS_Shape& theShape)
|
||||||
{
|
{
|
||||||
//=======================================================================
|
TopLoc_Location aLocDummy;
|
||||||
//function : isTriangulated
|
for (TopExp_Explorer aFaceIter (theShape, TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
|
||||||
//purpose : Returns true if all faces within shape are triangulated.
|
|
||||||
// Same as BRepTools::Triangulation() but without extra checks.
|
|
||||||
//=======================================================================
|
|
||||||
static Standard_Boolean isTriangulated (const TopoDS_Shape& theShape)
|
|
||||||
{
|
{
|
||||||
TopLoc_Location aLocDummy;
|
const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Current());
|
||||||
for (TopExp_Explorer aFaceIter (theShape, TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
|
const Handle(Poly_Triangulation)& aTri = BRep_Tool::Triangulation (aFace, aLocDummy);
|
||||||
|
if (aTri.IsNull())
|
||||||
{
|
{
|
||||||
const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Current());
|
return Standard_False;
|
||||||
const Handle(Poly_Triangulation)& aTri = BRep_Tool::Triangulation (aFace, aLocDummy);
|
|
||||||
if (aTri.IsNull())
|
|
||||||
{
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return Standard_True;
|
|
||||||
}
|
}
|
||||||
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -88,6 +84,12 @@ Standard_Boolean StdPrs_ToolShadedShape::IsClosed (const TopoDS_Shape& theShape)
|
|||||||
}
|
}
|
||||||
case TopAbs_SOLID:
|
case TopAbs_SOLID:
|
||||||
{
|
{
|
||||||
|
// Check for non-manifold topology first of all:
|
||||||
|
// have to use BRep_Tool::IsClosed() because it checks the face connectivity
|
||||||
|
// inside the shape
|
||||||
|
if (!BRep_Tool::IsClosed (theShape))
|
||||||
|
return Standard_False;
|
||||||
|
|
||||||
for (TopoDS_Iterator anIter (theShape); anIter.More(); anIter.Next())
|
for (TopoDS_Iterator anIter (theShape); anIter.More(); anIter.Next())
|
||||||
{
|
{
|
||||||
const TopoDS_Shape& aShape = anIter.Value();
|
const TopoDS_Shape& aShape = anIter.Value();
|
||||||
@ -96,17 +98,12 @@ Standard_Boolean StdPrs_ToolShadedShape::IsClosed (const TopoDS_Shape& theShape)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aShape.ShapeType() == TopAbs_SHELL
|
if (aShape.ShapeType() == TopAbs_FACE)
|
||||||
&& !aShape.Closed())
|
|
||||||
{
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
else if (aShape.ShapeType() == TopAbs_FACE)
|
|
||||||
{
|
{
|
||||||
// invalid solid
|
// invalid solid
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
else if (!isTriangulated (aShape))
|
else if (!IsTriangulated (aShape))
|
||||||
{
|
{
|
||||||
// mesh contains holes
|
// mesh contains holes
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
@ -32,8 +32,12 @@ public:
|
|||||||
|
|
||||||
DEFINE_STANDARD_ALLOC
|
DEFINE_STANDARD_ALLOC
|
||||||
|
|
||||||
|
//! Similar to BRepTools::Triangulation() but without extra checks.
|
||||||
|
//! @return true if all faces within shape are triangulated.
|
||||||
|
Standard_EXPORT static Standard_Boolean IsTriangulated (const TopoDS_Shape& theShape);
|
||||||
|
|
||||||
//! Checks back faces visibility for specified shape (to activate back-face culling). <br>
|
//! Checks back faces visibility for specified shape (to activate back-face culling). <br>
|
||||||
//! @return true if shape is closed Solid or compound of closed Solids. <br>
|
//! @return true if shape is closed manifold Solid or compound of such Solids. <br>
|
||||||
Standard_EXPORT static Standard_Boolean IsClosed(const TopoDS_Shape& theShape);
|
Standard_EXPORT static Standard_Boolean IsClosed(const TopoDS_Shape& theShape);
|
||||||
|
|
||||||
Standard_EXPORT static Handle_Poly_Triangulation Triangulation(const TopoDS_Face& aFace,
|
Standard_EXPORT static Handle_Poly_Triangulation Triangulation(const TopoDS_Face& aFace,
|
||||||
|
34
tests/bugs/vis/bug25132
Normal file
34
tests/bugs/vis/bug25132
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
puts "============"
|
||||||
|
puts "OCC25132"
|
||||||
|
puts "============"
|
||||||
|
puts ""
|
||||||
|
####################################################################################
|
||||||
|
# Visualization - Capping algorithm not working sometimes
|
||||||
|
####################################################################################
|
||||||
|
|
||||||
|
vinit View1
|
||||||
|
vsetdispmode 1
|
||||||
|
vclipplane create pln1
|
||||||
|
vclipplane change pln1 equation 0 1 0 0
|
||||||
|
vclipplane change pln1 capping on
|
||||||
|
vclipplane set pln1 view Driver1/Viewer1/View1
|
||||||
|
|
||||||
|
# Capping should be enabled for the solid with a bounding shell with Closed flag not set
|
||||||
|
restore [locate_data_file OCC25132-flight_solid.brep] fs
|
||||||
|
vdisplay fs
|
||||||
|
vfit
|
||||||
|
vdump $imagedir/${casename}_flight_solid.png
|
||||||
|
vremove fs
|
||||||
|
|
||||||
|
# Capping should be enabled for the solid with cavities
|
||||||
|
restore [locate_data_file OCC25132-solid_with_cavities.brep] sc
|
||||||
|
vdisplay sc
|
||||||
|
vfit
|
||||||
|
vdump $imagedir/${casename}_solid_with_cavities.png
|
||||||
|
vremove sc
|
||||||
|
|
||||||
|
# Capping should display a non-manifold solid with an internal open shell correctly
|
||||||
|
restore [locate_data_file OCC25132-Partition_1.brep] p1
|
||||||
|
vdisplay p1
|
||||||
|
vfit
|
||||||
|
vdump $imagedir/${casename}_Partition_1.png
|
@ -1 +1,8 @@
|
|||||||
set TheFileName shading_137.brep
|
set TheFileName shading_137.brep
|
||||||
|
if { [string compare ${command} "shading"] == 0 && [string compare ${group} "standard"] == 0 } {
|
||||||
|
puts ""
|
||||||
|
puts "CR25132"
|
||||||
|
puts "san (developer) 2014-08-26 16:59"
|
||||||
|
puts "The shaded representation looks strange because it is treated as a closed solid by visualization (back faces of the triangles are not drawn)."
|
||||||
|
puts ""
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user