<commit_before>/****************************************************************************

 This file is part of the GLC-lib library.
 Copyright (C) 2005-2006 <NAME> (<EMAIL>)
 Version 0.9.6, packaged on June, 2006.

 http://glc-lib.sourceforge.net

 GLC-lib is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 GLC-lib is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with GLC-lib; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

*****************************************************************************/

//! \file glc_material.cpp implementation of the GLC_Material class.

#include <QtDebug>
#include <assert.h>
#include "glc_material.h"
#include "glc_collection.h"

//////////////////////////////////////////////////////////////////////
// Constructor Destructor
//////////////////////////////////////////////////////////////////////

GLC_Material::GLC_Material()
:GLC_Object("Material")
, m_fShininess(50.0)		// By default shininess 50
, m_pTexture(NULL)			// no texture 
{
	// Ambient Color
	initAmbientColor();

	// Others
	initOtherColor();
}

GLC_Material::GLC_Material(const QColor &ambientColor)
:GLC_Object("Material")
, m_fShininess(50.0)		// default : shininess 50
, m_pTexture(NULL)			// no texture
{

	m_AmbientColor= ambientColor;
	
	// Others
	initOtherColor();
}


GLC_Material::GLC_Material(const char *pName ,const GLfloat *pAmbientColor)
:GLC_Object(pName)
, m_fShininess(50.0)		// default : shininess 50
, m_pTexture(NULL)			// no texture
{

	// Init Ambiant Color
	if (pAmbientColor != 0)
	{
		m_AmbientColor.setRgbF(static_cast<qreal>(pAmbientColor[0]),
								static_cast<qreal>(pAmbientColor[1]), 
								static_cast<qreal>(pAmbientColor[2]),
								static_cast<qreal>(pAmbientColor[3]));
	}
	else
	{	
		initAmbientColor();
	}
	// Others
	initOtherColor();
}
GLC_Material::GLC_Material(GLC_Texture* pTexture, const char *pName)
:GLC_Object(pName)
, m_fShininess(50.0)		// By default shininess 50
, m_pTexture(pTexture)		// Init texture 
{
	// Ambiente Color
	initAmbientColor();

	// Others
	initOtherColor();
}

// Copy constructor
GLC_Material::GLC_Material(const GLC_Material &InitMaterial)
:GLC_Object(InitMaterial.getName())
, m_fShininess(InitMaterial.m_fShininess)
, m_pTexture(NULL)
{
	if (NULL != InitMaterial.m_pTexture)
	{
		m_pTexture= new GLC_Texture(*(InitMaterial.m_pTexture));
		assert(m_pTexture != NULL);
	}
	
	// Ambient Color
	m_AmbientColor= InitMaterial.m_AmbientColor;

	// Diffuse Color
	m_DiffuseColor= InitMaterial.m_DiffuseColor;

	// Specular Color
	m_SpecularColor= InitMaterial.m_SpecularColor;

	// Lighting emit
	m_LightEmission= InitMaterial.m_LightEmission;
		
}

// Destructor
GLC_Material::~GLC_Material(void)
{

	// Remove material from Geometries
	CWhereUsed::iterator iEntry= m_WhereUsed.begin();
	
    while (iEntry != m_WhereUsed.constEnd())
    {
        // Remove material from geometry
        iEntry.value()->delMaterial(iEntry.value());
        ++iEntry;
    }
    // clear whereUSED Hash table
    m_WhereUsed.clear();
    
    if (NULL != m_pTexture)
    {
   		delete m_pTexture;
    	m_pTexture= NULL;
    }
    

}


//////////////////////////////////////////////////////////////////////
// Get Functions
//////////////////////////////////////////////////////////////////////

// Get Ambiant color
QColor GLC_Material::getAmbientColor() const
{
	return m_AmbientColor;
}

