From a7e43173dbb54b313b842e636ce9560405b74f2d Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Sun, 17 Jul 2011 01:09:56 +0000 Subject: [PATCH] git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1046 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/CMakeLists.txt | 1 + code/IFCCurve.cpp | 510 +++++++++++++++++++++++++++++++++++ code/IFCGeometry.cpp | 4 +- code/IFCLoader.cpp | 5 +- code/IFCLoader.h | 4 +- code/IFCProfile.cpp | 17 +- code/IFCReaderGen.cpp | 291 +++++++++++++++++--- code/IFCReaderGen.h | 36 ++- code/IFCUtil.cpp | 9 +- code/IFCUtil.h | 85 +++++- workspaces/vc9/assimp.vcproj | 1 + 11 files changed, 902 insertions(+), 61 deletions(-) create mode 100644 code/IFCCurve.cpp diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 999b5d32f..f1a7f56e4 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -369,6 +369,7 @@ SET(IFC_SRCS IFCGeometry.cpp IFCMaterial.cpp IFCProfile.cpp + IFCCurve.cpp STEPFile.h STEPFileReader.h STEPFileReader.cpp diff --git a/code/IFCCurve.cpp b/code/IFCCurve.cpp new file mode 100644 index 000000000..67f6046fe --- /dev/null +++ b/code/IFCCurve.cpp @@ -0,0 +1,510 @@ +/* +Open Asset Import Library (ASSIMP) +---------------------------------------------------------------------- + +Copyright (c) 2006-2010, ASSIMP Development Team +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the +following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +* Neither the name of the ASSIMP team, nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission of the ASSIMP Development Team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +---------------------------------------------------------------------- +*/ + +/** @file IFCProfile.cpp + * @brief Read profile and curves entities from IFC files + */ + +#include "AssimpPCH.h" + +#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER +#include "IFCUtil.h" + +namespace Assimp { + namespace IFC { + namespace { + + +// -------------------------------------------------------------------------------- +// Conic is the base class for Circle and Ellipse +// -------------------------------------------------------------------------------- +class Conic : public Curve +{ + +public: + + // -------------------------------------------------- + Conic(const IfcConic& entity, ConversionData& conv) + : Curve(entity,conv) + { + aiMatrix4x4 trafo; + ConvertAxisPlacement(trafo,*entity.Position,conv); + + // for convenience, extract the matrix rows + location = aiVector3D(trafo.a4,trafo.b4,trafo.c4); + p[0] = aiVector3D(trafo.a1,trafo.b1,trafo.c1); + p[1] = aiVector3D(trafo.a2,trafo.b2,trafo.c2); + p[2] = aiVector3D(trafo.a3,trafo.b3,trafo.c3); + } + +public: + + // -------------------------------------------------- + std::pair GetParametricRange() const { + return std::make_pair(0.f,360.f); + } + +protected: + aiVector3D location, p[3]; +}; + + +// -------------------------------------------------------------------------------- +// Circle +// -------------------------------------------------------------------------------- +class Circle : public Conic +{ + +public: + + // -------------------------------------------------- + Circle(const IfcCircle& entity, ConversionData& conv) + : Conic(entity,conv) + , entity(entity) + { + } + +public: + + // -------------------------------------------------- + aiVector3D Eval(float u) const { + u = -conv.angle_scale * u; + return location + entity.Radius*(::cos(u)*p[0] + ::sin(u)*p[1]); + } + +private: + const IfcCircle& entity; +}; + + +// -------------------------------------------------------------------------------- +// Ellipse +// -------------------------------------------------------------------------------- +class Ellipse : public Conic +{ + +public: + + // -------------------------------------------------- + Ellipse(const IfcEllipse& entity, ConversionData& conv) + : Conic(entity,conv) + , entity(entity) + { + } + +public: + + // -------------------------------------------------- + aiVector3D Eval(float u) const { + u = -conv.angle_scale * u; + return location + entity.SemiAxis1*::cos(u)*p[0] + entity.SemiAxis2*::sin(u)*p[1]; + } + +private: + const IfcEllipse& entity; +}; + + +// -------------------------------------------------------------------------------- +// Line +// -------------------------------------------------------------------------------- +class Line : public Curve +{ + +public: + + // -------------------------------------------------- + Line(const IfcLine& entity, ConversionData& conv) + : Curve(entity,conv) + , entity(entity) + { + ConvertCartesianPoint(p,entity.Pnt); + ConvertVector(v,entity.Dir); + } + +public: + + // -------------------------------------------------- + aiVector3D Eval(float u) const { + return p + u*v; + } + + // -------------------------------------------------- + std::pair GetParametricRange() const { + const float inf = std::numeric_limits::infinity(); + + return std::make_pair(-inf,+inf); + } + +private: + const IfcLine& entity; + aiVector3D p,v; +}; + +// -------------------------------------------------------------------------------- +// CompositeCurve joins multiple smaller, bounded curves +// -------------------------------------------------------------------------------- +class CompositeCurve : public BoundedCurve +{ + + // XXX the implementation currently ignores curve transitions + +public: + + // -------------------------------------------------- + CompositeCurve(const IfcCompositeCurve& entity, ConversionData& conv) + : BoundedCurve(entity,conv) + , entity(entity) + { + curves.reserve(entity.Segments.size()); + BOOST_FOREACH(const IfcCompositeCurveSegment& curveSegment,entity.Segments) { + // according to the specification, this must be a bounded curve + boost::shared_ptr< Curve > cv(Curve::Convert(curveSegment.ParentCurve,conv)); + boost::shared_ptr< BoundedCurve > bc = boost::dynamic_pointer_cast(cv); + + if (!bc) { + IFCImporter::LogError("expected segment of composite curve to be a bounded curve"); + continue; + } + + if ( (std::string)curveSegment.Transition != "CONTINUOUS" ) { + IFCImporter::LogDebug("ignoring transition code on composite curve segment, only continuous transitions are supported"); + } + + curves.push_back(bc); + } + + if (curves.empty()) { + IFCImporter::LogError("empty composite curve"); + return; + } + + total = 0.f; + BOOST_FOREACH(boost::shared_ptr< const BoundedCurve > curve, curves) { + const std::pair range = curve->GetParametricRange(); + total += range.second-range.first; + } + } + +public: + + // -------------------------------------------------- + aiVector3D Eval(float u) const { + if (curves.empty()) { + return aiVector3D(); + } + + float acc = 0; + BOOST_FOREACH(boost::shared_ptr< const BoundedCurve > curve, curves) { + const std::pair range = curve->GetParametricRange(); + const float delta = range.second-range.first; + if (u < acc+delta) { + return curve->Eval( (u-acc) + range.first ); + } + + acc += delta; + } + // clamp to end + return curves.back()->Eval(curves.back()->GetParametricRange().second); + } + + // -------------------------------------------------- + float SuggestNext(float u) const { + + float acc = 0; + BOOST_FOREACH(boost::shared_ptr< const BoundedCurve > curve, curves) { + const std::pair range = curve->GetParametricRange(); + const float delta = range.second-range.first; + if (u < acc+delta) { + return curve->SuggestNext( (u-acc) + range.first ) - range.first + acc; + } + acc += delta; + } + return std::numeric_limits::infinity(); + } + + // -------------------------------------------------- + std::pair GetParametricRange() const { + return std::make_pair(0.f,total); + } + +private: + const IfcCompositeCurve& entity; + std::vector< boost::shared_ptr< const BoundedCurve> > curves; + + float total; +}; + + +// -------------------------------------------------------------------------------- +// TrimmedCurve can be used to trim an unbounded curve to a bounded range +// -------------------------------------------------------------------------------- +class TrimmedCurve : public BoundedCurve +{ + +public: + + // -------------------------------------------------- + TrimmedCurve(const IfcTrimmedCurve& entity, ConversionData& conv) + : BoundedCurve(entity,conv) + , entity(entity) + { + base = boost::shared_ptr(Curve::Convert(entity.BasisCurve,conv)); + + typedef boost::shared_ptr Entry; + + // for some reason, trimmed curves can either specify a parametric value + // or a point on the curve, or both. And they can even specify which of the + // two representations they prefer, even though an information invariant + // claims that they must be identical if both are present. + // oh well. + bool ok = false; + BOOST_FOREACH(const Entry sel,entity.Trim1) { + if (const EXPRESS::REAL* const r = sel->ToPtr()) { + range.first = *r; + ok = true; + break; + } + } + if (!ok) { + IFCImporter::LogError("trimming by curve points not currently supported, skipping first cut point"); + range.first = base->GetParametricRange().first; + if (range.first == std::numeric_limits::infinity()) { + range.first = 0; + } + } + ok = false; + BOOST_FOREACH(const Entry sel,entity.Trim2) { + if (const EXPRESS::REAL* const r = sel->ToPtr()) { + range.second = *r; + ok = true; + break; + } + } + if (!ok) { + IFCImporter::LogError("trimming by curve points not currently supported, skipping second cut point"); + range.second = base->GetParametricRange().second; + if (range.second == std::numeric_limits::infinity()) { + range.second = 0; + } + } + + maxval = range.second-range.first; + } + +public: + + // -------------------------------------------------- + aiVector3D Eval(float p) const { + p = std::min(range.second, std::max(range.first+p,range.first)); + if (!IsTrue(entity.SenseAgreement)) { + p = range.second - (p-range.first); + } + return base->Eval( p ); + } + + // -------------------------------------------------- + float SuggestNext(float u) const { + if (u >= maxval) { + return std::numeric_limits::infinity(); + } + + if (const Line* const l = dynamic_cast(base.get())) { + // a line is, well, a line .. so two points are always sufficient to represent it + return maxval; + } + + if (const Conic* const l = dynamic_cast(base.get())) { + // the suitable sampling density for conics is a configuration property + return std::min(maxval, static_cast( u + maxval/ceil(maxval/conv.settings.conicSamplingAngle)) ); + } + + return BoundedCurve::SuggestNext(u); + } + + // -------------------------------------------------- + std::pair GetParametricRange() const { + return std::make_pair(0,maxval); + } + +private: + const IfcTrimmedCurve& entity; + std::pair range; + float maxval; + + boost::shared_ptr base; +}; + + +// -------------------------------------------------------------------------------- +// PolyLine is a 'curve' defined by linear interpolation over a set of discrete points +// -------------------------------------------------------------------------------- +class PolyLine : public BoundedCurve +{ + +public: + + // -------------------------------------------------- + PolyLine(const IfcPolyline& entity, ConversionData& conv) + : BoundedCurve(entity,conv) + , entity(entity) + { + points.reserve(entity.Points.size()); + + aiVector3D t; + BOOST_FOREACH(const IfcCartesianPoint& cp, entity.Points) { + ConvertCartesianPoint(t,cp); + points.push_back(t); + } + } + +public: + + // -------------------------------------------------- + aiVector3D Eval(float p) const { + if (p < 0.f) { + return points.front(); + } + const size_t b = static_cast(floor(p)); + if (b >= points.size()-1) { + return points.back(); + } + + const float d = p-static_cast(b); + return points[b+1] * d + points[b] * (1.f-d); + } + + // -------------------------------------------------- + float SuggestNext(float u) const { + if (u > points.size()-1) { + return std::numeric_limits::infinity(); + } + return ::floor(u)+1; + } + + // -------------------------------------------------- + std::pair GetParametricRange() const { + return std::make_pair(0.f,static_cast(points.size()-1)); + } + +private: + const IfcPolyline& entity; + std::vector points; +}; + + +} // anon + + +// ------------------------------------------------------------------------------------------------ +Curve* Curve :: Convert(const IFC::IfcCurve& curve,ConversionData& conv) +{ + if(curve.ToPtr()) { + if(const IfcPolyline* c = curve.ToPtr()) { + return new PolyLine(*c,conv); + } + if(const IfcTrimmedCurve* c = curve.ToPtr()) { + return new TrimmedCurve(*c,conv); + } + if(const IfcCompositeCurve* c = curve.ToPtr()) { + return new CompositeCurve(*c,conv); + } + //if(const IfcBSplineCurve* c = curve.ToPtr()) { + // return new BSplineCurve(*c,conv); + //} + } + + if(curve.ToPtr()) { + if(const IfcCircle* c = curve.ToPtr()) { + return new Circle(*c,conv); + } + if(const IfcEllipse* c = curve.ToPtr()) { + return new Ellipse(*c,conv); + } + } + + if(const IfcLine* c = curve.ToPtr()) { + return new Line(*c,conv); + } + + // XXX OffsetCurve2D, OffsetCurve3D not currently supported + return NULL; +} + +// ------------------------------------------------------------------------------------------------ +float BoundedCurve :: SuggestNext(float u) const +{ + // the default behavior is to subdivide each curve into approximately 32 linear segments + const unsigned int segments = 32; + + const std::pair range = GetParametricRange(); + const float delta = range.second - range.first, perseg = delta/segments; + + if (u < range.first) { + return range.first; + } + + u = u+perseg; + if (u > range.second) { + return std::numeric_limits::infinity(); + } + + return u; +} + +// ------------------------------------------------------------------------------------------------ +void BoundedCurve :: SampleDiscrete(TempMesh& out) const +{ + const std::pair range = GetParametricRange(); + const float inf = std::numeric_limits::infinity(); + + size_t cnt = 0; + float u = range.first; + do ++cnt; while( (u = SuggestNext(u)) != inf ); + out.verts.reserve(cnt); + + u = range.first; + do out.verts.push_back(Eval(u)); while( (u = SuggestNext(u)) != inf ); +} + +} // IFC +} // Assimp + +#endif // ASSIMP_BUILD_NO_IFC_IMPORTER diff --git a/code/IFCGeometry.cpp b/code/IFCGeometry.cpp index eb4118618..9e7479f12 100644 --- a/code/IFCGeometry.cpp +++ b/code/IFCGeometry.cpp @@ -49,6 +49,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "PolyTools.h" #include "ProcessHelper.h" +#include + namespace Assimp { namespace IFC { @@ -1139,7 +1141,7 @@ void ProcessSweptAreaSolid(const IfcSweptAreaSolid& swept, TempMesh& meshout, Co // ------------------------------------------------------------------------------------------------ void ProcessBoolean(const IfcBooleanResult& boolean, TempMesh& result, ConversionData& conv) { - if(const IfcBooleanClippingResult* const clip = boolean.ToPtr()) { + if(const IfcBooleanResult* const clip = boolean.ToPtr()) { if(clip->Operator != "DIFFERENCE") { IFCImporter::LogWarn("encountered unsupported boolean operator: " + (std::string)clip->Operator); return; diff --git a/code/IFCLoader.cpp b/code/IFCLoader.cpp index 870f27251..fb6465119 100644 --- a/code/IFCLoader.cpp +++ b/code/IFCLoader.cpp @@ -139,6 +139,7 @@ void IFCImporter::SetupProperties(const Importer* pImp) settings.skipCurveRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_CURVE_REPRESENTATIONS,true); settings.useCustomTriangulation = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION,true); + settings.conicSamplingAngle = 10.f; settings.skipAnnotations = true; } @@ -354,7 +355,7 @@ bool ProcessMappedItem(const IfcMappedItem& mapped, aiNode* nd_src, std::vector< std::auto_ptr nd(new aiNode()); nd->mName.Set("IfcMappedItem"); - // handle the cartesian operator + // handle the Cartesian operator aiMatrix4x4 m; ConvertTransformOperator(m, *mapped.MappingTarget); @@ -378,7 +379,7 @@ bool ProcessMappedItem(const IfcMappedItem& mapped, aiNode* nd_src, std::vector< bool got = false; BOOST_FOREACH(const IfcRepresentationItem& item, repr.Items) { if(!ProcessRepresentationItem(item,meshes,conv)) { - IFCImporter::LogWarn("skipping unknown mapped entity, type is " + item.GetClassName()); + IFCImporter::LogWarn("skipping mapped entity of type " + item.GetClassName() + ", no representations could be generated"); } else got = true; } diff --git a/code/IFCLoader.h b/code/IFCLoader.h index 71170d419..8ed9dacf8 100644 --- a/code/IFCLoader.h +++ b/code/IFCLoader.h @@ -107,7 +107,7 @@ private: public: - // loader settings, publicy accessible via their corresponding AI_CONFIG constants + // loader settings, publicly accessible via their corresponding AI_CONFIG constants struct Settings { Settings() @@ -115,6 +115,7 @@ public: , skipCurveRepresentations() , useCustomTriangulation() , skipAnnotations() + , conicSamplingAngle(10.f) {} @@ -122,6 +123,7 @@ public: bool skipCurveRepresentations; bool useCustomTriangulation; bool skipAnnotations; + float conicSamplingAngle; }; diff --git a/code/IFCProfile.cpp b/code/IFCProfile.cpp index 53225ad9f..2c641e97d 100644 --- a/code/IFCProfile.cpp +++ b/code/IFCProfile.cpp @@ -65,14 +65,21 @@ void ProcessPolyLine(const IfcPolyline& def, TempMesh& meshout, ConversionData& // ------------------------------------------------------------------------------------------------ bool ProcessCurve(const IfcCurve& curve, TempMesh& meshout, ConversionData& conv) { - if(const IfcPolyline* poly = curve.ToPtr()) { - ProcessPolyLine(*poly,meshout,conv); - } - else { + boost::scoped_ptr cv(Curve::Convert(curve,conv)); + if (!cv) { IFCImporter::LogWarn("skipping unknown IfcCurve entity, type is " + curve.GetClassName()); return false; } - return true; + + // we must have a bounded curve at this point + if (const BoundedCurve* bc = dynamic_cast(cv.get())) { + bc->SampleDiscrete(meshout); + meshout.vertcnt.push_back(meshout.verts.size()); + return true; + } + + IFCImporter::LogError("cannot use unbounded curve as profile"); + return false; } // ------------------------------------------------------------------------------------------------ diff --git a/code/IFCReaderGen.cpp b/code/IFCReaderGen.cpp index 451aa4d22..f8700c41e 100644 --- a/code/IFCReaderGen.cpp +++ b/code/IFCReaderGen.cpp @@ -553,7 +553,7 @@ namespace { , SchemaEntry("ifcstructuralpointaction",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcspatialstructureelement",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcspace",&STEP::ObjectHelper::Construct ) -, SchemaEntry("ifccontextdependentunit",&STEP::ObjectHelper::Construct ) +, SchemaEntry("ifccontextdependentunit",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcvirtualgridintersection",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcrelassociates",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcrelassociatesclassification",&STEP::ObjectHelper::Construct ) @@ -643,7 +643,7 @@ namespace { , SchemaEntry("ifcdistributioncontrolelement",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifctransformertype",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifclaborresource",&STEP::ObjectHelper::Construct ) -, SchemaEntry("ifcderivedprofiledef",&STEP::ObjectHelper::Construct ) +, SchemaEntry("ifcderivedprofiledef",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcrelconnectsstructuralmember",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcrelconnectswitheccentricity",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcfurniturestandard",&STEP::ObjectHelper::Construct ) @@ -750,7 +750,7 @@ namespace { , SchemaEntry("ifcsubcontractresource",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifctimeseriesreferencerelationship",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcsweptdisksolid",&STEP::ObjectHelper::Construct ) -, SchemaEntry("ifccompositeprofiledef",&STEP::ObjectHelper::Construct ) +, SchemaEntry("ifccompositeprofiledef",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcelectricalbaseproperties",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcpredefinedpointmarkersymbol",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifctanktype",&STEP::ObjectHelper::Construct ) @@ -817,7 +817,7 @@ namespace { , SchemaEntry("ifctextstyletextmodel",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcprojectioncurve",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcfillareastyletiles",&STEP::ObjectHelper::Construct ) -, SchemaEntry("ifcrelfillselement",&STEP::ObjectHelper::Construct ) +, SchemaEntry("ifcrelfillselement",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcelectricmotortype",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifctendon",&STEP::ObjectHelper::Construct ) , SchemaEntry("ifcdistributionchamberelementtype",&STEP::ObjectHelper::Construct ) @@ -1045,7 +1045,7 @@ void IFC::GetSchema(EXPRESS::ConversionSchema& out) namespace STEP { // ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const STEP::DB& /*db*/, const LIST& /*params*/, NotImplemented* /*in*/) +template <> size_t GenericFill(const STEP::DB& db, const LIST& params, NotImplemented* in) { return 0; } @@ -1166,16 +1166,16 @@ template <> size_t GenericFill(const DB& db, const LIST& params, IfcGri return base; } // ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& /*db*/, const LIST& params, IfcRepresentationItem* /*in*/) +template <> size_t GenericFill(const DB& db, const LIST& params, IfcRepresentationItem* in) { size_t base = 0; - if (params.GetSize() < 0) { throw STEP::TypeError("expected 0 arguments to IfcRepresentationItem"); } return base; + return base; } // ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcGeometricRepresentationItem* in) { size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 0) { throw STEP::TypeError("expected 0 arguments to IfcGeometricRepresentationItem"); } return base; + return base; } // ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcOneDirectionRepeatFactor* in) @@ -1278,7 +1278,7 @@ template <> size_t GenericFill(const DB& db, const LIST& template <> size_t GenericFill(const DB& db, const LIST& params, IfcSurface* in) { size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 0) { throw STEP::TypeError("expected 0 arguments to IfcSurface"); } return base; + return base; } // ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcBoundedSurface* in) @@ -1553,20 +1553,29 @@ template <> size_t GenericFill(const DB& db, const template <> size_t GenericFill(const DB& db, const LIST& params, IfcCurve* in) { size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 0) { throw STEP::TypeError("expected 0 arguments to IfcCurve"); } return base; + return base; } // ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcConic* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members + if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to IfcConic"); } do { // convert the 'Position' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } + try { GenericConvert( in->Position, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to IfcConic to be a `IfcAxis2Placement`")); } + } while(0); return base; } // ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcCircle* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members + if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to IfcCircle"); } do { // convert the 'Radius' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->Radius, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to IfcCircle to be a `IfcPositiveLengthMeasure`")); } + } while(0); return base; } // ----------------------------------------------------------------------------------------------------------- @@ -1653,7 +1662,7 @@ template <> size_t GenericFill(const DB& db, const LI template <> size_t GenericFill(const DB& db, const LIST& params, IfcTopologicalRepresentationItem* in) { size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 0) { throw STEP::TypeError("expected 0 arguments to IfcTopologicalRepresentationItem"); } return base; + return base; } // ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcConnectedFaceSet* in) @@ -1706,7 +1715,16 @@ template <> size_t GenericFill(const DB& db, const LIST& params, I template <> size_t GenericFill(const DB& db, const LIST& params, IfcVector* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members + if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to IfcVector"); } do { // convert the 'Orientation' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->Orientation, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to IfcVector to be a `IfcDirection`")); } + } while(0); + do { // convert the 'Magnitude' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->Magnitude, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to IfcVector to be a `IfcLengthMeasure`")); } + } while(0); return base; } // ----------------------------------------------------------------------------------------------------------- @@ -1731,8 +1749,7 @@ template <> size_t GenericFill(const DB& db, const LIST& params, I template <> size_t GenericFill(const DB& db, const LIST& params, IfcFaceOuterBound* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members - return base; + if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to IfcFaceOuterBound"); } return base; } // ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcFeatureElementAddition* in) @@ -1748,11 +1765,7 @@ template <> size_t GenericFill(const DB& db, const LIST& params, I if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to IfcNamedUnit"); } do { // convert the 'Dimensions' argument boost::shared_ptr arg = params[base++]; if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } - if (dynamic_cast(&*arg)) { - // (hack) allow this - I found some Ifc files which violate the spec here - break; - } - try { GenericConvert( in->Dimensions, arg, db ); break; } + try { GenericConvert( in->Dimensions, arg, db ); break; } catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to IfcNamedUnit to be a `IfcDimensionalExponents`")); } } while(0); do { // convert the 'UnitType' argument @@ -1857,7 +1870,16 @@ template <> size_t GenericFill(const DB& db, const LIST& params, IfcPr template <> size_t GenericFill(const DB& db, const LIST& params, IfcLine* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members + if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to IfcLine"); } do { // convert the 'Pnt' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->Pnt, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to IfcLine to be a `IfcCartesianPoint`")); } + } while(0); + do { // convert the 'Dir' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->Dir, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to IfcLine to be a `IfcVector`")); } + } while(0); return base; } // ----------------------------------------------------------------------------------------------------------- @@ -1868,10 +1890,9 @@ template <> size_t GenericFill(const DB& db, const LIST& params, IfcC return base; } // ----------------------------------------------------------------------------------------------------------- -template <> size_t GenericFill(const DB& /*db*/, const LIST& params, IfcObjectPlacement* /*in*/) +template <> size_t GenericFill(const DB& db, const LIST& params, IfcObjectPlacement* in) { size_t base = 0; - if (params.GetSize() < 0) { throw STEP::TypeError("expected 0 arguments to IfcObjectPlacement"); } return base; } // ----------------------------------------------------------------------------------------------------------- @@ -1898,8 +1919,7 @@ template <> size_t GenericFill(const DB& db, const LIST& params, template <> size_t GenericFill(const DB& db, const LIST& params, IfcAnnotation* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members - return base; + if (params.GetSize() < 7) { throw STEP::TypeError("expected 7 arguments to IfcAnnotation"); } return base; } // ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcPlate* in) @@ -1912,7 +1932,7 @@ template <> size_t GenericFill(const DB& db, const LIST& params, IfcPl template <> size_t GenericFill(const DB& db, const LIST& params, IfcSolidModel* in) { size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 0) { throw STEP::TypeError("expected 0 arguments to IfcSolidModel"); } return base; + return base; } // ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcManifoldSolidBrep* in) @@ -2033,7 +2053,7 @@ template <> size_t GenericFill(const DB& db, const LIST& para template <> size_t GenericFill(const DB& db, const LIST& params, IfcBoundedCurve* in) { size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 0) { throw STEP::TypeError("expected 0 arguments to IfcBoundedCurve"); } return base; + return base; } // ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcAxis1Placement* in) @@ -2091,6 +2111,13 @@ template <> size_t GenericFill(const DB& db, const LIST& params, IfcSp return base; } // ----------------------------------------------------------------------------------------------------------- +template <> size_t GenericFill(const DB& db, const LIST& params, IfcContextDependentUnit* in) +{ + size_t base = GenericFill(db,params,static_cast(in)); +// this data structure is not used yet, so there is no code generated to fill its members + return base; +} +// ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcCoolingTowerType* in) { size_t base = GenericFill(db,params,static_cast(in)); @@ -2238,7 +2265,18 @@ template <> size_t GenericFill(const DB& db, const LIST& params, IfcRam template <> size_t GenericFill(const DB& db, const LIST& params, IfcCompositeCurve* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members + if (params.GetSize() < 2) { throw STEP::TypeError("expected 2 arguments to IfcCompositeCurve"); } do { // convert the 'Segments' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } + try { GenericConvert( in->Segments, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to IfcCompositeCurve to be a `LIST [1:?] OF IfcCompositeCurveSegment`")); } + } while(0); + do { // convert the 'SelfIntersect' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } + try { GenericConvert( in->SelfIntersect, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to IfcCompositeCurve to be a `LOGICAL`")); } + } while(0); return base; } // ----------------------------------------------------------------------------------------------------------- @@ -2611,6 +2649,13 @@ template <> size_t GenericFill(const DB& db, const LIST& param return base; } // ----------------------------------------------------------------------------------------------------------- +template <> size_t GenericFill(const DB& db, const LIST& params, IfcDerivedProfileDef* in) +{ + size_t base = GenericFill(db,params,static_cast(in)); +// this data structure is not used yet, so there is no code generated to fill its members + return base; +} +// ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcFurnitureStandard* in) { size_t base = GenericFill(db,params,static_cast(in)); @@ -2758,7 +2803,36 @@ template <> size_t GenericFill(const DB& db, const LIST& params template <> size_t GenericFill(const DB& db, const LIST& params, IfcBSplineCurve* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members + if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to IfcBSplineCurve"); } do { // convert the 'Degree' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[0]=true; break; } + try { GenericConvert( in->Degree, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to IfcBSplineCurve to be a `INTEGER`")); } + } while(0); + do { // convert the 'ControlPointsList' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; } + try { GenericConvert( in->ControlPointsList, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to IfcBSplineCurve to be a `LIST [2:?] OF IfcCartesianPoint`")); } + } while(0); + do { // convert the 'CurveForm' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[2]=true; break; } + try { GenericConvert( in->CurveForm, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to IfcBSplineCurve to be a `IfcBSplineCurveForm`")); } + } while(0); + do { // convert the 'ClosedCurve' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[3]=true; break; } + try { GenericConvert( in->ClosedCurve, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to IfcBSplineCurve to be a `LOGICAL`")); } + } while(0); + do { // convert the 'SelfIntersect' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[4]=true; break; } + try { GenericConvert( in->SelfIntersect, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to IfcBSplineCurve to be a `LOGICAL`")); } + } while(0); return base; } // ----------------------------------------------------------------------------------------------------------- @@ -2793,7 +2867,36 @@ template <> size_t GenericFill(const DB& db, const template <> size_t GenericFill(const DB& db, const LIST& params, IfcSite* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members + if (params.GetSize() < 14) { throw STEP::TypeError("expected 14 arguments to IfcSite"); } do { // convert the 'RefLatitude' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) break; + try { GenericConvert( in->RefLatitude, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 9 to IfcSite to be a `IfcCompoundPlaneAngleMeasure`")); } + } while(0); + do { // convert the 'RefLongitude' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) break; + try { GenericConvert( in->RefLongitude, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 10 to IfcSite to be a `IfcCompoundPlaneAngleMeasure`")); } + } while(0); + do { // convert the 'RefElevation' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) break; + try { GenericConvert( in->RefElevation, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 11 to IfcSite to be a `IfcLengthMeasure`")); } + } while(0); + do { // convert the 'LandTitleNumber' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) break; + try { GenericConvert( in->LandTitleNumber, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 12 to IfcSite to be a `IfcLabel`")); } + } while(0); + do { // convert the 'SiteAddress' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) break; + try { GenericConvert( in->SiteAddress, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 13 to IfcSite to be a `IfcPostalAddress`")); } + } while(0); return base; } // ----------------------------------------------------------------------------------------------------------- @@ -3002,7 +3105,7 @@ template <> size_t GenericFill(const DB& db, template <> size_t GenericFill(const DB& db, const LIST& params, IfcPoint* in) { size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 0) { throw STEP::TypeError("expected 0 arguments to IfcPoint"); } return base; + return base; } // ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcSurfaceOfRevolution* in) @@ -3194,7 +3297,7 @@ template <> size_t GenericFill(const DB& db, const LI template <> size_t GenericFill(const DB& db, const LIST& params, IfcLoop* in) { size_t base = GenericFill(db,params,static_cast(in)); - if (params.GetSize() < 0) { throw STEP::TypeError("expected 0 arguments to IfcLoop"); } return base; + return base; } // ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcVertexLoop* in) @@ -3276,6 +3379,13 @@ template <> size_t GenericFill(const DB& db, const LIST& para return base; } // ----------------------------------------------------------------------------------------------------------- +template <> size_t GenericFill(const DB& db, const LIST& params, IfcCompositeProfileDef* in) +{ + size_t base = GenericFill(db,params,static_cast(in)); +// this data structure is not used yet, so there is no code generated to fill its members + return base; +} +// ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcTankType* in) { size_t base = GenericFill(db,params,static_cast(in)); @@ -3339,7 +3449,24 @@ template <> size_t GenericFill(const DB& db, const LI template <> size_t GenericFill(const DB& db, const LIST& params, IfcBuilding* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members + if (params.GetSize() < 12) { throw STEP::TypeError("expected 12 arguments to IfcBuilding"); } do { // convert the 'ElevationOfRefHeight' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) break; + try { GenericConvert( in->ElevationOfRefHeight, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 9 to IfcBuilding to be a `IfcLengthMeasure`")); } + } while(0); + do { // convert the 'ElevationOfTerrain' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) break; + try { GenericConvert( in->ElevationOfTerrain, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 10 to IfcBuilding to be a `IfcLengthMeasure`")); } + } while(0); + do { // convert the 'BuildingAddress' argument + boost::shared_ptr arg = params[base++]; + if (dynamic_cast(&*arg)) break; + try { GenericConvert( in->BuildingAddress, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 11 to IfcBuilding to be a `IfcPostalAddress`")); } + } while(0); return base; } // ----------------------------------------------------------------------------------------------------------- @@ -3525,6 +3652,22 @@ template <> size_t GenericFill(const DB& db, const LIST& return base; } // ----------------------------------------------------------------------------------------------------------- +template <> size_t GenericFill(const DB& db, const LIST& params, IfcRelFillsElement* in) +{ + size_t base = GenericFill(db,params,static_cast(in)); + if (params.GetSize() < 6) { throw STEP::TypeError("expected 6 arguments to IfcRelFillsElement"); } do { // convert the 'RelatingOpeningElement' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->RelatingOpeningElement, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to IfcRelFillsElement to be a `IfcOpeningElement`")); } + } while(0); + do { // convert the 'RelatedBuildingElement' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->RelatedBuildingElement, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 5 to IfcRelFillsElement to be a `IfcElement`")); } + } while(0); + return base; +} +// ----------------------------------------------------------------------------------------------------------- template <> size_t GenericFill(const DB& db, const LIST& params, IfcElectricMotorType* in) { size_t base = GenericFill(db,params,static_cast(in)); @@ -3651,7 +3794,26 @@ template <> size_t GenericFill(const DB& db, const LIST& para template <> size_t GenericFill(const DB& db, const LIST& params, IfcBoundingBox* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members + if (params.GetSize() < 4) { throw STEP::TypeError("expected 4 arguments to IfcBoundingBox"); } do { // convert the 'Corner' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->Corner, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to IfcBoundingBox to be a `IfcCartesianPoint`")); } + } while(0); + do { // convert the 'XDim' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->XDim, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to IfcBoundingBox to be a `IfcPositiveLengthMeasure`")); } + } while(0); + do { // convert the 'YDim' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->YDim, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to IfcBoundingBox to be a `IfcPositiveLengthMeasure`")); } + } while(0); + do { // convert the 'ZDim' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->ZDim, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to IfcBoundingBox to be a `IfcPositiveLengthMeasure`")); } + } while(0); return base; } // ----------------------------------------------------------------------------------------------------------- @@ -4142,7 +4304,21 @@ template <> size_t GenericFill(const DB& db, const LIST& p template <> size_t GenericFill(const DB& db, const LIST& params, IfcCompositeCurveSegment* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members + if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to IfcCompositeCurveSegment"); } do { // convert the 'Transition' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->Transition, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to IfcCompositeCurveSegment to be a `IfcTransitionCode`")); } + } while(0); + do { // convert the 'SameSense' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->SameSense, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to IfcCompositeCurveSegment to be a `BOOLEAN`")); } + } while(0); + do { // convert the 'ParentCurve' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->ParentCurve, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to IfcCompositeCurveSegment to be a `IfcCurve`")); } + } while(0); return base; } // ----------------------------------------------------------------------------------------------------------- @@ -4170,7 +4346,31 @@ template <> size_t GenericFill(const DB& db, const LIS template <> size_t GenericFill(const DB& db, const LIST& params, IfcTrimmedCurve* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members + if (params.GetSize() < 5) { throw STEP::TypeError("expected 5 arguments to IfcTrimmedCurve"); } do { // convert the 'BasisCurve' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->BasisCurve, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to IfcTrimmedCurve to be a `IfcCurve`")); } + } while(0); + do { // convert the 'Trim1' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->Trim1, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to IfcTrimmedCurve to be a `SET [1:2] OF IfcTrimmingSelect`")); } + } while(0); + do { // convert the 'Trim2' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->Trim2, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to IfcTrimmedCurve to be a `SET [1:2] OF IfcTrimmingSelect`")); } + } while(0); + do { // convert the 'SenseAgreement' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->SenseAgreement, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 3 to IfcTrimmedCurve to be a `BOOLEAN`")); } + } while(0); + do { // convert the 'MasterRepresentation' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->MasterRepresentation, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 4 to IfcTrimmedCurve to be a `IfcTrimmingPreference`")); } + } while(0); return base; } // ----------------------------------------------------------------------------------------------------------- @@ -4327,7 +4527,16 @@ template <> size_t GenericFill(const DB& db, const LIST& params, IfcDoo template <> size_t GenericFill(const DB& db, const LIST& params, IfcEllipse* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members + if (params.GetSize() < 3) { throw STEP::TypeError("expected 3 arguments to IfcEllipse"); } do { // convert the 'SemiAxis1' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->SemiAxis1, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 1 to IfcEllipse to be a `IfcPositiveLengthMeasure`")); } + } while(0); + do { // convert the 'SemiAxis2' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->SemiAxis2, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 2 to IfcEllipse to be a `IfcPositiveLengthMeasure`")); } + } while(0); return base; } // ----------------------------------------------------------------------------------------------------------- @@ -4348,7 +4557,11 @@ template <> size_t GenericFill(const DB& db, const LIST& pa template <> size_t GenericFill(const DB& db, const LIST& params, IfcFaceBasedSurfaceModel* in) { size_t base = GenericFill(db,params,static_cast(in)); -// this data structure is not used yet, so there is no code generated to fill its members + if (params.GetSize() < 1) { throw STEP::TypeError("expected 1 arguments to IfcFaceBasedSurfaceModel"); } do { // convert the 'FbsmFaces' argument + boost::shared_ptr arg = params[base++]; + try { GenericConvert( in->FbsmFaces, arg, db ); break; } + catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 0 to IfcFaceBasedSurfaceModel to be a `SET [1:?] OF IfcConnectedFaceSet`")); } + } while(0); return base; } // ----------------------------------------------------------------------------------------------------------- diff --git a/code/IFCReaderGen.h b/code/IFCReaderGen.h index d2f979e46..298c65395 100644 --- a/code/IFCReaderGen.h +++ b/code/IFCReaderGen.h @@ -893,7 +893,7 @@ namespace IFC { struct IfcStructuralPointAction; struct IfcSpatialStructureElement; struct IfcSpace; - typedef NotImplemented IfcContextDependentUnit; // (not currently used by Assimp) + struct IfcContextDependentUnit; typedef NotImplemented IfcVirtualGridIntersection; // (not currently used by Assimp) typedef NotImplemented IfcRelAssociates; // (not currently used by Assimp) typedef NotImplemented IfcRelAssociatesClassification; // (not currently used by Assimp) @@ -983,7 +983,7 @@ namespace IFC { struct IfcDistributionControlElement; struct IfcTransformerType; struct IfcLaborResource; - typedef NotImplemented IfcDerivedProfileDef; // (not currently used by Assimp) + struct IfcDerivedProfileDef; typedef NotImplemented IfcRelConnectsStructuralMember; // (not currently used by Assimp) typedef NotImplemented IfcRelConnectsWithEccentricity; // (not currently used by Assimp) struct IfcFurnitureStandard; @@ -1090,7 +1090,7 @@ namespace IFC { struct IfcSubContractResource; typedef NotImplemented IfcTimeSeriesReferenceRelationship; // (not currently used by Assimp) struct IfcSweptDiskSolid; - typedef NotImplemented IfcCompositeProfileDef; // (not currently used by Assimp) + struct IfcCompositeProfileDef; typedef NotImplemented IfcElectricalBaseProperties; // (not currently used by Assimp) typedef NotImplemented IfcPreDefinedPointMarkerSymbol; // (not currently used by Assimp) struct IfcTankType; @@ -1157,7 +1157,7 @@ namespace IFC { typedef NotImplemented IfcTextStyleTextModel; // (not currently used by Assimp) struct IfcProjectionCurve; struct IfcFillAreaStyleTiles; - typedef NotImplemented IfcRelFillsElement; // (not currently used by Assimp) + struct IfcRelFillsElement; struct IfcElectricMotorType; struct IfcTendon; struct IfcDistributionChamberElementType; @@ -2014,6 +2014,11 @@ namespace IFC { Maybe< IfcLengthMeasure::Out > ElevationWithFlooring; }; + // C++ wrapper for IfcContextDependentUnit + struct IfcContextDependentUnit : IfcNamedUnit, ObjectHelper { IfcContextDependentUnit() : Object("IfcContextDependentUnit") {} + IfcLabel::Out Name; + }; + // C++ wrapper for IfcCoolingTowerType struct IfcCoolingTowerType : IfcEnergyConversionDeviceType, ObjectHelper { IfcCoolingTowerType() : Object("IfcCoolingTowerType") {} IfcCoolingTowerTypeEnum::Out PredefinedType; @@ -2342,6 +2347,13 @@ namespace IFC { Maybe< IfcText::Out > SkillSet; }; + // C++ wrapper for IfcDerivedProfileDef + struct IfcDerivedProfileDef : IfcProfileDef, ObjectHelper { IfcDerivedProfileDef() : Object("IfcDerivedProfileDef") {} + Lazy< IfcProfileDef > ParentProfile; + Lazy< IfcCartesianTransformationOperator2D > Operator; + Maybe< IfcLabel::Out > Label; + }; + // C++ wrapper for IfcFurnitureStandard struct IfcFurnitureStandard : IfcControl, ObjectHelper { IfcFurnitureStandard() : Object("IfcFurnitureStandard") {} @@ -2792,6 +2804,12 @@ namespace IFC { IfcParameterValue::Out EndParam; }; + // C++ wrapper for IfcCompositeProfileDef + struct IfcCompositeProfileDef : IfcProfileDef, ObjectHelper { IfcCompositeProfileDef() : Object("IfcCompositeProfileDef") {} + ListOf< Lazy< IfcProfileDef >, 2, 0 > Profiles; + Maybe< IfcLabel::Out > Label; + }; + // C++ wrapper for IfcTankType struct IfcTankType : IfcFlowStorageDeviceType, ObjectHelper { IfcTankType() : Object("IfcTankType") {} IfcTankTypeEnum::Out PredefinedType; @@ -2979,6 +2997,12 @@ namespace IFC { IfcPositiveRatioMeasure::Out TilingScale; }; + // C++ wrapper for IfcRelFillsElement + struct IfcRelFillsElement : IfcRelConnects, ObjectHelper { IfcRelFillsElement() : Object("IfcRelFillsElement") {} + Lazy< IfcOpeningElement > RelatingOpeningElement; + Lazy< IfcElement > RelatedBuildingElement; + }; + // C++ wrapper for IfcElectricMotorType struct IfcElectricMotorType : IfcEnergyConversionDeviceType, ObjectHelper { IfcElectricMotorType() : Object("IfcElectricMotorType") {} IfcElectricMotorTypeEnum::Out PredefinedType; @@ -3922,6 +3946,7 @@ namespace STEP { DECL_CONV_STUB(IfcStructuralPointAction); DECL_CONV_STUB(IfcSpatialStructureElement); DECL_CONV_STUB(IfcSpace); + DECL_CONV_STUB(IfcContextDependentUnit); DECL_CONV_STUB(IfcCoolingTowerType); DECL_CONV_STUB(IfcFacetedBrepWithVoids); DECL_CONV_STUB(IfcValveType); @@ -3981,6 +4006,7 @@ namespace STEP { DECL_CONV_STUB(IfcDistributionControlElement); DECL_CONV_STUB(IfcTransformerType); DECL_CONV_STUB(IfcLaborResource); + DECL_CONV_STUB(IfcDerivedProfileDef); DECL_CONV_STUB(IfcFurnitureStandard); DECL_CONV_STUB(IfcStairFlightType); DECL_CONV_STUB(IfcWorkControl); @@ -4054,6 +4080,7 @@ namespace STEP { DECL_CONV_STUB(IfcOpenShell); DECL_CONV_STUB(IfcSubContractResource); DECL_CONV_STUB(IfcSweptDiskSolid); + DECL_CONV_STUB(IfcCompositeProfileDef); DECL_CONV_STUB(IfcTankType); DECL_CONV_STUB(IfcSphere); DECL_CONV_STUB(IfcPolyLoop); @@ -4086,6 +4113,7 @@ namespace STEP { DECL_CONV_STUB(IfcLightSourcePositional); DECL_CONV_STUB(IfcProjectionCurve); DECL_CONV_STUB(IfcFillAreaStyleTiles); + DECL_CONV_STUB(IfcRelFillsElement); DECL_CONV_STUB(IfcElectricMotorType); DECL_CONV_STUB(IfcTendon); DECL_CONV_STUB(IfcDistributionChamberElementType); diff --git a/code/IFCUtil.cpp b/code/IFCUtil.cpp index df34c190a..cdaaf99ff 100644 --- a/code/IFCUtil.cpp +++ b/code/IFCUtil.cpp @@ -295,6 +295,13 @@ void ConvertCartesianPoint(aiVector3D& out, const IfcCartesianPoint& in) } } +// ------------------------------------------------------------------------------------------------ +void ConvertVector(aiVector3D& out, const IfcVector& in) +{ + ConvertDirection(out,in.Orientation); + out *= in.Magnitude; +} + // ------------------------------------------------------------------------------------------------ void ConvertDirection(aiVector3D& out, const IfcDirection& in) { @@ -304,7 +311,7 @@ void ConvertDirection(aiVector3D& out, const IfcDirection& in) } const float len = out.Length(); if (len<1e-6) { - IFCImporter::LogWarn("direction vector too small, normalizing would result in a division by zero"); + IFCImporter::LogWarn("direction vector magnitude too small, normalization would result in a division by zero"); return; } out /= len; diff --git a/code/IFCUtil.h b/code/IFCUtil.h index c80922662..d9cb27572 100644 --- a/code/IFCUtil.h +++ b/code/IFCUtil.h @@ -130,6 +130,8 @@ struct ConversionData std::vector* collect_openings; }; +// ------------------------------------------------------------------------------------------------ +// Binary predicate to compare vectors with a given, quadratic epsilon. // ------------------------------------------------------------------------------------------------ struct FuzzyVectorCompare { @@ -164,16 +166,17 @@ struct TempMesh // conversion routines for common IFC entities, implemented in IFCUtil.cpp -void ConvertColor(aiColor4D& out, const IFC::IfcColourRgb& in); -void ConvertColor(aiColor4D& out, const IFC::IfcColourOrFactor& in,ConversionData& conv,const aiColor4D* base); -void ConvertCartesianPoint(aiVector3D& out, const IFC::IfcCartesianPoint& in); -void ConvertDirection(aiVector3D& out, const IFC::IfcDirection& in); +void ConvertColor(aiColor4D& out, const IfcColourRgb& in); +void ConvertColor(aiColor4D& out, const IfcColourOrFactor& in,ConversionData& conv,const aiColor4D* base); +void ConvertCartesianPoint(aiVector3D& out, const IfcCartesianPoint& in); +void ConvertDirection(aiVector3D& out, const IfcDirection& in); +void ConvertVector(aiVector3D& out, const IfcVector& in); void AssignMatrixAxes(aiMatrix4x4& out, const aiVector3D& x, const aiVector3D& y, const aiVector3D& z); -void ConvertAxisPlacement(aiMatrix4x4& out, const IFC::IfcAxis2Placement3D& in); -void ConvertAxisPlacement(aiMatrix4x4& out, const IFC::IfcAxis2Placement2D& in); +void ConvertAxisPlacement(aiMatrix4x4& out, const IfcAxis2Placement3D& in); +void ConvertAxisPlacement(aiMatrix4x4& out, const IfcAxis2Placement2D& in); void ConvertAxisPlacement(aiVector3D& axis, aiVector3D& pos, const IFC::IfcAxis1Placement& in); -void ConvertAxisPlacement(aiMatrix4x4& out, const IFC::IfcAxis2Placement& in, ConversionData& conv); -void ConvertTransformOperator(aiMatrix4x4& out, const IFC::IfcCartesianTransformationOperator& op); +void ConvertAxisPlacement(aiMatrix4x4& out, const IfcAxis2Placement& in, ConversionData& conv); +void ConvertTransformOperator(aiMatrix4x4& out, const IfcCartesianTransformationOperator& op); bool IsTrue(const EXPRESS::BOOLEAN& in); float ConvertSIPrefix(const std::string& prefix); @@ -188,6 +191,72 @@ unsigned int ProcessMaterials(const IFC::IfcRepresentationItem& item, Conversion bool ProcessRepresentationItem(const IfcRepresentationItem& item, std::vector& mesh_indices, ConversionData& conv); void AssignAddedMeshes(std::vector& mesh_indices,aiNode* nd,ConversionData& /*conv*/); + +// IFCCurve.cpp + +// ------------------------------------------------------------------------------------------------ +// Temporary representation for an arbitrary sub-class of IfcCurve. Used to sample the curves +// to obtain a list of line segments. +// ------------------------------------------------------------------------------------------------ +class Curve +{ +protected: + + Curve(const IfcCurve& base_entity, ConversionData& conv) + : base_entity(base_entity) + , conv(conv) + {} + +public: + + // evaluate the curve at the given parametric position + virtual aiVector3D Eval(float p) const = 0; + + // get the range of the curve (both inclusive). + // +inf and -inf are valid return values, the curve is not bounded in such a case. + virtual std::pair GetParametricRange() const = 0; + +public: + + static Curve* Convert(const IFC::IfcCurve&,ConversionData& conv); + +protected: + + const IfcCurve& base_entity; + ConversionData& conv; +}; + + +// -------------------------------------------------------------------------------- +// A BoundedCurve always holds the invariant that GetParametricRange() +// never returns infinite values. +// -------------------------------------------------------------------------------- +class BoundedCurve : public Curve +{ +public: + + BoundedCurve(const IfcBoundedCurve& entity, ConversionData& conv) + : Curve(entity,conv) + {} + +public: + + // given a point on the curve, suggest a suitable next point for + // discrete sampling. The returned parameter value should be + // based on two considerations: + // a) curve geometry is to be preserved + // b) detail level should be chosen based on importer settings + // and (possibly) importance and dimension of the spatial + // structure. + // return +inf if the suggestion is to stop sampling. + virtual float SuggestNext(float u) const; + + // intelligently sample the curve based on Eval() and SuggestNext() + void SampleDiscrete(TempMesh& out) const; +}; + + + } } diff --git a/workspaces/vc9/assimp.vcproj b/workspaces/vc9/assimp.vcproj index 5f2d9c5c4..6d1fb5197 100644 --- a/workspaces/vc9/assimp.vcproj +++ b/workspaces/vc9/assimp.vcproj @@ -714,6 +714,7 @@