+static void ProfileUZToCurveCrProfile(const Handle(HYDROData_ProfileUZ)& aProfileUZ,
+ HYDROGUI_CurveCreatorProfile* outProfile)
+{
+ CurveCreator::Coordinates aCurveCoords;
+ CurveCreator::SectionsMap aSectionsMap;
+
+ HYDROData_ProfileUZ::PointsList aSectPointsList = aProfileUZ->GetPoints();
+ CurveCreator::PosPointsList aPoints;
+ for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
+ {
+ const HYDROData_ProfileUZ::Point& aSectPoint = aSectPointsList.Value( k );
+ aCurveCoords.clear();
+ aCurveCoords.push_back( aSectPoint.X() );
+ aCurveCoords.push_back( aSectPoint.Y() );
+
+ CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( k, aCurveCoords );
+ aPoints.push_back( aPosPoint );
+ }
+
+ aSectionsMap[0] = aPoints;
+ outProfile->addPointsInternal( aSectionsMap );
+
+ HYDROData_ProfileUZ::SectionType aSectType = aProfileUZ->GetSectionType( 0 );
+
+ CurveCreator::SectionType aCurveType = CurveCreator::Polyline;
+ if( aSectType == HYDROData_ProfileUZ::SECTION_SPLINE )
+ aCurveType = CurveCreator::Spline;
+
+ outProfile->setSectionType( 0, aCurveType );
+}
+
+static int CurveCrProfileToHProfile(const HYDROGUI_CurveCreatorProfile* outProfile,
+ Handle(HYDROData_Profile) theProfileObj,
+ const QString theProfileName,
+ bool IsEdit)
+{
+ if( theProfileObj.IsNull() )
+ return 0;
+
+ Handle(HYDROData_ProfileUZ) aProfileUZ = theProfileObj->GetProfileUZ();
+ if ( aProfileUZ.IsNull() )
+ return 0;
+
+ theProfileObj->SetName(theProfileName);
+
+ HYDROData_ProfileUZ::PointsList aProfileParamPoints;
+
+ Handle(TColgp_HArray1OfPnt) aCurveCoords = outProfile->GetDifferentPoints( 0 );
+ if ( aCurveCoords.IsNull() || aCurveCoords->Size() <= 2 )
+ return -1;
+
+ for ( int k = aCurveCoords->Lower(); k <= aCurveCoords->Upper() ; k++ )
+ {
+ HYDROData_ProfileUZ::Point aProfileParamPoint;
+
+ aProfileParamPoint.SetX( aCurveCoords->Value( k ).X() );
+ aProfileParamPoint.SetY( aCurveCoords->Value( k ).Y() );
+
+ aProfileParamPoints.Append( aProfileParamPoint );
+ }
+ theProfileObj->SetParametricPoints( aProfileParamPoints );
+
+ HYDROData_ProfileUZ::SectionType aSectType = HYDROData_ProfileUZ::SECTION_POLYLINE;
+ if ( outProfile->getSectionType( 0 ) == CurveCreator::Spline )
+ aSectType = HYDROData_ProfileUZ::SECTION_SPLINE;
+
+ aProfileUZ->SetSectionType( 0, aSectType );
+
+ if ( !IsEdit )
+ theProfileObj->SetBorderColor( theProfileObj->DefaultBorderColor() );
+
+ // At first we update the child u,z profile object
+ aProfileUZ->Changed( HYDROData_Entity::Geom_2d );
+ aProfileUZ->Update();
+
+ // And now we update our edited object
+ theProfileObj->Update();
+ return 1;
+}
+