0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / TObj / TObj_CheckModel.hxx
CommitLineData
b311480e 1// Created on: 2007-04-17
2// Created by: Michael Sazonov
973c2be1 3// Copyright (c) 2007-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
7fd59977 16// The original implementation Copyright: (C) RINA S.p.A
17
18#ifndef TObj_CheckModel_HeaderFile
19#define TObj_CheckModel_HeaderFile
20
21#include <TObj_Common.hxx>
22#include <TObj_Model.hxx>
23#include <Message_Algorithm.hxx>
24
25/**
26 * This class provides consistency check of the TObj model.
27 * It collects all inconsistencies in the status bits and prepaires
28 * messages to be sent using SendStatusMessages (SendMessages) method.
29 * It supports also the fix mode, in which some inconsistencies are
30 * corrected.
31 */
32
33class TObj_CheckModel: public Message_Algorithm
34{
35public:
36 //! Initialize checker by model
37 TObj_CheckModel(const Handle(TObj_Model)& theModel)
38 : myModel (theModel),
39 myToFix (Standard_False)
40 {}
41
42 //! Sets flag allowing fixing inconsistencies
43 void SetToFix(const Standard_Boolean theToFix)
44 { myToFix = theToFix; }
45
46 //! Returns true if it is allowed to fix inconsistencies
47 Standard_Boolean IsToFix() const
48 { return myToFix; }
49
50 //! Returns the checked model
51 const Handle(TObj_Model)& GetModel() const
52 { return myModel; }
53
54 //! Empty virtual destructor
55 virtual ~TObj_CheckModel () {}
56
57 //! Performs all checks. Descendants should call parent method before
58 //! doing own checks.
59 //! This implementation checks OCAF references and back references
60 //! between objects of the model.
61 //! Returns true if no inconsistencies found.
62 virtual Standard_EXPORT Standard_Boolean Perform();
63
64private:
65 //! Check References (and back references in model).
66 //! This method just tries to find object to that this reference is indicate and
67 //! test if that object is not null or not deleted. Also it test if that object has back
68 //! reference to correct object (object that has forward reference).
69 Standard_EXPORT Standard_Boolean checkReferences();
70
71private:
72 Handle(TObj_Model) myModel;
73 Standard_Boolean myToFix;
74
75 public:
76 //! Declaration of CASCADE RTTI
92efcf78 77 DEFINE_STANDARD_RTTIEXT(TObj_CheckModel,Message_Algorithm)
7fd59977 78};
79
80//! Definition of HANDLE object using Standard_DefineHandle.hxx
81DEFINE_STANDARD_HANDLE (TObj_CheckModel,Message_Algorithm)
82
83#endif
84
85#ifdef _MSC_VER
86#pragma once
87#endif