Share

GridSurface.ExtractContours(Double, ContourSmoothingType, Int32) Method

Extracts the surface contour information from the terrain surface at a specified elevation interval with smoothing.



Namespace: Autodesk.Civil.DatabaseServices
Assembly: AeccDbMgd (in AeccDbMgd.dll) Version: 13.8.0.280

Syntax

C#

public ObjectIdCollection ExtractContours(
	double interval,
	ContourSmoothingType smoothType,
	int smoothFactor
)

VB

Public Function ExtractContours ( 
	interval As Double,
	smoothType As ContourSmoothingType,
	smoothFactor As Integer
) As ObjectIdCollection

C++

public:
virtual ObjectIdCollection^ ExtractContours(
	double interval, 
	ContourSmoothingType smoothType, 
	int smoothFactor
) sealed

Parameters

interval  Double
The specified elevation interval.
smoothType  ContourSmoothingType
Currently, smoothType can be AddVertices only.
smoothFactor  Int32
smoothFactor should be in the range [0, 10]. A value of 10 generates the smoothest contours.

Return Value

ObjectIdCollection
An ObjectIdCollection of the extracted entities. The extracted entities are Polyline objects. If the surface has no contour information, this method returns an empty ObjectIdCollection.

Implements

ITerrainSurfaceExtractContours(Double, ContourSmoothingType, Int32)

Exceptions

ExceptionCondition
ArgumentException Thrown when smoothFactor is not between the range [0, 10].

Example

C#

 1// Setup: creates a new, random surface
 2// 
 3TinSurface surface = CreateRandomSurface("Example Surface");
 4
 5// Extract contours and print information about them:
 6ObjectIdCollection contours;
 7double contourInterval = 50.0;
 8contours = surface.ExtractContours(contourInterval);
 9write("# of extracted contours: " + contours.Count + "\n");
10int totalVertices = 0;
11for (int i = 0; i < contours.Count; i++)
12{
13    ObjectId contourId = contours[i];
14
15    // Contours are lightweight Polyline objects:
16    Polyline contour = contourId.GetObject(OpenMode.ForRead) as Polyline;
17    write(String.Format("Contour #{0} length:{1}, # of vertices:{2}\n",
18        i, contour.Length, contour.NumberOfVertices));
19    totalVertices += contour.NumberOfVertices;
20}
21
22// Extract contours with smoothing:
23contours = surface.ExtractContours(contourInterval, ContourSmoothingType.AddVertices, 10);
24int totalVerticesSmoothed = 0;
25foreach (ObjectId contourId in contours)
26{
27    Polyline contour = contourId.GetObject(OpenMode.ForRead) as Polyline;
28    totalVerticesSmoothed += contour.NumberOfVertices;
29}
30
31// Compare smoothing by adding vertices:
32write(String.Format("Effects of smoothing:\n  total vertices no smoothing: {0}\n  total vertices with smoothing: {1}\n",
33    totalVertices, totalVerticesSmoothed));
34
35// Extract contours in a range:
36double startRange = 130.0;
37double endRange = 190.0;
38contours = surface.ExtractContours(contourInterval, startRange, endRange);
39
40write("# of extracted contours in range: " + contours.Count + "\n");
41
42// You can also extract contours in a range with smoothing:
43// contours = surface.ExtractContours(contourInterval, startRange, endRange, 
44//    ContourSmoothingType.SplineCurve, 10);

VB

1!ERROR: See log file!

See Also

Reference

Was this information helpful?