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
/////////////////////////////////////////////////////////////////////////////// 
// 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 OD_GEGBL_H
#define OD_GEGBL_H /*!DOM*/
 
#include "Ge/GeTol.h"
 
#include "Ge/Ge.h"
#include "OdArrayPreDef.h"
#include "Ge/GePoint3dArray.h"
 
class OdGeSurface;
class OdGeVector3d;
class OdGePlane;
class OdGeCurve3d;
class OdGeNurbCurve2d;
class OdGeNurbCurve3d;
class OdGePoint3d;
 
#include "TD_PackPush.h"
 
/** \details
    This structure provides a namespace for tolerance values and functions ubiquitous to the OdGe library.
 
    \sa
    TD_Ge
 
    <group !!RECORDS_TD_APIRef>
*/
struct GE_TOOLKIT_EXPORT OdGeContext
{
  /** \details
    Provides the global default OdGeTol tolerance object.
    \remarks
    gTol.equalPoint == 1e-10  gTolequalVector == 1.e-10.
  */
  GE_STATIC_EXPORT static OdGeTol gTol;
 
  /** \details
    Provides the global 0.0 default OdGeTol tolerance object.
    \remarks
    gZeroTol.equalPoint == 0.0 and gZeroTol.equalVector == 1.e-10.
  */
  GE_STATIC_EXPORT static OdGeTol gZeroTol;
 
  /** \details
    A function pointer to a user-defined error handler.
    \remarks
    By default, points to a function that does nothing but return.
  */
  GE_STATIC_EXPORT static void (*gErrorFunc)(OdResult);
 
  /** \details
    A function pointer to a user-defined function that returns orthoVector orthogonal to vect.
 
    \remarks
    By default, points to a function that computes orthoVector with the arbitrary axis algorithm:
 
                if ( (vect.x < 0.015625) && (vect.x < 0.015625)) {
                  orthoVector.x = vect.z;
                  orthoVector.y = 0.0;
                  orthoVector.z = -vect.x;
                }
                else {
                  orthoVector.x = -vect.y;
                  orthoVector.y = vect.x;
                  orthoVector.z = 0.0;
                }
    \param vect [in]  Vector.
    \param orthoVector [out]  Receives the orthogonal vector.
  */
  GE_STATIC_EXPORT static void (*gOrthoVector) (const OdGeVector3d& vect, OdGeVector3d& orthoVector);
 
  /** \details
    A function pointer to a user-defined memory allocation function
    for all new operations in the OdGe library.
    \remarks
    Allows the OdGe library to use the same memory manager as the user application.
    \param size [in]  Size in bytes to allocate.
  */
  GE_STATIC_EXPORT static void* (*gAllocMem) (unsigned long size);
 
 
  /** A function pointer to a user-defined memory allocation function
    for all delete operations in the OdGe library.
 
    \remarks
    Allows the OdGe library to use the same memory manager as the user application.
 
    \param memBlock [in]  Allocated memory block to be freed.
  */
  GE_STATIC_EXPORT static void (*gFreeMem) (void* memBlock);
};
 
  /** \details
    Checks topology of a triangulated solid.
 
    \param points [in]  Array of 3D points (in order of the triangles they form).
    \param isValid [out]  Receives the validation result.
    \param tol [in]  Geometric tolerance.
 
    \remarks
    Array of points should be divided by 3 without remainder.
 
    Library: TD_Ge
  */
GE_TOOLKIT_EXPORT OdGeError geValidSolid (
    const OdGePoint3dArray &points,
    bool &isValid,
    const OdGeTol &tol = OdGeContext::gTol);
 
  /** \details
    Calculates signed volume of a triangulated solid.
 
    \param points [in]  Array of 3D points (in order of the triangles they form).
    \param volume [out]  Receives the volume value.
    \param basePoint [in]  Point to replace (0,0,0) for calculation purposes.
    
    \remarks
    Array of points should be divided by 3 without remainder.
    Negative sign of volume means that triangles in the solid are ordered clockwise.
 
    Library: TD_Ge
  */
GE_TOOLKIT_EXPORT OdGeError geSolidSignedVolume (
    const OdGePoint3dArray &points,
    double &volume,
    const OdGePoint3d *basePoint);
 
