Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-23 09:17:53

0001 // Created on: 1993-09-21
0002 // Created by: Christian CAILLET
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _IGESData_ToolLocation_HeaderFile
0018 #define _IGESData_ToolLocation_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Interface_GeneralLib.hxx>
0024 #include <Standard_Integer.hxx>
0025 #include <NCollection_Array1.hxx>
0026 #include <Standard_Transient.hxx>
0027 class IGESData_IGESModel;
0028 class IGESData_Protocol;
0029 class IGESData_IGESEntity;
0030 class gp_GTrsf;
0031 class gp_Trsf;
0032 
0033 //! This Tool determines and gives access to effective Locations
0034 //! of IGES Entities as defined by the IGES Norm. These Locations
0035 //! can be for each Entity :
0036 //! - on one part, explicitly defined by a Transf in Directory
0037 //! Part (this Transf can be itself compound); if not defined,
0038 //! no proper Transformation is defined
0039 //! - on the other part, implicitly defined by a reference from
0040 //! another Entity : its Parent
0041 //! Both implicit and explicit locations are combinable.
0042 //!
0043 //! Implicit definition can be itself defined, either through the
0044 //! definition of an Entity (i.e. a Composite Curve references
0045 //! a list of Curves), or by a specific Associativity, of type
0046 //! SingleParentEntity, by which the Location of the Parent is
0047 //! applied to the Childs defined by this Associativity.
0048 //! Remark that a Transf itself has no Location, but it can be
0049 //! compound
0050 //!
0051 //! This is a TShared object, then it is easier to use in an
0052 //! interactive session
0053 class IGESData_ToolLocation : public Standard_Transient
0054 {
0055 
0056 public:
0057   //! Creates a ToolLocation on a given Model, filled with the help
0058   //! of a Protocol (which allows to known Entities referenced by
0059   //! other ones)
0060   Standard_EXPORT IGESData_ToolLocation(const occ::handle<IGESData_IGESModel>& amodel,
0061                                         const occ::handle<IGESData_Protocol>&  protocol);
0062 
0063   //! Does the effective work of determining Locations of Entities
0064   Standard_EXPORT void Load();
0065 
0066   //! Sets a precision for the Analysis of Locations
0067   //! (default by constructor is 1.E-05)
0068   Standard_EXPORT void SetPrecision(const double prec);
0069 
0070   //! Sets the "Reference" information for <child> as being <parent>
0071   //! Sets an Error Status if already set (see method IsAmbiguous)
0072   Standard_EXPORT void SetReference(const occ::handle<IGESData_IGESEntity>& parent,
0073                                     const occ::handle<IGESData_IGESEntity>& child);
0074 
0075   //! Sets the "Associativity" information for <child> as being
0076   //! <parent> (it must be the Parent itself, not the Associativity)
0077   Standard_EXPORT void SetParentAssoc(const occ::handle<IGESData_IGESEntity>& parent,
0078                                       const occ::handle<IGESData_IGESEntity>& child);
0079 
0080   //! Resets all information about dependences for <child>
0081   Standard_EXPORT void ResetDependences(const occ::handle<IGESData_IGESEntity>& child);
0082 
0083   //! Unitary action which defines Entities referenced by <ent>
0084   //! (except those in Directory Part and Associativities List)
0085   //! as Dependent (their Locations are related to that of <ent>)
0086   Standard_EXPORT void SetOwnAsDependent(const occ::handle<IGESData_IGESEntity>& ent);
0087 
0088   //! Returns True if <ent> is kind of TransfEntity. Then, it has
0089   //! no location, while it can be used to define a Location)
0090   Standard_EXPORT bool IsTransf(const occ::handle<IGESData_IGESEntity>& ent) const;
0091 
0092   //! Returns True if <ent> is an Associativity (IGES Type 402).
0093   //! Then, Location does not apply.
0094   Standard_EXPORT bool IsAssociativity(const occ::handle<IGESData_IGESEntity>& ent) const;
0095 
0096   //! Returns True if <ent> has a Transformation Matrix in proper
0097   //! (referenced from its Directory Part)
0098   Standard_EXPORT bool HasTransf(const occ::handle<IGESData_IGESEntity>& ent) const;
0099 
0100   //! Returns the Explicit Location defined by the Transformation
0101   //! Matrix of <ent>. Identity if there is none
0102   Standard_EXPORT gp_GTrsf ExplicitLocation(const occ::handle<IGESData_IGESEntity>& ent) const;
0103 
0104   //! Returns True if more than one Parent has been determined for
0105   //! <ent>, by adding direct References and Associativities
0106   Standard_EXPORT bool IsAmbiguous(const occ::handle<IGESData_IGESEntity>& ent) const;
0107 
0108   //! Returns True if <ent> is dependent from one and only one other
0109   //! Entity, either by Reference or by Associativity
0110   Standard_EXPORT bool HasParent(const occ::handle<IGESData_IGESEntity>& ent) const;
0111 
0112   //! Returns the unique Parent recorded for <ent>.
0113   //! Returns a Null Handle if there is none
0114   Standard_EXPORT occ::handle<IGESData_IGESEntity> Parent(
0115     const occ::handle<IGESData_IGESEntity>& ent) const;
0116 
0117   //! Returns True if the Parent, if there is one, is defined by
0118   //! a SingleParentEntity Associativity
0119   //! Else, if HasParent is True, it is by Reference
0120   Standard_EXPORT bool HasParentByAssociativity(const occ::handle<IGESData_IGESEntity>& ent) const;
0121 
0122   //! Returns the effective Location of the Parent of <ent>, if
0123   //! there is one : this Location is itself given as compound
0124   //! according dependences on the Parent, if there are some.
0125   //! Returns an Identity Transformation if no Parent is recorded.
0126   Standard_EXPORT gp_GTrsf ParentLocation(const occ::handle<IGESData_IGESEntity>& ent) const;
0127 
0128   //! Returns the effective Location of an Entity, i.e. the
0129   //! composition of its proper Transformation Matrix (returned by
0130   //! Transf) and its Parent's Location (returned by ParentLocation)
0131   Standard_EXPORT gp_GTrsf EffectiveLocation(const occ::handle<IGESData_IGESEntity>& ent) const;
0132 
0133   //! Analysis a Location given as a GTrsf, by trying to convert it
0134   //! to a Trsf (i.e. to a True Location of which effect is
0135   //! described by an Isometry or a Similarity)
0136   //! Works with the Precision given by default or by SetPrecision
0137   //! Calls ConvertLocation (see below)
0138   Standard_EXPORT bool AnalyseLocation(const gp_GTrsf& loc, gp_Trsf& result) const;
0139 
0140   //! Conversion of a Location, from GTrsf form to Trsf form
0141   //! Works with a precision given as argument.
0142   //! Returns True if the Conversion is possible, (hence, <result>
0143   //! contains the converted location), False else
0144   //! <unit>, if given, indicates the unit in which <loc> is defined
0145   //! in meters. It concerns the translation part (to be converted.
0146   //!
0147   //! As a class method, it can be called separately
0148   Standard_EXPORT static bool ConvertLocation(const double    prec,
0149                                               const gp_GTrsf& loc,
0150                                               gp_Trsf&        result,
0151                                               const double    uni = 1);
0152 
0153   DEFINE_STANDARD_RTTIEXT(IGESData_ToolLocation, Standard_Transient)
0154 
0155 private:
0156   double                          theprec;
0157   occ::handle<IGESData_IGESModel> themodel;
0158   Interface_GeneralLib            thelib;
0159   NCollection_Array1<int>         therefs;
0160   NCollection_Array1<int>         theassocs;
0161 };
0162 
0163 #endif // _IGESData_ToolLocation_HeaderFile