File indexing completed on 2025-01-18 10:04:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _SelectMgr_RectangularFrustum_HeaderFile
0017 #define _SelectMgr_RectangularFrustum_HeaderFile
0018
0019 #include <SelectMgr_Frustum.hxx>
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 class SelectMgr_RectangularFrustum : public SelectMgr_Frustum<4>
0033 {
0034 public:
0035
0036
0037
0038 struct SelectionRectangle
0039 {
0040 SelectionRectangle()
0041 : myMinPnt(gp_Pnt2d(RealLast(), RealLast())),
0042 myMaxPnt(gp_Pnt2d(RealLast(), RealLast())) {}
0043
0044 const gp_Pnt2d& MousePos() const { return myMinPnt; }
0045 void SetMousePos (const gp_Pnt2d& thePos) { myMinPnt = thePos; myMaxPnt = thePos; }
0046
0047 const gp_Pnt2d& MinPnt() const { return myMinPnt; }
0048 void SetMinPnt (const gp_Pnt2d& theMinPnt) { myMinPnt = theMinPnt; }
0049
0050 const gp_Pnt2d& MaxPnt() const { return myMaxPnt; }
0051 void SetMaxPnt (const gp_Pnt2d& theMaxPnt) { myMaxPnt = theMaxPnt; }
0052
0053 private:
0054
0055 gp_Pnt2d myMinPnt;
0056 gp_Pnt2d myMaxPnt;
0057 };
0058
0059
0060 Standard_EXPORT SelectMgr_RectangularFrustum();
0061
0062
0063 Standard_EXPORT void Init (const gp_Pnt2d& thePoint);
0064
0065
0066 Standard_EXPORT void Init (const gp_Pnt2d& theMinPnt,
0067 const gp_Pnt2d& theMaxPnt);
0068
0069
0070 Standard_EXPORT Standard_Boolean isIntersectCircle (const Standard_Real theRadius,
0071 const gp_Pnt& theCenter,
0072 const gp_Trsf& theTrsf,
0073 const TColgp_Array1OfPnt& theVertices) const;
0074
0075
0076 Standard_EXPORT Standard_Boolean isSegmentsIntersect (const gp_Pnt& thePnt1Seg1,
0077 const gp_Pnt& thePnt2Seg1,
0078 const gp_Pnt& thePnt1Seg2,
0079 const gp_Pnt& thePnt2Seg2) const;
0080
0081
0082
0083 Standard_EXPORT virtual void Build() Standard_OVERRIDE;
0084
0085
0086
0087 Standard_EXPORT virtual Standard_Boolean IsScalable() const Standard_OVERRIDE;
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098 Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform (const Standard_Integer theScaleFactor,
0099 const gp_GTrsf& theTrsf,
0100 const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
0101
0102
0103
0104
0105 Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin,
0106 const SelectMgr_Vec3& theBoxMax,
0107 const SelectMgr_ViewClipRange& theClipRange,
0108 SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0109
0110
0111
0112 Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin,
0113 const SelectMgr_Vec3& theBoxMax,
0114 Standard_Boolean* theInside) const Standard_OVERRIDE;
0115
0116
0117 Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt,
0118 const SelectMgr_ViewClipRange& theClipRange,
0119 SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0120
0121
0122 Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt) const Standard_OVERRIDE;
0123
0124
0125
0126
0127 Standard_EXPORT virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts,
0128 Select3D_TypeOfSensitivity theSensType,
0129 const SelectMgr_ViewClipRange& theClipRange,
0130 SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0131
0132
0133 Standard_EXPORT virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePnt1,
0134 const gp_Pnt& thePnt2,
0135 const SelectMgr_ViewClipRange& theClipRange,
0136 SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0137
0138
0139
0140
0141 Standard_EXPORT virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePnt1,
0142 const gp_Pnt& thePnt2,
0143 const gp_Pnt& thePnt3,
0144 Select3D_TypeOfSensitivity theSensType,
0145 const SelectMgr_ViewClipRange& theClipRange,
0146 SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0147
0148
0149 Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
0150 const Standard_Real theRadius,
0151 const SelectMgr_ViewClipRange& theClipRange,
0152 SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0153
0154
0155 Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
0156 const Standard_Real theRadius,
0157 Standard_Boolean* theInside) const Standard_OVERRIDE;
0158
0159
0160
0161 Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
0162 const Standard_Real theTopRad,
0163 const Standard_Real theHeight,
0164 const gp_Trsf& theTrsf,
0165 const Standard_Boolean theIsHollow,
0166 const SelectMgr_ViewClipRange& theClipRange,
0167 SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0168
0169
0170
0171 Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
0172 const Standard_Real theTopRad,
0173 const Standard_Real theHeight,
0174 const gp_Trsf& theTrsf,
0175 const Standard_Boolean theIsHollow,
0176 Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
0177
0178
0179
0180
0181
0182 Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
0183 const gp_Trsf& theTrsf,
0184 const Standard_Boolean theIsFilled,
0185 const SelectMgr_ViewClipRange& theClipRange,
0186 SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0187
0188
0189
0190
0191
0192 Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
0193 const gp_Trsf& theTrsf,
0194 const Standard_Boolean theIsFilled,
0195 Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
0196
0197
0198
0199
0200 Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const Standard_OVERRIDE;
0201
0202
0203 Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE;
0204
0205
0206 const gp_Pnt* GetVertices() const { return myVertices; }
0207
0208
0209
0210
0211 virtual const gp_Pnt& GetNearPnt() const Standard_OVERRIDE { return myNearPickedPnt; }
0212
0213
0214
0215
0216 virtual const gp_Pnt& GetFarPnt() const Standard_OVERRIDE { return myFarPickedPnt; }
0217
0218
0219 virtual const gp_Dir& GetViewRayDirection() const Standard_OVERRIDE { return myViewRayDir; }
0220
0221
0222 Standard_EXPORT virtual const gp_Pnt2d& GetMousePosition() const Standard_OVERRIDE;
0223
0224
0225
0226 Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
0227
0228
0229 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0230
0231 protected:
0232
0233 Standard_EXPORT void segmentSegmentDistance (const gp_Pnt& theSegPnt1,
0234 const gp_Pnt& theSegPnt2,
0235 SelectBasics_PickResult& thePickResult) const;
0236
0237 Standard_EXPORT bool segmentPlaneIntersection (const gp_Vec& thePlane,
0238 const gp_Pnt& thePntOnPlane,
0239 SelectBasics_PickResult& thePickResult) const;
0240
0241 private:
0242
0243 void cacheVertexProjections (SelectMgr_RectangularFrustum* theFrustum) const;
0244
0245 private:
0246 enum { LeftTopNear, LeftTopFar,
0247 LeftBottomNear, LeftBottomFar,
0248 RightTopNear, RightTopFar,
0249 RightBottomNear, RightBottomFar };
0250
0251 private:
0252
0253 SelectionRectangle mySelRectangle;
0254 gp_Pnt myNearPickedPnt;
0255 gp_Pnt myFarPickedPnt;
0256 gp_Dir myViewRayDir;
0257 Standard_Real myScale;
0258
0259 };
0260
0261 #endif