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