Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
77127a0
UPDATE: joint detector adapted for cylinders
DamienGilliard Aug 17, 2024
106e4c4
FIX-UPDATE: return tuple with right values
DamienGilliard Aug 21, 2024
b264a3a
UPDATE: add flag to DFAssembly and DFBeam for log cases
DamienGilliard Aug 21, 2024
c1b49d4
FIX: comment-out if __name__ part
DamienGilliard Aug 21, 2024
8d4b559
WIP: GetCylinderCenterAndAxis method added to DFMesh
DamienGilliard Aug 21, 2024
1531211
WIP-UPDATE: add cylinder case to associateClusters methods.
DamienGilliard Aug 22, 2024
9850851
WIP-UPDATE: implement changes between cases with and without cylinder…
DamienGilliard Aug 22, 2024
7d89b06
UPDATE: update binding to add is_cylinder parameter to segmentation m…
DamienGilliard Aug 27, 2024
f4c067d
FIX: __init__.py imports the binding as well
DamienGilliard Aug 27, 2024
dae8a0b
WIP: cylinder segmentation now without IsPointOnFace check, because n…
DamienGilliard Aug 31, 2024
1d13587
Merge branch 'main' into cylinder_beam
DamienGilliard Aug 31, 2024
21e7c6e
UPDATE: joint detector more robust in the adjacency face calculation
DamienGilliard Sep 2, 2024
7a4ee73
UPDATE: add merge_shared_index method to df_utils to be used by df_jo…
DamienGilliard Sep 2, 2024
46d1249
FIX: remove commented-out code for component testing
DamienGilliard Sep 2, 2024
4ea1e26
FIX: update diffCheckApp.cc
DamienGilliard Sep 2, 2024
fdd13a3
FIX: applying changes from pre-commit
DamienGilliard Sep 2, 2024
8a9be07
FIX: forgot a file in pre-commit file adding in previous commit
DamienGilliard Sep 2, 2024
7540d8b
UPDATE: IsPointOnFace method optimized
DamienGilliard Sep 3, 2024
e04fe70
UPDATE: Small adaptation for cylinder case in DFSegmentation, integra…
DamienGilliard Sep 3, 2024
4bb9b34
UPDATE: code.py of segmentation component cleaned
DamienGilliard Sep 3, 2024
407ce16
FIX: is_cylinder property of DFBeam properly handled
DamienGilliard Sep 3, 2024
e6199c1
UPDATE: is_cylinder_beam function more robust
DamienGilliard Sep 3, 2024
4387e4d
UPDATE: general cleanup from pre-commit
DamienGilliard Sep 3, 2024
b436598
FIX: small changes to component code to properly generate and handle …
DamienGilliard Sep 3, 2024
298bf10
FIX: line in documentation accidentally deleted
DamienGilliard Sep 3, 2024
7a805e2
FIX: joint_detector now excludes 'cylindrical' faces from joints
DamienGilliard Sep 12, 2024
16a7966
Merge branch 'main' into cylinder_beam
DamienGilliard Sep 12, 2024
e46a8a1
WIP-UPDATE: joint detector more robust for corner log case
DamienGilliard Sep 19, 2024
18d66b6
ADD: DFMergeAssemblies component created
DamienGilliard Sep 21, 2024
abe3f61
UPDATE-WIP: add is_cylinder parameter to BuildAssembly component
DamienGilliard Sep 21, 2024
d40e4ed
WIP-UPDATE: Adaptations to semantic segmentation pipeline to improve …
DamienGilliard Sep 21, 2024
73ab8ec
UPDATE: cleaner CAD_segmentator component code
DamienGilliard Sep 22, 2024
55a844f
FIX: colors appended together with point and normals + merge shenanigans
DamienGilliard Sep 22, 2024
ec79524
FIX: name of input parameter of DFMergeAssemblies in metadata.json [n…
DamienGilliard Sep 22, 2024
959630a
FIX: CleanUnassociatedClusters better integrated so it daly with comp…
DamienGilliard Sep 22, 2024
c4ebde6
ADD Documentation for merrge assemblies
DamienGilliard Sep 22, 2024
602756d
FIX: underlining of title set to correct length [no ci]
DamienGilliard Sep 22, 2024
c259efa
FIX: Typo in rst file + issues with naming convention and commented-o…
DamienGilliard Sep 23, 2024
992a96a
FIX: naming of functions and switch from 'is_cylinder' to 'is_roundwood'
DamienGilliard Sep 23, 2024
1f1e22e
FIX: naming of functions and switch from 'is_cylinder' to 'is_roundwood'
DamienGilliard Sep 23, 2024
d12a1e8
FIX: df_joint_detector excludes non planar joint faces in squared bea…
DamienGilliard Sep 23, 2024
5e7d71b
FIX: forgotten chsnge of method name
DamienGilliard Sep 23, 2024
057ee36
FIX: indent mistake in df_joint_detector.py
DamienGilliard Sep 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/gh_DFMergeAssemblies.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. image:: ../src/gh/components/DF_merge_assemblies/icon.png
:align: left
:width: 40px

``DFMergeAssemblies`` component
===============================

.. ghcomponent_to_rst:: ../src/gh/components/DF_merge_assemblies
7 changes: 6 additions & 1 deletion doc/gh_components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ DF has a Grasshopper_ plugin with a set of components that allows the user to in
- .. image:: ../src/gh/components/DF_remove_statistical_outliers/icon.png
- `gh_DFRemoveStatisticalOutliers <gh_DFRemoveStatisticalOutliers.html>`_

* - .. image:: ../src/gh/components/DF_merge_assemblies/icon.png
- `gh_DFMergeAssemblies <gh_DFMergeAssemblies.html>`_
-
-


.. toctree::
Expand Down Expand Up @@ -114,4 +118,5 @@ DF has a Grasshopper_ plugin with a set of components that allows the user to in
gh_DFRemoveBeam
gh_DFColorizeCloud
gh_DFBrepToCloud
gh_DFRemoveStatisticalOutliers
gh_DFRemoveStatisticalOutliers
gh_DFMergeAssemblies
64 changes: 50 additions & 14 deletions src/diffCheck/geometry/DFMesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,31 +112,67 @@ namespace diffCheck::geometry
Eigen::Vector3d v1 = this->Vertices[triangle[1]];
Eigen::Vector3d v2 = this->Vertices[triangle[2]];
Eigen::Vector3d n = (v1 - v0).cross(v2 - v0);
double normOfNormal = n.norm();
n.normalize();

Eigen::Vector3d projectedPoint = point - n * (n.dot(point - v0)) ;
// Project the point onto the plane of the triangle
Eigen::Vector3d projectedPoint = point - n * (n.dot(point - v0));

double referenceTriangleArea = normOfNormal*0.5;
Eigen::Vector3d n1 = (v1 - v0).cross(projectedPoint - v0);
double area1 = n1.norm()*0.5;
Eigen::Vector3d n2 = (v2 - v1).cross(projectedPoint - v1);
double area2 = n2.norm()*0.5;
Eigen::Vector3d n3 = (v0 - v2).cross(projectedPoint - v2);
double area3 = n3.norm()*0.5;
double res = (area1 + area2 + area3 - referenceTriangleArea) / referenceTriangleArea;
// Compute vectors
Eigen::Vector3d v0v1 = v1 - v0;
Eigen::Vector3d v0v2 = v2 - v0;
Eigen::Vector3d v0p = projectedPoint - v0;

// arbitrary value to avoid false positives (points that, when projected on the triangle, are in it, but that are actually located too far from the mesh to actually belong to it)
double maxProjectionDistance = std::min({(v1 - v0).norm(), (v2 - v1).norm(), (v0 - v2).norm()}) / 2;
// Compute dot products
double dot00 = v0v2.dot(v0v2);
double dot01 = v0v2.dot(v0v1);
double dot02 = v0v2.dot(v0p);
double dot11 = v0v1.dot(v0v1);
double dot12 = v0v1.dot(v0p);

if (std::abs(res) < associationThreshold && (projectedPoint - point).norm() < maxProjectionDistance)
// Compute barycentric coordinates
double invDenom = 1.0 / (dot00 * dot11 - dot01 * dot01);
double u = (dot11 * dot02 - dot01 * dot12) * invDenom;
double v = (dot00 * dot12 - dot01 * dot02) * invDenom;

// Check if point is in triangle
if ((u >= -associationThreshold) && (v >= -associationThreshold) && (u + v <= 1 + associationThreshold))
{
return true;
// Check if the point is close enough to the face
double maxProjectionDistance = std::min({(v1 - v0).norm(), (v2 - v1).norm(), (v0 - v2).norm()}) ;
if ((projectedPoint - point).norm() < maxProjectionDistance)
{
return true;
}
}
}
return false;
}

