Removing hiddenlines and unspline splined curves.


Q1 having a "stick match" figure in 3D eg IGES file, how to easely remove "invisible" lines or parts of lines (or in first case find these parts).

Q2 Having the same drawing with some curves as splines, how to "convert" splines to arcs or small line pieces.

both in c/c++

Thanks in advance.
Who is Participating?
satsumoConnect With a Mentor Software DeveloperCommented:
1. Can you explain exactly what is meant by invisible in this case?  Do you mean things that can't be seen because they are behind other things (Hidden Line Removal)?

Or things which are hidden because they are on a hidden layer or something similar?

2. Curves are generated with homogenous functions that are evaluated between two control points, from 0 to 1 at either point. There are many functions to shape the curve, you need to know which is being used (splines on Wikipedia).

To divide a curve into 10 line segments, generate points by evaluating the function at 0.0, 0.1, 0.2, 0.3 etc, and join these points with line segments.

It might be sensible to separate this into two questions.  Each answer could become complicated.
RyanProject Engineer, ElectricalCommented:
I think you've picked the wrong categories for this. This questions sounds specific to IGES or AutoCAD or something, not the 3 categories you've chosen.

The general answer I would think is to loop every entity, checking it's property and if its visible=false then delete it.

The 2nd question is going to be very specific to your application.
lhademmorAuthor Commented:
No cause this task is to be done on every kind of 3d file type not only IGES, and without AutoCAD or SolidWorks on the calculating PC.
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

lhademmorAuthor Commented:
Forgot to say more like on everykind of vectorgraphic file in  3D were i need to "convert" it to 2D and delete everything "non visible".

I know AutoCAD can, but i don't have AutoCAD on the PC.
lhademmorAuthor Commented:
Dear moderator.

  OS is Win32, the application :-) ? that is what have the problem. It is solid homemade and to complete it i have to do some twistings on vector graphic file of any known kind (or at least the most common of these).

My guesstimate was this :
It has some theretically issues about how to move from 3D to 2D and remove all invisible parts. And how to take a spline or Belzier curve and "convert" it to simple arcs or line pieces.
And i need to find a solution/algrorithm to remove those hidden lines. and do the despline
It all happens in a C++ program that i write the code for.
Thus having Algorithm, miscelanious programming and theory. Sorry if i'm wrong. But If i'm wrong i could never find a better guess.

lhademmorAuthor Commented:
Q1  Yes hidde line removal everything is surposed to be at only 1 layer. My little house is handdrawn :-), the red lines are hidden and are surposed to be removed.

Q2  Do You meen split it up in same manner as an intergral equation ? having dX and dY small ?  Hmm i have thought of that, but wouldn't it be a very very slow process as You might reselect the line size several times, in order to precise enough ?
lhademmorAuthor Commented:
Q1 is not entirely answered but i can look at the WIKI for further information :-).

Q2 is almost a guideline and not a solution.

Algorithm will be like
  splitting in 10 peaces, testing if middle of point-2-point line is further away from actual curve than gradient factor (eg 0.01). If then jump into a "nested" loop splitting in 10 and so on. If not continue to next point-2-point peace.
satsumoSoftware DeveloperCommented:
I'm sorry lhademmor, I didn't have time to return to this question. I've been too busy to visit EE for a while.  Thanks for the points.

Speaking of your algorithm, this is a slightly different part of the problem.  Deciding how many segments to use.  Theres no single answer, it depends on the usage.  Some cases want reasonable description of the curve in the smallest number of segment, so are concerned with accuracy.  In other cases the segments have to follow rules, maximum angle or minimum distance.

However, my preferred method involves calculating the angles and distances.  A curve goes from point A to point B, you could draw a line between A and B.  The curve leaves point a at some angle from that line and arrives at point B with another angle from the AB line.  The amount of curvature can be described with those angles.

If the curve is almost a straight line between A and B, those angles will be very small, so you will tend to get less segments.  If the curves was actually a straight line, the angles would both be zero, so no dividing segments.

You can also use the distance from A to B, depending on what sort of fitting you want.  A short line might be considered to need fewer segments than a long line.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.