OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
SceneNodeMesh.h
Go to the documentation of this file.
1#pragma once
2
3namespace osg
4{
5 class Node;
6 class Switch;
7 class Geometry;
8}
9
10#include "Geometry.h"
11#include "SceneNodeContainer.h"
12#include "DataBase.h"
13
14#include <string>
15#include <map>
16
17#include <osg/Array>
18
19class Model;
21
23{
24 bool visible;
25 bool forward;
29 double r;
30 double g;
31 double b;
32};
33
35{
36public:
38 virtual ~SceneNodeMesh();
39
40 void setStorage(const std::string &proj, unsigned long long id, unsigned long long version) { projectName = proj; entityID = id, entityVersion = version; };
41 void setNeedsInitialization(void) { needsInitialization = true;};
42
43 std::string getProjectName(void) { return projectName; };
44
45 void setEdgeColor(double color[3]) { edgeColorRGB[0] = color[0]; edgeColorRGB[1] = color[1]; edgeColorRGB[2] = color[2]; };
46
47 Model *getModel(void) { return model; };
48 void setModel(Model *m) { model = m; };
49
50 void addOwner(SceneNodeMeshItem *item, int faceID);
51 void removeOwner(SceneNodeMeshItem *item, const std::vector<int> &faceID);
52 void updateFaceStatus(const std::vector<int> &faceID);
53
54 void ensureDataLoaded(void);
55
56 virtual bool isItem1D(void) { return false; };
57 virtual bool isItem3D(void) { return true; };
58
59 double getNodeX(size_t index) { return coordX[index]; }
60 double getNodeY(size_t index) { return coordY[index]; }
61 double getNodeZ(size_t index) { return coordZ[index]; }
62
63 bool getDisplayTetEdges(void) { return displayTetEdges; }
64 void setDisplayTetEdges(bool displayEdges);
65
66private:
67 void loadMeshData(bsoncxx::builder::basic::document &doc);
68 void loadCoordinates(unsigned long long meshNodesID, unsigned long long meshNodesVersion, double *&coordX, double *&coordY, double *&coordZ);
69 void loadFaces(unsigned long long meshFacesID, unsigned long long meshFacesVersion, double *coordX, double *coordY, double *coordZ);
70 void loadFace(unsigned long long faceStorageID, unsigned long long faceStorageVersion, double *coordX, double *coordY, double *coordZ, osg::Node *&faceNode, osg::Node *&edgeNode);
71 osg::Node *createFaceNode(bsoncxx::document::view view, double *coordX, double *coordY, double *coordZ);
72 osg::Node *createFaceNodeBackwardCompatible(bsoncxx::document::view view, double *coordX, double *coordY, double *coordZ);
73 osg::Node *createEdgeNode(bsoncxx::document::view view, double *coordX, double *coordY, double *coordZ);
74 osg::Node *createEdgeNodeBackwardCompatible(bsoncxx::document::view view, double *coordX, double *coordY, double *coordZ);
75 void addEdge(size_t p1, size_t p2, std::map<std::pair<size_t, size_t>, bool> &edgeMap);
76 void setFaceStatus(int face, bool visible, bool forward, bool doublesided, bool transparent, bool wireframe, double r, double g, double b, SceneNodeBase *owner);
77 void setTransparent(osg::Geometry *faceGeometry, bool transparent);
78 void recursivelySetDisplayEdges(bool displayEdges, SceneNodeBase *root);
79 void getPrefetchForAllChildNodes(SceneNodeBase *root, std::string &projectName, std::list<std::pair<unsigned long long, unsigned long long>> &prefetchIDs);
80 void addTriangleVerticesAndNormals(bsoncxx::array::view::const_iterator &item, osg::ref_ptr<osg::Vec3Array> &vertices, osg::ref_ptr<osg::Vec3Array> &normals, size_t &nVertex, size_t &nNormal);
81 void addTriangleVerticesAndNormalsOrder1(bsoncxx::array::view::const_iterator &item, osg::ref_ptr<osg::Vec3Array> &vertices, osg::ref_ptr<osg::Vec3Array> &normals, size_t &nVertex, size_t &nNormal);
82 void addTriangleVerticesAndNormalsOrder2(bsoncxx::array::view::const_iterator &item, osg::ref_ptr<osg::Vec3Array> &vertices, osg::ref_ptr<osg::Vec3Array> &normals, size_t &nVertex, size_t &nNormal);
83 void addTriangleVerticesAndNormalsOrder3(bsoncxx::array::view::const_iterator &item, osg::ref_ptr<osg::Vec3Array> &vertices, osg::ref_ptr<osg::Vec3Array> &normals, size_t &nVertex, size_t &nNormal);
84 void addTriangleEdges(bsoncxx::array::view::const_iterator &item, std::map<std::pair<size_t, size_t>, bool> &edgeMap);
85 void addTriangleEdgesOrder1(bsoncxx::array::view::const_iterator &item, std::map<std::pair<size_t, size_t>, bool> &edgeMap);
86 void addTriangleEdgesOrder2(bsoncxx::array::view::const_iterator &item, std::map<std::pair<size_t, size_t>, bool> &edgeMap);
87 void addTriangleEdgesOrder3(bsoncxx::array::view::const_iterator &item, std::map<std::pair<size_t, size_t>, bool> &edgeMap);
88 void addTriangle(size_t n1Index, size_t n2Index, size_t n3Index, osg::ref_ptr<osg::Vec3Array> &vertices, osg::ref_ptr<osg::Vec3Array> &normals, size_t &nVertex, size_t &nNormal);
89 void averageNormals(size_t n1Index, size_t n2Index, size_t n3Index, osg::ref_ptr<osg::Vec3Array> &normals, size_t &nNormalBase);
90 void averageNormals(size_t n1Index, size_t n2Index, size_t n3Index, size_t n4Index, size_t n5Index, size_t n6Index, osg::ref_ptr<osg::Vec3Array> &normals, size_t &nNormalBase);
91
92 std::map<int, osg::Node *> faceTriangles;
93 std::map<int, osg::Node *> faceEdges;
94
95 std::string projectName;
96 unsigned long long entityID;
97 unsigned long long entityVersion;
98 bool needsInitialization;
99
100 bool displayTetEdges;
101
102 double edgeColorRGB[3];
103 double *coordX, *coordY, *coordZ;
104
105 Model *model;
106
107 std::map<int, std::vector < std::pair<bool, SceneNodeMeshItem*> >> faceOwners;
108
109 std::map<int, FaceStatus> faceStatusCache;
110};
111
Mesh m
Definition SelfIntersectionCheck.cpp:26
The Model class is the main interface to the model. There may be multiple instances of this class....
Definition Model.h:94
Definition SceneNodeBase.h:14
Definition SceneNodeContainer.h:8
Definition SceneNodeMesh.h:35
virtual bool isItem1D(void)
Definition SceneNodeMesh.h:56
bool getDisplayTetEdges(void)
Definition SceneNodeMesh.h:63
void ensureDataLoaded(void)
Definition SceneNodeMesh.cpp:142
void setDisplayTetEdges(bool displayEdges)
Definition SceneNodeMesh.cpp:94
Model * getModel(void)
Definition SceneNodeMesh.h:47
void setModel(Model *m)
Definition SceneNodeMesh.h:48
void setNeedsInitialization(void)
Definition SceneNodeMesh.h:41
void setStorage(const std::string &proj, unsigned long long id, unsigned long long version)
Definition SceneNodeMesh.h:40
void updateFaceStatus(const std::vector< int > &faceID)
Definition SceneNodeMesh.cpp:1014
void addOwner(SceneNodeMeshItem *item, int faceID)
Definition SceneNodeMesh.cpp:1004
virtual ~SceneNodeMesh()
Definition SceneNodeMesh.cpp:41
virtual bool isItem3D(void)
Definition SceneNodeMesh.h:57
double getNodeX(size_t index)
Definition SceneNodeMesh.h:59
void setEdgeColor(double color[3])
Definition SceneNodeMesh.h:45
void removeOwner(SceneNodeMeshItem *item, const std::vector< int > &faceID)
Definition SceneNodeMesh.cpp:1281
double getNodeZ(size_t index)
Definition SceneNodeMesh.h:61
std::string getProjectName(void)
Definition SceneNodeMesh.h:43
double getNodeY(size_t index)
Definition SceneNodeMesh.h:60
SceneNodeMesh()
Definition SceneNodeMesh.cpp:26
Definition SceneNodeMeshItem.h:22
Definition Geometry.h:13
Definition RubberbandOsgWrapper.h:22
Definition SceneNodeMesh.h:23
bool wireframe
Definition SceneNodeMesh.h:28
bool forward
Definition SceneNodeMesh.h:25
double r
Definition SceneNodeMesh.h:29
double b
Definition SceneNodeMesh.h:31
double g
Definition SceneNodeMesh.h:30
bool doublesided
Definition SceneNodeMesh.h:26
bool visible
Definition SceneNodeMesh.h:24
bool transparent
Definition SceneNodeMesh.h:27