MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / convert

Method convert

src/ifcgeom/kernels/cgal/CgalKernel.cpp:161–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159#endif
160
161bool CgalKernel::convert(const taxonomy::shell::ptr l, cgal_shape_t& shape) {
162 for (auto& f : l->children) {
163 if (f->basis && f->basis->kind() != taxonomy::PLANE) {
164 Logger::Error("CGAL Kernel: Non-planar faces not supported at the moment");
165 throw not_supported_error();
166 }
167 for (auto& w : f->children) {
168 for (auto& e : w->children) {
169 if (e->basis && e->basis->kind() == taxonomy::BSPLINE_CURVE) {
170 Logger::Error("CGAL Kernel: B-spline edge curves not supported at the moment");
171 throw not_supported_error();
172 }
173 }
174 }
175 }
176 if (false && l->children.size() > 100) {
177 static double inf = 1.e9; // std::numeric_limits<double>::infinity();
178 std::pair<Eigen::Vector3d, Eigen::Vector3d> minmax(
179 Eigen::Vector3d(+inf, +inf, +inf),
180 Eigen::Vector3d(-inf, -inf, -inf)
181 );
182 size_t num_points = 0;
183 visit_2<taxonomy::point3, taxonomy::shell>(l, [&minmax, &num_points](const taxonomy::point3::ptr p) {
184 auto& c = p->ccomponents();
185 ++num_points;
186 for (int i = 0; i < 3; ++i) {
187 if (c(i) < minmax.first(i)) {
188 minmax.first(i) = c(i);
189 }
190 if (c(i) > minmax.second(i)) {
191 minmax.second(i) = c(i);
192 }
193 }
194 });
195 auto diag = minmax.second - minmax.first;
196 double volume = diag(0) * diag(1) * diag(2);
197 // @todo volume van be zero also..
198 double density = num_points / volume;
199 Logger::Notice("Density " + boost::lexical_cast<std::string>(density), l->instance);
200 if (density > 5000) {
201 Logger::Notice("Substituted element with " + boost::lexical_cast<std::string>(density) + " vertices / m3 with a bounding box");
202 CGAL::Point_3<Kernel_> lower(minmax.first(0), minmax.first(1), minmax.first(2));
203 CGAL::Point_3<Kernel_> upper(minmax.second(0), minmax.second(1), minmax.second(2));
204 shape = utils::create_cube(lower, upper);
205 return true;
206 }
207 }
208
209 std::list<cgal_face_t> face_list;
210 for (auto& f : l->children) {
211 bool success = false;
212 try {
213 success = convert(f, face_list);
214 } catch (...) {}
215
216 if (!success) {
217 Logger::Message(Logger::LOG_WARNING, "Failed to convert face:", f->instance);
218 continue;

Callers

nothing calls this directly

Calls 15

NoticeFunction · 0.85
convertFunction · 0.85
MessageClass · 0.85
convert_curveFunction · 0.85
reverseFunction · 0.85
extend_wireFunction · 0.85
WarningFunction · 0.85
loop_to_segmentsFunction · 0.85
do_segments_intersectFunction · 0.85
push_backMethod · 0.80
normMethod · 0.80
to_doubleFunction · 0.70

Tested by

no test coverage detected