1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +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

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

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

@ -107,6 +107,7 @@
#include <BRep_PointOnCurve.hxx>
#include <BRep_ListOfPointRepresentation.hxx>
#include <BRep_TVertex.hxx>
#include <Message_ProgressSentry.hxx>
static void SortBox (const Handle(Bnd_HArray1OfBox) hSetBoxes,
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
// Remarks (lengSec - indRef) must be >= 1
//=======================================================================
void BRepBuilderAPI_Sewing::EvaluateDistances(TopTools_SequenceOfShape& sequenceSec,
TColStd_Array1OfBoolean& secForward,
TColStd_Array1OfReal& tabDst,
@ -1746,8 +1746,10 @@ void BRepBuilderAPI_Sewing::Add(const TopoDS_Shape& aShape)
#include <OSD_Timer.hxx>
#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
Standard_Real t_total = 0., t_analysis = 0., t_assembling = 0., t_cutting = 0., t_merging = 0.;
OSD_Chronometer chr_total, chr_local;
@ -1756,13 +1758,17 @@ void BRepBuilderAPI_Sewing::Perform()
#endif
// face analysis
if (myAnalysis) {
if (myAnalysis)
{
#if DEB
cout << "Begin face analysis..." << endl;
chr_local.Reset();
chr_local.Start();
#endif
FaceAnalysis();
FaceAnalysis (thePI);
if (!aPS.More())
return;
aPS.Next();
#if DEB
chr_local.Stop();
chr_local.Show(t_analysis);
@ -1770,34 +1776,43 @@ void BRepBuilderAPI_Sewing::Perform()
#endif
}
if (myNbShapes || !myShape.IsNull()) {
if (myNbShapes || !myShape.IsNull())
{
FindFreeBoundaries();
if (myBoundFaces.Extent()) {
if (myBoundFaces.Extent())
{
#if DEB
cout << "Begin vertices assembling..." << endl;
chr_local.Reset();
chr_local.Start();
#endif
VerticesAssembling();
VerticesAssembling (thePI);
if (!aPS.More())
return;
aPS.Next();
#if DEB
chr_local.Stop();
chr_local.Show(t_assembling);
cout << "Vertices assembling finished after " << t_assembling << " s" << endl;
#endif
if (myCutting) {
if (myCutting)
{
#if DEB
cout << "Begin cutting..." << endl;
chr_local.Reset();
chr_local.Start();
cout << "Begin cutting..." << endl;
chr_local.Reset();
chr_local.Start();
#endif
Cutting();
Cutting (thePI);
if (!aPS.More())
return;
aPS.Next();
#if DEB
chr_local.Stop();
chr_local.Show(t_cutting);
cout << "Cutting finished after " << t_cutting << " s" << endl;
chr_local.Stop();
chr_local.Show(t_cutting);
cout << "Cutting finished after " << t_cutting << " s" << endl;
#endif
}
#if DEB
@ -1805,30 +1820,61 @@ void BRepBuilderAPI_Sewing::Perform()
chr_local.Reset();
chr_local.Start();
#endif
Merging(Standard_True);
Merging (Standard_True, thePI);
if (!aPS.More())
return;
aPS.Next();
#if DEB
chr_local.Stop();
chr_local.Show(t_merging);
cout << "Merging finished after " << t_merging << " s" << endl;
#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
cout << "Creating sewed shape..." << endl;
#endif
// examine the multiple edges if any and process sameparameter for edges if necessary
EdgeProcessing();
EdgeProcessing (thePI);
if (!aPS.More())
return;
CreateSewedShape();
if (mySameParameterMode && myFaceMode) SameParameterShape();
if (!aPS.More())
{
mySewedShape.Nullify();
return;
}
if (mySameParameterMode && myFaceMode)
SameParameterShape();
if (!aPS.More())
{
mySewedShape.Nullify();
return;
}
#if DEB
cout << "Sewed shape created" << endl;
#endif
}
// create edge informations for output
CreateOutputInformations();
if (!aPS.More())
{
mySewedShape.Nullify();
return;
}
}
#if DEB
chr_total.Stop();
@ -2120,7 +2166,7 @@ void BRepBuilderAPI_Sewing::Dump() const
// myDegenerated
//=======================================================================
void BRepBuilderAPI_Sewing::FaceAnalysis()
void BRepBuilderAPI_Sewing::FaceAnalysis(const Handle(Message_ProgressIndicator)& thePI)
{
if (!myShape.IsNull() && myOldShapes.IsEmpty()) {
Add(myShape);
@ -2131,7 +2177,8 @@ void BRepBuilderAPI_Sewing::FaceAnalysis()
TopTools_MapOfShape SmallEdges;
TopTools_DataMapOfShapeListOfShape GluedVertices;
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()) {
// Retrieve current face
@ -2659,9 +2706,10 @@ static Standard_Integer IsMergedVertices(const TopoDS_Shape& face1,
}
static Standard_Boolean GlueVertices(TopTools_IndexedDataMapOfShapeShape& aVertexNode,
TopTools_DataMapOfShapeListOfShape& aNodeEdges,
const TopTools_IndexedDataMapOfShapeListOfShape& aBoundFaces,
const Standard_Real Tolerance)
TopTools_DataMapOfShapeListOfShape& aNodeEdges,
const TopTools_IndexedDataMapOfShapeListOfShape& aBoundFaces,
const Standard_Real Tolerance,
const Handle(Message_ProgressIndicator)& theProgress)
{
Standard_Integer i, nbVertices = aVertexNode.Extent();
// Create map of node -> vertices
@ -2694,7 +2742,8 @@ static Standard_Boolean GlueVertices(TopTools_IndexedDataMapOfShapeShape& aVerte
}
// Merge nearest nodes
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));
// Find near nodes
TColStd_ListOfInteger listIndex;
@ -2823,10 +2872,11 @@ static Standard_Boolean GlueVertices(TopTools_IndexedDataMapOfShapeShape& aVerte
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 nbVertFree = myVertexNodeFree.Extent();
Message_ProgressSentry aPS (thePI, "Vertices assembling", 0, 2, 1);
if (nbVert || nbVertFree) {
// Fill map node -> sections
Standard_Integer i;
@ -2848,13 +2898,16 @@ void BRepBuilderAPI_Sewing::VerticesAssembling()
#ifdef DEB
cout << "Assemble " << nbVert << " vertices on faces..." << endl;
#endif
while (GlueVertices(myVertexNode,myNodeSections,myBoundFaces,myTolerance));
while (GlueVertices(myVertexNode,myNodeSections,myBoundFaces,myTolerance, thePI));
}
if (!aPS.More())
return;
aPS.Next();
if (nbVertFree) {
#ifdef DEB
cout << "Assemble " << nbVertFree << " vertices on floating edges..." << endl;
#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;
// 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);
@ -3510,7 +3565,7 @@ Standard_Boolean BRepBuilderAPI_Sewing::MergedNearestEdges(const TopoDS_Shape& e
// myCuttingNode
//=======================================================================
void BRepBuilderAPI_Sewing::Cutting()
void BRepBuilderAPI_Sewing::Cutting(const Handle(Message_ProgressIndicator)& thePI)
{
Standard_Integer i, nbVertices = myVertexNode.Extent();
if (!nbVertices) return;
@ -3529,7 +3584,8 @@ void BRepBuilderAPI_Sewing::Cutting()
Standard_Real first, last;
// Iterate on all boundaries
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));
// Do not cut floating edges
if (!myBoundFaces(i).Extent()) continue;
@ -3865,12 +3921,13 @@ static TopoDS_Edge DegeneratedSection(const TopoDS_Shape& section, const TopoDS_
// - make the contigous edges sameparameter
//=======================================================================
void BRepBuilderAPI_Sewing::EdgeProcessing()
void BRepBuilderAPI_Sewing::EdgeProcessing(const Handle(Message_ProgressIndicator)& thePI)
{
// constructs sectionEdge
TopTools_MapOfShape MapFreeEdges;
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 TopTools_ListOfShape& listFaces = myBoundFaces(i);
if (listFaces.Extent() == 1) {

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