OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
SceneNodeCartesianMesh.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;
22
24{
25 bool visible;
26 bool forward;
30 double r;
31 double g;
32 double b;
33};
34
36{
37public:
40
41 void setMeshLines(const std::vector<double> &x, const std::vector<double> &y, const std::vector<double> &z);
42 void setNeedsInitialization(void) { needsInitialization = true;};
43
44 std::string getProjectName(void) { return projectName; };
45
46 void setEdgeColor(double color[3]) { edgeColorRGB[0] = color[0]; edgeColorRGB[1] = color[1]; edgeColorRGB[2] = color[2]; };
47 void setMeshLineColor(double color[3]) { meshLineColorRGB[0] = color[0]; meshLineColorRGB[1] = color[1]; meshLineColorRGB[2] = color[2]; };
48
49 Model *getModel(void) { return model; };
50 void setModel(Model *m) { model = m; };
51
52 void addOwner(SceneNodeCartesianMeshItem *item, int faceID);
53 void removeOwner(SceneNodeCartesianMeshItem *item, const std::vector<int> &faceID);
54 void updateFaceStatus(const std::vector<int> &faceID);
55
56 void ensureDataLoaded(void);
57
58 virtual bool isItem1D(void) { return false; };
59 virtual bool isItem3D(void) { return true; };
60
61 virtual void setTransparent(bool t) override;
62 virtual void setWireframe(bool w) override;
63 virtual void setVisible(bool v) override;
64 virtual void setHighlighted(bool h) override;
65
66 void showMeshLines(bool showMesh);
67
68 void setFaceListStorage(const std::string &proj, unsigned long long id, unsigned long long version) { projectName = proj; faceListEntityID = id, faceListEntityVersion = version; }
69 void setNodeListStorage(unsigned long long id, unsigned long long version) { nodeListEntityID = id, nodeListEntityVersion = version; }
70
71private:
72 osg::Node *createOSGNodeFromCoordinates(const std::vector<double> &x, const std::vector<double> &y, const std::vector<double> &z);
73 void get1DBounds(const std::vector<double> &coords, double &min, double &max);
74 void addQuadsX(const std::vector<double> &x, double ymin, double ymax, double zmin, double zmax, osg::Vec3Array *vertices, size_t &quadIndex);
75 void addQuadsY(const std::vector<double> &y, double xmin, double xmax, double zmin, double zmax, osg::Vec3Array *vertices, size_t &quadIndex);
76 void addQuadsZ(const std::vector<double> &z, double xmin, double xmax, double ymin, double ymax, osg::Vec3Array *vertices, size_t &quadIndex);
77
78 void loadNodes(unsigned long long meshNodesID, unsigned long long meshNodesVersion, size_t &numberPoints, double *&coordX, double *&coordY, double *&coordZ);
79 void loadFaces(unsigned long long meshFacesID, unsigned long long meshFacesVersion, size_t numberPoints, double *coordX, double *coordY, double *coordZ);
80 void loadFace(unsigned long long faceStorageID, unsigned long long faceStorageVersion, osg::Node *&faceNode, osg::Node *&edgeNode, size_t numberPoints, double *coordX, double *coordY, double *coordZ);
81 osg::Node *createFaceNode(osg::ref_ptr<osg::Vec3Array> &vertices, osg::ref_ptr<osg::Vec3Array> &normals);
82 osg::Node *createEdgeNode(osg::ref_ptr<osg::Vec3Array> &vertices, osg::ref_ptr<osg::Vec3Array> &normals);
83 void setFaceStatus(int face, bool visible, bool forward, bool doublesided, bool transparent, bool wireframe, double r, double g, double b, SceneNodeBase *owner);
84 void setTransparent(osg::Geometry *faceGeometry, bool transparent);
85 void createFaceFromIndices(bsoncxx::document::view view, osg::ref_ptr<osg::Vec3Array> &vertices, osg::ref_ptr<osg::Vec3Array> &normals);
86 void createFaceFromPoints(bsoncxx::document::view view, osg::ref_ptr<osg::Vec3Array> &vertices, osg::ref_ptr<osg::Vec3Array> &normals, size_t numberPoints, double *coordX, double *coordY, double *coordZ);
87 void calculateNormal(double normal[3], double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2);
88
89 std::map<int, osg::Node *> faceTriangles;
90 std::map<int, osg::Node *> faceEdges;
91
92 std::string projectName;
93 unsigned long long faceListEntityID;
94 unsigned long long faceListEntityVersion;
95 unsigned long long nodeListEntityID;
96 unsigned long long nodeListEntityVersion;
97 bool needsInitialization;
98 bool showMeshLinesFlag;
99
100 double edgeColorRGB[3];
101 double meshLineColorRGB[3];
102
103 Model *model;
104
105 std::vector<double> meshCoords[3];
106
107 osg::Node *meshLines;
108
109 std::map<int, std::vector < std::pair<bool, SceneNodeCartesianMeshItem*> >> faceOwners;
110
111 std::map<int, CartesianMeshFaceStatus> faceStatusCache;
112};
113
Mesh m
Definition SelfIntersectionCheck.cpp:26
@ h
Definition SourceTarget.h:4
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 SceneNodeCartesianMesh.h:36
void updateFaceStatus(const std::vector< int > &faceID)
Definition SceneNodeCartesianMesh.cpp:889
virtual void setTransparent(bool t) override
Definition SceneNodeCartesianMesh.cpp:103
void setMeshLines(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &z)
Definition SceneNodeCartesianMesh.cpp:86
void setFaceListStorage(const std::string &proj, unsigned long long id, unsigned long long version)
Definition SceneNodeCartesianMesh.h:68
Model * getModel(void)
Definition SceneNodeCartesianMesh.h:49
std::string getProjectName(void)
Definition SceneNodeCartesianMesh.h:44
virtual ~SceneNodeCartesianMesh()
Definition SceneNodeCartesianMesh.cpp:40
void setNeedsInitialization(void)
Definition SceneNodeCartesianMesh.h:42
void removeOwner(SceneNodeCartesianMeshItem *item, const std::vector< int > &faceID)
Definition SceneNodeCartesianMesh.cpp:1146
void addOwner(SceneNodeCartesianMeshItem *item, int faceID)
Definition SceneNodeCartesianMesh.cpp:879
virtual bool isItem1D(void)
Definition SceneNodeCartesianMesh.h:58
virtual void setHighlighted(bool h) override
Definition SceneNodeCartesianMesh.cpp:129
virtual void setVisible(bool v) override
Definition SceneNodeCartesianMesh.cpp:113
void ensureDataLoaded(void)
Definition SceneNodeCartesianMesh.cpp:237
virtual void setWireframe(bool w) override
Definition SceneNodeCartesianMesh.cpp:108
void showMeshLines(bool showMesh)
Definition SceneNodeCartesianMesh.cpp:227
void setModel(Model *m)
Definition SceneNodeCartesianMesh.h:50
void setNodeListStorage(unsigned long long id, unsigned long long version)
Definition SceneNodeCartesianMesh.h:69
void setMeshLineColor(double color[3])
Definition SceneNodeCartesianMesh.h:47
void setEdgeColor(double color[3])
Definition SceneNodeCartesianMesh.h:46
virtual bool isItem3D(void)
Definition SceneNodeCartesianMesh.h:59
SceneNodeCartesianMesh()
Definition SceneNodeCartesianMesh.cpp:26
Definition SceneNodeCartesianMeshItem.h:23
Definition SceneNodeContainer.h:8
Definition SceneNodeMeshItem.h:22
Definition Geometry.h:13
Definition RubberbandOsgWrapper.h:22
Definition SceneNodeCartesianMesh.h:24
bool transparent
Definition SceneNodeCartesianMesh.h:28
bool wireframe
Definition SceneNodeCartesianMesh.h:29
bool forward
Definition SceneNodeCartesianMesh.h:26
bool doublesided
Definition SceneNodeCartesianMesh.h:27
double r
Definition SceneNodeCartesianMesh.h:30
bool visible
Definition SceneNodeCartesianMesh.h:25
double b
Definition SceneNodeCartesianMesh.h:32
double g
Definition SceneNodeCartesianMesh.h:31