Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 09:17:07

0001 // Created on: 1999-09-08
0002 // Created by: Andrey BETENEV
0003 // Copyright (c) 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 _STEPConstruct_ValidationProps_HeaderFile
0018 #define _STEPConstruct_ValidationProps_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <StepBasic_Unit.hxx>
0025 #include <STEPConstruct_Tool.hxx>
0026 #include <Standard_CString.hxx>
0027 #include <Standard_Transient.hxx>
0028 #include <NCollection_Sequence.hxx>
0029 class StepBasic_ProductDefinition;
0030 class XSControl_WorkSession;
0031 class TopoDS_Shape;
0032 class StepRepr_RepresentationItem;
0033 class StepRepr_CharacterizedDefinition;
0034 class StepRepr_RepresentationContext;
0035 class gp_Pnt;
0036 class StepRepr_NextAssemblyUsageOccurrence;
0037 class StepRepr_PropertyDefinition;
0038 
0039 //! This class provides tools for access (write and read)
0040 //! the validation properties on shapes in the STEP file.
0041 //! These are surface area, solid volume and centroid.
0042 class STEPConstruct_ValidationProps : public STEPConstruct_Tool
0043 {
0044 public:
0045   DEFINE_STANDARD_ALLOC
0046 
0047   //! Creates an empty tool
0048   Standard_EXPORT STEPConstruct_ValidationProps();
0049 
0050   //! Creates a tool and loads it with worksession
0051   Standard_EXPORT STEPConstruct_ValidationProps(const occ::handle<XSControl_WorkSession>& WS);
0052 
0053   //! Load worksession; returns True if succeeded
0054   Standard_EXPORT bool Init(const occ::handle<XSControl_WorkSession>& WS);
0055 
0056   //! General method for adding (writing) a validation property
0057   //! for shape which should be already mapped on writing itself.
0058   //! It uses FindTarget() to find target STEP entity
0059   //! resulting from given shape, and associated context
0060   //! Returns True if success, False in case of fail
0061   Standard_EXPORT bool AddProp(const TopoDS_Shape&                             Shape,
0062                                const occ::handle<StepRepr_RepresentationItem>& Prop,
0063                                const char* const                               Descr,
0064                                const bool                                      instance = false);
0065 
0066   //! General method for adding (writing) a validation property
0067   //! for shape which should be already mapped on writing itself.
0068   //! It takes target and Context entities which correspond to shape
0069   //! Returns True if success, False in case of fail
0070   Standard_EXPORT bool AddProp(const StepRepr_CharacterizedDefinition&            target,
0071                                const occ::handle<StepRepr_RepresentationContext>& Context,
0072                                const occ::handle<StepRepr_RepresentationItem>&    Prop,
0073                                const char* const                                  Descr);
0074 
0075   //! Adds surface area property for given shape (already mapped).
0076   //! Returns True if success, False in case of fail
0077   Standard_EXPORT bool AddArea(const TopoDS_Shape& Shape, const double Area);
0078 
0079   //! Adds volume property for given shape (already mapped).
0080   //! Returns True if success, False in case of fail
0081   Standard_EXPORT bool AddVolume(const TopoDS_Shape& Shape, const double Vol);
0082 
0083   //! Adds centroid property for given shape (already mapped).
0084   //! Returns True if success, False in case of fail
0085   //! If instance is True, then centroid is assigned to
0086   //! an instance of component in assembly
0087   Standard_EXPORT bool AddCentroid(const TopoDS_Shape& Shape,
0088                                    const gp_Pnt&       Pnt,
0089                                    const bool          instance = false);
0090 
0091   //! Finds target STEP entity to which validation props should
0092   //! be assigned, and corresponding context, starting from shape
0093   //! Returns True if success, False in case of fail
0094   Standard_EXPORT bool FindTarget(const TopoDS_Shape&                          S,
0095                                   StepRepr_CharacterizedDefinition&            target,
0096                                   occ::handle<StepRepr_RepresentationContext>& Context,
0097                                   const bool                                   instance = false);
0098 
0099   //! Searches for entities of the type PropertyDefinitionRepresentation
0100   //! in the model and fills the sequence by them
0101   Standard_EXPORT bool LoadProps(NCollection_Sequence<occ::handle<Standard_Transient>>& seq) const;
0102 
0103   //! Returns CDSR associated with given PpD or NULL if not found
0104   //! (when, try GetPropSDR)
0105   Standard_EXPORT occ::handle<StepRepr_NextAssemblyUsageOccurrence> GetPropNAUO(
0106     const occ::handle<StepRepr_PropertyDefinition>& PD) const;
0107 
0108   //! Returns SDR associated with given PpD or NULL if not found
0109   //! (when, try GetPropCDSR)
0110   Standard_EXPORT occ::handle<StepBasic_ProductDefinition> GetPropPD(
0111     const occ::handle<StepRepr_PropertyDefinition>& PD) const;
0112 
0113   //! Returns Shape associated with given SDR or Null Shape
0114   //! if not found
0115   Standard_EXPORT TopoDS_Shape
0116     GetPropShape(const occ::handle<StepBasic_ProductDefinition>& ProdDef) const;
0117 
0118   //! Returns Shape associated with given PpD or Null Shape
0119   //! if not found
0120   Standard_EXPORT TopoDS_Shape
0121     GetPropShape(const occ::handle<StepRepr_PropertyDefinition>& PD) const;
0122 
0123   //! Returns value of Real-Valued property (Area or Volume)
0124   //! If Property is neither Area nor Volume, returns False
0125   //! Else returns True and isArea indicates whether property
0126   //! is area or volume
0127   Standard_EXPORT bool GetPropReal(
0128     const occ::handle<StepRepr_RepresentationItem>& item,
0129     double&                                         Val,
0130     bool&                                           isArea,
0131     const StepData_Factors&                         theLocalFactors = StepData_Factors()) const;
0132 
0133   //! Returns value of Centroid property (or False if it is not)
0134   Standard_EXPORT bool GetPropPnt(
0135     const occ::handle<StepRepr_RepresentationItem>&    item,
0136     const occ::handle<StepRepr_RepresentationContext>& Context,
0137     gp_Pnt&                                            Pnt,
0138     const StepData_Factors&                            theLocalFactors = StepData_Factors()) const;
0139 
0140   //! Sets current assembly shape SDR (for FindCDSR calls)
0141   Standard_EXPORT void SetAssemblyShape(const TopoDS_Shape& shape);
0142 
0143 private:
0144   StepBasic_Unit                           areaUnit;
0145   StepBasic_Unit                           volUnit;
0146   occ::handle<StepBasic_ProductDefinition> myAssemblyPD;
0147 };
0148 
0149 #endif // _STEPConstruct_ValidationProps_HeaderFile