Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Although a SegmentKey has a method to obtain the bounding (i.e. ShowBounding) this approach will not include any modeling matrices applied to the segment or those inherited. That is to say the net modelling matrix.

Instructions

To obtain the bounding which includes the net modelling matrix, you must use the ShowNetBounding method of a KeyPath. A KeyPath “is an ordered list of keys that forms an unambiguous chain from a scene graph leaf to its root.” This approach ensures the bounding information will account for all concatenated modelling transforms for a particular segment in a given location in the scene graph.

Consider the following sample code which can be added to the CHPSView class in the mfc_sandbox;

Code Block
void CHPSView::OnUserCode1()
{
	Point points[8] = { Point(0, 0, 0), Point(2, 0, 0), Point(2, 2, 0), Point(0, 2, 0),
		Point(0, 0, 2), Point(2, 0, 2), Point(2, 2, 2), Point(0, 2, 2) };

	int faceList[30] = { 4, 0, 1, 2, 3,
		4, 1, 5, 6, 2,
		4, 5, 4, 7, 6,
		4, 4, 0, 3, 7,
		4, 3, 2, 6, 7,
		4, 0, 4, 5, 1 };

	SegmentKey parentSegmentKey = GetCanvas().GetFrontView().GetAttachedModel().GetSegmentKey().Subsegment("test");
	parentSegmentKey.GetModellingMatrixControl().Translate(0, 0, 10);
	
	SegmentKey mySegmentKey = parentSegmentKey.Subsegment("geom");
	mySegmentKey.InsertShell(8, points, 30, faceList);
	mySegmentKey.GetModellingMatrixControl().Translate(10, 10, 0);

    // First obtain the bounding from this segment for comparison
	BoundingKit bKit;
	mySegmentKey.ShowBounding(bKit);

	SimpleSphere sphere;
	SimpleCuboid cuboid;
	bKit.ShowVolume(sphere, cuboid);
	
	TRACE("bounding sphere : center = { %g, %g, %g }, r = %g\n",
		sphere.center.x, sphere.center.y, sphere.center.z, sphere.radius);
	TRACE("bounding cuboid : min = { %g, %g, %g }, max = { %g, %g, %g }\n",
		cuboid.min.x, cuboid.min.y, cuboid.min.z,
		cuboid.max.x, cuboid.max.y, cuboid.max.z);

    // Next obtain the net bounding
	BoundingKit netBKit;
	// Build the key path
	KeyPath kpath;
	kpath.PushBack(mySegmentKey);
	kpath.PushBack(parentSegmentKey); // optional
	kpath.PushBack(GetCanvas().GetFrontView().GetAttachedModel().GetSegmentKey());
	kpath.ShowNetBounding(netBKit);
	netBKit.ShowVolume(sphere, cuboid);

	TRACE("net bounding sphere : center = { %g, %g, %g }, r = %g\n",
		sphere.center.x, sphere.center.y, sphere.center.z, sphere.radius);
	TRACE("net bounding cuboid : min = { %g, %g, %g }, max = { %g, %g, %g }\n",
		cuboid.min.x, cuboid.min.y, cuboid.min.z,
		cuboid.max.x, cuboid.max.y, cuboid.max.z);
}

...

Build and launch the mfc_sandbox

...

Execute Use Code 1

Note the following in the debug output window;

...

For more information, check out our forum post.

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@2318a5
sortmodified
showSpacefalse
reversetrue
typepage
cqllabel in ( "kb-how-to-article" , "keypath" , "bounding" ) and type = "page" and space = "KBHV"
labelskb-how-to-article
Page Properties
hiddentrue

Related issues

Jira Legacy
serverId43f371d0-7091-3b3c-9683-94c0b791358d
keySDHV-10501