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
/////////////////////////////////////////////////////////////////////////////// 
// 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 _ODGESHELL_INCLUDED_
#define _ODGESHELL_INCLUDED_ /*!DOM*/
 
#include "TD_PackPush.h"
 
#include "Ge/GePoint3dArray.h"
#include "Ge/GeVector3dArray.h"
#include "DbStubPtrArray.h"
#include "Int32Array.h"
#include "UInt16Array.h"
#include "UInt8Array.h"
#include "CmEntityColorArray.h"
#include "CmTransparencyArray.h"
#include "GsMarkerArray.h"
#include "Gi/GiGeometry.h"
 
/** \details
    This class represents shell primitives.
    
    \remarks
    A shell is a set of faces, defined by a list of shell vertices. Shells can have regular faces and holes and disjoint regions. 
    Shell objects contain vertex data, edge data and face data. Vertex data is defined by one array that is the list of face vertices. 
    Edge data contains arrays of edge properties such as edge color, linetype, visibility etc. 
    Face data is defined by an array of shell faces and arrays of face properties such as face color, normals, transparency, material etc.
     
    Library: TD_Ge
 
    <group OdGe_Classes>
*/
class OdGeShell
{
  int                   m_nFaceStartIndex;
public:
  OdGeShell() : m_nFaceStartIndex(-1) {}
 
  /** \details
    An array of vertices that are used to construct faces of the shell.
  */
  OdGePoint3dArray      vertices;
 
  /** \details
    An array of integer number that defines a list of shell faces.
    In a face list a particular face is defined be a set of number. The first number contains the number of vertices of the face and its sign indicates if the face is a hole or a regular face: if the face is a hole then its vertices number must be negative.
    A hole face must be coplanar and entirely in another face (not touching edges).
    For example, the face array {3,0,2,4,-3,1,0,5} represents two faces. The first is a regular face that consists of three vertices: vertex 0, vertex 2, and vertex 4. The second is the hole face having three vertices: vertex 1, vertex 0, and vertex 5.
  */
  OdInt32Array          faces;
 
  /** \details
    An array of edges colors.
  */
  OdUInt16Array         edgeColors;
 
  /** \details
    An array of edges true colors.
  */
  OdCmEntityColorArray  edgeTrueColors;
 
  /** \details
    An array of edges layers.
  */
  OdDbStubPtrArray edgeLayers;
 
  /** \details
    An array of edges linetypes.
  */
  OdDbStubPtrArray edgeLinetypes;
 
  /** \details
    An array of edges selection markers.
  */
  OdGsMarkerArray       edgeSelectionMarkers;
 
  /** \details
    An array of edges visibilities.
  */
  OdUInt8Array          edgeVisibilities;
 
  /** \details
    An array of faces colors.
  */
  OdUInt16Array         faceColors;
 
  /** \details
    An array of faces true colors.
  */
  OdCmEntityColorArray  faceTrueColors;
 
  /** \details
    An array of faces layers.
  */
  OdDbStubPtrArray faceLayers;
 
  /** \details
    An array of faces normal vectors.
  */
  OdGeVector3dArray     faceNormals;
 
  /** \details
    An array of faces selection markers.
  */
  OdGsMarkerArray       faceSelectionMarkers;
 
  /** \details
    An array of faces visibilities.
  */
  OdUInt8Array          faceVisibilities;
 
  /** \details
    An array of faces materials.
  */
  OdDbStubPtrArray faceMaterials;
 
  /** \details
    An array of faces mappers.
  */
  OdArray<OdGiMapper>   faceMappers;
 
  /** \details
    An array of faces transparencies.
  */
  OdCmTransparencyArray faceTransparencies;
 
  /** \details
    Adds a vertex to the vertex array of the shell.
 
    \param vertex [in]  The vertex to be inserted.
  */
  void addVertex(const OdGePoint3d& vertex)
  {
    vertices.push_back(vertex);
  }
 
  /** \details
    Ends face assembling. Writes the number of face vertices that have been added by the addFaceVertex() method.
  */
  void endFace()
  {
    if(m_nFaceStartIndex>=0)
    {
      faces[m_nFaceStartIndex] *= (faces.size()-m_nFaceStartIndex-1);
      m_nFaceStartIndex = -1;
    }
  }
 
  /** \details
    Starts face assembling. Sets the face index at the start position of a new face to be added and reserves place for the number of face vertices adding -1 or 1 values: -1 if a hole face is expected and 1 for a regular face.
 
    \param bHole [in]  Indicates if a hole or regular face is expected. It's false by default.
  */
  void startFace(bool bHole = false)
  {
    ODA_ASSERT(m_nFaceStartIndex==-1); // endFace() wasn't called.
    m_nFaceStartIndex = faces.size();
    faces.push_back(bHole ? -1 : 1);
  }
 
  /** \details
    Adds a face vertex with a specified index to the face array. 
 
    \param nVertexIndex [in]  The index from the shell vertices array.
  */
  void addFaceVertex(int nVertexIndex)
  {
    edgeVisibilities.push_back(OdUInt8(nVertexIndex > 0));
    faces.push_back(Od_abs(nVertexIndex)-1);
  }
 
  /** \details
    Draws the shell using the specified vectorization context.
 
    \param geometry [in]  The vectorization context.
  */
  void draw(OdGiGeometry& geometry)
  {
    ODA_ASSERT(m_nFaceStartIndex<0 || faces[m_nFaceStartIndex]>2); // endFace() wasn't called.
 
    OdGiEdgeData edgeData;
    if (!edgeColors.isEmpty()) 
      edgeData.setColors(edgeColors.getPtr());
    if (!edgeTrueColors.isEmpty()) 
      edgeData.setTrueColors(edgeTrueColors.getPtr());
    if (!edgeLayers.isEmpty())
      edgeData.setLayers((OdDbStub**)edgeLayers.getPtr());
    if (!edgeLinetypes.isEmpty()) 
      edgeData.setLinetypes((OdDbStub**)edgeLinetypes.getPtr());
    if (!edgeSelectionMarkers.isEmpty()) 
      edgeData.setSelectionMarkers(edgeSelectionMarkers.getPtr());
    if (!edgeVisibilities.isEmpty()) 
      edgeData.setVisibility(edgeVisibilities.getPtr());
 
    OdGiFaceData faceData;
    if (!faceColors.isEmpty())
      faceData.setColors(faceColors.getPtr());
    if (!faceTrueColors.isEmpty()) 
      faceData.setTrueColors(faceTrueColors.getPtr());
    if (!faceLayers.isEmpty()) 
      faceData.setLayers((OdDbStub**)faceLayers.getPtr());
    if (!faceNormals.isEmpty()) 
      faceData.setNormals(faceNormals.getPtr());
    if (!faceSelectionMarkers.isEmpty()) 
      faceData.setSelectionMarkers(faceSelectionMarkers.getPtr());
    if (!faceVisibilities.isEmpty()) 
      faceData.setVisibility(faceVisibilities.getPtr());
    if (!faceMaterials.isEmpty()) 
      faceData.setMaterials((OdDbStub**)faceMaterials.getPtr());
    if (!faceMappers.isEmpty()) 
      faceData.setMappers(faceMappers.getPtr());
    if (!faceTransparencies.isEmpty()) 
      faceData.setTransparency(faceTransparencies.getPtr());
 
    geometry.shell(vertices.size(), vertices.getPtr(), faces.size(), faces.getPtr(), &edgeData, &faceData);
  }
};
 
#include "TD_PackPop.h"
 
 
#endif // _ODGESHELL_INCLUDED_