File indexing completed on 2025-01-18 10:03:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef _Graphic3d_Structure_HeaderFile
0018 #define _Graphic3d_Structure_HeaderFile
0019
0020 #include <Graphic3d_CStructure.hxx>
0021 #include <Graphic3d_MapOfStructure.hxx>
0022 #include <Graphic3d_SequenceOfGroup.hxx>
0023 #include <Graphic3d_SequenceOfHClipPlane.hxx>
0024 #include <Graphic3d_TypeOfConnection.hxx>
0025 #include <Graphic3d_TypeOfStructure.hxx>
0026 #include <Graphic3d_TransformPers.hxx>
0027 #include <Graphic3d_ZLayerId.hxx>
0028 #include <NCollection_IndexedMap.hxx>
0029
0030 class Graphic3d_StructureManager;
0031 class Graphic3d_DataStructureManager;
0032 class Bnd_Box;
0033
0034 DEFINE_STANDARD_HANDLE(Graphic3d_Structure, Standard_Transient)
0035
0036
0037
0038
0039 class Graphic3d_Structure : public Standard_Transient
0040 {
0041 DEFINE_STANDARD_RTTIEXT(Graphic3d_Structure, Standard_Transient)
0042 friend class Graphic3d_Group;
0043 public:
0044
0045
0046
0047
0048
0049
0050 Standard_EXPORT Graphic3d_Structure (const Handle(Graphic3d_StructureManager)& theManager,
0051 const Handle(Graphic3d_Structure)& theLinkPrs = Handle(Graphic3d_Structure)());
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 virtual void Clear (const Standard_Boolean WithDestruction = Standard_True)
0064 {
0065 clear (WithDestruction);
0066 }
0067
0068
0069
0070 Standard_EXPORT virtual ~Graphic3d_Structure();
0071
0072
0073 Standard_EXPORT virtual void Display();
0074
0075
0076 Graphic3d_DisplayPriority DisplayPriority() const { return myCStructure->Priority(); }
0077
0078
0079
0080
0081
0082
0083
0084
0085 Standard_EXPORT void SetDisplayPriority (const Graphic3d_DisplayPriority thePriority);
0086
0087 Standard_DEPRECATED("Deprecated since OCCT7.7, Graphic3d_DisplayPriority should be passed instead of integer number to SetDisplayPriority()")
0088 void SetDisplayPriority (const Standard_Integer thePriority) { SetDisplayPriority ((Graphic3d_DisplayPriority )thePriority); }
0089
0090
0091
0092 Standard_EXPORT void ResetDisplayPriority();
0093
0094
0095 virtual void Erase() { erase(); }
0096
0097
0098
0099
0100
0101 Standard_EXPORT void Highlight (const Handle(Graphic3d_PresentationAttributes)& theStyle, const Standard_Boolean theToUpdateMgr = Standard_True);
0102
0103
0104
0105
0106
0107 Standard_EXPORT void Remove();
0108
0109
0110 Standard_EXPORT virtual void CalculateBoundBox();
0111
0112
0113
0114
0115
0116
0117 void SetInfiniteState (const Standard_Boolean theToSet)
0118 {
0119 if (!myCStructure.IsNull()) { myCStructure->IsInfinite = theToSet ? 1 : 0; }
0120 }
0121
0122
0123
0124
0125
0126 Standard_EXPORT void SetZLayer (const Graphic3d_ZLayerId theLayerId);
0127
0128
0129
0130 Graphic3d_ZLayerId GetZLayer() const { return myCStructure->ZLayer(); }
0131
0132
0133
0134 void SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes)
0135 {
0136 if (!myCStructure.IsNull()) { myCStructure->SetClipPlanes (thePlanes); }
0137 }
0138
0139
0140
0141 const Handle(Graphic3d_SequenceOfHClipPlane)& ClipPlanes() const { return myCStructure->ClipPlanes(); }
0142
0143
0144
0145
0146
0147 Standard_EXPORT void SetVisible (const Standard_Boolean AValue);
0148
0149
0150 Standard_EXPORT virtual void SetVisual (const Graphic3d_TypeOfStructure AVisual);
0151
0152
0153
0154
0155
0156
0157
0158
0159 Standard_EXPORT void SetZoomLimit (const Standard_Real LimitInf, const Standard_Real LimitSup);
0160
0161
0162 void SetIsForHighlight (const Standard_Boolean isForHighlight)
0163 {
0164 if (!myCStructure.IsNull()) { myCStructure->IsForHighlight = isForHighlight; }
0165 }
0166
0167
0168
0169 Standard_EXPORT void UnHighlight();
0170
0171 virtual void Compute()
0172 {
0173
0174 }
0175
0176
0177 virtual void computeHLR (const Handle(Graphic3d_Camera)& theProjector,
0178 Handle(Graphic3d_Structure)& theStructure)
0179 {
0180 (void )theProjector;
0181 (void )theStructure;
0182 }
0183
0184
0185
0186 Standard_EXPORT void ReCompute();
0187
0188
0189
0190 Standard_EXPORT void ReCompute (const Handle(Graphic3d_DataStructureManager)& aProjector);
0191
0192
0193 const Graphic3d_SequenceOfGroup& Groups() const { return myCStructure->Groups(); }
0194
0195
0196 Standard_Integer NumberOfGroups() const { return myCStructure->Groups().Length(); }
0197
0198
0199 Standard_EXPORT Handle(Graphic3d_Group) NewGroup();
0200
0201
0202 Handle(Graphic3d_Group) CurrentGroup()
0203 {
0204 if (Groups().IsEmpty())
0205 {
0206 return NewGroup();
0207 }
0208 return Groups().Last();
0209 }
0210
0211
0212 const Handle(Graphic3d_PresentationAttributes)& HighlightStyle() const { return myCStructure->HighlightStyle(); }
0213
0214
0215 Standard_Boolean IsDeleted() const { return myCStructure.IsNull(); }
0216
0217
0218 virtual Standard_Boolean IsDisplayed() const
0219 {
0220 return !myCStructure.IsNull()
0221 && myCStructure->stick != 0;
0222 }
0223
0224
0225
0226
0227
0228
0229 Standard_EXPORT Standard_Boolean IsEmpty() const;
0230
0231
0232 Standard_Boolean IsInfinite() const
0233 {
0234 return IsDeleted()
0235 || myCStructure->IsInfinite;
0236 }
0237
0238
0239 virtual Standard_Boolean IsHighlighted() const
0240 {
0241 return !myCStructure.IsNull()
0242 && myCStructure->highlight != 0;
0243 }
0244
0245
0246 Standard_Boolean IsTransformed() const
0247 {
0248 return !myCStructure.IsNull()
0249 && !myCStructure->Transformation().IsNull()
0250 && myCStructure->Transformation()->Form() != gp_Identity;
0251 }
0252
0253
0254 Standard_Boolean IsVisible() const
0255 {
0256 return !myCStructure.IsNull()
0257 && myCStructure->visible != 0;
0258 }
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269 Standard_EXPORT Bnd_Box MinMaxValues (const Standard_Boolean theToIgnoreInfiniteFlag = Standard_False) const;
0270
0271
0272 Graphic3d_TypeOfStructure Visual() const { return myVisual; }
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287 Standard_EXPORT static Standard_Boolean AcceptConnection (Graphic3d_Structure* theStructure1,
0288 Graphic3d_Structure* theStructure2,
0289 Graphic3d_TypeOfConnection theType);
0290
0291
0292 Standard_EXPORT void Ancestors (Graphic3d_MapOfStructure& SG) const;
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302 Standard_EXPORT void Connect (Graphic3d_Structure* theStructure,
0303 Graphic3d_TypeOfConnection theType,
0304 Standard_Boolean theWithCheck = Standard_False);
0305
0306 Standard_DEPRECATED("Deprecated short-cut")
0307 void Connect (const Handle(Graphic3d_Structure)& thePrs)
0308 {
0309 Connect (thePrs.get(), Graphic3d_TOC_DESCENDANT);
0310 }
0311
0312
0313 Standard_EXPORT void Descendants (Graphic3d_MapOfStructure& SG) const;
0314
0315
0316 Standard_EXPORT void Disconnect (Graphic3d_Structure* theStructure);
0317
0318 Standard_DEPRECATED("Deprecated alias for Disconnect()")
0319 void Remove (const Handle(Graphic3d_Structure)& thePrs) { Disconnect (thePrs.get()); }
0320
0321
0322
0323
0324
0325 Standard_EXPORT void DisconnectAll (const Graphic3d_TypeOfConnection AType);
0326
0327 Standard_DEPRECATED("Deprecated alias for DisconnectAll()")
0328 void RemoveAll() { DisconnectAll (Graphic3d_TOC_DESCENDANT); }
0329
0330
0331
0332
0333
0334
0335 Standard_EXPORT static void Network (Graphic3d_Structure* theStructure,
0336 const Graphic3d_TypeOfConnection theType,
0337 NCollection_Map<Graphic3d_Structure*>& theSet);
0338
0339 void SetOwner (const Standard_Address theOwner) { myOwner = theOwner; }
0340
0341 Standard_Address Owner() const { return myOwner; }
0342
0343 void SetHLRValidation (const Standard_Boolean theFlag)
0344 {
0345 if (!myCStructure.IsNull()) { myCStructure->HLRValidation = theFlag ? 1 : 0; }
0346 }
0347
0348
0349
0350
0351 Standard_Boolean HLRValidation() const
0352 {
0353 return myOwner != NULL
0354 && myCStructure->HLRValidation != 0;
0355 }
0356
0357
0358 const Handle(TopLoc_Datum3D)& Transformation() const { return myCStructure->Transformation(); }
0359
0360
0361 Standard_EXPORT void SetTransformation (const Handle(TopLoc_Datum3D)& theTrsf);
0362
0363
0364 Standard_EXPORT void SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
0365
0366
0367 const Handle(Graphic3d_TransformPers)& TransformPersistence() const { return myCStructure->TransformPersistence(); }
0368
0369
0370 void SetMutable (const Standard_Boolean theIsMutable)
0371 {
0372 if (!myCStructure.IsNull()) { myCStructure->IsMutable = theIsMutable; }
0373 }
0374
0375
0376
0377 Standard_Boolean IsMutable() const
0378 {
0379 return !myCStructure.IsNull()
0380 && myCStructure->IsMutable;
0381 }
0382
0383 Graphic3d_TypeOfStructure ComputeVisual() const { return myComputeVisual; }
0384
0385
0386 Standard_EXPORT void GraphicClear (const Standard_Boolean WithDestruction);
0387
0388 void GraphicConnect (const Handle(Graphic3d_Structure)& theDaughter)
0389 {
0390 if (!myCStructure.IsNull()) { myCStructure->Connect (*theDaughter->myCStructure); }
0391 }
0392
0393 void GraphicDisconnect (const Handle(Graphic3d_Structure)& theDaughter)
0394 {
0395 if (!myCStructure.IsNull()) { myCStructure->Disconnect (*theDaughter->myCStructure); }
0396 }
0397
0398
0399 void GraphicTransform (const Handle(TopLoc_Datum3D)& theTrsf)
0400 {
0401 if (!myCStructure.IsNull()) { myCStructure->SetTransformation (theTrsf); }
0402 }
0403
0404
0405 Standard_Integer Identification() const { return myCStructure->Identification(); }
0406
0407
0408
0409 Standard_EXPORT static void PrintNetwork (const Handle(Graphic3d_Structure)& AStructure, const Graphic3d_TypeOfConnection AType);
0410
0411
0412 Standard_EXPORT void Remove (Graphic3d_Structure* thePtr,
0413 const Graphic3d_TypeOfConnection theType);
0414
0415 void SetComputeVisual (const Graphic3d_TypeOfStructure theVisual)
0416 {
0417
0418
0419 if (theVisual != Graphic3d_TOS_COMPUTED)
0420 {
0421 myComputeVisual = theVisual;
0422 }
0423 }
0424
0425
0426 Standard_EXPORT static void Transforms (const gp_Trsf& theTrsf,
0427 const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
0428 Standard_Real& theNewX, Standard_Real& theNewY, Standard_Real& theNewZ);
0429
0430
0431 const Handle(Graphic3d_CStructure)& CStructure() const { return myCStructure; }
0432
0433
0434 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0435
0436 protected:
0437
0438
0439 Standard_EXPORT static void TransformBoundaries (const gp_Trsf& theTrsf,
0440 Standard_Real& theXMin, Standard_Real& theYMin, Standard_Real& theZMin,
0441 Standard_Real& theXMax, Standard_Real& theYMax, Standard_Real& theZMax);
0442
0443
0444 Standard_EXPORT Standard_Boolean AppendDescendant (Graphic3d_Structure* theDescendant);
0445
0446
0447 Standard_EXPORT Standard_Boolean RemoveDescendant (Graphic3d_Structure* theDescendant);
0448
0449
0450 Standard_EXPORT Standard_Boolean AppendAncestor (Graphic3d_Structure* theAncestor);
0451
0452
0453 Standard_EXPORT Standard_Boolean RemoveAncestor (Graphic3d_Structure* theAncestor);
0454
0455
0456 Standard_EXPORT void clear (const Standard_Boolean WithDestruction);
0457
0458
0459 Standard_EXPORT void erase();
0460
0461 private:
0462
0463
0464
0465 Standard_EXPORT void Remove (const Handle(Graphic3d_Group)& theGroup);
0466
0467
0468 Standard_EXPORT Graphic3d_BndBox4f minMaxCoord() const;
0469
0470
0471 Standard_EXPORT void getBox (Graphic3d_BndBox3d& theBox, const Standard_Boolean theToIgnoreInfiniteFlag = Standard_False) const;
0472
0473
0474 Standard_EXPORT void addTransformed (Graphic3d_BndBox3d& theBox, const Standard_Boolean theToIgnoreInfiniteFlag = Standard_False) const;
0475
0476
0477 Standard_EXPORT Handle(Graphic3d_StructureManager) StructureManager() const;
0478
0479
0480
0481 Standard_EXPORT void Update (const bool theUpdateLayer = false) const;
0482
0483 protected:
0484
0485 Graphic3d_StructureManager* myStructureManager;
0486 Handle(Graphic3d_CStructure) myCStructure;
0487 NCollection_IndexedMap<Graphic3d_Structure*> myAncestors;
0488 NCollection_IndexedMap<Graphic3d_Structure*> myDescendants;
0489 Standard_Address myOwner;
0490 Graphic3d_TypeOfStructure myVisual;
0491 Graphic3d_TypeOfStructure myComputeVisual;
0492
0493 };
0494
0495 #endif