A planar solid object uses four vertices, the normal, and the thickness properties to define the geometry to be drawn. In examples, the pSolid variable stores a pointer to the planar solid object.
The Vertices property defines four vertices of the planar solid in three-dimensional coordinates. Vertices are enumerated as 0, 1, 2, 3. All vertices are connected by linear segments in the closed figure. The end of the current segment is the start of the next segment and the last segment connects with first segment. When the coordinates of two vertices overlap, two adjacent triangles will be drawn. When two vertices coincide, a triangle will be drawn. All vertices have the coordinates (0,0,0) by default.
To get the vertex, use the getPointAt() method which requires a vertex index in the range 0 to 3 as the first argument of an Integer type, requires a reference to an existing three-dimensional point instance as the second argument of the OdGePoint3d type, and returns the specified vertex through the second argument. For example:
OdGePoint3d vertex0, vertex1, vertex2, vertex3;
pSolid->getPointAt(0, vertex0);
pSolid->getPointAt(1, vertex1);
pSolid->getPointAt(2, vertex2);
pSolid->getPointAt(3, vertex3);
odPrintConsoleString(L"\nVertex(0) = (%g,%g,%g)", vertex0.x, vertex0.y, vertex0.z);
odPrintConsoleString(L"\nVertex(1) = (%g,%g,%g)", vertex1.x, vertex1.y, vertex1.z);
odPrintConsoleString(L"\nVertex(2) = (%g,%g,%g)", vertex2.x, vertex2.y, vertex2.z);
odPrintConsoleString(L"\nVertex(3) = (%g,%g,%g)", vertex3.x, vertex3.y, vertex3.z);
To set the vertex, use the setPointAt() method which requires a vertex index in the range 0 to 3 as the first argument of an Integer type, requires the three-dimensional point as the second argument of the OdGePoint3d type, and does not return a value. For example:
OdGePoint3d corner0(1, 1, 0);
OdGePoint3d corner1(7, 2, 0);
OdGePoint3d corner2(9, 9, 0);
OdGePoint3d corner3(2, 7, 0);
pSolid->setPointAt(0, corner0);
pSolid->setPointAt(1, corner1);
pSolid->setPointAt(2, corner2);
pSolid->setPointAt(3, corner3);
The Normal property defines the normal to the plane in which the planar solid is placed. The normal defines the orientation of the solid plane in world space. The normal has the coordinates (0,0,1) by default.
To get the normal, use the normal() method which does not have arguments and returns the three-dimensional vector as an instance of the OdGeVector3d type. For example:
OdGeVector3d normal = pSolid->normal();
odPrintConsoleString(L"\nNormal = (%g,%g,%g)", normal.x, normal.y, normal.z);
To set the normal, use the setNormal() method which requires the three-dimensional vector as an argument of the OdGeVector3d type and does not return a value. For example:
OdGeVector3d vector(0.606, 0.101, 0.303);
pSolid->setNormal(vector);
The setNormal() method automatically converts the specified coordinates to a unit vector. For example:
pSolid->setNormal( OdGeVector3d(2.5, 1.2, 3.4) );
OdGeVector3d result = pSolid->normal();
odPrintConsoleString(L"\n(%g, %g, %g)", result.x, result.y, result.z);
// (0.569803, 0.273505, 0.774932)
The Thickness property defines the thickness of the planar solid as a Double value in drawing units. A positive value defines the thickness to be drawn along the normal direction. A negative value defines the thickness to be drawn in the opposite direction from the normal. A zero value defines a planar solid without thickness. The thickness is zero by default.
To get the thickness, use the thickness() method which does not have arguments and returns the thickness as a Double value. For example:
odPrintConsoleString(L"\nThickness = %g", pSolid->thickness());
To set the thickness, use the setThickness() method which requires a Double value as an argument and does not return a value. For example:
pSolid->setThickness(1.5);
Example of Working with the Planar Solid Object
Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.
|