1 // Created on: 1999-06-22
2 // Created by: data exchange team
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <ShapeProcessAPI_ApplySequence.ixx>
24 #include <TCollection_AsciiString.hxx>
25 #include <TopoDS_Iterator.hxx>
26 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
27 #include <Message_Messenger.hxx>
28 #include <Message_Msg.hxx>
29 #include <Resource_Manager.hxx>
30 #include <ShapeProcess.hxx>
31 #include <ShapeProcess_OperLibrary.hxx>
33 //=======================================================================
34 //function : ShapeProcessAPI_ApplySequence
36 //=======================================================================
38 ShapeProcessAPI_ApplySequence::ShapeProcessAPI_ApplySequence(const Standard_CString rscName,
39 const Standard_CString seqName)
42 myContext = new ShapeProcess_ShapeContext(rscName);
43 myContext->SetDetalisation ( TopAbs_FACE );
44 TCollection_AsciiString str ( seqName );
46 // initialize operators
47 ShapeProcess_OperLibrary::Init ();
52 //=======================================================================
55 //=======================================================================
57 Handle(ShapeProcess_ShapeContext)& ShapeProcessAPI_ApplySequence::Context()
62 //=======================================================================
63 //function : PrepareShape
65 //=======================================================================
67 TopoDS_Shape ShapeProcessAPI_ApplySequence::PrepareShape(const TopoDS_Shape& shape,
68 const Standard_Boolean /*fillmap*/,
69 const TopAbs_ShapeEnum /*until*/)
71 Handle(Resource_Manager) rsc = myContext->ResourceManager();
72 myContext->Init(shape);
74 TCollection_AsciiString str(mySeq);
76 if ( rsc->Find ( str.ToCString() ) ) {
77 ShapeProcess::Perform ( myContext, mySeq.ToCString() );
80 return myContext->Result();
83 //=======================================================================
86 //=======================================================================
88 void ShapeProcessAPI_ApplySequence::ClearMap()
90 //myContext->Map().Clear();
93 //=======================================================================
96 //=======================================================================
98 const TopTools_DataMapOfShapeShape& ShapeProcessAPI_ApplySequence::Map() const
100 return myContext->Map();
103 //=======================================================================
104 //function : PrintPreparationResult
106 //=======================================================================
108 void ShapeProcessAPI_ApplySequence::PrintPreparationResult () const
110 Standard_Integer SS = 0, SN = 0, FF = 0, FS = 0, FN = 0;
111 for (TopTools_DataMapIteratorOfDataMapOfShapeShape It (myContext->Map()); It.More(); It.Next()) {
112 TopoDS_Shape keyshape = It.Key(), valueshape = It.Value();
113 if (keyshape.ShapeType() == TopAbs_SHELL)
114 if (valueshape.IsNull()) SN++;
116 else if (keyshape.ShapeType() == TopAbs_FACE)
117 if (valueshape.IsNull()) FN++;
118 else if (valueshape.ShapeType() == TopAbs_SHELL) FS++;
122 Handle(Message_Messenger) aMessenger = myContext->Messenger();
125 Message_Msg EPMSG100 ("PrResult.Print.MSG100"); //Mapping:
126 aMessenger->Send (EPMSG100, Message_Info, Standard_True);
127 Message_Msg TPMSG50 ("PrResult.Print.MSG50"); // Shells:
128 aMessenger->Send (TPMSG50, Message_Info, Standard_True);
129 Message_Msg EPMSG110 ("PrResult.Print.MSG110"); // Result is Shell : %d
131 aMessenger->Send (EPMSG110, Message_Info, Standard_True);
132 Message_Msg EPMSG150 ("PrResult.Print.MSG150"); // No Result : %d
134 aMessenger->Send (EPMSG150, Message_Info, Standard_True);
136 TCollection_AsciiString tmp110 (EPMSG110.Original()), tmp150 (EPMSG150.Original());
137 EPMSG110.Set (tmp110.ToCString());
138 EPMSG150.Set (tmp150.ToCString());
140 Message_Msg TPMSG55 ("PrResult.Print.MSG55"); // Faces:
141 aMessenger->Send (TPMSG55, Message_Info, Standard_True);
142 Message_Msg EPMSG115 ("PrResult.Print.MSG115"); // Result is Face : %d
144 aMessenger->Send (EPMSG115, Message_Info, Standard_True);
146 aMessenger->Send (EPMSG110, Message_Info, Standard_True);
148 aMessenger->Send (EPMSG150, Message_Info, Standard_True);
151 Standard_Real SPR = 1, FPR = 1;
152 Standard_Integer STotalR = SS, FTotalR = FF + FS;
153 Standard_Integer NbS = STotalR + SN, NbF = FTotalR + FN;
154 if (NbS > 0) SPR = 1. * (NbS - SN) / NbS;
155 if (NbF > 0) FPR = 1. * (NbF - FN) / NbF;
156 Message_Msg PMSG200 ("PrResult.Print.MSG200"); //Preparation ratio:
157 aMessenger->Send (PMSG200, Message_Info, Standard_True);
158 Message_Msg PMSG205 ("PrResult.Print.MSG205"); // Shells: %d per cent
159 PMSG205.Arg ((Standard_Integer) (100 * SPR));
160 aMessenger->Send (PMSG205, Message_Info, Standard_True);
161 Message_Msg PMSG210 ("PrResult.Print.MSG210"); // Faces : %d per cent
162 PMSG210.Arg ((Standard_Integer) (100 * FPR));
163 aMessenger->Send (PMSG210, Message_Info, Standard_True);