1 // Created on: 1990-12-19
2 // Created by: Christophe MARION
3 // Copyright (c) 1990-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.
17 #ifndef _TopLoc_Location_HeaderFile
18 #define _TopLoc_Location_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <TopLoc_SListOfItemLocation.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_Integer.hxx>
27 #include <Standard_OStream.hxx>
28 class Standard_NoSuchObject;
29 class Standard_ConstructionError;
34 //! A Location is a composite transition. It comprises a
35 //! series of elementary reference coordinates, i.e.
36 //! objects of type TopLoc_Datum3D, and the powers to
37 //! which these objects are raised.
45 //! Constructs an empty local coordinate system object.
46 //! Note: A Location constructed from a default datum is said to be "empty".
47 Standard_EXPORT TopLoc_Location();
49 //! Constructs the local coordinate system object defined
50 //! by the transformation T. T invokes in turn, a TopLoc_Datum3D object.
51 Standard_EXPORT TopLoc_Location(const gp_Trsf& T);
53 //! Constructs the local coordinate system object defined by the 3D datum D.
55 //! Standard_ConstructionError if the transformation
56 //! T does not represent a 3D coordinate system.
57 Standard_EXPORT TopLoc_Location(const Handle(TopLoc_Datum3D)& D);
59 //! Returns true if this location is equal to the Identity transformation.
60 Standard_Boolean IsIdentity() const;
62 //! Resets this location to the Identity transformation.
65 //! Returns the first elementary datum of the
66 //! Location. Use the NextLocation function recursively to access
67 //! the other data comprising this location.
69 //! Standard_NoSuchObject if this location is empty.
70 const Handle(TopLoc_Datum3D)& FirstDatum() const;
72 //! Returns the power elevation of the first
75 //! Standard_NoSuchObject if this location is empty.
76 Standard_Integer FirstPower() const;
78 //! Returns a Location representing <me> without the
79 //! first datum. We have the relation :
81 //! <me> = NextLocation() * FirstDatum() ^ FirstPower()
83 //! Standard_NoSuchObject if this location is empty.
84 const TopLoc_Location& NextLocation() const;
86 //! Returns the transformation associated to the
87 //! coordinate system.
88 Standard_EXPORT const gp_Trsf& Transformation() const;
89 Standard_EXPORT operator gp_Trsf() const;
91 //! Returns the inverse of <me>.
93 //! <me> * Inverted() is an Identity.
94 Standard_EXPORT Standard_NODISCARD TopLoc_Location Inverted() const;
96 //! Returns <me> * <Other>, the elementary datums are
98 Standard_EXPORT Standard_NODISCARD TopLoc_Location Multiplied (const TopLoc_Location& Other) const;
99 Standard_NODISCARD TopLoc_Location operator* (const TopLoc_Location& Other) const
101 return Multiplied(Other);
104 //! Returns <me> / <Other>.
105 Standard_EXPORT Standard_NODISCARD TopLoc_Location Divided (const TopLoc_Location& Other) const;
106 Standard_NODISCARD TopLoc_Location operator/ (const TopLoc_Location& Other) const
108 return Divided(Other);
111 //! Returns <Other>.Inverted() * <me>.
112 Standard_EXPORT Standard_NODISCARD TopLoc_Location Predivided (const TopLoc_Location& Other) const;
114 //! Returns me at the power <pwr>. If <pwr> is zero
115 //! returns Identity. <pwr> can be lower than zero
116 //! (usual meaning for powers).
117 Standard_EXPORT Standard_NODISCARD TopLoc_Location Powered (const Standard_Integer pwr) const;
119 //! Returns a hashed value for this local coordinate system. This value is used, with map tables, to store and
120 //! retrieve the object easily, and is in the range [1, theUpperBound].
121 //! @param theUpperBound the upper bound of the range a computing hash code must be within
122 //! @return a computed hash code, in the range [1, theUpperBound]
123 Standard_EXPORT Standard_Integer HashCode (Standard_Integer theUpperBound) const;
125 //! Returns true if this location and the location Other
126 //! have the same elementary data, i.e. contain the same
127 //! series of TopLoc_Datum3D and respective powers.
128 //! This method is an alias for operator ==.
129 Standard_EXPORT Standard_Boolean IsEqual (const TopLoc_Location& Other) const;
130 Standard_Boolean operator == (const TopLoc_Location& Other) const
132 return IsEqual(Other);
135 //! Returns true if this location and the location Other do
136 //! not have the same elementary data, i.e. do not
137 //! contain the same series of TopLoc_Datum3D and respective powers.
138 //! This method is an alias for operator !=.
139 Standard_EXPORT Standard_Boolean IsDifferent (const TopLoc_Location& Other) const;
140 Standard_Boolean operator != (const TopLoc_Location& Other) const
142 return IsDifferent(Other);
145 //! Prints the contents of <me> on the stream <s>.
146 Standard_EXPORT void ShallowDump (Standard_OStream& S) const;
161 TopLoc_SListOfItemLocation myItems;
167 #include <TopLoc_Location.lxx>
170 //! Computes a hash code for the given location, in the range [1, theUpperBound]
171 //! @param theLocation the location which hash code is to be computed
172 //! @param theUpperBound the upper bound of the range a computing hash code must be within
173 //! @return a computed hash code, in the range [1, theUpperBound]
174 inline Standard_Integer HashCode (const TopLoc_Location& theLocation, const Standard_Integer theUpperBound)
176 return theLocation.HashCode (theUpperBound);
179 inline void ShallowDump(const TopLoc_Location& me,Standard_OStream& S) {
185 #endif // _TopLoc_Location_HeaderFile