コード例 #1
0
ファイル: IFCProfile.cpp プロジェクト: Finkky/spring
// ------------------------------------------------------------------------------------------------
void ProcessParametrizedProfile(const IfcParameterizedProfileDef& def, TempMesh& meshout, ConversionData& conv)
{
	if(const IfcRectangleProfileDef* const cprofile = def.ToPtr<IfcRectangleProfileDef>()) {
		const IfcFloat x = cprofile->XDim*0.5f, y = cprofile->YDim*0.5f;

		meshout.verts.reserve(meshout.verts.size()+4);
		meshout.verts.push_back( IfcVector3( x, y, 0.f ));
		meshout.verts.push_back( IfcVector3(-x, y, 0.f ));
		meshout.verts.push_back( IfcVector3(-x,-y, 0.f ));
		meshout.verts.push_back( IfcVector3( x,-y, 0.f ));
		meshout.vertcnt.push_back(4);
	}
	else if( const IfcCircleProfileDef* const circle = def.ToPtr<IfcCircleProfileDef>()) {
		if( const IfcCircleHollowProfileDef* const hollow = def.ToPtr<IfcCircleHollowProfileDef>()) {
			// TODO
		}
		const size_t segments = 32;
		const IfcFloat delta = AI_MATH_TWO_PI_F/segments, radius = circle->Radius;

		meshout.verts.reserve(segments);

		IfcFloat angle = 0.f;
		for(size_t i = 0; i < segments; ++i, angle += delta) {
			meshout.verts.push_back( IfcVector3( ::cos(angle)*radius, ::sin(angle)*radius, 0.f ));
		}

		meshout.vertcnt.push_back(segments);
	}
	else {
		IFCImporter::LogWarn("skipping unknown IfcParameterizedProfileDef entity, type is " + def.GetClassName());
		return;
	}

	IfcMatrix4 trafo;
	ConvertAxisPlacement(trafo, *def.Position);
	meshout.Transform(trafo);
}
コード例 #2
0
ファイル: IFCProfile.cpp プロジェクト: Synicix/assimp
// ------------------------------------------------------------------------------------------------
void ProcessParametrizedProfile(const IfcParameterizedProfileDef& def, TempMesh& meshout, ConversionData& /*conv*/)
{
    if(const IfcRectangleProfileDef* const cprofile = def.ToPtr<IfcRectangleProfileDef>()) {
        const IfcFloat x = cprofile->XDim*0.5f, y = cprofile->YDim*0.5f;

        meshout.verts.reserve(meshout.verts.size()+4);
        meshout.verts.push_back( IfcVector3( x, y, 0.f ));
        meshout.verts.push_back( IfcVector3(-x, y, 0.f ));
        meshout.verts.push_back( IfcVector3(-x,-y, 0.f ));
        meshout.verts.push_back( IfcVector3( x,-y, 0.f ));
        meshout.vertcnt.push_back(4);
    }
    else if( const IfcCircleProfileDef* const circle = def.ToPtr<IfcCircleProfileDef>()) {
        if(def.ToPtr<IfcCircleHollowProfileDef>()) {
            // TODO
        }
        const size_t segments = 32;
        const IfcFloat delta = AI_MATH_TWO_PI_F/segments, radius = circle->Radius;

        meshout.verts.reserve(segments);

        IfcFloat angle = 0.f;
        for(size_t i = 0; i < segments; ++i, angle += delta) {
            meshout.verts.push_back( IfcVector3( std::cos(angle)*radius, std::sin(angle)*radius, 0.f ));
        }

        meshout.vertcnt.push_back(segments);
    }
    else if( const IfcIShapeProfileDef* const ishape = def.ToPtr<IfcIShapeProfileDef>()) {
        // construct simplified IBeam shape
        const IfcFloat offset = (ishape->OverallWidth - ishape->WebThickness) / 2;
        const IfcFloat inner_height = ishape->OverallDepth - ishape->FlangeThickness * 2;

        meshout.verts.reserve(12);
        meshout.verts.push_back(IfcVector3(0,0,0));
        meshout.verts.push_back(IfcVector3(0,ishape->FlangeThickness,0));
        meshout.verts.push_back(IfcVector3(offset,ishape->FlangeThickness,0));
        meshout.verts.push_back(IfcVector3(offset,ishape->FlangeThickness + inner_height,0));
        meshout.verts.push_back(IfcVector3(0,ishape->FlangeThickness + inner_height,0));
        meshout.verts.push_back(IfcVector3(0,ishape->OverallDepth,0));
        meshout.verts.push_back(IfcVector3(ishape->OverallWidth,ishape->OverallDepth,0));
        meshout.verts.push_back(IfcVector3(ishape->OverallWidth,ishape->FlangeThickness + inner_height,0));
        meshout.verts.push_back(IfcVector3(offset+ishape->WebThickness,ishape->FlangeThickness + inner_height,0));
        meshout.verts.push_back(IfcVector3(offset+ishape->WebThickness,ishape->FlangeThickness,0));
        meshout.verts.push_back(IfcVector3(ishape->OverallWidth,ishape->FlangeThickness,0));
        meshout.verts.push_back(IfcVector3(ishape->OverallWidth,0,0));

        meshout.vertcnt.push_back(12);
    }
    else {
        IFCImporter::LogWarn("skipping unknown IfcParameterizedProfileDef entity, type is " + def.GetClassName());
        return;
    }

    IfcMatrix4 trafo;
    ConvertAxisPlacement(trafo, *def.Position);
    meshout.Transform(trafo);
}