Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions core/ig/inc/gmds/ig/Face.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ namespace gmds{
*/
TCoord area() const;

/*------------------------------------------------------------------------*/
/** \brief Compute the signed area of the face
*
* \return the signed area of the face
*/
TCoord signedArea() const;

/*------------------------------------------------------------------------*/
/** \brief Compute the scaled jacobian of the face
*
Expand Down
32 changes: 32 additions & 0 deletions core/ig/src/Face.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,38 @@ namespace gmds {
}
}
/*----------------------------------------------------------------------------*/
TCoord
Face::signedArea() const {
math::Vector3d n;
std::vector<Node> nodes = this->get<Node>();
auto nb_nodes = nodes.size();

if (nb_nodes == 3) {

Node n1 = nodes[0];
Node n2 = nodes[1];
Node n3 = nodes[2];
math::Triangle t(n1.point(),n2.point(),n3.point());
return t.signedArea();

} else if (nb_nodes == 4) {
math::Point p1 = nodes[0].point();
math::Point p2 = nodes[1].point();
math::Point p3 = nodes[2].point();
math::Point p4 = nodes[3].point();
math::Point c = center();
math::Triangle t1(p1,p2,c);
math::Triangle t2(p2,p3,c);
math::Triangle t3(p3,p4,c);
math::Triangle t4(p4,p1,c);

return t1.signedArea()+t2.signedArea()+t3.signedArea()+t4.signedArea();
} else {
throw GMDSException("Not yet implemented!");

}
}
/*----------------------------------------------------------------------------*/
math::Point
Face::center() const
{
Expand Down
5 changes: 5 additions & 0 deletions core/math/inc/gmds/math/Triangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ class Plane;
*/
double area() const;

/*------------------------------------------------------------------------*/
/** \brief Computes the signed area of the triangle (works for triangles in the plane)
*/
double signedArea() const;

/*------------------------------------------------------------------------*/
/** \brief Computes the angle (in rad) of the triangle, as seen by its first vertex
*/
Expand Down
13 changes: 12 additions & 1 deletion core/math/src/Triangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ Triangle::~Triangle(){}
return 0.5 * (v1.cross(v2)).norm();
}
/*----------------------------------------------------------------------------*/
double Triangle::signedArea() const
{
Vector3d v1 = m_pnts[1] - m_pnts[0];
Vector3d v2 = m_pnts[2] - m_pnts[0];
Vector3d cross_prod = v1.cross(v2);
if (cross_prod.Z() >= 0)
return 0.5 * cross_prod.norm();
else
return -0.5 * cross_prod.norm();
}
/*----------------------------------------------------------------------------*/
double Triangle::angle() const
{
Vector3d v1 = m_pnts[1] - m_pnts[0];
Expand Down Expand Up @@ -105,7 +116,7 @@ Point Triangle::getCircumcenter() const
double yB = B.Y();
double xC = C.X();
double yC = C.Y();
double S = area();
double S = signedArea();
double xO = ((xA*xA+yA*yA)*(yB-yC)-(xB*xB+yB*yB)*(yA-yC)+(xC*xC+yC*yC)*(yA-yB))*(1./(4.*S));
double yO = -((xA*xA+yA*yA)*(xB-xC)-(xB*xB+yB*yB)*(xA-xC)+(xC*xC+yC*yC)*(xA-xB))*(1./(4.*S));
math::Point Ctr(xO, yO, 0.);
Expand Down
22 changes: 17 additions & 5 deletions modules/medialaxis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# LIBRARY DEFINITION (SOURCE FILES)
#==============================================================================
# Explicitly used the name given in this preamble
set(GMDS_LIB ${LIB_GMDS_MEDIALAXIS})
set(GMDS_LIB ${LIB_GMDS_MEDIAL_AXIS})
set(GMDS_LIB_PREFIX gmds/medialaxis)

set(GMDS_INC
Expand All @@ -13,6 +13,15 @@ set(GMDS_INC
inc/gmds/medialaxis/MedialAxis3D.h
inc/gmds/medialaxis/MedialAxis3DBuilder.h
inc/gmds/medialaxis/CrossField.h
inc/gmds/medialaxis/NonConformalHalfEdge.h
inc/gmds/medialaxis/QuantizationSolver.h
inc/gmds/medialaxis/QuantizationGraph.h
inc/gmds/medialaxis/ConformalMeshBuilder.h
inc/gmds/medialaxis/BlockStructureSimplifier.h
inc/gmds/medialaxis/MinDelaunayCleaner.h
inc/gmds/medialaxis/Conformalizer.h
inc/gmds/medialaxis/MedaxBasedTMeshBuilder.h
inc/gmds/medialaxis/TrianglesRemover.h
)
set(GMDS_SRC
src/MedialAxis2D.cpp
Expand All @@ -22,11 +31,14 @@ set(GMDS_SRC
src/MedialAxis3DBuilder.cpp
src/CrossField.cpp
src/NonConformalHalfEdge.cpp
inc/gmds/medialaxis/NonConformalHalfEdge.h
src/QuantizationSolver.cpp
inc/gmds/medialaxis/QuantizationSolver.h
src/QuantizationSolver.cpp
src/QuantizationGraph.cpp
inc/gmds/medialaxis/QuantizationGraph.h
src/ConformalMeshBuilder.cpp
src/BlockStructureSimplifier.cpp
src/MinDelaunayCleaner.cpp
src/Conformalizer.cpp
src/MedaxBasedTMeshBuilder.cpp
src/TrianglesRemover.cpp
)
#==============================================================================
add_library(${GMDS_LIB} ${GMDS_INC} ${GMDS_SRC})
Expand Down
200 changes: 200 additions & 0 deletions modules/medialaxis/inc/gmds/medialaxis/BlockStructureSimplifier.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
#ifndef GMDS_BLOCKSTRUCTURESIMPLIFIER_H
#define GMDS_BLOCKSTRUCTURESIMPLIFIER_H
/*----------------------------------------------------------------------------*/
#include "GMDSMedialaxis_export.h"
#include "gmds/medialaxis/MedialAxis2D.h"
#include "gmds/medialaxis/NonConformalHalfEdge.h"
#include "gmds/medialaxis/MedialAxisMath.h"
#include "gmds/medialaxis/QuantizationGraph.h"
#include "gmds/io/IGMeshIOService.h"
#include "gmds/io/VTKWriter.h"
#include "gmds/ig/MeshDoctor.h"
#include <gmds/ig/Mesh.h>
/*----------------------------------------------------------------------------*/
namespace gmds{
/** \class dummy
* \brief dummy class.
*/
class GMDSMedialaxis_API BlockStructureSimplifier
{
private:
// Non conformal quad block decomposition
Mesh* m_mesh;
// Corresponding non-conformal half edges
std::vector<NonConformalHalfEdge> m_half_edges;
// Quantization graph
QuantizationGraph* m_quantization_graph;
// Half edges length
std::vector<int> m_half_edges_lengths;
// Mesh after removing half edges of length zero
Mesh* m_simplified_mesh;

public:

/*-------------------------------------------------------------------------*/
/** @brief Constructor.
* @param AMesh
*/
explicit BlockStructureSimplifier(Mesh &AMesh);

/*-------------------------------------------------------------------------*/
/** @brief Default destructor.
* @param
*/
virtual ~BlockStructureSimplifier()=default;

/*-------------------------------------------------------------------------*/
/** @brief Getters.
* @param
*/
std::vector<NonConformalHalfEdge> halfEdges(){return m_half_edges;}
std::vector<int> halfEdgesLengths(){return m_half_edges_lengths;}

/*-------------------------------------------------------------------------*/
/** @brief Build the half edges.
* @param
*/
void buildHalfEdges();

/*-------------------------------------------------------------------------*/
/** @brief Build the quantization graph nodes.
* @param
*/
void buildQuantizationGraphNodes();

/*-------------------------------------------------------------------------*/
/** @brief Build the connected component of the given half edge.
* @param AHalfEdgeID an half edge ID
*/
void buildConnectedComponent(int AHalfEdgeID);

/*-------------------------------------------------------------------------*/
/** @brief Return the next of the next half edge of the given half edge.
* @param AHalfEdgeID an half edge ID
*/
int oppositeInQuad(int AHalfEdgeID);

/*-------------------------------------------------------------------------*/
/** @brief Build the connected component graph.
* @param
*/
void buildQuantizationGraph();

/*-------------------------------------------------------------------------*/
/** @brief Get the quantization graph.
* @param
*/
QuantizationGraph* getQuantizationGraph();

/*-------------------------------------------------------------------------*/
/** @brief Set half edges length.
* @param
*/
void setHalfEdgesLength();

/*-------------------------------------------------------------------------*/
/** @brief Return the set of sides of the input geometry, each side being a set of half-edge Ids.
* @param
*/
std::vector<std::vector<TCellID>> sides();

/*-------------------------------------------------------------------------*/
/** @brief Mark the T-junctions.
* @param
*/
void markTJunctions();

/*-------------------------------------------------------------------------*/
/** @brief Return true if the given node is on the boundary.
* @param
*/
bool isOnBoundary(Node AN);

/*-------------------------------------------------------------------------*/
/** @brief Return the set of half-edges that must be non zero, ie that are adjacent to a singularity.
* @param
*/
std::vector<TCellID> nonZeroHalfEdges();

/*-------------------------------------------------------------------------*/
/** @brief Return the set of groups of nodes, each group being a set of nodes connected by half-edges of length 0.
* @param
*/
std::vector<std::vector<Node>> groupsOfConfundedNodes();

/*-------------------------------------------------------------------------*/
/** @brief Return true if the given node is a corner of the boundary.
* @param
*/
bool isABoundaryCorner(Node AN);

/*-------------------------------------------------------------------------*/
/** @brief Compute the disappearance gain for each node.
* @param
*/
void computeChosingGains();

/*-------------------------------------------------------------------------*/
/** @brief Return a representative for the given group of confunded nodes.
* @param AV
*/
Node representative(std::vector<Node> AV);

/*-------------------------------------------------------------------------*/
/** @brief Build the simplified mesh.
* @param
*/
void buildSimplifiedMesh();

/*-------------------------------------------------------------------------*/
/** @brief Set the connectivity of the simplified mesh.
* @param
*/
void setSimplifiedMeshConnectivity();

/*-------------------------------------------------------------------------*/
/** @brief Get the simplified mesh.
* @param
*/
Mesh getSimplifiedMesh();

/*-------------------------------------------------------------------------*/
/** @brief Write the simplified mesh.
* @param
*/
void writeSimplifiedMesh(std::basic_string<char> AFileName);

/*-------------------------------------------------------------------------*/
/** @brief Execute.
* @param
*/
void execute();

/*-------------------------------------------------------------------------*/
/** @brief Attach 1 to edges belonging to separatricies.
* @param
*/
void markSeparatrices();

/*-------------------------------------------------------------------------*/
/** @brief Attach to each face the id of the block it belongs to.
* @param
*/
void setBlocksIDs();

/*-------------------------------------------------------------------------*/
/** @brief Trace the outlines of the TopMaker blocks.
* @param
*/
void traceTopMakerBlocksOutlines();

/*-------------------------------------------------------------------------*/
/** @brief Attach to each face the id of the TopMaker block it belongs to.
* @param
*/
void setTopMakerBlocksIDs();
};
/*----------------------------------------------------------------------------*/
} // end namespace gmds
/*----------------------------------------------------------------------------*/
#endif // GMDS_BLOCKSTRUCTURESIMPLIFIER_H
Loading
Loading