// Get diffuse color
QColor GLC_Material::getDiffuseColor() const
{
	return m_DiffuseColor; 
}<commit_msg>when the last geometry which use a material is destruct, it delete his material. That why, the destructor of material no need to update geometry.<commit_after>/****************************************************************************

 This file is part of the GLC-lib library.
 Copyright (C) 2005-2006 <NAME> (<EMAIL>)
 Version 0.9.6, packaged on June, 2006.

 http://glc-lib.sourceforge.net

 GLC-lib is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 GLC-lib is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with GLC-lib; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

*****************************************************************************/

//! \file glc_material.cpp implementation of the GLC_Material class.

#include <QtDebug>
#include <assert.h>
#include "glc_material.h"
#include "glc_collection.h"

//////////////////////////////////////////////////////////////////////
// Constructor Destructor
//////////////////////////////////////////////////////////////////////

GLC_Material::GLC_Material()
:GLC_Object("Material")
, m_fShininess(50.0)		// By default shininess 50
, m_pTexture(NULL)			// no texture 
{
	// Ambient Color
	initAmbientColor();

	// Others
	initOtherColor();
}

GLC_Material::GLC_Material(const QColor &ambientColor)
:GLC_Object("Material")
, m_fShininess(50.0)		// default : shininess 50
, m_pTexture(NULL)			// no texture
{

	m_AmbientColor= ambientColor;
	
	// Others
	initOtherColor();
}


GLC_Material::GLC_Material(const char *pName ,const GLfloat *pAmbientColor)
:GLC_Object(pName)
, m_fShininess(50.0)		// default : shininess 50
, m_pTexture(NULL)			// no texture
{

	// Init Ambiant Color
	if (pAmbientColor != 0)
	{
		m_AmbientColor.setRgbF(static_cast<qreal>(pAmbientColor[0]),
								static_cast<qreal>(pAmbientColor[1]), 
								static_cast<qreal>(pAmbientColor[2]),
								static_cast<qreal>(pAmbientColor[3]));
	}
	else
	{	
		initAmbientColor();
	}
	// Others
	initOtherColor();
}
GLC_Material::GLC_Material(GLC_Texture* pTexture, const char *pName)
:GLC_Object(pName)
, m_fShininess(50.0)		// By default shininess 50
, m_pTexture(pTexture)		// Init texture 
{
	// Ambiente Color
	initAmbientColor();

	// Others
	initOtherColor();
}

// Copy constructor
GLC_Material::GLC_Material(const GLC_Material &InitMaterial)
:GLC_Object(InitMaterial.getName())
, m_fShininess(InitMaterial.m_fShininess)
, m_pTexture(NULL)
{
	if (NULL != InitMaterial.m_pTexture)
	{
		m_pTexture= new GLC_Texture(*(InitMaterial.m_pTexture));
		assert(m_pTexture != NULL);
	}
	
	// Ambient Color
	m_AmbientColor= InitMaterial.m_AmbientColor;

	// Diffuse Color
	m_DiffuseColor= InitMaterial.m_DiffuseColor;

	// Specular Color
	m_SpecularColor= InitMaterial.m_SpecularColor;

	// Lighting emit
	m_LightEmission= InitMaterial.m_LightEmission;
		
}

// Destructor
GLC_Material::~GLC_Material(void)
{

    // clear whereUSED Hash table
    m_WhereUsed.clear();
    
    if (NULL != m_pTexture)
    {
   		delete m_pTexture;
    	m_pTexture= NULL;
    }
    

}


//////////////////////////////////////////////////////////////////////
// Get Functions
//////////////////////////////////////////////////////////////////////

// Get Ambiant color
QColor GLC_Material::getAmbientColor() const
{
	return m_AmbientColor;
}

// Get diffuse color
QColor GLC_Material::getDiffuseColor() const
{
	return m_DiffuseColor; 
}
{'fraction_non_alphanumeric': 0.20507562163547807, 'fraction_numerical': 0.013329915406306075, 'mean_word_length': 3.0704225352112675, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4070764', 'n_tokens_mistral': 2622, 'n_tokens_neox': 2394, 'n_words': 618}