#include <HYDROData_Entity.h>
#include <HYDROData_Document.h>
#include <HYDROData_Profile.h>
+#include <HYDROData_Iterator.h>
#include <gp_XYZ.hxx>
#include <gp_XY.hxx>
{
}
+void HYDROData_SinusX::CollectExistingNames(Handle_HYDROData_Document theDocument)
+{
+ HYDROData_Iterator anIter( theDocument );
+ int anInd = 0;
+ myExistingNames.clear();
+ std::vector<int> anAllowedIndexes;
+ for( ; anIter.More(); anIter.Next() )
+ myExistingNames.push_back(anIter.Current()->GetName());
+}
+
+QString HYDROData_SinusX::GetName(const QString& theName)
+{
+ if (myExistingNames.contains(theName))
+ {
+ QString aName = theName;
+ while (myExistingNames.contains(aName))
+ {
+ QStringList aList = aName.split("_");
+ int aLastInd = aName.lastIndexOf("_");
+ bool IsNum = false;
+ int anInd = -1;
+ anInd = aList.last().toInt(&IsNum);
+ if (IsNum)
+ {
+ aName = aName.left(aLastInd) + "_";
+ aName+= QString::number(++anInd);
+ }
+ else
+ aName = theName + "_0";
+ }
+
+ myExistingNames.push_back(aName);
+ return aName;
+ }
+ else
+ {
+ myExistingNames.push_back(theName);
+ return theName;
+ }
+
+}
+
bool HYDROData_SinusX::Import(const QString& theFilePath, Handle(HYDROData_Document) theDocument, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities)
{
Parse(aFile);
+ CollectExistingNames(theDocument);
SXToHydro(theDocument, theEntities);
aFile.close();
aAPoints.Append(gp_XYZ (myCurveBlocks[i].myXYZPoints[j]));
aBath->SetAltitudePoints(aAPoints);
- aBath->SetName(myCurveBlocks[i].myName);
+ aBath->SetName(GetName(myCurveBlocks[i].myName + "_bath"));
theEntities.Append(aBath);
}
if (myCurveBlocks[i].myType == 1 || myCurveBlocks[i].myType == 3)
NCollection_Sequence<gp_XYZ> aPoints;
for (size_t j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
aPoints.Append(gp_XYZ (myCurveBlocks[i].myXYZPoints[j]));
- if (myCurveBlocks[i].myIsClosed)
- aPoints.Append(gp_XYZ (myCurveBlocks[i].myXYZPoints[0]));
+ /*if (myCurveBlocks[i].myIsClosed)
+ aPoints.Append(gp_XYZ (myCurveBlocks[i].myXYZPoints[0]));*/
Handle(HYDROData_ProfileUZ) aProfileUZ = Handle(HYDROData_ProfileUZ)::DownCast( theDocument->CreateObject( KIND_PROFILEUZ ) );
Handle(HYDROData_PolylineXY) aPolyXY = Handle(HYDROData_PolylineXY)::DownCast( theDocument->CreateObject( KIND_POLYLINEXY ) );
- aPolyXY->AddSection( "", myCurveBlocks[i].myIsSpline ? HYDROData_PolylineXY::SECTION_SPLINE : HYDROData_PolylineXY::SECTION_POLYLINE, false );
+ aPolyXY->AddSection( "",
+ myCurveBlocks[i].myIsSpline ? HYDROData_PolylineXY::SECTION_SPLINE : HYDROData_PolylineXY::SECTION_POLYLINE,
+ myCurveBlocks[i].myIsClosed ? true : false);
aProfileUZ->CalculateAndAddPoints(aPoints, aPolyXY);
Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( theDocument->CreateObject( KIND_PROFILE ) );
aProfile->SetParametricPoints(aProfileUZ->GetPoints());
- aPolyXY->SetName(myCurveBlocks[i].myName + "_polyXY");
- aProfileUZ->SetName(myCurveBlocks[i].myName + "_profileUZ");
- aProfile->SetName(myCurveBlocks[i].myName + "_profile");
+ aPolyXY->SetName(GetName(myCurveBlocks[i].myName + "_polyXY"));
+ aProfileUZ->SetName(GetName(myCurveBlocks[i].myName + "_profileUZ"));
+ aProfile->SetName(GetName(myCurveBlocks[i].myName + "_profile"));
theEntities.Append(aPolyXY);
theEntities.Append(aProfileUZ);
theEntities.Append(aProfile);
HYDROData_ProfileUZ::PointsList aPointList;
for (size_t j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
aPointList.Append(gp_XY (myCurveBlocks[i].myXYZPoints[j].X(), myCurveBlocks[i].myXYZPoints[j].Z()));
-
+ aProfile->GetProfileUZ()->SetSectionType(0, myCurveBlocks[i].myIsSpline ? HYDROData_PolylineXY::SECTION_SPLINE : HYDROData_PolylineXY::SECTION_POLYLINE);
+ aProfile->GetProfileUZ()->SetSectionClosed(0, myCurveBlocks[i].myIsClosed ? true : false);
aProfile->SetParametricPoints(aPointList);
if ( ! (myCurveBlocks[i].myAdditionalCurveInfo[0] == 0 && myCurveBlocks[i].myAdditionalCurveInfo[1] == 0 &&
myCurveBlocks[i].myAdditionalCurveInfo[2] == 0 && myCurveBlocks[i].myAdditionalCurveInfo[3] == 0) )
aProfile->SetRightPoint(gp_XY(myCurveBlocks[i].myAdditionalCurveInfo[2], myCurveBlocks[i].myAdditionalCurveInfo[3]));
aProfile->Update();
}
- aProfile->SetName(myCurveBlocks[i].myName + "_profile");
+ aProfile->SetName(GetName(myCurveBlocks[i].myName + "_profile"));
theEntities.Append(aProfile);
}
}
HYDROData_Profile::ProfilePoints aPointList;
for (size_t j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
aPointList.Append(myCurveBlocks[i].myXYZPoints[j]);
+ aProfile->GetProfileUZ()->SetSectionType(0, myCurveBlocks[i].myIsSpline ? HYDROData_PolylineXY::SECTION_SPLINE : HYDROData_PolylineXY::SECTION_POLYLINE);
+ aProfile->GetProfileUZ()->SetSectionClosed(0, myCurveBlocks[i].myIsClosed ? true : false);
aProfile->SetProfilePoints(aPointList);
- aProfile->SetName(myCurveBlocks[i].myName + "_profile");
+ aProfile->SetName(GetName(myCurveBlocks[i].myName + "_profile"));
theEntities.Append(aProfile);
}
}
}
-
-
bool HYDROData_SinusX::Parse(QFile& theFile)
{
if ( !theFile.isOpen() )