A method and system for pattern filling when drawing a geological map
Patent Information
- Application Number
- CN202610973641.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-01
- Publication Date
- 2026-09-22
AI Technical Summary
用户往往需要在不同的工具或模式之间频繁切换,打断了创作的连续性
(1)提升绘图效率与精度:通过智能几何捕捉技术,用户无需进行像素级的精确操作即可快速构建出首尾相连的精确几何图形,将绘制闭合多边形的效率大幅提升,并保证了图形的数学严谨性。
Smart Images

Figure CN122798918A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer graphics and mobile application development technology, specifically referring to a method and system for pattern filling when drawing geological maps. Background Technology
[0002] In fields such as geological exploration, mineral development, and geological teaching, it is frequently necessary to create geological cross-sections, plan views, and other maps that include specific lithological patterns. Currently, this requirement is primarily met through the following methods: Manual hand-drawing: This method requires high professional skills from the drafter, who must be familiar with various rock texture symbols. It is inefficient, inconsistent, difficult to modify and copy, and the quality of the drawings depends on the individual's skill level.
[0003] Professional desktop software, such as AutoCAD and MapGIS, with professional geological symbol libraries, is powerful but complex to operate, has a high learning cost, requires paid licenses, and cannot quickly sketch in mobile scenarios.
[0004] General drawing applications: easy to use but lacking in geological professional functions, lacking precise line segment connections, quick construction of irregular polygons, and automatic filling of standard lithological patterns. Manual drawing is tedious, inefficient, and has poor accuracy.
[0005] Existing graphic filling technologies require users to predefine complete closed polygon paths. The filling algorithms are rigid and cannot handle imprecise geometric shapes generated by free drawing. This results in problems such as low drawing efficiency, poor geometric accuracy, inflexible filling functions, and fragmented workflows, making it difficult to meet the needs of efficient and standardized drawing of geological maps on mobile devices.
[0006] Based on the technology, existing methods mainly have the following problems and shortcomings: Inefficient drawing: It is extremely difficult to draw closed polygons accurately on mobile devices. Users need to repeatedly adjust control points to ensure that line segments are connected end to end, which is time-consuming and laborious.
[0007] Lack of geometric intelligence: General drawing applications lack a "snap" function, resulting in gaps or intersections between drawn line segments, making it impossible to form an effective closed area, which poses a fundamental obstacle to subsequent pattern filling.
[0008] The filling function is rigid: existing filling technologies either do not support custom patterns (such as only supporting solid colors or simple textures) or cannot flexibly adjust the density, angle and size of the filling pattern, making it difficult to meet the standardized requirements for lithological patterns in geological maps.
[0009] The workflow is disjointed: from drawing lines to drawing areas, and then to filling patterns, the entire process is fragmented. Users often need to switch frequently between different tools or modes, disrupting the continuity of creation. Summary of the Invention
[0010] The purpose of this invention is to address the shortcomings of existing technologies and provide a method and system for generating lithological patterns based on interactive line segment capture and dynamic pattern filling. By using real-time geometric endpoints and line segment capture algorithms to assist in the rapid and accurate construction of closed polygons, and integrating an adjustable pattern filling engine to automatically identify closed areas and fill them with standard lithological patterns, the invention lowers the threshold for drawing professional geological maps and improves drawing efficiency and standardization.
[0011] To achieve the above objectives, the present invention adopts the following technical solution: Users draw straight or curved lines on a touchscreen canvas by dragging and dropping. The system monitors the coordinates of the touch point in real time, performs two-level geometric snapping calculations, prioritizes snapping the drawn point to the endpoint of an existing line segment, and secondarily snaps it to the nearest point of an existing line segment, while simultaneously calculating the line segment angle. When the user clicks on the endpoint of an already drawn line segment, the system selects polygon vertices based on the click location and a hit threshold, automatically adds smooth connections to the midpoints of continuous curve segments, and constructs a closed polygon region. The user selects pattern materials from a built-in lithological pattern library or a local image library, configuring the pattern size, spacing, and rotation angle parameters. The system constructs a closed path based on the vertices of the closed polygon and performs region clipping. Through overall coordinate system transformation, it achieves uniform pattern rotation and, combined with safe expansion distance calculation, completes a seamless tiling fill, generating a geological map with standard lithological patterns.
[0012] Furthermore, the two-level geometric snapping calculation sets a fixed pixel snapping threshold, prioritizes endpoint snapping to force vertex sharing and correct line segment topology errors, and then performs line segment snapping to achieve visual alignment; the projection of a point to the nearest point of a line segment is determined by vector dot product calculation, and the projection of a point to the nearest point of a curve is determined by traversing the curve sampling points to calculate the minimum distance.
[0013] Furthermore, the construction of closed polygon regions does not require prior entry into polygon drawing mode. Instead, it adopts a reverse interaction model that first allows free drawing of line segments and then clicking on the endpoints to aggregate them. This automatically identifies valid closed regions with more than 2 vertices and triggers the pattern filling control.
[0014] Furthermore, the region clipping and coordinate system transformation include: strictly limiting the drawing range to the closed polygon path using the canvas clipping function; translating the canvas origin to the geometric center of the polygon, rotating the canvas at the user-defined angle, and then moving back to the origin to achieve a one-time overall rotation of all patterns; calculating the safe expansion distance based on the width, height, and pattern tiling step of the polygon's bounding rectangle to ensure no blank filling after rotation.
[0015] Furthermore, the pattern tiling step size is the sum of the pattern size and the pattern spacing, and the safe expansion distance is the sum of half the diagonal of the circumscribed rectangle and the maximum tiling step size. This determines the traversal drawing range and iterates the tiling according to the step size.
[0016] Furthermore, the pattern materials support SVG and image formats, the fill parameters are adjusted in real time, and the generated geological maps conform to the industry standards for lithological patterns.
[0017] This invention also provides a system for pattern filling when drawing geological maps, comprising: an interactive drawing module for receiving touch drag commands on a touchscreen device to draw straight line segments or curve segments; a geometric snapping module for performing two-level real-time geometric snapping calculations to achieve the snapping of drawing points to the endpoints of existing line segments and the nearest points of the line segments, ensuring the topological consistency of the line segments; a closed region construction module for responding to user endpoint click operations, selecting vertices and adding curve midpoints to dynamically generate closed polygons; a pattern configuration module for providing lithological pattern selection entry and size, spacing, and rotation angle parameter adjustment controls; and a fill rendering module for performing region clipping, overall coordinate system transformation, safe extension distance calculation, and pattern tiling to complete the pattern filling of the geological map area.
[0018] Furthermore, the system is implemented based on the Flutter framework, integrating a coherent workflow of drawing, building, filling, and exporting, and is suitable for field geological sketching and on-site mapping on mobile devices such as mobile phones and tablets.
[0019] Furthermore, the fill rendering module achieves overall pattern rotation through coordinate system translation, rotation, and return, reducing the computational complexity from O(n) to O(1) and improving mobile rendering performance.
[0020] Furthermore, the system supports the expansion of the lithological pattern library, and the pattern filling algorithm can be adapted to custom pattern filling scenarios in other fields.
[0021] The beneficial effects achieved by the present invention using the above structure are as follows: (1) Improve drawing efficiency and accuracy: Through intelligent geometric snapping technology, users can quickly construct accurate geometric figures with connected ends without performing pixel-level precise operations, which greatly improves the efficiency of drawing closed polygons and ensures the mathematical rigor of the figures.
[0022] (2) Achieve professional and standardized pattern filling: Provides lithological pattern filling solutions for the geological industry. The filling pattern, density and angle can be flexibly adjusted according to industry standards, and the generated drawings meet professional requirements.
[0023] (3) Optimize the user experience on mobile devices: integrate drawing, building, filling and exporting into a seamless and coherent workflow. The operation is intuitive and simple, making it particularly suitable for field geological sketching or on-site reporting on mobile devices such as mobile phones and tablets.
[0024] (4) It has good scalability: the system architecture is clear, the pattern library can be easily expanded, and the filling algorithm is not limited to the geological field. With a little modification, it can be used in various other scenarios that require custom pattern filling. Attached Figure Description
[0025] Figure 1 This is a technical roadmap for a lithological pattern generation method based on interactive line segment capture and dynamic pattern filling proposed in this invention. Figure 2 This is an interface diagram of a lithological pattern generation system based on interactive line segment capture and dynamic pattern filling proposed in this invention. Detailed Implementation
[0026] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0027] In the description of this invention, it should be understood that the terms "upper", "lower", "front", "rear", "left", "right", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.
[0028] Example 1 A method for pattern filling when drawing geological maps, the specific steps of which are as follows: When a user performs a touch drag gesture on the touchscreen device canvas, the touch point coordinates P are monitored in real time. Two levels of geometric snap calculations are performed at the start of the touch and during the movement phase, with the snap threshold set to 25px. The drawing point is first snapped to the endpoint of an existing line segment, and then snapped to the nearest point of the line segment. At the same time, the angle of the drawn line segment is calculated using a formula to ensure drawing accuracy.
[0029] When a user clicks on an endpoint of a drawn line segment, the system selects polygon vertices based on the click location and the hit threshold, automatically adds the midpoints of continuous curve segments to achieve a smooth connection, and constructs a closed polygon region. When the number of vertices is greater than 2, the pattern fill control is automatically displayed.
[0030] Users can select SVG or image-format patterns from the built-in lithological pattern library or local image library using the pattern selection control, and adjust the pattern size, spacing, and rotation angle parameters.
[0031] The system constructs closed paths based on the vertices of closed polygons and uses a canvas clipping function to limit the drawing range. The canvas origin is translated to the geometric center of the polygon, the canvas is rotated by a set angle, and then the origin is moved back to achieve overall pattern rotation. The safe expansion distance is calculated based on the width and height of the circumscribed rectangle and the tiling step size. The pattern is tiled iteratively according to the step size to complete the no-blank filling and generate the final geological map.
[0032] Example 2 A system for pattern filling when drawing geological maps, implemented based on the Flutter framework, includes: Interactive drawing module: Receives user touch and drag commands to draw straight line segments and curve segments on the mobile canvas, and supports switching the curve drawing on / off switch.
[0033] The geometry snapping module executes a real-time two-level geometry snapping algorithm, prioritizing endpoint snapping and then line segment snapping, correcting line segment topology errors, and ensuring graphic accuracy.
[0034] Closed region construction module: Responds to user endpoint clicks, aggregates vertices and adds curve midpoints to dynamically generate valid closed polygons.
[0035] Pattern configuration module: Provides a built-in pattern library and a local material import entry, and supports real-time adjustment of pattern size, spacing, and rotation angle.
[0036] Fill rendering module: Performs region clipping, coordinate system transformation, safe extension distance calculation and pattern tiling, efficiently completes pattern filling, and supports saving and exporting of images.
[0037] To better understand the working process of a method and system for pattern filling when drawing geological maps according to an embodiment of this application, the system is implemented within the Flutter framework, as described above. Figures 1-2 The following is a specific embodiment: Step 1. User interacts to draw line segments or curves, and performs real-time geometric snap calculations. When a user performs a touch drag gesture on the canvas, the coordinates P of the touch point are monitored in real time. During the touch start (onPanStart) and movement (onPanUpdate) events, geometric snap calculations are performed, simultaneously calculating the angles of line segments to ensure drawing accuracy. Geometric snap calculations automatically snap the drawing point to the endpoint of an existing line segment (curve) or the nearest point on the line segment; the snap threshold is set to a fixed pixel value.
[0038] The formula for calculating the angle is: Where (x1, y1) is the starting point and (x2, y2) is the ending point.
[0039] Point Snapping Algorithm: During the drawing process, the system automatically snaps to the endpoints or the closest point on existing lines (line segments, curves), the snapping threshold is set to a fixed pixel value _snapThreshold=25px.
[0040] The calculation formula for the projection of the closest point from a point to a line segment is: Given a line segment AB, a point P, the vector , dot product
[0041] a. If t ≤ 0, the closest point is A b. If t ≥ 1, the closest point is B c. 0<t<1, the coordinates of the projection point are: .
[0042] Calculation formula for the coordinates of the closest projection point from a point to a curve:
[0043] Step 2. Select the endpoints of the surface to be filled, and construct the closed surface to be filled By clicking the screen, the endpoint of an existing line is found according to the position of the clicked point and the hit threshold. If found, it is taken as an endpoint of the polygon to be filled with a pattern, and the system automatically adds intermediate points on the continuous curve segment to achieve smooth connection.
[0044] Step 3. The user selects the pattern to be configured User pattern selection control: supports selecting SVG or images as filling patterns from the local gallery and built-in pattern library. Users can adjust the parameters of the pattern through the pattern setting button. These parameters include the basic size of the pattern imageSize, the spacing spacing, and the display rotation ratationAngle.
[0045] Step 4. Execute the filling algorithm Through the above steps, the endpoints selPoints of the closed surface to be filled and the pattern data imageData to be filled into the surface can be obtained. Next, the pattern image needs to be cropped and tiled. This is also the core algorithm of the present invention. Before filling, the system first constructs a closed path according to the polygon vertices and performs area clipping to ensure that the pattern does not exceed the boundary. The entire pattern is rotated around the area center, and the calculation formula of the rotation center is:
[0046] Canvas transformation and filling: Use the canvas clipping function to strictly restrict subsequent drawing operations within the specified path area. Only pixels falling within the path range will be actually drawn, and pixels outside the path range will be discarded.
[0047] The canvas coordinate system origin is translated to the center of the area, then the entire canvas is rotated according to the user-defined angle `ratationAngle`, and finally the origin is translated back. This achieves the overall rotation of all fill patterns.
[0048] To ensure that the rotated pattern completely covers the original polygonal region, this algorithm introduces the concept of a safe extension distance. This distance is calculated based on the geometric characteristics of the original region: first, the bounding rectangle of the region is obtained, and its diagonal length is calculated as the maximum possible displacement; then, a pattern step size is added as a drawing margin.
[0049] Calculation of tiling step length:
[0050] Where w and h are the sizes of the patterns set by the user, and s is the spacing between the patterns set by the user.
[0051] The final safe extension distance is:
[0052] Where W and H are the width and height of the bounding rectangle of the original region, respectively, and s is the pattern and the spacing between patterns set by the user. The drawing area obtained by expanding outwards from this distance mathematically guarantees that even for extremely long and narrow graphics, no blank fill can be achieved at any rotation angle.
[0053] Draw the pattern using tiling. Based on the polygon's extent and the required expansion distance, calculate the four endpoints of the outer rectangle: left, right, top, and bottom. In the rotated coordinate system, starting from the starting point of the bounding box... Initially, an iterative tiling method with stepX and stepY as steps is used to draw the pattern within the rectangular area at that position.
[0054] Iteration range: for
[0055] for
[0056] After the drawing is completed, restore the rotation transformation of the canvas.
[0057] The core innovation and protection focus of this invention patent lies in proposing and implementing a complete technical system suitable for mobile touch screen environments, from free sketches to standardized drawings. Its key value is reflected in the following four aspects.
[0058] 1. Innovation in Interaction Models: A Dynamic Polygon Construction Method Based on Discrete Capture and Click Aggregation Unlike the traditional drawing software's "pre-defined polygon drawing mode" interaction process, this invention pioneers a reverse construction model of "first draw freely, then define by clicking." The system ensures the geometric accuracy of drawn elements through real-time geometric capture; the user then dynamically aggregates and forms polygonal regions by tapping the endpoints of drawn line segments. This model better aligns with the human cognitive habit of "first outlining the contours, then defining the regions" when sketching, significantly reducing the cognitive load and operational difficulty of accurately constructing complex closed regions on a touchscreen.
[0059] 2. Innovation in core algorithms: A real-time two-level geometry capture algorithm that ensures topology consistency. The capture algorithm of this invention is not a simple spatial nearest point query; its core lies in solving topological errors in free drawing. The algorithm adopts a two-level priority strategy: Endpoint capture: Prioritize the overlap of new line segment endpoints with existing endpoints, forcing vertex sharing, fundamentally correcting topological errors between line segments, and laying the foundation for building an effective polygon network.
[0060] Line segment snapping: This feature snaps new endpoints to the nearest point on existing line segments, resolving visual alignment issues related to near-collinearity and improving overall consistency. This algorithm, combined with a perception threshold, achieves an optimal balance between the uncertainty of touch input and the accuracy of professional graphics, making it crucial for intelligent sketching.
[0061] 3. Innovation in rendering algorithms: A method for filling clipping regions based on global coordinate system transformation. Filling rotatable custom patterns within a limited, arbitrary polygonal region presents multiple challenges in terms of cropping accuracy and computational efficiency. This invention proposes a novel rendering method.
[0062] Hard clipping priority: First, use canvas clipping to strictly control the drawing area within the target closed surface, logically absolutely preventing overflow.
[0063] Overall transformation replaces local transformation: By translating-rotating-translating the canvas coordinate system, all filled patterns can be rotated at once. Compared with rotating each pattern instance, the computational complexity is reduced from O(n) to O(1), which greatly improves rendering performance and complexity.
[0064] Extended Traversal Guarantees No Omissions: This invention proposes a pattern filling algorithm with mathematical completeness guarantees. By analyzing the spatial positional relationships of arbitrary polygons after rotation, a precise formula for calculating the safe extension distance is derived. This formula, based on the radius of the circumcircle of the original region and the pattern step size, theoretically proves the completeness of the filling result, completely solving the problem of blank gaps that may occur under extreme graphics and rotation angles. This method achieves high-performance pattern filling on mobile devices while ensuring accurate results.
[0065] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0066] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
[0067] The present invention and its embodiments have been described above. This description is not restrictive, and the accompanying drawings are only one embodiment of the present invention; the actual structure is not limited thereto. In conclusion, if those skilled in the art are inspired by this description and design similar structures and embodiments without departing from the spirit of the invention, such designs should fall within the protection scope of the present invention.
Claims
1. A method for pattern filling when drawing geological maps. Its features are, Includes the following steps: S1, the user draws a straight line or curve segment on the canvas of the touch screen device by touching and dragging. The system listens to the coordinates of the touch point in real time and performs two-level geometric snap calculations. It prioritizes snapping the drawing point to the endpoint of the existing line segment, and secondarily snaps it to the nearest point on the existing line segment. At the same time, it calculates the angle of the drawn line segment. S2, when the user clicks on the endpoint of the drawn line segment, the system selects the vertices of the polygon based on the click location and the hit threshold, and automatically adds the midpoints of the continuous curve segments to connect them smoothly and construct a closed polygon region. S3 allows users to select pattern materials from the built-in lithological pattern library or local image library, and configure the pattern size, spacing, and rotation angle parameters; S4: The system constructs closed paths based on the vertices of closed polygons and performs region clipping. It achieves uniform rotation of patterns through overall coordinate system transformation and completes blank-free tiling filling by combining safe extension distance calculation, generating geological maps with standard lithological patterns.
2. The method according to claim 1 Its features are, The two-level geometric snap calculation sets a fixed pixel snap threshold, prioritizes endpoint snapping to force vertex sharing and correct line segment topology errors, and then performs line segment snapping to achieve visual alignment. The projection of a point onto the nearest point of a line segment is determined by calculating the vector dot product, and the projection of a point onto the nearest point of a curve is determined by calculating the minimum distance by traversing the sampling points of the curve.
3. The method according to claim 1 Its features are, The construction of the closed polygon region does not require prior entry into polygon drawing mode. It adopts a reverse interaction model of first freely drawing line segments and then clicking the endpoints to aggregate them. It automatically identifies valid closed regions with more than 2 vertices and triggers the pattern filling control.
4. The method according to claim 1 Its features are, The region clipping and overall coordinate system transformation include: The canvas clipping function strictly limits the drawing area to the closed polygon path; The canvas origin is translated to the center of the polygon geometry, the canvas is rotated at the user-defined angle, and then the origin is returned to achieve a one-time overall rotation of all patterns. The safe expansion distance is calculated based on the width and height of the bounding rectangle of the polygon and the tiling step of the pattern to ensure that there is no blank filling after rotation.
5. The method according to claim 4 Its features are, The pattern tiling step size is the sum of the pattern size and the pattern spacing. The safe expansion distance is the sum of half the diagonal of the circumscribed rectangle and the maximum tiling step size. This determines the traversal drawing range and iterates the tiling according to the step size.
6. The method according to claim 1 Its features are, The pattern material supports SVG and image formats, the fill parameters are adjusted in real time, and the generated geological map conforms to the industry standard for lithological patterns.
7. A system for pattern filling when drawing geological maps. Its features are, include: Interactive drawing module: used to receive touch drag commands on touch screen devices and draw straight line segments or curve segments; The geometry snapping module is used to perform two-level real-time geometry snapping calculations, enabling drawing points to snap to the endpoints of existing line segments and the nearest points of the line segments, ensuring the topological consistency of the line segments. Closed region construction module: used to respond to user endpoint click operations, select vertices and add curve midpoints to dynamically generate closed polygons; Pattern configuration module: provides an entry point for selecting lithological patterns and controls for adjusting parameters such as size, spacing, and rotation angle; Fill rendering module: Used to perform region clipping, coordinate system transformation, safe extension distance calculation and pattern tiling to complete the pattern filling of geological map areas.
8. The system according to claim 7 Its features are, The system is based on the Flutter framework and integrates a coherent workflow of drawing, building, filling, and exporting. It is suitable for field geological sketching and on-site mapping on mobile devices such as mobile phones and tablets.
9. The system according to claim 7 Its features are, The filling rendering module achieves overall pattern rotation through coordinate system translation, rotation, and return, reducing the computational complexity from Om to O1 and improving mobile rendering performance.
10. The system according to claim 7 Its features are, The system supports the expansion of the lithological pattern library, and the pattern filling algorithm can be adapted to custom pattern filling scenarios in other fields.