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

0022746: Progress indicator in ShapeHealing

This commit is contained in:
KGV and DBV
2011-11-18 14:51:14 +00:00
committed by bugmaster
parent ffe74e4685
commit b485ee79ca
23 changed files with 515 additions and 324 deletions

View File

@@ -4,15 +4,14 @@
-- <det@nnov.matra-dtv.fr>
---Copyright: Matra Datavision 1998
package ShapeFix
---Purpose: This package provides algorithms for fixing
-- problematic (violating Open CASCADE requirements) shapes.
-- Tools from package ShapeAnalysis are used for detecting the problems. The
-- detecting and fixing is done taking in account various
-- criteria implemented in BRepCheck package.
-- Each class of package ShapeFix deals with one
---Purpose: This package provides algorithms for fixing
-- problematic (violating Open CASCADE requirements) shapes.
-- Tools from package ShapeAnalysis are used for detecting the problems. The
-- detecting and fixing is done taking in account various
-- criteria implemented in BRepCheck package.
-- Each class of package ShapeFix deals with one
-- certain type of shapes or with some family of problems.
uses
@@ -47,31 +46,31 @@ is
---Purpose: Fixing different problems on edge
class Wire;
---Purpose: Fixing different problems with wires
---Purpose: Fixing different problems with wires
class Face;
---Purpose: Fixing problems with face (orientation of wires and wrong wires)
class FixSmallFace;
---Purpose: Fixing face with small size
---Purpose: Fixing face with small size
class WireVertex;
---Purpose: Fixing disconnected edges in the wire
class Wireframe;
---Purpose: Provides methods to fix wireframe of shape
---Purpose: Provides methods to fix wireframe of shape
class FreeBounds;
---Purpose: Fixing free bounds of the shape (connecting open wires)
---Purpose: Fixing free bounds of the shape (connecting open wires)
class FaceConnect;
---Purpose: Rebuilds connectivity between faces in shell
---Purpose: Rebuilds connectivity between faces in shell
class Shell;
---Purpose: Fixing orientation of faces in shell
class Solid;
---Purpose: Creating solid from shell and orienting it to have finite volume
---Purpose: Creating solid from shell and orienting it to have finite volume
class ShapeTolerance;
---Purpose: Modifying shape tolerances
@@ -87,21 +86,18 @@ is
class SplitCommonVertex;
---Purpose: Splits vertex which is common for two wires
-- (for writing into STEP)
-- (for writing into STEP)
class WireSegment;
---Purpose: Auxiliary class (data storage) for ComposeShell
class IntersectionTool;
---Purpose: Tool for fixing selfintersecting wire
-- and intersecting wires
--class OverlappingTool; now it is in package OverlapShape of Products
---Purpose: Tool for fixing overlapping
-- and intersecting wires
class SplitTool;
---Purpose: Tool for splitting and cutting edges; incudes methods
-- used in OverlappingTool and IntersectionTool
-- used in OverlappingTool and IntersectionTool
class SequenceOfWireSegment instantiates Sequence from TCollection
(WireSegment from ShapeFix);
@@ -110,9 +106,10 @@ is
(Shape from TopoDS, Box2d from Bnd, ShapeMapHasher from TopTools);
SameParameter (shape : Shape from TopoDS;
enforce: Boolean;
preci : Real = 0.0)
SameParameter (shape : Shape from TopoDS;
enforce : Boolean;
preci : Real = 0.0;
theProgress : ProgressIndicator from Message = 0)
returns Boolean;
---Purpose : Runs SameParameter from BRepLib with these adaptations :
-- <enforce> forces computations, else they are made only on
@@ -121,25 +118,27 @@ is
-- Tolerance
-- Returns True when done, False if an exception has been raised
-- In case of exception anyway, as many edges as possible have
-- been processed
-- been processed. The passed progress indicator allows user
-- to consult the current progress stage and abort algorithm
-- if needed.
EncodeRegularity (shape: Shape from TopoDS; tolang: Real = 1.0e-10);
---Purpose : Runs EncodeRegularity from BRepLib taking into account
-- shared components of assemblies, so that each component
-- is processed only once
-- shared components of assemblies, so that each component
-- is processed only once
RemoveSmallEdges (shape: in out Shape from TopoDS; Tolerance: Real; context: in out ReShape from ShapeBuild)
returns Shape from TopoDS;
---Purpose: Removes edges which are less than given tolerance from shape
-- with help of ShapeFix_Wire::FixSmall()
---Purpose: Removes edges which are less than given tolerance from shape
-- with help of ShapeFix_Wire::FixSmall()
FixVertexPosition(theshape: in out Shape from TopoDS;
theTolerance: Real;
thecontext: ReShape from ShapeBuild) returns Boolean;
---Purpose: Fix position of the vertices having tolerance more tnan specified one.;
---Purpose: Fix position of the vertices having tolerance more tnan specified one.;
LeastEdgeSize(theshape: in out Shape from TopoDS) returns Real;
---Purpose: Calculate size of least edge;
---Purpose: Calculate size of least edge;
end ShapeFix;

