Skip to content

Commit

Permalink
small fixes in CurveConverter
Browse files Browse the repository at this point in the history
  • Loading branch information
ifcapps committed Aug 9, 2024
1 parent b7c10dd commit 3fa8947
Show file tree
Hide file tree
Showing 19 changed files with 1,587 additions and 1,545 deletions.
75 changes: 1 addition & 74 deletions IfcPlusPlus/src/external/Carve/src/include/carve/kd_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,81 +265,8 @@ class kd_node {
// distance_t must provide:
// double operator()(data_t, vector<ndim>);
// double operator()(axis_pos, vector<ndim>);
template <typename distance_t>
struct near_point_query {
// q_t - the priority queue value type.
// q_t.first: distance from object to query point.
// q_t.second: pointer to object
typedef std::pair<double, const data_t*> q_t;

// the queue priority should sort from smallest distance to largest, and on
// equal distance, by object pointer.
struct pcmp {
bool operator()(const q_t& a, const q_t& b) {
return (a.first > b.first) ||
((a.first == b.first) && (a.second < b.second));
}
};

vector<ndim> point;
const kd_node* node;
std::priority_queue<q_t, std::vector<q_t>, pcmp> pq;

distance_t dist;
double dist_to_parent_split;

void addToPQ(kd_node* node) {
if (node->c_neg) {
addToPQ(node->c_neg);
addToPQ(node->c_pos);
} else {
for (typename kd_node::container_t::const_iterator i =
node->data.begin();
i != node->data.end(); ++i) {
double d = dist((*i), point);
pq.push(std::make_pair(d, &(*i)));
}
}
}

const data_t* next() {
while (1) {
if (pq.size()) {
q_t t = pq.top();
if (!node->parent || t.first < dist_to_parent_split) {
pq.pop();
return t.second;
}
}

if (!node->parent) {
return NULL;
}


if (node->parent->c_neg == node) {
addToPQ(node->parent->c_pos);
} else {
addToPQ(node->parent->c_neg);
}

node = node->parent;
dist_to_parent_split = dist(node->splitpos, point);
}
}

near_point_query(const vector<ndim> _point, const kd_node* _node)
: point(_point), node(_node), pq(), dist() {
while (node->c_neg) {
node = (point[node->axis] < node->pos) ? node->c_neg : node->c_pos;
}
if (node->parent) {
dist_to_parent_split = dist(node->parent->splitpos, point);
} else {
dist_to_parent_split = HUGE_VAL;
}
addToPQ(node);
}
};
};
} // namespace geom
} // namespace carve
2 changes: 1 addition & 1 deletion IfcPlusPlus/src/external/Carve/src/include/carve/rtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <carve/geom.hpp>

#include <iostream>

#include <cstdint>
#include <cmath>
#include <limits>

Expand Down
1,758 changes: 879 additions & 879 deletions IfcPlusPlus/src/ifcpp/IFC4X3/EntityFactory.h

Large diffs are not rendered by default.

880 changes: 440 additions & 440 deletions IfcPlusPlus/src/ifcpp/IFC4X3/TypeFactory.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions IfcPlusPlus/src/ifcpp/geometry/CSG_Adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ bool CSG_Adapter::computeCSG_Carve(const shared_ptr<carve::mesh::MeshSet<3> >& i
bool operandA_dumped = false;
bool operandB_dumped = false;
bool dump_result_mesh = false;

if(false)
{
if (5598 == tag || !infoInputA.meshSetValid)
{
Expand Down Expand Up @@ -763,7 +763,7 @@ bool CSG_Adapter::computeCSG_Carve(const shared_ptr<carve::mesh::MeshSet<3> >& i

if (!result_valid_2)
{
std::cout << "!result" << std::endl;
std::cout << __FUNCTION__ << ": !result_valid_2" << std::endl;
}
}
#endif
Expand Down
11 changes: 5 additions & 6 deletions IfcPlusPlus/src/ifcpp/geometry/ConverterOSG.h
Original file line number Diff line number Diff line change
Expand Up @@ -839,13 +839,12 @@ class ConverterOSG : public StatusCallback
double epsCoplanarFacesAngle = eps;
double minFaceArea = eps;
bool dumpMeshes = false;
PolyInputCache3D polyTriangulated;
GeomProcessingParams params(m_geom_settings, dumpMeshes);
PolyInputCache3D poly(0.001);
MeshOps::retriangulateMeshSetForExport(item_meshset, poly, params);
MeshOps::retriangulateMeshSetForExport(item_meshset, polyTriangulated, params);

std::map<std::string, std::string> mesh_input_options;
shared_ptr<carve::mesh::MeshSet<3> > meshsetTriangulated(poly.m_poly_data->createMesh(mesh_input_options, eps));

shared_ptr<carve::mesh::MeshSet<3> > meshsetTriangulated(polyTriangulated.m_poly_data->createMesh(mesh_input_options, EPS_M7));
drawMeshSet(meshsetTriangulated, geode, crease_angle, min_triangle_area, false, disableBackfaceCulling);

if (m_render_crease_edges)
Expand All @@ -864,7 +863,7 @@ class ConverterOSG : public StatusCallback
#ifdef _DEBUG
//vec4 color(0.6f, 0.6f, 0.6f, 0.1f);
//GeomDebugDump::moveOffset(1);
//GeomDebugDump::dumpMeshset(meshsetTriangulated, color, false, true, true);
//GeomDebugDump::dumpMeshset(item_meshset, color, false, true, true);
#endif
}
}
Expand All @@ -891,7 +890,7 @@ class ConverterOSG : public StatusCallback

#ifdef _DEBUG
int tag = ifc_product->m_tag;
if (product_guid.compare("3WMG3ehJnBiu4F_L5ltNmO") == 0 || ifc_product->classID() == IFC4X3::IFCWINDOW)
if (product_guid.compare("3WMG3ehJnBiu4F_L5ltNmO") == 0 || ifc_product->classID() == IFCWINDOW)
{
int wait = 0;
}
Expand Down
Loading

0 comments on commit 3fa8947

Please sign in to comment.