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

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

3
src/ShapeProcess/FILES Executable file
View File

@@ -0,0 +1,3 @@
ShapeProcess_OperFunc.hxx
ShapeProcess_OperFunc.cxx

View File

@@ -0,0 +1,65 @@
-- File: ShapeProcess.cdl
-- Created: Mon Aug 21 18:51:20 2000
-- Author: Andrey BETENEV
-- <abv@doomox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2000
package ShapeProcess
---Purpose: Shape Processing module
-- allows to define and apply general Shape Processing as a
-- customizable sequence of Shape Healing operators. The
-- customization is implemented via user-editable resource
-- file which defines sequence of operators to be executed
-- and their parameters.
uses
Dico,
Resource,
TCollection,
TColStd,
GeomAbs,
TopAbs,
TopoDS,
TopTools,
BRepTools,
Message,
ShapeExtend,
ShapeBuild
is
class Context;
---Purpose: Provides general context for processing (resource file)
class ShapeContext;
---Purpose: Extends context to support processing of the shape
deferred class Operator;
---Purpose: Defines interface to Operator which do the job
primitive OperFunc;
class UOperator;
---Purpose: Customizable operator-container loaded by OperFunc
class OperLibrary;
---Purpose: Provides standard set of operators
class DictionaryOfOperator instantiates
Dictionary from Dico (Operator from ShapeProcess);
RegisterOperator (name: CString; op: Operator from ShapeProcess)
returns Boolean;
---Purpose: Registers operator to make it visible for Performer
FindOperator (name: CString; op: out Operator from ShapeProcess)
returns Boolean;
---Purpose: Finds operator by its name
Perform (context: Context from ShapeProcess; seq: CString)
returns Boolean;
---Purpose: Performs a specified sequence of operators on Context
-- Resource file and other data should be already loaded
-- to Context (including description of sequence seq)
end ShapeProcess;

133
src/ShapeProcess/ShapeProcess.cxx Executable file
View File

