0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IGESData / IGESData_ToolLocation.hxx
CommitLineData
42cf5bc1 1// Created on: 1993-09-21
2// Created by: Christian CAILLET
3// Copyright (c) 1993-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _IGESData_ToolLocation_HeaderFile
18#define _IGESData_ToolLocation_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <Standard_Real.hxx>
24#include <Interface_GeneralLib.hxx>
25#include <TColStd_Array1OfInteger.hxx>
25e59720 26#include <Standard_Transient.hxx>
42cf5bc1 27#include <Standard_Boolean.hxx>
28class IGESData_IGESModel;
29class Standard_DomainError;
30class IGESData_Protocol;
31class IGESData_IGESEntity;
32class gp_GTrsf;
33class gp_Trsf;
34
35
36class IGESData_ToolLocation;
25e59720 37DEFINE_STANDARD_HANDLE(IGESData_ToolLocation, Standard_Transient)
42cf5bc1 38
39//! This Tool determines and gives access to effective Locations
40//! of IGES Entities as defined by the IGES Norm. These Locations
41//! can be for each Entity :
42//! - on one part, explicitly defined by a Transf in Directory
43//! Part (this Transf can be itself compound); if not defined,
44//! no proper Transformation is defined
45//! - on the other part, implicitly defined by a reference from
46//! another Entity : its Parent
47//! Both implicit and explicit locations are combinable.
48//!
49//! Implicit definition can be itself defined, either through the
50//! definition of an Entity (i.e. a Composite Curve references
51//! a list of Curves), or by a specific Associativity, of type
52//! SingleParentEntity, by which the Location of the Parent is
53//! applied to the Childs defined by this Associativity.
54//! Remark that a Transf itself has no Location, but it can be
55//! compound
56//!
57//! This is a TShared object, then it is easier to use in an
58//! interactive session
25e59720 59class IGESData_ToolLocation : public Standard_Transient
42cf5bc1 60{
61
62public:
63
64
65 //! Creates a ToolLocation on a given Model, filled with the help
66 //! of a Protocol (which allows to known Entities referenced by
67 //! other ones)
68 Standard_EXPORT IGESData_ToolLocation(const Handle(IGESData_IGESModel)& amodel, const Handle(IGESData_Protocol)& protocol);
69
70 //! Does the effective work of determining Locations of Entities
71 Standard_EXPORT void Load();
72
73 //! Sets a precision for the Analysis of Locations
74 //! (default by constructor is 1.E-05)
75 Standard_EXPORT void SetPrecision (const Standard_Real prec);
76
77 //! Sets the "Reference" information for <child> as being <parent>
78 //! Sets an Error Status if already set (see method IsAmbiguous)
79 Standard_EXPORT void SetReference (const Handle(IGESData_IGESEntity)& parent, const Handle(IGESData_IGESEntity)& child);
80
81 //! Sets the "Associativity" information for <child> as being
82 //! <parent> (it must be the Parent itself, not the Associativity)
83 Standard_EXPORT void SetParentAssoc (const Handle(IGESData_IGESEntity)& parent, const Handle(IGESData_IGESEntity)& child);
84
85 //! Resets all informations about dependences for <child>
86 Standard_EXPORT void ResetDependences (const Handle(IGESData_IGESEntity)& child);
87
88 //! Unitary action which defines Entities referenced by <ent>
89 //! (except those in Directory Part and Associativities List)
90 //! as Dependent (their Locations are related to that of <ent>)
91 Standard_EXPORT void SetOwnAsDependent (const Handle(IGESData_IGESEntity)& ent);
92
93 //! Returns True if <ent> is kind of TransfEntity. Then, it has
94 //! no location, while it can be used to define a Location)
95 Standard_EXPORT Standard_Boolean IsTransf (const Handle(IGESData_IGESEntity)& ent) const;
96
97 //! Returns True if <ent> is an Associativity (IGES Type 402).
98 //! Then, Location does not apply.
99 Standard_EXPORT Standard_Boolean IsAssociativity (const Handle(IGESData_IGESEntity)& ent) const;
100
101 //! Returns True if <ent> has a Transformation Matrix in proper
102 //! (referenced from its Directory Part)
103 Standard_EXPORT Standard_Boolean HasTransf (const Handle(IGESData_IGESEntity)& ent) const;
104
105 //! Returns the Explicit Location defined by the Transformation
106 //! Matrix of <ent>. Identity if there is none
107 Standard_EXPORT gp_GTrsf ExplicitLocation (const Handle(IGESData_IGESEntity)& ent) const;
108
109 //! Returns True if more than one Parent has been determined for
110 //! <ent>, by adding direct References and Associativities
111 Standard_EXPORT Standard_Boolean IsAmbiguous (const Handle(IGESData_IGESEntity)& ent) const;
112
113 //! Returns True if <ent> is dependent from one and only one other
114 //! Entity, either by Reference or by Associativity
115 Standard_EXPORT Standard_Boolean HasParent (const Handle(IGESData_IGESEntity)& ent) const;
116
117 //! Returns the unique Parent recorded for <ent>.
118 //! Returns a Null Handle if there is none
119 Standard_EXPORT Handle(IGESData_IGESEntity) Parent (const Handle(IGESData_IGESEntity)& ent) const;
120
121 //! Returns True if the Parent, if there is one, is defined by
122 //! a SingleParentEntity Associativity
123 //! Else, if HasParent is True, it is by Reference
124 Standard_EXPORT Standard_Boolean HasParentByAssociativity (const Handle(IGESData_IGESEntity)& ent) const;
125
126 //! Returns the effective Location of the Parent of <ent>, if
127 //! there is one : this Location is itself given as compound
128 //! according dependences on the Parent, if there are some.
129 //! Returns an Identity Transformation if no Parent is recorded.
130 Standard_EXPORT gp_GTrsf ParentLocation (const Handle(IGESData_IGESEntity)& ent) const;
131
132 //! Returns the effective Location of an Entity, i.e. the
133 //! composition of its proper Transformation Matrix (returned by
134 //! Transf) and its Parent's Location (returned by ParentLocation)
135 Standard_EXPORT gp_GTrsf EffectiveLocation (const Handle(IGESData_IGESEntity)& ent) const;
136
137 //! Analysis a Location given as a GTrsf, by trying to convert it
138 //! to a Trsf (i.e. to a True Location of which effect is
139 //! described by an Isometry or a Similarity)
140 //! Works with the Precision given by default or by SetPrecision
141 //! Calls ConvertLocation (see below)
142 Standard_EXPORT Standard_Boolean AnalyseLocation (const gp_GTrsf& loc, gp_Trsf& result) const;
143
144 //! Convertion of a Location, from GTrsf form to Trsf form
145 //! Works with a precision given as argument.
146 //! Returns True if the Conversion is possible, (hence, <result>
147 //! contains the converted location), False else
148 //! <unit>, if given, indicates the unit in which <loc> is defined
149 //! in meters. It concerns the translation part (to be converted.
150 //!
151 //! As a class method, it can be called separately
152 Standard_EXPORT static Standard_Boolean ConvertLocation (const Standard_Real prec, const gp_GTrsf& loc, gp_Trsf& result, const Standard_Real uni = 1);
153
154
155
156
25e59720 157 DEFINE_STANDARD_RTTIEXT(IGESData_ToolLocation,Standard_Transient)
42cf5bc1 158
159protected:
160
161
162
163
164private:
165
166
167 Standard_Real theprec;
168 Handle(IGESData_IGESModel) themodel;
169 Interface_GeneralLib thelib;
170 TColStd_Array1OfInteger therefs;
171 TColStd_Array1OfInteger theassocs;
172
173
174};
175
176
177
178
179
180
181
182#endif // _IGESData_ToolLocation_HeaderFile