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
/////////////////////////////////////////////////////////////////////////////// 
// 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 _DBMPOLYGON_H_INCLUDED_
#define _DBMPOLYGON_H_INCLUDED_
 
#include "DbHatch.h"
 
class OdDbCircle;
class OdDb2dPolyline;
class OdDbPolyline;
class OdDbMPolygonCrossing;
typedef OdArray<OdDbMPolygonCrossing,OdPlainObjectsAllocator<OdDbMPolygonCrossing> > OdDbMPolygonCrossingArray;
class OdDbMPolygonNode;
 
const double OdDbMPolygonCrossingFuzz = 1E-6;
 
/** \details
    This class processes one or more closed polygons as a single polygon.
    
    \sa
    TD_Db
   
    <group OdDb_Classes>
*/
class TOOLKIT_EXPORT OdDbMPolygon : public OdDbEntity {
public:
  OdDbMPolygon();
  virtual ~OdDbMPolygon();
 
  ODDB_DECLARE_MEMBERS(OdDbMPolygon);
 
  virtual OdDbHatchPtr hatch();
 
  virtual double elevation() const;
  virtual void setElevation(double elevation);
 
  virtual OdGeVector3d normal() const;
  virtual void setNormal(const OdGeVector3d& normal);
 
  virtual OdResult evaluateHatch(bool bUnderestimateNumLines = false);
 
  virtual OdDbHatch::HatchPatternType patternType() const;
 
  virtual const OdString& patternName() const;
 
  virtual void setPattern(OdDbHatch::HatchPatternType patType,
    const OdString& patName);
 
  virtual double patternAngle() const;
  virtual void setPatternAngle(double angle);
 
  virtual double patternSpace() const;
  virtual void setPatternSpace(double space);
 
  virtual double patternScale() const;
  virtual void setPatternScale(double scale);
 
  virtual bool patternDouble() const;
  virtual void setPatternDouble(bool isDouble);
 
  virtual int numPatternDefinitions() const;
  virtual void getPatternDefinitionAt(int index, 
    double& angle,
    double& baseX,
    double& baseY,
    double& offsetX,
    double& offsetY,
    OdGeDoubleArray& dashes)
    const;
 
  void setGradientAngle(double angle);
  void setGradientShift( float shiftValue );
  void setGradientOneColorMode( bool oneColorMode );
  void setGradientColors( unsigned int count, 
    const OdCmColor* colors,
    const double* values );
  void setGradient(OdDbHatch::GradientPatternType gradType,
    const OdString& gradName);
 
 
  virtual OdCmColor patternColor() const;
  virtual void setPatternColor(const OdCmColor& pc);
 
  /** \details
    Returns the area of this entity.
 
    \param area [out]  Receives the area.
    \remarks
    Returns eOk if successful, or an appropriate error code if not.
  */
  virtual OdResult getArea(double& area) const;
 
  virtual OdGeVector2d getOffsetVector() const;
 
  virtual OdResult appendLoopFromBoundary(const OdDbCircle* pCircle,
    bool excludeCrossing = true, double tol = OdDbMPolygonCrossingFuzz);
  virtual OdResult appendLoopFromBoundary(const OdDbPolyline* pPoly,
    bool excludeCrossing = true, double tol = OdDbMPolygonCrossingFuzz);
  virtual OdResult appendLoopFromBoundary(const OdDb2dPolyline* pPoly,
    bool excludeCrossing = true, double tol = OdDbMPolygonCrossingFuzz);
 
  /** \details
    Returns the number of loops in the closed polygon.
  */
  virtual int numMPolygonLoops() const;
 
  virtual OdResult getMPolygonLoopAt(int loopIndex, OdGePoint2dArray& vertices,
    OdGeDoubleArray& bulges) const;
 
  virtual OdResult appendMPolygonLoop(const OdGePoint2dArray& vertices,
    const OdGeDoubleArray& bulges, bool excludeCrossing = true,
    double tol = OdDbMPolygonCrossingFuzz);
 
  virtual OdResult insertMPolygonLoopAt(int loopIndex, 
    const OdGePoint2dArray& vertices, const OdGeDoubleArray& bulges, 
    bool excludeCrossing = true, double tol = OdDbMPolygonCrossingFuzz);
 
  virtual OdResult removeMPolygonLoopAt(int loopIndex);
 
  /** \details
    Declares the loop directions.
  */
  enum loopDir {
    kExterior   = 0,   // Loop direction is counter-clockwise
    kInterior   = 1,   // Loop direction is clockwise
    kAnnotation = 2    // Text
  };
 
  /** \details
    Gets the direction of the specified loop in the closed polygon.
    Returns eOk if successful, or eInvalidInput if loop index is out of range.
 
    \param lindex [in]  Loop index as an Ingeter value in the range 0 to numMPolygonLoops()-1.
    \param dir [out]  Reference to a variable in which the loop direction must be saved.
  */
  virtual OdResult getLoopDirection(int lindex, OdDbMPolygon::loopDir& dir) const;
 
  /** \details
    Sets the direction for the specified loop in the closed polygon.
    Returns eOk if successful, or eInvalidInput if loop index is out of range.
 
    \param lindex [in]  Loop index as an Ingeter value in range 0 to numMPolygonLoops()-1.
    \param dir [in]  Loop direction.
  */
  virtual OdResult setLoopDirection(int lindex, OdDbMPolygon::loopDir dir);
 
