X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROCurveCreator%2FCurveCreator_AISCurve.cxx;h=923d0384402d7963f59673d7658f8e34a4b7521d;hb=8edd427af3997521bda72ca3c416cc1d490565d5;hp=b6a2d60aeba7d285115252f3d0324e8c7a2f7234;hpb=100c5bfedd7562979a95346b82e56b257884625d;p=modules%2Fhydro.git diff --git a/src/HYDROCurveCreator/CurveCreator_AISCurve.cxx b/src/HYDROCurveCreator/CurveCreator_AISCurve.cxx index b6a2d60a..923d0384 100644 --- a/src/HYDROCurveCreator/CurveCreator_AISCurve.cxx +++ b/src/HYDROCurveCreator/CurveCreator_AISCurve.cxx @@ -18,7 +18,7 @@ // #include "CurveCreator_AISCurve.hxx" -#include "CurveCreator_ICurve.hxx" +#include "CurveCreator_Curve.hxx" #include #include @@ -28,58 +28,95 @@ #include #include #include +#include #include #include +#include +#include +#include +#include + IMPLEMENT_STANDARD_HANDLE(CurveCreator_AISCurve, AIS_Shape) IMPLEMENT_STANDARD_RTTIEXT(CurveCreator_AISCurve, AIS_Shape) -CurveCreator_AISCurve::CurveCreator_AISCurve( CurveCreator_ICurve* theCurve ) +CurveCreator_AISCurve::CurveCreator_AISCurve( CurveCreator_Curve* theCurve ) : AIS_Shape( TopoDS_Shape() ), myCurve( theCurve ) { } +void CurveCreator_AISCurve::getPoint( const int theISection, const int theIPoint, + gp_Pnt& thePoint ) +{ + double anX, anY, aZ; + myCurve->getCoordinates( theISection, theIPoint, anX, anY, aZ ); + thePoint = gp_Pnt( anX, anY, aZ); +} + +#define MAKE_BUILDER_USE void CurveCreator_AISCurve::Compute( const Handle(PrsMgr_PresentationManager3d)& thePM, const Handle(Prs3d_Presentation)& thePrs, const Standard_Integer theMode ) { thePrs->Clear(); - //AIS_Shape::Compute( thePM, thePrs, theMode ); - for( int iSection = 0 ; iSection < myCurve->getNbSections() ; iSection++ ) { - //TopoDS_Shape aShape; CurveCreator::SectionType aSectType = myCurve->getSectionType( iSection ); - int aSectSize = myCurve->getNbPoints( iSection ); + int aPointSize = myCurve->getNbPoints( iSection ); bool aSectIsClosed = myCurve->isClosed( iSection ); - //if( aSectType == CurveCreator::Polyline ) + if( aSectType == CurveCreator::Polyline ) { - - /*int iPoint = 0; - for( ; iPoint < ( aSectSize - 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 ); + int iPoint = 0; + gp_Pnt aPrevPoint, aPoint; + if ( aPointSize == 1 ) { + getPoint( iSection, iPoint, aPrevPoint ); + TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex( aPrevPoint ).Vertex(); + Set( aVertex ); } - if( aSectSize != 0 ){ - Handle_AIS_Point anAISPnt = getAISPoint(theISection, iPoint); - aSectionRepresentation.push_back( anAISPnt ); - if( isClosed(theISection) && ( aSectSize > 1 ) ){ - Handle_AIS_Line aLine = getAISLine( theISection, iPoint, 0 ); - aSectionRepresentation.push_back( aLine ); + else if ( aPointSize > 1 ) { +#ifdef MAKE_BUILDER_USE + TopoDS_Edge aPointEdge; + BRepBuilderAPI_MakeWire aMakeWire; + getPoint( iSection, iPoint, aPrevPoint ); + iPoint++; + for( ; iPoint < aPointSize; iPoint++ ) { + getPoint( iSection, iPoint, aPoint ); + aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge(); + aMakeWire.Add( BRepBuilderAPI_MakeWire( aPointEdge ) ); + aPrevPoint = aPoint; } + if( myCurve->isClosed( iSection ) && ( aPointSize > 2 ) ) { + getPoint( iSection, 0, aPoint ); + aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge(); + aMakeWire.Add( BRepBuilderAPI_MakeWire( aPointEdge ) ); + } + + TopoDS_Wire aLineWire = aMakeWire.Wire(); + Set( aLineWire ); + AIS_Shape::Compute( thePM, thePrs, theMode ); + } +#else + bool isClosed = myCurve->isClosed( iSection ) && ( aPointSize > 2 ); + Handle(Graphic3d_ArrayOfPolylines) anArray = new Graphic3d_ArrayOfPolylines + ( !isClosed ? aPointSize : aPointSize+1 ); + for( ; iPoint < aPointSize; iPoint++ ) { + getPoint( iSection, iPoint, aPoint ); + anArray->AddVertex(aPoint.X(), aPoint.Y(), aPoint.Z()); + } + + if( myCurve->isClosed( iSection ) && ( aPointSize > 2 ) ) { + getPoint( iSection, 0, aPoint ); + anArray->AddVertex(aPoint.X(), aPoint.Y(), aPoint.Z()); } - */ + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( thePrs ); + aGroup->AddPrimitiveArray(anArray); +#endif } - //else if( aSectType == CurveCreator::Spline ) + else if( aSectType == CurveCreator::Spline ) { std::vector aPoints; - for( int iPoint = 0; iPoint < aSectSize; iPoint++ ) + for( int iPoint = 0; iPoint < aPointSize; iPoint++ ) { - /*Handle_AIS_Point anAISPnt = getAISPoint( theISection, iPoint ); - aSectionRepresentation.push_back( anAISPnt ); - */ CurveCreator::Coordinates aCoords = myCurve->getPoint( iSection, iPoint ); double aX = aCoords[0]; double aY = aCoords[1]; @@ -87,9 +124,10 @@ void CurveCreator_AISCurve::Compute( const Handle(PrsMgr_PresentationManager3d)& aPoints.push_back( aX ); aPoints.push_back( aY ); } - if( aSectSize > 1 ) + if( aPointSize > 1 ) { Handle(Geom_BSplineCurve) aBSplineCurve; + Handle(Geom_Curve) aGeomCurve; // fill array for algorithm by the received coordinates int aLen = aPoints.size() / 2; Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt (1, aLen);