+ BRep_Builder aBuilder;
+ TopoDS_Compound aComp;
+ aBuilder.MakeCompound( aComp );
+ for( int iSection = 0 ; iSection < theCurve->getNbSections() ; iSection++ )
+ {
+ int theISection = iSection;
+
+ CurveCreator::SectionType aSectType = theCurve->getSectionType( theISection );
+ int aPointSize = theCurve->getNbPoints( theISection );
+ bool aSectIsClosed = theCurve->isClosed( theISection );
+ bool isPolyline = aSectType == CurveCreator::Polyline;
+ int iPoint = 0;
+ gp_Pnt aPrevPoint, aPoint;
+ if ( aPointSize == 1 ) {
+ CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPoint );
+ TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
+ aBuilder.Add( aComp, aVertex );
+ }
+ else if ( aPointSize > 1 ) {
+ Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt (1, aPointSize);
+ int aHIndex = 1;
+
+ TopoDS_Edge aPointEdge;
+ TopoDS_Vertex aVertex;
+ CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPoint );
+ aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
+ aBuilder.Add( aComp, aVertex );
+ aHCurvePoints->SetValue(aHIndex++, aPoint);
+ aPrevPoint = aPoint;
+ iPoint++;
+ for( ; iPoint < aPointSize; iPoint++ ) {
+ CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPoint );
+ aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
+ aBuilder.Add( aComp, aVertex );
+ aHCurvePoints->SetValue(aHIndex++, aPoint);
+ if ( isPolyline ) {
+ 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 );
+ if ( isPolyline ) {
+ aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge();
+ aBuilder.Add( aComp, aPointEdge );
+ }
+ }
+ if( !isPolyline ) {
+ // compute BSpline
+ Handle(Geom_BSplineCurve) aBSplineCurve;
+ 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();
+ aBuilder.Add( aComp, aWire );
+ }
+ }
+ }
+ theShape = aComp;
+}
+
+class ComparePnt
+{
+public:
+ ComparePnt( const gp_Pnt& thePoint ) : myPoint( thePoint) {};
+ ~ComparePnt() {}
+
+ bool operator < ( const ComparePnt& theOtherPoint ) const
+ {
+ bool isLess = myPoint.X() < theOtherPoint.myPoint.X();
+ if ( !isLess && myPoint.X() == theOtherPoint.myPoint.X() ) {
+ isLess = myPoint.Y() < theOtherPoint.myPoint.Y();
+ if ( !isLess && myPoint.Y() == theOtherPoint.myPoint.Y() )
+ isLess = myPoint.Z() < theOtherPoint.myPoint.Z();
+ }
+ return isLess;
+ }
+private:
+ gp_Pnt myPoint;
+};
+
+void CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theContext,
+ const CurveCreator_ICurve* theCurve,
+ CurveCreator_ICurve::SectionToPointList& thePoints )
+{
+ thePoints.clear();