// Created on: 1994-03-24
// Created by: Bruno DUMORTIER
// Copyright (c) 1994-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
-
-#include <Geom2dAPI_InterCurveCurve.ixx>
-
-#include <Geom2dAdaptor_Curve.hxx>
+#include <Geom2d_Curve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2dAdaptor_Curve.hxx>
+#include <Geom2dAPI_InterCurveCurve.hxx>
+#include <Geom2dInt_GInter.hxx>
+#include <gp_Pnt2d.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <IntRes2d_IntersectionSegment.hxx>
-
#include <Standard_NotImplemented.hxx>
+#include <Standard_NullObject.hxx>
+#include <Standard_OutOfRange.hxx>
//=======================================================================
//function : Geom2dAPI_InterCurveCurve
//purpose :
//=======================================================================
-
Geom2dAPI_InterCurveCurve::Geom2dAPI_InterCurveCurve()
{
myIsDone = Standard_False;
//=======================================================================
//function : Segment
//purpose :
+// If aSeg.IsOpposite() == TRUE
+//
+// U1 U2
+// Curve 1: *------------>*
+//
+// V2 V1
+// Curve 2: *<------------*
+//
+// Segment: FirstPoint--->LastPoint
+//
+//
+// If aSeg.IsOpposite() == FALSE
+//
+// U1 U2
+// Curve 1: *------------>*
+//
+// V1 V2
+// Curve 2: *------------>*
+//
+// Segment: FirstPoint--->LastPoint
//=======================================================================
void Geom2dAPI_InterCurveCurve::Segment
- (const Standard_Integer Index,
- Handle(Geom2d_Curve)& Curve1,
- Handle(Geom2d_Curve)& Curve2) const
+ (const Standard_Integer theIndex,
+ Handle(Geom2d_Curve)& theCurve1,
+ Handle(Geom2d_Curve)& theCurve2) const
{
- Standard_OutOfRange_Raise_if(Index < 0 || Index > NbSegments(),
- "Geom2dAPI_InterCurveCurve::Segment");
-
- Standard_NullObject_Raise_if(myCurve2.IsNull(),
- "Geom2dAPI_InterCurveCurve::Segment");
-
- Standard_Real U1, U2, V1, V2;
-
- IntRes2d_IntersectionSegment Seg = myIntersector.Segment(Index);
- if ( Seg.IsOpposite()) {
- if ( Seg.HasFirstPoint()) {
- IntRes2d_IntersectionPoint IP1 = Seg.FirstPoint();
- U1 = IP1.ParamOnFirst();
- V2 = IP1.ParamOnSecond();
- }
- else {
- U1 = Curve1->FirstParameter();
- V2 = Curve2->LastParameter();
- }
- if ( Seg.HasLastPoint()) {
- IntRes2d_IntersectionPoint IP2 = Seg.LastPoint();
- U2 = IP2.ParamOnFirst();
- V1 = IP2.ParamOnSecond();
- }
- else {
- U2 = Curve1->FirstParameter();
- V1 = Curve2->LastParameter();
- }
+ Standard_OutOfRange_Raise_if(theIndex < 1 || theIndex > NbSegments(),
+ "Geom2dAPI_InterCurveCurve::Segment");
+
+ Standard_NullObject_Raise_if(myCurve1.IsNull(),
+ "Geom2dAPI_InterCurveCurve::Segment");
+
+ Standard_Real aU1, aU2, aV1, aV2;
+ aU1 = myCurve1->FirstParameter();
+ aU2 = myCurve1->LastParameter();
+ if (myCurve2.IsNull())
+ {
+ aV1 = aU1;
+ aV2 = aU2;
}
- else {
- if ( Seg.HasFirstPoint()) {
- IntRes2d_IntersectionPoint IP1 = Seg.FirstPoint();
- U1 = IP1.ParamOnFirst();
- V1 = IP1.ParamOnSecond();
- }
- else {
- U1 = Curve1->FirstParameter();
- V1 = Curve2->FirstParameter();
- }
- if ( Seg.HasLastPoint()) {
- IntRes2d_IntersectionPoint IP2 = Seg.LastPoint();
- U2 = IP2.ParamOnFirst();
- V2 = IP2.ParamOnSecond();
- }
- else {
- U2 = Curve1->FirstParameter();
- V2 = Curve2->FirstParameter();
- }
+ else
+ {
+ aV1 = myCurve2->FirstParameter();
+ aV2 = myCurve2->LastParameter();
}
- Curve1 = new Geom2d_TrimmedCurve(myCurve1, U1, U2);
- Curve2 = new Geom2d_TrimmedCurve(myCurve2, V1, V2);
-
-}
-
-
-//=======================================================================
-//function : Segment
-//purpose :
-//=======================================================================
+ const IntRes2d_IntersectionSegment& aSeg = myIntersector.Segment(theIndex);
+ const Standard_Boolean isOpposite = aSeg.IsOpposite();
+
+ if(aSeg.HasFirstPoint())
+ {
+ const IntRes2d_IntersectionPoint& anIPF = aSeg.FirstPoint();
+ aU1 = anIPF.ParamOnFirst();
+
+ if(isOpposite)
+ aV2 = anIPF.ParamOnSecond();
+ else
+ aV1 = anIPF.ParamOnSecond();
+ }
-void Geom2dAPI_InterCurveCurve::Segment (const Standard_Integer Index,
- Handle(Geom2d_Curve)&) const
-{
- Standard_NotImplemented::Raise(" ");
+ if(aSeg.HasLastPoint())
+ {
+ const IntRes2d_IntersectionPoint& anIPL = aSeg.LastPoint();
+ aU2 = anIPL.ParamOnFirst();
- Standard_OutOfRange_Raise_if(Index < 0 || Index > NbSegments(),
- "Geom2dAPI_InterCurveCurve::Segment");
+ if(isOpposite)
+ aV1 = anIPL.ParamOnSecond();
+ else
+ aV2 = anIPL.ParamOnSecond();
+ }
+ theCurve1 = new Geom2d_TrimmedCurve(myCurve1, aU1, aU2);
+ if (myCurve2.IsNull())
+ theCurve2 = new Geom2d_TrimmedCurve(myCurve1, aV1, aV2);
+ else
+ theCurve2 = new Geom2d_TrimmedCurve(myCurve2, aV1, aV2);
}