bool CFuzzyMembershipFunction::InitTrapezoid (long x1, long x2, long x3, long x4) { if ((x1 < x2) && (x2 < x3) && (x3 < x4)) { CFuzzyElement FE; DeleteVertices(); // Leftmost vertex. FE.SetValue(x1); FE.SetMembership(0.0); AddVertex(FE); // Left peak vertex. FE.SetValue(x2); FE.SetMembership(1.0); AddVertex(FE); // Right peak vertex. FE.SetValue(x3); FE.SetMembership(1.0); AddVertex(FE); // Rightmost vertex. FE.SetValue(x4); FE.SetMembership(0.0); AddVertex(FE); return true; } return false; }
bool CFuzzyMembershipFunction::InitTrapezoid (const CFuzzyElement& v1, const CFuzzyElement& v2, const CFuzzyElement& v3, const CFuzzyElement v4) { if ((v1.GetValue() < v2.GetValue()) && (v2.GetValue() < v3.GetValue()) && (v3.GetValue() < v4.GetValue()) && (v2.GetMembership() > v1.GetMembership()) && (v2.GetMembership() > v4.GetMembership()) && (v3.GetMembership() > v1.GetMembership()) && (v3.GetMembership() > v4.GetMembership())) { DeleteVertices(); // Leftmost vertex. AddVertex(v1); // Left peak vertex. AddVertex(v2); // Right peak vertex. AddVertex(v3); // Rightmost vertex. AddVertex(v4); return true; } return false; }
bool CFuzzyMembershipFunction::InitTriangle (long x1, long x2, long x3) { if ((x1 < x2) && (x2 < x3)) { CFuzzyElement FE; DeleteVertices(); // Left vertex. FE.SetValue(x1); FE.SetMembership(0.0); AddVertex(FE); // Peak vertex. FE.SetValue(x2); FE.SetMembership(1.0); AddVertex(FE); // Right vertex. FE.SetValue(x3); FE.SetMembership(0.0); AddVertex(FE); return true; } return false; }
//! sets the pointers to the vertices void VertexBuffer::SetVertices(uchar* pVertices, uint numVertices, uint vertexSize, std::vector<AttributeInfo>& attribInfos) { if (pVertices == m_pVertices) return; DeleteVertices(); m_pVertices = pVertices; m_Format = 0; m_MaxVertices = m_NumVertices = m_AllocatedVertices = numVertices; m_aAttribInfos = attribInfos; m_VertexSize = vertexSize; m_bDirty = true; }
CFuzzyMembershipFunction& CFuzzyMembershipFunction::Is (const CFuzzySet& right) { CFuzzyElement FE; DeleteVertices(); for (long i = 0; i < right.GetNumFuzzyElements(); i++) { if (right.GetFuzzyElement(i,&FE)) { AddVertex(FE); } } return *this; }
CFuzzyMembershipFunction & CFuzzyMembershipFunction::operator=(const CFuzzyMembershipFunction &right) { CFuzzyElement FE; DeleteVertices(); for (long v=0; v < right.GetNumVertices(); v++) { if (!right.GetVertex(v,&FE)) { return *this; } AddVertex(FE); } return *this; }
bool CFuzzyMembershipFunction::InitTriangle (const CFuzzyElement& v1, const CFuzzyElement& v2, const CFuzzyElement& v3) { if ((v1.GetValue() < v2.GetValue()) && (v2.GetValue() < v3.GetValue()) && (v2.GetMembership() > v1.GetMembership()) && (v2.GetMembership() > v3.GetMembership())) { DeleteVertices(); // Left vertex. AddVertex(v1); // Peak vertex. AddVertex(v2); // Right vertex. AddVertex(v3); return true; } return false; }
//! sets the pointers to the vertices void VertexBuffer::SetVertices(Vertex3D* pVertices, uint numVertices, uint format) { uchar* _pVertices = reinterpret_cast<uchar*>(pVertices); if(m_pVertices == _pVertices) return; DeleteVertices(); m_pVertices = _pVertices; m_Format = format; m_MaxVertices = m_NumVertices = m_AllocatedVertices = numVertices; m_VertexSize = sizeof(Vertex3D); m_aAttribInfos.clear(); if(format & Vertex3D::VF_Pos) { AttributeInfo info = { "aPosition", offsetof(Vertex3D, Pos), ADT_Float, 3 }; m_aAttribInfos.push_back(info); } if(format & Vertex3D::VF_UV) { AttributeInfo info = { "aUV", offsetof(Vertex3D, UV), ADT_Float, 2 }; m_aAttribInfos.push_back(info); } if(format & Vertex3D::VF_Normal) { AttributeInfo info = { "aNormal", offsetof(Vertex3D, Normal), ADT_Float, 3 }; m_aAttribInfos.push_back(info); } if(format & Vertex3D::VF_Color) { AttributeInfo info = { "aColor", offsetof(Vertex3D, color), ADT_Float, 4 }; m_aAttribInfos.push_back(info); } if(format & Vertex3D::VF_TangentBinormal) { AttributeInfo tangent = { "aTangent", offsetof(Vertex3D, Tangent), ADT_Float, 4 }; m_aAttribInfos.push_back(tangent); } m_bDirty = true; }
CFuzzyMembershipFunction::~CFuzzyMembershipFunction() { DeleteVertices(); }
//! destructor VertexBuffer::~VertexBuffer() { DeleteVertices(); DeleteIndices(); }