/** \details
    Returns the normal to the plane defined by the specified points.
 
    \param points [in]  Array of 3D points.
    \param numPoints [in]  Number of points.
    \param pNormal [out]  Receives the normal to the calculated plane.
    \param tol [in]  Geometric tolerance.
 
    \remarks
    Possible return values are as follows:
 
    @untitled table
    kOk
    kNonCoplanarGeometry
    kDegenerateGeometry
    kSingularPoint
 
    Library: TD_Ge
*/
GE_TOOLKIT_EXPORT OdGeError geCalculateNormal (
    const OdGePoint3dArray& points,
    OdGeVector3d * pNormal,
    const OdGeTol& tol = OdGeContext::gTol);
 
GE_TOOLKIT_EXPORT OdGeError geCalculateNormal (
    const OdGePoint3d *points,
    OdUInt32 numPoints,
    OdGeVector3d * pNormal,
    const OdGeTol& tol = OdGeContext::gTol);
 
// Same with previous functions, but returns result as plane
 
/** \details
    Returns the plane defined by the specified points.
 
    \param points [in]  Array of 3D points.
    \param curves [in]  Array of 3D curves.
    \param numPoints [in]  Number of points.
    \param numCurves [in]  Number of curves.
    \param plane [out]  Receives the calculated plane.
    \param tol [in]  Geometric tolerance.
 
    \remarks
    Supported curves are OdGeCircArc3d, OdGeEllipArc3d, OdGeNurbCurve3d, and OdGeLineSeg3d.
 
    Possible return values are as follows:
 
    @untitled table
    kOk
    kNonCoplanarGeometry
    kDegenerateGeometry
    kSingularPoint
 
    Library: TD_Ge
*/
GE_TOOLKIT_EXPORT OdGeError geCalculatePlane (
    const OdGePoint3dArray& points,
    OdGePlane& plane,
    const OdGeTol& tol = OdGeContext::gTol);
 
GE_TOOLKIT_EXPORT OdGeError geCalculatePlane (
    const OdGePoint3d *points,
    OdUInt32 numPoints,
    OdGePlane& plane,
    const OdGeTol& tol = OdGeContext::gTol);
 
GE_TOOLKIT_EXPORT OdGeError geCalculatePlane (
    const OdGeCurve3d * const* curves,
    OdUInt32 numCurves,
    OdGePlane& plane,
    const OdGeTol& tol = OdGeContext::gTol);
 
/** \details
    Converts a 3D NURBS curve to a 2D NURBS curve by projecting it onto the specified plane.
 
    \param nurb3d [in]  Any 3D NURBS curve.
    \param plane [in]  Projection plane.
    \param nurb2d [out]  Receives the 2D NURBS curve.
    \param tol [in]  Geometric tolerance.
 
    Library: TD_Ge
*/
GE_TOOLKIT_EXPORT bool geNurb3dTo2d (
    const OdGeNurbCurve3d &nurb3d,
    OdGePlane& plane,
    OdGeNurbCurve2d &nurb2d,
    const OdGeTol& tol = OdGeContext::gTol);
 
/** \details
    Calculates a properties for a specified surface.
 
    \param pS [in]  Any surface.
    \param propU, propV [out] Receives the properties.
    \param tol [in] Geometric tolerance.
 
    Library: TD_Ge
 
    \remarks
      Rational state valid only for NURB surfaces.
*/
GE_TOOLKIT_EXPORT bool geSurfaceProp(
    const OdGeSurface &pS, 
    OdGe::NurbSurfaceProperties &propU,
    OdGe::NurbSurfaceProperties &propV,
    const OdGeTol& tol);
 
// was moved from Examples\Common\toString
/// Convert the specified value to an OdGe::EntityId string
GE_TOOLKIT_EXPORT OdString geToString(const OdGe::EntityId val);
 
#include "TD_PackPop.h"
 
inline void GE_ERROR(OdResult res)
{
  (*OdGeContext::gErrorFunc)(res);
}
 
/** \details
  <group Error_Classes> 
 
  Library: TD_Ge
*/
class GE_TOOLKIT_EXPORT OdError_GeNotImplemted : public OdError
{
public:
  OdError_GeNotImplemted(const OdString& sMessage);
};
 
#define GE_NOT_IMPL(pGeEnt) \
{ \
  try \
  { \
    (*OdGeContext::gErrorFunc)(eNotImplemented); \
  } \
  catch (OdError &err) \
  { \
    if (err.code() == eNotImplemented) \
    { \
      OdString sFunc(TD_FUNC); \
      OdString sMessage; \
      sMessage.format(OD_T("%s method %s for Ge type %s"), \
                      OD_T("%s"), \
                      sFunc.c_str(), \
                      geToString(pGeEnt->type()).c_str()); \
      throw OdError_GeNotImplemted(sMessage); \
    } \
    throw; \
  } \
}
 
#endif // OD_GEGBL_H