@@ -3057,6 +3057,50 @@ int ENGINE_Sew(const Handle(asiTcl_Interp)& interp,
30573057
30583058// -----------------------------------------------------------------------------
30593059
3060+ int ENGINE_MaximizeFaces (const Handle (asiTcl_Interp)& interp,
3061+ int argc,
3062+ const char** argv)
3063+ {
3064+ if ( argc != 1 )
3065+ {
3066+ return interp->ErrorOnWrongArgs (argv[0 ]);
3067+ }
3068+
3069+ // Get Part Node.
3070+ Handle (asiData_PartNode) partNode = cmdEngine::model->GetPartNode ();
3071+ //
3072+ if ( partNode.IsNull () || !partNode->IsWellFormed () )
3073+ {
3074+ interp->GetProgress ().SendLogMessage (LogErr (Normal) << " Part Node is null or ill-defined." );
3075+ return TCL_ERROR;
3076+ }
3077+ //
3078+ TopoDS_Shape shape = partNode->GetShape ();
3079+
3080+ // Modify shape.
3081+ cmdEngine::model->OpenCommand ();
3082+ {
3083+ if ( !asiAlgo_Utils::MaximizeFaces (shape) )
3084+ {
3085+ interp->GetProgress ().SendLogMessage (LogErr (Normal) << " Face maximization failed." );
3086+ //
3087+ cmdEngine::model->AbortCommand ();
3088+ return TCL_ERROR;
3089+ }
3090+ //
3091+ asiEngine_Part (cmdEngine::model).Update (shape);
3092+ }
3093+ cmdEngine::model->CommitCommand ();
3094+
3095+ // Update UI.
3096+ if ( cmdEngine::cf && cmdEngine::cf->ViewerPart )
3097+ cmdEngine::cf->ViewerPart ->PrsMgr ()->Actualize (partNode);
3098+
3099+ return TCL_OK;
3100+ }
3101+
3102+ // -----------------------------------------------------------------------------
3103+
30603104void cmdEngine::Commands_Editing (const Handle (asiTcl_Interp)& interp,
30613105 const Handle(Standard_Transient)& cmdEngine_NotUsed(data))
30623106{
@@ -3468,4 +3512,12 @@ void cmdEngine::Commands_Editing(const Handle(asiTcl_Interp)& interp,
34683512 " \t is passed, the default value 1.e-7 is used." ,
34693513 //
34703514 __FILE__, group, ENGINE_Sew);
3515+
3516+ // -------------------------------------------------------------------------//
3517+ interp->AddCommand (" maximize-faces" ,
3518+ //
3519+ " maximize-faces\n "
3520+ " \t Maximizes canonical faces." ,
3521+ //
3522+ __FILE__, group, ENGINE_MaximizeFaces);
34713523}
0 commit comments