1 // File: ShHealOper_ShapeProcess.cxx
2 // Created: 14.04.04 10:58:04
3 // Author: Galina KULIKOVA
4 // < MODULE = KERNEL> <PACKAGE = ShHealOper> : <Shape Healing Operations>
5 // Copyright (C) 2003 CEA
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Lesser General Public
9 // License as published by the Free Software Foundation; either
10 // version 2.1 of the License.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <ShHealOper_ShapeProcess.hxx>
24 #include <ShapeProcessAPI_ApplySequence.hxx>
25 #include <ShapeProcess_Context.hxx>
26 #include <TCollection_AsciiString.hxx>
27 #include <Resource_Manager.hxx>
28 #include <TopoDS_Shape.hxx>
29 #include <TopAbs_ShapeEnum.hxx>
30 #include <TopTools_DataMapOfShapeShape.hxx>
31 #include <ShapeProcess_ShapeContext.hxx>
32 //=======================================================================
33 //function : ShHealOper_ShapeProcess()
34 //purpose : Constructor
35 //=======================================================================
37 ShHealOper_ShapeProcess::ShHealOper_ShapeProcess ( ) :
38 myOperations(TCollection_AsciiString("ShHealing").ToCString(),
39 TCollection_AsciiString("ShapeProcess").ToCString())
41 //myResource = new Resource_Manager("ShHealing");
42 myPrefix = "ShapeProcess";
43 mySaveHistoryMode = Standard_False;
44 myLevel = TopAbs_FACE;
45 myDone = Standard_False;
48 //=======================================================================
49 //function : ShHealOper_ShapeProcess
51 //=======================================================================
53 ShHealOper_ShapeProcess::ShHealOper_ShapeProcess (const TCollection_AsciiString& theNameResource,
54 const TCollection_AsciiString& thePrefix ) :
55 myOperations(theNameResource.ToCString(),thePrefix.ToCString())
57 //myResource = new Resource_Manager(theNameResource);
59 mySaveHistoryMode = Standard_False;
60 myLevel = TopAbs_FACE;
61 myDone = Standard_False;
64 //=======================================================================
67 //=======================================================================
68 void ShHealOper_ShapeProcess::Perform(const TopoDS_Shape& theOldShape,
69 TopoDS_Shape& theNewShape)
72 myMapModifications.Clear();
73 //ShapeProcessAPI_ApplySequence aOperations(myResource,myPrefix.ToCString());
74 //myDone = Standard_False;
75 myOperations.ClearMap();
77 theNewShape = myOperations.PrepareShape(theOldShape,mySaveHistoryMode,myLevel);
79 myMapModifications = myOperations.Map();
80 myDone = !theOldShape.IsSame(theNewShape);
82 //=======================================================================
83 //function : SetOperators
85 //=======================================================================
87 void ShHealOper_ShapeProcess::SetOperators(const TColStd_SequenceOfAsciiString& theSeqOperators)
90 TCollection_AsciiString anameParam(myPrefix);
92 anameParam += "exec.op";
93 TCollection_AsciiString aseq;
94 Standard_Integer i =1;
95 for( ; i <= theSeqOperators.Length(); i++) {
96 aseq += theSeqOperators.Value(i);
100 myOperations.Context()->ResourceManager()->SetResource(anameParam.ToCString(),aseq.ToCString());
102 //=======================================================================
103 //function : SetParameter
105 //=======================================================================
107 void ShHealOper_ShapeProcess::SetParameter(const TCollection_AsciiString& theNameParam,
108 const TCollection_AsciiString& theVal)
110 TCollection_AsciiString anameParam(myPrefix);
112 anameParam+= theNameParam;
113 if(theVal.IsIntegerValue())
114 myOperations.Context()->ResourceManager()->
115 SetResource(anameParam.ToCString(),theVal.IntegerValue());
116 else if(theVal.IsRealValue())
117 myOperations.Context()->ResourceManager()->
118 SetResource(anameParam.ToCString(),theVal.RealValue());
120 myOperations.Context()->ResourceManager()->
121 SetResource(anameParam.ToCString(),theVal.ToCString());
124 //=======================================================================
125 //function : GetOperators
127 //=======================================================================
129 Standard_Boolean ShHealOper_ShapeProcess::GetOperators(TColStd_SequenceOfAsciiString& theSeqOperators)
131 TCollection_AsciiString nameSeq(myPrefix);
132 nameSeq +=".exec.op";
133 if(!myOperations.Context()->ResourceManager()->Find(nameSeq.ToCString()))
134 return Standard_False;
136 TCollection_AsciiString seqoper = myOperations.Context()->ResourceManager()->Value(nameSeq.ToCString());
139 TCollection_AsciiString anOper = seqoper.Token ( " \t,;", i );
140 if ( anOper.Length() <=0 ) break;
141 theSeqOperators.Append(anOper);
143 return (theSeqOperators.Length());
145 //=======================================================================
146 //function : GetParameter
148 //=======================================================================
150 Standard_Boolean ShHealOper_ShapeProcess::GetParameter(const TCollection_AsciiString& theNameParam,
151 TCollection_AsciiString& theVal)
153 TCollection_AsciiString namePar(myPrefix);
155 namePar += theNameParam;
156 if(!myOperations.Context()->ResourceManager()->Find(namePar.ToCString()))
157 return Standard_False;
159 theVal = myOperations.Context()->ResourceManager()->Value(namePar.ToCString());
160 return Standard_True;