OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
SceneNodeGeometry.h
Go to the documentation of this file.
1#pragma once
2
3namespace osg
4{
5 class Node;
6 class Switch;
7}
8
9#include "Geometry.h"
10#include "Viewer.h"
11#include "SceneNodeBase.h"
12#include <osg/Material>
13#include <osg/TexGen>
14#include <osg/TexEnv>
15#include <osg/Matrix>
16#include <osgText/Text>
17
18#include <string>
19#include <osg/Array>
20
21//#include "SceneNodeMaterial.h"
22
23class Model;
24class Viewer;
25//class SceneNodeMaterial;
26//class SceneNodeMaterialConcrete;
27
29{
30public:
32 virtual ~SceneNodeGeometry();
33
34 void setTriangles(osg::Node *t) { triangles = t; };
35 void setEdges(osg::Node* e) { edges = e; };
36 void setEdgesHighlighted(osg::Node *e) { edgesHighlighted = e; };
37 void setFaceEdgesHighlighted(osg::Switch *e) { faceEdgesHighlightNode = e; };
38 void setMaterialType(const std::string &material) { materialType = material; }
39 void setTextureType(const std::string &texture, bool reflect) { textureType = texture; reflective = reflect; }
40 void setMaterialProperties(osg::ref_ptr<osg::Material>& mat,double r , double g, double b);
41 void setTransformation(std::vector<double> &transformation);
42 void setHighlightNode(osg::Node* highlight);
43
44 osg::Matrix getTransformation(void);
45 osg::Matrix getParentTransformation(void);
46 osg::Matrix getOwnTransformation(void) { return transformationMatrix; }
47 void setOwnTransformation(const osg::Matrix &matrix) { transformationMatrix = matrix; }
48
49 void applyTransform(osg::Matrix matrix);
50
51 osg::Node *getTriangles(void) { return triangles; };
52 osg::Node* getEdges(void) { return edges; };
53 osg::Node *getEdgesHighlighted(void) { return edgesHighlighted; };
54 osg::Switch *getFaceEdgesHighlight(void) { return faceEdgesHighlightNode; };
55
56 void setEdgeHighlightNode(unsigned long long faceId1, unsigned long long faceId2);
57
58 virtual void setTransparent(bool t) override;
59 virtual void setWireframe(bool w) override;
60 virtual void setVisible(bool v) override;
61 virtual void setHighlighted(bool h) override;
62 virtual void setSelected(bool selected, bool _selectionFromNavigationTree) override;
63
64 void setShowWhenSelected(bool flag) { showWhenSelected = flag; };
65
66 void initializeFromFacetData(std::vector<Geometry::Node> &nodes, std::list<Geometry::Triangle> &triangles, std::list<Geometry::Edge> &edges, std::map<ot::UID, std::string> &faceNameMap);
67 //void assignMaterial(const std::string & materialType);
68 void updateObjectColor(double surfaceColorRGB[3], double edgeColorRGB[3], const std::string &materialType, const std::string &textureType, bool reflective);
69 void updateObjectFacetsFromDataBase(unsigned long long entityID, unsigned long long entityVersion);
70
71 void setEdgeHighlight(unsigned long long faceId, bool h, double thickness);
72 unsigned long long getFaceIdFromTriangleIndex(unsigned long long index) { return triangleToFaceId[index]; };
73 ot::UID getFaceIdFromEdgePrimitiveIndex(unsigned long long hitIndex);
74
75 std::string getFaceNameFromId(unsigned long long faceId);
76
77 std::string getEdgeNameFromFaceIds(unsigned long long faceId1, unsigned long long faceId2);
78
79 void setSurfaceColorRGB(double color[3]) { surfaceColorRGB[0] = color[0]; surfaceColorRGB[1] = color[1]; surfaceColorRGB[2] = color[2]; };
80 void setEdgeColorRGB(double color[3]) { edgeColorRGB[0] = color[0]; edgeColorRGB[1] = color[1]; edgeColorRGB[2] = color[2]; };
81 void setBackFaceCulling(bool b) { backFaceCulling = b; };
82 void setOffsetFactor(double o) { offsetFactor = o; };
83 void setStorage(const std::string &proj, unsigned long long id, unsigned long long version) { projectName = proj; entityID = id, entityVersion = version; };
84 void setNeedsInitialization(void) { needsInitialization = true; };
85
86 std::string getProjectName(void) { return projectName; };
87
89
90 Model *getModel(void) { return model; };
91 void setModel(Model *m) { model = m; };
92
93 virtual bool isItem1D(void) { return false; };
94 virtual bool isItem3D(void) { return true; };
95
96 osg::Node* addSelectedEdge(unsigned long long faceId1, unsigned long long faceId2);
97 void removeSelectedEdge(osg::Node* selected);
98
99private:
100 void deleteShapeNode(void);
101 osg::Node *createOSGNodeFromTriangles(double colorRGB[3], const std::string &materialType, const std::string &textureType, bool reflective, bool backFaceCulling, double offsetFactor, std::vector<Geometry::Node> &nodes, std::list<Geometry::Triangle> &triangles);
102 void createOSGNodeFromEdges(double colorRGB[3], std::list<Geometry::Edge> &edges, osg::Node *&edgesNode, osg::Node *&edgesHighlightedNode, osg::Switch *&faceEdgesHighlightNode);
103 osg::Node *buildEdgesOSGNode(unsigned long long nEdges, osg::Vec3Array *vertices, double r, double g, double b, double transp, bool depthTest, double width);
104 void assignTexture(osg::Geometry *geometry, const std::string &textureType, bool reflective, double r, double g, double b);
105 void updateWireframeState(bool visible, bool wireframe, bool transparent);
106 void setVisibleState(bool visible, bool transparent, bool wireframe);
107 void updateTransparentState(bool visible, bool transparent, bool wireframe);
108 void applyParentTransform(void);
109 osg::Node* getEdgeHighlightNode(unsigned long long faceId1, unsigned long long faceId2, double lineWidth);
110
111 osg::Node * triangles;
112 osg::Node * edges;
113 osg::Node * edgesHighlighted;
114 osg::Switch * faceEdgesHighlightNode;
115 osg::Node * highlightNode;
116
117 std::map<unsigned long long, osg::Node *> faceEdgesHighlight;
118 std::vector<unsigned long long> triangleToFaceId;
119 std::map<ot::UID, std::string> faceIdToNameMap;
120 std::vector<unsigned long long> edgeStartIndex;
121 std::vector<ot::UID> edgeFaceId;
122
123 double surfaceColorRGB[3];
124 double edgeColorRGB[3];
125 bool backFaceCulling;
126 double offsetFactor;
127 std::string materialType;
128 std::string textureType;
129 bool reflective;
130 bool showWhenSelected;
131 std::string projectName;
132 unsigned long long entityID;
133 unsigned long long entityVersion;
134 bool needsInitialization;
135 Model *model;
136 osg::StateAttribute *textureAttribute;
137 osg::TexGen *textureAttributeGen;
138 osg::TexEnv *textureAttributeEnv;
139 double edgeTranspacency;
140 osg::Matrix transformationMatrix;
141};
142
@ nodes
Definition MonitorSettings.h:17
Mesh m
Definition SelfIntersectionCheck.cpp:26
@ e
Definition SourceTarget.h:4
@ 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 SceneNodeGeometry.h:29
osg::Node * addSelectedEdge(unsigned long long faceId1, unsigned long long faceId2)
Definition SceneNodeGeometry.cpp:1250
void setNeedsInitialization(void)
Definition SceneNodeGeometry.h:84
std::string getEdgeNameFromFaceIds(unsigned long long faceId1, unsigned long long faceId2)
Definition SceneNodeGeometry.cpp:728
void updateObjectFacetsFromDataBase(unsigned long long entityID, unsigned long long entityVersion)
Definition SceneNodeGeometry.cpp:1078
virtual void setHighlighted(bool h) override
Definition SceneNodeGeometry.cpp:368
virtual void setSelected(bool selected, bool _selectionFromNavigationTree) override
Definition SceneNodeGeometry.cpp:402
void setEdgeColorRGB(double color[3])
Definition SceneNodeGeometry.h:80
SceneNodeGeometry()
Definition SceneNodeGeometry.cpp:37
void setStorage(const std::string &proj, unsigned long long id, unsigned long long version)
Definition SceneNodeGeometry.h:83
void setBackFaceCulling(bool b)
Definition SceneNodeGeometry.h:81
virtual bool isItem3D(void)
Definition SceneNodeGeometry.h:94
std::string getProjectName(void)
Definition SceneNodeGeometry.h:86
void setSurfaceColorRGB(double color[3])
Definition SceneNodeGeometry.h:79
void setEdgeHighlightNode(unsigned long long faceId1, unsigned long long faceId2)
Definition SceneNodeGeometry.cpp:883
void setOffsetFactor(double o)
Definition SceneNodeGeometry.h:82
void applyTransform(osg::Matrix matrix)
Definition SceneNodeGeometry.cpp:435
osg::Node * getEdgesHighlighted(void)
Definition SceneNodeGeometry.h:53
virtual void setWireframe(bool w) override
Definition SceneNodeGeometry.cpp:252
void setTriangles(osg::Node *t)
Definition SceneNodeGeometry.h:34
osg::Node * getTriangles(void)
Definition SceneNodeGeometry.h:51
void setEdgeHighlight(unsigned long long faceId, bool h, double thickness)
Definition SceneNodeGeometry.cpp:385
void setTransformation(std::vector< double > &transformation)
Definition SceneNodeGeometry.cpp:97
void setHighlightNode(osg::Node *highlight)
Definition SceneNodeGeometry.cpp:1226
virtual bool isItem1D(void)
Definition SceneNodeGeometry.h:93
void setOwnTransformation(const osg::Matrix &matrix)
Definition SceneNodeGeometry.h:47
std::string getFaceNameFromId(unsigned long long faceId)
Definition SceneNodeGeometry.cpp:1214
osg::Matrix getTransformation(void)
Definition SceneNodeGeometry.cpp:121
osg::Matrix getOwnTransformation(void)
Definition SceneNodeGeometry.h:46
void setMaterialProperties(osg::ref_ptr< osg::Material > &mat, double r, double g, double b)
Definition SceneNodeGeometry.cpp:1153
virtual ~SceneNodeGeometry()
Definition SceneNodeGeometry.cpp:62
void removeSelectedEdge(osg::Node *selected)
Definition SceneNodeGeometry.cpp:1243
void initializeFromFacetData(std::vector< Geometry::Node > &nodes, std::list< Geometry::Triangle > &triangles, std::list< Geometry::Edge > &edges, std::map< ot::UID, std::string > &faceNameMap)
Definition SceneNodeGeometry.cpp:448
void setModel(Model *m)
Definition SceneNodeGeometry.h:91
Model * getModel(void)
Definition SceneNodeGeometry.h:90
void setEdges(osg::Node *e)
Definition SceneNodeGeometry.h:35
osg::Matrix getParentTransformation(void)
Definition SceneNodeGeometry.cpp:106
unsigned long long getFaceIdFromTriangleIndex(unsigned long long index)
Definition SceneNodeGeometry.h:72
osg::Node * getEdges(void)
Definition SceneNodeGeometry.h:52
virtual void setTransparent(bool t) override
Definition SceneNodeGeometry.cpp:136
void setEdgesHighlighted(osg::Node *e)
Definition SceneNodeGeometry.h:36
void setFaceEdgesHighlighted(osg::Switch *e)
Definition SceneNodeGeometry.h:37
void initializeFromDataStorage(void)
Definition SceneNodeGeometry.cpp:1094
ot::UID getFaceIdFromEdgePrimitiveIndex(unsigned long long hitIndex)
Definition SceneNodeGeometry.cpp:747
void updateObjectColor(double surfaceColorRGB[3], double edgeColorRGB[3], const std::string &materialType, const std::string &textureType, bool reflective)
Definition SceneNodeGeometry.cpp:1005
virtual void setVisible(bool v) override
Definition SceneNodeGeometry.cpp:325
void setShowWhenSelected(bool flag)
Definition SceneNodeGeometry.h:64
void setTextureType(const std::string &texture, bool reflect)
Definition SceneNodeGeometry.h:39
osg::Switch * getFaceEdgesHighlight(void)
Definition SceneNodeGeometry.h:54
void setMaterialType(const std::string &material)
Definition SceneNodeGeometry.h:38
Simple 3D viewer.
Definition Viewer.h:41
Definition RubberbandOsgWrapper.h:22
unsigned long UID
Unique identifier (32 bit unsigned integer)
Definition CoreTypes.h:27
Definition PHREECMeshExport.h:35