std::tuple<Eigen::Vector3d, Eigen::Vector3d> DFMesh::ComputeOBBCenterAndAxis()
{
Eigen::Vector3d center = Eigen::Vector3d::Zero();
Eigen::Vector3d axis = Eigen::Vector3d::Zero();

std::vector<Eigen::Vector3d> tightBoundingBox = this->GetTightBoundingBox();

Eigen::Vector3d deltaFirstDir = tightBoundingBox[1] - tightBoundingBox[0];
Eigen::Vector3d deltaSecondDir = tightBoundingBox[2] - tightBoundingBox[0];
Eigen::Vector3d deltaThirdDir = tightBoundingBox[3] - tightBoundingBox[0];

for (Eigen::Vector3d direction : {deltaFirstDir, deltaSecondDir, deltaThirdDir})
{
if (direction.norm() > axis.norm())
{
axis = direction;
}
}
axis.normalize();

center = tightBoundingBox[0] + deltaFirstDir/2 + deltaSecondDir/2 + deltaThirdDir/2;

return std::make_tuple(center, axis);
}

void DFMesh::LoadFromPLY(const std::string &path)
{
std::shared_ptr<diffCheck::geometry::DFMesh> tempMesh_ptr = diffCheck::io::ReadPLYMeshFromFile(path);
Expand Down
7 changes: 7 additions & 0 deletions src/diffCheck/geometry/DFMesh.hh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ namespace diffCheck::geometry
*/
bool IsPointOnFace(Eigen::Vector3d point, double associationThreshold = 0.1);

/**
* @brief Get the center and main axis of oriented boundung box of the mesh. It was developped for the cylinder case, but can be used for other shapes.
*
* @return std::tuple<Eigen::Vector3d, Eigen::Vector3d> the first element is the center of the obb of the mesh, the second element is the main axis of the obb of the mesh
*/
std::tuple<Eigen::Vector3d, Eigen::Vector3d> ComputeOBBCenterAndAxis();

public: ///< I/O loader
/**
* @brief Read a mesh from a file
Expand Down
Loading