1 // File: ShapeProcessAPI_ApplySequence.cxx
2 // Created: Tue Jun 22 11:41:11 1999
3 // Author: data exchange team
7 #include <ShapeProcessAPI_ApplySequence.ixx>
8 #include <TCollection_AsciiString.hxx>
9 #include <TopoDS_Iterator.hxx>
10 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
11 #include <Message_Messenger.hxx>
12 #include <Message_Msg.hxx>
13 #include <Resource_Manager.hxx>
14 #include <ShapeProcess.hxx>
15 #include <ShapeProcess_OperLibrary.hxx>
17 //=======================================================================
18 //function : ShapeProcessAPI_ApplySequence
20 //=======================================================================
22 ShapeProcessAPI_ApplySequence::ShapeProcessAPI_ApplySequence(const Standard_CString rscName,
23 const Standard_CString seqName)
26 myContext = new ShapeProcess_ShapeContext(rscName);
27 myContext->SetDetalisation ( TopAbs_FACE );
28 TCollection_AsciiString str ( seqName );
30 // initialize operators
31 ShapeProcess_OperLibrary::Init ();
36 //=======================================================================
39 //=======================================================================
41 Handle(ShapeProcess_ShapeContext)& ShapeProcessAPI_ApplySequence::Context()
46 //=======================================================================
47 //function : PrepareShape
49 //=======================================================================
51 TopoDS_Shape ShapeProcessAPI_ApplySequence::PrepareShape(const TopoDS_Shape& shape,
52 const Standard_Boolean /*fillmap*/,
53 const TopAbs_ShapeEnum /*until*/)
55 Handle(Resource_Manager) rsc = myContext->ResourceManager();
56 myContext->Init(shape);
58 TCollection_AsciiString str(mySeq);
60 if ( rsc->Find ( str.ToCString() ) ) {
61 ShapeProcess::Perform ( myContext, mySeq.ToCString() );
64 return myContext->Result();
67 //=======================================================================
70 //=======================================================================
72 void ShapeProcessAPI_ApplySequence::ClearMap()
74 //myContext->Map().Clear();
77 //=======================================================================
80 //=======================================================================
82 const TopTools_DataMapOfShapeShape& ShapeProcessAPI_ApplySequence::Map() const
84 return myContext->Map();
87 //=======================================================================
88 //function : PrintPreparationResult
90 //=======================================================================
92 void ShapeProcessAPI_ApplySequence::PrintPreparationResult () const
94 Standard_Integer SS = 0, SN = 0, FF = 0, FS = 0, FN = 0;
95 for (TopTools_DataMapIteratorOfDataMapOfShapeShape It (myContext->Map()); It.More(); It.Next()) {
96 TopoDS_Shape keyshape = It.Key(), valueshape = It.Value();
97 if (keyshape.ShapeType() == TopAbs_SHELL)
98 if (valueshape.IsNull()) SN++;
100 else if (keyshape.ShapeType() == TopAbs_FACE)
101 if (valueshape.IsNull()) FN++;
102 else if (valueshape.ShapeType() == TopAbs_SHELL) FS++;
106 Handle(Message_Messenger) aMessenger = myContext->Messenger();
109 Message_Msg EPMSG100 ("PrResult.Print.MSG100"); //Mapping:
110 aMessenger->Send (EPMSG100, Message_Info, Standard_True);
111 Message_Msg TPMSG50 ("PrResult.Print.MSG50"); // Shells:
112 aMessenger->Send (TPMSG50, Message_Info, Standard_True);
113 Message_Msg EPMSG110 ("PrResult.Print.MSG110"); // Result is Shell : %d
115 aMessenger->Send (EPMSG110, Message_Info, Standard_True);
116 Message_Msg EPMSG150 ("PrResult.Print.MSG150"); // No Result : %d
118 aMessenger->Send (EPMSG150, Message_Info, Standard_True);
120 TCollection_AsciiString tmp110 (EPMSG110.Original()), tmp150 (EPMSG150.Original());
121 EPMSG110.Set (tmp110.ToCString());
122 EPMSG150.Set (tmp150.ToCString());
124 Message_Msg TPMSG55 ("PrResult.Print.MSG55"); // Faces:
125 aMessenger->Send (TPMSG55, Message_Info, Standard_True);
126 Message_Msg EPMSG115 ("PrResult.Print.MSG115"); // Result is Face : %d
128 aMessenger->Send (EPMSG115, Message_Info, Standard_True);
130 aMessenger->Send (EPMSG110, Message_Info, Standard_True);
132 aMessenger->Send (EPMSG150, Message_Info, Standard_True);
135 Standard_Real SPR = 1, FPR = 1;
136 Standard_Integer STotalR = SS, FTotalR = FF + FS;
137 Standard_Integer NbS = STotalR + SN, NbF = FTotalR + FN;
138 if (NbS > 0) SPR = 1. * (NbS - SN) / NbS;
139 if (NbF > 0) FPR = 1. * (NbF - FN) / NbF;
140 Message_Msg PMSG200 ("PrResult.Print.MSG200"); //Preparation ratio:
141 aMessenger->Send (PMSG200, Message_Info, Standard_True);
142 Message_Msg PMSG205 ("PrResult.Print.MSG205"); // Shells: %d per cent
143 PMSG205.Arg ((Standard_Integer) (100 * SPR));
144 aMessenger->Send (PMSG205, Message_Info, Standard_True);
145 Message_Msg PMSG210 ("PrResult.Print.MSG210"); // Faces : %d per cent
146 PMSG210.Arg ((Standard_Integer) (100 * FPR));
147 aMessenger->Send (PMSG210, Message_Info, Standard_True);