@@ -0,0 +1,133 @@
// File: ShapeProcess.cxx
// Created: Mon Aug 21 19:03:02 2000
// Author: Andrey BETENEV
// <abv@doomox.nnov.matra-dtv.fr>
#include <ShapeProcess.ixx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColStd_SequenceOfAsciiString.hxx>
#include <Message_Msg.hxx>
#include <Message_Messenger.hxx>
#include <ShapeProcess_Operator.hxx>
#include <ShapeProcess_DictionaryOfOperator.hxx>
static Handle(ShapeProcess_DictionaryOfOperator) dic;
//=======================================================================
//function : RegisterOperator
//purpose :
//=======================================================================
Standard_Boolean ShapeProcess::RegisterOperator (const Standard_CString name,
const Handle(ShapeProcess_Operator)& op)
{
if ( dic.IsNull() ) dic = new ShapeProcess_DictionaryOfOperator;
if ( dic->HasItem ( name, Standard_True ) ) {
#ifdef DEB
cout << "Warning: operator with name " << name << " is already registered!" << endl;
#endif
return Standard_False;
}
dic->SetItem ( name, op );
return Standard_True;
}
//=======================================================================
//function : FindOperator
//purpose :
//=======================================================================
Standard_Boolean ShapeProcess::FindOperator (const Standard_CString name,
Handle(ShapeProcess_Operator)& op)
{
if ( dic.IsNull() ) dic = new ShapeProcess_DictionaryOfOperator;
if ( ! dic->HasItem ( name, Standard_True ) ) {
#ifdef DEB
cout << "Error: no operator with name " << name << " registered!" << endl;
#endif
return Standard_False;
}
op = dic->Item ( name );
return !op.IsNull();
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
Standard_Boolean ShapeProcess::Perform (const Handle(ShapeProcess_Context)& context,
const Standard_CString seq)
{
context->SetScope ( seq );
// get description of the sequence
TCollection_AsciiString sequence;
if ( ! context->GetString ( "exec.op", sequence ) ) {
#ifdef DEB
cout << "Error: ShapeProcess_Performer::Perform: sequence not defined for " << seq << endl;
#endif
context->UnSetScope();
return Standard_False;
}
TColStd_SequenceOfAsciiString sequenceOfOperators;
TCollection_AsciiString oper;
Standard_Integer i;
for ( i=1; ; i++ ) {
oper = sequence.Token ( " \t,;", i );
if ( oper.Length() <=0 ) break;
sequenceOfOperators.Append(oper);
}
// put a message
if ( context->TraceLevel() >=2 ) {
Message_Msg SMSG0 ("Sequence.MSG0"); //Sequence of operators: %s
TCollection_AsciiString Seq;
for ( Standard_Integer i1=1; i1 <= sequenceOfOperators.Length(); i1++ ) {
if (i1 > 1) Seq += ",";
Seq += sequenceOfOperators.Value(i1);
}
SMSG0.Arg (Seq.ToCString());
context->Messenger()->Send (SMSG0, Message_Info);
}
// iterate on operators in the sequence
for (i=1; i<=sequenceOfOperators.Length(); i++) {
oper = sequenceOfOperators.Value(i);
if ( context->TraceLevel() >=2 ) {
Message_Msg SMSG5 ("Sequence.MSG5"); //Operator %d/%d: %s
SMSG5 << i << sequenceOfOperators.Length() << oper.ToCString();
context->Messenger()->Send (SMSG5, Message_Alarm);
}
Handle(ShapeProcess_Operator) op;
if ( ! ShapeProcess::FindOperator ( oper.ToCString(), op ) ) {
if ( context->TraceLevel() >0 ) {
Message_Msg SMSG1 ("Sequence.MSG1"); //Operator %s not found
context->Messenger()->Send (SMSG1 << oper, Message_Alarm);
}
continue;
}
context->SetScope ( oper.ToCString() );
try {
OCC_CATCH_SIGNALS
op->Perform ( context );
}
catch (Standard_Failure) {
Message_Msg SMSG2 ("Sequence.MSG2"); //Operator %s failed with exception %s
SMSG2 << oper << Standard_Failure::Caught()->GetMessageString();
context->Messenger()->Send (SMSG2, Message_Alarm);
}
context->UnSetScope();
}
context->UnSetScope();
return Standard_True;
}

View File

@@ -0,0 +1,97 @@
-- File: ShapeProcess_Context.cdl
-- Created: Mon Aug 21 19:11:11 2000
-- Author: Andrey BETENEV
-- <abv@nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2000
class Context from ShapeProcess inherits TShared from MMgt
---Purpose: Provides convenient interface to resource file
-- Allows to load resource file and get values of
-- attributes starting from some scope, for example
-- if scope is defined as "ToV4" and requested parameter
-- is "exec.op", value of "ToV4.exec.op" parameter from
-- the resource file will be returned
uses
Manager from Resource,
AsciiString from TCollection,
HSequenceOfHAsciiString from TColStd,
Messenger from Message
is
Create;
---Purpose: Creates an empty tool
Create (file: CString; scope: CString = "");
---Purpose: Creates a new tool and initialises by name of
-- resource file and (if specified) starting scope
-- Calls method Init()
Init (me: mutable; file: CString; scope: CString = "")
returns Boolean;
---Purpose: Initialises a tool by loading resource file and
-- (if specified) sets starting scope
-- Returns False if resource file not found
LoadResourceManager(me: mutable; file: CString) returns Manager from Resource;
---Purpose: Loading Resource_Manager object if this object not
-- equal internal static Resource_Manager object or
-- internal static Resource_Manager object is null
ResourceManager (me) returns Manager from Resource;
---Purpose: Returns internal Resource_Manager object
---C++: return const &
SetScope (me: mutable; scope: CString);
---Purpose: Set a new (sub)scope
UnSetScope (me: mutable);
---Purpose: Go out of current scope
IsParamSet (me; param: CString) returns Boolean;
---Purpose: Returns True if parameter is defined in the resource file
GetReal (me; param: CString; val: out Real ) returns Boolean;
GetInteger (me; param: CString; val: out Integer) returns Boolean;
GetBoolean (me; param: CString; val: out Boolean) returns Boolean;
GetString (me; param: CString; val: out AsciiString from TCollection) returns Boolean;
---Purpose: Get value of parameter as being of specific type
-- Returns False if parameter is not defined or has a wrong type
RealVal (me; param: CString; def: Real ) returns Real;
IntegerVal (me; param: CString; def: Integer) returns Integer;
BooleanVal (me; param: CString; def: Boolean) returns Boolean;
StringVal (me; param: CString; def: CString) returns CString;
---Purpose: Get value of parameter as being of specific type
-- If parameter is not defined or does not have expected
-- type, returns default value as specified
SetMessenger (me: mutable; messenger: Messenger from Message);
---Purpose : Sets Messenger used for outputting messages.
Messenger (me) returns Messenger from Message;
---Purpose : Returns Messenger used for outputting messages.
SetTraceLevel (me: mutable; tracelev: Integer);
---Purpose : Sets trace level used for outputting messages
-- - 0: no trace at all
-- - 1: errors
-- - 2: errors and warnings
-- - 3: all messages
-- Default is 1 : Errors traced
TraceLevel (me) returns Integer;
---Purpose : Returns trace level used for outputting messages.
fields
myRC: Manager from Resource;
myScope: HSequenceOfHAsciiString from TColStd;
myMessenger: Messenger from Message;
myTraceLev : Integer;
end Context;

View File

@@ -0,0 +1,375 @@
// File: ShapeProcess_Context.cxx
// Created: Mon Aug 21 19:27:30 2000
// Author: Andrey BETENEV
// <abv@doomox.nnov.matra-dtv.fr>
#include <ShapeProcess_Context.ixx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <TCollection_HAsciiString.hxx>
#include <Message_Messenger.hxx>
#include <Message.hxx>
#include <sys/stat.h>
//=======================================================================
//function : ShapeProcess_Context
//purpose :
//=======================================================================
ShapeProcess_Context::ShapeProcess_Context()
{
myMessenger = Message::DefaultMessenger();
myTraceLev = 1;
}
//=======================================================================
//function : ShapeProcess_Context
//purpose :
//=======================================================================
ShapeProcess_Context::ShapeProcess_Context (const Standard_CString file,
const Standard_CString scope)
{
Init ( file, scope );
myMessenger = Message::DefaultMessenger();
myTraceLev = 1;
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
Standard_Boolean ShapeProcess_Context::Init (const Standard_CString file,
const Standard_CString scope)
{
myScope.Nullify();
myRC = LoadResourceManager ( file );
if ( scope && scope[0] ) {
SetScope ( scope );
}
return Standard_True; // myRC->Length() >0; NOT IMPLEMENTED
}
//=======================================================================
//function : LoadResourceManager
//purpose :
//=======================================================================
Handle(Resource_Manager) ShapeProcess_Context::LoadResourceManager (const Standard_CString file)
{
// Optimisation of loading resource file: file is load only once
// and reloaded only if file date has changed
static Handle(Resource_Manager) sRC;
static long mtime;
static TCollection_AsciiString name;
if ( ! sRC.IsNull() && ! name.IsEqual ( file ) ) sRC.Nullify();
if ( ! sRC.IsNull() ) {
struct stat buf;
if ( ! stat ( file, &buf ) && buf.st_mtime != mtime ) {
sRC.Nullify();
mtime = buf.st_mtime;
}
}
if ( sRC.IsNull() ) {
#ifdef DEB
cout << "Info: ShapeProcess_Context: Reload Resource_Manager: "
<< name.ToCString() << " -> " << file << endl;
#endif
sRC = new Resource_Manager ( file );
name = file;
}
return sRC;
}
//=======================================================================
//function : ResourceManager
//purpose :
//=======================================================================
const Handle(Resource_Manager) &ShapeProcess_Context::ResourceManager () const
{
return myRC;
}
//=======================================================================
//function : SetScope
//purpose :
//=======================================================================
void ShapeProcess_Context::SetScope (const Standard_CString scope)
{
if ( myScope.IsNull() ) myScope = new TColStd_HSequenceOfHAsciiString;
Handle(TCollection_HAsciiString) str;
if ( myScope->Length() >0 ) {
str = new TCollection_HAsciiString ( myScope->Value ( myScope->Length() ) );
str->AssignCat ( "." );
str->AssignCat ( scope );
}
else str = new TCollection_HAsciiString ( scope );
myScope->Append ( str );
}
//=======================================================================
//function : UnSetScope
//purpose :
//=======================================================================
void ShapeProcess_Context::UnSetScope ()
{
if ( ! myScope.IsNull() && myScope->Length() >0 )
myScope->Remove ( myScope->Length() );
}
//=======================================================================
//function : IsParamSet
//purpose :
//=======================================================================
static Handle(TCollection_HAsciiString) MakeName (const Handle(TColStd_HSequenceOfHAsciiString) &scope,
const Standard_CString param)
{
Handle(TCollection_HAsciiString) str;
if ( ! scope.IsNull() && scope->Length() >0 ) {
str = new TCollection_HAsciiString ( scope->Value ( scope->Length() )->String() );
str->AssignCat (".");
str->AssignCat ( param );
}
else str = new TCollection_HAsciiString ( param );
return str;
}
Standard_Boolean ShapeProcess_Context::IsParamSet (const Standard_CString param) const
{
return ! myRC.IsNull() && myRC->Find ( MakeName ( myScope, param )->ToCString() );
}
//=======================================================================
//function : GetString
//purpose :
//=======================================================================
Standard_Boolean ShapeProcess_Context::GetString (const Standard_CString param,
TCollection_AsciiString &str) const
{
if ( myRC.IsNull() ) return Standard_False;
Handle(TCollection_HAsciiString) pname = MakeName ( myScope, param );
if ( ! myRC->Find ( pname->ToCString() ) ) {
#ifdef DEB
cout << "Warning: ShapeProcess_Context::GetInteger(): Parameter " << pname->ToCString() << " is not defined" << endl;
#endif
return Standard_False;
}
str = myRC->Value ( pname->ToCString() );
return Standard_True;
}
//=======================================================================
//function : GetReal
//purpose :
//=======================================================================
Standard_Boolean ShapeProcess_Context::GetReal (const Standard_CString param,
Standard_Real &val) const
{
if ( myRC.IsNull() ) return Standard_False;
TCollection_AsciiString str;
if ( ! GetString ( param, str ) ) return Standard_False;
if ( str.IsRealValue() ) {
val = str.RealValue();
return Standard_True;
}
// if not real, try to treat as alias "&param"
str.LeftAdjust();
if ( str.Value(1) == '&' ) {
TCollection_AsciiString ref = str.Split ( 1 );
ref.LeftAdjust();
ref.RightAdjust();
if ( ! myRC->Find ( ref.ToCString() ) ) {
#ifdef DEB
cout << "Warning: ShapeProcess_Context::GetInteger(): Parameter " << ref.ToCString() << " is not defined" << endl;
#endif
return Standard_False;
}
str = myRC->Value ( ref.ToCString() );
if ( str.IsRealValue() ) {
val = str.RealValue();
return Standard_True;
}
}
#ifdef DEB
cout << "Warning: ShapeProcess_Context::GetInteger(): Parameter " << param << " is neither Real nor reference to Real";
#endif
return Standard_False;
}
//=======================================================================
//function : GetInteger
//purpose :
//=======================================================================
Standard_Boolean ShapeProcess_Context::GetInteger (const Standard_CString param,
Standard_Integer &val) const
{
if ( myRC.IsNull() ) return Standard_False;
TCollection_AsciiString str;
if ( ! GetString ( param, str ) ) return Standard_False;
if ( str.IsIntegerValue() ) {
val = str.IntegerValue();
return Standard_True;
}
// if not integer, try to treat as alias "&param"
str.LeftAdjust();
if ( str.Value(1) == '&' ) {
TCollection_AsciiString ref = str.Split ( 1 );
ref.LeftAdjust();
ref.RightAdjust();
if ( ! myRC->Find ( ref.ToCString() ) ) {
#ifdef DEB
cout << "Warning: ShapeProcess_Context::GetInteger(): Parameter " << ref.ToCString() << " is not defined" << endl;
#endif
return Standard_False;
}
str = myRC->Value ( ref.ToCString() );
if ( str.IsIntegerValue() ) {
val = str.IntegerValue();
return Standard_True;
}
}
#ifdef DEB
cout << "Warning: ShapeProcess_Context::GetInteger(): Parameter " << param << " is neither Integer nor reference to Integer";
#endif
return Standard_False;
}
//=======================================================================
//function : GetBoolean
//purpose :
//=======================================================================
Standard_Boolean ShapeProcess_Context::GetBoolean (const Standard_CString param,
Standard_Boolean &val) const
{
if ( myRC.IsNull() ) return Standard_False;
try {
OCC_CATCH_SIGNALS
val = (Standard_Boolean)myRC->Integer ( MakeName ( myScope, param )->ToCString() );
return Standard_True;
}
catch (Standard_Failure) {
#ifdef DEB
cout << "Warning: ShapeProcess_Context::GetInteger(): " << param << ": ";
Standard_Failure::Caught()->Print(cout); cout << endl;
#endif
}
return Standard_False;
}
//=======================================================================
//function : RealVal
//purpose :
//=======================================================================
Standard_Real ShapeProcess_Context::RealVal (const Standard_CString param,
const Standard_Real def) const
{
Standard_Real val;
return GetReal ( param, val ) ? val : def;
}
//=======================================================================
//function : BooleanVal
//purpose :
//=======================================================================
Standard_Boolean ShapeProcess_Context::BooleanVal (const Standard_CString param,
const Standard_Boolean def) const
{
Standard_Boolean val;
return GetBoolean ( param, val ) ? val : def;
}
//=======================================================================
//function : IntegerVal
//purpose :
//=======================================================================
Standard_Integer ShapeProcess_Context::IntegerVal (const Standard_CString param,
const Standard_Integer def) const
{
Standard_Integer val;
return GetInteger ( param, val ) ? val : def;
}
//=======================================================================
//function : StringVal
//purpose :
//=======================================================================
Standard_CString ShapeProcess_Context::StringVal (const Standard_CString param,
const Standard_CString def) const
{
if ( myRC.IsNull() ) return def;
try {
OCC_CATCH_SIGNALS
return myRC->Value ( MakeName ( myScope, param )->ToCString() );
}
catch (Standard_Failure) {
#ifdef DEB
cout << "Warning: ShapeProcess_Context::GetInteger(): " << param << ": ";
Standard_Failure::Caught()->Print(cout); cout << endl;
#endif
}
return def;
}
//=======================================================================
//function : SetMessenger
//purpose :
//=======================================================================
void ShapeProcess_Context::SetMessenger (const Handle(Message_Messenger)& messenger)
{
if ( messenger.IsNull() )
myMessenger = Message::DefaultMessenger();
else
myMessenger = messenger;
}
//=======================================================================
//function : Messenger
//purpose :
//=======================================================================
Handle(Message_Messenger) ShapeProcess_Context::Messenger () const
{
return myMessenger;
}
//=======================================================================
//function : SetTraceLevel
//purpose :
//=======================================================================
void ShapeProcess_Context::SetTraceLevel (const Standard_Integer tracelev)
{
myTraceLev = tracelev;
}
//=======================================================================
//function : TraceLevel
//purpose :
//=======================================================================
Standard_Integer ShapeProcess_Context::TraceLevel () const
{
return myTraceLev;
}

View File

@@ -0,0 +1,20 @@
// File: ShapeProcess_OperFunc.cxx
// Created: Tue Aug 22 13:36:08 2000
// Author: data exchange team
// <det@doomox>
#include <ShapeProcess_OperFunc.hxx>
//=======================================================================
//function : MoniFrame_OperFunc_Type_
//purpose :
//=======================================================================
/*
Handle(Standard_Type)& STANDARD_TYPE(ShapeProcess_OperFunc)
{
static Handle(Standard_Type) _aType =
new Standard_Type("MoniFrame_OperFunc", sizeof(ShapeProcess_OperFunc), 0, NULL);
return _aType;
}
*/

View File

@@ -0,0 +1,17 @@
// File: ShapeProcess_OperFunc.hxx
// Created: Tue Feb 29 15:28:37 2000
// Author: data exchange team
// <det@kinox>
#ifndef ShapeProcess_OperFunc_HeaderFile
#define ShapeProcess_OperFunc_HeaderFile
#include <Standard_Type.hxx>
#include <Handle_ShapeProcess_Context.hxx>
typedef Standard_Boolean (*ShapeProcess_OperFunc) (const Handle(ShapeProcess_Context)& context);
//Standard_EXPORT Handle(Standard_Type)& STANDARD_TYPE(ShapeProcess_OperFunc);
#endif

View File

@@ -0,0 +1,50 @@
-- File: ShapeProcess_OperLibrary.cdl
-- Created: Thu Aug 31 11:34:18 2000
-- Author: Andrey BETENEV
-- <abv@nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2000
class OperLibrary from ShapeProcess
---Purpose: Provides a set of following operators
--
-- DirectFaces
-- FixShape
-- SameParameter
-- SetTolerance
-- SplitAngle
-- BSplineRestriction
-- ElementaryToRevolution
-- SurfaceToBSpline
-- ToBezier
-- SplitContinuity
-- SplitClosedFaces
-- FixWireGaps
-- FixFaceSize
-- DropSmallEdges
-- FixShape
-- SplitClosedEdges
uses
Shape from TopoDS,
UOperator from ShapeProcess,
ShapeContext from ShapeProcess,
Modification from BRepTools,
DataMapOfShapeShape from TopTools
is
Init (myclass);
---Purpose: Registers all the operators
ApplyModifier (myclass; S: Shape from TopoDS;
context: ShapeContext from ShapeProcess;
M: Modification from BRepTools;
map: in out DataMapOfShapeShape from TopTools)
---Purpose: Applies BRepTools_Modification to a shape,
-- taking into account sharing of components of compounds.
returns Shape from TopoDS;
end OperLibrary;

View File

@@ -0,0 +1,726 @@
// File: ShapeProcess_OperLibrary.cxx
// Created: Thu Aug 31 11:34:26 2000
// Author: Andrey BETENEV
// <abv@nnov.matra-dtv.fr>
#include <ShapeProcess_OperLibrary.ixx>
#include <Precision.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
#include <BRep_Builder.hxx>
#include <BRepLib.hxx>
#include <Message_MsgFile.hxx>
#include <ShapeExtend_MsgRegistrator.hxx>
#include <ShapeProcess.hxx>
#include <ShapeProcess_UOperator.hxx>
#include <ShapeProcess_ShapeContext.hxx>
#include <BRepTools_Modifier.hxx>
#include <BRepTools_Modification.hxx>
#include <ShapeCustom_DirectModification.hxx>
#include <ShapeCustom_RestrictionParameters.hxx>
#include <ShapeCustom_BSplineRestriction.hxx>
#include <ShapeCustom_ConvertToRevolution.hxx>
#include <ShapeCustom_SweptToElementary.hxx>
#include <ShapeCustom_ConvertToBSpline.hxx>
#include <ShapeExtend.hxx>
#include <ShapeBuild_ReShape.hxx>
#include <ShapeUpgrade_ShapeDivideAngle.hxx>
#include <ShapeUpgrade_ShapeConvertToBezier.hxx>
#include <ShapeUpgrade_ShapeDivideContinuity.hxx>
#include <ShapeUpgrade_ShapeDivideClosed.hxx>
#include <ShapeUpgrade_ShapeDivideClosedEdges.hxx>
#include <ShapeFix_ShapeTolerance.hxx>
#include <ShapeFix_Shape.hxx>
#include <ShapeFix_Face.hxx>
#include <ShapeFix_Wire.hxx>
#include <ShapeFix_FixSmallFace.hxx>
#include <ShapeFix_Wireframe.hxx>
#include <ShapeFix.hxx>
#include <ShapeFix_SplitCommonVertex.hxx>
//=======================================================================
//function : ApplyModifier
//purpose : Applies BRepTools_Modification to a shape,
// taking into account sharing of components of compounds
//=======================================================================
TopoDS_Shape ShapeProcess_OperLibrary::ApplyModifier (const TopoDS_Shape &S,
const Handle(ShapeProcess_ShapeContext)& context,
const Handle(BRepTools_Modification) &M,
TopTools_DataMapOfShapeShape &map)
{
// protect against INTERNAL/EXTERNAL shapes
TopoDS_Shape SF = S.Oriented(TopAbs_FORWARD);
// Process COMPOUNDs separately in order to handle sharing in assemblies
if ( SF.ShapeType() == TopAbs_COMPOUND ) {
Standard_Boolean locModified = Standard_False;
TopoDS_Compound C;
BRep_Builder B;
B.MakeCompound ( C );
for ( TopoDS_Iterator it(SF); it.More(); it.Next() ) {
TopoDS_Shape shape = it.Value();
TopLoc_Location L = shape.Location(), nullLoc;
shape.Location ( nullLoc );
TopoDS_Shape res;
if(map.IsBound ( shape ))
res = map.Find ( shape ).Oriented ( shape.Orientation() );
else {
res = ApplyModifier (shape, context, M, map );
map.Bind ( shape, res );
}
if ( ! res.IsSame ( shape ) ) locModified = Standard_True;
res.Location ( L );
B.Add ( C, res );
}
if ( ! locModified ) return S;
map.Bind ( SF, C );
return C.Oriented ( S.Orientation() );
}
// Modify the shape
BRepTools_Modifier MD(SF,M);
context->RecordModification ( SF, MD );
return MD.ModifiedShape(SF).Oriented(S.Orientation());
}
//=======================================================================
//function : directfaces
//purpose :
//=======================================================================
static Standard_Boolean directfaces (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
Handle(ShapeCustom_DirectModification) DM = new ShapeCustom_DirectModification;
TopTools_DataMapOfShapeShape map;
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier ( ctx->Result(), ctx, DM, map );
ctx->RecordModification ( map );
ctx->SetResult ( res );
return 0;
}
//=======================================================================
//function : sameparam
//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!
return Standard_True;
}
//=======================================================================
//function : settol
//purpose :
//=======================================================================
static Standard_Boolean settol (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
Standard_Real val;
if ( ctx->IntegerVal ( "Mode", 0 ) >0 && ctx->GetReal ( "Value", val ) ) {
Standard_Real rat = ctx->RealVal ( "Ratio", 1. );
if ( rat >= 1 ) {
ShapeFix_ShapeTolerance SFST;
SFST.LimitTolerance (ctx->Result(), val/rat, val*rat);
}
}
BRepLib::UpdateTolerances (ctx->Result(),Standard_True);
Standard_Real reg;
if ( ctx->GetReal ("Regularity", reg) )
BRepLib::EncodeRegularity (ctx->Result(), reg);
// WARNING: no update of context yet!
return Standard_True;
}
//=======================================================================
//function : splitangle
//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;
ShapeUpgrade_ShapeDivideAngle SDA ( ctx->RealVal ( "Angle", 2*PI ), ctx->Result() );
SDA.SetMaxTolerance ( ctx->RealVal ( "MaxTolerance", 1. ) );
if ( ! SDA.Perform() && SDA.Status (ShapeExtend_FAIL) ) {
#ifdef DEB
cout<<"ShapeDivideAngle failed"<<endl;
#endif
return Standard_False;
}
ctx->RecordModification ( SDA.GetContext() );
ctx->SetResult ( SDA.Result() );
return Standard_True;
}
//=======================================================================
//function : bsplinerestriction
//purpose :
//=======================================================================
static Standard_Boolean bsplinerestriction (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
Standard_Boolean ModeSurf = ctx->IntegerVal ( "SurfaceMode", Standard_True );
Standard_Boolean ModeC3d = ctx->IntegerVal ( "Curve3dMode", Standard_True );
Standard_Boolean ModeC2d = ctx->IntegerVal ( "Curve2dMode", Standard_True );
Standard_Real aTol3d = ctx->RealVal ( "Tolerance3d", 0.01 );
Standard_Real aTol2d = ctx->RealVal ( "Tolerance2d", 1e-06 );
GeomAbs_Shape aCont3d = ctx->ContinuityVal ( "Continuity3d", GeomAbs_C1 );
GeomAbs_Shape aCont2d = ctx->ContinuityVal ( "Continuity2d", GeomAbs_C2 );
Standard_Integer aMaxDeg = ctx->IntegerVal ( "RequiredDegree", 9 );
Standard_Integer aMaxSeg = ctx->IntegerVal ( "RequiredNbSegments", 10000 );
Standard_Boolean ModeDeg = ctx->IntegerVal ( "PreferDegree", Standard_True );
Standard_Boolean Rational = ctx->IntegerVal ( "RationalToPolynomial", Standard_False );
Handle(ShapeCustom_RestrictionParameters) aParameters = new ShapeCustom_RestrictionParameters;
ctx->GetInteger ( "MaxDegree", aParameters->GMaxDegree() );
ctx->GetInteger ( "MaxNbSegments", aParameters->GMaxSeg() );
ctx->GetBoolean ( "OffsetSurfaceMode", aParameters->ConvertOffsetSurf() );
ctx->GetBoolean ( "OffsetCurve3dMode", aParameters->ConvertOffsetCurv3d() );
ctx->GetBoolean ( "OffsetCurve2dMode", aParameters->ConvertOffsetCurv2d() );
ctx->GetBoolean ( "LinearExtrusionMode",aParameters->ConvertExtrusionSurf() );
ctx->GetBoolean ( "RevolutionMode", aParameters->ConvertRevolutionSurf() );
ctx->GetBoolean ( "SegmentSurfaceMode", aParameters->SegmentSurfaceMode() );
ctx->GetBoolean ( "ConvCurve3dMode", aParameters->ConvertCurve3d() );
ctx->GetBoolean ( "ConvCurve2dMode", aParameters->ConvertCurve2d() );
ctx->GetBoolean ( "BezierMode", aParameters->ConvertBezierSurf() );
//modes to convert elementary surfaces
ctx->GetBoolean ( "PlaneMode", aParameters->ConvertPlane() );
//ctx->GetBoolean ("ElementarySurfMode", aParameters->ConvertElementarySurf());
ctx->GetBoolean ( "ConicalSurfMode", aParameters->ConvertConicalSurf());
ctx->GetBoolean ( "CylindricalSurfMode", aParameters->ConvertCylindricalSurf());
ctx->GetBoolean ( "ToroidalSurfMode", aParameters->ConvertToroidalSurf());
ctx->GetBoolean ( "SphericalSurfMode", aParameters->ConvertSphericalSurf());
Handle(ShapeCustom_BSplineRestriction) LD =
new ShapeCustom_BSplineRestriction ( ModeSurf, ModeC3d, ModeC2d,
aTol3d, aTol2d, aCont3d, aCont2d,
aMaxDeg, aMaxSeg, ModeDeg, Rational, aParameters );
TopTools_DataMapOfShapeShape map;
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier ( ctx->Result(), ctx, LD, map );
ctx->RecordModification ( map );
ctx->SetResult ( res );
return Standard_True;
}
//=======================================================================
//function : torevol
//purpose :
//=======================================================================
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();
TopTools_DataMapOfShapeShape map;
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier ( ctx->Result(), ctx, CR, map );
ctx->RecordModification ( map );
ctx->SetResult ( res );
return Standard_True;
}
//=======================================================================
//function : swepttoelem
//purpose :
//=======================================================================
static Standard_Boolean swepttoelem (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
Handle(ShapeCustom_SweptToElementary) SE = new ShapeCustom_SweptToElementary();
TopTools_DataMapOfShapeShape map;
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier ( ctx->Result(), ctx, SE, map );
ctx->RecordModification ( map );
ctx->SetResult ( res );
return Standard_True;
}
//=======================================================================
//function : shapetobezier
//purpose :
//=======================================================================
static Standard_Boolean shapetobezier (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
Standard_Boolean ModeC3d = ctx->BooleanVal ( "Curve3dMode", Standard_False );
Standard_Boolean ModeC2d = ctx->BooleanVal ( "Curve2dMode", Standard_False );
Standard_Boolean ModeSurf = ctx->BooleanVal ( "SurfaceMode", Standard_False );
Standard_Boolean ModeLine3d = ctx->BooleanVal ( "Line3dMode", Standard_True );
Standard_Boolean ModeCircle3d = ctx->BooleanVal ( "Circle3dMode", Standard_True );
Standard_Boolean ModeConic3d = ctx->BooleanVal ( "Conic3dMode", Standard_True );
Standard_Boolean SegmentMode = ctx->BooleanVal ( "SegmentSurfaceMode", Standard_True );
Standard_Boolean PlaneMode = ctx->BooleanVal ( "PlaneMode", Standard_True );
Standard_Boolean RevolutionMode = ctx->BooleanVal ( "RevolutionMode", Standard_True );
Standard_Boolean ExtrusionMode = ctx->BooleanVal ( "ExtrusionMode", Standard_True );
Standard_Boolean BSplineMode = ctx->BooleanVal ( "BSplineMode", Standard_True );
ShapeUpgrade_ShapeConvertToBezier SCB (ctx->Result());
SCB.SetSurfaceSegmentMode(SegmentMode);
SCB.SetSurfaceConversion (ModeSurf);
SCB.Set2dConversion (ModeC2d);
SCB.Set3dConversion (ModeC3d);
if(ModeC3d) {
SCB.Set3dLineConversion (ModeLine3d);
SCB.Set3dCircleConversion (ModeCircle3d);
SCB.Set3dConicConversion (ModeConic3d);
}
if(ModeSurf) {
SCB.SetPlaneMode(PlaneMode);
SCB.SetRevolutionMode(RevolutionMode);
SCB.SetExtrusionMode(ExtrusionMode);
SCB.SetBSplineMode(BSplineMode);
}
Standard_Real maxTol, minTol;
if ( ctx->GetReal ( "MaxTolerance", maxTol ) ) SCB.SetMaxTolerance(maxTol);
if ( ctx->GetReal ( "MinCurveLength", minTol ) ) SCB.SetMinTolerance(minTol);
Standard_Boolean EdgeMode;
if ( ctx->GetBoolean ( "EdgeMode", EdgeMode ) ) SCB.SetEdgeMode(EdgeMode);
if ( ! SCB.Perform() && SCB.Status (ShapeExtend_FAIL) ) {
#ifdef DEB
cout<<"Shape::ShapeConvertToBezier failed"<<endl; // !!!!
#endif
return Standard_False;
}
ctx->RecordModification ( SCB.GetContext() );
ctx->SetResult ( SCB.Result() );
return Standard_True;
}
//=======================================================================
//function : converttobspline
//purpose :
//=======================================================================
static Standard_Boolean converttobspline (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
Standard_Boolean extrMode = ctx->BooleanVal ( "LinearExtrusionMode", Standard_True );
Standard_Boolean revolMode = ctx->BooleanVal ( "RevolutionMode", Standard_True );
Standard_Boolean offsetMode = ctx->BooleanVal ( "OffsetMode", Standard_True );
Handle(ShapeCustom_ConvertToBSpline) CBspl = new ShapeCustom_ConvertToBSpline();
CBspl->SetExtrusionMode(extrMode);
CBspl->SetRevolutionMode(revolMode);
CBspl->SetOffsetMode(offsetMode);
TopTools_DataMapOfShapeShape map;
TopoDS_Shape res = ShapeProcess_OperLibrary::ApplyModifier ( ctx->Result(), ctx, CBspl, map );
ctx->RecordModification ( map );
ctx->SetResult ( res );
return Standard_True;
}
//=======================================================================
//function : splitcontinuity
//purpose : Split by Continuity
//=======================================================================
static Standard_Boolean splitcontinuity (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
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 );
GeomAbs_Shape aSrfCont = ctx->ContinuityVal ( "SurfaceContinuity", GeomAbs_C1 );
GeomAbs_Shape aCrv2dCont = ctx->ContinuityVal ( "Curve2dContinuity", GeomAbs_C1 );
ShapeUpgrade_ShapeDivideContinuity tool (ctx->Result());
tool.SetBoundaryCriterion(aCrvCont);
tool.SetSurfaceCriterion(aSrfCont);
tool.SetPCurveCriterion(aCrv2dCont);
tool.SetTolerance(aTol);
tool.SetTolerance2d(aTol2D);
Standard_Real maxTol;
if ( ctx->GetReal ( "MaxTolerance", maxTol ) ) tool.SetMaxTolerance(maxTol);
if ( ! tool.Perform() && tool.Status (ShapeExtend_FAIL) ) {
#ifdef DEB
cout<<"SplitContinuity failed"<<endl;
#endif
return Standard_False;
}
ctx->RecordModification ( tool.GetContext() );
ctx->SetResult ( tool.Result() );
return Standard_True;
}
//=======================================================================
//function : splitclosedfaces
//purpose :
//=======================================================================
static Standard_Boolean splitclosedfaces (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
ShapeUpgrade_ShapeDivideClosed tool ( ctx->Result() );
Standard_Real closeTol;
if ( ctx->GetReal ( "CloseTolerance", closeTol ) ) tool.SetPrecision(closeTol);
Standard_Real maxTol;
if ( ctx->GetReal ( "MaxTolerance", maxTol ) ) tool.SetMaxTolerance(maxTol);
Standard_Integer num = ctx->IntegerVal ( "NbSplitPoints", 1 );
Standard_Boolean hasSeg = Standard_True;
ctx->GetBoolean ( "SegmentSurfaceMode", hasSeg);
tool.SetNbSplitPoints(num);
tool.SetSurfaceSegmentMode(hasSeg);
if ( ! tool.Perform() && tool.Status (ShapeExtend_FAIL) ) {
#ifdef DEB
cout<<"Splitting of closed faces failed"<<endl;
#endif
return Standard_False;
}
ctx->RecordModification ( tool.GetContext() );
ctx->SetResult ( tool.Result() );
return Standard_True;
}
//=======================================================================
//function : fixfacesize
//purpose :
//=======================================================================
static Standard_Boolean fixfacesize (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
Handle(ShapeBuild_ReShape) reshape = new ShapeBuild_ReShape;
ShapeFix_FixSmallFace FSC;
FSC.SetContext(reshape);
FSC.Init(ctx->Result());
Standard_Real aTol;
if ( ctx->GetReal ( "Tolerance", aTol ) ) FSC.SetPrecision (aTol);
FSC.Perform();
TopoDS_Shape newsh = FSC.Shape();
if ( newsh != ctx->Result() ) {
ctx->RecordModification ( reshape );
ctx->SetResult ( newsh );
}
return Standard_True;
}
//=======================================================================
//function : fixwgaps
//purpose :
//=======================================================================
static Standard_Boolean fixwgaps (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
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->SetContext(reshape);
sfwf->SetPrecision(aTol3d);
sfwf->FixWireGaps();
TopoDS_Shape result = sfwf->Shape();
if ( result != ctx->Result() ) {
ctx->RecordModification ( reshape );
ctx->SetResult ( result );
}
return Standard_True;
}
/*
//=======================================================================
//function :
//purpose :
//=======================================================================
static Standard_Boolean dropsmalledges (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
//Handle(ShapeBuild_ReShape) ctx = new ShapeBuild_ReShape;
Handle(MoniFrame_Element) elem = astep->Operand();
TopoDS_Shape Shape = MoniShape::Shape(elem);
Standard_Real aTol3d = Precision::Confusion();
Handle(MoniFrame_TypedValue) ptol3d = aproc->StackParam("Tolerance3d",Standard_True);
if (ptol3d->IsSetValue()) aTol3d = ptol3d->RealValue();
Handle(ShapeBuild_ReShape) context;
TopoDS_Shape result = ShapeFix::RemoveSmallEdges(Shape,aTol3d,context);
if (result == Shape) astep->AddTouched (aproc->Infos(),MoniShape::Element(Shape));
else
MoniShapeSW::UpdateFromReShape (aproc->Infos(), astep, Shape, context, TopAbs_FACE);
return 0;
}
*/
//=======================================================================
//function : mergesmalledges
//purpose :
//=======================================================================
static Standard_Boolean mergesmalledges (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
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);
if ( ShapeFixWireframe.FixSmallEdges() ) {
ctx->RecordModification ( reshape );
}
return Standard_True;
}
//=======================================================================
//function : fixshape
//purpose :
//=======================================================================
static Standard_Boolean fixshape (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(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->SetPrecision ( ctx->RealVal ( "Tolerance3d", Precision::Confusion() ) );
sfs->SetMinTolerance ( ctx->RealVal ( "MinTolerance3d", Precision::Confusion() ) );
sfs->SetMaxTolerance ( ctx->RealVal ( "MaxTolerance3d", Precision::Confusion() ) );
sfs->FixFreeShellMode() = ctx->IntegerVal ( "FixFreeShellMode", -1 );
sfs->FixFreeFaceMode() = ctx->IntegerVal ( "FixFreeFaceMode", -1 );
sfs->FixFreeWireMode() = ctx->IntegerVal ( "FixFreeWireMode", -1 );
sfs->FixSameParameterMode() = ctx->IntegerVal ( "FixSameParameterMode", -1 );
sfs->FixSolidMode() = ctx->IntegerVal ( "FixSolidMode", -1 );
sfs->FixVertexPositionMode() = ctx->IntegerVal ( "FixVertexPositionMode", 0 );
sfs->FixSolidTool()->FixShellMode() = ctx->IntegerVal ( "FixShellMode", -1 );
sfs->FixSolidTool()->CreateOpenSolidMode() = ctx->IntegerVal ( "CreateOpenSolidMode", 1 );
sfs->FixShellTool()->FixFaceMode() = ctx->IntegerVal ( "FixFaceMode", -1 );
//parameters for ShapeFix_Face
sff->FixWireMode() = ctx->IntegerVal ( "FixWireMode", -1 );
sff->FixOrientationMode() = ctx->IntegerVal ( "FixOrientationMode", -1 );
sff->FixAddNaturalBoundMode() = ctx->IntegerVal ( "FixAddNaturalBoundMode", -1 );
sff->FixMissingSeamMode() = ctx->IntegerVal ( "FixMissingSeamMode", -1 );
sff->FixSmallAreaWireMode() = ctx->IntegerVal ( "FixSmallAreaWireMode", -1 );
sff->FixIntersectingWiresMode() = ctx->IntegerVal ( "FixIntersectingWiresMode", -1 );
sff->FixLoopWiresMode() = ctx->IntegerVal ( "FixLoopWiresMode", -1 );
sff->FixSplitFaceMode() = ctx->IntegerVal ( "FixSplitFaceMode", -1 );
//parameters for ShapeFix_Wire
sfw->ModifyTopologyMode() = ctx->BooleanVal ( "ModifyTopologyMode", Standard_False );
sfw->ModifyGeometryMode() = ctx->BooleanVal ( "ModifyGeometryMode", Standard_True );
sfw->ClosedWireMode() = ctx->BooleanVal ( "ClosedWireMode", Standard_True );
sfw->PreferencePCurveMode() = ctx->BooleanVal ( "PreferencePCurveMode", Standard_True );
sfw->FixReorderMode() = ctx->IntegerVal ( "FixReorderMode", -1 );
sfw->FixSmallMode() = ctx->IntegerVal ( "FixSmallMode", -1 );
sfw->FixConnectedMode() = ctx->IntegerVal ( "FixConnectedMode", -1 );
sfw->FixEdgeCurvesMode() = ctx->IntegerVal ( "FixEdgeCurvesMode", -1 );
sfw->FixDegeneratedMode() = ctx->IntegerVal ( "FixDegeneratedMode", -1 );
sfw->FixLackingMode() = ctx->IntegerVal ( "FixLackingMode", -1 );
sfw->FixSelfIntersectionMode() = ctx->IntegerVal ( "FixSelfIntersectionMode", -1 );
sfw->ModifyRemoveLoopMode() = ctx->IntegerVal ( "RemoveLoopMode", -1);
sfw->FixReversed2dMode() = ctx->IntegerVal ( "FixReversed2dMode", -1 );
sfw->FixRemovePCurveMode() = ctx->IntegerVal ( "FixRemovePCurveMode", -1 );
sfw->FixRemoveCurve3dMode() = ctx->IntegerVal ( "FixRemoveCurve3dMode", -1 );
sfw->FixAddPCurveMode() = ctx->IntegerVal ( "FixAddPCurveMode", -1 );
sfw->FixAddCurve3dMode() = ctx->IntegerVal ( "FixAddCurve3dMode", -1 );
sfw->FixShiftedMode() = ctx->IntegerVal ( "FixShiftedMode", -1 );
sfw->FixSeamMode() = ctx->IntegerVal ( "FixSeamMode", -1 );
sfw->FixSameParameterMode() = ctx->IntegerVal ( "FixEdgeSameParameterMode", -1 );
sfw->FixNotchedEdgesMode() = ctx->IntegerVal ( "FixNotchedEdgesMode", -1 );
sfw->FixSelfIntersectingEdgeMode() = ctx->IntegerVal ( "FixSelfIntersectingEdgeMode", -1 );
sfw->FixIntersectingEdgesMode() = ctx->IntegerVal ( "FixIntersectingEdgesMode", -1 );
sfw->FixNonAdjacentIntersectingEdgesMode() = ctx->IntegerVal ( "FixNonAdjacentIntersectingEdgesMode", -1 );
sfs->Init(ctx->Result());
sfs->Perform();
TopoDS_Shape result = sfs->Shape();
if ( result != ctx->Result() ) {
ctx->RecordModification ( sfs->Context(), msg );
ctx->SetResult ( result );
}
return Standard_True;
}
//=======================================================================
//function : spltclosededges
//purpose :
//=======================================================================
static Standard_Boolean spltclosededges (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx =
Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
Standard_Integer nbSplits = ctx->IntegerVal ( "NbSplitPoints", 1 );
ShapeUpgrade_ShapeDivideClosedEdges tool (ctx->Result());
tool.SetNbSplitPoints(nbSplits);
if ( ! tool.Perform() && tool.Status (ShapeExtend_FAIL) ) {
#ifdef DEB
cout<<"Splitting of closed edges failed"<<endl;
#endif
return Standard_False;
}
ctx->RecordModification ( tool.GetContext() );
ctx->SetResult ( tool.Result() );
return Standard_True;
}
//=======================================================================
//function : splitcommonvertex
//purpose : Two wires have common vertex - this case is valid in BRep model
// and isn't valid in STEP => before writing into STEP it is necessary
// to split this vertex (each wire must has one vertex)
//=======================================================================
static Standard_Boolean splitcommonvertex (const Handle(ShapeProcess_Context)& context)
{
Handle(ShapeProcess_ShapeContext) ctx = Handle(ShapeProcess_ShapeContext)::DownCast ( context );
if ( ctx.IsNull() ) return Standard_False;
Handle(ShapeBuild_ReShape) reshape = new ShapeBuild_ReShape;
ShapeFix_SplitCommonVertex SCV;
SCV.SetContext(reshape);
SCV.Init(ctx->Result());
SCV.Perform();
TopoDS_Shape newsh = SCV.Shape();
if ( newsh != ctx->Result() ) {
ctx->RecordModification ( reshape );
ctx->SetResult ( newsh );
}
return Standard_True;
}
//=======================================================================
//function : Init
//purpose : Register standard operators
//=======================================================================
void ShapeProcess_OperLibrary::Init ()
{
static Standard_Boolean done = Standard_False;
if ( done ) return;
done = Standard_True;
ShapeExtend::Init();
// load message file for Shape Processing
Message_MsgFile::LoadFromEnv ("CSF_SHMessage", "SHAPE");
ShapeProcess::RegisterOperator ( "DirectFaces", new ShapeProcess_UOperator ( directfaces ) );
ShapeProcess::RegisterOperator ( "SameParameter", new ShapeProcess_UOperator ( sameparam ) );
ShapeProcess::RegisterOperator ( "SetTolerance", new ShapeProcess_UOperator ( settol ) );
ShapeProcess::RegisterOperator ( "SplitAngle", new ShapeProcess_UOperator ( splitangle ) );
ShapeProcess::RegisterOperator ( "BSplineRestriction", new ShapeProcess_UOperator ( bsplinerestriction ) );
ShapeProcess::RegisterOperator ( "ElementaryToRevolution",new ShapeProcess_UOperator ( torevol ) );
ShapeProcess::RegisterOperator ( "SweptToElementary", new ShapeProcess_UOperator ( swepttoelem ) );
ShapeProcess::RegisterOperator ( "SurfaceToBSpline", new ShapeProcess_UOperator ( converttobspline ) );
ShapeProcess::RegisterOperator ( "ToBezier", new ShapeProcess_UOperator ( shapetobezier ) );
ShapeProcess::RegisterOperator ( "SplitContinuity", new ShapeProcess_UOperator ( splitcontinuity ) );
ShapeProcess::RegisterOperator ( "SplitClosedFaces", new ShapeProcess_UOperator ( splitclosedfaces ) );
ShapeProcess::RegisterOperator ( "FixWireGaps", new ShapeProcess_UOperator ( fixwgaps ) );
ShapeProcess::RegisterOperator ( "FixFaceSize", new ShapeProcess_UOperator ( fixfacesize ) );
ShapeProcess::RegisterOperator ( "DropSmallEdges", new ShapeProcess_UOperator ( mergesmalledges ) );
ShapeProcess::RegisterOperator ( "FixShape", new ShapeProcess_UOperator ( fixshape ) );
ShapeProcess::RegisterOperator ( "SplitClosedEdges", new ShapeProcess_UOperator ( spltclosededges ) );
ShapeProcess::RegisterOperator ( "SplitCommonVertex", new ShapeProcess_UOperator ( splitcommonvertex ) );
}

View File

@@ -0,0 +1,24 @@
-- File: ShapeProcess_Operator.cdl
-- Created: Tue Aug 22 12:06:13 2000
-- Author: Andrey BETENEV
-- <abv@doomox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2000
deferred class Operator from ShapeProcess inherits TShared from MMgt
---Purpose: Abstract Operator class providing a tool to
-- perform an operation on Context
uses
Context from ShapeProcess
is
Perform (me: mutable; context: Context from ShapeProcess)
returns Boolean is deferred;
---Purpose: Performs operation and eventually records
-- changes in the context
end Operator;

View File

@@ -0,0 +1,6 @@
// File: ShapeProcess_Operator.cxx
// Created: Tue Aug 22 12:07:27 2000
// Author: Andrey BETENEV
// <abv@nnov.matra-dtv.fr>
#include <ShapeProcess_Operator.ixx>

View File

@@ -0,0 +1,125 @@
-- File: ShapeProcess_ShapeContext.cdl
-- Created: Tue Aug 22 12:34:17 2000
-- Author: Andrey BETENEV
-- <abv@nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2000
class ShapeContext from ShapeProcess inherits Context from ShapeProcess
---Purpose: Extends Context to handle shapes
-- Contains map of shape-shape, and messages
-- attached to shapes
uses
Shape from GeomAbs,
Shape from TopoDS,
ShapeEnum from TopAbs,
DataMapOfShapeShape from TopTools,
Modifier from BRepTools,
ReShape from ShapeBuild,
Msg from Message,
Gravity from Message,
MsgRegistrator from ShapeExtend,
Printer from Message
is
Create (file: CString; seq: CString = "");
Create (S: Shape from TopoDS; file: CString; seq: CString = "");
---Purpose: Initializes a tool by resource file and shape
-- to be processed
Init (me: mutable; S: Shape from TopoDS);
---Purpose: Initializes tool by a new shape and clears all results
Shape (me) returns Shape from TopoDS;
---Purpose: Returns shape being processed
---C++: return const &
Result (me) returns Shape from TopoDS;
---Purpose: Returns current result
---C++: return const &
Map (me) returns DataMapOfShapeShape from TopTools;
---Purpose: Returns map of replacements shape -> shape
-- This map is not recursive
---C++: return const &
Messages (me) returns MsgRegistrator from ShapeExtend;
---C++: return const &
Messages (me: mutable) returns MsgRegistrator from ShapeExtend;
---C++: return &
---Purpose: Returns messages recorded during shape processing
-- It can be nullified before processing in order to
-- avoid recording messages
SetDetalisation (me: mutable; level: ShapeEnum from TopAbs);
GetDetalisation (me) returns ShapeEnum from TopAbs;
---Purpose: Set and get value for detalisation level
-- Only shapes of types from TopoDS_COMPOUND and until
-- specified detalisation level will be recorded in maps
-- To cancel mapping, use TopAbs_SHAPE
-- To force full mapping, use TopAbs_VERTEX
-- The default level is TopAbs_FACE
SetResult (me: mutable; S: Shape from TopoDS);
---Purpose: Sets a new result shape
-- NOTE: this method should be used very carefully
-- to keep consistency of modifications
-- It is recommended to use RecordModification() methods
-- with explicit definition of mapping from current
-- result to a new one
RecordModification (me: mutable; repl: DataMapOfShapeShape from TopTools);
RecordModification (me: mutable; repl: ReShape from ShapeBuild;
msg : MsgRegistrator from ShapeExtend);
RecordModification (me: mutable; repl: ReShape from ShapeBuild);
RecordModification (me: mutable; sh : Shape from TopoDS;
repl: Modifier from BRepTools);
---Purpose: Records modifications and resets result accordingly
-- NOTE: modification of resulting shape should be explicitly
-- defined in the maps along with modifications of subshapes
--
-- In the last function, sh is the shape on which Modifier
-- was run. It can be different from the whole shape,
-- but in that case result as a whole should be reset later
-- either by call to SetResult(), or by another call to
-- RecordModification() which contains mapping of current
-- result to a new one explicitly
AddMessage (me: mutable; S: Shape from TopoDS; msg: Msg from Message;
gravity: Gravity from Message = Message_Warning);
---Purpose: Record a message for shape S
-- Shape S should be one of subshapes of original shape
-- (or whole one), but not one of intermediate shapes
-- Records only if Message() is not Null
GetContinuity (me; param: CString; val: out Shape from GeomAbs)
returns Boolean;
---Purpose: Get value of parameter as being of the type GeomAbs_Shape
-- Returns False if parameter is not defined or has a wrong type
ContinuityVal (me; param: CString; def: Shape from GeomAbs)
returns Shape from GeomAbs;
---Purpose: Get value of parameter as being of the type GeomAbs_Shape
-- If parameter is not defined or does not have expected
-- type, returns default value as specified
PrintStatistics (me);
---Purpose: Prints statistics on Shape Processing onto the current Messenger.
---Remark: At the moment outputs information only on shells and faces.
fields
myShape : Shape from TopoDS;
myResult: Shape from TopoDS;
myMap : DataMapOfShapeShape from TopTools;
myMsg : MsgRegistrator from ShapeExtend;
myUntil : ShapeEnum from TopAbs;
end ShapeContext;

View File

@@ -0,0 +1,447 @@
// File: ShapeProcess_ShapeContext.cxx
// Created: Tue Aug 22 12:56:45 2000
// Author: Andrey BETENEV
// <abv@nnov.matra-dtv.fr>
#include <ShapeProcess_ShapeContext.ixx>
#include <TCollection_AsciiString.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
#include <BRep_Builder.hxx>
#include <Message_Msg.hxx>
#include <Message_Messenger.hxx>
#include <Message_ListOfMsg.hxx>
#include <Message_ListIteratorOfListOfMsg.hxx>
#include <ShapeExtend_MsgRegistrator.hxx>
#include <ShapeExtend_DataMapOfShapeListOfMsg.hxx>
//=======================================================================
//function : ShapeProcess_ShapeContext
//purpose :
//=======================================================================
ShapeProcess_ShapeContext::ShapeProcess_ShapeContext (const Standard_CString file,
const Standard_CString seq)
: ShapeProcess_Context ( file, seq ), myUntil(TopAbs_FACE)
{
}
//=======================================================================
//function : ShapeProcess_ShapeContext
//purpose :
//=======================================================================
ShapeProcess_ShapeContext::ShapeProcess_ShapeContext (const TopoDS_Shape &S,
const Standard_CString file,
const Standard_CString seq)
: ShapeProcess_Context ( file, seq ), myUntil(TopAbs_FACE)
{
Init ( S );
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void ShapeProcess_ShapeContext::Init (const TopoDS_Shape &S)
{
myMap.Clear();
myMsg = new ShapeExtend_MsgRegistrator;
myShape = S;
myResult = myShape;//.Nullify();
}
//=======================================================================
//function : Shape
//purpose :
//=======================================================================
const TopoDS_Shape &ShapeProcess_ShapeContext::Shape () const
{
return myShape;
}
//=======================================================================
//function : Result
//purpose :
//=======================================================================
const TopoDS_Shape &ShapeProcess_ShapeContext::Result () const
{
return myResult;
}
//=======================================================================
//function : Map
//purpose :
//=======================================================================
const TopTools_DataMapOfShapeShape &ShapeProcess_ShapeContext::Map () const
{
return myMap;
}
//=======================================================================
//function : Messages
//purpose :
//=======================================================================
Handle(ShapeExtend_MsgRegistrator) &ShapeProcess_ShapeContext::Messages ()
{
return myMsg;
}
//=======================================================================
//function : Messages
//purpose :
//=======================================================================
const Handle(ShapeExtend_MsgRegistrator) &ShapeProcess_ShapeContext::Messages () const
{
return myMsg;
}
//=======================================================================
//function : SetDetalisation
//purpose :
//=======================================================================
void ShapeProcess_ShapeContext::SetDetalisation (const TopAbs_ShapeEnum level)
{
myUntil = level;
}
//=======================================================================
//function : GetDetalisation
//purpose :
//=======================================================================
TopAbs_ShapeEnum ShapeProcess_ShapeContext::GetDetalisation () const
{
return myUntil;
}
//=======================================================================
//function : SetResult
//purpose :
//=======================================================================
void ShapeProcess_ShapeContext::SetResult (const TopoDS_Shape &res)
{
myResult = res;
myMap.Bind ( myShape, myResult );
}
//=======================================================================
//function : RecordModification
//purpose :
//=======================================================================
/*
#ifdef DEB
static void DumpMap (const TopTools_DataMapOfShapeShape &map)
{
cout << "----" << endl;
cout << "Map:" << endl;
for (TopTools_DataMapIteratorOfDataMapOfShapeShape It (map); It.More(); It.Next()) {
TopoDS_Shape S0 = It.Key(), S = It.Value();
cout << S0.TShape()->DynamicType()->Name() << "\t" << *(void**)&S0.TShape() <<
" \t-> " << S.TShape()->DynamicType()->Name() << "\t" << *(void**)&S.TShape() << endl;
}
cout << "----" << endl;
}
#endif
*/
static void RecModif (const TopoDS_Shape &S,
const TopTools_DataMapOfShapeShape &repl,
TopTools_DataMapOfShapeShape &map,
const TopAbs_ShapeEnum until)
{
TopoDS_Shape r = S;
//gka -modification to keep history for shape with location (OCC21617)
TopLoc_Location aShLoc = S.Location();
TopLoc_Location aNullLoc;
r.Location(aNullLoc);
if ( map.IsBound ( r ) )
r = map.Find ( r );
if ( ! r.IsNull() ) {
TopoDS_Shape res = r;
if ( repl.IsBound ( r.Located(aShLoc) ) ) {
res = repl.Find ( r.Located(aShLoc) );
// it is supposed that map is created for r having FORWARD orientation
// hence, if it is reversed, result should be reversed too
// INTERNAL or EXTERNAL orientations are not allowed
if ( r.Orientation() != TopAbs_FORWARD )
res.Reverse();
}
// Treat special case: if S was split, r will be a compound of
// resulting shapes, each to be checked separately
// It is supposed that repl does not contain such splitting
else if ( r.ShapeType() < S.ShapeType() ) {
TopoDS_Shape result = r.EmptyCopied();
result.Orientation(TopAbs_FORWARD); // protect against INTERNAL or EXTERNAL shapes
Standard_Boolean modif = Standard_False;
BRep_Builder B;
for ( TopoDS_Iterator it(r,Standard_False); it.More(); it.Next() ) {
TopoDS_Shape sh = it.Value();
if ( repl.IsBound(sh) ) {
TopoDS_Shape newsh = repl.Find(sh);
if ( ! newsh.IsNull() ) B.Add ( result, newsh );
modif = Standard_True;
}
else B.Add ( result, sh );
}
if ( modif ) res = result;
}
if ( res != r ) map.Bind ( S.Located(aNullLoc), res );
}
if ( until == TopAbs_SHAPE || S.ShapeType() >= until ) return;
for ( TopoDS_Iterator it(S); it.More(); it.Next() ) {
RecModif ( it.Value(), repl, map, until );
}
}
void ShapeProcess_ShapeContext::RecordModification (const TopTools_DataMapOfShapeShape &repl)
{
if ( repl.Extent() <=0 ) return;
RecModif ( myShape, repl, myMap, myUntil );
if ( myMap.IsBound(myShape) ) myResult = myMap.Find ( myShape );
#ifdef DEB
// cout << "Modifier: " << endl; DumpMap (myMap);
#endif
}
//=======================================================================
//function : RecordModification
//purpose :
//=======================================================================
static void RecModif (const TopoDS_Shape &S,
const Handle(ShapeBuild_ReShape) &repl,
const Handle(ShapeExtend_MsgRegistrator) &msg,
TopTools_DataMapOfShapeShape &map,
Handle(ShapeExtend_MsgRegistrator) &myMsg,
const TopAbs_ShapeEnum until)
{
if(S.IsNull())
return;
//gka -modification to keep history for shape with location (OCC21617)
TopLoc_Location aNullLoc;
TopoDS_Shape aS = S.Located(aNullLoc);
TopoDS_Shape r = aS;
if ( map.IsBound ( r ) )
r = map.Find ( r );
if ( ! r.IsNull() ) {
TopoDS_Shape res;
if ( repl->Status (r, res, Standard_True ) && res != r )
map.Bind ( aS, res );
// Treat special case: if S was split, r will be a compound of
// resulting shapes, recursive procedure should be applied
else if ( r.ShapeType() < S.ShapeType() ) {
res = repl->Apply ( r, (TopAbs_ShapeEnum)((Standard_Integer)S.ShapeType()+1) );
if ( res != r ) map.Bind ( aS, res );
}
}
// update messages (messages must be taken from each level in the substitution map)
if ( ! r.IsNull() && ! myMsg.IsNull() &&
! msg.IsNull() && msg->MapShape().Extent() >0 ) {
TopoDS_Shape cur, next = r;
const ShapeExtend_DataMapOfShapeListOfMsg& msgmap = msg->MapShape();
do {
cur = next;
if (msgmap.IsBound (cur)) {
const Message_ListOfMsg &msglist = msgmap.Find (cur);
for (Message_ListIteratorOfListOfMsg iter (msglist); iter.More(); iter.Next()) {
myMsg->Send ( S, iter.Value(), Message_Warning );
}
}
next = repl->Value (cur);
} while ( ! next.IsNull() && cur != next);
}
if ( until == TopAbs_SHAPE || S.ShapeType() >= until ) return;
for ( TopoDS_Iterator it(S,Standard_False,Standard_False); it.More(); it.Next() ) {
RecModif ( it.Value(), repl, msg, map, myMsg, until );
}
}
void ShapeProcess_ShapeContext::RecordModification (const Handle(ShapeBuild_ReShape) &repl,
const Handle(ShapeExtend_MsgRegistrator) &msg)
{
RecModif ( myShape, repl, msg, myMap, myMsg, myUntil );
if ( myMap.IsBound(myShape) )
{
myResult = myMap.Find ( myShape );
myResult.Location(myShape.Location());
}
#ifdef DEB
// cout << "ReShape: " << endl; DumpMap (myMap);
#endif
}
//=======================================================================
//function : RecordModification
//purpose :
//=======================================================================
void ShapeProcess_ShapeContext::RecordModification (const Handle(ShapeBuild_ReShape) &repl)
{
Handle(ShapeExtend_MsgRegistrator) msg;
RecordModification ( repl, msg );
}
//=======================================================================
//function : AddMessage
//purpose :
//=======================================================================
void ShapeProcess_ShapeContext::AddMessage (const TopoDS_Shape &S,
const Message_Msg &msg,
const Message_Gravity grv)
{
if ( ! myMsg.IsNull() ) myMsg->Send ( S, msg, grv );
}
//=======================================================================
//function : RecordModification
//purpose :
//=======================================================================
static void ExplodeModifier (const TopoDS_Shape &S,
const BRepTools_Modifier &repl,
TopTools_DataMapOfShapeShape &map,
const TopAbs_ShapeEnum until)
{
TopoDS_Shape res = repl.ModifiedShape ( S );
if ( res != S )
{
map.Bind ( S, res );
}
if ( until == TopAbs_SHAPE || S.ShapeType() >= until ) return;
for ( TopoDS_Iterator it(S); it.More(); it.Next() ) {
ExplodeModifier ( it.Value(), repl, map, until );
}
}
void ShapeProcess_ShapeContext::RecordModification (const TopoDS_Shape &S,
const BRepTools_Modifier &repl)
{
TopTools_DataMapOfShapeShape map;
ExplodeModifier ( S, repl, map, myUntil );
RecordModification ( map );
}
//=======================================================================
//function : GetContinuity
//purpose :
//=======================================================================
Standard_Boolean ShapeProcess_ShapeContext::GetContinuity (const Standard_CString param,
GeomAbs_Shape &cont) const
{
TCollection_AsciiString str;
if ( ! GetString ( param, str ) ) return Standard_False;
str.LeftAdjust();
str.RightAdjust();
str.UpperCase();
if ( str.IsEqual ( "C0" ) ) cont = GeomAbs_C0;
else if ( str.IsEqual ( "G1" ) ) cont = GeomAbs_G1;
else if ( str.IsEqual ( "C1" ) ) cont = GeomAbs_C1;
else if ( str.IsEqual ( "G2" ) ) cont = GeomAbs_G2;
else if ( str.IsEqual ( "C2" ) ) cont = GeomAbs_C2;
else if ( str.IsEqual ( "C3" ) ) cont = GeomAbs_C3;
else if ( str.IsEqual ( "CN" ) ) cont = GeomAbs_CN;
else return Standard_False;
return Standard_True;
}
//=======================================================================
//function : ContinuityVal
//purpose :
//=======================================================================
GeomAbs_Shape ShapeProcess_ShapeContext::ContinuityVal (const Standard_CString param,
const GeomAbs_Shape def) const
{
GeomAbs_Shape val;
return GetContinuity ( param, val ) ? val : def;
}
//=======================================================================
//function : PrintStatistics
//purpose :
//=======================================================================
void ShapeProcess_ShapeContext::PrintStatistics () const
{
Standard_Integer SS = 0, SN = 0, FF = 0, FS = 0, FN = 0;
for (TopTools_DataMapIteratorOfDataMapOfShapeShape It (myMap); It.More(); It.Next()) {
TopoDS_Shape keyshape = It.Key(), valueshape = It.Value();
if (keyshape.ShapeType() == TopAbs_SHELL)
if (valueshape.IsNull()) SN++;
else SS++;
else if (keyshape.ShapeType() == TopAbs_FACE)
if (valueshape.IsNull()) FN++;
else if (valueshape.ShapeType() == TopAbs_SHELL) FS++;
else FF++;
}
// mapping
Message_Msg EPMSG100 ("PrResult.Print.MSG100"); //Mapping:
Messenger()->Send (EPMSG100, Message_Info);
Message_Msg TPMSG50 ("PrResult.Print.MSG50"); // Shells:
Messenger()->Send (TPMSG50, Message_Info);
Message_Msg EPMSG110 ("PrResult.Print.MSG110"); // Result is Shell : %d
EPMSG110.Arg (SS);
Messenger()->Send (EPMSG110, Message_Info);
Message_Msg EPMSG150 ("PrResult.Print.MSG150"); // No Result : %d
EPMSG150.Arg (SN);
Messenger()->Send (EPMSG150.Get(), Message_Info);
TCollection_AsciiString tmp110 (EPMSG110.Original()), tmp150 (EPMSG150.Original());
EPMSG110.Set (tmp110.ToCString());
EPMSG150.Set (tmp150.ToCString());
Message_Msg TPMSG55 ("PrResult.Print.MSG55"); // Faces:
Messenger()->Send (TPMSG55, Message_Info);
Message_Msg EPMSG115 ("PrResult.Print.MSG115"); // Result is Face : %d
EPMSG115.Arg (FF);
Messenger()->Send (EPMSG115, Message_Info);
EPMSG110.Arg (FS);
Messenger()->Send (EPMSG110, Message_Info);
EPMSG150.Arg (FN);
Messenger()->Send (EPMSG150, Message_Info);
// preparation ratio
Standard_Real SPR = 1, FPR = 1;
Standard_Integer STotalR = SS, FTotalR = FF + FS;
Standard_Integer NbS = STotalR + SN, NbF = FTotalR + FN;
if (NbS > 0) SPR = 1. * (NbS - SN) / NbS;
if (NbF > 0) FPR = 1. * (NbF - FN) / NbF;
Message_Msg PMSG200 ("PrResult.Print.MSG200"); //Preparation ratio:
Messenger()->Send (PMSG200, Message_Info);
Message_Msg PMSG205 ("PrResult.Print.MSG205"); // Shells: %d per cent
PMSG205.Arg ((Standard_Integer) (100. * SPR));
Messenger()->Send (PMSG205, Message_Info);
Message_Msg PMSG210 ("PrResult.Print.MSG210"); // Faces : %d per cent
PMSG210.Arg ((Standard_Integer) (100. * FPR));
Messenger()->Send (PMSG210, Message_Info);
}

View File

@@ -0,0 +1,33 @@
-- File: ShapeProcess_UOperator.cdl
-- Created: Tue Aug 22 12:06:13 2000
-- Author: Andrey BETENEV
-- <abv@nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2000
class UOperator from ShapeProcess inherits Operator from ShapeProcess
---Purpose: Defines operator as container for static function
-- OperFunc. This allows user to create new operators
-- without creation of new classes
uses
OperFunc from ShapeProcess,
Context from ShapeProcess
is
Create (func: OperFunc from ShapeProcess);
---Purpose: Creates operator with implementation defined as
-- OperFunc (static function)
Perform (me: mutable; context: Context from ShapeProcess)
returns Boolean is redefined;
---Purpose: Performs operation and records changes in the context
fields
myFunc: OperFunc from ShapeProcess;
end UOperator;

View File

@@ -0,0 +1,25 @@
// File: ShapeProcess_UOperator.cxx
// Created: Tue Aug 22 13:29:08 2000
// Author: Andrey BETENEV
// <abv@nnov.matra-dtv.fr>
#include <ShapeProcess_UOperator.ixx>
//=======================================================================
//function : ShapeProcess_UOperator
//purpose :
//=======================================================================
ShapeProcess_UOperator::ShapeProcess_UOperator (const ShapeProcess_OperFunc func) : myFunc(func)
{
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
Standard_Boolean ShapeProcess_UOperator::Perform (const Handle(ShapeProcess_Context)& context)
{
return myFunc ( context );
}