Parsing 3dm file

Next
 From:  miquik
5061.1 
Hi,
I'm writing a program that parse a 3dm file (possibly create with MoI) and I have some questions : I know that every BrepFace has a list of BrepLoop with contains a list of BrepTrim curves. My question is : Am I always sure that every BrepLoop I read is closed? Can I skip this test? Other question : the list of BrepTrim are in correct order (i mean the end vertex of BrepTrim1 is equal to BrepTrim2 start vertex, and so on?) Or I have to check it? BrepTrims are always oriented correctly (I mean clockwise order for outer trimming loop and counter-clockwise for every internal trimming loop)?

At the end : if I write a program that parse a 3dm file, can I skip all this test (loop closure and orientation) or I have no guarantee of that?

Thank you a lot!!
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
5061.2 In reply to 5061.1 
Hi miquik, the diagram here may help:
http://wiki.mcneel.com/developer/brepstructure

> My question is : Am I always sure that every BrepLoop I read is closed?

There's a m_type field on ON_BrepLoop which marks the type of the loop as one of:

code:
  enum TYPE {
    unknown  = 0,
    outer    = 1,  // 2d loop curves form a simple closed curve with a counterclockwise orientation
    inner    = 2,  // 2d loop curves form a simple closed curve with a clockwise orientation
    slit     = 3,  // always closed - used internally during splitting operations
    crvonsrf = 4,  // "loop" is a curveonsrf made from a single 
                   // (open or closed) trim that is has type ON_BrepTrim::crvonsrf.
    ptonsrf = 5,   // "loop" is a ptonsrf made from a single 
                   // trim that is has type ON_BrepTrim::ptonsrf.
    type_count = 6
  };


If the type is one of: outer, inner, or slit then it is supposed to form a closed loop and you shouldn't have to check it for being closed. If it's marked as a type "crvonsrf", then the loop is not actually a trim loop that actually cuts the face but is instead a holder for just a regular curve that lives on the surface, and if it's marked as "ptonsrf" then it actually doesn't have any curves at all and it's just a holder for a uv point that lives on the surface.

MoI will only make loops of the "outer" or "inner" varieties and not these other types, but other programs could. You probably just want to skip the "crvonsrf" or "ptonsrf" ones since those do not actually cut anything on the face, they're more like for sticking curves and points embedded into the brep so that they are carried around with the brep while some various kinds of code may be passing it around and doing different kinds of things to it.


> Other question : the list of BrepTrim are in correct order (i
> mean the end vertex of BrepTrim1 is equal to BrepTrim2 start
> vertex, and so on?)

Yes, I'm pretty sure that's the case.


> BrepTrims are always oriented correctly (I mean clockwise order
> for outer trimming loop and counter-clockwise for every internal
> trimming loop)?

Yeah each trim holds a UV curve and each of those UV curves will be oriented in the loop direction such that the active part of the face is on the left-hand side of the trim curve, so it's actually opposite of what you wrote here, it's counter-clockwise for the outer one and clockwise for each inner one. You shouldn't need to check that unless you want to possibly deal with correcting files that were not written properly by the generating application.

But this is all for the UV parameter space curves - the 3D edge curves are separate from that and the 3D edge curve that's associated with the trim can be reversed in direction from the UV loop direction since it's possible for different loop boundaries to share the same 3D edge curve where they are joined to one another. When that's the case the m_bRev3d flag will be set on the trim.

Hope this helps!

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  miquik
5061.3 In reply to 5061.2 
Thank you Micheal!!!

I appreciate very much your help and your availability!
This is very important for us!

Thank you
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All