Wish - SHRINKWRAP COGO Points in Point Group

It would be nice to draw a polyline around a group of COGO points.

Comments

  • If you were to consider third party add-ons, DotSoft's MapWorks for BricsCAD Civil contains multiple methods to shrinkwrap the CivilPoint objects found in v24 or higher.

  • In case you did not know Terry Dotson passed away in 2024. I'll miss him and his brilliant solutions to common CAD tasks. Carlson Software has acquired the assets of DotSoft.

  • Tom Foster
    edited July 14

    ……..

  • Hi ALANH. Good suggestion. The input is coplanar points. Civil Points are probably not coplanar most of the time. I was thinking a surface from a point group then extracting the surface boundary would be a workaround for the moment.

  • Here you find a plugin exposing 2 commands , CONVEXHULL2D and CONVEXHULL3D .
    It is programmed in a "quick and dirty" mode, therefore it might generate errors if the selected points are not accepted by the algorithms…in this case an error message pops up similar to

    The 2D Convex Hull is based on GrahamsScan algorithm and is a polyline, the 3D Convex Hull is based on the MIConvexHull algorithm which is technically an implementation of the QuickHull algorithm and is a mesh(SubDMesh) , You find more information at
    https://designengrlab.github.io/MIConvexHull/
    https://github.com/DesignEngrLab/MIConvexHull
    It is very fast for me …..
    You find attached the plugin with ConvexHull2D3D.dll and MIConvexHull.dll in a ZIP archiv and the test DWG. Save both in a directory and load the ConvexHull2D3D.dll with the NETLOAD command.
    Call the commands at the command line…..
    In the screenshot you see the convex hull (2d, 3d) of different groups of points.
    Attached is also the test file used.



  • An alternative is to use scipy.spatial, which may have other goodies

    import traceback
    from pyrx import Ap, Ax, Db, Ed, Ge, Gi, Rx
    
    # maybe has other usful tools
    from scipy.spatial import ConvexHull
    
    @Ap.Command()
    def doit() -> None: # change me
        try:
            db = Db.curDb()
            
            ps, ss = Ed.Editor.select([(0, "POINT")])
            if ps != Ed.PromptStatus.eOk:
                raise RuntimeError("Selection Error! {}: ".format(ps)) 
    
            # get all the positions 
            pnts = [Db.Point(id).position() for id in ss.objectIdArray()]
            
            # compute the hull with a Z of zero
            hull = ConvexHull([pnt.to2d().toTuple() for pnt in pnts])
            
            # extract the hull points using indexs
            segs = []
            for simplex in hull.simplices:
                segs.append(Ge.LineSeg3d(pnts[simplex[0]],pnts[simplex[1]]))
                
            # create a composit curve 
            results = Ge.CompositeCurve3d.createFromLineSeg3dArray(segs)
            for item in results:
                # BricsCAD will create a 3d polyline if the points arn't planar
                dbo = Db.Core.convertGelibCurveToAcDbCurve(item)
                db.addToCurrentspace(dbo)
    
        except Exception as err:
            traceback.print_exception(err)
    
    

  • The command CONVEXHULL2D creates the convex hull for a set of 3D points as well !

  • ALANH
    edited July 28

    Having spent way to many years playing with TIN's there is an error in the convex hull shape if you look closely at the image the boundary skips across a large indent, lower left, a true boundary would actually follow this shape.

    One other way is to use the TINS to make an outer shape but its not quick as you need to get rid of long triangles. Make a 3dfaces and so on.

    The main reason for wanting boundary is when comparing to another surface eg Volumes.

  • That’s not an error in convex hull, if you want to pick that up, you’d have to use a concave hull.  
    I played with the C++ port of concaveman https://github.com/mapbox/concaveman
    
    I used this to create a constrained TIN
    https://www.theswamp.org/index.php?topic=57122.msg607079#msg607079
    https://www.theswamp.org/index.php?topic=57122.msg607153#msg607153
    
    Note the caveats, 
    - most all concavity routines require user input, i.e. concavity and lengthThreshold
    - can start to generate islands on some point sets, though it the pointset is uniform it’s not an issue 
    

  • Supplementary to the above, i would like to point out that the functionality of creating a concave hull 2D is available via the TIN, TINEDIT and TINEXTRACT command…

    1. create a TIN using a set of points, a group of points or a point cloud

    :TIN
    Select entities to create TIN surface or [Import from file/place Points/create from Faces/create from point Cloud/create from point Groups/create from cOntours/create from Mesh/cLip polygon/selection options (?)]:
    Opposite Corner:
    Entities in set: 4202

    2. Remove the outer edges thus creating the outer concave hull boundary of the tin surface using the TINEDIT command

    : TINEDIT
    Select TIN surface [selection options (?)]:
    [Add Points/Add Point Groups/Add Breaklines/Add bOundaries/Remove Points/Swap Edge/Point Location/Point Elevation/Add Line/Delete Line/Remove Outer Edges/Minimize Flat Areas/Remove Elevations/SMoothing]: ROE
    Define
    concavity and lengthThreshold in the pop-up window


    3. Extract a concave hull 2D (3d polyline) of the tin surface boundary using the TINEXTRACT command

    : TINEXTRACT
    Select Surface [selection options (?)]:
    Entities in set: 1
    Select Surface [selection options (?)]:

    Extracting ...

    Extracting borders: 1 entities extracted.
    Total entities extracted: 1.