zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
/////////////////////////////////////////////////////////////////////////////// 
// Copyright (C) 2002-2016, Open Design Alliance (the "Alliance"). 
// All rights reserved. 
// 
// This software and its documentation and related materials are owned by 
// the Alliance. The software may only be incorporated into application 
// programs owned by members of the Alliance, subject to a signed 
// Membership Agreement and Supplemental Software License Agreement with the
// Alliance. The structure and organization of this software are the valuable  
// trade secrets of the Alliance and its suppliers. The software is also 
// protected by copyright law and international treaty provisions. Application  
// programs incorporating this software must include the following statement 
// with their copyright notices:
//   
//   This application incorporates Teigha(R) software pursuant to a license 
//   agreement with Open Design Alliance.
//   Teigha(R) Copyright (C) 2002-2016 by Open Design Alliance. 
//   All rights reserved.
//
// By use of this software, its documentation or related materials, you 
// acknowledge and accept the above terms.
///////////////////////////////////////////////////////////////////////////////
 
 
 
 
#ifndef GEOMENT_DBREGION_H
#define GEOMENT_DBREGION_H
 
#include "TD_PackPush.h"
#include "ModelerDefs.h"
#include "DbEntity.h"
#include "DbSubentId.h"
 
class OdBrBrep;
class OdModelerGeometry;
 
/** \details
    This class represents Region entities in an OdDbDatabase instance.
 
    An OdDbRegion entity is a wrapper for an ACIS model that represents
    the geometry of the OdDbRegion entity.
 
    \sa
    TD_Db
    
   <group OdDb_Classes> 
*/
class TOOLKIT_EXPORT OdDbRegion : public OdDbEntity
{
public:
  ODDB_DECLARE_MEMBERS(OdDbRegion);
 
  OdDbRegion();
 
  /** \details
  Writes the ACIS data of this entity to the specified StreamBuf object.
 
  \param pStreamBuf [in] Pointer to the StreamBuf object to which the data is to be written.   
  \param typeVer    [in] Type and version of the ACIS data to write.
  
  \returns Returns eOk if successful or an appropriate error code if not. 
  */
  OdResult acisOut(
    OdStreamBuf* pStreamBuf, 
    AfTypeVer typeVer = kAfTypeVerAny);
 
  /** \details
  Reads the ACIS data for this entity from the specified StreamBuf object.
 
  \param pStreamBuf [in]  Pointer to the StreamBuf object from which the data is to be read.   
  \param typeVer    [out] Receives the type and version of the ACIS data to return.
 
  \returns eOk if successful or an appropriate error code in the other case.
  
  \remarks 
  If typeVer is null, this function uses the type and version 
  of this Region entity.
  */
  OdResult acisIn(
    OdStreamBuf* pStreamBuf, 
    AfTypeVer *typeVer = 0);
 
  /** \details
  Returns the boundary representation of the 3D solid entity.
  
  \param brep [out]  Receives the boundary representation.
  */
  void brep(
    OdBrBrep& brep);
 
  /** \details
  Returns true if and only if there is no ACIS model associated with this entity. 
  */
  bool isNull() const;
 
  /** \details
  Creates OdDbRegion entities from the closed loops defined by the specified curve segments.
  
  \param curveSegments  [in]  Array of curve segments. Each curve segment must be one of the following: OdDb3dPolyline, OdDbArc, OdDbCircle, OdDbEllipse, OdDbLine, OdDbPolyline, or OdDbSpline.
  \param regions        [out] Receives an array of pointers to the regions.
 
  \returns Returns eOk if successful, or an appropriate error code if not. 
 
  \remarks 
  The newly created regions are non-database residents. It is up to the caller to either add them
  to an OdDbDatabase or to delete them.
  */
  static OdResult createFromCurves( 
    const OdRxObjectPtrArray& curveSegments,
    OdRxObjectPtrArray& regions );
 
  /** \details
  Returns the WCS normal to the plane of this entity (DXF 210).
 
  \param normal [out]  Receives the normal.
 
  \returns Returns eOk if successful or an appropriate error code if not. 
  */
  virtual OdResult getNormal(
  OdGeVector3d& normal) const;
 
  /** \details
  Returns true if the region is planar or false in the other case.
  */
  virtual bool isPlanar() const;
 
  /** \details
  Returns the OdGePlane object that contains the region. If the region is Null, then the WCS X-Y plane is returned. 
 
  \param plane      [out] A reference to the OdGePlane object that stores the containing plane.
  \param planarity  [out] A reference to a variable containing information about planarity of the OdGePlane object.
 
  \returns Returns eOk if successful or an appropriate error code in other case.
 
  \remarks
  If typeVer is null, this function uses the type and version 
  of this region entity.
  */
  virtual OdResult getPlane(
    OdGePlane& plane, 
    OdDb::Planarity& planarity) const;
 
  TD_USING(OdDbEntity::getPlane);
 
  virtual OdResult dwgInFields(
    OdDbDwgFiler* pFiler);
 
  virtual void dwgOutFields(
    OdDbDwgFiler* pFiler) const;
 
