Engines Home  |  PCLIP

PCLIP - Polygon-Polygon Clipping Utility

PCLIP is the polygon-polygon intersection program that allows polygons in 3-D space to be intersected with other polygons to produce the difference, intersection, or union of the polygons in the X-Y (2-D) plane.

Use the syntax, pclip -h to display this help:

                           POLYGON-POLYGON CLIPPING UTILITY

               -vbm/srv    Input VBM/Survey file with polygons.

                           There can be one or two input files of the same format.

                    oper   A pre-processing operation over input polygons to be

                           performed before other calculations.

                           It can be one of the following:

                       n     No preprocessing.

                       s     Separate polygons into independent sets.

                       c     Option opposite to 's'. Combine all polygons in one.

               -prm file   Input parameter file. Used when survey files used.

               -int file   Output intersection of input polygons.

             -union file   Output union of input polygons.

              -diff file   Output difference of input polygons.

                   -f<n>   Validate polygons before intersection, where n can be

                              0 - make external and internal polygons

                                  to have opposite direction (default);

                              1 - use original direction of polygons.

                      -R   Reverse polygons (external oriented clockwise).

                -dat dir   Define a directory with input files.

 

NOTE:

The –r and –tmp options which existed in older versions of PCLIP have been deprecated.  They can still be used in the command line (for backward compatibility in old scripts) but they will have no effect.

Option –R is a used to redefine the mathematical default polygon direction (which is counter-clockwise).  In MS3D the default direction is always clockwise.  You will need to use this option to get the same result as in MS3D.

Use the –f(n) option to define if the input data has internal polygons (holes) that need to be automatically re-oriented. This option invokes a special algorithm that will handle multiple holes with any level of enclosure.  Note that "hole" polygons must have a direction that is opposite to external polygons.

Usage

Examples showing the syntax for the use of PCLIP are discussed below.

Example 1 - polygon 1 vs polygon 2

Two intersecting polygons that are located on the same plane are used to demonstrate the usage of the engine, "PCLIP".  One is a circle shape (circle.srv) and the other is in the shape of a rectangle (rectangle.srv), as displayed below in green and blue.

 

In this example, these polygons are in survey code files (.srv), but they could be in VBM (.vbm) files.  Input and output must use the same file type;  if .srv file(s) are used for input, then the output file format will be in .srv file format.  Or, if you use .vbm format for input, then the output should also be in .vbm format.  The program does not allow for mixed format types.

In addition, if survey code files (.srv) are used, then a valid Survey Parameter Code file (param.cod) must also be specified.

Pclip can perform only one operation at a time.  Multiple operations cannot be strung together, like with the union standalone engine.  

Since this example uses only two polygons, and no other polygons are nested within these polygons, no preprocessing is necessary.  Therefore, the "n" option is used.  If there were multiple polygons within a group, then preprocessing would be necessary - see Example 2.

  • Union

Use the following syntax to find the union of the two polygons:

pclip -srv n circle.srv -srv n rectangle.srv -prm param.cod -union union.srv

The result is shown below filled in golden brown.  The original polygons are also displayed as dotted lines for reference.

  • Intersection

Use the following syntax to find the intersection of the two polygons:

pclip -srv n circle.srv -srv n rectangle.srv -prm param.cod -int intersect.srv

The result is shown below filled in yellow.  The original polygons are also displayed as dotted lines for reference.

  • Difference

Depending on which polygon is listed first in the syntax will affect what is output.

  • To find the difference of the circle polygon without the intersecting rectangle polygon, use the following syntax:

pclip.exe -srv n circle.srv -srv n rectangle.srv -prm param.cod -diff difference1.srv

The result is shown below filled in blue.  The original polygons are also displayed as dotted lines for reference.

  • To find the difference of the rectangle polygon without the intersecting circle polygon, use the following syntax:

pclip.exe -srv n rectangle.srv -srv n circle.srv -prm param.cod -diff difference2.srv

The result is shown below filled in hot pink.  The original polygons are also displayed as dotted lines for reference.

All of the resulting differences and intersection pieces shown together:

Example 2 - Groups of polygons vs Groups of polygons

This is a simplified example using multiple polygons that exist in two "Groups".  In this case, the green circles are considered part of Group1 and the blue rectangles are part of Group2, as illustrated in the image below.  All of these polygons exist on the same (horizontal) plane.

Use operation mode "c" to combine all of the polygons in each group together.  Using modes "n" (no preprocessing) and "s" (separate polygons into independent polygons) can return erroneous results.  An error may be displayed when using one of those two options.

  • Union

Use the following syntax to find the union of the two polygons:

pclip -srv c Group1.srv -srv c Group2.srv -prm param.cod -union union-groups.srv

The result is shown below in golden brown;  displayed as an outline on the left and filled on the right..  This is the union of all the polygons.  The original polygons are also displayed in the image on the right as dotted lines for reference.

 

Optionally use the -R option to ensure that the outer, external polygon has a clockwise orientation.

pclip -srv c Group1.srv -srv c Group2.srv -prm param.cod -R -union union-groups-Rev.srv

In the results as shown below when using the "-R" option, the outer, external polygon is oriented in the clockwise direction and the inner polygon (a hole between the original polygons) has a counter-clockwise orientation.

  • Intersection

Use the following syntax to find the intersection of the two polygons:

pclip -srv c Group1.srv -srv c Group2.srv -prm param.cod -int intersect-groups.srv

The result is shown below filled in dark yellow.  The original polygons are also displayed as dotted lines for reference.

  • Difference

Depending on which Group of polygons is listed first in the syntax will affect the resulting output.

  • To find the difference of the Group of circle polygons without the intersecting Group of rectangle polygons, use the following syntax:

pclip.exe -srv c Group1.srv -srv c Group2.srv -prm param.cod -diff diff1.srv

The result is shown below filled in green.  The original polygons are also displayed as dotted lines for reference.

  • To find the difference of the Group of rectangle polygons without the intersecting Group of circle polygons, use the following syntax:

pclip.exe -srv c Group2.srv -srv c Group1.srv -prm param.cod -diff diff2.srv

The result is shown below filled in blue.  The original polygons are also displayed as dotted lines for reference.

The image below shows all of the resulting differences and intersection pieces displayed together: