0030686: Visualization, SelectMgr_ViewerSelector - sorting issues of transformation...
[occt.git] / src / GeomToStep / GeomToStep_MakeRectangularTrimmedSurface.cxx
CommitLineData
b311480e 1// Created on: 1996-01-25
2// Created by: Frederic MAUPAS
3// Copyright (c) 1996-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
7fd59977 18#include <Geom_ConicalSurface.hxx>
42cf5bc1 19#include <Geom_CylindricalSurface.hxx>
20#include <Geom_Plane.hxx>
21#include <Geom_RectangularTrimmedSurface.hxx>
7fd59977 22#include <Geom_SphericalSurface.hxx>
23#include <Geom_SurfaceOfRevolution.hxx>
42cf5bc1 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>
7fd59977 31#include <UnitsMethods.hxx>
7fd59977 32
33//=============================================================================
34// Creation d' une rectangular_trimmed_surface de STEP
35// a partir d' une RectangularTrimmedSurface de Geom
36//=============================================================================
7fd59977 37GeomToStep_MakeRectangularTrimmedSurface::
38 GeomToStep_MakeRectangularTrimmedSurface( const
39 Handle(Geom_RectangularTrimmedSurface)& RTSurf )
40
41{
42
43 Handle(StepGeom_RectangularTrimmedSurface) StepRTS = new StepGeom_RectangularTrimmedSurface;
44
45 Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString("");
46
47 GeomToStep_MakeSurface mkSurf(RTSurf->BasisSurface());
48 if (!mkSurf.IsDone()) {
49 done = Standard_False;
50 return;
51 }
52 Handle(StepGeom_Surface) StepSurf = mkSurf.Value();
53
54 Standard_Real U1,U2,V1,V2;
55 RTSurf->Bounds(U1, U2, V1, V2);
56
57 // -----------------------------------------
58 // Modification of the Trimming Parameters ?
59 // -----------------------------------------
60
c6541a0c 61 Standard_Real AngleFact = 180./M_PI;
7fd59977 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))) {
67 uFact = AngleFact;
68 vFact = 1. / LengthFact;
69 }
70 else if (theSurf->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
71 uFact = AngleFact;
72 }
73 else if (theSurf->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)) ||
74 theSurf->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
75 uFact = AngleFact;
76 vFact = AngleFact;
77 }
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();
82 uFact = AngleFact;
83 vFact = Cos(semAng) / LengthFact;
84 }
85 else if (theSurf->IsKind(STANDARD_TYPE(Geom_Plane))) {
86 uFact = vFact = 1. / LengthFact;
87 }
88
89 U1 = U1 * uFact;
90 U2 = U2 * uFact;
91 V1 = V1 * vFact;
92 V2 = V2 * vFact;
93
94 StepRTS->Init(aName, StepSurf, U1, U2, V1, V2, Standard_True, Standard_True);
95 theRectangularTrimmedSurface = StepRTS;
96 done = Standard_True;
97}
98
99//=============================================================================
100// renvoi des valeurs
101//=============================================================================
102
103const Handle(StepGeom_RectangularTrimmedSurface) &
104 GeomToStep_MakeRectangularTrimmedSurface::Value() const
105{
2d2b3d53 106 StdFail_NotDone_Raise_if (!done, "GeomToStep_MakeRectangularTrimmedSurface::Value() - no result");
7fd59977 107 return theRectangularTrimmedSurface;
108}