You are here: AGGeom » JavaView » JVCommonTasks


This page presents some common tasks during the basic coding workflow with the JavaView library.

Copying Geometries

To copy a geometry you should use the copy() method provided by each geometry class. This needs a cast in the argument of the copy method.

PgElementSet geom = new PgElementSet(3);
geom.computeTorus(10, 10, 2., 1.);

PgElementSet geomCopy = new PgElementSet();
geomCopy.copy((PgElementSet) geom);

A similar method is provided by other geometry type classes. See also Clone vs. Copy

Create Geometry from Scratch

Compute Default Geometries

PgElementSet provides several member methods to compute some default geometries such as spheres or tori with prescribed resolution.

PgElementSet geom = new PgElementSet(3);
// Compute a torus with radius 2 and transversal radius 1
// with 10 x 10 grid lines.
geom.computeTorus(10, 10, 2., 1.);
Other default geometry methods include

See the reference API entry for more methods.

Remove duplicated Vertices and Elements

Adding/Removing/Selecting Geometries from Display

When working in a PjProject==-derived class, the member method ==getGeometry() returns the currently active geometry in the project display. Since the project does not know about the geometry type, the method returns a generic PgGeometryIf interface that needs to be cast to a specific geometry type such as PgElementSet, depending on its actual type.

Another option is via access to the m_display member variable of the PjProject class. This variable represents the display associated to the project and thus provides access to various display methods such as adding, selecting or removing certain geometries:

// Add a new geometry to display. 
// Can be of any type (PgPointSet, PgPolygon, PgElementSet,...)

// Return currently selected geometry.

// Selects the given geometry.

// Removes the given geometry from the display.

// Cleans the display by removing all geometries.

Similar methods are available for light sources and cameras. See the reference API entry for more methods.


This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback