From: isn Date: Tue, 16 Jun 2015 16:55:33 +0000 (+0300) Subject: sinusX p.2 X-Git-Tag: v1.4.2~54^2~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=97893b85e4456b19844eb4f4e8738af7bd30aecf;p=modules%2Fhydro.git sinusX p.2 --- diff --git a/src/HYDROData/HYDROData_ProfileUZ.cxx b/src/HYDROData/HYDROData_ProfileUZ.cxx index a551f43f..1189970c 100755 --- a/src/HYDROData/HYDROData_ProfileUZ.cxx +++ b/src/HYDROData/HYDROData_ProfileUZ.cxx @@ -32,6 +32,9 @@ #include +#include +#include + IMPLEMENT_STANDARD_HANDLE(HYDROData_ProfileUZ, HYDROData_IPolyline) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ProfileUZ, HYDROData_IPolyline) @@ -275,4 +278,36 @@ HYDROData_ProfileUZ::PointsList HYDROData_ProfileUZ::GetPoints( const int /*theS return aResList; } +void HYDROData_ProfileUZ::CalculateAndAddPoints(const NCollection_Sequence& 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() ) ); + +} + diff --git a/src/HYDROData/HYDROData_ProfileUZ.h b/src/HYDROData/HYDROData_ProfileUZ.h index 62a5c14e..fd543f07 100644 --- a/src/HYDROData/HYDROData_ProfileUZ.h +++ b/src/HYDROData/HYDROData_ProfileUZ.h @@ -23,6 +23,9 @@ DEFINE_STANDARD_HANDLE(HYDROData_ProfileUZ, HYDROData_IPolyline) +class gp_XYZ; +class Handle_HYDROData_PolylineXY; + /**\class HYDROData_ProfileUZ * \brief Class that stores/retreives information about the * parametric profile points. @@ -167,6 +170,8 @@ public: */ HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1 ) const; + HYDRODATA_EXPORT virtual void CalculateAndAddPoints(const NCollection_Sequence& theXYZPoints, Handle_HYDROData_PolylineXY& thePolylineXY); + protected: friend class HYDROData_Iterator; diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index 29b7aae6..e9da1296 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -1082,33 +1082,7 @@ bool HYDROData_Stream::GenerateBottomPolyline() aProfileUZ->RemoveSection( 0 ); - // Fill 2D polyline - for ( int i = 1; i <= aNbBottomPoints; i++ ) { - const HYDROData_Profile::ProfilePoint& aBottomPoint = aBottomPoints.Value( i ); - aPolylineXY->AddPoint( 0, HYDROData_PolylineXY::Point( aBottomPoint.X(), aBottomPoint.Y() ) ); - } - - // Calculate profile UZ points - - // First point - const HYDROData_Profile::ProfilePoint& aFirstBottomPoint = aBottomPoints.First(); - aProfileUZ->AddPoint( 0, HYDROData_ProfileUZ::Point( 0, aFirstBottomPoint.Z() ) ); - - // Intermediate points - double aPolylineCommonDist = aPolylineXY->GetDistance( 0, aPolylineXY->NbPoints( 0 ) - 1 ); - - for ( int i = 2, aNbPoints = aBottomPoints.Size(); i < aNbPoints; i++ ) { - const HYDROData_Profile::ProfilePoint& aBottomPoint = aBottomPoints.Value( i ); - - double aDistance = aPolylineXY->GetDistance( 0, i - 1 ); - - Standard_Real anU = aDistance; // = ( aDistance / aPolylineCommonDist ) * aPolylineCommonDist; - aProfileUZ->AddPoint( 0, HYDROData_ProfileUZ::Point( anU, aBottomPoint.Z() ) ); - } - - // Last point - const HYDROData_Profile::ProfilePoint& aLastBottomPoint = aBottomPoints.Last(); - aProfileUZ->AddPoint( 0, HYDROData_ProfileUZ::Point( aPolylineCommonDist, aLastBottomPoint.Z() ) ); + aProfileUZ->CalculateAndAddPoints(aBottomPoints, aPolylineXY); return true; } diff --git a/src/HYDROGUI/HYDROGUI_ImportSinusXOp.cxx b/src/HYDROGUI/HYDROGUI_ImportSinusXOp.cxx index 7491988e..291338a0 100644 --- a/src/HYDROGUI/HYDROGUI_ImportSinusXOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportSinusXOp.cxx @@ -111,72 +111,96 @@ void HYDROGUI_ImportSinusXOp::onApply() 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 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 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) @@ -196,7 +220,7 @@ 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") @@ -204,7 +228,9 @@ bool HYDROGUI_ImportSinusXOp::Parse( QFile& theFile) 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) { @@ -226,7 +252,7 @@ bool HYDROGUI_ImportSinusXOp::Parse( QFile& theFile) 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 { @@ -264,10 +290,13 @@ bool HYDROGUI_ImportSinusXOp::Parse( QFile& theFile) else break; - } while (!theFile.atEnd()/* && aBLine[0] == 'B'*/ ); + } while (!theFile.atEnd() || !aBLine.isEmpty()); if (aTotStat) myCurveBlocks.push_back(aCurveBlockInfo); + aLine = aBLine; + aList = aBList; + } else { diff --git a/src/HYDROGUI/HYDROGUI_ImportSinusXOp.h b/src/HYDROGUI/HYDROGUI_ImportSinusXOp.h index 0e1d3048..dcd38ed5 100644 --- a/src/HYDROGUI/HYDROGUI_ImportSinusXOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportSinusXOp.h @@ -36,7 +36,7 @@ struct HYDROGUI_CurveBlock //{}; std::vector myXYZPoints; int myType; - bool myIsConnected; + bool myIsSpline; bool myIsClosed; int myCurvePlane; QString myName;