#pragma once #include "Engine/Operator/Attribute.h" #include "Engine/Types.h" #include #include #include "Engine/Operator/AttributeHandle.h" #include #include #include #include namespace enzo::geo { using Kernel = CGAL::Simple_cartesian; using Point = Kernel::Point_3; using Vector = Kernel::Vector_3; using HeMesh = CGAL::Surface_mesh; using vertexDescriptor = HeMesh::Vertex_index; using faceDescriptor = HeMesh::Face_index; using V_index = HeMesh::Vertex_index; using F_index = HeMesh::Face_index; using attributeIterator = std::vector>::iterator; class Geometry { public: Geometry(); Geometry(const Geometry& other); Geometry& operator=(const Geometry& rhs); ga::AttributeHandle addIntAttribute(ga::AttributeOwner owner, std::string name); ga::AttributeHandleBool addBoolAttribute(ga::AttributeOwner owner, std::string name); ga::AttributeHandle addVector3Attribute(ga::AttributeOwner owner, std::string name); // TODO: return weak ptr std::shared_ptr getAttribByName(ga::AttributeOwner owner, std::string name); const size_t getNumAttributes(const ga::AttributeOwner owner) const; std::weak_ptr getAttributeByIndex(ga::AttributeOwner owner, unsigned int index) const; // attributeIterator attributesBegin(const ga::AttributeOwner owner); // attributeIterator attributesEnd(const ga::AttributeOwner owner); std::vector derivePointNormals(); HeMesh computeHalfEdgeMesh(); void addFace(std::vector pointOffsets, bool closed=true); void addPoint(const bt::Vector3& pos); std::set::const_iterator soloPointsBegin(); std::set::const_iterator soloPointsEnd(); void setPointPos(const ga::Offset offset, const bt::Vector3& pos); ga::Offset getPrimStartVertex(ga::Offset primOffset) const; // returns the first vertex of the primitive bt::Vector3 getPosFromVert(ga::Offset vertexOffset) const; bt::Vector3 getPointPos(ga::Offset pointOffset) const; unsigned int getPrimVertCount(ga::Offset primOffset) const; ga::Offset getVertexPrim(ga::Offset vertexOffset) const; ga::Offset getNumPrims() const; ga::Offset getNumVerts() const; ga::Offset getNumPoints() const; ga::Offset getNumSoloPoints() const; bt::boolT isClosed(ga::Offset primOffset) const; void computePrimStartVertices() const; private: using attribVector = std::vector>; geo::Geometry::attribVector& getAttributeStore(const ga::AttributeOwner& owner); const geo::Geometry::attribVector& getAttributeStore(const ga::AttributeOwner& owner) const; attribVector deepCopyAttributes(attribVector source); attribVector pointAttributes_; attribVector vertexAttributes_; attribVector primitiveAttributes_; attribVector globalAttributes_; std::set soloPoints_; mutable std::vector primStarts_; mutable std::vector vertexPrims_; mutable std::atomic primStartsDirty_{true}; mutable tbb::spin_mutex primStartsMutex_; // handles enzo::ga::AttributeHandleInt vertexCountHandlePrim_; enzo::ga::AttributeHandleBool closedHandlePrim_; enzo::ga::AttributeHandleInt pointOffsetHandleVert_; enzo::ga::AttributeHandleVector3 posHandlePoint_; }; }