From: nds Date: Tue, 3 Dec 2013 15:32:50 +0000 (+0000) Subject: OCC functionality moving out from the widget X-Git-Tag: BR_hydro_v_0_4~75 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c3e4d5bddd44c587d45f0e1d908d58c7ade3d094;p=modules%2Fhydro.git OCC functionality moving out from the widget --- diff --git a/src/HYDROCurveCreator/CurveCreator_Curve.cxx b/src/HYDROCurveCreator/CurveCreator_Curve.cxx index cab312d6..12952013 100644 --- a/src/HYDROCurveCreator/CurveCreator_Curve.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Curve.cxx @@ -182,58 +182,17 @@ int CurveCreator_Curve::toICoord(const int theIPnt) const return theIPnt * myDimension; } -//#define USE_COMPOUND std::vector CurveCreator_Curve::constructSection( int theISection ) const { std::vector aSectionRepresentation; - CurveCreator::SectionType aSectType = getSectionType( theISection ); - bool isShapeConstruct = false; -#ifdef USE_COMPOUND - isShapeConstruct = true; -#else - isShapeConstruct = aSectType == CurveCreator::Spline; -#endif + TopoDS_Shape aShape; + CurveCreator_Utils::constructShape( this, theISection, aShape, aSectionRepresentation ); - if ( isShapeConstruct ) { - TopoDS_Shape aShape; - CurveCreator_Utils::constructShape( this, theISection, aShape ); - AIS_Shape* anAISShape = new AIS_Shape( aShape ); - //aShape->SetSelectionMode( AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) ); - aSectionRepresentation.push_back( anAISShape ); - if ( aSectType != CurveCreator::Spline ) - return aSectionRepresentation; - } + AIS_Shape* anAISShape = new AIS_Shape( aShape ); + //aShape->SetSelectionMode( AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) ); + aSectionRepresentation.push_back( anAISShape ); - int aPointSize = getNbPoints( theISection ); - bool aSectIsClosed = isClosed( theISection ); - if( aSectType == CurveCreator::Polyline ) - { - int iPoint = 0; - for( ; iPoint < ( aPointSize - 1 ) ; iPoint++ ){ - Handle_AIS_Point anAISPnt = getAISPoint(theISection, iPoint); - aSectionRepresentation.push_back( anAISPnt ); - Handle_AIS_Line aLine = getAISLine( theISection, iPoint, iPoint+1 ); - aSectionRepresentation.push_back( aLine ); - } - if( aPointSize != 0 ){ - Handle_AIS_Point anAISPnt = getAISPoint(theISection, iPoint); - aSectionRepresentation.push_back( anAISPnt ); - if( isClosed(theISection) && ( aPointSize > 1 ) ){ - Handle_AIS_Line aLine = getAISLine( theISection, iPoint, 0 ); - aSectionRepresentation.push_back( aLine ); - } - } - } - else if( aSectType == CurveCreator::Spline ) - { - std::vector aPoints; - for( int iPoint = 0; iPoint < aPointSize; iPoint++ ) - { - Handle_AIS_Point anAISPnt = getAISPoint( theISection, iPoint ); - aSectionRepresentation.push_back( anAISPnt ); - } - } return aSectionRepresentation; } @@ -335,6 +294,7 @@ void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& } } +//#define USE_COMPOUND void CurveCreator_Curve::redisplayCurve() { if( myDisplayer ) { diff --git a/src/HYDROCurveCreator/CurveCreator_Curve.hxx b/src/HYDROCurveCreator/CurveCreator_Curve.hxx index 339a485f..09811188 100644 --- a/src/HYDROCurveCreator/CurveCreator_Curve.hxx +++ b/src/HYDROCurveCreator/CurveCreator_Curve.hxx @@ -110,9 +110,9 @@ protected: */ virtual bool addEmptyDiff(); +public: // TODO: remove public Handle_AIS_Point getAISPoint( int theISection, int theIPoint ) const; Handle_AIS_Line getAISLine( int theISection, int theIPoint1, int theIPoint2 ) const; -public: // TODO: remove public void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const; protected: // TODO: remove public void redisplayCurve(); diff --git a/src/HYDROCurveCreator/CurveCreator_Utils.cxx b/src/HYDROCurveCreator/CurveCreator_Utils.cxx index c05b926a..39084ac6 100644 --- a/src/HYDROCurveCreator/CurveCreator_Utils.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Utils.cxx @@ -86,8 +86,10 @@ gp_Pnt CurveCreator_Utils::ConvertClickToPoint( int x, int y, Handle(V3d_View) a //#define USE_COMPOUND +#include "CurveCreator_Curve.hxx" // TODO - remove void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve, - const int theISection, TopoDS_Shape& theShape ) + const int theISection, TopoDS_Shape& theShape, + std::vector& aSectionRepresentation ) { CurveCreator::SectionType aSectType = theCurve->getSectionType( theISection ); @@ -96,7 +98,7 @@ void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve, bool aSectIsClosed = theCurve->isClosed( theISection ); if( aSectType == CurveCreator::Polyline ) { -//#ifdef USE_COMPOUND +#ifdef USE_COMPOUND BRep_Builder aBuilder; TopoDS_Compound aComp; aBuilder.MakeCompound(aComp); @@ -123,7 +125,7 @@ void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve, aBuilder.Add( aComp, aPointEdge ); aPrevPoint = aPoint; } - if( theCurve->isClosed( theISection ) && ( aPointSize > 2 ) ) { + if( aSectIsClosed && ( aPointSize > 2 ) ) { CurveCreator_UtilsICurve::getPoint( theCurve, theISection, 0, aPoint ); aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex(); aBuilder.Add( aComp, aVertex ); @@ -132,12 +134,11 @@ void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve, } theShape = aComp; } -//#endif +#endif } else if( aSectType == CurveCreator::Spline ) { #ifdef USE_COMPOUND - #else std::vector aPoints; for( int iPoint = 0; iPoint < aPointSize; iPoint++ ) @@ -182,6 +183,40 @@ void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve, } #endif } + +#ifndef USE_COMPOUND + const CurveCreator_Curve* aCurve = dynamic_cast( theCurve ); + if ( !aCurve ) + return; + + if( aSectType == CurveCreator::Polyline ) + { + int iPoint = 0; + for( ; iPoint < ( aPointSize - 1 ) ; iPoint++ ){ + Handle_AIS_Point anAISPnt = aCurve->getAISPoint(theISection, iPoint); + aSectionRepresentation.push_back( anAISPnt ); + Handle_AIS_Line aLine = aCurve->getAISLine( theISection, iPoint, iPoint+1 ); + aSectionRepresentation.push_back( aLine ); + } + if( aPointSize != 0 ){ + Handle_AIS_Point anAISPnt = aCurve->getAISPoint(theISection, iPoint); + aSectionRepresentation.push_back( anAISPnt ); + if( aSectIsClosed && ( aPointSize > 1 ) ){ + Handle_AIS_Line aLine = aCurve->getAISLine( theISection, iPoint, 0 ); + aSectionRepresentation.push_back( aLine ); + } + } + } + else if( aSectType == CurveCreator::Spline ) + { + std::vector aPoints; + for( int iPoint = 0; iPoint < aPointSize; iPoint++ ) + { + Handle_AIS_Point anAISPnt = aCurve->getAISPoint( theISection, iPoint ); + aSectionRepresentation.push_back( anAISPnt ); + } + } +#endif } std::list CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theContext ) diff --git a/src/HYDROCurveCreator/CurveCreator_Utils.h b/src/HYDROCurveCreator/CurveCreator_Utils.h index 49694656..cc0817fa 100644 --- a/src/HYDROCurveCreator/CurveCreator_Utils.h +++ b/src/HYDROCurveCreator/CurveCreator_Utils.h @@ -23,12 +23,14 @@ #include "CurveCreator_Macro.hxx" #include +#include // TODO: remove #include #include #include #include #include +#include // TODO: remove class CurveCreator_ICurve; @@ -67,7 +69,8 @@ public: */ CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve, const int theISection, - TopoDS_Shape& theShape ); + TopoDS_Shape& theShape, + std::vector& theAdditional ); /** * Find selected points in the context