How to use ON_TransformBrepComponents function

I’d like to achieve the same result in C++.

I used SolidPtOn in Rhino5 and i found the function called ON_TransformBrepComponents in RhinoCommon SDK which achieve the same result probably.
However, i don’t know how to use this function.
Can someone post a simple example how to use it.Thanks!!!

Hi @wayne387315
You are right. ON_TransformBrepComponents is what SolidPtOn uses. Which part of the function was not clear? Here is the header description

  Transform a list of brep components, bend neighbors
  to match, and leave the rest fixed.
  brep - [in]
    brep to modify
  brep_component_count - [in]
    Length of brep_components[] array
  brep_components - [in]
    components to transform.
  xform - [in]
    transformation to apply to compoents
  tolerance - [in]
    Desired fitting tolerance to use when bending
    faces that share edges with both fixed and 
    transformed components.
  time_limit - [in]
    If the deformation is extreme, it can take a long time to
    calculate the result. If time_limit > 0, then the value
    specifies the maximum amount of time in seconds you want
    to spend before giving up.
  bUseMultipleThreads - [in]
    True if multiple threads can be used.
  True if successful.
bool ON_TransformBrepComponents( 
  ON_Brep* brep,
  int brep_component_count,
  const ON_COMPONENT_INDEX* brep_components,
  ON_Xform xform,
  double tolerance,
  double time_limit,
  bool bUseMultipleThreads

Hi @wayne387315,

I’ve moved this discussion to the Rhino Developer category because ON_TransformBrepComponents is only implemented on the Rhino SDK (and not standalone openNURBS).

– Dale

I want to know these two parameter .
First one is int brep_component_count,the description said that
“Length of brep_components[] array”. How can I know the length or
what is the components it mentioned?
Second,const ON_COMPONENT_INDEX* brep_components,I think it is an array,
but I don’t know what I should put into the array.

OK , Thanks!!

That refers to the number of brep parts (or components) that you need to transform. For example, if you are transforming 3 vertices in the breps, you pass “3”. This is needed because you are passing a pointer to the array, and hence the size of it is not clear.

Each brep part (Face, Edge, Vertex) has a unique identification called “COMPONENET_INDEX”. You can get to it by calling the ComponentIndex() function.

For example if you compile an array of component indexes that you need to transnfom with something like:

ON_SimpleArray<ON_COMPONENT_INDEX>& indexes_array

and append to it, say for example:

ON_COMPONENT_INDEX ci1 = brep.Face(0)->ComponentIndex();
ON_COMPONENT_INDEX ci2 = brep.Face(1)->ComponentIndex();


The you can set the values in the function as such:

bool result = ON_TransformBrepComponents(brep, indexes_array.Count(), indexes_array.Array(), etc

I hope this helps

It really helps.I have achieve the same result successfully by using this function.

After knowing how to use it , I have already done lots of works by using this function.
I am very curious about how to program the function like this.
Before using this function , I tried many methods to transform a brep.
However, I can’t make it successfully. I am eager to know what is the correct way to transform a brep.
Could you get me the source code or something that I can study for.

Hi @wayne387315,

ON_TransformBrepComponents is part of openNURBS, and the source code for openNURBS is available.

– Dale

ON_TransformBrepComponents is in opennurbs_brep.h in my SDK.
I have already checked the opennurbs_brep.cpp in GitHub , I still can not find it.
I think the opennurbs_brep.cpp is not complete in GitHub or maybe it’s in other place that I haven’t find yet.

Hi @wayne387315,

Yep my mistake, the source for this function is not publically available - sorry.

– Dale