/* Code generated by IfcQuery EXPRESS generator, www.ifcquery.com */
#include <sstream>
#include <limits>

#include "ifcpp/model/AttributeObject.h"
#include "ifcpp/model/BuildingException.h"
#include "ifcpp/model/BuildingGuid.h"
#include "ifcpp/reader/ReaderUtil.h"
#include "ifcpp/writer/WriterUtil.h"
#include "ifcpp/IFC4/include/IfcAxis2Placement.h"
#include "ifcpp/IFC4/include/IfcCoordinateOperation.h"
#include "ifcpp/IFC4/include/IfcDimensionCount.h"
#include "ifcpp/IFC4/include/IfcDirection.h"
#include "ifcpp/IFC4/include/IfcGeometricRepresentationContext.h"
#include "ifcpp/IFC4/include/IfcGeometricRepresentationSubContext.h"
#include "ifcpp/IFC4/include/IfcLabel.h"
#include "ifcpp/IFC4/include/IfcReal.h"
#include "ifcpp/IFC4/include/IfcRepresentation.h"

// ENTITY IfcGeometricRepresentationContext 
IfcGeometricRepresentationContext::IfcGeometricRepresentationContext( int id ) { m_entity_id = id; }
IfcGeometricRepresentationContext::~IfcGeometricRepresentationContext() {}
shared_ptr<BuildingObject> IfcGeometricRepresentationContext::getDeepCopy( BuildingCopyOptions& options )
{
	shared_ptr<IfcGeometricRepresentationContext> copy_self( new IfcGeometricRepresentationContext() );
	if( m_ContextIdentifier ) { copy_self->m_ContextIdentifier = dynamic_pointer_cast<IfcLabel>( m_ContextIdentifier->getDeepCopy(options) ); }
	if( m_ContextType ) { copy_self->m_ContextType = dynamic_pointer_cast<IfcLabel>( m_ContextType->getDeepCopy(options) ); }
	if( m_CoordinateSpaceDimension ) { copy_self->m_CoordinateSpaceDimension = dynamic_pointer_cast<IfcDimensionCount>( m_CoordinateSpaceDimension->getDeepCopy(options) ); }
	if( m_Precision ) { copy_self->m_Precision = dynamic_pointer_cast<IfcReal>( m_Precision->getDeepCopy(options) ); }
	if( m_WorldCoordinateSystem ) { copy_self->m_WorldCoordinateSystem = dynamic_pointer_cast<IfcAxis2Placement>( m_WorldCoordinateSystem->getDeepCopy(options) ); }
	if( m_TrueNorth ) { copy_self->m_TrueNorth = dynamic_pointer_cast<IfcDirection>( m_TrueNorth->getDeepCopy(options) ); }
	return copy_self;
}
void IfcGeometricRepresentationContext::getStepLine( std::stringstream& stream ) const
{
	stream << "#" << m_entity_id << "= IFCGEOMETRICREPRESENTATIONCONTEXT" << "(";
	if( m_ContextIdentifier ) { m_ContextIdentifier->getStepParameter( stream ); } else { stream << "$"; }
	stream << ",";
	if( m_ContextType ) { m_ContextType->getStepParameter( stream ); } else { stream << "$"; }
	stream << ",";
	if( m_CoordinateSpaceDimension ) { m_CoordinateSpaceDimension->getStepParameter( stream ); } else { stream << "$"; }
	stream << ",";
	if( m_Precision ) { m_Precision->getStepParameter( stream ); } else { stream << "$"; }
	stream << ",";
	if( m_WorldCoordinateSystem ) { m_WorldCoordinateSystem->getStepParameter( stream, true ); } else { stream << "$" ; }
	stream << ",";
	if( m_TrueNorth ) { stream << "#" << m_TrueNorth->m_entity_id; } else { stream << "$"; }
	stream << ");";
}
void IfcGeometricRepresentationContext::getStepParameter( std::stringstream& stream, bool ) const { stream << "#" << m_entity_id; }
const std::wstring IfcGeometricRepresentationContext::toString() const { return L"IfcGeometricRepresentationContext"; }
void IfcGeometricRepresentationContext::readStepArguments( const std::vector<std::wstring>& args, const std::map<int,shared_ptr<BuildingEntity> >& map )
{
	const size_t num_args = args.size();
	if( num_args != 6 ){ std::stringstream err; err << "Wrong parameter count for entity IfcGeometricRepresentationContext, expecting 6, having " << num_args << ". Entity ID: " << m_entity_id << std::endl; throw BuildingException( err.str().c_str() ); }
	m_ContextIdentifier = IfcLabel::createObjectFromSTEP( args[0], map );
	m_ContextType = IfcLabel::createObjectFromSTEP( args[1], map );
	m_CoordinateSpaceDimension = IfcDimensionCount::createObjectFromSTEP( args[2], map );
	m_Precision = IfcReal::createObjectFromSTEP( args[3], map );
	m_WorldCoordinateSystem = IfcAxis2Placement::createObjectFromSTEP( args[4], map );
	readEntityReference( args[5], m_TrueNorth, map );
}
void IfcGeometricRepresentationContext::getAttributes( std::vector<std::pair<std::string, shared_ptr<BuildingObject> > >& vec_attributes ) const
{
	IfcRepresentationContext::getAttributes( vec_attributes );
	vec_attributes.emplace_back( std::make_pair( "CoordinateSpaceDimension", m_CoordinateSpaceDimension ) );
	vec_attributes.emplace_back( std::make_pair( "Precision", m_Precision ) );
	vec_attributes.emplace_back( std::make_pair( "WorldCoordinateSystem", m_WorldCoordinateSystem ) );
	vec_attributes.emplace_back( std::make_pair( "TrueNorth", m_TrueNorth ) );
}
void IfcGeometricRepresentationContext::getAttributesInverse( std::vector<std::pair<std::string, shared_ptr<BuildingObject> > >& vec_attributes_inverse ) const
{
	IfcRepresentationContext::getAttributesInverse( vec_attributes_inverse );
	if( !m_HasSubContexts_inverse.empty() )
	{
		shared_ptr<AttributeObjectVector> HasSubContexts_inverse_vec_obj( new AttributeObjectVector() );
		for( size_t i=0; i<m_HasSubContexts_inverse.size(); ++i )
		{
			if( !m_HasSubContexts_inverse[i].expired() )
			{
				HasSubContexts_inverse_vec_obj->m_vec.emplace_back( shared_ptr<IfcGeometricRepresentationSubContext>( m_HasSubContexts_inverse[i] ) );
			}
		}
		vec_attributes_inverse.emplace_back( std::make_pair( "HasSubContexts_inverse", HasSubContexts_inverse_vec_obj ) );
	}
	if( !m_HasCoordinateOperation_inverse.empty() )
	{
		shared_ptr<AttributeObjectVector> HasCoordinateOperation_inverse_vec_obj( new AttributeObjectVector() );
		for( size_t i=0; i<m_HasCoordinateOperation_inverse.size(); ++i )
		{
			if( !m_HasCoordinateOperation_inverse[i].expired() )
			{
				HasCoordinateOperation_inverse_vec_obj->m_vec.emplace_back( shared_ptr<IfcCoordinateOperation>( m_HasCoordinateOperation_inverse[i] ) );
			}
		}
		vec_attributes_inverse.emplace_back( std::make_pair( "HasCoordinateOperation_inverse", HasCoordinateOperation_inverse_vec_obj ) );
	}
}
void IfcGeometricRepresentationContext::setInverseCounterparts( shared_ptr<BuildingEntity> ptr_self_entity )
{
	IfcRepresentationContext::setInverseCounterparts( ptr_self_entity );
}
void IfcGeometricRepresentationContext::unlinkFromInverseCounterparts()
{
	IfcRepresentationContext::unlinkFromInverseCounterparts();
}
