1 // File: StepToGeom_MakeSurface.cxx
2 // Created: Mon Jul 5 09:56:37 1993
3 // Author: Martine LANGLOIS
4 //:n7 abv 15.02.99: S4132: adding translation of surface_replica
5 //:p0 abv 19.02.99: management of 'done' flag improved
6 //:s5 abv 22.04.99 Adding debug printouts in catch {} blocks
7 //sln 03.10.01. BUC61003. creation of offset surface is corrected
9 #include <StepToGeom_MakeSurface.ixx>
10 #include <Standard_ErrorHandler.hxx>
11 #include <Standard_Failure.hxx>
12 #include <StepGeom_Surface.hxx>
13 #include <StepToGeom_MakeSurface.hxx>
14 #include <StepGeom_BoundedSurface.hxx>
15 #include <StepToGeom_MakeBoundedSurface.hxx>
16 #include <StepGeom_ElementarySurface.hxx>
17 #include <StepToGeom_MakeElementarySurface.hxx>
18 #include <StepGeom_SweptSurface.hxx>
19 #include <StepToGeom_MakeSweptSurface.hxx>
22 #include <StepGeom_OffsetSurface.hxx>
23 #include <Geom_OffsetSurface.hxx>
24 #include <StepGeom_SurfaceReplica.hxx>
25 #include <StepGeom_CartesianTransformationOperator3d.hxx>
26 #include <StepToGeom_MakeTransformation3d.hxx>
27 #include <UnitsMethods.hxx>
29 #include <BRepBuilderAPI_MakeFace.hxx>
30 #include <TopoDS_Face.hxx>
31 #include <ShapeAlgo.hxx>
32 #include <ShapeAlgo_AlgoContainer.hxx>
34 #include <BRep_Tool.hxx>
35 #include <gp_Trsf.hxx>
37 //=============================================================================
38 // Creation d' une Surface de Geom a partir d' une Surface de Step
39 //=============================================================================
41 Standard_Boolean StepToGeom_MakeSurface::Convert (const Handle(StepGeom_Surface)& SS, Handle(Geom_Surface)& CS)
43 // sln 01.10.2001 BUC61003. If entry shell is NULL do nothing
46 // cout<<"Warning: StepToGeom_MakeSurface: Null Surface:";
48 return Standard_False;
53 if (SS->IsKind(STANDARD_TYPE(StepGeom_BoundedSurface))) {
54 const Handle(StepGeom_BoundedSurface) S1 = Handle(StepGeom_BoundedSurface)::DownCast(SS);
55 return StepToGeom_MakeBoundedSurface::Convert(S1,*((Handle(Geom_BoundedSurface)*)&CS));
57 if (SS->IsKind(STANDARD_TYPE(StepGeom_ElementarySurface))) {
58 const Handle(StepGeom_ElementarySurface) S1 = Handle(StepGeom_ElementarySurface)::DownCast(SS);
59 return StepToGeom_MakeElementarySurface::Convert(S1,*((Handle(Geom_ElementarySurface)*)&CS));
61 if (SS->IsKind(STANDARD_TYPE(StepGeom_SweptSurface))) {
62 const Handle(StepGeom_SweptSurface) S1 = Handle(StepGeom_SweptSurface)::DownCast(SS);
63 return StepToGeom_MakeSweptSurface::Convert(S1,*((Handle(Geom_SweptSurface)*)&CS));
65 if (SS->IsKind(STANDARD_TYPE(StepGeom_OffsetSurface))) { //:d4 abv 12 Mar 98
66 const Handle(StepGeom_OffsetSurface) OS = Handle(StepGeom_OffsetSurface)::DownCast(SS);
67 Handle(Geom_Surface) aBasisSurface;
68 if (StepToGeom_MakeSurface::Convert(OS->BasisSurface(),aBasisSurface))
70 // sln 03.10.01. BUC61003. creation of offset surface is corrected
71 const Standard_Real anOffset = OS->Distance() * UnitsMethods::LengthFactor();
72 if (aBasisSurface->Continuity() == GeomAbs_C0)
74 const BRepBuilderAPI_MakeFace aBFace(aBasisSurface);
77 const TopoDS_Shape aResult = ShapeAlgo::AlgoContainer()->C0ShapeToC1Shape(aBFace.Face(), Abs(anOffset));
78 if (aResult.ShapeType() == TopAbs_FACE)
80 aBasisSurface = BRep_Tool::Surface(TopoDS::Face(aResult));
84 if(aBasisSurface->Continuity() != GeomAbs_C0)
86 CS = new Geom_OffsetSurface ( aBasisSurface, anOffset );
91 else if (SS->IsKind(STANDARD_TYPE(StepGeom_SurfaceReplica))) { //:n7 abv 16 Feb 99
92 const Handle(StepGeom_SurfaceReplica) SR = Handle(StepGeom_SurfaceReplica)::DownCast(SS);
93 const Handle(StepGeom_Surface) PS = SR->ParentSurface();
94 const Handle(StepGeom_CartesianTransformationOperator3d) T =
95 Handle(StepGeom_CartesianTransformationOperator3d)::DownCast(SR->Transformation());
96 // protect against cyclic references and wrong type of cartop
97 if ( !T.IsNull() && PS != SS ) {
98 Handle(Geom_Surface) S1;
99 if (StepToGeom_MakeSurface::Convert(PS,S1))
102 if (StepToGeom_MakeTransformation3d::Convert(T,T1))
104 S1->Transform ( T1 );
106 return Standard_True;
112 catch(Standard_Failure) {
115 cout<<"Warning: StepToGeom_MakeSurface: Exception:";
116 Standard_Failure::Caught()->Print(cout); cout << endl;
119 return Standard_False;