File indexing completed on 2025-01-18 10:02:55
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 class AIS_Shape : public AIS_InteractiveObject
0061 {
0062 DEFINE_STANDARD_RTTIEXT(AIS_Shape, AIS_InteractiveObject)
0063 public:
0064
0065
0066
0067 Standard_EXPORT AIS_Shape(const TopoDS_Shape& shap);
0068
0069
0070 virtual Standard_Integer Signature() const Standard_OVERRIDE { return 0; }
0071
0072
0073 virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Shape; }
0074
0075
0076 virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE { return Standard_True; }
0077
0078
0079 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode >= 0 && theMode <= 2; }
0080
0081
0082 const TopoDS_Shape& Shape() const { return myshape; }
0083
0084
0085 void SetShape (const TopoDS_Shape& theShape)
0086 {
0087 myshape = theShape;
0088 myCompBB = Standard_True;
0089 }
0090
0091
0092 void Set (const TopoDS_Shape& theShape) { SetShape (theShape); }
0093
0094
0095 Standard_EXPORT Standard_Boolean SetOwnDeviationCoefficient();
0096
0097
0098 Standard_EXPORT Standard_Boolean SetOwnDeviationAngle();
0099
0100
0101 Standard_EXPORT void SetOwnDeviationCoefficient (const Standard_Real aCoefficient);
0102
0103
0104
0105 Standard_EXPORT void SetAngleAndDeviation (const Standard_Real anAngle);
0106
0107
0108 Standard_EXPORT Standard_Real UserAngle() const;
0109
0110
0111 Standard_EXPORT void SetOwnDeviationAngle (const Standard_Real anAngle);
0112
0113
0114
0115
0116
0117 Standard_EXPORT Standard_Boolean OwnDeviationCoefficient (Standard_Real& aCoefficient, Standard_Real& aPreviousCoefficient) const;
0118
0119
0120
0121
0122 Standard_EXPORT Standard_Boolean OwnDeviationAngle (Standard_Real& anAngle, Standard_Real& aPreviousAngle) const;
0123
0124
0125 void SetTypeOfHLR (const Prs3d_TypeOfHLR theTypeOfHLR) { myDrawer->SetTypeOfHLR (theTypeOfHLR); }
0126
0127
0128 Prs3d_TypeOfHLR TypeOfHLR() const { return myDrawer->TypeOfHLR(); }
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143 Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
0144
0145
0146 Standard_EXPORT virtual void UnsetColor() Standard_OVERRIDE;
0147
0148
0149
0150 Standard_EXPORT virtual void SetWidth (const Standard_Real aValue) Standard_OVERRIDE;
0151
0152
0153 Standard_EXPORT virtual void UnsetWidth() Standard_OVERRIDE;
0154
0155
0156
0157 Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& aName) Standard_OVERRIDE;
0158
0159
0160 Standard_EXPORT virtual void UnsetMaterial() Standard_OVERRIDE;
0161
0162
0163 Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6) Standard_OVERRIDE;
0164
0165
0166 Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
0167
0168
0169
0170 Standard_EXPORT virtual const Bnd_Box& BoundingBox();
0171
0172
0173
0174 using AIS_InteractiveObject::BoundingBox;
0175
0176
0177
0178 Standard_EXPORT virtual void Color (Quantity_Color& aColor) const Standard_OVERRIDE;
0179
0180
0181
0182 Standard_EXPORT virtual Graphic3d_NameOfMaterial Material() const Standard_OVERRIDE;
0183
0184
0185
0186 Standard_EXPORT virtual Standard_Real Transparency() const Standard_OVERRIDE;
0187
0188
0189 static TopAbs_ShapeEnum SelectionType (const Standard_Integer theSelMode)
0190 {
0191 switch (theSelMode)
0192 {
0193 case 1: return TopAbs_VERTEX;
0194 case 2: return TopAbs_EDGE;
0195 case 3: return TopAbs_WIRE;
0196 case 4: return TopAbs_FACE;
0197 case 5: return TopAbs_SHELL;
0198 case 6: return TopAbs_SOLID;
0199 case 7: return TopAbs_COMPSOLID;
0200 case 8: return TopAbs_COMPOUND;
0201 case 0: return TopAbs_SHAPE;
0202 }
0203 return TopAbs_SHAPE;
0204 }
0205
0206
0207 static Standard_Integer SelectionMode (const TopAbs_ShapeEnum theShapeType)
0208 {
0209 switch (theShapeType)
0210 {
0211 case TopAbs_VERTEX: return 1;
0212 case TopAbs_EDGE: return 2;
0213 case TopAbs_WIRE: return 3;
0214 case TopAbs_FACE: return 4;
0215 case TopAbs_SHELL: return 5;
0216 case TopAbs_SOLID: return 6;
0217 case TopAbs_COMPSOLID: return 7;
0218 case TopAbs_COMPOUND: return 8;
0219 case TopAbs_SHAPE: return 0;
0220 }
0221 return 0;
0222 }
0223
0224 public:
0225
0226
0227 const gp_Pnt2d& TextureRepeatUV() const { return myUVRepeat; }
0228
0229
0230
0231 void SetTextureRepeatUV (const gp_Pnt2d& theRepeatUV) { myUVRepeat = theRepeatUV; }
0232
0233
0234 const gp_Pnt2d& TextureOriginUV() const { return myUVOrigin; }
0235
0236
0237
0238 void SetTextureOriginUV (const gp_Pnt2d& theOriginUV) { myUVOrigin = theOriginUV; }
0239
0240
0241 const gp_Pnt2d& TextureScaleUV() const { return myUVScale; }
0242
0243
0244
0245
0246
0247 void SetTextureScaleUV (const gp_Pnt2d& theScaleUV) { myUVScale = theScaleUV; }
0248
0249 protected:
0250
0251
0252 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
0253 const Handle(Prs3d_Presentation)& thePrs,
0254 const Standard_Integer theMode) Standard_OVERRIDE;
0255
0256
0257 virtual void computeHLR (const Handle(Graphic3d_Camera)& theProjector,
0258 const Handle(TopLoc_Datum3D)& theTrsf,
0259 const Handle(Prs3d_Presentation)& thePrs) Standard_OVERRIDE
0260 {
0261 if (!theTrsf.IsNull()
0262 && theTrsf->Form() != gp_Identity)
0263 {
0264 const TopLoc_Location& aLoc = myshape.Location();
0265 const TopoDS_Shape aShape = myshape.Located (TopLoc_Location (theTrsf->Trsf()) * aLoc);
0266 computeHlrPresentation (theProjector, thePrs, aShape, myDrawer);
0267 }
0268 else
0269 {
0270 computeHlrPresentation (theProjector, thePrs, myshape, myDrawer);
0271 }
0272 }
0273
0274
0275 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
0276 const Standard_Integer theMode) Standard_OVERRIDE;
0277
0278
0279
0280 Standard_EXPORT bool setColor (const Handle(Prs3d_Drawer)& theDrawer, const Quantity_Color& theColor) const;
0281
0282
0283
0284 Standard_EXPORT bool setWidth (const Handle(Prs3d_Drawer)& theDrawer, const Standard_Real theWidth) const;
0285
0286 Standard_EXPORT void setTransparency (const Handle(Prs3d_Drawer)& theDrawer, const Standard_Real theValue) const;
0287
0288 Standard_EXPORT void setMaterial (const Handle(Prs3d_Drawer)& theDrawer, const Graphic3d_MaterialAspect& theMaterial, const Standard_Boolean theToKeepColor, const Standard_Boolean theToKeepTransp) const;
0289
0290
0291 Standard_EXPORT void replaceWithNewOwnAspects();
0292
0293 public:
0294
0295
0296 Standard_EXPORT static void computeHlrPresentation (const Handle(Graphic3d_Camera)& theProjector,
0297 const Handle(Prs3d_Presentation)& thePrs,
0298 const TopoDS_Shape& theShape,
0299 const Handle(Prs3d_Drawer)& theDrawer);
0300
0301
0302 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0303
0304 protected:
0305
0306 TopoDS_Shape myshape;
0307 Bnd_Box myBB;
0308 gp_Pnt2d myUVOrigin;
0309 gp_Pnt2d myUVRepeat;
0310 gp_Pnt2d myUVScale;
0311 Standard_Real myInitAng;
0312 Standard_Boolean myCompBB;
0313
0314 };
0315
0316 DEFINE_STANDARD_HANDLE(AIS_Shape, AIS_InteractiveObject)
0317
0318 #endif