Refactor: Expand tabs to 4 spaces

This commit is contained in:
Richard
2015-06-28 16:04:15 -06:00
parent a96a595a7a
commit 83de707587
324 changed files with 78942 additions and 78947 deletions
+111 -111
View File
@@ -50,154 +50,154 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../include/assimp/material.h"
namespace Assimp {
namespace IFC {
namespace IFC {
// ------------------------------------------------------------------------------------------------
int ConvertShadingMode(const std::string& name)
{
if (name == "BLINN") {
return aiShadingMode_Blinn;
}
else if (name == "FLAT" || name == "NOTDEFINED") {
return aiShadingMode_NoShading;
}
else if (name == "PHONG") {
return aiShadingMode_Phong;
}
IFCImporter::LogWarn("shading mode "+name+" not recognized by Assimp, using Phong instead");
return aiShadingMode_Phong;
if (name == "BLINN") {
return aiShadingMode_Blinn;
}
else if (name == "FLAT" || name == "NOTDEFINED") {
return aiShadingMode_NoShading;
}
else if (name == "PHONG") {
return aiShadingMode_Phong;
}
IFCImporter::LogWarn("shading mode "+name+" not recognized by Assimp, using Phong instead");
return aiShadingMode_Phong;
}
// ------------------------------------------------------------------------------------------------
void FillMaterial(aiMaterial* mat,const IFC::IfcSurfaceStyle* surf,ConversionData& conv)
{
aiString name;
name.Set((surf->Name? surf->Name.Get() : "IfcSurfaceStyle_Unnamed"));
mat->AddProperty(&name,AI_MATKEY_NAME);
aiString name;
name.Set((surf->Name? surf->Name.Get() : "IfcSurfaceStyle_Unnamed"));
mat->AddProperty(&name,AI_MATKEY_NAME);
// now see which kinds of surface information are present
BOOST_FOREACH(boost::shared_ptr< const IFC::IfcSurfaceStyleElementSelect > sel2, surf->Styles) {
if (const IFC::IfcSurfaceStyleShading* shade = sel2->ResolveSelectPtr<IFC::IfcSurfaceStyleShading>(conv.db)) {
aiColor4D col_base,col;
// now see which kinds of surface information are present
BOOST_FOREACH(boost::shared_ptr< const IFC::IfcSurfaceStyleElementSelect > sel2, surf->Styles) {
if (const IFC::IfcSurfaceStyleShading* shade = sel2->ResolveSelectPtr<IFC::IfcSurfaceStyleShading>(conv.db)) {
aiColor4D col_base,col;
ConvertColor(col_base, shade->SurfaceColour);
mat->AddProperty(&col_base,1, AI_MATKEY_COLOR_DIFFUSE);
ConvertColor(col_base, shade->SurfaceColour);
mat->AddProperty(&col_base,1, AI_MATKEY_COLOR_DIFFUSE);
if (const IFC::IfcSurfaceStyleRendering* ren = shade->ToPtr<IFC::IfcSurfaceStyleRendering>()) {
if (const IFC::IfcSurfaceStyleRendering* ren = shade->ToPtr<IFC::IfcSurfaceStyleRendering>()) {
if (ren->Transparency) {
const float t = 1.f-static_cast<float>(ren->Transparency.Get());
mat->AddProperty(&t,1, AI_MATKEY_OPACITY);
}
if (ren->Transparency) {
const float t = 1.f-static_cast<float>(ren->Transparency.Get());
mat->AddProperty(&t,1, AI_MATKEY_OPACITY);
}
if (ren->DiffuseColour) {
ConvertColor(col, *ren->DiffuseColour.Get(),conv,&col_base);
mat->AddProperty(&col,1, AI_MATKEY_COLOR_DIFFUSE);
}
if (ren->DiffuseColour) {
ConvertColor(col, *ren->DiffuseColour.Get(),conv,&col_base);
mat->AddProperty(&col,1, AI_MATKEY_COLOR_DIFFUSE);
}
if (ren->SpecularColour) {
ConvertColor(col, *ren->SpecularColour.Get(),conv,&col_base);
mat->AddProperty(&col,1, AI_MATKEY_COLOR_SPECULAR);
}
if (ren->SpecularColour) {
ConvertColor(col, *ren->SpecularColour.Get(),conv,&col_base);
mat->AddProperty(&col,1, AI_MATKEY_COLOR_SPECULAR);
}
if (ren->TransmissionColour) {
ConvertColor(col, *ren->TransmissionColour.Get(),conv,&col_base);
mat->AddProperty(&col,1, AI_MATKEY_COLOR_TRANSPARENT);
}
if (ren->TransmissionColour) {
ConvertColor(col, *ren->TransmissionColour.Get(),conv,&col_base);
mat->AddProperty(&col,1, AI_MATKEY_COLOR_TRANSPARENT);
}
if (ren->ReflectionColour) {
ConvertColor(col, *ren->ReflectionColour.Get(),conv,&col_base);
mat->AddProperty(&col,1, AI_MATKEY_COLOR_REFLECTIVE);
}
if (ren->ReflectionColour) {
ConvertColor(col, *ren->ReflectionColour.Get(),conv,&col_base);
mat->AddProperty(&col,1, AI_MATKEY_COLOR_REFLECTIVE);
}
const int shading = (ren->SpecularHighlight && ren->SpecularColour)?ConvertShadingMode(ren->ReflectanceMethod):static_cast<int>(aiShadingMode_Gouraud);
mat->AddProperty(&shading,1, AI_MATKEY_SHADING_MODEL);
const int shading = (ren->SpecularHighlight && ren->SpecularColour)?ConvertShadingMode(ren->ReflectanceMethod):static_cast<int>(aiShadingMode_Gouraud);
mat->AddProperty(&shading,1, AI_MATKEY_SHADING_MODEL);
if (ren->SpecularHighlight) {
if(const EXPRESS::REAL* rt = ren->SpecularHighlight.Get()->ToPtr<EXPRESS::REAL>()) {
// at this point we don't distinguish between the two distinct ways of
// specifying highlight intensities. leave this to the user.
const float e = static_cast<float>(*rt);
mat->AddProperty(&e,1,AI_MATKEY_SHININESS);
}
else {
IFCImporter::LogWarn("unexpected type error, SpecularHighlight should be a REAL");
}
}
}
} /*
else if (const IFC::IfcSurfaceStyleWithTextures* tex = sel2->ResolveSelectPtr<IFC::IfcSurfaceStyleWithTextures>(conv.db)) {
// XXX
} */
}
if (ren->SpecularHighlight) {
if(const EXPRESS::REAL* rt = ren->SpecularHighlight.Get()->ToPtr<EXPRESS::REAL>()) {
// at this point we don't distinguish between the two distinct ways of
// specifying highlight intensities. leave this to the user.
const float e = static_cast<float>(*rt);
mat->AddProperty(&e,1,AI_MATKEY_SHININESS);
}
else {
IFCImporter::LogWarn("unexpected type error, SpecularHighlight should be a REAL");
}
}
}
} /*
else if (const IFC::IfcSurfaceStyleWithTextures* tex = sel2->ResolveSelectPtr<IFC::IfcSurfaceStyleWithTextures>(conv.db)) {
// XXX
} */
}
}
// ------------------------------------------------------------------------------------------------
unsigned int ProcessMaterials(uint64_t id, unsigned int prevMatId, ConversionData& conv, bool forceDefaultMat)
{
STEP::DB::RefMapRange range = conv.db.GetRefs().equal_range(id);
for(;range.first != range.second; ++range.first) {
if(const IFC::IfcStyledItem* const styled = conv.db.GetObject((*range.first).second)->ToPtr<IFC::IfcStyledItem>()) {
BOOST_FOREACH(const IFC::IfcPresentationStyleAssignment& as, styled->Styles) {
BOOST_FOREACH(boost::shared_ptr<const IFC::IfcPresentationStyleSelect> sel, as.Styles) {
STEP::DB::RefMapRange range = conv.db.GetRefs().equal_range(id);
for(;range.first != range.second; ++range.first) {
if(const IFC::IfcStyledItem* const styled = conv.db.GetObject((*range.first).second)->ToPtr<IFC::IfcStyledItem>()) {
BOOST_FOREACH(const IFC::IfcPresentationStyleAssignment& as, styled->Styles) {
BOOST_FOREACH(boost::shared_ptr<const IFC::IfcPresentationStyleSelect> sel, as.Styles) {
if( const IFC::IfcSurfaceStyle* const surf = sel->ResolveSelectPtr<IFC::IfcSurfaceStyle>(conv.db) ) {
// try to satisfy from cache
ConversionData::MaterialCache::iterator mit = conv.cached_materials.find(surf);
if( mit != conv.cached_materials.end() )
return mit->second;
if( const IFC::IfcSurfaceStyle* const surf = sel->ResolveSelectPtr<IFC::IfcSurfaceStyle>(conv.db) ) {
// try to satisfy from cache
ConversionData::MaterialCache::iterator mit = conv.cached_materials.find(surf);
if( mit != conv.cached_materials.end() )
return mit->second;
// not found, create new material
const std::string side = static_cast<std::string>(surf->Side);
if( side != "BOTH" ) {
IFCImporter::LogWarn("ignoring surface side marker on IFC::IfcSurfaceStyle: " + side);
}
// not found, create new material
const std::string side = static_cast<std::string>(surf->Side);
if( side != "BOTH" ) {
IFCImporter::LogWarn("ignoring surface side marker on IFC::IfcSurfaceStyle: " + side);
}
std::auto_ptr<aiMaterial> mat(new aiMaterial());
std::auto_ptr<aiMaterial> mat(new aiMaterial());
FillMaterial(mat.get(), surf, conv);
FillMaterial(mat.get(), surf, conv);
conv.materials.push_back(mat.release());
unsigned int matindex = conv.materials.size() - 1;
conv.cached_materials[surf] = matindex;
return matindex;
}
}
}
}
}
conv.materials.push_back(mat.release());
unsigned int matindex = conv.materials.size() - 1;
conv.cached_materials[surf] = matindex;
return matindex;
}
}
}
}
}
// no local material defined. If there's global one, use that instead
if( prevMatId != std::numeric_limits<uint32_t>::max() )
return prevMatId;
// no local material defined. If there's global one, use that instead
if( prevMatId != std::numeric_limits<uint32_t>::max() )
return prevMatId;
// we're still here - create an default material if required, or simply fail otherwise
if( !forceDefaultMat )
return std::numeric_limits<uint32_t>::max();
// we're still here - create an default material if required, or simply fail otherwise
if( !forceDefaultMat )
return std::numeric_limits<uint32_t>::max();
aiString name;
name.Set("<IFCDefault>");
// ConvertColorToString( color, name);
aiString name;
name.Set("<IFCDefault>");
// ConvertColorToString( color, name);
// look if there's already a default material with this base color
for( size_t a = 0; a < conv.materials.size(); ++a )
{
aiString mname;
conv.materials[a]->Get(AI_MATKEY_NAME, mname);
if( name == mname )
return (unsigned int)a;
}
// look if there's already a default material with this base color
for( size_t a = 0; a < conv.materials.size(); ++a )
{
aiString mname;
conv.materials[a]->Get(AI_MATKEY_NAME, mname);
if( name == mname )
return (unsigned int)a;
}
// we're here, yet - no default material with suitable color available. Generate one
std::auto_ptr<aiMaterial> mat(new aiMaterial());
mat->AddProperty(&name,AI_MATKEY_NAME);
// we're here, yet - no default material with suitable color available. Generate one
std::auto_ptr<aiMaterial> mat(new aiMaterial());
mat->AddProperty(&name,AI_MATKEY_NAME);
const aiColor4D col = aiColor4D( 0.6f, 0.6f, 0.6f, 1.0f); // aiColor4D( color.r, color.g, color.b, 1.0f);
mat->AddProperty(&col,1, AI_MATKEY_COLOR_DIFFUSE);
const aiColor4D col = aiColor4D( 0.6f, 0.6f, 0.6f, 1.0f); // aiColor4D( color.r, color.g, color.b, 1.0f);
mat->AddProperty(&col,1, AI_MATKEY_COLOR_DIFFUSE);
conv.materials.push_back(mat.release());
return (unsigned int) conv.materials.size() - 1;
conv.materials.push_back(mat.release());
return (unsigned int) conv.materials.size() - 1;
}
} // ! IFC