  virtual OdResult dxfInFields(
    OdDbDxfFiler* pFiler);
 
  virtual void dxfOutFields(
    OdDbDxfFiler* pFiler) const;
 
  virtual bool subWorldDraw(
    OdGiWorldDraw* pWd) const;
 
  virtual OdResult subGetClassID(
    void* pClsid) const;
 
  virtual OdDbObjectPtr decomposeForSave(
    OdDb::DwgVersion ver, 
    OdDbObjectId& replaceId, 
    bool& exchangeXData);
 
  /** \details
  Directly sets the contained modeler geometry of this entity.
  
  \param pGeometry [in]  Pointer to the modeler geometry.
  
  \returns Returns eOk if successful or an appropriate error code in the other case.
  */
  virtual OdResult setBody( const void* pGeometry );
  
  /** \details 
  Returns the current modeler geometry. 
  */
  virtual void *body( ) const;
 
  virtual OdResult subExplode(
    OdRxObjectPtrArray& entitySet) const;
  
  virtual OdResult subTransformBy( 
    const OdGeMatrix3d& xfm );
 
  /** \details
  Creates a geometric representation of the region for saving proxy graphics or converting to previous formats.
 
  \param pWd [in] Pointer to the OdGiWorldDraw object.
  \param ver [in] Specifies the reason why the method is called.
 
  \remarks
  This method can be overridden in a custom classes.
  */
      virtual void saveAs(
    OdGiWorldDraw* pWd,
    OdDb::DwgVersion ver ) const;
 
  /** \details
  Performs a Boolean operation between this and another region object. 
  
  Possible operation types are: 
* kBoolUnite - unites two regions into one.
* kBoolIntersect - returns the intersection of two regions.
* kBoolSubtract - subtracts the region from the first one.
 
  \param operation  [in] Type of Boolean operation.     
  \param otherRegion      [out] Pointer to other region object which also will contain the result of the Boolean operation.
 
  \returns Returns eOk if the Boolean operation is successful or an appropriate error code if not. If the region is null, eInvalidInput is returned.
 
  \remarks
  This method is implemented only for Spatial modeler and returns eNotImplementedYet status
  for other modelers. 
  */
  virtual OdResult booleanOper(OdDb::BoolOperType operation, OdDbRegion* otherRegion);
 
  /** \details
  Calculates the area of the region.
  Area value is returned in square drawing units.
  
  \param area [out] Reference for returning the area value.
 
  \returns Returns eOk if successful or an appropriate error code otherwise.
  
  \remarks 
  This method is implemented only for Spatial modeler and returns eNotImplementedYet status
  for other modelers. 
  */
  virtual OdResult getArea(double& regionArea) const;
 
  /** \details
  Calculates the perimeter of the region.
  Perimeter value is returned in drawing units.
  
  \param area [out] Reference for returning the perimeter value.
 
  \returns Returns eOk if successful, or an appropriate error code otherwise.
 
  \remarks 
  This method is implemented only for Spatial modeler and returns eNotImplementedYet status
  for other modelers. 
  */
    virtual OdResult getPerimeter(double&) const;
 
  /** \details
  Calculates the area properties of the region. 
  
  The method validates the origin, xAxis, and yAxis parameters to ensure that:
* axes are perpendicular to each other.
* axes and the origin lie in the same plane as the region.
 
  \param origin        [in]  Origin of the coordinate system to use for evaluation (WCS). 
  \param xAxis         [in]  X axis of the coordinate system to use for evaluation (WCS).
  \param yAxis         [in]  Y axis of the coordinate system to use for evaluation (WCS).
  \param perimeter     [out] Reference for returning the value of region's perimeter.
  \param area          [out] Reference for returning the value of region's area.
  \param centroid      [out] Reference for returning centroid of the region.
  \param momInertia    [out] Static array for returning moments of inertia for the region.
  \param prodInertia   [out] Reference for returning region's product of inertia.
  \param prinMoments   [out] Static array for returning principal moments for the region. 
  \param prinAxes      [out] Static array for returning principle axes of the region. 
  \param radiiGyration [out] Static array for returning radii of gyration of the region. 
  \param extentsLow    [out] Reference for returning region's minimum extents point. 
  \param extentsHigh   [out] Reference for returning region's maximum extents point.
 
  \returns Returns eOk if successful, or an appropriate error code otherwise.
 
  \remarks 
  Returned values are measured using the values of origin, xAxis, yAxis parameters. 
  and are represented in WCS coordinates.
 
  This method is implemented only for Spatial modeler and returns eNotImplementedYet status
  for other modelers. 
  */
  virtual OdResult getAreaProp( const OdGePoint3d& origin, const OdGeVector3d& xAxis,
    const OdGeVector3d& yAxis, double& perimeter,
    double& area, OdGePoint2d& centroid,
    double momInertia[2], double& prodInertia,
    double prinMoments[2], OdGeVector2d prinAxes[2],
    double radiiGyration[2], OdGePoint2d& extentsLow,
    OdGePoint2d& extentsHigh ) const;
 
