1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : VISU_CutSegment_i.cc
23 // Author : Oleg UVAROV
26 #include "VISU_CutSegment_i.hh"
27 #include "VISU_Prs3dUtils.hh"
28 #include "VISU_Result_i.hh"
30 #include "VISU_Actor.h"
31 #include "VISU_CutSegmentPL.hxx"
32 #include "VISU_Convertor.hxx"
33 #include "VISU_PipeLineUtils.hxx"
35 #include "SUIT_ResourceMgr.h"
36 #include "SALOME_Event.h"
38 #include <vtkAppendPolyData.h>
41 static int MYDEBUG = 0;
43 static int MYDEBUG = 0;
48 //---------------------------------------------------------------
51 ::IsPossible(Result_i* theResult,
52 const std::string& theMeshName,
53 VISU::Entity theEntity,
54 const std::string& theFieldName,
55 CORBA::Long theTimeStampNumber,
56 bool theIsMemoryCheck)
58 return TSuperClass::IsPossible(theResult,
66 //---------------------------------------------------------------
67 int VISU::CutSegment_i::myNbPresent = 0;
69 //---------------------------------------------------------------
71 VISU::CutSegment_i::GenerateName()
73 return VISU::GenerateName("CutSegment",myNbPresent++);
76 //---------------------------------------------------------------
77 const string VISU::CutSegment_i::myComment = "CUTSEGMENT";
79 //---------------------------------------------------------------
84 return myComment.c_str();
87 //----------------------------------------------------------------------------
93 return "ICON_TREE_CUT_SEGMENT";
95 return "ICON_TREE_CUT_SEGMENT_GROUPS";
98 //---------------------------------------------------------------
100 CutSegment_i(EPublishInStudyMode thePublishInStudyMode) :
101 ColoredPrs3d_i(thePublishInStudyMode),
102 ScalarMap_i(thePublishInStudyMode),
103 CutLinesBase_i(thePublishInStudyMode),
108 //---------------------------------------------------------------
111 ::SameAs(const Prs3d_i* theOrigin)
113 TSuperClass::SameAs(theOrigin);
117 //---------------------------------------------------------------
120 ::Create(const std::string& theMeshName,
121 VISU::Entity theEntity,
122 const std::string& theFieldName,
123 CORBA::Long theTimeStampNumber)
125 return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
129 //---------------------------------------------------------------
132 ::Restore(SALOMEDS::SObject_ptr theSObject,
133 const Storable::TRestoringMap& theMap)
135 if(!TSuperClass::Restore(theSObject, theMap))
138 SetPoint1(VISU::Storable::FindValue(theMap,"myPoint1[0]").toDouble(),
139 VISU::Storable::FindValue(theMap,"myPoint1[1]").toDouble(),
140 VISU::Storable::FindValue(theMap,"myPoint1[2]").toDouble());
141 SetPoint2(VISU::Storable::FindValue(theMap,"myPoint2[0]").toDouble(),
142 VISU::Storable::FindValue(theMap,"myPoint2[1]").toDouble(),
143 VISU::Storable::FindValue(theMap,"myPoint2[2]").toDouble());
149 //---------------------------------------------------------------
152 ::ToStream(std::ostringstream& theStr)
154 TSuperClass::ToStream(theStr);
157 GetPoint1( aCoord[0], aCoord[1], aCoord[2] );
158 Storable::DataToStream( theStr, "myPoint1[0]", aCoord[0] );
159 Storable::DataToStream( theStr, "myPoint1[1]", aCoord[1] );
160 Storable::DataToStream( theStr, "myPoint1[2]", aCoord[2] );
162 GetPoint2( aCoord[0], aCoord[1], aCoord[2] );
163 Storable::DataToStream( theStr, "myPoint2[0]", aCoord[0] );
164 Storable::DataToStream( theStr, "myPoint2[1]", aCoord[1] );
165 Storable::DataToStream( theStr, "myPoint2[2]", aCoord[2] );
169 //---------------------------------------------------------------
173 if(MYDEBUG) MESSAGE("CutSegment_i::~CutSegment_i()");
177 //---------------------------------------------------------------
178 struct TSetPoint1Event: public SALOME_Event
180 VISU_CutSegmentPL* myCutSegmentPL;
181 CORBA::Double myX, myY, myZ;
182 TSetPoint1Event(VISU_CutSegmentPL* theCutSegment,
186 myCutSegmentPL(theCutSegment),
196 myCutSegmentPL->SetPoint1(myX, myY, myZ);
202 ::SetPoint1(CORBA::Double theX,
206 VISU::TSetModified aModified(this);
208 ProcessVoidEvent(new TSetPoint1Event(myCutSegmentPL, theX, theY, theZ));
212 //---------------------------------------------------------------
215 ::GetPoint1(CORBA::Double& theX,
219 myCutSegmentPL->GetPoint1(theX, theY, theZ);
223 //---------------------------------------------------------------
224 struct TSetPoint2Event: public SALOME_Event
226 VISU_CutSegmentPL* myCutSegmentPL;
227 CORBA::Double myX, myY, myZ;
228 TSetPoint2Event(VISU_CutSegmentPL* theCutSegment,
232 myCutSegmentPL(theCutSegment),
242 myCutSegmentPL->SetPoint2(myX, myY, myZ);
248 ::SetPoint2(CORBA::Double theX,
252 VISU::TSetModified aModified(this);
254 ProcessVoidEvent(new TSetPoint2Event(myCutSegmentPL, theX, theY, theZ));
258 //---------------------------------------------------------------
261 ::GetPoint2(CORBA::Double& theX,
265 myCutSegmentPL->GetPoint2(theX, theY, theZ);
269 //---------------------------------------------------------------
272 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
275 myCutSegmentPL = VISU_CutSegmentPL::New();
277 myCutSegmentPL = dynamic_cast<VISU_CutSegmentPL*>(thePipeLine);
279 TSuperClass::CreatePipeLine(myCutSegmentPL);
283 //----------------------------------------------------------------------------
288 return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
292 //---------------------------------------------------------------
297 if(VISU_Actor* anActor = TSuperClass::CreateActor()){
298 anActor->SetVTKMapping(true);
299 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
300 int aDispMode = aResourceMgr->integerValue("VISU", "cut_segment_represent", 2);
301 anActor->SetRepresentation(aDispMode);