@@ -34,8 +34,9 @@ using namespace IfcGeom::util;
3434
3535bool OpenCascadeKernel::convert (const taxonomy::sweep_along_curve::ptr scs, TopoDS_Shape& result) {
3636 auto w = convert_curve (scs->curve );
37- if (w.which () == 0 ) {
37+ if (w.which () != 2 ) {
3838 Logger::Error (" Unsupported directrix" );
39+ return false ;
3940 }
4041 TopoDS_Shape face;
4142 convert (taxonomy::cast<taxonomy::face>(scs->basis ), face);
@@ -136,6 +137,9 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo
136137 builder.SetMode (surface_face);
137138 }
138139 builder.Build ();
140+ if (!builder.IsDone ()) {
141+ return false ;
142+ }
139143 builder.MakeSolid ();
140144 result = builder.Shape ();
141145
@@ -144,12 +148,45 @@ bool OpenCascadeKernel::convert(const taxonomy::sweep_along_curve::ptr scs, Topo
144148
145149bool OpenCascadeKernel::convert_impl (const taxonomy::sweep_along_curve::ptr scs, IfcGeom::ConversionResults& results) {
146150 TopoDS_Shape shape;
151+ // For tiny radii occt will fail building the sweep, in which case we enlarge the inputs to occt, and add a scale matrix to the output
152+ bool enlarged = false ;
153+ static double enlarge_factor = 1000 .;
154+ if (scs->basis ->kind () == taxonomy::FACE) {
155+ auto w = std::static_pointer_cast<taxonomy::face>(scs->basis )->children [0 ];
156+ if (w->children .size () == 1 && w->children [0 ]->basis && w->children [0 ]->basis ->kind () == taxonomy::CIRCLE) {
157+ auto circ = std::static_pointer_cast<taxonomy::circle>(w->children [0 ]->basis );
158+ enlarged = circ->radius < 1 .e -4 ;
159+ if (enlarged) {
160+ // @todo immutability
161+ circ->radius *= enlarge_factor;
162+ auto crv = std::static_pointer_cast<taxonomy::geom_item>(scs->curve );
163+ if (crv->matrix ) {
164+ crv->matrix = taxonomy::make<taxonomy::matrix4>(
165+ Eigen::Scaling (enlarge_factor) *
166+ crv->matrix ->ccomponents ()
167+ );
168+ } else {
169+ crv->matrix = taxonomy::make<taxonomy::matrix4>();
170+ crv->matrix ->components ().topLeftCorner <3 , 3 >() = Eigen::Scaling (enlarge_factor, enlarge_factor, enlarge_factor).toDenseMatrix ();
171+ }
172+ }
173+ }
174+ }
147175 if (!convert (scs, shape)) {
148176 return false ;
149177 }
178+ taxonomy::matrix4::ptr m;
179+ if (enlarged) {
180+ m = taxonomy::make<taxonomy::matrix4>(
181+ Eigen::Scaling (1 . / enlarge_factor) *
182+ scs->matrix ->ccomponents ()
183+ );
184+ } else {
185+ m = scs->matrix ;
186+ }
150187 results.emplace_back (ConversionResult (
151188 scs->instance ->as <IfcUtil::IfcBaseEntity>()->id (),
152- scs-> matrix ,
189+ m ,
153190 new OpenCascadeShape (shape),
154191 scs->surface_style
155192 ));
0 commit comments