42cf5bc1 |
1 | // Created on: 1999-09-08 |
2 | // Created by: Andrey BETENEV |
3 | // Copyright (c) 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 _STEPConstruct_ValidationProps_HeaderFile |
18 | #define _STEPConstruct_ValidationProps_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <StepBasic_Unit.hxx> |
25 | #include <STEPConstruct_Tool.hxx> |
26 | #include <Standard_Boolean.hxx> |
27 | #include <Standard_CString.hxx> |
28 | #include <Standard_Real.hxx> |
29 | #include <TColStd_SequenceOfTransient.hxx> |
30 | class StepBasic_ProductDefinition; |
31 | class XSControl_WorkSession; |
32 | class TopoDS_Shape; |
33 | class StepRepr_RepresentationItem; |
34 | class StepRepr_CharacterizedDefinition; |
35 | class StepRepr_RepresentationContext; |
36 | class gp_Pnt; |
37 | class StepRepr_NextAssemblyUsageOccurrence; |
38 | class StepRepr_PropertyDefinition; |
39 | |
40 | |
41 | //! This class provides tools for access (write and read) |
42 | //! the validation properties on shapes in the STEP file. |
43 | //! These are surface area, solid volume and centroid. |
44 | class STEPConstruct_ValidationProps : public STEPConstruct_Tool |
45 | { |
46 | public: |
47 | |
48 | DEFINE_STANDARD_ALLOC |
49 | |
50 | |
51 | //! Creates an empty tool |
52 | Standard_EXPORT STEPConstruct_ValidationProps(); |
53 | |
54 | //! Creates a tool and loads it with worksession |
55 | Standard_EXPORT STEPConstruct_ValidationProps(const Handle(XSControl_WorkSession)& WS); |
56 | |
57 | //! Load worksession; returns True if succeeded |
58 | Standard_EXPORT Standard_Boolean Init (const Handle(XSControl_WorkSession)& WS); |
59 | |
60 | //! General method for adding (writing) a validation property |
61 | //! for shape which should be already mapped on writing itself. |
62 | //! It uses FindTarget() to find target STEP entity |
63 | //! resulting from given shape, and associated context |
64 | //! Returns True if success, False in case of fail |
65 | Standard_EXPORT Standard_Boolean AddProp (const TopoDS_Shape& Shape, const Handle(StepRepr_RepresentationItem)& Prop, const Standard_CString Descr, const Standard_Boolean instance = Standard_False); |
66 | |
67 | //! General method for adding (writing) a validation property |
68 | //! for shape which should be already mapped on writing itself. |
69 | //! It takes target and Context entities which correspond to shape |
70 | //! Returns True if success, False in case of fail |
71 | Standard_EXPORT Standard_Boolean AddProp (const StepRepr_CharacterizedDefinition& target, const Handle(StepRepr_RepresentationContext)& Context, const Handle(StepRepr_RepresentationItem)& Prop, const Standard_CString Descr); |
72 | |
73 | //! Adds surface area property for given shape (already mapped). |
74 | //! Returns True if success, False in case of fail |
75 | Standard_EXPORT Standard_Boolean AddArea (const TopoDS_Shape& Shape, const Standard_Real Area); |
76 | |
77 | //! Adds volume property for given shape (already mapped). |
78 | //! Returns True if success, False in case of fail |
79 | Standard_EXPORT Standard_Boolean AddVolume (const TopoDS_Shape& Shape, const Standard_Real Vol); |
80 | |
81 | //! Adds centroid property for given shape (already mapped). |
82 | //! Returns True if success, False in case of fail |
83 | //! If instance is True, then centroid is assigned to |
84 | //! an instance of component in assembly |
85 | Standard_EXPORT Standard_Boolean AddCentroid (const TopoDS_Shape& Shape, const gp_Pnt& Pnt, const Standard_Boolean instance = Standard_False); |
86 | |
87 | //! Finds target STEP entity to which validation props should |
88 | //! be assigned, and corresponding context, starting from shape |
89 | //! Returns True if success, False in case of fail |
90 | Standard_EXPORT Standard_Boolean FindTarget (const TopoDS_Shape& S, StepRepr_CharacterizedDefinition& target, Handle(StepRepr_RepresentationContext)& Context, const Standard_Boolean instance = Standard_False); |
91 | |
92 | //! Searches for entities of the type PropertyDefinitionRepresentation |
93 | //! in the model and fills the sequence by them |
94 | Standard_EXPORT Standard_Boolean LoadProps (TColStd_SequenceOfTransient& seq) const; |
95 | |
96 | //! Returns CDSR associated with given PpD or NULL if not found |
97 | //! (when, try GetPropSDR) |
98 | Standard_EXPORT Handle(StepRepr_NextAssemblyUsageOccurrence) GetPropNAUO (const Handle(StepRepr_PropertyDefinition)& PD) const; |
99 | |
100 | //! Returns SDR associated with given PpD or NULL if not found |
101 | //! (when, try GetPropCDSR) |
102 | Standard_EXPORT Handle(StepBasic_ProductDefinition) GetPropPD (const Handle(StepRepr_PropertyDefinition)& PD) const; |
103 | |
104 | //! Returns Shape associated with given SDR or Null Shape |
105 | //! if not found |
106 | Standard_EXPORT TopoDS_Shape GetPropShape (const Handle(StepBasic_ProductDefinition)& ProdDef) const; |
107 | |
108 | //! Returns Shape associated with given PpD or Null Shape |
109 | //! if not found |
110 | Standard_EXPORT TopoDS_Shape GetPropShape (const Handle(StepRepr_PropertyDefinition)& PD) const; |
111 | |
112 | //! Returns value of Real-Valued property (Area or Volume) |
113 | //! If Property is neither Area nor Volume, returns False |
114 | //! Else returns True and isArea indicates whether property |
115 | //! is area or volume |
116 | Standard_EXPORT Standard_Boolean GetPropReal (const Handle(StepRepr_RepresentationItem)& item, Standard_Real& Val, Standard_Boolean& isArea) const; |
117 | |
118 | //! Returns value of Centriod property (or False if it is not) |
119 | Standard_EXPORT Standard_Boolean GetPropPnt (const Handle(StepRepr_RepresentationItem)& item, const Handle(StepRepr_RepresentationContext)& Context, gp_Pnt& Pnt) const; |
120 | |
121 | //! Sets current assembly shape SDR (for FindCDSR calls) |
122 | Standard_EXPORT void SetAssemblyShape (const TopoDS_Shape& shape); |
123 | |
124 | |
125 | |
126 | |
127 | protected: |
128 | |
129 | |
130 | |
131 | |
132 | |
133 | private: |
134 | |
135 | |
136 | |
137 | StepBasic_Unit areaUnit; |
138 | StepBasic_Unit volUnit; |
139 | Handle(StepBasic_ProductDefinition) myAssemblyPD; |
140 | |
141 | |
142 | }; |
143 | |
144 | |
145 | |
146 | |
147 | |
148 | |
149 | |
150 | #endif // _STEPConstruct_ValidationProps_HeaderFile |