Basic workflow
-
As seen in the 2D chapter, the 3D representation is based on a loop too, where the number of runs is equal with the number of profile components.
It can be drawn with a TUBE{2} or CPRISM_{3} command. The method is the same as for 2D. Some variables are coming from the master script, see the earlier chapter:
_nComponents
, _bShowPart[]
, _profileGeometryRawData
, _idxStartPoints[]
, _idxEndPoints[]
. How to draw with cprism_{3} or tube{2} commands
In this sample code we introduce both command usage with the i3DType selection parameter.
for _iComp = 1 to _nComponents
if _bShowPart[_iComp] then
dim _currSurfaces[]
n = REQUEST{4} ("Profile_component_info", myProfileIdx, _iComp, "gs_profile_comp_surfaces", _currSurfaces)
_bmat = 1
_surface = 1
_pen = 1
n = REQUEST{4} ("Profile_component_info", myProfileIdx, _iComp, "gs_profile_bmat", _bmat)
n = REQUEST{4} ("Profile_component_info", myProfileIdx, _iComp, "gs_profile_surface", _surface)
n = REQUEST{4} ("Profile_component_info", myProfileIdx, _iComp, "gs_profile_outlinepen", _pen)
building_material _bmat
pen _pen
if i3DType = TYPE_TUBE then
! number of the polyline nodes - all nodes have 5 properties
! (x, y, edgeVisible, verticalEdgeVisible, additionalStatus)
_numPolyNodes = (_idxEndPoints[_iComp] - _idxStartPoints[_iComp] + 1) / 5
! number of route points - fixed in this example
_numPathNodes = 7
put _numPolyNodes,
_numPathNodes,
1 + 2 + 16 + 32 + 256 ! mask
_surfIdx = 1
for _i = _idxStartPoints[_iComp] to _idxEndPoints[_iComp] step 5
gosub "set_status_code" ! input _profileGeometryRawData, returns tubeStatus
put _profileGeometryRawData[_i], ! xn
_profileGeometryRawData[_i + 1], ! yn
tubeStatus, ! sn
_currSurfaces[_surfIdx] ! surfn
_surfIdx = _surfIdx + 1
next _i
! put points for tube path
put 0, 0, -1, 90,
0, 0, 0, 90,
0, 0, 1, 90,
1, 0, 1, 90,
1, 0, 2, 180,
1, 1, 2, 180,
1, 1, 3, 180
tube{2} _surface, _surface, _surface,
get (NSP)
else ! TYPE_CPRISM
_surfIdx = 1
for _i = _idxStartPoints[_iComp] to _idxEndPoints[_iComp] step 5
gosub "set_status_code" ! input _profileGeometryRawData, returns prismStatus
put _profileGeometryRawData[_i], ! xn
_profileGeometryRawData[_i + 1], ! yn
0, ! angle of sides from the perpendicular plane
prismStatus, ! sn
_currSurfaces[_surfIdx] ! surfn
_surfIdx = _surfIdx + 1
next _i
! info from Manual : CPRISM_, SPRISM_, CROOF, TUBE and REVOLVE commands (versions {3} and above),
! curved surface can be smooth, the curved segment edges no longer copy the masking settings of the first node of the curved section:
_mask = 8
cprism_{3} _surface, _surface, _surface, _mask,
NSP/5, ZZYZX,
get(NSP)
endif
endif
next _iComp
! ==============================================================================
end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end
! ==============================================================================
! ------------------------------------------------------------------------------
! Set status code for each point
! ------------------------------------------------------------------------------
"set_status_code":
edgeVisible = _profileGeometryRawData[_i + 2]
verticalEdgeVisible = _profileGeometryRawData[_i + 3]
additionalStatus = _profileGeometryRawData[_i + 4]
poly2Status = edgeVisible + additionalStatus
prismStatus = additionalStatus
tubeStatus = additionalStatus
if additionalStatus >= 0 then ! not contour end
if edgeVisible then
prismStatus = prismStatus + 15 ! j1, j2, j3, j4
endif
if verticalEdgeVisible = 0 then
! status code - j2=1 and j7=1: the vertical edge is only visible when it is a contour observed from the current direction of view
! needed only if mask 8 is not used for cprism_{3}
prismStatus = prismStatus + 64
! in tube, lateral edges starting from the node are used for showing the contour
! needed only if mask 256 is not used for tube_{2}
tubeStatus = tubeStatus + 1
endif
endif
return