From 020782794048cec8416dbf9fe8d962fac2ae4478 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 4 Dec 2013 04:08:29 +0000 Subject: [PATCH] OCC functionality moving out from the widget One compound shape for curve sections. --- src/HYDROCurveCreator/CurveCreator_Curve.cxx | 64 --------- src/HYDROCurveCreator/CurveCreator_Curve.hxx | 9 -- src/HYDROCurveCreator/CurveCreator_Utils.cxx | 129 ------------------- src/HYDROCurveCreator/CurveCreator_Utils.h | 11 -- 4 files changed, 213 deletions(-) diff --git a/src/HYDROCurveCreator/CurveCreator_Curve.cxx b/src/HYDROCurveCreator/CurveCreator_Curve.cxx index 26268884..ac43473c 100644 --- a/src/HYDROCurveCreator/CurveCreator_Curve.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Curve.cxx @@ -28,8 +28,6 @@ #include "CurveCreator_Displayer.h" #include "CurveCreator_Utils.h" -#include -#include #include #include #include @@ -182,20 +180,6 @@ int CurveCreator_Curve::toICoord(const int theIPnt) const return theIPnt * myDimension; } -std::vector CurveCreator_Curve::constructSection( int theISection ) const -{ - std::vector aSectionRepresentation; - - TopoDS_Shape aShape; - CurveCreator_Utils::constructShape( this, theISection, aShape, aSectionRepresentation ); - - AIS_Shape* anAISShape = new AIS_Shape( aShape ); - //aShape->SetSelectionMode( AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) ); - aSectionRepresentation.push_back( anAISShape ); - - return aSectionRepresentation; -} - //======================================================================= // function: setUndoDepth // purpose: @@ -254,35 +238,6 @@ int CurveCreator_Curve::getUndoDepth() const return myUndoDepth; } -Handle_AIS_Point CurveCreator_Curve::getAISPoint( int theISection, int theIPoint ) const -{ - double anX, anY, aZ; - getCoordinates( theISection, theIPoint, anX, anY, aZ ); - gp_Pnt aPoint( anX, anY, aZ); - - AIS_Point* aPnt = new AIS_Point( new Geom_CartesianPoint(aPoint)); - return aPnt; -} - -Handle_AIS_Line CurveCreator_Curve::getAISLine( int theISection, int theIPoint1, int theIPoint2 ) const -{ - double anX, anY, aZ; - getCoordinates( theISection, theIPoint1, anX, anY, aZ ); - gp_Pnt aPoint1( anX, anY, aZ); - - double anX2, anY2, aZ2; - getCoordinates( theISection, theIPoint2, anX2, anY2, aZ2 ); -//MTN to avoid crash during line construction - if( ( anX == anX2 ) && ( anY == anY2 ) && (aZ == aZ2 ) ){ - aZ2 += 1e-7; - } - - gp_Pnt aPoint2( anX2, anY2, aZ2 ); - - AIS_Line* aLine = new AIS_Line( new Geom_CartesianPoint(aPoint1), new Geom_CartesianPoint(aPoint2) ); - return aLine; -} - void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const { CurveCreator::Coordinates aCoords = getPoint( theISection, theIPoint ); @@ -1016,29 +971,10 @@ std::vector CurveCreator_Curve::constructWire() co { std::vector aCurveRepresentation; -#ifndef ONE_SHAPE - std::vector aSectionObjects; - for( int iSection = 0 ; iSection < getNbSections() ; iSection++ ){ - aSectionObjects = constructSection( iSection ); - for( int iObject = 0 ; iObject < aSectionObjects.size() ; iObject++ ){ - aCurveRepresentation.push_back( aSectionObjects.at(iObject) ); - } - } -#else TopoDS_Shape aShape; CurveCreator_Utils::constructShape( this, aShape ); AIS_Shape* anAISShape = new AIS_Shape( aShape ); - //aShape->SetSelectionMode( AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) ); aCurveRepresentation.push_back( anAISShape ); -#endif return aCurveRepresentation; } - -void CurveCreator_Curve::getPoint( const int theISection, const int theIPoint, - gp_Pnt& thePoint ) const -{ - double anX, anY, aZ; - getCoordinates( theISection, theIPoint, anX, anY, aZ ); - thePoint = gp_Pnt( anX, anY, aZ); -} diff --git a/src/HYDROCurveCreator/CurveCreator_Curve.hxx b/src/HYDROCurveCreator/CurveCreator_Curve.hxx index 09811188..67f0242f 100644 --- a/src/HYDROCurveCreator/CurveCreator_Curve.hxx +++ b/src/HYDROCurveCreator/CurveCreator_Curve.hxx @@ -30,8 +30,6 @@ #include "CurveCreator_Diff.hxx" #include "CurveCreator_AISCurve.hxx" -#include -#include #include #include @@ -94,8 +92,6 @@ public: */ virtual int toICoord(const int theIPnt) const; - ListAISObjects constructSection( int theISection ) const; - //! For internal use only! Undo/Redo are not used here. virtual bool moveSectionInternal(const int theISection, const int theNewIndex); @@ -111,8 +107,6 @@ 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; void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const; protected: // TODO: remove public void redisplayCurve(); @@ -270,9 +264,6 @@ public: /***********************************************/ virtual ListAISObjects constructWire() const; -public: // TODO: remove - void getPoint( const int theSectionId, const int thePointId, gp_Pnt& thePoint ) const; - public: Handle(CurveCreator_AISCurve) myAISCurve; bool myIsLocked; diff --git a/src/HYDROCurveCreator/CurveCreator_Utils.cxx b/src/HYDROCurveCreator/CurveCreator_Utils.cxx index 0007e660..5e39c625 100644 --- a/src/HYDROCurveCreator/CurveCreator_Utils.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Utils.cxx @@ -84,135 +84,6 @@ gp_Pnt CurveCreator_Utils::ConvertClickToPoint( int x, int y, Handle(V3d_View) a return GEOMUtils::ConvertClickToPoint( x, y, aView ); } - -//#define USE_COMPOUND -#include "CurveCreator_Curve.hxx" // TODO - remove -void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve, - const int theISection, TopoDS_Shape& theShape, - std::vector& aSectionRepresentation ) -{ - CurveCreator::SectionType aSectType = theCurve->getSectionType( theISection ); - - - int aPointSize = theCurve->getNbPoints( theISection ); - bool aSectIsClosed = theCurve->isClosed( theISection ); - if( aSectType == CurveCreator::Polyline ) - { -#ifdef USE_COMPOUND - BRep_Builder aBuilder; - TopoDS_Compound aComp; - aBuilder.MakeCompound(aComp); - - int iPoint = 0; - gp_Pnt aPrevPoint, aPoint; - if ( aPointSize == 1 ) { - CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPrevPoint ); - TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex( aPrevPoint ).Vertex(); - aBuilder.Add( aComp, aVertex ); - } - else if ( aPointSize > 1 ) { - TopoDS_Edge aPointEdge; - TopoDS_Vertex aVertex; - CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPrevPoint ); - aVertex = BRepBuilderAPI_MakeVertex( aPrevPoint ).Vertex(); - aBuilder.Add( aComp, aVertex ); - iPoint++; - for( ; iPoint < aPointSize; iPoint++ ) { - CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPoint ); - aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex(); - aBuilder.Add( aComp, aVertex ); - aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge(); - aBuilder.Add( aComp, aPointEdge ); - aPrevPoint = aPoint; - } - if( aSectIsClosed && ( aPointSize > 2 ) ) { - CurveCreator_UtilsICurve::getPoint( theCurve, theISection, 0, aPoint ); - aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex(); - aBuilder.Add( aComp, aVertex ); - aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge(); - aBuilder.Add( aComp, aPointEdge ); - } - theShape = aComp; - } -#endif - } - else if( aSectType == CurveCreator::Spline ) - { - std::vector aPoints; - for( int iPoint = 0; iPoint < aPointSize; iPoint++ ) - { - CurveCreator::Coordinates aCoords = theCurve->getPoint( theISection, iPoint ); - double aX = aCoords[0]; - double aY = aCoords[1]; - double aZ = aCoords[2]; - aPoints.push_back( aX ); - aPoints.push_back( aY ); - } - - if( aPointSize > 1 ) - { - Handle(Geom_BSplineCurve) aBSplineCurve; - // fill array for algorithm by the received coordinates - int aLen = aPoints.size() / 2; - Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt (1, aLen); - std::vector::const_iterator aListIter = aPoints.begin(); - for (int ind = 1; ind <= aLen; ind++) { - gp_Pnt aPnt(gp::Origin()); - aPnt.SetX(*aListIter); - aListIter++; - aPnt.SetY(*aListIter); - aListIter++; - aPnt.SetZ(0); - aHCurvePoints->SetValue(ind, aPnt); - } - // compute BSpline - GeomAPI_Interpolate aGBC(aHCurvePoints, aSectIsClosed, gp::Resolution()); - aGBC.Perform(); - if (aGBC.IsDone()) { - aBSplineCurve = aGBC.Curve(); - } - TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSplineCurve ).Edge(); - - TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire(); - theShape = aWire; - } - } - - const CurveCreator_Curve* aCurve = dynamic_cast( theCurve ); - if ( !aCurve ) - return; - - if( aSectType == CurveCreator::Polyline ) - { -#ifndef USE_COMPOUND - 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 ); - } - } -#endif - } - 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 ); - } - } -} - void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve, TopoDS_Shape& theShape ) { diff --git a/src/HYDROCurveCreator/CurveCreator_Utils.h b/src/HYDROCurveCreator/CurveCreator_Utils.h index b81f4cf2..0182d19b 100644 --- a/src/HYDROCurveCreator/CurveCreator_Utils.h +++ b/src/HYDROCurveCreator/CurveCreator_Utils.h @@ -61,17 +61,6 @@ public: CURVECREATOR_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) theView ); - /** - * Generates shape on the curve with a fixed section index - * \param theCurve a curve object, that contains data - * \param theISection a curve section index - * \param theShape a generated shape - */ - CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve, - const int theISection, - TopoDS_Shape& theShape, - std::vector& theAdditional ); - /** * Generates shape on the curve * \param theCurve a curve object, that contains data -- 2.39.2