#include "HYDROGUI_AISCurve.h"
-#include "CurveCreator_Curve.hxx"
+#include <HYDROOperations_BSpline.h>
+
+#include <CurveCreator_Curve.hxx>
#include <AIS_Point.hxx>
#include <AIS_Line.hxx>
-
+#include <AIS_Shape.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <Geom_CartesianPoint.hxx>
#include <gp_Pnt.hxx>
#include <gp_Lin.hxx>
-
-#include <Geom_CartesianPoint.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
HYDROGUI_AISCurveSection::HYDROGUI_AISCurveSection( Handle_AIS_InteractiveContext theContext,
CurveCreator_Curve* theCurve, int theSection) :
Quantity_Color aColor = getActiveColor();
for( int i = 0 ; i < myObjects.size() ; i++ ){
myObjects[i]->SetColor(aColor);
- myContext->Display(myObjects[i]);
+ myContext->Display(myObjects[i], Standard_False);
}
+ myContext->UpdateCurrentViewer();
}
void HYDROGUI_AISCurveSection::Display()
{
for( int i = 0 ; i < myObjects.size() ; i++ ){
- myContext->Display(myObjects[i]);
+ myContext->Display(myObjects[i], Standard_False);
}
+ myContext->UpdateCurrentViewer();
}
void HYDROGUI_AISCurveSection::Erase()
{
for( int i = 0 ; i < myObjects.size() ; i++ ){
- myContext->Erase(myObjects[i]);
+ myContext->Erase(myObjects[i], Standard_False);
}
+ myContext->UpdateCurrentViewer();
}
void HYDROGUI_AISCurveSection::buildSection()
{
+ CurveCreator::Type aSectType = myCurve->getType( mySection );
int aSectSize = myCurve->getNbPoints( mySection );
- double anX;
- double anY;
- double aZ;
- int i = 0;
- for( ; i < ( aSectSize - 1 ) ; i++ ){
- Handle_AIS_Point anAISPnt = getAISPoint(i);
- myObjects.push_back( anAISPnt );
- Handle_AIS_Line aLine = getAISLine( i, i+1 );
- myObjects.push_back( aLine );
- }
- if( aSectSize != 0 ){
- Handle_AIS_Point anAISPnt = getAISPoint(i);
- myObjects.push_back( anAISPnt );
- if( myCurve->isClosed(mySection) && ( aSectSize > 1 ) ){
- Handle_AIS_Line aLine = getAISLine( i, 0 );
+ bool aSectIsClosed = myCurve->isClosed( mySection );
+
+ if( aSectType == CurveCreator::Polyline )
+ {
+ int i = 0;
+ for( ; i < ( aSectSize - 1 ) ; i++ ){
+ Handle_AIS_Point anAISPnt = getAISPoint(i);
+ myObjects.push_back( anAISPnt );
+ Handle_AIS_Line aLine = getAISLine( i, i+1 );
myObjects.push_back( aLine );
}
+ if( aSectSize != 0 ){
+ Handle_AIS_Point anAISPnt = getAISPoint(i);
+ myObjects.push_back( anAISPnt );
+ if( myCurve->isClosed(mySection) && ( aSectSize > 1 ) ){
+ Handle_AIS_Line aLine = getAISLine( i, 0 );
+ myObjects.push_back( aLine );
+ }
+ }
+ }
+ else if( aSectType == CurveCreator::BSpline )
+ {
+ QList<double> aPoints;
+ for( int i = 0; i < aSectSize; i++ )
+ {
+ Handle_AIS_Point anAISPnt = getAISPoint( i );
+ myObjects.push_back( anAISPnt );
+
+ double aX = 0, aY = 0, aZ = 0;
+ getPoint( i, aX, aY, aZ );
+ aPoints << aX << aY;
+ }
+
+ if( aSectSize > 1 )
+ {
+ HYDROOperations_BSpline aBSpline( aPoints, aSectIsClosed );
+ TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge();
+
+ TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire();
+
+ Handle(AIS_Shape) aShape = new AIS_Shape( aWire );
+ myObjects.push_back( aShape );
+ }
}
}