Computes the volume differences between two overlapping surfaces.
More...
#include <CutAndFill.h>
|
| CutAndFill (Zone2 *pZoneBefore, Zone2 *pZoneAfter, double ignoreThreshold=1e-6) |
| Constructor. More...
|
|
| ~CutAndFill () |
| Destructor.
|
|
CAF_Component * | getComponent (size_t idx) const |
| Retrieves the component at the specified index. More...
|
|
bool | getDiffZone (Zone2 *&pDiffZone, std::map< Point2 *, std::pair< double, double > > &mVtx2BeforeAfter) |
| Retrieves the difference zone between the two surfaces. More...
|
|
size_t | getNumberOfComponents () const |
| Get the number of components. More...
|
|
bool | go (bool bWithMessages=true) |
| Starts the computation of the cut and fill volumes. More...
|
|
void | show (Visualizer2 *pVis) const |
| Draws a postscript or PDF visualization of the result. More...
|
|
void | showVtk (VtkWriter *pVtkWriter, VtkColor cutColor, VtkColor fillColor, VtkColor nullColor) const |
| Visualizes the result as a .VTK file. More...
|
|
void | subscribe (MsgType msgType, MsgBase *pMsg) |
| Registers a message receiver object to receive progress updates. More...
|
|
void | unsubscribe (MsgType msgType, MsgBase *pMsg) |
| Unregisters a message receiver object. More...
|
|
Given two overlapping surfaces with different elevations, the CutAndFill
algorithm:
- Computes the overlapping part.
- Partitions the overlapping area into components of type "cut", "fill" and "zero".
- Computes the volumes that must be removed (cut) or added (fill) to transform one surface into the other.
Cut-and-fill: The original and the desired surface after the earthworks
- Note
- The method works also if the surfaces do not match perfectly, as it only requires an overlapping area for the calculation.
- See also
- https://www.geom.at/cut-and-fill/
◆ CutAndFill()
GEOM_FADE25D::CutAndFill::CutAndFill |
( |
Zone2 * |
pZoneBefore, |
|
|
Zone2 * |
pZoneAfter, |
|
|
double |
ignoreThreshold = 1e-6 |
|
) |
| |
Initializes the CutAndFill
object with the specified surface data.
- Parameters
-
pZoneBefore | A pointer to the surface before the earthworks (Zone2 object). |
pZoneAfter | A pointer to the surface after the earthworks (Zone2 object). |
ignoreThreshold | A threshold value to ignore insignificant height differences (default: 1e-6). |
◆ getComponent()
CAF_Component* GEOM_FADE25D::CutAndFill::getComponent |
( |
size_t |
idx | ) |
const |
A CAF_Component object represents a connected part of the surface such that
- the first surface is below the second one (Type CT_FILL)
- the first surface is above the second one (Type CT_CUT)
- the first surface corresponds to the second one (Type CT_NULL)
- Parameters
-
[in] | idx | The index of the component. |
- Returns
- A pointer to the
CAF_Component
at the specified index.
◆ getDiffZone()
bool GEOM_FADE25D::CutAndFill::getDiffZone |
( |
Zone2 *& |
pDiffZone, |
|
|
std::map< Point2 *, std::pair< double, double > > & |
mVtx2BeforeAfter |
|
) |
| |
This method returns a Zone2 of the overlapping area in which the z-values represent the height differences of the input surfaces ('surface-before' minus 'surface-after'). Additionally, a map is returned that contains the height values for each vertex of this zone in the two input surfaces.
- Parameters
-
[out] | pDiffZone | A Zone2, in which the z-coordinates represent the height differences ('surface-before' minus 'surface-after'). |
[out] | mVtx2BeforeAfter | A map that associates each vertex of pDiffZone with the height values from both the before and after surfaces. |
- Returns
true
if the operation succeeds, or false
if the two input surfaces do not share a common area. In this case, the previous call to CutAndFill::go()
would have already returned false
.
- See also
- https://www.geom.at/cut-and-fill/#difference-zone
◆ getNumberOfComponents()
size_t GEOM_FADE25D::CutAndFill::getNumberOfComponents |
( |
| ) |
const |
This method returns the number of CAF_Component objects.
- Returns
- the number of components.
◆ go()
bool GEOM_FADE25D::CutAndFill::go |
( |
bool |
bWithMessages = true | ) |
|
This method starts the computation of the volume difference between the two surfaces.
- Parameters
-
[in] | bWithMessages | If true , messages and warnings will be displayed during the computation. If false , warnings will be suppressed. |
- Returns
true
if the computation succeeds, false
otherwise (e.g., if there is no overlapping area).
◆ show()
void GEOM_FADE25D::CutAndFill::show |
( |
Visualizer2 * |
pVis | ) |
const |
This method generates a postscript or PDF image showing the cut and fill areas, providing a quick visual overview of the computation results.
Cut-and-fill result: YELLOW area = CUT, CYAN area = FILL
- Parameters
-
pVis | A pointer to the Visualizer2 object that handles the visualization. |
- Note
- You must call
pVis->writeFile()
to finalize the visualization.
◆ showVtk()
This method visualizes the result using a VtkWriter, which can generate VTK files for visualization in external programs such as ParaView.
- Parameters
-
pVtkWriter | A pointer to an existing VtkWriter that will handle the visualization. |
cutColor | The color to represent the cut area. |
fillColor | The color to represent the fill area. |
nullColor | The color to represent the null area (neither cut nor fill). |
- Note
- You must call
pVtkWriter->writeFile()
to write the output file.
◆ subscribe()
void GEOM_FADE25D::CutAndFill::subscribe |
( |
MsgType |
msgType, |
|
|
MsgBase * |
pMsg |
|
) |
| |
A user-defined progress bar or message receiver object can be registered to receive progress information during the computation. This step is optional.
- Parameters
-
msgType | The message type (for progress updates, the type is always MSG_PROGRESS ). |
pMsg | A pointer to the user-defined message receiver object, which must derive from MsgBase . |
- See also
- https://www.geom.at/cut-and-fill/
◆ unsubscribe()
void GEOM_FADE25D::CutAndFill::unsubscribe |
( |
MsgType |
msgType, |
|
|
MsgBase * |
pMsg |
|
) |
| |
Removes a previously registered message receiver object for progress updates.
- Parameters
-
msgType | The message type (for progress updates, the type is always MSG_PROGRESS ). |
pMsg | A pointer to the user-defined message receiver object, which must derive from MsgBase . |
- See also
- https://www.geom.at/cut-and-fill/
The documentation for this class was generated from the following file: