1 // Created on: 1996-01-25
2 // Created by: Frederic MAUPAS
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Geom_ConicalSurface.hxx>
19 #include <Geom_CylindricalSurface.hxx>
20 #include <Geom_Plane.hxx>
21 #include <Geom_RectangularTrimmedSurface.hxx>
22 #include <Geom_SphericalSurface.hxx>
23 #include <Geom_SurfaceOfRevolution.hxx>
24 #include <Geom_ToroidalSurface.hxx>
25 #include <GeomToStep_MakeRectangularTrimmedSurface.hxx>
26 #include <GeomToStep_MakeSurface.hxx>
27 #include <StdFail_NotDone.hxx>
28 #include <StepGeom_RectangularTrimmedSurface.hxx>
29 #include <StepGeom_Surface.hxx>
30 #include <TCollection_HAsciiString.hxx>
31 #include <UnitsMethods.hxx>
33 //=============================================================================
34 // Creation d' une rectangular_trimmed_surface de STEP
35 // a partir d' une RectangularTrimmedSurface de Geom
36 //=============================================================================
37 GeomToStep_MakeRectangularTrimmedSurface::
38 GeomToStep_MakeRectangularTrimmedSurface( const
39 Handle(Geom_RectangularTrimmedSurface)& RTSurf )
43 Handle(StepGeom_RectangularTrimmedSurface) StepRTS = new StepGeom_RectangularTrimmedSurface;
45 Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString("");
47 GeomToStep_MakeSurface mkSurf(RTSurf->BasisSurface());
48 if (!mkSurf.IsDone()) {
49 done = Standard_False;
52 Handle(StepGeom_Surface) StepSurf = mkSurf.Value();
54 Standard_Real U1,U2,V1,V2;
55 RTSurf->Bounds(U1, U2, V1, V2);
57 // -----------------------------------------
58 // Modification of the Trimming Parameters ?
59 // -----------------------------------------
61 Standard_Real AngleFact = 180./M_PI;
62 Standard_Real uFact = 1.;
63 Standard_Real vFact = 1.;
64 Standard_Real LengthFact = UnitsMethods::LengthFactor();
65 Handle(Geom_Surface) theSurf = RTSurf->BasisSurface();
66 if (theSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
68 vFact = 1. / LengthFact;
70 else if (theSurf->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
73 else if (theSurf->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)) ||
74 theSurf->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
78 else if (theSurf->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) {
79 Handle(Geom_ConicalSurface) conicS =
80 Handle(Geom_ConicalSurface)::DownCast(theSurf);
81 Standard_Real semAng = conicS->SemiAngle();
83 vFact = Cos(semAng) / LengthFact;
85 else if (theSurf->IsKind(STANDARD_TYPE(Geom_Plane))) {
86 uFact = vFact = 1. / LengthFact;
94 StepRTS->Init(aName, StepSurf, U1, U2, V1, V2, Standard_True, Standard_True);
95 theRectangularTrimmedSurface = StepRTS;
99 //=============================================================================
100 // renvoi des valeurs
101 //=============================================================================
103 const Handle(StepGeom_RectangularTrimmedSurface) &
104 GeomToStep_MakeRectangularTrimmedSurface::Value() const
106 StdFail_NotDone_Raise_if(!done, "");
107 return theRectangularTrimmedSurface;