0025520: To provide info on what has been done by Shape Process and Shape Fix

Messages are registered in ShapeExtend_MsgRegistrator added to ShapeCutom and ShapeUpgrade packages
All operators of ShapeProcess_OperLibrary are instrumented with MsgRegistrator

0025520: To provide info on what has been done by Shape Process and Shape Fix

Update SHAPE.fr

Fix some messages (minor change)
This commit is contained in:
bugmaster
2014-12-12 14:19:09 +03:00
parent e275de58af
commit da2db6a705
30 changed files with 636 additions and 66 deletions

View File

@@ -67,7 +67,8 @@
TopoDS_Shape ShapeProcess_OperLibrary::ApplyModifier (const TopoDS_Shape &S,
const Handle(ShapeProcess_ShapeContext)& context,
const Handle(BRepTools_Modification) &M,
TopTools_DataMapOfShapeShape &map)
TopTools_DataMapOfShapeShape &map,
const Handle(ShapeExtend_MsgRegistrator) &msg)
{
// protect against INTERNAL/EXTERNAL shapes
TopoDS_Shape SF = S.Oriented(TopAbs_FORWARD);
@@ -102,7 +103,7 @@ TopoDS_Shape ShapeProcess_OperLibrary::ApplyModifier (const TopoDS_Shape &S,
// Modify the shape
BRepTools_Modifier MD(SF,M);
context->RecordModification ( SF, MD );
context->RecordModification ( SF, MD, msg );
return MD.ModifiedShape(SF).Oriented(S.Orientation());
}
@@ -117,10 +118,15 @@ static Standard_Boolean directfaces (const Handle(ShapeProcess_Context)& context
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
Handle(ShapeCustom_DirectModification) DM = new ShapeCustom_DirectModification;
DM->SetMsgRegistrator( msg );
TopTools_DataMapOfShapeShape map;
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier ( ctx->Result(), ctx, DM, map );
ctx->RecordModification ( map );
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier ( ctx->Result(), ctx, DM, map, msg );
ctx->RecordModification ( map, msg );
ctx->SetResult ( res );
return Standard_True;
}
@@ -128,17 +134,29 @@ static Standard_Boolean directfaces (const Handle(ShapeProcess_Context)& context
//=======================================================================
//function : sameparam
//purpose :
//purpose :
//=======================================================================
static Standard_Boolean sameparam (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
ShapeFix::SameParameter ( ctx->Result(),
ctx->IntegerVal ( "Force", Standard_False ),
ctx->RealVal ( "Tolerance3d", Precision::Confusion() /* -1 */) );
// WARNING: no update of context yet!
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
ShapeFix::SameParameter ( ctx->Result(),
ctx->IntegerVal ( "Force", Standard_False ),
ctx->RealVal ( "Tolerance3d", Precision::Confusion() /* -1 */),
NULL, msg );
if ( !msg.IsNull() )
{
// WARNING: not FULL update of context yet!
Handle(ShapeBuild_ReShape) reshape = new ShapeBuild_ReShape;
ctx->RecordModification( reshape, msg );
}
return Standard_True;
}
@@ -175,25 +193,30 @@ static Standard_Boolean settol (const Handle(ShapeProcess_Context)& context)
//=======================================================================
//function : splitangle
//purpose :
//purpose :
//=======================================================================
static Standard_Boolean splitangle (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
ShapeUpgrade_ShapeDivideAngle SDA ( ctx->RealVal ( "Angle", 2*M_PI ), ctx->Result() );
SDA.SetMaxTolerance ( ctx->RealVal ( "MaxTolerance", 1. ) );
SDA.SetMsgRegistrator ( msg );
if ( ! SDA.Perform() && SDA.Status (ShapeExtend_FAIL) ) {
#ifdef OCCT_DEBUG
cout<<"ShapeDivideAngle failed"<<endl;
#endif
return Standard_False;
}
ctx->RecordModification ( SDA.GetContext() );
ctx->RecordModification ( SDA.GetContext(), msg );
ctx->SetResult ( SDA.Result() );
return Standard_True;
}
@@ -209,6 +232,10 @@ static Standard_Boolean bsplinerestriction (const Handle(ShapeProcess_Context)&
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
Standard_Boolean ModeSurf = ctx->IntegerVal ( "SurfaceMode", Standard_True );
Standard_Boolean ModeC3d = ctx->IntegerVal ( "Curve3dMode", Standard_True );
Standard_Boolean ModeC2d = ctx->IntegerVal ( "Curve2dMode", Standard_True );
@@ -249,9 +276,10 @@ static Standard_Boolean bsplinerestriction (const Handle(ShapeProcess_Context)&
new ShapeCustom_BSplineRestriction ( ModeSurf, ModeC3d, ModeC2d,
aTol3d, aTol2d, aCont3d, aCont2d,
aMaxDeg, aMaxSeg, ModeDeg, Rational, aParameters );
LD->SetMsgRegistrator( msg );
TopTools_DataMapOfShapeShape map;
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier ( ctx->Result(), ctx, LD, map );
ctx->RecordModification ( map );
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier ( ctx->Result(), ctx, LD, map, msg );
ctx->RecordModification ( map, msg );
ctx->SetResult ( res );
return Standard_True;
}
@@ -267,11 +295,15 @@ static Standard_Boolean torevol (const Handle(ShapeProcess_Context)& context)
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
Handle(ShapeCustom_ConvertToRevolution) CR =
new ShapeCustom_ConvertToRevolution();
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
Handle(ShapeCustom_ConvertToRevolution) CR = new ShapeCustom_ConvertToRevolution();
CR->SetMsgRegistrator( msg );
TopTools_DataMapOfShapeShape map;
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier ( ctx->Result(), ctx, CR, map );
ctx->RecordModification ( map );
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier ( ctx->Result(), ctx, CR, map, msg );
ctx->RecordModification ( map, msg );
ctx->SetResult ( res );
return Standard_True;
}
@@ -287,10 +319,15 @@ static Standard_Boolean swepttoelem (const Handle(ShapeProcess_Context)& context
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
Handle(ShapeCustom_SweptToElementary) SE = new ShapeCustom_SweptToElementary();
SE->SetMsgRegistrator( msg );
TopTools_DataMapOfShapeShape map;
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier ( ctx->Result(), ctx, SE, map );
ctx->RecordModification ( map );
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier ( ctx->Result(), ctx, SE, map, msg );
ctx->RecordModification ( map, msg );
ctx->SetResult ( res );
return Standard_True;
}
@@ -306,6 +343,10 @@ static Standard_Boolean shapetobezier (const Handle(ShapeProcess_Context)& conte
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
Standard_Boolean ModeC3d = ctx->BooleanVal ( "Curve3dMode", Standard_False );
Standard_Boolean ModeC2d = ctx->BooleanVal ( "Curve2dMode", Standard_False );
Standard_Boolean ModeSurf = ctx->BooleanVal ( "SurfaceMode", Standard_False );
@@ -319,6 +360,7 @@ static Standard_Boolean shapetobezier (const Handle(ShapeProcess_Context)& conte
Standard_Boolean BSplineMode = ctx->BooleanVal ( "BSplineMode", Standard_True );
ShapeUpgrade_ShapeConvertToBezier SCB (ctx->Result());
SCB.SetMsgRegistrator( msg );
SCB.SetSurfaceSegmentMode(SegmentMode);
SCB.SetSurfaceConversion (ModeSurf);
SCB.Set2dConversion (ModeC2d);
@@ -349,7 +391,7 @@ static Standard_Boolean shapetobezier (const Handle(ShapeProcess_Context)& conte
return Standard_False;
}
ctx->RecordModification ( SCB.GetContext() );
ctx->RecordModification ( SCB.GetContext(), msg );
ctx->SetResult ( SCB.Result() );
return Standard_True;
}
@@ -365,6 +407,10 @@ static Standard_Boolean converttobspline (const Handle(ShapeProcess_Context)& co
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
Standard_Boolean extrMode = ctx->BooleanVal ( "LinearExtrusionMode", Standard_True );
Standard_Boolean revolMode = ctx->BooleanVal ( "RevolutionMode", Standard_True );
Standard_Boolean offsetMode = ctx->BooleanVal ( "OffsetMode", Standard_True );
@@ -373,10 +419,11 @@ static Standard_Boolean converttobspline (const Handle(ShapeProcess_Context)& co
CBspl->SetExtrusionMode(extrMode);
CBspl->SetRevolutionMode(revolMode);
CBspl->SetOffsetMode(offsetMode);
CBspl->SetMsgRegistrator( msg );
TopTools_DataMapOfShapeShape map;
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier ( ctx->Result(), ctx, CBspl, map );
ctx->RecordModification ( map );
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier( ctx->Result(), ctx, CBspl, map, msg );
ctx->RecordModification ( map, msg );
ctx->SetResult ( res );
return Standard_True;
}
@@ -392,6 +439,10 @@ static Standard_Boolean splitcontinuity (const Handle(ShapeProcess_Context)& con
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
Standard_Real aTol = ctx->RealVal ( "Tolerance3d", 1.e-7 );
Standard_Real aTol2D = ctx->RealVal ( "Tolerance2d", 1.e-9 );
GeomAbs_Shape aCrvCont = ctx->ContinuityVal ( "CurveContinuity", GeomAbs_C1 );
@@ -403,7 +454,9 @@ static Standard_Boolean splitcontinuity (const Handle(ShapeProcess_Context)& con
tool.SetPCurveCriterion(aCrv2dCont);
tool.SetTolerance(aTol);
tool.SetTolerance2d(aTol2D);
tool.SetMsgRegistrator( msg );
Standard_Real maxTol;
if ( ctx->GetReal ( "MaxTolerance", maxTol ) ) tool.SetMaxTolerance(maxTol);
@@ -414,7 +467,7 @@ static Standard_Boolean splitcontinuity (const Handle(ShapeProcess_Context)& con
return Standard_False;
}
ctx->RecordModification ( tool.GetContext() );
ctx->RecordModification ( tool.GetContext(), msg );
ctx->SetResult ( tool.Result() );
return Standard_True;
}
@@ -430,7 +483,12 @@ static Standard_Boolean splitclosedfaces (const Handle(ShapeProcess_Context)& co
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
ShapeUpgrade_ShapeDivideClosed tool ( ctx->Result() );
tool.SetMsgRegistrator( msg );
Standard_Real closeTol;
if ( ctx->GetReal ( "CloseTolerance", closeTol ) ) tool.SetPrecision(closeTol);
@@ -451,7 +509,7 @@ static Standard_Boolean splitclosedfaces (const Handle(ShapeProcess_Context)& co
return Standard_False;
}
ctx->RecordModification ( tool.GetContext() );
ctx->RecordModification ( tool.GetContext(), msg );
ctx->SetResult ( tool.Result() );
return Standard_True;
}
@@ -467,10 +525,15 @@ static Standard_Boolean fixfacesize (const Handle(ShapeProcess_Context)& context
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
Handle(ShapeBuild_ReShape) reshape = new ShapeBuild_ReShape;
ShapeFix_FixSmallFace FSC;
FSC.SetContext(reshape);
FSC.Init(ctx->Result());
FSC.SetMsgRegistrator ( msg );
Standard_Real aTol;
if ( ctx->GetReal ( "Tolerance", aTol ) ) FSC.SetPrecision (aTol);
@@ -479,7 +542,7 @@ static Standard_Boolean fixfacesize (const Handle(ShapeProcess_Context)& context
TopoDS_Shape newsh = FSC.Shape();
if ( newsh != ctx->Result() ) {
ctx->RecordModification ( reshape );
ctx->RecordModification ( reshape, msg );
ctx->SetResult ( newsh );
}
@@ -497,17 +560,22 @@ static Standard_Boolean fixwgaps (const Handle(ShapeProcess_Context)& context)
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
Standard_Real aTol3d = ctx->RealVal ( "Tolerance3d", Precision::Confusion() );
Handle(ShapeBuild_ReShape) reshape = new ShapeBuild_ReShape;
Handle(ShapeFix_Wireframe) sfwf = new ShapeFix_Wireframe(ctx->Result());
sfwf->SetMsgRegistrator( msg );
sfwf->SetContext(reshape);
sfwf->SetPrecision(aTol3d);
sfwf->FixWireGaps();
TopoDS_Shape result = sfwf->Shape();
if ( result != ctx->Result() ) {
ctx->RecordModification ( reshape );
ctx->RecordModification ( reshape, msg );
ctx->SetResult ( result );
}
return Standard_True;
@@ -589,15 +657,20 @@ static Standard_Boolean mergesmalledges (const Handle(ShapeProcess_Context)& con
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
Standard_Real aTol3d = ctx->RealVal ( "Tolerance3d", Precision::Confusion() );
Handle(ShapeBuild_ReShape) reshape = new ShapeBuild_ReShape;
ShapeFix_Wireframe ShapeFixWireframe(ctx->Result());
ShapeFixWireframe.SetContext(reshape);
ShapeFixWireframe.SetPrecision(aTol3d);
ShapeFixWireframe.SetMsgRegistrator( msg );
if ( ShapeFixWireframe.FixSmallEdges() ) {
ctx->RecordModification ( reshape );
ctx->RecordModification ( reshape, msg );
}
return Standard_True;
}
@@ -618,9 +691,9 @@ static Standard_Boolean fixshape (const Handle(ShapeProcess_Context)& context)
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
sfs->SetMsgRegistrator ( msg );
Handle(ShapeFix_Face) sff = Handle(ShapeFix_Face)::DownCast(sfs->FixFaceTool());
Handle(ShapeFix_Wire) sfw = Handle(ShapeFix_Wire)::DownCast(sfs->FixWireTool());
sfs->SetMsgRegistrator( msg );
sfs->SetPrecision ( ctx->RealVal ( "Tolerance3d", Precision::Confusion() ) );
sfs->SetMinTolerance ( ctx->RealVal ( "MinTolerance3d", Precision::Confusion() ) );
@@ -681,7 +754,9 @@ static Standard_Boolean fixshape (const Handle(ShapeProcess_Context)& context)
return Standard_False;
TopoDS_Shape result = sfs->Shape();
if ( result != ctx->Result() ) {
if (( result != ctx->Result() ) ||
( !msg.IsNull() && !msg->MapShape().IsEmpty()))
{
ctx->RecordModification ( sfs->Context(), msg );
ctx->SetResult ( result );
}
@@ -700,10 +775,15 @@ static Standard_Boolean spltclosededges (const Handle(ShapeProcess_Context)& con
Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
Standard_Integer nbSplits = ctx->IntegerVal ( "NbSplitPoints", 1 );
ShapeUpgrade_ShapeDivideClosedEdges tool (ctx->Result());
tool.SetNbSplitPoints(nbSplits);
tool.SetMsgRegistrator( msg );
if ( ! tool.Perform() && tool.Status (ShapeExtend_FAIL) ) {
#ifdef OCCT_DEBUG
@@ -712,7 +792,7 @@ static Standard_Boolean spltclosededges (const Handle(ShapeProcess_Context)& con
return Standard_False;
}
ctx->RecordModification ( tool.GetContext() );
ctx->RecordModification ( tool.GetContext(), msg );
ctx->SetResult ( tool.Result() );
return Standard_True;
}
@@ -729,16 +809,22 @@ static Standard_Boolean splitcommonvertex (const Handle(ShapeProcess_Context)& c
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
// activate message mechanism if it is supported by context
Handle(ShapeExtend_MsgRegistrator) msg;
if ( ! ctx->Messages().IsNull() ) msg = new ShapeExtend_MsgRegistrator;
Handle(ShapeBuild_ReShape) reshape = new ShapeBuild_ReShape;
ShapeFix_SplitCommonVertex SCV;
SCV.SetContext(reshape);
SCV.Init(ctx->Result());
SCV.SetMsgRegistrator( msg );
SCV.Perform();
TopoDS_Shape newsh = SCV.Shape();
if ( newsh != ctx->Result() ) {
ctx->RecordModification ( reshape );
ctx->RecordModification ( reshape, msg );
ctx->SetResult ( newsh );
}