0023948: Wrong intersection between a surface of revolution and a plane.
[occt.git] / src / StepToTopoDS / StepToTopoDS_MakeTransformed.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14//:n7 abv 16.02.99: treatment of CARTESIAN_TRSF_OP_3D placed to StepGeom_MkTransformed3d
15// sln 23.10.2001. CTS23496: Verifying on error creation of directions is added (StepToTopoDS_MakeTransformed::Compute(...) function)
16
17#include <StepToTopoDS_MakeTransformed.ixx>
18#include <Transfer_Binder.hxx>
19#include <TransferBRep_ShapeBinder.hxx>
20
21#include <StepToGeom_MakeAxis2Placement.hxx>
22#include <Geom_Axis2Placement.hxx>
23#include <gp_Ax3.hxx>
24#include <gp_TrsfForm.hxx>
25#include <TopLoc_Location.hxx>
26
27#include <StepRepr_RepresentationMap.hxx>
28#include <StepRepr_Representation.hxx>
29
30// + pour CartesianOperator3d
31#include <Geom_CartesianPoint.hxx>
32#include <Geom_Direction.hxx>
33#include <StepGeom_CartesianPoint.hxx>
34#include <StepGeom_Direction.hxx>
35#include <StepToGeom_MakeCartesianPoint.hxx>
36#include <StepToGeom_MakeDirection.hxx>
37#include <StepToGeom_MakeTransformation3d.hxx>
38
39
40StepToTopoDS_MakeTransformed::StepToTopoDS_MakeTransformed ()
41{
42}
43
44Standard_Boolean StepToTopoDS_MakeTransformed::Compute
45 (const Handle(StepGeom_Axis2Placement3d)& Origin,
46 const Handle(StepGeom_Axis2Placement3d)& Target)
47{
48 theTrsf = gp_Trsf(); // reinit
49 if (Origin.IsNull() || Target.IsNull()) return Standard_False;
50
51 // sln 23.10.2001 : If the directions have not been created do nothing.
52 Handle(Geom_Axis2Placement) theOrig;
53 if (!StepToGeom_MakeAxis2Placement::Convert(Origin,theOrig))
54 return Standard_False;
55 Handle(Geom_Axis2Placement) theTarg;
56 if (!StepToGeom_MakeAxis2Placement::Convert(Target,theTarg))
57 return Standard_False;
58
59 const gp_Ax3 ax3Orig(theOrig->Ax2());
60 const gp_Ax3 ax3Targ(theTarg->Ax2());
61
62 // ne pas se tromper de sens !
63 theTrsf.SetTransformation(ax3Targ, ax3Orig);
64 return Standard_True;
65}
66
67Standard_Boolean StepToTopoDS_MakeTransformed::Compute
68 (const Handle(StepGeom_CartesianTransformationOperator3d)& Operator)
69{
70 return StepToGeom_MakeTransformation3d::Convert(Operator,theTrsf);
71}
72
73const gp_Trsf& StepToTopoDS_MakeTransformed::Transformation () const
74{
75 return theTrsf;
76}
77
78Standard_Boolean StepToTopoDS_MakeTransformed::Transform
79 (TopoDS_Shape& shape) const
80{
81 if (theTrsf.Form() == gp_Identity) return Standard_False;
82 TopLoc_Location theLoc(theTrsf);
83 shape.Move (theLoc);
84// shape.Location(theLoc);
85 return Standard_True;
86}
87
88TopoDS_Shape StepToTopoDS_MakeTransformed::TranslateMappedItem
89(const Handle(StepRepr_MappedItem)& mapit,
90 const Handle(Transfer_TransientProcess)& TP)
91{
92 TopoDS_Shape theResult;
93
94 // Positionnement : 2 formules
95 // 1/ Ax2 dans Source et comme Target : passage de Source a Target
96 // 2/ CartesianOperator3d comme Target : on applique
97
98 Handle(StepGeom_Axis2Placement3d) Origin =
99 Handle(StepGeom_Axis2Placement3d)::DownCast(mapit->MappingSource()
100 ->MappingOrigin());
101 Handle(StepGeom_Axis2Placement3d) Target =
102 Handle(StepGeom_Axis2Placement3d)::DownCast(mapit->MappingTarget());
103
104 Handle(StepGeom_CartesianTransformationOperator3d) CartOp =
105 Handle(StepGeom_CartesianTransformationOperator3d)::DownCast(mapit->MappingTarget());
106// Handle(StepRepr_ItemDefinedTransformation) ItemDef =
107// Handle(StepRepr_ItemDefinedTransformation)::DownCast(mapit->MappingTarget());
108
109 Standard_Boolean ok = Standard_False;
110 if (!Origin.IsNull() && !Target.IsNull()) ok = Compute (Origin,Target);
111 else if (!CartOp.IsNull()) ok = Compute (CartOp);
112
113 if (!ok) TP->AddWarning (mapit,"Mapped Item, case not recognized, location ignored");
114
115 // La Shape, et la mise en position
116 Handle(StepRepr_Representation) maprep = mapit->MappingSource()->MappedRepresentation();
117 Handle(Transfer_Binder) binder = TP->Find(maprep);
118 if (binder.IsNull()) binder = TP->Transferring(maprep);
119 Handle(TransferBRep_ShapeBinder) shbinder =
120 Handle(TransferBRep_ShapeBinder)::DownCast(binder);
121 if (shbinder.IsNull()) TP->AddWarning(mapit,"No Shape Produced");
122 else {
123 theResult = shbinder->Result();
124 Transform (theResult);
125 }
126
127 return theResult;
128}