30 #include <qvector3d.h>
60 childs.push_back(pTYElementGraphic);
63 pTYElementGraphic->
getChilds(childs, recursif);
76 TYTabPoint tabpoints = getElement()->getListPoints();
79 for (
unsigned int i = 0; i < tabpoints.size(); i++)
81 tabpoints[i]._z += 0.5;
96 glColor4fv(getElement()->getColor());
98 _pPolygon->getGraphicObject()->display(renderContext);
132 TYTabPoint polygonVertices = getElement()->getListPoints();
133 polygonVertices.push_back(polygonVertices[0]);
136 for (
unsigned int i = 0; i < polygonVertices.size(); i++)
138 polygonVertices[i]._z += 0.5;
145 std::vector<TesselatorVertexData*>()};
146 GLUtesselator* tesselator = gluNewTess();
157 unsigned int lastVertexIndex = primitive.
vertices.size() - 1;
159 if (primitive.
type == GL_TRIANGLES)
161 primitive.
indices.push_back(lastVertexIndex);
163 else if (primitive.
type == GL_TRIANGLE_STRIP)
165 if (lastVertexIndex >= 2)
167 primitive.
indices.push_back(lastVertexIndex - 2);
168 primitive.
indices.push_back(lastVertexIndex - 1);
169 primitive.
indices.push_back(lastVertexIndex);
172 else if (primitive.
type == GL_TRIANGLE_FAN)
174 if (lastVertexIndex >= 2)
176 primitive.
indices.push_back(0);
177 primitive.
indices.push_back(lastVertexIndex - 1);
178 primitive.
indices.push_back(lastVertexIndex);
184 auto combineCallback = +[](GLdouble coords[3],
TesselatorVertexData* vertexData[4], GLfloat weight[4],
189 outVertexData->
position = QVector3D(0, 0, 0);
190 for (
int i = 0; i < 4; i++)
192 if (vertexData[i] !=
nullptr)
197 *outData = outVertexData;
198 polygonData->generatedVerticesData.push_back(outVertexData);
201 gluTessCallback(tesselator, GLU_TESS_BEGIN_DATA, (
void (*)())
beginCallback);
202 gluTessCallback(tesselator, GLU_TESS_VERTEX_DATA, (
void (*)())vertexDataCallback);
203 gluTessCallback(tesselator, GLU_TESS_COMBINE_DATA, (
void (*)())combineCallback);
205 gluTessBeginPolygon(tesselator, &polygonData);
206 gluTessBeginContour(tesselator);
207 std::vector<TesselatorVertexData> verticesData;
208 for (
const auto& point : polygonVertices)
216 for (
auto& vertexData : verticesData)
219 gluTessVertex(tesselator, position, &vertexData);
221 gluTessEndContour(tesselator);
222 gluTessEndPolygon(tesselator);
224 gluDeleteTess(tesselator);
227 delete generatedVertexData;
230 std::vector<QVector3D> vertices;
231 std::vector<unsigned int> indices;
232 unsigned int indicesOffset = 0;
235 for (
auto& primitive : polygonData.primitives)
237 vertices.insert(vertices.end(), primitive.vertices.begin(), primitive.vertices.end());
238 for (
auto index : primitive.indices)
240 indices.push_back(indicesOffset + index);
242 indicesOffset += primitive.vertices.size();
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
list< TYElementGraphic * > TYListPtrTYElementGraphic
List de pointeur de TYElement.
Gestion de la table de correspondance indice/element pour le picking (fichier header)
Representation graphique d'un plan d'eau (fichier header)
void STDCALL beginCallback(GLenum which)
Contexte de rendu utilisé par les fonctions d'affichage.
@ Picking
The current render is only done for picking purpose.
@ Overlay
The current render pass is for overlay elements.
Bridges TY* types with CGAL functionalities exposed by.
classe graphique pour un element de base
void drawName(TYRenderContext &renderContext)
bool _visible
Inique si l'element est visible.
bool _highlight
Indique si le highlight est active pour cet element.
virtual void update(bool force=false)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
virtual void display(TYRenderContext &renderContext)
QMatrix4x4 globalMatrix() const
static void addElement(TYElement *pElt)
virtual void display(TYRenderContext &renderContext)
std::shared_ptr< OGLPolygonMesh > _pPolygonMesh
void collectMeshInstances(std::vector< OGLMeshInstance > &meshInstances, TYRenderContext *renderContext) const
virtual void update(bool force=false)
TYPlanEauGraphic(TYPlanEau *pElement)
virtual void getChilds(TYListPtrTYElementGraphic &childs, bool recursif=true)
void setPoints(const TYTabPoint &pts)
std::vector< TesselatorPrimitive > primitives
std::vector< TesselatorVertexData * > generatedVerticesData
std::vector< QVector3D > vertices
std::vector< unsigned int > indices