Random Choice of factors. Here we only process 20% and 80%.

Source: Internet
Author: User

----- There is also a random choice of familiarity
---- This idea is relatively clear. Determine if it is poly MRSH to the surface level.
--- 2. Collect all the arrays. There are two cases
--- 3 I want to randomly select 100 faces, and I want to incrementally select 100 faces.
--- I am. Random 1 to familiar. How many times are selected and added to the array
---- And we cannot call the array already exists. That's all.
--- The following is a "variant" function, which is actually good. I think so.
--- 1. Know the number of factors in poly and determine the number of factors in which the number of faces is located. In this way, when selecting the corresponding number of factors, there may be multiple aspects in one factor.
--- 2. In this case, it is better to say that the factor is unique.
-- Start to write the function immediately.
-- Very important. Then the function is executed at the poly layer. It is also processed at the grassroots level. Above this base layer
-- Random vertex line surface. That is to say, if I have selected a dot and line plane in advance, it will be processed randomly at the selected grass-roots layer, and if not, it will be processed globally.
-- In fact, another factor is random. This was also important later. Remember this.
-- In the selection, I add 10% for processing, but it must be converted to an integer at that time. Because of the edge points, there is no. A few issues.
FN poly_random_type input_poly type count_t percentage = -- the function is a random selection factor. Type is the type of the factor (the last one that is not considered for the moment)
-- Count_t: percent of the quantity of percentage. Input_poly
(
Case of --- this is my manual processing. So here I will only list 3 cases for processing.
(

(Type = "vertex "):(

Local vertes_count _ = #()
------ There are two options: quantity and %. Finally, I need the most event in the UI.
---- When count_t percentage is not zero at the same time, the error reporting mechanism is triggered. When count_t = 0 then percentage = 10 when percentage = 0 then count_t = 1
---- Select and process the selected type. Still not selected for processing.
--- Select the number first
If percentage = 0 and count_t = 0 then return false
If percentage! = 0 and count_t! = 0 then return false --- this error reporting mechanism is fine.

If percentage = 0 and count_t! = 0 then ----- Number of picks.
(
Local back_verts_array
--- View the selected vertex in two cases. If the array is null or not, it is divided into global and local relations.
Total_verts_array = polyop. getnumverts input_poly
--- Number of global vertices, and the selected array.
If count_t> total_verts_array then count_t = total_verts_array ------ ensure that the number of inputs does not exceed the standard
Back_verts_array = polyop. getvertselection input_poly

If (back_verts_array as array). Count = 0 then --- Global Selection
(
For I in 1 to count_t do
(
--- The unique array mechanism should be added here
Random_count = random 1 total_verts_array
If finditem vertes_count _ random_count = 0 then
(
--- Because I have no cyclic points. Therefore, you do not need to add the undefined mechanism. When the query plane returns the vertex function, sometimes there are more faces, but finding vertices on the circular plane is
--- Undefined, which must be remembered by yourself.
Append vertes_count _ random_count
) --- End if finditem

) --- End for total


) --- End back
If (back_verts_array as array). Count! = 0 then --- Global Selection
(
Back_verts_array = (back_verts_array as array) -- this method is temporary.

If count_t> back_verts_array.count then count_t = back_verts_array.count ------ ensure that the number of inputs does not exceed the threshold
For I in 1 to count_t do -- defines the number of inputs.
(
Random_count = back_verts_array [(random 1 back_verts_array.count)] ---- number of points in the local area.

If finditem vertes_count _ random_count = 0 then
(
--- Because I have no cyclic points. Therefore, you do not need to add the undefined mechanism. When the query plane returns the vertex function, sometimes there are more faces, but finding vertices on the circular plane is
--- Undefined, which must be remembered by yourself.
Append vertes_count _ random_count
) --- End if finditem
 
) --- End for I in 1 to count_t ..
 
) ---- End if back


) --- End if percenntage
If percentage! = 0 and count_t = 0 then ---- % ratio, this is good.
(
--- % The actual situation can be exactly the same as the previous one. Let's calculate the array line of %.
Local back_verts_array, total_verts_array
--- View the selected vertex in two cases. If the array is null or not, it is divided into global and local relations.
Total_verts_array = polyop. getnumverts input_poly
--- Number of global vertices, and the selected array.
/*
Percentage_count = total_verts_array * Percentage/100
Percentage_count = percentage_count as integer
If percentage_count> total_verts_array then percentage_count = total_verts_array ------ ensure that the number of inputs does not exceed the standard
*/
Back_verts_array = polyop. getvertselection input_poly

If (back_verts_array as array). Count = 0 then --- Global Selection
(
Percentage_count = total_verts_array * Percentage/100
Percentage_count = percentage_count as integer
If percentage_count> total_verts_array then percentage_count = total_verts_array ------ ensure that the number of inputs does not exceed the standard

Local true_tt = true
While (true_tt) Do
(
-- For I in 1 to total_verts_array do -- Because I control the number above, this is a real loop.
--- I understand that there is no need to add loops here. While itself is a loop, so here it will slow down.

(
--- The unique array mechanism should be added here
Random_count = random 1 total_verts_array
--- Here I want to talk about it, because it is 100%, but the same value is often obtained at random. That is, the 100% point is running the same, so there will be dissatisfaction.
-- I should have an infinite loop, knowing that the number in the array matches his % score.

If finditem vertes_count _ random_count = 0 then
(
--- Because I have no cyclic points. Therefore, you do not need to add the undefined mechanism. When the query plane returns the vertex function, sometimes there are more faces, but finding vertices on the circular plane is
--- Undefined, which must be remembered by yourself.
Append vertes_count _ random_count
) --- End if finditem

) --- End for total
If (vertes_count _. Count = percentage_count) then
(
True_tt = false
)

) --- End while
) --- End back
----------------------- 2011.4.22
If (back_verts_array as array). Count! = 0 then --- Global Selection
(
Percentage_count = (back_verts_array as array). Count) * Percentage/100
Percentage_count = percentage_count as integer
If percentage_count> (back_verts_array as array). Count) Then percentage_count = (back_verts_array as array). Count) ------ ensure that the number of inputs does not exceed the standard

Local true_tt = true
While (true_tt) Do
(
-- For I in 1 to total_verts_array do -- Because I control the number above, this is a real loop.
--- I understand that there is no need to add loops here. While itself is a loop, so here it will slow down.
(
--- The unique array mechanism should be added here
-- Random_count = random 1 total_verts_array
Back_verts_array = back_verts_array as array ---
--- 1.4.22 the test fails. It is very important to forget the transfer array.
Random_count = back_verts_array [(random 1 back_verts_array.count)] ---- number of points in the local area.
--- Here I want to talk about it, because it is 100%, but the same value is often obtained at random. That is, the 100% point is running the same, so there will be dissatisfaction.
-- I should have an infinite loop, knowing that the number in the array matches his % score.

If finditem vertes_count _ random_count = 0 then
(
--- Because I have no cyclic points. Therefore, you do not need to add the undefined mechanism. When the query plane returns the vertex function, sometimes there are more faces, but finding vertices on the circular plane is
--- Undefined, which must be remembered by yourself.
Append vertes_count _ random_count
) --- End if finditem

) --- End for total
If (vertes_count _. Count = percentage_count) then
(
True_tt = false
)

) --- End while

) ---- End back


) -- End if percentage



Polyop. setvertselection input_poly vertes_count __

) -- End ()

(Type = "edge "):(



)

(Type = "polygon "):(


)

) --- End case



) ---- End FN

--- The processing here is actually like this. The elements are randomly divided into three elements, and each element is selected by quantity or by percentage.

Each method is selected either locally or globally. These are all important.

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.