From: isn Date: Thu, 15 Dec 2016 11:14:25 +0000 (+0300) Subject: refs #1100 X-Git-Tag: Salome_8_3_Hydro_1_1rc1~67^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1a3dbfabc8e29d3330010471798d5e6fffd2fa41;p=modules%2Fhydro.git refs #1100 --- diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx index 2c96221d..6678a8b9 100644 --- a/src/HYDROData/HYDROData_DTM.cxx +++ b/src/HYDROData/HYDROData_DTM.cxx @@ -534,13 +534,14 @@ Handle_Geom2d_BSplineCurve HYDROData_DTM::CreateHydraulicAxis( TColgp_Array1OfVec2d tangents( 1, (int)n ); Handle(TColStd_HArray1OfBoolean) flags = new TColStd_HArray1OfBoolean( 1, (int)n ); - for( size_t i = 1; i <= n; i++ ) + // Stage 1. Orient all profiles to be co-oriented with the first profile + theProfiles[0]->Update(); + for( size_t i = 1; i < n; i++ ) { - Handle_HYDROData_Profile aProfile = theProfiles[i-1]; - Handle_HYDROData_Profile aPrevProfile = i==1 ? theProfiles[i-1] : theProfiles[i-2]; - Handle_HYDROData_Profile aNextProfile = i==n ? theProfiles[i-1] : theProfiles[i]; + Handle_HYDROData_Profile aProfile = theProfiles[i]; + Handle_HYDROData_Profile aPrevProfile = theProfiles[i-1]; - if( !IsCooriented( aProfile, aNextProfile ) ) + if( !IsCooriented( aProfile, aPrevProfile ) ) { gp_XY lp, rp; aProfile->GetLeftPoint( lp, true ); @@ -549,20 +550,22 @@ Handle_Geom2d_BSplineCurve HYDROData_DTM::CreateHydraulicAxis( aProfile->SetRightPoint( lp, true ); } aProfile->Update(); + } + + // Stage 2. Calculate normals so that each normal "points" to the next profile + for( size_t i = 0; i < n; i++ ) + { + Handle_HYDROData_Profile aProfile = theProfiles[i]; + Handle_HYDROData_Profile aNextProfile = i==n-1 ? theProfiles[i-1] : theProfiles[i+1]; gp_Pnt aLowest; gp_Vec2d aNormal; double zmin, zmax; - gp_XYZ curP = aProfile->GetBottomPoint(); + gp_XYZ curP = aProfile->GetBottomPoint(true); gp_XY curP2d = gp_XY(curP.X(), curP.Y()); - gp_XYZ nextP; - if( i==n ) - nextP = aPrevProfile->GetBottomPoint(true); - else - nextP = aNextProfile->GetBottomPoint(true); - + gp_XYZ nextP = aNextProfile->GetBottomPoint(true); gp_XY nextP2d = gp_XY(nextP.X(), nextP.Y()); gp_Vec2d aPrTangent; @@ -570,16 +573,17 @@ Handle_Geom2d_BSplineCurve HYDROData_DTM::CreateHydraulicAxis( aNormal.SetCoord( -aPrTangent.Y(), aPrTangent.X() ); gp_Vec2d aDirToNextProfile(nextP2d.X() - curP2d.X(), nextP2d.Y() - curP2d.Y() ); - if( i==n ) + if( i==n-1 ) aDirToNextProfile.Reverse(); + if (aNormal.Dot(aDirToNextProfile) < 0) aNormal.Reverse(); aNormal.Normalize(); - points->SetValue( (int)i, gp_Pnt2d( aLowest.X(), aLowest.Y() ) ); - tangents.SetValue( (int)i, aNormal ); - flags->SetValue( (int)i, Standard_True ); + points->SetValue( (int)(i+1), gp_Pnt2d( aLowest.X(), aLowest.Y() ) ); + tangents.SetValue( (int)(i+1), aNormal ); + flags->SetValue( (int)(i+1), Standard_True ); } Geom2dAPI_Interpolate anInterpolator( points, Standard_False, Standard_False ); diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx index 93499b74..7745ee0f 100644 --- a/src/HYDROData/HYDROData_Object.cxx +++ b/src/HYDROData/HYDROData_Object.cxx @@ -317,8 +317,8 @@ void HYDROData_Object::checkAndSetAltitudeObject() if ( anAltitudeObjectType == KIND_UNKNOWN ) return; // No need to create altitude object - TDF_Label aLabel = myLab.FindChild( DataTag_ChildAltitudeObject, false ); - if ( !aLabel.IsNull() ) + Handle(HYDROData_IAltitudeObject) altObject = GetAltitudeObject(); + if( !altObject.IsNull() && altObject->GetKind()==anAltitudeObjectType ) return; TDF_Label aChildLabel = myLab.FindChild( DataTag_ChildAltitudeObject ).FindChild( 0 );