there is a line and line string which is intersect at different points. how to check whether the line intersect the line string at a point where there is vertex or not. if not how to insert vertex in line string?
Unknown said:there is a line and line string which is intersect at different points
Surely they intersect at the same point? That is the definition of an intersection.
Perhaps you mean that the line-string and the line have multiple intersections. That would be true if the line-string zig-zags and crosses the line several times.
However, rather than have us guess the true meaning of your question, why not post a small DGN model that illustrates the problem?
Regards, Jon Summers LA Solutions
here i ve attached a dgn file.
Regards
Sajan
OK: you've provided a MicroStation/J file that contains a single 3D model (V7 — any particular reason?). There is a single red line element and a single green line string element. They appear to be co-planar.
Now you have to work out where the intersection points lie in relation to your element's vertices. Create a new, elastic, array to hold the copied vertices. You need to build a new array of vertices, copying from the existing array, and inserting a new intersection vertex each time you find a co-linear match.
Finally, create a new line string element from your modified array of vertices.
4314.example.dgn
same problem but the condition is different. attached a dgn file, there is a linestring and lines that intersect the linestring, Now i want to insert the intersecting points of line into the linestring. I ve tried by using distance but could not get success. How to solve this?
Unknown said:I've tried by using distance but could not get success
What have you tried? Show some code.
if(SUCCESS == mdlSelect_returnPositions(&filePosArray,&modelRefArray,&m)) { for(i=0;i<m;i++) { mdlElmdscr_readToMaster (&pObject, filePosArray[i], modelRefArray[i], FALSE, NULL); elemType = mdlElement_getType(&pObject->el); if(LINE_STRING_ELM == elemType) { mdlElement_getProperties(&level, NULL, NULL, NULL, NULL, NULL, NULL, NULL,&pObject->el); mdlElement_getSymbology(&color,&weight,&style,&pObject->el); mdlLinear_extract(points,&numVerts,&pObject->el,modelRefArray[i]); } for(j=i+1;j<m;j++) { mdlElmdscr_readToMaster(&pElmNext,filePosArray[j],modelRefArray[j],FALSE,NULL); number = mdlIntersect_allBetweenElms(ElmA,ElmB,MAX_VERTICES,pObject,pElmNext,NULL,0.0); if(number>0) { intrsect[tmp].x = ElmA->x; intrsect[tmp].y = ElmA->y; tmp++; } } } for(i=0,j=i+1;i<numVerts,j<numVerts;i++,j++) { sumDist = sumDist+sqrt(pow((points[i].x-points[j].x),2)+pow((points[i].y-points[j].y),2)); Distance[p] = sumDist; p++; }
for(i=0,j=i+1;i<tmp,j<tmp;i++,j++) { sumIntrDist = sumIntrDist + sqrt(pow((intrsect[i].x-intrsect[j].x),2)+pow((intrsect[i].y-intrsect[j].y),2)); intrDist[q] = sumIntrDist; q++; }then Distance and intrDist is compared to check whether the intrDist lies between the Distance so that i can keep the coordinates in the linestring..
Unknown said:intrsect[tmp].x = ElmA->x; intrsect[tmp].y = ElmA->y;
Assuming that intrsect is an array of DPoint3d, then simply do this …
intrsect[tmp] = *ElmA;
Unknown said: I want to insert the intersecting points of line into the linestring. I've tried by using distance but could not get success
I'm having trouble correlating your requirement with your implementation. I don't see how distance is involved.
You need to …
Unknown said: for each intersection insert the intersection coordinate into your elastic array finally, create a new line-string from your modified vertex list
The main problem is how to insert the intersection coordinate into the elastic array? the points need to be compared? how to compare them? confused.
Unknown said:The main problem is how to insert the intersection coordinate into the elastic array?
Each intersection point must be colinear with two existing adjacent points. Walk through the vertex list, and examine points[N], intersection-point and points[N+1]. When you find those three points colinear, then insert the intersection point.
mdlVec_colinear will be useful.
can you show me some lines of codes as example?
Unknown said:Can you show me some lines of codes as example?
What about the suggestions I made previously in this thread (28-Aug-14)? Did you attempt to use those?
In that thread (28 Aug 2014) I am confused in these
Examine each pair of vertices (vertex[n] and vertex[n+1])Each intersection point will be co-linear with its adjacent vertices, which you can test using mdlVec_colinear()
two points. Here what to examine in pair of vertices?
Unknown said:I am confused...what to examine in pair of vertices?
#include <embeddeddpoint3darray.fdf> #include <msvec.fdf> BoolInt InsertVertex (EmbeddedDPoint3dArray *pVertices, DPoint3d const* intersection) { BoolInt inserted = FALSE; int nPoints = jmdlEmbeddedDPoint3dArray_getCount (pVertices); int i; for (i = 0; i != nPoints - 1; ++i) { DPoint3d test [3]; jmdlEmbeddedDPoint3dArray_getDPoint3d (pVertices, test + 0, i); test [1] = *intersection; jmdlEmbeddedDPoint3dArray_getDPoint3d (pVertices, test + 2, i + 1); if (mdlVec_colinear (test)) { jmdlEmbeddedDPoint3dArray_insertDPoint3d (pVertices, intersection, i + 1); inserted = TRUE; break; } } return inserted; }
Search the MDL Function Reference for Embedded Arrays to find an overview of the jmdlEmbeddedArray_api.
when i used the above function and compiled it gives the following error message. what's wrong?
### C:\PROGRA~2\Bentley\Program\MICROS~1\mdl\library\builtin.dlo: ####Unresolved symbol jmdlEmbeddedDPoint3dArray_getDPoint3d in C:\PROGRA~2\Bentley\Program\MICROS~1\mdl\objects\line_coordinates.mo.### C:\PROGRA~2\Bentley\Program\MICROS~1\mdl\library\builtin.dlo: ####Unresolved symbol jmdlEmbeddedDPoint3dArray_insertDPoint3d in C:\PROGRA~2\Bentley\Program\MICROS~1\mdl\objects\line_coordinates.mo.### C:\PROGRA~2\Bentley\Program\MICROS~1\mdl\library\builtin.dlo: ####Unresolved symbol jmdlEmbeddedDPoint3dArray_getCount in C:\PROGRA~2\Bentley\Program\MICROS~1\mdl\objects\line_coordinates.mo.### C:\PROGRA~2\Bentley\Program\MICROS~1\mdl\library\builtin.dlo: Unrecoverableerrors detected. Output file not created.
Unknown said: I used the above function and compiled it gives the following error message
There is no compiler error.
Unknown said:### C:\PROGRA~2\Bentley\Program\MICROS~1\mdl\library...
The clue lies in that message. It's the linker that is complaining about functions such as jmdlEmbeddedDPoint3dArray_getDPoint3d.
While you've added the appropriate #include directive to your source files, you haven't added the relevant library directives to your bmake file. Look at the MDL Function Reference help for that function and note the Required Header and Required Library. You already have the right header, and you must add the required library (mtg.lib) to the list of libs in your .mke file.
tried this but still could not get the goal. and in my mdl api function reference there is no any jmdlEmbeddedArray_* functions.
Unknown said:tried this but still could not get the goal
It's not clear what you've tried and what goal you have failed to reach.
Your previous post tells us that you compiled some code that uses jmdlEmbedded_arrays, but failed to link. I advised you to include the library file mtg.lib in your make file. Have you succeeded in building your application?
Unknown said:in my mdl api function reference there is no any jmdlEmbeddedArray_* functions
jmdlEmbedded_arrays have been around since MicroStation/J. Can you see header file embeddeddpoint3darray.fdf in your \mdl\include folder? Can you see library file mtg.lib in your \mdl\library folder?