View File

@@ -59,6 +59,7 @@
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopExp.hxx>
#include <Message_ProgressSentry.hxx>
//=======================================================================
//function : SameParameter
@@ -67,8 +68,19 @@
Standard_Boolean ShapeFix::SameParameter(const TopoDS_Shape& shape,
const Standard_Boolean enforce,
const Standard_Real preci)
const Standard_Real preci,
const Handle(Message_ProgressIndicator)& theProgress)
{
// Calculate number of edges
Standard_Integer aNbEdges = 0;
for ( TopExp_Explorer anEdgeExp(shape, TopAbs_EDGE); anEdgeExp.More(); anEdgeExp.Next() )
++aNbEdges;
// Calculate number of faces
Standard_Integer aNbFaces = 0;
for ( TopExp_Explorer anEdgeExp(shape, TopAbs_FACE); anEdgeExp.More(); anEdgeExp.Next() )
++aNbFaces;
BRep_Builder B;
//Standard_Integer nbexcp = 0;
Standard_Integer nbfail = 0, numedge = 0;
@@ -78,88 +90,118 @@ Standard_Boolean ShapeFix::SameParameter(const TopoDS_Shape& shape,
Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge;
TopExp_Explorer ex(shape,TopAbs_EDGE);
while (ex.More()) {
TopoDS_Edge E;
while (ex.More()) {
numedge ++;
int ierr = 0;
TopLoc_Location loc; //Standard_Real u0,u1; //szv#4:S4163:12Mar99 moved down unused
E = TopoDS::Edge (ex.Current());
ex.Next();
//pdn degenerated edges shuld be samerange and sameparameter.
//if (BRep_Tool::Degenerated(E)) continue; // ne vaut pas
if (!iatol) tol = BRep_Tool::Tolerance (E);
if (enforce) {
B.SameRange (E,Standard_False);
B.SameParameter (E,Standard_False);
}
//:pdn if (BRep_Tool::SameParameter(E)) continue;
// Handle(Geom_Curve) crv = BRep_Tool::Curve (E,loc,u0,u1);
// if (crv.IsNull()) BRepLib::BuildCurve3d (E,tol);
sfe->FixSameParameter (E); // et non BRepLib:: jusqu a K2-SEP97
if (!BRep_Tool::SameParameter (E)) { ierr = 1; nbfail ++; }
if (ierr) {
status = Standard_False;
B.SameRange (E,Standard_False);
B.SameParameter (E,Standard_False);
}
} // -- end while
}
// Start progress scope (no need to check if progress exists -- it is safe)
Message_ProgressSentry aPSentry(theProgress, "Fixing same parameter problem", 0, 2, 1);
//:i2 abv 21 Aug 98: ProSTEP TR8 Motor.rle face 710:
// Update tolerance of edges on planes (no pcurves are stored)
for ( TopExp_Explorer exp ( shape, TopAbs_FACE ); exp.More(); exp.Next() ) {
TopoDS_Face face = TopoDS::Face ( exp.Current() );
Handle(Geom_Surface) Surf = BRep_Tool::Surface ( face );
Handle(Geom_Plane) plane = Handle(Geom_Plane)::DownCast ( Surf );
if ( plane.IsNull() ) {
Handle(Geom_RectangularTrimmedSurface) GRTS =
Handle(Geom_RectangularTrimmedSurface)::DownCast ( Surf );
if ( ! GRTS.IsNull() )
plane = Handle(Geom_Plane)::DownCast ( GRTS->BasisSurface() );
if ( plane.IsNull() ) continue;
{
// Start progress scope (no need to check if progress exists -- it is safe)
Message_ProgressSentry aPSentry(theProgress, "Fixing edge", 0, aNbEdges, 1);
while ( ex.More() )
{
TopoDS_Edge E;
while ( ex.More() && aPSentry.More() )
{
numedge ++;
int ierr = 0;
TopLoc_Location loc;
E = TopoDS::Edge (ex.Current());
ex.Next();
if (!iatol)
tol = BRep_Tool::Tolerance (E);
if (enforce)
{
B.SameRange (E,Standard_False);
B.SameParameter (E,Standard_False);
}
sfe->FixSameParameter (E); // K2-SEP97
if (!BRep_Tool::SameParameter (E)) { ierr = 1; nbfail ++; }
if (ierr)
{
status = Standard_False;
B.SameRange (E,Standard_False);
B.SameParameter (E,Standard_False);
}
// Complete step in current progress scope
aPSentry.Next();
} // -- end while
// Halt algorithm in case of user's abort
if ( !aPSentry.More() )
return Standard_False;
}
// Handle(ShapeConstruct_ProjectCurveOnSurface) Proj = new ShapeConstruct_ProjectCurveOnSurface; //:k2 abv 16 Dec 98: use existing tool //smh#14
// Handle(ShapeAnalysis_Surface) sas = new ShapeAnalysis_Surface ( plane );
// Proj->Init ( sas, Precision::Confusion() ); // projection will be analitic
Handle(GeomAdaptor_HSurface) AS = new GeomAdaptor_HSurface ( plane );
for ( TopExp_Explorer ed ( face, TopAbs_EDGE ); ed.More(); ed.Next() ) {
TopoDS_Edge edge = TopoDS::Edge ( ed.Current() );
Standard_Real f, l;
Handle(Geom_Curve) crv = BRep_Tool::Curve ( edge, f, l );
if ( crv.IsNull() ) continue;
// Handle(Geom2d_Curve) c2d;
// Proj->Perform ( crv, f, l, c2d );
Handle(Geom2d_Curve) c2d = BRep_Tool::CurveOnSurface ( edge, face, f, l );;
if ( c2d.IsNull() ) continue;
Handle(Geom2dAdaptor_HCurve) GHPC = new Geom2dAdaptor_HCurve ( c2d, f, l );
Adaptor3d_CurveOnSurface ACS(GHPC,AS);//sas->Adaptor3d());
Standard_Real tol0 = BRep_Tool::Tolerance ( edge );
tol = tol0;
Standard_Real tol2 = tol*tol;
const Standard_Integer NCONTROL = 23;
for ( Standard_Integer i=0; i < NCONTROL; i++ ) {
Standard_Real par = ( f * ( NCONTROL - 1 - i ) + l * i ) / ( NCONTROL - 1 );
gp_Pnt pnt = crv->Value ( par );
gp_Pnt prj = ACS.Value( par );
Standard_Real dist = pnt.SquareDistance(prj);
if ( tol2 < dist ) tol2 = dist;
}
// Switch to "Update tolerances" step
aPSentry.Next();
{
// Start progress scope (no need to check if progress exists -- it is safe)
Message_ProgressSentry aPSentry(theProgress, "Update tolerances", 0, aNbFaces, 1);
//:i2 abv 21 Aug 98: ProSTEP TR8 Motor.rle face 710:
// Update tolerance of edges on planes (no pcurves are stored)
for ( TopExp_Explorer exp ( shape, TopAbs_FACE ); exp.More() && aPSentry.More(); exp.Next(), aPSentry.Next() )
{
TopoDS_Face face = TopoDS::Face ( exp.Current() );
Handle(Geom_Surface) Surf = BRep_Tool::Surface ( face );
Handle(Geom_Plane) plane = Handle(Geom_Plane)::DownCast ( Surf );
if ( plane.IsNull() ) {
Handle(Geom_RectangularTrimmedSurface) GRTS =
Handle(Geom_RectangularTrimmedSurface)::DownCast ( Surf );
if ( ! GRTS.IsNull() )
plane = Handle(Geom_Plane)::DownCast ( GRTS->BasisSurface() );
if ( plane.IsNull() )
continue;
}
tol = 1.00005 * sqrt(tol2); // coeff: see trj3_pm1-ct-203.stp #19681, edge 10
if ( tol >= tol0 ) {
B.UpdateEdge ( edge, tol );
for ( TopoDS_Iterator itV(edge); itV.More(); itV.Next() ) {
TopoDS_Shape S = itV.Value();
B.UpdateVertex ( TopoDS::Vertex ( S ), tol );
}
Handle(GeomAdaptor_HSurface) AS = new GeomAdaptor_HSurface ( plane );
for ( TopExp_Explorer ed ( face, TopAbs_EDGE ); ed.More(); ed.Next() ) {
TopoDS_Edge edge = TopoDS::Edge ( ed.Current() );
Standard_Real f, l;
Handle(Geom_Curve) crv = BRep_Tool::Curve ( edge, f, l );
if ( crv.IsNull() )
continue;
Handle(Geom2d_Curve) c2d = BRep_Tool::CurveOnSurface ( edge, face, f, l );;
if ( c2d.IsNull() ) continue;
Handle(Geom2dAdaptor_HCurve) GHPC = new Geom2dAdaptor_HCurve ( c2d, f, l );
Adaptor3d_CurveOnSurface ACS(GHPC,AS);
Standard_Real tol0 = BRep_Tool::Tolerance(edge);
tol = tol0;
Standard_Real tol2 = tol*tol;
const Standard_Integer NCONTROL = 23;
for ( Standard_Integer i = 0; i < NCONTROL; i++ )
{
Standard_Real par = ( f * ( NCONTROL - 1 - i ) + l * i ) / ( NCONTROL - 1 );
gp_Pnt pnt = crv->Value ( par );
gp_Pnt prj = ACS.Value( par );
Standard_Real dist = pnt.SquareDistance(prj);
if ( tol2 < dist )
tol2 = dist;
}
tol = 1.00005 * sqrt(tol2); // coeff: see trj3_pm1-ct-203.stp #19681, edge 10
if ( tol >= tol0 )
{
B.UpdateEdge ( edge, tol );
for ( TopoDS_Iterator itV(edge); itV.More(); itV.Next() )
{
TopoDS_Shape S = itV.Value();
B.UpdateVertex ( TopoDS::Vertex ( S ), tol );
}
}
}
// Halt algorithm in case of user's abort
if ( !aPSentry.More() )
return Standard_False;
}
}
@@ -167,7 +209,6 @@ Standard_Boolean ShapeFix::SameParameter(const TopoDS_Shape& shape,
#ifdef DEB
cout<<"** SameParameter not complete. On "<<numedge<<" Edges:";
if (nbfail > 0) cout<<" "<<nbfail<<" Failed";
//if (nbexcp > 0) cout<<" "<<nbexcp<<" Raised"; //SK original
cout<<endl;
#endif
}

View File

@@ -19,8 +19,9 @@ uses
Edge from ShapeFix,
Status from ShapeExtend,
MapOfShape from TopTools,
BasicMsgRegistrator from ShapeExtend
BasicMsgRegistrator from ShapeExtend,
ProgressIndicator from Message
is
Create returns Shape from ShapeFix;
@@ -33,10 +34,17 @@ is
Init (me: mutable; shape: Shape from TopoDS);
---Purpose: Initislises by shape.
Perform (me: mutable) returns Boolean;
Perform (me : mutable;
theProgress : ProgressIndicator from Message = 0) returns Boolean;
---Purpose: Iterates on sub- shape and performs fixes
SameParameter (me: mutable; shape: Shape from TopoDS; force: Boolean) is protected;
SameParameter (me : mutable;
shape : Shape from TopoDS;
enforce : Boolean;
theProgress : ProgressIndicator from Message = 0) is protected;
---Purpose: Fixes same parameterization problem on the passed shape
-- by updating tolerances of the corresponding topological
-- entitites.
Shape (me) returns Shape from TopoDS;
---Purpose: Returns resulting shape

View File

@@ -26,6 +26,8 @@
#include <ShapeFix_Shell.hxx>
#include <ShapeFix_Solid.hxx>
#include <Message_ProgressSentry.hxx>
//=======================================================================
//function : ShapeFix_Shape
//purpose :
@@ -81,11 +83,11 @@ void ShapeFix_Shape::Init(const TopoDS_Shape& shape)
//purpose :
//=======================================================================
Standard_Boolean ShapeFix_Shape::Perform()
Standard_Boolean ShapeFix_Shape::Perform(const Handle(Message_ProgressIndicator)& theProgress)
{
Standard_Integer savFixSmallAreaWireMode = 0;
Handle(ShapeFix_Face) fft = Handle(ShapeFix_Face)::DownCast ( FixFaceTool() );
Handle(ShapeFix_Face) fft = Handle(ShapeFix_Face)::DownCast( FixFaceTool() );
if ( !fft.IsNull() ) {
savFixSmallAreaWireMode = fft->FixSmallAreaWireMode();
if ( savFixSmallAreaWireMode == -1 &&
@@ -117,41 +119,60 @@ Standard_Boolean ShapeFix_Shape::Perform()
ShapeFix::FixVertexPosition(S,Precision(),Context());
st = S.ShapeType();
// Open progress indication scope for the following fix stages:
// - Fix on Solid or Shell;
// - Fix same parameterization;
Message_ProgressSentry aPSentry(theProgress, "Fixing stage", 0, 2, 1);
switch ( st ) {
case TopAbs_COMPOUND:
case TopAbs_COMPSOLID: {
TopoDS_Shape shape = myShape;
Standard_Boolean savFixSameParameterMode = myFixSameParameterMode;
myFixSameParameterMode = Standard_False;
for( TopoDS_Iterator iter(S); iter.More(); iter.Next()) {
myShape = iter.Value();
if ( Perform() ) status = Standard_True;
Standard_Integer aShapesNb = 0;
for ( TopoDS_Iterator anIter(S); anIter.More(); anIter.Next() )
++aShapesNb;
// Open progress indication scope for sub-shape fixing
Message_ProgressSentry aPSentry(theProgress, "Fixing sub-shape", 0, aShapesNb, 1);
for ( TopoDS_Iterator anIter(S); anIter.More() && aPSentry.More(); anIter.Next(), aPSentry.Next() )
{
myShape = anIter.Value();
if ( Perform(theProgress) )
status = Standard_True;
}
if ( !aPSentry.More() )
return Standard_False; // aborted execution
myFixSameParameterMode = savFixSameParameterMode;
myShape = shape;
// myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE5 );
break;
}
case TopAbs_SOLID: {
if ( ! NeedFix ( myFixSolidMode ) ) break;
if ( !NeedFix(myFixSolidMode) )
break;
myFixSolid->Init(TopoDS::Solid(S));
myFixSolid->SetContext(Context());
if(myFixSolid->Perform()) {
// Context()->Replace(S,myFixSolid->Solid());
if ( myFixSolid->Perform(theProgress) )
status = Standard_True;
}
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE4 );
break;
}
case TopAbs_SHELL: {
if ( ! NeedFix ( myFixShellMode ) ) break;
if ( !NeedFix(myFixShellMode) )
break;
Handle(ShapeFix_Shell) sfsh = FixShellTool();
sfsh->Init(TopoDS::Shell(S));
sfsh->SetContext(Context());
if(sfsh->Perform()) {
// Context()->Replace(S,sfsh->Shell());
sfsh->Init( TopoDS::Shell(S) );
sfsh->SetContext( Context() );
if ( sfsh->Perform(theProgress) )
status = Standard_True;
}
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE4 );
break;
}
@@ -162,8 +183,8 @@ Standard_Boolean ShapeFix_Shape::Perform()
sff->FixWireTool()->ModifyTopologyMode() = Standard_True;
sff->Init(TopoDS::Face(S));
sff->SetContext(Context());
if(sff->Perform()) {
// Context()->Replace(S,sff->Face());
status = Standard_True;
}
sff->FixWireTool()->ModifyTopologyMode() = savTopoMode;
@@ -178,7 +199,6 @@ Standard_Boolean ShapeFix_Shape::Perform()
sfw->ModifyTopologyMode() = Standard_True;
if ( ! S.Closed() )
sfw->ClosedWireMode() = Standard_False;
// sfw->FixEdgeCurvesMode() =0;
sfw->SetFace(TopoDS_Face());
sfw->Load(TopoDS::Wire(S));
sfw->SetContext(Context());
@@ -201,10 +221,16 @@ Standard_Boolean ShapeFix_Shape::Perform()
case TopAbs_SHAPE :
default : break;
}
// Switch to the second progress indication scope if it exists
aPSentry.Next();
myResult = Context()->Apply(S);
if ( NeedFix ( myFixSameParameterMode ) )
SameParameter (myResult,Standard_False);
myResult = Context()->Apply(S);
if ( NeedFix(myFixSameParameterMode) )
{
SameParameter(myResult, Standard_False, theProgress);
}
if ( !fft.IsNull() )
fft->FixSmallAreaWireMode() = savFixSmallAreaWireMode;
@@ -217,9 +243,11 @@ Standard_Boolean ShapeFix_Shape::Perform()
//purpose :
//=======================================================================
void ShapeFix_Shape::SameParameter(const TopoDS_Shape& sh, const Standard_Boolean enforce)
void ShapeFix_Shape::SameParameter(const TopoDS_Shape& sh,
const Standard_Boolean enforce,
const Handle(Message_ProgressIndicator)& theProgress)
{
ShapeFix::SameParameter(sh, enforce);
ShapeFix::SameParameter(sh, enforce, 0.0, theProgress);
}
//=======================================================================

View File

@@ -16,7 +16,9 @@ uses
Shape from TopoDS,
Status from ShapeExtend,
BasicMsgRegistrator from ShapeExtend,
Face from ShapeFix
Face from ShapeFix,
ProgressIndicator from Message
is
Create returns Shell from ShapeFix;
@@ -29,33 +31,36 @@ is
Init (me: mutable; shell: Shell from TopoDS);
---Purpose: Initializes by shell.
Perform (me: mutable) returns Boolean;
---Purpose: Iterates on subshapes and performs fixes
-- (for each face calls ShapeFix_Face::Perform and
-- then calls FixFaceOrientation)
Perform (me: mutable;
theProgress : ProgressIndicator from Message = 0) returns Boolean;
---Purpose: Iterates on subshapes and performs fixes
-- (for each face calls ShapeFix_Face::Perform and
-- then calls FixFaceOrientation). The passed progress
-- indicator allows user to consult the current progress
-- stage and abort algorithm if needed.
FixFaceOrientation (me : mutable; shell : Shell from TopoDS;
isAccountMultiConex : Boolean = Standard_True;
NonManifold : Boolean = Standard_False ) returns Boolean;
---Purpose: Fixes orientation of faces in shell.
-- Changes orientation of face in the shell, if it is oriented opposite
-- to neigbouring faces. If it is not possible to orient all faces in the
-- shell (like in case of mebious band), this method orients only subset
-- of faces. Other faces are stored in Error compound.
-- Modes :
-- isAccountMultiConex - mode for account cases of multiconnexity.
-- If this mode is equal to Standard_True, separate shells will be created
-- in the cases of multiconnexity. If this mode is equal to Standard_False,
-- one shell will be created without account of multiconnexity.By defautt - Standard_True;
-- NonManifold - mode for creation of non-manifold shells.
-- If this mode is equal to Standard_True one non-manifold will be created from shell
-- contains multishared edges. Else if this mode is equal to Standard_False only
-- manifold shells will be created. By default - Standard_False.
--
---Returns: If resulting shell is ok returns TRUE, else returns FALSE.
---Status : OK - faces in shall were oriented correcty.
-- DONE - faces in shell oriented succesfully
-- FAIL - faces orientation process has been failed
---Purpose: Fixes orientation of faces in shell.
-- Changes orientation of face in the shell, if it is oriented opposite
-- to neigbouring faces. If it is not possible to orient all faces in the
-- shell (like in case of mebious band), this method orients only subset
-- of faces. Other faces are stored in Error compound.
-- Modes :
-- isAccountMultiConex - mode for account cases of multiconnexity.
-- If this mode is equal to Standard_True, separate shells will be created
-- in the cases of multiconnexity. If this mode is equal to Standard_False,
-- one shell will be created without account of multiconnexity.By defautt - Standard_True;
-- NonManifold - mode for creation of non-manifold shells.
-- If this mode is equal to Standard_True one non-manifold will be created from shell
-- contains multishared edges. Else if this mode is equal to Standard_False only
-- manifold shells will be created. By default - Standard_False.
--
---Returns: If resulting shell is ok returns TRUE, else returns FALSE.
---Status : OK - faces in shall were oriented correcty.
-- DONE - faces in shell oriented succesfully
-- FAIL - faces orientation process has been failed
Shell(me : mutable) returns Shell from TopoDS;
---Purpose: Returns fixed shell (or subset of oriented faces).
@@ -74,10 +79,10 @@ is
FixFaceTool (me:mutable) returns Face from ShapeFix;
---Purpose: Returns tool for fixing faces.
---C++:inline
---C++:inline
SetMsgRegistrator (me: mutable; msgreg: BasicMsgRegistrator from ShapeExtend) is redefined;
---Purpose: Sets message registrator
---Purpose: Sets message registrator
SetPrecision (me: mutable; preci: Real) is redefined;
---Purpose: Sets basic precision value (also to FixWireTool)
@@ -90,15 +95,15 @@ is
FixFaceMode (me: mutable) returns Integer;
---C++: return &
---C++: inline
---Purpose: Returns (modifiable) the mode for applying fixes of
-- ShapeFix_Face, by default True.
---C++: inline
---Purpose: Returns (modifiable) the mode for applying fixes of
-- ShapeFix_Face, by default True.
FixOrientationMode (me: mutable) returns Integer;
---C++: return &
---C++: inline
---Purpose: Returns (modifiable) the mode for applying
-- FixFaceOrientation, by default True.
---C++: inline
---Purpose: Returns (modifiable) the mode for applying
-- FixFaceOrientation, by default True.
fields
@@ -108,5 +113,6 @@ fields
myFixFace : Face from ShapeFix is protected;
myFixFaceMode : Integer is protected;
myFixOrientationMode : Integer is protected;
myNbShells : Integer is protected;
myNbShells : Integer is protected;
end Shell;

View File

@@ -33,6 +33,7 @@
#include <ShapeExtend.hxx>
#include <ShapeBuild_ReShape.hxx>
#include <Message_Msg.hxx>
#include <Message_ProgressSentry.hxx>
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <TopTools_DataMapOfShapeInteger.hxx>
@@ -93,26 +94,40 @@ void ShapeFix_Shell::Init(const TopoDS_Shell& shell)
//purpose :
//=======================================================================
Standard_Boolean ShapeFix_Shell::Perform()
Standard_Boolean ShapeFix_Shell::Perform(const Handle(Message_ProgressIndicator)& theProgress)
{
Standard_Boolean status = Standard_False;
if(Context().IsNull())
SetContext ( new ShapeBuild_ReShape );
if ( Context().IsNull() )
SetContext(new ShapeBuild_ReShape);
myFixFace->SetContext(Context());
if ( NeedFix ( myFixFaceMode ) ) {
TopoDS_Shape S = Context()->Apply ( myShell );
for( TopoDS_Iterator iter(S); iter.More(); iter.Next()) {
if ( NeedFix(myFixFaceMode) )
{
TopoDS_Shape S = Context()->Apply(myShell);
// Get the number of faces for progress indication
Standard_Integer aNbFaces = 0;
for ( TopExp_Explorer aFaceExp(S, TopAbs_FACE); aFaceExp.More(); aFaceExp.Next() )
++aNbFaces;
// Start progress scope (no need to check if progress exists -- it is safe)
Message_ProgressSentry aPSentry(theProgress, "Fixing face", 0, aNbFaces, 1);
for( TopoDS_Iterator iter(S); iter.More() && aPSentry.More(); iter.Next(), aPSentry.Next() )
{
TopoDS_Shape sh = iter.Value();
TopoDS_Face tmpFace = TopoDS::Face(sh);
myFixFace->Init(tmpFace);
// myFixFace->SetPrecision(Precision());
if(myFixFace->Perform()) {
// if(!Context().IsNull())
// Context()->Replace(tmpFace,myFixFace->Face());
status = Standard_True;
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
if ( myFixFace->Perform() )
{
status = Standard_True;
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
}
}
// Halt algorithm in case of user's abort
if ( !aPSentry.More() )
return Standard_False;
}
TopoDS_Shape newsh = Context()->Apply(myShell);
if ( NeedFix ( myFixOrientationMode) )

View File

@@ -17,7 +17,8 @@ uses
Shape from TopoDS,
Shell from ShapeFix,
Status from ShapeExtend,
BasicMsgRegistrator from ShapeExtend
BasicMsgRegistrator from ShapeExtend,
ProgressIndicator from Message
is
Create returns Solid from ShapeFix;
@@ -29,9 +30,12 @@ is
Init(me: mutable; solid : Solid from TopoDS) is virtual;
---Purpose: Initializes by solid .
Perform(me: mutable) returns Boolean is virtual;
Perform(me: mutable;
theProgress : ProgressIndicator from Message = 0) returns Boolean is virtual;
---Purpose: Iterates on shells and performs fixes
-- (calls ShapeFix_Shell for each subshell)
-- (calls ShapeFix_Shell for each subshell). The passed
-- progress indicator allows user to consult the current
-- progress stage and abort algorithm if needed.
SolidFromShell (me: mutable; shell: Shell from TopoDS)
returns Solid from TopoDS;
@@ -45,10 +49,10 @@ is
FixShellTool (me) returns Shell from ShapeFix;
---Purpose: Returns tool for fixing shells.
---C++:inline
---C++:inline
SetMsgRegistrator (me: mutable; msgreg: BasicMsgRegistrator from ShapeExtend) is redefined;
---Purpose: Sets message registrator
---Purpose: Sets message registrator
SetPrecision (me: mutable; preci: Real) is redefined;
---Purpose: Sets basic precision value (also to FixShellTool)
@@ -61,17 +65,17 @@ is
FixShellMode (me: mutable) returns Integer;
---C++: return &
---C++: inline
---Purpose: Returns (modifiable) the mode for applying fixes of
-- ShapeFix_Shell, by default True.
---C++: inline
---Purpose: Returns (modifiable) the mode for applying fixes of
-- ShapeFix_Shell, by default True.
CreateOpenSolidMode(me: mutable) returns Boolean;
---C++: return &
---C++: inline
---Purpose: Returns (modifiable) the mode for creation of solids.
-- If mode myCreateOpenSolidMode is equal to true
-- solids are created from open shells
-- else solids are created from closed shells only.
-- ShapeFix_Shell, by default False.
---C++: inline
---Purpose: Returns (modifiable) the mode for creation of solids.
-- If mode myCreateOpenSolidMode is equal to true
-- solids are created from open shells
-- else solids are created from closed shells only.
-- ShapeFix_Shell, by default False.
Shape(me : mutable) returns Shape from TopoDS;
---Purpose: In case of multiconnexity returns compound of fixed solids
-- else returns one solid.

View File

@@ -44,13 +44,13 @@
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeShape.hxx>
#include <Message_Msg.hxx>
#include <Message_ProgressSentry.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <Geom_Curve.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
//======================================================
//function : ShapeFix_Solid
@@ -341,36 +341,55 @@ static Standard_Boolean CreateSolids(const TopoDS_Shape aShape,TopTools_IndexedM
//purpose :
//=======================================================================
Standard_Boolean ShapeFix_Solid::Perform()
Standard_Boolean ShapeFix_Solid::Perform(const Handle(Message_ProgressIndicator)& theProgress)
{
Standard_Boolean status = Standard_False;
if(Context().IsNull())
if ( Context().IsNull() )
SetContext ( new ShapeBuild_ReShape );
myFixShell->SetContext(Context());
Standard_Integer NbShells =0;
Standard_Integer NbShells = 0;
TopoDS_Shape S = Context()->Apply ( myShape );
if ( NeedFix ( myFixShellMode ) ) {
// call FixShell
for( TopoDS_Iterator iter(S); iter.More(); iter.Next()) {
TopoDS_Shape sh = iter.Value();
if(sh.ShapeType() != TopAbs_SHELL)
continue;
myFixShell->Init(TopoDS::Shell(sh));
if(myFixShell->Perform()) {
// Context()->Replace(sh,myFixShell->Shell());
// Calculate number of underlying shells
Standard_Integer aNbShells = 0;
for ( TopExp_Explorer aExpSh(S, TopAbs_SHELL); aExpSh.More(); aExpSh.Next() )
aNbShells++;
// Start progress scope (no need to check if progress exists -- it is safe)
Message_ProgressSentry aPSentry(theProgress, "Fixing solid stage", 0, 2, 1);
if ( NeedFix(myFixShellMode) )
{
// Start progress scope (no need to check if progress exists -- it is safe)
Message_ProgressSentry aPSentry(theProgress, "Fixing shell", 0, aNbShells, 1);
// Fix shell by shell using ShapeFix_Shell tool
for ( TopExp_Explorer aExpSh(S, TopAbs_SHELL); aExpSh.More() && aPSentry.More(); aExpSh.Next(), aPSentry.Next() )
{
TopoDS_Shape sh = aExpSh.Current();
myFixShell->Init( TopoDS::Shell(sh) );
if ( myFixShell->Perform(theProgress) )
{
status = Standard_True;
myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE1 );
}
NbShells+= myFixShell->NbShells();
}
// Halt algorithm in case of user's abort
if ( !aPSentry.More() )
return Standard_False;
}
else {
for(TopExp_Explorer aExpSh(myShape,TopAbs_SHELL); aExpSh.More(); aExpSh.Next())
NbShells++;
else
{
NbShells = aNbShells;
}
//if(!status) return status;
// Switch to the second stage
aPSentry.Next();
if(NbShells ==1) {
TopoDS_Shape tmpShape = Context()->Apply(myShape);
@@ -441,7 +460,11 @@ Standard_Boolean ShapeFix_Solid::Perform()
BRep_Builder aB;
TopoDS_Compound aComp;
aB.MakeCompound(aComp);
for(Standard_Integer i =1; i <= aMapSolids.Extent(); i++) {
Message_ProgressSentry aPSentry(theProgress, "Creating solid",
0, aMapSolids.Extent(), 1);
for(Standard_Integer i =1; (i <= aMapSolids.Extent()) && (aPSentry.More());
i++, aPSentry.Next())
{
TopoDS_Shape aResSh =aMapSolids.FindKey(i);
if(aResShape.ShapeType() == TopAbs_SHELL && myCreateOpenSolidMode) {
aResSh.Closed(Standard_False);
@@ -456,6 +479,8 @@ Standard_Boolean ShapeFix_Solid::Perform()
aB.Add(aComp,aResSh);
}
if ( !aPSentry.More() )
return Standard_False; // aborted execution
Context()->Replace(aResShape,aComp);
}
}