IFCCurve.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2016, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. /** @file IFCProfile.cpp
  34. * @brief Read profile and curves entities from IFC files
  35. */
  36. #ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
  37. #include "IFCUtil.h"
  38. namespace Assimp {
  39. namespace IFC {
  40. namespace {
  41. // --------------------------------------------------------------------------------
  42. // Conic is the base class for Circle and Ellipse
  43. // --------------------------------------------------------------------------------
  44. class Conic : public Curve
  45. {
  46. public:
  47. // --------------------------------------------------
  48. Conic(const IfcConic& entity, ConversionData& conv)
  49. : Curve(entity,conv)
  50. {
  51. IfcMatrix4 trafo;
  52. ConvertAxisPlacement(trafo,*entity.Position,conv);
  53. // for convenience, extract the matrix rows
  54. location = IfcVector3(trafo.a4,trafo.b4,trafo.c4);
  55. p[0] = IfcVector3(trafo.a1,trafo.b1,trafo.c1);
  56. p[1] = IfcVector3(trafo.a2,trafo.b2,trafo.c2);
  57. p[2] = IfcVector3(trafo.a3,trafo.b3,trafo.c3);
  58. }
  59. public:
  60. // --------------------------------------------------
  61. bool IsClosed() const {
  62. return true;
  63. }
  64. // --------------------------------------------------
  65. size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const {
  66. ai_assert(InRange(a) && InRange(b));
  67. a *= conv.angle_scale;
  68. b *= conv.angle_scale;
  69. a = std::fmod(a,static_cast<IfcFloat>( AI_MATH_TWO_PI ));
  70. b = std::fmod(b,static_cast<IfcFloat>( AI_MATH_TWO_PI ));
  71. const IfcFloat setting = static_cast<IfcFloat>( AI_MATH_PI * conv.settings.conicSamplingAngle / 180.0 );
  72. return static_cast<size_t>( std::ceil(std::abs( b-a)) / setting);
  73. }
  74. // --------------------------------------------------
  75. ParamRange GetParametricRange() const {
  76. return std::make_pair(static_cast<IfcFloat>( 0. ), static_cast<IfcFloat>( AI_MATH_TWO_PI / conv.angle_scale ));
  77. }
  78. protected:
  79. IfcVector3 location, p[3];
  80. };
  81. // --------------------------------------------------------------------------------
  82. // Circle
  83. // --------------------------------------------------------------------------------
  84. class Circle : public Conic
  85. {
  86. public:
  87. // --------------------------------------------------
  88. Circle(const IfcCircle& entity, ConversionData& conv)
  89. : Conic(entity,conv)
  90. , entity(entity)
  91. {
  92. }
  93. public:
  94. // --------------------------------------------------
  95. IfcVector3 Eval(IfcFloat u) const {
  96. u = -conv.angle_scale * u;
  97. return location + static_cast<IfcFloat>(entity.Radius)*(static_cast<IfcFloat>(std::cos(u))*p[0] +
  98. static_cast<IfcFloat>(std::sin(u))*p[1]);
  99. }
  100. private:
  101. const IfcCircle& entity;
  102. };
  103. // --------------------------------------------------------------------------------
  104. // Ellipse
  105. // --------------------------------------------------------------------------------
  106. class Ellipse : public Conic
  107. {
  108. public:
  109. // --------------------------------------------------
  110. Ellipse(const IfcEllipse& entity, ConversionData& conv)
  111. : Conic(entity,conv)
  112. , entity(entity)
  113. {
  114. }
  115. public:
  116. // --------------------------------------------------
  117. IfcVector3 Eval(IfcFloat u) const {
  118. u = -conv.angle_scale * u;
  119. return location + static_cast<IfcFloat>(entity.SemiAxis1)*static_cast<IfcFloat>(std::cos(u))*p[0] +
  120. static_cast<IfcFloat>(entity.SemiAxis2)*static_cast<IfcFloat>(std::sin(u))*p[1];
  121. }
  122. private:
  123. const IfcEllipse& entity;
  124. };
  125. // --------------------------------------------------------------------------------
  126. // Line
  127. // --------------------------------------------------------------------------------
  128. class Line : public Curve
  129. {
  130. public:
  131. // --------------------------------------------------
  132. Line(const IfcLine& entity, ConversionData& conv)
  133. : Curve(entity,conv)
  134. {
  135. ConvertCartesianPoint(p,entity.Pnt);
  136. ConvertVector(v,entity.Dir);
  137. }
  138. public:
  139. // --------------------------------------------------
  140. bool IsClosed() const {
  141. return false;
  142. }
  143. // --------------------------------------------------
  144. IfcVector3 Eval(IfcFloat u) const {
  145. return p + u*v;
  146. }
  147. // --------------------------------------------------
  148. size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const {
  149. ai_assert(InRange(a) && InRange(b));
  150. // two points are always sufficient for a line segment
  151. return a==b ? 1 : 2;
  152. }
  153. // --------------------------------------------------
  154. void SampleDiscrete(TempMesh& out,IfcFloat a, IfcFloat b) const
  155. {
  156. ai_assert(InRange(a) && InRange(b));
  157. if (a == b) {
  158. out.verts.push_back(Eval(a));
  159. return;
  160. }
  161. out.verts.reserve(out.verts.size()+2);
  162. out.verts.push_back(Eval(a));
  163. out.verts.push_back(Eval(b));
  164. }
  165. // --------------------------------------------------
  166. ParamRange GetParametricRange() const {
  167. const IfcFloat inf = std::numeric_limits<IfcFloat>::infinity();
  168. return std::make_pair(-inf,+inf);
  169. }
  170. private:
  171. IfcVector3 p,v;
  172. };
  173. // --------------------------------------------------------------------------------
  174. // CompositeCurve joins multiple smaller, bounded curves
  175. // --------------------------------------------------------------------------------
  176. class CompositeCurve : public BoundedCurve
  177. {
  178. typedef std::pair< std::shared_ptr< BoundedCurve >, bool > CurveEntry;
  179. public:
  180. // --------------------------------------------------
  181. CompositeCurve(const IfcCompositeCurve& entity, ConversionData& conv)
  182. : BoundedCurve(entity,conv)
  183. , total()
  184. {
  185. curves.reserve(entity.Segments.size());
  186. for(const IfcCompositeCurveSegment& curveSegment :entity.Segments) {
  187. // according to the specification, this must be a bounded curve
  188. std::shared_ptr< Curve > cv(Curve::Convert(curveSegment.ParentCurve,conv));
  189. std::shared_ptr< BoundedCurve > bc = std::dynamic_pointer_cast<BoundedCurve>(cv);
  190. if (!bc) {
  191. IFCImporter::LogError("expected segment of composite curve to be a bounded curve");
  192. continue;
  193. }
  194. if ( (std::string)curveSegment.Transition != "CONTINUOUS" ) {
  195. IFCImporter::LogDebug("ignoring transition code on composite curve segment, only continuous transitions are supported");
  196. }
  197. curves.push_back( CurveEntry(bc,IsTrue(curveSegment.SameSense)) );
  198. total += bc->GetParametricRangeDelta();
  199. }
  200. if (curves.empty()) {
  201. throw CurveError("empty composite curve");
  202. }
  203. }
  204. public:
  205. // --------------------------------------------------
  206. IfcVector3 Eval(IfcFloat u) const {
  207. if (curves.empty()) {
  208. return IfcVector3();
  209. }
  210. IfcFloat acc = 0;
  211. for(const CurveEntry& entry : curves) {
  212. const ParamRange& range = entry.first->GetParametricRange();
  213. const IfcFloat delta = std::abs(range.second-range.first);
  214. if (u < acc+delta) {
  215. return entry.first->Eval( entry.second ? (u-acc) + range.first : range.second-(u-acc));
  216. }
  217. acc += delta;
  218. }
  219. // clamp to end
  220. return curves.back().first->Eval(curves.back().first->GetParametricRange().second);
  221. }
  222. // --------------------------------------------------
  223. size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const {
  224. ai_assert(InRange(a) && InRange(b));
  225. size_t cnt = 0;
  226. IfcFloat acc = 0;
  227. for(const CurveEntry& entry : curves) {
  228. const ParamRange& range = entry.first->GetParametricRange();
  229. const IfcFloat delta = std::abs(range.second-range.first);
  230. if (a <= acc+delta && b >= acc) {
  231. const IfcFloat at = std::max(static_cast<IfcFloat>( 0. ),a-acc), bt = std::min(delta,b-acc);
  232. cnt += entry.first->EstimateSampleCount( entry.second ? at + range.first : range.second - bt, entry.second ? bt + range.first : range.second - at );
  233. }
  234. acc += delta;
  235. }
  236. return cnt;
  237. }
  238. // --------------------------------------------------
  239. void SampleDiscrete(TempMesh& out,IfcFloat a, IfcFloat b) const
  240. {
  241. ai_assert(InRange(a) && InRange(b));
  242. const size_t cnt = EstimateSampleCount(a,b);
  243. out.verts.reserve(out.verts.size() + cnt);
  244. for(const CurveEntry& entry : curves) {
  245. const size_t cnt = out.verts.size();
  246. entry.first->SampleDiscrete(out);
  247. if (!entry.second && cnt != out.verts.size()) {
  248. std::reverse(out.verts.begin()+cnt,out.verts.end());
  249. }
  250. }
  251. }
  252. // --------------------------------------------------
  253. ParamRange GetParametricRange() const {
  254. return std::make_pair(static_cast<IfcFloat>( 0. ),total);
  255. }
  256. private:
  257. std::vector< CurveEntry > curves;
  258. IfcFloat total;
  259. };
  260. // --------------------------------------------------------------------------------
  261. // TrimmedCurve can be used to trim an unbounded curve to a bounded range
  262. // --------------------------------------------------------------------------------
  263. class TrimmedCurve : public BoundedCurve
  264. {
  265. public:
  266. // --------------------------------------------------
  267. TrimmedCurve(const IfcTrimmedCurve& entity, ConversionData& conv)
  268. : BoundedCurve(entity,conv)
  269. {
  270. base = std::shared_ptr<const Curve>(Curve::Convert(entity.BasisCurve,conv));
  271. typedef std::shared_ptr<const STEP::EXPRESS::DataType> Entry;
  272. // for some reason, trimmed curves can either specify a parametric value
  273. // or a point on the curve, or both. And they can even specify which of the
  274. // two representations they prefer, even though an information invariant
  275. // claims that they must be identical if both are present.
  276. // oh well.
  277. bool have_param = false, have_point = false;
  278. IfcVector3 point;
  279. for(const Entry sel :entity.Trim1) {
  280. if (const EXPRESS::REAL* const r = sel->ToPtr<EXPRESS::REAL>()) {
  281. range.first = *r;
  282. have_param = true;
  283. break;
  284. }
  285. else if (const IfcCartesianPoint* const r = sel->ResolveSelectPtr<IfcCartesianPoint>(conv.db)) {
  286. ConvertCartesianPoint(point,*r);
  287. have_point = true;
  288. }
  289. }
  290. if (!have_param) {
  291. if (!have_point || !base->ReverseEval(point,range.first)) {
  292. throw CurveError("IfcTrimmedCurve: failed to read first trim parameter, ignoring curve");
  293. }
  294. }
  295. have_param = false, have_point = false;
  296. for(const Entry sel :entity.Trim2) {
  297. if (const EXPRESS::REAL* const r = sel->ToPtr<EXPRESS::REAL>()) {
  298. range.second = *r;
  299. have_param = true;
  300. break;
  301. }
  302. else if (const IfcCartesianPoint* const r = sel->ResolveSelectPtr<IfcCartesianPoint>(conv.db)) {
  303. ConvertCartesianPoint(point,*r);
  304. have_point = true;
  305. }
  306. }
  307. if (!have_param) {
  308. if (!have_point || !base->ReverseEval(point,range.second)) {
  309. throw CurveError("IfcTrimmedCurve: failed to read second trim parameter, ignoring curve");
  310. }
  311. }
  312. agree_sense = IsTrue(entity.SenseAgreement);
  313. if( !agree_sense ) {
  314. std::swap(range.first,range.second);
  315. }
  316. // "NOTE In case of a closed curve, it may be necessary to increment t1 or t2
  317. // by the parametric length for consistency with the sense flag."
  318. if (base->IsClosed()) {
  319. if( range.first > range.second ) {
  320. range.second += base->GetParametricRangeDelta();
  321. }
  322. }
  323. maxval = range.second-range.first;
  324. ai_assert(maxval >= 0);
  325. }
  326. public:
  327. // --------------------------------------------------
  328. IfcVector3 Eval(IfcFloat p) const {
  329. ai_assert(InRange(p));
  330. return base->Eval( TrimParam(p) );
  331. }
  332. // --------------------------------------------------
  333. size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const {
  334. ai_assert(InRange(a) && InRange(b));
  335. return base->EstimateSampleCount(TrimParam(a),TrimParam(b));
  336. }
  337. // --------------------------------------------------
  338. void SampleDiscrete(TempMesh& out,IfcFloat a,IfcFloat b) const {
  339. ai_assert(InRange(a) && InRange(b));
  340. return base->SampleDiscrete(out,TrimParam(a),TrimParam(b));
  341. }
  342. // --------------------------------------------------
  343. ParamRange GetParametricRange() const {
  344. return std::make_pair(static_cast<IfcFloat>( 0. ),maxval);
  345. }
  346. private:
  347. // --------------------------------------------------
  348. IfcFloat TrimParam(IfcFloat f) const {
  349. return agree_sense ? f + range.first : range.second - f;
  350. }
  351. private:
  352. ParamRange range;
  353. IfcFloat maxval;
  354. bool agree_sense;
  355. std::shared_ptr<const Curve> base;
  356. };
  357. // --------------------------------------------------------------------------------
  358. // PolyLine is a 'curve' defined by linear interpolation over a set of discrete points
  359. // --------------------------------------------------------------------------------
  360. class PolyLine : public BoundedCurve
  361. {
  362. public:
  363. // --------------------------------------------------
  364. PolyLine(const IfcPolyline& entity, ConversionData& conv)
  365. : BoundedCurve(entity,conv)
  366. {
  367. points.reserve(entity.Points.size());
  368. IfcVector3 t;
  369. for(const IfcCartesianPoint& cp : entity.Points) {
  370. ConvertCartesianPoint(t,cp);
  371. points.push_back(t);
  372. }
  373. }
  374. public:
  375. // --------------------------------------------------
  376. IfcVector3 Eval(IfcFloat p) const {
  377. ai_assert(InRange(p));
  378. const size_t b = static_cast<size_t>(std::floor(p));
  379. if (b == points.size()-1) {
  380. return points.back();
  381. }
  382. const IfcFloat d = p-static_cast<IfcFloat>(b);
  383. return points[b+1] * d + points[b] * (static_cast<IfcFloat>( 1. )-d);
  384. }
  385. // --------------------------------------------------
  386. size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const {
  387. ai_assert(InRange(a) && InRange(b));
  388. return static_cast<size_t>( std::ceil(b) - std::floor(a) );
  389. }
  390. // --------------------------------------------------
  391. ParamRange GetParametricRange() const {
  392. return std::make_pair(static_cast<IfcFloat>( 0. ),static_cast<IfcFloat>(points.size()-1));
  393. }
  394. private:
  395. std::vector<IfcVector3> points;
  396. };
  397. } // anon
  398. // ------------------------------------------------------------------------------------------------
  399. Curve* Curve :: Convert(const IFC::IfcCurve& curve,ConversionData& conv)
  400. {
  401. if(curve.ToPtr<IfcBoundedCurve>()) {
  402. if(const IfcPolyline* c = curve.ToPtr<IfcPolyline>()) {
  403. return new PolyLine(*c,conv);
  404. }
  405. if(const IfcTrimmedCurve* c = curve.ToPtr<IfcTrimmedCurve>()) {
  406. return new TrimmedCurve(*c,conv);
  407. }
  408. if(const IfcCompositeCurve* c = curve.ToPtr<IfcCompositeCurve>()) {
  409. return new CompositeCurve(*c,conv);
  410. }
  411. //if(const IfcBSplineCurve* c = curve.ToPtr<IfcBSplineCurve>()) {
  412. // return new BSplineCurve(*c,conv);
  413. //}
  414. }
  415. if(curve.ToPtr<IfcConic>()) {
  416. if(const IfcCircle* c = curve.ToPtr<IfcCircle>()) {
  417. return new Circle(*c,conv);
  418. }
  419. if(const IfcEllipse* c = curve.ToPtr<IfcEllipse>()) {
  420. return new Ellipse(*c,conv);
  421. }
  422. }
  423. if(const IfcLine* c = curve.ToPtr<IfcLine>()) {
  424. return new Line(*c,conv);
  425. }
  426. // XXX OffsetCurve2D, OffsetCurve3D not currently supported
  427. return NULL;
  428. }
  429. #ifdef ASSIMP_BUILD_DEBUG
  430. // ------------------------------------------------------------------------------------------------
  431. bool Curve :: InRange(IfcFloat u) const
  432. {
  433. const ParamRange range = GetParametricRange();
  434. if (IsClosed()) {
  435. return true;
  436. //ai_assert(range.first != std::numeric_limits<IfcFloat>::infinity() && range.second != std::numeric_limits<IfcFloat>::infinity());
  437. //u = range.first + std::fmod(u-range.first,range.second-range.first);
  438. }
  439. const IfcFloat epsilon = 1e-5;
  440. return u - range.first > -epsilon && range.second - u > -epsilon;
  441. }
  442. #endif
  443. // ------------------------------------------------------------------------------------------------
  444. IfcFloat Curve :: GetParametricRangeDelta() const
  445. {
  446. const ParamRange& range = GetParametricRange();
  447. return std::abs(range.second - range.first);
  448. }
  449. // ------------------------------------------------------------------------------------------------
  450. size_t Curve :: EstimateSampleCount(IfcFloat a, IfcFloat b) const
  451. {
  452. ai_assert(InRange(a) && InRange(b));
  453. // arbitrary default value, deriving classes should supply better suited values
  454. return 16;
  455. }
  456. // ------------------------------------------------------------------------------------------------
  457. IfcFloat RecursiveSearch(const Curve* cv, const IfcVector3& val, IfcFloat a, IfcFloat b, unsigned int samples, IfcFloat threshold, unsigned int recurse = 0, unsigned int max_recurse = 15)
  458. {
  459. ai_assert(samples>1);
  460. const IfcFloat delta = (b-a)/samples, inf = std::numeric_limits<IfcFloat>::infinity();
  461. IfcFloat min_point[2] = {a,b}, min_diff[2] = {inf,inf};
  462. IfcFloat runner = a;
  463. for (unsigned int i = 0; i < samples; ++i, runner += delta) {
  464. const IfcFloat diff = (cv->Eval(runner)-val).SquareLength();
  465. if (diff < min_diff[0]) {
  466. min_diff[1] = min_diff[0];
  467. min_point[1] = min_point[0];
  468. min_diff[0] = diff;
  469. min_point[0] = runner;
  470. }
  471. else if (diff < min_diff[1]) {
  472. min_diff[1] = diff;
  473. min_point[1] = runner;
  474. }
  475. }
  476. ai_assert(min_diff[0] != inf && min_diff[1] != inf);
  477. if ( std::fabs(a-min_point[0]) < threshold || recurse >= max_recurse) {
  478. return min_point[0];
  479. }
  480. // fix for closed curves to take their wrap-over into account
  481. if (cv->IsClosed() && std::fabs(min_point[0]-min_point[1]) > cv->GetParametricRangeDelta()*0.5 ) {
  482. const Curve::ParamRange& range = cv->GetParametricRange();
  483. const IfcFloat wrapdiff = (cv->Eval(range.first)-val).SquareLength();
  484. if (wrapdiff < min_diff[0]) {
  485. const IfcFloat t = min_point[0];
  486. min_point[0] = min_point[1] > min_point[0] ? range.first : range.second;
  487. min_point[1] = t;
  488. }
  489. }
  490. return RecursiveSearch(cv,val,min_point[0],min_point[1],samples,threshold,recurse+1,max_recurse);
  491. }
  492. // ------------------------------------------------------------------------------------------------
  493. bool Curve :: ReverseEval(const IfcVector3& val, IfcFloat& paramOut) const
  494. {
  495. // note: the following algorithm is not guaranteed to find the 'right' parameter value
  496. // in all possible cases, but it will always return at least some value so this function
  497. // will never fail in the default implementation.
  498. // XXX derive threshold from curve topology
  499. const IfcFloat threshold = 1e-4f;
  500. const unsigned int samples = 16;
  501. const ParamRange& range = GetParametricRange();
  502. paramOut = RecursiveSearch(this,val,range.first,range.second,samples,threshold);
  503. return true;
  504. }
  505. // ------------------------------------------------------------------------------------------------
  506. void Curve :: SampleDiscrete(TempMesh& out,IfcFloat a, IfcFloat b) const
  507. {
  508. ai_assert(InRange(a) && InRange(b));
  509. const size_t cnt = std::max(static_cast<size_t>(0),EstimateSampleCount(a,b));
  510. out.verts.reserve( out.verts.size() + cnt + 1);
  511. IfcFloat p = a, delta = (b-a)/cnt;
  512. for(size_t i = 0; i <= cnt; ++i, p += delta) {
  513. out.verts.push_back(Eval(p));
  514. }
  515. }
  516. // ------------------------------------------------------------------------------------------------
  517. bool BoundedCurve :: IsClosed() const
  518. {
  519. return false;
  520. }
  521. // ------------------------------------------------------------------------------------------------
  522. void BoundedCurve :: SampleDiscrete(TempMesh& out) const
  523. {
  524. const ParamRange& range = GetParametricRange();
  525. ai_assert(range.first != std::numeric_limits<IfcFloat>::infinity() && range.second != std::numeric_limits<IfcFloat>::infinity());
  526. return SampleDiscrete(out,range.first,range.second);
  527. }
  528. } // IFC
  529. } // Assimp
  530. #endif // ASSIMP_BUILD_NO_IFC_IMPORTER