ArcGIS Procedural Runtime  3.2.10650
Mesh.h
1 /*
2  COPYRIGHT (c) 2012-2024 Esri R&D Center Zurich
3  TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
4  Unpublished material - all rights reserved under the
5  Copyright Laws of the United States and applicable international
6  laws, treaties, and conventions.
7 
8  For additional information, contact:
9  Environmental Systems Research Institute, Inc.
10  Attn: Contracts and Legal Services Department
11  380 New York Street
12  Redlands, California, 92373
13  USA
14 
15  email: contracts@esri.com
16 */
17 
18 #ifndef PRTX_MESH_H_
19 #define PRTX_MESH_H_
20 
21 #include "prtx/prtx.h"
22 #include "prtx/Types.h"
23 #include "prtx/Material.h"
24 #include "prtx/OpaquePtr.h"
25 
26 #include <vector>
27 #include <memory>
28 
29 #ifdef _MSC_VER
30 # pragma warning(push)
31 # pragma warning (disable : 4231 4251 4275 4660)
32 #endif
33 
34 
35 namespace prtx {
36 
37 
38 typedef std::vector<uint32_t> IndexVector;
39 
40 class BoundingBox;
41 
42 class Mesh;
43 typedef std::shared_ptr<Mesh> MeshPtr;
44 typedef std::vector<MeshPtr> MeshPtrVector;
45 
46 
73 class PRTX_EXPORTS_API Mesh : public Content {
74 public:
75  // @cond
76  friend class MeshBuilder;
77  struct Payload;
78  // @endcond
79 
80 public:
81  virtual ~Mesh();
82 
86  const std::wstring& getName() const;
90  const BoundingBox& getBoundingBox() const;
91 
96  const DoubleVector& getVertexCoords() const;
101  const DoubleVector& getVertexNormalsCoords() const;
109  const DoubleVector& getUVCoords(uint32_t uvSet) const;
118  const DoubleVector& getTextureRegions(uint32_t uvSet) const;
122  uint32_t getUVSetsCount() const;
126  const MaterialPtrVector& getMaterials() const;
127 
131  uint32_t getFaceCount() const;
136  const IndexVector& getFaceVertexCounts() const;
142  uint32_t getFaceVertexCount(uint32_t faceId) const;
149  const uint32_t* getFaceVertexIndices(uint32_t faceId) const;
150 
154  uint32_t getHolesCount() const;
158  const IndexVector& getFaceHolesCounts() const;
163  uint32_t getFaceHolesCount(uint32_t faceId) const;
168  const uint32_t* getFaceHolesIndices(uint32_t faceId) const;
169 
174  const IndexVector& getFaceMaterialIndices() const;
179  uint32_t getFaceMaterialIndex(uint32_t faceId) const;
180 
187  const IndexVector& getFaceVertexNormalCounts() const;
194  uint32_t getFaceVertexNormalCount(uint32_t faceId) const;
201  const uint32_t* getFaceVertexNormalIndices(uint32_t faceId) const;
202 
210  const IndexVector& getFaceUVCounts(uint32_t uvSet) const;
219  uint32_t getFaceUVCount(uint32_t faceId, uint32_t uvSet) const;
228  const uint32_t* getFaceUVIndices(uint32_t faceId, uint32_t uvSet) const;
237  const IndexVector& getFaceTextureRegionIndices(uint32_t uvSet) const;
247  uint32_t getFaceTextureRegionIndex(uint32_t faceId, uint32_t uvSet) const;
248 
254  int32_t getFaceEncirclingFace(uint32_t faceId) const;
255 
259  size_t getUsedMem() const;
260 
261 protected:
262  // @cond
263  Mesh(Payload const* p);
264  const Payload* mPayload;
265  // @endcond
266 };
267 
268 
277 class PRTX_EXPORTS_API MeshBuilder : public SharedPtrBuilder<Mesh> {
278 public:
282  MeshBuilder();
283  MeshBuilder(const MeshBuilder& mb);
289  MeshBuilder(const MeshBuilder& mb, const DoubleVector& trafoMatrix);
294  MeshBuilder(const Mesh& mesh);
300  MeshBuilder(const Mesh& mesh, const DoubleVector& trafoMatrix);
301  virtual ~MeshBuilder();
302 
303  MeshBuilder& operator=(const MeshBuilder& right);
304 
305 
306  // SharedPtrBuilder interface implementation
307  virtual MeshPtr createShared(std::wstring* warnings = 0) const;
308  virtual MeshPtr createSharedAndReset(std::wstring* warnings = 0);
309 
310 
314  void reset();
318  void resetMaterials();
319 
324  void setName(const std::wstring& name);
325 
331  uint32_t addMaterial(const MaterialPtr& material);
336  void addMaterials(const MaterialPtrVector& materials);
337 
343  uint32_t addVertexCoords(const double coords[3]);
349  void addVertexCoords(const double* coords, size_t count);
354  void addVertexCoords(const DoubleVector& coords);
355 
361  uint32_t addNormalCoords(const double coords[3]);
367  void addNormalCoords(const double* coords, size_t count);
372  void addNormalCoords(const DoubleVector& coords);
373 
380  uint32_t addUVCoords(uint32_t uvSet, const double coords[2]);
387  void addUVCoords(uint32_t uvSet, const double* coords, size_t count);
393  void addUVCoords(uint32_t uvSet, const DoubleVector& coords);
394 
403  uint32_t addTextureRegionCoords(uint32_t uvSet, const double coords[4]);
412  void addTextureRegionCoords(uint32_t uvSet, const double* coords, size_t count);
420  void addTextureRegionCoords(uint32_t uvSet, const DoubleVector& coords);
421 
431  uint32_t addFace(const IndexVector& vertexIndices, const IndexVector& holeFacesIndices,
432  uint32_t materialIndex, const IndexVector& normalIndices, const std::vector<IndexVector>& uvIndices);
433 
434 
448  uint32_t addFace(
449  const uint32_t* vertexIndices, size_t vertexIndicesCount,
450  const uint32_t* holeFaceIndices, size_t holeFacesIndicesCount,
451  uint32_t materialIndex,
452  const uint32_t* normalIndices, size_t normalIndicesCount,
453  const std::vector<const uint32_t*>& uvIndices, const std::vector<size_t>& uvIndicesCounts);
454 
459  uint32_t addFace();
465  void addFaceVertexIndex(uint32_t faceId, uint32_t index);
471  void addFaceHoleIndex(uint32_t faceId, uint32_t index);
477  void addFaceNormalIndex(uint32_t faceId, uint32_t index);
484  void addFaceUVIndex(uint32_t faceId, uint32_t uvSet, uint32_t i);
485 
491  void setFaceVertexIndices(uint32_t faceId, const IndexVector& indices);
497  void setFaceNormalIndices(uint32_t faceId, const IndexVector& indices);
504  void setFaceUVIndices(uint32_t faceId, uint32_t uvSet, const IndexVector& indices);
505 
511  void setFaceMaterialIndex(uint32_t faceId, uint32_t index);
518  void setFaceTextureRegionIndex(uint32_t faceId, uint32_t uvSet, uint32_t index);
519 
523  bool isEmpty() const;
524 
525  struct MBImpl;
526 
527 private:
528  void checkAndClean(std::wstring* warnings) const;
529 
530  Mesh::Payload *mPayload;
531  OpaquePtr<MBImpl> mImpl;
532 };
533 
534 } // namespace prtx
535 
536 #ifdef _MSC_VER
537 #pragma warning(pop)
538 #endif
539 
540 #endif /* PRTX_MESH_H_ */
std::vector< uint32_t > IndexVector
vector of indices
Definition: Mesh.h:38
Definition: Builder.h:65
Definition: BoundingBox.h:38
std::vector< double > DoubleVector
vector of double
Definition: Types.h:32
Definition: Content.h:40
std::shared_ptr< Material > MaterialPtr
shared Material pointer
Definition: DataBackend.h:45
The Procedural Runtime eXtension namespace. The prtx namespace contains the tools to extend the Proce...
Definition: AnnotationBuilder.h:35
std::vector< MeshPtr > MeshPtrVector
vector of shared Mesh pointers
Definition: DataBackend.h:42
std::vector< MaterialPtr > MaterialPtrVector
vector of shared Material pointers
Definition: DataBackend.h:46
std::shared_ptr< Mesh > MeshPtr
shared Mesh pointer
Definition: DataBackend.h:41
Definition: Mesh.h:73
Definition: Mesh.h:277