1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-16 10:08:36 +03:00

0022747: Progress indicator in sewing algorithm

This commit is contained in:
AMA 2011-11-03 09:52:18 +00:00 committed by bugmaster
parent f7ae443ad8
commit 92434a36ef
4 changed files with 120 additions and 52 deletions

View File

@ -86,7 +86,8 @@ uses
BRepLib, BRepLib,
BRepTools, BRepTools,
TColStd, TColStd,
TColgp TColgp,
Message
is is

View File

@ -81,7 +81,8 @@ uses
ReShape from BRepTools, ReShape from BRepTools,
SequenceOfInteger from TColStd, SequenceOfInteger from TColStd,
SequenceOfReal from TColStd, SequenceOfReal from TColStd,
SequenceOfPnt from TColgp SequenceOfPnt from TColgp,
ProgressIndicator from Message
raises raises
@ -117,8 +118,10 @@ is
Add(me : mutable; shape : Shape from TopoDS); Add(me : mutable; shape : Shape from TopoDS);
---Purpose: Defines the shapes to be sewed or controlled ---Purpose: Defines the shapes to be sewed or controlled
Perform(me : mutable); ---is virtual; Perform(me : mutable;
thePI : ProgressIndicator from Message = 0);
---Purpose: Computing ---Purpose: Computing
-- thePI - progress indicator of algorithm
SewedShape(me) returns Shape from TopoDS; SewedShape(me) returns Shape from TopoDS;
---C++: return const & ---C++: return const &
@ -285,10 +288,13 @@ is
--- INTERNAL FUCTIONS --- --- INTERNAL FUCTIONS ---
------------------------- -------------------------
Cutting(me : mutable) is protected; Cutting(me : mutable;
thePI : ProgressIndicator from Message = 0) is protected;
---Purpose: Performs cutting of sections ---Purpose: Performs cutting of sections
-- thePI - progress indicator of processing
Merging(me : mutable; passage : Boolean) is protected; Merging(me : mutable; passage : Boolean;
thePI : ProgressIndicator from Message = 0) is protected;
IsMergedClosed(me; IsMergedClosed(me;
Edge1 : Edge from TopoDS; Edge1 : Edge from TopoDS;
@ -318,7 +324,8 @@ is
returns Boolean is protected; returns Boolean is protected;
---Purpose: Merged nearest edges. ---Purpose: Merged nearest edges.
EdgeProcessing(me : mutable) is protected; EdgeProcessing(me : mutable;
thePI : ProgressIndicator from Message = 0) is protected;
CreateOutputInformations(me : mutable) is protected; CreateOutputInformations(me : mutable) is protected;
@ -336,17 +343,21 @@ is
returns Boolean is virtual protected; returns Boolean is virtual protected;
---Purpose:Defines if surface is V closed. ---Purpose:Defines if surface is V closed.
FaceAnalysis(me : mutable) is virtual protected; FaceAnalysis(me : mutable;
thePI : ProgressIndicator from Message = 0) is virtual protected;
---Purpose: ---Purpose:
-- This method is called from Perform only -- This method is called from Perform only
-- thePI - progress indicator of processing
FindFreeBoundaries(me : mutable) is virtual protected; FindFreeBoundaries(me : mutable) is virtual protected;
---Purpose: ---Purpose:
-- This method is called from Perform only -- This method is called from Perform only
VerticesAssembling(me : mutable) is virtual protected; VerticesAssembling(me : mutable;
thePI : ProgressIndicator from Message = 0) is virtual protected;
---Purpose: ---Purpose:
-- This method is called from Perform only -- This method is called from Perform only
-- thePI - progress indicator of processing
CreateSewedShape(me : mutable) is virtual protected; CreateSewedShape(me : mutable) is virtual protected;
---Purpose: ---Purpose:

View File

@ -107,6 +107,7 @@
#include <BRep_PointOnCurve.hxx> #include <BRep_PointOnCurve.hxx>
#include <BRep_ListOfPointRepresentation.hxx> #include <BRep_ListOfPointRepresentation.hxx>
#include <BRep_TVertex.hxx> #include <BRep_TVertex.hxx>
#include <Message_ProgressSentry.hxx>
static void SortBox (const Handle(Bnd_HArray1OfBox) hSetBoxes, static void SortBox (const Handle(Bnd_HArray1OfBox) hSetBoxes,
const Bnd_Box& aBox, const Bnd_Box& aBox,
@ -984,7 +985,6 @@ void BRepBuilderAPI_Sewing::EvaluateAngulars(TopTools_SequenceOfShape& sequenceS
// Evaluate distance beetween edges with indice indRef and the following edges in the list // Evaluate distance beetween edges with indice indRef and the following edges in the list
// Remarks (lengSec - indRef) must be >= 1 // Remarks (lengSec - indRef) must be >= 1
//======================================================================= //=======================================================================
void BRepBuilderAPI_Sewing::EvaluateDistances(TopTools_SequenceOfShape& sequenceSec, void BRepBuilderAPI_Sewing::EvaluateDistances(TopTools_SequenceOfShape& sequenceSec,
TColStd_Array1OfBoolean& secForward, TColStd_Array1OfBoolean& secForward,
TColStd_Array1OfReal& tabDst, TColStd_Array1OfReal& tabDst,
@ -1746,8 +1746,10 @@ void BRepBuilderAPI_Sewing::Add(const TopoDS_Shape& aShape)
#include <OSD_Timer.hxx> #include <OSD_Timer.hxx>
#endif #endif
void BRepBuilderAPI_Sewing::Perform() void BRepBuilderAPI_Sewing::Perform(const Handle(Message_ProgressIndicator)& thePI)
{ {
const Standard_Integer aNumberOfStages = myAnalysis + myCutting + mySewing + 2;
Message_ProgressSentry aPS (thePI, "Sewing", 0, aNumberOfStages, 1);
#ifdef DEB #ifdef DEB
Standard_Real t_total = 0., t_analysis = 0., t_assembling = 0., t_cutting = 0., t_merging = 0.; Standard_Real t_total = 0., t_analysis = 0., t_assembling = 0., t_cutting = 0., t_merging = 0.;
OSD_Chronometer chr_total, chr_local; OSD_Chronometer chr_total, chr_local;
@ -1756,13 +1758,17 @@ void BRepBuilderAPI_Sewing::Perform()
#endif #endif
// face analysis // face analysis
if (myAnalysis) { if (myAnalysis)
{
#if DEB #if DEB
cout << "Begin face analysis..." << endl; cout << "Begin face analysis..." << endl;
chr_local.Reset(); chr_local.Reset();
chr_local.Start(); chr_local.Start();
#endif #endif
FaceAnalysis(); FaceAnalysis (thePI);
if (!aPS.More())
return;
aPS.Next();
#if DEB #if DEB
chr_local.Stop(); chr_local.Stop();
chr_local.Show(t_analysis); chr_local.Show(t_analysis);
@ -1770,30 +1776,39 @@ void BRepBuilderAPI_Sewing::Perform()
#endif #endif
} }
if (myNbShapes || !myShape.IsNull()) { if (myNbShapes || !myShape.IsNull())
{
FindFreeBoundaries(); FindFreeBoundaries();
if (myBoundFaces.Extent()) { if (myBoundFaces.Extent())
{
#if DEB #if DEB
cout << "Begin vertices assembling..." << endl; cout << "Begin vertices assembling..." << endl;
chr_local.Reset(); chr_local.Reset();
chr_local.Start(); chr_local.Start();
#endif #endif
VerticesAssembling(); VerticesAssembling (thePI);
if (!aPS.More())
return;
aPS.Next();
#if DEB #if DEB
chr_local.Stop(); chr_local.Stop();
chr_local.Show(t_assembling); chr_local.Show(t_assembling);
cout << "Vertices assembling finished after " << t_assembling << " s" << endl; cout << "Vertices assembling finished after " << t_assembling << " s" << endl;
#endif #endif
if (myCutting) { if (myCutting)
{
#if DEB #if DEB
cout << "Begin cutting..." << endl; cout << "Begin cutting..." << endl;
chr_local.Reset(); chr_local.Reset();
chr_local.Start(); chr_local.Start();
#endif #endif
Cutting(); Cutting (thePI);
if (!aPS.More())
return;
aPS.Next();
#if DEB #if DEB
chr_local.Stop(); chr_local.Stop();
chr_local.Show(t_cutting); chr_local.Show(t_cutting);
@ -1805,23 +1820,49 @@ void BRepBuilderAPI_Sewing::Perform()
chr_local.Reset(); chr_local.Reset();
chr_local.Start(); chr_local.Start();
#endif #endif
Merging(Standard_True); Merging (Standard_True, thePI);
if (!aPS.More())
return;
aPS.Next();
#if DEB #if DEB
chr_local.Stop(); chr_local.Stop();
chr_local.Show(t_merging); chr_local.Show(t_merging);
cout << "Merging finished after " << t_merging << " s" << endl; cout << "Merging finished after " << t_merging << " s" << endl;
#endif #endif
} }
else
{
aPS.Next( 1, Handle(TCollection_HAsciiString)());
if (myCutting)
aPS.Next( 1, Handle(TCollection_HAsciiString)());
aPS.Next( 1, Handle(TCollection_HAsciiString)());
if (!aPS.More())
return;
}
if (mySewing) { if (mySewing)
{
#if DEB #if DEB
cout << "Creating sewed shape..." << endl; cout << "Creating sewed shape..." << endl;
#endif #endif
// examine the multiple edges if any and process sameparameter for edges if necessary // examine the multiple edges if any and process sameparameter for edges if necessary
EdgeProcessing(); EdgeProcessing (thePI);
if (!aPS.More())
return;
CreateSewedShape(); CreateSewedShape();
if (mySameParameterMode && myFaceMode) SameParameterShape(); if (!aPS.More())
{
mySewedShape.Nullify();
return;
}
if (mySameParameterMode && myFaceMode)
SameParameterShape();
if (!aPS.More())
{
mySewedShape.Nullify();
return;
}
#if DEB #if DEB
cout << "Sewed shape created" << endl; cout << "Sewed shape created" << endl;
#endif #endif
@ -1829,6 +1870,11 @@ void BRepBuilderAPI_Sewing::Perform()
// create edge informations for output // create edge informations for output
CreateOutputInformations(); CreateOutputInformations();
if (!aPS.More())
{
mySewedShape.Nullify();
return;
}
} }
#if DEB #if DEB
chr_total.Stop(); chr_total.Stop();
@ -2120,7 +2166,7 @@ void BRepBuilderAPI_Sewing::Dump() const
// myDegenerated // myDegenerated
//======================================================================= //=======================================================================
void BRepBuilderAPI_Sewing::FaceAnalysis() void BRepBuilderAPI_Sewing::FaceAnalysis(const Handle(Message_ProgressIndicator)& thePI)
{ {
if (!myShape.IsNull() && myOldShapes.IsEmpty()) { if (!myShape.IsNull() && myOldShapes.IsEmpty()) {
Add(myShape); Add(myShape);
@ -2131,7 +2177,8 @@ void BRepBuilderAPI_Sewing::FaceAnalysis()
TopTools_MapOfShape SmallEdges; TopTools_MapOfShape SmallEdges;
TopTools_DataMapOfShapeListOfShape GluedVertices; TopTools_DataMapOfShapeListOfShape GluedVertices;
Standard_Integer i = 1; Standard_Integer i = 1;
for (i = 1; i <= myOldShapes.Extent(); i++) { Message_ProgressSentry aPS (thePI, "Shape analysis", 0, myOldShapes.Extent(), 1);
for (i = 1; i <= myOldShapes.Extent() && aPS.More(); i++, aPS.Next()) {
for (TopExp_Explorer fexp(myOldShapes(i),TopAbs_FACE); fexp.More(); fexp.Next()) { for (TopExp_Explorer fexp(myOldShapes(i),TopAbs_FACE); fexp.More(); fexp.Next()) {
// Retrieve current face // Retrieve current face
@ -2661,7 +2708,8 @@ static Standard_Integer IsMergedVertices(const TopoDS_Shape& face1,
static Standard_Boolean GlueVertices(TopTools_IndexedDataMapOfShapeShape& aVertexNode, static Standard_Boolean GlueVertices(TopTools_IndexedDataMapOfShapeShape& aVertexNode,
TopTools_DataMapOfShapeListOfShape& aNodeEdges, TopTools_DataMapOfShapeListOfShape& aNodeEdges,
const TopTools_IndexedDataMapOfShapeListOfShape& aBoundFaces, const TopTools_IndexedDataMapOfShapeListOfShape& aBoundFaces,
const Standard_Real Tolerance) const Standard_Real Tolerance,
const Handle(Message_ProgressIndicator)& theProgress)
{ {
Standard_Integer i, nbVertices = aVertexNode.Extent(); Standard_Integer i, nbVertices = aVertexNode.Extent();
// Create map of node -> vertices // Create map of node -> vertices
@ -2694,7 +2742,8 @@ static Standard_Boolean GlueVertices(TopTools_IndexedDataMapOfShapeShape& aVerte
} }
// Merge nearest nodes // Merge nearest nodes
TopTools_IndexedDataMapOfShapeShape NodeNearestNode; TopTools_IndexedDataMapOfShapeShape NodeNearestNode;
for (i = 1; i <= nbNodes; i++) { Message_ProgressSentry aPS (theProgress, "Glueing nodes", 0, nbNodes, 1, Standard_True);
for (i = 1; i <= nbNodes && aPS.More(); i++, aPS.Next()) {
TopoDS_Vertex node1 = TopoDS::Vertex(NodeVertices.FindKey(i)); TopoDS_Vertex node1 = TopoDS::Vertex(NodeVertices.FindKey(i));
// Find near nodes // Find near nodes
TColStd_ListOfInteger listIndex; TColStd_ListOfInteger listIndex;
@ -2823,10 +2872,11 @@ static Standard_Boolean GlueVertices(TopTools_IndexedDataMapOfShapeShape& aVerte
return CreateNewNodes(NodeNearestNode,NodeVertices,aVertexNode,aNodeEdges); return CreateNewNodes(NodeNearestNode,NodeVertices,aVertexNode,aNodeEdges);
} }
void BRepBuilderAPI_Sewing::VerticesAssembling() void BRepBuilderAPI_Sewing::VerticesAssembling(const Handle(Message_ProgressIndicator)& thePI)
{ {
Standard_Integer nbVert = myVertexNode.Extent(); Standard_Integer nbVert = myVertexNode.Extent();
Standard_Integer nbVertFree = myVertexNodeFree.Extent(); Standard_Integer nbVertFree = myVertexNodeFree.Extent();
Message_ProgressSentry aPS (thePI, "Vertices assembling", 0, 2, 1);
if (nbVert || nbVertFree) { if (nbVert || nbVertFree) {
// Fill map node -> sections // Fill map node -> sections
Standard_Integer i; Standard_Integer i;
@ -2848,13 +2898,16 @@ void BRepBuilderAPI_Sewing::VerticesAssembling()
#ifdef DEB #ifdef DEB
cout << "Assemble " << nbVert << " vertices on faces..." << endl; cout << "Assemble " << nbVert << " vertices on faces..." << endl;
#endif #endif
while (GlueVertices(myVertexNode,myNodeSections,myBoundFaces,myTolerance)); while (GlueVertices(myVertexNode,myNodeSections,myBoundFaces,myTolerance, thePI));
} }
if (!aPS.More())
return;
aPS.Next();
if (nbVertFree) { if (nbVertFree) {
#ifdef DEB #ifdef DEB
cout << "Assemble " << nbVertFree << " vertices on floating edges..." << endl; cout << "Assemble " << nbVertFree << " vertices on floating edges..." << endl;
#endif #endif
while (GlueVertices(myVertexNodeFree,myNodeSections,myBoundFaces,myTolerance)); while (GlueVertices(myVertexNodeFree,myNodeSections,myBoundFaces,myTolerance, thePI));
} }
} }
} }
@ -3013,11 +3066,13 @@ static void ReplaceEdge(const TopoDS_Shape& oldEdge,
// //
//======================================================================= //=======================================================================
void BRepBuilderAPI_Sewing::Merging(const Standard_Boolean /* firstTime */) void BRepBuilderAPI_Sewing::Merging(const Standard_Boolean /* firstTime */,
const Handle(Message_ProgressIndicator)& thePI)
{ {
BRep_Builder B; BRep_Builder B;
// TopTools_MapOfShape MergedEdges; // TopTools_MapOfShape MergedEdges;
for (Standard_Integer i = 1; i <= myBoundFaces.Extent(); i++) { Message_ProgressSentry aPS (thePI, "Merging bounds", 0, myBoundFaces.Extent(), 1);
for (Standard_Integer i = 1; i <= myBoundFaces.Extent() && aPS.More(); i++, aPS.Next()) {
TopoDS_Shape bound = myBoundFaces.FindKey(i); TopoDS_Shape bound = myBoundFaces.FindKey(i);
@ -3510,7 +3565,7 @@ Standard_Boolean BRepBuilderAPI_Sewing::MergedNearestEdges(const TopoDS_Shape& e
// myCuttingNode // myCuttingNode
//======================================================================= //=======================================================================
void BRepBuilderAPI_Sewing::Cutting() void BRepBuilderAPI_Sewing::Cutting(const Handle(Message_ProgressIndicator)& thePI)
{ {
Standard_Integer i, nbVertices = myVertexNode.Extent(); Standard_Integer i, nbVertices = myVertexNode.Extent();
if (!nbVertices) return; if (!nbVertices) return;
@ -3529,7 +3584,8 @@ void BRepBuilderAPI_Sewing::Cutting()
Standard_Real first, last; Standard_Real first, last;
// Iterate on all boundaries // Iterate on all boundaries
Standard_Integer nbBounds = myBoundFaces.Extent(); Standard_Integer nbBounds = myBoundFaces.Extent();
for (i = 1; i <= nbBounds; i++) { Message_ProgressSentry aPS (thePI, "Cutting bounds", 0, nbBounds, 1);
for (i = 1; i <= nbBounds && aPS.More(); i++, aPS.Next()) {
const TopoDS_Edge& bound = TopoDS::Edge(myBoundFaces.FindKey(i)); const TopoDS_Edge& bound = TopoDS::Edge(myBoundFaces.FindKey(i));
// Do not cut floating edges // Do not cut floating edges
if (!myBoundFaces(i).Extent()) continue; if (!myBoundFaces(i).Extent()) continue;
@ -3865,12 +3921,13 @@ static TopoDS_Edge DegeneratedSection(const TopoDS_Shape& section, const TopoDS_
// - make the contigous edges sameparameter // - make the contigous edges sameparameter
//======================================================================= //=======================================================================
void BRepBuilderAPI_Sewing::EdgeProcessing() void BRepBuilderAPI_Sewing::EdgeProcessing(const Handle(Message_ProgressIndicator)& thePI)
{ {
// constructs sectionEdge // constructs sectionEdge
TopTools_MapOfShape MapFreeEdges; TopTools_MapOfShape MapFreeEdges;
TopTools_DataMapOfShapeShape EdgeFace; TopTools_DataMapOfShapeShape EdgeFace;
for (Standard_Integer i = 1; i <= myBoundFaces.Extent(); i++) { Message_ProgressSentry aPS (thePI, "Edge processing", 0, myBoundFaces.Extent(), 1);
for (Standard_Integer i = 1; i <= myBoundFaces.Extent() && aPS.More(); i++, aPS.Next()) {
const TopoDS_Shape& bound = myBoundFaces.FindKey(i); const TopoDS_Shape& bound = myBoundFaces.FindKey(i);
const TopTools_ListOfShape& listFaces = myBoundFaces(i); const TopTools_ListOfShape& listFaces = myBoundFaces(i);
if (listFaces.Extent() == 1) { if (listFaces.Extent() == 1) {

View File

@ -32,6 +32,7 @@
#include <Geom2d_TrimmedCurve.hxx> #include <Geom2d_TrimmedCurve.hxx>
#include <TopTools_ListOfShape.hxx> #include <TopTools_ListOfShape.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <Draw_ProgressIndicator.hxx>
#ifdef WNT #ifdef WNT
//#define strcasecmp strcmp Already defined //#define strcasecmp strcmp Already defined
@ -261,7 +262,7 @@ static Standard_Integer pcurve(Draw_Interpretor& , Standard_Integer n, const cha
// sewing // sewing
//======================================================================= //=======================================================================
static Standard_Integer sewing (Draw_Interpretor& , static Standard_Integer sewing (Draw_Interpretor& theDi,
Standard_Integer n, const char** a) Standard_Integer n, const char** a)
{ {
if (n < 3) return (1); if (n < 3) return (1);
@ -289,7 +290,6 @@ static Standard_Integer sewing (Draw_Interpretor& ,
NonManifoldMode = Standard_True; NonManifoldMode = Standard_True;
ntmp--; ntmp--;
} }
aSewing.Init(tol, Standard_True,Standard_True,Standard_True,NonManifoldMode); aSewing.Init(tol, Standard_True,Standard_True,Standard_True,NonManifoldMode);
while (i < ntmp) { while (i < ntmp) {
@ -297,10 +297,9 @@ static Standard_Integer sewing (Draw_Interpretor& ,
aSewing.Add(sh); aSewing.Add(sh);
i++; i++;
} }
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDi, 1);
aSewing.Perform(); aSewing.Perform (aProgress);
aSewing.Dump(); aSewing.Dump();
const TopoDS_Shape& sh2 = aSewing.SewedShape(); const TopoDS_Shape& sh2 = aSewing.SewedShape();
if (!sh2.IsNull()) { if (!sh2.IsNull()) {
DBRep::Set(a[1], sh2); DBRep::Set(a[1], sh2);