Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all articles
Browse latest Browse all 8531

(C++) How to detect if a referenced Brep object is Trimmed after reading it from the user

$
0
0

@robin_l wrote:

Hello everyone

I’m currently writing a small script where I get some objects from the user and deform them. The way to deform them differs depending on whether the object has been trimmed previously or not, as untrimmed ones allow me some simplifications.

So, before deforming, I need to detect whether a trim was present. I do know that usually a Geometry filter is used for this purpose, but this doesn’t help me as I want to read the objects with or without trims, and that attribute doesn’t seem to be passed along to the reference or object.

Currently I have a very simple method:

bool isTrimmed(CRhinoObjRef brepref) {
	// referenced object is always a brep with a single face
	CRhinoBrepObject *obj = (CRhinoBrepObject *)brepref.Object();
	ON_Brep *brep = obj->Brep()->Duplicate();

	ON_BrepFace *face = brep->Face(0);
	ON_BrepLoop *outerLoop = face->Loop(0);

	if (
		face->LoopCount() == 1 &&  // brep has no holes
		outerLoop->TrimCount() == 4  // outer loop contains 4 edges
		) {
		return false;
	}
	return true;
}

Obviously, an object could be trimmed and still have 4 edges in the outer trimming loop, so this method is incomplete.

Is there a way to get the geometry attribute from the reference? Or, if not, how would I best detect trims in the outer loop? Or, even, in a Brep in general?

~robin

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 8531

Trending Articles