Arcengine marks the line as a cube

Source: Internet
Author: User

3D views in 2D and 3D synchronization must be signed into 3D elements by using two-dimensional elements. In the previous project test, this self-generated tubular circle is used temporarily:

Esrisimple3dlinestyle axisstyle = esrisimple3dlinestyle. esris3dlstube; is symbolic, but this built-in style cannot be expanded more. You still need to manually graphic it. Today, I spent half a day reading the official example, at last, the line symbol connecting the two points of the specified coordinate was merged into a cube, and some problems were encountered in the middle. I thought arcengine provided a very good API. I only used to input two vertices or a line, and then gave it a polygon, which could help me draw a cube along the line, however, if the location is incorrect or the angle is incorrect, the official example is too simple and cannot be used in my application, so I analyzed the cause and used the following three steps:

 

Step 1: The space has a root line, and the start and end points are certainly available. I want to mark the line as a cube, so the length of the two points must be used. We will draw a cube along the zcoordinate at the coordinate origin. The height is the length of the Line mentioned above.

Step 2: assume that the starting point of the line is (0, 0, 0), that is, the custom origin. Through the ivector3d interface, it is easy to get the offset angle of the line. In this way, the cube above is rotated twice at the origin to obtain the correct line segment direction.

Step 3: Move the cube in step 2 to the starting position to complete the process.

 

C # code
  1. Public static igeometry getcubetubebylinepoint (ipoint fpoint, ipoint tpoint, double width, double height)
  2. {
  3. // Ipoint fpoint = geometryutilities. constructpoint3d (5, 6, 3 );
  4. // Ipoint tpoint = geometryutilities. constructpoint3d (15, 13, 13 );
  5. // Calculate the coordinates --> move the coordinate origin
  6. Ivector3d tarpointv3d = geometryutilities. constructvector3d (tpoint. X-fpoint. X, tpoint. Y-fpoint. Y, tpoint. Z-fpoint. z );
  7. // Define the axis for two rotations
  8. Ivector3d axisofrotationvector3d_y = geometryutilities. constructvector3d (0, 10, 0 );
  9. Ivector3d axisofrotationvector3d_z = geometryutilities. constructvector3d (0, 0, 10 );
  10. // Define a line segment
  11. Iline extrusionline = new lineclass ();
  12. Extrusionline. frompoint = fpoint;
  13. Extrusionline. topoint = tpoint;
  14. Double mytoz = extrusionline. length; // Line Segment Length
  15. // Initialize the section shape
  16. Ipointcollection polygonpointcollection = new polygonclass ();
  17. Polygonpointcollection. addpoint (geometryutilities. constructpoint2d (-(height/2), (width/2), ref _ missing, ref _ missing );
  18. Polygonpointcollection. addpoint (geometryutilities. constructpoint2d (height/2), (width/2), ref _ missing, ref _ missing );
  19. Polygonpointcollection. addpoint (geometryutilities. constructpoint2d (height/2),-(width/2), ref _ missing, ref _ missing );
  20. Polygonpointcollection. addpoint (geometryutilities. constructpoint2d (-(height/2),-(width/2), ref _ missing, ref _ missing );
  21. Ipolympus Gon polygon = polygonpointcollection as ipolympus gon;
  22. Polygon. Close ();
  23. Igeometry polygongeometry = polygonpointcollection as igeometry;
  24. Itopologicaloperator topologicaloperator = polygongeometry as itopologicaloperator;
  25. Topologicaloperator. Simplify ();
  26. // Perform Extrusion
  27. Iconstructmultipatch constructmultipatch = new multipatchclass ();
  28. Constructmultipatch. constructextrudefromto (0, mytoz, polygongeometry );
  29. // Rotation Angle
  30. Itransform3d transform3d = constructmultipatch as itransform3d;
  31. Transform3d. rotatevector3d (axisofrotationvector3d_y, tarpointv3d. inclination );
  32. Transform3d. rotatevector3d (axisofrotationvector3d_z, geometryutilities. getradians (90)-tarpointv3d. Azimuth );
  33. // Move to the start point
  34. Transform3d. move3d (fpoint. X, fpoint. Y, fpoint. z );
  35. Return constructmultipatch as igeometry;
  36. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.