//purpose :
//=======================================================================
-void BRepTools::Clean (const TopoDS_Shape& theShape)
+void BRepTools::Clean (const TopoDS_Shape& theShape, const Standard_Boolean theForce)
{
if (theShape.IsNull())
return;
TopExp_Explorer aEdgeIt(aFace, TopAbs_EDGE);
for (; aEdgeIt.More(); aEdgeIt.Next())
{
- const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current());
- aBuilder.UpdateEdge(aEdge, aNullPoly, aTriangulation, aLoc);
+ const TopoDS_Edge& anEdge = TopoDS::Edge(aEdgeIt.Current());
+ aBuilder.UpdateEdge(anEdge, aNullPoly, aTriangulation, aLoc);
}
aBuilder.UpdateFace(aFace, aNullTriangulation);
TopExp_Explorer aEdgeIt (theShape, TopAbs_EDGE);
for (; aEdgeIt.More (); aEdgeIt.Next ())
{
- TopoDS_Edge anEdgeNoLoc = TopoDS::Edge (aEdgeIt.Value());
- anEdgeNoLoc.Location (anEmptyLoc);
+ TopoDS_Edge anEdge = TopoDS::Edge(aEdgeIt.Value());
+ anEdge.Location(anEmptyLoc);
- if (!aShapeMap.Add (anEdgeNoLoc))
+ if (!aShapeMap.Add(anEdge))
{
// the edge has already been processed
continue;
}
- if (!BRep_Tool::IsGeometric (TopoDS::Edge (anEdgeNoLoc)))
+ if (!BRep_Tool::IsGeometric(TopoDS::Edge(anEdge)))
{
// Do not remove polygon 3d as there is no curve to recompute it.
continue;
}
TopLoc_Location aLoc;
- Handle (Poly_Polygon3D) aPoly3d = BRep_Tool::Polygon3D (anEdgeNoLoc, aLoc);
- if (aPoly3d.IsNull())
- continue;
+ Handle(Poly_Polygon3D) aPoly3d = BRep_Tool::Polygon3D(anEdge, aLoc);
- aBuilder.UpdateEdge (anEdgeNoLoc, aNullPoly3d);
+ if (!aPoly3d.IsNull())
+ {
+ aBuilder.UpdateEdge(anEdge, aNullPoly3d);
+ }
+ if (theForce)
+ {
+ Handle(BRep_CurveRepresentation) aCR;
+ BRep_TEdge* aTE = static_cast<BRep_TEdge*>(anEdge.TShape().get());
+ BRep_ListOfCurveRepresentation& aLCR = aTE->ChangeCurves();
+ BRep_ListIteratorOfListOfCurveRepresentation anIterCR(aLCR);
+
+ // find and remove all representations
+ while (anIterCR.More())
+ {
+ aCR = anIterCR.Value();
+ if (aCR->IsPolygonOnTriangulation())
+ {
+ aLCR.Remove(anIterCR);
+ }
+ else
+ {
+ anIterCR.Next();
+ }
+ }
+ aTE->Modified(Standard_True);
+ }
}
}
//=======================================================================
for (TopExp_Explorer aEdgeIt2(theShape, TopAbs_EDGE); aEdgeIt2.More(); aEdgeIt2.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge(aEdgeIt2.Current());
-
aBuilder.UpdateEdge(anEdge, Handle(Geom_Curve)(),
TopLoc_Location(), BRep_Tool::Tolerance(anEdge));
}
//! triangulations and polygons 3d of the edges.
//! In case polygonal representation is the only available representation
//! for the shape (shape does not have geometry) it is not removed.
- Standard_EXPORT static void Clean (const TopoDS_Shape& S);
+ //! @param theShape [in] the shape to clean
+ //! @param theForce [in] allows removing all polygonal representations from the shape,
+ //! including polygons on triangulations irrelevant for the faces of the given shape.
+ Standard_EXPORT static void Clean (const TopoDS_Shape& theShape, const Standard_Boolean theForce = Standard_False);
//! Removes geometry (curves and surfaces) from all edges and faces of the shape
Standard_EXPORT static void CleanGeometry(const TopoDS_Shape& theShape);
// tclean
//=======================================================================
-static Standard_Integer tclean(Draw_Interpretor& ,
- Standard_Integer n, const char** a)
+static Standard_Integer tclean(Draw_Interpretor& di,
+ Standard_Integer n, const char** a)
{
- if (n == 1) return 1;
-
- Standard_Integer aStart = 1;
Standard_Boolean toRemoveGeometry = Standard_False;
- if (strcmp(a[1], "-geom") == 0)
+ Standard_Boolean isForceClean = Standard_False;
+
+ if (n <= 1)
{
- aStart++;
- toRemoveGeometry = Standard_True;
+ di.PrintHelp(a[0]);
+ return 1;
}
-
- for (Standard_Integer i = aStart; i < n; i++) {
- TopoDS_Shape S = DBRep::Get(a[i]);
- if (toRemoveGeometry)
- BRepTools::CleanGeometry(S);
+ TopoDS_Compound aCompound;
+ BRep_Builder().MakeCompound(aCompound);
+ for (Standard_Integer anArgIter = 1; anArgIter < n; ++anArgIter)
+ {
+ if (strcmp(a[anArgIter], "-geom") == 0)
+ {
+ toRemoveGeometry = Standard_True;
+ }
+ else if (strcmp(a[anArgIter], "-force") == 0)
+ {
+ isForceClean = Standard_True;
+ }
else
- BRepTools::Clean(S);
+ {
+ TopoDS_Shape aShape = DBRep::Get(a[anArgIter]);
+ if (aShape.IsNull())
+ {
+ di << "Syntax error : NULL shape '"<< a[anArgIter] << "'";
+ return 1;
+ }
+ BRep_Builder().Add(aCompound, aShape);
+ }
}
+ if (aCompound.NbChildren() == 0)
+ {
+ di << "Syntax error : wrong number of arguments";
+ di.PrintHelp(a[0]);
+ return 1;
+ }
+ if (isForceClean && toRemoveGeometry)
+ {
+ di << "Syntax error: wrong usage of arguments: do not use 'force' and 'geom' flags together";
+ return 1;
+ }
+
+ if (toRemoveGeometry)
+ BRepTools::CleanGeometry(aCompound);
+ else
+ BRepTools::Clean(aCompound, isForceClean);
return 0;
}
theCommands.Add("hlr" ,"[no]hlr, rg1, rgn, hid, ang",__FILE__,hlr ,g);
theCommands.Add("vori","vori [name1 ...], edges are colored by orientation (see vconn)",__FILE__,dispor,g);
theCommands.Add("triangles", "triangles [name1]..., display triangles of shapes if exists",__FILE__, triangles, g);
- theCommands.Add("tclean", "tclean [-geom] [name1]..., depending on using or not key -geom, \n"
- "\t erase geometry objects from shapes - key is used or \n"
- "\t erase triangulations and polygons on triangulations from shapes - key is omitted \n",
+ theCommands.Add("tclean", "tclean [-force] [-geom] [name1]..., depending on using or not key -geom, \n"
+ "\t\t -geom : erase geometry\n"
+ "\t\t if [-geom] is omitted - erase triangulations and \n"
+ "\t\t polygons on triangulations from shapes \n"
+ "\t\t -force : force delete all representations not relevant to the given shape \n",
__FILE__, tclean, g);
theCommands.Add("polygons", "polygons [name1]..., display polygons of shapes if exists",__FILE__, polygons, g);
theCommands.Add("vconn","vconn [name1 ...] , edges are colored by number of faces (see vori)",__FILE__,dispor,g);
#include <Poly_Connect.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <BRep_CurveRepresentation.hxx>
+#include <BRep_TEdge.hxx>
+#include <TopExp.hxx>
#include <BRepMesh_Context.hxx>
#include <BRepMesh_FaceDiscret.hxx>
TopLoc_Location L;
Standard_Real MaxDeflection = 0.0;
- Standard_Integer nbtriangles = 0, nbnodes = 0;
+ Standard_Integer nbtriangles = 0, nbnodes = 0, nbrepresentations = 0;
for (ex.Init(S, TopAbs_FACE); ex.More(); ex.Next()) {
TopoDS_Face F = TopoDS::Face(ex.Current());
T = BRep_Tool::Triangulation(F, L);
MaxDeflection = T->Deflection();
}
}
+ TopTools_IndexedMapOfShape anEdges;
+ TopExp::MapShapes(S, TopAbs_EDGE, anEdges);
+ for (int i = 1; i<=anEdges.Extent(); ++i)
+ {
+ const TopoDS_Edge& anEdge = TopoDS::Edge(anEdges(i));
+ Handle(BRep_CurveRepresentation) aCR;
+ BRep_TEdge* aTE = static_cast<BRep_TEdge*>(anEdge.TShape().get());
+ const BRep_ListOfCurveRepresentation& aLCR = aTE->Curves();
+ BRep_ListIteratorOfListOfCurveRepresentation anIterCR(aLCR);
+
+ while (anIterCR.More()) {
+ aCR = anIterCR.Value();
+ if (aCR->IsPolygonOnTriangulation())
+ {
+ nbrepresentations++;
+ }
+ anIterCR.Next();
+ }
+ }
di<<"\n";
- di<<"This shape contains " <<nbtriangles<<" triangles.\n";
- di<<" " <<nbnodes <<" nodes.\n";
- di<<"Maximal deflection " <<MaxDeflection<<"\n";
+ di << "This shape contains " << nbtriangles << " triangles.\n";
+ di << " " << nbnodes << " nodes.\n";
+ di << " " << nbrepresentations << " polygons on triangulation .\n";;
+ di << "Maximal deflection " << MaxDeflection << "\n";
+
di<<"\n";
#ifdef OCCT_DEBUG_MESH_CHRONO
Standard_Real tot, addp, unif, contr, inter;
--- /dev/null
+puts "========================================================================================="
+puts "OCC28026: Modeling Data - BRepTools::Clean() does not clean all triangulation from shape "
+puts "========================================================================================="
+puts ""
+
+restore [locate_data_file bug28026_Ball.brep] b
+
+set expected {"0 triangles" "0 nodes"
+ "0 polygons on triangulation"
+ "Maximal deflection 0"}
+
+tclean b -force
+set output [trinfo b]
+
+foreach data ${expected} {
+ if ![regexp $data $output] {
+ puts "Error: Not cleanned all trinfo in '$data'"
+ break;
+ }
+}