#include <TopoDS_Shape.hxx>
+#include <HYDROData_Profile.h>
+#include <HYDROData_PolylineXY.h>
+
IMPLEMENT_STANDARD_HANDLE(HYDROData_ProfileUZ, HYDROData_IPolyline)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ProfileUZ, HYDROData_IPolyline)
return aResList;
}
+void HYDROData_ProfileUZ::CalculateAndAddPoints(const NCollection_Sequence<gp_XYZ>& theXYZPoints, Handle_HYDROData_PolylineXY& thePolylineXY)
+{
+ // Fill 2D polyline
+ for ( int i = 1; i <= theXYZPoints.Size(); i++ ) {
+ const HYDROData_Profile::ProfilePoint& aBottomPoint = theXYZPoints.Value( i );
+ thePolylineXY->AddPoint( 0, HYDROData_PolylineXY::Point( aBottomPoint.X(), aBottomPoint.Y() ) );
+ }
+
+ // Calculate profile UZ points
+
+ // First point
+ const HYDROData_Profile::ProfilePoint& aFirstBottomPoint = theXYZPoints.First();
+ AddPoint( 0, HYDROData_ProfileUZ::Point( 0, aFirstBottomPoint.Z() ) );
+
+ // Intermediate points
+ double aPolylineCommonDist = thePolylineXY->GetDistance( 0, thePolylineXY->NbPoints( 0 ) - 1 );
+
+ for ( int i = 2, aNbPoints = theXYZPoints.Size(); i < aNbPoints; i++ ) {
+ const HYDROData_Profile::ProfilePoint& aBottomPoint = theXYZPoints.Value( i );
+
+ double aDistance = thePolylineXY->GetDistance( 0, i - 1 );
+
+ Standard_Real anU = aDistance; // = ( aDistance / aPolylineCommonDist ) * aPolylineCommonDist;
+ AddPoint( 0, HYDROData_ProfileUZ::Point( anU, aBottomPoint.Z() ) );
+ }
+
+ // Last point
+ const HYDROData_Profile::ProfilePoint& aLastBottomPoint = theXYZPoints.Last();
+ AddPoint( 0, HYDROData_ProfileUZ::Point( aPolylineCommonDist, aLastBottomPoint.Z() ) );
+
+}
+
void HYDROGUI_ImportSinusXOp::ProcessSX()
{
- Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( doc()->CreateObject( KIND_POLYLINEXY ) );
+ /*Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( doc()->CreateObject( KIND_POLYLINEXY ) );
Handle(HYDROData_Polyline3D) aPolylineObj = Handle(HYDROData_Polyline3D)::DownCast( doc()->CreateObject( KIND_POLYLINE ) );
-
- Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( doc()->CreateObject( KIND_BATHYMETRY ) );
- HYDROData_Bathymetry::AltitudePoints aAPoints;
-
- int aNSect = myCurveBlocks.size();
- for ( int i = 0 ; i < aNSect ; i++ )
+ */
+ //TODO - move to hydro data
+ std::vector<Handle(HYDROData_Entity)> anEntities;
+ for ( int i = 0; i < myCurveBlocks.size(); i++ )
{
- bool aSectClosure = true;
- HYDROData_PolylineXY::SectionType aSectType = HYDROData_PolylineXY::SECTION_POLYLINE;
- aPolylineXY->AddSection( TCollection_AsciiString(myCurveBlocks[i].myName.toStdString().c_str()), aSectType, myCurveBlocks[i].myIsConnected );
-
- for ( int k = 0 ; k < myCurveBlocks[i].myXYZPoints.size() ; k+=3 )
+ if (myCurveBlocks[i].myType == 4) /// scatter plot -> to bathy
{
- HYDROData_PolylineXY::Point aSectPoint;
- aSectPoint.SetX( myCurveBlocks[i].myXYZPoints[k].X() );
- aSectPoint.SetY( myCurveBlocks[i].myXYZPoints[k].Y() );
- aPolylineXY->AddPoint( i, aSectPoint );
-
- aAPoints.Append(myCurveBlocks[i].myXYZPoints[k]);
+ Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( doc()->CreateObject( KIND_BATHYMETRY ) );
+ HYDROData_Bathymetry::AltitudePoints aAPoints;
+ for (int j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
+ aAPoints.Append(gp_XYZ (myCurveBlocks[i].myXYZPoints[j]));
+
+ aBath->SetAltitudePoints(aAPoints);
+ aBath->SetName(myCurveBlocks[i].myName);
+ anEntities.push_back(aBath);
+ }
+ if (myCurveBlocks[i].myType == 1 || myCurveBlocks[i].myType == 3)
+ {
+ NCollection_Sequence<gp_XYZ> aPoints;
+ for (int 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]));
+ Handle(HYDROData_ProfileUZ) aProfileUZ = Handle(HYDROData_ProfileUZ)::DownCast( doc()->CreateObject( KIND_PROFILEUZ ) );
+ Handle(HYDROData_PolylineXY) aPolyXY = Handle(HYDROData_PolylineXY)::DownCast( doc()->CreateObject( KIND_POLYLINEXY ) );
+ aPolyXY->AddSection( "", myCurveBlocks[i].myIsSpline ? HYDROData_PolylineXY::SECTION_SPLINE : HYDROData_PolylineXY::SECTION_POLYLINE, false );
+ aProfileUZ->CalculateAndAddPoints(aPoints, aPolyXY);
+ Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( doc()->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");
+ anEntities.push_back(aPolyXY);
+ anEntities.push_back(aProfileUZ);
+ anEntities.push_back(aProfile);
+ }
+ if (myCurveBlocks[i].myType == 2)
+ {
+ if (myCurveBlocks[i].myCurvePlane == 2)
+ {
+ if (myCurveBlocks[i].myAdditionalCurveInfo.size() == 4)
+ {
+ Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( doc()->CreateObject( KIND_PROFILE ) );
+ HYDROData_ProfileUZ::PointsList aPointList;
+ for (int j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
+ aPointList.Append(gp_XY (myCurveBlocks[i].myXYZPoints[j].X(), myCurveBlocks[i].myXYZPoints[j].Z()));
+
+ 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->SetLeftPoint(gp_XY(myCurveBlocks[i].myAdditionalCurveInfo[0], myCurveBlocks[i].myAdditionalCurveInfo[1]));
+ aProfile->SetRightPoint(gp_XY(myCurveBlocks[i].myAdditionalCurveInfo[2], myCurveBlocks[i].myAdditionalCurveInfo[3]));
+ aProfile->Update();
+ }
+ aProfile->SetName(myCurveBlocks[i].myName + "_profile");
+ anEntities.push_back(aProfile);
+ }
+ }
+ if (myCurveBlocks[i].myCurvePlane == 0)
+ {
+ Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( doc()->CreateObject( KIND_PROFILE ) );
+ HYDROData_Profile::ProfilePoints aPointList;
+ for (int j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
+ aPointList.Append(myCurveBlocks[i].myXYZPoints[j]);
+ aProfile->SetProfilePoints(aPointList);
+ aProfile->SetName(myCurveBlocks[i].myName + "_profile");
+ anEntities.push_back(aProfile);
+ }
}
}
- QString aFileName = myFileDlg->selectedFile();
- QFileInfo aFileInfo(aFileName);
- QString aBaseFileName = aFileInfo.baseName();
- QString aBathName = aBaseFileName + "_bath_1";
- QString aPolyXYName = aBaseFileName + "_polyXY_1";
- QString aPoly3DName = aBaseFileName + "_poly3D_1";
-
- int anInd = 2;
- for (;HYDROGUI_Tool::FindObjectByName( module(), aBathName, KIND_BATHYMETRY) ||
- HYDROGUI_Tool::FindObjectByName( module(), aPolyXYName, KIND_POLYLINEXY) ||
- HYDROGUI_Tool::FindObjectByName( module(), aPoly3DName, KIND_POLYLINE);)
- {
- aBathName = aBaseFileName + "_bath_" + QString::number(anInd);
- aPolyXYName = aBaseFileName + "_polyXY_" + QString::number(anInd);
- aPoly3DName = aBaseFileName + "_poly3D_" + QString::number(anInd);
- anInd++;
- }
-
- aPolylineXY->SetName( aPolyXYName );
- aPolylineXY->SetWireColor(HYDROData_PolylineXY::DefaultWireColor());
- aPolylineXY->Update();
-
- aBath->SetAltitudePoints(aAPoints);
- aBath->SetName( aBathName );
-
- aPolylineObj->SetPolylineXY (aPolylineXY, false);
- aPolylineObj->SetAltitudeObject(aBath);
-
- aPolylineObj->SetBorderColor( HYDROData_Polyline3D::DefaultBorderColor() );
- aPolylineObj->SetName( aPoly3DName );
-
- aPolylineObj->Update();
-
+
+ /////
+
size_t anActiveViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
if ( anActiveViewId == 0 )
anActiveViewId = HYDROGUI_Tool::GetActiveOCCViewId( module() );
-
- module()->setObjectVisible( anActiveViewId, aPolylineXY, true );
- module()->setObjectVisible( anActiveViewId, aPolylineObj, true );
-
- module()->setIsToUpdate( aPolylineObj );
+
+ for (int i = 0; i < anEntities.size() ; i++)
+ {
+ anEntities[i]->Update();
+ module()->setObjectVisible( anActiveViewId, anEntities[i], true );
+ module()->setIsToUpdate( anEntities[i] );
+ }
}
+
+
bool HYDROGUI_ImportSinusXOp::Parse( QFile& theFile)
for (;!theFile.atEnd();)
{
- if (aList[0] == "B" && (aList[1] == "C" || aList[1] == "P" || aList[1] == "N"))
+ if (aList[0] == "B" && (aList[1] == "C" || aList[1] == "P" || aList[1] == "N" || aList[1] == "S" ))
{
HYDROGUI_CurveBlock aCurveBlockInfo;
if (aList[1] == "C")
else if (aList[1] == "P")
aCurveBlockInfo.myType = 2;
else if (aList[1] == "N")
- aCurveBlockInfo.myType = 2;
+ aCurveBlockInfo.myType = 3;
+ else if (aList[1] == "S")
+ aCurveBlockInfo.myType = 4;
if (aList.size() == 9)
{
else if (aBList.size() == 3 && (aBList[1] == "0" || aBList[1] == "1") && (aBList[2] == "0" || aBList[2] == "1"))
{
aCurveBlockInfo.myIsClosed = aBList[1].toInt();
- aCurveBlockInfo.myIsClosed = aBList[2].toInt();
+ aCurveBlockInfo.myIsSpline = aBList[2].toInt();
}
else
{
else
break;
- } while (!theFile.atEnd()/* && aBLine[0] == 'B'*/ );
+ } while (!theFile.atEnd() || !aBLine.isEmpty());
if (aTotStat)
myCurveBlocks.push_back(aCurveBlockInfo);
+ aLine = aBLine;
+ aList = aBList;
+
}
else
{