  /** \details
    Finds the intersections of the specified entity with all the edges of the region's bounding box. 
    
 
  \param pEnt               [in]  Pointer to the entity which must be intersected with the region.
  \param intType        [in]  Intersection type.
  \param points             [out] Reference to the array of the appended points of intersection (point coordinates are represented in WCS).
  \param thisGsMarker   [in]  GS marker of the subentity of the region involved in the intersection operation.
  \param otherGsMarker  [in]  GS marker of the subentity of the entity represented by pEnt that is involved in the intersection operation.    
    
 
  \returns Returns eOk if successful or an appropriate error code in other case.
 
  \remarks 
    The intType parameter determines the extension of the region and the specified entity while calculating intersections:
* OdDb::kOnBothOperands - do not extend the region or the entity represented with pEnt bounding box edges. 
In this case the method calculates only where the bounding box lines actually intersect with the specified entity.
* OdDb::kExtendThis - extend the region's bounding box edges (if necessary) when calculating intersections without extending the specified entity. 
* OdDb::kExtendArg - extend the specified entity (if necessary) when calculating intersections without extending the region's bounding box edges.
* OdDb::kExtendBoth - extend both the region's bounding box and the specified entity (if necessary) when calculating intersections.
    
    Any found intersection points are appended to the points array. All points are represented in WCS coordinates. 
 
  The thisGsMarker and otherGsMarker parameters provide information for searching intersections between specified subentities. 
    The default value for these parameters is zero.
    
    This method is implemented only for Spatial modeler and returns eNotImplementedYet status 
    for other modelers. 
  */
  virtual OdResult subIntersectWith(const OdDbEntity* pEnt, OdDb::Intersect intType,
    OdGePoint3dArray& points, OdGsMarker thisGsMarker = 0,
    OdGsMarker otherGsMarker = 0) const;
 
  /** \details
  Projects the bounding box edges of the region and the specified entity onto the specified plane, finds the intersection points for the projections, 
  and then projects them back onto the bounding box edge of the region.   
   
 
  \param pEnt                 [in]  Pointer to the entity which must be intersected with the region.
  \param intType             [in]  Intersection type.
  \param projPlane         [in]  Projection plane for the apparent intersection of the specified entity and the region.
  \param points             [out] Reference to the array of the appended points of intersection (points coordinates are represented in WCS).
  \param thisGsMarker   [in]  GS marker of the subentity of the region involved in the intersection operation.
  \param otherGsMarker  [in]  GS marker of the subentity of the entity represented by pEnt that is involved in the intersection operation.
  
  \returns Returns eOk if successful or an appropriate error code otherwise.
  
  \remarks 
  All the points appended to the points array will be on its bounding box edges. The projections are parallel to the normal vector of the plane referenced with projPlane. 
  Intersection type can be one of the following:
* OdDb::kOnBothOperands - do not extend the region or the entity represented with pEnt bounding box edges. 
  In this case the method calculates only where the bounding box lines actually intersect with the specified entity.
* OdDb::kExtendThis - extend the region's bounding box edges (if necessary) when calculating intersections without extending the specified entity.  
* OdDb::kExtendArg - extend the specified entity (if necessary) when calculating intersections without extending region's bounding box edges.
* OdDb::kExtendBoth  extend both the region's bounding box and the specified entity (if necessary) when calculating intersections.
 
  This method is implemented only for Spatial modeler and returns eNotImplementedYet status
  for other modelers. 
  */
  virtual OdResult subIntersectWith(const OdDbEntity* pEnt, OdDb::Intersect intType,
    const OdGePlane& projPlane, OdGePoint3dArray& points,
    OdGsMarker thisGsMarker = 0, OdGsMarker otherGsMarker = 0) const;
 
  virtual OdDbEntityPtr subSubentPtr(const OdDbFullSubentPath& id) const;
 
  virtual OdResult subGetGsMarkersAtSubentPath(const OdDbFullSubentPath& subPath, OdGsMarkerArray& gsMarkers) const;
 
  virtual OdResult subGetSubentPathsAtGsMarker(OdDb::SubentType type,
                                               OdGsMarker gsMark, 
                                               const OdGePoint3d& pickPoint,
                                               const OdGeMatrix3d& viewXform, 
                                               OdDbFullSubentPathArray& subentPaths, 
                                               const OdDbObjectIdArray* pEntAndInsertStack = 0) const;
 
  /** \details
  Returns the number of changes occurred since the region was created.
  */
    virtual OdUInt32 numChanges() const;
 
  virtual OdDbSubentId internalSubentId(void* ent) const;
  virtual void* internalSubentPtr(const OdDbSubentId& id) const;
 
  virtual OdUInt32 subSetAttributes(OdGiDrawableTraits* pTraits) const;
 
  virtual OdResult subGetGeomExtents( OdGeExtents3d& extents) const;
};
 
/** \details
This template class is a specialization of the OdSmartPtr class for OdDbRegion object pointers.
*/
typedef OdSmartPtr<OdDbRegion> OdDbRegionPtr;
 
#include "TD_PackPop.h"
 
#endif