Fade2.5D Documentation pages v2.16.8
Delaunay Features
GEOM_FADE25D::CutAndFill Class Reference

Computes the volume differences between two overlapping surfaces. More...

#include <CutAndFill.h>

Public Member Functions

 CutAndFill (Zone2 *pZoneBefore, Zone2 *pZoneAfter, double ignoreThreshold=1e-6)
 Constructor. More...
 
 ~CutAndFill ()
 Destructor.
 
CAF_ComponentgetComponent (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...
 

Detailed Description

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/

Constructor & Destructor Documentation

◆ CutAndFill()

GEOM_FADE25D::CutAndFill::CutAndFill ( Zone2 pZoneBefore,
Zone2 pZoneAfter,
double  ignoreThreshold = 1e-6 
)

Initializes the CutAndFill object with the specified surface data.

Parameters
pZoneBeforeA pointer to the surface before the earthworks (Zone2 object).
pZoneAfterA pointer to the surface after the earthworks (Zone2 object).
ignoreThresholdA threshold value to ignore insignificant height differences (default: 1e-6).

Member Function Documentation

◆ 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]idxThe 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]pDiffZoneA Zone2, in which the z-coordinates represent the height differences ('surface-before' minus 'surface-after').
[out]mVtx2BeforeAfterA 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]bWithMessagesIf 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
pVisA pointer to the Visualizer2 object that handles the visualization.
Note
You must call pVis->writeFile() to finalize the visualization.

◆ showVtk()

void GEOM_FADE25D::CutAndFill::showVtk ( VtkWriter pVtkWriter,
VtkColor  cutColor,
VtkColor  fillColor,
VtkColor  nullColor 
) const

This method visualizes the result using a VtkWriter, which can generate VTK files for visualization in external programs such as ParaView.

Parameters
pVtkWriterA pointer to an existing VtkWriter that will handle the visualization.
cutColorThe color to represent the cut area.
fillColorThe color to represent the fill area.
nullColorThe 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
msgTypeThe message type (for progress updates, the type is always MSG_PROGRESS).
pMsgA 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
msgTypeThe message type (for progress updates, the type is always MSG_PROGRESS).
pMsgA 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: