|
|
|||
File indexing completed on 2026-09-26 09:05:06
0001 // Created on: 1990-12-11 0002 // Created by: Remi Lequette 0003 // Copyright (c) 1990-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _TopoDS_HeaderFile 0018 #define _TopoDS_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <Standard_TypeMismatch.hxx> 0023 #include <TopAbs_ShapeEnum.hxx> 0024 #include <TopoDS_Shape.hxx> 0025 0026 class TopoDS_Vertex; 0027 class TopoDS_Shape; 0028 class TopoDS_Edge; 0029 class TopoDS_Wire; 0030 class TopoDS_Face; 0031 class TopoDS_Shell; 0032 class TopoDS_Solid; 0033 class TopoDS_CompSolid; 0034 class TopoDS_Compound; 0035 class TopoDS_HShape; 0036 class TopoDS_TShape; 0037 class TopoDS_TVertex; 0038 class TopoDS_TEdge; 0039 class TopoDS_TWire; 0040 class TopoDS_TFace; 0041 class TopoDS_TShell; 0042 class TopoDS_TSolid; 0043 class TopoDS_TCompSolid; 0044 class TopoDS_TCompound; 0045 class TopoDS_Builder; 0046 class TopoDS_Iterator; 0047 0048 //! Provides methods to cast objects of class TopoDS_Shape to more specialized 0049 //! sub-classes. The types are not verified before casting. If the type does 0050 //! not match, a Standard_TypeMismatch exception is thrown. Below are examples 0051 //! of correct and incorrect casts: 0052 //! 0053 //! Correct: 0054 //! @code 0055 //! TopoDS_Shape aShape = ...; // aShape->ShapeType() == TopAbs_VERTEX 0056 //! const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape); 0057 //! @endcode 0058 //! 0059 //! Incorrect (will throw a Standard_TypeMismatch exception): 0060 //! @code 0061 //! TopoDS_Shape aShape = ...; // aShape->ShapeType() == TopAbs_VERTEX 0062 //! const TopoDS_Face& face = TopoDS::Edge(aShape); 0063 //! @endcode 0064 namespace TopoDS 0065 { 0066 //! Casts shape theShape to the more specialized return type, Vertex. 0067 //! @param theShape the shape to be cast 0068 //! @return the casted shape as TopoDS_Vertex 0069 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0070 inline const TopoDS_Vertex& Vertex(const TopoDS_Shape& theShape) 0071 { 0072 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false : theShape.ShapeType() != TopAbs_VERTEX, 0073 "TopoDS::Vertex"); 0074 return *(TopoDS_Vertex*)&theShape; 0075 } 0076 0077 //! Casts shape theShape to the more specialized return type, Vertex. 0078 //! @param theShape the shape to be cast 0079 //! @return the casted shape as TopoDS_Vertex 0080 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0081 inline TopoDS_Vertex& Vertex(TopoDS_Shape& theShape) 0082 { 0083 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false : theShape.ShapeType() != TopAbs_VERTEX, 0084 "TopoDS::Vertex"); 0085 return *(TopoDS_Vertex*)&theShape; 0086 } 0087 0088 //! Casts shape theShape to the more specialized return type, Edge. 0089 //! @param theShape the shape to be cast 0090 //! @return the casted shape as TopoDS_Edge 0091 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0092 inline const TopoDS_Edge& Edge(const TopoDS_Shape& theShape) 0093 { 0094 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false : theShape.ShapeType() != TopAbs_EDGE, 0095 "TopoDS::Edge"); 0096 return *(TopoDS_Edge*)&theShape; 0097 } 0098 0099 //! Casts shape theShape to the more specialized return type, Edge. 0100 //! @param theShape the shape to be cast 0101 //! @return the casted shape as TopoDS_Edge 0102 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0103 inline TopoDS_Edge& Edge(TopoDS_Shape& theShape) 0104 { 0105 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false : theShape.ShapeType() != TopAbs_EDGE, 0106 "TopoDS::Edge"); 0107 return *(TopoDS_Edge*)&theShape; 0108 } 0109 0110 //! Casts shape theShape to the more specialized return type, Wire. 0111 //! @param theShape the shape to be cast 0112 //! @return the casted shape as TopoDS_Wire 0113 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0114 inline const TopoDS_Wire& Wire(const TopoDS_Shape& theShape) 0115 { 0116 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false : theShape.ShapeType() != TopAbs_WIRE, 0117 "TopoDS::Wire"); 0118 return *(TopoDS_Wire*)&theShape; 0119 } 0120 0121 //! Casts shape theShape to the more specialized return type, Wire. 0122 //! @param theShape the shape to be cast 0123 //! @return the casted shape as TopoDS_Wire 0124 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0125 inline TopoDS_Wire& Wire(TopoDS_Shape& theShape) 0126 { 0127 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false : theShape.ShapeType() != TopAbs_WIRE, 0128 "TopoDS::Wire"); 0129 return *(TopoDS_Wire*)&theShape; 0130 } 0131 0132 //! Casts shape theShape to the more specialized return type, Face. 0133 //! @param theShape the shape to be cast 0134 //! @return the casted shape as TopoDS_Face 0135 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0136 inline const TopoDS_Face& Face(const TopoDS_Shape& theShape) 0137 { 0138 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false : theShape.ShapeType() != TopAbs_FACE, 0139 "TopoDS::Face"); 0140 return *(TopoDS_Face*)&theShape; 0141 } 0142 0143 //! Casts shape theShape to the more specialized return type, Face. 0144 //! @param theShape the shape to be cast 0145 //! @return the casted shape as TopoDS_Face 0146 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0147 inline TopoDS_Face& Face(TopoDS_Shape& theShape) 0148 { 0149 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false : theShape.ShapeType() != TopAbs_FACE, 0150 "TopoDS::Face"); 0151 return *(TopoDS_Face*)&theShape; 0152 } 0153 0154 //! Casts shape theShape to the more specialized return type, Shell. 0155 //! @param theShape the shape to be cast 0156 //! @return the casted shape as TopoDS_Shell 0157 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0158 inline const TopoDS_Shell& Shell(const TopoDS_Shape& theShape) 0159 { 0160 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false : theShape.ShapeType() != TopAbs_SHELL, 0161 "TopoDS::Shell"); 0162 return *(TopoDS_Shell*)&theShape; 0163 } 0164 0165 //! Casts shape theShape to the more specialized return type, Shell. 0166 //! @param theShape the shape to be cast 0167 //! @return the casted shape as TopoDS_Shell 0168 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0169 inline TopoDS_Shell& Shell(TopoDS_Shape& theShape) 0170 { 0171 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false : theShape.ShapeType() != TopAbs_SHELL, 0172 "TopoDS::Shell"); 0173 return *(TopoDS_Shell*)&theShape; 0174 } 0175 0176 //! Casts shape theShape to the more specialized return type, Solid. 0177 //! @param theShape the shape to be cast 0178 //! @return the casted shape as TopoDS_Solid 0179 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0180 inline const TopoDS_Solid& Solid(const TopoDS_Shape& theShape) 0181 { 0182 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false : theShape.ShapeType() != TopAbs_SOLID, 0183 "TopoDS::Solid"); 0184 return *(TopoDS_Solid*)&theShape; 0185 } 0186 0187 //! Casts shape theShape to the more specialized return type, Solid. 0188 //! @param theShape the shape to be cast 0189 //! @return the casted shape as TopoDS_Solid 0190 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0191 inline TopoDS_Solid& Solid(TopoDS_Shape& theShape) 0192 { 0193 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false : theShape.ShapeType() != TopAbs_SOLID, 0194 "TopoDS::Solid"); 0195 return *(TopoDS_Solid*)&theShape; 0196 } 0197 0198 //! Casts shape theShape to the more specialized return type, CompSolid. 0199 //! @param theShape the shape to be cast 0200 //! @return the casted shape as TopoDS_CompSolid 0201 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0202 inline const TopoDS_CompSolid& CompSolid(const TopoDS_Shape& theShape) 0203 { 0204 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false 0205 : theShape.ShapeType() != TopAbs_COMPSOLID, 0206 "TopoDS::CompSolid"); 0207 return *(TopoDS_CompSolid*)&theShape; 0208 } 0209 0210 //! Casts shape theShape to the more specialized return type, CompSolid. 0211 //! @param theShape the shape to be cast 0212 //! @return the casted shape as TopoDS_CompSolid 0213 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0214 inline TopoDS_CompSolid& CompSolid(TopoDS_Shape& theShape) 0215 { 0216 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false 0217 : theShape.ShapeType() != TopAbs_COMPSOLID, 0218 "TopoDS::CompSolid"); 0219 return *(TopoDS_CompSolid*)&theShape; 0220 } 0221 0222 //! Casts shape theShape to the more specialized return type, Compound. 0223 //! @param theShape the shape to be cast 0224 //! @return the casted shape as TopoDS_Compound 0225 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0226 inline const TopoDS_Compound& Compound(const TopoDS_Shape& theShape) 0227 { 0228 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false 0229 : theShape.ShapeType() != TopAbs_COMPOUND, 0230 "TopoDS::Compound"); 0231 return *(TopoDS_Compound*)&theShape; 0232 } 0233 0234 //! Casts shape theShape to the more specialized return type, Compound. 0235 //! @param theShape the shape to be cast 0236 //! @return the casted shape as TopoDS_Compound 0237 //! @throws Standard_TypeMismatch if theShape cannot be cast to this return type. 0238 inline TopoDS_Compound& Compound(TopoDS_Shape& theShape) 0239 { 0240 Standard_TypeMismatch_Raise_if(theShape.IsNull() ? false 0241 : theShape.ShapeType() != TopAbs_COMPOUND, 0242 "TopoDS::Compound"); 0243 return *(TopoDS_Compound*)&theShape; 0244 } 0245 } // namespace TopoDS 0246 0247 #endif // _TopoDS_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|