File indexing completed on 2026-06-27 08:38:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef _AIS_Shape_HeaderFile
0018 #define _AIS_Shape_HeaderFile
0019
0020 #include <AIS_DisplayMode.hxx>
0021 #include <AIS_InteractiveObject.hxx>
0022 #include <Bnd_Box.hxx>
0023 #include <TopoDS_Shape.hxx>
0024 #include <Prs3d_Drawer.hxx>
0025 #include <Prs3d_TypeOfHLR.hxx>
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 class AIS_Shape : public AIS_InteractiveObject
0063 {
0064 DEFINE_STANDARD_RTTIEXT(AIS_Shape, AIS_InteractiveObject)
0065 public:
0066
0067
0068 Standard_EXPORT AIS_Shape(const TopoDS_Shape& shap);
0069
0070
0071 virtual Standard_Integer Signature() const Standard_OVERRIDE { return 0; }
0072
0073
0074 virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE
0075 {
0076 return AIS_KindOfInteractive_Shape;
0077 }
0078
0079
0080 virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE
0081 {
0082 return Standard_True;
0083 }
0084
0085
0086 virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
0087 {
0088 return theMode >= 0 && theMode <= 2;
0089 }
0090
0091
0092 const TopoDS_Shape& Shape() const { return myshape; }
0093
0094
0095 void SetShape(const TopoDS_Shape& theShape)
0096 {
0097 myshape = theShape;
0098 myCompBB = Standard_True;
0099 }
0100
0101
0102 void Set(const TopoDS_Shape& theShape) { SetShape(theShape); }
0103
0104
0105 Standard_EXPORT Standard_Boolean SetOwnDeviationCoefficient();
0106
0107
0108 Standard_EXPORT Standard_Boolean SetOwnDeviationAngle();
0109
0110
0111 Standard_EXPORT void SetOwnDeviationCoefficient(const Standard_Real aCoefficient);
0112
0113
0114
0115 Standard_EXPORT void SetAngleAndDeviation(const Standard_Real anAngle);
0116
0117
0118 Standard_EXPORT Standard_Real UserAngle() const;
0119
0120
0121 Standard_EXPORT void SetOwnDeviationAngle(const Standard_Real anAngle);
0122
0123
0124
0125
0126
0127 Standard_EXPORT Standard_Boolean
0128 OwnDeviationCoefficient(Standard_Real& aCoefficient, Standard_Real& aPreviousCoefficient) const;
0129
0130
0131
0132
0133 Standard_EXPORT Standard_Boolean OwnDeviationAngle(Standard_Real& anAngle,
0134 Standard_Real& aPreviousAngle) const;
0135
0136
0137 void SetTypeOfHLR(const Prs3d_TypeOfHLR theTypeOfHLR) { myDrawer->SetTypeOfHLR(theTypeOfHLR); }
0138
0139
0140 Prs3d_TypeOfHLR TypeOfHLR() const { return myDrawer->TypeOfHLR(); }
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155 Standard_EXPORT virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE;
0156
0157
0158 Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
0159
0160
0161
0162 Standard_EXPORT virtual void SetWidth(const Standard_Real aValue) Standard_OVERRIDE;
0163
0164
0165 Standard_EXPORT virtual void UnsetWidth() Standard_OVERRIDE;
0166
0167
0168
0169 Standard_EXPORT virtual void SetMaterial(const Graphic3d_MaterialAspect& aName) Standard_OVERRIDE;
0170
0171
0172 Standard_EXPORT virtual void UnsetMaterial() Standard_OVERRIDE;
0173
0174
0175 Standard_EXPORT virtual void SetTransparency(const Standard_Real aValue = 0.6) Standard_OVERRIDE;
0176
0177
0178 Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
0179
0180
0181
0182 Standard_EXPORT virtual const Bnd_Box& BoundingBox();
0183
0184
0185
0186 using AIS_InteractiveObject::BoundingBox;
0187
0188
0189
0190 Standard_EXPORT virtual void Color(Quantity_Color& aColor) const Standard_OVERRIDE;
0191
0192
0193
0194 Standard_EXPORT virtual Graphic3d_NameOfMaterial Material() const Standard_OVERRIDE;
0195
0196
0197
0198 Standard_EXPORT virtual Standard_Real Transparency() const Standard_OVERRIDE;
0199
0200
0201 static TopAbs_ShapeEnum SelectionType(const Standard_Integer theSelMode)
0202 {
0203 switch (theSelMode)
0204 {
0205 case 1:
0206 return TopAbs_VERTEX;
0207 case 2:
0208 return TopAbs_EDGE;
0209 case 3:
0210 return TopAbs_WIRE;
0211 case 4:
0212 return TopAbs_FACE;
0213 case 5:
0214 return TopAbs_SHELL;
0215 case 6:
0216 return TopAbs_SOLID;
0217 case 7:
0218 return TopAbs_COMPSOLID;
0219 case 8:
0220 return TopAbs_COMPOUND;
0221 case 0:
0222 return TopAbs_SHAPE;
0223 }
0224 return TopAbs_SHAPE;
0225 }
0226
0227
0228 static Standard_Integer SelectionMode(const TopAbs_ShapeEnum theShapeType)
0229 {
0230 switch (theShapeType)
0231 {
0232 case TopAbs_VERTEX:
0233 return 1;
0234 case TopAbs_EDGE:
0235 return 2;
0236 case TopAbs_WIRE:
0237 return 3;
0238 case TopAbs_FACE:
0239 return 4;
0240 case TopAbs_SHELL:
0241 return 5;
0242 case TopAbs_SOLID:
0243 return 6;
0244 case TopAbs_COMPSOLID:
0245 return 7;
0246 case TopAbs_COMPOUND:
0247 return 8;
0248 case TopAbs_SHAPE:
0249 return 0;
0250 }
0251 return 0;
0252 }
0253
0254 public:
0255
0256 const gp_Pnt2d& TextureRepeatUV() const { return myUVRepeat; }
0257
0258
0259
0260
0261 void SetTextureRepeatUV(const gp_Pnt2d& theRepeatUV) { myUVRepeat = theRepeatUV; }
0262
0263
0264 const gp_Pnt2d& TextureOriginUV() const { return myUVOrigin; }
0265
0266
0267
0268 void SetTextureOriginUV(const gp_Pnt2d& theOriginUV) { myUVOrigin = theOriginUV; }
0269
0270
0271 const gp_Pnt2d& TextureScaleUV() const { return myUVScale; }
0272
0273
0274
0275
0276
0277 void SetTextureScaleUV(const gp_Pnt2d& theScaleUV) { myUVScale = theScaleUV; }
0278
0279 protected:
0280
0281 Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
0282 const Handle(Prs3d_Presentation)& thePrs,
0283 const Standard_Integer theMode) Standard_OVERRIDE;
0284
0285
0286 virtual void computeHLR(const Handle(Graphic3d_Camera)& theProjector,
0287 const Handle(TopLoc_Datum3D)& theTrsf,
0288 const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE
0289 {
0290 if (!theTrsf.IsNull() && theTrsf->Form() != gp_Identity)
0291 {
0292 const TopLoc_Location& aLoc = myshape.Location();
0293 const TopoDS_Shape aShape = myshape.Located(TopLoc_Location(theTrsf->Trsf()) * aLoc);
0294 computeHlrPresentation(theProjector, thePrs, aShape, myDrawer);
0295 }
0296 else
0297 {
0298 computeHlrPresentation(theProjector, thePrs, myshape, myDrawer);
0299 }
0300 }
0301
0302
0303 Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
0304 const Standard_Integer theMode) Standard_OVERRIDE;
0305
0306
0307
0308 Standard_EXPORT bool setColor(const Handle(Prs3d_Drawer)& theDrawer,
0309 const Quantity_Color& theColor) const;
0310
0311
0312
0313 Standard_EXPORT bool setWidth(const Handle(Prs3d_Drawer)& theDrawer,
0314 const Standard_Real theWidth) const;
0315
0316 Standard_EXPORT void setTransparency(const Handle(Prs3d_Drawer)& theDrawer,
0317 const Standard_Real theValue) const;
0318
0319 Standard_EXPORT void setMaterial(const Handle(Prs3d_Drawer)& theDrawer,
0320 const Graphic3d_MaterialAspect& theMaterial,
0321 const Standard_Boolean theToKeepColor,
0322 const Standard_Boolean theToKeepTransp) const;
0323
0324
0325 Standard_EXPORT void replaceWithNewOwnAspects();
0326
0327 public:
0328
0329 Standard_EXPORT static void computeHlrPresentation(const Handle(Graphic3d_Camera)& theProjector,
0330 const Handle(Prs3d_Presentation)& thePrs,
0331 const TopoDS_Shape& theShape,
0332 const Handle(Prs3d_Drawer)& theDrawer);
0333
0334
0335 Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0336 Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0337
0338 protected:
0339 TopoDS_Shape myshape;
0340 Bnd_Box myBB;
0341 gp_Pnt2d myUVOrigin;
0342 gp_Pnt2d myUVRepeat;
0343 gp_Pnt2d myUVScale;
0344 Standard_Real myInitAng;
0345 Standard_Boolean myCompBB;
0346 };
0347
0348 DEFINE_STANDARD_HANDLE(AIS_Shape, AIS_InteractiveObject)
0349
0350 #endif