  virtual bool isPointOnLoopBoundary(const OdGePoint3d& worldPt, int loop,
    double tol = OdDbMPolygonCrossingFuzz) const;
  virtual int isPointInsideMPolygon(const OdGePoint3d& worldPt, OdGeIntArray& loopsArray,
    double tol = OdDbMPolygonCrossingFuzz) const;
  /* Not implemented
 
 
  virtual OdResult getMPolygonTree(OdDbMPolygonNode*& loopNode) const;
  virtual void deleteMPolygonTree(OdDbMPolygonNode* loopNode) const;
 
  virtual double getPerimeter() const;
  virtual bool isBalanced() const;
 
  virtual OdResult balanceTree();
  virtual OdResult balanceDisplay();
 
  //virtual OdResult getLoopAtGsMarker(OdGsMarker gsMark, int &loop) const;
  virtual void getChildLoops(int curLoop, OdGeIntArray& selectedLoopIndexes) const;
  virtual int getParentLoop(int curLoop) const;
  virtual int getClosestLoopTo(const OdGePoint3d& worldPt) const;
 
  // Mpolyon loop crossing and inside methods.
  //
 
  virtual OdResult loopCrossesItself(bool& crosses, bool findAll,
    OdDbMPolygonCrossingArray& crossingsArray,
    const OdGePoint2dArray& vertexPts, 
    const OdGeDoubleArray& vertexBulges, 
    double tol = OdDbMPolygonCrossingFuzz) const;
 
  virtual bool loopCrossesItself(const OdGePoint2dArray& vertexPts, 
    const OdGeDoubleArray& vertexBulges, 
    double tol = OdDbMPolygonCrossingFuzz) const;
 
  virtual OdResult loopCrossesMPolygon(bool& crosses, bool findAll,
    OdDbMPolygonCrossingArray& crossingsArray,
    const OdGePoint2dArray& testVertexPts, 
    const OdGeDoubleArray& testVertexBulges, 
    double tol = OdDbMPolygonCrossingFuzz) const;
 
  virtual bool selfCrosses(const OdGePoint2dArray& vertexPts, 
    const OdGeDoubleArray& vertexBulges,
    double tol = OdDbMPolygonCrossingFuzz) const;
 
  virtual bool includesTouchingLoops(double tol = OdDbMPolygonCrossingFuzz) const;
 
  //virtual OdResult subGetClassID(void* pClsid) const;
 
  virtual OdResult   intersectWith(
    const OdDbEntity*   ent,
    OdDb::Intersect     intType,
    OdGePoint3dArray&   points,
    OdGsMarker            thisGsMarker  = 0,
    OdGsMarker            otherGsMarker = 0)
    const;
 
  virtual OdResult   intersectWith(
    const OdDbEntity*   ent,
    OdDb::Intersect     intType,
    const OdGePlane&    projPlane,
    OdGePoint3dArray&   points,
    OdGsMarker            thisGsMarker  = 0,
    OdGsMarker            otherGsMarker = 0)
    const;
 
  virtual OdResult   getOsnapPoints(
    OdDb::OsnapMode       osnapMode,
    OdGsMarker              gsSelectionMark,
    const OdGePoint3d&    pickPoint,
    const OdGePoint3d&    lastPoint,
    const OdGeMatrix3d&   viewXform,
    OdGePoint3dArray&        snapPoints,
    OdDbIntArray&     geomIds) const;
 
  virtual OdResult getGripPoints(OdGePoint3dArray&     gripPoints,
    OdDbIntArray&  osnapModes,
    OdDbIntArray&  geomIds) const;
 
  virtual OdResult moveGripPointsAt(const OdDbIntArray& indices,
    const OdGeVector3d& offset);
 
  virtual OdResult getStretchPoints(OdGePoint3dArray& stretchPoints) const;
 
  virtual OdResult moveStretchPointsAt( const OdDbIntArray& indices,
    const OdGeVector3d& offset);
 
  virtual OdResult createLoopsFromBoundaries (const OdDbObjectIdArray &ids,
    OdIntArray &rejectedObjs,
    bool excludeCrossing = true, double tol = OdDbMPolygonCrossingFuzz);
  
  virtual OdResult createLoops (const OdGePoint2dArrayArray &vertices,
    const OdArray<OdGeDoubleArray> &bulges, OdIntArray &rejectedObjs,
    bool excludeCrossing = true, double tol = OdDbMPolygonCrossingFuzz);
  */
  virtual OdResult subExplode(
    OdRxObjectPtrArray& entitySet) const;
 
  virtual OdResult subTransformBy( 
    const OdGeMatrix3d& xfn );
 
  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 void subSetDatabaseDefaults(
    OdDbDatabase* pDb, 
    bool doSubents);
 
  virtual void saveAs(
    OdGiWorldDraw* pWd,
    OdDb::DwgVersion ver ) const;
};
 
typedef OdSmartPtr<OdDbMPolygon> OdDbMPolygonPtr;
 
#endif // _DBMPOLYGON_H_INCLUDED_