#include <BRepLib_MakeWire.hxx>
#include <BRep_Builder.hxx>
+
+
IMPLEMENT_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
IMPLEMENT_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry )
HYDROData_SequenceOfObjects objs = GetProfiles();
double ddz = GetDDZ();
double step = GetSpatialStep();
- CreateProfilesFromDTM( objs, ddz, step, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, true, true );
+ CreateProfilesFromDTM( objs, ddz, step, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, true, true, std::set<int>() );
SetAltitudePoints( points );
SetShape( DataTag_LeftBankShape, OutLeftB);
TopoDS_Shape& OutInlet,
TopoDS_Shape& OutOutlet,
bool Create3dPres,
- bool Create2dPres)
+ bool Create2dPres,
+ std::set<int> InvInd)
{
int aLower = InpProfiles.Lower(), anUpper = InpProfiles.Upper();
if( ddz>EPS && step>EPS )
CreateProfiles(profiles, ddz, step, left, right, points, main_profiles,
- Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, Create3dPres, Create2dPres );
+ Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, Create3dPres, Create2dPres, InvInd );
}
void HYDROData_DTM::ProjWireOnPlane(const TopoDS_Wire& inpWire, const Handle_Geom_Plane& RefPlane, TopoDS_Wire& outWire)
TopoDS_Shape& OutInlet,
TopoDS_Shape& OutOutlet,
bool Create3dPres,
- bool Create2dPres)
+ bool Create2dPres,
+ std::set<int> InvInd)
{
if (theProfiles.empty())
return;
- theOutPoints = Interpolate( theProfiles, theDDZ, theSpatialStep, theOutLeft, theOutRight, theOutMainProfiles );
+ theOutPoints = Interpolate( theProfiles, theDDZ, theSpatialStep, theOutLeft, theOutRight, theOutMainProfiles, InvInd );
//note that if Create3dPres is false => Create2dPres flag is meaningless!
if (Create3dPres)
{
void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& theProfile,
double theXCurv, double theMinZ, double theMaxZ, double theDDZ,
CurveUZ& theMidPointCurve,
- CurveUZ& theWidthCurve,
- double theTolerance )
+ CurveUZ& theWidthCurve,
+ int& intersection_nb,
+ double theTolerance)
{
double aDblMax = std::numeric_limits<double>::max(),
aUMin = aDblMax,
intersections.push_back( anIntersect.Point( k ) );
}
- if( intersections.size() >= 2 )
+ intersection_nb = intersections.size();
+ if( intersection_nb >= 2 )
{
double u_mid, u_wid;
if( !CalcMidWidth( intersections, u_mid, u_wid ) )
double theXCurvA,
const Handle_HYDROData_Profile& theProfileB,
double theXCurvB,
- double theDDZ, int theNbSteps, bool isAddSecond )
+ double theDDZ, int theNbSteps, bool isAddSecond,
+ int& inter_nb_1, int& inter_nb_2)
{
double zminA, zmaxA, zminB, zmaxB;
gp_Pnt lowestA, lowestB;
CurveUZ midA(0, gp_Vec2d()), midB(0, gp_Vec2d());
CurveUZ widA(0, gp_Vec2d()), widB(0, gp_Vec2d());
- ProfileDiscretization( theProfileA, theXCurvA, zmin, zmax, theDDZ, midA, widA );
- ProfileDiscretization( theProfileB, theXCurvB, zmin, zmax, theDDZ, midB, widB );
+ ProfileDiscretization( theProfileA, theXCurvA, zmin, zmax, theDDZ, midA, widA, inter_nb_1 );
+ ProfileDiscretization( theProfileB, theXCurvB, zmin, zmax, theDDZ, midB, widB, inter_nb_2 );
std::vector<CurveUZ> mid, wid;
Interpolate( midA, midB, theNbSteps, mid, isAddSecond );
double theDDZ, double theSpatialStep,
AltitudePoints& theLeft,
AltitudePoints& theRight,
- std::vector<AltitudePoints>& theMainProfiles )
+ std::vector<AltitudePoints>& theMainProfiles,
+ std::set<int> invalInd)
{
AltitudePoints points;
size_t n = theProfiles.size();
bool isAddSecond = i==n1-1;
// 1. Calculate interpolated profiles
+ int inter_nb_1, inter_nb_2;
std::vector<AltitudePoints> local_points = Interpolate( aHydraulicAxis, theProfiles[i], distances[i],
- theProfiles[i+1], distances[i+1], theDDZ, aNbSteps, isAddSecond );
+ theProfiles[i+1], distances[i+1], theDDZ, aNbSteps, isAddSecond, inter_nb_1, inter_nb_2 );
int lps = local_points.size();
+ if (inter_nb_1 >= 2)
+ invalInd.insert(i);
+
+ if (inter_nb_2 >= 2)
+ invalInd.insert(i+1);
+
// 2. Put all points into the global container
for( size_t j=0; j<lps; j++ )
{
#include "HYDROData_Bathymetry.h"
#include <vector>
+#include <set>
#include <gp_Pnt2d.hxx>
class Handle_HYDROData_Profile;
double theXCurv, double theMinZ, double theMaxZ, double theDDZ,
CurveUZ& theMidPointCurve,
CurveUZ& theWidthCurve,
+ int& intersection_nb,
double theTolerance = 1E-6 );
static void CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
double theXCurvA,
const Handle_HYDROData_Profile& theProfileB,
double theXCurvB,
- double theDDZ, int theNbSteps, bool isAddSecond );
+ double theDDZ, int theNbSteps, bool isAddSecond,
+ int& inter_nb_1, int& inter_nb_2 );
static AltitudePoints Interpolate( const std::vector<Handle_HYDROData_Profile>& theProfiles,
double theDDZ, double theSpatialStep,
AltitudePoints& theLeft,
AltitudePoints& theRight,
- std::vector<AltitudePoints>& theMainProfiles );
+ std::vector<AltitudePoints>& theMainProfiles,
+ std::set<int> invalInd );
static void PointToWire(const AltitudePoints& pnts, TopoDS_Wire& W );
TopoDS_Shape& OutInlet,
TopoDS_Shape& OutOutlet,
bool Create3dPres,
- bool Create2dPres );
+ bool Create2dPres,
+ std::set<int> InvInd );
static void Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF );
TopoDS_Shape& OutInlet,
TopoDS_Shape& OutOutlet,
bool Create3dPres,
- bool Create2dPres );
+ bool Create2dPres,
+ std::set<int> InvInd );
};
void HYDROData_Stream::Update()
{
- updateProfilesOrder();
+ if (!GetHydraulicAxis().IsNull())
+ updateProfilesOrder();
// Update bottom polyline if exists
const Handle(HYDROData_Polyline3D) aBottomPolyline = GetBottomPolyline();
if ( theProfile.IsNull() )
return false;
- Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
- if ( aHydAxis.IsNull() )
- return false;
+ // Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
+ // if ( aHydAxis.IsNull() )
+ // return false;
TopoDS_Face aPlane;
- if(!BuildFace(aHydAxis, aPlane))
- return false;
+ BuildRefFace( aPlane );
Standard_Real aPar(.0);
if ( HasReference( theProfile, DataTag_Profile ) || !HasIntersection( theProfile, aPlane, aPar ) )
void HYDROData_Stream::insertProfileInToOrder( const Handle(HYDROData_Profile)& theProfile,
const int theBeforeIndex )
{
- Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
- if ( theProfile.IsNull() || aHydAxis.IsNull() )
+ //Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
+ if ( theProfile.IsNull() )
return;
- TopoDS_Wire aHydraulicWire = TopoDS::Wire( aHydAxis->GetShape() );
+ //TopoDS_Wire aHydraulicWire = TopoDS::Wire( aHydAxis->GetShape() );
TopoDS_Wire aProfileWire = TopoDS::Wire( theProfile->GetTopShape() );
- if ( aHydraulicWire.IsNull() || aProfileWire.IsNull() )
+ if ( aProfileWire.IsNull() )
return;
if ( theBeforeIndex == -1 )
InsertReferenceObject( theProfile, DataTag_Profile, theBeforeIndex );
}
-bool HYDROData_Stream::BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis,
- TopoDS_Face& thePlane )
+void HYDROData_Stream::BuildRefFace( TopoDS_Face& thePlane )
{
- //if ( !IsValidAsAxis( theHydAxis ) )
- // return false;
-
- //TopoDS_Wire aHydraulicWire = TopoDS::Wire( theHydAxis->GetShape() );
- //
- //gp_Ax2 aX2(gp::XOY());
- //gp_Ax3 aX3(aX2);
- //gp_Pln aPln(aX3);
- //Bnd_Box B;
- //BRepBndLib::Add(aHydraulicWire,B);
- //Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
- //B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
- //BRepBuilderAPI_MakeFace aMkr(aPln, axmin-500., axmax+500., aymin-500., aymax+500.); // to be tuned later according max/ Profile deviation
- //if(!aMkr.IsDone() || aMkr.Shape().IsNull()) return false;
thePlane = BRepBuilderAPI_MakeFace(gp_Pln(gp_Pnt(0,0,0),gp_Dir(0,0,1))).Face();
- return true;
}
void HYDROData_Stream::updateProfilesOrder()
return;
TopoDS_Face aPlane;
- if ( !BuildFace( aHydAxis, aPlane ) )
- return;
+ BuildRefFace( aPlane );
Standard_Real aPar( .0 );
/**
* Builds a planar face
*/
- HYDRODATA_EXPORT static bool BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis,
- TopoDS_Face& thePlane );
+ HYDRODATA_EXPORT static void BuildRefFace( TopoDS_Face& thePlane );
/**
* Add new one reference profile object for stream.
aParamLayout->addLayout( aParam1Layout );
aParamLayout->addWidget( myProfiles );
aParamLayout->addLayout( aButtonsLayout );
-
-
-
+
aParamGroup->setLayout( aParamLayout );
// Common
myProfiles->setObjects( aProfiles );
+
myRemoveButton->setEnabled( myProfiles->getObjects().count() > 0 );
myProfiles->setUpdatesEnabled( true );
myHydAxis = aHydraulicAxis->GetName();
TopoDS_Face aPlane;
- if ( HYDROData_Stream::BuildFace( aHydraulicAxis, aPlane ) )
+ HYDROData_Stream::BuildRefFace( aPlane ) ;
+
+ // Stream profiles
+ HYDROData_SequenceOfObjects aStreamProfiles = myEditedObject->GetProfiles();
+ for ( int i = 1, n = aStreamProfiles.Length(); i <= n; ++i )
{
- // Stream profiles
- HYDROData_SequenceOfObjects aStreamProfiles = myEditedObject->GetProfiles();
- for ( int i = 1, n = aStreamProfiles.Length(); i <= n; ++i )
- {
- Handle(HYDROData_Profile) aProfile =
- Handle(HYDROData_Profile)::DownCast( aStreamProfiles.Value( i ) );
- if ( aProfile.IsNull() )
- continue;
-
- QString aProfileName = aProfile->GetName();
-
- Standard_Real aProfilePar = 0.0;
- HYDROData_Stream::HasIntersection( aHydraulicAxis, aProfile, aPlane, aProfilePar );
-
- myProfiles << aProfileName;
- myProfileParams << aProfilePar;
- }
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aStreamProfiles.Value( i ) );
+ if ( aProfile.IsNull() )
+ continue;
+
+ QString aProfileName = aProfile->GetName();
+
+ Standard_Real aProfilePar = 0.0;
+ HYDROData_Stream::HasIntersection( aHydraulicAxis, aProfile, aPlane, aProfilePar );
+
+ myProfiles << aProfileName;
+ myProfileParams << aProfilePar;
+
}
}
}
return false;
}
- // Set the object name
+ bool ToOrder = true;
+
+ if (aHydAxis.IsNull())
+ ToOrder = false;
+
+ myEditedObject->SetProfiles (aRefProfiles, ToOrder) ;
myEditedObject->SetName( anObjectName );
- myEditedObject->SetHydraulicAxis( aHydAxis );
+ if (!aHydAxis.IsNull())
+ myEditedObject->SetHydraulicAxis( aHydAxis );
myEditedObject->SetProfiles( aRefProfiles, false );
myEditedObject->SetDDZ( aPanel->getDDZ() );
myEditedObject->SetSpatialStep( aPanel->getSpatialStep() );
HYDROGUI_StreamDlg* aPanel = ::qobject_cast<HYDROGUI_StreamDlg*>( inputPanel() );
double ddz = aPanel->getDDZ();
double ss = aPanel->getSpatialStep();
+
+ std::set<int> InvInd;
HYDROData_DTM::CreateProfilesFromDTM( aRefProfiles, ddz, ss, HYDROData_Bathymetry::AltitudePoints(), Out3dPres, Out2dPres, OutLeftB, OutRightB,
- OutInlet, OutOutlet, true, true);
+ OutInlet, OutOutlet, true, true, InvInd);
+
+ //TODO!! aPanel->my---;
aPrsDef.myInlet = TopoDS::Wire(OutInlet);
aPrsDef.myOutlet = TopoDS::Wire(OutOutlet);
// return;
TopoDS_Face aPlane;
-
- if ( !HYDROData_Stream::BuildFace( aHydAxis, aPlane ) )
- return;
+ HYDROData_Stream::BuildRefFace( aPlane );
// Get the current profiles list
QStringList aCurrentProfiles = myProfiles;
// Prepare data for intersection check
TopoDS_Face aPlane;
- if ( !HYDROData_Stream::BuildFace( aNewAxis, aPlane ) )
- {
- SUIT_MessageBox::critical( module()->getApp()->desktop(),
- tr( "BAD_SELECTED_POLYLINE_TLT" ),
- tr( "BAD_SELECTED_POLYLINE_MSG" ).arg( theNewAxis ) );
- // To restore the old axis
- updatePanelData();
- return;
- }
+ HYDROData_Stream::BuildRefFace( aPlane );
+ //{
+ // SUIT_MessageBox::critical( module()->getApp()->desktop(),
+ // tr( "BAD_SELECTED_POLYLINE_TLT" ),
+ // tr( "BAD_SELECTED_POLYLINE_MSG" ).arg( theNewAxis ) );
+ // // To restore the old axis
+ // updatePanelData();
+ // return;
+ //}
QStringList aNewProfiles;
QList<double> aNewProfileParams;
aProfile->SetRightPoint( gp_XY( 20, 20 ) );
HYDROData_DTM::CurveUZ aMid( 0.0 ), aWid( 0.0 );
- HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 0.5, aMid, aWid );
+ int dummy = 0;
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 0.5, aMid, aWid, dummy );
CPPUNIT_ASSERT_EQUAL( 11, (int)aMid.size() );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].U, EPS );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].Z, EPS );
aProfile->SetRightPoint( gp_XY( 20, 20 ) );
HYDROData_DTM::CurveUZ aMid( 0.0 ), aWid( 0.0 );
- HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 0.5, aMid, aWid );
+ int dummy = 0 ;
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 0.5, aMid, aWid, dummy );
CPPUNIT_ASSERT_EQUAL( 11, (int)aMid.size() );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.242, aMid[0].U, EPS );
CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].Z, EPS );