b311480e |
1 | // Created on: 1993-07-02 |
2 | // Created by: Martine LANGLOIS |
3 | // Copyright (c) 1993-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | //:n7 abv 16.02.99: S4132: adding translation of curve_replica |
22 | //:o2 abv 17.02.99: S4132: adding translation of offset_curve_3d |
23 | //:o5 abv 17.02.99: bm4_sd_seal_c.stp #58720: translate surface_curve (3d only) |
24 | //:p0 abv 19.02.99: management of 'done' flag improved |
25 | |
26 | #include <StepToGeom_MakeCurve.ixx> |
27 | |
28 | #include <Geom_OffsetCurve.hxx> |
29 | #include <Geom_Direction.hxx> |
30 | |
31 | #include <StepGeom_Curve.hxx> |
32 | #include <StepGeom_TrimmedCurve.hxx> |
33 | #include <StepGeom_Line.hxx> |
34 | #include <StepGeom_Conic.hxx> |
35 | #include <StepGeom_BoundedCurve.hxx> |
36 | #include <StepGeom_CartesianTransformationOperator3d.hxx> |
37 | #include <StepGeom_CurveReplica.hxx> |
38 | #include <StepGeom_OffsetCurve3d.hxx> |
39 | #include <StepGeom_SurfaceCurve.hxx> |
40 | |
41 | #include <StepToGeom_MakeDirection.hxx> |
42 | #include <StepToGeom_MakeTrimmedCurve.hxx> |
43 | #include <StepToGeom_MakeCurve.hxx> |
44 | #include <StepToGeom_MakeLine.hxx> |
45 | #include <StepToGeom_MakeConic.hxx> |
46 | #include <StepToGeom_MakeBoundedCurve.hxx> |
47 | #include <StepToGeom_MakeTransformation3d.hxx> |
48 | |
49 | //============================================================================= |
50 | // Creation d' une Curve de Geom a partir d' une Curve de Step |
51 | //============================================================================= |
52 | |
53 | Standard_Boolean StepToGeom_MakeCurve::Convert (const Handle(StepGeom_Curve)& SC, Handle(Geom_Curve)& CC) |
54 | { |
fb20c143 |
55 | if (SC.IsNull()){ |
56 | return Standard_False; |
57 | } |
7fd59977 |
58 | if (SC->IsKind(STANDARD_TYPE(StepGeom_Line))) { |
59 | const Handle(StepGeom_Line) L = Handle(StepGeom_Line)::DownCast(SC); |
60 | return StepToGeom_MakeLine::Convert(L,*((Handle(Geom_Line)*)&CC)); |
61 | } |
62 | if (SC->IsKind(STANDARD_TYPE(StepGeom_TrimmedCurve))) { |
63 | const Handle(StepGeom_TrimmedCurve) TC = Handle(StepGeom_TrimmedCurve)::DownCast(SC); |
64 | return StepToGeom_MakeTrimmedCurve::Convert(TC,*((Handle(Geom_TrimmedCurve)*)&CC)); |
65 | } |
66 | if (SC->IsKind(STANDARD_TYPE(StepGeom_Conic))) { |
67 | const Handle(StepGeom_Conic) CO = Handle(StepGeom_Conic)::DownCast(SC); |
68 | return StepToGeom_MakeConic::Convert(CO,*((Handle(Geom_Conic)*)&CC)); |
69 | } |
70 | if (SC->IsKind(STANDARD_TYPE(StepGeom_BoundedCurve))) { |
71 | const Handle(StepGeom_BoundedCurve) BC = Handle(StepGeom_BoundedCurve)::DownCast(SC); |
72 | return StepToGeom_MakeBoundedCurve::Convert(BC,*((Handle(Geom_BoundedCurve)*)&CC)); |
73 | } |
74 | if (SC->IsKind(STANDARD_TYPE(StepGeom_CurveReplica))) { //:n7 abv 16 Feb 99 |
75 | const Handle(StepGeom_CurveReplica) CR = Handle(StepGeom_CurveReplica)::DownCast(SC); |
76 | const Handle(StepGeom_Curve) PC = CR->ParentCurve(); |
77 | const Handle(StepGeom_CartesianTransformationOperator3d) T = |
78 | Handle(StepGeom_CartesianTransformationOperator3d)::DownCast(CR->Transformation()); |
79 | // protect against cyclic references and wrong type of cartop |
80 | if ( !T.IsNull() && PC != SC ) |
81 | { |
82 | Handle(Geom_Curve) C1; |
83 | if (StepToGeom_MakeCurve::Convert(PC,C1)) |
84 | { |
85 | gp_Trsf T1; |
86 | if (StepToGeom_MakeTransformation3d::Convert(T,T1)) |
87 | { |
88 | C1->Transform ( T1 ); |
89 | CC = C1; |
90 | return Standard_True; |
91 | } |
92 | } |
93 | } |
94 | } |
95 | else if (SC->IsKind(STANDARD_TYPE(StepGeom_OffsetCurve3d))) { //:o2 abv 17 Feb 99 |
96 | const Handle(StepGeom_OffsetCurve3d) OC = Handle(StepGeom_OffsetCurve3d)::DownCast(SC); |
97 | const Handle(StepGeom_Curve) BC = OC->BasisCurve(); |
98 | if ( BC != SC ) { // protect against loop |
99 | Handle(Geom_Curve) C1; |
100 | if (StepToGeom_MakeCurve::Convert(BC,C1)) |
101 | { |
102 | Handle(Geom_Direction) RD; |
103 | if (StepToGeom_MakeDirection::Convert(OC->RefDirection(),RD)) |
104 | { |
105 | CC = new Geom_OffsetCurve ( C1, -OC->Distance(), RD->Dir() ); |
106 | return Standard_True; |
107 | } |
108 | } |
109 | } |
110 | } |
111 | else if (SC->IsKind(STANDARD_TYPE(StepGeom_SurfaceCurve))) { //:o5 abv 17 Feb 99 |
112 | const Handle(StepGeom_SurfaceCurve) SurfC = Handle(StepGeom_SurfaceCurve)::DownCast(SC); |
113 | return StepToGeom_MakeCurve::Convert(SurfC->Curve3d(),CC); |
114 | } |
115 | return Standard_False; |
116 | } |