60001971 Optimization of the GetVisibleArea() method in order for it to execute correctly while passing only the needed entities

Article 60001971
Type Wish
Product Engine
Version 6025
Date Added 6/20/2013 12:00:00 AM
Fixed (6/21/2013 12:00:00 AM)
Submitted by Bertrand Munier

Summary

Optimization of the GetVisibleArea() method in order for it to execute correctly while passing only the needed entities and extract their respective visible areas.

Solution

In version 6026 a new overload of the GetVisibleArea method is added in vdDocument object.

public VectorDraw.Render.PrimitivesExport.RenderProperties.EntityViewAreas GetVisibleArea(vdEntities entities, vdSelection subentities, Vector VisibleDirection, double SquareRectSize)
Get the visible area of passed entities at the specified view direction

param name="entities" A collection of objects that make up the entire drawing.
param name="subentities" A collection of vdFigures for which the visible area will be calculated in reference to the entire drawing. If it is null the visible area of passed entities will be calculated.
param name="VisibleDirection" Visible view direction of clip view plane in World Coordinate System(WCS). Defines the Vector from target to camera point (if you are looking from the top, a {0,0,1} vector should be used).
param name="SquareRectSize" Defines the size of the square in Drawing units that each surface is divided. Smaller values give more precise results but need more time to calculate.
returns A collection of object type that contains information about the area of each passed vdFigure object.

example:
Get the projection area in active View of all grip selected entities in Model Layout.
If there are no grip selected entities the visible area of all entities in model layout is calculated.
Note: set the SquareRectSize to 0.01 that is 1 square centimeter in case we assume that 1 DrawingUnit represents 1 meter.
The return area value will be in square Drawing Units (square meters in this case)

vdSelection set = doc.GetGripSelection();
if (set != null && set.Count == 0) set = null;
VectorDraw.Render.PrimitivesExport.RenderProperties.EntityViewAreas ret =document.GetVisibleArea(document.Model.Entities, set, doc.Model.Render.ViewDir, 0.01);
double surfacesVisibleArea = ret.Area(false); //get the visible area of all entities surfaces.
double ProjectionToViewArea = ret.Area(true); //get the area that projected on the selected view.

UPDATED! 17/07/2013

A new GetVisibleAreas() method was added. The difference with the already added GetVisibleArea() methods is that the user can define a Vectors collection and get the visible areas for every of these Vector objects. The process time consumption was also improved than using one of the previous GetVisibleArea() methods for every Vector in the collection.

param name="entities"A collection of objects that make up the entire drawing.
param name="subentities"A collection of vdFigures for which the visible area will be calculated in connection with the entire drawing.If it is null the visible area of passed entities will be calculated.
param name="SquareRectSize"Defines the size of small square in Drawing units that each surface is divided. Smaller values gets more time to calculate.
returns An array of "VectorDraw.Render.PrimitivesExport.RenderProperties.EntityViewAreas object type that contains information about the area of each passed vdFigure object in each view.

example:

vdSelection set = doc.GetGripSelection();
if (set != null && set.Count == 0) set = null;
VectorDraw.Render.PrimitivesExport.VisibleAreas va = doc.GetVisibleAreas(doc.Model.Entities, set, 0.01);
for (int i = 0; i < 360; i += 36)
{
double x = Math.Cos(Globals.DegreesToRadians(i));
double y = Math.Sin(Globals.DegreesToRadians(i));
Vector v = new Vector(x, y, 1);

VectorDraw.Render.PrimitivesExport.RenderProperties.EntityViewAreas viewarea = va.GetEntitiesArea(v);
double surfacesVisibleArea = viewarea.Area(false); //get the visible area of all entities surfaces in specific view.
double ProjectionToViewArea = viewarea.Area(true); //get the projected area on the specific view.
}
va.Dispose(); //Always dispose immediately after you have finished with visible area jobs}

Send comments on this topic.