afd82eb0e9dc868acff7c6f35b8e72fac1292ca5
[occt.git] / src / StepToGeom / StepToGeom_MakeCurve2d.cxx
1 // Created on: 1993-08-04
2 // Created by: Martine LANGLOIS
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 //:n7 abv 15.02.99: S4132: adding translation of curve_replica
18 //:p0 abv 19.02.99: management of 'done' flag improved
19
20 #include <Geom2d_BSplineCurve.hxx>
21 #include <Geom2d_Conic.hxx>
22 #include <Geom2d_Line.hxx>
23 #include <Geom2d_TrimmedCurve.hxx>
24 #include <Geom2dConvert.hxx>
25 #include <gp_Trsf2d.hxx>
26 #include <StepGeom_BoundedCurve.hxx>
27 #include <StepGeom_CartesianTransformationOperator2d.hxx>
28 #include <StepGeom_Conic.hxx>
29 #include <StepGeom_Curve.hxx>
30 #include <StepGeom_CurveReplica.hxx>
31 #include <StepGeom_HArray1OfTrimmingSelect.hxx>
32 #include <StepGeom_Line.hxx>
33 #include <StepGeom_TrimmedCurve.hxx>
34 #include <StepToGeom_MakeBoundedCurve2d.hxx>
35 #include <StepToGeom_MakeConic2d.hxx>
36 #include <StepToGeom_MakeCurve2d.hxx>
37 #include <StepToGeom_MakeLine2d.hxx>
38 #include <StepToGeom_MakeTransformation2d.hxx>
39
40 //=============================================================================
41 // Creation d' une Curve de Geom2d a partir d' une Curve de Step
42 //=============================================================================
43 Standard_Boolean StepToGeom_MakeCurve2d::Convert (const Handle(StepGeom_Curve)& SC, Handle(Geom2d_Curve)& CC)
44 {
45   if (SC->IsKind(STANDARD_TYPE(StepGeom_Line))) {
46     const Handle(StepGeom_Line) L = Handle(StepGeom_Line)::DownCast(SC);
47         return StepToGeom_MakeLine2d::Convert(L,Handle(Geom2d_Line)::DownCast (CC));
48   }
49   if (SC->IsKind(STANDARD_TYPE(StepGeom_Conic))) {
50     const Handle(StepGeom_Conic) L = Handle(StepGeom_Conic)::DownCast(SC);
51         return StepToGeom_MakeConic2d::Convert(L,Handle(Geom2d_Conic)::DownCast (CC));
52   }
53   if (SC->IsKind(STANDARD_TYPE(StepGeom_BoundedCurve))) {
54     const Handle(StepGeom_BoundedCurve) L = Handle(StepGeom_BoundedCurve)::DownCast(SC);
55         return StepToGeom_MakeBoundedCurve2d::Convert(L,Handle(Geom2d_BoundedCurve)::DownCast (CC));
56   }
57   if (SC->IsKind(STANDARD_TYPE(StepGeom_CurveReplica))) { //:n7 abv 16 Feb 99
58     const Handle(StepGeom_CurveReplica) CR = Handle(StepGeom_CurveReplica)::DownCast(SC);
59     const Handle(StepGeom_Curve) PC = CR->ParentCurve();
60     const Handle(StepGeom_CartesianTransformationOperator2d) T =
61       Handle(StepGeom_CartesianTransformationOperator2d)::DownCast(CR->Transformation());
62     // protect against cyclic references and wrong type of cartop
63     if ( !T.IsNull() && PC != SC )
64     {
65       Handle(Geom2d_Curve) C1;
66       if (StepToGeom_MakeCurve2d::Convert(PC,C1))
67       {
68         gp_Trsf2d T1;
69         if (StepToGeom_MakeTransformation2d::Convert(T,T1))
70         {
71           C1->Transform ( T1 );
72           CC = C1;
73           return Standard_True;
74                 }
75       }
76     }
77   }
78   return Standard_False;
79 }