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 // VISU OBJECT : interactive object for VISU entities implementation
23 // File : VISU_PrsObject_i.cxx
24 // Author : Alexey PETROV
27 #include "VISU_CutLines_i.hh"
28 #include "VISU_Prs3dUtils.hh"
29 #include "VISU_Result_i.hh"
31 #include "VISU_Actor.h"
32 #include "VISU_CutLinesPL.hxx"
33 #include "VISU_Convertor.hxx"
34 #include "VISU_PipeLineUtils.hxx"
36 #include "SUIT_ResourceMgr.h"
37 #include "SALOME_Event.h"
39 #include <vtkAppendPolyData.h>
41 static vtkFloatingPointType EPS_machine = 1.0E-7;
44 static int MYDEBUG = 0;
46 static int MYDEBUG = 0;
51 //---------------------------------------------------------------
54 ::IsPossible(Result_i* theResult,
55 const std::string& theMeshName,
56 VISU::Entity theEntity,
57 const std::string& theFieldName,
58 CORBA::Long theTimeStampNumber,
59 bool theIsMemoryCheck)
61 return TSuperClass::IsPossible(theResult,
69 //---------------------------------------------------------------
70 int VISU::CutLines_i::myNbPresent = 0;
72 //---------------------------------------------------------------
74 VISU::CutLines_i::GenerateName()
76 return VISU::GenerateName("CutLines",myNbPresent++);
79 //---------------------------------------------------------------
80 const string VISU::CutLines_i::myComment = "CUTLINES";
82 //---------------------------------------------------------------
87 return myComment.c_str();
90 //----------------------------------------------------------------------------
96 return "ICON_TREE_CUT_LINES";
98 return "ICON_TREE_CUT_LINES_GROUPS";
101 //---------------------------------------------------------------
103 CutLines_i(EPublishInStudyMode thePublishInStudyMode) :
104 ColoredPrs3d_i(thePublishInStudyMode),
105 ScalarMap_i(thePublishInStudyMode),
106 myUseAbsLength( false ),
111 //---------------------------------------------------------------
114 ::SameAs(const Prs3d_i* theOrigin)
116 TSuperClass::SameAs(theOrigin);
118 if(const CutLines_i* aPrs3d = dynamic_cast<const CutLines_i*>(theOrigin)){
119 CutLines_i* anOrigin = const_cast<CutLines_i*>(aPrs3d);
120 myUseAbsLength = anOrigin->IsUseAbsoluteLength();
121 CopyCurvesInverted(anOrigin->GetCurvesInverted());
126 //---------------------------------------------------------------
127 /*! Copy map to /a myMapCurvesInverted.
128 * \param theCurves - map
132 ::CopyCurvesInverted(const TCurvesInv& theCurves)
134 myMapCurvesInverted = theCurves;
138 //---------------------------------------------------------------
141 ::Create(const std::string& theMeshName,
142 VISU::Entity theEntity,
143 const std::string& theFieldName,
144 CORBA::Long theTimeStampNumber)
146 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
147 SetUseAbsoluteLength( aResourceMgr->booleanValue( "VISU", "use_absolute_length", false ) );
148 SetAllCurvesInverted( aResourceMgr->booleanValue( "VISU", "invert_all_curves", false ) );
149 return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
153 //---------------------------------------------------------------
156 ::Restore(SALOMEDS::SObject_ptr theSObject,
157 const Storable::TRestoringMap& theMap)
159 if(!TSuperClass::Restore(theSObject, theMap))
162 SetNbLines(VISU::Storable::FindValue(theMap,"myNbLines").toInt());
163 SetDisplacement(VISU::Storable::FindValue(theMap,"myDisplacement[0]").toDouble());
164 SetDisplacement2(VISU::Storable::FindValue(theMap,"myDisplacement[1]").toDouble());
165 SetOrientation(CutPlanes::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane[0]").toInt()),
166 Storable::FindValue(theMap,"aRot[0][0]").toDouble(),
167 Storable::FindValue(theMap,"aRot[0][1]").toDouble());
168 SetOrientation2(CutPlanes::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane[1]").toInt()),
169 Storable::FindValue(theMap,"aRot[1][0]").toDouble(),
170 Storable::FindValue(theMap,"aRot[1][1]").toDouble());
171 SetUseAbsoluteLength(VISU::Storable::FindValue(theMap,"myUseAbsLength").toInt());
173 if (VISU::Storable::FindValue(theMap,"myBasePlaneCondition").toInt())
176 SetBasePlanePosition(VISU::Storable::FindValue(theMap,"myBasePlanePosition").toDouble());
178 QStringList aPosList = VISU::Storable::FindValue(theMap,"myLinePosition").split("|", QString::SkipEmptyParts );
179 QStringList aCondList = VISU::Storable::FindValue(theMap,"myLineCondition").split("|",QString::SkipEmptyParts );
180 for(int i = 0, iEnd = GetNbLines(); i < iEnd; i++)
181 if(aCondList[i].toInt() == 0)
182 SetLinePosition(i,aPosList[i].toDouble());
184 // Restoring the map - \a myMapCurvesInverted
185 QStringList aMapCurvesInverted = VISU::Storable::FindValue(theMap,"myMapCurvesInverted").split("|",QString::SkipEmptyParts );
186 if (aMapCurvesInverted.count() == GetNbLines()){
187 for(int i = 0, iEnd = GetNbLines(); i < iEnd ; i++){
188 if(aMapCurvesInverted[i].toInt())
189 SetCurveInverted(i,true);
191 SetCurveInverted(i,false);
194 for(int i = 0, iEnd = GetNbLines(); i < iEnd ; i++)
195 SetCurveInverted(i,false);
202 //---------------------------------------------------------------
205 ::ToStream(std::ostringstream& theStr)
207 TSuperClass::ToStream(theStr);
209 int aNbLines = GetNbLines();
211 Storable::DataToStream( theStr, "myNbLines", aNbLines );
212 Storable::DataToStream( theStr, "myDisplacement[0]", GetDisplacement() );
213 Storable::DataToStream( theStr, "myDisplacement[1]", GetDisplacement2() );
214 Storable::DataToStream( theStr, "myBasePlane[0]", int(GetOrientationType()) );
215 Storable::DataToStream( theStr, "myBasePlane[1]", int(GetOrientationType2()) );
216 Storable::DataToStream( theStr, "aRot[0][0]", GetRotateX() );
217 Storable::DataToStream( theStr, "aRot[0][1]", GetRotateY() );
218 Storable::DataToStream( theStr, "aRot[1][0]", GetRotateX2() );
219 Storable::DataToStream( theStr, "aRot[1][1]", GetRotateY2() );
220 Storable::DataToStream( theStr, "myBasePlanePosition", GetBasePlanePosition() );
221 Storable::DataToStream( theStr, "myBasePlaneCondition", IsDefault() );
223 QString aStrPos, aStrCon;
224 for(int i = 0, iEnd = GetNbLines(); i < iEnd; i++){
225 aStrPos.append(QString::number(GetLinePosition(i)) + "|");
226 aStrCon.append(QString::number(IsDefaultPosition(i)) + "|");
229 Storable::DataToStream( theStr, "myLinePosition", (const char*)aStrPos.toLatin1());
230 Storable::DataToStream( theStr, "myLineCondition", (const char*)aStrCon.toLatin1());
231 Storable::DataToStream( theStr,"myUseAbsLength", IsUseAbsoluteLength());
233 // Storing the map - \a myMapCurvesInverted
234 QString aStrCurvesInverted;
235 for(int i = 0, iEnd = GetNbLines(); i < iEnd; i++)
236 aStrCurvesInverted.append(QString::number(IsCurveInverted(i)) + "|");
237 Storable::DataToStream( theStr, "myMapCurvesInverted", (const char*)aStrCurvesInverted.toLatin1());
241 //---------------------------------------------------------------
245 if(MYDEBUG) MESSAGE("CutLines_i::~CutLines_i()");
249 //---------------------------------------------------------------
252 ::SetOrientation(VISU::CutPlanes::Orientation theOrient,
253 CORBA::Double theXAngle,
254 CORBA::Double theYAngle)
256 struct TEvent: public SALOME_Event
258 VISU_CutLinesPL* myCutLinesPL;
259 CORBA::Double myXAngle, myYAngle;
260 VISU::CutPlanes::Orientation myOrient;
261 TEvent(VISU_CutLinesPL* theCutLines,
262 VISU::CutPlanes::Orientation theOrient,
263 CORBA::Double theXAngle,
264 CORBA::Double theYAngle):
265 myCutLinesPL(theCutLines),
275 myCutLinesPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(myOrient),
281 VISU::TSetModified aModified(this);
283 ProcessVoidEvent(new TEvent(myCutLinesPL, theOrient, theXAngle, theYAngle));
286 //---------------------------------------------------------------
289 ::SetOrientation2(VISU::CutPlanes::Orientation theOrient,
290 CORBA::Double theXAngle,
291 CORBA::Double theYAngle)
293 struct TEvent: public SALOME_Event
295 VISU_CutLinesPL* myCutLinesPL;
296 CORBA::Double myXAngle, myYAngle;
297 VISU::CutPlanes::Orientation myOrient;
298 TEvent(VISU_CutLinesPL* theCutLines,
299 VISU::CutPlanes::Orientation theOrient,
300 CORBA::Double theXAngle,
301 CORBA::Double theYAngle):
302 myCutLinesPL(theCutLines),
312 myCutLinesPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(myOrient),
319 VISU::TSetModified aModified(this);
321 ProcessVoidEvent(new TEvent(myCutLinesPL, theOrient, theXAngle, theYAngle));
324 //---------------------------------------------------------------
325 VISU::CutPlanes::Orientation
327 ::GetOrientationType()
329 return VISU::CutPlanes::Orientation(myCutLinesPL->GetPlaneOrientation());
332 //---------------------------------------------------------------
333 VISU::CutPlanes::Orientation
335 ::GetOrientationType2()
337 return VISU::CutPlanes::Orientation(myCutLinesPL->GetPlaneOrientation(1));
340 //---------------------------------------------------------------
345 return myCutLinesPL->GetRotateX();
348 //---------------------------------------------------------------
353 return myCutLinesPL->GetRotateY();
357 //---------------------------------------------------------------
362 return myCutLinesPL->GetRotateX(1);
365 //---------------------------------------------------------------
370 return myCutLinesPL->GetRotateY(1);
374 //---------------------------------------------------------------
377 ::SetDisplacement(CORBA::Double theDisp)
379 VISU::TSetModified aModified(this);
381 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_CutLinesPL, vtkFloatingPointType, int>
382 (GetSpecificPL(), &VISU_CutLinesPL::SetDisplacement, theDisp, 0));
385 //---------------------------------------------------------------
388 ::SetDisplacement2(CORBA::Double theDisp)
390 VISU::TSetModified aModified(this);
392 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_CutLinesPL, vtkFloatingPointType, int>
393 (GetSpecificPL(), &VISU_CutLinesPL::SetDisplacement, theDisp, 1));
397 //---------------------------------------------------------------
402 return myCutLinesPL->GetDisplacement();
405 //---------------------------------------------------------------
410 return myCutLinesPL->GetDisplacement(1);
414 //---------------------------------------------------------------
417 ::SetBasePlanePosition(CORBA::Double thePlanePosition)
419 VISU::TSetModified aModified(this);
421 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_CutLinesPL, vtkFloatingPointType>
422 (GetSpecificPL(), &VISU_CutLinesPL::SetPosition, thePlanePosition));
425 //---------------------------------------------------------------
428 ::GetBasePlanePosition()
430 return myCutLinesPL->GetPosition();
433 //---------------------------------------------------------------
436 ::SetLinePosition(CORBA::Long thePlaneNumber,
437 CORBA::Double thePlanePosition)
439 VISU::TSetModified aModified(this);
441 ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_CutLinesPL, int, vtkFloatingPointType>
442 (GetSpecificPL(), &VISU_CutLinesPL::SetPartPosition, thePlaneNumber, thePlanePosition));
445 //---------------------------------------------------------------
448 ::GetLinePosition(CORBA::Long thePlaneNumber)
450 return myCutLinesPL->GetPartPosition(thePlaneNumber,1);
454 //---------------------------------------------------------------
459 VISU::TSetModified aModified(this);
461 ProcessVoidEvent(new TVoidMemFunEvent<VISU_CutLinesPL>
462 (GetSpecificPL(), &VISU_CutLinesPL::SetDefault));
465 //---------------------------------------------------------------
470 return myCutLinesPL->IsDefault();
473 //---------------------------------------------------------------
476 ::SetDefaultPosition(CORBA::Long thePlaneNumber)
478 VISU::TSetModified aModified(this);
480 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_CutLinesPL, int>
481 (GetSpecificPL(), &VISU_CutLinesPL::SetPartDefault, thePlaneNumber));
484 //---------------------------------------------------------------
487 ::IsDefaultPosition(CORBA::Long thePlaneNumber)
489 return myCutLinesPL->IsPartDefault(thePlaneNumber);
492 //---------------------------------------------------------------
493 /*! Invert all curves of corresponding table
494 * see void VISU::CutLines_i::SetCurveInverted(CORBA::Long theCurveNumber,CORBA::Boolean theInvert)
495 * \param theInvert - Invert all curves, if value is TRUE, else not.
499 ::SetAllCurvesInverted(CORBA::Boolean theInvert)
501 for(int i=0; i < GetNbLines(); i++)
502 SetCurveInverted(i, theInvert);
505 //---------------------------------------------------------------
506 /*! Checks the orientation of all curves
507 * \retval TRUE - if all curves are inverted, else FALSE
511 ::IsAllCurvesInverted()
513 for (int i=0; i<GetNbLines(); i++)
514 if (!IsCurveInverted(i)) return false;
518 //---------------------------------------------------------------
519 /*! Sets orientation of curve
520 * \param theCurveNumber - integer value, number of cut line.
521 * \param theInvert - boolean value, TRUE or false.
525 ::SetCurveInverted(CORBA::Long theCurveNumber, CORBA::Boolean theInvert)
527 if(myMapCurvesInverted[theCurveNumber] == theInvert)
530 VISU::TSetModified aModified(this);
532 myMapCurvesInverted[theCurveNumber] = theInvert;
533 myParamsTime.Modified();
536 //---------------------------------------------------------------
537 /*! Checks orientation of curve.
538 * \param theCurveNumber - integer value, number of cut line.
539 * \retval TRUE - if line in the table is inverted, else FALSE.
543 ::IsCurveInverted(CORBA::Long theCurveNumber)
545 return myMapCurvesInverted[theCurveNumber];
548 //---------------------------------------------------------------
549 /*! It control the way the length of cutlines is shown: using aboslute or relative values
550 * \param theAbsLength - boolean value, TRUE or false.
554 ::SetUseAbsoluteLength(CORBA::Boolean theAbsLength)
556 if ( myUseAbsLength == theAbsLength )
559 VISU::TSetModified aModified(this);
561 myUseAbsLength = theAbsLength;
562 myParamsTime.Modified();
565 //---------------------------------------------------------------
568 ::IsUseAbsoluteLength()
570 return myUseAbsLength;
573 //---------------------------------------------------------------
576 ::SetNbLines(CORBA::Long theNb)
578 VISU::TSetModified aModified(this);
580 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_CutLinesPL, int>
581 (GetSpecificPL(), &VISU_CutLinesPL::SetNbParts, theNb));
584 //---------------------------------------------------------------
589 return myCutLinesPL->GetNbParts();
593 //---------------------------------------------------------------
596 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
599 myCutLinesPL = VISU_CutLinesPL::New();
601 myCutLinesPL = dynamic_cast<VISU_CutLinesPL*>(thePipeLine);
603 TSuperClass::CreatePipeLine(myCutLinesPL);
607 //----------------------------------------------------------------------------
612 return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
616 //---------------------------------------------------------------
621 if(VISU_Actor* anActor = TSuperClass::CreateActor()){
622 anActor->SetVTKMapping(true);
623 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
624 int aDispMode = aResourceMgr->integerValue("VISU" , "cut_lines_represent", 2);
625 anActor->SetRepresentation(aDispMode);
631 //---------------------------------------------------------------
634 ::BuildTableOfReal(SALOMEDS::SObject_var theSObject)
637 if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal");
639 SALOMEDS::GenericAttribute_var anAttr;
640 SALOMEDS::StudyBuilder_var aStudyBuilder = GetStudyDocument()->NewBuilder();
641 anAttr = aStudyBuilder->FindOrCreateAttribute(theSObject, "AttributeTableOfReal");
642 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
644 typedef set<vtkFloatingPointType> TXCont;
645 typedef map<vtkFloatingPointType,vtkFloatingPointType> TXYMap;
646 typedef map<int,TXYMap> TXYMapCont;
647 typedef map<long,long> TLineIdCont;
649 QString aTitle( GetScalarBarTitle().c_str() );
650 aTitle = aTitle.simplified();
651 aTableOfReal->SetTitle( aTitle.toLatin1().data() );
653 int iLineEnd = myCutLinesPL->GetAppendPolyData()->GetNumberOfInputConnections(0);
654 if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal iLineEnd = "<<iLineEnd);
656 TXYMapCont aXYMapCont;
657 TLineIdCont aLineIdCont; // Define internal numeration of lines
658 const vtkFloatingPointType *aDirLn = myCutLinesPL->GetDirLn();
659 const vtkFloatingPointType *aBasePnt = myCutLinesPL->GetBasePnt();
660 const vtkFloatingPointType *aBoundPrjLn = myCutLinesPL->GetBoundPrjLn();
661 for(int iLine = 0, jLine = 0; iLine < iLineEnd; iLine++){
662 vtkDataSet *aDataSet = myCutLinesPL->GetAppendPolyData()->GetInput(iLine);
664 int aNbPoints = aDataSet->GetNumberOfPoints();
665 if(!aNbPoints) continue;
666 vtkPointData *aPointData = aDataSet->GetPointData();
667 vtkDataArray *aScalars = aPointData->GetScalars();
668 vtkCellDataToPointData *aFilter = NULL;
670 aFilter = vtkCellDataToPointData::New();
671 aFilter->SetInput(aDataSet);
672 aFilter->PassCellDataOn();
673 aDataSet = aFilter->GetOutput();
676 aPointData = aDataSet->GetPointData();
677 aScalars = aPointData->GetScalars();
678 if(!aScalars) continue;
679 if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal iLine = "<<iLine<<"; aNbPoints = "<<aNbPoints);
680 aLineIdCont[iLine] = jLine++;
681 TXYMap& aXYMap = aXYMapCont[iLine];
682 vtkFloatingPointType aPnt[3], aVect[3], aDist, aTopBnd, aDivide;
683 aTopBnd = aBoundPrjLn[2];
684 aDivide = aBoundPrjLn[2];
685 if( !IsUseAbsoluteLength() ){
690 for(int i = 0; i < aNbPoints; i++){
691 aDataSet->GetPoint(i,aPnt);
692 for(int j = 0; j < 3; j++)
693 aVect[j] = aPnt[j] - aBasePnt[j];
694 //VISU::Sub(aPnt,aBasePnt,aVect);
695 if ( fabs(aBoundPrjLn[2]) < EPS_machine )
699 aDist = vtkMath::Dot(aVect,aDirLn)/aDivide;
701 if(aDist < 0.0) aDist = 0.0;
702 if(aDist > aTopBnd) aDist = aTopBnd;
704 aXYMap[aDist] = aScalars->GetTuple1(i);
709 if(aXYMapCont.size() == 0)
710 throw std::runtime_error("CutPlanes_i::BuildTableOfReal aXYMapCont.size() == 0 !!!");
713 // Invertion all curves in the table, which has inversion flag is TRUE (see \a myMapCurvesInverted)
714 for(int iLine=0; iLine < iLineEnd; iLine++){
715 if (!IsCurveInverted(iLine)) continue;
717 TXYMap& aXYMap = aXYMapCont[iLine];
718 TXYMap::const_iterator aXYMapIter = aXYMap.begin();
719 std::list<vtkFloatingPointType> XKeys;
720 for (;aXYMapIter != aXYMap.end() ; aXYMapIter++) XKeys.push_back(aXYMapIter->first);
722 if (XKeys.size() > 1) {
723 vtkFloatingPointType a_first_indx = XKeys.front();
724 vtkFloatingPointType a_last_indx = XKeys.back();
725 if (a_first_indx > a_last_indx){
727 vtkFloatingPointType tmp = a_first_indx;
728 a_first_indx = a_last_indx;
731 std::list<vtkFloatingPointType>::const_iterator aIter = XKeys.begin();
732 for (int k=0;k<XKeys.size() && aIter != XKeys.end();k++,aIter++){
733 // Warning: value '1.0' come from workaround:
734 // see also aDist = vtkMath::Dot(aVect,aDirLn) / aBoundPrjLn[2];
735 // aDist >= 0 and aDist<=1.0
736 vtkFloatingPointType aTopBnd = aBoundPrjLn[2];
737 if( !IsUseAbsoluteLength() ){
740 aNewXYMap[aTopBnd - *aIter] = aXYMap[*aIter];
742 TXYMap::const_iterator aNewXYMapIter = aNewXYMap.begin();
744 for (;aNewXYMapIter != aNewXYMap.end();aNewXYMapIter++) {
745 aXYMap[aNewXYMapIter->first] = aNewXYMapIter->second;
750 //Resorting of theXYMap
751 TXYMapCont::iterator aXYMapContIter = aXYMapCont.begin();
752 for(; aXYMapContIter != aXYMapCont.end(); aXYMapContIter++){
753 TXYMap& aXYMap = aXYMapContIter->second, aNewXYMap;
754 if(aXYMap.size() > 2){
755 // Try to smooth the values of the line by applying linear approximation
756 TXYMap::const_iterator aXYMapIter[2] = {aXYMap.begin(), ++aXYMap.begin()};
757 aNewXYMap[aXYMapIter[0]->first] = aXYMapIter[0]->second;
758 aXCont.insert(aXYMapIter[0]->first);
759 for(; aXYMapIter[1] != aXYMap.end(); aXYMapIter[0]++, aXYMapIter[1]++){
760 vtkFloatingPointType aY[3] = {aXYMapIter[0]->second, aXYMapIter[1]->second, 0.0};
761 aY[2] = (aY[0] + aY[1])/2.0;
762 vtkFloatingPointType aX[3] = {aXYMapIter[0]->first, aXYMapIter[1]->first, 0.0};
763 aX[2] = (aX[0] + aX[1])/2.0;
764 aNewXYMap[aX[2]] = aY[2];
765 aXCont.insert(aX[2]);
767 aNewXYMap[aXYMapIter[0]->first] = aXYMapIter[0]->second;
768 aXCont.insert(aXYMapIter[0]->first);
771 TXYMap::const_iterator aXYMapIter = aXYMap.begin();
772 for(; aXYMapIter != aXYMap.end(); aXYMapIter++)
773 aXCont.insert(aXYMapIter->first);
776 if(aXCont.size() == 0)
777 throw std::runtime_error("CutPlanes_i::BuildTableOfReal aXCont.size() == 0 !!!");
779 int iEnd = aXCont.size();
780 aTableOfReal->SetNbColumns(iEnd);
781 TXCont::const_iterator aXContIter = aXCont.begin();
782 for(long i = 0; aXContIter != aXCont.end(); aXContIter++, i++){
783 vtkFloatingPointType aDist = *aXContIter;
784 aTableOfReal->PutValue(aDist,1,i+1);
785 aString.sprintf("%d",i);
786 aTableOfReal->SetColumnTitle(i+1,(const char*)aString.toLatin1());
787 if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal aDist = "<<aDist);
788 TXYMapCont::const_iterator aXYMapContIter = aXYMapCont.begin();
789 for(; aXYMapContIter != aXYMapCont.end(); aXYMapContIter++){
790 long iLine = aXYMapContIter->first;
791 long iLineId = aLineIdCont[iLine];
792 const TXYMap& aXYMap = aXYMapCont[iLine];
793 TXYMap::const_iterator aXYMapIter = aXYMap.find(aDist);
794 // Can we find some value that belong to the line and have the same X coordinate?
795 if(aXYMapIter == aXYMap.end()) continue;
796 vtkFloatingPointType aVal = aXYMapIter->second;
797 aTableOfReal->PutValue(aVal,iLineId+2,i+1);
801 aTableOfReal->SetRowTitle(1,"X");
802 aTableOfReal->SetRowUnit(1,"-");
803 QString aUnitName = GetField()->myUnitNames[0].c_str();
804 int aScalarMode = myCutLinesPL->GetScalarMode();
806 aUnitName = GetField()->myUnitNames[aScalarMode-1].c_str();
807 aUnitName = aUnitName.simplified();
808 if(aUnitName.isEmpty()) aUnitName = "-";
809 TXYMapCont::const_iterator aXYMapContIter = aXYMapCont.begin();
810 for(; aXYMapContIter != aXYMapCont.end(); aXYMapContIter++){
811 long iLine = aXYMapContIter->first;
812 long iLineId = aLineIdCont[iLine];
813 aString.sprintf("Y%d",iLine);
815 MESSAGE("CutPlanes_i::BuildTableOfReal - SetRowTitle("<<iLineId+2<<",'"<<(const char*)aString.toLatin1()<<"')");
816 aTableOfReal->SetRowTitle(iLineId+2,(const char*)aString.toLatin1());
817 aTableOfReal->SetRowUnit(iLineId+2,(const char*)aUnitName.toLatin1());
820 }catch(std::exception& exc){
821 INFOS("Follow exception was occured :\n"<<exc.what());
823 INFOS("Unknown exception was occured !!!");